@datagrok/sequence-translator 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/detectors.js +24 -0
  3. package/dist/455.js +2 -0
  4. package/dist/455.js.map +1 -0
  5. package/dist/package-test.js +2 -1
  6. package/dist/package-test.js.LICENSE.txt +8 -0
  7. package/dist/package-test.js.map +1 -1
  8. package/dist/package.js +1 -1
  9. package/dist/package.js.map +1 -1
  10. package/files/polytool-rules/rules_example.json +4 -4
  11. package/files/samples/cyclized.csv +3 -2
  12. package/package.json +14 -14
  13. package/src/apps/common/model/oligo-toolkit-package.ts +12 -0
  14. package/src/apps/common/view/components/molecule-img.ts +2 -2
  15. package/src/apps/pattern/model/data-manager.ts +9 -9
  16. package/src/apps/translator/view/ui.ts +8 -8
  17. package/src/package-test.ts +2 -0
  18. package/src/package.ts +30 -4
  19. package/src/polytool/pt-conversion.ts +361 -32
  20. package/src/polytool/pt-dialog.ts +18 -25
  21. package/src/polytool/pt-enumeration-helm-dialog.ts +18 -11
  22. package/src/polytool/pt-enumeration-helm.ts +3 -2
  23. package/src/polytool/pt-unrule-dialog.ts +2 -2
  24. package/src/polytool/pt-unrule.ts +1 -1
  25. package/src/polytool/types.ts +18 -0
  26. package/src/tests/polytool-chain-from-notation-tests.ts +45 -0
  27. package/src/tests/polytool-chain-parse-notation-tests.ts +59 -0
  28. package/src/tests/polytool-detectors-custom-notation-test.ts +43 -0
  29. package/src/tests/toAtomicLevel-tests.ts +26 -1
  30. package/src/tests/utils/detect-macromolecule-utils.ts +64 -0
  31. package/src/tests/{utils.ts → utils/index.ts} +2 -2
  32. package/src/utils/context-menu.ts +0 -3
  33. package/src/utils/cyclized.ts +90 -0
  34. package/src/utils/dimerized.ts +10 -0
package/dist/package.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see package.js.LICENSE.txt */
2
- var sequencetranslator;(()=>{var t={74:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},252:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},507:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},254:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},314: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,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(r)for(var a=0;a<this.length;a++){var u=this[a][0];null!=u&&(s[u]=!0)}for(var l=0;l<t.length;l++){var c=[].concat(t[l]);r&&s[c[0]]||(void 0!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),i&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=i):c[4]="".concat(i)),e.push(c))}},e}},354: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)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},982: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,i,o){for(var s,a,u,l,c,h,f,d,p,g,m,y,v;o>=64;){for(s=n[0],a=n[1],u=n[2],l=n[3],c=n[4],h=n[5],f=n[6],d=n[7],g=0;g<16;g++)m=i+4*g,t[g]=(255&r[m])<<24|(255&r[m+1])<<16|(255&r[m+2])<<8|255&r[m+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,v=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(v+t[g-16]|0);for(g=0;g<64;g++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&f)|0)+(d+(e[g]+t[g]|0)|0)|0,v=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&u^a&u)|0,d=f,f=h,h=c,c=l+y|0,l=u,u=a,a=s,s=y+v|0;n[0]+=s,n[1]+=a,n[2]+=u,n[3]+=l,n[4]+=c,n[5]+=h,n[6]+=f,n[7]+=d,i+=64,o-=64}return i}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,i=e/536870912|0,o=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]=i>>>24&255,this.buffer[s-7]=i>>>16&255,this.buffer[s-6]=i>>>8&255,this.buffer[s-5]=i>>>0&255,this.buffer[s-4]=o>>>24&255,this.buffer[s-3]=o>>>16&255,this.buffer[s-2]=o>>>8&255,this.buffer[s-1]=o>>>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 i=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 o(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new i(t).update(e),r=n.digest();return n.clean(),r}function a(t,e,n,r){var i=r[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=i,t.hash=o,t.default=o,t.hmac=s;var u=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=u),void 0===r&&(r=32);for(var o=new Uint8Array([1]),l=s(e,t),c=new i(l),h=new Uint8Array(c.digestLength),f=h.length,d=new Uint8Array(r),p=0;p<r;p++)f===h.length&&(a(h,c,n,o),f=0),d[p]=h[f++];return c.clean(),h.fill(0),o.fill(0),d},t.pbkdf2=function(t,e,n,r){for(var o=new i(t),s=o.digestLength,a=new Uint8Array(4),u=new Uint8Array(s),l=new Uint8Array(s),c=new Uint8Array(r),h=0;h*s<r;h++){var f=h+1;a[0]=f>>>24&255,a[1]=f>>>16&255,a[2]=f>>>8&255,a[3]=f>>>0&255,o.reset(),o.update(e),o.update(a),o.finish(l);for(var d=0;d<s;d++)u[d]=l[d];for(d=2;d<=n;d++){o.reset(),o.update(l).finish(l);for(var p=0;p<s;p++)u[p]^=l[p]}for(d=0;d<s&&h*s+d<r;d++)c[h*s+d]=u[d]}for(h=0;h<s;h++)u[h]=l[h]=0;for(h=0;h<4;h++)a[h]=0;return o.clean(),c}}(e);var i=e.default;for(var o in e)i[o]=e[o];"object"==typeof t.exports?t.exports=i:void 0===(r=function(){return i}.call(e,n,e,t))||(t.exports=r)}()},543:function(t,e,n){var r;t=n.nmd(t),function(){var i,o="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",u=32,l=128,c=1/0,h=9007199254740991,f=NaN,d=4294967295,p=[["ary",l],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",u],["partialRight",64],["rearg",256]],g="[object Arguments]",m="[object Array]",y="[object Boolean]",v="[object Date]",b="[object Error]",w="[object Function]",C="[object GeneratorFunction]",A="[object Map]",x="[object Number]",_="[object Object]",E="[object Promise]",T="[object RegExp]",S="[object Set]",I="[object String]",N="[object Symbol]",M="[object WeakMap]",O="[object ArrayBuffer]",L="[object DataView]",B="[object Float32Array]",P="[object Float64Array]",R="[object Int8Array]",D="[object Int16Array]",F="[object Int32Array]",H="[object Uint8Array]",k="[object Uint8ClampedArray]",U="[object Uint16Array]",$="[object Uint32Array]",V=/\b__p \+= '';/g,j=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(G.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+/,it=/\s/,ot=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,st=/\{\n\/\* \[wrapped with (.+)\] \*/,at=/,? & /,ut=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,lt=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ft=/\w*$/,dt=/^[-+]0x[0-9a-f]+$/i,pt=/^0b[01]+$/i,gt=/^\[object .+?Constructor\]$/,mt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,vt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,bt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,Ct="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",_t="a-z\\xdf-\\xf6\\xf8-\\xff",Et="A-Z\\xc0-\\xd6\\xd8-\\xde",Tt="\\ufe0e\\ufe0f",St="\\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",It="["+Ct+"]",Nt="["+St+"]",Mt="["+At+"]",Ot="\\d+",Lt="["+xt+"]",Bt="["+_t+"]",Pt="[^"+Ct+St+Ot+xt+_t+Et+"]",Rt="\\ud83c[\\udffb-\\udfff]",Dt="[^"+Ct+"]",Ft="(?:\\ud83c[\\udde6-\\uddff]){2}",Ht="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+Et+"]",Ut="\\u200d",$t="(?:"+Bt+"|"+Pt+")",Vt="(?:"+kt+"|"+Pt+")",jt="(?:['’](?:d|ll|m|re|s|t|ve))?",qt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gt="(?:"+Mt+"|"+Rt+")?",Wt="["+Tt+"]?",zt=Wt+Gt+"(?:"+Ut+"(?:"+[Dt,Ft,Ht].join("|")+")"+Wt+Gt+")*",Yt="(?:"+[Lt,Ft,Ht].join("|")+")"+zt,Kt="(?:"+[Dt+Mt+"?",Mt,Ft,Ht,It].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Mt,"g"),Xt=RegExp(Rt+"(?="+Rt+")|"+Kt+zt,"g"),Zt=RegExp([kt+"?"+Bt+"+"+jt+"(?="+[Nt,kt,"$"].join("|")+")",Vt+"+"+qt+"(?="+[Nt,kt+$t,"$"].join("|")+")",kt+"?"+$t+"+"+jt,kt+"+"+qt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ot,Yt].join("|"),"g"),te=RegExp("["+Ut+Ct+At+Tt+"]"),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,ie={};ie[B]=ie[P]=ie[R]=ie[D]=ie[F]=ie[H]=ie[k]=ie[U]=ie[$]=!0,ie[g]=ie[m]=ie[O]=ie[y]=ie[L]=ie[v]=ie[b]=ie[w]=ie[A]=ie[x]=ie[_]=ie[T]=ie[S]=ie[I]=ie[M]=!1;var oe={};oe[g]=oe[m]=oe[O]=oe[L]=oe[y]=oe[v]=oe[B]=oe[P]=oe[R]=oe[D]=oe[F]=oe[A]=oe[x]=oe[_]=oe[T]=oe[S]=oe[I]=oe[N]=oe[H]=oe[k]=oe[U]=oe[$]=!0,oe[b]=oe[w]=oe[M]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,ue=parseInt,le="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ce="object"==typeof self&&self&&self.Object===Object&&self,he=le||ce||Function("return this")(),fe=e&&!e.nodeType&&e,de=fe&&t&&!t.nodeType&&t,pe=de&&de.exports===fe,ge=pe&&le.process,me=function(){try{return de&&de.require&&de.require("util").types||ge&&ge.binding&&ge.binding("util")}catch(t){}}(),ye=me&&me.isArrayBuffer,ve=me&&me.isDate,be=me&&me.isMap,we=me&&me.isRegExp,Ce=me&&me.isSet,Ae=me&&me.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 _e(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i<o;){var s=t[i];e(r,s,n(s),t)}return r}function Ee(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Te(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Se(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 Ie(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}function Ne(t,e){return!(null==t||!t.length)&&ke(t,e,0)>-1}function Me(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}function Oe(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}function Le(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}function Be(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function Pe(t,e,n,r){var i=null==t?0:t.length;for(r&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}function Re(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 De=je("length");function Fe(t,e,n){var r;return n(t,(function(t,n,i){if(e(t,n,i))return r=n,!1})),r}function He(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}function ke(t,e,n){return e==e?function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):He(t,$e,n)}function Ue(t,e,n,r){for(var i=n-1,o=t.length;++i<o;)if(r(t[i],e))return i;return-1}function $e(t){return t!=t}function Ve(t,e){var n=null==t?0:t.length;return n?We(t,e)/n:f}function je(t){return function(e){return null==e?i:e[t]}}function qe(t){return function(e){return null==t?i:t[e]}}function Ge(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}function We(t,e){for(var n,r=-1,o=t.length;++r<o;){var s=e(t[r]);s!==i&&(n=n===i?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,fn(t)+1).replace(rt,""):t}function Ke(t){return function(e){return t(e)}}function Je(t,e){return Oe(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({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});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,i=0,o=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,o[i++]=n)}return o}function un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function ln(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):De(t)}function hn(t){return rn(t)?function(t){return t.match(Xt)||[]}(t):function(t){return t.split("")}(t)}function fn(t){for(var e=t.length;e--&&it.test(t.charAt(e)););return e}var dn=qe({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,it=e.Date,Ct=e.Error,At=e.Function,xt=e.Math,_t=e.Object,Et=e.RegExp,Tt=e.String,St=e.TypeError,It=r.prototype,Nt=At.prototype,Mt=_t.prototype,Ot=e["__core-js_shared__"],Lt=Nt.toString,Bt=Mt.hasOwnProperty,Pt=0,Rt=(n=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Dt=Mt.toString,Ft=Lt.call(_t),Ht=he._,kt=Et("^"+Lt.call(Bt).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ut=pe?e.Buffer:i,$t=e.Symbol,Vt=e.Uint8Array,jt=Ut?Ut.allocUnsafe:i,qt=sn(_t.getPrototypeOf,_t),Gt=_t.create,Wt=Mt.propertyIsEnumerable,zt=It.splice,Yt=$t?$t.isConcatSpreadable:i,Kt=$t?$t.iterator:i,Xt=$t?$t.toStringTag:i,te=function(){try{var t=uo(_t,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,le=it&&it.now!==he.Date.now&&it.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,fe=xt.ceil,de=xt.floor,ge=_t.getOwnPropertySymbols,me=Ut?Ut.isBuffer:i,De=e.isFinite,qe=It.join,gn=sn(_t.keys,_t),mn=xt.max,yn=xt.min,vn=it.now,bn=e.parseInt,wn=xt.random,Cn=It.reverse,An=uo(e,"DataView"),xn=uo(e,"Map"),_n=uo(e,"Promise"),En=uo(e,"Set"),Tn=uo(e,"WeakMap"),Sn=uo(_t,"create"),In=Tn&&new Tn,Nn={},Mn=Fo(An),On=Fo(xn),Ln=Fo(_n),Bn=Fo(En),Pn=Fo(Tn),Rn=$t?$t.prototype:i,Dn=Rn?Rn.valueOf:i,Fn=Rn?Rn.toString:i;function Hn(t){if(ta(t)&&!js(t)&&!(t instanceof Vn)){if(t instanceof $n)return t;if(Bt.call(t,"__wrapped__"))return Ho(t)}return new $n(t)}var kn=function(){function t(){}return function(e){if(!Zs(e))return{};if(Gt)return Gt(e);t.prototype=e;var n=new t;return t.prototype=i,n}}();function Un(){}function $n(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=i}function Vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=d,this.__views__=[]}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 Gn(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 Gn;++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=js(t),r=!n&&Vs(t),i=!n&&!r&&zs(t),o=!n&&!r&&!i&&ua(t),s=n||r||i||o,a=s?ze(t.length,Tt):[],u=a.length;for(var l in t)!e&&!Bt.call(t,l)||s&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||mo(l,u))||a.push(l);return a}function Kn(t){var e=t.length;return e?t[Gr(0,e-1)]:i}function Jn(t,e){return Lo(Ti(t),or(e,0,t.length))}function Qn(t){return Lo(Ti(t))}function Xn(t,e,n){(n!==i&&!ks(t[e],n)||n===i&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Bt.call(t,e)&&ks(r,n)&&(n!==i||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,i,o){e(r,t,n(t),o)})),r}function nr(t,e){return t&&Si(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 ir(t,e){for(var n=-1,o=e.length,s=r(o),a=null==t;++n<o;)s[n]=a?i:Ea(t,e[n]);return s}function or(t,e,n){return t==t&&(n!==i&&(t=t<=n?t:n),e!==i&&(t=t>=e?t:e)),t}function sr(t,e,n,r,o,s){var a,u=1&e,l=2&e,c=4&e;if(n&&(a=o?n(t,r,o,s):n(t)),a!==i)return a;if(!Zs(t))return t;var h=js(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Bt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!u)return Ti(t,a)}else{var f=ho(t),d=f==w||f==C;if(zs(t))return wi(t,u);if(f==_||f==g||d&&!o){if(a=l||d?{}:po(t),!u)return l?function(t,e){return Si(t,co(t),e)}(t,function(t,e){return t&&Si(e,Oa(e),t)}(a,t)):function(t,e){return Si(t,lo(t),e)}(t,nr(a,t))}else{if(!oe[f])return o?t:{};a=function(t,e,n){var r,i=t.constructor;switch(e){case O:return Ci(t);case y:case v:return new i(+t);case L:return function(t,e){var n=e?Ci(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case B:case P:case R:case D:case F:case H:case k:case U:case $:return Ai(t,n);case A:return new i;case x:case I:return new i(t);case T:return function(t){var e=new t.constructor(t.source,ft.exec(t));return e.lastIndex=t.lastIndex,e}(t);case S:return new i;case N:return r=t,Dn?_t(Dn.call(r)):{}}}(t,f,u)}}s||(s=new zn);var p=s.get(t);if(p)return p;s.set(t,a),oa(t)?t.forEach((function(r){a.add(sr(r,e,n,r,t,s))})):ea(t)&&t.forEach((function(r,i){a.set(i,sr(r,e,n,i,t,s))}));var m=h?i:(c?l?eo:to:l?Oa:Ma)(t);return Ee(m||t,(function(r,i){m&&(r=t[i=r]),Zn(a,i,sr(r,e,n,i,t,s))})),a}function ar(t,e,n){var r=n.length;if(null==t)return!r;for(t=_t(t);r--;){var o=n[r],s=e[o],a=t[o];if(a===i&&!(o in t)||!s(a))return!1}return!0}function ur(t,e,n){if("function"!=typeof t)throw new St(o);return Io((function(){t.apply(i,n)}),e)}function lr(t,e,n,r){var i=-1,o=Ne,s=!0,a=t.length,u=[],l=e.length;if(!a)return u;n&&(e=Oe(e,Ke(n))),r?(o=Me,s=!1):e.length>=200&&(o=Qe,s=!1,e=new Wn(e));t:for(;++i<a;){var c=t[i],h=null==n?c:n(c);if(c=r||0!==c?c:0,s&&h==h){for(var f=l;f--;)if(e[f]===h)continue t;u.push(c)}else o(e,h,r)||u.push(c)}return u}Hn.templateSettings={escape:K,evaluate:J,interpolate:Q,variable:"",imports:{_:Hn}},Hn.prototype=Un.prototype,Hn.prototype.constructor=Hn,$n.prototype=kn(Un.prototype),$n.prototype.constructor=$n,Vn.prototype=kn(Un.prototype),Vn.prototype.constructor=Vn,jn.prototype.clear=function(){this.__data__=Sn?Sn(null):{},this.size=0},jn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},jn.prototype.get=function(t){var e=this.__data__;if(Sn){var n=e[t];return n===s?i:n}return Bt.call(e,t)?e[t]:i},jn.prototype.has=function(t){var e=this.__data__;return Sn?e[t]!==i:Bt.call(e,t)},jn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Sn&&e===i?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?i: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},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(xn||qn),string:new jn}},Gn.prototype.delete=function(t){var e=so(this,t).delete(t);return this.size-=e?1:0,e},Gn.prototype.get=function(t){return so(this,t).get(t)},Gn.prototype.has=function(t){return so(this,t).has(t)},Gn.prototype.set=function(t,e){var n=so(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 Gn(r)}return n.set(t,e),this.size=n.size,this};var cr=Mi(vr),hr=Mi(br,!0);function fr(t,e){var n=!0;return cr(t,(function(t,r,i){return n=!!e(t,r,i)})),n}function dr(t,e,n){for(var r=-1,o=t.length;++r<o;){var s=t[r],a=e(s);if(null!=a&&(u===i?a==a&&!aa(a):n(a,u)))var u=a,l=s}return l}function pr(t,e){var n=[];return cr(t,(function(t,r,i){e(t,r,i)&&n.push(t)})),n}function gr(t,e,n,r,i){var o=-1,s=t.length;for(n||(n=go),i||(i=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?gr(a,e-1,n,r,i):Le(i,a):r||(i[i.length]=a)}return i}var mr=Oi(),yr=Oi(!0);function vr(t,e){return t&&mr(t,e,Ma)}function br(t,e){return t&&yr(t,e,Ma)}function wr(t,e){return Ie(e,(function(e){return Js(t[e])}))}function Cr(t,e){for(var n=0,r=(e=mi(e,t)).length;null!=t&&n<r;)t=t[Do(e[n++])];return n&&n==r?t:i}function Ar(t,e,n){var r=e(t);return js(t)?r:Le(r,n(t))}function xr(t){return null==t?t===i?"[object Undefined]":"[object Null]":Xt&&Xt in _t(t)?function(t){var e=Bt.call(t,Xt),n=t[Xt];try{t[Xt]=i;var r=!0}catch(t){}var o=Dt.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),o}(t):function(t){return Dt.call(t)}(t)}function _r(t,e){return t>e}function Er(t,e){return null!=t&&Bt.call(t,e)}function Tr(t,e){return null!=t&&e in _t(t)}function Sr(t,e,n){for(var o=n?Me:Ne,s=t[0].length,a=t.length,u=a,l=r(a),c=1/0,h=[];u--;){var f=t[u];u&&e&&(f=Oe(f,Ke(e))),c=yn(f.length,c),l[u]=!n&&(e||s>=120&&f.length>=120)?new Wn(u&&f):i}f=t[0];var d=-1,p=l[0];t:for(;++d<s&&h.length<c;){var g=f[d],m=e?e(g):g;if(g=n||0!==g?g:0,!(p?Qe(p,m):o(h,m,n))){for(u=a;--u;){var y=l[u];if(!(y?Qe(y,m):o(t[u],m,n)))continue t}p&&p.push(m),h.push(g)}}return h}function Ir(t,e,n){var r=null==(t=Eo(t,e=mi(e,t)))?t:t[Do(Ko(e))];return null==r?i:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==g}function Mr(t,e,n,r,o){return t===e||(null==t||null==e||!ta(t)&&!ta(e)?t!=t&&e!=e:function(t,e,n,r,o,s){var a=js(t),u=js(e),l=a?m:ho(t),c=u?m:ho(e),h=(l=l==g?_:l)==_,f=(c=c==g?_:c)==_,d=l==c;if(d&&zs(t)){if(!zs(e))return!1;a=!0,h=!1}if(d&&!h)return s||(s=new zn),a||ua(t)?Xi(t,e,n,r,o,s):function(t,e,n,r,i,o,s){switch(n){case L:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case O:return!(t.byteLength!=e.byteLength||!o(new Vt(t),new Vt(e)));case y:case v:case x:return ks(+t,+e);case b:return t.name==e.name&&t.message==e.message;case T:case I:return t==e+"";case A:var a=on;case S:var u=1&r;if(a||(a=un),t.size!=e.size&&!u)return!1;var l=s.get(t);if(l)return l==e;r|=2,s.set(t,e);var c=Xi(a(t),a(e),r,i,o,s);return s.delete(t),c;case N:if(Dn)return Dn.call(t)==Dn.call(e)}return!1}(t,e,l,n,r,o,s);if(!(1&n)){var p=h&&Bt.call(t,"__wrapped__"),w=f&&Bt.call(e,"__wrapped__");if(p||w){var C=p?t.value():t,E=w?e.value():e;return s||(s=new zn),o(C,E,n,r,s)}}return!!d&&(s||(s=new zn),function(t,e,n,r,o,s){var a=1&n,u=to(t),l=u.length;if(l!=to(e).length&&!a)return!1;for(var c=l;c--;){var h=u[c];if(!(a?h in e:Bt.call(e,h)))return!1}var f=s.get(t),d=s.get(e);if(f&&d)return f==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var g=a;++c<l;){var m=t[h=u[c]],y=e[h];if(r)var v=a?r(y,m,h,e,t,s):r(m,y,h,t,e,s);if(!(v===i?m===y||o(m,y,n,r,s):v)){p=!1;break}g||(g="constructor"==h)}if(p&&!g){var b=t.constructor,w=e.constructor;b==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof w&&w instanceof w||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,o,s))}(t,e,n,r,Mr,o))}function Or(t,e,n,r){var o=n.length,s=o,a=!r;if(null==t)return!s;for(t=_t(t);o--;){var u=n[o];if(a&&u[2]?u[1]!==t[u[0]]:!(u[0]in t))return!1}for(;++o<s;){var l=(u=n[o])[0],c=t[l],h=u[1];if(a&&u[2]){if(c===i&&!(l in t))return!1}else{var f=new zn;if(r)var d=r(c,h,l,t,e,f);if(!(d===i?Mr(h,c,3,r,f):d))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Rt&&Rt in e))&&(Js(t)?kt:gt).test(Fo(t));var e}function Br(t){return"function"==typeof t?t:null==t?nu:"object"==typeof t?js(t)?Hr(t[0],t[1]):Fr(t):hu(t)}function Pr(t){if(!Co(t))return gn(t);var e=[];for(var n in _t(t))Bt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Rr(t,e){return t<e}function Dr(t,e){var n=-1,i=Gs(t)?r(t.length):[];return cr(t,(function(t,r,o){i[++n]=e(t,r,o)})),i}function Fr(t){var e=ao(t);return 1==e.length&&e[0][2]?xo(e[0][0],e[0][1]):function(n){return n===t||Or(n,t,e)}}function Hr(t,e){return vo(t)&&Ao(e)?xo(Do(t),e):function(n){var r=Ea(n,t);return r===i&&r===e?Ta(n,t):Mr(e,r,3)}}function kr(t,e,n,r,o){t!==e&&mr(e,(function(s,a){if(o||(o=new zn),Zs(s))!function(t,e,n,r,o,s,a){var u=To(t,n),l=To(e,n),c=a.get(l);if(c)Xn(t,n,c);else{var h=s?s(u,l,n+"",t,e,a):i,f=h===i;if(f){var d=js(l),p=!d&&zs(l),g=!d&&!p&&ua(l);h=l,d||p||g?js(u)?h=u:Ws(u)?h=Ti(u):p?(f=!1,h=wi(l,!0)):g?(f=!1,h=Ai(l,!0)):h=[]:ra(l)||Vs(l)?(h=u,Vs(u)?h=ma(u):Zs(u)&&!Js(u)||(h=po(l))):f=!1}f&&(a.set(l,h),o(h,l,r,s,a),a.delete(l)),Xn(t,n,h)}}(t,e,a,n,kr,r,o);else{var u=r?r(To(t,a),s,a+"",t,e,o):i;u===i&&(u=s),Xn(t,a,u)}}),Oa)}function Ur(t,e){var n=t.length;if(n)return mo(e+=e<0?n:0,n)?t[e]:i}function $r(t,e,n){e=e.length?Oe(e,(function(t){return js(t)?function(e){return Cr(e,1===t.length?t[0]:t)}:t})):[nu];var r=-1;e=Oe(e,Ke(oo()));var i=Dr(t,(function(t,n,i){var o=Oe(e,(function(e){return e(t)}));return{criteria:o,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,i=t.criteria,o=e.criteria,s=i.length,a=n.length;++r<s;){var u=xi(i[r],o[r]);if(u)return r>=a?u:u*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)}));e--;)t[e]=t[e].value;return t}(i)}function Vr(t,e,n){for(var r=-1,i=e.length,o={};++r<i;){var s=e[r],a=Cr(t,s);n(a,s)&&Jr(o,mi(s,t),a)}return o}function jr(t,e,n,r){var i=r?Ue:ke,o=-1,s=e.length,a=t;for(t===e&&(e=Ti(e)),n&&(a=Oe(t,Ke(n)));++o<s;)for(var u=0,l=e[o],c=n?n(l):l;(u=i(a,c,u,r))>-1;)a!==t&&zt.call(a,u,1),zt.call(t,u,1);return t}function qr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;mo(i)?zt.call(t,i,1):ui(t,i)}}return t}function Gr(t,e){return t+de(wn()*(e-t+1))}function Wr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=de(e/2))&&(t+=t)}while(e);return n}function zr(t,e){return No(_o(t,e,nu),t+"")}function Yr(t){return Kn(ka(t))}function Kr(t,e){var n=ka(t);return Lo(n,or(e,0,n.length))}function Jr(t,e,n,r){if(!Zs(t))return t;for(var o=-1,s=(e=mi(e,t)).length,a=s-1,u=t;null!=u&&++o<s;){var l=Do(e[o]),c=n;if("__proto__"===l||"constructor"===l||"prototype"===l)return t;if(o!=a){var h=u[l];(c=r?r(h,l,u):i)===i&&(c=Zs(h)?h:mo(e[o+1])?[]:{})}Zn(u,l,c),u=u[l]}return t}var Qr=In?function(t,e){return In.set(t,e),t}:nu,Xr=te?function(t,e){return te(t,"toString",{configurable:!0,enumerable:!1,value:Za(e),writable:!0})}:nu;function Zr(t){return Lo(ka(t))}function ti(t,e,n){var i=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i<o;)s[i]=t[i+e];return s}function ei(t,e){var n;return cr(t,(function(t,r,i){return!(n=e(t,r,i))})),!!n}function ni(t,e,n){var r=0,i=null==t?r:t.length;if("number"==typeof e&&e==e&&i<=2147483647){for(;r<i;){var o=r+i>>>1,s=t[o];null!==s&&!aa(s)&&(n?s<=e:s<e)?r=o+1:i=o}return i}return ri(t,e,nu,n)}function ri(t,e,n,r){var o=0,s=null==t?0:t.length;if(0===s)return 0;for(var a=(e=n(e))!=e,u=null===e,l=aa(e),c=e===i;o<s;){var h=de((o+s)/2),f=n(t[h]),d=f!==i,p=null===f,g=f==f,m=aa(f);if(a)var y=r||g;else y=c?g&&(r||d):u?g&&d&&(r||!p):l?g&&d&&!p&&(r||!m):!p&&!m&&(r?f<=e:f<e);y?o=h+1:s=h}return yn(s,4294967294)}function ii(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!ks(a,u)){var u=a;o[i++]=0===s?0:s}}return o}function oi(t){return"number"==typeof t?t:aa(t)?f:+t}function si(t){if("string"==typeof t)return t;if(js(t))return Oe(t,si)+"";if(aa(t))return Fn?Fn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ai(t,e,n){var r=-1,i=Ne,o=t.length,s=!0,a=[],u=a;if(n)s=!1,i=Me;else if(o>=200){var l=e?null:Wi(t);if(l)return un(l);s=!1,i=Qe,u=new Wn}else u=e?[]:a;t:for(;++r<o;){var c=t[r],h=e?e(c):c;if(c=n||0!==c?c:0,s&&h==h){for(var f=u.length;f--;)if(u[f]===h)continue t;e&&u.push(h),a.push(c)}else i(u,h,n)||(u!==a&&u.push(h),a.push(c))}return a}function ui(t,e){return null==(t=Eo(t,e=mi(e,t)))||delete t[Do(Ko(e))]}function li(t,e,n,r){return Jr(t,e,n(Cr(t,e)),r)}function ci(t,e,n,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&e(t[o],o,t););return n?ti(t,r?0:o,r?o+1:i):ti(t,r?o+1:0,r?i:o)}function hi(t,e){var n=t;return n instanceof Vn&&(n=n.value()),Be(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function fi(t,e,n){var i=t.length;if(i<2)return i?ai(t[0]):[];for(var o=-1,s=r(i);++o<i;)for(var a=t[o],u=-1;++u<i;)u!=o&&(s[o]=lr(s[o]||a,t[u],e,n));return ai(gr(s,1),e,n)}function di(t,e,n){for(var r=-1,o=t.length,s=e.length,a={};++r<o;){var u=r<s?e[r]:i;n(a,t[r],u)}return a}function pi(t){return Ws(t)?t:[]}function gi(t){return"function"==typeof t?t:nu}function mi(t,e){return js(t)?t:vo(t,e)?[t]:Ro(ya(t))}var yi=zr;function vi(t,e,n){var r=t.length;return n=n===i?r:n,!e&&n>=r?t:ti(t,e,n)}var bi=se||function(t){return he.clearTimeout(t)};function wi(t,e){if(e)return t.slice();var n=t.length,r=jt?jt(n):new t.constructor(n);return t.copy(r),r}function Ci(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function Ai(t,e){var n=e?Ci(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function xi(t,e){if(t!==e){var n=t!==i,r=null===t,o=t==t,s=aa(t),a=e!==i,u=null===e,l=e==e,c=aa(e);if(!u&&!c&&!s&&t>e||s&&a&&l&&!u&&!c||r&&a&&l||!n&&l||!o)return 1;if(!r&&!s&&!c&&t<e||c&&n&&o&&!r&&!s||u&&n&&o||!a&&o||!l)return-1}return 0}function _i(t,e,n,i){for(var o=-1,s=t.length,a=n.length,u=-1,l=e.length,c=mn(s-a,0),h=r(l+c),f=!i;++u<l;)h[u]=e[u];for(;++o<a;)(f||o<s)&&(h[n[o]]=t[o]);for(;c--;)h[u++]=t[o++];return h}function Ei(t,e,n,i){for(var o=-1,s=t.length,a=-1,u=n.length,l=-1,c=e.length,h=mn(s-u,0),f=r(h+c),d=!i;++o<h;)f[o]=t[o];for(var p=o;++l<c;)f[p+l]=e[l];for(;++a<u;)(d||o<s)&&(f[p+n[a]]=t[o++]);return f}function Ti(t,e){var n=-1,i=t.length;for(e||(e=r(i));++n<i;)e[n]=t[n];return e}function Si(t,e,n,r){var o=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var u=e[s],l=r?r(n[u],t[u],u,n,t):i;l===i&&(l=t[u]),o?rr(n,u,l):Zn(n,u,l)}return n}function Ii(t,e){return function(n,r){var i=js(n)?_e:er,o=e?e():{};return i(n,t,oo(r,2),o)}}function Ni(t){return zr((function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:i,a=o>2?n[2]:i;for(s=t.length>3&&"function"==typeof s?(o--,s):i,a&&yo(n[0],n[1],a)&&(s=o<3?i:s,o=1),e=_t(e);++r<o;){var u=n[r];u&&t(e,u,r,s)}return e}))}function Mi(t,e){return function(n,r){if(null==n)return n;if(!Gs(n))return t(n,r);for(var i=n.length,o=e?i:-1,s=_t(n);(e?o--:++o<i)&&!1!==r(s[o],o,s););return n}}function Oi(t){return function(e,n,r){for(var i=-1,o=_t(e),s=r(e),a=s.length;a--;){var u=s[t?a:++i];if(!1===n(o[u],u,o))break}return e}}function Li(t){return function(e){var n=rn(e=ya(e))?hn(e):i,r=n?n[0]:e.charAt(0),o=n?vi(n,1).join(""):e.slice(1);return r[t]()+o}}function Bi(t){return function(e){return Be(Ja(Va(e).replace(Jt,"")),t,"")}}function Pi(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 Ri(t){return function(e,n,r){var o=_t(e);if(!Gs(e)){var s=oo(n,3);e=Ma(e),n=function(t){return s(o[t],t,o)}}var a=t(e,n,r);return a>-1?o[s?e[a]:a]:i}}function Di(t){return Zi((function(e){var n=e.length,r=n,s=$n.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new St(o);if(s&&!u&&"wrapper"==ro(a))var u=new $n([],!0)}for(r=u?r:n;++r<n;){var l=ro(a=e[r]),c="wrapper"==l?no(a):i;u=c&&bo(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?u[ro(c[0])].apply(u,c[3]):1==a.length&&bo(a)?u[l]():u.thru(a)}return function(){var t=arguments,r=t[0];if(u&&1==t.length&&js(r))return u.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i<n;)o=e[i].call(this,o);return o}}))}function Fi(t,e,n,o,s,a,u,c,h,f){var d=e&l,p=1&e,g=2&e,m=24&e,y=512&e,v=g?i:Pi(t);return function l(){for(var b=arguments.length,w=r(b),C=b;C--;)w[C]=arguments[C];if(m)var A=io(l),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(w,A);if(o&&(w=_i(w,o,s,m)),a&&(w=Ei(w,a,u,m)),b-=x,m&&b<f){var _=an(w,A);return qi(t,e,Fi,l.placeholder,n,w,_,c,h,f-b)}var E=p?n:this,T=g?E[t]:t;return b=w.length,c?w=function(t,e){for(var n=t.length,r=yn(e.length,n),o=Ti(t);r--;){var s=e[r];t[r]=mo(s,n)?o[s]:i}return t}(w,c):y&&b>1&&w.reverse(),d&&h<b&&(w.length=h),this&&this!==he&&this instanceof l&&(T=v||Pi(T)),T.apply(E,w)}}function Hi(t,e){return function(n,r){return function(t,e,n,r){return vr(t,(function(t,i,o){e(r,n(t),i,o)})),r}(n,t,e(r),{})}}function ki(t,e){return function(n,r){var o;if(n===i&&r===i)return e;if(n!==i&&(o=n),r!==i){if(o===i)return r;"string"==typeof n||"string"==typeof r?(n=si(n),r=si(r)):(n=oi(n),r=oi(r)),o=t(n,r)}return o}}function Ui(t){return Zi((function(e){return e=Oe(e,Ke(oo())),zr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function $i(t,e){var n=(e=e===i?" ":si(e)).length;if(n<2)return n?Wr(e,t):e;var r=Wr(e,fe(t/cn(e)));return rn(e)?vi(hn(r),0,t).join(""):r.slice(0,t)}function Vi(t){return function(e,n,o){return o&&"number"!=typeof o&&yo(e,n,o)&&(n=o=i),e=fa(e),n===i?(n=e,e=0):n=fa(n),function(t,e,n,i){for(var o=-1,s=mn(fe((e-t)/(n||1)),0),a=r(s);s--;)a[i?s:++o]=t,t+=n;return a}(e,n,o=o===i?e<n?1:-1:fa(o),t)}}function ji(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ga(e),n=ga(n)),t(e,n)}}function qi(t,e,n,r,o,s,a,l,c,h){var f=8&e;e|=f?u:64,4&(e&=~(f?64:u))||(e&=-4);var d=[t,e,o,f?s:i,f?a:i,f?i:s,f?i:a,l,c,h],p=n.apply(i,d);return bo(t)&&So(p,d),p.placeholder=r,Mo(p,t,e)}function Gi(t){var e=xt[t];return function(t,n){if(t=ga(t),(n=null==n?0:yn(da(n),292))&&De(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 Wi=En&&1/un(new En([,-0]))[1]==c?function(t){return new En(t)}:au;function zi(t){return function(e){var n=ho(e);return n==A?on(e):n==S?ln(e):function(t,e){return Oe(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Yi(t,e,n,s,c,h,f,d){var p=2&e;if(!p&&"function"!=typeof t)throw new St(o);var g=s?s.length:0;if(g||(e&=-97,s=c=i),f=f===i?f:mn(da(f),0),d=d===i?d:da(d),g-=c?c.length:0,64&e){var m=s,y=c;s=c=i}var v=p?i:no(t),b=[t,e,n,s,c,m,y,h,f,d];if(v&&function(t,e){var n=t[1],r=e[1],i=n|r,o=i<131,s=r==l&&8==n||r==l&&256==n&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!o&&!s)return t;1&r&&(t[2]=e[2],i|=1&n?0:4);var u=e[3];if(u){var c=t[3];t[3]=c?_i(c,u,e[4]):u,t[4]=c?an(t[3],a):e[4]}(u=e[5])&&(c=t[5],t[5]=c?Ei(c,u,e[6]):u,t[6]=c?an(t[5],a):e[6]),(u=e[7])&&(t[7]=u),r&l&&(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]=i}(b,v),t=b[0],e=b[1],n=b[2],s=b[3],c=b[4],!(d=b[9]=b[9]===i?p?0:t.length:mn(b[9]-g,0))&&24&e&&(e&=-25),e&&1!=e)w=8==e||16==e?function(t,e,n){var o=Pi(t);return function s(){for(var a=arguments.length,u=r(a),l=a,c=io(s);l--;)u[l]=arguments[l];var h=a<3&&u[0]!==c&&u[a-1]!==c?[]:an(u,c);return(a-=h.length)<n?qi(t,e,Fi,s.placeholder,i,u,h,i,i,n-a):xe(this&&this!==he&&this instanceof s?o:t,this,u)}}(t,e,d):e!=u&&33!=e||c.length?Fi.apply(i,b):function(t,e,n,i){var o=1&e,s=Pi(t);return function e(){for(var a=-1,u=arguments.length,l=-1,c=i.length,h=r(c+u),f=this&&this!==he&&this instanceof e?s:t;++l<c;)h[l]=i[l];for(;u--;)h[l++]=arguments[++a];return xe(f,o?n:this,h)}}(t,e,n,s);else var w=function(t,e,n){var r=1&e,i=Pi(t);return function e(){return(this&&this!==he&&this instanceof e?i:t).apply(r?n:this,arguments)}}(t,e,n);return Mo((v?Qr:So)(w,b),t,e)}function Ki(t,e,n,r){return t===i||ks(t,Mt[n])&&!Bt.call(r,n)?e:t}function Ji(t,e,n,r,o,s){return Zs(t)&&Zs(e)&&(s.set(e,t),kr(t,e,i,Ji,s),s.delete(e)),t}function Qi(t){return ra(t)?i:t}function Xi(t,e,n,r,o,s){var a=1&n,u=t.length,l=e.length;if(u!=l&&!(a&&l>u))return!1;var c=s.get(t),h=s.get(e);if(c&&h)return c==e&&h==t;var f=-1,d=!0,p=2&n?new Wn:i;for(s.set(t,e),s.set(e,t);++f<u;){var g=t[f],m=e[f];if(r)var y=a?r(m,g,f,e,t,s):r(g,m,f,t,e,s);if(y!==i){if(y)continue;d=!1;break}if(p){if(!Re(e,(function(t,e){if(!Qe(p,e)&&(g===t||o(g,t,n,r,s)))return p.push(e)}))){d=!1;break}}else if(g!==m&&!o(g,m,n,r,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function Zi(t){return No(_o(t,i,qo),t+"")}function to(t){return Ar(t,Ma,lo)}function eo(t){return Ar(t,Oa,co)}var no=In?function(t){return In.get(t)}:au;function ro(t){for(var e=t.name+"",n=Nn[e],r=Bt.call(Nn,e)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==t)return i.name}return e}function io(t){return(Bt.call(Hn,"placeholder")?Hn:t).placeholder}function oo(){var t=Hn.iteratee||ru;return t=t===ru?Br:t,arguments.length?t(arguments[0],arguments[1]):t}function so(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function ao(t){for(var e=Ma(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Ao(i)]}return e}function uo(t,e){var n=function(t,e){return null==t?i:t[e]}(t,e);return Lr(n)?n:i}var lo=ge?function(t){return null==t?[]:(t=_t(t),Ie(ge(t),(function(e){return Wt.call(t,e)})))}:pu,co=ge?function(t){for(var e=[];t;)Le(e,lo(t)),t=qt(t);return e}:pu,ho=xr;function fo(t,e,n){for(var r=-1,i=(e=mi(e,t)).length,o=!1;++r<i;){var s=Do(e[r]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++r!=i?o:!!(i=null==t?0:t.length)&&Xs(i)&&mo(s,i)&&(js(t)||Vs(t))}function po(t){return"function"!=typeof t.constructor||Co(t)?{}:kn(qt(t))}function go(t){return js(t)||Vs(t)||!!(Yt&&t&&t[Yt])}function mo(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 yo(t,e,n){if(!Zs(n))return!1;var r=typeof e;return!!("number"==r?Gs(n)&&mo(e,n.length):"string"==r&&e in n)&&ks(n[e],t)}function vo(t,e){if(js(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 _t(e)}function bo(t){var e=ro(t),n=Hn[e];if("function"!=typeof n||!(e in Vn.prototype))return!1;if(t===n)return!0;var r=no(n);return!!r&&t===r[0]}(An&&ho(new An(new ArrayBuffer(1)))!=L||xn&&ho(new xn)!=A||_n&&ho(_n.resolve())!=E||En&&ho(new En)!=S||Tn&&ho(new Tn)!=M)&&(ho=function(t){var e=xr(t),n=e==_?t.constructor:i,r=n?Fo(n):"";if(r)switch(r){case Mn:return L;case On:return A;case Ln:return E;case Bn:return S;case Pn:return M}return e});var wo=Ot?Js:gu;function Co(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Mt)}function Ao(t){return t==t&&!Zs(t)}function xo(t,e){return function(n){return null!=n&&n[t]===e&&(e!==i||t in _t(n))}}function _o(t,e,n){return e=mn(e===i?t.length-1:e,0),function(){for(var i=arguments,o=-1,s=mn(i.length-e,0),a=r(s);++o<s;)a[o]=i[e+o];o=-1;for(var u=r(e+1);++o<e;)u[o]=i[o];return u[e]=n(a),xe(t,this,u)}}function Eo(t,e){return e.length<2?t:Cr(t,ti(e,0,-1))}function To(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var So=Oo(Qr),Io=ce||function(t,e){return he.setTimeout(t,e)},No=Oo(Xr);function Mo(t,e,n){var r=e+"";return No(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(ot,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Ee(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 Oo(t){var e=0,n=0;return function(){var r=vn(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(i,arguments)}}function Lo(t,e){var n=-1,r=t.length,o=r-1;for(e=e===i?r:e;++n<e;){var s=Gr(n,o),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Bo,Po,Ro=(Bo=Bs((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,i){e.push(r?i.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Po.size&&Po.clear(),t})),Po=Bo.cache,Bo);function Do(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fo(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ho(t){if(t instanceof Vn)return t.clone();var e=new $n(t.__wrapped__,t.__chain__);return e.__actions__=Ti(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var ko=zr((function(t,e){return Ws(t)?lr(t,gr(e,1,Ws,!0)):[]})),Uo=zr((function(t,e){var n=Ko(e);return Ws(n)&&(n=i),Ws(t)?lr(t,gr(e,1,Ws,!0),oo(n,2)):[]})),$o=zr((function(t,e){var n=Ko(e);return Ws(n)&&(n=i),Ws(t)?lr(t,gr(e,1,Ws,!0),i,n):[]}));function Vo(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:da(n);return i<0&&(i=mn(r+i,0)),He(t,oo(e,3),i)}function jo(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r-1;return n!==i&&(o=da(n),o=n<0?mn(r+o,0):yn(o,r-1)),He(t,oo(e,3),o,!0)}function qo(t){return null!=t&&t.length?gr(t,1):[]}function Go(t){return t&&t.length?t[0]:i}var Wo=zr((function(t){var e=Oe(t,pi);return e.length&&e[0]===t[0]?Sr(e):[]})),zo=zr((function(t){var e=Ko(t),n=Oe(t,pi);return e===Ko(n)?e=i:n.pop(),n.length&&n[0]===t[0]?Sr(n,oo(e,2)):[]})),Yo=zr((function(t){var e=Ko(t),n=Oe(t,pi);return(e="function"==typeof e?e:i)&&n.pop(),n.length&&n[0]===t[0]?Sr(n,i,e):[]}));function Ko(t){var e=null==t?0:t.length;return e?t[e-1]:i}var Jo=zr(Qo);function Qo(t,e){return t&&t.length&&e&&e.length?jr(t,e):t}var Xo=Zi((function(t,e){var n=null==t?0:t.length,r=ir(t,e);return qr(t,Oe(e,(function(t){return mo(t,n)?+t:t})).sort(xi)),r}));function Zo(t){return null==t?t:Cn.call(t)}var ts=zr((function(t){return ai(gr(t,1,Ws,!0))})),es=zr((function(t){var e=Ko(t);return Ws(e)&&(e=i),ai(gr(t,1,Ws,!0),oo(e,2))})),ns=zr((function(t){var e=Ko(t);return e="function"==typeof e?e:i,ai(gr(t,1,Ws,!0),i,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=Ie(t,(function(t){if(Ws(t))return e=mn(t.length,e),!0})),ze(e,(function(e){return Oe(t,je(e))}))}function is(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Oe(n,(function(t){return xe(e,i,t)}))}var os=zr((function(t,e){return Ws(t)?lr(t,e):[]})),ss=zr((function(t){return fi(Ie(t,Ws))})),as=zr((function(t){var e=Ko(t);return Ws(e)&&(e=i),fi(Ie(t,Ws),oo(e,2))})),us=zr((function(t){var e=Ko(t);return e="function"==typeof e?e:i,fi(Ie(t,Ws),i,e)})),ls=zr(rs),cs=zr((function(t){var e=t.length,n=e>1?t[e-1]:i;return n="function"==typeof n?(t.pop(),n):i,is(t,n)}));function hs(t){var e=Hn(t);return e.__chain__=!0,e}function fs(t,e){return e(t)}var ds=Zi((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return ir(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Vn&&mo(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:fs,args:[o],thisArg:i}),new $n(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(i),t}))):this.thru(o)})),ps=Ii((function(t,e,n){Bt.call(t,n)?++t[n]:rr(t,n,1)})),gs=Ri(Vo),ms=Ri(jo);function ys(t,e){return(js(t)?Ee:cr)(t,oo(e,3))}function vs(t,e){return(js(t)?Te:hr)(t,oo(e,3))}var bs=Ii((function(t,e,n){Bt.call(t,n)?t[n].push(e):rr(t,n,[e])})),ws=zr((function(t,e,n){var i=-1,o="function"==typeof e,s=Gs(t)?r(t.length):[];return cr(t,(function(t){s[++i]=o?xe(e,t,n):Ir(t,e,n)})),s})),Cs=Ii((function(t,e,n){rr(t,n,e)}));function As(t,e){return(js(t)?Oe:Dr)(t,oo(e,3))}var xs=Ii((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),_s=zr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&yo(t,e[0],e[1])?e=[]:n>2&&yo(e[0],e[1],e[2])&&(e=[e[0]]),$r(t,gr(e,1),[])})),Es=le||function(){return he.Date.now()};function Ts(t,e,n){return e=n?i:e,e=t&&null==e?t.length:e,Yi(t,l,i,i,i,i,e)}function Ss(t,e){var n;if("function"!=typeof e)throw new St(o);return t=da(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=i),n}}var Is=zr((function(t,e,n){var r=1;if(n.length){var i=an(n,io(Is));r|=u}return Yi(t,r,e,n,i)})),Ns=zr((function(t,e,n){var r=3;if(n.length){var i=an(n,io(Ns));r|=u}return Yi(e,r,t,n,i)}));function Ms(t,e,n){var r,s,a,u,l,c,h=0,f=!1,d=!1,p=!0;if("function"!=typeof t)throw new St(o);function g(e){var n=r,o=s;return r=s=i,h=e,u=t.apply(o,n)}function m(t){var n=t-c;return c===i||n>=e||n<0||d&&t-h>=a}function y(){var t=Es();if(m(t))return v(t);l=Io(y,function(t){var n=e-(t-c);return d?yn(n,a-(t-h)):n}(t))}function v(t){return l=i,p&&r?g(t):(r=s=i,u)}function b(){var t=Es(),n=m(t);if(r=arguments,s=this,c=t,n){if(l===i)return function(t){return h=t,l=Io(y,e),f?g(t):u}(c);if(d)return bi(l),l=Io(y,e),g(c)}return l===i&&(l=Io(y,e)),u}return e=ga(e)||0,Zs(n)&&(f=!!n.leading,a=(d="maxWait"in n)?mn(ga(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),b.cancel=function(){l!==i&&bi(l),h=0,r=c=s=l=i},b.flush=function(){return l===i?u:v(Es())},b}var Os=zr((function(t,e){return ur(t,1,e)})),Ls=zr((function(t,e,n){return ur(t,ga(e)||0,n)}));function Bs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new St(o);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Bs.Cache||Gn),n}function Ps(t){if("function"!=typeof t)throw new St(o);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)}}Bs.Cache=Gn;var Rs=yi((function(t,e){var n=(e=1==e.length&&js(e[0])?Oe(e[0],Ke(oo())):Oe(gr(e,1),Ke(oo()))).length;return zr((function(r){for(var i=-1,o=yn(r.length,n);++i<o;)r[i]=e[i].call(this,r[i]);return xe(t,this,r)}))})),Ds=zr((function(t,e){var n=an(e,io(Ds));return Yi(t,u,i,e,n)})),Fs=zr((function(t,e){var n=an(e,io(Fs));return Yi(t,64,i,e,n)})),Hs=Zi((function(t,e){return Yi(t,256,i,i,i,e)}));function ks(t,e){return t===e||t!=t&&e!=e}var Us=ji(_r),$s=ji((function(t,e){return t>=e})),Vs=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Bt.call(t,"callee")&&!Wt.call(t,"callee")},js=r.isArray,qs=ye?Ke(ye):function(t){return ta(t)&&xr(t)==O};function Gs(t){return null!=t&&Xs(t.length)&&!Js(t)}function Ws(t){return ta(t)&&Gs(t)}var zs=me||gu,Ys=ve?Ke(ve):function(t){return ta(t)&&xr(t)==v};function Ks(t){if(!ta(t))return!1;var e=xr(t);return e==b||"[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==w||e==C||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==da(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=be?Ke(be):function(t){return ta(t)&&ho(t)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=_)return!1;var e=qt(t);if(null===e)return!0;var n=Bt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Ft}var ia=we?Ke(we):function(t){return ta(t)&&xr(t)==T},oa=Ce?Ke(Ce):function(t){return ta(t)&&ho(t)==S};function sa(t){return"string"==typeof t||!js(t)&&ta(t)&&xr(t)==I}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var ua=Ae?Ke(Ae):function(t){return ta(t)&&Xs(t.length)&&!!ie[xr(t)]},la=ji(Rr),ca=ji((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(Gs(t))return sa(t)?hn(t):Ti(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=ho(t);return(e==A?on:e==S?un:ka)(t)}function fa(t){return t?(t=ga(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function da(t){var e=fa(t),n=e%1;return e==e?n?e-n:e:0}function pa(t){return t?or(da(t),0,d):0}function ga(t){if("number"==typeof t)return t;if(aa(t))return f;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||mt.test(t)?ue(t.slice(2),n?2:8):dt.test(t)?f:+t}function ma(t){return Si(t,Oa(t))}function ya(t){return null==t?"":si(t)}var va=Ni((function(t,e){if(Co(e)||Gs(e))Si(e,Ma(e),t);else for(var n in e)Bt.call(e,n)&&Zn(t,n,e[n])})),ba=Ni((function(t,e){Si(e,Oa(e),t)})),wa=Ni((function(t,e,n,r){Si(e,Oa(e),t,r)})),Ca=Ni((function(t,e,n,r){Si(e,Ma(e),t,r)})),Aa=Zi(ir),xa=zr((function(t,e){t=_t(t);var n=-1,r=e.length,o=r>2?e[2]:i;for(o&&yo(e[0],e[1],o)&&(r=1);++n<r;)for(var s=e[n],a=Oa(s),u=-1,l=a.length;++u<l;){var c=a[u],h=t[c];(h===i||ks(h,Mt[c])&&!Bt.call(t,c))&&(t[c]=s[c])}return t})),_a=zr((function(t){return t.push(i,Ji),xe(Ba,i,t)}));function Ea(t,e,n){var r=null==t?i:Cr(t,e);return r===i?n:r}function Ta(t,e){return null!=t&&fo(t,e,Tr)}var Sa=Hi((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),t[e]=n}),Za(nu)),Ia=Hi((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),Bt.call(t,e)?t[e].push(n):t[e]=[n]}),oo),Na=zr(Ir);function Ma(t){return Gs(t)?Yn(t):Pr(t)}function Oa(t){return Gs(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in _t(t))e.push(n);return e}(t);var e=Co(t),n=[];for(var r in t)("constructor"!=r||!e&&Bt.call(t,r))&&n.push(r);return n}(t)}var La=Ni((function(t,e,n){kr(t,e,n)})),Ba=Ni((function(t,e,n,r){kr(t,e,n,r)})),Pa=Zi((function(t,e){var n={};if(null==t)return n;var r=!1;e=Oe(e,(function(e){return e=mi(e,t),r||(r=e.length>1),e})),Si(t,eo(t),n),r&&(n=sr(n,7,Qi));for(var i=e.length;i--;)ui(n,e[i]);return n})),Ra=Zi((function(t,e){return null==t?{}:function(t,e){return Vr(t,e,(function(e,n){return Ta(t,n)}))}(t,e)}));function Da(t,e){if(null==t)return{};var n=Oe(eo(t),(function(t){return[t]}));return e=oo(e),Vr(t,n,(function(t,n){return e(t,n[0])}))}var Fa=zi(Ma),Ha=zi(Oa);function ka(t){return null==t?[]:Je(t,Ma(t))}var Ua=Bi((function(t,e,n){return e=e.toLowerCase(),t+(n?$a(e):e)}));function $a(t){return Ka(ya(t).toLowerCase())}function Va(t){return(t=ya(t))&&t.replace(vt,tn).replace(Qt,"")}var ja=Bi((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),qa=Bi((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Ga=Li("toLowerCase"),Wa=Bi((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),za=Bi((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Bi((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Li("toUpperCase");function Ja(t,e,n){return t=ya(t),(e=n?i:e)===i?function(t){return ee.test(t)}(t)?function(t){return t.match(Zt)||[]}(t):function(t){return t.match(ut)||[]}(t):t.match(e)||[]}var Qa=zr((function(t,e){try{return xe(t,i,e)}catch(t){return Ks(t)?t:new Ct(t)}})),Xa=Zi((function(t,e){return Ee(e,(function(e){e=Do(e),rr(t,e,Is(t[e],t))})),t}));function Za(t){return function(){return t}}var tu=Di(),eu=Di(!0);function nu(t){return t}function ru(t){return Br("function"==typeof t?t:sr(t,1))}var iu=zr((function(t,e){return function(n){return Ir(n,t,e)}})),ou=zr((function(t,e){return function(n){return Ir(t,n,e)}}));function su(t,e,n){var r=Ma(e),i=wr(e,r);null!=n||Zs(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=wr(e,Ma(e)));var o=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Ee(i,(function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__);return(n.__actions__=Ti(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Le([this.value()],arguments))})})),t}function au(){}var uu=Ui(Oe),lu=Ui(Se),cu=Ui(Re);function hu(t){return vo(t)?je(Do(t)):function(t){return function(e){return Cr(e,t)}}(t)}var fu=Vi(),du=Vi(!0);function pu(){return[]}function gu(){return!1}var mu,yu=ki((function(t,e){return t+e}),0),vu=Gi("ceil"),bu=ki((function(t,e){return t/e}),1),wu=Gi("floor"),Cu=ki((function(t,e){return t*e}),1),Au=Gi("round"),xu=ki((function(t,e){return t-e}),0);return Hn.after=function(t,e){if("function"!=typeof e)throw new St(o);return t=da(t),function(){if(--t<1)return e.apply(this,arguments)}},Hn.ary=Ts,Hn.assign=va,Hn.assignIn=ba,Hn.assignInWith=wa,Hn.assignWith=Ca,Hn.at=Aa,Hn.before=Ss,Hn.bind=Is,Hn.bindAll=Xa,Hn.bindKey=Ns,Hn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return js(t)?t:[t]},Hn.chain=hs,Hn.chunk=function(t,e,n){e=(n?yo(t,e,n):e===i)?1:mn(da(e),0);var o=null==t?0:t.length;if(!o||e<1)return[];for(var s=0,a=0,u=r(fe(o/e));s<o;)u[a++]=ti(t,s,s+=e);return u},Hn.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i},Hn.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],i=t;i--;)e[i-1]=arguments[i];return Le(js(n)?Ti(n):[n],gr(e,1))},Hn.cond=function(t){var e=null==t?0:t.length,n=oo();return t=e?Oe(t,(function(t){if("function"!=typeof t[1])throw new St(o);return[n(t[0]),t[1]]})):[],zr((function(n){for(var r=-1;++r<e;){var i=t[r];if(xe(i[0],this,n))return xe(i[1],this,n)}}))},Hn.conforms=function(t){return function(t){var e=Ma(t);return function(n){return ar(n,t,e)}}(sr(t,1))},Hn.constant=Za,Hn.countBy=ps,Hn.create=function(t,e){var n=kn(t);return null==e?n:nr(n,e)},Hn.curry=function t(e,n,r){var o=Yi(e,8,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},Hn.curryRight=function t(e,n,r){var o=Yi(e,16,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},Hn.debounce=Ms,Hn.defaults=xa,Hn.defaultsDeep=_a,Hn.defer=Os,Hn.delay=Ls,Hn.difference=ko,Hn.differenceBy=Uo,Hn.differenceWith=$o,Hn.drop=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,(e=n||e===i?1:da(e))<0?0:e,r):[]},Hn.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,0,(e=r-(e=n||e===i?1:da(e)))<0?0:e):[]},Hn.dropRightWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!0,!0):[]},Hn.dropWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!0):[]},Hn.fill=function(t,e,n,r){var o=null==t?0:t.length;return o?(n&&"number"!=typeof n&&yo(t,e,n)&&(n=0,r=o),function(t,e,n,r){var o=t.length;for((n=da(n))<0&&(n=-n>o?0:o+n),(r=r===i||r>o?o:da(r))<0&&(r+=o),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},Hn.filter=function(t,e){return(js(t)?Ie:pr)(t,oo(e,3))},Hn.flatMap=function(t,e){return gr(As(t,e),1)},Hn.flatMapDeep=function(t,e){return gr(As(t,e),c)},Hn.flatMapDepth=function(t,e,n){return n=n===i?1:da(n),gr(As(t,e),n)},Hn.flatten=qo,Hn.flattenDeep=function(t){return null!=t&&t.length?gr(t,c):[]},Hn.flattenDepth=function(t,e){return null!=t&&t.length?gr(t,e=e===i?1:da(e)):[]},Hn.flip=function(t){return Yi(t,512)},Hn.flow=tu,Hn.flowRight=eu,Hn.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var i=t[e];r[i[0]]=i[1]}return r},Hn.functions=function(t){return null==t?[]:wr(t,Ma(t))},Hn.functionsIn=function(t){return null==t?[]:wr(t,Oa(t))},Hn.groupBy=bs,Hn.initial=function(t){return null!=t&&t.length?ti(t,0,-1):[]},Hn.intersection=Wo,Hn.intersectionBy=zo,Hn.intersectionWith=Yo,Hn.invert=Sa,Hn.invertBy=Ia,Hn.invokeMap=ws,Hn.iteratee=ru,Hn.keyBy=Cs,Hn.keys=Ma,Hn.keysIn=Oa,Hn.map=As,Hn.mapKeys=function(t,e){var n={};return e=oo(e,3),vr(t,(function(t,r,i){rr(n,e(t,r,i),t)})),n},Hn.mapValues=function(t,e){var n={};return e=oo(e,3),vr(t,(function(t,r,i){rr(n,r,e(t,r,i))})),n},Hn.matches=function(t){return Fr(sr(t,1))},Hn.matchesProperty=function(t,e){return Hr(t,sr(e,1))},Hn.memoize=Bs,Hn.merge=La,Hn.mergeWith=Ba,Hn.method=iu,Hn.methodOf=ou,Hn.mixin=su,Hn.negate=Ps,Hn.nthArg=function(t){return t=da(t),zr((function(e){return Ur(e,t)}))},Hn.omit=Pa,Hn.omitBy=function(t,e){return Da(t,Ps(oo(e)))},Hn.once=function(t){return Ss(2,t)},Hn.orderBy=function(t,e,n,r){return null==t?[]:(js(e)||(e=null==e?[]:[e]),js(n=r?i:n)||(n=null==n?[]:[n]),$r(t,e,n))},Hn.over=uu,Hn.overArgs=Rs,Hn.overEvery=lu,Hn.overSome=cu,Hn.partial=Ds,Hn.partialRight=Fs,Hn.partition=xs,Hn.pick=Ra,Hn.pickBy=Da,Hn.property=hu,Hn.propertyOf=function(t){return function(e){return null==t?i:Cr(t,e)}},Hn.pull=Jo,Hn.pullAll=Qo,Hn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,oo(n,2)):t},Hn.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,i,n):t},Hn.pullAt=Xo,Hn.range=fu,Hn.rangeRight=du,Hn.rearg=Hs,Hn.reject=function(t,e){return(js(t)?Ie:pr)(t,Ps(oo(e,3)))},Hn.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,i=[],o=t.length;for(e=oo(e,3);++r<o;){var s=t[r];e(s,r,t)&&(n.push(s),i.push(r))}return qr(t,i),n},Hn.rest=function(t,e){if("function"!=typeof t)throw new St(o);return zr(t,e=e===i?e:da(e))},Hn.reverse=Zo,Hn.sampleSize=function(t,e,n){return e=(n?yo(t,e,n):e===i)?1:da(e),(js(t)?Jn:Kr)(t,e)},Hn.set=function(t,e,n){return null==t?t:Jr(t,e,n)},Hn.setWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:Jr(t,e,n,r)},Hn.shuffle=function(t){return(js(t)?Qn:Zr)(t)},Hn.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&yo(t,e,n)?(e=0,n=r):(e=null==e?0:da(e),n=n===i?r:da(n)),ti(t,e,n)):[]},Hn.sortBy=_s,Hn.sortedUniq=function(t){return t&&t.length?ii(t):[]},Hn.sortedUniqBy=function(t,e){return t&&t.length?ii(t,oo(e,2)):[]},Hn.split=function(t,e,n){return n&&"number"!=typeof n&&yo(t,e,n)&&(e=n=i),(n=n===i?d:n>>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!ia(e))&&!(e=si(e))&&rn(t)?vi(hn(t),0,n):t.split(e,n):[]},Hn.spread=function(t,e){if("function"!=typeof t)throw new St(o);return e=null==e?0:mn(da(e),0),zr((function(n){var r=n[e],i=vi(n,0,e);return r&&Le(i,r),xe(t,this,i)}))},Hn.tail=function(t){var e=null==t?0:t.length;return e?ti(t,1,e):[]},Hn.take=function(t,e,n){return t&&t.length?ti(t,0,(e=n||e===i?1:da(e))<0?0:e):[]},Hn.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,(e=r-(e=n||e===i?1:da(e)))<0?0:e,r):[]},Hn.takeRightWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!1,!0):[]},Hn.takeWhile=function(t,e){return t&&t.length?ci(t,oo(e,3)):[]},Hn.tap=function(t,e){return e(t),t},Hn.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new St(o);return Zs(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ms(t,e,{leading:r,maxWait:e,trailing:i})},Hn.thru=fs,Hn.toArray=ha,Hn.toPairs=Fa,Hn.toPairsIn=Ha,Hn.toPath=function(t){return js(t)?Oe(t,Do):aa(t)?[t]:Ti(Ro(ya(t)))},Hn.toPlainObject=ma,Hn.transform=function(t,e,n){var r=js(t),i=r||zs(t)||ua(t);if(e=oo(e,4),null==n){var o=t&&t.constructor;n=i?r?new o:[]:Zs(t)&&Js(o)?kn(qt(t)):{}}return(i?Ee:vr)(t,(function(t,r,i){return e(n,t,r,i)})),n},Hn.unary=function(t){return Ts(t,1)},Hn.union=ts,Hn.unionBy=es,Hn.unionWith=ns,Hn.uniq=function(t){return t&&t.length?ai(t):[]},Hn.uniqBy=function(t,e){return t&&t.length?ai(t,oo(e,2)):[]},Hn.uniqWith=function(t,e){return e="function"==typeof e?e:i,t&&t.length?ai(t,i,e):[]},Hn.unset=function(t,e){return null==t||ui(t,e)},Hn.unzip=rs,Hn.unzipWith=is,Hn.update=function(t,e,n){return null==t?t:li(t,e,gi(n))},Hn.updateWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:li(t,e,gi(n),r)},Hn.values=ka,Hn.valuesIn=function(t){return null==t?[]:Je(t,Oa(t))},Hn.without=os,Hn.words=Ja,Hn.wrap=function(t,e){return Ds(gi(e),t)},Hn.xor=ss,Hn.xorBy=as,Hn.xorWith=us,Hn.zip=ls,Hn.zipObject=function(t,e){return di(t||[],e||[],Zn)},Hn.zipObjectDeep=function(t,e){return di(t||[],e||[],Jr)},Hn.zipWith=cs,Hn.entries=Fa,Hn.entriesIn=Ha,Hn.extend=ba,Hn.extendWith=wa,su(Hn,Hn),Hn.add=yu,Hn.attempt=Qa,Hn.camelCase=Ua,Hn.capitalize=$a,Hn.ceil=vu,Hn.clamp=function(t,e,n){return n===i&&(n=e,e=i),n!==i&&(n=(n=ga(n))==n?n:0),e!==i&&(e=(e=ga(e))==e?e:0),or(ga(t),e,n)},Hn.clone=function(t){return sr(t,4)},Hn.cloneDeep=function(t){return sr(t,5)},Hn.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:i)},Hn.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:i)},Hn.conformsTo=function(t,e){return null==e||ar(t,e,Ma(e))},Hn.deburr=Va,Hn.defaultTo=function(t,e){return null==t||t!=t?e:t},Hn.divide=bu,Hn.endsWith=function(t,e,n){t=ya(t),e=si(e);var r=t.length,o=n=n===i?r:or(da(n),0,r);return(n-=e.length)>=0&&t.slice(n,o)==e},Hn.eq=ks,Hn.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(W,en):t},Hn.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},Hn.every=function(t,e,n){var r=js(t)?Se:fr;return n&&yo(t,e,n)&&(e=i),r(t,oo(e,3))},Hn.find=gs,Hn.findIndex=Vo,Hn.findKey=function(t,e){return Fe(t,oo(e,3),vr)},Hn.findLast=ms,Hn.findLastIndex=jo,Hn.findLastKey=function(t,e){return Fe(t,oo(e,3),br)},Hn.floor=wu,Hn.forEach=ys,Hn.forEachRight=vs,Hn.forIn=function(t,e){return null==t?t:mr(t,oo(e,3),Oa)},Hn.forInRight=function(t,e){return null==t?t:yr(t,oo(e,3),Oa)},Hn.forOwn=function(t,e){return t&&vr(t,oo(e,3))},Hn.forOwnRight=function(t,e){return t&&br(t,oo(e,3))},Hn.get=Ea,Hn.gt=Us,Hn.gte=$s,Hn.has=function(t,e){return null!=t&&fo(t,e,Er)},Hn.hasIn=Ta,Hn.head=Go,Hn.identity=nu,Hn.includes=function(t,e,n,r){t=Gs(t)?t:ka(t),n=n&&!r?da(n):0;var i=t.length;return n<0&&(n=mn(i+n,0)),sa(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&ke(t,e,n)>-1},Hn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:da(n);return i<0&&(i=mn(r+i,0)),ke(t,e,i)},Hn.inRange=function(t,e,n){return e=fa(e),n===i?(n=e,e=0):n=fa(n),function(t,e,n){return t>=yn(e,n)&&t<mn(e,n)}(t=ga(t),e,n)},Hn.invoke=Na,Hn.isArguments=Vs,Hn.isArray=js,Hn.isArrayBuffer=qs,Hn.isArrayLike=Gs,Hn.isArrayLikeObject=Ws,Hn.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},Hn.isBuffer=zs,Hn.isDate=Ys,Hn.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},Hn.isEmpty=function(t){if(null==t)return!0;if(Gs(t)&&(js(t)||"string"==typeof t||"function"==typeof t.splice||zs(t)||ua(t)||Vs(t)))return!t.length;var e=ho(t);if(e==A||e==S)return!t.size;if(Co(t))return!Pr(t).length;for(var n in t)if(Bt.call(t,n))return!1;return!0},Hn.isEqual=function(t,e){return Mr(t,e)},Hn.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:i)?n(t,e):i;return r===i?Mr(t,e,i,n):!!r},Hn.isError=Ks,Hn.isFinite=function(t){return"number"==typeof t&&De(t)},Hn.isFunction=Js,Hn.isInteger=Qs,Hn.isLength=Xs,Hn.isMap=ea,Hn.isMatch=function(t,e){return t===e||Or(t,e,ao(e))},Hn.isMatchWith=function(t,e,n){return n="function"==typeof n?n:i,Or(t,e,ao(e),n)},Hn.isNaN=function(t){return na(t)&&t!=+t},Hn.isNative=function(t){if(wo(t))throw new Ct("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},Hn.isNil=function(t){return null==t},Hn.isNull=function(t){return null===t},Hn.isNumber=na,Hn.isObject=Zs,Hn.isObjectLike=ta,Hn.isPlainObject=ra,Hn.isRegExp=ia,Hn.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},Hn.isSet=oa,Hn.isString=sa,Hn.isSymbol=aa,Hn.isTypedArray=ua,Hn.isUndefined=function(t){return t===i},Hn.isWeakMap=function(t){return ta(t)&&ho(t)==M},Hn.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},Hn.join=function(t,e){return null==t?"":qe.call(t,e)},Hn.kebabCase=ja,Hn.last=Ko,Hn.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=da(n))<0?mn(r+o,0):yn(o,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,o):He(t,$e,o,!0)},Hn.lowerCase=qa,Hn.lowerFirst=Ga,Hn.lt=la,Hn.lte=ca,Hn.max=function(t){return t&&t.length?dr(t,nu,_r):i},Hn.maxBy=function(t,e){return t&&t.length?dr(t,oo(e,2),_r):i},Hn.mean=function(t){return Ve(t,nu)},Hn.meanBy=function(t,e){return Ve(t,oo(e,2))},Hn.min=function(t){return t&&t.length?dr(t,nu,Rr):i},Hn.minBy=function(t,e){return t&&t.length?dr(t,oo(e,2),Rr):i},Hn.stubArray=pu,Hn.stubFalse=gu,Hn.stubObject=function(){return{}},Hn.stubString=function(){return""},Hn.stubTrue=function(){return!0},Hn.multiply=Cu,Hn.nth=function(t,e){return t&&t.length?Ur(t,da(e)):i},Hn.noConflict=function(){return he._===this&&(he._=Ht),this},Hn.noop=au,Hn.now=Es,Hn.pad=function(t,e,n){t=ya(t);var r=(e=da(e))?cn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return $i(de(i),n)+t+$i(fe(i),n)},Hn.padEnd=function(t,e,n){t=ya(t);var r=(e=da(e))?cn(t):0;return e&&r<e?t+$i(e-r,n):t},Hn.padStart=function(t,e,n){t=ya(t);var r=(e=da(e))?cn(t):0;return e&&r<e?$i(e-r,n)+t:t},Hn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),bn(ya(t).replace(rt,""),e||0)},Hn.random=function(t,e,n){if(n&&"boolean"!=typeof n&&yo(t,e,n)&&(e=n=i),n===i&&("boolean"==typeof e?(n=e,e=i):"boolean"==typeof t&&(n=t,t=i)),t===i&&e===i?(t=0,e=1):(t=fa(t),e===i?(e=t,t=0):e=fa(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var o=wn();return yn(t+o*(e-t+ae("1e-"+((o+"").length-1))),e)}return Gr(t,e)},Hn.reduce=function(t,e,n){var r=js(t)?Be:Ge,i=arguments.length<3;return r(t,oo(e,4),n,i,cr)},Hn.reduceRight=function(t,e,n){var r=js(t)?Pe:Ge,i=arguments.length<3;return r(t,oo(e,4),n,i,hr)},Hn.repeat=function(t,e,n){return e=(n?yo(t,e,n):e===i)?1:da(e),Wr(ya(t),e)},Hn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Hn.result=function(t,e,n){var r=-1,o=(e=mi(e,t)).length;for(o||(o=1,t=i);++r<o;){var s=null==t?i:t[Do(e[r])];s===i&&(r=o,s=n),t=Js(s)?s.call(t):s}return t},Hn.round=Au,Hn.runInContext=t,Hn.sample=function(t){return(js(t)?Kn:Yr)(t)},Hn.size=function(t){if(null==t)return 0;if(Gs(t))return sa(t)?cn(t):t.length;var e=ho(t);return e==A||e==S?t.size:Pr(t).length},Hn.snakeCase=Wa,Hn.some=function(t,e,n){var r=js(t)?Re:ei;return n&&yo(t,e,n)&&(e=i),r(t,oo(e,3))},Hn.sortedIndex=function(t,e){return ni(t,e)},Hn.sortedIndexBy=function(t,e,n){return ri(t,e,oo(n,2))},Hn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=ni(t,e);if(r<n&&ks(t[r],e))return r}return-1},Hn.sortedLastIndex=function(t,e){return ni(t,e,!0)},Hn.sortedLastIndexBy=function(t,e,n){return ri(t,e,oo(n,2),!0)},Hn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=ni(t,e,!0)-1;if(ks(t[n],e))return n}return-1},Hn.startCase=za,Hn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:or(da(n),0,t.length),e=si(e),t.slice(n,n+e.length)==e},Hn.subtract=xu,Hn.sum=function(t){return t&&t.length?We(t,nu):0},Hn.sumBy=function(t,e){return t&&t.length?We(t,oo(e,2)):0},Hn.template=function(t,e,n){var r=Hn.templateSettings;n&&yo(t,e,n)&&(e=i),t=ya(t),e=wa({},e,r,Ki);var o,s,a=wa({},e.imports,r.imports,Ki),u=Ma(a),l=Je(a,u),c=0,h=e.interpolate||bt,f="__p += '",d=Et((e.escape||bt).source+"|"+h.source+"|"+(h===Q?ht:bt).source+"|"+(e.evaluate||bt).source+"|$","g"),p="//# sourceURL="+(Bt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(d,(function(e,n,r,i,a,u){return r||(r=i),f+=t.slice(c,u).replace(wt,nn),n&&(o=!0,f+="' +\n__e("+n+") +\n'"),a&&(s=!0,f+="';\n"+a+";\n__p += '"),r&&(f+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=u+e.length,e})),f+="';\n";var g=Bt.call(e,"variable")&&e.variable;if(g){if(lt.test(g))throw new Ct("Invalid `variable` option passed into `_.template`")}else f="with (obj) {\n"+f+"\n}\n";f=(s?f.replace(V,""):f).replace(j,"$1").replace(q,"$1;"),f="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var m=Qa((function(){return At(u,p+"return "+f).apply(i,l)}));if(m.source=f,Ks(m))throw m;return m},Hn.times=function(t,e){if((t=da(t))<1||t>h)return[];var n=d,r=yn(t,d);e=oo(e),t-=d;for(var i=ze(r,e);++n<t;)e(n);return i},Hn.toFinite=fa,Hn.toInteger=da,Hn.toLength=pa,Hn.toLower=function(t){return ya(t).toLowerCase()},Hn.toNumber=ga,Hn.toSafeInteger=function(t){return t?or(da(t),-9007199254740991,h):0===t?t:0},Hn.toString=ya,Hn.toUpper=function(t){return ya(t).toUpperCase()},Hn.trim=function(t,e,n){if((t=ya(t))&&(n||e===i))return Ye(t);if(!t||!(e=si(e)))return t;var r=hn(t),o=hn(e);return vi(r,Xe(r,o),Ze(r,o)+1).join("")},Hn.trimEnd=function(t,e,n){if((t=ya(t))&&(n||e===i))return t.slice(0,fn(t)+1);if(!t||!(e=si(e)))return t;var r=hn(t);return vi(r,0,Ze(r,hn(e))+1).join("")},Hn.trimStart=function(t,e,n){if((t=ya(t))&&(n||e===i))return t.replace(rt,"");if(!t||!(e=si(e)))return t;var r=hn(t);return vi(r,Xe(r,hn(e))).join("")},Hn.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var o="separator"in e?e.separator:o;n="length"in e?da(e.length):n,r="omission"in e?si(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 u=n-cn(r);if(u<1)return r;var l=a?vi(a,0,u).join(""):t.slice(0,u);if(o===i)return l+r;if(a&&(u+=l.length-u),ia(o)){if(t.slice(u).search(o)){var c,h=l;for(o.global||(o=Et(o.source,ya(ft.exec(o))+"g")),o.lastIndex=0;c=o.exec(h);)var f=c.index;l=l.slice(0,f===i?u:f)}}else if(t.indexOf(si(o),u)!=u){var d=l.lastIndexOf(o);d>-1&&(l=l.slice(0,d))}return l+r},Hn.unescape=function(t){return(t=ya(t))&&z.test(t)?t.replace(G,dn):t},Hn.uniqueId=function(t){var e=++Pt;return ya(t)+e},Hn.upperCase=Ya,Hn.upperFirst=Ka,Hn.each=ys,Hn.eachRight=vs,Hn.first=Go,su(Hn,(mu={},vr(Hn,(function(t,e){Bt.call(Hn.prototype,e)||(mu[e]=t)})),mu),{chain:!1}),Hn.VERSION="4.17.21",Ee(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Hn[t].placeholder=Hn})),Ee(["drop","take"],(function(t,e){Vn.prototype[t]=function(n){n=n===i?1:mn(da(n),0);var r=this.__filtered__&&!e?new Vn(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,d),type:t+(r.__dir__<0?"Right":"")}),r},Vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Ee(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;Vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:oo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Ee(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Vn.prototype[t]=function(){return this[n](1).value()[0]}})),Ee(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Vn.prototype[t]=function(){return this.__filtered__?new Vn(this):this[n](1)}})),Vn.prototype.compact=function(){return this.filter(nu)},Vn.prototype.find=function(t){return this.filter(t).head()},Vn.prototype.findLast=function(t){return this.reverse().find(t)},Vn.prototype.invokeMap=zr((function(t,e){return"function"==typeof t?new Vn(this):this.map((function(n){return Ir(n,t,e)}))})),Vn.prototype.reject=function(t){return this.filter(Ps(oo(t)))},Vn.prototype.slice=function(t,e){t=da(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Vn(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==i&&(n=(e=da(e))<0?n.dropRight(-e):n.take(e-t)),n)},Vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Vn.prototype.toArray=function(){return this.take(d)},vr(Vn.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),o=Hn[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);o&&(Hn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,u=e instanceof Vn,l=a[0],c=u||js(e),h=function(t){var e=o.apply(Hn,Le([t],a));return r&&f?e[0]:e};c&&n&&"function"==typeof l&&1!=l.length&&(u=c=!1);var f=this.__chain__,d=!!this.__actions__.length,p=s&&!f,g=u&&!d;if(!s&&c){e=g?e:new Vn(this);var m=t.apply(e,a);return m.__actions__.push({func:fs,args:[h],thisArg:i}),new $n(m,f)}return p&&g?t.apply(this,a):(m=this.thru(h),p?r?m.value()[0]:m.value():m)})})),Ee(["pop","push","shift","sort","splice","unshift"],(function(t){var e=It[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);Hn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(js(i)?i:[],t)}return this[n]((function(n){return e.apply(js(n)?n:[],t)}))}})),vr(Vn.prototype,(function(t,e){var n=Hn[e];if(n){var r=n.name+"";Bt.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[Fi(i,2).name]=[{name:"wrapper",func:i}],Vn.prototype.clone=function(){var t=new Vn(this.__wrapped__);return t.__actions__=Ti(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ti(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ti(this.__views__),t},Vn.prototype.reverse=function(){if(this.__filtered__){var t=new Vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=js(t),r=e<0,i=n?t.length:0,o=function(t,e,n){for(var r=-1,i=n.length;++r<i;){var o=n[r],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yn(e,t+s);break;case"takeRight":t=mn(t,e-s)}}return{start:t,end:e}}(0,i,this.__views__),s=o.start,a=o.end,u=a-s,l=r?a:s-1,c=this.__iteratees__,h=c.length,f=0,d=yn(u,this.__takeCount__);if(!n||!r&&i==u&&d==u)return hi(t,this.__actions__);var p=[];t:for(;u--&&f<d;){for(var g=-1,m=t[l+=e];++g<h;){var y=c[g],v=y.iteratee,b=y.type,w=v(m);if(2==b)m=w;else if(!w){if(1==b)continue t;break t}}p[f++]=m}return p},Hn.prototype.at=ds,Hn.prototype.chain=function(){return hs(this)},Hn.prototype.commit=function(){return new $n(this.value(),this.__chain__)},Hn.prototype.next=function(){this.__values__===i&&(this.__values__=ha(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?i:this.__values__[this.__index__++]}},Hn.prototype.plant=function(t){for(var e,n=this;n instanceof Un;){var r=Ho(n);r.__index__=0,r.__values__=i,e?o.__wrapped__=r:e=r;var o=r;n=n.__wrapped__}return o.__wrapped__=t,e},Hn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Vn){var e=t;return this.__actions__.length&&(e=new Vn(this)),(e=e.reverse()).__actions__.push({func:fs,args:[Zo],thisArg:i}),new $n(e,this.__chain__)}return this.thru(Zo)},Hn.prototype.toJSON=Hn.prototype.valueOf=Hn.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},Hn.prototype.first=Hn.prototype.head,Kt&&(Hn.prototype[Kt]=function(){return this}),Hn}();he._=pn,(r=function(){return pn}.call(e,n,e,t))===i||(t.exports=r)}.call(this)},802:t=>{t.exports=function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},e[s][0].call(a.exports,(function(t){return i(e[s][1][t]||t)}),a,a.exports,t,e,n,r)}return n[s].exports}for(var o=void 0,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){(function(r,i,o,s,a,u,l,c,h){"use strict";var f=t("crypto");function d(t,e){var n;return void 0===(n="passthrough"!==(e=m(t,e)).algorithm?f.createHash(e.algorithm):new b).write&&(n.write=n.update,n.end=n.update),v(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=d).sha1=function(t){return d(t)},n.keys=function(t){return d(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return d(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return d(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var p=f.getHashes?f.getHashes().slice():["sha1","md5"],g=(p.push("passthrough"),["buffer","hex","binary","base64"]);function m(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===g.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+g.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 v(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 i,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!==o&&o.isBuffer&&o.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+":"),i=this,s.forEach((function(n){i.dispatch(n),r(":"),t.excludeValues||i.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,i){i=void 0!==i?i:!1!==t.unorderedArrays;var o=this;if(r("array:"+e.length+":"),!i||e.length<=1)return e.forEach((function(t){return o.dispatch(t)}));var s=[];return i=e.map((function(e){var r=new b,i=n.slice();return v(t,r,i).dispatch(e),s=s.concat(i.slice(n.length)),r.read().toString()})),n=n.concat(s),i.sort(),this._array(i,!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 b(){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={}),v(e=m(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,i,o,s,a,u,l){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),i="0".charCodeAt(0),o="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),u="_".charCodeAt(0);function l(t){return(t=t.charCodeAt(0))===n||t===a?62:t===r||t===u?63:t<i?-1:t<i+10?t-i+26+26:t<s+26?t-s:t<o+26?t-o+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 i=t.length,o=(i="="===t.charAt(i-2)?2:"="===t.charAt(i-1)?1:0,new e(3*t.length/4-i)),s=0<i?t.length-4:t.length,a=0;function u(t){o[a++]=t}for(n=0;n<s;n+=4,0)u((16711680&(r=l(t.charAt(n))<<18|l(t.charAt(n+1))<<12|l(t.charAt(n+2))<<6|l(t.charAt(n+3))))>>16),u((65280&r)>>8),u(255&r);return 2==i?u(255&(r=l(t.charAt(n))<<2|l(t.charAt(n+1))>>4)):1==i&&(u((r=l(t.charAt(n))<<10|l(t.charAt(n+1))<<4|l(t.charAt(n+2))>>2)>>8&255),u(255&r)),o},t.fromByteArray=function(t){var e,n,r,i,o=t.length%3,s="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,r=t.length-o;e<r;e+=3)s+=a((i=n=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(i>>12&63)+a(i>>6&63)+a(63&i);switch(o){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,i,o,s,a,u,l,c){var h=t("base64-js"),f=t("ieee754");function i(t,e,n){if(!(this instanceof i))return new i(t,e,n);var r,o,s,a,u=typeof t;if("base64"===e&&"string"==u)for(t=(a=t).trim?a.trim():a.replace(/^\s+|\s+$/g,"");t.length%4!=0;)t+="=";if("number"==u)r=S(t);else if("string"==u)r=i.byteLength(t,e);else{if("object"!=u)throw new Error("First argument needs to be a number, array or string.");r=S(t.length)}if(i._useTypedArrays?o=i._augment(new Uint8Array(r)):((o=this).length=r,o._isBuffer=!0),i._useTypedArrays&&"number"==typeof t.byteLength)o._set(t);else if(I(a=t)||i.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<r;s++)i.isBuffer(t)?o[s]=t.readUInt8(s):o[s]=t[s];else if("string"==u)o.write(t,0,e);else if("number"==u&&!i._useTypedArrays&&!n)for(s=0;s<r;s++)o[s]=0;return o}function d(t,e,n,r){var i;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?(i=t[e],e+1<r&&(i|=t[e+1]<<8)):(i=t[e]<<8,e+1<r&&(i|=t[e+1])),i}function p(t,e,n,r){var i;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&&(i=t[e+2]<<16),e+1<r&&(i|=t[e+1]<<8),i|=t[e],e+3<r&&(i+=t[e+3]<<24>>>0)):(e+1<r&&(i=t[e+1]<<16),e+2<r&&(i|=t[e+2]<<8),e+3<r&&(i|=t[e+3]),i+=t[e]<<24>>>0),i}function g(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=d(t,e,n,!0))?-1*(65535-r+1):r}function m(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")),f.read(t,e,n,23,4)}function v(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")),f.read(t,e,n,52,8)}function b(t,e,n,r,i){if(i||(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"),P(e,65535)),!((i=t.length)<=n))for(var o=0,s=Math.min(i-n,2);o<s;o++)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function w(t,e,n,r,i){if(i||(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"),P(e,4294967295)),!((i=t.length)<=n))for(var o=0,s=Math.min(i-n,4);o<s;o++)t[n+o]=e>>>8*(r?o:3-o)&255}function C(t,e,n,r,i){i||(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,32767,-32768)),t.length<=n||b(t,0<=e?e:65535+e+1,n,r,i)}function A(t,e,n,r,i){i||(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,2147483647,-2147483648)),t.length<=n||w(t,0<=e?e:4294967295+e+1,n,r,i)}function x(t,e,n,r,i){i||(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,34028234663852886e22,-34028234663852886e22)),t.length<=n||f.write(t,e,n,r,23,4)}function _(t,e,n,r,i){i||(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"),D(e,17976931348623157e292,-17976931348623157e292)),t.length<=n||f.write(t,e,n,r,52,8)}n.Buffer=i,n.SlowBuffer=i,n.INSPECT_MAX_BYTES=50,i.poolSize=8192,i._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}}(),i.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}},i.isBuffer=function(t){return!(null==t||!t._isBuffer)},i.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=O(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},i.concat=function(t,e){if(F(I(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new i(0);if(1===t.length)return t[0];if("number"!=typeof e)for(o=e=0;o<t.length;o++)e+=t[o].length;for(var n=new i(e),r=0,o=0;o<t.length;o++){var s=t[o];s.copy(n,r),r+=s.length}return n},i.prototype.write=function(t,e,n,r){isFinite(e)?isFinite(n)||(r=n,n=void 0):(l=r,r=e,e=n,n=l),e=Number(e)||0;var o,s,a,u,l=this.length-e;switch((!n||l<(n=Number(n)))&&(n=l),r=String(r||"utf8").toLowerCase()){case"hex":o=function(t,e,n,r){n=Number(n)||0;var o=t.length-n;(!r||o<(r=Number(r)))&&(r=o),F((o=e.length)%2==0,"Invalid hex string"),o/2<r&&(r=o/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 i._charsWritten=2*s,s}(this,t,e,n);break;case"utf8":case"utf-8":s=this,a=e,u=n,o=i._charsWritten=L(M(t),s,a,u);break;case"ascii":case"binary":o=function(t,e,n,r){return i._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,u=n,o=i._charsWritten=L(O(t),s,a,u);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=function(t,e,n,r){return i._charsWritten=L(function(t){for(var e,n,r=[],i=0;i<t.length;i++)e=(n=t.charCodeAt(i))>>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 o},i.prototype.toString=function(t,e,n){var r,i,o,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 i="",o=e;o<n;o++)i+=N(t[o]);return i}(a,e,n);break;case"utf8":case"utf-8":r=function(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;o<n;o++)t[o]<=127?(r+=B(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+B(i)}(a,e,n);break;case"ascii":case"binary":r=function(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;i++)r+=String.fromCharCode(t[i]);return r}(a,e,n);break;case"base64":i=a,s=n,r=0===(o=e)&&s===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(o,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}(a,e,n);break;default:throw new Error("Unknown encoding")}return r},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},i.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 o=(r=t.length-e<r-n?t.length-e+n:r)-n;if(o<100||!i._useTypedArrays)for(var s=0;s<o;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+o),e)}},i.prototype.slice=function(t,e){var n=this.length;if(t=T(t,n,0),e=T(e,n,n),i._useTypedArrays)return i._augment(this.subarray(t,e));for(var r=e-t,o=new i(r,void 0,!0),s=0;s<r;s++)o[s]=this[s+t];return o},i.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},i.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},i.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]},i.prototype.readUInt16LE=function(t,e){return d(this,t,!0,e)},i.prototype.readUInt16BE=function(t,e){return d(this,t,!1,e)},i.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},i.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},i.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]},i.prototype.readInt16LE=function(t,e){return g(this,t,!0,e)},i.prototype.readInt16BE=function(t,e){return g(this,t,!1,e)},i.prototype.readInt32LE=function(t,e){return m(this,t,!0,e)},i.prototype.readInt32BE=function(t,e){return m(this,t,!1,e)},i.prototype.readFloatLE=function(t,e){return y(this,t,!0,e)},i.prototype.readFloatBE=function(t,e){return y(this,t,!1,e)},i.prototype.readDoubleLE=function(t,e){return v(this,t,!0,e)},i.prototype.readDoubleBE=function(t,e){return v(this,t,!1,e)},i.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"),P(t,255)),e>=this.length||(this[e]=t)},i.prototype.writeUInt16LE=function(t,e,n){b(this,t,e,!0,n)},i.prototype.writeUInt16BE=function(t,e,n){b(this,t,e,!1,n)},i.prototype.writeUInt32LE=function(t,e,n){w(this,t,e,!0,n)},i.prototype.writeUInt32BE=function(t,e,n){w(this,t,e,!1,n)},i.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"),R(t,127,-128)),e>=this.length||(0<=t?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n))},i.prototype.writeInt16LE=function(t,e,n){C(this,t,e,!0,n)},i.prototype.writeInt16BE=function(t,e,n){C(this,t,e,!1,n)},i.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},i.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},i.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){_(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){_(this,t,e,!1,n)},i.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}},i.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(" ")+">"},i.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(i._useTypedArrays)return new i(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 E=i.prototype;function T(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function S(t){return(t=~~Math.ceil(+t))<0?0:t}function I(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 i=n,o=(55296<=r&&r<=57343&&n++,encodeURIComponent(t.slice(i,n+1)).substr(1).split("%")),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}return e}function O(t){return h.toByteArray(t)}function L(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function B(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function P(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 R(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 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")}function F(t,e){if(!t)throw new Error(e||"Failed assertion")}i._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=E.get,t.set=E.set,t.write=E.write,t.toString=E.toString,t.toLocaleString=E.toString,t.toJSON=E.toJSON,t.copy=E.copy,t.slice=E.slice,t.readUInt8=E.readUInt8,t.readUInt16LE=E.readUInt16LE,t.readUInt16BE=E.readUInt16BE,t.readUInt32LE=E.readUInt32LE,t.readUInt32BE=E.readUInt32BE,t.readInt8=E.readInt8,t.readInt16LE=E.readInt16LE,t.readInt16BE=E.readInt16BE,t.readInt32LE=E.readInt32LE,t.readInt32BE=E.readInt32BE,t.readFloatLE=E.readFloatLE,t.readFloatBE=E.readFloatBE,t.readDoubleLE=E.readDoubleLE,t.readDoubleBE=E.readDoubleBE,t.writeUInt8=E.writeUInt8,t.writeUInt16LE=E.writeUInt16LE,t.writeUInt16BE=E.writeUInt16BE,t.writeUInt32LE=E.writeUInt32LE,t.writeUInt32BE=E.writeUInt32BE,t.writeInt8=E.writeInt8,t.writeInt16LE=E.writeInt16LE,t.writeInt16BE=E.writeInt16BE,t.writeInt32LE=E.writeInt32LE,t.writeInt32BE=E.writeInt32BE,t.writeFloatLE=E.writeFloatLE,t.writeFloatBE=E.writeFloatBE,t.writeDoubleLE=E.writeDoubleLE,t.writeDoubleBE=E.writeDoubleBE,t.fill=E.fill,t.inspect=E.inspect,t.toArrayBuffer=E.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,i,o,s,a,u,l,c){i=t("buffer").Buffer;var h=new i(4);h.fill(0),e.exports={hash:function(t,e,n,r){for(var o=e(function(t,e){t.length%4!=0&&(n=t.length+(4-t.length%4),t=i.concat([t,h],n));for(var n,r=[],o=e?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=4)r.push(o.call(t,s));return r}(t=i.isBuffer(t)?t:new i(t),r),8*t.length),s=(e=r,new i(n)),a=e?s.writeInt32BE:s.writeInt32LE,u=0;u<o.length;u++)a.call(s,o[u],4*u,!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,i,o,s,a,u,l,c){i=t("buffer").Buffer;var h=t("./sha"),f=t("./sha256"),d=t("./rng"),p={sha1:h,sha256:f,md5:t("./md5")},g=64,m=new i(g);function y(t,e){var n=p[t=t||"sha1"],r=[];return n||v("algorithm:",t,"is not yet supported"),{update:function(t){return i.isBuffer(t)||(t=new i(t)),r.push(t),t.length,this},digest:function(t){var o=i.concat(r);return o=e?function(t,e,n){i.isBuffer(e)||(e=new i(e)),i.isBuffer(n)||(n=new i(n)),e.length>g?e=t(e):e.length<g&&(e=i.concat([e,m],g));for(var r=new i(g),o=new i(g),s=0;s<g;s++)r[s]=54^e[s],o[s]=92^e[s];return n=t(i.concat([r,n])),t(i.concat([o,n]))}(n,e,o):n(o),r=null,t?o.toString(t):o}}}function v(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}m.fill(0),n.createHash=function(t){return y(t)},n.createHmac=y,n.randomBytes=function(t,e){if(!e||!e.call)return new i(d(t));try{e.call(this,void 0,new i(d(t)))}catch(t){e(t)}};var b,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],C=function(t){n[t]=function(){v("sorry,",t,"is not implemented yet")}};for(b in w)C(w[b])}).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,i,o,s,a,u,l,c){var h=t("./helpers");function f(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;for(var n=1732584193,r=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=n,u=r,l=i,c=o;n=p(n,r,i,o,t[s+0],7,-680876936),o=p(o,n,r,i,t[s+1],12,-389564586),i=p(i,o,n,r,t[s+2],17,606105819),r=p(r,i,o,n,t[s+3],22,-1044525330),n=p(n,r,i,o,t[s+4],7,-176418897),o=p(o,n,r,i,t[s+5],12,1200080426),i=p(i,o,n,r,t[s+6],17,-1473231341),r=p(r,i,o,n,t[s+7],22,-45705983),n=p(n,r,i,o,t[s+8],7,1770035416),o=p(o,n,r,i,t[s+9],12,-1958414417),i=p(i,o,n,r,t[s+10],17,-42063),r=p(r,i,o,n,t[s+11],22,-1990404162),n=p(n,r,i,o,t[s+12],7,1804603682),o=p(o,n,r,i,t[s+13],12,-40341101),i=p(i,o,n,r,t[s+14],17,-1502002290),n=g(n,r=p(r,i,o,n,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=g(o,n,r,i,t[s+6],9,-1069501632),i=g(i,o,n,r,t[s+11],14,643717713),r=g(r,i,o,n,t[s+0],20,-373897302),n=g(n,r,i,o,t[s+5],5,-701558691),o=g(o,n,r,i,t[s+10],9,38016083),i=g(i,o,n,r,t[s+15],14,-660478335),r=g(r,i,o,n,t[s+4],20,-405537848),n=g(n,r,i,o,t[s+9],5,568446438),o=g(o,n,r,i,t[s+14],9,-1019803690),i=g(i,o,n,r,t[s+3],14,-187363961),r=g(r,i,o,n,t[s+8],20,1163531501),n=g(n,r,i,o,t[s+13],5,-1444681467),o=g(o,n,r,i,t[s+2],9,-51403784),i=g(i,o,n,r,t[s+7],14,1735328473),n=m(n,r=g(r,i,o,n,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=m(o,n,r,i,t[s+8],11,-2022574463),i=m(i,o,n,r,t[s+11],16,1839030562),r=m(r,i,o,n,t[s+14],23,-35309556),n=m(n,r,i,o,t[s+1],4,-1530992060),o=m(o,n,r,i,t[s+4],11,1272893353),i=m(i,o,n,r,t[s+7],16,-155497632),r=m(r,i,o,n,t[s+10],23,-1094730640),n=m(n,r,i,o,t[s+13],4,681279174),o=m(o,n,r,i,t[s+0],11,-358537222),i=m(i,o,n,r,t[s+3],16,-722521979),r=m(r,i,o,n,t[s+6],23,76029189),n=m(n,r,i,o,t[s+9],4,-640364487),o=m(o,n,r,i,t[s+12],11,-421815835),i=m(i,o,n,r,t[s+15],16,530742520),n=y(n,r=m(r,i,o,n,t[s+2],23,-995338651),i,o,t[s+0],6,-198630844),o=y(o,n,r,i,t[s+7],10,1126891415),i=y(i,o,n,r,t[s+14],15,-1416354905),r=y(r,i,o,n,t[s+5],21,-57434055),n=y(n,r,i,o,t[s+12],6,1700485571),o=y(o,n,r,i,t[s+3],10,-1894986606),i=y(i,o,n,r,t[s+10],15,-1051523),r=y(r,i,o,n,t[s+1],21,-2054922799),n=y(n,r,i,o,t[s+8],6,1873313359),o=y(o,n,r,i,t[s+15],10,-30611744),i=y(i,o,n,r,t[s+6],15,-1560198380),r=y(r,i,o,n,t[s+13],21,1309151649),n=y(n,r,i,o,t[s+4],6,-145523070),o=y(o,n,r,i,t[s+11],10,-1120210379),i=y(i,o,n,r,t[s+2],15,718787259),r=y(r,i,o,n,t[s+9],21,-343485551),n=v(n,a),r=v(r,u),i=v(i,l),o=v(o,c)}return Array(n,r,i,o)}function d(t,e,n,r,i,o){return v((e=v(v(e,t),v(r,o)))<<i|e>>>32-i,n)}function p(t,e,n,r,i,o,s){return d(e&n|~e&r,t,e,i,o,s)}function g(t,e,n,r,i,o,s){return d(e&r|n&~r,t,e,i,o,s)}function m(t,e,n,r,i,o,s){return d(e^n^r,t,e,i,o,s)}function y(t,e,n,r,i,o,s){return d(n^(e|~r),t,e,i,o,s)}function v(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,f,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,i,o,s,a,u,l){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,i,o,s,a,u,l,c){var h=t("./helpers");function f(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var n,r,i,o=Array(80),s=1732584193,a=-271733879,u=-1732584194,l=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var f=s,g=a,m=u,y=l,v=c,b=0;b<80;b++){o[b]=b<16?t[h+b]:p(o[b-3]^o[b-8]^o[b-14]^o[b-16],1);var w=d(d(p(s,5),(w=a,r=u,i=l,(n=b)<20?w&r|~w&i:!(n<40)&&n<60?w&r|w&i|r&i:w^r^i)),d(d(c,o[b]),(n=b)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=l,l=u,u=p(a,30),a=s,s=w}s=d(s,f),a=d(a,g),u=d(u,m),l=d(l,y),c=d(c,v)}return Array(s,a,u,l,c)}function d(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,f,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,i,o,s,a,u,l,c){function h(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function f(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),i=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),o=new Array(64);t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var s,a,u=0;u<t.length;u+=16){for(var l=i[0],c=i[1],f=i[2],d=i[3],m=i[4],y=i[5],v=i[6],b=i[7],w=0;w<64;w++)o[w]=w<16?t[w+u]:h(h(h((a=o[w-2],p(a,17)^p(a,19)^g(a,10)),o[w-7]),(a=o[w-15],p(a,7)^p(a,18)^g(a,3))),o[w-16]),n=h(h(h(h(b,p(a=m,6)^p(a,11)^p(a,25)),m&y^~m&v),r[w]),o[w]),s=h(p(s=l,2)^p(s,13)^p(s,22),l&c^l&f^c&f),b=v,v=y,y=m,m=h(d,n),d=f,f=c,c=l,l=h(n,s);i[0]=h(l,i[0]),i[1]=h(c,i[1]),i[2]=h(f,i[2]),i[3]=h(d,i[3]),i[4]=h(m,i[4]),i[5]=h(y,i[5]),i[6]=h(v,i[6]),i[7]=h(b,i[7])}return i}var d=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},g=function(t,e){return t>>>e};e.exports=function(t){return d.hash(t,f,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,i,o,s,a,u,l){n.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,l=u>>1,c=-7,h=n?i-1:0,f=n?-1:1;for(i=t[e+h],h+=f,o=i&(1<<-c)-1,i>>=-c,c+=a;0<c;o=256*o+t[e+h],h+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=f,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(i?-1:1);s+=Math.pow(2,r),o-=l}return(i?-1:1)*s*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var s,a,u=8*o-i-1,l=(1<<u)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,d=r?1:-1;for(o=e<0||0===e&&1/e<0?1:0,e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(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),l<=s+c?(a=0,s=l):1<=s+c?(a=(e*r-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));8<=i;t[n+f]=255&a,f+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;0<u;t[n+f]=255&s,f+=d,s/=256,u-=8);t[n+f-d]|=128*o}}).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,i,o,s,a,u,l){var c,h,f;function d(){}(t=e.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,f="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(t){return window.setImmediate(t)}:f?(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=d,t.addListener=d,t.once=d,t.off=d,t.removeListener=d,t.removeAllListeners=d,t.emit=d,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)},146:(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 i="http://www.w3.org/2000/xmlns/",o="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"},u=function(t){return t instanceof HTMLElement||t instanceof SVGElement},l=function(t){if(!u(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},c=function(t){return new Promise((function(e,n){u(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},f=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(e.length),i=new Uint8Array(r),o=0;o<e.length;o++)i[o]=e.charCodeAt(o);return new Blob([r],{type:n})},d={},p=null,g=function(t,e){var n=e||{},r=n.selectorRemap,i=n.modifyStyle,o=n.modifyCss,u=n.fonts,l=n.excludeUnusedCss,c=o||function(t,e){return(r?r(t):t)+"{"+(i?i(e):e)+"}\n"},h=[],f=void 0===u,g=u||[];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(f&&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 i,o,u=r.startsWith("../")?e+"/../"+r:r.startsWith("./")?e+"/."+r:r;return{text:t.cssText,format:(i=u,o=Object.keys(a).filter((function(t){return i.indexOf("."+t)>0})).map((function(t){return a[t]})),o?o[0]:(console.error("Unknown font format for "+i+". Fonts may not be working correctly."),"application/octet-stream")),url:u}}}(e,r);n&&g.push(n)}else l||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(d[t.url])return e(d[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),i=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";d[t.url]=i,e(i)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),d[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("")}))}(g).then((function(t){return h.join("\n")+t}))},m=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};r.prepareSvg=function(t,e,n){l(t);var r=e||{},s=r.left,a=void 0===s?0:s,u=r.top,c=void 0===u?0:u,f=r.width,d=r.height,p=r.scale,m=void 0===p?1:p,y=r.responsive,v=void 0!==y&&y,b=r.excludeCss,w=void 0!==b&&b;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 i=document.createElement("canvas"),o=new Image;o.crossOrigin="anonymous",o.src=n,o.onerror=function(){return r(new Error("Could not load "+n))},o.onload=function(){i.width=o.width,i.height=o.height,i.getContext("2d").drawImage(o,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",i.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 i=t.getBBox(),o=i.x,s=i.y;return{width:o+i.width,height:s+i.height}}}(t,r,f,d),u=s.width,l=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,u,l].join(" ")),r.getAttribute("xmlns")||r.setAttributeNS(i,"xmlns",o),r.getAttribute("xmlns:xlink")||r.setAttributeNS(i,"xmlns:xlink","http://www.w3.org/1999/xlink"),v?(r.removeAttribute("width"),r.removeAttribute("height"),r.setAttribute("preserveAspectRatio","xMinYMin meet")):(r.setAttribute("width",u*m),r.setAttribute("height",l*m)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(i,"xmlns","svg"===t.tagName?o:"http://www.w3.org/1999/xhtml")})),!w)return g(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var i=document.createElement("defs");i.appendChild(e),r.insertBefore(i,r.firstChild);var o=document.createElement("div");o.appendChild(r);var s=o.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:u,height:l};n(s,u,l)}));var y=document.createElement("div");y.appendChild(r);var b=y.innerHTML;if("function"!=typeof n)return{src:b,width:u,height:l};n(b,u,l)}))},r.svgAsDataUri=function(t,e,n){return l(t),r.prepareSvg(t,e).then((function(t){var e=t.src,r=t.width,i=t.height,o="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 "&#160;">]>'+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(o,r,i),o}))},r.svgAsPngUri=function(t,e,n){l(t);var i=e||{},o=i.encoderType,s=void 0===o?"image/png":o,a=i.encoderOptions,u=void 0===a?.8:a,c=i.canvg,h=function(t){var e=t.src,r=t.width,i=t.height,o=document.createElement("canvas"),a=o.getContext("2d"),l=window.devicePixelRatio||1;o.width=r*l,o.height=i*l,o.style.width=o.width+"px",o.style.height=o.height+"px",a.setTransform(l,0,0,l,0,0),c?c(o,e):a.drawImage(e,0,0);var h=void 0;try{h=o.toDataURL(s,u)}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,o.width,o.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(f(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 i=f(e),o=URL.createObjectURL(i);r.href=o,r.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(o)}))}}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 i=m();return c(t).then((function(t){return r.svgAsDataUri(t,n||{})})).then((function(t){return r.download(e,t,i)}))},r.saveSvgAsPng=function(t,e,n){var i=m();return c(t).then((function(t){return r.svgAsPngUri(t,n||{})})).then((function(t){return r.download(e,t,i)}))}}()},72: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 o={},s=[],a=0;a<t.length;a++){var u=t[a],l=r.base?u[0]+r.base:u[0],c=o[l]||0,h="".concat(l," ").concat(c);o[l]=c+1;var f=n(h),d={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==f)e[f].references++,e[f].updater(d);else{var p=i(d,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,references:1})}s.push(h)}return s}function i(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,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var a=n(o[s]);e[a].references--}for(var u=r(t,i),l=0;l<o.length;l++){var c=n(o[l]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=u}}},659: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}},56:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},825: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 i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113: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))}}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}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.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),n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>Vr,addContextMenu:()=>hi,createMonomerLibraryForPolyTool:()=>ci,demoOligoPattern:()=>Zr,demoOligoStructure:()=>ti,demoTranslateSequence:()=>Xr,getCodeToWeightsMap:()=>Yr,getMolfileFromGcrsSequence:()=>Jr,getPolyToolConvertEditor:()=>ii,getTranslationHelper:()=>zr,linkStrands:()=>Qr,oligoPatternApp:()=>Gr,oligoStructureApp:()=>Wr,oligoToolkitApp:()=>jr,oligoTranslatorApp:()=>qr,polyToolColumnChoice:()=>li,polyToolConvert2:()=>oi,polyToolConvertTopMenu:()=>ri,polyToolEnumerateChemTopMenu:()=>ai,polyToolEnumerateHelmTopMenu:()=>si,ptEnumeratorChemApp:()=>di,ptEnumeratorHelmApp:()=>fi,translateOligonucleotideSequence:()=>ei,validateSequence:()=>Kr});const t=grok,e=DG;class i{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=i._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new i(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,o=0;for(;e-o>=4;)n._data[r++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[r]=(255&t[o+2])<<16),e-o==2&&(n._data[r]|=(255&t[o+1])<<8),e-o==1&&(n._data[r]|=255&t[o]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new i(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=i._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=i._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let o=0;for(;o<r-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let o=Math.floor(t/32);o<r;o++){let r=e?this._data[o]:~this._data[o];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=i._firstOnBit[255&r];if(n>=0)return(t=n+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}var o,s,a,u,l,c,h;function f(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,i=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach((([t,r])=>{const o=n[r];Object.entries(e).forEach((([e,r])=>{i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[r]}))})),(t,e)=>1-i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let i=0;const o=t.length,s=r.length,a=Math.ceil(Math.max(o,s)*(1-n));o!==s&&(i=Math.abs(o-s));let u=0;for(let n=0;n<Math.min(o,s);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>a))return 1;return u+=i,u/=Math.max(o,s),u}}i._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),i._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),i._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(o||(o={})),function(t){t.Euclidean="Euclidean"}(s||(s={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(a||(a={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(u||(u={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(l||(l={})),function(t){t.Difference="Difference"}(c||(c={})),function(t){t.CommonItems="Common Items"}(h||(h={}));const d=new Uint32Array(65536),p={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var g;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(g||(g={}));const m={[g.HAMMING]:f,[g.LEVENSHTEIN]:function(){return(t,e)=>((t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,s=0,a=n,u=n;for(;u--;)d[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=d[e.charCodeAt(u)];const n=t|s;t|=(t&o)+o^o,s|=~(t|o),o&=t,s&i&&a++,o&i&&a--,s=s<<1|1,o=o<<1|~(n|s),s&=n}for(u=n;u--;)d[t.charCodeAt(u)]=0;return a})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],s=Math.ceil(n/32),a=Math.ceil(r/32);for(let t=0;t<s;t++)o[t]=-1,i[t]=0;let u=0;for(;u<a-1;u++){let s=0,a=-1;const l=32*u,c=Math.min(32,r)+l;for(let e=l;e<c;e++)d[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=d[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,u=i[t/32|0]>>>t&1,l=n|s,c=((n|u)&a)+a^a|n|u;let h=s|~(c|a),f=a&c;h>>>31^r&&(o[t/32|0]^=1<<t),f>>>31^u&&(i[t/32|0]^=1<<t),h=h<<1|r,f=f<<1|u,a=f|~(l|h),s=h&l}for(let e=l;e<c;e++)d[t.charCodeAt(e)]=0}let l=0,c=-1;const h=32*u,f=Math.min(32,r-h)+h;for(let e=h;e<f;e++)d[t.charCodeAt(e)]|=1<<e;let p=r;for(let t=0;t<n;t++){const n=d[e.charCodeAt(t)],s=o[t/32|0]>>>t&1,a=i[t/32|0]>>>t&1,u=n|l,h=((n|a)&c)+c^c|n|a;let f=l|~(h|c),g=c&h;p+=f>>>r-1&1,p-=g>>>r-1&1,f>>>31^s&&(o[t/32|0]^=1<<t),g>>>31^a&&(i[t/32|0]^=1<<t),f=f<<1|s,g=g<<1|a,c=g|~(u|f),l=f&u}for(let e=h;e<f;e++)d[t.charCodeAt(e)]=0;return p})(t,e)})(t,e)/Math.max(t.length,e.length)},[g.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...p,...t};Object.entries(o).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const s=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const a=new Array(t.length+1).fill(!1),u=new Array(t.length+1).fill(!1);let l=0,c=1;for(let e=1;e<t.length+1;e++)s[0][e]=-r-(e-1)*r,s[1][e]=0;s[0][0]=0;for(let h=1;h<o.length+1;h++){s[c][0]=-r-(h-1)*r;for(let f=1;f<t.length+1;f++){const d=s[l][f-1]+i[e[t.charCodeAt(f-1)]][e[o.charCodeAt(h-1)]],p=s[l][f]-(a[f]||1===h||h===o.length?r:n),g=s[c][f-1]-(u[f-1]||1===f||f===t.length?r:n);s[c][f]=Math.max(d,g,p),s[c][f]===d?(a[f]=!1,u[f]=!1):s[c][f]===g?(a[f]=!1,u[f]=!0):(a[f]=!0,u[f]=!1)}l=c,c=(c+1)%2}const h=Math.min(t.length,o.length);return(h-s[l][t.length])/h}},[g.MONOMER_CHEMICAL_DISTANCE]:f};a.Tanimoto,a.Dice,a.Asymmetric,a.BraunBlanquet,a.Cosine,a.Kulczynski,a.McConnaughey,a.RogotGoldberg,a.Russel,a.Sokal,a.Hamming,a.Euclidean,a.Tanimoto,a.Dice,a.Asymmetric,a.BraunBlanquet,a.Cosine,a.Kulczynski,a.McConnaughey,a.RogotGoldberg,a.Russel,a.Sokal,a.Hamming,a.Euclidean,a.Tanimoto,a.Dice,a.Cosine,a.Tanimoto,a.Asymmetric,a.Cosine,a.Sokal,g.HAMMING,g.LEVENSHTEIN,g.MONOMER_CHEMICAL_DISTANCE,g.NEEDLEMANN_WUNSCH;const y={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},v="p",b=new RegExp(`[rd]\\((\\w)\\)${v}?`,"g"),w=wu;var C,A,x,_,E,T=n.n(w);class S{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class I extends S{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}(E=C||(C={})).FASTA="fasta",E.SEPARATOR="separator",E.HELM="helm",E.CUSTOM="custom",(_=A||(A={})).DNA="DNA",_.RNA="RNA",_.PT="PT",_.UN="UN",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"}(x||(x={}));const N=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,M=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"])}}},O=[new S(A.PT,M.fasta.peptide,.5),new S(A.DNA,M.fasta.dna,.55),new S(A.RNA,M.fasta.rna,.55)],L={[C.FASTA]:"-",[C.SEPARATOR]:"",[C.HELM]:"*"};class B extends Float32Array{}function P(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}class R{static makePalette(t,e=!1,n=R){const r={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[i][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}R.undefinedColor="rgb(100,100,100)",R.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 D extends R{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,D)),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,D)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new D({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 D.aaSynonyms?D.aaSynonyms[t]:t;return super.get(e)}}D.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class F{static getPalette(t="grok"){switch(t){case"grok":return D.GrokGroups;case"lesk":return D.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const i of t)"("==i?e++:")"==i?e--:e?n+=i:r+=i;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,i]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,i,1]:[this.undefinedColor,r,i,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,i,2]:[this.undefinedColor,r,i,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,i,3]:[this.undefinedColor,r,i,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,i,4]:[this.undefinedColor,r,i,4]}return[this.undefinedColor,r,i,0]}}F.SemType="Aminoacids",F.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",F.undefinedColor="rgb(100,100,100)",F.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"},F.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"},F.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(*)*"},F.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 H{}function k(t,n=!0){if(null==t)return"rgb(100,100,100)";const r=e.Color.fromHtml(t);if(n){const t=e.Color.g(r),n=e.Color.r(r),i=e.Color.b(r),o=Math.sqrt(Math.pow(0-n,2)+Math.pow(0-t,2)+Math.pow(0-i,2));if(o>210)return`rgb(${n/o*210},${t/o*210},${i/o*210})`}return e.Color.toRgb(r)}H.SemType="Nucleotides",H.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",H.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class U{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 V{}class j extends V{static buildPalette(){return rt().then((t=>{t.awaitLoaded().then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{j.customMonomerColors={},j.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]=k(n.meta.colors.default.background,!1))}}}))}))})),[].concat(...Object.values(R.colourPalette))}get(t,e){const n=j.customMonomerColors[t],r=e??"PEPTIDE";if(n&&n[r])return n[r];const i=U.hashCode(t)%j.palette.length;return k(j.palette[i])}}j.palette=j.buildPalette(),j.customMonomerColors={},j.polymerTypes=[];class q{get length(){return this.mList.length}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:""}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class G{get length(){return this.seqS.length}isGap(t){return this.getOriginal(t)===L[C.FASTA]}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");return this.isGap(t)?"":this.seqS[t]}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.seqS[t]}constructor(t){this.seqS=t}}const W=t=>{const e=T()(t.toString().matchAll(N)).map((t=>t[2]??t[1])).toArray();return new q(e,L[C.FASTA])},z=t=>t?new G(t):new q([],L[C.FASTA]);function Y(t,e=void 0){return n=>{if(n){let r;const i=new RegExp(String.raw`"-"|'-'|[^${t}]+`,"g");if(void 0!==e){i.lastIndex=0,r=new Array(Math.ceil(e));let t=null,o=0;for(;null!==(t=i.exec(n))&&o<e;)r[o++]=t[0].replace('"-"',"").replace("'-'","");r.splice(o)}else r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e);return new q(r,L[C.SEPARATOR])}return new q([],L[C.SEPARATOR])}}const K=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,J=/\[([^\[\]]+)]/g,Q=t=>{K.lastIndex=0;const e=K.exec(t.toString()),n=e?e[2]:null,r=n?n.split("."):[];return new q(r.map((t=>{J.lastIndex=0;const e=J.exec(t);return e&&e.length>=2?e[1]:t})),L[C.HELM])};function X(t,e,n="-"){const r=e.map((e=>{const r=function(t,e,n="-"){const r=new Set([...new Set(Object.keys(t)),...e]);r.delete(n);const i=[],o=[];for(const n of r)i.push(n in t?t[n]:0),o.push(e.has(n)?1:0);const s=new B(i),a=new B(o);return function(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r];return n}(s,a)/(P(s)*P(a))}(t,e.alphabet,n);return new I(e,t,r)}));let i;const o=Math.max(...r.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return i=o>0?r.find((t=>t.similarity===o)).name:A.UN,i}const Z=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};class tt{constructor(t){if(this.notationProvider=null,this._splitter=null,this.cached=!0,this._splitted=null,this.columnVersion=null,this._stats=null,this._maxLength=null,this._posList=null,this._joiner=void 0,t.type!==e.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${e.TYPE.STRING}'.`);this._column=t;const n=this._column.meta.units;if(null==n)throw new Error("Units are not specified in column");if(this._units=n,this._notation=this.getNotation(),this._defaultGapOriginal=this.isFasta()?L[C.FASTA]:this.isHelm()?L[C.HELM]:L[C.SEPARATOR],!this.column.tags.has(x.aligned)||!this.column.tags.has(x.alphabet)||!this.column.tags.has(x.alphabetIsMultichar)&&!this.isHelm()&&this.alphabet===A.UN)if(this.isFasta())tt.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag(x.separator);tt.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.meta.units}'.`);tt.setUnitsToHelmColumn(this)}if(!this.column.tags.has(x.alphabetIsMultichar))if(this.isHelm())this.column.setTag(x.alphabetIsMultichar,"true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '${x.alphabetIsMultichar}' is mandatory.`);this.column.meta.units===C.CUSTOM&&(this.notationProvider=this.column.temp[Z.notationProvider]??null),this.columnVersion=this.column.version}static setUnitsToFastaColumn(t){if(t.column.semType!==e.SEMTYPE.MACROMOLECULE||t.column.meta.units!==C.FASTA)throw new Error(`The column of notation '${C.FASTA}' must be '${e.SEMTYPE.MACROMOLECULE}'.`);t.column.meta.units=C.FASTA,tt.setTags(t)}static setUnitsToSeparatorColumn(t,n){if(t.column.semType!==e.SEMTYPE.MACROMOLECULE||t.column.meta.units!==C.SEPARATOR)throw new Error(`The column of notation '${C.SEPARATOR}' must be '${e.SEMTYPE.MACROMOLECULE}'.`);if(!n)throw new Error(`The column of notation '${C.SEPARATOR}' must have the separator tag.`);t.column.meta.units=C.SEPARATOR,t.column.setTag(x.separator,n),tt.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==e.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${C.HELM}' must be '${e.SEMTYPE.MACROMOLECULE}'`);t.column.meta.units=C.HELM,tt.setTags(t)}static setTags(t){const e=t.column.meta.units;if([C.FASTA,C.SEPARATOR].includes(e)){if(!t.column.getTag(x.alphabet)&&0===Object.keys(t.stats.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag(x.aligned);null===e&&(e=t.stats.sameLength?"SEQ.MSA":"SEQ",t.column.setTag(x.aligned,e));let n=t.column.getTag(x.alphabet);if(null===n&&(n=X(t.stats.freq,O),t.column.setTag(x.alphabet,n)),n===A.UN){const e=Object.keys(t.stats.freq).length,n=Object.keys(t.stats.freq).some((t=>t.length>1));t.column.setTag(x.alphabetSize,e.toString()),t.column.setTag(x.alphabetIsMultichar,n?"true":"false")}}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const t=this.column.getTag(x.separator)??void 0;if(this.notation===C.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag(x.aligned);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag(x.alphabet);if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(x.isHelmCompatible)}getAlphabetSize(){if(this.notation==C.HELM||this.alphabet==A.UN){const t=this.column.getTag(x.alphabetSize);let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case A.PT:return 20;case A.DNA:case A.RNA:return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===C.HELM||this.alphabet===A.UN&&"true"===this.column.getTag(x.alphabetIsMultichar)}getSplitted(t,e){if(this.cached&&void 0===e){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let e=this._splitted[t]?this._splitted[t].deref():void 0;if(!e){const n=this.column.get(t);e=this.splitter(n),this._splitted[t]=new WeakRef(e)}return e}{const n=this.column.get(t);return this.getSplitter(e)(n)}}async getHelm(t,e){const n=this.column.get(t);return this.notationProvider?(await this.notationProvider.getHelm(this.column,e)).get(t):this.convertToHelm(n)}get stats(){if(null===this._stats){const t={};let e=!0,n=null;const r=this.column.length;for(let i=0;i<r;++i){const r=this.getSplitted(i);null==n?n=r.length:r.length!==n&&(e=!1);for(let e=0;e<r.length;++e){const n=r.getCanonical(e);n in t||(t[n]=0),t[n]+=1}}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:Math.max(...T().count(0).take(this.column.length).map((t=>this.getSplitted(t).length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(x.positionNames);this._posList=t?t.split(", ").map((t=>t.trim())):T().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===C.FASTA}isSeparator(){return this.notation===C.SEPARATOR}isHelm(){return this.notation===C.HELM}isRna(){return this.alphabet===A.RNA}isDna(){return this.alphabet===A.DNA}isPeptide(){return this.alphabet===A.PT}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||t===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(C.FASTA))return C.FASTA;if(this.units.toLowerCase().startsWith(C.SEPARATOR))return C.SEPARATOR;if(this.units.toLowerCase().startsWith(C.HELM))return C.HELM;if(this.units.toLowerCase().startsWith(C.CUSTOM))return C.CUSTOM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(t,n,r,i){const o=this.column,s=t.toLowerCase()+"("+o.name+")",a=r??o.dataFrame?.columns.getUnusedName(s)??s,u=e.Column.fromList("string",a,i??new Array(this.column.length).fill(""));if(u.semType=e.SEMTYPE.MACROMOLECULE,u.meta.units=t,t===C.SEPARATOR){if(!n)throw new Error(`Notation '${C.SEPARATOR}' requires separator value.`);u.setTag(x.separator,n)}u.setTag(e.TAGS.CELL_RENDERER,t===C.HELM?"helm":"sequence");const l=o.getTag(x.aligned);l&&u.setTag(x.aligned,l);let c=o.getTag(x.alphabet);c||this.notation!==C.HELM||t===C.HELM||(c=A.UN),null!=c&&u.setTag(x.alphabet,c);let h=o.getTag(x.alphabetSize);null!=c&&h&&u.setTag(x.alphabetSize,h);const f=o.getTag(x.alphabetIsMultichar);return null!=c&&void 0!==f&&u.setTag(x.alphabetIsMultichar,f),t==C.HELM&&(h=this.getAlphabetSize().toString(),u.setTag(x.alphabetSize,h)),u}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static getNewColumn(t){const e=tt.forColumn(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),[C.FASTA,C.SEPARATOR,C.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,n,r){if(!tt.unitsStringIsValid(r))throw new Error("Invalid format of 'units' parameter");const i=e.Column.fromList("string",n,new Array(t).fill(""));return i.semType=e.SEMTYPE.MACROMOLECULE,i.meta.units=r,i}getSplitter(t){let e=null;if(e=this.notationProvider?this.notationProvider.splitter:null,e)return e;if(this.units.toLowerCase().startsWith(C.FASTA))return null===this.column.getTag(x.alphabet)||this.getAlphabetIsMultichar()?W:z;if(this.units.toLowerCase().startsWith(C.SEPARATOR))return Y(this.separator,t);if(this.units.toLowerCase().startsWith(C.HELM))return Q;throw new Error(`Unexpected units ${this.units} .`)}split(t){return this.splitter(t)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return g.HAMMING;switch(this.alphabet){case A.DNA:case A.RNA:case A.PT:}return g.LEVENSHTEIN}getDistanceFunction(){return m[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(x.isHelmCompatible))return"true"===this.column.getTag(x.isHelmCompatible);const t=(await rt()).getMonomerLib().getMonomerSymbolsByType("PEPTIDE"),e=new Set(t),n=(Y(this.separator),new Set),r=this.column.length,i=this.column.getRawData();for(let t=0;t<r;++t){const r=i[t];if(!(r in n)){n.add(r);const i=this.getSplitted(t);for(let t=0;t<i.length;++t){const n=i.getCanonical(t);if(!e.has(n))return this.column.setTag(x.isHelmCompatible,"false"),!1}}}return this.column.setTag(x.isHelmCompatible,"true"),!0}get splitter(){return null===this._splitter&&(this._splitter=this.getSplitter()),this._splitter}toFasta(t){return t===C.FASTA}toSeparator(t){return t===C.SEPARATOR}toHelm(t){return t===C.HELM}convertHelmToFastaSeparator(t,e,n,r){r||(r=this.toFasta(e)?L[C.FASTA]:L[C.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const i=t.startsWith("RNA"),o=this.splitter(t),s=[];for(let t=0;t<o.length;++t){let n=o.getOriginal(t);if(i&&(n=n.replace(b,"")),n===L[C.HELM])s.push(r);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";s.push(t)}else s.push(n)}return s.join(n)}convert(t,e){const n=this.getJoiner({notation:t,separator:e}),r=this.getNewColumn(t,e);return r.init((t=>{const e=this.getSplitted(t);return n(e)})),r}getRegion(t,e,n){const r=this.getNewColumn(this.notation,this.separator);r.name=n;const i=t??0,o=e??this.maxLength-1,s=this.getJoiner(),a=o-i+1,u=L[this.notation];r.init((t=>{const e=this.getSplitted(t),n=new Array(a);for(let t=0;t<a;++t){const r=i+t;n[t]=r<e.length?e.getOriginal(r):u}return s(new q(n,u))}));const l=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(a);for(let t=0;t<a;++t){const r=i+t;n[t]=r<e.length?e[r]:"?"}return n.join(", ")},c=this.column.getTag(x.positionNames);c&&r.setTag(x.positionNames,l(c));const h=this.column.getTag(x.positionLabels);return h&&r.setTag(x.positionLabels,l(h)),r}get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(t){const e=t?t.notation:this.notation,n=t?t.separator:this.separator;let r;const i=this;switch(e){case C.FASTA:r=function(t){return i.joinToFasta(t,i.isHelm())};break;case C.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${e}'.`);r=function(t){return et(t,n,i.isHelm())};break;case C.HELM:{const t=i.alphabet===A.DNA||i.alphabet===A.RNA,e=i.getHelmWrappers();r=function(n){return nt(n,e,t)};break}default:throw new Error(`Unexpected notation '${e}'.`)}return r}getConverter(t,e=void 0){if(t===C.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${C.SEPARATOR}'.`);const n=this;if(t===C.FASTA)return function(t){return n.convertToFasta(t)};if(t===C.HELM)return function(t){return n.convertToHelm(t)};if(t===C.SEPARATOR)return function(t){return n.convertToSeparator(t,e)};throw new Error}static forColumn(t){let e=t.temp[Z.seqHandler];return e&&e.columnVersion===t.version||(e=t.temp[Z.seqHandler]=new tt(t)),e}joinToFasta(t,e){const n=new Array(t.length);for(let r=0;r<t.length;++r){const i=t.getOriginal(r);let o=t.getOriginal(r);e&&(o=o.replace(b,"$1")),""===i?o=L[C.FASTA]:i===v?o="":o.length>1&&(o="["+o+"]"),n[r]=o}return n.join("")}convertToFasta(t){const e=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(t):e(t);return this.joinToFasta(n,this.isHelm())}convertToSeparator(t,e){return et(this.isHelm()?this.splitterAsHelmNucl(t):this.splitter(t),e,this.isHelm())}convertToHelm(t){if(this.notation==C.HELM)return t;const e=this.getHelmWrappers(),n=t.startsWith("DNA")||t.startsWith("RNA");return nt(this.splitter(t),e,n)}splitterAsHelmNucl(t){const e=this.splitter(t),n=new Array(e.length),r=t.startsWith("DNA"),i=t.startsWith("RNA");for(let t=0;t<e.length;++t){let o=e.getOriginal(t);(r||i)&&(o=o.replace(b,"$1"),o=o===v?null:o),n[t]=o||null}return new q(n.filter((t=>!!t)),L[C.HELM])}getRendererBack(t,e){const n=this.column.temp;let r=n.rendererBack;return r||(r=n.rendererBack=this.notationProvider.createCellRendererBack(t,e)),r}}function et(t,e,n){const r=new Array(t.length);for(let e=0;e<t.length;++e){const i=t.getCanonical(e);let o=t.getOriginal(e);n&&(o=o.replace(b,"$1")),""===i?o=L[C.SEPARATOR]:i===v&&(o=""),r[e]=o}return r.join(e)}function nt(t,e,n){const[r,i,o,s]=e,a=new Array(t.length);for(let e=0;e<t.length;++e){const r=t.getCanonical(e);let s=t.getOriginal(e);""===r?s=L[C.HELM]:(n&&(s=s.replace(b,"$1")),s=1===s.length?`${i}${s}${o}`:`${i}[${s}]${o}`),a[e]=s}return`${r}${a.join(".")}${s}`}async function rt(){const t=e.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()}class it{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 ot="System:AppData/SequenceTranslator/monomers-sample",st="pattern-app-data.json",at="formats-to-helm.json",ut="codes-to-symbols.json",lt="linkers.json",ct=["A","G","C","U"];var ht;function ft(t){return t.sort(((t,e)=>e.length-t.length))}function dt(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 pt(e,n,r="Oligo app"){try{return await e()}catch(e){const n=e.hasOwnProperty("message")?e.message:e.toString();throw t.shell.error(`${r} error: `+n),e}finally{n&&n()}}!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(ht||(ht={}));class gt{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(t){if(t===ht.HELM)return this.sequence.length;const e=["r","d"],n=ft(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&&ct.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&ct.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 mt{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function yt(e){const n=await Promise.all([st,at,ut,lt].map((n=>async function(e,n){const r=e.endsWith("/")?`${e}${n}`:`${e}/${n}`;try{const e=await t.dapi.files.readAsText(r);return JSON.parse(e)}catch(t){console.error(`Error loading json from '${r}':`,t)}}(e,n))));return new mt(n[0],n[1],n[2],n[3])}class vt{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===ht.HELM)return;const r=this.jsonData.codesToSymbolsDict[n],i=Object.keys(r).filter((e=>r[e]===t.symbol));e[n]=i.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 e.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),i=r.meta?.molecularWeight;t.set(e,i)}))})),t}}const bt="<?>",wt=(t,e)=>e.length-t.length;class Ct{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(wt);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(wt)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(At(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=At(Array.from(new Set(Object.values(e.phosphateBackbone))).sort(wt));return new RegExp(`p.(${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===ht.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(wt)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(At(e)+"|\\([^()]*\\)|.","g")}}function At(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const xt={LEFT:"RNA1{",RIGHT:"}$$$$"};class _t{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new Ct(this.th)}convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===ht.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===ht.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(At(Object.values(xt)),"g");let r=t.replace(n,"");const i=this.formats.getHelmToFormatDict(e),o=this.formats.getTargetFormatHelmCodes(e),s=this.formats.getTargetFormatHelmCodesRegExp(e);return r=r.replace(s,(t=>o.includes(t)?i[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,bt).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),i=this.formats.getFormatRegExp(e),o=this.formats.getPhosphateHelmCodesRegExp(e);let s=t?t.replace(i,(t=>r.includes(t)?n[t]+".":"?")):"";return s=s.replace(/\?+/g,`${bt}.`),s=s.slice(0,-1),"p"===s[s.length-1]&&(s=s.slice(0,-1)),s=s.replace(o,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${xt.LEFT+s+xt.RIGHT}`}}class Et{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 ht.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 i=t[r];n[r]=e.getInvalidCodeIndex(i)}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=ft(this.libWrapper.getCodesByFormat(n));let i=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){i=e+1;break}r.some((e=>e===t.slice(i,i+e.length)))&&e.push(n)}return e}}const Tt=ui,St=$;var It=n.n(St);function Nt(t,e){let n=0;const r=e.createFormatDetector(t).getFormat();null!==r&&(n=new gt(t,e).getInvalidCodeIndex(r));const i=n<0||""===t,o=Tt.span([]);It()(o).css("-webkit-text-fill-color","var(--grey-6)");const s=Tt.span([]);return It()(s).css("-webkit-text-fill-color","red"),i?o.innerHTML=t:(o.innerHTML=t.slice(0,n),s.innerHTML=t.slice(n)),[o,s]}class Mt extends e.Package{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}constructor(t={debug:!1}){super(),this.highlightInvalidSubsequence=t=>Nt(t,this),super._logger=new it(super.logger,t.debug)}async initLibData(){return this.initPromise||(this.initPromise=(async()=>{let e=(await this.getSettings()).MonomersPath;e&&await t.dapi.files.exists(e)||(this.logger.warning(`Monomers path '${e}' not found. Fallback to monomers sample path '${ot}'.`),e=ot),[this._jsonData,this._monomerLib]=await Promise.all([yt(e),Ot(e)]),this._monomerLibWrapper=new vt(this.monomerLib,this.jsonData)})()),this.initPromise}async getTranslationHelper(){return await t.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(t){return new gt(t,this)}createFormatConverter(t,e){return new _t(t,e,this)}createFormatDetector(t){return new Et(t,this)}}async function Ot(t){const n=e.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const e=await rt();return await e.readLibrary(t,"monomer-lib.json")}finally{n.close()}}class Lt{constructor(t,e){this.appName=t,this.parentAppName=e}async getAppView(){const n=e.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),r=t.shell.v?.root;r&&Tt.setUpdateIndicator(r,!0);try{return await this.constructView()}finally{n.close(),r&&Tt.setUpdateIndicator(r,!1)}}}class Bt extends Lt{constructor(t){super(t),this.view=e.View.create(),this.configureView()}async constructView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${Vr.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 e=t.shell.windows;e.showProperties=!1,e.showToolbox=!1,e.showHelp=!1}getView(){return this.view}}const Pt=["SS","AS"],Rt={SS:"Sense strand",AS:"Anti sense"},Dt=["3'","5'"],Ft="OligoToolkit";var Ht,kt,Ut,$t;!function(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(Ht||(Ht={})),function(t){t.PATTERN_NAME="patternName",t.PATTERN_COMMENT="patternComment",t.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(kt||(kt={})),function(t){t.PATTERN_CONFIG="patternConfig",t.AUTHOR_ID="authorID",t.DATE="date"}(Ut||(Ut={})),function(t){t.CREATE="create",t.MODIFY="modify"}($t||($t={}));const Vt=[Ht.IS_ANTISENSE_STRAND_INCLUDED,Ht.NUCLEOTIDE_SEQUENCES,Ht.PHOSPHOROTHIOATE_LINKAGE_FLAGS,Ht.STRAND_TERMINUS_MODIFICATIONS],jt=(kt.PATTERN_NAME,kt.PATTERN_COMMENT,kt.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:""}),qt="2024-01-01T18:00:00.000Z";class Gt extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class Wt extends Error{constructor(t){super(t),this.name="PatternExistsError"}}var zt=n(802),Yt=n.n(zt);class Kt{constructor(t){this.th=t,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const t=await Vr.getTranslationHelper(),e=new Kt(t);e.currentUserName=await e.fetchCurrentUserName(),e.currentUserId=await e.fetchCurrentUserId();const n=await 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 Gt(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new Wt(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(e){if(null===e||""===e)return null;try{const n=await t.dapi.userDataStorage.getValue(Ft,e,!1);return JSON.parse(n)}catch{return null}}async getPatternConfig(t){if(""===t||null===t)return null;const e=await this.getPatternRecordByHash(t);return null===e?null:e[Ut.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=jt;return t[Ut.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return jt[Ut.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(e){return{[Ut.PATTERN_CONFIG]:e,[Ut.AUTHOR_ID]:await t.dapi.users.current().then((t=>t.id))}}getHash(t){const e=Vt.reduce(((e,n)=>(e[n]=t[n],e)),{});return Yt().sha1(e)}async savePatternToUserStorage(e){const n=e.getPatternConfig();try{const r=this.getHash(n);this.validatePatternUniqueness(r);const i=n[kt.PATTERN_NAME];this.validatePatternNameUniqueness(i);const o=await this.getRecordFromPattern(n),s=(new Date).toISOString();o[Ut.DATE]={[$t.CREATE]:s,[$t.MODIFY]:s};const a=JSON.stringify(o);await t.dapi.userDataStorage.postValue(Ft,r,a,!1),this.currentUserPatternNameToHash.set(i,r),e.selectAuthor(this.getCurrentUserAuthorshipCategory()),e.updatePatternList(),e.requestPatternLoad(r),e.updateUrlState(r)}catch(t){if(t instanceof Gt||t instanceof Wt)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(e){const n=e.getPatternConfig(),r=n[kt.PATTERN_NAME],i=this.currentUserPatternNameToHash.get(r);if(void 0===i)throw new Error("Old hash is undefined");const o=this.getHash(n),s=await this.getRecordFromPattern(n),a=(new Date).toISOString();s[Ut.DATE]={[$t.MODIFY]:a};const u=await t.dapi.userDataStorage.getValue(Ft,i,!1),l=JSON.parse(u);void 0!==l[Ut.DATE]&&null!=l[Ut.DATE][$t.CREATE]&&(s[Ut.DATE][$t.CREATE]=l[Ut.DATE][$t.CREATE]);const c=JSON.stringify(s);await t.dapi.userDataStorage.postValue(Ft,o,c,!1),await t.dapi.userDataStorage.remove(Ft,i,!1),this.currentUserPatternNameToHash.set(r,o),e.requestPatternLoad(o),e.updateUrlState(o)}async deletePattern(e,n){const r=this.currentUserPatternNameToHash.get(e);if(e===this.getDefaultPatternName())return void t.shell.warning("Cannot delete default pattern");if(void 0===r)throw new Error(`Pattern with name ${e} not found`);await t.dapi.userDataStorage.remove(Ft,r,!1),this.currentUserPatternNameToHash.delete(e),n.updatePatternList();const i=this.getHashOfPatternToBeLoadedAfterDeletion();n.requestPatternLoad(i)}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 t.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await t.dapi.users.current()).id}async fetchPatterns(){return await t.dapi.userDataStorage.get(Ft,!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=jt[Ut.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[kt.PATTERN_NAME],"")}async extractDataFromRecordToMaps(e,n,r){const i=JSON.parse(n),o=i[Ut.PATTERN_CONFIG].patternName,s=i[Ut.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(o,e);else{if(!r.has(s)){let e="<UNKNOWN_USER>";try{e=(await t.dapi.users.find(s)).friendlyName}catch(t){}r.set(s,e)}const n=o+` (created by ${r.get(s)})`;this.otherUsersPatternNameToHash.set(n,e)}}getDefaultPatternName(){return jt[Ut.PATTERN_CONFIG][kt.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(t){return t===this.currentUserId}}const Jt=rxjs,Qt=rxjs.operators;function Xt(t){return t.endsWith("(o)")}function Zt(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 te;function ee(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 i=n-t.length,o=t.concat(new Array(n-t.length).fill(r)),s=0===t.length?n+1:i;return{nucleotides:o,ptoFlags:e.concat(new Array(s).fill(!0))}}}(te||(te={}));var ne=n(543),re=n.n(ne);class ie{constructor(t,e){this.dataManager=t,this._patternListUpdated$=new Jt.Subject,this._patternLoadRequested$=new Jt.Subject,this._patternLoaded$=new Jt.Subject,this._uniqueNucleotides$=new Jt.BehaviorSubject([]),this._patternDeletionRequested$=new Jt.Subject,this._tableSelection$=new Jt.BehaviorSubject(null),this._svgSaveRequested$=new Jt.Subject,this._loadPatternInNewTabRequested$=new Jt.Subject,this._urlStateUpdated$=new Jt.Subject,this._patternHasUnsavedChanges$=new Jt.BehaviorSubject(!1),this._selectedStrandColumn=new Jt.BehaviorSubject(null),this._selectedIdColumn=new Jt.BehaviorSubject(null),this.initializeAuthorSelection(e),this.initializePatternState(e),this._lastLoadedPatternConfig=new Jt.BehaviorSubject(re().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((t=>{t||Dt.forEach((t=>{this.updateTerminusModification("AS",t,"")}))})),this.patternStateChanged$.pipe((0,Qt.debounceTime)(20)).subscribe((()=>{const t=this._lastLoadedPatternConfig.getValue(),e=this.getPatternConfig(),n=!re().isEqual(e,t);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const t=(e=this._nucleotideSequences$.getValue(),ee(Object.values(e).flat()));var e;this._uniqueNucleotides$.next(t)}updateSequenceBase(){const t=Zt(this._nucleotideSequences$.getValue());this._sequenceBase$.next(t)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(t){const e=t[Ut.AUTHOR_ID];this.dataManager.isCurrentUserId(e)?this._patternAuthorSelection$=new Jt.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new Jt.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(t){const e=t[Ut.PATTERN_CONFIG];this._patternName$=new Jt.BehaviorSubject(e[kt.PATTERN_NAME]),this._isAntisenseStrandActive$=new Jt.BehaviorSubject(e[Ht.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new Jt.BehaviorSubject(e[Ht.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new Jt.BehaviorSubject(e[Ht.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new Jt.BehaviorSubject(e[Ht.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new Jt.BehaviorSubject(e[kt.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new Jt.BehaviorSubject(e[kt.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new Jt.BehaviorSubject(Zt(e[Ht.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:i,ptoFlags:o}=te.getTruncatedStrandData(n,r,e);return void this.setNewStrandData(i,o,t)}const i=this.getSequenceBase(),{nucleotides:o,ptoFlags:s}=te.getExtendedStrandData(n,r,e,i);this.setNewStrandData(o,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 ee(t).filter((t=>!Xt(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={};Pt.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 Jt.merge(this._patternName$.pipe((0,Qt.debounceTime)(300),(0,Qt.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,Qt.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,Qt.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(t){const e=this.getPhosphorothioateLinkageFlags();Pt.forEach((n=>{e[n]=e[n].map((()=>t))})),this.updatePhosphorothioateLinkageFlags(e)}setPatternConfig(t){this._patternName$.next(t[kt.PATTERN_NAME]),this._isAntisenseStrandActive$.next(t[Ht.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[Ht.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[Ht.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[Ht.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(t[kt.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(t[kt.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(t){this._lastLoadedPatternConfig.next(re().cloneDeep(t))}getPatternConfig(){return{[kt.PATTERN_NAME]:this.getPatternName(),[Ht.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[Ht.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[Ht.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[Ht.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[kt.PATTERN_COMMENT]:this.getComment(),[kt.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 i=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(i.concat(n)),this.updateNucleotideSequences(r)}get strandsUpdated$(){return Jt.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,Qt.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,Qt.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,Qt.map)((()=>{})))).pipe((0,Qt.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return Jt.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,Qt.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,Qt.map)((()=>{}))))}updateControlsUponPatternLoaded(t){this._patternLoaded$.next(t)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,Qt.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,Qt.debounceTime)(100))}}const oe="pattern";class se{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}?${oe}=${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(oe)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(oe,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(oe),window.history.pushState({},"",`${window.location.pathname}`)}}var ae=n(72),ue=n.n(ae),le=n(825),ce=n.n(le),he=n(659),fe=n.n(he),de=n(56),pe=n.n(de),ge=n(540),me=n.n(ge),ye=n(113),ve=n.n(ye),be=n(252),we={};we.styleTagTransform=ve(),we.setAttributes=pe(),we.insert=fe().bind(null,"head"),we.domAPI=ce(),we.insertStyleElement=me(),ue()(be.A,we),be.A&&be.A.locals&&be.A.locals;class Ce{constructor(t){this.eventBus=t,this.columnControlsContainer=Tt.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){It()(this.columnControlsContainer).empty(),It()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const t=this.createStrandColumnInput(),e=t.SS,n=t.AS;this.eventBus.antisenseStrandToggled$.subscribe((t=>{It()(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(Pt.map((e=>{const n=Tt.input.choice(`${Rt[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=Tt.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class Ae{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=Tt.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){t.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),t.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){if(!t&&t.args&&t.args.dataFrame instanceof e.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();It()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getTableSelection();return Tt.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(e){return t.shell.tableNames.includes(e.name)}displayTable(e){const n=t.shell.v;t.shell.addTableView(e),t.shell.v=n}}function xe(t,e,n,r){const i=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+Dt.length);r[0]=n["5'"],r[r.length-1]=n["3'"];let i=1;return e[0]&&(r[i]="ps",i++),t.forEach(((t,n)=>{r[n+i]=t,e[n+1]&&(r[n+i+1]="ps",i++)})),r}(t.split("").map(((t,n)=>{const r=function(t,e,n){const r=Object.keys(n.patternAppData)[0],i=n.patternAppData[r][e].substitution;return t.replace(/([AGCTU])/,i)}(t,e[n],Vr.jsonData);return r})),n,r);return i.join("")}class _e{constructor(t){this.eventBus=t,this.tableInputManager=new Ae(t),this.columnInputManager=new Ce(t)}createControls(){const t=Tt.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=Tt.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,Tt.buttonsInput([r])]}processConvertButtonClick(){!function(e){const n=e.getTableSelection();if(!n)return void t.shell.warning("Please select a table");const r=Pt.filter((t=>!("AS"===t&&!e.isAntisenseStrandActive()))).map((t=>({strand:t,column:e.getSelectedStrandColumn(t)}))).filter((t=>t.column));if(0===r.length)return void t.shell.warning("Select a sense strand column");const i=e.getSelectedIdColumn();if(!i)throw new Error("No ID column selected");n.getCol(i);const o=r.map((t=>({strand:t.strand,column:n.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))}))}(o,e)?t.shell.warning("Some strands in the table input do not match pattern length"):o.forEach((t=>{const r=t.column,i=t.strand,o=e.getNucleotideSequences()[i],s=e.getTerminalModifications()[i],a=e.getPhosphorothioateLinkageFlags()[i],u=`${e.getPatternName()}(${r.name})`;n.columns.addNewString(u).init((t=>xe(r.get(t),o,a,s)))}))}(this.eventBus)}}class Ee{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return Tt.divV([Tt.h1("PTO"),Tt.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((t=>t.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(t){return Pt.map((e=>t[e].filter((t=>t)).length)).reduce(((t,e)=>t+e),0)===Pt.map((t=>this.initialPatternConfig.nucleotideSequences[t].length)).reduce(((t,e)=>t+e),0)+Pt.filter((e=>t[e].length)).length}createAllPtoActivationInput(){const t=this.initialPatternConfig.phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t),n=Tt.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),Tt.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 Pt.map((t=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return;const e=this.isFirstPtoActive(t),n=Tt.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),Tt.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Te{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=Pt.map((t=>this.constructControlsPanel(t)));return Tt.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return Tt.div([]);const e=this.constructHeader(),n=this.createControls(t);return Tt.block([Tt.h1(`${Rt[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return Tt.divH([Tt.div([Tt.divText("#")],{style:{width:"20px"}}),Tt.block75([Tt.divText("Modification")]),Tt.div([Tt.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return Tt.div(e.map(((t,e)=>Tt.divH([n[e],Tt.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 i=Tt.input.choice("",{value:n,items:e});return i.onInput.subscribe((()=>{const e=i.value;this.eventBus.setNucleotide(t,r,e)})),i}))}createPTOFlagInputs(t){return this.eventBus.getPhosphorothioateLinkageFlags()[t].slice(1).map(((e,n)=>{const r=Tt.input.bool("",{value:e});r.onInput.subscribe((()=>{const e=r.value;this.eventBus.setPhosphorothioateLinkageFlag(t,n+1,e)}));const i=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const i=e[t][n+1];r.value=i}));return this.subscriptions.add(i),r}))}computeDisplayedInputLabels(){const t=this.eventBus.getNucleotideSequences(),e=new Map;return Pt.forEach((n=>{let r=1;const i=t[n].map((t=>{if(Xt(t))return"";const e=String(r);return r++,e}));e.set(n,i)})),e}createLabelDivs(t){const e=this.createLabels(t).map((t=>Tt.div([t],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(t).forEach(((t,n)=>{It()(e[n]).empty(),It()(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 Tt.label(r)}))}}class Se{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(t){t instanceof Jt.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 Ie{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Se}static open(t,e){Ie.isDialogOpen||(Ie.instance||(Ie.instance=new Ie(t,e)),Ie.instance.openDialog())}openDialog(){this.initialPatternConfig=re().cloneDeep(this.eventBus.getPatternConfig()),Ie.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=Tt.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=Tt.dialog("Edit strands").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Ie.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Ee(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Te(this.eventBus,this.dataManager,this.subscriptions).create();It()(t).empty(),It()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Ie.isDialogOpen=!1;class Ne{constructor(t){this.eventBus=t,this.subscriptions=new Se}static open(t){Ne.isDialogOpen||(Ne.instance||(Ne.instance=new Ne(t)),Ne.instance.openDialog())}openDialog(){this.initialPatternConfig=re().cloneDeep(this.eventBus.getPatternConfig()),Ne.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=Tt.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=Tt.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Ne.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Me(this.eventBus).create();It()(t).empty(),It()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Ne.isDialogOpen=!1;class Me{constructor(t){this.eventBus=t}create(){const t=Pt.map((t=>this.constructControlsPanel(t)));return Tt.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return Tt.div([]);const e=this.createInputs(t);return Tt.block([Tt.h1(`${Rt[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...Dt].reverse():Dt).map((e=>this.createInputForTerminus(t,e)));return Tt.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=Tt.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];It()(e).css("resize","none")}}class Oe{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,i=this.createSequenceBaseInput().root,o=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),u=this.createEditTerminalModificationsButton();return[Tt.h1("Edit"),t,n,r,i,s,o,Tt.buttonsInput([u,a])]}createEditPatternButton(){const t=Tt.button("Edit strands",(()=>Ie.open(this.eventBus,this.dataManager)));return Tt.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=Tt.button("Edit terminals",(()=>Ne.open(this.eventBus)));return Tt.tooltip.bind(t,"Edit terminal modifications"),It()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=Tt.input.toggle(`${Rt.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 e=t=>{const e=this.eventBus.getNucleotideSequences()[t].length,r=Tt.input.int(`${Rt[t]} length`,{value:e});return r.onInput.subscribe((()=>n(t,r))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{r.value=this.eventBus.getNucleotideSequences()[t].length})),r.setTooltip(`Number of nucleotides in ${t}, including overhangs`),[t,r]},n=(e,n)=>{const r=n.value;null!==r&&(r<=0&&(t.shell.warning("Sequence length must be greater than 0"),n.value=1),r>34&&(t.shell.warning("Sequence length must be less than 35"),n.value=34),this.eventBus.updateStrandLength(e,n.value))},r=Object.fromEntries(Pt.map((t=>e(t))));return this.eventBus.antisenseStrandToggled$.subscribe((t=>{It()(r.AS.root).toggle(t)})),r}createSequenceBaseInput(){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))),e=this.dataManager.fetchDefaultNucleobase(),n=Tt.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=Tt.input.textArea("Comment",{value:this.eventBus.getComment()});return It()(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=Tt.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return It()(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 Le{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Se,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[Tt.h1("Load"),t]}getPatternInputsContainer(){const t=Tt.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),It()(t).empty(),It()(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=Tt.div([t.root]),n=this.eventBus.userSelection$.subscribe((()=>{It()(e).empty(),It()(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=Tt.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){It()(t.input).css({"max-width":"100px","min-width":"100px"}),It()(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=Tt.input.choice("Pattern",{value:e,items:t});return n.setTooltip("Select pattern to load"),It()(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 e=Tt.button(Tt.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():t.shell.warning("Cannot delete example pattern")}));Tt.tooltip.bind(e,"Delete pattern from user storage");const n=this.eventBus.userSelection$.subscribe((()=>{e.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(n),e}showDeletePatternDialog(){const t=Tt.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(Tt.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class Be{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Le(this.eventBus,this.dataManager),e=new Oe(this.eventBus,this.dataManager),n=new _e(this.eventBus),r=t.createControls(),i=e.createControls(),o=n.createControls(),s=Tt.div(r);It()(s).css({"padding-bottom":"20px"});const a=Tt.div([...i,...o],"ui-form"),u=Tt.div([s,a]);return It()(u).css({padding:"25px"}),Tt.box(u,{style:{maxWidth:"450px"}})}}var Pe=n(146);class Re{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 De{constructor(){}static getInstance(){return De.instance||(De.instance=new De,De.instance.canvas=document.createElement("canvas")),De.instance}static getTextDimensions(t,e){const n=De.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 Fe(t){const e=Object.keys(Vr.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${st}'`);return Vr.jsonData.patternAppData[e][t].color||""}class He extends Re{constructor(t,e,n){super(t,e,n);const r=Pt.filter((t=>e.nucleotideSequences[t].length>0));this.strands=r.map((t=>new ke(this.svgElementFactory,e,n,t))),this.terminalModifications=r.map(((t,r)=>new $e(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new Ue(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 ke extends Re{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=>Xt(e)?null:(t++,t)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return Ve(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=Fe(t),i={...n,x:n.x+30*e};return[this.svgElementFactory.createCircleElement(i,15,r),this.createNucleotideLetterLabel(e,n,t)]}getNucleotideCircleCenterPosition(t,e){return{x:e.x+30*t,y:e.y}}createNucleotideLetterLabel(t,e,n){if(!ct.includes(n))return null;const r=function(t){return!Xt(t)&&ct.includes(t)?t:""}(n),i=function(t){const e=Fe(t),n=e.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[r,i,o]=n;return.299*r+.587*i+.114*o>186?"#333333":"#ffffff"}(n),o=this.getPositionForNucleotideLabel(t,e);return this.svgElementFactory.createTextElement(r,o,17,i)}getPositionForNucleotideLabel(t,e){const n=this.getNucleotideCircleCenterPosition(t,e),r=De.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=De.getTextDimensions(n.toString(),15).width,i={x:e.x+30*t-r/2,y:this.getNumericLabelYShift(e)};return this.svgElementFactory.createTextElement(n.toString(),i,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 Ue extends Re{constructor(t,e,n,r,i){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.terminalModifications=i,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=De.getTextDimensions(e,17),r={x:10,y:Ve(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=De.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:Ve(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 $e extends Re{constructor(t,e,n,r,i){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.strandSvgWrapper=i,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 De.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(),i={x:r?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:Ve(this.strand,this.yShift)+n.height/3};return r&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(e,i,17,"red")}createTerminalModifications(){return("AS"===this.strand?Dt:Array.from(Dt).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+Dt.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function Ve(t,e){return"SS"===t?e+5+15+15:e+52+10+15}class je{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 i=this.createElement("text");return this.setAttributes(i,{x:e.x,y:e.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:r}),i.textContent=t,i}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,i)=>{const o=i%2==0?6:3,s=i*e+n;return[t.x+Math.cos(s)*o,t.y+Math.sin(s)*o]}))}createRectangleElement(t,e,n,r){const i=this.createElement("rect");return this.setAttributes(i,{x:t.x,y:t.y,width:e,height:n,fill:r}),i}}class qe extends Re{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 De.getTextDimensions(this.titleText,17).width}getContentHeight(){return De.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 Ge extends Re{constructor(t,e,n){super(t,e,n),this._svgElements=[];const{elements:r,width:i}=this.createLegendItems();this._svgElements=r,this.width=i}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,Fe(t));e+=12;const i={y:this.yShift,x:e};return{elements:[r,this.svgElementFactory.createTextElement(t,i,15,"var(--grey-6)")],width:12+De.getTextDimensions(t,15).width}}createLegendItems(){let t=10;const e=[],n=e=>t+=e+15;if(this.isPhosphorothioatePresent()){const{elements:r,width:i}=this.createLegendItem("PTO linkage",t);n(i),e.push(r)}return this.getModificationTypesList().forEach((r=>{const{elements:i,width:o}=this.createLegendItem(r,t);n(o),e.push(i)})),{elements:e.flat(),width:t}}getContentHeight(){return 20}getContentWidth(){return this.width}}class We{constructor(t){this.svgElementFactory=new je;const e=re().cloneDeep(t);let n=10;this.title=new qe(this.svgElementFactory,e,n),n+=this.title.getContentHeight(),this.strands=new He(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Ge(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 ze{constructor(t){this.eventBus=t,this.svgDisplayDiv=Tt.div([]),t.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),t.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(t){return new ze(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 We(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();Pe.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Ye{constructor(t){this.eventBus=t,this.togglesContainer=Tt.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){It()(this.togglesContainer).empty(),It()(this.togglesContainer).append(this.createInputs())}createInputs(){const t=this.eventBus.getUniqueNucleotides().filter((t=>!Xt(t))).map((t=>this.createSingleInput(t)));return t.sort(((t,e)=>t.captionLabel.textContent.localeCompare(e.captionLabel.textContent))),Tt.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=Tt.input.bool(t,{value:e,onValueChanged:e=>this.handleNumericLabelToggle(t,e)});return It()(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 Ke{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Se}createContainer(){return Tt.div([Tt.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=Tt.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),It()(t).empty(),It()(t).append(this.getExampleElements())})),t}getExampleElements(){return Pt.map((t=>new Je(t,this.eventBus,this.subscriptions).create()))}}class Je{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(),Tt.block50([Tt.h2(Rt[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):Tt.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 ${Rt[this.strand]}`),t}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((t,e)=>ct[e%ct.length])).join("")}createOutputExample(t){const e=this.createTextInputForExamples();return e.value=this.computeOutputValue(t),e.setTooltip(`Pattern applied to the example input for ${Rt[this.strand]}`),e}computeOutputValue(t){const e=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return xe(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=Tt.input.textArea("",{value:""});return this.applyStylingToInput(t),t}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];e.setAttribute("readonly","true"),It()(e).css("resize","none"),It()(t.root).css("opacity","75%")}}class Qe{constructor(t,e){this.eventBus=t,this.dataManager=e,this.svgDisplay=ze.createSvgDiv(t)}getLayout(){const t=new Ye(this.eventBus).getContainer(),e=this.generateDownloadControls(),n=new Ke(this.eventBus,this.dataManager).createContainer();return Tt.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return Tt.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=Tt.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return Tt.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=Tt.button(Tt.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),Tt.tooltip.bind(t,"View pattern metadata"),t}async openInfoDialog(){let e=this.dataManager.getCurrentUserName(),n=this.dataManager.getDefaultPatternName(),r=qt,i=qt;const o=new URLSearchParams(window.location.search).get("pattern");if(null!==o){const s=await this.dataManager.getPatternRecordByHash(o);if(null!==s){const o=s[Ut.AUTHOR_ID];if(e=(await t.dapi.users.find(o)).friendlyName,n=s[Ut.PATTERN_CONFIG][kt.PATTERN_NAME],void 0!==s[Ut.DATE]){const t=s[Ut.DATE][$t.CREATE];void 0!==t&&(r=t);const e=s[Ut.DATE][$t.MODIFY];void 0!==e&&(i=e)}}}const s=Tt.divV([Tt.divText(`Pattern Name: ${n}`),Tt.divText(`Author: ${e}`),Tt.divText(`Created: ${Ze(new Date(r))}`),Tt.divText(`Modified: ${Ze(new Date(i))}`)]);t.shell.info(s)}createShareLinkButton(){const e=Tt.button(Tt.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>t.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),Tt.tooltip.bind(e,"Share pattern link"),e}createSavePatternButton(){const t=Tt.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),Tt.tooltip.bind(t,"Save pattern to user storage"),t}processSaveButtonClick(){const e=this.eventBus.getPatternName();e!==this.dataManager.getDefaultPatternName()?""!==e?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{t.shell.info(`Pattern ${e} saved`)})).catch((t=>this.handleErrorWhileSavingPattern(t))):t.shell.warning("Insert pattern name"):t.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(e){e instanceof Gt?new Xe(this.eventBus,this.dataManager).show():e instanceof Wt?t.shell.warning(Tt.div([Tt.divText("Pattern already exists"),Tt.button("Load",(()=>{const t=e.message;this.eventBus.requestLoadPatternInNewTab(t)}))])):console.error("Error while saving pattern",e)}}class Xe{constructor(t,e){this.eventBus=t,this.dataManager=e}show(){const t=this.eventBus.getPatternName(),e=Tt.dialog(`Pattern "${t}" already exists`);e.add(Tt.divText(`Pattern "${t}" already exists. Do you want to overwrite it?`)),e.show(),e.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const e=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{t.shell.info(`Pattern ${e} overwritten`)})).catch((e=>{console.error("Error while overwriting pattern in user storage",e),t.shell.error("Error while overwriting pattern")}))}}function Ze(t){return t.toLocaleString().split(":").slice(0,-1).join(":")}class tn extends Bt{constructor(t){super("Oligo Pattern"),this.th=t}getContent(){return async function(){const t=await Kt.getInstance(),e=new se,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 ie(t,n);e.subscribeToObservables(r);const i=new Be(r,t).getLayout(),o=new Qe(r,t).getLayout();return Tt.splitH([i,o],{},!0)}()}}var en=n(507),nn={};function rn(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?rn(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}nn.styleTagTransform=ve(),nn.setAttributes=pe(),nn.insert=fe().bind(null,"head"),nn.domAPI=ce(),nn.insertStyleElement=me(),ue()(en.A,nn),en.A&&en.A.locals&&en.A.locals;var on,sn=n(74),an={};an.styleTagTransform=ve(),an.setAttributes=pe(),an.insert=fe().bind(null,"head"),an.domAPI=ce(),an.insertStyleElement=me(),ue()(sn.A,an),sn.A&&sn.A.locals&&sn.A.locals;class un{constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,It()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{It()(this.textArea).css("height",0),It()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=Tt.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"}(on||(on={}));class ln{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 i=0;i<this.atomCount;i++){r=this.shiftIdxToXColumn(r);for(const o of[t,e,n])o[i]=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 cn extends ln{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 hn extends cn{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(on.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(on.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),r=n.map((t=>e[t])),i=n.map((t=>e[t+1]));r.forEach(((e,n)=>{const r=parseInt(e.split(/\s+/)[1])-1,o=parseInt(i[n].substring(1));if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,r)}));const o=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);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(on.TYPE)&&-1!==t.indexOf(on.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,on.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<on.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,on.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,on.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+on.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=on.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class fn extends cn{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 i=e[1];if(t.has(i))throw new Error(`R group ${i} is already in the map`);t.set(i,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 dn{constructor(){}static getInstance(t){if(dn.isMolfileV2K(t))return new hn(t);if(dn.isMolfileV3K(t))return new fn(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return hn.isValidMolfile(t)}static isMolfileV3K(t){return fn.isValidMolfile(t)}}const pn=class extends Error{constructor(t){super(t)}};class gn{constructor(t){this.molblock=t}get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof pn&&(t="");const n=rn(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new pn("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(e){try{await t.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(t){const e=rn(t);console.error(e)}}getMoleculeDimensions(){const t=dn.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=Tt.dialog({title:"Molecule",showFooter:!1}),e=.7*It()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,i=e,o=n.width*r,s=Tt.canvas(o,i);await this.drawMolBlockOnCanvas(s);const a=Tt.block([s],{style:{overflowX:"scroll"}});t.add(a).showModal(!0),It()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),It()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),It()(t.root).find(".d4-dialog-contents").addClass("ui-box"),It()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const r=Tt.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(Tt.tooltip.bind(r,"Click to zoom"))}}class mn extends Error{constructor(t,e){super(t,e)}}class yn{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 i=this.getSymbolForCode(n);r>0&&function(t){return Vr.jsonData.monomersWithPhosphate.left.includes(t)}(i)&&e.pop(),e.push(i);const o=vn(i),s=r===t.length-1,a=r+1<t.length&&vn(this.getSymbolForCode(t[r+1]));o||function(t){return Vr.jsonData.monomersWithPhosphate.right.includes(t)}(i)||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 mn(`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 ft(Array.from(this.codeMap.keys()))}}function vn(t){return Vr.jsonData.monomersWithPhosphate.phosphate.includes(t)}class bn{constructor(t,e=!1,n){this.invert=e,this.lib=Vr.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new yn(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),i=e.atomIndex.indexOf(n),o=(e.x[i]+e.x[r])/2,s=(e.y[i]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=o,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 u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let l=u;for(let r=0;r<n;r++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,l=t.indexOf(" ",u)+1,l=t.indexOf(" ",l),u=(t=t.slice(0,u)+e.x[r]+" "+e.y[r]+t.slice(l)).indexOf("\n",u)+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 i=Array(e.natom),o=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let u=0;u<e.natom;u++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),i[u]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),o[u]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[u]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[u]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:i,atomType:o,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),i=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,r,i);const o=(e.x[i]+e.x[r])/2,s=(e.y[i]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=s;let a=0;if(0===e.x[r])a=e.y[r]>e.y[i]?Math.PI/2:3*Math.PI/2;else if(0===e.y[r])a=e.x[r]>e.x[i]?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 u=Math.cos(a),l=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*u-e.y[t]*l,e.y[t]=n*l+e.y[t]*u}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 f=h;for(let r=0;r<n;r++)h=t.indexOf("V30",h)+4,h=t.indexOf(" ",h)+1,h=t.indexOf(" ",h)+1,f=t.indexOf(" ",h)+1,f=t.indexOf(" ",f),h=(t=t.slice(0,h)+e.x[r]+" "+e.y[r]+t.slice(f)).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="",i="",o="";const s=[];let a=0,u=0,l=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let o=0;n&&(o=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 f=t[e].indexOf("M V30 BEGIN ATOM");f=t[e].indexOf("\n",f);let d=f,p=f;for(let r=0;r<c.natom;r++)if(1!==h.atomIndex[r]||0===e){d=t[e].indexOf("V30",d)+4,p=t[e].indexOf(" ",d);let r=0;n?(r=parseInt(t[e].substring(d,p)),1===r?r=o:r===o&&(r=1),r+=a):r=parseInt(t[e].substring(d,p))+a,t[e]=t[e].slice(0,d)+r+t[e].slice(p),d=t[e].indexOf(" ",d)+1,d=t[e].indexOf(" ",d)+1,p=t[e].indexOf(" ",d);const i=l-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(d,p))+i))/1e4;t[e]=t[e].slice(0,d)+s+t[e].slice(p),d=t[e].indexOf(" ",d)+1,p=t[e].indexOf(" ",d),s=Math.round(1e4*parseFloat(t[e].substring(d,p)))/1e4,t[e]=t[e].slice(0,d)+s+t[e].slice(p),d=t[e].indexOf("\n",d)+1}else d=t[e].indexOf("M V30",d)-1,p=t[e].indexOf("\n",d+1),t[e]=t[e].slice(0,d)+t[e].slice(p);const g=t[e].indexOf("M V30 END ATOM");r+=t[e].substring(f+1,g);let m=t[e].indexOf("M V30 BEGIN BOND");m=t[e].indexOf("\n",m),d=m,p=m;for(let r=0;r<c.nbond;r++){d=t[e].indexOf("V30",d)+4,p=t[e].indexOf(" ",d);const r=parseInt(t[e].substring(d,p))+u;t[e]=t[e].slice(0,d)+r+t[e].slice(p),d=t[e].indexOf(" ",d)+1,d=t[e].indexOf(" ",d)+1,p=t[e].indexOf(" ",d);let i=0;n?(i=parseInt(t[e].substring(d,p)),1===i?i=o:i===o&&(i=1),i+=a):i=parseInt(t[e].substring(d,p))+a,t[e]=t[e].slice(0,d)+i+t[e].slice(p),d=t[e].indexOf(" ",d)+1,p=Math.min(t[e].indexOf("\n",d),t[e].indexOf(" ",d)),i=0,n?(i=parseInt(t[e].substring(d,p)),1===i?i=o:i===o&&(i=1),i+=a):i=parseInt(t[e].substring(d,p))+a,t[e]=t[e].slice(0,d)+i+t[e].slice(p),d=t[e].indexOf("\n",d)+1}const y=t[e].indexOf("M V30 END BOND");i+=t[e].substring(m+1,y);let v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const n=t[e].indexOf(")",v);t[e].substring(v,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=n,v=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=c.natom-1,u+=c.nbond,l+=n?Math.max(...h.x):h.x[c.natom-1]-h.x[0]}const c=Math.ceil(s.length/4);o+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){o+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)o+=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+" "+u+" 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+=i,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=o,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,i=t.x[r],o=t.y[r],s=t.x[n]-i,a=t.y[n]-o,u=t.x[e]-i,l=t.y[e]-o,c=u*Math.cos(2*Math.PI/3)-l*Math.sin(2*Math.PI/3),h=u*Math.sin(2*Math.PI/3)+l*Math.cos(2*Math.PI/3),f=u-s,d=l-a,p=c-s,g=h-a;Math.sqrt(g*g+p*p)>=Math.sqrt(d*d+f*f)&&(t.x[e]=c+i,t.y[e]=h+o)}}function wn(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="",i="",o="";const s=[];let a=0,u=0,l=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Cn(t.antiStrands[e]);let c=!1;const h=t.senseStrands.concat(t.antiStrands);let f=0;for(let e=0;e<h.length;e++){h[e]=h[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=An(h[e]),o=xn(h[e]);if(e>=t.senseStrands.length?!1===c&&(c=!0,l=0):f=Math.min(f,Math.min(...o.y.filter((t=>t<0)))),c){const t=Math.min(...o.x)-l,e=Math.max(...o.y)+5;for(let e=0;e<o.x.length;e++)o.x[e]-=t;for(let t=0;t<o.y.length;t++)o.y[t]-=e-f}let d=h[e].indexOf("M V30 BEGIN ATOM");d=h[e].indexOf("\n",d);let p=d,g=d;for(let t=0;t<n.natom;t++){p=h[e].indexOf("V30",p)+4,g=h[e].indexOf(" ",p);const n=parseInt(h[e].substring(p,g))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(g),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,g=h[e].indexOf(" ",p);let r=Math.round(1e4*o.x[t])/1e4;h[e]=h[e].slice(0,p)+r+h[e].slice(g),p=h[e].indexOf(" ",p)+1,g=h[e].indexOf(" ",p),r=Math.round(1e4*o.y[t])/1e4,h[e]=h[e].slice(0,p)+r+h[e].slice(g),p=h[e].indexOf("\n",p)+1}const m=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(d+1,m);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),p=y,g=y;for(let t=0;t<n.nbond;t++){p=h[e].indexOf("V30",p)+4,g=h[e].indexOf(" ",p);const t=parseInt(h[e].substring(p,g))+u;h[e]=h[e].slice(0,p)+t+h[e].slice(g),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,g=h[e].indexOf(" ",p);let n=parseInt(h[e].substring(p,g))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(g),p=h[e].indexOf(" ",p)+1,g=Math.min(h[e].indexOf("\n",p),h[e].indexOf(" ",p)),n=parseInt(h[e].substring(p,g))+a,h[e]=h[e].slice(0,p)+n+h[e].slice(g),p=h[e].indexOf("\n",p)+1}const v=h[e].indexOf("M V30 END BOND");i+=h[e].substring(y+1,v);let b=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const t=h[e].indexOf(")",b);h[e].substring(b,t).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),b=t,b=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=n.natom,u+=n.nbond,l+=Math.max(...o.x)+5}const d=Math.ceil(s.length/4);o+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<d;t++){o+="M V30 ";const e=t+1===d?s.length-4*(d-1):4;for(let n=0;n<e;n++)o+=n+1===e?t===d-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return n+="M V30 COUNTS "+a+" "+u+" 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+=i,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=o,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function Cn(t){const e=xn(t),n=e.atomIndex.length,r=(Math.max(...e.x)+Math.min(...e.x))/2,i=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=i;const o=Math.PI,s=Math.cos(o),a=Math.sin(o);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 u=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=r,e.y[t]-=u;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let c=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,c=t.indexOf(" ",l)+1,c=t.indexOf(" ",c),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",l)+1;return t}function An(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 xn(t){const e=An(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const i=Array(e.natom),o=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let u=0;u<e.natom;u++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),i[u]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),o[u]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[u]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[u]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:i,atomType:o,x:s,y:a}}function _n(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let i="";try{i=new bn(t,e,r).convert()}catch(t){const e=rn(t);console.error(e)}return i}function En(t,e,n,r,i){const o=[t,e,n].filter((t=>""!==t.strand));return 1===o.length?_n(o[0].strand,o[0].invert,i):wn({senseStrands:[_n(t.strand,t.invert,i)],antiStrands:[_n(e.strand,e.invert,i),_n(n.strand,n.invert,i)].filter((t=>""!==t))},r)}const Tn=["ss","as","as2"];class Sn{constructor(){this.th=Vr,this.onInput=new Jt.Subject,this.onInvalidInput=new Jt.Subject,this.inputBase=Object.fromEntries(Tn.map((t=>{const e=Tt.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),It()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=Tt.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=Tt.input.bool("Save as one entity",{value:!0}),Tt.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Tn.map((t=>[t,!1]))),this.moleculeImgDiv=Tt.block([]),It()(this.moleculeImgDiv).addClass("st-structure-mol-img"),e.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),e.debounce(this.onInvalidInput,1e3).subscribe((async()=>{t.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(t){const e=this.getTableInput(t),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const r=Tt.divH([n,this.moleculeImgDiv]);It()(r).addClass("st-structure-bottom");const i=Tt.divV([e,r]);return It()(i).addClass("st-structure-body"),i}getBoolInputsAndButton(){const e=Tt.buttonsInput([Tt.bigButton("Save SDF",(()=>{const e=this.getStrandData();!function(e,n,r,i,o,s){const a=[e.strand,n.strand,r.strand].filter((t=>""!==t));if(0===a.length||1===a.length&&""===e.strand)t.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let u;if(o)u=En(e,n,r,i,s)+"\n$$$$\n";else{const h=_n(e.strand,e.invert,s),f=_n(n.strand,n.invert,s),d=_n(r.strand,r.invert,s);u=h+"\n> <Sequence>\nSense Strand\n$$$$\n",f&&(u+=f+"\n> <Sequence>\nAnti Sense\n$$$$\n"),d&&(u+=d+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const l=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}dt(`SequenceTranslator-${l.getFullYear()+"-"+c(l.getMonth()+1)+"-"+c(l.getDate())+"_"+c(l.getHours())+"-"+c(l.getMinutes())+"-"+c(l.getSeconds())}.sdf`,encodeURIComponent(u))}}(e.ss,e.as,e.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),n=[this.saveAllStrandsInput.root,this.useChiralInput.root,e],r=Tt.divV(n);for(const t of n)It()(t).addClass("st-structure-bool-button-block");return r}getTableInput(t){const e=Object.fromEntries(Tn.map((e=>[e,new un(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Tn.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,Tt.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Tn.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"],i=new Map(Tn.map(((t,e)=>[t,r[e]]))),o=(Object.fromEntries(Tn.map((t=>[t,Tt.label(i.get(t))]))),Object.fromEntries(Tn.map((t=>{const n=Tt.icons.delete((()=>{e[t].inputBase.value=""})),r=Tt.button(n,(()=>{}));return Tt.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=Tt.form([],"st-structure-inputs"),a=Tt.divV([],"st-structure-clear-buttons"),u=Tt.form([],"st-direction-inputs");for(const t of Tn)s.append(this.inputBase[t].root),a.append(o[t]),u.append(n[t].root);return Tt.divH([s,a,u])}getStrandData(){return Object.fromEntries(Tn.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return En(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=rn(t);console.error(e)}const e=new gn(t);await e.drawMolecule(this.moleculeImgDiv,650,150),It()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class In extends Bt{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Sn}getContent(){return this.layout.getHtmlDivElement(this.th)}}async function Nn(e){try{const n={overflowX:"scroll"},r=Tt.div([],{style:n}),i=xn(e),o=.7*It()(window).height(),s=Math.max(...i.x)-Math.min(...i.x),a=Math.max(...i.y)-Math.min(...i.y),u=o/a,l=u*s,c=u*a,h=Tt.canvas(l*window.devicePixelRatio,c*window.devicePixelRatio);h.style.width=`${l}px`,h.style.height=`${c}px`,await async function(e,n){await t.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:n,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,e),r.appendChild(h),Tt.dialog("Molecule").add(r).showModal(!0)}catch(t){const e=rn(t);console.error(e)}}class Mn{static async view(){const e=Vr.monomerLibWrapper.getTableForViewer();e.name="Monomer Library";const n=t.shell.addTableView(e);n.grid.props.allowEdit=!1,n.grid.onCellDoubleClick.subscribe((async t=>{const e=t.cell.value;"Molecule"===t.tableColumn?.semType&&await Nn(e)}))}}const On="Copied",Ln="Nucleotides";function Bn(t,e){const n=new RegExp("\\([^()]*\\)","g"),r=t.match(n);return r?r.map((t=>{const n=t.replace(/[\[\]()]/g,"");return ct.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||bt)).join(""):null}var Pn=n(254),Rn={};Rn.styleTagTransform=ve(),Rn.setAttributes=pe(),Rn.insert=fe().bind(null,"head"),Rn.domAPI=ce(),Rn.insertStyleElement=me(),ue()(Pn.A,Rn),Pn.A&&Pn.A.locals&&Pn.A.locals;const Dn=["Sequence"];class Fn{constructor(t){this.th=t,this.inputFormats=Object.keys(Vr.jsonData.codesToHelmDict).concat(ht.HELM),this.onInput=new Jt.Subject,this.moleculeImgDiv=Tt.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=Tt.div([]),this.formatChoiceInput=Tt.input.choice("",{value:ht.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),It()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=Tt.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),e.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=$n.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=Tt.box(Tt.panel([t,e,Tt.block([Tt.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=Tt.h1("Bulk");Tt.tooltip.bind(t,"Bulk translation from table input");const e=new Hn(this.eventBus).createUIComponents(),n=Tt.input.choice("Input format",{value:ht.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=Tt.input.choice("Output format",{value:Ln,items:(i=this.th,Object.keys(i.jsonData.codesToHelmDict).concat([ht.HELM,Ln]).sort()),onValueChanged:t=>this.eventBus.selectOutputFormat(t)});var i;const o=this.createConvertBulkButton(),s=Tt.div([...e,n,r,o],"ui-form");return Tt.block25([t,s])}createConvertBulkButton(){const t=Tt.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return Tt.tooltip.bind(t,"Convert sequences from table input"),It()(t).css({float:"right","margin-top":"20px"}),t}processConvertBulkButtonClick(){const n=this.eventBus.getSelectedTable();if(!n)return void t.shell.warning("No table selected");const r=this.eventBus.getSelectedInputFormat(),i=this.eventBus.getSelectedOutputFormat(),o=this.eventBus.getSelectedColumn("Sequence");if(!o)return void t.shell.warning("No sequence column selected");const s=`${o.name} (${i})`,a=e.Column.fromList(e.TYPE.STRING,s,o.toList().map((t=>{const e=function(t,e,n,r){const i=r.createFormatConverter(t,e);return n===Ln?Bn(i.convertTo(ht.HELM),r.monomerLibWrapper):i.convertTo(n)}(t,r,i,this.th);return e})));if(i===Ln||i===ht.HELM){a.semType=e.SEMTYPE.MACROMOLECULE;const t=i==Ln?C.FASTA:C.HELM;a.meta.units=t;const n=tt.forColumn(a);(i==Ln?tt.setUnitsToFastaColumn:tt.setUnitsToHelmColumn)(n)}n.columns.add(a),t.data.detectSemanticTypes(n),t.shell.v=t.shell.getTableView(n.name)}constructSingleSequenceControls(){const t=new un(this.sequenceInputBase,(t=>Nt(t,this.th))),e=Tt.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=Tt.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=Tt.div([this.formatChoiceInput]),i=Tt.button(Tt.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));Tt.tooltip.bind(i,"Clear input");const o={format:r,textInput:t.root,clearBtn:i},s=Tt.table([o],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=Tt.block([this.outputTableDiv,e,n]);return Tt.block75([Tt.h1("Single sequence"),s,a])}saveMolfile(){const t=new bn(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";dt(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const n=e.chem.convert(this.molfile,e.chem.Notation.MolBlock,e.chem.Notation.Smiles);navigator.clipboard.writeText(n).then((()=>t.shell.info(On)))}updateTable(){this.outputTableDiv.innerHTML="";const e=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,n=function(t,e,n,r){const i=Object.keys(r.jsonData.codesToHelmDict).concat([ht.HELM]);if(!t||-1!==e&&n!==ht.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const o=i.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),s=r.createFormatConverter(t,n),a=Object.fromEntries(o.map((t=>{let e;try{e=s.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),u=Bn(n===ht.HELM?t:a[ht.HELM],r.monomerLibWrapper);return u&&(a.Nucleotides=u),a}(this.sequence,e,this.format,this.th),r=[];for(const e of Object.keys(n)){const i="indexOfFirstInvalidChar"in n?Tt.divH([]):Tt.link(n[e],(()=>navigator.clipboard.writeText(n[e]).then((()=>t.shell.info(On)))),"Copy sequence","");r.push({format:e,sequence:i})}const i=Tt.table(r,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(i),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new gn(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===ht.HELM){const t=this.th.createFormatConverter(this.sequence,this.format).convertTo(ht.AXOLABS);return new bn(t,!1,ht.AXOLABS).convert()}return new bn(this.sequence,!1,this.format).convert()}}class Hn{constructor(t){this.tableInputManager=new kn(t),this.columnInputManager=new Un(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class kn{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=Tt.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){t.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),t.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();It()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getSelectedTable();return Tt.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(e){return t.shell.tableNames.includes(e.name)}displayTable(e){const n=t.shell.v;t.shell.addTableView(e),t.shell.v=n}}class Un{constructor(t){this.eventBus=t,this.columnControlsContainer=Tt.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const t=this.createColumnInputs();It()(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 Dn.map((n=>this.createColumnInput(n,e,t)))}createColumnInput(t,e,n){const r=t.toLowerCase(),i=e.find((t=>t.toLowerCase().includes(r)))||e[0];return this.selectColumnIfTableNotNull(n,i,t),Tt.input.choice(`${t}`,{value:i,items:e,onValueChanged:e=>this.selectColumnIfTableNotNull(n,e,t)})}selectColumnIfTableNotNull(t,e,n){if(null!==t){const r=t.getCol(e);this.eventBus.selectColumn(n,r)}}}class $n{constructor(){this._tableSelection$=new Jt.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Dn.map((t=>[t,new Jt.BehaviorSubject(null)]))),this._inputFormatSelection$=new Jt.BehaviorSubject(ht.AXOLABS),this._outputFormatSelection$=new Jt.BehaviorSubject(Ln)}static getInstance(){return void 0===$n._instance&&($n._instance=new $n),$n._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 Vn extends Bt{constructor(t){super("Oligo Translator"),this.th=t,this.th=Vr,this.layout=new Fn(this.th);const e=Tt.iconFA("book",Mn.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class jn extends Bt{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class qn extends Lt{constructor(t,n){super("Oligo Toolkit"),this.externalViewFactories=t,this.th=n;const r=this.getViewFactories(this.th);this.multiView=new e.MultiView({viewFactories:r})}getViewFactories(t){function n(n){e.View.create();const r=new n(t);return r.initView().catch((t=>console.error(`Failed to initialize ${n.name}: ${t}`))),()=>r.getView()}let r={TRANSLATOR:n(Vn),PATTERN:n(tn),STRUCTURE:n(In)};return this.externalViewFactories&&(r=Object.assign({},r,this.externalViewFactories)),r}getCurrentPanePath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${Vr.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}n(982),e.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(e.Column.fromList(e.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var Gn,Wn=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))};async function zn(){await pt((async()=>{const e=await Wr();t.shell.addView(e),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await function(t){return Wn(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[t];n.value=e;const r=new Event("input");n.dispatchEvent(r)}(e,t)}))}))}function Yn(t){const e=Tt.input.textArea("",{value:""});return{coloredInput:new un(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}async function Kn(){const t="Helm",n=e.Func.find({package:t,name:"getHelmHelper"});if(0===n.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await n[0].prepare().call()).getOutputParamValue()}function Jn(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?Jn(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function Qn(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?Qn(t.$thrownJsError):void 0}function Xn(t){return[Jn(t),Qn(t)]}async function Zn(){const t=e.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()}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(Gn||(Gn={})),e.DataFrame.fromColumns([e.Column.fromStrings("col",["val1","val2","val3"])]),e.JsInputBase,Error,Tt.input.helmAsync=async function(t,e){return(await Kn()).createHelmInput(t,e)};var tr=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))};class er{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 tr(this,void 0,void 0,(function*(){if(this.settings)return this.settings;const e=t.userSettings.getValue(this.userStorageName,"Settings"),n=e?JSON.parse(e):{excluded:[],explicit:[]};return n.explicit=n.explicit instanceof Array?n.explicit:[],n.excluded=n.excluded instanceof Array?n.excluded:[],this.settings=n}))}setUserSettings(e){this.settings=e,t.userSettings.add(this.userStorageName,"Settings",JSON.stringify(e))}getAllAvailable(){return tr(this,void 0,void 0,(function*(){return(yield t.dapi.files.list(this.path)).map((t=>t.fullPath.replace(`${this.path}`,"")))}))}getActive(){return tr(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=Tt.input.bool(t,{value:e,onValueChanged:e=>this.updateSelectionStatus(t,e)});return n.addOptions(Tt.button(Tt.iconFA("trash"),(()=>{Tt.dialog({title:"Warning"}).add(Tt.divText(`Delete file '${t}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(t)})).show()}),`Delete ${t}`)),n}getInputs(){return tr(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 i=e.includes(t[r]);n[r]=this.createInput(t[r],i),this.inputs.set(t[r],n[r])}return this.fireOnValueChanged(),n}))}getForm(){return tr(this,void 0,void 0,(function*(){const t=yield this.getInputs(),e=Tt.divV(t);return Tt.divV([e,Tt.button("ADD",(()=>tr(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(T()(this.inputs.entries()).filter((([t,e])=>e.value)).map((([t,e])=>t)).toArray())}updateSelectionStatus(t,e){return tr(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(e){return tr(this,void 0,void 0,(function*(){this.inputs.delete(e),this.fireOnValueChanged();const n=yield this.getUserSettings(),r=n.excluded.indexOf(e);r>-1&&n.excluded.splice(r,1),this.setUserSettings(n),yield t.dapi.files.delete(this.path+e),t.shell.info(`File ${e} successfully deleted`)}))}getNewAvailable(){return tr(this,void 0,void 0,(function*(){return new Promise(((n,r)=>{e.Utils.openFile({accept:this.ext,open:e=>tr(this,void 0,void 0,(function*(){const r=e.name,i=yield e.arrayBuffer();yield t.dapi.files.write(this.path+`${e.name}`,new Uint8Array(i)),n(r)}))})}))}))}}const nr="System:AppData/SequenceTranslator/polytool-rules/",rr="Polytool",ir="link",or="reaction",sr="fragmentDuplication",ar="differentFragments";class ur extends er{constructor(t,e,n,r){super(t,e,n,r)}}class lr{constructor(t,e){this.linkages=e,this.monomers=t}static fromHelm(t){const e=t.split("$"),n=e[0].split("|"),r=e[1].split("|"),i=new Array(n.length),o=[];for(let t=0;t<n.length;t++){const e=n[t].indexOf("{"),r=n[t].indexOf("}");i[t]=n[t].slice(e+1,r).split(".")}for(let t=0;t<r.length;t++)if(""!==r[t]&&"V2.0"!==r[t]){const e=r[t].split(","),n=e[0].replace("PEPTIDE","")-1,i=e[1].replace("PEPTIDE","")-1,s=e[2].split("-"),a=s[0].split(":"),u=s[1].split(":");o.push({fChain:n,sChain:i,fMonomer:a[0],sMonomer:u[0],fR:a[1].replace("R",""),sR:u[1].replace("R","")})}return new lr(i,o)}static fromNotation(t,e){const n=e.heterodimerCode,r=e.homodimerCode,i=[],o=[],s=null!==n?t.split(`(${e.heterodimerCode})`):"";null!==n&&s.length>1?(o.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),i.push(s[1].replaceAll("{","").replaceAll("}","")),i.push(s[2].replaceAll("{","").replaceAll("}",""))):i.push(t);for(let t=0;t<i.length;t++)if(null!==r&&i[t].includes(`(${r})`)){const e=i.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const n=i[t].replace(`(${r})`,""),s=n.indexOf("{"),a=n.slice(0,s),u=n.replace(a,"").replaceAll("{","").replaceAll("}","");i[t]=a+u,i.push(u)}for(let t=0;t<i.length;t++)if(null!==r&&i[t].includes(`(${r})`)){const e=i.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const n=i[t].replace(`(${r})`,""),s=n.indexOf("{"),a=n.slice(0,s),u=n.replace(a,"").replaceAll("{","").replaceAll("}","");i[t]=a+u,i.push(u)}const a=new Array(i.length);for(let t=0;t<i.length;t++){const n=i[t].split("-"),r=this.getLinkedPositions(n,e.linkRules),[s,u,l,c,h]=this.getAllCycles(e.linkRules,n,r);new Array(s.length);for(let e=0;e<u.length;e++)o.push({fChain:t,sChain:t,fMonomer:u[e],sMonomer:l[e],fR:c[e],sR:h[e]});a[t]=s}const u=[];for(let t=0;t<a.length;t++){const n=this.getLinkedPositions(a[t],e.reactionRules),[r,i,s,l]=this.getAllReactants(e.reactionRules,a[t],n);if(i.length>=1){const t=new Array(s[0]-1),n=new Array(r.length-s[0]);for(let e=0;e<s[0]-1;e++)t[e]=r[e];for(let t=s[0];t<r.length;t++)n[t-s[0]]=r[t];t[i[0]-1]=e.reactionRules[l[0]].name;for(let t=0;t<o.length;t++)o[t].fMonomer>s[0]&&(o[t].fMonomer-=s[0],o[t].fChain++),o[t].sMonomer>s[0]&&(o[t].sMonomer-=s[0],o[t].sChain++);o.push({fChain:0,sChain:0,fMonomer:i[0],sMonomer:s[0]-1,fR:3,sR:2}),o.push({fChain:0,sChain:1,fMonomer:i[0],sMonomer:1,fR:4,sR:1});const a=new Array(t.length);for(let e=0;e<t.length;e++)a[e]=`[${t[e]}]`;const c=new Array(n.length);for(let t=0;t<n.length;t++)c[t]=`[${n[t]}]`;u.push(t),u.push(n)}else u.push(a[t])}return new lr(u,o)}getHelmChanged(t,e){let n=0,r=0,i=0;t:for(let e=0;e<this.monomers.length;e++)for(let o=0;o<this.monomers[e].length;o++){if(n==t){r=e,i=o;break t}n++}const o=this.monomers[r][i];this.monomers[r][i]=`[${e}]`;const s=this.getHelm();return this.monomers[r][i]=o,s}getHelm(){let t="";for(let e=0;e<this.monomers.length;e++){e>0&&(t+="|"),t+=`PEPTIDE${e+1}{`;for(let n=0;n<this.monomers[e].length;n++){n>0&&(t+=".");const r=this.monomers[e][n];t+=r.length>1?`[${r}]`:r}t+="}"}t+="$";for(let e=0;e<this.linkages.length;e++)e>0&&(t+="|"),t+=`PEPTIDE${this.linkages[e].fChain+1},PEPTIDE${this.linkages[e].sChain+1},`,t+=`${this.linkages[e].fMonomer}:R${this.linkages[e].fR}-`,t+=`${this.linkages[e].sMonomer}:R${this.linkages[e].sR}`;return t+="$$$",t}getNotation(t){return"not implemented"}static getLinkedPositions(t,e){const n=new Array(e.length);for(let r=0;r<e.length;r++){let i=!1,o=!1,s=!1,a=-1,u=-1;const l=`(${e[r].code})`;for(let n=0;n<t.length;n++)if(t[n].includes(l)){if(i){if(s&&t[n]==e[r].secondMonomer+l){o=!0,u=n;break}if(s||t[n]!=e[r].firstMonomer+l)continue;o=!0,u=n;break}if(t[n]==e[r].firstMonomer+l)i=!0,s=!0,a=n;else{if(t[n]!=e[r].secondMonomer+l)continue;i=!0,s=!1,a=n}}n[r]=i&&o?s?[a,u,r]:[u,a,r]:[-1,-1,-1]}return n}static getAllCycles(t,e,n){const r=[],i=[],o=[],s=[],a=t.length;for(let u=0;u<a;u++){if(-1==n[u][0])continue;const a=e[n[u][0]],l=e[n[u][1]];e[n[u][0]]=e[n[u][0]].replace(a,t[u].firstSubstitution),e[n[u][1]]=e[n[u][1]].replace(l,t[u].secondSubstitution),r.push(n[u][0]+1),i.push(n[u][1]+1),o.push(t[u].firstLinkingGroup),s.push(t[u].secondLinkingGroup)}return[e,r,i,o,s]}static getAllReactants(t,e,n){const r=[],i=[],o=[],s=t.length;for(let a=0;a<s;a++){if(-1==n[a][0])continue;const s=e[n[a][0]],u=e[n[a][1]];e[n[a][0]]=e[n[a][0]].replace(s,t[a].firstMonomer),e[n[a][1]]=e[n[a][1]].replace(u,t[a].secondMonomer),r.push(n[a][0]+1),i.push(n[a][1]+1),o.push(n[a][2])}return[e,r,i,o]}}function cr(e,n=!0){const[r,i]=Xn(e);return Vr.logger.error(r,void 0,i),n&&t.shell.error(r),[r,i]}const hr="System:AppData/Bio/monomer-libraries/";async function fr(){const e=await t.functions.call("Bio:getMonomerLibHelper",{});return(await e.getFileManager()).getValidLibraryPaths()}const dr="\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";const pr={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},gr=[{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"}],mr="No dataframe with macromolecule columns open",yr="Get HELM",vr="Add HELM column",br="Chirality engine",wr="Poly Tool Conversion",Cr="Poly Tool Enumeration",Ar="Rules used";function xr(n){(async function(n){const r=[],i=()=>{for(const t of r)t.unsubscribe()};try{const[o,s]=await Promise.all([fr(),Kn()]),a=n&&n.rowIndex>=0?n.value:dr;let u=await(async()=>e.chem.isMolBlock(a)?a:await t.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:n?.column.getTag(e.TAGS.UNITS)??e.chem.Notation.Unknown,targetNotation:e.chem.Notation.MolBlock}))();const l=new e.chem.Sketcher(e.chem.SKETCHER_MODE.EXTERNAL);l.syncCurrentObject=!1,l.onChanged.subscribe((t=>{u=l.getMolFile()})),l.root.classList.add("ui-input-editor"),l.root.style.marginTop="3px",l.setMolFile(u);const c=Tt.input.choice("Library to use",{value:null,items:o});l.root.setAttribute("style","min-width:250px!important;"),l.root.setAttribute("style","max-width:250px!important;"),c.input.setAttribute("style","min-width:250px!important;");const h=Tt.div([l.root,c.root]);r.push(t.events.onCurrentCellChanged.subscribe((()=>{const n=t.shell.tv.dataFrame.currentCell;n.column.semType===e.SEMTYPE.MOLECULE&&l.setValue(n.value)})));const f=async()=>{try{const n=l.getMolFile();if(void 0===n||""===n)t.shell.warning("PolyTool: no molecule was provided");else if(n.includes("R#")){const r=await async function(e,n){const r=await async function(e){const n=await t.functions.call("Bio:getMonomerLibHelper",{});return(await n.readLibrary(hr,e)).getMonomerSymbolsByType("PEPTIDE")}(n),i=await async function(e){const n=await t.functions.call("Bio:getMonomerLibHelper",{}),r=await n.readLibrary(hr,e),i=r.getMonomerSymbolsByType("PEPTIDE");return new Array(i.length),r.getMonomerMolsByPolymerType("PEPTIDE")}(n),o=new Array(r.length),s=await t.functions.call("Chem:getRdKitModule"),a=s.get_mol(e),u=a.get_smiles();a.delete();const l=new Array(r.length);for(let t=0;t<r.length;t++){const e=i[r[t]],n=s.get_mol(e);l[t]=n.get_smiles(),n.delete()}for(let t=0;t<r.length;t++){let e=null;try{const n=`${`${u}.${l[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();o[t]=r}catch(e){o[t]=""}finally{e?.delete()}}return o}(n,c.value),i=e.Column.fromStrings("Enumerated",r),o=e.DataFrame.fromColumns([i]);t.shell.addTableView(o)}else t.shell.warning("PolyTool: no R group was provided")}catch(t){cr(t)}},d=Tt.dialog(Cr).add(h).onOK((()=>{f().finally((()=>{i()}))})).onCancel((()=>{i()}));return r.push(d.onClose.subscribe((()=>{i()}))),d.history((()=>({mol:l.getMolFile(),screenLibrary:c.value})),(t=>{l.setMolFile(t.mol),c.value=t.screenLibrary})),d}catch(t){throw i(),t}})(n).then((t=>{t.show({resizable:!0})})).catch((e=>{t.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}))}async function _r(n,r,i,o){const s=e.TaskBarProgressIndicator.create("PolyTool converting...");try{const s=(t,e)=>t?t.columns.getUnusedName(e):e;await Kn();const a=n.dataFrame,u=await async function(n){const r=new e.FileSource(nr),i=[],o=[],s={homodimerCode:null,heterodimerCode:null,linkRules:i,reactionRules:o};for(let e=0;e<n.length;e++){const a=await r.readAsText(n[e].replace(nr,"")),u=JSON.parse(a);for(let e=0;e<u.length;e++)if(void 0!==u[e].type&&void 0!==u[e].code)switch(u[e].type){case ir:{const t=u[e].monomericSubstitution;t.code=u[e].code,i.push(t);break}case or:{const t=u[e].monomericSubstitution;t.code=u[e].code,o.push(t);break}case sr:s.homodimerCode&&t.shell.warning("PolyTool: homodimer code is duplicated in rules."),s.homodimerCode=u[e].code;break;case ar:s.heterodimerCode&&t.shell.warning("PolyTool: heterodimer code is duplicated in rules."),s.heterodimerCode=u[e].code;break;default:t.shell.warning(`PolyTool: Unexpected type - '${u[e]}'.`)}else t.shell.warning("Polytool: rules contain invalid rule")}return s}(o),l=function(t,e){const n=new Array(t.length);for(let r=0;r<t.length;r++)if(null==t[r])n[r]="";else{const i=lr.fromNotation(t[r],e);n[r]=i.getHelm()}return n}(n.toList(),u),c=s(a,`transformed(${n.name})`),h=e.Column.fromType(e.COLUMN_TYPE.STRING,c,l.length).init((t=>l[t]));h.semType=e.SEMTYPE.MACROMOLECULE,h.meta.units=C.HELM,h.setTag(e.TAGS.CELL_RENDERER,"helm"),r&&a&&a.columns.add(h,!0);const f=await Zn(),d=(await f.helmToAtomicLevel(h,i,r)).molCol;return d.name=s(a,`molfile(${n.name})`),d.semType=e.SEMTYPE.MOLECULE,a&&(a.columns.add(d,!0),await t.data.detectSemanticTypes(a)),[h,d]}finally{s.close()}}var Er,Tr;function Sr(t){let e;switch(t){case Er.BASE:case Er.SUGAR:case Er.LINKER:case Er.NUCLEOTIDE:case"nucleotide":e="RNA";break;case Er.AA:e="PEPTIDE";break;case Er.CHEM:e="CHEM";break;case Er.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}!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"}(Er||(Er={}));class Ir extends e.InputBase{constructor(t,e){super(Tt.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){Tt.input.setColumnInputTable(this,t,this.options?.filter)}}Tt.input.column2=function(t,e){return new Ir(t,e)},function(t){t.Single="single",t.Matrix="matrix"}(Tr||(Tr={}));const Nr="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function Mr(t,e,n,r){const i=new Array(r.length*(n-e+1));for(let o=0;o<r.length;++o){const s=n-e+1;for(let n=0;n<s;++n){const a=e+n,u=r[o],l=i[o*s+n]=t.clone(),c=l.atoms[a].elem;l.atoms[a].elem=u;const h=c?.length>1?`[${c}]`:c,f=u?.length>1?`[${u}]`:u;l.name=`${t.name}-${h}${a+1}${f}`}}return i}class Or extends e.JsInputBase{get inputType(){return"Positions"}get dataType(){return e.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.grid.dataFrame=t}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.grid.dataFrame=e.DataFrame.fromCsv(t)}get placeholdersValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){const r=parseInt(t.get("Position",n))-1;if(!isNaN(r)){const i=Lr(t.get("Monomers",n));e.push({position:r,monomers:i})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.subs=[],t&&(this.captionLabel.innerText=t),this.gridHost=Tt.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}}),this.grid=e,this.gridHost.append(this.grid.root),null!=n?this.updateGridHeight(n+.7):(this.updateGridHeight(this.grid.dataFrame.rowCount+.6),this.subs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.6)})))),this.grid.root.style.width="100%",this.subs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.subs.push(Tt.onSizeChanged(this.grid.root).subscribe((()=>{this.grid.columns.byIndex(2).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-10}))),this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost)}detach(){for(const t of this.subs)t.unsubscribe()}static async create(t,n,r){const i=e.DataFrame.fromColumns([e.Column.fromType(e.COLUMN_TYPE.INT,"Position",0),e.Column.fromType(e.COLUMN_TYPE.STRING,"Monomers",0)]),o=await i.plot.fromType(e.VIEWER.GRID,n);return o.sort(["Position"]),new Or(t,o,r)}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(2).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-10}}function Lr(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 Br extends e.JsInputBase{get inputType(){return"Breadth"}get dataType(){return e.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.grid.dataFrame=t}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.grid.dataFrame=e.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,i=parseInt(t.get("End",n))-1;if(!isNaN(r)&&!isNaN(i)){const o=Lr(t.get("Monomers",n));e.push({start:r,end:i,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.subs=[],t&&(this.captionLabel.innerText=t),this.gridHost=Tt.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}}),this.grid=e,this.gridHost.append(this.grid.root),null!=n?this.updateGridHeight(n+.7):(this.updateGridHeight(this.grid.dataFrame.rowCount+.6),this.subs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.6)})))),this.grid.root.style.width="100%",this.subs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.subs.push(Tt.onSizeChanged(this.grid.root).subscribe((()=>{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}))),this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost)}detach(){for(const t of this.subs)t.unsubscribe()}static async create(t,n,r){const i=e.DataFrame.fromColumns([e.Column.fromType(e.COLUMN_TYPE.INT,"Start",0),e.Column.fromType(e.COLUMN_TYPE.INT,"End",0),e.Column.fromType(e.COLUMN_TYPE.STRING,"Monomers",0)]),o=await i.plot.fromType(e.VIEWER.GRID,n);return o.sort(["Start","End"]),new Br(t,o,r)}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}}async function Pr(n){const r=window.innerWidth,i=window.innerHeight;try{let o;const s=()=>{if(null==o)return;const t=It()(o.root).find("div.d4-dialog-contents").get(0),e=t.clientHeight,n={0:1},r=Object.values(n).reduce(((t,e)=>t+e),0),i=e-T().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;o.inputs.forEach(((t,e)=>{if(e in n){const o=i*n[e]/r;t.root.style.height=`${o}px`}}))};o=await async function(n,r){const i="ST: PT: HelmDialog()";let o;const s=[],a=()=>{for(const t of s)t.unsubscribe();o.placeholders.detach()};try{const u=(await rt()).getMonomerLib(),l=(await Zn(),e.DataFrame.fromColumns([])),[c,h]=await Promise.all([fr(),Kn()]);let f=null;const d=Tt.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),p=Tt.divText("",{style:{color:"red"}});o={macromolecule:h.createHelmInput("Macromolecule",{editable:!1}),placeholders:await Or.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:Tt.input.choice("Enumerator type",{value:Tr.Single,items:Object.values(Tr)}),placeholdersBreadth:await Br.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),toAtomicLevel:Tt.input.bool("To atomic level",{value:!1}),keepOriginal:Tt.input.bool("Keep original",{value:!1}),trivialNameCol:Tt.input.column2("Trivial name",{table:n?.dataFrame,filter:t=>t.type===e.COLUMN_TYPE.STRING&&t!=n?.column,onValueChanged:()=>{const t=o.trivialNameCol.value;let e=null;n&&t&&(e={value:t.get(n.rowIndex),colName:t.name}),f=e,d.textContent=f?`Original ID: ${f.value}`:""},nullable:!0})},o.trivialNameCol.addOptions(d);let g=null;o.placeholders.addValidator((t=>{const e=[];try{const t=[];for(const n of o.placeholders.placeholdersValue){const r=n.position;if(r>=o.macromolecule.molValue.atoms.length){e.push(`There is no monomer at position ${r+1}.`);continue}const i=Sr(o.macromolecule.molValue.atoms[r].biotype());for(const e of n.monomers){const n=u.getMonomer(i,e);n&&n.lib||t.push({polymerType:i,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}`),g=e.length>0?e.join("\n"):null}catch(t){const[e,n]=cr(t,!1);g=e}return setTimeout((()=>{y()}),0),g})),s.push(o.macromolecule.onMouseMove.subscribe((t=>{try{Vr.logger.debug(`${i}, placeholdersInput.onMouseMove()`);const e=t.offsetX,n=t.offsetY,r=o.macromolecule.molValue,s=h.getHoveredAtom(e,n,r,o.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s),n=o.placeholders.placeholdersValue.find((t=>t.position===e))?.monomers;if(n){const e=Tt.divText(n.join(", "));o.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){cr(t,!1)}}))),s.push(o.macromolecule.onClick.subscribe((t=>{try{Vr.logger.debug(`${i}, placeholdersInput.onClick()`);const e=t.offsetX,n=t.offsetY,r=o.macromolecule.molValue,s=h.getHoveredAtom(e,n,r,o.macromolecule.root.clientHeight);if(s){const t=(s._parent.atoms.indexOf(s)+1).toString(),e=o.placeholders.grid.dataFrame,n=e.columns.byName("Position").toList();let r=n.indexOf(t);-1===r&&(r=n.findIndex((t=>isNaN(t))),-1===r&&(r=e.rows.addNew([t,""]).idx),e.set("Position",r,t)),e.currentCell=e.cell(r,"Monomers")}}catch(t){cr(t)}}))),s.push(o.placeholders.grid.dataFrame.onDataChanged.subscribe((()=>{m()}))),s.push((0,Jt.fromEvent)(o.placeholders.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),s.push(Tt.onSizeChanged(o.placeholders.root).subscribe((()=>{r&&r()}))),s.push(t.events.onCurrentCellChanged.subscribe((()=>{const n=t.shell.tv.dataFrame.currentCell;n.column.semType===e.SEMTYPE.MACROMOLECULE&&b(n)}))),o.macromolecule.root.style.setProperty("min-width","250px","important");const m=()=>{const t=o.macromolecule.molValue;for(let e=0;e<t.atoms.length;e++)t.atoms[e].highlighted=e in o.placeholders.placeholdersValue;o.macromolecule.redraw()},y=()=>{const t=g,e=p;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},v=t=>{t?(o.trivialNameCol.setColumnInputTable(t),o.trivialNameCol.root.style.removeProperty("display")):(o.trivialNameCol.setColumnInputTable(l),o.trivialNameCol.root.style.setProperty("display","none")),r&&r()},b=async t=>{let n,r;if(t&&t.rowIndex>=0&&t?.column.semType==e.SEMTYPE.MACROMOLECULE){const e=tt.forColumn(t.column);n=await e.getHelm(t.rowIndex),r=t.dataFrame}else n=Nr;o.macromolecule.stringValue=n,v(r)};await b(n);const w=async()=>{try{const n=o.macromolecule.stringValue;if(T().enumerate(o.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray(),void 0===n||""===n)t.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(o.placeholders.placeholdersValue).length&&0===Object.keys(o.placeholdersBreadth.placeholdersBreadthValue).length)return void t.shell.warning(`${Cr}: placeholders are empty`);await Kn();const r={placeholders:o.placeholders.placeholdersValue,type:o.enumeratorType.value,placeholdersBreadth:o.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:o.keepOriginal.value},i=await async function(t,n,r,i){const o=e.TaskBarProgressIndicator.create("PolyTool enumerating...");try{await Kn();const o=function(t,e,n){const r=new JSDraw2.MolHandler,i=new org.helm.webeditor.Plugin(r);org.helm.webeditor.IO.parseHelm(i,t,new JSDraw2.Point(0,0),void 0);const o=r.m;o.name=e;let s=[];if(n.placeholders)switch(n.type){case Tr.Single:s=function(t,e){return e.map((e=>Mr(t,e.position,e.position,e.monomers))).reduce(((t,e)=>t.concat(e)),[])}(r.m,n.placeholders);break;case Tr.Matrix:s=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>Mr(e,t.position,t.position,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(r.m,n.placeholders)}let a=[];n.placeholdersBreadth&&(a=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>Mr(e,t.start,t.end,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(r.m,n.placeholdersBreadth)),s=s.concat(a),n.keepOriginal&&(s=[o,...s]);const u=s.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return u}(t,n?.value??"",r),s=e.Column.fromType(e.COLUMN_TYPE.STRING,"Enumerated",o.length).init((t=>o[t][0])),a=e.DataFrame.fromColumns([s]);if(i){const t=await Zn(),n=await t.helmToAtomicLevel(s,!0,!0);n.molCol.semType=e.SEMTYPE.MOLECULE,a.columns.add(n.molCol,!1)}if(n){const t=e.Column.fromType(e.COLUMN_TYPE.STRING,n.colName,o.length).init((t=>o[t][1]));a.columns.add(t)}return a}finally{o.close()}}(n,f,r,o.toAtomicLevel.value);t.shell.addTableView(i)}}catch(t){cr(t)}},C=Tt.dialog({title:Cr,showFooter:!0}).add(o.macromolecule).add(o.placeholders).add(o.enumeratorType).add(o.placeholdersBreadth).add(o.trivialNameCol).add(o.toAtomicLevel).add(o.keepOriginal).add(p).onOK((()=>{w()}));return s.push(C.onClose.subscribe((()=>{a()}))),C.history((()=>({macromolecule:o.macromolecule.stringValue,placeholders:o.placeholders.stringValue,enumeratorType:o.enumeratorType.value,placeholdersBreadth:o.placeholdersBreadth.stringValue,trivialNameCol:o.trivialNameCol.stringValue,toAtomicLevel:o.toAtomicLevel.value,keepOriginal:o.keepOriginal.value})),(t=>{o.macromolecule.stringValue=t.macromolecule,o.placeholders.stringValue=t.placeholders,o.enumeratorType.value=t.enumeratorType,o.placeholdersBreadth.stringValue=t.placeholdersBreadth,o.trivialNameCol.stringValue=t.trivialNameCol,o.toAtomicLevel.value=t.toAtomicLevel,o.keepOriginal.value=t.keepOriginal})),C}catch(t){throw a(),t}}(n,s);let a=!0;Tt.onSizeChanged(o.root).subscribe((()=>{if(a){o.inputs;const t=It()(o.root),e=(t.find("div.d4-dialog-header").get(0).offsetHeight,t.find("div.d4-dialog-footer").get(0).offsetHeight,.7*r),n=.7*i;o.root.style.width=`${Math.min(r,e)}px`,o.root.style.height=`${Math.min(i,n)}px`,o.root.style.left=`${Math.floor((r-o.root.offsetWidth)/2)}px`,o.root.style.top=`${Math.floor((i-o.root.offsetHeight)/2)}px`,a=!1}s()})),s(),Vr.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),o.show({width:Math.max(350,.7*r),resizable:!0}),Vr.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(e){const[n,r]=Xn(e);t.shell.warning("To run PolyTool Enumeration, sketch the macromolecule and select monomers to vary"),Vr.logger.error(n,void 0,r)}}class Rr{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(pr).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={...y};Object.entries(pr).forEach((([n,r])=>{const i=t[r];e[n]=i}));let n="smiles";const r=t[pr[n]],i=new Dr(r),o=i.getCappedSmiles();return e[n]=o,n="rgroups",e[n]=Fr.getRGroups(i.getNumberOfRGroups()),n="molfile",e[n]=new Hr(i.getSmilesWithRGroups()).getMolfile(),e}}class Dr{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 Fr{constructor(){}static getRGroups(t){return gr.slice(0,t)}}class Hr{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=e.chem.convert(this.smilesWithRGroups,e.chem.Notation.Smiles,e.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 kr{constructor(t,n){this.fileName=t,this.fileContent=n,this.validateFileType();const r=e.DataFrame.fromCsv(this.fileContent),i=this.toJson(r);this.polyToolMonomerLib=new Rr(i),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")}}var Ur;!function(t){t.table="table",t.seqCol="seqCol",t.generateHelm="generateHelm",t.chiralityEngine="chiralityEngine",t.rules="rules"}(Ur||(Ur={}));class $r{constructor(t){this.call=t,this.ruleInputs=new ur(nr,rr,".json")}async initInputs(){const t=t=>this.call.inputParams[t];this.inputs={table:(()=>{const e=t(Ur.table);return Tt.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Ur.seqCol);return Tt.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:Tt.input.forProperty(t(Ur.generateHelm).property),chiralityEngine:Tt.input.forProperty(t(Ur.chiralityEngine).property),rules:{header:Tt.inlineText([Ar]),form:await this.ruleInputs.getForm()}}}static async create(t){const e=new $r(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=Tt.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)=>{Tt.dialog({title:wr}).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")}}const Vr=new Mt({debug:!0});async function jr(){await Vr.initLibData();const e=await async function(e){const n={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Yn(e)}},r={};for(const[e,i]of Object.entries(n)){let n;try{n=await t.functions.call(e,i.parameters);const o=new jn(i.tabName,n);o.initView(),r[i.tabName]=()=>o.getView()}catch(t){console.warn(`Plugin ${e} not loaded, reason:`,t);continue}}return r}(Vr);if(!e)throw new Error("External app view factories not loaded");const n=new qn(e,Vr);return await n.getAppView()}async function qr(){return await ni("Oligo Translator")}async function Gr(){return await ni("Oligo Pattern")}async function Wr(){return await ni("Oligo Structure")}async function zr(){return await Vr.initLibData(),Vr}function Yr(){const t=Vr.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}function Kr(t){const e=Vr.createSequenceValidator(t),n=Vr.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}function Jr(t,e){return new bn(t,e,"GCRS").convert()}function Qr(t){return wn(t,!0)}async function Xr(){await async function(){await pt((async()=>{const e=await qr();t.shell.addView(e)}))}()}async function Zr(){await async function(){await pt((async()=>{const e=await Gr();t.shell.addView(e)}))}()}async function ti(){await zn()}async function ei(t,e,n){return await Vr.initLibData(),Vr.createFormatConverter(t,e).convertTo(n)}async function ni(t){await Vr.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new Vn(e);case"Oligo Pattern":return new tn(e);case"Oligo Structure":return new In(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Vr);return await e.getAppView()}async function ri(){await async function(){let n;try{n=await async function(){const n=[],r=()=>{for(const t of n)t.unsubscribe()};try{let i;if(!i){const n=t.shell.t.columns.bySemTypeAll(e.SEMTYPE.MACROMOLECULE);if(n.length<1)throw new Error(mr);i=n[0]}const o=Tt.input.column("Column",{table:i.dataFrame,value:i,filter:t=>t.semType===e.SEMTYPE.MACROMOLECULE&&tt.forColumn(t).notation===C.CUSTOM}),s=Tt.input.bool(yr,{value:!0});Tt.tooltip.bind(s.root,vr);const a=Tt.input.bool(br,{value:!1});let u;const l=new ur(nr,rr,".json",{onValueChanged:t=>{u=t}}),c=Tt.inlineText([Ar]);Tt.tooltip.bind(c,"Add or specify rules to use");const h=await l.getForm(),f=Tt.divV([o,s,a,c,h]),d=async()=>{try{const t=await l.getActive();await _r(o.value,s.value,a.value,t)}catch(t){cr(t)}},p=Tt.dialog(wr).add(f).onOK((()=>{d()}));return n.push(p.onClose.subscribe((()=>{r()}))),p.history((()=>({generateHelm:s.value,chiralityEngine:a.value,rules:u})),(t=>{s.value=t.generateHelm,a.value=t.chiralityEngine,l.setActive(u)})),p}catch(t){throw r(),t}}(),n.show()}catch(e){const[n,r]=Xn(e);t.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Vr.logger.error(n,void 0,r)}}()}async function ii(t){const e=await $r.create(t);return await e.showDialog()}async function oi(t,e,n,r,i){return(await _r(e,n,r,i))[0]}async function si(){await Pr(t.shell.tv?.dataFrame.currentCell)}async function ai(){xr()}async function li(n,r){var i;(function(t){t.semType=e.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",A.PT)})(i=r),i.meta.units=C.SEPARATOR,i.setTag("separator","-"),await t.data.detectSemanticTypes(n)}async function ci(t){const n=await t.readAsString(),r=new kr(t.fileName,n),i=await r.getJson(),o=t.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(i,null,2);e.Utils.download(o,s)}function hi(t){!function(t){try{const n=t.args.item;if(n){const r=t.args.menu;(n instanceof e.GridCell||"GridCell"==n.constructor.name)&&function(t,n){if(Vr.logger.debug("ST: addContextMenuForCell(), start"),t&&t.tableColumn)switch(t.tableColumn.semType){case e.SEMTYPE.MACROMOLECULE:return n.item("PolyTool-Enumerate",(()=>{Pr(t.cell)})),!0;case e.SEMTYPE.MOLECULE:return n.item("PolyTool-Enumerate",(()=>{xr(t.cell)})),!0}return!1}(n,r)&&t.preventDefault()}}catch(t){cr(t),window.$sequenceTranslator||(window.$sequenceTranslator={}),window.$sequenceTranslator.contextMenuError=t}}(t)}async function fi(){await Pr()}async function di(){xr()}})(),sequencetranslator=r})();
2
+ var sequencetranslator;(()=>{var t={717:(t,e,n)=>{"use strict";n.d(e,{j:()=>i});var r=n(82);async function i(){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()}},599:(t,e,n)=>{"use strict";n.d(e,{o:()=>r.o});var r=n(869)},124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>o});var r=n(389),i=n(82);async function o(){const t="Helm",e=i.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()}i.JsInputBase,Error,r.input.helmAsync=async function(t,e){return(await o()).createHelmInput(t,e)}},890:(t,e,n)=>{"use strict";n.d(e,{pj:()=>f});var r,i,o,s,a,l,u,c=n(82);n(328);class h{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=h._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new h(t._length);n._length=t._length,n._data=h._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new h(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new h(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return h.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new h(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new h(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new h(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return h.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=h._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=h._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=h._onBitCount[255&e];let o=this._data[i]&t._data[i];const s=31&this._length;for(0!=s&&(o&=~(4294967295<<s));0!=o;o>>>=8)n+=h._onBitCount[255&o];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=h._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=h._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}h._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),h._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),h._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(r||(r={})),function(t){t.Euclidean="Euclidean"}(i||(i={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(o||(o={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(u||(u={}));new Uint32Array(65536);var d;async function f(){const t=c.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()}!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(d||(d={})),d.HAMMING,d.LEVENSHTEIN,d.NEEDLEMANN_WUNSCH,d.MONOMER_CHEMICAL_DISTANCE,o.Tanimoto,o.Dice,o.Asymmetric,o.BraunBlanquet,o.Cosine,o.Kulczynski,o.McConnaughey,o.RogotGoldberg,o.Russel,o.Sokal,o.Hamming,o.Euclidean,o.Tanimoto,o.Dice,o.Asymmetric,o.BraunBlanquet,o.Cosine,o.Kulczynski,o.McConnaughey,o.RogotGoldberg,o.Russel,o.Sokal,o.Hamming,o.Euclidean,o.Tanimoto,o.Dice,o.Cosine,o.Tanimoto,o.Asymmetric,o.Cosine,o.Sokal,d.HAMMING,d.LEVENSHTEIN,d.MONOMER_CHEMICAL_DISTANCE,d.NEEDLEMANN_WUNSCH,n(151),n(439)},151:(t,e,n)=>{"use strict";n.d(e,{f6:()=>r,pe:()=>i});const r=["symbol","molfile","rgroups","name"],i={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},192:(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 i(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):void 0}function o(t){return[r(t),i(t)]}n.d(e,{AP:()=>o})},439:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r,YI:()=>i,_S:()=>l,b9:()=>u,gp:()=>o});var r,i,o,s=n(738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom"}(r||(r={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(i||(i={})),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"}(o||(o={}));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(i.PT,a.fasta.peptide,.5),new s.a(i.DNA,a.fasta.dna,.55),new s.a(i.RNA,a.fasta.rna,.55),""),u={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*"}},3:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r.Hi,YI:()=>r.YI,dh:()=>i.dh,gp:()=>r.gp});var r=n(439),i=n(291)},738:(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}}},291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>p,dh:()=>g,zS:()=>y});var r=n(82),i=(n(991),n(738),n(439));class o{static makePalette(t,e=!1,n=o){const r={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[i][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}o.undefinedColor="rgb(100,100,100)",o.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 s extends o{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,s)),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,s)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new s({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 s.aaSynonyms?s.aaSynonyms[t]:t;return super.get(e)}}s.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class a{static getPalette(t="grok"){switch(t){case"grok":return s.GrokGroups;case"lesk":return s.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const i of t)"("==i?e++:")"==i?e--:e?n+=i:r+=i;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,i]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,i,1]:[this.undefinedColor,r,i,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,i,2]:[this.undefinedColor,r,i,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,i,3]:[this.undefinedColor,r,i,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,i,4]:[this.undefinedColor,r,i,4]}return[this.undefinedColor,r,i,0]}}a.SemType="Aminoacids",a.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",a.undefinedColor="rgb(100,100,100)",a.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"},a.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"},a.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(*)*"},a.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 l{}l.SemType="Nucleotides",l.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",l.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var u=n(890);function c(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),i=r.Color.b(n),o=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-i,2));if(o>210)return`rgb(${e/o*210},${t/o*210},${i/o*210})`}return r.Color.toRgb(n)}class h{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 d{}class f extends d{static buildPalette(){return(0,u.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{f.customMonomerColors={},f.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]=c(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(o.colourPalette))}get(t,e){const n=f.customMonomerColors[t],r=e??"PEPTIDE";if(n&&n[r])return n[r];const i=h.hashCode(t)%f.palette.length;return c(f.palette[i])}}f.palette=f.buildPalette(),f.customMonomerColors={},f.polymerTypes=[];class p{get length(){return this.mList.length}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:i._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}function g(t,e=void 0){return n=>{if(n){let r;const o=new RegExp(String.raw`"-"|'-'|[^${t}]+`,"g");if(void 0!==e){o.lastIndex=0,r=new Array(Math.ceil(e));let t=null,i=0;for(;null!==(t=o.exec(n))&&i<e;)r[i++]=t[0].replace('"-"',"").replace("'-'","");r.splice(i)}else r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e);return new p(r,i.b9[i.Hi.SEPARATOR])}return new p([],i.b9[i.Hi.SEPARATOR])}}const m=/([^\W_]+)/g;function y(t,e){if(t.length<=e)return t;const n=t.match(m),r=t.length>e||(n?.length??0)>1,i=n?.[0]??" ";return r?i.substring(0,e-1)+"…":i}},312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>i});var r=n(82);async function i(){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()}},16:(t,e,n)=>{"use strict";function r(){var t;return null!==(t=window.$monomerHover)&&void 0!==t?t:null}function i(t){window.$monomerHover=t}function o(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}n.d(e,{OF:()=>r,QA:()=>o,eV:()=>i})},869:(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={}))},70:(t,e,n)=>{"use strict";n.d(e,{cb:()=>a,PE:()=>s}),n(328);var r=n(82);n(982),r.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(r.Column.fromList(r.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var i,o=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(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())}))};function s(t,e,n,r=0,i="timeout"){return o(this,void 0,void 0,(function*(){return new Promise(((o,s)=>{const a=t.subscribe((t=>{try{e(t),o("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(i)}),r);n()}))}))}function a(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(i||(i={})),r.DataFrame.fromColumns([r.Column.fromStrings("col",["val1","val2","val3"])])},74:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},252:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},507:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},254:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(354),i=n.n(r),o=n(314),s=n.n(o)()(i());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},314: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,i,o){"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!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),i&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=i):c[4]="".concat(i)),e.push(c))}},e}},354: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)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},982: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,i,o){for(var s,a,l,u,c,h,d,f,p,g,m,y,b;o>=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],g=0;g<16;g++)m=i+4*g,t[g]=(255&r[m])<<24|(255&r[m+1])<<16|(255&r[m+2])<<8|255&r[m+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(b+t[g-16]|0);for(g=0;g<64;g++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(f+(e[g]+t[g]|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,i+=64,o-=64}return i}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,i=e/536870912|0,o=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]=i>>>24&255,this.buffer[s-7]=i>>>16&255,this.buffer[s-6]=i>>>8&255,this.buffer[s-5]=i>>>0&255,this.buffer[s-4]=o>>>24&255,this.buffer[s-3]=o>>>16&255,this.buffer[s-2]=o>>>8&255,this.buffer[s-1]=o>>>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 i=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 o(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new i(t).update(e),r=n.digest();return n.clean(),r}function a(t,e,n,r){var i=r[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=i,t.hash=o,t.default=o,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 o=new Uint8Array([1]),u=s(e,t),c=new i(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,o),d=0),f[p]=h[d++];return c.clean(),h.fill(0),o.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var o=new i(t),s=o.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,o.reset(),o.update(e),o.update(a),o.finish(u);for(var f=0;f<s;f++)l[f]=u[f];for(f=2;f<=n;f++){o.reset(),o.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 o.clean(),c}}(e);var i=e.default;for(var o in e)i[o]=e[o];"object"==typeof t.exports?t.exports=i:void 0===(r=function(){return i}.call(e,n,e,t))||(t.exports=r)}()},543:function(t,e,n){var r;t=n.nmd(t),function(){var i,o="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]],g="[object Arguments]",m="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",w="[object Function]",C="[object GeneratorFunction]",A="[object Map]",x="[object Number]",_="[object Object]",S="[object Promise]",E="[object RegExp]",T="[object Set]",I="[object String]",N="[object Symbol]",O="[object WeakMap]",M="[object ArrayBuffer]",L="[object DataView]",B="[object Float32Array]",P="[object Float64Array]",R="[object Int8Array]",D="[object Int16Array]",F="[object Int32Array]",k="[object Uint8Array]",H="[object Uint8ClampedArray]",U="[object Uint16Array]",V="[object Uint32Array]",$=/\b__p \+= '';/g,j=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,z=/[&<>"']/g,W=RegExp(G.source),K=RegExp(z.source),Y=/<%-([\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+/,it=/\s/,ot=/\{(?:\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,gt=/^\[object .+?Constructor\]$/,mt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,bt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,Ct="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",_t="a-z\\xdf-\\xf6\\xf8-\\xff",St="A-Z\\xc0-\\xd6\\xd8-\\xde",Et="\\ufe0e\\ufe0f",Tt="\\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",It="["+Ct+"]",Nt="["+Tt+"]",Ot="["+At+"]",Mt="\\d+",Lt="["+xt+"]",Bt="["+_t+"]",Pt="[^"+Ct+Tt+Mt+xt+_t+St+"]",Rt="\\ud83c[\\udffb-\\udfff]",Dt="[^"+Ct+"]",Ft="(?:\\ud83c[\\udde6-\\uddff]){2}",kt="[\\ud800-\\udbff][\\udc00-\\udfff]",Ht="["+St+"]",Ut="\\u200d",Vt="(?:"+Bt+"|"+Pt+")",$t="(?:"+Ht+"|"+Pt+")",jt="(?:['’](?:d|ll|m|re|s|t|ve))?",qt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gt="(?:"+Ot+"|"+Rt+")?",zt="["+Et+"]?",Wt=zt+Gt+"(?:"+Ut+"(?:"+[Dt,Ft,kt].join("|")+")"+zt+Gt+")*",Kt="(?:"+[Lt,Ft,kt].join("|")+")"+Wt,Yt="(?:"+[Dt+Ot+"?",Ot,Ft,kt,It].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Ot,"g"),Xt=RegExp(Rt+"(?="+Rt+")|"+Yt+Wt,"g"),Zt=RegExp([Ht+"?"+Bt+"+"+jt+"(?="+[Nt,Ht,"$"].join("|")+")",$t+"+"+qt+"(?="+[Nt,Ht+Vt,"$"].join("|")+")",Ht+"?"+Vt+"+"+jt,Ht+"+"+qt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Mt,Kt].join("|"),"g"),te=RegExp("["+Ut+Ct+At+Et+"]"),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,ie={};ie[B]=ie[P]=ie[R]=ie[D]=ie[F]=ie[k]=ie[H]=ie[U]=ie[V]=!0,ie[g]=ie[m]=ie[M]=ie[y]=ie[L]=ie[b]=ie[v]=ie[w]=ie[A]=ie[x]=ie[_]=ie[E]=ie[T]=ie[I]=ie[O]=!1;var oe={};oe[g]=oe[m]=oe[M]=oe[L]=oe[y]=oe[b]=oe[B]=oe[P]=oe[R]=oe[D]=oe[F]=oe[A]=oe[x]=oe[_]=oe[E]=oe[T]=oe[I]=oe[N]=oe[k]=oe[H]=oe[U]=oe[V]=!0,oe[v]=oe[w]=oe[O]=!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,ge=pe&&ue.process,me=function(){try{return fe&&fe.require&&fe.require("util").types||ge&&ge.binding&&ge.binding("util")}catch(t){}}(),ye=me&&me.isArrayBuffer,be=me&&me.isDate,ve=me&&me.isMap,we=me&&me.isRegExp,Ce=me&&me.isSet,Ae=me&&me.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 _e(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i<o;){var s=t[i];e(r,s,n(s),t)}return r}function Se(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Ee(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Te(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 Ie(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}function Ne(t,e){return!(null==t||!t.length)&&He(t,e,0)>-1}function Oe(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}function Me(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}function Le(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}function Be(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function Pe(t,e,n,r){var i=null==t?0:t.length;for(r&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}function Re(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 De=je("length");function Fe(t,e,n){var r;return n(t,(function(t,n,i){if(e(t,n,i))return r=n,!1})),r}function ke(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}function He(t,e,n){return e==e?function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):ke(t,Ve,n)}function Ue(t,e,n,r){for(var i=n-1,o=t.length;++i<o;)if(r(t[i],e))return i;return-1}function Ve(t){return t!=t}function $e(t,e){var n=null==t?0:t.length;return n?ze(t,e)/n:d}function je(t){return function(e){return null==e?i:e[t]}}function qe(t){return function(e){return null==t?i:t[e]}}function Ge(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}function ze(t,e){for(var n,r=-1,o=t.length;++r<o;){var s=e(t[r]);s!==i&&(n=n===i?s:n+s)}return n}function We(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function Ke(t){return t?t.slice(0,dn(t)+1).replace(rt,""):t}function Ye(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&&He(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&He(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({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});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,i=0,o=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,o[i++]=n)}return o}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):De(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--&&it.test(t.charAt(e)););return e}var fn=qe({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,it=e.Date,Ct=e.Error,At=e.Function,xt=e.Math,_t=e.Object,St=e.RegExp,Et=e.String,Tt=e.TypeError,It=r.prototype,Nt=At.prototype,Ot=_t.prototype,Mt=e["__core-js_shared__"],Lt=Nt.toString,Bt=Ot.hasOwnProperty,Pt=0,Rt=(n=/[^.]+$/.exec(Mt&&Mt.keys&&Mt.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Dt=Ot.toString,Ft=Lt.call(_t),kt=he._,Ht=St("^"+Lt.call(Bt).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ut=pe?e.Buffer:i,Vt=e.Symbol,$t=e.Uint8Array,jt=Ut?Ut.allocUnsafe:i,qt=sn(_t.getPrototypeOf,_t),Gt=_t.create,zt=Ot.propertyIsEnumerable,Wt=It.splice,Kt=Vt?Vt.isConcatSpreadable:i,Yt=Vt?Vt.iterator:i,Xt=Vt?Vt.toStringTag:i,te=function(){try{var t=lo(_t,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ue=it&&it.now!==he.Date.now&&it.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,de=xt.ceil,fe=xt.floor,ge=_t.getOwnPropertySymbols,me=Ut?Ut.isBuffer:i,De=e.isFinite,qe=It.join,gn=sn(_t.keys,_t),mn=xt.max,yn=xt.min,bn=it.now,vn=e.parseInt,wn=xt.random,Cn=It.reverse,An=lo(e,"DataView"),xn=lo(e,"Map"),_n=lo(e,"Promise"),Sn=lo(e,"Set"),En=lo(e,"WeakMap"),Tn=lo(_t,"create"),In=En&&new En,Nn={},On=Fo(An),Mn=Fo(xn),Ln=Fo(_n),Bn=Fo(Sn),Pn=Fo(En),Rn=Vt?Vt.prototype:i,Dn=Rn?Rn.valueOf:i,Fn=Rn?Rn.toString:i;function kn(t){if(ta(t)&&!js(t)&&!(t instanceof $n)){if(t instanceof Vn)return t;if(Bt.call(t,"__wrapped__"))return ko(t)}return new Vn(t)}var Hn=function(){function t(){}return function(e){if(!Zs(e))return{};if(Gt)return Gt(e);t.prototype=e;var n=new t;return t.prototype=i,n}}();function Un(){}function Vn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=i}function $n(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}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 Gn(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 zn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Gn;++e<n;)this.add(t[e])}function Wn(t){var e=this.__data__=new qn(t);this.size=e.size}function Kn(t,e){var n=js(t),r=!n&&$s(t),i=!n&&!r&&Ws(t),o=!n&&!r&&!i&&la(t),s=n||r||i||o,a=s?We(t.length,Et):[],l=a.length;for(var u in t)!e&&!Bt.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||mo(u,l))||a.push(u);return a}function Yn(t){var e=t.length;return e?t[Gr(0,e-1)]:i}function Jn(t,e){return Lo(Ei(t),or(e,0,t.length))}function Qn(t){return Lo(Ei(t))}function Xn(t,e,n){(n!==i&&!Hs(t[e],n)||n===i&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Bt.call(t,e)&&Hs(r,n)&&(n!==i||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(Hs(t[n][0],e))return n;return-1}function er(t,e,n,r){return cr(t,(function(t,i,o){e(r,t,n(t),o)})),r}function nr(t,e){return t&&Ti(e,Oa(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 ir(t,e){for(var n=-1,o=e.length,s=r(o),a=null==t;++n<o;)s[n]=a?i:Sa(t,e[n]);return s}function or(t,e,n){return t==t&&(n!==i&&(t=t<=n?t:n),e!==i&&(t=t>=e?t:e)),t}function sr(t,e,n,r,o,s){var a,l=1&e,u=2&e,c=4&e;if(n&&(a=o?n(t,r,o,s):n(t)),a!==i)return a;if(!Zs(t))return t;var h=js(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Bt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return Ei(t,a)}else{var d=ho(t),f=d==w||d==C;if(Ws(t))return wi(t,l);if(d==_||d==g||f&&!o){if(a=u||f?{}:po(t),!l)return u?function(t,e){return Ti(t,co(t),e)}(t,function(t,e){return t&&Ti(e,Ma(e),t)}(a,t)):function(t,e){return Ti(t,uo(t),e)}(t,nr(a,t))}else{if(!oe[d])return o?t:{};a=function(t,e,n){var r,i=t.constructor;switch(e){case M:return Ci(t);case y:case b:return new i(+t);case L:return function(t,e){var n=e?Ci(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case B:case P:case R:case D:case F:case k:case H:case U:case V:return Ai(t,n);case A:return new i;case x:case I:return new i(t);case E:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case T:return new i;case N:return r=t,Dn?_t(Dn.call(r)):{}}}(t,d,l)}}s||(s=new Wn);var p=s.get(t);if(p)return p;s.set(t,a),oa(t)?t.forEach((function(r){a.add(sr(r,e,n,r,t,s))})):ea(t)&&t.forEach((function(r,i){a.set(i,sr(r,e,n,i,t,s))}));var m=h?i:(c?u?eo:to:u?Ma:Oa)(t);return Se(m||t,(function(r,i){m&&(r=t[i=r]),Zn(a,i,sr(r,e,n,i,t,s))})),a}function ar(t,e,n){var r=n.length;if(null==t)return!r;for(t=_t(t);r--;){var o=n[r],s=e[o],a=t[o];if(a===i&&!(o in t)||!s(a))return!1}return!0}function lr(t,e,n){if("function"!=typeof t)throw new Tt(o);return Io((function(){t.apply(i,n)}),e)}function ur(t,e,n,r){var i=-1,o=Ne,s=!0,a=t.length,l=[],u=e.length;if(!a)return l;n&&(e=Me(e,Ye(n))),r?(o=Oe,s=!1):e.length>=200&&(o=Qe,s=!1,e=new zn(e));t:for(;++i<a;){var c=t[i],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 o(e,h,r)||l.push(c)}return l}kn.templateSettings={escape:Y,evaluate:J,interpolate:Q,variable:"",imports:{_:kn}},kn.prototype=Un.prototype,kn.prototype.constructor=kn,Vn.prototype=Hn(Un.prototype),Vn.prototype.constructor=Vn,$n.prototype=Hn(Un.prototype),$n.prototype.constructor=$n,jn.prototype.clear=function(){this.__data__=Tn?Tn(null):{},this.size=0},jn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},jn.prototype.get=function(t){var e=this.__data__;if(Tn){var n=e[t];return n===s?i:n}return Bt.call(e,t)?e[t]:i},jn.prototype.has=function(t){var e=this.__data__;return Tn?e[t]!==i:Bt.call(e,t)},jn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Tn&&e===i?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():Wt.call(e,n,1),--this.size,0))},qn.prototype.get=function(t){var e=this.__data__,n=tr(e,t);return n<0?i: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},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(xn||qn),string:new jn}},Gn.prototype.delete=function(t){var e=so(this,t).delete(t);return this.size-=e?1:0,e},Gn.prototype.get=function(t){return so(this,t).get(t)},Gn.prototype.has=function(t){return so(this,t).has(t)},Gn.prototype.set=function(t,e){var n=so(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},zn.prototype.add=zn.prototype.push=function(t){return this.__data__.set(t,s),this},zn.prototype.has=function(t){return this.__data__.has(t)},Wn.prototype.clear=function(){this.__data__=new qn,this.size=0},Wn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Wn.prototype.get=function(t){return this.__data__.get(t)},Wn.prototype.has=function(t){return this.__data__.has(t)},Wn.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 Gn(r)}return n.set(t,e),this.size=n.size,this};var cr=Oi(br),hr=Oi(vr,!0);function dr(t,e){var n=!0;return cr(t,(function(t,r,i){return n=!!e(t,r,i)})),n}function fr(t,e,n){for(var r=-1,o=t.length;++r<o;){var s=t[r],a=e(s);if(null!=a&&(l===i?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,i){e(t,r,i)&&n.push(t)})),n}function gr(t,e,n,r,i){var o=-1,s=t.length;for(n||(n=go),i||(i=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?gr(a,e-1,n,r,i):Le(i,a):r||(i[i.length]=a)}return i}var mr=Mi(),yr=Mi(!0);function br(t,e){return t&&mr(t,e,Oa)}function vr(t,e){return t&&yr(t,e,Oa)}function wr(t,e){return Ie(e,(function(e){return Js(t[e])}))}function Cr(t,e){for(var n=0,r=(e=mi(e,t)).length;null!=t&&n<r;)t=t[Do(e[n++])];return n&&n==r?t:i}function Ar(t,e,n){var r=e(t);return js(t)?r:Le(r,n(t))}function xr(t){return null==t?t===i?"[object Undefined]":"[object Null]":Xt&&Xt in _t(t)?function(t){var e=Bt.call(t,Xt),n=t[Xt];try{t[Xt]=i;var r=!0}catch(t){}var o=Dt.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),o}(t):function(t){return Dt.call(t)}(t)}function _r(t,e){return t>e}function Sr(t,e){return null!=t&&Bt.call(t,e)}function Er(t,e){return null!=t&&e in _t(t)}function Tr(t,e,n){for(var o=n?Oe: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,Ye(e))),c=yn(d.length,c),u[l]=!n&&(e||s>=120&&d.length>=120)?new zn(l&&d):i}d=t[0];var f=-1,p=u[0];t:for(;++f<s&&h.length<c;){var g=d[f],m=e?e(g):g;if(g=n||0!==g?g:0,!(p?Qe(p,m):o(h,m,n))){for(l=a;--l;){var y=u[l];if(!(y?Qe(y,m):o(t[l],m,n)))continue t}p&&p.push(m),h.push(g)}}return h}function Ir(t,e,n){var r=null==(t=So(t,e=mi(e,t)))?t:t[Do(Yo(e))];return null==r?i:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==g}function Or(t,e,n,r,o){return t===e||(null==t||null==e||!ta(t)&&!ta(e)?t!=t&&e!=e:function(t,e,n,r,o,s){var a=js(t),l=js(e),u=a?m:ho(t),c=l?m:ho(e),h=(u=u==g?_:u)==_,d=(c=c==g?_:c)==_,f=u==c;if(f&&Ws(t)){if(!Ws(e))return!1;a=!0,h=!1}if(f&&!h)return s||(s=new Wn),a||la(t)?Xi(t,e,n,r,o,s):function(t,e,n,r,i,o,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||!o(new $t(t),new $t(e)));case y:case b:case x:return Hs(+t,+e);case v:return t.name==e.name&&t.message==e.message;case E:case I:return t==e+"";case A:var a=on;case T: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=Xi(a(t),a(e),r,i,o,s);return s.delete(t),c;case N:if(Dn)return Dn.call(t)==Dn.call(e)}return!1}(t,e,u,n,r,o,s);if(!(1&n)){var p=h&&Bt.call(t,"__wrapped__"),w=d&&Bt.call(e,"__wrapped__");if(p||w){var C=p?t.value():t,S=w?e.value():e;return s||(s=new Wn),o(C,S,n,r,s)}}return!!f&&(s||(s=new Wn),function(t,e,n,r,o,s){var a=1&n,l=to(t),u=l.length;if(u!=to(e).length&&!a)return!1;for(var c=u;c--;){var h=l[c];if(!(a?h in e:Bt.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 g=a;++c<u;){var m=t[h=l[c]],y=e[h];if(r)var b=a?r(y,m,h,e,t,s):r(m,y,h,t,e,s);if(!(b===i?m===y||o(m,y,n,r,s):b)){p=!1;break}g||(g="constructor"==h)}if(p&&!g){var v=t.constructor,w=e.constructor;v==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof w&&w instanceof w||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,o,s))}(t,e,n,r,Or,o))}function Mr(t,e,n,r){var o=n.length,s=o,a=!r;if(null==t)return!s;for(t=_t(t);o--;){var l=n[o];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++o<s;){var u=(l=n[o])[0],c=t[u],h=l[1];if(a&&l[2]){if(c===i&&!(u in t))return!1}else{var d=new Wn;if(r)var f=r(c,h,u,t,e,d);if(!(f===i?Or(h,c,3,r,d):f))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Rt&&Rt in e))&&(Js(t)?Ht:gt).test(Fo(t));var e}function Br(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?js(t)?kr(t[0],t[1]):Fr(t):hl(t)}function Pr(t){if(!Co(t))return gn(t);var e=[];for(var n in _t(t))Bt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Rr(t,e){return t<e}function Dr(t,e){var n=-1,i=Gs(t)?r(t.length):[];return cr(t,(function(t,r,o){i[++n]=e(t,r,o)})),i}function Fr(t){var e=ao(t);return 1==e.length&&e[0][2]?xo(e[0][0],e[0][1]):function(n){return n===t||Mr(n,t,e)}}function kr(t,e){return bo(t)&&Ao(e)?xo(Do(t),e):function(n){var r=Sa(n,t);return r===i&&r===e?Ea(n,t):Or(e,r,3)}}function Hr(t,e,n,r,o){t!==e&&mr(e,(function(s,a){if(o||(o=new Wn),Zs(s))!function(t,e,n,r,o,s,a){var l=Eo(t,n),u=Eo(e,n),c=a.get(u);if(c)Xn(t,n,c);else{var h=s?s(l,u,n+"",t,e,a):i,d=h===i;if(d){var f=js(u),p=!f&&Ws(u),g=!f&&!p&&la(u);h=u,f||p||g?js(l)?h=l:zs(l)?h=Ei(l):p?(d=!1,h=wi(u,!0)):g?(d=!1,h=Ai(u,!0)):h=[]:ra(u)||$s(u)?(h=l,$s(l)?h=ma(l):Zs(l)&&!Js(l)||(h=po(u))):d=!1}d&&(a.set(u,h),o(h,u,r,s,a),a.delete(u)),Xn(t,n,h)}}(t,e,a,n,Hr,r,o);else{var l=r?r(Eo(t,a),s,a+"",t,e,o):i;l===i&&(l=s),Xn(t,a,l)}}),Ma)}function Ur(t,e){var n=t.length;if(n)return mo(e+=e<0?n:0,n)?t[e]:i}function Vr(t,e,n){e=e.length?Me(e,(function(t){return js(t)?function(e){return Cr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Me(e,Ye(oo()));var i=Dr(t,(function(t,n,i){var o=Me(e,(function(e){return e(t)}));return{criteria:o,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,i=t.criteria,o=e.criteria,s=i.length,a=n.length;++r<s;){var l=xi(i[r],o[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}(i)}function $r(t,e,n){for(var r=-1,i=e.length,o={};++r<i;){var s=e[r],a=Cr(t,s);n(a,s)&&Jr(o,mi(s,t),a)}return o}function jr(t,e,n,r){var i=r?Ue:He,o=-1,s=e.length,a=t;for(t===e&&(e=Ei(e)),n&&(a=Me(t,Ye(n)));++o<s;)for(var l=0,u=e[o],c=n?n(u):u;(l=i(a,c,l,r))>-1;)a!==t&&Wt.call(a,l,1),Wt.call(t,l,1);return t}function qr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;mo(i)?Wt.call(t,i,1):li(t,i)}}return t}function Gr(t,e){return t+fe(wn()*(e-t+1))}function zr(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 Wr(t,e){return No(_o(t,e,nl),t+"")}function Kr(t){return Yn(Ha(t))}function Yr(t,e){var n=Ha(t);return Lo(n,or(e,0,n.length))}function Jr(t,e,n,r){if(!Zs(t))return t;for(var o=-1,s=(e=mi(e,t)).length,a=s-1,l=t;null!=l&&++o<s;){var u=Do(e[o]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(o!=a){var h=l[u];(c=r?r(h,u,l):i)===i&&(c=Zs(h)?h:mo(e[o+1])?[]:{})}Zn(l,u,c),l=l[u]}return t}var Qr=In?function(t,e){return In.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 Lo(Ha(t))}function ti(t,e,n){var i=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i<o;)s[i]=t[i+e];return s}function ei(t,e){var n;return cr(t,(function(t,r,i){return!(n=e(t,r,i))})),!!n}function ni(t,e,n){var r=0,i=null==t?r:t.length;if("number"==typeof e&&e==e&&i<=2147483647){for(;r<i;){var o=r+i>>>1,s=t[o];null!==s&&!aa(s)&&(n?s<=e:s<e)?r=o+1:i=o}return i}return ri(t,e,nl,n)}function ri(t,e,n,r){var o=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===i;o<s;){var h=fe((o+s)/2),d=n(t[h]),f=d!==i,p=null===d,g=d==d,m=aa(d);if(a)var y=r||g;else y=c?g&&(r||f):l?g&&f&&(r||!p):u?g&&f&&!p&&(r||!m):!p&&!m&&(r?d<=e:d<e);y?o=h+1:s=h}return yn(s,4294967294)}function ii(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!Hs(a,l)){var l=a;o[i++]=0===s?0:s}}return o}function oi(t){return"number"==typeof t?t:aa(t)?d:+t}function si(t){if("string"==typeof t)return t;if(js(t))return Me(t,si)+"";if(aa(t))return Fn?Fn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ai(t,e,n){var r=-1,i=Ne,o=t.length,s=!0,a=[],l=a;if(n)s=!1,i=Oe;else if(o>=200){var u=e?null:zi(t);if(u)return ln(u);s=!1,i=Qe,l=new zn}else l=e?[]:a;t:for(;++r<o;){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 i(l,h,n)||(l!==a&&l.push(h),a.push(c))}return a}function li(t,e){return null==(t=So(t,e=mi(e,t)))||delete t[Do(Yo(e))]}function ui(t,e,n,r){return Jr(t,e,n(Cr(t,e)),r)}function ci(t,e,n,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&e(t[o],o,t););return n?ti(t,r?0:o,r?o+1:i):ti(t,r?o+1:0,r?i:o)}function hi(t,e){var n=t;return n instanceof $n&&(n=n.value()),Be(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function di(t,e,n){var i=t.length;if(i<2)return i?ai(t[0]):[];for(var o=-1,s=r(i);++o<i;)for(var a=t[o],l=-1;++l<i;)l!=o&&(s[o]=ur(s[o]||a,t[l],e,n));return ai(gr(s,1),e,n)}function fi(t,e,n){for(var r=-1,o=t.length,s=e.length,a={};++r<o;){var l=r<s?e[r]:i;n(a,t[r],l)}return a}function pi(t){return zs(t)?t:[]}function gi(t){return"function"==typeof t?t:nl}function mi(t,e){return js(t)?t:bo(t,e)?[t]:Ro(ya(t))}var yi=Wr;function bi(t,e,n){var r=t.length;return n=n===i?r:n,!e&&n>=r?t:ti(t,e,n)}var vi=se||function(t){return he.clearTimeout(t)};function wi(t,e){if(e)return t.slice();var n=t.length,r=jt?jt(n):new t.constructor(n);return t.copy(r),r}function Ci(t){var e=new t.constructor(t.byteLength);return new $t(e).set(new $t(t)),e}function Ai(t,e){var n=e?Ci(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function xi(t,e){if(t!==e){var n=t!==i,r=null===t,o=t==t,s=aa(t),a=e!==i,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||!o)return 1;if(!r&&!s&&!c&&t<e||c&&n&&o&&!r&&!s||l&&n&&o||!a&&o||!u)return-1}return 0}function _i(t,e,n,i){for(var o=-1,s=t.length,a=n.length,l=-1,u=e.length,c=mn(s-a,0),h=r(u+c),d=!i;++l<u;)h[l]=e[l];for(;++o<a;)(d||o<s)&&(h[n[o]]=t[o]);for(;c--;)h[l++]=t[o++];return h}function Si(t,e,n,i){for(var o=-1,s=t.length,a=-1,l=n.length,u=-1,c=e.length,h=mn(s-l,0),d=r(h+c),f=!i;++o<h;)d[o]=t[o];for(var p=o;++u<c;)d[p+u]=e[u];for(;++a<l;)(f||o<s)&&(d[p+n[a]]=t[o++]);return d}function Ei(t,e){var n=-1,i=t.length;for(e||(e=r(i));++n<i;)e[n]=t[n];return e}function Ti(t,e,n,r){var o=!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):i;u===i&&(u=t[l]),o?rr(n,l,u):Zn(n,l,u)}return n}function Ii(t,e){return function(n,r){var i=js(n)?_e:er,o=e?e():{};return i(n,t,oo(r,2),o)}}function Ni(t){return Wr((function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:i,a=o>2?n[2]:i;for(s=t.length>3&&"function"==typeof s?(o--,s):i,a&&yo(n[0],n[1],a)&&(s=o<3?i:s,o=1),e=_t(e);++r<o;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Oi(t,e){return function(n,r){if(null==n)return n;if(!Gs(n))return t(n,r);for(var i=n.length,o=e?i:-1,s=_t(n);(e?o--:++o<i)&&!1!==r(s[o],o,s););return n}}function Mi(t){return function(e,n,r){for(var i=-1,o=_t(e),s=r(e),a=s.length;a--;){var l=s[t?a:++i];if(!1===n(o[l],l,o))break}return e}}function Li(t){return function(e){var n=rn(e=ya(e))?hn(e):i,r=n?n[0]:e.charAt(0),o=n?bi(n,1).join(""):e.slice(1);return r[t]()+o}}function Bi(t){return function(e){return Be(Ja($a(e).replace(Jt,"")),t,"")}}function Pi(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=Hn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function Ri(t){return function(e,n,r){var o=_t(e);if(!Gs(e)){var s=oo(n,3);e=Oa(e),n=function(t){return s(o[t],t,o)}}var a=t(e,n,r);return a>-1?o[s?e[a]:a]:i}}function Di(t){return Zi((function(e){var n=e.length,r=n,s=Vn.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new Tt(o);if(s&&!l&&"wrapper"==ro(a))var l=new Vn([],!0)}for(r=l?r:n;++r<n;){var u=ro(a=e[r]),c="wrapper"==u?no(a):i;l=c&&vo(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[ro(c[0])].apply(l,c[3]):1==a.length&&vo(a)?l[u]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&js(r))return l.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i<n;)o=e[i].call(this,o);return o}}))}function Fi(t,e,n,o,s,a,l,c,h,d){var f=e&u,p=1&e,g=2&e,m=24&e,y=512&e,b=g?i:Pi(t);return function u(){for(var v=arguments.length,w=r(v),C=v;C--;)w[C]=arguments[C];if(m)var A=io(u),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(w,A);if(o&&(w=_i(w,o,s,m)),a&&(w=Si(w,a,l,m)),v-=x,m&&v<d){var _=an(w,A);return qi(t,e,Fi,u.placeholder,n,w,_,c,h,d-v)}var S=p?n:this,E=g?S[t]:t;return v=w.length,c?w=function(t,e){for(var n=t.length,r=yn(e.length,n),o=Ei(t);r--;){var s=e[r];t[r]=mo(s,n)?o[s]:i}return t}(w,c):y&&v>1&&w.reverse(),f&&h<v&&(w.length=h),this&&this!==he&&this instanceof u&&(E=b||Pi(E)),E.apply(S,w)}}function ki(t,e){return function(n,r){return function(t,e,n,r){return br(t,(function(t,i,o){e(r,n(t),i,o)})),r}(n,t,e(r),{})}}function Hi(t,e){return function(n,r){var o;if(n===i&&r===i)return e;if(n!==i&&(o=n),r!==i){if(o===i)return r;"string"==typeof n||"string"==typeof r?(n=si(n),r=si(r)):(n=oi(n),r=oi(r)),o=t(n,r)}return o}}function Ui(t){return Zi((function(e){return e=Me(e,Ye(oo())),Wr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function Vi(t,e){var n=(e=e===i?" ":si(e)).length;if(n<2)return n?zr(e,t):e;var r=zr(e,de(t/cn(e)));return rn(e)?bi(hn(r),0,t).join(""):r.slice(0,t)}function $i(t){return function(e,n,o){return o&&"number"!=typeof o&&yo(e,n,o)&&(n=o=i),e=da(e),n===i?(n=e,e=0):n=da(n),function(t,e,n,i){for(var o=-1,s=mn(de((e-t)/(n||1)),0),a=r(s);s--;)a[i?s:++o]=t,t+=n;return a}(e,n,o=o===i?e<n?1:-1:da(o),t)}}function ji(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ga(e),n=ga(n)),t(e,n)}}function qi(t,e,n,r,o,s,a,u,c,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var f=[t,e,o,d?s:i,d?a:i,d?i:s,d?i:a,u,c,h],p=n.apply(i,f);return vo(t)&&To(p,f),p.placeholder=r,Oo(p,t,e)}function Gi(t){var e=xt[t];return function(t,n){if(t=ga(t),(n=null==n?0:yn(fa(n),292))&&De(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 zi=Sn&&1/ln(new Sn([,-0]))[1]==c?function(t){return new Sn(t)}:al;function Wi(t){return function(e){var n=ho(e);return n==A?on(e):n==T?un(e):function(t,e){return Me(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ki(t,e,n,s,c,h,d,f){var p=2&e;if(!p&&"function"!=typeof t)throw new Tt(o);var g=s?s.length:0;if(g||(e&=-97,s=c=i),d=d===i?d:mn(fa(d),0),f=f===i?f:fa(f),g-=c?c.length:0,64&e){var m=s,y=c;s=c=i}var b=p?i:no(t),v=[t,e,n,s,c,m,y,h,d,f];if(b&&function(t,e){var n=t[1],r=e[1],i=n|r,o=i<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(!o&&!s)return t;1&r&&(t[2]=e[2],i|=1&n?0:4);var l=e[3];if(l){var c=t[3];t[3]=c?_i(c,l,e[4]):l,t[4]=c?an(t[3],a):e[4]}(l=e[5])&&(c=t[5],t[5]=c?Si(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]=i}(v,b),t=v[0],e=v[1],n=v[2],s=v[3],c=v[4],!(f=v[9]=v[9]===i?p?0:t.length:mn(v[9]-g,0))&&24&e&&(e&=-25),e&&1!=e)w=8==e||16==e?function(t,e,n){var o=Pi(t);return function s(){for(var a=arguments.length,l=r(a),u=a,c=io(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?qi(t,e,Fi,s.placeholder,i,l,h,i,i,n-a):xe(this&&this!==he&&this instanceof s?o:t,this,l)}}(t,e,f):e!=l&&33!=e||c.length?Fi.apply(i,v):function(t,e,n,i){var o=1&e,s=Pi(t);return function e(){for(var a=-1,l=arguments.length,u=-1,c=i.length,h=r(c+l),d=this&&this!==he&&this instanceof e?s:t;++u<c;)h[u]=i[u];for(;l--;)h[u++]=arguments[++a];return xe(d,o?n:this,h)}}(t,e,n,s);else var w=function(t,e,n){var r=1&e,i=Pi(t);return function e(){return(this&&this!==he&&this instanceof e?i:t).apply(r?n:this,arguments)}}(t,e,n);return Oo((b?Qr:To)(w,v),t,e)}function Yi(t,e,n,r){return t===i||Hs(t,Ot[n])&&!Bt.call(r,n)?e:t}function Ji(t,e,n,r,o,s){return Zs(t)&&Zs(e)&&(s.set(e,t),Hr(t,e,i,Ji,s),s.delete(e)),t}function Qi(t){return ra(t)?i:t}function Xi(t,e,n,r,o,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 zn:i;for(s.set(t,e),s.set(e,t);++d<l;){var g=t[d],m=e[d];if(r)var y=a?r(m,g,d,e,t,s):r(g,m,d,t,e,s);if(y!==i){if(y)continue;f=!1;break}if(p){if(!Re(e,(function(t,e){if(!Qe(p,e)&&(g===t||o(g,t,n,r,s)))return p.push(e)}))){f=!1;break}}else if(g!==m&&!o(g,m,n,r,s)){f=!1;break}}return s.delete(t),s.delete(e),f}function Zi(t){return No(_o(t,i,qo),t+"")}function to(t){return Ar(t,Oa,uo)}function eo(t){return Ar(t,Ma,co)}var no=In?function(t){return In.get(t)}:al;function ro(t){for(var e=t.name+"",n=Nn[e],r=Bt.call(Nn,e)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==t)return i.name}return e}function io(t){return(Bt.call(kn,"placeholder")?kn:t).placeholder}function oo(){var t=kn.iteratee||rl;return t=t===rl?Br:t,arguments.length?t(arguments[0],arguments[1]):t}function so(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function ao(t){for(var e=Oa(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Ao(i)]}return e}function lo(t,e){var n=function(t,e){return null==t?i:t[e]}(t,e);return Lr(n)?n:i}var uo=ge?function(t){return null==t?[]:(t=_t(t),Ie(ge(t),(function(e){return zt.call(t,e)})))}:pl,co=ge?function(t){for(var e=[];t;)Le(e,uo(t)),t=qt(t);return e}:pl,ho=xr;function fo(t,e,n){for(var r=-1,i=(e=mi(e,t)).length,o=!1;++r<i;){var s=Do(e[r]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++r!=i?o:!!(i=null==t?0:t.length)&&Xs(i)&&mo(s,i)&&(js(t)||$s(t))}function po(t){return"function"!=typeof t.constructor||Co(t)?{}:Hn(qt(t))}function go(t){return js(t)||$s(t)||!!(Kt&&t&&t[Kt])}function mo(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 yo(t,e,n){if(!Zs(n))return!1;var r=typeof e;return!!("number"==r?Gs(n)&&mo(e,n.length):"string"==r&&e in n)&&Hs(n[e],t)}function bo(t,e){if(js(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 _t(e)}function vo(t){var e=ro(t),n=kn[e];if("function"!=typeof n||!(e in $n.prototype))return!1;if(t===n)return!0;var r=no(n);return!!r&&t===r[0]}(An&&ho(new An(new ArrayBuffer(1)))!=L||xn&&ho(new xn)!=A||_n&&ho(_n.resolve())!=S||Sn&&ho(new Sn)!=T||En&&ho(new En)!=O)&&(ho=function(t){var e=xr(t),n=e==_?t.constructor:i,r=n?Fo(n):"";if(r)switch(r){case On:return L;case Mn:return A;case Ln:return S;case Bn:return T;case Pn:return O}return e});var wo=Mt?Js:gl;function Co(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ot)}function Ao(t){return t==t&&!Zs(t)}function xo(t,e){return function(n){return null!=n&&n[t]===e&&(e!==i||t in _t(n))}}function _o(t,e,n){return e=mn(e===i?t.length-1:e,0),function(){for(var i=arguments,o=-1,s=mn(i.length-e,0),a=r(s);++o<s;)a[o]=i[e+o];o=-1;for(var l=r(e+1);++o<e;)l[o]=i[o];return l[e]=n(a),xe(t,this,l)}}function So(t,e){return e.length<2?t:Cr(t,ti(e,0,-1))}function Eo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var To=Mo(Qr),Io=ce||function(t,e){return he.setTimeout(t,e)},No=Mo(Xr);function Oo(t,e,n){var r=e+"";return No(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(ot,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Se(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 Mo(t){var e=0,n=0;return function(){var r=bn(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(i,arguments)}}function Lo(t,e){var n=-1,r=t.length,o=r-1;for(e=e===i?r:e;++n<e;){var s=Gr(n,o),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Bo,Po,Ro=(Bo=Bs((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,i){e.push(r?i.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Po.size&&Po.clear(),t})),Po=Bo.cache,Bo);function Do(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fo(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function ko(t){if(t instanceof $n)return t.clone();var e=new Vn(t.__wrapped__,t.__chain__);return e.__actions__=Ei(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Ho=Wr((function(t,e){return zs(t)?ur(t,gr(e,1,zs,!0)):[]})),Uo=Wr((function(t,e){var n=Yo(e);return zs(n)&&(n=i),zs(t)?ur(t,gr(e,1,zs,!0),oo(n,2)):[]})),Vo=Wr((function(t,e){var n=Yo(e);return zs(n)&&(n=i),zs(t)?ur(t,gr(e,1,zs,!0),i,n):[]}));function $o(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:fa(n);return i<0&&(i=mn(r+i,0)),ke(t,oo(e,3),i)}function jo(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r-1;return n!==i&&(o=fa(n),o=n<0?mn(r+o,0):yn(o,r-1)),ke(t,oo(e,3),o,!0)}function qo(t){return null!=t&&t.length?gr(t,1):[]}function Go(t){return t&&t.length?t[0]:i}var zo=Wr((function(t){var e=Me(t,pi);return e.length&&e[0]===t[0]?Tr(e):[]})),Wo=Wr((function(t){var e=Yo(t),n=Me(t,pi);return e===Yo(n)?e=i:n.pop(),n.length&&n[0]===t[0]?Tr(n,oo(e,2)):[]})),Ko=Wr((function(t){var e=Yo(t),n=Me(t,pi);return(e="function"==typeof e?e:i)&&n.pop(),n.length&&n[0]===t[0]?Tr(n,i,e):[]}));function Yo(t){var e=null==t?0:t.length;return e?t[e-1]:i}var Jo=Wr(Qo);function Qo(t,e){return t&&t.length&&e&&e.length?jr(t,e):t}var Xo=Zi((function(t,e){var n=null==t?0:t.length,r=ir(t,e);return qr(t,Me(e,(function(t){return mo(t,n)?+t:t})).sort(xi)),r}));function Zo(t){return null==t?t:Cn.call(t)}var ts=Wr((function(t){return ai(gr(t,1,zs,!0))})),es=Wr((function(t){var e=Yo(t);return zs(e)&&(e=i),ai(gr(t,1,zs,!0),oo(e,2))})),ns=Wr((function(t){var e=Yo(t);return e="function"==typeof e?e:i,ai(gr(t,1,zs,!0),i,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=Ie(t,(function(t){if(zs(t))return e=mn(t.length,e),!0})),We(e,(function(e){return Me(t,je(e))}))}function is(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Me(n,(function(t){return xe(e,i,t)}))}var os=Wr((function(t,e){return zs(t)?ur(t,e):[]})),ss=Wr((function(t){return di(Ie(t,zs))})),as=Wr((function(t){var e=Yo(t);return zs(e)&&(e=i),di(Ie(t,zs),oo(e,2))})),ls=Wr((function(t){var e=Yo(t);return e="function"==typeof e?e:i,di(Ie(t,zs),i,e)})),us=Wr(rs),cs=Wr((function(t){var e=t.length,n=e>1?t[e-1]:i;return n="function"==typeof n?(t.pop(),n):i,is(t,n)}));function hs(t){var e=kn(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var fs=Zi((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return ir(e,t)};return!(e>1||this.__actions__.length)&&r instanceof $n&&mo(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:ds,args:[o],thisArg:i}),new Vn(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(i),t}))):this.thru(o)})),ps=Ii((function(t,e,n){Bt.call(t,n)?++t[n]:rr(t,n,1)})),gs=Ri($o),ms=Ri(jo);function ys(t,e){return(js(t)?Se:cr)(t,oo(e,3))}function bs(t,e){return(js(t)?Ee:hr)(t,oo(e,3))}var vs=Ii((function(t,e,n){Bt.call(t,n)?t[n].push(e):rr(t,n,[e])})),ws=Wr((function(t,e,n){var i=-1,o="function"==typeof e,s=Gs(t)?r(t.length):[];return cr(t,(function(t){s[++i]=o?xe(e,t,n):Ir(t,e,n)})),s})),Cs=Ii((function(t,e,n){rr(t,n,e)}));function As(t,e){return(js(t)?Me:Dr)(t,oo(e,3))}var xs=Ii((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),_s=Wr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&yo(t,e[0],e[1])?e=[]:n>2&&yo(e[0],e[1],e[2])&&(e=[e[0]]),Vr(t,gr(e,1),[])})),Ss=ue||function(){return he.Date.now()};function Es(t,e,n){return e=n?i:e,e=t&&null==e?t.length:e,Ki(t,u,i,i,i,i,e)}function Ts(t,e){var n;if("function"!=typeof e)throw new Tt(o);return t=fa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=i),n}}var Is=Wr((function(t,e,n){var r=1;if(n.length){var i=an(n,io(Is));r|=l}return Ki(t,r,e,n,i)})),Ns=Wr((function(t,e,n){var r=3;if(n.length){var i=an(n,io(Ns));r|=l}return Ki(e,r,t,n,i)}));function Os(t,e,n){var r,s,a,l,u,c,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new Tt(o);function g(e){var n=r,o=s;return r=s=i,h=e,l=t.apply(o,n)}function m(t){var n=t-c;return c===i||n>=e||n<0||f&&t-h>=a}function y(){var t=Ss();if(m(t))return b(t);u=Io(y,function(t){var n=e-(t-c);return f?yn(n,a-(t-h)):n}(t))}function b(t){return u=i,p&&r?g(t):(r=s=i,l)}function v(){var t=Ss(),n=m(t);if(r=arguments,s=this,c=t,n){if(u===i)return function(t){return h=t,u=Io(y,e),d?g(t):l}(c);if(f)return vi(u),u=Io(y,e),g(c)}return u===i&&(u=Io(y,e)),l}return e=ga(e)||0,Zs(n)&&(d=!!n.leading,a=(f="maxWait"in n)?mn(ga(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){u!==i&&vi(u),h=0,r=c=s=u=i},v.flush=function(){return u===i?l:b(Ss())},v}var Ms=Wr((function(t,e){return lr(t,1,e)})),Ls=Wr((function(t,e,n){return lr(t,ga(e)||0,n)}));function Bs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Tt(o);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Bs.Cache||Gn),n}function Ps(t){if("function"!=typeof t)throw new Tt(o);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)}}Bs.Cache=Gn;var Rs=yi((function(t,e){var n=(e=1==e.length&&js(e[0])?Me(e[0],Ye(oo())):Me(gr(e,1),Ye(oo()))).length;return Wr((function(r){for(var i=-1,o=yn(r.length,n);++i<o;)r[i]=e[i].call(this,r[i]);return xe(t,this,r)}))})),Ds=Wr((function(t,e){var n=an(e,io(Ds));return Ki(t,l,i,e,n)})),Fs=Wr((function(t,e){var n=an(e,io(Fs));return Ki(t,64,i,e,n)})),ks=Zi((function(t,e){return Ki(t,256,i,i,i,e)}));function Hs(t,e){return t===e||t!=t&&e!=e}var Us=ji(_r),Vs=ji((function(t,e){return t>=e})),$s=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Bt.call(t,"callee")&&!zt.call(t,"callee")},js=r.isArray,qs=ye?Ye(ye):function(t){return ta(t)&&xr(t)==M};function Gs(t){return null!=t&&Xs(t.length)&&!Js(t)}function zs(t){return ta(t)&&Gs(t)}var Ws=me||gl,Ks=be?Ye(be):function(t){return ta(t)&&xr(t)==b};function Ys(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==w||e==C||"[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?Ye(ve):function(t){return ta(t)&&ho(t)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=_)return!1;var e=qt(t);if(null===e)return!0;var n=Bt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Ft}var ia=we?Ye(we):function(t){return ta(t)&&xr(t)==E},oa=Ce?Ye(Ce):function(t){return ta(t)&&ho(t)==T};function sa(t){return"string"==typeof t||!js(t)&&ta(t)&&xr(t)==I}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var la=Ae?Ye(Ae):function(t){return ta(t)&&Xs(t.length)&&!!ie[xr(t)]},ua=ji(Rr),ca=ji((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(Gs(t))return sa(t)?hn(t):Ei(t);if(Yt&&t[Yt])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Yt]());var e=ho(t);return(e==A?on:e==T?ln:Ha)(t)}function da(t){return t?(t=ga(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?or(fa(t),0,f):0}function ga(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=Ke(t);var n=pt.test(t);return n||mt.test(t)?le(t.slice(2),n?2:8):ft.test(t)?d:+t}function ma(t){return Ti(t,Ma(t))}function ya(t){return null==t?"":si(t)}var ba=Ni((function(t,e){if(Co(e)||Gs(e))Ti(e,Oa(e),t);else for(var n in e)Bt.call(e,n)&&Zn(t,n,e[n])})),va=Ni((function(t,e){Ti(e,Ma(e),t)})),wa=Ni((function(t,e,n,r){Ti(e,Ma(e),t,r)})),Ca=Ni((function(t,e,n,r){Ti(e,Oa(e),t,r)})),Aa=Zi(ir),xa=Wr((function(t,e){t=_t(t);var n=-1,r=e.length,o=r>2?e[2]:i;for(o&&yo(e[0],e[1],o)&&(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===i||Hs(h,Ot[c])&&!Bt.call(t,c))&&(t[c]=s[c])}return t})),_a=Wr((function(t){return t.push(i,Ji),xe(Ba,i,t)}));function Sa(t,e,n){var r=null==t?i:Cr(t,e);return r===i?n:r}function Ea(t,e){return null!=t&&fo(t,e,Er)}var Ta=ki((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),t[e]=n}),Za(nl)),Ia=ki((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),Bt.call(t,e)?t[e].push(n):t[e]=[n]}),oo),Na=Wr(Ir);function Oa(t){return Gs(t)?Kn(t):Pr(t)}function Ma(t){return Gs(t)?Kn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in _t(t))e.push(n);return e}(t);var e=Co(t),n=[];for(var r in t)("constructor"!=r||!e&&Bt.call(t,r))&&n.push(r);return n}(t)}var La=Ni((function(t,e,n){Hr(t,e,n)})),Ba=Ni((function(t,e,n,r){Hr(t,e,n,r)})),Pa=Zi((function(t,e){var n={};if(null==t)return n;var r=!1;e=Me(e,(function(e){return e=mi(e,t),r||(r=e.length>1),e})),Ti(t,eo(t),n),r&&(n=sr(n,7,Qi));for(var i=e.length;i--;)li(n,e[i]);return n})),Ra=Zi((function(t,e){return null==t?{}:function(t,e){return $r(t,e,(function(e,n){return Ea(t,n)}))}(t,e)}));function Da(t,e){if(null==t)return{};var n=Me(eo(t),(function(t){return[t]}));return e=oo(e),$r(t,n,(function(t,n){return e(t,n[0])}))}var Fa=Wi(Oa),ka=Wi(Ma);function Ha(t){return null==t?[]:Je(t,Oa(t))}var Ua=Bi((function(t,e,n){return e=e.toLowerCase(),t+(n?Va(e):e)}));function Va(t){return Ya(ya(t).toLowerCase())}function $a(t){return(t=ya(t))&&t.replace(bt,tn).replace(Qt,"")}var ja=Bi((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),qa=Bi((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Ga=Li("toLowerCase"),za=Bi((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),Wa=Bi((function(t,e,n){return t+(n?" ":"")+Ya(e)})),Ka=Bi((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ya=Li("toUpperCase");function Ja(t,e,n){return t=ya(t),(e=n?i:e)===i?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=Wr((function(t,e){try{return xe(t,i,e)}catch(t){return Ys(t)?t:new Ct(t)}})),Xa=Zi((function(t,e){return Se(e,(function(e){e=Do(e),rr(t,e,Is(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Di(),el=Di(!0);function nl(t){return t}function rl(t){return Br("function"==typeof t?t:sr(t,1))}var il=Wr((function(t,e){return function(n){return Ir(n,t,e)}})),ol=Wr((function(t,e){return function(n){return Ir(t,n,e)}}));function sl(t,e,n){var r=Oa(e),i=wr(e,r);null!=n||Zs(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=wr(e,Oa(e)));var o=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Se(i,(function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__);return(n.__actions__=Ei(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=Ui(Me),ul=Ui(Te),cl=Ui(Re);function hl(t){return bo(t)?je(Do(t)):function(t){return function(e){return Cr(e,t)}}(t)}var dl=$i(),fl=$i(!0);function pl(){return[]}function gl(){return!1}var ml,yl=Hi((function(t,e){return t+e}),0),bl=Gi("ceil"),vl=Hi((function(t,e){return t/e}),1),wl=Gi("floor"),Cl=Hi((function(t,e){return t*e}),1),Al=Gi("round"),xl=Hi((function(t,e){return t-e}),0);return kn.after=function(t,e){if("function"!=typeof e)throw new Tt(o);return t=fa(t),function(){if(--t<1)return e.apply(this,arguments)}},kn.ary=Es,kn.assign=ba,kn.assignIn=va,kn.assignInWith=wa,kn.assignWith=Ca,kn.at=Aa,kn.before=Ts,kn.bind=Is,kn.bindAll=Xa,kn.bindKey=Ns,kn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return js(t)?t:[t]},kn.chain=hs,kn.chunk=function(t,e,n){e=(n?yo(t,e,n):e===i)?1:mn(fa(e),0);var o=null==t?0:t.length;if(!o||e<1)return[];for(var s=0,a=0,l=r(de(o/e));s<o;)l[a++]=ti(t,s,s+=e);return l},kn.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i},kn.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],i=t;i--;)e[i-1]=arguments[i];return Le(js(n)?Ei(n):[n],gr(e,1))},kn.cond=function(t){var e=null==t?0:t.length,n=oo();return t=e?Me(t,(function(t){if("function"!=typeof t[1])throw new Tt(o);return[n(t[0]),t[1]]})):[],Wr((function(n){for(var r=-1;++r<e;){var i=t[r];if(xe(i[0],this,n))return xe(i[1],this,n)}}))},kn.conforms=function(t){return function(t){var e=Oa(t);return function(n){return ar(n,t,e)}}(sr(t,1))},kn.constant=Za,kn.countBy=ps,kn.create=function(t,e){var n=Hn(t);return null==e?n:nr(n,e)},kn.curry=function t(e,n,r){var o=Ki(e,8,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},kn.curryRight=function t(e,n,r){var o=Ki(e,16,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},kn.debounce=Os,kn.defaults=xa,kn.defaultsDeep=_a,kn.defer=Ms,kn.delay=Ls,kn.difference=Ho,kn.differenceBy=Uo,kn.differenceWith=Vo,kn.drop=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,(e=n||e===i?1:fa(e))<0?0:e,r):[]},kn.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,0,(e=r-(e=n||e===i?1:fa(e)))<0?0:e):[]},kn.dropRightWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!0,!0):[]},kn.dropWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!0):[]},kn.fill=function(t,e,n,r){var o=null==t?0:t.length;return o?(n&&"number"!=typeof n&&yo(t,e,n)&&(n=0,r=o),function(t,e,n,r){var o=t.length;for((n=fa(n))<0&&(n=-n>o?0:o+n),(r=r===i||r>o?o:fa(r))<0&&(r+=o),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},kn.filter=function(t,e){return(js(t)?Ie:pr)(t,oo(e,3))},kn.flatMap=function(t,e){return gr(As(t,e),1)},kn.flatMapDeep=function(t,e){return gr(As(t,e),c)},kn.flatMapDepth=function(t,e,n){return n=n===i?1:fa(n),gr(As(t,e),n)},kn.flatten=qo,kn.flattenDeep=function(t){return null!=t&&t.length?gr(t,c):[]},kn.flattenDepth=function(t,e){return null!=t&&t.length?gr(t,e=e===i?1:fa(e)):[]},kn.flip=function(t){return Ki(t,512)},kn.flow=tl,kn.flowRight=el,kn.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var i=t[e];r[i[0]]=i[1]}return r},kn.functions=function(t){return null==t?[]:wr(t,Oa(t))},kn.functionsIn=function(t){return null==t?[]:wr(t,Ma(t))},kn.groupBy=vs,kn.initial=function(t){return null!=t&&t.length?ti(t,0,-1):[]},kn.intersection=zo,kn.intersectionBy=Wo,kn.intersectionWith=Ko,kn.invert=Ta,kn.invertBy=Ia,kn.invokeMap=ws,kn.iteratee=rl,kn.keyBy=Cs,kn.keys=Oa,kn.keysIn=Ma,kn.map=As,kn.mapKeys=function(t,e){var n={};return e=oo(e,3),br(t,(function(t,r,i){rr(n,e(t,r,i),t)})),n},kn.mapValues=function(t,e){var n={};return e=oo(e,3),br(t,(function(t,r,i){rr(n,r,e(t,r,i))})),n},kn.matches=function(t){return Fr(sr(t,1))},kn.matchesProperty=function(t,e){return kr(t,sr(e,1))},kn.memoize=Bs,kn.merge=La,kn.mergeWith=Ba,kn.method=il,kn.methodOf=ol,kn.mixin=sl,kn.negate=Ps,kn.nthArg=function(t){return t=fa(t),Wr((function(e){return Ur(e,t)}))},kn.omit=Pa,kn.omitBy=function(t,e){return Da(t,Ps(oo(e)))},kn.once=function(t){return Ts(2,t)},kn.orderBy=function(t,e,n,r){return null==t?[]:(js(e)||(e=null==e?[]:[e]),js(n=r?i:n)||(n=null==n?[]:[n]),Vr(t,e,n))},kn.over=ll,kn.overArgs=Rs,kn.overEvery=ul,kn.overSome=cl,kn.partial=Ds,kn.partialRight=Fs,kn.partition=xs,kn.pick=Ra,kn.pickBy=Da,kn.property=hl,kn.propertyOf=function(t){return function(e){return null==t?i:Cr(t,e)}},kn.pull=Jo,kn.pullAll=Qo,kn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,oo(n,2)):t},kn.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?jr(t,e,i,n):t},kn.pullAt=Xo,kn.range=dl,kn.rangeRight=fl,kn.rearg=ks,kn.reject=function(t,e){return(js(t)?Ie:pr)(t,Ps(oo(e,3)))},kn.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,i=[],o=t.length;for(e=oo(e,3);++r<o;){var s=t[r];e(s,r,t)&&(n.push(s),i.push(r))}return qr(t,i),n},kn.rest=function(t,e){if("function"!=typeof t)throw new Tt(o);return Wr(t,e=e===i?e:fa(e))},kn.reverse=Zo,kn.sampleSize=function(t,e,n){return e=(n?yo(t,e,n):e===i)?1:fa(e),(js(t)?Jn:Yr)(t,e)},kn.set=function(t,e,n){return null==t?t:Jr(t,e,n)},kn.setWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:Jr(t,e,n,r)},kn.shuffle=function(t){return(js(t)?Qn:Zr)(t)},kn.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&yo(t,e,n)?(e=0,n=r):(e=null==e?0:fa(e),n=n===i?r:fa(n)),ti(t,e,n)):[]},kn.sortBy=_s,kn.sortedUniq=function(t){return t&&t.length?ii(t):[]},kn.sortedUniqBy=function(t,e){return t&&t.length?ii(t,oo(e,2)):[]},kn.split=function(t,e,n){return n&&"number"!=typeof n&&yo(t,e,n)&&(e=n=i),(n=n===i?f:n>>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!ia(e))&&!(e=si(e))&&rn(t)?bi(hn(t),0,n):t.split(e,n):[]},kn.spread=function(t,e){if("function"!=typeof t)throw new Tt(o);return e=null==e?0:mn(fa(e),0),Wr((function(n){var r=n[e],i=bi(n,0,e);return r&&Le(i,r),xe(t,this,i)}))},kn.tail=function(t){var e=null==t?0:t.length;return e?ti(t,1,e):[]},kn.take=function(t,e,n){return t&&t.length?ti(t,0,(e=n||e===i?1:fa(e))<0?0:e):[]},kn.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?ti(t,(e=r-(e=n||e===i?1:fa(e)))<0?0:e,r):[]},kn.takeRightWhile=function(t,e){return t&&t.length?ci(t,oo(e,3),!1,!0):[]},kn.takeWhile=function(t,e){return t&&t.length?ci(t,oo(e,3)):[]},kn.tap=function(t,e){return e(t),t},kn.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new Tt(o);return Zs(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Os(t,e,{leading:r,maxWait:e,trailing:i})},kn.thru=ds,kn.toArray=ha,kn.toPairs=Fa,kn.toPairsIn=ka,kn.toPath=function(t){return js(t)?Me(t,Do):aa(t)?[t]:Ei(Ro(ya(t)))},kn.toPlainObject=ma,kn.transform=function(t,e,n){var r=js(t),i=r||Ws(t)||la(t);if(e=oo(e,4),null==n){var o=t&&t.constructor;n=i?r?new o:[]:Zs(t)&&Js(o)?Hn(qt(t)):{}}return(i?Se:br)(t,(function(t,r,i){return e(n,t,r,i)})),n},kn.unary=function(t){return Es(t,1)},kn.union=ts,kn.unionBy=es,kn.unionWith=ns,kn.uniq=function(t){return t&&t.length?ai(t):[]},kn.uniqBy=function(t,e){return t&&t.length?ai(t,oo(e,2)):[]},kn.uniqWith=function(t,e){return e="function"==typeof e?e:i,t&&t.length?ai(t,i,e):[]},kn.unset=function(t,e){return null==t||li(t,e)},kn.unzip=rs,kn.unzipWith=is,kn.update=function(t,e,n){return null==t?t:ui(t,e,gi(n))},kn.updateWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:ui(t,e,gi(n),r)},kn.values=Ha,kn.valuesIn=function(t){return null==t?[]:Je(t,Ma(t))},kn.without=os,kn.words=Ja,kn.wrap=function(t,e){return Ds(gi(e),t)},kn.xor=ss,kn.xorBy=as,kn.xorWith=ls,kn.zip=us,kn.zipObject=function(t,e){return fi(t||[],e||[],Zn)},kn.zipObjectDeep=function(t,e){return fi(t||[],e||[],Jr)},kn.zipWith=cs,kn.entries=Fa,kn.entriesIn=ka,kn.extend=va,kn.extendWith=wa,sl(kn,kn),kn.add=yl,kn.attempt=Qa,kn.camelCase=Ua,kn.capitalize=Va,kn.ceil=bl,kn.clamp=function(t,e,n){return n===i&&(n=e,e=i),n!==i&&(n=(n=ga(n))==n?n:0),e!==i&&(e=(e=ga(e))==e?e:0),or(ga(t),e,n)},kn.clone=function(t){return sr(t,4)},kn.cloneDeep=function(t){return sr(t,5)},kn.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:i)},kn.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:i)},kn.conformsTo=function(t,e){return null==e||ar(t,e,Oa(e))},kn.deburr=$a,kn.defaultTo=function(t,e){return null==t||t!=t?e:t},kn.divide=vl,kn.endsWith=function(t,e,n){t=ya(t),e=si(e);var r=t.length,o=n=n===i?r:or(fa(n),0,r);return(n-=e.length)>=0&&t.slice(n,o)==e},kn.eq=Hs,kn.escape=function(t){return(t=ya(t))&&K.test(t)?t.replace(z,en):t},kn.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},kn.every=function(t,e,n){var r=js(t)?Te:dr;return n&&yo(t,e,n)&&(e=i),r(t,oo(e,3))},kn.find=gs,kn.findIndex=$o,kn.findKey=function(t,e){return Fe(t,oo(e,3),br)},kn.findLast=ms,kn.findLastIndex=jo,kn.findLastKey=function(t,e){return Fe(t,oo(e,3),vr)},kn.floor=wl,kn.forEach=ys,kn.forEachRight=bs,kn.forIn=function(t,e){return null==t?t:mr(t,oo(e,3),Ma)},kn.forInRight=function(t,e){return null==t?t:yr(t,oo(e,3),Ma)},kn.forOwn=function(t,e){return t&&br(t,oo(e,3))},kn.forOwnRight=function(t,e){return t&&vr(t,oo(e,3))},kn.get=Sa,kn.gt=Us,kn.gte=Vs,kn.has=function(t,e){return null!=t&&fo(t,e,Sr)},kn.hasIn=Ea,kn.head=Go,kn.identity=nl,kn.includes=function(t,e,n,r){t=Gs(t)?t:Ha(t),n=n&&!r?fa(n):0;var i=t.length;return n<0&&(n=mn(i+n,0)),sa(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&He(t,e,n)>-1},kn.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:fa(n);return i<0&&(i=mn(r+i,0)),He(t,e,i)},kn.inRange=function(t,e,n){return e=da(e),n===i?(n=e,e=0):n=da(n),function(t,e,n){return t>=yn(e,n)&&t<mn(e,n)}(t=ga(t),e,n)},kn.invoke=Na,kn.isArguments=$s,kn.isArray=js,kn.isArrayBuffer=qs,kn.isArrayLike=Gs,kn.isArrayLikeObject=zs,kn.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},kn.isBuffer=Ws,kn.isDate=Ks,kn.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},kn.isEmpty=function(t){if(null==t)return!0;if(Gs(t)&&(js(t)||"string"==typeof t||"function"==typeof t.splice||Ws(t)||la(t)||$s(t)))return!t.length;var e=ho(t);if(e==A||e==T)return!t.size;if(Co(t))return!Pr(t).length;for(var n in t)if(Bt.call(t,n))return!1;return!0},kn.isEqual=function(t,e){return Or(t,e)},kn.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:i)?n(t,e):i;return r===i?Or(t,e,i,n):!!r},kn.isError=Ys,kn.isFinite=function(t){return"number"==typeof t&&De(t)},kn.isFunction=Js,kn.isInteger=Qs,kn.isLength=Xs,kn.isMap=ea,kn.isMatch=function(t,e){return t===e||Mr(t,e,ao(e))},kn.isMatchWith=function(t,e,n){return n="function"==typeof n?n:i,Mr(t,e,ao(e),n)},kn.isNaN=function(t){return na(t)&&t!=+t},kn.isNative=function(t){if(wo(t))throw new Ct("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},kn.isNil=function(t){return null==t},kn.isNull=function(t){return null===t},kn.isNumber=na,kn.isObject=Zs,kn.isObjectLike=ta,kn.isPlainObject=ra,kn.isRegExp=ia,kn.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},kn.isSet=oa,kn.isString=sa,kn.isSymbol=aa,kn.isTypedArray=la,kn.isUndefined=function(t){return t===i},kn.isWeakMap=function(t){return ta(t)&&ho(t)==O},kn.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},kn.join=function(t,e){return null==t?"":qe.call(t,e)},kn.kebabCase=ja,kn.last=Yo,kn.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=fa(n))<0?mn(r+o,0):yn(o,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,o):ke(t,Ve,o,!0)},kn.lowerCase=qa,kn.lowerFirst=Ga,kn.lt=ua,kn.lte=ca,kn.max=function(t){return t&&t.length?fr(t,nl,_r):i},kn.maxBy=function(t,e){return t&&t.length?fr(t,oo(e,2),_r):i},kn.mean=function(t){return $e(t,nl)},kn.meanBy=function(t,e){return $e(t,oo(e,2))},kn.min=function(t){return t&&t.length?fr(t,nl,Rr):i},kn.minBy=function(t,e){return t&&t.length?fr(t,oo(e,2),Rr):i},kn.stubArray=pl,kn.stubFalse=gl,kn.stubObject=function(){return{}},kn.stubString=function(){return""},kn.stubTrue=function(){return!0},kn.multiply=Cl,kn.nth=function(t,e){return t&&t.length?Ur(t,fa(e)):i},kn.noConflict=function(){return he._===this&&(he._=kt),this},kn.noop=al,kn.now=Ss,kn.pad=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return Vi(fe(i),n)+t+Vi(de(i),n)},kn.padEnd=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?t+Vi(e-r,n):t},kn.padStart=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?Vi(e-r,n)+t:t},kn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},kn.random=function(t,e,n){if(n&&"boolean"!=typeof n&&yo(t,e,n)&&(e=n=i),n===i&&("boolean"==typeof e?(n=e,e=i):"boolean"==typeof t&&(n=t,t=i)),t===i&&e===i?(t=0,e=1):(t=da(t),e===i?(e=t,t=0):e=da(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var o=wn();return yn(t+o*(e-t+ae("1e-"+((o+"").length-1))),e)}return Gr(t,e)},kn.reduce=function(t,e,n){var r=js(t)?Be:Ge,i=arguments.length<3;return r(t,oo(e,4),n,i,cr)},kn.reduceRight=function(t,e,n){var r=js(t)?Pe:Ge,i=arguments.length<3;return r(t,oo(e,4),n,i,hr)},kn.repeat=function(t,e,n){return e=(n?yo(t,e,n):e===i)?1:fa(e),zr(ya(t),e)},kn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},kn.result=function(t,e,n){var r=-1,o=(e=mi(e,t)).length;for(o||(o=1,t=i);++r<o;){var s=null==t?i:t[Do(e[r])];s===i&&(r=o,s=n),t=Js(s)?s.call(t):s}return t},kn.round=Al,kn.runInContext=t,kn.sample=function(t){return(js(t)?Yn:Kr)(t)},kn.size=function(t){if(null==t)return 0;if(Gs(t))return sa(t)?cn(t):t.length;var e=ho(t);return e==A||e==T?t.size:Pr(t).length},kn.snakeCase=za,kn.some=function(t,e,n){var r=js(t)?Re:ei;return n&&yo(t,e,n)&&(e=i),r(t,oo(e,3))},kn.sortedIndex=function(t,e){return ni(t,e)},kn.sortedIndexBy=function(t,e,n){return ri(t,e,oo(n,2))},kn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=ni(t,e);if(r<n&&Hs(t[r],e))return r}return-1},kn.sortedLastIndex=function(t,e){return ni(t,e,!0)},kn.sortedLastIndexBy=function(t,e,n){return ri(t,e,oo(n,2),!0)},kn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=ni(t,e,!0)-1;if(Hs(t[n],e))return n}return-1},kn.startCase=Wa,kn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:or(fa(n),0,t.length),e=si(e),t.slice(n,n+e.length)==e},kn.subtract=xl,kn.sum=function(t){return t&&t.length?ze(t,nl):0},kn.sumBy=function(t,e){return t&&t.length?ze(t,oo(e,2)):0},kn.template=function(t,e,n){var r=kn.templateSettings;n&&yo(t,e,n)&&(e=i),t=ya(t),e=wa({},e,r,Yi);var o,s,a=wa({},e.imports,r.imports,Yi),l=Oa(a),u=Je(a,l),c=0,h=e.interpolate||vt,d="__p += '",f=St((e.escape||vt).source+"|"+h.source+"|"+(h===Q?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),p="//# sourceURL="+(Bt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(f,(function(e,n,r,i,a,l){return r||(r=i),d+=t.slice(c,l).replace(wt,nn),n&&(o=!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 g=Bt.call(e,"variable")&&e.variable;if(g){if(ut.test(g))throw new Ct("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace($,""):d).replace(j,"$1").replace(q,"$1;"),d="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var m=Qa((function(){return At(l,p+"return "+d).apply(i,u)}));if(m.source=d,Ys(m))throw m;return m},kn.times=function(t,e){if((t=fa(t))<1||t>h)return[];var n=f,r=yn(t,f);e=oo(e),t-=f;for(var i=We(r,e);++n<t;)e(n);return i},kn.toFinite=da,kn.toInteger=fa,kn.toLength=pa,kn.toLower=function(t){return ya(t).toLowerCase()},kn.toNumber=ga,kn.toSafeInteger=function(t){return t?or(fa(t),-9007199254740991,h):0===t?t:0},kn.toString=ya,kn.toUpper=function(t){return ya(t).toUpperCase()},kn.trim=function(t,e,n){if((t=ya(t))&&(n||e===i))return Ke(t);if(!t||!(e=si(e)))return t;var r=hn(t),o=hn(e);return bi(r,Xe(r,o),Ze(r,o)+1).join("")},kn.trimEnd=function(t,e,n){if((t=ya(t))&&(n||e===i))return t.slice(0,dn(t)+1);if(!t||!(e=si(e)))return t;var r=hn(t);return bi(r,0,Ze(r,hn(e))+1).join("")},kn.trimStart=function(t,e,n){if((t=ya(t))&&(n||e===i))return t.replace(rt,"");if(!t||!(e=si(e)))return t;var r=hn(t);return bi(r,Xe(r,hn(e))).join("")},kn.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var o="separator"in e?e.separator:o;n="length"in e?fa(e.length):n,r="omission"in e?si(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?bi(a,0,l).join(""):t.slice(0,l);if(o===i)return u+r;if(a&&(l+=u.length-l),ia(o)){if(t.slice(l).search(o)){var c,h=u;for(o.global||(o=St(o.source,ya(dt.exec(o))+"g")),o.lastIndex=0;c=o.exec(h);)var d=c.index;u=u.slice(0,d===i?l:d)}}else if(t.indexOf(si(o),l)!=l){var f=u.lastIndexOf(o);f>-1&&(u=u.slice(0,f))}return u+r},kn.unescape=function(t){return(t=ya(t))&&W.test(t)?t.replace(G,fn):t},kn.uniqueId=function(t){var e=++Pt;return ya(t)+e},kn.upperCase=Ka,kn.upperFirst=Ya,kn.each=ys,kn.eachRight=bs,kn.first=Go,sl(kn,(ml={},br(kn,(function(t,e){Bt.call(kn.prototype,e)||(ml[e]=t)})),ml),{chain:!1}),kn.VERSION="4.17.21",Se(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){kn[t].placeholder=kn})),Se(["drop","take"],(function(t,e){$n.prototype[t]=function(n){n=n===i?1:mn(fa(n),0);var r=this.__filtered__&&!e?new $n(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},$n.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Se(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;$n.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:oo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Se(["head","last"],(function(t,e){var n="take"+(e?"Right":"");$n.prototype[t]=function(){return this[n](1).value()[0]}})),Se(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");$n.prototype[t]=function(){return this.__filtered__?new $n(this):this[n](1)}})),$n.prototype.compact=function(){return this.filter(nl)},$n.prototype.find=function(t){return this.filter(t).head()},$n.prototype.findLast=function(t){return this.reverse().find(t)},$n.prototype.invokeMap=Wr((function(t,e){return"function"==typeof t?new $n(this):this.map((function(n){return Ir(n,t,e)}))})),$n.prototype.reject=function(t){return this.filter(Ps(oo(t)))},$n.prototype.slice=function(t,e){t=fa(t);var n=this;return n.__filtered__&&(t>0||e<0)?new $n(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==i&&(n=(e=fa(e))<0?n.dropRight(-e):n.take(e-t)),n)},$n.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},$n.prototype.toArray=function(){return this.take(f)},br($n.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),o=kn[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);o&&(kn.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof $n,u=a[0],c=l||js(e),h=function(t){var e=o.apply(kn,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,g=l&&!f;if(!s&&c){e=g?e:new $n(this);var m=t.apply(e,a);return m.__actions__.push({func:ds,args:[h],thisArg:i}),new Vn(m,d)}return p&&g?t.apply(this,a):(m=this.thru(h),p?r?m.value()[0]:m.value():m)})})),Se(["pop","push","shift","sort","splice","unshift"],(function(t){var e=It[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);kn.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(js(i)?i:[],t)}return this[n]((function(n){return e.apply(js(n)?n:[],t)}))}})),br($n.prototype,(function(t,e){var n=kn[e];if(n){var r=n.name+"";Bt.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[Fi(i,2).name]=[{name:"wrapper",func:i}],$n.prototype.clone=function(){var t=new $n(this.__wrapped__);return t.__actions__=Ei(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ei(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ei(this.__views__),t},$n.prototype.reverse=function(){if(this.__filtered__){var t=new $n(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},$n.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=js(t),r=e<0,i=n?t.length:0,o=function(t,e,n){for(var r=-1,i=n.length;++r<i;){var o=n[r],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yn(e,t+s);break;case"takeRight":t=mn(t,e-s)}}return{start:t,end:e}}(0,i,this.__views__),s=o.start,a=o.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&&i==l&&f==l)return hi(t,this.__actions__);var p=[];t:for(;l--&&d<f;){for(var g=-1,m=t[u+=e];++g<h;){var y=c[g],b=y.iteratee,v=y.type,w=b(m);if(2==v)m=w;else if(!w){if(1==v)continue t;break t}}p[d++]=m}return p},kn.prototype.at=fs,kn.prototype.chain=function(){return hs(this)},kn.prototype.commit=function(){return new Vn(this.value(),this.__chain__)},kn.prototype.next=function(){this.__values__===i&&(this.__values__=ha(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?i:this.__values__[this.__index__++]}},kn.prototype.plant=function(t){for(var e,n=this;n instanceof Un;){var r=ko(n);r.__index__=0,r.__values__=i,e?o.__wrapped__=r:e=r;var o=r;n=n.__wrapped__}return o.__wrapped__=t,e},kn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof $n){var e=t;return this.__actions__.length&&(e=new $n(this)),(e=e.reverse()).__actions__.push({func:ds,args:[Zo],thisArg:i}),new Vn(e,this.__chain__)}return this.thru(Zo)},kn.prototype.toJSON=kn.prototype.valueOf=kn.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},kn.prototype.first=kn.prototype.head,Yt&&(kn.prototype[Yt]=function(){return this}),kn}();he._=pn,(r=function(){return pn}.call(e,n,e,t))===i||(t.exports=r)}.call(this)},802:t=>{t.exports=function t(e,n,r){function i(s,a){if(!n[s]){if(!e[s]){if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},e[s][0].call(a.exports,(function(t){return i(e[s][1][t]||t)}),a,a.exports,t,e,n,r)}return n[s].exports}for(var o=void 0,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){(function(r,i,o,s,a,l,u,c,h){"use strict";var d=t("crypto");function f(t,e){var n;return void 0===(n="passthrough"!==(e=m(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"],g=(p.push("passthrough"),["buffer","hex","binary","base64"]);function m(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===g.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+g.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 i,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!==o&&o.isBuffer&&o.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+":"),i=this,s.forEach((function(n){i.dispatch(n),r(":"),t.excludeValues||i.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,i){i=void 0!==i?i:!1!==t.unorderedArrays;var o=this;if(r("array:"+e.length+":"),!i||e.length<=1)return e.forEach((function(t){return o.dispatch(t)}));var s=[];return i=e.map((function(e){var r=new v,i=n.slice();return b(t,r,i).dispatch(e),s=s.concat(i.slice(n.length)),r.read().toString()})),n=n.concat(s),i.sort(),this._array(i,!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=m(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,i,o,s,a,l,u){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),i="0".charCodeAt(0),o="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<i?-1:t<i+10?t-i+26+26:t<s+26?t-s:t<o+26?t-o+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 i=t.length,o=(i="="===t.charAt(i-2)?2:"="===t.charAt(i-1)?1:0,new e(3*t.length/4-i)),s=0<i?t.length-4:t.length,a=0;function l(t){o[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==i?l(255&(r=u(t.charAt(n))<<2|u(t.charAt(n+1))>>4)):1==i&&(l((r=u(t.charAt(n))<<10|u(t.charAt(n+1))<<4|u(t.charAt(n+2))>>2)>>8&255),l(255&r)),o},t.fromByteArray=function(t){var e,n,r,i,o=t.length%3,s="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,r=t.length-o;e<r;e+=3)s+=a((i=n=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(i>>12&63)+a(i>>6&63)+a(63&i);switch(o){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,i,o,s,a,l,u,c){var h=t("base64-js"),d=t("ieee754");function i(t,e,n){if(!(this instanceof i))return new i(t,e,n);var r,o,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=T(t);else if("string"==l)r=i.byteLength(t,e);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");r=T(t.length)}if(i._useTypedArrays?o=i._augment(new Uint8Array(r)):((o=this).length=r,o._isBuffer=!0),i._useTypedArrays&&"number"==typeof t.byteLength)o._set(t);else if(I(a=t)||i.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<r;s++)i.isBuffer(t)?o[s]=t.readUInt8(s):o[s]=t[s];else if("string"==l)o.write(t,0,e);else if("number"==l&&!i._useTypedArrays&&!n)for(s=0;s<r;s++)o[s]=0;return o}function f(t,e,n,r){var i;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?(i=t[e],e+1<r&&(i|=t[e+1]<<8)):(i=t[e]<<8,e+1<r&&(i|=t[e+1])),i}function p(t,e,n,r){var i;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&&(i=t[e+2]<<16),e+1<r&&(i|=t[e+1]<<8),i|=t[e],e+3<r&&(i+=t[e+3]<<24>>>0)):(e+1<r&&(i=t[e+1]<<16),e+2<r&&(i|=t[e+2]<<8),e+3<r&&(i|=t[e+3]),i+=t[e]<<24>>>0),i}function g(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 m(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,i){if(i||(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"),P(e,65535)),!((i=t.length)<=n))for(var o=0,s=Math.min(i-n,2);o<s;o++)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function w(t,e,n,r,i){if(i||(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"),P(e,4294967295)),!((i=t.length)<=n))for(var o=0,s=Math.min(i-n,4);o<s;o++)t[n+o]=e>>>8*(r?o:3-o)&255}function C(t,e,n,r,i){i||(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,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,i)}function A(t,e,n,r,i){i||(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,2147483647,-2147483648)),t.length<=n||w(t,0<=e?e:4294967295+e+1,n,r,i)}function x(t,e,n,r,i){i||(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,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function _(t,e,n,r,i){i||(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"),D(e,17976931348623157e292,-17976931348623157e292)),t.length<=n||d.write(t,e,n,r,52,8)}n.Buffer=i,n.SlowBuffer=i,n.INSPECT_MAX_BYTES=50,i.poolSize=8192,i._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}}(),i.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}},i.isBuffer=function(t){return!(null==t||!t._isBuffer)},i.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=O(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},i.concat=function(t,e){if(F(I(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new i(0);if(1===t.length)return t[0];if("number"!=typeof e)for(o=e=0;o<t.length;o++)e+=t[o].length;for(var n=new i(e),r=0,o=0;o<t.length;o++){var s=t[o];s.copy(n,r),r+=s.length}return n},i.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 o,s,a,l,u=this.length-e;switch((!n||u<(n=Number(n)))&&(n=u),r=String(r||"utf8").toLowerCase()){case"hex":o=function(t,e,n,r){n=Number(n)||0;var o=t.length-n;(!r||o<(r=Number(r)))&&(r=o),F((o=e.length)%2==0,"Invalid hex string"),o/2<r&&(r=o/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 i._charsWritten=2*s,s}(this,t,e,n);break;case"utf8":case"utf-8":s=this,a=e,l=n,o=i._charsWritten=L(O(t),s,a,l);break;case"ascii":case"binary":o=function(t,e,n,r){return i._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,o=i._charsWritten=L(M(t),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=function(t,e,n,r){return i._charsWritten=L(function(t){for(var e,n,r=[],i=0;i<t.length;i++)e=(n=t.charCodeAt(i))>>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 o},i.prototype.toString=function(t,e,n){var r,i,o,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 i="",o=e;o<n;o++)i+=N(t[o]);return i}(a,e,n);break;case"utf8":case"utf-8":r=function(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;o<n;o++)t[o]<=127?(r+=B(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+B(i)}(a,e,n);break;case"ascii":case"binary":r=function(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;i++)r+=String.fromCharCode(t[i]);return r}(a,e,n);break;case"base64":i=a,s=n,r=0===(o=e)&&s===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(o,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}(a,e,n);break;default:throw new Error("Unknown encoding")}return r},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},i.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 o=(r=t.length-e<r-n?t.length-e+n:r)-n;if(o<100||!i._useTypedArrays)for(var s=0;s<o;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+o),e)}},i.prototype.slice=function(t,e){var n=this.length;if(t=E(t,n,0),e=E(e,n,n),i._useTypedArrays)return i._augment(this.subarray(t,e));for(var r=e-t,o=new i(r,void 0,!0),s=0;s<r;s++)o[s]=this[s+t];return o},i.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},i.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},i.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]},i.prototype.readUInt16LE=function(t,e){return f(this,t,!0,e)},i.prototype.readUInt16BE=function(t,e){return f(this,t,!1,e)},i.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},i.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},i.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]},i.prototype.readInt16LE=function(t,e){return g(this,t,!0,e)},i.prototype.readInt16BE=function(t,e){return g(this,t,!1,e)},i.prototype.readInt32LE=function(t,e){return m(this,t,!0,e)},i.prototype.readInt32BE=function(t,e){return m(this,t,!1,e)},i.prototype.readFloatLE=function(t,e){return y(this,t,!0,e)},i.prototype.readFloatBE=function(t,e){return y(this,t,!1,e)},i.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},i.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},i.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"),P(t,255)),e>=this.length||(this[e]=t)},i.prototype.writeUInt16LE=function(t,e,n){v(this,t,e,!0,n)},i.prototype.writeUInt16BE=function(t,e,n){v(this,t,e,!1,n)},i.prototype.writeUInt32LE=function(t,e,n){w(this,t,e,!0,n)},i.prototype.writeUInt32BE=function(t,e,n){w(this,t,e,!1,n)},i.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"),R(t,127,-128)),e>=this.length||(0<=t?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n))},i.prototype.writeInt16LE=function(t,e,n){C(this,t,e,!0,n)},i.prototype.writeInt16BE=function(t,e,n){C(this,t,e,!1,n)},i.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},i.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},i.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){_(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){_(this,t,e,!1,n)},i.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}},i.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(" ")+">"},i.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(i._useTypedArrays)return new i(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 S=i.prototype;function E(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function T(t){return(t=~~Math.ceil(+t))<0?0:t}function I(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 O(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 i=n,o=(55296<=r&&r<=57343&&n++,encodeURIComponent(t.slice(i,n+1)).substr(1).split("%")),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}return e}function M(t){return h.toByteArray(t)}function L(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function B(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function P(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 R(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 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")}function F(t,e){if(!t)throw new Error(e||"Failed assertion")}i._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=S.get,t.set=S.set,t.write=S.write,t.toString=S.toString,t.toLocaleString=S.toString,t.toJSON=S.toJSON,t.copy=S.copy,t.slice=S.slice,t.readUInt8=S.readUInt8,t.readUInt16LE=S.readUInt16LE,t.readUInt16BE=S.readUInt16BE,t.readUInt32LE=S.readUInt32LE,t.readUInt32BE=S.readUInt32BE,t.readInt8=S.readInt8,t.readInt16LE=S.readInt16LE,t.readInt16BE=S.readInt16BE,t.readInt32LE=S.readInt32LE,t.readInt32BE=S.readInt32BE,t.readFloatLE=S.readFloatLE,t.readFloatBE=S.readFloatBE,t.readDoubleLE=S.readDoubleLE,t.readDoubleBE=S.readDoubleBE,t.writeUInt8=S.writeUInt8,t.writeUInt16LE=S.writeUInt16LE,t.writeUInt16BE=S.writeUInt16BE,t.writeUInt32LE=S.writeUInt32LE,t.writeUInt32BE=S.writeUInt32BE,t.writeInt8=S.writeInt8,t.writeInt16LE=S.writeInt16LE,t.writeInt16BE=S.writeInt16BE,t.writeInt32LE=S.writeInt32LE,t.writeInt32BE=S.writeInt32BE,t.writeFloatLE=S.writeFloatLE,t.writeFloatBE=S.writeFloatBE,t.writeDoubleLE=S.writeDoubleLE,t.writeDoubleBE=S.writeDoubleBE,t.fill=S.fill,t.inspect=S.inspect,t.toArrayBuffer=S.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,i,o,s,a,l,u,c){i=t("buffer").Buffer;var h=new i(4);h.fill(0),e.exports={hash:function(t,e,n,r){for(var o=e(function(t,e){t.length%4!=0&&(n=t.length+(4-t.length%4),t=i.concat([t,h],n));for(var n,r=[],o=e?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=4)r.push(o.call(t,s));return r}(t=i.isBuffer(t)?t:new i(t),r),8*t.length),s=(e=r,new i(n)),a=e?s.writeInt32BE:s.writeInt32LE,l=0;l<o.length;l++)a.call(s,o[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,i,o,s,a,l,u,c){i=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),f=t("./rng"),p={sha1:h,sha256:d,md5:t("./md5")},g=64,m=new i(g);function y(t,e){var n=p[t=t||"sha1"],r=[];return n||b("algorithm:",t,"is not yet supported"),{update:function(t){return i.isBuffer(t)||(t=new i(t)),r.push(t),t.length,this},digest:function(t){var o=i.concat(r);return o=e?function(t,e,n){i.isBuffer(e)||(e=new i(e)),i.isBuffer(n)||(n=new i(n)),e.length>g?e=t(e):e.length<g&&(e=i.concat([e,m],g));for(var r=new i(g),o=new i(g),s=0;s<g;s++)r[s]=54^e[s],o[s]=92^e[s];return n=t(i.concat([r,n])),t(i.concat([o,n]))}(n,e,o):n(o),r=null,t?o.toString(t):o}}}function b(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}m.fill(0),n.createHash=function(t){return y(t)},n.createHmac=y,n.randomBytes=function(t,e){if(!e||!e.call)return new i(f(t));try{e.call(this,void 0,new i(f(t)))}catch(t){e(t)}};var v,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],C=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in w)C(w[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,i,o,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,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=n,l=r,u=i,c=o;n=p(n,r,i,o,t[s+0],7,-680876936),o=p(o,n,r,i,t[s+1],12,-389564586),i=p(i,o,n,r,t[s+2],17,606105819),r=p(r,i,o,n,t[s+3],22,-1044525330),n=p(n,r,i,o,t[s+4],7,-176418897),o=p(o,n,r,i,t[s+5],12,1200080426),i=p(i,o,n,r,t[s+6],17,-1473231341),r=p(r,i,o,n,t[s+7],22,-45705983),n=p(n,r,i,o,t[s+8],7,1770035416),o=p(o,n,r,i,t[s+9],12,-1958414417),i=p(i,o,n,r,t[s+10],17,-42063),r=p(r,i,o,n,t[s+11],22,-1990404162),n=p(n,r,i,o,t[s+12],7,1804603682),o=p(o,n,r,i,t[s+13],12,-40341101),i=p(i,o,n,r,t[s+14],17,-1502002290),n=g(n,r=p(r,i,o,n,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=g(o,n,r,i,t[s+6],9,-1069501632),i=g(i,o,n,r,t[s+11],14,643717713),r=g(r,i,o,n,t[s+0],20,-373897302),n=g(n,r,i,o,t[s+5],5,-701558691),o=g(o,n,r,i,t[s+10],9,38016083),i=g(i,o,n,r,t[s+15],14,-660478335),r=g(r,i,o,n,t[s+4],20,-405537848),n=g(n,r,i,o,t[s+9],5,568446438),o=g(o,n,r,i,t[s+14],9,-1019803690),i=g(i,o,n,r,t[s+3],14,-187363961),r=g(r,i,o,n,t[s+8],20,1163531501),n=g(n,r,i,o,t[s+13],5,-1444681467),o=g(o,n,r,i,t[s+2],9,-51403784),i=g(i,o,n,r,t[s+7],14,1735328473),n=m(n,r=g(r,i,o,n,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=m(o,n,r,i,t[s+8],11,-2022574463),i=m(i,o,n,r,t[s+11],16,1839030562),r=m(r,i,o,n,t[s+14],23,-35309556),n=m(n,r,i,o,t[s+1],4,-1530992060),o=m(o,n,r,i,t[s+4],11,1272893353),i=m(i,o,n,r,t[s+7],16,-155497632),r=m(r,i,o,n,t[s+10],23,-1094730640),n=m(n,r,i,o,t[s+13],4,681279174),o=m(o,n,r,i,t[s+0],11,-358537222),i=m(i,o,n,r,t[s+3],16,-722521979),r=m(r,i,o,n,t[s+6],23,76029189),n=m(n,r,i,o,t[s+9],4,-640364487),o=m(o,n,r,i,t[s+12],11,-421815835),i=m(i,o,n,r,t[s+15],16,530742520),n=y(n,r=m(r,i,o,n,t[s+2],23,-995338651),i,o,t[s+0],6,-198630844),o=y(o,n,r,i,t[s+7],10,1126891415),i=y(i,o,n,r,t[s+14],15,-1416354905),r=y(r,i,o,n,t[s+5],21,-57434055),n=y(n,r,i,o,t[s+12],6,1700485571),o=y(o,n,r,i,t[s+3],10,-1894986606),i=y(i,o,n,r,t[s+10],15,-1051523),r=y(r,i,o,n,t[s+1],21,-2054922799),n=y(n,r,i,o,t[s+8],6,1873313359),o=y(o,n,r,i,t[s+15],10,-30611744),i=y(i,o,n,r,t[s+6],15,-1560198380),r=y(r,i,o,n,t[s+13],21,1309151649),n=y(n,r,i,o,t[s+4],6,-145523070),o=y(o,n,r,i,t[s+11],10,-1120210379),i=y(i,o,n,r,t[s+2],15,718787259),r=y(r,i,o,n,t[s+9],21,-343485551),n=b(n,a),r=b(r,l),i=b(i,u),o=b(o,c)}return Array(n,r,i,o)}function f(t,e,n,r,i,o){return b((e=b(b(e,t),b(r,o)))<<i|e>>>32-i,n)}function p(t,e,n,r,i,o,s){return f(e&n|~e&r,t,e,i,o,s)}function g(t,e,n,r,i,o,s){return f(e&r|n&~r,t,e,i,o,s)}function m(t,e,n,r,i,o,s){return f(e^n^r,t,e,i,o,s)}function y(t,e,n,r,i,o,s){return f(n^(e|~r),t,e,i,o,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,i,o,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,i,o,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,i,o=Array(80),s=1732584193,a=-271733879,l=-1732584194,u=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var d=s,g=a,m=l,y=u,b=c,v=0;v<80;v++){o[v]=v<16?t[h+v]:p(o[v-3]^o[v-8]^o[v-14]^o[v-16],1);var w=f(f(p(s,5),(w=a,r=l,i=u,(n=v)<20?w&r|~w&i:!(n<40)&&n<60?w&r|w&i|r&i:w^r^i)),f(f(c,o[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=u,u=l,l=p(a,30),a=s,s=w}s=f(s,d),a=f(a,g),l=f(l,m),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,i,o,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),i=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),o=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=i[0],c=i[1],d=i[2],f=i[3],m=i[4],y=i[5],b=i[6],v=i[7],w=0;w<64;w++)o[w]=w<16?t[w+l]:h(h(h((a=o[w-2],p(a,17)^p(a,19)^g(a,10)),o[w-7]),(a=o[w-15],p(a,7)^p(a,18)^g(a,3))),o[w-16]),n=h(h(h(h(v,p(a=m,6)^p(a,11)^p(a,25)),m&y^~m&b),r[w]),o[w]),s=h(p(s=u,2)^p(s,13)^p(s,22),u&c^u&d^c&d),v=b,b=y,y=m,m=h(f,n),f=d,d=c,c=u,u=h(n,s);i[0]=h(u,i[0]),i[1]=h(c,i[1]),i[2]=h(d,i[2]),i[3]=h(f,i[3]),i[4]=h(m,i[4]),i[5]=h(y,i[5]),i[6]=h(b,i[6]),i[7]=h(v,i[7])}return i}var f=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},g=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,i,o,s,a,l,u){n.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1;for(i=t[e+h],h+=d,o=i&(1<<-c)-1,i>>=-c,c+=a;0<c;o=256*o+t[e+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(i?-1:1);s+=Math.pow(2,r),o-=u}return(i?-1:1)*s*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var s,a,l=8*o-i-1,u=(1<<l)-1,c=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1;for(o=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,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));8<=i;t[n+d]=255&a,d+=f,a/=256,i-=8);for(s=s<<i|a,l+=i;0<l;t[n+d]=255&s,d+=f,s/=256,l-=8);t[n+d-f]|=128*o}}).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,i,o,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)},146:(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 i="http://www.w3.org/2000/xmlns/",o="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),i=new Uint8Array(r),o=0;o<e.length;o++)i[o]=e.charCodeAt(o);return new Blob([r],{type:n})},f={},p=null,g=function(t,e){var n=e||{},r=n.selectorRemap,i=n.modifyStyle,o=n.modifyCss,l=n.fonts,u=n.excludeUnusedCss,c=o||function(t,e){return(r?r(t):t)+"{"+(i?i(e):e)+"}\n"},h=[],d=void 0===l,g=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 i,o,l=r.startsWith("../")?e+"/../"+r:r.startsWith("./")?e+"/."+r:r;return{text:t.cssText,format:(i=l,o=Object.keys(a).filter((function(t){return i.indexOf("."+t)>0})).map((function(t){return a[t]})),o?o[0]:(console.error("Unknown font format for "+i+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,r);n&&g.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),i=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";f[t.url]=i,e(i)})),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("")}))}(g).then((function(t){return h.join("\n")+t}))},m=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,m=void 0===p?1:p,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,w=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 i=document.createElement("canvas"),o=new Image;o.crossOrigin="anonymous",o.src=n,o.onerror=function(){return r(new Error("Could not load "+n))},o.onload=function(){i.width=o.width,i.height=o.height,i.getContext("2d").drawImage(o,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",i.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 i=t.getBBox(),o=i.x,s=i.y;return{width:o+i.width,height:s+i.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(i,"xmlns",o),r.getAttribute("xmlns:xlink")||r.setAttributeNS(i,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(r.removeAttribute("width"),r.removeAttribute("height"),r.setAttribute("preserveAspectRatio","xMinYMin meet")):(r.setAttribute("width",l*m),r.setAttribute("height",u*m)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(i,"xmlns","svg"===t.tagName?o:"http://www.w3.org/1999/xhtml")})),!w)return g(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var i=document.createElement("defs");i.appendChild(e),r.insertBefore(i,r.firstChild);var o=document.createElement("div");o.appendChild(r);var s=o.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,i=t.height,o="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 "&#160;">]>'+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(o,r,i),o}))},r.svgAsPngUri=function(t,e,n){u(t);var i=e||{},o=i.encoderType,s=void 0===o?"image/png":o,a=i.encoderOptions,l=void 0===a?.8:a,c=i.canvg,h=function(t){var e=t.src,r=t.width,i=t.height,o=document.createElement("canvas"),a=o.getContext("2d"),u=window.devicePixelRatio||1;o.width=r*u,o.height=i*u,o.style.width=o.width+"px",o.style.height=o.height+"px",a.setTransform(u,0,0,u,0,0),c?c(o,e):a.drawImage(e,0,0);var h=void 0;try{h=o.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,o.width,o.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 i=d(e),o=URL.createObjectURL(i);r.href=o,r.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(o)}))}}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 i=m();return c(t).then((function(t){return r.svgAsDataUri(t,n||{})})).then((function(t){return r.download(e,t,i)}))},r.saveSvgAsPng=function(t,e,n){var i=m();return c(t).then((function(t){return r.svgAsPngUri(t,n||{})})).then((function(t){return r.download(e,t,i)}))}}()},72: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 o={},s=[],a=0;a<t.length;a++){var l=t[a],u=r.base?l[0]+r.base:l[0],c=o[u]||0,h="".concat(u," ").concat(c);o[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=i(f,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,references:1})}s.push(h)}return s}function i(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,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<o.length;s++){var a=n(o[s]);e[a].references--}for(var l=r(t,i),u=0;u<o.length;u++){var c=n(o[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=l}}},659: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}},56:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},825: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 i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113: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))}}},686:(t,e,n)=>{"use strict";n.d(e,{AL:()=>r,NO:()=>i});const r=["A","G","C","U"];var i;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(i||(i={}))},670:(t,e,n)=>{"use strict";function r(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="",a="",l="";const u=[];let c=0,h=0,d=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=i(t.antiStrands[e]);let f=!1;const p=t.senseStrands.concat(t.antiStrands);let g=0;for(let e=0;e<p.length;e++){p[e]=p[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=o(p[e]),i=s(p[e]);if(e>=t.senseStrands.length?!1===f&&(f=!0,d=0):g=Math.min(g,Math.min(...i.y.filter((t=>t<0)))),f){const t=Math.min(...i.x)-d,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-g}let l=p[e].indexOf("M V30 BEGIN ATOM");l=p[e].indexOf("\n",l);let m=l,y=l;for(let t=0;t<n.natom;t++){m=p[e].indexOf("V30",m)+4,y=p[e].indexOf(" ",m);const n=parseInt(p[e].substring(m,y))+c;p[e]=p[e].slice(0,m)+n+p[e].slice(y),m=p[e].indexOf(" ",m)+1,m=p[e].indexOf(" ",m)+1,y=p[e].indexOf(" ",m);let r=Math.round(1e4*i.x[t])/1e4;p[e]=p[e].slice(0,m)+r+p[e].slice(y),m=p[e].indexOf(" ",m)+1,y=p[e].indexOf(" ",m),r=Math.round(1e4*i.y[t])/1e4,p[e]=p[e].slice(0,m)+r+p[e].slice(y),m=p[e].indexOf("\n",m)+1}const b=p[e].indexOf("M V30 END ATOM");r+=p[e].substring(l+1,b);let v=p[e].indexOf("M V30 BEGIN BOND");v=p[e].indexOf("\n",v),m=v,y=v;for(let t=0;t<n.nbond;t++){m=p[e].indexOf("V30",m)+4,y=p[e].indexOf(" ",m);const t=parseInt(p[e].substring(m,y))+h;p[e]=p[e].slice(0,m)+t+p[e].slice(y),m=p[e].indexOf(" ",m)+1,m=p[e].indexOf(" ",m)+1,y=p[e].indexOf(" ",m);let n=parseInt(p[e].substring(m,y))+c;p[e]=p[e].slice(0,m)+n+p[e].slice(y),m=p[e].indexOf(" ",m)+1,y=Math.min(p[e].indexOf("\n",m),p[e].indexOf(" ",m)),n=parseInt(p[e].substring(m,y))+c,p[e]=p[e].slice(0,m)+n+p[e].slice(y),m=p[e].indexOf("\n",m)+1}const w=p[e].indexOf("M V30 END BOND");a+=p[e].substring(v+1,w);let C=p[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==C;){C+=28;const t=p[e].indexOf(")",C);p[e].substring(C,t).split(" ").slice(1).forEach((t=>{u.push(parseInt(t)+c)})),C=t,C=p[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",C)}c+=n.natom,h+=n.nbond,d+=Math.max(...i.x)+5}const m=Math.ceil(u.length/4);l+="M V30 MDLV30/STEABS ATOMS=("+u.length+" -\n";for(let t=0;t<m;t++){l+="M V30 ";const e=t+1===m?u.length-4*(m-1):4;for(let n=0;n<e;n++)l+=n+1===e?t===m-1?u[4*t+n]+")\n":u[4*t+n]+" -\n":u[4*t+n]+" "}return n+="M V30 COUNTS "+c+" "+h+" 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+=a,n+="M V30 END BOND\n",e&&u.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=l,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function i(t){const e=s(t),n=e.atomIndex.length,r=(Math.max(...e.x)+Math.min(...e.x))/2,i=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=i;const o=Math.PI,a=Math.cos(o),l=Math.sin(o);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*a-e.y[t]*l,e.y[t]=n*l+e.y[t]*a}const u=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=r,e.y[t]-=u;let c=t.indexOf("M V30 BEGIN ATOM");c=t.indexOf("\n",c);let h=c;for(let r=0;r<n;r++)c=t.indexOf("V30",c)+4,c=t.indexOf(" ",c)+1,c=t.indexOf(" ",c)+1,h=t.indexOf(" ",c)+1,h=t.indexOf(" ",h),c=(t=t.slice(0,c)+e.x[r]+" "+e.y[r]+t.slice(h)).indexOf("\n",c)+1;return t}function o(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 s(t){const e=o(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const i=Array(e.natom),s=Array(e.natom),a=Array(e.natom),l=Array(e.natom);for(let o=0;o<e.natom;o++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),i[o]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),s[o]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),a[o]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),l[o]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:i,atomType:s,x:a,y:l}}n.d(e,{cx:()=>s,vS:()=>r})},537:(t,e,n)=>{"use strict";n.d(e,{iL:()=>o,q7:()=>i,ti:()=>r});const r={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},i="p",o="<?>"},480:(t,e,n)=>{"use strict";n.d(e,{C6:()=>l,OT:()=>u,bD:()=>s});var r=n(686),i=n(67),o=n(537);function s(t,e,n,i){const o=Object.keys(i.jsonData.codesToHelmDict).concat([r.NO.HELM]);if(!t||-1!==e&&n!==r.NO.HELM)return{};if(!o.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=o.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),l=i.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],i.monomerLibWrapper);return c&&(u.Nucleotides=c),u}function a(t,e){const n=new RegExp("\\([^()]*\\)","g"),i=t.match(n);return i?i.map((t=>{const n=t.replace(/[\[\]()]/g,"");return r.AL.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||o.iL)).join(""):null}function l(t,e,n,o){const s=o.createFormatConverter(t,e);return n===i.qP?a(s.convertTo(r.NO.HELM),o.monomerLibWrapper):s.convertTo(n)}function u(t){return Object.keys(t.jsonData.codesToHelmDict).concat([r.NO.HELM,i.qP]).sort()}},67:(t,e,n)=>{"use strict";n.d(e,{U_:()=>i,n_:()=>r,qP:()=>o});const r="Copied",i="Copy sequence",o="Nucleotides"},544:(t,e,n)=>{"use strict";n.r(e),n.d(e,{_package:()=>Or,addContextMenu:()=>ti,applyNotationProviderForCyclized:()=>ri,createMonomerLibraryForPolyTool:()=>Zr,demoOligoPattern:()=>jr,demoOligoStructure:()=>qr,demoTranslateSequence:()=>$r,getCodeToWeightsMap:()=>kr,getMolfileFromGcrsSequence:()=>Ur,getPolyToolConvertEditor:()=>Kr,getTranslationHelper:()=>Fr,init:()=>Lr,linkStrands:()=>Vr,oligoPatternApp:()=>Rr,oligoStructureApp:()=>Dr,oligoToolkitApp:()=>Br,oligoTranslatorApp:()=>Pr,polyToolColumnChoice:()=>Xr,polyToolConvert2:()=>Yr,polyToolConvertTopMenu:()=>Wr,polyToolEnumerateChemTopMenu:()=>Qr,polyToolEnumerateHelmTopMenu:()=>Jr,ptEnumeratorChemApp:()=>ni,ptEnumeratorHelmApp:()=>ei,translateOligonucleotideSequence:()=>Gr,validateSequence:()=>Hr});var r=n(328),i=n(82),o=n(439);const s=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};var a=n(890);class l{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 u="System:AppData/SequenceTranslator/monomers-sample",c="pattern-app-data.json",h="formats-to-helm.json",d="codes-to-symbols.json",f="linkers.json";var p=n(686);function g(t){return t.sort(((t,e)=>e.length-t.length))}function m(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 y(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 b{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(t){if(t===p.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&&p.AL.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&p.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 v{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([c,h,d,f].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 v(e[0],e[1],e[2],e[3])}class C{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===p.NO.HELM)return;const r=this.jsonData.codesToSymbolsDict[n],i=Object.keys(r).filter((e=>r[e]===t.symbol));e[n]=i.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 i.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),i=r.meta?.molecularWeight;t.set(e,i)}))})),t}}var A=n(537);const x=(t,e)=>e.length-t.length;class _{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(x);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(x)}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[A.ti.LINKAGE]))).sort(x));return new RegExp(`${A.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===p.NO.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(x)}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 E={LEFT:"RNA1{",RIGHT:"}$$$$"};class T{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new _(this.th)}convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===p.NO.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===p.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(E)),"g");let r=t.replace(n,"");const i=this.formats.getHelmToFormatDict(e),o=this.formats.getTargetFormatHelmCodes(e),s=this.formats.getTargetFormatHelmCodesRegExp(e);return r=r.replace(s,(t=>o.includes(t)?i[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,A.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),i=this.formats.getFormatRegExp(e),o=this.formats.getPhosphateHelmCodesRegExp(e);let s=t?t.replace(i,(t=>r.includes(t)?n[t]+".":"?")):"";return s=s.replace(/\?+/g,`${A.iL}.`),s=s.slice(0,-1),s[s.length-1]===A.q7&&(s=s.slice(0,-1)),s=s.replace(o,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${E.LEFT+s+E.RIGHT}`}}class I{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 p.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 i=t[r];n[r]=e.getInvalidCodeIndex(i)}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 i=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){i=e+1;break}r.some((e=>e===t.slice(i,i+e.length)))&&e.push(n)}return e}}var N=n(389);const O=$;var M=n.n(O);function L(t,e){let n=0;const r=e.createFormatDetector(t).getFormat();null!==r&&(n=new b(t,e).getInvalidCodeIndex(r));const i=n<0||""===t,o=N.span([]);M()(o).css("-webkit-text-fill-color","var(--grey-6)");const s=N.span([]);return M()(s).css("-webkit-text-fill-color","red"),i?o.innerHTML=t:(o.innerHTML=t.slice(0,n),s.innerHTML=t.slice(n)),[o,s]}class B extends i.Package{get seqHelper(){if(!this._seqHelper)throw new Error("Package SequenceTranslator .seqHelper is not initialized");return this._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}constructor(t={debug:!1}){super(),this.highlightInvalidSubsequence=t=>L(t,this),super._logger=new l(super.logger,t.debug)}completeInit(t){this._seqHelper=t}async initLibData(){return this.initPromise||(this.initPromise=(async()=>{let t=(await this.getSettings()).MonomersPath;t&&await r.dapi.files.exists(t)||(this.logger.warning(`Monomers path '${t}' not found. Fallback to monomers sample path '${u}'.`),t=u),[this._jsonData,this._monomerLib]=await Promise.all([w(t),P(t)]),this._monomerLibWrapper=new C(this.monomerLib,this.jsonData)})()),this.initPromise}async getTranslationHelper(){return await r.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(t){return new b(t,this)}createFormatConverter(t,e){return new T(t,e,this)}createFormatDetector(t){return new I(t,this)}}async function P(t){const e=i.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const e=await(0,a.pj)();return await e.readLibrary(t,"monomer-lib.json")}finally{e.close()}}class R{constructor(t,e){this.appName=t,this.parentAppName=e}async getAppView(){const t=i.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),e=r.shell.v?.root;e&&N.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&N.setUpdateIndicator(e,!1)}}}class D extends R{constructor(t){super(t),this.view=i.View.create(),this.configureView()}async constructView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${Or.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 F=["SS","AS"],k={SS:"Sense strand",AS:"Anti sense"},H=["3'","5'"],U="OligoToolkit";var V,j,q,G;!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"}(G||(G={}));const z=[V.IS_ANTISENSE_STRAND_INCLUDED,V.NUCLEOTIDE_SEQUENCES,V.PHOSPHOROTHIOATE_LINKAGE_FLAGS,V.STRAND_TERMINUS_MODIFICATIONS],W=(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 Y extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class J extends Error{constructor(t){super(t),this.name="PatternExistsError"}}var Q=n(802),X=n.n(Q);class Z{constructor(t){this.th=t,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const t=await Or.getTranslationHelper(),e=new Z(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 Y(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new J(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=W;return t[q.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return W[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 X().sha1(e)}async savePatternToUserStorage(t){const e=t.getPatternConfig();try{const n=this.getHash(e);this.validatePatternUniqueness(n);const i=e[j.PATTERN_NAME];this.validatePatternNameUniqueness(i);const o=await this.getRecordFromPattern(e),s=(new Date).toISOString();o[q.DATE]={[G.CREATE]:s,[G.MODIFY]:s};const a=JSON.stringify(o);r.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(i,n),t.selectAuthor(this.getCurrentUserAuthorshipCategory()),t.updatePatternList(),t.requestPatternLoad(n),t.updateUrlState(n)}catch(t){if(t instanceof Y||t instanceof J)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(t){const e=t.getPatternConfig(),n=e[j.PATTERN_NAME],i=this.currentUserPatternNameToHash.get(n);if(void 0===i)throw new Error("Old hash is undefined");const o=this.getHash(e),s=await this.getRecordFromPattern(e),a=(new Date).toISOString();s[q.DATE]={[G.MODIFY]:a};const l=r.userSettings.getValue(U,i,!1)??"null",u=JSON.parse(l);void 0!==u[q.DATE]&&null!=u[q.DATE][G.CREATE]&&(s[q.DATE][G.CREATE]=u[q.DATE][G.CREATE]);const c=JSON.stringify(s);r.userSettings.add(U,o,c,!1),r.userSettings.delete(U,i,!1),this.currentUserPatternNameToHash.set(n,o),t.requestPatternLoad(o),t.updateUrlState(o)}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 i=this.getHashOfPatternToBeLoadedAfterDeletion();e.requestPatternLoad(i)}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=W[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const i=JSON.parse(e),o=i[q.PATTERN_CONFIG].patternName,s=i[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(o,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=o+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(e,t)}}getDefaultPatternName(){return W[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(t){return t===this.currentUserId}}const tt=rxjs,et=rxjs.operators;function nt(t){return t.endsWith("(o)")}function rt(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 ot(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 i=n-t.length,o=t.concat(new Array(n-t.length).fill(r)),s=0===t.length?n+1:i;return{nucleotides:o,ptoFlags:e.concat(new Array(s).fill(!0))}}}(it||(it={}));var st=n(543),at=n.n(st);class lt{constructor(t,e){this.dataManager=t,this._patternListUpdated$=new tt.Subject,this._patternLoadRequested$=new tt.Subject,this._patternLoaded$=new tt.Subject,this._uniqueNucleotides$=new tt.BehaviorSubject([]),this._patternDeletionRequested$=new tt.Subject,this._tableSelection$=new tt.BehaviorSubject(null),this._svgSaveRequested$=new tt.Subject,this._loadPatternInNewTabRequested$=new tt.Subject,this._urlStateUpdated$=new tt.Subject,this._patternHasUnsavedChanges$=new tt.BehaviorSubject(!1),this._selectedStrandColumn=new tt.BehaviorSubject(null),this._selectedIdColumn=new tt.BehaviorSubject(null),this.initializeAuthorSelection(e),this.initializePatternState(e),this._lastLoadedPatternConfig=new tt.BehaviorSubject(at().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((t=>{t||H.forEach((t=>{this.updateTerminusModification("AS",t,"")}))})),this.patternStateChanged$.pipe((0,et.debounceTime)(20)).subscribe((()=>{const t=this._lastLoadedPatternConfig.getValue(),e=this.getPatternConfig(),n=!at().isEqual(e,t);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const t=(e=this._nucleotideSequences$.getValue(),ot(Object.values(e).flat()));var e;this._uniqueNucleotides$.next(t)}updateSequenceBase(){const t=rt(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 tt.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new tt.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(t){const e=t[q.PATTERN_CONFIG];this._patternName$=new tt.BehaviorSubject(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new tt.BehaviorSubject(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new tt.BehaviorSubject(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new tt.BehaviorSubject(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new tt.BehaviorSubject(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new tt.BehaviorSubject(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new tt.BehaviorSubject(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new tt.BehaviorSubject(rt(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:i,ptoFlags:o}=it.getTruncatedStrandData(n,r,e);return void this.setNewStrandData(i,o,t)}const i=this.getSequenceBase(),{nucleotides:o,ptoFlags:s}=it.getExtendedStrandData(n,r,e,i);this.setNewStrandData(o,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 ot(t).filter((t=>!nt(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={};F.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 tt.merge(this._patternName$.pipe((0,et.debounceTime)(300),(0,et.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,et.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,et.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(t){const e=this.getPhosphorothioateLinkageFlags();F.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(at().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 i=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(i.concat(n)),this.updateNucleotideSequences(r)}get strandsUpdated$(){return tt.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,et.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,et.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,et.map)((()=>{})))).pipe((0,et.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return tt.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,et.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,et.map)((()=>{}))))}updateControlsUponPatternLoaded(t){this._patternLoaded$.next(t)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,et.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,et.debounceTime)(100))}}const ut="pattern";class ct{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}?${ut}=${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(ut)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ut,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ut),window.history.pushState({},"",`${window.location.pathname}`)}}var ht=n(72),dt=n.n(ht),ft=n(825),pt=n.n(ft),gt=n(659),mt=n.n(gt),yt=n(56),bt=n.n(yt),vt=n(540),wt=n.n(vt),Ct=n(113),At=n.n(Ct),xt=n(252),_t={};_t.styleTagTransform=At(),_t.setAttributes=bt(),_t.insert=mt().bind(null,"head"),_t.domAPI=pt(),_t.insertStyleElement=wt(),dt()(xt.A,_t),xt.A&&xt.A.locals&&xt.A.locals;class St{constructor(t){this.eventBus=t,this.columnControlsContainer=N.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){M()(this.columnControlsContainer).empty(),M()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const t=this.createStrandColumnInput(),e=t.SS,n=t.AS;this.eventBus.antisenseStrandToggled$.subscribe((t=>{M()(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(F.map((e=>{const n=N.input.choice(`${k[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=N.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class Et{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=N.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 i.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();M()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getTableSelection();return N.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 Tt(t,e,n,r){const i=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+H.length);r[0]=n["5'"],r[r.length-1]=n["3'"];let i=1;return e[0]&&(r[i]="ps",i++),t.forEach(((t,n)=>{r[n+i]=t,e[n+1]&&(r[n+i+1]="ps",i++)})),r}(t.split("").map(((t,n)=>{const r=function(t,e,n){const r=Object.keys(n.patternAppData)[0],i=n.patternAppData[r][e].substitution;return t.replace(/([AGCTU])/,i)}(t,e[n],Or.jsonData);return r})),n,r);return i.join("")}class It{constructor(t){this.eventBus=t,this.tableInputManager=new Et(t),this.columnInputManager=new St(t)}createControls(){const t=N.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=N.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,N.buttonsInput([r])]}processConvertButtonClick(){!function(t){const e=t.getTableSelection();if(!e)return void r.shell.warning("Please select a table");const n=F.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 i=t.getSelectedIdColumn();if(!i)throw new Error("No ID column selected");e.getCol(i);const o=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))}))}(o,t)?r.shell.warning("Some strands in the table input do not match pattern length"):o.forEach((n=>{const r=n.column,i=n.strand,o=t.getNucleotideSequences()[i],s=t.getTerminalModifications()[i],a=t.getPhosphorothioateLinkageFlags()[i],l=`${t.getPatternName()}(${r.name})`;e.columns.addNewString(l).init((t=>Tt(r.get(t),o,a,s)))}))}(this.eventBus)}}class Nt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return N.divV([N.h1("PTO"),N.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((t=>t.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(t){return F.map((e=>t[e].filter((t=>t)).length)).reduce(((t,e)=>t+e),0)===F.map((t=>this.initialPatternConfig.nucleotideSequences[t].length)).reduce(((t,e)=>t+e),0)+F.filter((e=>t[e].length)).length}createAllPtoActivationInput(){const t=this.initialPatternConfig.phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t),n=N.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),N.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 F.map((t=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return;const e=this.isFirstPtoActive(t),n=N.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),N.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Ot{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=F.map((t=>this.constructControlsPanel(t)));return N.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return N.div([]);const e=this.constructHeader(),n=this.createControls(t);return N.block([N.h1(`${k[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return N.divH([N.div([N.divText("#")],{style:{width:"20px"}}),N.block75([N.divText("Modification")]),N.div([N.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return N.div(e.map(((t,e)=>N.divH([n[e],N.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 i=N.input.choice("",{value:n,items:e});return i.onInput.subscribe((()=>{const e=i.value;this.eventBus.setNucleotide(t,r,e)})),i}))}createPTOFlagInputs(t){return this.eventBus.getPhosphorothioateLinkageFlags()[t].slice(1).map(((e,n)=>{const r=N.input.bool("",{value:e});r.onInput.subscribe((()=>{const e=r.value;this.eventBus.setPhosphorothioateLinkageFlag(t,n+1,e)}));const i=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const i=e[t][n+1];r.value=i}));return this.subscriptions.add(i),r}))}computeDisplayedInputLabels(){const t=this.eventBus.getNucleotideSequences(),e=new Map;return F.forEach((n=>{let r=1;const i=t[n].map((t=>{if(nt(t))return"";const e=String(r);return r++,e}));e.set(n,i)})),e}createLabelDivs(t){const e=this.createLabels(t).map((t=>N.div([t],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(t).forEach(((t,n)=>{M()(e[n]).empty(),M()(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 N.label(r)}))}}class Mt{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(t){t instanceof tt.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 Lt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Mt}static open(t,e){Lt.isDialogOpen||(Lt.instance||(Lt.instance=new Lt(t,e)),Lt.instance.openDialog())}openDialog(){this.initialPatternConfig=at().cloneDeep(this.eventBus.getPatternConfig()),Lt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=N.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=N.dialog("Edit strands").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Lt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Nt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Ot(this.eventBus,this.dataManager,this.subscriptions).create();M()(t).empty(),M()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Lt.isDialogOpen=!1;class Bt{constructor(t){this.eventBus=t,this.subscriptions=new Mt}static open(t){Bt.isDialogOpen||(Bt.instance||(Bt.instance=new Bt(t)),Bt.instance.openDialog())}openDialog(){this.initialPatternConfig=at().cloneDeep(this.eventBus.getPatternConfig()),Bt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=N.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=N.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Bt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Pt(this.eventBus).create();M()(t).empty(),M()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Bt.isDialogOpen=!1;class Pt{constructor(t){this.eventBus=t}create(){const t=F.map((t=>this.constructControlsPanel(t)));return N.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return N.div([]);const e=this.createInputs(t);return N.block([N.h1(`${k[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...H].reverse():H).map((e=>this.createInputForTerminus(t,e)));return N.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=N.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];M()(e).css("resize","none")}}class Rt{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,i=this.createSequenceBaseInput().root,o=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[N.h1("Edit"),t,n,r,i,s,o,N.buttonsInput([l,a])]}createEditPatternButton(){const t=N.button("Edit strands",(()=>Lt.open(this.eventBus,this.dataManager)));return N.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=N.button("Edit terminals",(()=>Bt.open(this.eventBus)));return N.tooltip.bind(t,"Edit terminal modifications"),M()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=N.input.toggle(`${k.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=N.input.int(`${k[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(F.map((e=>t(e))));return this.eventBus.antisenseStrandToggled$.subscribe((t=>{M()(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=N.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=N.input.textArea("Comment",{value:this.eventBus.getComment()});return M()(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=N.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return M()(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 Dt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Mt,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[N.h1("Load"),t]}getPatternInputsContainer(){const t=N.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),M()(t).empty(),M()(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=N.div([t.root]),n=this.eventBus.userSelection$.subscribe((()=>{M()(e).empty(),M()(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=N.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){M()(t.input).css({"max-width":"100px","min-width":"100px"}),M()(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=N.input.choice("Pattern",{value:e,items:t});return n.setTooltip("Select pattern to load"),M()(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=N.button(N.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));N.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=N.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(N.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class Ft{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Dt(this.eventBus,this.dataManager),e=new Rt(this.eventBus,this.dataManager),n=new It(this.eventBus),r=t.createControls(),i=e.createControls(),o=n.createControls(),s=N.div(r);M()(s).css({"padding-bottom":"20px"});const a=N.div([...i,...o],"ui-form"),l=N.div([s,a]);return M()(l).css({padding:"25px"}),N.box(l,{style:{maxWidth:"450px"}})}}var kt=n(146);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 Ut{constructor(){}static getInstance(){return Ut.instance||(Ut.instance=new Ut,Ut.instance.canvas=document.createElement("canvas")),Ut.instance}static getTextDimensions(t,e){const n=Ut.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 Vt(t){const e=Object.keys(Or.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${c}'`);return Or.jsonData.patternAppData[e][t].color||""}class $t extends Ht{constructor(t,e,n){super(t,e,n);const r=F.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 Gt(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=>nt(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=Vt(t),i={...n,x:n.x+30*e};return[this.svgElementFactory.createCircleElement(i,15,r),this.createNucleotideLetterLabel(e,n,t)]}getNucleotideCircleCenterPosition(t,e){return{x:e.x+30*t,y:e.y}}createNucleotideLetterLabel(t,e,n){if(!p.AL.includes(n))return null;const r=function(t){return!nt(t)&&p.AL.includes(t)?t:""}(n),i=function(t){const e=Vt(t),n=e.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[r,i,o]=n;return.299*r+.587*i+.114*o>186?"#333333":"#ffffff"}(n),o=this.getPositionForNucleotideLabel(t,e);return this.svgElementFactory.createTextElement(r,o,17,i)}getPositionForNucleotideLabel(t,e){const n=this.getNucleotideCircleCenterPosition(t,e),r=Ut.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=Ut.getTextDimensions(n.toString(),15).width,i={x:e.x+30*t-r/2,y:this.getNumericLabelYShift(e)};return this.svgElementFactory.createTextElement(n.toString(),i,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,i){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.terminalModifications=i,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=Ut.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=Ut.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 Gt extends Ht{constructor(t,e,n,r,i){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.strandSvgWrapper=i,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 Ut.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(),i={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,i,17,"red")}createTerminalModifications(){return("AS"===this.strand?H:Array.from(H).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+H.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 Wt{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 i=this.createElement("text");return this.setAttributes(i,{x:e.x,y:e.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:r}),i.textContent=t,i}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,i)=>{const o=i%2==0?6:3,s=i*e+n;return[t.x+Math.cos(s)*o,t.y+Math.sin(s)*o]}))}createRectangleElement(t,e,n,r){const i=this.createElement("rect");return this.setAttributes(i,{x:t.x,y:t.y,width:e,height:n,fill:r}),i}}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 Ut.getTextDimensions(this.titleText,17).width}getContentHeight(){return Ut.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 Yt extends Ht{constructor(t,e,n){super(t,e,n),this._svgElements=[];const{elements:r,width:i}=this.createLegendItems();this._svgElements=r,this.width=i}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,Vt(t));e+=12;const i={y:this.yShift,x:e};return{elements:[r,this.svgElementFactory.createTextElement(t,i,15,"var(--grey-6)")],width:12+Ut.getTextDimensions(t,15).width}}createLegendItems(){let t=10;const e=[],n=e=>t+=e+15;if(this.isPhosphorothioatePresent()){const{elements:r,width:i}=this.createLegendItem("PTO linkage",t);n(i),e.push(r)}return this.getModificationTypesList().forEach((r=>{const{elements:i,width:o}=this.createLegendItem(r,t);n(o),e.push(i)})),{elements:e.flat(),width:t}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Jt{constructor(t){this.svgElementFactory=new Wt;const e=at().cloneDeep(t);let n=10;this.title=new Kt(this.svgElementFactory,e,n),n+=this.title.getContentHeight(),this.strands=new $t(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Yt(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 Qt{constructor(t){this.eventBus=t,this.svgDisplayDiv=N.div([]),t.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),t.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(t){return new Qt(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 Jt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();kt.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Xt{constructor(t){this.eventBus=t,this.togglesContainer=N.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){M()(this.togglesContainer).empty(),M()(this.togglesContainer).append(this.createInputs())}createInputs(){const t=this.eventBus.getUniqueNucleotides().filter((t=>!nt(t))).map((t=>this.createSingleInput(t)));return t.sort(((t,e)=>t.captionLabel.textContent.localeCompare(e.captionLabel.textContent))),N.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=N.input.bool(t,{value:e,onValueChanged:e=>this.handleNumericLabelToggle(t,e)});return M()(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 Zt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Mt}createContainer(){return N.div([N.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=N.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),M()(t).empty(),M()(t).append(this.getExampleElements())})),t}getExampleElements(){return F.map((t=>new te(t,this.eventBus,this.subscriptions).create()))}}class te{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(),N.block50([N.h2(k[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):N.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 ${k[this.strand]}`),t}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((t,e)=>p.AL[e%p.AL.length])).join("")}createOutputExample(t){const e=this.createTextInputForExamples();return e.value=this.computeOutputValue(t),e.setTooltip(`Pattern applied to the example input for ${k[this.strand]}`),e}computeOutputValue(t){const e=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return Tt(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=N.input.textArea("",{value:""});return this.applyStylingToInput(t),t}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];e.setAttribute("readonly","true"),M()(e).css("resize","none"),M()(t.root).css("opacity","75%")}}class ee{constructor(t,e){this.eventBus=t,this.dataManager=e,this.svgDisplay=Qt.createSvgDiv(t)}getLayout(){const t=new Xt(this.eventBus).getContainer(),e=this.generateDownloadControls(),n=new Zt(this.eventBus,this.dataManager).createContainer();return N.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return N.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=N.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return N.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=N.button(N.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),N.tooltip.bind(t,"View pattern metadata"),t}async openInfoDialog(){let t=this.dataManager.getCurrentUserName(),e=this.dataManager.getDefaultPatternName(),n=K,i=K;const o=new URLSearchParams(window.location.search).get("pattern");if(null!==o){const s=await this.dataManager.getPatternRecordByHash(o);if(null!==s){const o=s[q.AUTHOR_ID];if(t=(await r.dapi.users.find(o)).friendlyName,e=s[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[q.DATE]){const t=s[q.DATE][G.CREATE];void 0!==t&&(n=t);const e=s[q.DATE][G.MODIFY];void 0!==e&&(i=e)}}}const s=N.divV([N.divText(`Pattern Name: ${e}`),N.divText(`Author: ${t}`),N.divText(`Created: ${re(new Date(n))}`),N.divText(`Modified: ${re(new Date(i))}`)]);r.shell.info(s)}createShareLinkButton(){const t=N.button(N.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})),N.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=N.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),N.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 Y?new ne(this.eventBus,this.dataManager).show():t instanceof J?r.shell.warning(N.div([N.divText("Pattern already exists"),N.button("Load",(()=>{const e=t.message;this.eventBus.requestLoadPatternInNewTab(e)}))])):console.error("Error while saving pattern",t)}}class ne{constructor(t,e){this.eventBus=t,this.dataManager=e}show(){const t=this.eventBus.getPatternName(),e=N.dialog(`Pattern "${t}" already exists`);e.add(N.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 re(t){return t.toLocaleString().split(":").slice(0,-1).join(":")}class ie extends D{constructor(t){super("Oligo Pattern"),this.th=t}getContent(){return async function(){const t=await Z.getInstance(),e=new ct,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 lt(t,n);e.subscribeToObservables(r);const i=new Ft(r,t).getLayout(),o=new ee(r,t).getLayout();return N.splitH([i,o],{},!0)}()}}var oe=n(507),se={};function ae(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?ae(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}se.styleTagTransform=At(),se.setAttributes=bt(),se.insert=mt().bind(null,"head"),se.domAPI=pt(),se.insertStyleElement=wt(),dt()(oe.A,se),oe.A&&oe.A.locals&&oe.A.locals;var le,ue=n(74),ce={};ce.styleTagTransform=At(),ce.setAttributes=bt(),ce.insert=mt().bind(null,"head"),ce.domAPI=pt(),ce.insertStyleElement=wt(),dt()(ue.A,ce),ue.A&&ue.A.locals&&ue.A.locals;class he{constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,M()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{M()(this.textArea).css("height",0),M()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=N.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"}(le||(le={}));class de{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 i=0;i<this.atomCount;i++){r=this.shiftIdxToXColumn(r);for(const o of[t,e,n])o[i]=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 fe extends de{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 pe extends fe{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(le.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(le.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),r=n.map((t=>e[t])),i=n.map((t=>e[t+1]));r.forEach(((e,n)=>{const r=parseInt(e.split(/\s+/)[1])-1,o=parseInt(i[n].substring(1));if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,r)}));const o=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);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(le.TYPE)&&-1!==t.indexOf(le.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,le.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<le.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,le.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,le.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+le.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=le.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends fe{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 i=e[1];if(t.has(i))throw new Error(`R group ${i} is already in the map`);t.set(i,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 me{constructor(){}static getInstance(t){if(me.isMolfileV2K(t))return new pe(t);if(me.isMolfileV3K(t))return new ge(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return pe.isValidMolfile(t)}static isMolfileV3K(t){return ge.isValidMolfile(t)}}const ye=class extends Error{constructor(t){super(t)}};class be{constructor(t){this.molblock=t}get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof ye&&(t="");const n=ae(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new ye("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=ae(t);console.error(e)}}getMoleculeDimensions(){const t=me.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=N.dialog({title:"Molecule",showFooter:!1}),e=.7*M()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,i=e,o=n.width*r,s=N.canvas(o,i);await this.drawMolBlockOnCanvas(s);const a=N.block([s],{style:{overflowX:"scroll"}});t.add(a).showModal(!0),M()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),M()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),M()(t.root).find(".d4-dialog-contents").addClass("ui-box"),M()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const r=N.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(N.tooltip.bind(r,"Click to zoom"))}}class ve 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 i=this.getSymbolForCode(n);r>0&&function(t){return Or.jsonData.monomersWithPhosphate.left.includes(t)}(i)&&e.pop(),e.push(i);const o=Ce(i),s=r===t.length-1,a=r+1<t.length&&Ce(this.getSymbolForCode(t[r+1]));o||function(t){return Or.jsonData.monomersWithPhosphate.right.includes(t)}(i)||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 ve(`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 Ce(t){return Or.jsonData.monomersWithPhosphate.phosphate.includes(t)}class Ae{constructor(t,e=!1,n){this.invert=e,this.lib=Or.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),i=e.atomIndex.indexOf(n),o=(e.x[i]+e.x[r])/2,s=(e.y[i]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=o,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 i=Array(e.natom),o=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),i[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),o[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:i,atomType:o,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),i=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,r,i);const o=(e.x[i]+e.x[r])/2,s=(e.y[i]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=s;let a=0;if(0===e.x[r])a=e.y[r]>e.y[i]?Math.PI/2:3*Math.PI/2;else if(0===e.y[r])a=e.x[r]>e.x[i]?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="",i="",o="";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 o=0;n&&(o=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=o:r===o&&(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 i=u-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(f,p))+i))/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 g=t[e].indexOf("M V30 END ATOM");r+=t[e].substring(d+1,g);let m=t[e].indexOf("M V30 BEGIN BOND");m=t[e].indexOf("\n",m),f=m,p=m;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 i=0;n?(i=parseInt(t[e].substring(f,p)),1===i?i=o:i===o&&(i=1),i+=a):i=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+i+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=Math.min(t[e].indexOf("\n",f),t[e].indexOf(" ",f)),i=0,n?(i=parseInt(t[e].substring(f,p)),1===i?i=o:i===o&&(i=1),i+=a):i=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+i+t[e].slice(p),f=t[e].indexOf("\n",f)+1}const y=t[e].indexOf("M V30 END BOND");i+=t[e].substring(m+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);o+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){o+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)o+=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+=i,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=o,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,i=t.x[r],o=t.y[r],s=t.x[n]-i,a=t.y[n]-o,l=t.x[e]-i,u=t.y[e]-o,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,g=h-a;Math.sqrt(g*g+p*p)>=Math.sqrt(f*f+d*d)&&(t.x[e]=c+i,t.y[e]=h+o)}}var xe=n(670);function _e(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let i="";try{i=new Ae(t,e,r).convert()}catch(t){const e=ae(t);console.error(e)}return i}function Se(t,e,n,r,i){const o=[t,e,n].filter((t=>""!==t.strand));if(1===o.length)return _e(o[0].strand,o[0].invert,i);{const o=_e(t.strand,t.invert,i),s=[_e(e.strand,e.invert,i),_e(n.strand,n.invert,i)].filter((t=>""!==t));return(0,xe.vS)({senseStrands:[o],antiStrands:s},r)}}const Ee=["ss","as","as2"];class Te{constructor(){this.th=Or,this.onInput=new tt.Subject,this.onInvalidInput=new tt.Subject,this.inputBase=Object.fromEntries(Ee.map((t=>{const e=N.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),M()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=N.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=N.input.bool("Save as one entity",{value:!0}),N.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Ee.map((t=>[t,!1]))),this.moleculeImgDiv=N.block([]),M()(this.moleculeImgDiv).addClass("st-structure-mol-img"),i.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),i.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=N.divH([n,this.moleculeImgDiv]);M()(r).addClass("st-structure-bottom");const i=N.divV([e,r]);return M()(i).addClass("st-structure-body"),i}getBoolInputsAndButton(){const t=N.buttonsInput([N.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,i,o,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(o)l=Se(t,e,n,i,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()}m(`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=N.divV(e);for(const t of e)M()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Ee.map((e=>[e,new he(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Ee.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,N.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Ee.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"],i=new Map(Ee.map(((t,e)=>[t,r[e]]))),o=(Object.fromEntries(Ee.map((t=>[t,N.label(i.get(t))]))),Object.fromEntries(Ee.map((t=>{const n=N.icons.delete((()=>{e[t].inputBase.value=""})),r=N.button(n,(()=>{}));return N.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=N.form([],"st-structure-inputs"),a=N.divV([],"st-structure-clear-buttons"),l=N.form([],"st-direction-inputs");for(const t of Ee)s.append(this.inputBase[t].root),a.append(o[t]),l.append(n[t].root);return N.divH([s,a,l])}getStrandData(){return Object.fromEntries(Ee.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return Se(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=ae(t);console.error(e)}const e=new be(t);await e.drawMolecule(this.moleculeImgDiv,650,150),M()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class Ie extends D{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Te}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Ne=n(3);async function Oe(t){try{const e={overflowX:"scroll"},n=N.div([],{style:e}),i=(0,xe.cx)(t),o=.7*M()(window).height(),s=Math.max(...i.x)-Math.min(...i.x),a=Math.max(...i.y)-Math.min(...i.y),l=o/a,u=l*s,c=l*a,h=N.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),N.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=ae(t);console.error(e)}}class Me{static async view(){const t=Or.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 Oe(e)}))}}var Le=n(480),Be=n(67),Pe=n(254),Re={};Re.styleTagTransform=At(),Re.setAttributes=bt(),Re.insert=mt().bind(null,"head"),Re.domAPI=pt(),Re.insertStyleElement=wt(),dt()(Pe.A,Re),Pe.A&&Pe.A.locals&&Pe.A.locals;const De=["Sequence"];class Fe{constructor(t){this.th=t,this.inputFormats=Object.keys(Or.jsonData.codesToHelmDict).concat(p.NO.HELM),this.seqHelper=Or.seqHelper,this.onInput=new tt.Subject,this.moleculeImgDiv=N.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=N.div([]),this.formatChoiceInput=N.input.choice("",{value:p.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),M()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=N.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),i.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=Ve.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=N.box(N.panel([t,e,N.block([N.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=N.h1("Bulk");N.tooltip.bind(t,"Bulk translation from table input");const e=new ke(this.eventBus).createUIComponents(),n=N.input.choice("Input format",{value:p.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=N.input.choice("Output format",{value:Be.qP,items:(0,Le.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),i=this.createConvertBulkButton(),o=N.div([...e,n,r,i],"ui-form");return N.block25([t,o])}createConvertBulkButton(){const t=N.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return N.tooltip.bind(t,"Convert sequences from table input"),M()(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(),o=this.eventBus.getSelectedColumn("Sequence");if(!o)return void r.shell.warning("No sequence column selected");const s=`${o.name} (${n})`,a=i.Column.fromList(i.TYPE.STRING,s,o.toList().map((t=>(0,Le.C6)(t,e,n,this.th))));if(n===Be.qP||n===p.NO.HELM){a.semType=i.SEMTYPE.MACROMOLECULE;const t=n==Be.qP?Ne.Hi.FASTA:Ne.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 he(this.sequenceInputBase,(t=>L(t,this.th))),e=N.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=N.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=N.div([this.formatChoiceInput]),i=N.button(N.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));N.tooltip.bind(i,"Clear input");const o={format:r,textInput:t.root,clearBtn:i},s=N.table([o],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=N.block([this.outputTableDiv,e,n]);return N.block75([N.h1("Single sequence"),s,a])}saveMolfile(){const t=new Ae(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";m(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=i.chem.convert(this.molfile,i.chem.Notation.MolBlock,i.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,Le.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const i="indexOfFirstInvalidChar"in e?N.divH([]):N.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Be.n_)))),Be.U_,"");n.push({format:t,sequence:i})}const i=N.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(i),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new be(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===p.NO.HELM){const t=this.th.createFormatConverter(this.sequence,this.format).convertTo(p.NO.AXOLABS);return new Ae(t,!1,p.NO.AXOLABS).convert()}return new Ae(this.sequence,!1,this.format).convert()}}class ke{constructor(t){this.tableInputManager=new He(t),this.columnInputManager=new Ue(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class He{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=N.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();M()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getSelectedTable();return N.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 Ue{constructor(t){this.eventBus=t,this.columnControlsContainer=N.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const t=this.createColumnInputs();M()(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 De.map((n=>this.createColumnInput(n,e,t)))}createColumnInput(t,e,n){const r=t.toLowerCase(),i=e.find((t=>t.toLowerCase().includes(r)))||e[0];return this.selectColumnIfTableNotNull(n,i,t),N.input.choice(`${t}`,{value:i,items:e,onValueChanged:e=>this.selectColumnIfTableNotNull(n,e,t)})}selectColumnIfTableNotNull(t,e,n){if(null!==t){const r=t.getCol(e);this.eventBus.selectColumn(n,r)}}}class Ve{constructor(){this._tableSelection$=new tt.BehaviorSubject(null),this._columnSelection=Object.fromEntries(De.map((t=>[t,new tt.BehaviorSubject(null)]))),this._inputFormatSelection$=new tt.BehaviorSubject(p.NO.AXOLABS),this._outputFormatSelection$=new tt.BehaviorSubject(Be.qP)}static getInstance(){return void 0===Ve._instance&&(Ve._instance=new Ve),Ve._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 $e extends D{constructor(t){super("Oligo Translator"),this.th=t,this.th=Or,this.layout=new Fe(this.th);const e=N.iconFA("book",Me.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class je extends D{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class qe extends R{constructor(t,e){super("Oligo Toolkit"),this.externalViewFactories=t,this.th=e;const n=this.getViewFactories(this.th);this.multiView=new i.MultiView({viewFactories:n})}getViewFactories(t){function e(e){i.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($e),PATTERN:e(ie),STRUCTURE:e(Ie)};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/${Or.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}var Ge=n(70);function ze(t){const e=N.input.textArea("",{value:""});return{coloredInput:new he(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var We=n(124),Ke=n(192),Ye=n(312),Je=n(991),Qe=n.n(Je);const Xe="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Ze=new Set,tn="object"==typeof process&&process?process:{},en=(t,e,n,r)=>{"function"==typeof tn.emitWarning?tn.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let nn=globalThis.AbortController,rn=globalThis.AbortSignal;if(void 0===nn){rn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},nn=class{constructor(){e()}signal=new rn;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"!==tn.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,en("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 on=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),sn=t=>on(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?an:null:null;class an extends Array{constructor(t){super(t),this.fill(0)}}class ln{heap;length;static#t=!1;static create(t){const e=sn(t);if(!e)return[];ln.#t=!0;const n=new ln(t,e);return ln.#t=!1,n}constructor(t,e){if(!ln.#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 un{#e;#n;#r;#i;#o;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#c;#h;#d;#f;#p;#g;#m;#y;#b;#v;#w;#C;#A;#x;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#w,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.#g},free:t.#m,isBackgroundFetch:e=>t.#_(e),backgroundFetch:(e,n,r,i)=>t.#S(e,n,r,i),moveToTail:e=>t.#E(e),indexes:e=>t.#T(e),rindexes:e=>t.#I(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.#o}get memoMethod(){return this.#s}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:i,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:u,noDisposeOnSet:c,noUpdateTTL:h,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:g,memoMethod:m,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:w,ignoreFetchAbort:C}=t;if(0!==e&&!on(e))throw new TypeError("max option must be a nonnegative integer");const A=e?sn(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!==m&&"function"!=typeof m)throw new TypeError("memoMethod must be a function if defined");if(this.#s=m,void 0!==g&&"function"!=typeof g)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=g,this.#A=!!g,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.#g=0,this.#m=ln.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof u?(this.#i=u,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#C=!!this.#r,this.#x=!!this.#i,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!C,0!==this.maxEntrySize){if(0!==this.#n&&!on(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!on(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=on(r)||0===r?r:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!on(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=>!Ze.has(t))(t)&&(Ze.add(t),en("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,un))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#M(){const t=new an(this.#e),e=new an(this.#e);this.#w=t,this.#v=e,this.#L=(n,r,i=Xe.now())=>{if(e[n]=0!==r?i:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#N(n)&&this.#B(this.#c[n],"expire")}),r+1);t.unref&&t.unref()}},this.#P=n=>{e[n]=0!==t[n]?Xe.now():0},this.#R=(i,o)=>{if(t[o]){const s=t[o],a=e[o];if(!s||!a)return;i.ttl=s,i.start=a,i.now=n||r();const l=i.now-a;i.remainingTTL=s-l}};let n=0;const r=()=>{const t=Xe.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const o=this.#u.get(i);if(void 0===o)return 0;const s=t[o],a=e[o];return s&&a?s-((n||r())-a):1/0},this.#N=i=>{const o=e[i],s=t[i];return!!s&&!!o&&(n||r())-o>s}}#P=()=>{};#R=()=>{};#L=()=>{};#N=()=>!1;#O(){const t=new an(this.#e);this.#l=0,this.#b=t,this.#D=e=>{this.#l-=t[e],t[e]=0},this.#F=(t,e,n,r)=>{if(this.#_(e))return 0;if(!on(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),!on(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#k=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#H(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#D=t=>{};#k=(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};*#T({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#g;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#U(e)&&(!t&&this.#N(e)||(yield e),e!==this.#g);)e=this.#d[e]}#U(t){return void 0!==t&&this.#u.get(this.#c[t])===t}*entries(){for(const t of this.#T())void 0===this.#h[t]||void 0===this.#c[t]||this.#_(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*rentries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#c[t]||this.#_(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*keys(){for(const t of this.#T()){const e=this.#c[t];void 0===e||this.#_(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#I()){const e=this.#c[t];void 0===e||this.#_(this.#h[t])||(yield e)}}*values(){for(const t of this.#T())void 0===this.#h[t]||this.#_(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#I())void 0===this.#h[t]||this.#_(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#T()){const r=this.#h[n],i=this.#_(r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#T()){const r=this.#h[n],i=this.#_(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],i=this.#_(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#I({allowStale:!0}))this.#N(e)&&(this.#B(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.#_(n)?n.__staleWhileFetching:n;if(void 0===r)return;const i={value:r};if(this.#w&&this.#v){const t=this.#w[e],n=this.#v[e];if(t&&n){const e=t-(Xe.now()-n);i.ttl=e,i.start=Date.now()}}return this.#b&&(i.size=this.#b[e]),i}dump(){const t=[];for(const e of this.#T({allowStale:!0})){const n=this.#c[e],r=this.#h[e],i=this.#_(r)?r.__staleWhileFetching:r;if(void 0===i||void 0===n)continue;const o={value:i};if(this.#w&&this.#v){o.ttl=this.#w[e];const t=Xe.now()-this.#v[e];o.start=Math.floor(Date.now()-t)}this.#b&&(o.size=this.#b[e]),t.unshift([n,o])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=Xe.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:i,noDisposeOnSet:o=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.#B(t,"set"),this;let c=0===this.#a?void 0:this.#u.get(t);if(void 0===c)c=0===this.#a?this.#g:0!==this.#m.length?this.#m.pop():this.#a===this.#e?this.#H(!1):this.#a,this.#c[c]=t,this.#h[c]=e,this.#u.set(t,c),this.#d[this.#g]=c,this.#f[c]=this.#g,this.#g=c,this.#a++,this.#k(c,u,a),a&&(a.set="add"),l=!1;else{this.#E(c);const n=this.#h[c];if(e!==n){if(this.#A&&this.#_(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||o||(this.#C&&this.#r?.(e,t,"set"),this.#x&&this.#y?.push([e,t,"set"]))}else o||(this.#C&&this.#r?.(n,t,"set"),this.#x&&this.#y?.push([n,t,"set"]));if(this.#D(c),this.#k(c,u,a),this.#h[c]=e,a){a.set="replace";const t=n&&this.#_(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#w||this.#M(),this.#w&&(l||this.#L(c,r,i),a&&this.#R(a,c)),!o&&this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#h[this.#p];if(this.#H(!0),this.#_(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.#i?.(...e)}}}#H(t){const e=this.#p,n=this.#c[e],r=this.#h[e];return this.#A&&this.#_(r)?r.__abortController.abort(new Error("evicted")):(this.#C||this.#x)&&(this.#C&&this.#r?.(r,n,"evict"),this.#x&&this.#y?.push([r,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#h[e]=void 0,this.#m.push(e)),1===this.#a?(this.#p=this.#g=0,this.#m.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,i=this.#u.get(t);if(void 0!==i){const t=this.#h[i];if(this.#_(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#N(i))return n&&this.#P(i),r&&(r.has="hit",this.#R(r,i)),!0;r&&(r.has="stale",this.#R(r,i))}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 i=this.#h[r];return this.#_(i)?i.__staleWhileFetching:i}#S(t,e,n,r){const i=void 0===e?void 0:this.#h[e];if(this.#_(i))return i;const o=new nn,{signal:s}=n;s?.addEventListener("abort",(()=>o.abort(s.reason)),{signal:o.signal});const a={signal:o.signal,options:n,context:r},l=(r,i=!1)=>{const{aborted:s}=o.signal,l=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(s&&!i?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!i)return u(o.signal.reason);const h=c;return this.#h[e]===c&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#B(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:i}=o.signal,s=i&&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.#B(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.#o?.(t,i,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),r),o.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:o,__staleWhileFetching:i,__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}#_(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof nn}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=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:g=!1,status:m,signal:y}=e;if(!this.#A)return m&&(m.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:m});const b={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:m,signal:y};let v=this.#u.get(t);if(void 0===v){m&&(m.fetch="miss");const e=this.#S(t,v,b,p);return e.__returned=e}{const e=this.#h[v];if(this.#_(e)){const t=n&&void 0!==e.__staleWhileFetching;return m&&(m.fetch="inflight",t&&(m.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#N(v);if(!g&&!i)return m&&(m.fetch="hit"),this.#E(v),r&&this.#P(v),m&&this.#R(m,v),e;const o=this.#S(t,v,b,p),s=void 0!==o.__staleWhileFetching&&n;return m&&(m.fetch=i?"stale":"refresh",s&&i&&(m.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}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:i,...o}=e,s=this.get(t,o);if(!i&&void 0!==s)return s;const a=n(t,s,{options:o,context:r});return this.set(t,a,o),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=e,s=this.#u.get(t);if(void 0!==s){const e=this.#h[s],a=this.#_(e);return o&&this.#R(o,s),this.#N(s)?(o&&(o.get="stale"),a?(o&&n&&void 0!==e.__staleWhileFetching&&(o.returnedStale=!0),n?e.__staleWhileFetching:void 0):(i||this.#B(t,"expire"),o&&n&&(o.returnedStale=!0),n?e:void 0)):(o&&(o.get="hit"),a?e.__staleWhileFetching:(this.#E(s),r&&this.#P(s),e))}o&&(o.get="miss")}#V(t,e){this.#f[e]=t,this.#d[t]=e}#E(t){t!==this.#g&&(t===this.#p?this.#p=this.#d[t]:this.#V(this.#f[t],this.#d[t]),this.#V(this.#g,t),this.#g=t)}delete(t){return this.#B(t,"delete")}#B(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.#$(e);else{this.#D(r);const n=this.#h[r];if(this.#_(n)?n.__abortController.abort(new Error("deleted")):(this.#C||this.#x)&&(this.#C&&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.#g)this.#g=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.#m.push(r)}}if(this.#x&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}return n}clear(){return this.#$("delete")}#$(t){for(const e of this.#I({allowStale:!0})){const n=this.#h[e];if(this.#_(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#c[e];this.#C&&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.#w&&this.#v&&(this.#w.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#g=0,this.#m.length=0,this.#l=0,this.#a=0,this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#i?.(...e)}}}var cn=n(16);const hn={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"};function dn(t,e){return t[e.polymerType]?.[e.symbol]}class fn extends Map{constructor(t){super(t)}}class pn{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new pn("",new fn(null))}}var gn=n(151),mn=n(599);function yn(t){let e;switch(t){case mn.o.BASE:case mn.o.SUGAR:case mn.o.LINKER:case mn.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case mn.o.AA:e="PEPTIDE";break;case mn.o.CHEM:e="CHEM";break;case mn.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}function bn(t,e,n,r){r.flipFactor=(-1)**(r.i%2),vn(t,e,n,r)}function vn(t,e,n,r){!function(t,e,n){for(let r=0;r<t.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;e[n.nodeShift+r]=hn.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[r]+" "+xn(n.backbonePositionShift[0]+t.atoms.x[r])+" "+xn(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[r])+" "+t.atoms.kwargs[r]}}(t,e,r),Cn(t,n,r),function(t,e,n){if(0!==n.backboneAttachNode){const r=n.bondShift,i=n.backboneAttachNode,o=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=hn.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+o+"\n"}}(t,n,r),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,r),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift[0],e.backbonePositionShift[1]+=e.flipFactor*t.meta.backboneShift[1]}(t,r)}function wn(t,e,n,r,i){if(0===r.i)vn(i.sugar,e,n,r);else for(const t of[i.phosphate,i.sugar])vn(t,e,n,r);!function(t,e,n,r){(function(t,e,n){for(let r=0;r<t.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;e[n.nodeShift+r]=hn.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[r]+" "+xn(n.branchPositionShift[0]+t.atoms.x[r])+" "+xn(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[r])+" "+t.atoms.kwargs[r]}})(t,e,r),Cn(t,n,r),function(t,e,n){const r=n.bondShift,i=n.branchAttachNode,o=t.meta.terminalNodes[0]+n.nodeShift;e[r-1]=hn.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+o+"\n"}(t,n,r);const i=r.bondShift,o=r.branchAttachNode,s=t.meta.terminalNodes[0]+r.nodeShift;n[i-1]=hn.V3K_BEGIN_DATA_LINE+i+" 1 "+o+" "+s+"\n",r.bondShift+=t.bonds.atomPairs.length+1,r.nodeShift+=t.atoms.atomTypes.length}(t,e,n,r)}function Cn(t,e,n){for(let r=0;r<t.bonds.atomPairs.length;++r){const i=n.bondShift+r+1,o=t.bonds.atomPairs[r][0]+n.nodeShift,s=t.bonds.atomPairs[r][1]+n.nodeShift;let a="";if(t.bonds.bondConfiguration.has(r)){let e=t.bonds.bondConfiguration.get(r);n.flipFactor<0&&(e=1===e?3:1),a=" CFG="+e}const l=t.bonds.kwargs.has(r)?" "+t.bonds.kwargs.get(r):"";e[n.bondShift+r]=hn.V3K_BEGIN_DATA_LINE+i+" "+t.bonds.bondTypes[r]+" "+o+" "+s+a+l+"\n"}}function An(t,e,n,r){let i=0,s=0,a=0;for(const n of t){if(n.symbol===o._S)continue;if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");const t=dn(e,{symbol:n.symbol,polymerType:yn(n.biotype)});i+=t.atoms.x.length,s+=t.bonds.bondTypes.length,a++}if("PEPTIDE"===r)i+=1,s+=a;else{const r=n===o.YI.DNA?dn(e,hn.DEOXYRIBOSE):dn(e,hn.RIBOSE),a=dn(e,hn.PHOSPHATE);i+=(t.length-1)*a.atoms.x.length,i+=t.length*r.atoms.x.length,i+=1,s+=(t.length-1)*a.bonds.bondTypes.length,s+=t.length*r.bonds.bondTypes.length,s-=1,s+=3*t.length}return{atomCount:i,bondCount:s}}function xn(t){return Math.round(hn.PRECISION_FACTOR*t)/hn.PRECISION_FACTOR}function _n(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}function Sn(t,e){const n={},r={};for(const o of t){const t=_n(e.getWebEditorMonomer(o.biotype,o.symbol).backgroundcolor??i.Color.toRgb(i.Color.mouseOverRows))??[1,0,0,.7];for(const e of o.atoms)n[e]=t;for(const e of o.bonds)r[e]=t}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(r).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:r}}function En(t,e,n,r,i,o){const s={polymerType:i,symbol:e};if(a=t,l=s,!a[l.polymerType]?.[l.symbol]){const a=function(t,e,n,r,i){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,""),e.push(t)}return e}(s.rgroups),l=(o=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}(o):function(t){const e=new Map;let n=t.indexOf(hn.V2K_A_LINE,0),r=n;for(;-1!==n;){r=t.indexOf("\n",n);const i=parseInt(t.substring(n,r).replace(/^A\s+/,""));n=t.indexOf("R",r),r=t.indexOf("\n",n);const o=parseInt(t.substring(n,r).replace(/^R/,""));e.set(i,o),n=t.indexOf(hn.V2K_A_LINE,r)}for(n=t.indexOf(hn.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=hn.V2K_RGP_SHIFT,r=t.indexOf("\n",n);const i=t.substring(n,r).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<i.length;t+=2){if(e.has(i[t])&&e.get(i[t])!==i[t+1])throw new Error(`r-group index ${i[t]} has already been added with a different value`);e.set(i[t],i[t+1])}n=t.indexOf(hn.V2K_RGP_LINE,r)}return e}(o),u=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(t),r=n.get_v3Kmolblock();return n.delete(),r}(function(t){let e=t.indexOf(hn.V2K_A_LINE,0);-1===e&&(e=t.indexOf(hn.V2K_RGP_LINE));const n=t.indexOf(hn.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(hn.V3K_BEGIN_COUNTS_LINE)+hn.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))}}(u),h=function(t,e){const n=new Array(e),r=new Float32Array(e),i=new Float32Array(e),o=new Array(e);let s=t.indexOf(hn.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(hn.V3K_BEGIN_DATA_LINE,s)+hn.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],i[l]=e[1],s=a,a=t.indexOf("\n",s)+1,o[l]=t.slice(s,a),s=a}return{atomTypes:n,x:r,y:i,kwargs:o}}(u,c.atomCount),d=function(t,e){const n=new Uint32Array(e),r=new Array(e),i=new Map,o=new Map;let s=t.indexOf(hn.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(hn.V3K_BEGIN_DATA_LINE,a)+hn.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(hn.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));i.set(l,e);const n=hn.V3K_BOND_CONFIG+e.toString();c=c.replace(n,"")}c||o.set(l,c)}return{bondTypes:n,atomPairs:r,bondConfiguration:i,kwargs:o}}(u,c.bondCount),f=function(t,e,n,r){const i={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,n){for(const[r,i]of n)t.atomTypes[r-1]=e[i-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,i),Tn(e,i),i}(h,d,a,l),p=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}(u),g={atoms:h,bonds:d,meta:f,stereoAtoms:p};return"PEPTIDE"===r?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,i=t.atoms.y;Rn(t,-r[e],-i[e]);const o=Ln(r[n],i[n]);Bn(t.atoms,-o),r[t.meta.rNodes[1]-1]<0&&function(t){Pn(t,!1)}(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],i=n[(t+1)%2];e.has(r)?e.get(r)?.push(i):e.set(r,new Array(1).fill(i))}return e}(t);let n=0;const r=t.atoms.atomTypes.length;let i=0;for(;0===n;){const o=e.get(t.meta.terminalNodes[1])[i];if(t.atoms.atomTypes[o-1]===hn.OXYGEN&&o!==t.meta.rNodes[1]&&(n=o),i++,i>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){Pn(t,!0)}(t),Bn(t.atoms,-function(t,e){return Ln(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,i=n-1,o=t.atoms.x,s=t.atoms.y,a=o[r],l=s[r];o[r]=o[i],s[r]=s[i],o[i]=a,s[i]=l}(t,e,t.meta.rNodes[1])}(t,s))}(g):t===hn.RIBOSE.symbol||t===hn.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,r=t.atoms.y;let i=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;Rn(t,-n[i],-r[i]);const s=Ln(n[o],r[o]);Bn(t.atoms,3*Math.PI/2-s),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,r=t.meta.rNodes[2]-1,i=t.meta.terminalNodes[2]-1,o=e[r]-e[i],s=n[r]-n[i];return Math.atan(s/o)+Math.PI/2}(t),i=t.meta.terminalNodes[0]-1,Rn(t,-n[i],-r[i])}(g,i):t===hn.PHOSPHATE.symbol?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,i=t.atoms.y;Rn(t,-r[e],-i[e]);const o=Ln(r[n],i[n]);Bn(t.atoms,Math.PI/2-o)}(g):function(t,e){const n=t.atoms.x,r=t.atoms.y,i=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;Rn(t,-n[i],-r[i]);const s=Ln(n[o],r[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");Bn(t.atoms,Math.PI-s+a);const l=function(t,e){return xn(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!=l)for(let t=0;t<n.length;++t)n[t]=xn(n[t]/l),r[t]=xn(r[t]/l)}(g,i),function(t,e,n){"PEPTIDE"===t?(In(e,t),On(e,e.meta.rNodes[1])):n===hn.RIBOSE.symbol||n===hn.DEOXYRIBOSE.symbol?(On(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],Tn(e.bonds,e.meta),In(e,t),On(e,e.meta.rNodes[1]),On(e,e.meta.rNodes[0]),On(e,e.meta.rNodes[2])):n===hn.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],Rn(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),In(e,t),On(e,e.meta.rNodes[1]))}(r,g,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===hn.HYDROGEN&&(On(t,e+1),--e),++e}(g),g}var o;return null}(e,n,r,i,o);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);!function(t,e,n){let r=t[e.polymerType];r||(r=t[e.polymerType]={}),r[e.symbol]=n}(t,s,a)}var a,l}function Tn(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const r=e.terminalNodes,i=t.atomPairs;let o=0,s=0;for(;o<i.length&&s<r.length;){for(let t=0;t<r.length;++t)for(let e=0;e<2;++e)i[o][e]===n[t]&&(r[t]=i[o][(e+1)%2],n.length,++s);++o}}function In(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=Nn(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=Nn(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function Nn(t,e,n){return[xn(t.atoms.x[e]-t.atoms.x[n]),xn(t.atoms.y[e]-t.atoms.y[n])]}function On(t,e){if(void 0!==e){const n=e-1,r=t.atoms,i=t.bonds,o=t.meta;r.atomTypes.splice(n,1),r.x=Mn(Float32Array,r.x,n,1),r.y=Mn(Float32Array,r.y,n,1),r.kwargs.splice(n,1);for(let t=0;t<o.terminalNodes.length;++t)o.terminalNodes[t]>e?--o.terminalNodes[t]:o.terminalNodes[t]===e&&(o.terminalNodes[t]=-1);for(let t=0;t<o.rNodes.length;++t)o.rNodes[t]>e?--o.rNodes[t]:o.rNodes[t]===e&&(o.rNodes[t]=-1);let s=0;for(;s<i.atomPairs.length;){const t=i.atomPairs[s][0],n=i.atomPairs[s][1];t===e||n===e?(i.atomPairs.splice(s,1),i.bondTypes=Mn(Uint32Array,i.bondTypes,s,1),i.bondConfiguration.has(s)&&i.bondConfiguration.delete(s),i.kwargs.has(s)&&i.kwargs.delete(s),--s):(i.atomPairs[s][0]=t>e?t-1:t,i.atomPairs[s][1]=n>e?n-1:n),++s}let a=Array.from(i.bondConfiguration.keys());a.forEach((t=>{if(i.bondConfiguration.has(t)&&t>n){const e=i.bondConfiguration.get(t);i.bondConfiguration.delete(t),i.bondConfiguration.set(t-1,e)}})),a=Array.from(i.kwargs.keys()),a.forEach((t=>{if(i.kwargs.has(t)&&t>n){const e=i.kwargs.get(t);i.kwargs.delete(t),i.kwargs.set(t-1,e)}}))}}function Mn(t,e,n,r){const i=new t(e.length-r);let o=0,s=0;for(;o<e.length;)o===n&&(o+=r),i[s]=e[o],++s,++o;return i}function Ln(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,i=Math.atan(r);n=t<0?Math.PI/2+i:-Math.PI/2+i}return n}function Bn(t,e){if(0!==e){const n=t.x,r=t.y,i=Math.cos(e),o=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=xn(e*i-r[t]*o),r[t]=xn(e*o+r[t]*i)}}}function Pn(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 Rn(t,e,n){const r=t.atoms.x,i=t.atoms.y;for(let t=0;t<r.length;++t)r[t]=xn(r[t]+e),void 0!==n&&(i[t]=xn(i[t]+n))}const Dn="MonomerHoverLinks";function Fn(t,e,n,r,i){const s=new un({max:100});function a(t,e){const a=t.get(e);if(null==a)return null;let l=s.get(a);return l||s.set(a,l=function(t,e){const s=r.getSeqHandler(t),a=s.getSplitted(e),l=s.defaultBiotype,u=Qe().count(0).take(a.length).map((t=>({position:t,symbol:a.getCanonical(t),biotype:l}))).toArray(),c=s.alphabet,h=c==Ne.YI.RNA||c==Ne.YI.DNA?"RNA":"PEPTIDE";return function(t,e,n,r){if(0===t.length)return pn.createEmpty();const i=An,{atomCount:s,bondCount:a}=i(t,e,n,r),l=new Array(s),u=new Array(a);let c,h=null,d=null;"PEPTIDE"===r?c=bn:(c=wn,h=n===o.YI.DNA?dn(e,hn.DEOXYRIBOSE):dn(e,hn.RIBOSE),d=dn(e,hn.PHOSPHATE));const f={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},p={sugar:h,phosphate:d,seqLength:t.length,atomCount:s,bondCount:a},g=new fn,m=[];let y=0;for(f.i=0;f.i<p.seqLength;++f.i){const n=t[f.i];if(n.symbol===o._S)continue;const r=dn(e,{symbol:n.symbol,polymerType:yn(n.biotype)}),i=f.nodeShift,s=f.bondShift;c(r,l,u,f,p),r.stereoAtoms?.forEach((t=>m.push(t+y))),y+=r.atoms.x.length;const a=f.nodeShift-i,h=new Array(a);for(let t=0;t<a;++t)h[t]=i+t;const d=f.bondShift-s,b=new Array(d);for(let t=0;t<d;++t)b[t]=s+t;g.set(f.i,{biotype:n.biotype,symbol:n.symbol,atoms:h,bonds:b})}!function(t,e,n,r){const i=n.nodeShift+1;t[r.atomCount]=hn.V3K_BEGIN_DATA_LINE+i+" "+hn.OXYGEN+" "+xn(n.backbonePositionShift[0])+" "+n.flipFactor*xn(n.backbonePositionShift[1])+" 0.000000 0\n";const o=n.backboneAttachNode,s=i;e[r.bondCount]=hn.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+o+" "+s+"\n"}(l,u,f,p);const b=hn.V3K_BEGIN_COUNTS_LINE+s+" "+a+hn.V3K_COUNTS_LINE_ENDING;let v="";return v+=hn.V3K_HEADER_FIRST_LINE,v+=hn.V3K_HEADER_SECOND_LINE,v+=hn.V3K_BEGIN_CTAB_BLOCK,v+=b,v+=hn.V3K_BEGIN_ATOM_BLOCK,v+=l.join(""),v+=hn.V3K_END_ATOM_BLOCK,v+=hn.V3K_BEGIN_BOND_BLOCK,v+=u.join(""),v+=hn.V3K_END_BOND_BLOCK,m.length>0&&(v+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let r=0;r<t.length;r++){const i=`${n} ${t[r]}`;i.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[r]}`):n=i,r===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(m)),v+=hn.V3K_END_CTAB_BLOCK,v+=hn.V3K_END,{molfile:v,monomers:g}}(u,function(t,e,n,r,i){const s=function(t,e,n){const r=new Map;for(const i of t.getMonomerSymbolsByType(e)){const s=t.getMonomer(e,i);if("RNA"===e&&("Branch"===s.monomerType||n===o.YI.DNA&&s.symbol===hn.DEOXYRIBOSE.symbol||n===o.YI.RNA&&s.symbol===hn.RIBOSE.symbol||s.symbol===hn.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==s.monomerType){const t={};gn.f6.forEach((e=>{t[e]=s[e]})),r.set(s.symbol,t)}}return r}(r,e,n),a={},l={value:null};if("RNA"===e){const t=n===o.YI.RNA?[hn.RIBOSE,hn.PHOSPHATE]:[hn.DEOXYRIBOSE,hn.PHOSPHATE];for(const n of t)En(a,n.symbol,s,i,e,l)}for(let n=0;n<t.length;++n){const r=t[n];for(const t of r){const n=t.symbol;if(""!==n)try{En(a,n,s,i,e,l)}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 a}([u],h,c,n,i),c,h).monomers}(t,e)),l}const l={targetCol:e,handler:(e,r,i)=>{const o=i.grid,s=e.tableRowIndex,l=e.gridRow,u=o.cell(i.name,l),c=(0,cn.OF)();if(!c||c&&(c.dataFrameId!=t.dataFrame.id||c.gridRowIdx!=l||c.seqColName!=t.name||c.seqPosition!=r?.position)){if(c&&((0,cn.eV)(null),c.gridCell.grid?.invalidate()),!r)return(0,cn.eV)(null),!0;(0,cn.eV)({gridCell:u,dataFrameId:t.dataFrame.id,gridRowIdx:l,seqColName:t.name,seqPosition:r?r.position:-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=a(t,s);if(!e)return;const i=e.get(r.position);return i?Sn([i],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),o.invalidate()}return!0},getSubstruct:r=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==r)return;if(!t.get(r))return;const i=a(t,r);return i?Sn(i.values(),n):void 0}};return function(t,e){let n=t[Dn];n||(n=t[Dn]=[]),n.push(e),t[Dn]=n}(t.temp,l),(0,cn.QA)(e.temp,l),l}function kn(t,e){const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[Dn]??[]}(n);for(let n=r.length-1;n>=0;--n){const i=r[n],o=t.grid.col(i.targetCol.name);if(o&&!i.handler(t,e,o))break}}var Hn=n(717),Un=n(702),Vn=n(682);function $n(t,e=!0){const[n,i]=(0,Ke.AP)(t);return Or.logger.error(n,void 0,i),e&&r.shell.error(n),[n,i]}const jn="System:AppData/Bio/monomer-libraries/";async function qn(){const t=await r.functions.call("Bio:getMonomerLibHelper",{});return(await t.getFileManager()).getValidLibraryPaths()}const Gn="\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";const zn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Wn=[{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"}],Kn="No dataframe with macromolecule columns open",Yn="Get HELM",Jn="Add HELM column",Qn="Chirality engine",Xn="Poly Tool Conversion",Zn="Poly Tool Enumeration",tr="Rules used";function er(t){(async function(t){const e=[],n=()=>{for(const t of e)t.unsubscribe()};try{const[o,s]=await Promise.all([qn(),(0,We.b2)()]),a=t&&t.rowIndex>=0?t.value:Gn;let l=await(async()=>i.chem.isMolBlock(a)?a:await r.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:t?.column.getTag(i.TAGS.UNITS)??i.chem.Notation.Unknown,targetNotation:i.chem.Notation.MolBlock}))();const u=new i.chem.Sketcher(i.chem.SKETCHER_MODE.EXTERNAL);u.syncCurrentObject=!1,u.onChanged.subscribe((t=>{l=u.getMolFile()})),u.root.classList.add("ui-input-editor"),u.root.style.marginTop="3px",u.setMolFile(l);const c=N.input.choice("Library to use",{value:null,items:o});u.root.setAttribute("style","min-width:250px!important;"),u.root.setAttribute("style","max-width:250px!important;"),c.input.setAttribute("style","min-width:250px!important;");const h=N.div([u.root,c.root]);e.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===i.SEMTYPE.MOLECULE&&u.setValue(t.value)})));const d=async()=>{try{const t=u.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 r.functions.call("Bio:getMonomerLibHelper",{});return(await e.readLibrary(jn,t)).getMonomerSymbolsByType("PEPTIDE")}(e),i=await async function(t){const e=await r.functions.call("Bio:getMonomerLibHelper",{}),n=await e.readLibrary(jn,t),i=n.getMonomerSymbolsByType("PEPTIDE");return new Array(i.length),n.getMonomerMolsByPolymerType("PEPTIDE")}(e),o=new Array(n.length),s=await r.functions.call("Chem:getRdKitModule"),a=s.get_mol(t),l=a.get_smiles();a.delete();const u=new Array(n.length);for(let t=0;t<n.length;t++){const e=i[n[t]],r=s.get_mol(e);u[t]=r.get_smiles(),r.delete()}for(let t=0;t<n.length;t++){let e=null;try{const n=`${`${l}.${u[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();o[t]=r}catch(e){o[t]=""}finally{e?.delete()}}return o}(t,c.value),n=i.Column.fromStrings("Enumerated",e),o=i.DataFrame.fromColumns([n]);r.shell.addTableView(o)}else r.shell.warning("PolyTool: no R group was provided")}catch(t){$n(t)}},f=N.dialog(Zn).add(h).onOK((()=>{d().finally((()=>{n()}))})).onCancel((()=>{n()}));return e.push(f.onClose.subscribe((()=>{n()}))),f.history((()=>({mol:u.getMolFile(),screenLibrary:c.value})),(t=>{u.setMolFile(t.mol),c.value=t.screenLibrary})),f}catch(t){throw n(),t}})(t).then((t=>{t.show({resizable:!0})})).catch((t=>{r.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}))}async function nr(t,e,n,o){const s=i.TaskBarProgressIndicator.create("PolyTool converting...");try{const s=(t,e)=>t?t.columns.getUnusedName(e):e;await(0,We.b2)();const a=t.dataFrame,l=await(0,Un.Q4)(o),u=(0,Vn.by)(t.toList(),l),c=s(a,`transformed(${t.name})`),h=i.Column.fromType(i.COLUMN_TYPE.STRING,c,u.length).init((t=>u[t]));h.semType=i.SEMTYPE.MACROMOLECULE,h.meta.units=Ne.Hi.HELM,h.setTag(i.TAGS.CELL_RENDERER,"helm"),e&&a&&a.columns.add(h,!0);const d=await(0,Ye.Q)(),f=await(0,Hn.j)(),p=await(0,Vn.AM)(l),g=h.temp;g[".mm.cellRenderer.overriddenLibrary"]=p,h.temp=g;const m=(await d.helmToAtomicLevel(h,n,e,p)).molCol;return m.name=s(a,`molfile(${t.name})`),m.semType=i.SEMTYPE.MOLECULE,a&&(a.columns.add(m,!0),await r.data.detectSemanticTypes(a)),Fn(h,m,p,d,f),[h,m]}finally{s.close()}}class rr extends i.InputBase{constructor(t,e){super(N.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){N.input.setColumnInputTable(this,t,this.options?.filter)}}N.input.column2=function(t,e){return new rr(t,e)};var ir,or=n(296),sr=n(820);class ar extends i.JsInputBase{get inputType(){return"Positions"}get dataType(){return i.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.grid.dataFrame=t}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.grid.dataFrame=i.DataFrame.fromCsv(t)}get placeholdersValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){const r=parseInt(t.get("Position",n))-1;if(!isNaN(r)){const i=lr(t.get("Monomers",n));e.push({position:r,monomers:i})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.subs=[],t&&(this.captionLabel.innerText=t),this.gridHost=N.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}}),this.grid=e,this.gridHost.append(this.grid.root),null!=n?this.updateGridHeight(n+.7):(this.updateGridHeight(this.grid.dataFrame.rowCount+.6),this.subs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.6)})))),this.grid.root.style.width="100%",this.subs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.subs.push(N.onSizeChanged(this.grid.root).subscribe((()=>{this.grid.columns.byIndex(2).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-10}))),this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost)}detach(){for(const t of this.subs)t.unsubscribe()}static async create(t,e,n){const r=i.DataFrame.fromColumns([i.Column.fromType(i.COLUMN_TYPE.INT,"Position",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]),o=await r.plot.fromType(i.VIEWER.GRID,e);return o.sort(["Position"]),new ar(t,o,n)}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(2).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-10}}function lr(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 ur extends i.JsInputBase{get inputType(){return"Breadth"}get dataType(){return i.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.grid.dataFrame=t}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.grid.dataFrame=i.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,i=parseInt(t.get("End",n))-1;if(!isNaN(r)&&!isNaN(i)){const o=lr(t.get("Monomers",n));e.push({start:r,end:i,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.subs=[],t&&(this.captionLabel.innerText=t),this.gridHost=N.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}}),this.grid=e,this.gridHost.append(this.grid.root),null!=n?this.updateGridHeight(n+.7):(this.updateGridHeight(this.grid.dataFrame.rowCount+.6),this.subs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.6)})))),this.grid.root.style.width="100%",this.subs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.subs.push(N.onSizeChanged(this.grid.root).subscribe((()=>{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}))),this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost)}detach(){for(const t of this.subs)t.unsubscribe()}static async create(t,e,n){const r=i.DataFrame.fromColumns([i.Column.fromType(i.COLUMN_TYPE.INT,"Start",0),i.Column.fromType(i.COLUMN_TYPE.INT,"End",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]),o=await r.plot.fromType(i.VIEWER.GRID,e);return o.sort(["Start","End"]),new ur(t,o,n)}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}}async function cr(t){const e=window.innerWidth,n=window.innerHeight;try{let o;const s=()=>{if(null==o)return;const t=M()(o.root).find("div.d4-dialog-contents").get(0),e=t.clientHeight,n={0:1},r=Object.values(n).reduce(((t,e)=>t+e),0),i=e-Qe().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;o.inputs.forEach(((t,e)=>{if(e in n){const o=i*n[e]/r;t.root.style.height=`${o}px`}}))};o=await async function(t,e){const n="ST: PT: HelmDialog()";let o;const s=[],l=()=>{for(const t of s)t.unsubscribe();o.placeholders.detach()};try{const u=(await(0,a.pj)()).getMonomerLib(),c=(await(0,Ye.Q)(),i.DataFrame.fromColumns([])),[h,d]=await Promise.all([qn(),(0,We.b2)()]);let f=null;const p=N.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),g=N.divText("",{style:{color:"red"}});o={macromolecule:d.createHelmInput("Macromolecule",{editable:!1}),placeholders:await ar.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:N.input.choice("Enumerator type",{value:or.aK.Single,items:Object.values(or.aK)}),placeholdersBreadth:await ur.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:N.input.bool("Keep original",{value:!1}),toAtomicLevel:N.input.bool("To atomic level",{value:!1}),toHarmonizedSequence:N.input.bool("To harmonized sequence",{value:!1}),trivialNameCol:N.input.column2("Trivial name",{table:t?.dataFrame,filter:e=>e.type===i.COLUMN_TYPE.STRING&&e!=t?.column,onValueChanged:()=>{const e=o.trivialNameCol.value;let n=null;t&&e&&(n={value:e.get(t.rowIndex),colName:e.name}),f=n,p.textContent=f?`Original ID: ${f.value}`:""},nullable:!0})},o.toHarmonizedSequence.root.style.display="none",o.trivialNameCol.addOptions(p);let m=null;o.placeholders.addValidator((t=>{const e=[];try{const t=[];for(const n of o.placeholders.placeholdersValue){const r=n.position;if(r>=o.macromolecule.molValue.atoms.length){e.push(`There is no monomer at position ${r+1}.`);continue}const i=yn(o.macromolecule.molValue.atoms[r].biotype());for(const e of n.monomers){const n=u.getMonomer(i,e);n&&n.lib||t.push({polymerType:i,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}`),m=e.length>0?e.join("\n"):null}catch(t){const[e,n]=$n(t,!1);m=e}return setTimeout((()=>{b()}),0),m})),s.push(o.macromolecule.onMouseMove.subscribe((t=>{try{Or.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,i=o.macromolecule.molValue,s=d.getHoveredAtom(e,r,i,o.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s),n=o.placeholders.placeholdersValue.find((t=>t.position===e))?.monomers;if(n){const e=N.divText(n.join(", "));o.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){$n(t,!1)}}))),s.push(o.macromolecule.onClick.subscribe((t=>{try{Or.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,i=o.macromolecule.molValue,s=d.getHoveredAtom(e,r,i,o.macromolecule.root.clientHeight);if(s){const t=(s._parent.atoms.indexOf(s)+1).toString(),e=o.placeholders.grid.dataFrame,n=e.columns.byName("Position").toList();let r=n.indexOf(t);-1===r&&(r=n.findIndex((t=>isNaN(t))),-1===r&&(r=e.rows.addNew([t,""]).idx),e.set("Position",r,t)),e.currentCell=e.cell(r,"Monomers")}}catch(t){$n(t)}}))),s.push(o.placeholders.grid.dataFrame.onDataChanged.subscribe((()=>{y()}))),s.push((0,tt.fromEvent)(o.placeholders.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),s.push(N.onSizeChanged(o.placeholders.root).subscribe((()=>{e&&e()}))),s.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===i.SEMTYPE.MACROMOLECULE&&w(t)}))),o.macromolecule.root.style.setProperty("min-width","250px","important");const y=()=>{const t=o.macromolecule.molValue;for(let e=0;e<t.atoms.length;e++)t.atoms[e].highlighted=e in o.placeholders.placeholdersValue;o.macromolecule.redraw()},b=()=>{const t=m,e=g;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},v=t=>{t?(o.trivialNameCol.setColumnInputTable(t),o.trivialNameCol.root.style.removeProperty("display")):(o.trivialNameCol.setColumnInputTable(c),o.trivialNameCol.root.style.setProperty("display","none")),e&&e()},w=async t=>{let e,n;if(t&&t.rowIndex>=0&&t?.column.semType==i.SEMTYPE.MACROMOLECULE){const r=Or.seqHelper.getSeqHandler(t.column);e=(await r.getHelm(t.rowIndex)).value,n=t.dataFrame}else e=sr.d;o.macromolecule.stringValue=e,v(n)};await w(t);const C=async()=>{try{const t=o.macromolecule.stringValue;if(Qe().enumerate(o.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray(),void 0===t||""===t)r.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(o.placeholders.placeholdersValue).length&&0===Object.keys(o.placeholdersBreadth.placeholdersBreadthValue).length)return void r.shell.warning(`${Zn}: placeholders are empty`);await(0,We.b2)();const e={placeholders:o.placeholders.placeholdersValue,type:o.enumeratorType.value,placeholdersBreadth:o.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:o.keepOriginal.value},n=await async function(t,e,n,r){const o=i.TaskBarProgressIndicator.create("PolyTool enumerating...");try{await(0,We.b2)();const o=(0,sr.o)(t,e?.value??"",n),s=i.Column.fromType(i.COLUMN_TYPE.STRING,"Enumerated",o.length).init((t=>o[t][0])),a=i.DataFrame.fromColumns([s]);if(r){const t=await(0,Ye.Q)(),e=await t.helmToAtomicLevel(s,!0,!0);e.molCol.semType=i.SEMTYPE.MOLECULE,a.columns.add(e.molCol,!1)}if(e){const t=i.Column.fromType(i.COLUMN_TYPE.STRING,e.colName,o.length).init((t=>o[t][1]));a.columns.add(t)}return a}finally{o.close()}}(t,f,e,o.toAtomicLevel.value);r.shell.addTableView(n)}}catch(t){$n(t)}},A=N.dialog({title:Zn,showFooter:!0}).add(o.macromolecule).add(o.placeholders).add(o.enumeratorType).add(o.placeholdersBreadth).add(o.trivialNameCol).add(N.divH([o.keepOriginal.root,o.toAtomicLevel.root,o.toHarmonizedSequence.root],{style:{width:"100%"}})).add(g).onOK((()=>{C()}));return s.push(A.onClose.subscribe((()=>{l()}))),A.history((()=>({macromolecule:o.macromolecule.stringValue,placeholders:o.placeholders.stringValue,enumeratorType:o.enumeratorType.value,placeholdersBreadth:o.placeholdersBreadth.stringValue,trivialNameCol:o.trivialNameCol.stringValue,keepOriginal:o.keepOriginal.value,toAtomicLevel:o.toAtomicLevel.value,toHarmonizedSequence:o.toHarmonizedSequence.value})),(t=>{o.macromolecule.stringValue=t.macromolecule,o.placeholders.stringValue=t.placeholders,o.enumeratorType.value=t.enumeratorType,o.placeholdersBreadth.stringValue=t.placeholdersBreadth,o.trivialNameCol.stringValue=t.trivialNameCol,o.keepOriginal.value=t.keepOriginal,o.toAtomicLevel.value=t.toAtomicLevel,o.toHarmonizedSequence.value=t.toHarmonizedSequence})),A}catch(t){throw l(),t}}(t,s);let l=!0;N.onSizeChanged(o.root).subscribe((()=>{if(l){o.inputs;const t=M()(o.root),r=(t.find("div.d4-dialog-header").get(0).offsetHeight,t.find("div.d4-dialog-footer").get(0).offsetHeight,.7*e),i=.7*n;o.root.style.width=`${Math.min(e,r)}px`,o.root.style.height=`${Math.min(n,i)}px`,o.root.style.left=`${Math.floor((e-o.root.offsetWidth)/2)}px`,o.root.style.top=`${Math.floor((n-o.root.offsetHeight)/2)}px`,l=!1}s()})),s(),Or.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),o.show({width:Math.max(350,.7*e),resizable:!0}),Or.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(t){const[e,n]=(0,Ke.AP)(t);r.shell.warning("To run PolyTool Enumeration, sketch the macromolecule and select monomers to vary"),Or.logger.error(e,void 0,n)}}class hr{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(zn).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={...gn.pe};Object.entries(zn).forEach((([n,r])=>{const i=t[r];e[n]=i}));let n="smiles";const r=t[zn[n]],i=new dr(r),o=i.getCappedSmiles();return e[n]=o,n="rgroups",e[n]=fr.getRGroups(i.getNumberOfRGroups()),n="molfile",e[n]=new pr(i.getSmilesWithRGroups()).getMolfile(),e}}class dr{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 fr{constructor(){}static getRGroups(t){return Wn.slice(0,t)}}class pr{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=i.chem.convert(this.smilesWithRGroups,i.chem.Notation.Smiles,i.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 gr{constructor(t,e){this.fileName=t,this.fileContent=e,this.validateFileType();const n=i.DataFrame.fromCsv(this.fileContent),r=this.toJson(n);this.polyToolMonomerLib=new hr(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"}(ir||(ir={}));class mr{constructor(t){this.call=t,this.ruleInputs=new Un._v(Un.MU,Un.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t];this.inputs={table:(()=>{const e=t(ir.table);return N.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(ir.seqCol);return N.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:N.input.forProperty(t(ir.generateHelm).property),chiralityEngine:N.input.forProperty(t(ir.chiralityEngine).property),rules:{header:N.inlineText([tr]),form:await this.ruleInputs.getForm()}}}static async create(t){const e=new mr(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=N.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)=>{N.dialog({title:Xn}).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 yr{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 br extends yr{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++br.viewerCounter,this.errors=[],this._onRendered=new tt.Subject,this.tableCol&&this.tableCol.dataFrame&&this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),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,Ge.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`)}}br.viewerCounter=-1;var vr=n(291);const wr=vr.zS;var Cr,Ar,xr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(Cr||(Cr={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(Ar||(Ar={})),function(t){t.MSA="MSA",t.classic="classic"}(xr||(xr={}));const _r=new class{constructor(){this.color="rgb(100,100,100)",this.pivot=0,this.left=!1,this.transparencyRate=1,this.separator="",this.last=!1,this.drawStyle=xr.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0}};function Sr(t,e,n,r,i,o,s){var a,l,u;const c=Object.assign(Object.assign({},_r),s);s.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let h=e.substring(0),d=c.last?"":c.separator;c.drawStyle===xr.MSA&&(d="");let f=!0,p=!0,g="difference";if(null!=c.gridCell&&null!=c.gridCell.cell.column&&(f=c.gridCell.cell.column.temp["color-code"]??!0,p=c.gridCell.cell.column.temp["compare-with-current"]??!0,g=c.gridCell.cell.column.temp["highlight-difference"]??"difference"),c.referenceSequence){const t=c.referenceSequence[c.wordIdx];p&&c.referenceSequence.length>0&&"difference"===g&&(c.transparencyRate=h==t?.3:c.transparencyRate),p&&c.referenceSequence.length>0&&"equal"===g&&(c.transparencyRate=h!=t?.3:c.transparencyRate)}null!=c.maxLengthOfMonomer&&(h=wr(h,c.maxLengthOfMonomer));const m=h+d;(a=c.monomerTextSizeMap)[m]??(a[m]=t.measureText(m));let y=c.monomerTextSizeMap[m];(l=c.monomerTextSizeMap)[h]??(l[h]=t.measureText(h));let b=c.monomerTextSizeMap[h].width;const v=o/2-(y.fontBoundingBoxAscent+y.fontBoundingBoxDescent)/2+1;(u=c.monomerTextSizeMap)[d]??(u[d]=t.measureText(d));const w=c.monomerTextSizeMap[d].width;function C(e,i){const o=f?c.color:"rgb(0,0,0)";t.fillStyle=o,t.globalAlpha=c.transparencyRate,c.drawStyle===xr.classic&&(t.fillText(h,n+e,r+v),t.fillStyle="#808080",t.fillText(d,n+i,r+v)),c.drawStyle===xr.MSA&&t.fillText(h,n+e,r+v)}y=y.width,c.drawStyle===xr.MSA&&(b=c.maxWord[c.wordIdx],y=c.maxWord[c.wordIdx]);const A=(c.maxWord[c.wordIdx]??0)-(c.maxWord[0]??0);if(c.left||y>i)return C(A,A+b),n+A+b+w;{const t=(i-y)/2;return C(t,t+b),n+A+t+b}}const Er="rgb(100,100,100)";class Tr extends br{constructor(t,e,n,r,o){super(t,e,n),this.monomerLengthLimit=r,this.propsProvider=o,this.colWidth=0,this._monomerLengthList=null,this.separatorWidth=5,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this.sysMonomerLib=null,this.padding=5,this.props=this.propsProvider(),this._processedRows=i.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol&&this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{const t=this.tableCol.dataFrame;this.gridCol.grid,-1===t.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})))}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Ye.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,a.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=i.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},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,Ke.AP)(t);this.logger.error(e,void 0,n)}const r=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),i=new Array(r.length+1);i[0]=5;for(let t=1;t<i.length;t++)i[t]=i[t-1]+r[t-1];return[r,i]}getCellMonomerLengthsForSeq(t){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.seqHelper.getSeqHandler(this.tableCol),n=this.props.separatorWidth+1*this.props.monomerCharWidth,r=Math.ceil(this.colWidth/n),i=e.getSplitted(t),o=Math.min(r,i.length);let s=this._monomerLengthList[t];if(null===s||s.length<o){s=this._monomerLengthList[t]=new Array(i.length);let n=0;for(let t=0;t<o;++t){const r=i.getOriginal(t),o=this.props.monomerToShort(r,this.monomerLengthLimit),a=(e.isSeparator()?this.separatorWidth:this.props.separatorWidth)+o.length*this.props.monomerCharWidth;if(s[t]=a,n+=a,n>this.colWidth)break}}return s}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)}}})(),i=this.props.separatorWidth+1*this.props.monomerCharWidth,o=Math.ceil(this.colWidth/i);for(let t=n;t<r;t++){if(this._processedRows.get(t)&&o<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,o),r=Math.min(o,n.length);r>e.length&&e.push(...new Array(r-e.length).fill(i));let s=0;for(let t=0;t<r;++t){const r=n.getOriginal(t),i=this.props.monomerToShort(r,this.monomerLengthLimit),o=this.props.separatorWidth+i.length*this.props.monomerCharWidth;if(e[t]=Math.max(e[t]??0,o),s+=o,s>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,o)}return e}getPosition(t,e,n){const[r,i]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e){let n,r=100,i=0,o=t.length-1;for(;i<=o;){if(n=Math.floor((o+i)/2),t[n]<=e&&e<t[n+1])return n;if(e<t[n]?o=n-1:i=n+1,--r<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(i,e)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}render(t,e,n,r,i,o,s){if(!this.seqHelper)return;const a=this.gridCol,l=this.tableCol,u=window.devicePixelRatio;let c=this.monomerLengthLimit;if(Cr.maxMonomerLength in l.tags){const t=parseInt(l.getTag(Cr.maxMonomerLength));c=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in l.temp){const t=l.temp[".mm.cellRenderer.maxMonomerLength"];c=!isNaN(t)&&t?t:50}t.save();try{const s=this.seqHelper.getSeqHandler(l);if("1"===l.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=c){let t=0;const e=8;t=l.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(c),this.setSeparatorWidth(s.isMsa()?e:t),l.temp[".mm.cellRenderer.settingsChanged"]="0"}const[h,d]=this.getCellMonomerLengths(o.tableRowIndex,r),f=(h.length,o.cell.value,o.cell.rowIndex),p=(l.getTag(Ne.gp.alphabet),50);r=function(t,e,n,r,i){return t?Math.max(Math.min(t.canvas.width/i-n,r)):Math.max(e.canvas.width/i-n,0)}(a?.grid,t,e,r,u),t.beginPath(),t.rect(e+this.padding,n+this.padding,r-this.padding-1,i-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const g=l.meta.units,m=l.getTag(Ne.gp.aligned),y=l.getTag(Ne.gp.separator)??"",b=this.props.separatorWidth+1*this.props.monomerCharWidth,v=Math.ceil(r/b),w=l.temp["reference-sequence"],C=this.tableCol.temp["current-word"];C&&-1===l?.dataFrame?.currentRowIdx&&(this.tableCol.temp["current-word"]=null);const A=(()=>{const t=s.getSplitter(v)(null!=w&&""!=w?w:C??"");return Qe().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray()})(),x=s.getSplitted(f);let _=xr.classic;m&&m.includes("MSA")&&g==Ne.Hi.SEPARATOR&&(_=xr.MSA);const S=Math.min(x.length,v);for(let a=0;a<S;++a){const l=x.getOriginal(a),u=x.getCanonical(a);let h=Er;const f=this.getMonomerLib();if(f){const t=s.defaultBiotype;h=f.getMonomerTextColor(t,u)}t.fillStyle=Er;const g={color:h,pivot:0,left:!0,transparencyRate:1,separator:y,last:a===x.length-1,drawStyle:_,maxWord:d,wordIdx:a,gridCell:o,referenceSequence:A,maxLengthOfMonomer:c,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};if(Sr(t,l,e+this.padding,n,r,i,g),p>r)break}}catch(t){const[e,n]=(0,Ke.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}onMouseMove(t,e){if(!this.seqHelper||null==t.tableRowIndex)return;const[n,r,i]=function(t){let e=null,n=null;try{n=t.dart?t.gridColumn:null,e=n?n.temp:null}catch{[n,e]=[null,null]}const r=t.cell.column;if(e=e??r.temp,!e)throw new Error("Grid cell renderer back store (GridColumn or Column) not found.");return[n,r,e]}(t),o=i.rendererBack;if(!o)return;const s=t.bounds,a=e.offsetX-t.gridColumn.left+(t.gridColumn.left-s.x),l=o.getPosition(t.tableRowIndex,a,s.width),u=this.seqHelper.getSeqHandler(r),c=u.getSplitted(t.tableRowIndex);if(null!==l&&l<c.length){const n=u.alphabet??Ne.YI.UN,r={position:l,biotype:n===Ne.YI.RNA||n===Ne.YI.DNA?mn.o.NUCLEOTIDE:mn.o.AA,symbol:c.getCanonical(l)},i=[];let s=o._monomerStructureMap[r.symbol];{const t=this.getMonomerLib();s=o._monomerStructureMap[r.symbol]=t?t.getTooltip(r.biotype,r.symbol):N.divText("Monomer library is not available")}i.push(s),N.tooltip.show(N.divV(i),e.x+16,e.y+16),kn(t,r)}else N.tooltip.hide(),kn(t,null)}}class Ir{constructor(t,e){this.separator=t,this.seqHelper=e,this.separatorSplitter=(0,Ne.dh)(this.separator),this.splitter=this._splitter.bind(this)}_splitter(t){const e=this.separatorSplitter(t);return new Nr(Qe().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),o.b9[o.Hi.SEPARATOR])}async getHelm(t,e){const n=(await Vn.sW.parseNotation(t)).getNotationHelm(),r=i.SemanticValue.fromValueType(n,i.SEMTYPE.MACROMOLECULE,o.Hi.HELM);return r.tags["pt-role"]="template",r}createCellRendererBack(t,e){const n=new Tr(t,e,Or.logger,4,(()=>({seqHandler:this.seqHelper.getSeqHandler(e),monomerCharWidth:7,separatorWidth:11,monomerToShort:vr.zS})));return n.init().then((()=>{})),n}}class Nr extends vr.Mu{getCanonical(t){if(this.isGap(t))return o._S;let e=this.seqCList[t];if(null===e){const n=this.getOriginal(t);e=n,")"===n[n.length-1]&&(e=this.seqCList[t]=n.replace(/\(\d+\)$/,""))}return e}constructor(t,e){super(t,e),this.seqCList=new Array(this.length).fill(null)}}const Or=new B({debug:!0});let Mr=null;async function Lr(){return null===Mr&&(Mr=async function(){const[t]=await Promise.all([(0,Ye.Q)()]);Or.completeInit(t)}()),Mr}async function Br(){await Or.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:ze(t)}},n={};for(const[t,i]of Object.entries(e)){let e;try{e=await r.functions.call(t,i.parameters);const o=new je(i.tabName,e);o.initView(),n[i.tabName]=()=>o.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(Or);if(!t)throw new Error("External app view factories not loaded");const e=new qe(t,Or);return await e.getAppView()}async function Pr(){return await zr("Oligo Translator")}async function Rr(){return await zr("Oligo Pattern")}async function Dr(){return await zr("Oligo Structure")}async function Fr(){return await Or.initLibData(),Or}function kr(){const t=Or.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}function Hr(t){const e=Or.createSequenceValidator(t),n=Or.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}function Ur(t,e){return new Ae(t,e,"GCRS").convert()}function Vr(t){return(0,xe.vS)(t,!0)}async function $r(){await async function(){await y((async()=>{const t=await Pr();r.shell.addView(t)}))}()}async function jr(){await async function(){await y((async()=>{const t=await Rr();r.shell.addView(t)}))}()}async function qr(){await async function(){await y((async()=>{const t=await Dr();r.shell.addView(t),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,Ge.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)}))}))}()}async function Gr(t,e,n){return await Or.initLibData(),Or.createFormatConverter(t,e).convertTo(n)}async function zr(t){await Or.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new $e(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Ie(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Or);return await e.getAppView()}async function Wr(){await async function(){let t;try{t=await async function(){const t=[],e=()=>{for(const e of t)e.unsubscribe()};try{let n;if(!n){const t=r.shell.t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);if(t.length<1)throw new Error(Kn);n=t[0]}const o=N.input.column("Column",{table:n.dataFrame,value:n,filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE&&Or.seqHelper.getSeqHandler(t).notation===Ne.Hi.CUSTOM}),s=N.input.bool(Yn,{value:!0});N.tooltip.bind(s.root,Jn);const a=N.input.bool(Qn,{value:!1});let l;const u=new Un._v(Un.MU,Un.yy,".json",{onValueChanged:t=>{l=t}}),c=N.inlineText([tr]);N.tooltip.bind(c,"Add or specify rules to use");const h=await u.getForm(),d=N.divV([o,s,a,c,h]),f=async()=>{try{const t=await u.getActive();await nr(o.value,s.value,a.value,t)}catch(t){$n(t)}},p=N.dialog(Xn).add(d).onOK((()=>{f()}));return t.push(p.onClose.subscribe((()=>{e()}))),p.history((()=>({generateHelm:s.value,chiralityEngine:a.value,rules:l})),(t=>{s.value=t.generateHelm,a.value=t.chiralityEngine,u.setActive(l)})),p}catch(t){throw e(),t}}(),t.show()}catch(t){const[e,n]=(0,Ke.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Or.logger.error(e,void 0,n)}}()}async function Kr(t){const e=await mr.create(t);return await e.showDialog()}async function Yr(t,e,n,r,i){return(await nr(e,n,r,i))[0]}async function Jr(){await cr(r.shell.tv?.dataFrame.currentCell)}async function Qr(){er()}async function Xr(t,e){var n;(function(t){t.semType=i.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Ne.YI.PT)})(n=e),n.meta.units=Ne.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}async function Zr(t){const e=await t.readAsString(),n=new gr(t.fileName,e),r=await n.getJson(),o=t.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(r,null,2);i.Utils.download(o,s)}function ti(t){!function(t){try{const e=t.args.item;if(e){const n=t.args.menu;(e instanceof i.GridCell||"GridCell"==e.constructor.name)&&function(t,e){if(Or.logger.debug("ST: addContextMenuForCell(), start"),t&&t.tableColumn)switch(t.tableColumn.semType){case i.SEMTYPE.MACROMOLECULE:return e.item("PolyTool-Enumerate",(()=>{cr(t.cell)})),!0;case i.SEMTYPE.MOLECULE:return e.item("PolyTool-Enumerate",(()=>{er(t.cell)})),!0}return!1}(e,n)&&t.preventDefault()}}catch(t){$n(t),window.$sequenceTranslator||(window.$sequenceTranslator={}),window.$sequenceTranslator.contextMenuError=t}}(t)}async function ei(){await cr()}async function ni(){er()}function ri(t,e){t.meta.units=o.Hi.CUSTOM,t.tags["pt-role"]="template",t.temp[s.notationProvider]=new Ir(e,Or.seqHelper)}},682:(t,e,n)=>{"use strict";n.d(e,{AM:()=>m,by:()=>p,sW:()=>f});var r=n(328),i=n(991),o=n.n(i),s=n(599),a=n(890),l=n(717),u=n(192),c=n(124),h=n(296),d=n(544);class f{constructor(t,e,n){this.linkages=e,this.monomers=t,this.mol=n}static fromHelm(t){const e=t.split("$"),n=e[0].split("|"),r=e[1].split("|"),i=new Array(n.length),o=[];for(let t=0;t<n.length;t++){const e=n[t].indexOf("{"),r=n[t].indexOf("}");i[t]=n[t].slice(e+1,r).split(".")}for(let t=0;t<r.length;t++)if(""!==r[t]&&"V2.0"!==r[t]){const e=r[t].split(","),n=e[0].replace("PEPTIDE","")-1,i=e[1].replace("PEPTIDE","")-1,s=e[2].split("-"),a=s[0].split(":"),l=s[1].split(":");o.push({fChain:n,sChain:i,fMonomer:a[0],sMonomer:l[0],fR:a[1].replace("R",""),sR:l[1].replace("R","")})}return new f(i,o,null)}static fromNotation(t,e){const n=e.heterodimerCode,r=e.homodimerCode,i=[],o=[],s=null!==n?t.split(`(${e.heterodimerCode})`):"";null!==n&&s.length>1?(o.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),i.push(s[1].replaceAll("{","").replaceAll("}","")),i.push(s[2].replaceAll("{","").replaceAll("}",""))):i.push(t);for(let t=0;t<i.length;t++)if(null!==r&&i[t].includes(`(${r})`)){const e=i.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const n=i[t].replace(`(${r})`,""),s=n.indexOf("{"),a=n.slice(0,s),l=n.replace(a,"").replaceAll("{","").replaceAll("}","");i[t]=a+l,i.push(l)}for(let t=0;t<i.length;t++)if(null!==r&&i[t].includes(`(${r})`)){const e=i.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const n=i[t].replace(`(${r})`,""),s=n.indexOf("{"),a=n.slice(0,s),l=n.replace(a,"").replaceAll("{","").replaceAll("}","");i[t]=a+l,i.push(l)}const a=new Array(i.length);for(let t=0;t<i.length;t++){const n=i[t].split("-"),r=this.getLinkedPositions(n,e.linkRules),[s,l,u,c,h]=this.getAllCycles(e.linkRules,n,r);new Array(s.length);for(let e=0;e<l.length;e++)o.push({fChain:t,sChain:t,fMonomer:l[e],sMonomer:u[e],fR:c[e],sR:h[e]});a[t]=s}const l=[];for(let t=0;t<a.length;t++){const n=this.getLinkedPositions(a[t],e.reactionRules),[r,i,s,u]=this.getAllReactants(e.reactionRules,a[t],n);if(i.length>=1){const t=new Array(s[0]-1),n=new Array(r.length-s[0]);for(let e=0;e<s[0]-1;e++)t[e]=r[e];for(let t=s[0];t<r.length;t++)n[t-s[0]]=r[t];t[i[0]-1]=e.reactionRules[u[0]].name;for(let t=0;t<o.length;t++)o[t].fMonomer>s[0]&&(o[t].fMonomer-=s[0],o[t].fChain++),o[t].sMonomer>s[0]&&(o[t].sMonomer-=s[0],o[t].sChain++);o.push({fChain:0,sChain:0,fMonomer:i[0],sMonomer:s[0]-1,fR:3,sR:2}),o.push({fChain:0,sChain:1,fMonomer:i[0],sMonomer:1,fR:4,sR:1});const a=new Array(t.length);for(let e=0;e<t.length;e++)a[e]=`[${t[e]}]`;const c=new Array(n.length);for(let t=0;t<n.length;t++)c[t]=`[${n[t]}]`;l.push(t),l.push(n)}else l.push(a[t])}return new f(l,o,null)}static async parseNotation(t){const e=[],n=[],r=(await(0,c.b2)()).createHelmWebEditor().editor.m,i=/(\(.\d+\))?\{[^\}]*\}/g,o=[];o.push(t.replaceAll(i,""));const a=t.matchAll(i);for(const t of a){const e=t[0];e&&o.push(e)}let l=0;for(let t=0;t<o.length;t++){const r=o[t].split("-"),i=new Array(r.length);for(let e=0;e<r.length;e++){const o=r[e].replace("{","").replace("}","");""!==o?(i[e]=o,l++):n.push({fChain:t,sChain:t+1,fMonomer:l,sMonomer:l+1,fR:1,sR:1})}e.push(i)}l=0;const u=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 i=e[t][n],o={type:s.o.AA,i:t,j:n},a=new JSDraw2.Atom(u,i,o);if(r.addAtom(a),0!==n){const t=r.atoms[l-1],e=r.atoms[l],n=new JSDraw2.Bond(t,e);n.r1=2,n.r2=1,r.addBond(n)}l++,u.x+=JSDraw2.Editor.BONDLENGTH}u.y+=4*JSDraw2.Editor.BONDLENGTH}for(let t=0;t<n.length;t++){const e=r.atoms[n[t].fMonomer-1],i=r.atoms[n[t].sMonomer-1],o=new JSDraw2.Bond(e,i);o.r1=n[t].fR,o.r2=n[t].sR,r.addBond(o)}return new f(e,n,r)}getHelmChanged(t,e){let n=0,r=0,i=0;t:for(let e=0;e<this.monomers.length;e++)for(let o=0;o<this.monomers[e].length;o++){if(n==t){r=e,i=o;break t}n++}const o=this.monomers[r][i];this.monomers[r][i]=`[${e}]`;const s=this.getHelm();return this.monomers[r][i]=o,s}getNotationHelm(){return this.getHelm()}getHelm(){let t="";for(let e=0;e<this.monomers.length;e++){e>0&&(t+="|"),t+=`PEPTIDE${e+1}{`;for(let n=0;n<this.monomers[e].length;n++){n>0&&(t+=".");const r=this.monomers[e][n];t+=r.length>1?`[${r}]`:r}t+="}"}t+="$";for(let e=0;e<this.linkages.length;e++)e>0&&(t+="|"),t+=`PEPTIDE${this.linkages[e].fChain+1},PEPTIDE${this.linkages[e].sChain+1},`,t+=`${this.linkages[e].fMonomer}:R${this.linkages[e].fR}-`,t+=`${this.linkages[e].sMonomer}:R${this.linkages[e].sR}`;return t+="$$$",t}getNotation(){const t=this.mol.atoms,e=this.mol.bonds,n=[],r=[];for(let t=0;t<e.length;t++)e[t].a1.bio.i!==e[t].a2.bio.i&&r.push(t);for(let e=0;e<t.length;e++){const r=t[e].bio?.i;r+1>n.length?n.push(1):n[r]++}const i=new Array(n.length);let o=0;for(let e=0;e<n.length;e++){const r=new Array(n[e]);for(let i=0;i<n[e];i++)r[i]=t[o].elem,o++;i[e]=r}let s="";for(let t=0;t<i.length;t++){let n="";for(let e=0;e<i[t].length;e++)n+=`${0==e?"":"-"}${i[t][e]}`;if(0!==t){const t=/(\(.\d+\))/,e=n.match(t);n=n.replace(e?.[0],""),n=`${e?e?.[0]:""}{${n}}`}else if(i.length>1){const t=0==e[r[0]].a1.bio.i&&0==e[r[0]].a1.bio.j,i=1==e[r[0]].a2.bio.i&&0==e[r[0]].a1.bio.j;t&&i&&(n+="-")}s+=n}return s}static getLinkedPositions(t,e){const n=new Array(e.length);for(let r=0;r<e.length;r++){let i=!1,o=!1,s=!1,a=-1,l=-1;const u=`(${e[r].code})`;for(let n=0;n<t.length;n++)if(t[n].includes(u)){if(i){if(s&&t[n]==e[r].secondMonomer+u){o=!0,l=n;break}if(s||t[n]!=e[r].firstMonomer+u)continue;o=!0,l=n;break}if(t[n]==e[r].firstMonomer+u)i=!0,s=!0,a=n;else{if(t[n]!=e[r].secondMonomer+u)continue;i=!0,s=!1,a=n}}n[r]=i&&o?s?[a,l,r]:[l,a,r]:[-1,-1,-1]}return n}static getAllCycles(t,e,n){const r=[],i=[],o=[],s=[],a=t.length;for(let l=0;l<a;l++){if(-1==n[l][0])continue;const a=e[n[l][0]],u=e[n[l][1]];e[n[l][0]]=e[n[l][0]].replace(a,t[l].firstSubstitution),e[n[l][1]]=e[n[l][1]].replace(u,t[l].secondSubstitution),r.push(n[l][0]+1),i.push(n[l][1]+1),o.push(t[l].firstLinkingGroup),s.push(t[l].secondLinkingGroup)}return[e,r,i,o,s]}static getAllReactants(t,e,n){const r=[],i=[],o=[],s=t.length;for(let a=0;a<s;a++){if(-1==n[a][0])continue;const s=e[n[a][0]],l=e[n[a][1]];e[n[a][0]]=e[n[a][0]].replace(s,t[a].firstMonomer),e[n[a][1]]=e[n[a][1]].replace(l,t[a].secondMonomer),r.push(n[a][0]+1),i.push(n[a][1]+1),o.push(n[a][2])}return[e,r,i,o]}}function p(t,e){const n=new Array(t.length);for(let r=0;r<t.length;r++)try{if(null==t[r])n[r]="";else{const i=f.fromNotation(t[r],e);n[r]=i.getHelm()}}catch(t){const[e,i]=(0,u.AP)(t);d._package.logger.error(e,void 0,i),n[r]=""}return n}function g(t,e,n){const i=n.reaction,o=n.name,s=e.getMonomer("PEPTIDE",n.firstMonomer);if(!s)throw new h.bl("PEPTIDE",n.firstMonomer);const a=e.getMonomer("PEPTIDE",n.secondMonomer);if(!a)throw new h.bl("PEPTIDE",n.secondMonomer);const[l,c]=function(t,e){const n=t.molfile;let r=e.molfile;const i=t.rgroups.length,o=r.indexOf("M RGP");if(-1!==o){const t=r.substring(o+6,o+9),e=Number(t);for(let t=0;t<e;t++){const e=o+9+4+8*t,n=o+9+8+8*t,s=r.substring(e,n),a=Number(s)+i,l=Math.floor(Math.log10(a)+1),u=" ".repeat(4-l)+String(a);r=r.substring(0,e)+u+r.substring(n,r.length)}}return[n,r]}(s,a),d=function(t,e,n,i,o){let s=null,a=null,l=null,c=null,d=null,f=null,p="";try{if(s=t.get_rxn(e),!s)throw new h.J5(e);a=new t.MolList,l=t.get_mol(n),c=t.get_mol(i),a.append(l),a.append(c),d=s.run_reactants(a,1),f=d.get(0).next(),p=f?.get_molblock()}catch(t){const[e,n]=(0,u.AP)(t);throw r.shell.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{s?.delete(),a?.delete(),l?.delete(),c?.delete(),d?.delete(),f?.delete()}return p}(t,i,l,c,o),f=function(t,e){const n=new Array(t?.rgroups.length+e?.rgroups.length),r=t?.rgroups.length,i=e?.rgroups.length;for(let e=0;e<r;e++)n[e]=t?.rgroups[e];for(let t=0;t<i;t++){const i=e?.rgroups[t].label.replace("R",""),o=Number(i)+r,s={capGroupSMILES:e?.rgroups[t].capGroupSMILES.replace(i,String(o)),alternateId:e?.rgroups[t].alternateId.replace(i,String(o)),capGroupName:e?.rgroups[t].capGroupName,label:e?.rgroups[t].label.replace(i,String(o))};n[t+r]=s}return n}(s,a),p={symbol:o,name:o,molfile:d,author:"",id:0,rgroups:f,smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};return p.meta=Object.assign(p.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),[o,p]}async function m(t){const e=(await(0,a.pj)()).getMonomerLib(),n=await(0,l.j)(),r={};for(let i=0;i<t.reactionRules.length;i++){const[o,s]=g(n,e,t.reactionRules[i]);r[o]=s}const i={PEPTIDE:r};return e.override(i,"ST-PT-reactions."+o().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}},820:(t,e,n)=>{"use strict";n.d(e,{d:()=>i,o:()=>s});var r=n(296);const i="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function o(t,e,n,r){const i=new Array(r.length*(n-e+1));for(let o=0;o<r.length;++o){const s=n-e+1;for(let n=0;n<s;++n){const a=e+n,l=r[o],u=i[o*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 i}function s(t,e,n){const i=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(i);org.helm.webeditor.IO.parseHelm(s,t,new JSDraw2.Point(0,0),void 0);const a=i.m;a.name=e;let l=[];if(n.placeholders)switch(n.type){case r.aK.Single:l=function(t,e){return e.map((e=>o(t,e.position,e.position,e.monomers))).reduce(((t,e)=>t.concat(e)),[])}(i.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=>o(e,t.position,t.position,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(i.m,n.placeholders)}let u=[];n.placeholdersBreadth&&(u=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>o(e,t.start,t.end,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(i.m,n.placeholdersBreadth)),l=l.concat(u),n.keepOriginal&&(l=[a,...l]);const c=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return c}},702:(t,e,n)=>{"use strict";n.d(e,{MU:()=>c,yy:()=>h,_v:()=>m,Q4:()=>y});var r=n(82),i=n(328),o=n(389),s=n(991),a=n.n(s),l=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(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=i.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,i.userSettings.add(this.userStorageName,"Settings",JSON.stringify(t))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield i.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=o.input.bool(t,{value:e,onValueChanged:e=>this.updateSelectionStatus(t,e)});return n.addOptions(o.button(o.iconFA("trash"),(()=>{o.dialog({title:"Warning"}).add(o.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 i=e.includes(t[r]);n[r]=this.createInput(t[r],i),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=o.divV(t);return o.divV([e,o.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 i.dapi.files.delete(this.path+t),i.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 i.dapi.files.write(this.path+`${e.name}`,new Uint8Array(r)),t(n)}))})}))}))}}const c="System:AppData/SequenceTranslator/polytool-rules/",h="Polytool",d="link",f="reaction",p="fragmentDuplication",g="differentFragments";class m extends u{constructor(t,e,n,r){super(t,e,n,r)}}async function y(t){const e=new r.FileSource(c),n=[],o=[],s={homodimerCode:null,heterodimerCode:null,linkRules:n,reactionRules:o};for(let r=0;r<t.length;r++){const a=await e.readAsText(t[r].replace(c,"")),l=JSON.parse(a);for(let t=0;t<l.length;t++)if(void 0!==l[t].type&&void 0!==l[t].code)switch(l[t].type){case d:{const e=l[t].monomericSubstitution;e.code=l[t].code,n.push(e);break}case f:{const e=l[t].monomericSubstitution;e.code=l[t].code,o.push(e);break}case p:s.homodimerCode&&i.shell.warning("PolyTool: homodimer code is duplicated in rules."),s.homodimerCode=l[t].code;break;case g:s.heterodimerCode&&i.shell.warning("PolyTool: heterodimer code is duplicated in rules."),s.heterodimerCode=l[t].code;break;default:i.shell.warning(`PolyTool: Unexpected type - '${l[t]}'.`)}else i.shell.warning("Polytool: rules contain invalid rule")}return s}},296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r,bl:()=>i}),function(t){t.Single="single",t.Matrix="matrix"}(r||(r={}));class i extends Error{constructor(t,e,n){super(`Monomer '${e}' of polymer type '${t}' not found`,n),this.type="MonomerNotFoundError"}}class o extends Error{constructor(t,e){super(`Invalid reaction '${t}'.`),this.type="InvalidReactionError"}}},82:t=>{"use strict";t.exports=DG},328:t=>{"use strict";t.exports=grok},389:t=>{"use strict";t.exports=ui},991:t=>{"use strict";t.exports=wu}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.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 i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].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=n(544);sequencetranslator=r})();
3
3
  //# sourceMappingURL=package.js.map