@datagrok/sequence-translator 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Sequence Translator changelog
2
2
 
3
+ ## 1.2.6 (2024-01-29)
4
+
5
+ ### Bug fixes
6
+
7
+ * Fixed column input in Pattern
8
+ * Fixed whitespaces in molfiles
9
+
3
10
  ## 1.2.0 (2023-10-27)
4
11
 
5
12
  ### Features
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var sequencetranslator;(()=>{"use strict";var t={622:(t,e,n)=>{n.d(e,{w:()=>r});class o{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 o=this.isWhitespace(n)?e:e-1;for(let t=0;t<o;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToAtomType(n),e[o]=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 o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[t,e,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}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 o=new Uint16Array(2);o[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),o[1]=this.parseIntValue(e),t[n]=o,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToBondType(n),e[o]=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 r extends o{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 o=0;o<e;o++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}},577:(t,e,n)=>{n.d(e,{u:()=>r});var o=n(622);class r extends o.w{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const 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))}}}},61:(t,e,n)=>{n.d(e,{gw:()=>r}),n(469),n(976);var o;function r(t){return e=this,n=void 0,r=function*(){yield new Promise((e=>setTimeout(e,t)))},new((o=void 0)||(o=Promise))((function(t,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}l((r=r.apply(e,n||[])).next())}));var e,n,o,r}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={}))},604:(t,e,n)=>{function o(t){var e;return"string"==typeof t||t instanceof String?t:"$thrownJsError"in t?o(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>o})},490:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());s.push([t.id,".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/view/style/colored-text-input.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,0DAA0D;EAC1D,eAAe;EACf,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},753:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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","",{version:3,sources:["webpack://./src/view/style/structure-app.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;AACrB;;AAEA;EACE,iBAAiB;EACjB,mBAAmB;EACnB,eAAe;AACjB;;AAEA;EACE,gBAAgB;EAChB,YAAY;AACd;;AAEA;EACE,sBAAsB;AACxB;;AAEA,8BAA8B,qCAAqC;EACjE,WAAW;AACb;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB",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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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"],sourceRoot:""}]);const a=s},602:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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 table tbody tr td { */\n/* max-width: 20%; */\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/view/style/translator-app.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,oDAAoD;AACpD,sBAAsB;AACtB,MAAM;;AAEN;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 table tbody tr td { */\n/* max-width: 20%; */\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},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),e.push(u))}},e}},537:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},803:(t,e)=>{var n;!function(){var o=e||{}||this||window;void 0===(n=function(){return o}.apply(e,[]))||(t.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(t){return t instanceof HTMLElement||t instanceof SVGElement},c=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},u=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},d=function(t,e,n){var o=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==o||isNaN(parseFloat(o))?0:o},h=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(e.length),r=new Uint8Array(o),i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return new Blob([o],{type:n})},p={},m=null,g=function(t,e){var n=e||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(t,e){return(o?o(t):t)+"{"+(r?r(e):e)+"}\n"},d=[],h=void 0===l,g=l||[];return(m||(m=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,o=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))d.push(u(e.selectorText,e.style.cssText));else if(h&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?e+"/../"+o:o.startsWith("./")?e+"/."+o:o;return{text:t.cssText,format:(r=l,i=Object.keys(a).filter((function(t){return r.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,o);n&&g.push(n)}else c||d.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(p[t.url])return e(p[t.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),o=0;o<n.byteLength;o++)e+=String.fromCharCode(n[o]);return window.btoa(e)}(o.response),r=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";p[t.url]=r,e(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),p[t.url]=null,e(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),o.open("GET",t.url),o.responseType="arraybuffer",o.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(g).then((function(t){return d.join("\n")+t}))},f=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(t,e,n){c(t);var o=e||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,h=o.width,p=o.height,m=o.scale,f=void 0===m?1:m,A=o.responsive,v=void 0!==A&&A,x=o.excludeCss,C=void 0!==x&&x;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,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var o=t.cloneNode(!0);o.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,o){if("svg"===t.tagName)return{width:n||d(t,e,"width"),height:o||d(t,e,"height")};if(t.getBBox){var r=t.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(t,o,h,p),l=s.width,c=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.appendChild(o),o=m}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),v?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*f),o.setAttribute("height",c*f)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(r,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return g(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var r=document.createElement("defs");r.appendChild(e),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var A=document.createElement("div");A.appendChild(o);var x=A.innerHTML;if("function"!=typeof n)return{src:x,width:l,height:c};n(x,l,c)}))},o.svgAsDataUri=function(t,e,n){return c(t),o.prepareSvg(t,e).then((function(t){var e=t.src,o=t.width,r=t.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp "&#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(i,o,r),i}))},o.svgAsPngUri=function(t,e,n){c(t);var r=e||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,d=function(t){var e=t.src,o=t.width,r=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,e):a.drawImage(e,0,0);var d=void 0;try{d=i.toDataURL(s,l)}catch(t){if("undefined"!=typeof SecurityError&&t instanceof SecurityError||"SecurityError"===t.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw t}return"function"==typeof n&&n(d,i.width,i.height),Promise.resolve(d)};return u?o.prepareSvg(t,e).then(d):o.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var o=new Image;o.onload=function(){return e(d({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},o.src=t}))}))},o.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(h(e),t);else{var o=document.createElement("a");if("download"in o){o.download=t,o.style.display="none",document.body.appendChild(o);try{var r=h(e),i=URL.createObjectURL(r);o.href=i,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),o.href=e}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},o.saveSvg=function(t,e,n){var r=f();return u(t).then((function(t){return o.svgAsDataUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))},o.saveSvgAsPng=function(t,e,n){var r=f();return u(t).then((function(t){return o.svgAsPngUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))}}()},379:t=>{var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,d="".concat(c," ").concat(u);i[c]=u+1;var h=n(d),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var m=r(p,o);o.byIndex=a,e.splice(a,0,{identifier:d,updater:m,references:1})}s.push(d)}return s}function r(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,r){var i=o(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=o(t,r),c=0;c<i.length;c++){var u=n(i[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}i=l}}},569:t=>{var e={};t.exports=function(t,n){var o=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(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{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))}}},29:(t,e,n)=>{n.d(e,{NI:()=>r,mc:()=>o});const o=["A","G","C","U","T"];var r;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(r||(r={}))},895:(t,e,n)=>{n.d(e,{BX:()=>o,Dv:()=>a,VV:()=>l,Xz:()=>c,a_:()=>r,dz:()=>s,pl:()=>i});const o="System:AppData/SequenceTranslator",r="monomer-lib.json",i="System:AppData/SequenceTranslator",s="axolabs-style.json",a="formats-to-helm.json",l="codes-to-symbols.json",c="linkers.json"},996:(t,e,n)=>{n.d(e,{BF:()=>l,Rv:()=>a,VO:()=>u,al:()=>s,iA:()=>c});var o=n(976),r=n(895);const i=new o.FileSource(r.pl);let s,a,l,c;async function u(){[s,a,l,c].every((t=>void 0!==t))||(s=await d(r.dz),a=await d(r.Dv),l=await d(r.VV),c=await d(r.Xz))}async function d(t){let e;try{e=JSON.parse(await i.readAsText(t))}catch(e){const n=e.hasOwnProperty("message")?e.message:e.toString();throw new Error(`Error loading json from ${t}:`+n)}return e}},669:(t,e,n)=>{n.d(e,{LR:()=>i,Y3:()=>s,xB:()=>r});var o=n(469);function r(t){return t.sort(((t,e)=>e.length-t.length))}function i(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 s(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw o.shell.error(`${n} error: `+e),t}finally{e&&e()}}},559:(t,e,n)=>{n.d(e,{A:()=>a});var o=n(976),r=n(593),i=n(29),s=n(996);class a{constructor(){const t=r._package.monomerLib;if(null===t)throw new Error("SequenceTranslator: monomer library is null");this.lib=t,this.allMonomers=this.getAllMonomers()}lib;static instance;allMonomers;formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===i.NI.HELM)return;const o=s.BF[n],r=Object.keys(o).filter((e=>o[e]===t.symbol));e[n]=r.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}static getInstance(){return void 0===a.instance&&(a.instance=new a),a.instance}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(s.BF[t]))}getCodesByFormat(t){return Object.keys(s.BF[t])}getAllFormats(){return Object.keys(s.BF)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(s.BF).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const o=this.getMonomer(n).meta?.molecularWeight;t.set(e,o)}))})),t}}},947:(t,e,n)=>{n.d(e,{b:()=>s});var o=n(29),r=n(559),i=n(669);class s{sequence;constructor(t){this.sequence=t,this.libWrapper=r.A.getInstance()}libWrapper;getInvalidCodeIndex(t){if(t===o.NI.HELM)return this.sequence.length;const e=["r","d"],n=(0,i.xB)(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&&o.mc.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&o.mc.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}},900:(t,e,n)=>{n.d(e,{$:()=>o});const o="p"},261:(t,e,n)=>{function o(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",a="",l="";const c=[];let u=0,d=0,h=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=r(t.antiStrands[e]);let p=!1;const m=t.senseStrands.concat(t.antiStrands);let g=0;for(let e=0;e<m.length;e++){m[e]=m[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=i(m[e]),r=s(m[e]);if(e>=t.senseStrands.length?!1===p&&(p=!0,h=0):g=Math.min(g,Math.min(...r.y.filter((t=>t<0)))),p){const t=Math.min(...r.x)-h,e=Math.max(...r.y)+5;for(let e=0;e<r.x.length;e++)r.x[e]-=t;for(let t=0;t<r.y.length;t++)r.y[t]-=e-g}let l=m[e].indexOf("M V30 BEGIN ATOM");l=m[e].indexOf("\n",l);let f=l,A=l;for(let t=0;t<n.natom;t++){f=m[e].indexOf("V30",f)+4,A=m[e].indexOf(" ",f);const n=parseInt(m[e].substring(f,A))+u;m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf(" ",f)+1,f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f);let o=Math.round(1e4*r.x[t])/1e4;m[e]=m[e].slice(0,f)+o+m[e].slice(A),f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f),o=Math.round(1e4*r.y[t])/1e4,m[e]=m[e].slice(0,f)+o+m[e].slice(A),f=m[e].indexOf("\n",f)+1}const v=m[e].indexOf("M V30 END ATOM");o+=m[e].substring(l+1,v);let x=m[e].indexOf("M V30 BEGIN BOND");x=m[e].indexOf("\n",x),f=x,A=x;for(let t=0;t<n.nbond;t++){f=m[e].indexOf("V30",f)+4,A=m[e].indexOf(" ",f);const t=parseInt(m[e].substring(f,A))+d;m[e]=m[e].slice(0,f)+t+m[e].slice(A),f=m[e].indexOf(" ",f)+1,f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f);let n=parseInt(m[e].substring(f,A))+u;m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf(" ",f)+1,A=Math.min(m[e].indexOf("\n",f),m[e].indexOf(" ",f)),n=parseInt(m[e].substring(f,A))+u,m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf("\n",f)+1}const C=m[e].indexOf("M V30 END BOND");a+=m[e].substring(x+1,C);let b=m[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const t=m[e].indexOf(")",b);m[e].substring(b,t).split(" ").slice(1).forEach((t=>{c.push(parseInt(t)+u)})),b=t,b=m[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}u+=n.natom,d+=n.nbond,h+=Math.max(...r.x)+5}const f=Math.ceil(c.length/4);l+="M V30 MDLV30/STEABS ATOMS=("+c.length+" -\n";for(let t=0;t<f;t++){l+="M V30 ";const e=t+1===f?c.length-4*(f-1):4;for(let n=0;n<e;n++)l+=n+1===e?t===f-1?c[4*t+n]+")\n":c[4*t+n]+" -\n":c[4*t+n]+" "}return n+="M V30 COUNTS "+u+" "+d+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=a,n+="M V30 END BOND\n",e&&c.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 r(t){const e=s(t),n=e.atomIndex.length,o=(Math.max(...e.x)+Math.min(...e.x))/2,r=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=r;const i=Math.PI,a=Math.cos(i),l=Math.sin(i);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 c=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=o,e.y[t]-=c;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let d=u;for(let o=0;o<n;o++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,d=t.indexOf(" ",u)+1,d=t.indexOf(" ",d),u=(t=t.slice(0,u)+e.x[o]+" "+e.y[o]+t.slice(d)).indexOf("\n",u)+1;return t}function i(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}function s(t){const e=i(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const r=Array(e.natom),s=Array(e.natom),a=Array(e.natom),l=Array(e.natom);for(let i=0;i<e.natom;i++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),r[i]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),s[i]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),a[i]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),l[i]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:s,x:a,y:l}}n.d(e,{$U:()=>s,v5:()=>o})},544:(t,e,n)=>{n.d(e,{$3:()=>r,DD:()=>o,s8:()=>i});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},864:(t,e,n)=>{n.d(e,{D:()=>l});var o=n(29),r=n(544),i=n(456),s=n(996),a=n(559);function l(t,e,n){const l=Object.keys(s.Rv).concat([o.NI.HELM]);if(!t||-1!==e&&n!==o.NI.HELM)return{};if(!l.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const c=l.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),u=new i.I(t,n),d=Object.fromEntries(c.map((t=>{let e;try{e=u.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),h=function(t,e){const n=new RegExp("\\([^()]*\\)","g"),i=t.match(n);if(!i)return null;return i.map((t=>{const n=t.replace(/[\[\]()]/g,"");return o.mc.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||r.s8)).join("")}(n===o.NI.HELM?t:d[o.NI.HELM],a.A.getInstance());return h&&(d.Nucleotides=h),d}},456:(t,e,n)=>{n.d(e,{I:()=>u});var o=n(29),r=n(544),i=n(996);const s=(t,e)=>e.length-t.length;class a{constructor(){this.formats=this.getFormats()}formats;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 o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[o]?e[o]=[t]:e[o].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const o=n.sort(s);e[t]=o[0]})),e}(i.Rv[t])}getFormatToHelmDict(t){this.validateFormat(t);const e=i.Rv[t];return Object.assign({},...Object.values(e))}getTargetFormatHelmCodes(t){this.validateFormat(t);const e=this.getHelmToFormatDict(t);return Object.keys(e).sort(s)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(l(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=i.Rv[t],n=l(Array.from(new Set(Object.values(e[r.DD.LINKAGE]))).sort(s));return new RegExp(`${r.$3}.(${n})`,"g")}isValidFormat(t){return this.formats.includes(t)}getFormats(){return Object.keys(i.Rv)}validateFormat(t){if(!this.isValidFormat(t))throw new Error(`Invalid format: ${t}`)}isHelm(t){return t===o.NI.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(s)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(l(e)+"|\\([^()]*\\)|.","g")}}function l(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const c={LEFT:"RNA1{",RIGHT:"}$$$$"};class u{sequence;sourceFormat;constructor(t,e){this.sequence=t,this.sourceFormat=e}formats=new a;convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===o.NI.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===o.NI.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(l(Object.values(c)),"g");let o=t.replace(n,"");const i=this.formats.getHelmToFormatDict(e),s=this.formats.getTargetFormatHelmCodes(e),a=this.formats.getTargetFormatHelmCodesRegExp(e);return o=o.replace(a,(t=>s.includes(t)?i[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,r.s8).replace(/p\.|\./g,""),o=o.replace(/<empty>/g,""),o=o.replace(/\/\//g,"/"),o}formatToHelm(t,e){const n=this.formats.getFormatToHelmDict(e),o=this.formats.getCodesByFormat(e),i=this.formats.getFormatRegExp(e),s=this.formats.getPhosphateHelmCodesRegExp(e);let a=t.replace(i,(t=>o.includes(t)?n[t]+".":"?"));return a=a.replace(/\?+/g,`${r.s8}.`),a=a.slice(0,-1),a[a.length-1]===r.$3&&(a=a.slice(0,-1)),a=a.replace(s,((t,e)=>e)),a=a.replace(/<empty>/g,""),`${c.LEFT+a+c.RIGHT}`}}},593:(t,e,n)=>{n.r(e),n.d(e,{_package:()=>pe,demoOligoPattern:()=>Oe,demoOligoStructure:()=>Ie,demoTranslateSequence:()=>Ee,getCodeToWeightsMap:()=>Ce,getMolfileFromGcrsSequence:()=>we,initSequenceTranslatorLibData:()=>xe,linkStrands:()=>ye,oligoPatternApp:()=>Ae,oligoStructureApp:()=>ve,oligoToolkitApp:()=>ge,oligoTranslatorApp:()=>fe,translateOligonucleotideSequence:()=>Se,validateSequence:()=>be});var o=n(976),r=n(469);const i=ui,s=rxjs;var a=n(379),l=n.n(a),c=n(795),u=n.n(c),d=n(569),h=n.n(d),p=n(565),m=n.n(p),g=n(216),f=n.n(g),A=n(589),v=n.n(A),x=n(602),C={};C.styleTagTransform=v(),C.setAttributes=m(),C.insert=h().bind(null,"head"),C.domAPI=u(),C.insertStyleElement=f(),l()(x.Z,C),x.Z&&x.Z.locals&&x.Z.locals;var b=n(947),w=n(669),y=n(29),E=n(559),O=n(996);class I{sequence;constructor(t){this.sequence=t,this.libWrapper=E.A.getInstance(),this.formats=Object.keys(O.Rv)}libWrapper;formats;getFormat(){if(this.sequence.startsWith("RNA"))return y.NI.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=new b.b(this.sequence),n=Array(t.length).fill(0);for(let o=0;o<t.length;++o){const r=t[o];n[o]=e.getInvalidCodeIndex(r)}const o=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence;let e=[];for(const n of this.formats){let o=(0,w.xB)(this.libWrapper.getCodesByFormat(n)),r=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){r=e+1;break}o.some((e=>e===t.slice(r,r+e.length)))&&e.push(n)}return e}}const S=$;var T=n.n(S);function M(t){let e=0;const n=new I(t).getFormat();null!==n&&(e=new b.b(t).getInvalidCodeIndex(n));const o=e<0||""===t,r=i.span([]);T()(r).css("-webkit-text-fill-color","var(--grey-6)");const s=i.span([]);return T()(s).css("-webkit-text-fill-color","red"),o?r.innerHTML=t:(r.innerHTML=t.slice(0,e),s.innerHTML=t.slice(e)),[r,s]}var B=n(490),N={};N.styleTagTransform=v(),N.setAttributes=m(),N.insert=h().bind(null,"head"),N.domAPI=u(),N.insertStyleElement=f(),l()(B.Z,N),B.Z&&B.Z.locals&&B.Z.locals;class L{textInputBase;painter;constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,T()(this.root).addClass("colored-text-input"),n&&this.textInputBase.onChanged((()=>{T()(this.textArea).css("height",0),T()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=i.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged((()=>this.colorize()))}highlights;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)))}}var D=n(900);class F{sequence;codeMap;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,o)=>{const r=this.getSymbolForCode(n);o>0&&function(t){return O.iA.left.includes(t)}(r)&&e.pop(),e.push(r);const i=V(r),s=o===t.length-1,a=o+1<t.length&&V(this.getSymbolForCode(t[o+1]));i||function(t){return O.iA.right.includes(t)}(r)||a||s||e.push(D.$)})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??=t,e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const o=t.find((t=>t===this.sequence.substring(n,n+t.length)));e.push(o),n+=o.length}return e}getAllCodesOfFormat(){let t=Array.from(this.codeMap.keys());return(0,w.xB)(t)}}function V(t){return O.iA.phosphate.includes(t)}class k{invert;constructor(t,e=!1,n){this.invert=e,this.lib=E.A.getInstance();const o=this.lib.getCodeToSymbolMap(n);this.parser=new F(t,o)}parser;lib;convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const o=this.getMonomerMolfile(t,n);e.push(o)}));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 o=t.substring(e,n);return o=o.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+o+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,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n),i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[o];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 c=l;for(let o=0;o<n;o++)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[o]+" "+e.y[o]+t.slice(c)).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 o=n;const r=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),r[l]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),i[l]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,o,r);const i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[o])a=e.y[o]>e.y[r]?Math.PI/2:3*Math.PI/2;else if(0===e.y[o])a=e.x[o]>e.x[r]?Math.PI:0;else{const t=e.y[o]/e.x[o];a=t>0?e.x[o]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[o]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),c=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*c,e.y[t]=n*c+e.y[t]*l}const u=e.x[o];for(let t=0;t<n;t++)e.x[t]-=u;let d=t.indexOf("M V30 BEGIN ATOM");d=t.indexOf("\n",d);let h=d;for(let o=0;o<n;o++)d=t.indexOf("V30",d)+4,d=t.indexOf(" ",d)+1,d=t.indexOf(" ",d)+1,h=t.indexOf(" ",d)+1,h=t.indexOf(" ",h),d=(t=t.slice(0,d)+e.x[o]+" "+e.y[o]+t.slice(h)).indexOf("\n",d)+1;return t}linkV3000(t,e=!0){let n="\nDatagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(t[e]),d=this.extractAtomDataV3000(t[e]);let h=t[e].indexOf("M V30 BEGIN ATOM");h=t[e].indexOf("\n",h);let p=h,m=h;for(let o=0;o<u.natom;o++)if(1!==d.atomIndex[o]||0===e){p=t[e].indexOf("V30",p)+4,m=t[e].indexOf(" ",p);let o=0;n?(o=parseInt(t[e].substring(p,m)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(m),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p);const r=c-d.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(p,m))+r))/1e4;t[e]=t[e].slice(0,p)+s+t[e].slice(m),p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p),s=Math.round(1e4*parseFloat(t[e].substring(p,m)))/1e4,t[e]=t[e].slice(0,p)+s+t[e].slice(m),p=t[e].indexOf("\n",p)+1}else p=t[e].indexOf("M V30",p)-1,m=t[e].indexOf("\n",p+1),t[e]=t[e].slice(0,p)+t[e].slice(m);const g=t[e].indexOf("M V30 END ATOM");o+=t[e].substring(h+1,g);let f=t[e].indexOf("M V30 BEGIN BOND");f=t[e].indexOf("\n",f),p=f,m=f;for(let o=0;o<u.nbond;o++){p=t[e].indexOf("V30",p)+4,m=t[e].indexOf(" ",p);const o=parseInt(t[e].substring(p,m))+l;t[e]=t[e].slice(0,p)+o+t[e].slice(m),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p);let r=0;n?(r=parseInt(t[e].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(m),p=t[e].indexOf(" ",p)+1,m=Math.min(t[e].indexOf("\n",p),t[e].indexOf(" ",p)),r=0,n?(r=parseInt(t[e].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(m),p=t[e].indexOf("\n",p)+1}const A=t[e].indexOf("M V30 END BOND");r+=t[e].substring(f+1,A);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+=u.natom-1,l+=u.nbond,c+=n?Math.max(...d.x):d.x[u.natom-1]-d.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<u;t++){i+="M V30 ";const e=t+1===u?s.length-4*(u-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===u-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+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(t,e,n){const o=e+1,r=t.x[o],i=t.y[o],s=t.x[n]-r,a=t.y[n]-i,l=t.x[e]-r,c=t.y[e]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),d=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),h=l-s,p=c-a,m=u-s,g=d-a;Math.sqrt(g*g+m*m)>=Math.sqrt(p*p+h*h)&&(t.x[e]=u+r,t.y[e]=d+i)}}var P,H=n(864),_=n(622);!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(P||(P={}));class R extends _.w{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(P.HEADER)&&-1!==t.indexOf(P.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,P.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<P.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,P.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,P.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+P.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=P.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}var j=n(577);class q{constructor(){}static getInstance(t){if(R.validate(t))return new R(t);if(j.u.validate(t))return new j.u(t);throw new Error("Malformed molfile")}}var G=n(604);const U=class extends Error{constructor(t){super(t)}};class W{constructor(t){this.molblock=t}_validMolBlock;get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof U&&(t="");const n=(0,G.O)(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new U("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=(0,G.O)(t);console.error(e)}}getMoleculeDimensions(){const t=q.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=i.dialog({title:"Molecule",showFooter:!1}),e=.7*T()(window).height(),n=this.getMoleculeDimensions(),o=e/n.height,r=e,s=n.width*o,a=i.canvas(s,r);await this.drawMolBlockOnCanvas(a);const l=i.block([a],{style:{overflowX:"scroll"}});t.add(l).showModal(!0),T()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),T()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),T()(t.root).find(".d4-dialog-contents").addClass("ui-box"),T()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const o=i.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(i.tooltip.bind(o,"Click to zoom"))}}var Y=n(713),z=n(511),X=n(456);class Z{constructor(){const t=Object.keys(O.Rv).concat(y.NI.HELM);this.moleculeImgDiv=i.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=i.div([]),this.formatChoiceInput=i.choiceInput("",y.NI.HELM,t,(async()=>{this.format=this.formatChoiceInput.value,this.updateTable(),await this.updateMolImg()})),this.sequenceInputBase=i.textInput("",z.T,(()=>{this.onInput.next()})),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()}))}onInput=new s.Subject;moleculeImgDiv;outputTableDiv;formatChoiceInput;sequenceInputBase;molfile;sequence;format;async getHtmlElement(){const t=new L(this.sequenceInputBase,M),e=i.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=i.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o=i.div([this.formatChoiceInput]),r=i.button(i.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));i.tooltip.bind(r,"Clear input");const s={format:o,textInput:t.root,clearBtn:r},a=i.table([s],(t=>[t.format,t.textInput,t.clearBtn]));a.classList.add("st-translator-input-table");const l=i.block([this.outputTableDiv,e,n]),c=i.box(i.panel([a,l,i.block([i.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),c}saveMolfile(){const t=new k(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";(0,w.LR)(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Y.AU)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?new b.b(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,H.D)(this.sequence,t,this.format),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?i.divH([]):i.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Y.AU)))),Y.wm,"");n.push({format:t,sequence:o})}const o=i.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(o),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new W(this.molfile);await t.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=new I(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===y.NI.HELM){const t=new X.I(this.sequence,this.format).convertTo(y.NI.AXOLABS);return new k(t,!1,y.NI.AXOLABS).convert()}return new k(this.sequence,!1,this.format).convert()}}var K=n(753),Q={};Q.styleTagTransform=v(),Q.setAttributes=m(),Q.insert=h().bind(null,"head"),Q.domAPI=u(),Q.insertStyleElement=f(),l()(K.Z,Q),K.Z&&K.Z.locals&&K.Z.locals;var J=n(261);function tt(t,e){if(""===t)return"";const n=new I(t).getFormat();if(!n)return"";let o="";try{o=new k(t,e,n).convert()}catch(t){const e=(0,G.O)(t);console.error(e)}return o}function et(t,e,n,o){const r=[t,e,n].filter((t=>""!==t.strand));if(1===r.length)return tt(r[0].strand,r[0].invert);{const r=tt(t.strand,t.invert),i=[tt(e.strand,e.invert),tt(n.strand,n.invert)].filter((t=>""!==t));return(0,J.v5)({senseStrands:[r],antiStrands:i},o)}}const nt=["ss","as","as2"];class ot{constructor(){this.onInput=new s.Subject,this.onInvalidInput=new s.Subject,this.inputBase=Object.fromEntries(nt.map((t=>[t,i.textInput("","",(()=>{this.onInput.next()}))]))),this.useChiralInput=i.boolInput("Use chiral",!0),this.saveAllStrandsInput=i.boolInput("Save as one entity",!0),i.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(nt.map((t=>[t,!1]))),this.moleculeImgDiv=i.block([]),T()(this.moleculeImgDiv).addClass("st-structure-mol-img"),o.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),o.debounce(this.onInvalidInput,1e3).subscribe((async()=>{r.shell.warning("Insert Sense strand")}))}onInput;onInvalidInput;useChiralInput;saveAllStrandsInput;inputBase;directionInversion;moleculeImgDiv;async getHtmlDivElement(){const t=this.getTableInput(),e=this.getBoolInputsAndButton();await this.updateMoleculeImg();const n=i.divH([e,this.moleculeImgDiv]);T()(n).addClass("st-structure-bottom");const o=i.divV([t,n]);return T()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=i.buttonsInput([i.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i){const s=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===s.length||1===s.length&&""===t.strand)r.shell.warning("Enter SS and optionally AS/AS2 to save SDF");else{let a;if(i)a=et(t,e,n,o)+"\n$$$$\n";else{const d=tt(t.strand,t.invert),h=tt(e.strand,e.invert),p=tt(n.strand,n.invert);a=d+"\n> <Sequence>\nSense Strand\n$$$$\n",h&&(a+=h+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(a+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const l=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}const u=l.getFullYear()+"-"+c(l.getMonth()+1)+"-"+c(l.getDate())+"_"+c(l.getHours())+"-"+c(l.getMinutes())+"-"+c(l.getSeconds());(0,w.LR)(`SequenceTranslator-${u}.sdf`,encodeURIComponent(a))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=i.divV(e);for(const t of e)T()(t).addClass("st-structure-bool-button-block");return n}getTableInput(){const t=Object.fromEntries(nt.map((t=>[t,new L(this.inputBase[t],M)]))),e=Object.fromEntries(nt.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,i.choiceInput(`${t.toUpperCase()} direction`,n,["5′ → 3′","3′ → 5′"])]})));nt.forEach(((t,n)=>{e[t].onChanged((()=>{let o="3′ → 5′"===e[t].value;n>0&&(o=!o),this.directionInversion[t]=o,this.onInput.next()}))}));const n=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(nt.map(((t,e)=>[t,n[e]]))),r=Object.fromEntries(nt.map((t=>[t,i.label(o.get(t))]))),s=Object.fromEntries(nt.map((e=>{const n=i.icons.delete((()=>{t[e].inputBase.value=""})),o=i.button(n,(()=>{}));return i.tooltip.bind(o,`Clear ${e.toUpperCase()}`),[e,n]}))),a=nt.map((n=>({label:r[n],textInput:t[n].root,clear:s[n],choiceInput:e[n].root}))),l=i.table(a,(t=>[t.label,t.textInput,t.clear,t.choiceInput]));T()(l).css("margin-top","10px");for(const t of nt){let n=r[t].parentElement;n.classList.add("st-structure-input-form"),T()(n).css("padding-top","3px"),n=e[t].root.parentElement,n.classList.add("st-structure-input-form","st-structure-direction-choice"),n=this.inputBase[t].root.parentElement,n.classList.add("st-structure-text-input-td")}return l}getStrandData(){return Object.fromEntries(nt.map(((t,e)=>{let n=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:n}]})))}getMolfile(t,e,n){return et(t,e,n,this.useChiralInput.value)}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=(0,G.O)(t);console.error(e)}const e=new W(t);await e.drawMolecule(this.moleculeImgDiv,650,150),T()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}const rt="SequenceTranslator",it="SS",st="AS",at=[it,st],lt={[it]:"Sense strand",[st]:"Anti sense"},ct="THREE_PRIME",ut="FIVE_PRIME",dt=[ct,ut],ht={[ct]:3,[ut]:5};function pt(t){return"(o)"===t.slice(-3)}function mt(t){let e=0;for(;e<t.length&&pt(t[e]);)e++;return e===t.length-1?0:e}function gt(t,e){const n=document.createElement("canvas").getContext("2d");return n.font=String(e),2*n.measureText(t).width}function ft(t,e){return pt(t[e])||!y.mc.includes(t[e])?"":t[e]}function At(t){const e=O.al[t].color.match(/\d+/g).map((t=>Number(t)));return.299*e[0]+.587*e[1]+.114*e[2]>186?"#33333":"#ffffff"}function vt(t){return O.al[t].color}const xt={xmlns:"http://www.w3.org/2000/svg",render:function(t,e){const n=document.createElementNS(this.xmlns,"svg");return n.setAttribute("id","mySvg"),n.setAttribute("width",String(t)),n.setAttribute("height",String(e)),n},circle:function(t,e,n,o){const r=document.createElementNS(this.xmlns,"circle");return r.setAttribute("cx",String(t)),r.setAttribute("cy",String(e)),r.setAttribute("r",String(n)),r.setAttribute("fill",o),r},text:function(t,e,n,o,r){const i=document.createElementNS(this.xmlns,"text");return i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("font-size",String(o)),i.setAttribute("font-weight","normal"),i.setAttribute("font-family","Arial"),i.setAttribute("fill",r),i.innerHTML=t,i},star:function(t,e,n){const o=document.createElementNS(this.xmlns,"polygon");return o.setAttribute("points",function(t,e){const n=Math.PI/5;let o="";for(let r=0;r<10;r++){const i=r%2==0?6:3;o+=`${t+Math.cos(r*n+60)*i},${e+Math.sin(r*n+60)*i} `}return o}(t,e)),o.setAttribute("fill",n),o}};function Ct(t,e){const n=O.al[e].symbols.join("");return n.repeat(Math.floor(t/4))+n.slice(0,t%4)}async function bt(t){return await r.dapi.users.current().then((e=>{const[n,o]=function(t){let e=-1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return-1===e?["",""]:t.slice(e+9,t.length-1).split(" ").slice(1)}(t);return e.firstName!==n||e.lastName!==o}))}function wt(t){let e=t.length+1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return t.slice(0,e-1)}function yt(t,e,n,o,r,i){let s=-1,a=t.replace(/[AUGC]/g,(function(o){s++;const r=O.al,i=(Object.keys(r),r.RNA.symbols.indexOf(o));let a=r[e[s].value].symbols[i];return pt(e[s].value)&&(s<t.length/2&&!pt(e[s+1].value)?a=a+o+"f":s>t.length/2&&!pt(e[s-1].value)&&(a=o+"f"+a)),n[s].value?a+"s":a}));return 3===a.slice(0,5).split("mU").length&&(a="(uu)"+a.slice(4)),3===a.slice(a.length-7).split("mU").length&&(a=a.slice(0,a.length-4)+"(uu)"),o.value+(i?"s":"")+a+r.value}const Et=15,Ot=30,It=17,St="red",Tt="var(--grey-6)",Mt="red",Bt="SS: 5'",Nt="AS: 3'",Lt=Math.max(gt(Bt,It),gt(Nt,It)),Dt=Math.max(gt("3'",It),gt("5'",It)),Ft=0+Lt-5,Vt={TITLE:Et,SS_INDICES:30,SS_CIRCLES:52.5,SS_TEXTS:60,AS_CIRCLES:97.5,AS_TEXTS:105,AS_INDICES:127.5,comment:t=>t?165:127.5,circlesInLegends:t=>t?142.5:90,textLegend:t=>t?147:Vt.AS_CIRCLES-3,svgHeight:t=>t?165:135};function kt(t,e,n,o,r,i,s,a,l,c,u,d){function h(t){return Math.round((t+O)*M/(w.length+O)+6)}function p(t,e){return b+(A-t+e+1)*Ot}function m(t,e,n){return n<10||y.mc.includes(t[e])?-5:-10}n=n.reverse(),r=r.reverse();const g=mt(n),f=mt(o),A=Math.max(n.length-g,o.length-f),v=Math.max(g,f),x=Ot*(A+v),C=Math.max(gt(s,It),gt(c,It)),b=Math.max(gt(a,It),gt(l,It)),w=e?[...new Set(n.concat(o))]:[...new Set(n)],E=e?r.concat(i).includes(!0):r.includes(!0),O=E?1:0,I=g*Ot+p(-.5,0),S=f*Ot+p(-.5,0),T=Math.max(I,S)+C+Ot*v,M=Lt+C+x+b+Dt+Ot,B=xt.render(M,Vt.svgHeight(e));B.append(xt.text(Bt,0,Vt.SS_TEXTS,It,Tt),e?xt.text(Nt,0,Vt.AS_TEXTS,It,Tt):"",xt.text("3'",T,Vt.SS_TEXTS,It,Tt),e?xt.text("5'",T,Vt.AS_TEXTS,It,Tt):"",xt.text(a,Ft,Vt.SS_TEXTS,It,Mt),e?xt.text(l,Ft,Vt.AS_TEXTS,It,Mt):"",xt.text(s,I,Vt.SS_TEXTS,It,Mt),e?xt.text(c,S,Vt.AS_TEXTS,It,Mt):"",xt.text(u,0,Vt.comment(e),14,Tt),E?xt.star(Et,Vt.circlesInLegends(e),St):"",E?xt.text("ps linkage",22,Vt.textLegend(e),14,Tt):"");const N=n.filter((t=>!pt(t))).length;let L=N;for(let t=n.length-1;t>-1;t--){const e=p(t,g)+m(n,n.length-t,N-L);pt(n[t])||L--;const o=!pt(n[t])&&d.includes(n[t])?String(N-L):"";B.append(xt.text(o,e,Vt.SS_INDICES,14,Tt),xt.circle(p(t,g),Vt.SS_CIRCLES,Et,vt(n[t])),xt.text(ft(n,t),e,Vt.SS_TEXTS,It,At(n[t])),r[t]?xt.star(p(t,g)+Et,Vt.SS_TEXTS+5,St):"")}B.append(r[n.length]?xt.star(p(n.length,g)+Et,Vt.SS_TEXTS+5,St):"");const D=o.filter((t=>!pt(t))).length;if(e){let t=D;for(let e=o.length-1;e>-1;e--){pt(o[e])||t--;const n=p(e,f)+m(o,e,t+1),r=!pt(o[e])&&d.includes(o[e])?String(t+1):"";B.append(xt.text(r,n,Vt.AS_INDICES,14,Tt),xt.circle(p(e,f),Vt.AS_CIRCLES,Et,vt(o[e])),xt.text(ft(o,e),p(e,f)+m(o,e,t+1),Vt.AS_TEXTS,It,At(o[e])),i[e]?xt.star(p(e,f)+Et,Vt.AS_TEXTS+5,St):"")}B.append(i[o.length]?xt.star(p(o.length,f)+Et,Vt.AS_TEXTS+5,St):"")}const F=`${t} for ${N}${e?`/${D}`:""}mer`;B.append(xt.text(F,15,Vt.TITLE,It,"black"));for(let t=0;t<w.length;t++)B.append(xt.circle(h(t),Vt.circlesInLegends(e),6,vt(w[t])),xt.text(w[t],h(t)+6+4,Vt.textLegend(e),14,Tt));return B}var Pt=n(803);class Ht{get htmlDivElement(){function t(e){x[e].innerHTML="",C[e]=C[e].concat(Array(v[e]-b[e].length).fill(A)),b[e]=b[e].concat(Array(v[e]-b[e].length).fill(f));let o=0;for(let r=0;r<w[e].value;r++)C[e][r]=i.boolInput("",C[e][r].value,(()=>{s(),n()})),b[e][r]=i.choiceInput("",b[e][r].value,p,(e=>{g.includes(e)||(g.push(e),k.append(i.divText("",{style:{width:"25px"}}),i.boolInput(e,!0,(t=>{if(t)g.includes(e)||g.push(e);else{const t=g.indexOf(e,0);t>-1&&g.splice(t,1)}s()})).root)),t(st),s(),n()})),T()(b[e][r].root).addClass("st-pattern-choice-input"),pt(b[e][r].value)||o++,x[e].append(i.divH([i.div([i.label(pt(b[e][r].value)?"":String(o))],{style:{width:"20px"}}),i.block75([b[e][r].root]),i.div([C[e][r]])],{style:{alignItems:"center"}}))}function e(){Object.values(w).every((t=>t.value<35))?(at.forEach((e=>{w[e].value>v[e]&&(v[e]=w[e].value),t(e)})),s(),at.forEach((t=>{""===I[t].value&&(E[t].value=Ct(w[t].value,f.value))})),n()):i.dialog("Out of range").add(i.divText("Sequence length should be less than "+35..toString()+" due to UI constrains.")).onOK((()=>{Object.values(w).every((t=>t.value=34))})).onCancel((()=>{Object.values(w).every((t=>t.value=34))})).showModal(!1)}function n(){const t=[!0,j.value];at.forEach(((e,n)=>{t[n]&&(B[e].value=yt(E[e].value,b[e],C[e],M[e][ut],M[e][ct],S[e].value))}))}function s(){L.innerHTML="",L.append(i.span([kt(wt(q.value),j.value,b[it].slice(0,w[it].value).map((t=>t.value)),b[st].slice(0,w[st].value).map((t=>t.value)),[S[it].value].concat(C[it].slice(0,w[it].value).map((t=>t.value))),[S[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),M[it][ct].value,M[it][ut].value,M[st][ct].value,M[st][ut].value,$.value,g)]))}async function a(t){const e=o.TaskBarProgressIndicator.create("Loading pattern...");await r.dapi.userDataStorage.get(rt,!1).then((e=>{const n=JSON.parse(e[t]);f.value=function(t){const e={};let n=t[0],o=1;for(let r=0;r<t.length;r++){const i=t[r];null===e[i]?e[i]=1:e[i]++,e[i]>o&&(n=i,o=e[i])}return n}(n.asBases.concat(n.ssBases)),j.value=n.asBases.length>0,q.value=t;let o=["ssBases","asBases"];at.forEach(((t,e)=>{b[t]=[];const r=o[e];for(let e=0;e<n[r].length;e++)b[t].push(i.choiceInput("",n[r][e],p))})),o=["ssPtoLinkages","asPtoLinkages"],at.forEach(((t,e)=>{const r=o[e];S[t].value=n[r][0],C[t]=[];for(let e=1;e<n[r].length;e++)C[t].push(i.boolInput("",n[r][e]))})),o=["ssBases","asBases"],at.forEach(((t,e)=>{w[t].value=n[o[e]].length}));const r=[["ssThreeModification","ssFiveModification"],["asThreeModification","asFiveModification"]];at.forEach(((t,e)=>{dt.forEach(((o,i)=>{M[t][o].value=n[r[e][i]]}))})),$.value=n.comment})),e.close()}async function l(){const t=await async function(){return await r.dapi.users.current().then((t=>" (created by "+t.friendlyName+")"))}();return q.value=q.stringValue.includes("(created by ")?wt(q.value)+t:q.stringValue+t,r.dapi.userDataStorage.postValue(rt,q.value,JSON.stringify({ssBases:b[it].slice(0,w[it].value).map((t=>t.value)),asBases:b[st].slice(0,w[st].value).map((t=>t.value)),ssPtoLinkages:[S[it].value].concat(C[it].slice(0,w[it].value).map((t=>t.value))),asPtoLinkages:[S[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),ssThreeModification:M[it][ct].value,ssFiveModification:M[it][ut].value,asThreeModification:M[st][ct].value,asFiveModification:M[st][ut].value,comment:$.value}),!1).then((()=>r.shell.info("Pattern '"+q.value+"' was successfully uploaded!")))}async function c(){r.dapi.userDataStorage.get(rt,!1).then((async t=>{const e=[],n=[];for(const o of Object.keys(t))await bt(o)?n.push(o):e.push(o);let o=i.choiceInput("Load pattern","",e,(t=>a(t)));const s=(await r.dapi.users.current()).friendlyName,l=i.choiceInput("",s,[s,"Other users"],(t=>{const u=t===s?e:n;o=i.choiceInput("Load pattern","",u,(t=>a(t))),o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="120px",o.input.style.marginLeft="12px",o.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await bt(q.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}));l.input.style.maxWidth="142px",o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="100px",o.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await bt(q.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}))}async function u(){await r.dapi.userDataStorage.get(rt,!1).then((t=>{if(Object.keys(t).includes(q.value)){const t=i.dialog("Pattern already exists");T()(t.getButton("OK")).hide(),t.add(i.divText("Pattern name '"+q.value+"' already exists.")).add(i.divText("Replace pattern?")).addButton("YES",(async()=>{await r.dapi.userDataStorage.remove(rt,q.value,!1).then((()=>l())),t.close()})).show()}else l()})),await c()}function d(t,e){const n=function(t){const e=H.value.getCol(t);let n=!0;for(let t=1;t<e.length;t++)if(e.get(t-1).length!==e.get(t).length&&0!==e.get(t).length){n=!1;break}if(!n){const n=i.dialog("Sequences lengths mismatch");T()(n.getButton("OK")).hide(),n.add(i.divText("The sequence length should match the number of Raw sequences in the input file")).add(i.divText("'ADD COLUMN' to see sequences lengths")).addButton("ADD COLUMN",(()=>{H.value.columns.addNewInt("Sequences lengths in "+t).init((t=>e.get(t).length)),r.shell.info("Column with lengths added to '"+H.value.name+"'"),n.close(),r.shell.v=r.shell.getTableView(H.value.name)})).show()}return e.get(0).length!==w[it].value&&i.dialog("Length was updated by value to from imported file").add(i.divText("Latest modifications may not take effect during translation")).onOK((()=>r.shell.info("Lengths changed"))).show(),n}(t),o=H.value.getCol(t).get(0);n&&o.length!==w[e].value&&(w[e].value=H.value.getCol(t).get(0).length),E[e].value=o}function h(t){const e=H.value.getCol(t);if(e.type!==o.TYPE.INT)r.shell.error("Column should contain integers only");else if(e.categories.filter((t=>""!==t)).length<e.toList().filter((t=>""!==t)).length){const t=(n=e.getRawData(),Array.from(new Set(n)).filter((t=>n.indexOf(t)!==n.lastIndexOf(t))));i.dialog("Non-unique IDs").add(i.divText("Press 'OK' to select rows with non-unique values")).onOK((()=>{H.value.selection.init((n=>t.indexOf(e.get(n))>-1)),r.shell.v=r.shell.getTableView(H.value.name),r.shell.info("Rows are selected in table '"+H.value.name+"'")})).show()}var n}const p=Object.keys(O.al),m=p[0],g=[m],f=i.choiceInput("Sequence basis",m,p,(t=>{var e;e=t,at.forEach((t=>{for(let n=0;n<b[t].length;n++)b[t][n].value=e})),s(),n()})),A=i.boolInput("Fully PTO",!0,(t=>{var e;at.forEach((e=>{S[e].value=t})),e=t,at.forEach((t=>{for(let n=0;n<C[t].length;n++)C[t][n].value=e})),s(),n()}));A.captionLabel.classList.add("ui-label-right"),A.captionLabel.style.textAlign="left",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.minWidth="40px",A.captionLabel.style.width="auto";const v=Object.fromEntries(at.map((t=>[t,23]))),x=Object.fromEntries(at.map((t=>[t,i.div([])]))),C=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.boolInput("",!0))]))),b=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.choiceInput("",m,p))]))),w=Object.fromEntries(at.map((t=>{const n=i.intInput(`${lt[t]} length`,23,(()=>e()));return n.setTooltip(`Length of ${lt[t].toLowerCase()}, including overhangs`),[t,n]}))),y=Object.fromEntries(at.map((t=>[t,""]))),E=Object.fromEntries(at.map((t=>[t,i.textInput("",Ct(w[t].value,f.value))]))),I=Object.fromEntries(at.map((t=>{const e=i.choiceInput(`${lt[t]} column`,"",[],(e=>{d(e,t),y[t]=e}));return[t,e]}))),S=Object.fromEntries(at.map((t=>{const e=i.boolInput(`First ${t} PTO`,A.value,(()=>s()));return e.setTooltip(`ps linkage before first nucleotide of ${lt[t].toLowerCase()}`),e.captionLabel.classList.add("ui-label-right"),e.captionLabel.style.textAlign="left",e.captionLabel.style.maxWidth="100px",e.captionLabel.style.minWidth="40px",e.captionLabel.style.width="auto",[t,e]}))),M=Object.fromEntries(at.map((t=>{const e=Object.fromEntries(dt.map((e=>{const o=i.stringInput(`${t} ${ht[e]}' Modification`,"",(()=>{s(),n()}));return o.setTooltip(`Additional ${t} ${ht[e]}' Modification`),[e,o]})));return[t,e]}))),B=Object.fromEntries(at.map((t=>{const e=i.textInput("",yt(E[t].value,b[t],C[t],M[t][ct],M[t][ut],S[t].value));return e.input.style.minWidth="none",e.input.style.flexGrow="1",T()(e.root.lastChild).css("height","auto"),[t,e]}))),N=Object.fromEntries(at.map((t=>[t,i.block([i.h1(`${lt[t]}`),i.divH([i.div([i.divText("#")],{style:{width:"20px"}}),i.block75([i.divText("Modification")]),i.div([i.divText("PTO")])]),x[t]],{style:{paddingTop:"12px"}})])));at.forEach((t=>{E[t].input.style.resize="none",B[t].input.style.resize="none",E[t].input.style.minWidth="none",E[t].input.style.flexGrow="1",B[t].input.style.minWidth="none",B[t].input.style.flexGrow="1";let e=i.div([i.button(i.iconFA("copy",(()=>{})),(()=>{navigator.clipboard.writeText(B[t].value).then((()=>r.shell.info("Sequence was copied to clipboard")))}))],"ui-input-options");e.style.height="inherit",B[t].root.append(e)}));const L=i.div([]),D=i.div([],"ui-form ui-form-wide"),F=i.div([]),V=i.form([]),k=i.divH([i.boolInput(m,!0,(t=>{if(t)g.includes(m)||g.push(m);else{const t=g.indexOf(m,0);t>-1&&g.splice(t,1)}s(),n()})).root]),P=i.div([w[st].root]),H=function(t){const e=i.tableInput("Tables",t[0],t,(()=>{const t=e.value;if(null===t)return void console.warn("Table is null");const n=t.name;if(!r.shell.tableNames.includes(n)){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}const o=t.columns.names();at.forEach((t=>{const e=o[0];d(e,t),y[t]=e;const n=i.choiceInput(`${lt[t]} column`,e,o,(e=>{d(e,t),y[t]=e,console.log(`clicked ${t} var:`,y[t])}));T()(I[t].root).replaceWith(n.root)})),_=o[0];const s=i.choiceInput("ID column",o[0],o,(t=>{h(t),_=t}));T()(R.root).replaceWith(s.root)}));return e}([]);let _="";const R=i.choiceInput("ID column","",[],(t=>{h(t),_=t}));c();const j=i.boolInput("Anti sense strand",!0,(t=>{N[st].hidden=!t,I[st].root.hidden=!t,P.hidden=!t,V.hidden=!t,D.hidden=!t,S[st].root.hidden=!t,s()}));j.setTooltip("Create antisense strand sections on SVG and table to the right");const q=i.textInput("Save as","Pattern name",(()=>s()));q.setTooltip("Name Of New Pattern"),dt.forEach((t=>{V.append(M[st][t].root)}));const $=i.textInput("Comment","",(()=>s())),G=i.bigButton("Save",(()=>{if(""!==q.value)u().then((()=>r.shell.info("Pattern saved")));else{const t=i.stringInput("Enter name","");i.dialog("Pattern Name").add(t.root).onOK((()=>{q.value=t.value,u().then((()=>r.shell.info("Pattern saved")))})).show()}}));q.addOptions(G);const U=i.bigButton("Convert",(()=>{const t=[!0,j.value];if(console.log("strand vars:",Object.values(y)),at.some(((e,n)=>t[n]&&""===y[e])))r.shell.info("Please select table and columns on which to apply pattern");else if(at.some((t=>w[t].value!==E[t].value.length))){const t=i.dialog("Length Mismatch");T()(t.getButton("OK")).hide(),t.add(i.divText("Length of sequences in columns doesn't match entered length. Update length value?")).addButton("YES",(()=>{at.forEach((t=>{w[t].value=H.value.getCol(I[t].value).getString(0).length})),t.close()})).show()}else{""!==_&&function(t,e,n){const o="ID "+n,i=r.shell.table(t).columns;i.contains(o)&&i.remove(o);const s=i.byName(e);i.addNewString(o).init((t=>""===s.getString(t)?"":s.get(t)+"_"+n))}(H.value.name,_,wt(q.value));const t=[!0,j.value];at.forEach(((e,n)=>{t[n]&&function(t,e,n,o,i,s,a){const l="Axolabs "+e,c=r.shell.table(t).columns;c.contains(l)&&c.remove(l);const u=c.byName(e);c.addNewString(l).init((t=>""===u.getString(t)?"":yt(u.getString(t),n,o,i,s,a)))}(H.value.name,y[e],b[e],C[e],M[e][ut],M[e][ct],S[e].value)})),r.shell.v=r.shell.getTableView(H.value.name),r.shell.info((j.value?"Columns were":"Column was")+" added to table '"+H.value.name+"'"),n()}}));D.append(E[st].root),D.append(B[st].root),e(),i.div([i.h1("Conversion preview"),E[it].root,B[it].root,D],"ui-form ui-form-wide"),i.block50([i.h1("Convert options"),H.root,I[it].root,I[st].root,R.root,i.buttonsInput([U])]).classList.add("ui-form");const W=i.link("Download",(()=>Pt.saveSvgAsPng(document.getElementById("mySvg"),q.value,{backgroundColor:"white"})),"Download pattern as PNG image",""),Y=i.link("Edit pattern",(()=>{i.dialog("Edit pattern").add(i.divV([i.h1("PTO"),i.divH([A.root,S[it].root,S[st].root],{style:{gap:"12px"}})])).add(i.divH([N[it],N[st]],{style:{gap:"24px"}})).onOK((()=>{r.shell.info("Saved")})).show()}),"Edit pattern","");return w[it].addCaption("Length"),i.splitH([i.box(i.div([i.h1("Pattern"),j.root,w[it],w[st],f.root,$.root,F,q.root,i.h1("Convert"),H.root,I[it],I[st],R.root,i.buttonsInput([U])],"ui-form"),{style:{maxWidth:"450px"}}),i.panel([L,k,i.divH([W,Y],{style:{gap:"12px",marginTop:"12px"}}),i.divH([i.divV([i.h1("Sense strand"),E[it].root,B[it].root],"ui-block"),i.divV([i.h1("Anti sense"),E[st],B[st]],"ui-block")],{style:{gap:"24px",marginTop:"24px"}}),i.h1("Additional modifications"),i.form([M[it][ut],M[it][ct]]),V],{style:{overflowX:"scroll",padding:"12px 24px"}})],{},!0)}}async function _t(t){try{const e={overflowX:"scroll"},n=i.div([],{style:e}),o=(0,J.$U)(t),s=.7*T()(window).height(),a=Math.max(...o.x)-Math.min(...o.x),l=Math.max(...o.y)-Math.min(...o.y),c=s/l,u=c*a,d=c*l,h=i.canvas(u*window.devicePixelRatio,d*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${d}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),i.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=(0,G.O)(t);console.error(e)}}class Rt{static async view(){const t=E.A.getInstance().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 _t(e)}))}}class jt{appName;parentAppName;constructor(t,e){this.appName=t,this.parentAppName=e}async createAppLayout(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`);let e=r.shell.v?.root;e&&i.setUpdateIndicator(e,!0),await(0,w.Y3)((async()=>{await this.addView()}),(()=>t.close())),e&&i.setUpdateIndicator(e,!1)}}class qt extends jt{constructor(t){super(t),this.view=o.View.create(),this.setupView()}view;async addView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;this.view.path=`/apps/${pe.name}/${t.replace(/\s/g,"")}/`,r.shell.addView(this.view)}async initView(){const t=await this.getHtml();this.view.append(t)}setupView(){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}}class $t extends jt{constructor(t){super("Oligo Toolkit"),this.externalViewFactories=t;const e=this.getViewFactories();this.multiView=new o.MultiView({viewFactories:e})}multiView;externalViewFactories;getViewFactories(){function t(t){const e=new t(o.View.create());return e.initView(),()=>e.getView()}let e={TRANSLATOR:t(Wt),PATTERN:t(Yt),STRUCTURE:t(zt)};return this.externalViewFactories&&(e=Object.assign({},e,this.externalViewFactories)),e}getPath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${pe.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getPath()}async addView(){this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),r.shell.addView(this.multiView)}}class Gt extends qt{constructor(t,e){super(t),this.layout=e}layout;getHtml(){return Promise.resolve(this.layout)}}class Ut{constructor(){}static getUI(t){switch(t){case"Oligo Translator":return new Wt;case"Oligo Pattern":return new Yt;case"Oligo Structure":return new zt;default:throw new Error(`Unknown app name: ${t}`)}}}class Wt extends qt{constructor(){super("Oligo Translator");const t=i.iconFA("book",Rt.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel]),this.ui=new Z}topPanel;ui;getHtml(){return this.ui.getHtmlElement()}}class Yt extends qt{constructor(){super("Oligo Pattern"),this.ui=new Ht}ui;getHtml(){return Promise.resolve(this.ui.htmlDivElement)}}class zt extends qt{constructor(){super("Oligo Structure"),this.ui=new ot}ui;getHtml(){return this.ui.getHtmlDivElement()}}var Xt,Zt,Kt=n(895);wu;class Qt{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(Zt=Xt||(Xt={})).FASTA="fasta",Zt.SEPARATOR="separator",Zt.HELM="helm";const Jt=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"])}}};new Qt("PT",Jt.fasta.peptide,.5),new Qt("DNA",Jt.fasta.dna,.55),new Qt("RNA",Jt.fasta.rna,.55);class te extends Float32Array{}class ee{static makePalette(t,e=!1,n=ee){const o={};return t.forEach((t=>{const n=t[0],r=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[r][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}ee.undefinedColor="rgb(100,100,100)",ee.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 ne extends ee{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,ne)),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,ne)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new ne({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 ne.aaSynonyms?ne.aaSynonyms[t]:t;return super.get(e)}}ne.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class oe{static getPalette(t="grok"){switch(t){case"grok":return ne.GrokGroups;case"lesk":return ne.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",o="";for(const r of t)"("==r?e++:")"==r?e--:e?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[o,r]=this.getInnerOuter(t);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,r,1]:[this.undefinedColor,o,r,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,r,2]:[this.undefinedColor,o,r,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,r,3]:[this.undefinedColor,o,r,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,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}oe.SemType="Aminoacids",oe.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",oe.undefinedColor="rgb(100,100,100)",oe.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"},oe.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"},oe.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(*)*"},oe.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 re{}re.SemType="Nucleotides",re.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",re.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class ie{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 se{}class ae extends se{static buildPalette(){return[].concat(...Object.values(ee.colourPalette))}get(t){const e=ie.hashCode(t)%ae.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=o.Color.fromHtml(t),n=o.Color.g(e),r=o.Color.r(e),i=o.Color.b(e),s=Math.sqrt(Math.pow(0-r,2)+Math.pow(0-n,2)+Math.pow(0-i,2));return s>210?`rgb(${r/s*210},${n/s*210},${i/s*210})`:o.Color.toRgb(e)}(ae.palette[e])}}ae.palette=ae.buildPalette();new Uint32Array(65536);var le,ce;(ce=le||(le={})).HAMMING="Hamming",ce.LEVENSHTEIN="Levenshtein",ce.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",le.HAMMING,le.LEVENSHTEIN,le.NEEDLEMANN_WUNSCH,new class{constructor(){this.uhTemp=`units-handler.${o.SEMTYPE.MACROMOLECULE}`}},Xt.FASTA,Xt.SEPARATOR,Xt.HELM;var ue=n(61);function de(){const t=i.textInput("","");return{coloredInput:new L(t,M),codes:O.BF}}class he extends o.Package{_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}async initMonomerLib(){if(void 0!==this._monomerLib)return;const t=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");await(0,w.Y3)((async()=>{const t=await async function(){const t=o.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()}();this._monomerLib=await t.readLibrary(Kt.BX,Kt.a_)}),(()=>t.close()))}}const pe=new he;async function me(t){await xe();const e=Ut.getUI(t);await e.createAppLayout()}async function ge(){await xe();const t=await async function(){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:de()}},e={};for(const[n,o]of Object.entries(t)){let t;try{t=await r.functions.call(n,o.parameters);const i=new Gt(o.tabName,t);i.initView(),e[o.tabName]=()=>i.getView()}catch(t){console.warn(`Plugin ${n} not loaded, reason:`,t);continue}}return e}();if(!t)throw new Error("External app view factories not loaded");const e=new $t(t);await e.createAppLayout()}async function fe(){await me("Oligo Translator")}async function Ae(){await me("Oligo Pattern")}async function ve(){await me("Oligo Structure")}async function xe(){await(0,O.VO)(),await pe.initMonomerLib()}function Ce(){const t=E.A.getInstance().getCodesToWeightsMap();return Object.fromEntries(t)}function be(t){const e=new b.b(t),n=new I(t).getFormat();return null!==n&&e.isValidSequence(n)}function we(t,e){return new k(t,e,"GCRS").convert()}function ye(t){return(0,J.v5)(t,!0)}async function Ee(){await async function(){await(0,w.Y3)((async()=>fe()))}()}async function Oe(){await async function(){await(0,w.Y3)((async()=>{async function t(t,n,o){await(0,ue.gw)(3e3);const r=document.querySelectorAll(".st-pattern-choice-input > select");e=r.length;const i=r[o(n)];i.value=t;const s=new Event("input");i.dispatchEvent(s)}let e;await Ae(),["DNA","invAb","Z-New"].forEach((async(e,n)=>{t(e,n,(t=>2*t))})),["2'-O-Methyl","2'-Fluoro","2'-O-MOE"].forEach((async(n,o)=>{t(n,o,(t=>e-2-2*t))}))}))}()}async function Ie(){await async function(){await(0,w.Y3)((async()=>{await ve(),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,ue.gw)(500);const n=document.querySelectorAll(".colored-text-input > textarea")[t];n.value=e;const o=new Event("input");n.dispatchEvent(o)}(e,t)}))}))}()}async function Se(t,e,n){return await xe(),new X.I(t,e).convertTo(n)}},713:(t,e,n)=>{n.d(e,{AU:()=>o,wm:()=>r});const o="Copied",r="Copy sequence"},511:(t,e,n)=>{n.d(e,{T:()=>o});const o="Afcgacsu"},976:t=>{t.exports=DG},469:t=>{t.exports=grok}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,n),i.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 o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},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.nc=void 0;var o=n(593);sequencetranslator=o})();
1
+ var sequencetranslator;(()=>{"use strict";var t={622:(t,e,n)=>{n.d(e,{w:()=>r});class o{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 o=this.isWhitespace(n)?e:e-1;for(let t=0;t<o;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToAtomType(n),e[o]=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 o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[t,e,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}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 o=new Uint16Array(2);o[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),o[1]=this.parseIntValue(e),t[n]=o,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let o=0;o<t;o++)n=this.shiftIdxToBondType(n),e[o]=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 r extends o{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 o=0;o<e;o++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}},577:(t,e,n)=>{n.d(e,{u:()=>r});var o=n(622);class r extends o.w{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const 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))}}}},61:(t,e,n)=>{n.d(e,{gw:()=>r}),n(469),n(976);var o;function r(t){return e=this,n=void 0,r=function*(){yield new Promise((e=>setTimeout(e,t)))},new((o=void 0)||(o=Promise))((function(t,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}l((r=r.apply(e,n||[])).next())}));var e,n,o,r}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(o||(o={}))},604:(t,e,n)=>{function o(t){var e;return"string"==typeof t||t instanceof String?t:"$thrownJsError"in t?o(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>o})},490:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());s.push([t.id,".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/view/style/colored-text-input.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,0DAA0D;EAC1D,eAAe;EACf,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".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.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 Mono', 'Roboto Mono Local', monospace;\n font-size: 12px;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},753:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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","",{version:3,sources:["webpack://./src/view/style/structure-app.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;AACrB;;AAEA;EACE,iBAAiB;EACjB,mBAAmB;EACnB,eAAe;AACjB;;AAEA;EACE,gBAAgB;EAChB,YAAY;AACd;;AAEA;EACE,sBAAsB;AACxB;;AAEA,8BAA8B,qCAAqC;EACjE,WAAW;AACb;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB",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-input-form {\n text-align: right;\n vertical-align: top;\n min-width: 95px;\n}\n\n.st-structure-direction-choice label {\n min-width: 100px;\n float: right;\n}\n\n.st-structure-direction-choice div {\n justify-content: right;\n}\n\n.st-structure-text-input-td { /* Style for td containing textarea */\n width: 100%;\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"],sourceRoot:""}]);const a=s},602:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(537),r=n.n(o),i=n(645),s=n.n(i)()(r());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 table tbody tr td { */\n/* max-width: 20%; */\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/view/style/translator-app.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,oDAAoD;AACpD,sBAAsB;AACtB,MAAM;;AAEN;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 table tbody tr td { */\n/* max-width: 20%; */\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},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),e.push(u))}},e}},537:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},803:(t,e)=>{var n;!function(){var o=e||{}||this||window;void 0===(n=function(){return o}.apply(e,[]))||(t.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(t){return t instanceof HTMLElement||t instanceof SVGElement},c=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},u=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},d=function(t,e,n){var o=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==o||isNaN(parseFloat(o))?0:o},h=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(e.length),r=new Uint8Array(o),i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return new Blob([o],{type:n})},p={},m=null,g=function(t,e){var n=e||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(t,e){return(o?o(t):t)+"{"+(r?r(e):e)+"}\n"},d=[],h=void 0===l,g=l||[];return(m||(m=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,o=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))d.push(u(e.selectorText,e.style.cssText));else if(h&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?e+"/../"+o:o.startsWith("./")?e+"/."+o:o;return{text:t.cssText,format:(r=l,i=Object.keys(a).filter((function(t){return r.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,o);n&&g.push(n)}else c||d.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(p[t.url])return e(p[t.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),o=0;o<n.byteLength;o++)e+=String.fromCharCode(n[o]);return window.btoa(e)}(o.response),r=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";p[t.url]=r,e(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),p[t.url]=null,e(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),o.open("GET",t.url),o.responseType="arraybuffer",o.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(g).then((function(t){return d.join("\n")+t}))},f=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(t,e,n){c(t);var o=e||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,h=o.width,p=o.height,m=o.scale,f=void 0===m?1:m,A=o.responsive,v=void 0!==A&&A,x=o.excludeCss,C=void 0!==x&&x;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,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var o=t.cloneNode(!0);o.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,o){if("svg"===t.tagName)return{width:n||d(t,e,"width"),height:o||d(t,e,"height")};if(t.getBBox){var r=t.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(t,o,h,p),l=s.width,c=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.appendChild(o),o=m}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),v?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*f),o.setAttribute("height",c*f)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(r,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return g(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var r=document.createElement("defs");r.appendChild(e),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var A=document.createElement("div");A.appendChild(o);var x=A.innerHTML;if("function"!=typeof n)return{src:x,width:l,height:c};n(x,l,c)}))},o.svgAsDataUri=function(t,e,n){return c(t),o.prepareSvg(t,e).then((function(t){var e=t.src,o=t.width,r=t.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp "&#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(i,o,r),i}))},o.svgAsPngUri=function(t,e,n){c(t);var r=e||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,d=function(t){var e=t.src,o=t.width,r=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,e):a.drawImage(e,0,0);var d=void 0;try{d=i.toDataURL(s,l)}catch(t){if("undefined"!=typeof SecurityError&&t instanceof SecurityError||"SecurityError"===t.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw t}return"function"==typeof n&&n(d,i.width,i.height),Promise.resolve(d)};return u?o.prepareSvg(t,e).then(d):o.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var o=new Image;o.onload=function(){return e(d({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},o.src=t}))}))},o.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(h(e),t);else{var o=document.createElement("a");if("download"in o){o.download=t,o.style.display="none",document.body.appendChild(o);try{var r=h(e),i=URL.createObjectURL(r);o.href=i,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),o.href=e}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},o.saveSvg=function(t,e,n){var r=f();return u(t).then((function(t){return o.svgAsDataUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))},o.saveSvgAsPng=function(t,e,n){var r=f();return u(t).then((function(t){return o.svgAsPngUri(t,n||{})})).then((function(t){return o.download(e,t,r)}))}}()},379:t=>{var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,d="".concat(c," ").concat(u);i[c]=u+1;var h=n(d),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)e[h].references++,e[h].updater(p);else{var m=r(p,o);o.byIndex=a,e.splice(a,0,{identifier:d,updater:m,references:1})}s.push(d)}return s}function r(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,r){var i=o(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=o(t,r),c=0;c<i.length;c++){var u=n(i[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}i=l}}},569:t=>{var e={};t.exports=function(t,n){var o=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(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{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))}}},29:(t,e,n)=>{n.d(e,{NI:()=>r,mc:()=>o});const o=["A","G","C","U","T"];var r;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(r||(r={}))},895:(t,e,n)=>{n.d(e,{BX:()=>o,Dv:()=>a,VV:()=>l,Xz:()=>c,a_:()=>r,dz:()=>s,pl:()=>i});const o="System:AppData/SequenceTranslator",r="monomer-lib.json",i="System:AppData/SequenceTranslator",s="axolabs-style.json",a="formats-to-helm.json",l="codes-to-symbols.json",c="linkers.json"},996:(t,e,n)=>{n.d(e,{BF:()=>l,Rv:()=>a,VO:()=>u,al:()=>s,iA:()=>c});var o=n(976),r=n(895);const i=new o.FileSource(r.pl);let s,a,l,c;async function u(){[s,a,l,c].every((t=>void 0!==t))||(s=await d(r.dz),a=await d(r.Dv),l=await d(r.VV),c=await d(r.Xz))}async function d(t){let e;try{e=JSON.parse(await i.readAsText(t))}catch(e){const n=e.hasOwnProperty("message")?e.message:e.toString();throw new Error(`Error loading json from ${t}:`+n)}return e}},669:(t,e,n)=>{n.d(e,{LR:()=>i,Y3:()=>s,xB:()=>r});var o=n(469);function r(t){return t.sort(((t,e)=>e.length-t.length))}function i(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 s(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw o.shell.error(`${n} error: `+e),t}finally{e&&e()}}},559:(t,e,n)=>{n.d(e,{A:()=>a});var o=n(976),r=n(593),i=n(29),s=n(996);class a{constructor(){const t=r._package.monomerLib;if(null===t)throw new Error("SequenceTranslator: monomer library is null");this.lib=t,this.allMonomers=this.getAllMonomers()}lib;static instance;allMonomers;formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===i.NI.HELM)return;const o=s.BF[n],r=Object.keys(o).filter((e=>o[e]===t.symbol));e[n]=r.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}static getInstance(){return void 0===a.instance&&(a.instance=new a),a.instance}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(s.BF[t]))}getCodesByFormat(t){return Object.keys(s.BF[t])}getAllFormats(){return Object.keys(s.BF)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(s.BF).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const o=this.getMonomer(n).meta?.molecularWeight;t.set(e,o)}))})),t}}},947:(t,e,n)=>{n.d(e,{b:()=>s});var o=n(29),r=n(559),i=n(669);class s{sequence;constructor(t){this.sequence=t,this.libWrapper=r.A.getInstance()}libWrapper;getInvalidCodeIndex(t){if(t===o.NI.HELM)return this.sequence.length;const e=["r","d"],n=(0,i.xB)(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&&o.mc.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&o.mc.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}},900:(t,e,n)=>{n.d(e,{$:()=>o});const o="p"},261:(t,e,n)=>{function o(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 o="",a="",l="";const c=[];let u=0,d=0,h=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=r(t.antiStrands[e]);let p=!1;const m=t.senseStrands.concat(t.antiStrands);let g=0;for(let e=0;e<m.length;e++){m[e]=m[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=i(m[e]),r=s(m[e]);if(e>=t.senseStrands.length?!1===p&&(p=!0,h=0):g=Math.min(g,Math.min(...r.y.filter((t=>t<0)))),p){const t=Math.min(...r.x)-h,e=Math.max(...r.y)+5;for(let e=0;e<r.x.length;e++)r.x[e]-=t;for(let t=0;t<r.y.length;t++)r.y[t]-=e-g}let l=m[e].indexOf("M V30 BEGIN ATOM");l=m[e].indexOf("\n",l);let f=l,A=l;for(let t=0;t<n.natom;t++){f=m[e].indexOf("V30",f)+4,A=m[e].indexOf(" ",f);const n=parseInt(m[e].substring(f,A))+u;m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf(" ",f)+1,f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f);let o=Math.round(1e4*r.x[t])/1e4;m[e]=m[e].slice(0,f)+o+m[e].slice(A),f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f),o=Math.round(1e4*r.y[t])/1e4,m[e]=m[e].slice(0,f)+o+m[e].slice(A),f=m[e].indexOf("\n",f)+1}const v=m[e].indexOf("M V30 END ATOM");o+=m[e].substring(l+1,v);let x=m[e].indexOf("M V30 BEGIN BOND");x=m[e].indexOf("\n",x),f=x,A=x;for(let t=0;t<n.nbond;t++){f=m[e].indexOf("V30",f)+4,A=m[e].indexOf(" ",f);const t=parseInt(m[e].substring(f,A))+d;m[e]=m[e].slice(0,f)+t+m[e].slice(A),f=m[e].indexOf(" ",f)+1,f=m[e].indexOf(" ",f)+1,A=m[e].indexOf(" ",f);let n=parseInt(m[e].substring(f,A))+u;m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf(" ",f)+1,A=Math.min(m[e].indexOf("\n",f),m[e].indexOf(" ",f)),n=parseInt(m[e].substring(f,A))+u,m[e]=m[e].slice(0,f)+n+m[e].slice(A),f=m[e].indexOf("\n",f)+1}const C=m[e].indexOf("M V30 END BOND");a+=m[e].substring(x+1,C);let b=m[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const t=m[e].indexOf(")",b);m[e].substring(b,t).split(" ").slice(1).forEach((t=>{c.push(parseInt(t)+u)})),b=t,b=m[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}u+=n.natom,d+=n.nbond,h+=Math.max(...r.x)+5}const f=Math.ceil(c.length/4);l+="M V30 MDLV30/STEABS ATOMS=("+c.length+" -\n";for(let t=0;t<f;t++){l+="M V30 ";const e=t+1===f?c.length-4*(f-1):4;for(let n=0;n<e;n++)l+=n+1===e?t===f-1?c[4*t+n]+")\n":c[4*t+n]+" -\n":c[4*t+n]+" "}return n+="M V30 COUNTS "+u+" "+d+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=a,n+="M V30 END BOND\n",e&&c.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 r(t){const e=s(t),n=e.atomIndex.length,o=(Math.max(...e.x)+Math.min(...e.x))/2,r=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=o,e.y[t]-=r;const i=Math.PI,a=Math.cos(i),l=Math.sin(i);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 c=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=o,e.y[t]-=c;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let d=u;for(let o=0;o<n;o++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,d=t.indexOf(" ",u)+1,d=t.indexOf(" ",d),u=(t=t.slice(0,u)+e.x[o]+" "+e.y[o]+t.slice(d)).indexOf("\n",u)+1;return t}function i(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}function s(t){const e=i(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let o=n;const r=Array(e.natom),s=Array(e.natom),a=Array(e.natom),l=Array(e.natom);for(let i=0;i<e.natom;i++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),r[i]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),s[i]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),a[i]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),l[i]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:s,x:a,y:l}}n.d(e,{$U:()=>s,v5:()=>o})},544:(t,e,n)=>{n.d(e,{$3:()=>r,DD:()=>o,s8:()=>i});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},864:(t,e,n)=>{n.d(e,{D:()=>l});var o=n(29),r=n(544),i=n(456),s=n(996),a=n(559);function l(t,e,n){const l=Object.keys(s.Rv).concat([o.NI.HELM]);if(!t||-1!==e&&n!==o.NI.HELM)return{};if(!l.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const c=l.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),u=new i.I(t,n),d=Object.fromEntries(c.map((t=>{let e;try{e=u.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),h=function(t,e){const n=new RegExp("\\([^()]*\\)","g"),i=t.match(n);if(!i)return null;return i.map((t=>{const n=t.replace(/[\[\]()]/g,"");return o.mc.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||r.s8)).join("")}(n===o.NI.HELM?t:d[o.NI.HELM],a.A.getInstance());return h&&(d.Nucleotides=h),d}},456:(t,e,n)=>{n.d(e,{I:()=>u});var o=n(29),r=n(544),i=n(996);const s=(t,e)=>e.length-t.length;class a{constructor(){this.formats=this.getFormats()}formats;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 o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[o]?e[o]=[t]:e[o].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const o=n.sort(s);e[t]=o[0]})),e}(i.Rv[t])}getFormatToHelmDict(t){this.validateFormat(t);const e=i.Rv[t];return Object.assign({},...Object.values(e))}getTargetFormatHelmCodes(t){this.validateFormat(t);const e=this.getHelmToFormatDict(t);return Object.keys(e).sort(s)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(l(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=i.Rv[t],n=l(Array.from(new Set(Object.values(e[r.DD.LINKAGE]))).sort(s));return new RegExp(`${r.$3}.(${n})`,"g")}isValidFormat(t){return this.formats.includes(t)}getFormats(){return Object.keys(i.Rv)}validateFormat(t){if(!this.isValidFormat(t))throw new Error(`Invalid format: ${t}`)}isHelm(t){return t===o.NI.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(s)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(l(e)+"|\\([^()]*\\)|.","g")}}function l(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const c={LEFT:"RNA1{",RIGHT:"}$$$$"};class u{sequence;sourceFormat;constructor(t,e){this.sequence=t,this.sourceFormat=e}formats=new a;convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===o.NI.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===o.NI.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(l(Object.values(c)),"g");let o=t.replace(n,"");const i=this.formats.getHelmToFormatDict(e),s=this.formats.getTargetFormatHelmCodes(e),a=this.formats.getTargetFormatHelmCodesRegExp(e);return o=o.replace(a,(t=>s.includes(t)?i[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,r.s8).replace(/p\.|\./g,""),o=o.replace(/<empty>/g,""),o=o.replace(/\/\//g,"/"),o}formatToHelm(t,e){const n=this.formats.getFormatToHelmDict(e),o=this.formats.getCodesByFormat(e),i=this.formats.getFormatRegExp(e),s=this.formats.getPhosphateHelmCodesRegExp(e);let a=t.replace(i,(t=>o.includes(t)?n[t]+".":"?"));return a=a.replace(/\?+/g,`${r.s8}.`),a=a.slice(0,-1),a[a.length-1]===r.$3&&(a=a.slice(0,-1)),a=a.replace(s,((t,e)=>e)),a=a.replace(/<empty>/g,""),`${c.LEFT+a+c.RIGHT}`}}},593:(t,e,n)=>{n.r(e),n.d(e,{_package:()=>pe,demoOligoPattern:()=>Oe,demoOligoStructure:()=>Ie,demoTranslateSequence:()=>Ee,getCodeToWeightsMap:()=>Ce,getMolfileFromGcrsSequence:()=>we,initSequenceTranslatorLibData:()=>xe,linkStrands:()=>ye,oligoPatternApp:()=>Ae,oligoStructureApp:()=>ve,oligoToolkitApp:()=>ge,oligoTranslatorApp:()=>fe,translateOligonucleotideSequence:()=>Se,validateSequence:()=>be});var o=n(976),r=n(469);const i=ui,s=rxjs;var a=n(379),l=n.n(a),c=n(795),u=n.n(c),d=n(569),h=n.n(d),p=n(565),m=n.n(p),g=n(216),f=n.n(g),A=n(589),v=n.n(A),x=n(602),C={};C.styleTagTransform=v(),C.setAttributes=m(),C.insert=h().bind(null,"head"),C.domAPI=u(),C.insertStyleElement=f(),l()(x.Z,C),x.Z&&x.Z.locals&&x.Z.locals;var b=n(947),w=n(669),y=n(29),E=n(559),O=n(996);class I{sequence;constructor(t){this.sequence=t,this.libWrapper=E.A.getInstance(),this.formats=Object.keys(O.Rv)}libWrapper;formats;getFormat(){if(this.sequence.startsWith("RNA"))return y.NI.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=new b.b(this.sequence),n=Array(t.length).fill(0);for(let o=0;o<t.length;++o){const r=t[o];n[o]=e.getInvalidCodeIndex(r)}const o=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence;let e=[];for(const n of this.formats){let o=(0,w.xB)(this.libWrapper.getCodesByFormat(n)),r=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){r=e+1;break}o.some((e=>e===t.slice(r,r+e.length)))&&e.push(n)}return e}}const S=$;var T=n.n(S);function M(t){let e=0;const n=new I(t).getFormat();null!==n&&(e=new b.b(t).getInvalidCodeIndex(n));const o=e<0||""===t,r=i.span([]);T()(r).css("-webkit-text-fill-color","var(--grey-6)");const s=i.span([]);return T()(s).css("-webkit-text-fill-color","red"),o?r.innerHTML=t:(r.innerHTML=t.slice(0,e),s.innerHTML=t.slice(e)),[r,s]}var B=n(490),N={};N.styleTagTransform=v(),N.setAttributes=m(),N.insert=h().bind(null,"head"),N.domAPI=u(),N.insertStyleElement=f(),l()(B.Z,N),B.Z&&B.Z.locals&&B.Z.locals;class L{textInputBase;painter;constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,T()(this.root).addClass("colored-text-input"),n&&this.textInputBase.onChanged((()=>{T()(this.textArea).css("height",0),T()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=i.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged((()=>this.colorize()))}highlights;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)))}}var D=n(900);class F{sequence;codeMap;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,o)=>{const r=this.getSymbolForCode(n);o>0&&function(t){return O.iA.left.includes(t)}(r)&&e.pop(),e.push(r);const i=V(r),s=o===t.length-1,a=o+1<t.length&&V(this.getSymbolForCode(t[o+1]));i||function(t){return O.iA.right.includes(t)}(r)||a||s||e.push(D.$)})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??=t,e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const o=t.find((t=>t===this.sequence.substring(n,n+t.length)));e.push(o),n+=o.length}return e}getAllCodesOfFormat(){let t=Array.from(this.codeMap.keys());return(0,w.xB)(t)}}function V(t){return O.iA.phosphate.includes(t)}class k{invert;constructor(t,e=!1,n){this.invert=e,this.lib=E.A.getInstance();const o=this.lib.getCodeToSymbolMap(n);this.parser=new F(t,o)}parser;lib;convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const o=this.getMonomerMolfile(t,n);e.push(o)}));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 o=t.substring(e,n);return o=o.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+o+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,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n),i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[o];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 c=l;for(let o=0;o<n;o++)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[o]+" "+e.y[o]+t.slice(c)).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 o=n;const r=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,o=t.indexOf(" ",n),r[l]=parseInt(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),i[l]=t.substring(n,o),n=o+1,o=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,o)),n=o+1,o=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,o)),n=t.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const o=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:o,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,o=e.atomIndex.indexOf(1),r=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,o,r);const i=(e.x[r]+e.x[o])/2,s=(e.y[r]+e.y[o])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[o])a=e.y[o]>e.y[r]?Math.PI/2:3*Math.PI/2;else if(0===e.y[o])a=e.x[o]>e.x[r]?Math.PI:0;else{const t=e.y[o]/e.x[o];a=t>0?e.x[o]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[o]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),c=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*c,e.y[t]=n*c+e.y[t]*l}const u=e.x[o];for(let t=0;t<n;t++)e.x[t]-=u;let d=t.indexOf("M V30 BEGIN ATOM");d=t.indexOf("\n",d);let h=d;for(let o=0;o<n;o++)d=t.indexOf("V30",d)+4,d=t.indexOf(" ",d)+1,d=t.indexOf(" ",d)+1,h=t.indexOf(" ",d)+1,h=t.indexOf(" ",h),d=(t=t.slice(0,d)+e.x[o]+" "+e.y[o]+t.slice(h)).indexOf("\n",d)+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 o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(t[e]),d=this.extractAtomDataV3000(t[e]);let h=t[e].indexOf("M V30 BEGIN ATOM");h=t[e].indexOf("\n",h);let p=h,m=h;for(let o=0;o<u.natom;o++)if(1!==d.atomIndex[o]||0===e){p=t[e].indexOf("V30",p)+4,m=t[e].indexOf(" ",p);let o=0;n?(o=parseInt(t[e].substring(p,m)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+o+t[e].slice(m),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p);const r=c-d.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(p,m))+r))/1e4;t[e]=t[e].slice(0,p)+s+t[e].slice(m),p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p),s=Math.round(1e4*parseFloat(t[e].substring(p,m)))/1e4,t[e]=t[e].slice(0,p)+s+t[e].slice(m),p=t[e].indexOf("\n",p)+1}else p=t[e].indexOf("M V30",p)-1,m=t[e].indexOf("\n",p+1),t[e]=t[e].slice(0,p)+t[e].slice(m);const g=t[e].indexOf("M V30 END ATOM");o+=t[e].substring(h+1,g);let f=t[e].indexOf("M V30 BEGIN BOND");f=t[e].indexOf("\n",f),p=f,m=f;for(let o=0;o<u.nbond;o++){p=t[e].indexOf("V30",p)+4,m=t[e].indexOf(" ",p);const o=parseInt(t[e].substring(p,m))+l;t[e]=t[e].slice(0,p)+o+t[e].slice(m),p=t[e].indexOf(" ",p)+1,p=t[e].indexOf(" ",p)+1,m=t[e].indexOf(" ",p);let r=0;n?(r=parseInt(t[e].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(m),p=t[e].indexOf(" ",p)+1,m=Math.min(t[e].indexOf("\n",p),t[e].indexOf(" ",p)),r=0,n?(r=parseInt(t[e].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(p,m))+a,t[e]=t[e].slice(0,p)+r+t[e].slice(m),p=t[e].indexOf("\n",p)+1}const A=t[e].indexOf("M V30 END BOND");r+=t[e].substring(f+1,A);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+=u.natom-1,l+=u.nbond,c+=n?Math.max(...d.x):d.x[u.natom-1]-d.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<u;t++){i+="M V30 ";const e=t+1===u?s.length-4*(u-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===u-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+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",e&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(t,e,n){const o=e+1,r=t.x[o],i=t.y[o],s=t.x[n]-r,a=t.y[n]-i,l=t.x[e]-r,c=t.y[e]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),d=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),h=l-s,p=c-a,m=u-s,g=d-a;Math.sqrt(g*g+m*m)>=Math.sqrt(p*p+h*h)&&(t.x[e]=u+r,t.y[e]=d+i)}}var P,H=n(864),_=n(622);!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(P||(P={}));class R extends _.w{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(P.HEADER)&&-1!==t.indexOf(P.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,P.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<P.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,P.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,P.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+P.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=P.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}var j=n(577);class q{constructor(){}static getInstance(t){if(R.validate(t))return new R(t);if(j.u.validate(t))return new j.u(t);throw new Error("Malformed molfile")}}var G=n(604);const U=class extends Error{constructor(t){super(t)}};class W{constructor(t){this.molblock=t}_validMolBlock;get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof U&&(t="");const n=(0,G.O)(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new U("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=(0,G.O)(t);console.error(e)}}getMoleculeDimensions(){const t=q.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=i.dialog({title:"Molecule",showFooter:!1}),e=.7*T()(window).height(),n=this.getMoleculeDimensions(),o=e/n.height,r=e,s=n.width*o,a=i.canvas(s,r);await this.drawMolBlockOnCanvas(a);const l=i.block([a],{style:{overflowX:"scroll"}});t.add(l).showModal(!0),T()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),T()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),T()(t.root).find(".d4-dialog-contents").addClass("ui-box"),T()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const o=i.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${e}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(i.tooltip.bind(o,"Click to zoom"))}}var Y=n(713),z=n(511),X=n(456);class Z{constructor(){const t=Object.keys(O.Rv).concat(y.NI.HELM);this.moleculeImgDiv=i.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=i.div([]),this.formatChoiceInput=i.choiceInput("",y.NI.HELM,t,(async()=>{this.format=this.formatChoiceInput.value,this.updateTable(),await this.updateMolImg()})),this.sequenceInputBase=i.textInput("",z.T,(()=>{this.onInput.next()})),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()}))}onInput=new s.Subject;moleculeImgDiv;outputTableDiv;formatChoiceInput;sequenceInputBase;molfile;sequence;format;async getHtmlElement(){const t=new L(this.sequenceInputBase,M),e=i.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=i.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o=i.div([this.formatChoiceInput]),r=i.button(i.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));i.tooltip.bind(r,"Clear input");const s={format:o,textInput:t.root,clearBtn:r},a=i.table([s],(t=>[t.format,t.textInput,t.clearBtn]));a.classList.add("st-translator-input-table");const l=i.block([this.outputTableDiv,e,n]),c=i.box(i.panel([a,l,i.block([i.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),c}saveMolfile(){const t=new k(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";(0,w.LR)(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Y.AU)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?new b.b(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,H.D)(this.sequence,t,this.format),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?i.divH([]):i.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Y.AU)))),Y.wm,"");n.push({format:t,sequence:o})}const o=i.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(o),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new W(this.molfile);await t.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=new I(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===y.NI.HELM){const t=new X.I(this.sequence,this.format).convertTo(y.NI.AXOLABS);return new k(t,!1,y.NI.AXOLABS).convert()}return new k(this.sequence,!1,this.format).convert()}}var K=n(753),Q={};Q.styleTagTransform=v(),Q.setAttributes=m(),Q.insert=h().bind(null,"head"),Q.domAPI=u(),Q.insertStyleElement=f(),l()(K.Z,Q),K.Z&&K.Z.locals&&K.Z.locals;var J=n(261);function tt(t,e){if(""===t)return"";const n=new I(t).getFormat();if(!n)return"";let o="";try{o=new k(t,e,n).convert()}catch(t){const e=(0,G.O)(t);console.error(e)}return o}function et(t,e,n,o){const r=[t,e,n].filter((t=>""!==t.strand));if(1===r.length)return tt(r[0].strand,r[0].invert);{const r=tt(t.strand,t.invert),i=[tt(e.strand,e.invert),tt(n.strand,n.invert)].filter((t=>""!==t));return(0,J.v5)({senseStrands:[r],antiStrands:i},o)}}const nt=["ss","as","as2"];class ot{constructor(){this.onInput=new s.Subject,this.onInvalidInput=new s.Subject,this.inputBase=Object.fromEntries(nt.map((t=>[t,i.textInput("","",(()=>{this.onInput.next()}))]))),this.useChiralInput=i.boolInput("Use chiral",!0),this.saveAllStrandsInput=i.boolInput("Save as one entity",!0),i.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(nt.map((t=>[t,!1]))),this.moleculeImgDiv=i.block([]),T()(this.moleculeImgDiv).addClass("st-structure-mol-img"),o.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),o.debounce(this.onInvalidInput,1e3).subscribe((async()=>{r.shell.warning("Insert Sense strand")}))}onInput;onInvalidInput;useChiralInput;saveAllStrandsInput;inputBase;directionInversion;moleculeImgDiv;async getHtmlDivElement(){const t=this.getTableInput(),e=this.getBoolInputsAndButton();await this.updateMoleculeImg();const n=i.divH([e,this.moleculeImgDiv]);T()(n).addClass("st-structure-bottom");const o=i.divV([t,n]);return T()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=i.buttonsInput([i.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i){const s=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===s.length||1===s.length&&""===t.strand)r.shell.warning("Enter SS and optionally AS/AS2 to save SDF");else{let a;if(i)a=et(t,e,n,o)+"\n$$$$\n";else{const d=tt(t.strand,t.invert),h=tt(e.strand,e.invert),p=tt(n.strand,n.invert);a=d+"\n> <Sequence>\nSense Strand\n$$$$\n",h&&(a+=h+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(a+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const l=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}const u=l.getFullYear()+"-"+c(l.getMonth()+1)+"-"+c(l.getDate())+"_"+c(l.getHours())+"-"+c(l.getMinutes())+"-"+c(l.getSeconds());(0,w.LR)(`SequenceTranslator-${u}.sdf`,encodeURIComponent(a))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=i.divV(e);for(const t of e)T()(t).addClass("st-structure-bool-button-block");return n}getTableInput(){const t=Object.fromEntries(nt.map((t=>[t,new L(this.inputBase[t],M)]))),e=Object.fromEntries(nt.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,i.choiceInput(`${t.toUpperCase()} direction`,n,["5′ → 3′","3′ → 5′"])]})));nt.forEach(((t,n)=>{e[t].onChanged((()=>{let o="3′ → 5′"===e[t].value;n>0&&(o=!o),this.directionInversion[t]=o,this.onInput.next()}))}));const n=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(nt.map(((t,e)=>[t,n[e]]))),r=Object.fromEntries(nt.map((t=>[t,i.label(o.get(t))]))),s=Object.fromEntries(nt.map((e=>{const n=i.icons.delete((()=>{t[e].inputBase.value=""})),o=i.button(n,(()=>{}));return i.tooltip.bind(o,`Clear ${e.toUpperCase()}`),[e,n]}))),a=nt.map((n=>({label:r[n],textInput:t[n].root,clear:s[n],choiceInput:e[n].root}))),l=i.table(a,(t=>[t.label,t.textInput,t.clear,t.choiceInput]));T()(l).css("margin-top","10px");for(const t of nt){let n=r[t].parentElement;n.classList.add("st-structure-input-form"),T()(n).css("padding-top","3px"),n=e[t].root.parentElement,n.classList.add("st-structure-input-form","st-structure-direction-choice"),n=this.inputBase[t].root.parentElement,n.classList.add("st-structure-text-input-td")}return l}getStrandData(){return Object.fromEntries(nt.map(((t,e)=>{let n=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:n}]})))}getMolfile(t,e,n){return et(t,e,n,this.useChiralInput.value)}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=(0,G.O)(t);console.error(e)}const e=new W(t);await e.drawMolecule(this.moleculeImgDiv,650,150),T()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}const rt="SequenceTranslator",it="SS",st="AS",at=[it,st],lt={[it]:"Sense strand",[st]:"Anti sense"},ct="THREE_PRIME",ut="FIVE_PRIME",dt=[ct,ut],ht={[ct]:3,[ut]:5};function pt(t){return"(o)"===t.slice(-3)}function mt(t){let e=0;for(;e<t.length&&pt(t[e]);)e++;return e===t.length-1?0:e}function gt(t,e){const n=document.createElement("canvas").getContext("2d");return n.font=String(e),2*n.measureText(t).width}function ft(t,e){return pt(t[e])||!y.mc.includes(t[e])?"":t[e]}function At(t){const e=O.al[t].color.match(/\d+/g).map((t=>Number(t)));return.299*e[0]+.587*e[1]+.114*e[2]>186?"#33333":"#ffffff"}function vt(t){return O.al[t].color}const xt={xmlns:"http://www.w3.org/2000/svg",render:function(t,e){const n=document.createElementNS(this.xmlns,"svg");return n.setAttribute("id","mySvg"),n.setAttribute("width",String(t)),n.setAttribute("height",String(e)),n},circle:function(t,e,n,o){const r=document.createElementNS(this.xmlns,"circle");return r.setAttribute("cx",String(t)),r.setAttribute("cy",String(e)),r.setAttribute("r",String(n)),r.setAttribute("fill",o),r},text:function(t,e,n,o,r){const i=document.createElementNS(this.xmlns,"text");return i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("font-size",String(o)),i.setAttribute("font-weight","normal"),i.setAttribute("font-family","Arial"),i.setAttribute("fill",r),i.innerHTML=t,i},star:function(t,e,n){const o=document.createElementNS(this.xmlns,"polygon");return o.setAttribute("points",function(t,e){const n=Math.PI/5;let o="";for(let r=0;r<10;r++){const i=r%2==0?6:3;o+=`${t+Math.cos(r*n+60)*i},${e+Math.sin(r*n+60)*i} `}return o}(t,e)),o.setAttribute("fill",n),o}};function Ct(t,e){const n=O.al[e].symbols.join("");return n.repeat(Math.floor(t/4))+n.slice(0,t%4)}async function bt(t){return await r.dapi.users.current().then((e=>{const[n,o]=function(t){let e=-1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return-1===e?["",""]:t.slice(e+9,t.length-1).split(" ").slice(1)}(t);return e.firstName!==n||e.lastName!==o}))}function wt(t){let e=t.length+1;for(let n=0;n<t.length;n++)if("("===t[n]){e=n;break}return t.slice(0,e-1)}function yt(t,e,n,o,r,i){let s=-1,a=t.replace(/[AUGC]/g,(function(o){s++;const r=O.al,i=(Object.keys(r),r.RNA.symbols.indexOf(o));let a=r[e[s].value].symbols[i];return pt(e[s].value)&&(s<t.length/2&&!pt(e[s+1].value)?a=a+o+"f":s>t.length/2&&!pt(e[s-1].value)&&(a=o+"f"+a)),n[s].value?a+"s":a}));return 3===a.slice(0,5).split("mU").length&&(a="(uu)"+a.slice(4)),3===a.slice(a.length-7).split("mU").length&&(a=a.slice(0,a.length-4)+"(uu)"),o.value+(i?"s":"")+a+r.value}const Et=15,Ot=30,It=17,St="red",Tt="var(--grey-6)",Mt="red",Bt="SS: 5'",Nt="AS: 3'",Lt=Math.max(gt(Bt,It),gt(Nt,It)),Dt=Math.max(gt("3'",It),gt("5'",It)),Ft=0+Lt-5,Vt={TITLE:Et,SS_INDICES:30,SS_CIRCLES:52.5,SS_TEXTS:60,AS_CIRCLES:97.5,AS_TEXTS:105,AS_INDICES:127.5,comment:t=>t?165:127.5,circlesInLegends:t=>t?142.5:90,textLegend:t=>t?147:Vt.AS_CIRCLES-3,svgHeight:t=>t?165:135};function kt(t,e,n,o,r,i,s,a,l,c,u,d){function h(t){return Math.round((t+O)*M/(w.length+O)+6)}function p(t,e){return b+(A-t+e+1)*Ot}function m(t,e,n){return n<10||y.mc.includes(t[e])?-5:-10}n=n.reverse(),r=r.reverse();const g=mt(n),f=mt(o),A=Math.max(n.length-g,o.length-f),v=Math.max(g,f),x=Ot*(A+v),C=Math.max(gt(s,It),gt(c,It)),b=Math.max(gt(a,It),gt(l,It)),w=e?[...new Set(n.concat(o))]:[...new Set(n)],E=e?r.concat(i).includes(!0):r.includes(!0),O=E?1:0,I=g*Ot+p(-.5,0),S=f*Ot+p(-.5,0),T=Math.max(I,S)+C+Ot*v,M=Lt+C+x+b+Dt+Ot,B=xt.render(M,Vt.svgHeight(e));B.append(xt.text(Bt,0,Vt.SS_TEXTS,It,Tt),e?xt.text(Nt,0,Vt.AS_TEXTS,It,Tt):"",xt.text("3'",T,Vt.SS_TEXTS,It,Tt),e?xt.text("5'",T,Vt.AS_TEXTS,It,Tt):"",xt.text(a,Ft,Vt.SS_TEXTS,It,Mt),e?xt.text(l,Ft,Vt.AS_TEXTS,It,Mt):"",xt.text(s,I,Vt.SS_TEXTS,It,Mt),e?xt.text(c,S,Vt.AS_TEXTS,It,Mt):"",xt.text(u,0,Vt.comment(e),14,Tt),E?xt.star(Et,Vt.circlesInLegends(e),St):"",E?xt.text("ps linkage",22,Vt.textLegend(e),14,Tt):"");const N=n.filter((t=>!pt(t))).length;let L=N;for(let t=n.length-1;t>-1;t--){const e=p(t,g)+m(n,n.length-t,N-L);pt(n[t])||L--;const o=!pt(n[t])&&d.includes(n[t])?String(N-L):"";B.append(xt.text(o,e,Vt.SS_INDICES,14,Tt),xt.circle(p(t,g),Vt.SS_CIRCLES,Et,vt(n[t])),xt.text(ft(n,t),e,Vt.SS_TEXTS,It,At(n[t])),r[t]?xt.star(p(t,g)+Et,Vt.SS_TEXTS+5,St):"")}B.append(r[n.length]?xt.star(p(n.length,g)+Et,Vt.SS_TEXTS+5,St):"");const D=o.filter((t=>!pt(t))).length;if(e){let t=D;for(let e=o.length-1;e>-1;e--){pt(o[e])||t--;const n=p(e,f)+m(o,e,t+1),r=!pt(o[e])&&d.includes(o[e])?String(t+1):"";B.append(xt.text(r,n,Vt.AS_INDICES,14,Tt),xt.circle(p(e,f),Vt.AS_CIRCLES,Et,vt(o[e])),xt.text(ft(o,e),p(e,f)+m(o,e,t+1),Vt.AS_TEXTS,It,At(o[e])),i[e]?xt.star(p(e,f)+Et,Vt.AS_TEXTS+5,St):"")}B.append(i[o.length]?xt.star(p(o.length,f)+Et,Vt.AS_TEXTS+5,St):"")}const F=`${t} for ${N}${e?`/${D}`:""}mer`;B.append(xt.text(F,15,Vt.TITLE,It,"black"));for(let t=0;t<w.length;t++)B.append(xt.circle(h(t),Vt.circlesInLegends(e),6,vt(w[t])),xt.text(w[t],h(t)+6+4,Vt.textLegend(e),14,Tt));return B}var Pt=n(803);class Ht{get htmlDivElement(){function t(e){x[e].innerHTML="",C[e]=C[e].concat(Array(v[e]-b[e].length).fill(A)),b[e]=b[e].concat(Array(v[e]-b[e].length).fill(f));let o=0;for(let r=0;r<w[e].value;r++)C[e][r]=i.boolInput("",C[e][r].value,(()=>{s(),n()})),b[e][r]=i.choiceInput("",b[e][r].value,p,(e=>{g.includes(e)||(g.push(e),k.append(i.divText("",{style:{width:"25px"}}),i.boolInput(e,!0,(t=>{if(t)g.includes(e)||g.push(e);else{const t=g.indexOf(e,0);t>-1&&g.splice(t,1)}s()})).root)),t(st),s(),n()})),T()(b[e][r].root).addClass("st-pattern-choice-input"),pt(b[e][r].value)||o++,x[e].append(i.divH([i.div([i.label(pt(b[e][r].value)?"":String(o))],{style:{width:"20px"}}),i.block75([b[e][r].root]),i.div([C[e][r]])],{style:{alignItems:"center"}}))}function e(){Object.values(w).every((t=>t.value<35))?(at.forEach((e=>{w[e].value>v[e]&&(v[e]=w[e].value),t(e)})),s(),at.forEach((t=>{""===I[t].value&&(E[t].value=Ct(w[t].value,f.value))})),n()):i.dialog("Out of range").add(i.divText("Sequence length should be less than "+35..toString()+" due to UI constrains.")).onOK((()=>{Object.values(w).every((t=>t.value=34))})).onCancel((()=>{Object.values(w).every((t=>t.value=34))})).showModal(!1)}function n(){const t=[!0,j.value];at.forEach(((e,n)=>{t[n]&&(B[e].value=yt(E[e].value,b[e],C[e],M[e][ut],M[e][ct],S[e].value))}))}function s(){L.innerHTML="",L.append(i.span([kt(wt(q.value),j.value,b[it].slice(0,w[it].value).map((t=>t.value)),b[st].slice(0,w[st].value).map((t=>t.value)),[S[it].value].concat(C[it].slice(0,w[it].value).map((t=>t.value))),[S[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),M[it][ct].value,M[it][ut].value,M[st][ct].value,M[st][ut].value,$.value,g)]))}async function a(t){const e=o.TaskBarProgressIndicator.create("Loading pattern...");await r.dapi.userDataStorage.get(rt,!1).then((e=>{const n=JSON.parse(e[t]);f.value=function(t){const e={};let n=t[0],o=1;for(let r=0;r<t.length;r++){const i=t[r];null===e[i]?e[i]=1:e[i]++,e[i]>o&&(n=i,o=e[i])}return n}(n.asBases.concat(n.ssBases)),j.value=n.asBases.length>0,q.value=t;let o=["ssBases","asBases"];at.forEach(((t,e)=>{b[t]=[];const r=o[e];for(let e=0;e<n[r].length;e++)b[t].push(i.choiceInput("",n[r][e],p))})),o=["ssPtoLinkages","asPtoLinkages"],at.forEach(((t,e)=>{const r=o[e];S[t].value=n[r][0],C[t]=[];for(let e=1;e<n[r].length;e++)C[t].push(i.boolInput("",n[r][e]))})),o=["ssBases","asBases"],at.forEach(((t,e)=>{w[t].value=n[o[e]].length}));const r=[["ssThreeModification","ssFiveModification"],["asThreeModification","asFiveModification"]];at.forEach(((t,e)=>{dt.forEach(((o,i)=>{M[t][o].value=n[r[e][i]]}))})),$.value=n.comment})),e.close()}async function l(){const t=await async function(){return await r.dapi.users.current().then((t=>" (created by "+t.friendlyName+")"))}();return q.value=q.stringValue.includes("(created by ")?wt(q.value)+t:q.stringValue+t,r.dapi.userDataStorage.postValue(rt,q.value,JSON.stringify({ssBases:b[it].slice(0,w[it].value).map((t=>t.value)),asBases:b[st].slice(0,w[st].value).map((t=>t.value)),ssPtoLinkages:[S[it].value].concat(C[it].slice(0,w[it].value).map((t=>t.value))),asPtoLinkages:[S[st].value].concat(C[st].slice(0,w[st].value).map((t=>t.value))),ssThreeModification:M[it][ct].value,ssFiveModification:M[it][ut].value,asThreeModification:M[st][ct].value,asFiveModification:M[st][ut].value,comment:$.value}),!1).then((()=>r.shell.info("Pattern '"+q.value+"' was successfully uploaded!")))}async function c(){r.dapi.userDataStorage.get(rt,!1).then((async t=>{const e=[],n=[];for(const o of Object.keys(t))await bt(o)?n.push(o):e.push(o);let o=i.choiceInput("Load pattern","",e,(t=>a(t)));const s=(await r.dapi.users.current()).friendlyName,l=i.choiceInput("",s,[s,"Other users"],(t=>{const u=t===s?e:n;o=i.choiceInput("Load pattern","",u,(t=>a(t))),o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="120px",o.input.style.marginLeft="12px",o.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await bt(q.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}));l.input.style.maxWidth="142px",o.root.append(l.input),o.root.append(o.input),o.input.style.maxWidth="100px",o.setTooltip("Apply Existing Pattern"),F.innerHTML="",F.append(o.root),o.root.append(i.div([i.button(i.iconFA("trash-alt",(()=>{})),(async()=>{null===o.value?r.shell.warning("Choose pattern to delete"):await bt(q.value)?r.shell.warning("Cannot delete pattern, created by other user"):await r.dapi.userDataStorage.remove(rt,o.value,!1).then((()=>r.shell.info("Pattern '"+o.value+"' deleted"))),await c()}))],"ui-input-options"))}))}async function u(){await r.dapi.userDataStorage.get(rt,!1).then((t=>{if(Object.keys(t).includes(q.value)){const t=i.dialog("Pattern already exists");T()(t.getButton("OK")).hide(),t.add(i.divText("Pattern name '"+q.value+"' already exists.")).add(i.divText("Replace pattern?")).addButton("YES",(async()=>{await r.dapi.userDataStorage.remove(rt,q.value,!1).then((()=>l())),t.close()})).show()}else l()})),await c()}function d(t,e){const n=function(t){const e=H.value.getCol(t);let n=!0;for(let t=1;t<e.length;t++)if(e.get(t-1).length!==e.get(t).length&&0!==e.get(t).length){n=!1;break}if(!n){const n=i.dialog("Sequences lengths mismatch");T()(n.getButton("OK")).hide(),n.add(i.divText("The sequence length should match the number of Raw sequences in the input file")).add(i.divText("'ADD COLUMN' to see sequences lengths")).addButton("ADD COLUMN",(()=>{H.value.columns.addNewInt("Sequences lengths in "+t).init((t=>e.get(t).length)),r.shell.info("Column with lengths added to '"+H.value.name+"'"),n.close(),r.shell.v=r.shell.getTableView(H.value.name)})).show()}return e.get(0).length!==w[it].value&&i.dialog("Length was updated by value to from imported file").add(i.divText("Latest modifications may not take effect during translation")).onOK((()=>r.shell.info("Lengths changed"))).show(),n}(t),o=H.value.getCol(t).get(0);n&&o.length!==w[e].value&&(w[e].value=H.value.getCol(t).get(0).length),E[e].value=o}function h(t){const e=H.value.getCol(t);if(e.type!==o.TYPE.INT)r.shell.error("Column should contain integers only");else if(e.categories.filter((t=>""!==t)).length<e.toList().filter((t=>""!==t)).length){const t=(n=e.getRawData(),Array.from(new Set(n)).filter((t=>n.indexOf(t)!==n.lastIndexOf(t))));i.dialog("Non-unique IDs").add(i.divText("Press 'OK' to select rows with non-unique values")).onOK((()=>{H.value.selection.init((n=>t.indexOf(e.get(n))>-1)),r.shell.v=r.shell.getTableView(H.value.name),r.shell.info("Rows are selected in table '"+H.value.name+"'")})).show()}var n}const p=Object.keys(O.al),m=p[0],g=[m],f=i.choiceInput("Sequence basis",m,p,(t=>{var e;e=t,at.forEach((t=>{for(let n=0;n<b[t].length;n++)b[t][n].value=e})),s(),n()})),A=i.boolInput("Fully PTO",!0,(t=>{var e;at.forEach((e=>{S[e].value=t})),e=t,at.forEach((t=>{for(let n=0;n<C[t].length;n++)C[t][n].value=e})),s(),n()}));A.captionLabel.classList.add("ui-label-right"),A.captionLabel.style.textAlign="left",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.maxWidth="100px",A.captionLabel.style.minWidth="40px",A.captionLabel.style.width="auto";const v=Object.fromEntries(at.map((t=>[t,23]))),x=Object.fromEntries(at.map((t=>[t,i.div([])]))),C=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.boolInput("",!0))]))),b=Object.fromEntries(at.map((t=>[t,Array(23).fill(i.choiceInput("",m,p))]))),w=Object.fromEntries(at.map((t=>{const n=i.intInput(`${lt[t]} length`,23,(()=>e()));return n.setTooltip(`Length of ${lt[t].toLowerCase()}, including overhangs`),[t,n]}))),y=Object.fromEntries(at.map((t=>[t,""]))),E=Object.fromEntries(at.map((t=>[t,i.textInput("",Ct(w[t].value,f.value))]))),I=Object.fromEntries(at.map((t=>{const e=i.choiceInput(`${lt[t]} column`,"",[],(e=>{d(e,t),y[t]=e}));return[t,e]}))),S=Object.fromEntries(at.map((t=>{const e=i.boolInput(`First ${t} PTO`,A.value,(()=>s()));return e.setTooltip(`ps linkage before first nucleotide of ${lt[t].toLowerCase()}`),e.captionLabel.classList.add("ui-label-right"),e.captionLabel.style.textAlign="left",e.captionLabel.style.maxWidth="100px",e.captionLabel.style.minWidth="40px",e.captionLabel.style.width="auto",[t,e]}))),M=Object.fromEntries(at.map((t=>{const e=Object.fromEntries(dt.map((e=>{const o=i.stringInput(`${t} ${ht[e]}' Modification`,"",(()=>{s(),n()}));return o.setTooltip(`Additional ${t} ${ht[e]}' Modification`),[e,o]})));return[t,e]}))),B=Object.fromEntries(at.map((t=>{const e=i.textInput("",yt(E[t].value,b[t],C[t],M[t][ct],M[t][ut],S[t].value));return e.input.style.minWidth="none",e.input.style.flexGrow="1",T()(e.root.lastChild).css("height","auto"),[t,e]}))),N=Object.fromEntries(at.map((t=>[t,i.block([i.h1(`${lt[t]}`),i.divH([i.div([i.divText("#")],{style:{width:"20px"}}),i.block75([i.divText("Modification")]),i.div([i.divText("PTO")])]),x[t]],{style:{paddingTop:"12px"}})])));at.forEach((t=>{E[t].input.style.resize="none",B[t].input.style.resize="none",E[t].input.style.minWidth="none",E[t].input.style.flexGrow="1",B[t].input.style.minWidth="none",B[t].input.style.flexGrow="1";let e=i.div([i.button(i.iconFA("copy",(()=>{})),(()=>{navigator.clipboard.writeText(B[t].value).then((()=>r.shell.info("Sequence was copied to clipboard")))}))],"ui-input-options");e.style.height="inherit",B[t].root.append(e)}));const L=i.div([]),D=i.div([],"ui-form ui-form-wide"),F=i.div([]),V=i.form([]),k=i.divH([i.boolInput(m,!0,(t=>{if(t)g.includes(m)||g.push(m);else{const t=g.indexOf(m,0);t>-1&&g.splice(t,1)}s(),n()})).root]),P=i.div([w[st].root]),H=function(t){const e=i.tableInput("Tables",t[0],t,(()=>{const t=e.value;if(null===t)return void console.warn("Table is null");const n=t.name;if(!r.shell.tableNames.includes(n)){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}const o=t.columns.names();at.forEach((t=>{const e=o[0];d(e,t),y[t]=e;const n=i.choiceInput(`${lt[t]} column`,e,o,(e=>{d(e,t),y[t]=e,console.log(`clicked ${t} var:`,y[t])}));T()(I[t].root).replaceWith(n.root)})),_=o[0];const s=i.choiceInput("ID column",o[0],o,(t=>{h(t),_=t}));T()(R.root).replaceWith(s.root)}));return e}([]);let _="";const R=i.choiceInput("ID column","",[],(t=>{h(t),_=t}));c();const j=i.boolInput("Anti sense strand",!0,(t=>{N[st].hidden=!t,I[st].root.hidden=!t,P.hidden=!t,V.hidden=!t,D.hidden=!t,S[st].root.hidden=!t,s()}));j.setTooltip("Create antisense strand sections on SVG and table to the right");const q=i.textInput("Save as","Pattern name",(()=>s()));q.setTooltip("Name Of New Pattern"),dt.forEach((t=>{V.append(M[st][t].root)}));const $=i.textInput("Comment","",(()=>s())),G=i.bigButton("Save",(()=>{if(""!==q.value)u().then((()=>r.shell.info("Pattern saved")));else{const t=i.stringInput("Enter name","");i.dialog("Pattern Name").add(t.root).onOK((()=>{q.value=t.value,u().then((()=>r.shell.info("Pattern saved")))})).show()}}));q.addOptions(G);const U=i.bigButton("Convert",(()=>{const t=[!0,j.value];if(console.log("strand vars:",Object.values(y)),at.some(((e,n)=>t[n]&&""===y[e])))r.shell.info("Please select table and columns on which to apply pattern");else if(at.some((t=>w[t].value!==E[t].value.length))){const t=i.dialog("Length Mismatch");T()(t.getButton("OK")).hide(),t.add(i.divText("Length of sequences in columns doesn't match entered length. Update length value?")).addButton("YES",(()=>{at.forEach((t=>{w[t].value=H.value.getCol(I[t].value).getString(0).length})),t.close()})).show()}else{""!==_&&function(t,e,n){const o="ID "+n,i=r.shell.table(t).columns;i.contains(o)&&i.remove(o);const s=i.byName(e);i.addNewString(o).init((t=>""===s.getString(t)?"":s.get(t)+"_"+n))}(H.value.name,_,wt(q.value));const t=[!0,j.value];at.forEach(((e,n)=>{t[n]&&function(t,e,n,o,i,s,a){const l="Axolabs "+e,c=r.shell.table(t).columns;c.contains(l)&&c.remove(l);const u=c.byName(e);c.addNewString(l).init((t=>""===u.getString(t)?"":yt(u.getString(t),n,o,i,s,a)))}(H.value.name,y[e],b[e],C[e],M[e][ut],M[e][ct],S[e].value)})),r.shell.v=r.shell.getTableView(H.value.name),r.shell.info((j.value?"Columns were":"Column was")+" added to table '"+H.value.name+"'"),n()}}));D.append(E[st].root),D.append(B[st].root),e(),i.div([i.h1("Conversion preview"),E[it].root,B[it].root,D],"ui-form ui-form-wide"),i.block50([i.h1("Convert options"),H.root,I[it].root,I[st].root,R.root,i.buttonsInput([U])]).classList.add("ui-form");const W=i.link("Download",(()=>Pt.saveSvgAsPng(document.getElementById("mySvg"),q.value,{backgroundColor:"white"})),"Download pattern as PNG image",""),Y=i.link("Edit pattern",(()=>{i.dialog("Edit pattern").add(i.divV([i.h1("PTO"),i.divH([A.root,S[it].root,S[st].root],{style:{gap:"12px"}})])).add(i.divH([N[it],N[st]],{style:{gap:"24px"}})).onOK((()=>{r.shell.info("Saved")})).show()}),"Edit pattern","");return w[it].addCaption("Length"),i.splitH([i.box(i.div([i.h1("Pattern"),j.root,w[it],w[st],f.root,$.root,F,q.root,i.h1("Convert"),H.root,I[it],I[st],R.root,i.buttonsInput([U])],"ui-form"),{style:{maxWidth:"450px"}}),i.panel([L,k,i.divH([W,Y],{style:{gap:"12px",marginTop:"12px"}}),i.divH([i.divV([i.h1("Sense strand"),E[it].root,B[it].root],"ui-block"),i.divV([i.h1("Anti sense"),E[st],B[st]],"ui-block")],{style:{gap:"24px",marginTop:"24px"}}),i.h1("Additional modifications"),i.form([M[it][ut],M[it][ct]]),V],{style:{overflowX:"scroll",padding:"12px 24px"}})],{},!0)}}async function _t(t){try{const e={overflowX:"scroll"},n=i.div([],{style:e}),o=(0,J.$U)(t),s=.7*T()(window).height(),a=Math.max(...o.x)-Math.min(...o.x),l=Math.max(...o.y)-Math.min(...o.y),c=s/l,u=c*a,d=c*l,h=i.canvas(u*window.devicePixelRatio,d*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${d}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),i.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=(0,G.O)(t);console.error(e)}}class Rt{static async view(){const t=E.A.getInstance().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 _t(e)}))}}class jt{appName;parentAppName;constructor(t,e){this.appName=t,this.parentAppName=e}async createAppLayout(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`);let e=r.shell.v?.root;e&&i.setUpdateIndicator(e,!0),await(0,w.Y3)((async()=>{await this.addView()}),(()=>t.close())),e&&i.setUpdateIndicator(e,!1)}}class qt extends jt{constructor(t){super(t),this.view=o.View.create(),this.setupView()}view;async addView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;this.view.path=`/apps/${pe.name}/${t.replace(/\s/g,"")}/`,r.shell.addView(this.view)}async initView(){const t=await this.getHtml();this.view.append(t)}setupView(){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}}class $t extends jt{constructor(t){super("Oligo Toolkit"),this.externalViewFactories=t;const e=this.getViewFactories();this.multiView=new o.MultiView({viewFactories:e})}multiView;externalViewFactories;getViewFactories(){function t(t){const e=new t(o.View.create());return e.initView(),()=>e.getView()}let e={TRANSLATOR:t(Wt),PATTERN:t(Yt),STRUCTURE:t(zt)};return this.externalViewFactories&&(e=Object.assign({},e,this.externalViewFactories)),e}getPath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${pe.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getPath()}async addView(){this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),r.shell.addView(this.multiView)}}class Gt extends qt{constructor(t,e){super(t),this.layout=e}layout;getHtml(){return Promise.resolve(this.layout)}}class Ut{constructor(){}static getUI(t){switch(t){case"Oligo Translator":return new Wt;case"Oligo Pattern":return new Yt;case"Oligo Structure":return new zt;default:throw new Error(`Unknown app name: ${t}`)}}}class Wt extends qt{constructor(){super("Oligo Translator");const t=i.iconFA("book",Rt.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel]),this.ui=new Z}topPanel;ui;getHtml(){return this.ui.getHtmlElement()}}class Yt extends qt{constructor(){super("Oligo Pattern"),this.ui=new Ht}ui;getHtml(){return Promise.resolve(this.ui.htmlDivElement)}}class zt extends qt{constructor(){super("Oligo Structure"),this.ui=new ot}ui;getHtml(){return this.ui.getHtmlDivElement()}}var Xt,Zt,Kt=n(895);wu;class Qt{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(Zt=Xt||(Xt={})).FASTA="fasta",Zt.SEPARATOR="separator",Zt.HELM="helm";const Jt=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"])}}};new Qt("PT",Jt.fasta.peptide,.5),new Qt("DNA",Jt.fasta.dna,.55),new Qt("RNA",Jt.fasta.rna,.55);class te extends Float32Array{}class ee{static makePalette(t,e=!1,n=ee){const o={};return t.forEach((t=>{const n=t[0],r=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[r][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}ee.undefinedColor="rgb(100,100,100)",ee.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 ne extends ee{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,ne)),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,ne)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new ne({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 ne.aaSynonyms?ne.aaSynonyms[t]:t;return super.get(e)}}ne.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class oe{static getPalette(t="grok"){switch(t){case"grok":return ne.GrokGroups;case"lesk":return ne.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",o="";for(const r of t)"("==r?e++:")"==r?e--:e?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[o,r]=this.getInnerOuter(t);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,r,1]:[this.undefinedColor,o,r,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,r,2]:[this.undefinedColor,o,r,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,r,3]:[this.undefinedColor,o,r,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,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}oe.SemType="Aminoacids",oe.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",oe.undefinedColor="rgb(100,100,100)",oe.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"},oe.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"},oe.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(*)*"},oe.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 re{}re.SemType="Nucleotides",re.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",re.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class ie{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 se{}class ae extends se{static buildPalette(){return[].concat(...Object.values(ee.colourPalette))}get(t){const e=ie.hashCode(t)%ae.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=o.Color.fromHtml(t),n=o.Color.g(e),r=o.Color.r(e),i=o.Color.b(e),s=Math.sqrt(Math.pow(0-r,2)+Math.pow(0-n,2)+Math.pow(0-i,2));return s>210?`rgb(${r/s*210},${n/s*210},${i/s*210})`:o.Color.toRgb(e)}(ae.palette[e])}}ae.palette=ae.buildPalette();new Uint32Array(65536);var le,ce;(ce=le||(le={})).HAMMING="Hamming",ce.LEVENSHTEIN="Levenshtein",ce.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",le.HAMMING,le.LEVENSHTEIN,le.NEEDLEMANN_WUNSCH,new class{constructor(){this.uhTemp=`units-handler.${o.SEMTYPE.MACROMOLECULE}`}},Xt.FASTA,Xt.SEPARATOR,Xt.HELM;var ue=n(61);function de(){const t=i.textInput("","");return{coloredInput:new L(t,M),codes:O.BF}}class he extends o.Package{_monomerLib;get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}async initMonomerLib(){if(void 0!==this._monomerLib)return;const t=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");await(0,w.Y3)((async()=>{const t=await async function(){const t=o.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()}();this._monomerLib=await t.readLibrary(Kt.BX,Kt.a_)}),(()=>t.close()))}}const pe=new he;async function me(t){await xe();const e=Ut.getUI(t);await e.createAppLayout()}async function ge(){await xe();const t=await async function(){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:de()}},e={};for(const[n,o]of Object.entries(t)){let t;try{t=await r.functions.call(n,o.parameters);const i=new Gt(o.tabName,t);i.initView(),e[o.tabName]=()=>i.getView()}catch(t){console.warn(`Plugin ${n} not loaded, reason:`,t);continue}}return e}();if(!t)throw new Error("External app view factories not loaded");const e=new $t(t);await e.createAppLayout()}async function fe(){await me("Oligo Translator")}async function Ae(){await me("Oligo Pattern")}async function ve(){await me("Oligo Structure")}async function xe(){await(0,O.VO)(),await pe.initMonomerLib()}function Ce(){const t=E.A.getInstance().getCodesToWeightsMap();return Object.fromEntries(t)}function be(t){const e=new b.b(t),n=new I(t).getFormat();return null!==n&&e.isValidSequence(n)}function we(t,e){return new k(t,e,"GCRS").convert()}function ye(t){return(0,J.v5)(t,!0)}async function Ee(){await async function(){await(0,w.Y3)((async()=>fe()))}()}async function Oe(){await async function(){await(0,w.Y3)((async()=>{async function t(t,n,o){await(0,ue.gw)(3e3);const r=document.querySelectorAll(".st-pattern-choice-input > select");e=r.length;const i=r[o(n)];i.value=t;const s=new Event("input");i.dispatchEvent(s)}let e;await Ae(),["DNA","invAb","Z-New"].forEach((async(e,n)=>{t(e,n,(t=>2*t))})),["2'-O-Methyl","2'-Fluoro","2'-O-MOE"].forEach((async(n,o)=>{t(n,o,(t=>e-2-2*t))}))}))}()}async function Ie(){await async function(){await(0,w.Y3)((async()=>{await ve(),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,ue.gw)(500);const n=document.querySelectorAll(".colored-text-input > textarea")[t];n.value=e;const o=new Event("input");n.dispatchEvent(o)}(e,t)}))}))}()}async function Se(t,e,n){return await xe(),new X.I(t,e).convertTo(n)}},713:(t,e,n)=>{n.d(e,{AU:()=>o,wm:()=>r});const o="Copied",r="Copy sequence"},511:(t,e,n)=>{n.d(e,{T:()=>o});const o="Afcgacsu"},976:t=>{t.exports=DG},469:t=>{t.exports=grok}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,n),i.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 o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},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.nc=void 0;var o=n(593);sequencetranslator=o})();
2
2
  //# sourceMappingURL=package.js.map