@datagrok/helm 3.0.1 → 3.0.2
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 +12 -0
- package/CLAUDE.md +78 -92
- package/dist/489.js +2 -0
- package/dist/489.js.map +1 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/samples/helm-showcase.csv +7 -9
- package/package.json +10 -7
- package/src/helm-helper.ts +3 -0
- package/src/package-api.ts +1 -0
- package/src/package-test.ts +0 -4
- package/src/package.g.ts +2 -0
- package/src/package.ts +4 -1
- package/test-console-output-1.log +362 -0
- package/test-playwright-report.json +118 -0
- package/test-record-1.mp4 +0 -0
- package/test-report-playwright.csv +1 -0
- package/tsconfig.json +2 -1
- package/dist/137.js +0 -2
- package/dist/137.js.map +0 -1
- package/dist/323.js +0 -2
- package/dist/323.js.map +0 -1
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/657.js +0 -2
- package/dist/657.js.map +0 -1
- package/dist/782.js +0 -2
- package/dist/782.js.map +0 -1
- package/dist/884.js +0 -2
- package/dist/884.js.map +0 -1
- package/dist/94.js +0 -2
- package/dist/94.js.map +0 -1
- package/dist/libraries_bio_src_monomer-works_seq-to-molfile-worker_ts.js +0 -16420
- package/dist/libraries_bio_src_monomer-works_seq-to-molfile-worker_ts.js.map +0 -1
- package/dist/package-dojo.js +0 -2
- package/dist/package-dojo.js.map +0 -1
- package/dist/vendors-HELM_node_modules_lru-cache_dist_esm_index_js.js +0 -1560
- package/dist/vendors-HELM_node_modules_lru-cache_dist_esm_index_js.js.map +0 -1
package/dist/package-test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var helm_test;(()=>{var t={982(t,e,i){var s;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function i(t,i,s,n,r){for(var o,l,a,c,h,d,u,p,f,g,m,y,b;r>=64;){for(o=i[0],l=i[1],a=i[2],c=i[3],h=i[4],d=i[5],u=i[6],p=i[7],g=0;g<16;g++)m=n+4*g,t[g]=(255&s[m])<<24|(255&s[m+1])<<16|(255&s[m+2])<<8|255&s[m+3];for(g=16;g<64;g++)y=((f=t[g-2])>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,b=((f=t[g-15])>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,t[g]=(y+t[g-7]|0)+(b+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&u)|0)+(p+(e[g]+t[g]|0)|0)|0,b=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&l^o&a^l&a)|0,p=u,u=d,d=h,h=c+y|0,c=a,a=l,l=o,o=y+b|0;i[0]+=o,i[1]+=l,i[2]+=a,i[3]+=c,i[4]+=h,i[5]+=d,i[6]+=u,i[7]+=p,n+=64,r-=64}return n}var s=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var s=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[s++],e--;64===this.bufferLength&&(i(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(s=i(this.temp,this.state,t,s,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[s++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,s=this.bufferLength,n=e/536870912|0,r=e<<3,o=e%64<56?64:128;this.buffer[s]=128;for(var l=s+1;l<o-8;l++)this.buffer[l]=0;this.buffer[o-8]=n>>>24&255,this.buffer[o-7]=n>>>16&255,this.buffer[o-6]=n>>>8&255,this.buffer[o-5]=n>>>0&255,this.buffer[o-4]=r>>>24&255,this.buffer[o-3]=r>>>16&255,this.buffer[o-2]=r>>>8&255,this.buffer[o-1]=r>>>0&255,i(this.temp,this.state,this.buffer,0,o),this.finished=!0}for(l=0;l<8;l++)t[4*l+0]=this.state[l]>>>24&255,t[4*l+1]=this.state[l]>>>16&255,t[4*l+2]=this.state[l]>>>8&255,t[4*l+3]=this.state[l]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var i=0;i<this.state.length;i++)this.state[i]=t[i];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=s;var n=function(){function t(t){this.inner=new s,this.outer=new s,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new s).update(t).finish(e).clean();else for(var i=0;i<t.length;i++)e[i]=t[i];for(i=0;i<e.length;i++)e[i]^=54;for(this.inner.update(e),i=0;i<e.length;i++)e[i]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),i=0;i<e.length;i++)e[i]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function r(t){var e=(new s).update(t),i=e.digest();return e.clean(),i}function o(t,e){var i=new n(t).update(e),s=i.digest();return i.clean(),s}function l(t,e,i,s){var n=s[0];if(0===n)throw new Error("hkdf: cannot expand more");e.reset(),n>1&&e.update(t),i&&e.update(i),e.update(s),e.finish(t),s[0]++}t.HMAC=n,t.hash=r,t.default=r,t.hmac=o;var a=new Uint8Array(t.digestLength);t.hkdf=function(t,e,i,s){void 0===e&&(e=a),void 0===s&&(s=32);for(var r=new Uint8Array([1]),c=o(e,t),h=new n(c),d=new Uint8Array(h.digestLength),u=d.length,p=new Uint8Array(s),f=0;f<s;f++)u===d.length&&(l(d,h,i,r),u=0),p[f]=d[u++];return h.clean(),d.fill(0),r.fill(0),p},t.pbkdf2=function(t,e,i,s){for(var r=new n(t),o=r.digestLength,l=new Uint8Array(4),a=new Uint8Array(o),c=new Uint8Array(o),h=new Uint8Array(s),d=0;d*o<s;d++){var u=d+1;l[0]=u>>>24&255,l[1]=u>>>16&255,l[2]=u>>>8&255,l[3]=u>>>0&255,r.reset(),r.update(e),r.update(l),r.finish(c);for(var p=0;p<o;p++)a[p]=c[p];for(p=2;p<=i;p++){r.reset(),r.update(c).finish(c);for(var f=0;f<o;f++)a[f]^=c[f]}for(p=0;p<o&&d*o+p<s;p++)h[d*o+p]=a[p]}for(d=0;d<o;d++)a[d]=c[d]=0;for(d=0;d<4;d++)l[d]=0;return r.clean(),h}}(e);var n=e.default;for(var r in e)n[r]=e[r];"object"==typeof t.exports?t.exports=n:void 0===(s=function(){return n}.call(e,i,e,t))||(t.exports=s)}()}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{"use strict";i.r(s),i.d(s,{_package:()=>Ti,initAutoTests:()=>Ai,test:()=>xi,tests:()=>d});const t=DG;i(982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var n=function(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function l(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,l)}a((s=s.apply(t,e||[])).next())})};const r=3e4,o=108e5,l=console.log.bind(console),a=console.info.bind(console),c=console.warn.bind(console),h=console.error.bind(console),d={},u="Auto Tests",p="Demo",f="Detectors",g="Core",m={};let y;var b;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${e??"Value"} not defined`)}}(b||(b={}));class _{constructor(t,e,i){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,this.closeAll=!0,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==i&&(this.returnOnFail=i)}}class C{constructor(t,e,i,s){var o;this.category=t,this.name=e,null!=s||(s={}),null!==(o=s.timeout)&&void 0!==o||(s.timeout=r),this.options=s,this.test=()=>n(this,void 0,void 0,function*(){return new Promise((t,e)=>n(this,void 0,void 0,function*(){var s;let n="";try{DG.Test.isInDebug;let t=yield i();try{n=null!==(s=null==t?void 0:t.toString())&&void 0!==s?s:""}catch(t){n="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(n)}))})}}function v(t,e,i,s=0,r="timeout"){return n(this,void 0,void 0,function*(){return new Promise((n,o)=>{const l=t.subscribe(t=>{try{e(t),n("OK")}catch(t){o(t)}finally{l.unsubscribe(),clearTimeout(a)}}),a=setTimeout(()=>{l.unsubscribe(),o(r)},s);i()})})}function w(t,e,i){null==d[y]&&(d[y]={}),null==d[y].tests&&(d[y].tests=[]),d[y].tests.push(new C(y,t,e,i))}function T(t,e=!0,i){if(i=i?`${i}, `:"",t!==e)throw new Error(`${i}Expected "${e}", got "${t}"`)}function x(t,e,i=.001,s){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const n=Math.abs(t-e)<i;if(T(n,!0,`${null!=s?s:""} (tolerance = ${i}; a = ${t}, e = ${e})`),!n)throw new Error(`Expected ${e}, got ${t} (tolerance = ${i})`)}function A(t,e){for(const[i,s]of Object.entries(e)){if(!t.hasOwnProperty(i))throw new Error(`Expected property "${i}" not found`);const e=t[i];if(e instanceof Array&&s instanceof Array)E(e,s);else if(e instanceof Object&&s instanceof Object)A(e,s);else if(Number.isFinite(e)&&Number.isFinite(s))x(e,s);else if(e!=s)throw new Error(`Expected (${s}) for key '${i}', got (${e})`)}}function E(t,e){const i=t.length,s=e.length;if(i!=s)throw new Error(`Arrays are of different length: actual array length is ${i} and expected array length is ${s}`);for(let s=0;s<i;s++)if(t[s]instanceof Array&&e[s]instanceof Array)E(t[s],e[s]);else if(t[s]instanceof Object&&e[s]instanceof Object)A(t[s],e[s]);else if(t[s]!=e[s])throw new Error(`Expected ${e[s]} at position ${s}, got ${t[s]}`)}function P(t,e,i){var s;y=t,e(),d[y]&&(d[y].clear=null===(s=null==i?void 0:i.clear)||void 0===s||s,d[y].timeout=null==i?void 0:i.timeout,d[y].benchmarks=null==i?void 0:i.benchmarks,d[y].stressTests=null==i?void 0:i.stressTests,d[y].owner=null==i?void 0:i.owner)}function k(t){null==d[y]&&(d[y]={}),d[y].before=t}function S(t){null==d[y]&&(d[y]={}),d[y].after=t}function I(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function M(t,i){var s,l,a,c,h,y,b,_,v,w;return n(this,void 0,void 0,function*(){const x=t.id;if(m[x])return;const A=i?i.tests:d;if("DevTools"===t.name||i&&"DevTools"===i._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let i=null!==(s=e.pop())&&void 0!==s?s:t.name,n=e.length?g+": "+e.join(": "):g,o=i.split(" | ");i=o[o.length-1],o.unshift(n),o.pop(),n=o.join(": "),void 0===A[n]&&(A[n]={tests:[],clear:!0}),A[n].tests.push(new C(n,i,t.test,{isAggregated:!1,timeout:null!==(a=null===(l=t.options)||void 0===l?void 0:l.timeout)&&void 0!==a?a:r,skipReason:null===(c=t.options)||void 0===c?void 0:c.skipReason,owner:null===(h=t.options)||void 0===h?void 0:h.owner,benchmark:null!==(b=null===(y=t.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const E=[],P=[],k=[],S=yield grok.dapi.functions.filter(`package.id = "${x}"`).list(),$=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const i of S){const s=i.options.test,l=i.options.demoPath;if(s&&Array.isArray(s)&&s.length)for(let t=0;t<s.length;t++){const e=s[t].matchAll($),l={};Array.from(e).forEach(t=>{t[0].startsWith("skip")?l.skip=t[1]:t[0].startsWith("wait")?l.wait=parseInt(t[2]):t[0].startsWith("cat")?l.cat=t[3]:t[0].startsWith("timeout")&&(l.timeout=parseInt(t[4]))});const a=new C(null!==(_=l.cat)&&void 0!==_?_:u,1===s.length?i.name:`${i.name} ${t+1}`,()=>n(this,void 0,void 0,function*(){const e=yield grok.functions.eval(I(s[t],i));if(l.wait&&(yield R(l.wait)),"boolean"==typeof e&&!e)throw`Failed: ${s[t]}, expected true, got ${e}`}),{skipReason:l.skip,timeout:DG.Test.isInBenchmark?null!==(v=l.benchmarkTimeout)&&void 0!==v?v:o:null!==(w=l.timeout)&&void 0!==w?w:r});if(l.cat){const t=l.cat;void 0===A[t]&&(A[t]={tests:[],clear:!0}),A[t].tests||(A[t].tests=[]),A[t].tests.push(a)}else E.push(a)}if(l){const t=i.options.demoWait?parseInt(i.options.demoWait):void 0,e=new C(p,i.friendlyName,()=>n(this,void 0,void 0,function*(){yield R(300),grok.shell.clearLastError(),yield i.apply(),yield R(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}),{skipReason:i.options.demoSkip});P.push(e)}if(i.hasTag("semTypeDetector")){let s=e;i.options.testData&&(s=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${i.options.testData}`));const r=new C(f,i.friendlyName,()=>n(this,void 0,void 0,function*(){const e=[];console.log(`System:AppData/${t.nqName}/${i.options.testData}`);for(const t of s.clone().columns){const s=yield i.apply([t]);e.push(s||t.semType)}const n=e.filter(t=>t);T(n.length,1),i.options.testDataColumnName&&T(n[0],i.options.testDataColumnName)}),{skipReason:i.options.skipTest});k.push(r)}}m[x]=!0,E.length>0&&(A[u]={tests:E,clear:!0}),P.length>0&&(A[p]={tests:P,clear:!0}),k.length>0&&(A[f]={tests:k,clear:!1})})}function N(t){return n(this,void 0,void 0,function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`})}function L(t,e,i,s,o,a){var c,d,u,p,f,g,m,y,b,_,C,v,w,T;return n(this,void 0,void 0,function*(){let n;i.length=0;const x=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let A=(null===(c=t.options)||void 0===c?void 0:c.skipReason)||x,E=x?"skipped":null===(d=t.options)||void 0===d?void 0:d.skipReason;if(DG.Test.isInBenchmark&&!(null===(u=t.options)||void 0===u?void 0:u.benchmark))return void l(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);A&&!DG.Test.isInBenchmark&&l(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),A||l(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const P=Date.now(),k=new Date(P).toISOString();try{if(A)n={name:t.name,owner:null!==(f=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==f?f:"",category:t.category,logs:"",date:k,success:!0,result:E,ms:0,skipped:!0,package:null!=o?o:"",flaking:DG.Test.isReproducing};else{let e=null!=s?s:r;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),n={name:t.name,owner:null!==(m=null===(g=t.options)||void 0===g?void 0:g.owner)&&void 0!==m?m:"",category:t.category,logs:"",date:k,success:!0,result:null!==(y=(yield D(t.test,e)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=o?o:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){h(e),n={name:t.name,owner:null!==(_=null===(b=t.options)||void 0===b?void 0:b.owner)&&void 0!==_?_:"",category:t.category,logs:"",date:k,success:!1,result:yield N(e),ms:0,skipped:!1,package:null!=o?o:"",flaking:!1}}if((null===(C=t.options)||void 0===C?void 0:C.isAggregated)&&n.result.constructor===DG.DataFrame){const t=n.result.col("success");if(t&&(n.success=t.stats.sum===t.length),!a){const t=n.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),n.result=t}n.result=n.result.toCsv()}if(n.logs=i.join("\n"),n.ms=Date.now()-P,A||l(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${n.success?"success":"error"}}} for ${n.ms} ms`),n.success||l(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${n.result}`),n.category=t.category,n.name=t.name,n.owner=null!==(w=null===(v=t.options)||void 0===v?void 0:v.owner)&&void 0!==w?w:"",!x){let e={success:n.success,result:n.result,ms:n.ms,date:n.date,skipped:n.skipped,category:t.category,name:t.name,logs:n.logs,owner:n.owner,flaking:DG.Test.isReproducing&&n.success,package:n.package};if(n.result.constructor==Object){const t=Object.keys(n.result).reduce((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:n.result[e]}),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(T=e.result)||void 0===T?void 0:T.toJson())||""),yield grok.shell.reportTest("package",e)}return n})}function O(t){const e=t.slice();return e.sort(()=>Math.random()-.5),e}function R(t){return n(this,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,t))})}function F(t,e="Timeout exceeded",i=500,s=50){return n(this,void 0,void 0,function*(){return new Promise((n,r)=>{setTimeout(()=>{clearInterval(o),r(new Error(e))},i);const o=setInterval(()=>{t()&&(clearInterval(o),n(null))},s)})})}function D(t,e,i="EXECUTION TIMEOUT"){return n(this,void 0,void 0,function*(){let s=null;const n=new Promise((t,n)=>{s=setTimeout(()=>{n(i)},e)});try{return yield Promise.race([t(),n])}finally{s&&clearTimeout(s)}})}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]),P("_first",()=>{w("_first",async()=>{})});const H=/\{(\*\.)+/g,B=/\.(\*\.)+/g,G=/(\.\*)+\}/g;function V(t){const e=[];if(null!=(t=Y(t,"$")[0])&&""!==t){const i=Y(t,"|");for(let s=0;s<i.length;++s){let n=(t=z(i[s]).str).indexOf("{");n=(t=t.substring(n+1)).indexOf("}");const r=Y(t=t.substring(0,n),".");for(const t of r)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const i=U(t,1,"[","]"),s=t.substring(1,i);e.push(s);const n=t.substring(i+1);r.push(n)}else if(t.includes("[")&&t.endsWith("]")){const i=W(t,t.length-2,"[","]"),s=t.substring(i+1,t.length-1);e.push(s);const n=t.substring(0,i);r.push(n)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),i=t.substring(t.lastIndexOf(")")+1),s=[e,t.substring(e.length+1,t.length-i.length-1),i];for(const t of s)r.push(t)}else e.push(t)}}return e}function U(t,e,i,s){let n=e,r=0;for(;n<t.length;){if(t[n]===i&&r++,t[n]===s){if(0===r)return n;r--}n++}return-1}function W(t,e,i,s){let n=e,r=0;for(;n>=0;){if(t[n]===s&&r++,t[n]===i){if(0===r)return n;r--}n--}return-1}function Y(t,e){const i=[];let s="",n=0,r=0,o=0,l=0;for(let a=0;a<t.length;++a){let c=t.substring(a,a+1);if(c==e&&0==r&&0==n&&0==o&&0==l)i.push(s),s="";else{if(s+=c,l>0&&"\\"==c&&a+1<t.length){++a;const e=t.substring(a,a+1);s+=e,c+=e}'"'==c?a>0&&"\\"==t.substring(a-1,a)||(l=0==l?1:0):"["==c?++r:"]"==c?--r:"("==c?++n:")"==c?--n:"{"==c?++o:"}"==c&&--o}}return i.push(s),i}function z(t){const e=q(t,'"');if(null!=e.tag)return e;const i=q(t,"'");return{tag:e.tag,repeat:i.tag,str:i.str}}function q(t,e){let i=null;if(t.endsWith(e)){let s=t.length-1;for(;s>0&&(s=t.lastIndexOf(e,s-1),!(s<=0||"\\"!=t.substring(s-1,s))););s>0&&s<t.length-1&&(i=t.substring(s+1,t.length-1),t=t.substring(0,s))}return null!=i&&(i=function(t){return null==t||""===t?t:t.replace(/[\\]./g,function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}})}(i.replace(new RegExp("\\"+e,"g"),e))),{tag:i,str:t}}const K=ui;t.JsInputBase;async function j(){const e="Helm",i=t.Func.find({package:e,name:"getHelmHelper"});if(0===i.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await i[0].prepare().call()).getOutputParamValue()}async function Q(){await j()}async function X(t,e=5e3){await R(100),await v(t.onAfterDrawContent,()=>{},()=>{t.invalidate()},e)}async function J(e){const i=await async function(t){return await Ti.files.readAsText(t)}(e),s=t.DataFrame.fromCsv(i);return s.name=e.replace(".csv",""),s}async function Z(){const e=t.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}Error,K.input.helmAsync=async function(t,e){return(await j()).createHelmInput(t,e)},P("Helm",()=>{const t=[["L-hArg(Et,Et)","E","F","G","C","E"],["L-hArg(Et,Et)","L-hArg(Et,Et)","E","F","G"],["dhp","m1A","p","r","T","p","r","T","p","r","G","p"],["r","mo6pur","p","r","T","p","r","T","p","r","G","p"],["afhna","mo6pur","36SS","r","T","p"]],e=["complex-monomer","complex-monomer+side-chain","complex-monomer+side-chain-RNA","complex-side-chain","complex+side-chain+linker"];k(async()=>{await Q()}),w("parseHelm",async()=>{const t=[["meI","hHis","Aca","N","T","dK","Thr_PO3H2","D-Tyr_Et","Aze","dV","E","Phe_4Me"],["A","C","T","G","W","E","Q"],["R","U","P","T","A"],["A","*","G","C"]],e=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.Aze.dV.E.N.dV.Phe_4Me}$$$","PEPTIDE1{A.C.T.G.C.T.W.G.T.W.E.C.W.C.Q.W}|PEPTIDE2{A.C.T.G.C.T.W.G.T.W.E.Q}$PEPTIDE1,PEPTIDE1,5:R3-14:R3|PEPTIDE2,PEPTIDE1,2:R3-12:R3$$$","RNA1{R(U)P.R(T)P}|RNA2{P.R(A)P.R(A)}$RNA1,RNA2,2:pair-6:pair|RNA1,RNA2,5:pair-3:pair$$$","PEPTIDE1{A.*.G.C}$$$$V2.0"];for(let i=0;i<e.length;++i){const s=new Set(V(e[i])),n=Array.from(s);T(JSON.stringify(n),JSON.stringify(t[i]))}}),["PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0","PEPTIDE1{[L-hArg(Et,Et)]([L-hArg(Et,Et)]).E.F.G}$$$$","RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{r([mo6pur])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{[afhna]([mo6pur])[36SS].r(T)p}$$$$V2.0"].forEach((i,s)=>{w(e[s],async()=>{const e=V(i);e.sort();const n=t[s];n.sort(),E(e,n)})})});const tt=grok,et="Libraries",it="Settings",st="DuplicateMonomerPreferences",nt=4e3,rt="nextChunk";let ot=Promise.resolve();async function lt(){let t;return ot=ot.then(async()=>{const e=await tt.userSettings.getValue(et,it,!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const i=await async function(){let t=await tt.userSettings.getValue(et,st,!0)??"";if(!t)return{};for(;t.endsWith(rt);){const e=`${st}${t.charAt(t.length-9-1)}`,i=await tt.userSettings.getValue(et,e,!0)??"";t=t.slice(0,t.length-9-1)+i}return JSON.parse(t)}();t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{};for(const e in i){t.duplicateMonomerPreferences[e]=t.duplicateMonomerPreferences[e]??{};for(const s in i[e])for(const n of i[e][s])t.duplicateMonomerPreferences[e][n]=s}}),await ot,t}async function at(t){ot=ot.then(async()=>{t.duplicateMonomerPreferences=t.duplicateMonomerPreferences??{};const e={};for(const i in t.duplicateMonomerPreferences){e[i]={};for(const s in t.duplicateMonomerPreferences[i]){const n=t.duplicateMonomerPreferences[i][s];e[i][n]=e[i][n]??[],e[i][n].push(s)}}await async function(t){const e=JSON.stringify(t),i=Math.ceil(e.length/nt);for(let t=0;t<i;t++){const s=0===t?st:`${st}${t}`,n=t<i-1?`${t+1}`:"",r=e.slice(t*nt,(t+1)*nt),o=n?r+n+rt:r;await tt.userSettings.add(et,s,o,!0)}}(e),t.duplicateMonomerPreferences={},await tt.userSettings.add(et,it,JSON.stringify(t),!0)}),await ot}P("findMonomers",()=>{let t,e;k(async()=>{await Q(),t=await Z(),e=await lt(),await t.loadMonomerLibForTests()}),S(async()=>{await at(e),await t.loadMonomerLib(!0)});const i={withoutMissed:{test:"PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set},withMissed:{test:"PEPTIDE1{meI.missed2.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set(["missed2"])}};for(const[t,e]of Object.entries(i))w(t,async()=>{s(e.test,e.tgt)});function s(e,i){const s=t.getMonomerLib(),n=function(t,e){return new Set(t.filter(t=>e?.getMonomer(null,t)))}(V(e),s);A(n,i)}});const ct=$;var ht=i.n(ct);const dt=rxjs;var ut,pt,ft;class gt{constructor(t,e,i){this.name=t,this.alphabet=e,this.cutoff=i}}!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(ut||(ut={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(pt||(pt={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(ft||(ft={}));const mt=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 gt(pt.PT,mt.fasta.peptide,.5),new gt(pt.DNA,mt.fasta.dna,.55),new gt(pt.RNA,mt.fasta.rna,.55),ut.FASTA,ut.SEPARATOR,ut.HELM,ut.BILN,wu;class yt{static makePalette(t,e=!1,i=yt){const s={};return t.forEach(t=>{const i=t[0],n=t[1];i.forEach((t,i)=>{s[t]=this.colourPalette[n][e?0:i]})}),new i(s)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}yt.undefinedColor="rgb(100,100,100)",yt.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 bt extends yt{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,bt)),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,bt)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new bt({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 bt.aaSynonyms?bt.aaSynonyms[t]:t;return super.get(e)}}bt.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class _t{static getPalette(t="grok"){switch(t){case"grok":return bt.GrokGroups;case"lesk":return bt.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,i="",s="";for(const n of t)"("==n?e++:")"==n?e--:e?i+=n:s+=n;return isNaN(parseInt(i))?[s,i]:[s,""]}static getColorAAPivot(t="",e="grok"){const i=this.getPalette(e);let[s,n]=this.getInnerOuter(t);if(s=s.length>6?`${s.slice(0,3)}...`:s,n=n.length>6?`${n.slice(0,3)}...`:n,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in i?[i.get(e),e,n,1]:[this.undefinedColor,s,n,1]}if("d"==t[0]&&t[1]in i&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in i?[i.get(e),e,n,2]:[this.undefinedColor,s,n,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 i?[i.get(e),e,n,3]:[this.undefinedColor,s,n,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 i?[i.get(e),e,n,4]:[this.undefinedColor,s,n,4]}return[this.undefinedColor,s,n,0]}}_t.SemType="Aminoacids",_t.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",_t.undefinedColor="rgb(100,100,100)",_t.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"},_t.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"},_t.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(*)*"},_t.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 Ct{}Ct.SemType="Nucleotides",Ct.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",Ct.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"},"object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,new Set;const vt="object"==typeof process&&process?process:{};let wt=globalThis.AbortController,Tt=globalThis.AbortSignal;if(void 0===wt){Tt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},wt=class{constructor(){e()}signal=new Tt;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==vt.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{var i,s,n,r;t&&(t=!1,i="AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",s="NO_ABORT_CONTROLLER",n="ENOTSUP",r=e,"function"==typeof vt.emitWarning?vt.emitWarning(i,s,n,r):console.error(`[${n}] ${s}: ${i}`))}}Symbol("type"),Symbol.iterator,Symbol.toStringTag;Error;new Map([[123,"lbrace"],[125,"rbrace"],[40,"lparen"],[41,"rparen"],[93,"rbracket"],[124,"pipe"],[46,"dot"],[44,"comma"],[43,"plus"],[58,"colon"],[45,"dash"],[36,"dollar"],[62,"gt"],[63,"question"],[42,"asterisk"],[95,"underscore"],[39,"apos"]]);new Map;var xt="HELM_AA",At="HELM_SUGAR",Et="HELM_BASE",Pt="HELM_LINKER",kt="HELM_CHEM",St="HELM_BLOB",$t="HELM_NUCLEOTIDE",It={PEPTIDE:"PEPTIDE",RNA:"RNA",CHEM:"CHEM",BLOB:"BLOB",G:"G"};var Mt=class{constructor(){this._listeners=new Set,this._completed=!1}subscribe(t){return this._completed?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}next(t){if(!this._completed)for(let e of[...this._listeners])e(t)}complete(){this._completed=!0,this._listeners.clear()}get observerCount(){return this._listeners.size}};function Nt(t){return{line:"#202020",text:"#000000",background:t}}function Lt(t){return{line:"#e0e0e0",text:"#ffffff",background:Yt(t,.25)}}function Ot(t){let e=/^#([0-9a-fA-F]{6})$/.exec(t),i=/^#([0-9a-fA-F]{3})$/.exec(t);if(null!==e){let t=e[1];return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}if(null!==i){let t=i[1];return[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)]}return null}function Rt(t){return t.toString(16).padStart(2,"0")}function Ft(t,e,i){return`#${Rt(t)}${Rt(e)}${Rt(i)}`}function Dt(t,e,i){let s=t/255,n=e/255,r=i/255,o=Math.max(s,n,r),l=Math.min(s,n,r),a=(o+l)/2;if(o===l)return[0,0,a];let c,h=o-l;return c=o===s?60*((n-r)/h+(n<r?6:0)):o===n?60*((r-s)/h+2):60*((s-n)/h+4),[c,a>.5?h/(2-o-l):h/(o+l),a]}function Ht(t,e,i){let s=i;return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function Bt(t,e,i){if(0===e){let t=Math.round(255*i);return[t,t,t]}let s=i<.5?i*(1+e):i+e-i*e,n=2*i-s,r=t/360;return[Math.round(255*Ht(n,s,r+1/3)),Math.round(255*Ht(n,s,r)),Math.round(255*Ht(n,s,r-1/3))]}function Gt(t,e=.3,i=.1){let s=Ot(t);if(null===s)return t;let[n,r,o]=Dt(s[0],s[1],s[2]),l=Math.max(0,Math.min(1,r*(1-e))),a=Math.max(0,Math.min(.95,o+i*(1-o))),[c,h,d]=Bt(n,l,a);return Ft(c,h,d)}function Vt(t){let e=Ot(t);if(null===e)return 0;let i=t=>{let e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)};return.2126*i(e[0])+.7152*i(e[1])+.0722*i(e[2])}function Ut(t){let e=Ot(t);if(null===e)return"#1f2937";let[i,s,n]=Dt(e[0],e[1],e[2]);if(n>.85||s<.15&&n>.7)return"#1f2937";let r=Math.max(.08,n-.3);return function(t){let e=(t.h%360+360)%360,i=Math.max(0,Math.min(1,t.s)),s=Math.max(0,Math.min(1,t.l)),[n,r,o]=Bt(e,i,s);return Ft(n,r,o)}({h:i,s:Math.min(1,s+.1),l:r})}function Wt(t){let e=function(t){let e=Ot(t);return null===e?null:{r:e[0]/255,g:e[1]/255,b:e[2]/255}}(t);if(null===e)return"#1f2937";let i=t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),s=.2126*i(e.r)+.7152*i(e.g)+.0722*i(e.b);return 1.05/(s+.05)>(s+.05)/.05?"#ffffff":"#1f2937"}function Yt(t,e){let i=Ot(t);if(null===i)return t;let s=1-e;return Ft(Math.max(0,Math.min(255,Math.round(i[0]*s))),Math.max(0,Math.min(255,Math.round(i[1]*s))),Math.max(0,Math.min(255,Math.round(i[2]*s))))}var zt={A:Nt("#A0A0FF"),G:Nt("#FF7070"),T:Nt("#A0FFA0"),C:Nt("#FF8C4B"),U:Nt("#FF8080")},qt={R:Nt("#7a85c1"),r:Nt("#7a85c1")},Kt={P:Nt("#9aa5e1"),p:Nt("#9aa5e1")},jt={A:Nt("#C8C8C8"),R:Nt("#145AFF"),N:Nt("#00DCDC"),D:Nt("#E60A0A"),C:Nt("#E6E600"),E:Nt("#00DCDC"),Q:Nt("#E60A0A"),G:Nt("#EBEBEB"),H:Nt("#8282D2"),I:Nt("#0F820F"),L:Nt("#0F820F"),K:Nt("#145AFF"),M:Nt("#E6E600"),F:Nt("#3232AA"),P:Nt("#DC9682"),S:Nt("#FA9600"),T:Nt("#FA9600"),W:Nt("#B45AB4"),Y:Nt("#3232AA"),V:Nt("#0F820F")},Qt={R:Nt("#eeeeee")},Xt={B:Nt("#999999"),G:Nt("#e2e2e2")},Jt={P:Nt("#9aa5e1")},Zt={name:"light",fallback:{line:"#202020",text:"#000000",background:"#eeeeee"},errorTriple:{line:"#cc0000",text:"#000000",background:"#FFFF00"},palette:{[Et]:zt,[At]:qt,[Pt]:Kt,[xt]:jt,[kt]:Qt,[St]:Xt,[$t]:Jt}};function te(t){let e={};for(let[i,s]of Object.entries(t))e[i]=Lt(s.background);return e}var ee={name:"dark",fallback:{line:"#e0e0e0",text:"#ffffff",background:Yt("#eeeeee",.5)},errorTriple:{line:"#ff5050",text:"#ffffff",background:Yt("#FFFF00",.4)},palette:{[Et]:te(zt),[At]:te(qt),[Pt]:te(Kt),[xt]:te(jt),[kt]:te(Qt),[St]:te(Xt),[$t]:te(Jt)}};function ie(t,e,i=Zt){if(null===t)return{...i.errorTriple};let s=t.meta?.colors;if(void 0!==s){let t="light"===i.name?s.light:"dark"===i.name?s.dark:void 0;if(void 0!==t)return{...t,line:Ut(t.background)};if(void 0!==s.default)return{...s.default,line:Ut(s.default.background)}}let n=t.naturalAnalog;if(void 0!==n&&""!==n){let t=i.palette[e];if(void 0!==t){let e=t[n];if(void 0!==e)return{...e,line:Ut(e.background),text:Wt(e.background)}}}return{...i.fallback,line:Ut(i.fallback.background),text:Wt(i.fallback.background)}}function se(t){switch(t.polymerType){case It.PEPTIDE:return xt;case It.CHEM:return kt;case It.BLOB:return St;case It.RNA:if("Branch"===t.monomerType)return Et;if("Backbone"===t.monomerType){let e=t.naturalAnalog;return"P"===e||"p"===e?Pt:At}return null;default:return null}}new Set(["PEPTIDE","RNA","CHEM","BLOB"]),new Set(["Backbone","Branch","Terminal","Undefined"]);new Set(["?","*","_","X","N"]);Math.PI;function ne(t,e){let i=Math.min(t.x,e.x),s=Math.min(t.y,e.y);return{x:i,y:s,width:Math.max(t.x+t.width,e.x+e.width)-i,height:Math.max(t.y+t.height,e.y+e.height)-s}}function re(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function oe(t){if(0===t.length)return"";let e=t[0],i=`M ${re(e.x)} ${re(e.y)}`;for(let e=1;e<t.length;e++){let s=t[e];i+=` L ${re(s.x)} ${re(s.y)}`}return i+=` L ${re(e.x)} ${re(e.y)} Z`,i}function le(t,e,i,s){let n=[],r=360/e;for(let o=0;o<e;o++){let e=(s+o*r)*Math.PI/180;n.push({x:t.x+i*Math.cos(e),y:t.y+i*Math.sin(e)})}return n}function ae(t,e,i,s){let n=Math.abs(e)/2,r=Math.abs(i)/2,o=Math.max(0,Math.min(s,n,r)),l=t.x-n,a=t.y-r,c=l+2*n,h=a+2*r,d=`M ${re(l+o)} ${re(a)}`;return d+=` L ${re(c-o)} ${re(a)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(c)} ${re(a+o)}`,d+=` L ${re(c)} ${re(h-o)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(c-o)} ${re(h)}`,d+=` L ${re(l+o)} ${re(h)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(l)} ${re(h-o)}`,d+=` L ${re(l)} ${re(a+o)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(l+o)} ${re(a)}`,d+=" Z",d}function ce(t,e,i){let s=Math.abs(e),n=Math.abs(i);return`M ${re(t.x-s)} ${re(t.y)} A ${re(s)} ${re(n)} 0 1 0 ${re(t.x+s)} ${re(t.y)} A ${re(s)} ${re(n)} 0 1 0 ${re(t.x-s)} ${re(t.y)} Z`}function he(t,e,i,s){switch(t){case"hexagon":{let t=i*Math.sqrt(3)/2,s=i;return{x:e.x-t,y:e.y-s,width:2*t,height:2*s}}case"diamond":return{x:e.x-i,y:e.y-i,width:2*i,height:2*i};case"pentagon":{let t=Math.cos(18*Math.PI/180)*i,s=-i,n=Math.sin(54*Math.PI/180)*i;return{x:e.x-t,y:e.y+s,width:2*t,height:n-s}}case"rounded-rect":case"blob":{let t=s??i,n=Math.abs(i)/2,r=Math.abs(t)/2;return{x:e.x-n,y:e.y-r,width:2*n,height:2*r}}case"ellipse":{let t=Math.abs(i),n=Math.abs(s??i);return{x:e.x-t,y:e.y-n,width:2*t,height:2*n}}case"circle":{let t=Math.abs(i);return{x:e.x-t,y:e.y-t,width:2*t,height:2*t}}}}var de='"Helvetica Neue", Helvetica, Arial, sans-serif';function ue(t){return{aa:{size:.72*t,strokeWidth:5},sugar:{size:1.39*t,strokeWidth:5,cornerRadius:.3*t},base:{size:.88*t,strokeWidth:5},linker:{size:.63*t,strokeWidth:5},chem:{size:1.49*t,strokeWidth:5,cornerRadius:.5*t},blob:{size:1.64*t,strokeWidth:5,cornerRadius:.8*t},nucleotide:{size:.98*t,strokeWidth:5}}}var pe={name:"light",background:"#ffffff",defaultStroke:"#202020",defaultFill:"#ffffff",selectionColor:"#FFC107",highlightColor:"#A4E2DC",errorColor:"#cc0000",fontSize:14,fontFamily:de,bondLength:28,textColor:"#000000",idColor:"#00aa00",annotationColor:"#FFA500",tagDotColor:"#dd2222",hbondColor:"#888888",nonCanonicalHbondColor:"#cc8800",crossPolymerBondColor:"#1f5fcd",colorTheme:Zt,palette:{softenCanvas:!1},shapes:ue(14)};ue(14);function fe(t,e){switch(e){case xt:return t.shapes.aa;case At:return t.shapes.sugar;case Et:return t.shapes.base;case Pt:return t.shapes.linker;case kt:return t.shapes.chem;case St:return t.shapes.blob;case $t:return t.shapes.nucleotide}}function ge(t){switch(t){case xt:return"hexagon";case At:return"rounded-rect";case Et:return"diamond";case Pt:return"circle";case kt:return"rounded-rect";case St:return"blob";case $t:return"pentagon"}}function me(t,e,i=0){let s=fe(e,t.biotype);if("*"===t.symbol)return function(t,e){return ce(t,e,e)}(t.p,s.size+i);switch(ge(t.biotype)){case"hexagon":{let e=0===i?0:i/Math.cos(Math.PI/6);return function(t,e,i=-30){return oe(le(t,6,e,i))}(t.p,s.size+e)}case"diamond":{let e=0===i?0:i/Math.cos(Math.PI/4);return function(t,e){return oe([{x:t.x,y:t.y-e},{x:t.x+e,y:t.y},{x:t.x,y:t.y+e},{x:t.x-e,y:t.y}])}(t.p,s.size+e)}case"pentagon":{let e=0===i?0:i/Math.cos(Math.PI/5);return function(t,e,i=-90){return oe(le(t,5,e,i))}(t.p,s.size+e)}case"rounded-rect":return ae(t.p,s.size+2*i,s.size+2*i,(s.cornerRadius??0)+i);case"blob":return function(t,e,i,s){return ae(t,e,i,s)}(t.p,s.size+2*i,s.size+2*i,(s.cornerRadius??0)+i);case"circle":return ce(t.p,s.size+i,s.size+i)}}function ye(t,e){let i,s=fe(e,t.biotype),n="*"===t.symbol?"circle":ge(t.biotype);switch(n){case"hexagon":case"diamond":case"pentagon":case"circle":i=he(n,t.p,s.size);break;case"rounded-rect":case"blob":i=he(n,t.p,s.size,s.size)}let r=s.strokeWidth/2;return{x:i.x-r,y:i.y-r,width:i.width+2*r,height:i.height+2*r}}function be(t,e){return fe(e,t.biotype)}var _e=/[&"'<>]/;function Ce(t){return _e.test(t)?t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):t}function ve(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function we(t,e,i){let s=`<${t}`;if(void 0!==e)for(let t in e){let i=e[t];if(void 0!==i&&!1!==i){if(!0===i){s+=` ${t}`;continue}s+="number"==typeof i?` ${t}="${ve(i)}"`:` ${t}="${Ce(i)}"`}}return void 0===i?`${s}/>`:"string"==typeof i?`${s}>${i}</${t}>`:`${s}>${i.join("")}</${t}>`}function Te(t,e,i){if(0===i.size)return we("g",{class:"hw-layer hw-highlights"},"");let s=[];for(let n of t.atoms){if(!i.has(n.id))continue;let t=me(n,e,(be(n,e).strokeWidth+3)/2);s.push(we("path",{d:t,class:"hw-highlight",fill:"none",stroke:e.highlightColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":n.symbol,"data-ring-atom-id":n.id,"data-testid":`highlight-ring-${n.id}`}))}return we("g",{class:"hw-layer hw-highlights"},s.join(""))}function xe(t,e,i){if(0===i.size)return we("g",{class:"hw-layer hw-selections"},"");let s=[];for(let n of t.atoms){if(!i.has(n.id))continue;let t=me(n,e,(be(n,e).strokeWidth+3)/2);s.push(we("path",{d:t,class:"hw-selection",fill:"none",stroke:e.selectionColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":n.symbol,"data-ring-atom-id":n.id,"data-testid":`selection-ring-${n.id}`}))}return we("g",{class:"hw-layer hw-selections"},s.join(""))}new WeakMap;new Map;var Ae=class{constructor(t,e){this.atoms=t,this.bonds=e,this.isEmpty=0===t.size&&0===e.size,Object.freeze(this)}};new Ae(new Set,new Set);function Ee(t){let e=t.ownerDocument;if(null!=e)return e;let i=globalThis;if(void 0!==i.document)return i.document;throw new Error("EditorView: no Document available (host.ownerDocument is null).")}function Pe(t,e,i,s){let n=t.createElement(e);if(void 0!==i)for(let t of Object.keys(i)){let e=i[t];!1===e||void 0===e||n.setAttribute(t,!0===e?"":String(e))}if(void 0!==s)for(let e of s)"string"==typeof e?n.appendChild(t.createTextNode(e)):n.appendChild(e);return n}function ke(t,e,i=220,s=140){if(null==t||""===e)return null;try{let n=t.get_mol(e);if(null===n)return null;let r=n.get_svg(i,s);return n.delete(),r}catch{return null}}function Se(t,e,i){let s="data-testid";for(let i=0;i<t.body.children.length;i++){let n=t.body.children[i];if(void 0!==n&&n.getAttribute(s)===e)return n}let n=Pe(t,"div",{class:i,[s]:e});return n.style.display="none",t.body.appendChild(n),n}function $e(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(e.appendChild(Pe(t,"div",{class:"hw-tooltip__symbol"},[i.symbol])),void 0!==i.name&&""!==i.name&&i.name!==i.symbol&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__name"},[i.name])),void 0!==i.rdkitSvg&&null!==i.rdkitSvg&&""!==i.rdkitSvg){let s={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(s["data-testid"]=i.rdkitTestid);let n=Pe(t,"div",s);n.innerHTML=i.rdkitSvg,e.appendChild(n)}void 0!==i.hint&&""!==i.hint&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__hint"},[i.hint]))}function Ie(t,e,i){let s=t.style;s.display="block",s.left=`${e+12}px`,s.top=`${i+12}px`}function Me(t){null!==t&&(t.style.display="none")}function Ne(t){let e=t.body;if(null!=e)for(let t=0;t<e.children.length;t++){let i=e.children[t];if(void 0===i)continue;let s=void 0===i.getAttribute?null:i.getAttribute("data-testid");null!=s&&s.endsWith("-tooltip")&&Me(i)}}var Le=class t{constructor(t,e,i){this._baseTransform="",this._viewport={scale:1,offset:{x:0,y:0}},this._pinnedBbox=null,this._tooltip=null,this._bondTooltip=null,this._rdkitSvgCache=new Map,this._unsubs=[],this._destroyed=!1,this.host=t,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._width=i?.width??400,this._height=i?.height??200,function(t){let e=Ee(t);if(null!==e.querySelector("style[data-hw-editor-view-styles]"))return;let i=e.createElement("style");i.setAttribute("data-hw-editor-view-styles",""),i.textContent=".hw-editor-view{position:relative;display:block;overflow:hidden;outline:none;}.hw-editor-view svg{display:block;user-select:none;}.hw-editor-view.hw-view-only{cursor:default;}";let s=e.head??e.documentElement;null!==s&&s.appendChild(i)}(t);let s=this._doc.createElement("div");s.setAttribute("class","hw-editor-view"),t.appendChild(s),this._tooltip=Se(this._doc,"atom-tooltip","hw-atom-tooltip"),this._bondTooltip=Se(this._doc,"bond-tooltip","hw-bond-tooltip"),this._svgRoot=this._renderFresh(),this._unsubs.push(e.on("mol:changed",t=>{this._hideTooltip(),this._hideBondTooltip(),("setHelm"===t.reason||"cleanLayout"===t.reason||"initial"===t.reason)&&(this._pinnedBbox=null),this._renderFresh()})),this._unsubs.push(e.on("selection:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("highlight:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("theme:change",()=>{this._renderFresh()})),this._unsubs.push(e.on("view:resize",t=>{this._applyResize(t.width,t.height)})),this._unsubs.push(e.on("view:viewport-change",t=>{this._viewport=t.viewport,this._applyViewport(t.viewport)})),this._unsubs.push(e.on("view:fit-to-content",()=>{this._pinnedBbox=null,this._renderFresh()})),this._unsubs.push(e.on("monomer:hover",t=>{this._showTooltip(t.atom,t.clientX,t.clientY)})),this._unsubs.push(e.on("monomer:hover-end",()=>{this._hideTooltip()})),this._unsubs.push(e.on("bond:hover",t=>{this._showBondTooltip(t.bond,t.clientX,t.clientY)})),this._unsubs.push(e.on("bond:hover-end",()=>{this._hideBondTooltip()})),this._unsubs.push(e.on("bond:preview",t=>{this._paintBondPreview(t.start.p,t.cursor,null!==t.candidate)})),this._unsubs.push(e.on("bond:preview-end",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("bond:cancel",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("selection:rectangle-start",t=>{this._paintSelectionRect(t.origin,t.origin)})),this._unsubs.push(e.on("selection:rectangle-update",t=>{this._paintSelectionRectFromRect(t.rect)})),this._unsubs.push(e.on("selection:rectangle-end",()=>{this._clearSelectionRect()}))}get svgRoot(){return this._svgRoot}get width(){return this._width}get height(){return this._height}resize(t,e){this._destroyed||(this._width=t,this._height=e,this._renderFresh())}redraw(){this._destroyed||this._renderFresh()}destroy(){if(this._destroyed)return;this._destroyed=!0;for(let t of this._unsubs)t();this._unsubs.length=0;let t=this.host.querySelector(".hw-editor-view");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t),Me(this._tooltip),Me(this._bondTooltip),this._tooltip=null,this._bondTooltip=null}_renderFresh(){let t=this._editor.getService(),e=this._currentTheme(),i=this._editor.getMol();null===this._pinnedBbox&&(this._pinnedBbox=function(t,e=pe){if(0===t.atoms.length)return{x:0,y:0,width:0,height:0};let i=ye(t.atoms[0],e);for(let s=1;s<t.atoms.length;s++)i=ne(i,ye(t.atoms[s],e));return i}(i,e));let s=t.renderMol(i,{width:this._width,height:this._height,theme:e,fixedModelBbox:this._pinnedBbox});this._svgRoot=function(t,e){let i=Ee(t),s=t.querySelector(".hw-editor-view");if(null===s)throw new Error("EditorView.replaceSvg: missing .hw-editor-view wrapper.");let n=i.createElement("div");n.innerHTML=e;let r=n.querySelector("svg");if(null===r)throw new Error("EditorView.replaceSvg: rendered output contained no <svg>.");for(;null!==s.firstChild;)s.removeChild(s.firstChild);return s.appendChild(r),r}(this.host,s);let n=this._svgRoot.querySelector(".hw-content");return this._baseTransform=null!==n?n.getAttribute("transform")??"":"",this._svgRoot.setAttribute("data-testid","editor-svg"),this._applyOverlaysToCurrent(),(1!==this._viewport.scale||0!==this._viewport.offset.x||0!==this._viewport.offset.y)&&this._applyViewport(this._viewport),this._svgRoot}_refreshOverlays(t){this._applyOverlaysToCurrent()}_applyOverlaysToCurrent(){let t=this._editor.getMol(),e=this._editor.getSelection(),i=function(t,e={}){let i=e.theme??pe,s=e.selectedAtomIds??new Set;return{highlightLayer:Te(t,i,e.highlightedAtomIds??new Set),selectionLayer:xe(t,i,s)}}(t,{theme:this._currentTheme(),selectedAtomIds:e.atoms,highlightedAtomIds:this._editorHighlights()});this._spliceLayer("hw-highlights",i.highlightLayer),this._spliceLayer("hw-selections",i.selectionLayer)}_spliceLayer(t,e){let i=this._svgRoot.querySelector(`.${t}`);if(null===i||null===i.parentNode)return;let s=this._doc.createElementNS("http://www.w3.org/2000/svg","svg");s.innerHTML=e;let n=s.querySelector(`.${t}`);null!==n&&i.parentNode.replaceChild(n,i)}_editorHighlights(){let t=this._editor;return"function"==typeof t._currentHighlights?t._currentHighlights():new Set}_currentTheme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyResize(t,e){this._width=t,this._height=e,this._pinnedBbox=null,this._renderFresh()}_applyViewport(t){let e=this._svgRoot.querySelector(".hw-content");if(null===e)return;let i=`translate(${t.offset.x} ${t.offset.y}) scale(${t.scale})`,s=""===this._baseTransform?i:`${i} ${this._baseTransform}`;e.setAttribute("transform",s)}_showTooltip(t,e,i){let s=this._tooltip;if(null===s)return;let n=""===t.symbol?"?":t.symbol,r=t.monomer?.name??"",o=t.bio.positionInChain,l=""===t.bio.chainId?"?":t.bio.chainId,a=""!==r&&r!==n?`${r} @ ${l}:${o}`:`${n} @ ${l}:${o}`,c=this._renderRdkitTooltipSvg(t);$e(this._doc,s,{symbol:n,name:a,rdkitSvg:c,rdkitTestid:"atom-tooltip-rdkit-svg"});let h=""!==r&&r!==n?`${n} — ${r} @ ${l}:${o}`:`${n} @ ${l}:${o}`,d=this._doc.createElement("div");d.setAttribute("class","hw-atom-tooltip__text"),d.style.display="none",d.appendChild(this._doc.createTextNode(h)),s.appendChild(d),Ie(s,e,i)}_renderRdkitTooltipSvg(e){let i=this._editor.getService().options.rdkitModule;if(null==i)return null;let s=e.monomer;if(null===s)return null;let n=s.smiles;if(void 0===n||""===n)return null;let r=`${s.polymerType}:${s.symbol}`;if(this._rdkitSvgCache.has(r))return this._rdkitSvgCache.get(r)??null;let o=ke(i,n,220,140);if(this._rdkitSvgCache.size>=t._RDKIT_CACHE_LIMIT){let t=this._rdkitSvgCache.keys().next().value;void 0!==t&&this._rdkitSvgCache.delete(t)}return this._rdkitSvgCache.set(r,o),o}_hideTooltip(){Me(this._tooltip)}_showBondTooltip(t,e,i){let s=this._bondTooltip;if(null===s)return;let n=Oe(t.r1),r=Oe(t.r2),o=`${t.a1.symbol}@${t.a1.bio.chainId}:${t.a1.bio.positionInChain}`,l=`${t.a2.symbol}@${t.a2.bio.chainId}:${t.a2.bio.positionInChain}`;$e(this._doc,s,{symbol:`${n}-${r} (${t.kind})`,name:`${o} ↔ ${l}`}),Ie(s,e,i)}_hideBondTooltip(){Me(this._bondTooltip)}_paintBondPreview(t,e,i){let s=this._svgRoot.querySelector(".hw-content");if(null===s)return;let n=s.querySelector(".hw-bond-preview");null===n&&(n=this._doc.createElementNS("http://www.w3.org/2000/svg","line"),n.setAttribute("class","hw-bond-preview"),n.setAttribute("data-testid","bond-preview"),n.setAttribute("stroke-dasharray","6 4"),n.setAttribute("stroke-width","2"),n.setAttribute("fill","none"),n.setAttribute("pointer-events","none"),s.appendChild(n)),n.setAttribute("x1",String(t.x)),n.setAttribute("y1",String(t.y)),n.setAttribute("x2",String(e.x)),n.setAttribute("y2",String(e.y)),n.setAttribute("stroke",i?"#1f5fcd":"#999999")}_clearBondPreview(){let t=this._svgRoot.querySelector(".hw-bond-preview");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}_paintSelectionRect(t,e){let i=Math.min(t.x,e.x),s=Math.min(t.y,e.y),n=Math.abs(t.x-e.x),r=Math.abs(t.y-e.y);this._paintSelectionRectAt(i,s,n,r)}_paintSelectionRectFromRect(t){this._paintSelectionRectAt(t.x,t.y,t.width,t.height)}_paintSelectionRectAt(t,e,i,s){let n=this._svgRoot.querySelector(".hw-content");if(null===n)return;let r=n.querySelector(".hw-selection-rect");null===r&&(r=this._doc.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("class","hw-selection-rect"),r.setAttribute("data-testid","selection-rect"),r.setAttribute("fill","rgba(31, 95, 205, 0.08)"),r.setAttribute("stroke","#1f5fcd"),r.setAttribute("stroke-width","1"),r.setAttribute("stroke-dasharray","4 3"),r.setAttribute("pointer-events","none"),n.appendChild(r)),r.setAttribute("x",String(t)),r.setAttribute("y",String(e)),r.setAttribute("width",String(i)),r.setAttribute("height",String(s))}_clearSelectionRect(){let t=this._svgRoot.querySelector(".hw-selection-rect");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}};Le._RDKIT_CACHE_LIMIT=256;function Oe(t){switch(t.kind){case"numeric":return`R${t.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair";case"positional":return`${t.position}pos:R${t.r}`}}var Re=class t{constructor(t,e){this._onClose=null,this._primaryAction=null,this._host=t,this._doc=e.documentImpl??Ee(t);let i=this._doc,s={class:"hw-modal-backdrop",role:"presentation"};void 0!==e.testId&&(s["data-testid"]=`dialog-${e.testId}`);let n=Pe(i,"div",s),r={class:"hw-modal",role:"dialog","aria-modal":"true","aria-label":e.title};void 0!==e.testId&&(r["data-testid"]=`dialog-${e.testId}-frame`);let o=Pe(i,"div",r),l=Pe(i,"div",{class:"hw-modal__header"},[e.title]),a=Pe(i,"div",{class:"hw-modal__body"});o.appendChild(l),o.appendChild(a),n.appendChild(o);let c=t=>{t.stopPropagation()};for(let t of["mousedown","mousemove","mouseup","mouseover","mouseenter","mouseleave","wheel","contextmenu","dblclick","keydown","keyup","keypress"])n.addEventListener(t,c);o.addEventListener("keydown",t=>{let e=t;if("Enter"!==e.key||"TEXTAREA"===e.target?.tagName)return;let i=this._primaryAction;null!==i&&(e.preventDefault?.(),e.stopImmediatePropagation?.(),i())}),n.addEventListener("click",t=>{t.target!==n?t.stopPropagation():this.close()}),this.root=n,this.body=a}static anyOpen(){return t._openStack.length>0}static closeTopmost(){let e=t._openStack[t._openStack.length-1];return void 0!==e&&(e.close(),!0)}open(e){this._onClose=e??null,null===this.root.parentNode&&this._host.appendChild(this.root),t._openStack.includes(this)||t._openStack.push(this),Ne(this._doc)}close(){let e=t._openStack.indexOf(this);e>=0&&t._openStack.splice(e,1),null!==this.root.parentNode&&this.root.parentNode.removeChild(this.root);let i=this._onClose;this._onClose=null,null!==i&&i()}setPrimaryAction(t){this._primaryAction=t}get isOpen(){return null!==this.root.parentNode}};Re._openStack=[];Object.freeze(new Set);function Fe(t){return t.startsWith("[")&&t.endsWith("]")||1===t.length&&/^[A-Za-z]$/.test(t)?t:`[${t}]`}function De(t,e,i){return`${Fe(t)}(${Fe(e)})${Fe(i)}`}var He="http://www.w3.org/2000/svg",Be={sugar:At,base:Et,linker:Pt},Ge={sugar:["r","R"],base:["A"],linker:["p","P"]},Ve={x:70,y:60},Ue={x:140,y:60},We={x:70,y:130},Ye=class t{constructor(t,e,i){this.onValueSet=new Mt,this.onPickModeChange=new Mt,this._slots=new Map,this._favStar=null,this._pickMode=null,this._destroyed=!1,this._builderRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._hooks=i?.paletteHooks??null,this._favHooks=i?.favoriteHooks??null,this.element=Pe(this._doc,"div",{class:"hw-rna-builder","data-testid":"rna-builder"});let s=Pe(this._doc,"div",{class:"hw-rna-builder__header"});if(s.appendChild(Pe(this._doc,"div",{class:"hw-rna-builder__title"},["RNA builder"])),null!==this._favHooks){let t=Pe(this._doc,"span",{class:"hw-rna-builder__fav hw-rna-builder__fav--disabled",role:"button",tabindex:"0","data-testid":"rna-builder-fav-star",title:"Favorite this triplet","aria-pressed":"false","aria-disabled":"true"},["☆"]),e=t=>{t.stopPropagation();let e=this.getSelection();""===e.preview||null===this._favHooks||this._favHooks.toggleFavoriteTriplet(e.sugar,e.base,e.linker)};t.addEventListener("click",e),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&e(t)}),this._favStar=t,s.appendChild(t)}this.element.appendChild(s),this._hintEl=Pe(this._doc,"div",{class:"hw-rna-builder__hint","data-testid":"rna-builder-hint",hidden:!0}),this.element.appendChild(this._hintEl);let n=this._buildSvg();this.element.appendChild(n),this._preview=Pe(this._doc,"div",{class:"hw-rna-builder__preview","data-testid":"rna-builder-preview"}),this.element.appendChild(this._preview),this._addBtn=Pe(this._doc,"button",{class:"hw-rna-builder__add",type:"button","data-testid":"rna-builder-add-btn"},["Add triplet"]),this._addBtn.addEventListener("click",()=>this._onAddClicked()),this.element.appendChild(this._addBtn),t.appendChild(this.element);let r=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),o=e.on("theme:change",()=>{this._destroyed||this._repaintSlotColors()});this._libUnsub=()=>{try{r()}catch{}try{o()}catch{}},this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}refresh(){this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}getSelection(){let t=this._slots.get("sugar")?.value??"",e=this._slots.get("base")?.value??"",i=this._slots.get("linker")?.value??"";return{sugar:t,base:e,linker:i,preview:""!==t&&""!==e&&""!==i?De(t,e,i):""}}setField(t,e){let i=this._slots.get(t);void 0!==i&&(i.value=e,this._setLabelText(i.labelEl,e),this._repaintSlot(i),this._updatePreview(),this.onValueSet.next({field:t,symbol:e}))}startPickMode(t){this._pickMode!==t?(null!==this._pickMode&&this._setSlotPressed(this._pickMode,!1),this._pickMode=t,this._setSlotPressed(t,!0),this._setHintActive(t),this.onPickModeChange.next({field:t}),null!==this._hooks&&this._hooks.beginBiotypeFilter(Be[t],e=>{this.setField(t,e),this._exitPickMode()},()=>{this._exitPickMode()})):this.cancelPickMode()}cancelPickMode(){null!==this._pickMode&&(null!==this._hooks&&this._hooks.endBiotypeFilter(),this._exitPickMode())}getPickMode(){return this._pickMode}triggerAdd(){this._onAddClicked()}destroy(){this._destroyed||(this._destroyed=!0,null!==this._pickMode&&null!==this._hooks&&this._hooks.endBiotypeFilter(),this._libUnsub(),this.onValueSet.complete(),this.onPickModeChange.complete(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}_buildSvg(){let t=this._doc.createElementNS(He,"svg");t.setAttribute("class","hw-rna-builder__triplet"),t.setAttribute("viewBox","0 0 200 180"),t.setAttribute("data-testid","rna-builder-triplet-svg"),t.setAttribute("role","group"),t.setAttribute("aria-label","Triplet preview");let e=this._doc.createElementNS(He,"line");e.setAttribute("class","hw-rna-builder__bond"),e.setAttribute("x1",String(Ve.x+18)),e.setAttribute("y1",String(Ve.y)),e.setAttribute("x2",String(Ue.x-18)),e.setAttribute("y2",String(Ue.y)),t.appendChild(e);let i=this._doc.createElementNS(He,"line");i.setAttribute("class","hw-rna-builder__bond"),i.setAttribute("x1",String(Ve.x)),i.setAttribute("y1",String(Ve.y+18)),i.setAttribute("x2",String(We.x)),i.setAttribute("y2",String(We.y-22)),t.appendChild(i);let s=this._doc.createElementNS(He,"rect");s.setAttribute("class","hw-rna-builder__slot-shape"),s.setAttribute("x",String(-18)),s.setAttribute("y",String(-18)),s.setAttribute("width",String(36)),s.setAttribute("height",String(36)),s.setAttribute("rx","8"),s.setAttribute("ry","8");let n=this._buildSlot("sugar","Pick sugar (backbone)",Ve,s),r=this._doc.createElementNS(He,"circle");r.setAttribute("class","hw-rna-builder__slot-shape"),r.setAttribute("cx","0"),r.setAttribute("cy","0"),r.setAttribute("r",String(18));let o=this._buildSlot("linker","Pick linker",Ue,r),l=this._doc.createElementNS(He,"path");l.setAttribute("class","hw-rna-builder__slot-shape"),l.setAttribute("d","M -22 0 L 0 -22 L 22 0 L 0 22 Z");let a=this._buildSlot("base","Pick base",We,l);return t.appendChild(o.groupEl),t.appendChild(n.groupEl),t.appendChild(a.groupEl),this._slots.set("sugar",n),this._slots.set("linker",o),this._slots.set("base",a),t}_buildSlot(t,e,i,s){let n=this._doc.createElementNS(He,"g");n.setAttribute("class","hw-rna-builder__slot"),n.setAttribute("data-slot",t),n.setAttribute("data-testid",`rna-builder-slot-${t}`),n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label",e),n.setAttribute("aria-pressed","false"),n.setAttribute("transform",`translate(${i.x} ${i.y})`),n.appendChild(s);let r=this._doc.createElementNS(He,"text");r.setAttribute("class","hw-rna-builder__slot-label"),r.setAttribute("data-testid",`rna-builder-${t}-value`),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("text-anchor","middle"),r.setAttribute("dominant-baseline","central"),n.appendChild(r);let o=e=>{e.stopPropagation(),this.startPickMode(t)};return n.addEventListener("click",o),n.addEventListener("keydown",t=>{let e=t;("Enter"===e.key||" "===e.key)&&o(t)}),n.addEventListener("mouseenter",e=>this._showSlotTooltip(t,e)),n.addEventListener("mouseleave",()=>this._hideSlotTooltip()),n.addEventListener("focus",()=>this._showSlotTooltip(t,null)),n.addEventListener("blur",()=>this._hideSlotTooltip()),{id:t,biotype:Be[t],groupEl:n,shapeEl:s,labelEl:r,value:""}}_setLabelText(t,e){let i=[];for(let e=t.firstChild;null!==e;e=e.nextSibling)"title"===e.nodeName||"TITLE"===e.nodeName||i.push(e);for(let e of i)t.removeChild(e);let s=function(t){let e=t.length;return e<=2?16:e<=4?11:e<=7?8:e<=10?6:5}(e);t.setAttribute("font-size",String(s)),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","central");let n=e.length>10?`${e.slice(0,9)}…`:e;t.appendChild(this._doc.createTextNode(n));let r=t.parentNode;if(null!==r){let t=null;for(let e=r.firstChild;null!==e;e=e.nextSibling)if("title"===e.nodeName||"TITLE"===e.nodeName){t=e;break}for(null===t&&(t=this._doc.createElementNS(He,"title"),r.insertBefore(t,r.firstChild));null!==t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._doc.createTextNode(e))}}_repaintSlotColors(){for(let t of this._slots.values())this._repaintSlot(t)}_repaintSlot(t){let e=this._editor.getService().monomerLib,i=this._theme(),s=""===t.value?null:function(t,e,i){return t.getMonomerSet(e).get(i)??null}(e,t.biotype,t.value),n=ie(s,t.biotype,i.colorTheme);t.shapeEl.style.fill=n.background,t.shapeEl.style.stroke=n.line,t.labelEl.style.fill=n.text}_populateDefaults(){let t=this._editor.getService().monomerLib;for(let[e,i]of this._slots.entries()){let s=qe(t,i.biotype),n=Ke(s,Ge[e]),r=""!==i.value&&s.some(t=>t.symbol===i.value)?i.value:n??s[0]?.symbol??"";i.value=r,this._setLabelText(i.labelEl,r)}}_updatePreview(){let t=this.getSelection();for(;null!==this._preview.firstChild;)this._preview.removeChild(this._preview.firstChild);this._preview.appendChild(this._doc.createTextNode(""===t.preview?"-":t.preview)),this._updateFavStar(t)}_updateFavStar(t){if(null===this._favStar||null===this._favHooks)return;let e=""!==t.preview,i=e&&this._favHooks.isFavoriteTriplet(t.sugar,t.base,t.linker);for(;null!==this._favStar.firstChild;)this._favStar.removeChild(this._favStar.firstChild);this._favStar.appendChild(this._doc.createTextNode(i?"★":"☆")),this._favStar.setAttribute("aria-pressed",i?"true":"false"),e?this._favStar.removeAttribute("aria-disabled"):this._favStar.setAttribute("aria-disabled","true");let s="hw-rna-builder__fav"+(i?" hw-rna-builder__fav--active":"")+(e?"":" hw-rna-builder__fav--disabled");this._favStar.setAttribute("class",s)}_onAddClicked(){let t=this.getSelection();""!==t.preview&&this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)}_exitPickMode(){if(null===this._pickMode)return;let t=this._pickMode;this._setSlotPressed(t,!1),this._pickMode=null,this._setHintActive(null),this.onPickModeChange.next({field:null})}_setHintActive(t){let e=this._hintEl;for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(null===t)return void e.setAttribute("hidden","");e.removeAttribute("hidden");let i="sugar"===t?"sugar":"base"===t?"base":"linker";e.appendChild(this._doc.createTextNode(`Pick ${i} from palette`))}_setSlotPressed(t,e){let i=this._slots.get(t);if(void 0===i)return;i.groupEl.setAttribute("aria-pressed",e?"true":"false");let s=(i.groupEl.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-rna-builder__slot--active"!==t).join(" ");i.groupEl.setAttribute("class",e?`${s} hw-rna-builder__slot--active`:s)}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_builderRdkitSvgFor(e){if(null===e)return null;let i=e.smiles;if(void 0===i||""===i)return null;let s=this._rdkit();if(null===s)return null;let n=`${e.polymerType}:${e.symbol}`;if(this._builderRdkitCache.has(n))return this._builderRdkitCache.get(n)??null;let r=ke(s,i,220,140);if(this._builderRdkitCache.size>=t._BUILDER_RDKIT_CACHE_LIMIT){let t=this._builderRdkitCache.keys().next().value;void 0!==t&&this._builderRdkitCache.delete(t)}return this._builderRdkitCache.set(n,r),r}_slotHint(t){switch(t){case"sugar":return"Click to choose a different sugar";case"base":return"Click to choose a different base";case"linker":return"Click to choose a different linker"}}_slotTitle(t,e){let i=""===e?"?":e;switch(t){case"sugar":return`Sugar: ${i}`;case"base":return`Base: ${i}`;case"linker":return`Linker: ${i}`}}_showSlotTooltip(t,e){let i=this._slots.get(t);if(void 0===i)return;let s=this._editor.getService().monomerLib.getMonomerSet(i.biotype),n=""===i.value?null:s.get(i.value)??null,r=Se(this._doc,"builder-tooltip","hw-builder-tooltip");$e(this._doc,r,{symbol:this._slotTitle(t,i.value),name:n?.name??"",rdkitSvg:this._builderRdkitSvgFor(n),rdkitTestid:"builder-tooltip-rdkit-svg",hint:this._slotHint(t)});let o=e;if(null!==o&&"number"==typeof o.clientX&&"number"==typeof o.clientY)Ie(r,o.clientX,o.clientY);else{let t=i.groupEl,e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null;null!==e?Ie(r,e.left+e.width/2,e.top+e.height/2):Ie(r,0,0)}}_hideSlotTooltip(){Me(this._doc.body.querySelector('[data-testid="builder-tooltip"]'))}};Ye._BUILDER_RDKIT_CACHE_LIMIT=256;var ze=Ye;function qe(t,e){let i=t.getMonomerSet(e),s=[];for(let t of i.values())s.push(t);return s.sort((t,e)=>t.symbol.localeCompare(e.symbol)),s}function Ke(t,e){let i=new Set;for(let e of t)i.add(e.symbol);for(let t of e)if(i.has(t))return t;return null}var je="Favorites",Qe={[je]:"★ Favorites",[It.PEPTIDE]:"Peptides",[It.RNA]:"RNA",[It.CHEM]:"CHEM",[It.BLOB]:"BLOB",G:"G"},Xe=[je,It.PEPTIDE,It.RNA,It.CHEM,It.BLOB,"G"],Je="hwe:palette:favorites",Ze="hwe:palette:active-tab";function ti(t){return`${t.sugar}|${t.base}|${t.linker}`}var ei=class t{constructor(t,e,i){this.favoritesChanged=new Mt,this._nextAddUnsub=()=>{},this._favorites=new Set,this._favoriteTriplets=[],this._pendingRnaSelection=null,this._visibleTabs=[je],this._activeTab=je,this._searchInput=null,this._filter="",this._destroyed=!1,this._rnaBuilder=null,this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,this._pickEscapeListener=null,this._pickOutsideClickListener=null,this._paletteRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._opts={documentImpl:this._doc,groupByNaturalAnalog:i?.groupByNaturalAnalog??!0,allowFavorites:i?.allowFavorites??!0},this._loadFavorites(),this._activeTab=this._resolveInitialTab(i?.initialTab),this.element=Pe(this._doc,"div",{class:"hw-palette","data-testid":"palette"}),t.appendChild(this.element),this._render(),this._libUnsub=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),this._themeUnsub=e.on("theme:change",()=>{this._destroyed||this.refresh()}),this._nextAddUnsub=e.on("option:change",t=>{this._destroyed||"nextAdd"===t.key&&this._updatePrimedClasses()})}refresh(){this._render()}setFilter(t){this._filter=t.trim().toLowerCase(),null!==this._searchInput&&this._searchInput.value!==t&&(this._searchInput.value=t),this._applyFilter()}setActiveTab(t){this._visibleTabs.includes(t)&&(this._activeTab=t,this._persistActiveTab(),this._applyActiveTabClasses(),this._applyFilter())}getActiveTab(){return this._activeTab}getFavorites(){let t=this._editor.getService().monomerLib,e=[];for(let i of this._favorites)null!==this._findMonomer(t,i)&&e.push(i);return e}setFavorite(t,e){e!==this._favorites.has(t)&&(e?this._favorites.add(t):this._favorites.delete(t),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}clearFavorites(){0===this._favorites.size&&0===this._favoriteTriplets.length||(this._favorites.clear(),this._favoriteTriplets.length=0,this._saveFavorites(),this._render(),this._emitFavoritesChanged())}getFavoriteTriplets(){return this._favoriteTriplets.map(t=>({...t}))}isFavoriteTriplet(t,e,i){let s=ti({sugar:t,base:e,linker:i});return this._favoriteTriplets.some(t=>ti(t)===s)}setFavoriteTriplet(t,e,i,s){let n=ti({sugar:t,base:e,linker:i}),r=this._favoriteTriplets.findIndex(t=>ti(t)===n);s!==r>=0&&(s?this._favoriteTriplets.push({sugar:t,base:e,linker:i}):this._favoriteTriplets.splice(r,1),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}_hidePaletteTooltips(){let t=this._doc.body;Me(t.querySelector('[data-testid="palette-tooltip"]')),Me(t.querySelector('[data-testid="palette-triplet-tooltip"]'))}_emitFavoritesChanged(){this.favoritesChanged.next({favorites:this.getFavorites(),triplets:this.getFavoriteTriplets()})}destroy(){this._destroyed||(this._destroyed=!0,null!==this._rnaBuilder&&(this._rnaBuilder.destroy(),this._rnaBuilder=null),this._libUnsub(),this._themeUnsub(),this._nextAddUnsub(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}getRnaBuilder(){return this._rnaBuilder}hasActiveBiotypeFilter(){return null!==this._activeBiotypeFilter}getActiveBiotypeFilter(){return this._activeBiotypeFilter}cancelBiotypeFilter(){if(null===this._activeBiotypeFilter)return;let t=this._pickCanceller;this._teardownPickMode(),t?.()}_buildPaletteFilterHooks(){return{beginBiotypeFilter:(t,e,i)=>{null!==this._activeBiotypeFilter&&this._teardownPickMode(),this._activeBiotypeFilter=t,this._pickResolver=e,this._pickCanceller=i,this._applyFilter();let s=t=>{"Escape"===t.key&&this.cancelBiotypeFilter()};this._pickEscapeListener=s,this._doc.defaultView?.addEventListener("keydown",s);let n=t=>{if(null===this._activeBiotypeFilter)return;let e=t.target;if(null==e)return;let i=this._activeBiotypeFilter,s=e;for(;null!==s;){let t=void 0===s.getAttribute?null:s.getAttribute("class");if(null!==t){let e=t.split(/\s+/);if(e.includes("hw-palette__tile")){if((s.getAttribute("data-biotype")??"")===i)return;break}if(e.includes("hw-rna-builder__slot")){if(this._isInsideOwnPalette(s))return;break}}s=s.parentElement}this.cancelBiotypeFilter()};this._pickOutsideClickListener=n,this._doc.addEventListener("mousedown",n,!0)},endBiotypeFilter:()=>this._teardownPickMode()}}_scrollActivePaneToTop(){let t=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`);if(null===t)return;let e=t;try{if("function"==typeof e.scrollTo)return void e.scrollTo({top:0,behavior:"smooth"})}catch{}"number"==typeof e.scrollTop&&(e.scrollTop=0)}_isInsideOwnPalette(t){let e=t;for(;null!==e;){if(e===this.element)return!0;e=e.parentElement}return!1}_teardownPickMode(){null!==this._activeBiotypeFilter&&(this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,null!==this._pickEscapeListener&&(this._doc.defaultView?.removeEventListener("keydown",this._pickEscapeListener),this._pickEscapeListener=null),null!==this._pickOutsideClickListener&&(this._doc.removeEventListener("mousedown",this._pickOutsideClickListener,!0),this._pickOutsideClickListener=null),this._applyFilter())}_render(){for(null!==this._rnaBuilder&&(this._pendingRnaSelection=this._rnaBuilder.getSelection(),this._rnaBuilder.destroy(),this._rnaBuilder=null);null!==this.element.firstChild;)this.element.removeChild(this.element.firstChild);let t=this._doc.createElement("input");t.setAttribute("type","search"),t.setAttribute("class","hw-palette__search"),t.setAttribute("placeholder","Search monomers..."),t.setAttribute("data-testid","palette-search"),""!==this._filter&&(t.value=this._filter),t.addEventListener("input",()=>this.setFilter(t.value)),this._searchInput=t,this.element.appendChild(t),this._visibleTabs=this._computeVisibleTabs(),this._visibleTabs.includes(this._activeTab)||(this._activeTab=je);let e=Pe(this._doc,"div",{class:"hw-palette__tabs",role:"tablist","data-testid":"palette-tabs"});for(let t of this._visibleTabs){let i=t===this._activeTab,s=Pe(this._doc,"button",{class:"hw-palette__tab",type:"button",role:"tab","aria-controls":`hw-palette-pane-${t}`,"aria-selected":i?"true":"false","data-testid":`palette-tab-${t}`,"data-tab":t,title:Qe[t]},[Qe[t]]);s.addEventListener("click",()=>this.setActiveTab(t)),e.appendChild(s)}this.element.appendChild(e);let i=Pe(this._doc,"div",{class:"hw-palette__panes"}),s=this._theme(),n=this._editor.getService().monomerLib;for(let t of this._visibleTabs){let e=t===this._activeTab,r=Pe(this._doc,"div",{class:"hw-palette__pane",id:`hw-palette-pane-${t}`,role:"tabpanel","data-testid":`palette-pane-${t}`,"data-tab":t,hidden:!e});t===je?this._buildFavoritesPane(r,n,s):this._buildPolymerPane(r,t,n,s),i.appendChild(r)}this.element.appendChild(i),this._applyFilter()}_computeVisibleTabs(){let t=this._editor.getService().monomerLib,e=new Set;for(let i of t.getPolymerTypes())e.add(i);let i=[];i.push(je);for(let t of Xe)t!==je&&e.has(t)&&i.push(t);return i}_buildFavoritesPane(t,e,i){let s=this._resolveFavoriteMonomers(e),n=this._favoriteTriplets;if(0===s.length&&0===n.length){let e=Pe(this._doc,"div",{class:"hw-palette__placeholder","data-testid":"palette-favorites-empty"},["No favorites yet — click the ☆ on any tile to add one."]);return void t.appendChild(e)}for(let[e,i]of this._groupByPolymerAndType(s))t.appendChild(this._renderGroup(e,i));n.length>0&&t.appendChild(this._renderTripletGroup("RNA · Triplets",n,e))}_groupByPolymerAndType(t){let e=new Map;for(let i of t){let t=i.polymerType,s=i.monomerType??"Undefined",n=`${t}|${s}`,r=e.get(n);void 0===r&&(r={pt:t,mt:s,list:[]},e.set(n,r)),r.list.push(i)}let i=t=>{let e=Xe.indexOf(t);return e<0?99:e},s={Backbone:0,Branch:1,Terminal:2,Undefined:3};return Array.from(e.values()).sort((t,e)=>i(t.pt)-i(e.pt)||(s[t.mt]??9)-(s[e.mt]??9)||t.mt.localeCompare(e.mt)).map(t=>[`${this._polymerLabel(t.pt)} · ${t.mt}`,t.list])}_polymerLabel(t){return Qe[t]??t}_renderTripletGroup(t,e,i){let s=Pe(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),n=Pe(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),r=Pe(this._doc,"div",{class:"hw-triplet-chips","data-testid":"palette-triplet-favorites"});for(let t of e)r.appendChild(this._renderTripletChip(t,i));return s.appendChild(n),s.appendChild(r),s}_renderTripletChip(t,e){let i=De(t.sugar,t.base,t.linker),s=e.getMonomerSet(Et).get(t.base)??null,n=ie(s,Et,this._theme().colorTheme),r=this.isFavoriteTriplet(t.sugar,t.base,t.linker),o=void 0!==s?.name&&""!==s.name?`${i} — ${s.name}`:i,{root:l}=function(t,e){let i=!1!==e.showStar,s=Pe(t,"span",{class:"hw-triplet-chip__star"},[e.favorite?"★":"☆"]),n=Pe(t,"span",{class:"hw-triplet-chip__label"},[e.label]),r=["hw-triplet-chip"];e.favorite&&r.push("hw-triplet-chip--favorite");let o=i?[s,n]:[n];return{root:Pe(t,"div",{class:r.join(" "),role:"button",tabindex:"0","aria-label":e.title,"data-sugar":e.sugar,"data-base":e.base,"data-linker":e.linker,"data-triplet":e.label,"data-testid":`palette-triplet-${e.label}`,title:e.title,style:`background:${e.background};color:${e.textColor};`},o),star:s}}(this._doc,{sugar:t.sugar,base:t.base,linker:t.linker,label:i,title:o,background:Gt(n.background),textColor:n.text,favorite:r,showStar:this._opts.allowFavorites});return this._wireTripletChip(l,t),l}_wireTripletChip(t,e){t.addEventListener("mouseenter",t=>{let i=t,s=Se(this._doc,"palette-triplet-tooltip","hw-palette-tooltip hw-triplet-tooltip");(function(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);e.appendChild(Pe(t,"div",{class:"hw-tooltip__symbol"},[i.title]));let s=Pe(t,"div",{class:"hw-tooltip__triplet"});for(let e of i.parts){let n=Pe(t,"div",{class:"hw-tooltip__triplet-part"});if(n.appendChild(Pe(t,"div",{class:"hw-tooltip__triplet-role"},[`${e.role}: ${e.symbol}`])),void 0!==e.name&&""!==e.name&&e.name!==e.symbol&&n.appendChild(Pe(t,"div",{class:"hw-tooltip__name"},[e.name])),void 0!==e.rdkitSvg&&null!==e.rdkitSvg&&""!==e.rdkitSvg){let s={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(s["data-testid"]=i.rdkitTestid);let r=Pe(t,"div",s);r.innerHTML=e.rdkitSvg,n.appendChild(r)}s.appendChild(n)}e.appendChild(s),void 0!==i.hint&&""!==i.hint&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__hint"},[i.hint]))})(this._doc,s,{title:De(e.sugar,e.base,e.linker),parts:this._tripletTooltipParts(e),hint:"Click to add this triplet",rdkitTestid:"palette-triplet-tooltip-rdkit-svg"}),Ie(s,"number"==typeof i.clientX?i.clientX:0,"number"==typeof i.clientY?i.clientY:0)}),t.addEventListener("mouseleave",()=>{Me(this._doc.body.querySelector('[data-testid="palette-triplet-tooltip"]'))}),t.addEventListener("click",t=>{let i=t.target;if(this._opts.allowFavorites&&!0===i?.classList?.contains("hw-triplet-chip__star"))return this.setFavoriteTriplet(e.sugar,e.base,e.linker,!this.isFavoriteTriplet(e.sugar,e.base,e.linker)),void t.stopPropagation();this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)}),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)})}_buildRnaDefaultChips(e){let i=this._pickSymbol(e.getMonomerSet(At),["r","R"]),s=this._pickSymbol(e.getMonomerSet(Pt),["p","P"]),n=e.getMonomerSet(Et);if(null===i||null===s)return null;let r=t._DEFAULT_TRIPLET_BASES.filter(t=>n.has(t));if(0===r.length)return null;let o=Pe(this._doc,"div",{class:"hw-triplet-chips hw-triplet-chips--defaults","data-testid":"rna-default-triplets"});for(let t of r)o.appendChild(this._renderTripletChip({sugar:i,base:t,linker:s},e));return o}_tripletTooltipParts(t){let e=this._editor.getService().monomerLib,i=(t,i,s)=>{let n=e.getMonomerSet(i).get(s)??null;return{role:t,symbol:s,...void 0!==n?.name?{name:n.name}:{},rdkitSvg:null===n?null:this._paletteRdkitSvg(n)}};return[i("Sugar",At,t.sugar),i("Base",Et,t.base),i("Linker",Pt,t.linker)]}_pickSymbol(t,e){for(let i of e)if(t.has(i))return i;let i=t.keys().next();return!0===i.done?null:i.value}_restoreRnaSelection(){let t=this._pendingRnaSelection;if(this._pendingRnaSelection=null,null===t||null===this._rnaBuilder)return;let e=this._editor.getService().monomerLib;""!==t.sugar&&e.getMonomerSet(At).has(t.sugar)&&this._rnaBuilder.setField("sugar",t.sugar),""!==t.base&&e.getMonomerSet(Et).has(t.base)&&this._rnaBuilder.setField("base",t.base),""!==t.linker&&e.getMonomerSet(Pt).has(t.linker)&&this._rnaBuilder.setField("linker",t.linker)}_resolveFavoriteMonomers(t){let e=[];for(let i of this._favorites){let s=this._findMonomer(t,i);null!==s&&e.push(s)}return e}_findMonomer(t,e){for(let i of t.getPolymerTypes()){let s=t.getMonomer(i,e);if(null!==s)return s}return null}_buildPolymerPane(t,e,i,s){let n=e,r=this._monomersForPolymer(n,i);if(0===r.length)return;if(n===It.RNA){this._rnaBuilder=new ze(t,this._editor,{documentImpl:this._doc,paletteHooks:this._buildPaletteFilterHooks(),favoriteHooks:this._opts.allowFavorites?{isFavoriteTriplet:(t,e,i)=>this.isFavoriteTriplet(t,e,i),toggleFavoriteTriplet:(t,e,i)=>this.setFavoriteTriplet(t,e,i,!this.isFavoriteTriplet(t,e,i))}:null}),this._restoreRnaSelection();let e=this._buildRnaDefaultChips(i);null!==e&&t.appendChild(e);let s=this._groupRna(r);for(let[e,i]of s)0!==i.length&&t.appendChild(this._renderGroup(e,i));return}if(n===It.PEPTIDE&&this._opts.groupByNaturalAnalog){let e=this._groupByAnalog(r);for(let[i,s]of e){let e=""===i?"Other":i;t.appendChild(this._renderGroup(e,s))}return}let o=Pe(this._doc,"div",{class:"hw-palette__group-tiles"}),l=this._editor.getNextAddSymbol(),a=this._sortByColor(r);for(let t of a){let e=this._biotype(t,n);o.appendChild(this._renderTile(t,e,l))}t.appendChild(o)}_renderGroup(t,e){let i=Pe(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),s=Pe(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),n=Pe(this._doc,"div",{class:"hw-palette__group-tiles"}),r=this._editor.getNextAddSymbol(),o=this._sortByColor(e);for(let t of o){let e=this._biotype(t,t.polymerType);n.appendChild(this._renderTile(t,e,r))}return i.appendChild(s),i.appendChild(n),i}_sortByColor(t){let e=this._theme(),i=t.map((t,i)=>{let s=function(t){let e=Ot(t);if(null===e)return{h:0,s:0,l:0};let[i,s,n]=Dt(e[0],e[1],e[2]);return{h:i,s,l:n}}(ie(t,this._biotype(t,t.polymerType),e.colorTheme).background),n=0===s.s?1:0;return{m:t,idx:i,h:s.h,s:s.s,l:s.l,isGrey:n}});return i.sort((t,e)=>t.isGrey!==e.isGrey?t.isGrey-e.isGrey:t.h!==e.h?t.h-e.h:t.s!==e.s?t.s-e.s:t.l!==e.l?t.l-e.l:t.idx-e.idx),i.map(t=>t.m)}_monomersForPolymer(t,e){let i=e.getMonomerSymbolsByType(t),s=[];for(let n of i){let i=e.getMonomer(t,n);null!==i&&s.push(i)}return s.sort((t,e)=>t.symbol.localeCompare(e.symbol)),s}_groupByAnalog(t){let e=new Map;for(let i of t){let t=i.naturalAnalog??"",s=e.get(t);void 0===s&&(s=[],e.set(t,s)),s.push(i)}let i=[],s=Array.from(e.keys()).sort((t,e)=>""===t&&""!==e?1:""===e&&""!==t?-1:t.localeCompare(e));for(let t of s)i.push([t,e.get(t)]);return new Map(i)}_groupRna(t){let e=[],i=[],s=[],n=[];for(let r of t){let t=se(r);t===At?e.push(r):t===Et?i.push(r):t===Pt?s.push(r):n.push(r)}let r=new Map;return r.set("Backbones",e),r.set("Bases",i),r.set("Linkers",s),n.length>0&&r.set("Other",n),r}_renderTile(t,e,i){let s=this._favorites.has(t.symbol),n=null!==i&&i.symbol===t.symbol&&i.biotype===e,{root:r,star:o}=function(t,e){let i=ie(e.monomer,e.biotype,e.theme.colorTheme),s=Gt(i.background),n=i.text,r=function(t,e){let i=Vt(t),s=Vt(e);return(Math.max(i,s)+.05)/(Math.min(i,s)+.05)}(n,s)<5,o=e.monomer.symbol,l=function(t){return t<=3?14:t<=6?11:t<=9?9:8}(o.length),a=`font-size:${l}px;${o.length>=10?"line-height:1.1;letter-spacing:-0.02em;":""}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80px;display:inline-block;`,c=Pe(t,"span",{class:"hw-palette__star"},[e.favorite?"★":"☆"]),h=Pe(t,"span",{class:"hw-palette__label",style:a},[o]),d=["hw-palette__tile"];e.primed&&d.push("hw-palette__tile--primed"),e.favorite&&d.push("hw-palette__tile--favorite"),r&&d.push("hw-palette__tile--low-contrast");let u=void 0!==e.monomer.name?`${o} — ${e.monomer.name}`:o,p=`background:${s};color:${n};width:100%;min-width:48px;padding:4px 6px;height:40px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;`;return{root:Pe(t,"div",{class:d.join(" "),draggable:"true",role:"button","aria-pressed":e.primed?"true":"false","aria-label":u,"data-symbol":o,"data-biotype":e.biotype,"data-bg":s,"data-raw-bg":i.background,"data-testid":`palette-tile-${o}`,title:u,style:p},[c,h]),star:c}}(this._doc,{monomer:t,biotype:e,theme:this._theme(),favorite:s,primed:n});return this._wireTile(r,o,t,e),r}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_paletteRdkitSvg(e){let i=e.smiles;if(void 0===i||""===i)return null;let s=this._rdkit();if(null===s)return null;let n=`${e.polymerType}:${e.symbol}`;if(this._paletteRdkitCache.has(n))return this._paletteRdkitCache.get(n)??null;let r=ke(s,i,220,140);if(this._paletteRdkitCache.size>=t._PALETTE_RDKIT_CACHE_LIMIT){let t=this._paletteRdkitCache.keys().next().value;void 0!==t&&this._paletteRdkitCache.delete(t)}return this._paletteRdkitCache.set(n,r),r}_wireTile(t,e,i,s){t.addEventListener("mouseenter",t=>{let e=t,s=Se(this._doc,"palette-tooltip","hw-palette-tooltip");$e(this._doc,s,{symbol:i.symbol,name:i.name??"",rdkitSvg:this._paletteRdkitSvg(i),rdkitTestid:"palette-tooltip-rdkit-svg"}),Ie(s,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),t.addEventListener("mouseleave",()=>{Me(this._doc.body.querySelector('[data-testid="palette-tooltip"]'))}),t.addEventListener("click",t=>{let e=t.target;if(this._opts.allowFavorites&&void 0!==e&&!0===e?.classList?.contains("hw-palette__star"))return this.setFavorite(i.symbol,!this._favorites.has(i.symbol)),void t.stopPropagation();if(null!==this._activeBiotypeFilter&&this._activeBiotypeFilter===s){let e=this._pickResolver;return this._teardownPickMode(),e?.(i.symbol),this._scrollActivePaneToTop(),void t.stopPropagation()}let n=this._editor.getSelection();if(n.atoms.size>0){let e=this._editor.getMol(),r=[];for(let t of n.atoms){let i=e.atoms.find(e=>e.id===t);void 0!==i&&r.push(i)}return r.length>0&&r.every(t=>t.biotype===s)?(this._editor.replaceMonomers(r,i.symbol),void t.stopPropagation()):(this._editor.fire("editor:status",{message:`Cannot bulk-replace ${r.length} selected atom(s) with ${i.symbol}: selection contains incompatible biotypes for ${s}.`,severity:"warn",durationMs:3e3}),void t.stopPropagation())}let r=this._editor.getNextAddSymbol();if(null!==r&&r.symbol===i.symbol&&r.biotype===s)return this._editor.setNextAddSymbol(null),void this._updatePrimedClasses();this._editor.setNextAddSymbol(i.symbol,s),this._updatePrimedClasses()}),t.addEventListener("dragstart",t=>{let e=t.dataTransfer;if(null!=e)try{e.setData("application/x-hwe-monomer",JSON.stringify({symbol:i.symbol,biotype:s})),e.effectAllowed="copy"}catch{}Me(this._doc.body.querySelector('[data-testid="palette-tooltip"]')),this._editor.startPaletteDrag(i.symbol,s)})}_biotype(t,e){let i=se(t);if(null!==i)return i;switch(e){case It.PEPTIDE:return xt;case It.RNA:return At;case It.CHEM:return kt;case It.BLOB:return St;default:return kt}}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyFilter(){let t=this._filter,e=this._activeBiotypeFilter,i=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`),s=(i??this.element).querySelectorAll(".hw-palette__tile");for(let i=0;i<s.length;i++){let n=s[i],r=(n.getAttribute("data-symbol")??"").toLowerCase(),o=(n.getAttribute("title")??"").toLowerCase(),l=n.getAttribute("data-biotype")??"",a=(""===t||r.indexOf(t)>=0||o.indexOf(t)>=0)&&(null===e||l===e);n.style.display=a?"":"none"}let n=(i??this.element).querySelectorAll(".hw-triplet-chip");for(let i=0;i<n.length;i++){let s=n[i],r=[s.getAttribute("data-triplet")??"",s.getAttribute("data-sugar")??"",s.getAttribute("data-base")??"",s.getAttribute("data-linker")??""].join(" ").toLowerCase(),o=(""===t||r.indexOf(t)>=0)&&null===e;s.style.display=o?"":"none"}let r=(i??this.element).querySelectorAll(".hw-palette__group");for(let t=0;t<r.length;t++){let e=r[t],i=e.querySelectorAll(".hw-palette__tile, .hw-triplet-chip"),s=!1;for(let t=0;t<i.length;t++)if("none"!==i[t].style.display){s=!0;break}s?(e.removeAttribute("hidden"),e.removeAttribute("data-section-empty")):(e.setAttribute("hidden",""),e.setAttribute("data-section-empty","true"))}}_updatePrimedClasses(){let t=this._editor.getNextAddSymbol(),e=this.element.querySelectorAll(".hw-palette__tile");for(let i=0;i<e.length;i++){let s=e[i],n=s.getAttribute("data-symbol")??"",r=s.getAttribute("data-biotype")??"",o=null!==t&&t.symbol===n&&t.biotype===r,l=(s.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-palette__tile--primed"!==t).join(" ");s.setAttribute("class",o?`${l} hw-palette__tile--primed`:l),s.setAttribute("aria-pressed",o?"true":"false")}}_applyActiveTabClasses(){let t=this.element.querySelectorAll(".hw-palette__tab");for(let e=0;e<t.length;e++){let i=t[e],s=i.getAttribute("data-tab")??"";i.setAttribute("aria-selected",s===this._activeTab?"true":"false")}let e=this.element.querySelectorAll(".hw-palette__pane");for(let t=0;t<e.length;t++){let i=e[t];(i.getAttribute("data-tab")??"")===this._activeTab?i.removeAttribute("hidden"):i.setAttribute("hidden","")}}_localStorage(){if(!this._opts.allowFavorites)return null;let t=this._doc.defaultView;if(null==t)return null;try{return t.localStorage??null}catch{return null}}_resolveInitialTab(t){if(void 0!==t&&Xe.includes(t))return t;let e=this._localStorage();if(null!==e)try{let t=e.getItem(Ze);if(null!==t&&Xe.includes(t))return t}catch{}return je}_persistActiveTab(){let t=this._localStorage();if(null!==t)try{t.setItem(Ze,this._activeTab)}catch{}}_loadFavorites(){let t=this._localStorage();if(null!==t){try{let e=t.getItem(Je);if(null!==e&&""!==e){let t=JSON.parse(e),i=this._extractSymbols(t);for(let t of i)this._favorites.add(t);for(let e of this._extractTriplets(t))this._favoriteTriplets.push(e);return}}catch{}try{let e=t.getItem("hwe.palette.favorites");if(null===e||""===e)return;let i=JSON.parse(e);if(Array.isArray(i)){for(let t of i){if("string"!=typeof t)continue;let e=t.indexOf("|"),i=e>=0?t.slice(e+1):t;""!==i&&this._favorites.add(i)}this._saveFavorites()}}catch{}}}_extractSymbols(t){if(Array.isArray(t)){let e=[];for(let i of t)"string"==typeof i&&e.push(i);return e}if(null!==t&&"object"==typeof t){let e=t;if(Array.isArray(e.symbols)){let t=[];for(let i of e.symbols)"string"==typeof i&&t.push(i);return t}}return[]}_extractTriplets(t){if(null===t||"object"!=typeof t)return[];let e=t;if(!Array.isArray(e.triplets))return[];let i=[];for(let t of e.triplets){if(null===t||"object"!=typeof t)continue;let e=t;"string"==typeof e.sugar&&"string"==typeof e.base&&"string"==typeof e.linker&&i.push({sugar:e.sugar,base:e.base,linker:e.linker})}return i}_saveFavorites(){let t=this._localStorage();if(null!==t)try{let e={symbols:Array.from(this._favorites)};this._favoriteTriplets.length>0&&(e.triplets=this._favoriteTriplets.map(t=>({...t}))),t.setItem(Je,JSON.stringify(e))}catch{}}};ei._DEFAULT_TRIPLET_BASES=["A","C","G","U","T"],ei._PALETTE_RDKIT_CACHE_LIMIT=256;new Set([It.PEPTIDE,It.RNA,It.CHEM,It.BLOB]),new Set(["Backbone","Branch","Terminal","Undefined"]);var ii,si,ni;function ri(e,i=!0){if(null==e)return"rgb(100,100,100)";const s=t.Color.fromHtml(e);if(i){const e=t.Color.g(s),i=t.Color.r(s),n=t.Color.b(s),r=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-e,2)+Math.pow(0-n,2));if(r>210)return`rgb(${i/r*210},${e/r*210},${n/r*210})`}return t.Color.toRgb(s)}!function(t){t[t.default=0]="default",t[t.continuous=1]="continuous"}(ii||(ii={})),function(t){t.Sequence="sequence",t.Helm="notation",t.Properties="properties",t.StructureView="structureview"}(si||(si={}));class oi{static hashCode(t){let e=0;if(0===t.length)return e;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e|=0;return e}}class li{}class ai extends li{static get palette(){return ai._pallete||(ai._pallete=ai.buildPalette()),ai._pallete}static buildPalette(){return Z().then(t=>{t.awaitLoaded(1/0).then(()=>{const e=t.getMonomerLib();e.onChanged.subscribe(()=>{ai.customMonomerColors={},ai.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const i=e.getMonomerSymbolsByType(t);for(const s of i){const i=e.getMonomer(t,s);i?.meta?.colors?.default?.background&&(this.customMonomerColors[s]||(this.customMonomerColors[s]={}),this.customMonomerColors[s][t]=ri(i.meta.colors.default.background))}}})})}),[].concat(...Object.values(yt.colourPalette))}get(t,e){const i=ai.palette.length,s=ai.customMonomerColors[t],n=e??It.PEPTIDE;if(s&&s[n])return s[n];const r=oi.hashCode(t)%i;return ri(ai.palette[r])}}ai._pallete=null,ai.customMonomerColors={},ai.polymerTypes=[],P("renderers",()=>{let e,i;k(async()=>{await Q(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("missedInLib",async()=>{await async function(){const e=await tt.dapi.files.readCsv("System:AppData/Helm/tests/sample_HELM-missedInLib.csv"),i=e.getCol("HELM"),s=tt.shell.addTableView(e);await F(()=>ht()(s.root).find(".d4-grid canvas").length>0,"Table view canvas not found",100),await tt.data.detectSemanticTypes(e),T(i.semType,t.SEMTYPE.MACROMOLECULE),T(i.meta.units,ut.HELM),T(i.getTag(t.TAGS.CELL_RENDERER),"helm");const n=i.getTag(".cell-renderer.render.error");if(n){const t=JSON.parse(n),e=new Error(t.message);throw e.stack=t.stack,e}}()}),w("scatterPlotTooltip",async()=>{await async function(){const e=t.DataFrame.fromCsv(s);e.currentRowIdx=0;const i=tt.shell.addTableView(e);await tt.data.detectSemanticTypes(e);const n=e.plot.scatter({x:"x",y:"y"});i.dockManager.dock(n,t.DOCK_TYPE.RIGHT,null),await Promise.all([v(n.onAfterDrawScene,()=>{},()=>{n.invalidateCanvas()},1e3),X(i.grid,500)]);const r=n.root.getBoundingClientRect(),o=n.worldToScreen(1,0),l=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:r.left+o.x,clientY:r.top+o.y}),a=ht()(n.root).find("canvas").get()[0];await v((0,dt.fromEvent)(a,"mousemove"),()=>{Ti.logger.debug(`Test: event, currentRowIdx=${e.currentRowIdx}`),T(ht()(K.tooltip.root).find("div table.d4-row-tooltip-table tr td canvas").length,1),T(n.hitTest(o.x,o.y),1)},()=>{a.dispatchEvent(l)},500),await X(i.grid,1e3)}()});const s="seq,x,y\nPEPTIDE1{I.H.A.N.T.Thr_PO3H2.Aca.D-Tyr_Et}$$$$,0,0\nRNA1{r(A)p.r(C)p.r(G)p.r(U)p}$$$$,1,0\nRNA1{d(A)p.d(C)p.d(G)p.d(U)p}|PEPTIDE1{I.H.A.N.T.Thr_PO3H2}$$$$,0,1\n"}),function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(ni||(ni={}));class ci{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 i=t;const s=this.isWhitespace(i)?e:e-1;for(let t=0;t<s;t++)i=this.getNextColumnIdx(i);return i}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let i=this.getAtomBlockIdx();for(let s=0;s<t;s++)i=this.shiftIdxToAtomType(i),e[s]=this.parseAtomType(i),i=this.getNextLineIdx(i);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),i=new Float32Array(this.atomCount);let s=this.getAtomBlockIdx();for(let n=0;n<this.atomCount;n++){s=this.shiftIdxToXColumn(s);for(const r of[t,e,i])r[n]=this.parseFloatValue(s),s=this.getNextColumnIdx(s);s=this.getNextLineIdx(s)}return{x:t,y:e,z:i}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let i=0;i<this.bondCount;i++){e=this.shiftIdxToBondedAtomsPair(e);const s=new Uint16Array(2);s[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),s[1]=this.parseIntValue(e),t[i]=s,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let i=this.getBondBlockIdx();for(let s=0;s<t;s++)i=this.shiftIdxToBondType(i),e[s]=this.parseIntValue(i),i=this.getNextLineIdx(i);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 i=e+1;for(;!this.isWhitespace(i);)++i;return t(this.fileContent.substring(e,i))}}class hi extends ci{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,i=e;return this.isQuote(e)?(i=this.getNextIdenticalChar(e),e++):i=this.fileContent.indexOf(" ",i),this.fileContent.substring(e,i)}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&&!((i=this.fileContent.charCodeAt(e+1))>64&&i<91||i>96&&i<123);var i})}isFragment(){return this.isQueryOrFragment(t=>82===t||42===t)}isQueryOrFragment(t){const e=this.atomCount;let i=this.getAtomBlockIdx();for(let s=0;s<e;s++){if(i=this.shiftIdxToAtomType(i),t(this.fileContent.charCodeAt(i),i))return!0;i=this.getNextLineIdx(i)}return!1}}class di extends hi{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter(t=>t.startsWith(ni.RGP_LINE_START)).forEach(e=>{const i=this.getAtomIdxToRgpIdxList(e);for(const[e,s]of i){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,s)}});const i=e.map((t,e)=>{if(t.startsWith(ni.ATOM_ALIAS_LINE_START))return e}).filter(t=>void 0!==t),s=i.map(t=>e[t]),n=i.map(t=>e[t+1]);s.forEach((e,i)=>{const s=parseInt(e.split(/\s+/)[1])-1,r=parseInt(n[i].substring(1));if(t.has(r))throw new Error(`R group ${r} is already in the map`);t.set(r,s)});const r=this.getRGroupAtomicIndices().filter(e=>!Array.from(t.values()).includes(e));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter(t=>t).slice(3).map(t=>parseInt(t)),i=new Array(e.length/2);for(let t=0;t<e.length;t+=2)i[t/2]=[e[t+1],e[t]-1];return i}getRGroupAtomicIndices(){return this.atomTypes.map((t,e)=>{if(t.includes("R#"))return e}).filter(t=>void 0!==t)}static isValidMolfile(t){return-1!==t.indexOf(ni.TYPE)&&-1!==t.indexOf(ni.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ni.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ni.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,ni.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ni.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+ni.NUM_OF_COUNTS_DIGITS;const i=parseInt(this.fileContent.substring(t,e));return t=e,e+=ni.NUM_OF_COUNTS_DIGITS,{atomCount:i,bondCount:parseInt(this.fileContent.substring(t,e))}}}class pi extends hi{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach((e,i)=>{const s=e.match(/RGROUPS=\(([\d\s]+)\)/);if(s){const e=s[1].split(/\s+/).map(t=>parseInt(t));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const n=e[1];if(t.has(n))throw new Error(`R group ${n} is already in the map`);t.set(n,i)}}),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const i=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:i,bondCount:parseInt(this.fileContent.substring(t,e))}}}class fi{constructor(){}static getInstance(t){if(fi.isMolfileV2K(t))return new di(t);if(fi.isMolfileV3K(t))return new pi(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return di.isValidMolfile(t)}static isMolfileV3K(t){return pi.isValidMolfile(t)}}async function gi(){const e=t.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}P("getMolfiles",()=>{let e,i;k(async()=>{await Q(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("linear1",async()=>{const e=t.DataFrame.fromCsv("Helm, atoms, bonds\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV}$$$$,11,10\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV}$$$$,11,10\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$,9,8"),i=e.getCol("Helm"),s=tt.shell.addTableView(e);Ti.logger.debug("Helm/getMolfiles/linear1, grid awaiting 1"),await X(s.grid,5e3),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaited 1");const n=await tt.functions.call("Helm:getMolfiles",{col:i});T(n.length,i.length);const r=n.toList().map(t=>fi.getInstance(t));E(r.map(t=>t.atomCount),e.getCol("atoms").toList()),E(r.map(t=>t.bondCount),e.getCol("bonds").toList()),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaiting 2"),await X(s.grid,5e3),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaited 2")})});class mi extends Error{constructor(t,e){super(t,e)}}async function yi(t,e){const i=K.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(i);try{if(t.length>1e3)throw new mi("Too long sequence to calculate molecular properties.");const s=(e.isHelm()?t:e.getConverter(ut.HELM)(t)).replaceAll(H,"{").replaceAll(B,".").replaceAll(G,"}").replace("{*}","{}"),n=(await j()).createHelmWebEditor(i).editor;n.setHelm(s);const r=n.getFormula(!0),o=Math.round(100*n.getMolWeight())/100,l=Math.round(100*n.getExtinctionCoefficient())/100;return{formula:r.replace(/<sub>/g,"").replace(/<\/sub>/g,""),"molecular weight":o,"extinction coefficient":l}}finally{ht()(i).empty(),i.remove()}}const bi={Helm:{seq:"PEPTIDE1{I.H.A.C.T.[Thr_PO3H2].[Aca].[D-Tyr_Et]}|PEPTIDE2{E.A.[meG]}$PEPTIDE1,PEPTIDE2,4:R3-1:R1$$$V2.0",units:ut.HELM,res:{formula:"C58H94N13O21SP","molecular weight":1372.49,"extinction coefficient":1.55}},separator:{seq:"I/H/A/C/T/Thr_PO3H2/Aca/D-Tyr_Et",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C47H77N10O15SP","molecular weight":1085.22,"extinction coefficient":1.55}},separator2:{seq:"meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca/D-Tyr_Et/Aze/dV/E/N////Phe_4Me",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C91H146N19O25P","molecular weight":1937.25,"extinction coefficient":1.49}},"separator-gaps":{seq:"I/H/A//T/Thr_PO3H2/Aca/D-Tyr_Et",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C44H72N9O14P","molecular weight":982.08,"extinction coefficient":1.49}},"fasta-PT":{seq:"IHACTTAY",units:ut.FASTA,alphabet:pt.PT,res:{formula:"C38H58N10O12S","molecular weight":879,"extinction coefficient":1.55}},"fasta-RNA":{seq:"ACGUAUUCC",units:ut.FASTA,alphabet:pt.RNA,res:{formula:"C84H107N30O65P9","molecular weight":2855.69,"extinction coefficient":86.96}},"fasta-DNA":{seq:"ACGTATTCC",units:ut.FASTA,alphabet:pt.DNA,res:{formula:"C87H113N30O56P9","molecular weight":2753.78,"extinction coefficient":86.96}}};function _i(t,e,i){const s=i.parse(t);T(s.atoms.length,e.atomCount),T(s.bonds.length,e.bondCount),T(s.atoms.every(t=>!t.elem.startsWith("[")&&!t.elem.endsWith("]")),!0,"Atoms should not contain square braces.")}var Ci;P("properties-widget",()=>{let e,i,s=null;k(async()=>{await Q(),e=await gi(),i=await Z(),s=lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)});for(const[t,e]of Object.entries(bi))w(t,async()=>{await n(e.seq,e.units,e.separator,e.alphabet,e.res)});async function n(i,s,n,r,o){const l=t.Column.fromStrings("seq",[i]);l.semType=t.SEMTYPE.MACROMOLECULE,l.meta.units=s,n&&l.setTag(ft.separator,n),r&&l.setTag(ft.alphabet,r);const a=e.getSeqHandler(l);A(await yi(i,a),o)}w("too-long",async()=>{const i=function(e=1e4){const i="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),s=t.Column.fromList(t.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(i));s.semType=t.SEMTYPE.MACROMOLECULE,s.meta.units=ut.SEPARATOR,s.setTag(ft.separator,"/"),s.setTag(ft.alphabet,pt.UN),s.setTag(ft.alphabetIsMultichar,"true");const n=[];return n.push(s),n.push(t.Column.fromList(t.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),n}(),s=t.DataFrame.fromColumns(i).getCol("MSA"),n=e.getSeqHandler(s);let r=!0;try{await yi(s.get(0),n)}catch(t){t instanceof mi&&(r=!0)}T(r,!0)})}),P("parseHelm",()=>{const t={PT:{src:"PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0",tgt:{atomCount:6,bondCount:5,helm:"PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0"}},"PT-cyclic":{src:"PEPTIDE1{[meI].C.[Aca].[Cys_SEt].T.C.[Thr_PO3H2].[Aca]}$PEPTIDE1,PEPTIDE1,8:R2-1:R1$$$V2.0",tgt:{atomCount:8,bondCount:8,helm:"PEPTIDE1{[meI].C.[Aca].[Cys_SEt].T.C.[Thr_PO3H2].[Aca]}$PEPTIDE1,PEPTIDE1,8:R2-1:R1$$$V2.0"}},RNA:{src:"RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0",tgt:{atomCount:12,bondCount:11,helm:"RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0"}},"PT-with-gap":{src:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$$$$V2.0",tgt:{atomCount:8,bondCount:7,helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$$$$V2.0"}},"PT-with-gap-at-connection":{src:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0",tgt:{atomCount:8,bondCount:8,helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"}}};let e,i,s;k(async()=>{await Q(),e=await j(),i=await Z(),s=await lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)});for(const[i,{src:s,tgt:n}]of Object.entries(t))w(`HelmHelper-${i}`,async()=>{_i(s,n,e)})}),P("helm-web-editor",async()=>{let t,e,i;k(async()=>{await Q(),t=await Z(),e=await lt(),await t.loadMonomerLibForTests(),i=await j()}),S(async()=>{await at(e),await t.loadMonomerLib(!0)}),w("helm-web-editor",async()=>{i.createHelmWebEditor()}),w("web-editor-app",async()=>{const t=K.div([],{style:{width:"700px",height:"432px"}});i.createWebEditorApp(t,"PEPTIDE1{I.H.A.N.T.Thr_PO3H2.Aca.D-Tyr_Et}$$$$"),K.dialog().add(t).show().close()})}),P("HelmInput",()=>{let t,e,i;k(async()=>{t=await j(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("inDialog",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$",K.dialog("Helm Input Test").add(t).show(),await R(500);const e=t.molValue;T(e.atoms.length,4),T(e.bonds.length,3)}),w("renders-with-nonzero-height (root in a dialog)",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Height Test").add(t).show();try{await R(500);const e=t.getInput();T(e.clientHeight>0,!0,`editor host height must be > 0 (was ${e.clientHeight})`);const i=e.querySelector("svg");T(null!=i,!0,"an SVG must be mounted in the editor host");const s=i.getBoundingClientRect().height;T(s>0,!0,`mounted SVG height must be > 0 (was ${s})`)}finally{e.close()}}),w("default size is 250x250",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Default Size").add(t).show();try{await R(500);const e=t.getInput();T(Math.abs(e.clientWidth-250)<=4,!0,`default width ~250 (was ${e.clientWidth})`),T(Math.abs(e.clientHeight-250)<=4,!0,`default height ~250 (was ${e.clientHeight})`)}finally{e.close()}}),w("editorOptions.width/height override the default size",async()=>{const t=await K.input.helmAsync("Macromolecule",{editable:!0,editorOptions:{width:320,height:180}});t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Custom Size").add(t).show();try{await R(500);const e=t.getInput();T(Math.abs(e.clientWidth-320)<=4,!0,`width ~320 from editorOptions (was ${e.clientWidth})`),T(Math.abs(e.clientHeight-180)<=4,!0,`height ~180 from editorOptions (was ${e.clientHeight})`)}finally{e.close()}}),w("editor canvas sizes from getInput() box (consumer sets height on the host)",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm getInput() Size Test").add(t).show();try{await R(300);const e=t.getInput();e.style.setProperty("width","360px","important"),e.style.setProperty("height","260px","important"),await R(500),T(e.clientWidth,360,`host width (was ${e.clientWidth})`),T(e.clientHeight,260,`host height (was ${e.clientHeight})`);const i=e.querySelector("svg");T(null!=i,!0,"an SVG must be mounted");const s=i.getBoundingClientRect();T(s.height>=e.clientHeight-8,!0,`SVG height should track the host's ${e.clientHeight} (was ${s.height})`),T(s.width>=e.clientWidth-8,!0,`SVG width should track the host's ${e.clientWidth} (was ${s.width})`)}finally{e.close()}}),w("tooltip",async()=>{await async function(){const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=tt.shell.v?tt.shell.v.root.getBoundingClientRect():null,i=K.dialog("Helm Input Test").add(t).show({...e?{x:e.right+20,y:e.top+20}:{}});try{const e=ht()(i.root).find("div.d4-dialog-contents > div.ui-input-helm > div.ui-input-editor").get(0);T(t.getInput(),e);const s={i:0,elem:"meY"},n=t.molValue.atoms[s.i],r=t.getInput(),o=r.getBoundingClientRect(),l=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:o.left+n.p.x,clientY:o.top+n.p.y});await v(K.tooltip.onTooltipShown,()=>{},()=>{r.dispatchEvent(l)},100,"timeout await ui.tooltip.onTooltipShown");const a=ht()(document).find("body > div.d4-tooltip").get(0),c=ht()(a).find("div > div.d4-flex-row.ui-div > div:nth-child(1)").get(0);T("none"!=a.style.display,!0),T(c?.innerText,s.elem)}finally{await R(50),K.tooltip.hide()}}()},{timeout:3e5})}),P("HelmHelper: removeGaps",()=>{let t,e,i;k(async()=>{t=await j(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)});const s={"single-linear-start":{src:{helm:"PEPTIDE1{*.[meY].A.G.T}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[1,0],[2,1],[3,2],[4,3]]}},"single-linear-end":{src:{helm:"PEPTIDE1{[meY].A.G.T.*}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3]]}},"single-linear-middle":{src:{helm:"PEPTIDE1{[meY].A.*.G.T}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[0,0],[1,1],[3,2],[4,3]]}},"single-cycle-start":{src:{helm:"PEPTIDE1{*.[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,3:R3-7:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6]]}},"single-cycle-end":{src:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T.*}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]]}},"single-cycle-middle":{src:{helm:"PEPTIDE1{[meY].C.R.N.*.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3],[5,4],[6,5],[7,6]]}},"single-cycle-gap-at-connection":{src:{helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"},tgt:{helm:null,map:[],errType:"HelmNotSupportedError"}}};for(const[e,i]of Object.entries(s))w(`${e}`,async()=>{let e=null;try{const e=t.removeGaps(i.src.helm);T(e.resHelm,i.tgt.helm),E(Array.from(e.monomerMap.entries()),i.tgt.map)}catch(t){e=t}i.tgt.errType&&T(e?.type,i.tgt.errType,"HelmNotSupportedError thrown expected")})});class vi{constructor(t,e=!0,i){return this.substructure=t,this.readOnly=e,this.logger=i,new Proxy(this,{set:(t,e,i)=>{if(this.logger?.debug(`BioFilterProps.set ${e.toString()}( '${i}' )`),this.readOnly)throw new Error("Properties are immutable.");return t[e]=i,!0}})}}P("bio-substructure-filters",async()=>{let t,e,i;async function s(t,e){if(!e.columns.names().includes(t))throw new Error(`The column '${t}' not found. Available in data frame are ${JSON.stringify(e.columns.names())}`);const i=await tt.functions.call("Bio:bioSubstructureFilterTest");return i.attach(e),i.applyState({columnName:t}),i.column=e.col(t),i.columnName=t,i}k(async()=>{t=await gi(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("helm-dialog",async()=>{const t="Bio tests: substructureFilters/helm-dialog",e=await J("tests/filter_HELM.csv"),i=tt.shell.addTableView(e);await tt.data.detectSemanticTypes(e),await e.meta.detectSemanticTypes(),Ti.logger.debug(`${t}, filter attaching.`);const s=await tt.functions.call("Bio:bioSubstructureFilterTest");s.attach(e);const n=K.dialog("Test filters").add(s.root).show();await s.awaitRendered();try{const n=s.bioFilter;T(null!==s.bioFilter,!0,"bioFilter is not created"),Ti.logger.debug(`${t}, filter 1 change awaiting...`),await v(e.onRowsFiltered,()=>{},()=>{n.props=new vi("PEPTIDE1{A.C}$$$$V2.0",void 0,Ti.logger)},2e4),Ti.logger.debug(`${t}, filter 1 changed.`),T(s.dataFrame.filter.trueCount,1),T(s.dataFrame.filter.toBinaryString(),"0001"),Ti.logger.debug(`${t}, filter 2 change awaiting...`),await v(e.onRowsFiltered,()=>{},()=>{n.props=new vi("PEPTIDE1{C}$$$$V2.0",void 0,Ti.logger)},2e4),setTimeout(()=>i.grid.invalidate(),500),await X(i.grid),await R(1e3),Ti.logger.debug(`${t}, filter 2 changed.`),T(s.dataFrame.filter.trueCount,2),T(s.dataFrame.filter.toBinaryString(),"1001")}finally{n.close()}await s.awaitRendered(),await R(3e3)},{}),w("helm-view",async()=>{const t=await J("tests/filter_HELM.csv");t.getCol("HELM string"),await tt.data.detectSemanticTypes(t);const e=tt.shell.addTableView(t);e.getFiltersGroup(),await X(e.grid)}),w("sync-helm",async()=>{const t=await Ti.files.readCsv("tests/filter_HELM.csv");await tt.data.detectSemanticTypes(t);const e=tt.shell.addTableView(t),i="PEPTIDE1{A.C}$$$$V2.0",n=await s("HELM string",t),r=await s("HELM string",t),o=K.dialog("Test filters").add(n.root).add(r.root).show();await Promise.all([n.awaitRendered(),r.awaitRendered()]);try{T(!!n.bioFilter,!0),T(!!r.bioFilter,!0),T(n.bioFilter.type,"HelmBioFilter"),T(r.bioFilter.type,"HelmBioFilter");const s=n.bioFilter,o=r.bioFilter;await v(t.onRowsFiltered,()=>{},()=>{s.props=new vi(i,void 0,Ti.logger)},6e4,"await onRowsFiltered"),await X(e.grid),Ti.logger.debug("Bio tests: substructureFilters/sync-helm, before changed event"),await R(2*n.debounceTime),Ti.logger.debug("Bio tests: substructureFilters/sync-helm, after changed event"),T(t.filter.trueCount,1),await n.awaitRendered(),T(o.props.substructure,i)}finally{n.detach(),r.detach(),o.close()}await Promise.all([n.awaitRendered(),r.awaitRendered()]),await X(e.grid),await R(3e3)})}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(Ci||(Ci={}));new Uint32Array(65536);var wi;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(wi||(wi={})),wi.HAMMING,wi.LEVENSHTEIN,wi.NEEDLEMANN_WUNSCH,wi.MONOMER_CHEMICAL_DISTANCE;P("activityCliffs",async()=>{let e,i,s;const n=t.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0];k(async()=>{e=await j(),i=await Z(),s=await lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)}),w("Helm",async()=>{const e=await Ti.files.readCsv("samples/HELM_50.csv"),i=tt.shell.addTableView(e);await async function(e,i,s,n,r,o,l,a,c){await tt.data.detectSemanticTypes(i),await tt.functions.call("Bio:activityCliffs",{table:i,molecules:i.getCol("HELM"),activities:i.getCol("Activity"),similarity:65,methodName:s,similarityMetric:a,preprocessingFunction:c,options:{bypassLargeDataWarning:!0},demo:!1});const h=Array.from(e.viewers).find(e=>e.type===t.VIEWER.SCATTER_PLOT);T(null!=h,!0);await F(()=>(()=>{const t=h.root.getElementsByClassName("scatter_plot_link");return t.length>0&&"311 cliffs"===t[0].innerText.toLowerCase()})(),"activity cliffs failed")}(i,e,Ci.UMAP,0,0,0,0,wi.HAMMING,n)})}),P("toAtomicLevel-ui",()=>{let e,i,s,n;k(async()=>{n=await async function(){const e=t.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests(),s=e.getMonomerLib()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)});const r={fasta:{src:{seq:"MDYKETLLMPK",units:ut.FASTA},tgt:{atomCount:94,bondCount:95}},"fasta-with-gap":{src:{seq:"MD-YKETLLMPK",units:ut.FASTA},tgt:{atomCount:94,bondCount:95}},helm:{src:{seq:"PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2}$$$$",units:ut.HELM},tgt:{atomCount:68,bondCount:68}},"helm-with-gap":{src:{seq:"PEPTIDE1{meI.hHis.*.Aca.N.T.dK.Thr_PO3H2}$$$$",units:ut.HELM},tgt:{atomCount:68,bondCount:68}}},o=async e=>{const i=e.src.seq,s=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,"seq",[i])]);return await tt.data.detectSemanticTypes(s),{df:s,seqCol:s.getCol("seq")}};for(const[t,e]of Object.entries(r))w(`${t}-nonlinear`,async()=>{const t=await o(e);await l(t.df,t.seqCol,0,e.tgt)});async function l(e,i,s,r){await tt.functions.call("Bio:toAtomicLevel",{table:e,seqCol:i,nonlinear:!0,highlight:!1});const o=e.col("molfile(seq)");T(o?.semType,t.SEMTYPE.MOLECULE);const l=o?.get(0),a=n.get_mol(l);T(null!=a,!0,"No molecule generated");try{const t=a.get_num_atoms(),e=a.get_num_bonds();T(t,r.atomCount),T(e,r.bondCount)}finally{a.delete()}}});const Ti=new t.Package;async function xi(e,i,s){const u=await function(t){var e,i,s;return n(this,void 0,void 0,function*(){const u=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!u)throw new Error("Can't run tests outside of the package");const p=null===(e=u.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),f=p?p[1]:"";null!=u&&(yield M(u));const g=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(i=(s=t).testContext)&&void 0!==i||(s.testContext=new _),grok.shell.clearLastError();const m=function(){const t=[];return console.log=(...e)=>{t.push(...e),l(...e)},console.info=(...e)=>{t.push(...e),a(...e)},console.warn=(...e)=>{t.push(...e),c(...e)},console.error=(...e)=>{t.push(...e),h(...e)},t}();yield function(t,e){var i,s,r,o,d,p;return n(this,void 0,void 0,function*(){try{let a=null!=(null==e?void 0:e.skipToCategory),c=!1;for(const[h,m]of Object.entries(t)){if(null===(i=e.exclude)||void 0===i?void 0:i.some(t=>h.startsWith(t)))continue;if(null!=(null==e?void 0:e.category)&&!h.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(a)if(c)a=!1;else{if(null==(null==e?void 0:e.skipToCategory)||h.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;c=!0}const t=null===(s=m.tests)||void 0===s?void 0:s.every(t=>{var i;return(null===(i=t.options)||void 0===i?void 0:i.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()});if(!t){const t=(null!==(r=m.tests)&&void 0!==r?r:[]).filter(t=>{var i;return(null===(i=t.options)||void 0===i?void 0:i.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}).length;l(`Package testing: Started {{${h}}}${t>0?` skipped {{${t}}}`:""}`),m.beforeStatus=yield y(m.before,h)}let _,C=null!==(o=m.tests)&&void 0!==o?o:[];e.stressTest&&(C=C.filter(t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest}),C=O(C)),(null!==(p=null===(d=e.tags)||void 0===d?void 0:d.length)&&void 0!==p?p:0)>0&&(C=C.filter(t=>{var i,s;return null===(s=null===(i=t.options)||void 0===i?void 0:i.tags)||void 0===s?void 0:s.some(t=>{var i;return(null!==(i=null==e?void 0:e.tags)&&void 0!==i?i:[]).includes(t)})})),m.beforeStatus?(_=Array.from(C.map(t=>({date:(new Date).toISOString(),category:h,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing}))),_.forEach(t=>n(this,void 0,void 0,function*(){return yield grok.shell.reportTest("package",t)}))):_=yield b(m,e,a);const v=_.filter(t=>"skipped"!=t.result);if(t||(m.afterStatus=yield y(m.after,h)),m.afterStatus&&(l(`Package testing: Category after() {{${h}}} failed`),l(`Package testing: Result for {{${h}}} after: ${m.afterStatus}`),v.push({date:(new Date).toISOString(),category:h,name:"after",success:!1,result:m.afterStatus,ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),m.beforeStatus&&(l(`Package testing: Category before() {{${h}}} failed`),l(`Package testing: Result for {{${h}}} before: ${m.beforeStatus}`),v.push({date:(new Date).toISOString(),category:h,name:"before",success:!1,result:m.beforeStatus,ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.push(...v),e.returnOnFail&&v.some(t=>!t.success&&!t.skipped&&t.name!==e.skipToTest))break}}finally{console.log=l,console.info=a,console.warn=c,console.error=h}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=f?f:"",package:u.name,widgetsDifference:0};l(`Package testing: Unhandled Exception: ${t}`),g.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=u.name,yield grok.shell.reportTest("package",e)}}})}(d,t);for(let t of g)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return g;function y(t,e){return n(this,void 0,void 0,function*(){let i;try{void 0!==t&&(yield D(()=>n(this,void 0,void 0,function*(){yield t()}),1e5,`before ${e}: timeout error`))}catch(t){i=yield N(t)}return i})}function b(t,e,i){var s,l,a,c,h,d,p,g,y,b,_,v,w,T,x,A,E,P,k;return n(this,void 0,void 0,function*(){let n=null!==(s=t.tests)&&void 0!==s?s:[];const S=[],$=C();if(t.clear){let s=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){n[i].options&&void 0===(null===(l=n[i].options)||void 0===l?void 0:l.benchmark)&&(n[i].options||(n[i].options={}),n[i].options.benchmark=null!==(a=t.benchmarks)&&void 0!==a&&a);let w=n[i];if(e.test&&e.test.toLowerCase()!==w.name.toLowerCase())continue;if(s){if(null==(null==e?void 0:e.skipToTest)||w.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;s=!1}(null==w?void 0:w.options)&&(w.options.owner=null!==(p=null!==(d=null!==(h=null===(c=n[i].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==d?d:f)&&void 0!==p?p:"");let T=yield L(w,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(y=null===(g=n[i].options)||void 0===g?void 0:g.benchmarkTimeout)&&void 0!==y?y:o:null!==(_=null===(b=n[i].options)||void 0===b?void 0:b.timeout)&&void 0!==_?_:r,u.name,e.verbose);if(T&&(S.push(Object.assign(Object.assign({},T),{widgetsDifference:C()-$})),e.returnOnFail&&e.skipToTest!==w.name&&!T.success&&!T.skipped))return S;e.nodeOptions||!1===(null===(v=e.testContext)||void 0===v?void 0:v.closeAll)||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let s=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){let r=n[i];if(e.test&&e.test.toLowerCase()!==r.name.toLowerCase())continue;if(s){null!=(null==e?void 0:e.skipToTest)&&r.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(s=!1);continue}(null==r?void 0:r.options)&&(r.options.owner=null!==(A=null!==(x=null!==(T=null===(w=n[i].options)||void 0===w?void 0:w.owner)&&void 0!==T?T:null==t?void 0:t.owner)&&void 0!==x?x:f)&&void 0!==A?A:"");let l=yield L(r,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(P=null===(E=n[i].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==P?P:o:null===(k=n[i].options)||void 0===k?void 0:k.timeout,u.name,e.verbose);if(l&&(S.push(Object.assign(Object.assign({},l),{widgetsDifference:C()-$})),e.returnOnFail&&e.skipToTest!==r.name&&!l.success&&!l.skipped))return S}}return S})}function C(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}})}({category:e,test:i,testContext:s,verbose:!0});return t.DataFrame.fromObjects(u)}async function Ai(){await M(Ti,Ti.getModule("package-test.js"))}})(),helm_test=s})();
|
|
1
|
+
var helm_test;(()=>{var t={982(t,e,i){var s;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function i(t,i,s,n,r){for(var o,l,a,c,h,d,u,p,f,g,m,y,b;r>=64;){for(o=i[0],l=i[1],a=i[2],c=i[3],h=i[4],d=i[5],u=i[6],p=i[7],g=0;g<16;g++)m=n+4*g,t[g]=(255&s[m])<<24|(255&s[m+1])<<16|(255&s[m+2])<<8|255&s[m+3];for(g=16;g<64;g++)y=((f=t[g-2])>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,b=((f=t[g-15])>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,t[g]=(y+t[g-7]|0)+(b+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&u)|0)+(p+(e[g]+t[g]|0)|0)|0,b=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&l^o&a^l&a)|0,p=u,u=d,d=h,h=c+y|0,c=a,a=l,l=o,o=y+b|0;i[0]+=o,i[1]+=l,i[2]+=a,i[3]+=c,i[4]+=h,i[5]+=d,i[6]+=u,i[7]+=p,n+=64,r-=64}return n}var s=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var s=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[s++],e--;64===this.bufferLength&&(i(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(s=i(this.temp,this.state,t,s,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[s++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,s=this.bufferLength,n=e/536870912|0,r=e<<3,o=e%64<56?64:128;this.buffer[s]=128;for(var l=s+1;l<o-8;l++)this.buffer[l]=0;this.buffer[o-8]=n>>>24&255,this.buffer[o-7]=n>>>16&255,this.buffer[o-6]=n>>>8&255,this.buffer[o-5]=n>>>0&255,this.buffer[o-4]=r>>>24&255,this.buffer[o-3]=r>>>16&255,this.buffer[o-2]=r>>>8&255,this.buffer[o-1]=r>>>0&255,i(this.temp,this.state,this.buffer,0,o),this.finished=!0}for(l=0;l<8;l++)t[4*l+0]=this.state[l]>>>24&255,t[4*l+1]=this.state[l]>>>16&255,t[4*l+2]=this.state[l]>>>8&255,t[4*l+3]=this.state[l]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var i=0;i<this.state.length;i++)this.state[i]=t[i];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=s;var n=function(){function t(t){this.inner=new s,this.outer=new s,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new s).update(t).finish(e).clean();else for(var i=0;i<t.length;i++)e[i]=t[i];for(i=0;i<e.length;i++)e[i]^=54;for(this.inner.update(e),i=0;i<e.length;i++)e[i]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),i=0;i<e.length;i++)e[i]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function r(t){var e=(new s).update(t),i=e.digest();return e.clean(),i}function o(t,e){var i=new n(t).update(e),s=i.digest();return i.clean(),s}function l(t,e,i,s){var n=s[0];if(0===n)throw new Error("hkdf: cannot expand more");e.reset(),n>1&&e.update(t),i&&e.update(i),e.update(s),e.finish(t),s[0]++}t.HMAC=n,t.hash=r,t.default=r,t.hmac=o;var a=new Uint8Array(t.digestLength);t.hkdf=function(t,e,i,s){void 0===e&&(e=a),void 0===s&&(s=32);for(var r=new Uint8Array([1]),c=o(e,t),h=new n(c),d=new Uint8Array(h.digestLength),u=d.length,p=new Uint8Array(s),f=0;f<s;f++)u===d.length&&(l(d,h,i,r),u=0),p[f]=d[u++];return h.clean(),d.fill(0),r.fill(0),p},t.pbkdf2=function(t,e,i,s){for(var r=new n(t),o=r.digestLength,l=new Uint8Array(4),a=new Uint8Array(o),c=new Uint8Array(o),h=new Uint8Array(s),d=0;d*o<s;d++){var u=d+1;l[0]=u>>>24&255,l[1]=u>>>16&255,l[2]=u>>>8&255,l[3]=u>>>0&255,r.reset(),r.update(e),r.update(l),r.finish(c);for(var p=0;p<o;p++)a[p]=c[p];for(p=2;p<=i;p++){r.reset(),r.update(c).finish(c);for(var f=0;f<o;f++)a[f]^=c[f]}for(p=0;p<o&&d*o+p<s;p++)h[d*o+p]=a[p]}for(d=0;d<o;d++)a[d]=c[d]=0;for(d=0;d<4;d++)l[d]=0;return r.clean(),h}}(e);var n=e.default;for(var r in e)n[r]=e[r];"object"==typeof t.exports?t.exports=n:void 0===(s=function(){return n}.call(e,i,e,t))||(t.exports=s)}()}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{"use strict";i.r(s),i.d(s,{_package:()=>Ti,initAutoTests:()=>Ai,test:()=>xi,tests:()=>d});const t=DG;i(982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var n=function(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function l(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,l)}a((s=s.apply(t,e||[])).next())})};const r=3e4,o=108e5,l=console.log.bind(console),a=console.info.bind(console),c=console.warn.bind(console),h=console.error.bind(console),d={},u="Auto Tests",p="Demo",f="Detectors",g="Core",m={};let y;var b;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${e??"Value"} not defined`)}}(b||(b={}));class _{constructor(t,e,i){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,this.closeAll=!0,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==i&&(this.returnOnFail=i)}}class C{constructor(t,e,i,s){var o;this.category=t,this.name=e,null!=s||(s={}),null!==(o=s.timeout)&&void 0!==o||(s.timeout=r),this.options=s,this.test=()=>n(this,void 0,void 0,function*(){return new Promise((t,e)=>n(this,void 0,void 0,function*(){var s;let n="";try{DG.Test.isInDebug;let t=yield i();try{n=null!==(s=null==t?void 0:t.toString())&&void 0!==s?s:""}catch(t){n="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(n)}))})}}function v(t,e,i,s=0,r="timeout"){return n(this,void 0,void 0,function*(){return new Promise((n,o)=>{const l=t.subscribe(t=>{try{e(t),n("OK")}catch(t){o(t)}finally{l.unsubscribe(),clearTimeout(a)}}),a=setTimeout(()=>{l.unsubscribe(),o(r)},s);i()})})}function w(t,e,i){null==d[y]&&(d[y]={}),null==d[y].tests&&(d[y].tests=[]),d[y].tests.push(new C(y,t,e,i))}function T(t,e=!0,i){if(i=i?`${i}, `:"",t!==e)throw new Error(`${i}Expected "${e}", got "${t}"`)}function x(t,e,i=.001,s){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const n=Math.abs(t-e)<i;if(T(n,!0,`${null!=s?s:""} (tolerance = ${i}; a = ${t}, e = ${e})`),!n)throw new Error(`Expected ${e}, got ${t} (tolerance = ${i})`)}function A(t,e){for(const[i,s]of Object.entries(e)){if(!t.hasOwnProperty(i))throw new Error(`Expected property "${i}" not found`);const e=t[i];if(e instanceof Array&&s instanceof Array)E(e,s);else if(e instanceof Object&&s instanceof Object)A(e,s);else if(Number.isFinite(e)&&Number.isFinite(s))x(e,s);else if(e!=s)throw new Error(`Expected (${s}) for key '${i}', got (${e})`)}}function E(t,e){const i=t.length,s=e.length;if(i!=s)throw new Error(`Arrays are of different length: actual array length is ${i} and expected array length is ${s}`);for(let s=0;s<i;s++)if(t[s]instanceof Array&&e[s]instanceof Array)E(t[s],e[s]);else if(t[s]instanceof Object&&e[s]instanceof Object)A(t[s],e[s]);else if(t[s]!=e[s])throw new Error(`Expected ${e[s]} at position ${s}, got ${t[s]}`)}function P(t,e,i){var s;y=t,e(),d[y]&&(d[y].clear=null===(s=null==i?void 0:i.clear)||void 0===s||s,d[y].timeout=null==i?void 0:i.timeout,d[y].benchmarks=null==i?void 0:i.benchmarks,d[y].stressTests=null==i?void 0:i.stressTests,d[y].owner=null==i?void 0:i.owner)}function k(t){null==d[y]&&(d[y]={}),d[y].before=t}function S(t){null==d[y]&&(d[y]={}),d[y].after=t}function I(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function M(t,i){var s,l,a,c,h,y,b,_,v,w;return n(this,void 0,void 0,function*(){const x=t.id;if(m[x])return;const A=i?i.tests:d;if("DevTools"===t.name||i&&"DevTools"===i._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let i=null!==(s=e.pop())&&void 0!==s?s:t.name,n=e.length?g+": "+e.join(": "):g,o=i.split(" | ");i=o[o.length-1],o.unshift(n),o.pop(),n=o.join(": "),void 0===A[n]&&(A[n]={tests:[],clear:!0}),A[n].tests.push(new C(n,i,t.test,{isAggregated:!1,timeout:null!==(a=null===(l=t.options)||void 0===l?void 0:l.timeout)&&void 0!==a?a:r,skipReason:null===(c=t.options)||void 0===c?void 0:c.skipReason,owner:null===(h=t.options)||void 0===h?void 0:h.owner,benchmark:null!==(b=null===(y=t.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const E=[],P=[],k=[],S=yield grok.dapi.functions.filter(`package.id = "${x}"`).list(),$=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const i of S){const s=i.options.test,l=i.options.demoPath;if(s&&Array.isArray(s)&&s.length)for(let t=0;t<s.length;t++){const e=s[t].matchAll($),l={};Array.from(e).forEach(t=>{t[0].startsWith("skip")?l.skip=t[1]:t[0].startsWith("wait")?l.wait=parseInt(t[2]):t[0].startsWith("cat")?l.cat=t[3]:t[0].startsWith("timeout")&&(l.timeout=parseInt(t[4]))});const a=new C(null!==(_=l.cat)&&void 0!==_?_:u,1===s.length?i.name:`${i.name} ${t+1}`,()=>n(this,void 0,void 0,function*(){const e=yield grok.functions.eval(I(s[t],i));if(l.wait&&(yield R(l.wait)),"boolean"==typeof e&&!e)throw`Failed: ${s[t]}, expected true, got ${e}`}),{skipReason:l.skip,timeout:DG.Test.isInBenchmark?null!==(v=l.benchmarkTimeout)&&void 0!==v?v:o:null!==(w=l.timeout)&&void 0!==w?w:r});if(l.cat){const t=l.cat;void 0===A[t]&&(A[t]={tests:[],clear:!0}),A[t].tests||(A[t].tests=[]),A[t].tests.push(a)}else E.push(a)}if(l){const t=i.options.demoWait?parseInt(i.options.demoWait):void 0,e=new C(p,i.friendlyName,()=>n(this,void 0,void 0,function*(){yield R(300),grok.shell.clearLastError(),yield i.apply(),yield R(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}),{skipReason:i.options.demoSkip});P.push(e)}if(i.hasTag("semTypeDetector")){let s=e;i.options.testData&&(s=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${i.options.testData}`));const r=new C(f,i.friendlyName,()=>n(this,void 0,void 0,function*(){const e=[];console.log(`System:AppData/${t.nqName}/${i.options.testData}`);for(const t of s.clone().columns){const s=yield i.apply([t]);e.push(s||t.semType)}const n=e.filter(t=>t);T(n.length,1),i.options.testDataColumnName&&T(n[0],i.options.testDataColumnName)}),{skipReason:i.options.skipTest});k.push(r)}}m[x]=!0,E.length>0&&(A[u]={tests:E,clear:!0}),P.length>0&&(A[p]={tests:P,clear:!0}),k.length>0&&(A[f]={tests:k,clear:!1})})}function N(t){return n(this,void 0,void 0,function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`})}function L(t,e,i,s,o,a){var c,d,u,p,f,g,m,y,b,_,C,v,w,T;return n(this,void 0,void 0,function*(){let n;i.length=0;const x=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let A=(null===(c=t.options)||void 0===c?void 0:c.skipReason)||x,E=x?"skipped":null===(d=t.options)||void 0===d?void 0:d.skipReason;if(DG.Test.isInBenchmark&&!(null===(u=t.options)||void 0===u?void 0:u.benchmark))return void l(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);A&&!DG.Test.isInBenchmark&&l(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),A||l(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const P=Date.now(),k=new Date(P).toISOString();try{if(A)n={name:t.name,owner:null!==(f=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==f?f:"",category:t.category,logs:"",date:k,success:!0,result:E,ms:0,skipped:!0,package:null!=o?o:"",flaking:DG.Test.isReproducing};else{let e=null!=s?s:r;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),n={name:t.name,owner:null!==(m=null===(g=t.options)||void 0===g?void 0:g.owner)&&void 0!==m?m:"",category:t.category,logs:"",date:k,success:!0,result:null!==(y=(yield D(t.test,e)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=o?o:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){h(e),n={name:t.name,owner:null!==(_=null===(b=t.options)||void 0===b?void 0:b.owner)&&void 0!==_?_:"",category:t.category,logs:"",date:k,success:!1,result:yield N(e),ms:0,skipped:!1,package:null!=o?o:"",flaking:!1}}if((null===(C=t.options)||void 0===C?void 0:C.isAggregated)&&n.result.constructor===DG.DataFrame){const t=n.result.col("success");if(t&&(n.success=t.stats.sum===t.length),!a){const t=n.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),n.result=t}n.result=n.result.toCsv()}if(n.logs=i.join("\n"),n.ms=Date.now()-P,A||l(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${n.success?"success":"error"}}} for ${n.ms} ms`),n.success||l(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${n.result}`),n.category=t.category,n.name=t.name,n.owner=null!==(w=null===(v=t.options)||void 0===v?void 0:v.owner)&&void 0!==w?w:"",!x){let e={success:n.success,result:n.result,ms:n.ms,date:n.date,skipped:n.skipped,category:t.category,name:t.name,logs:n.logs,owner:n.owner,flaking:DG.Test.isReproducing&&n.success,package:n.package};if(n.result.constructor==Object){const t=Object.keys(n.result).reduce((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:n.result[e]}),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(T=e.result)||void 0===T?void 0:T.toJson())||""),yield grok.shell.reportTest("package",e)}return n})}function O(t){const e=t.slice();return e.sort(()=>Math.random()-.5),e}function R(t){return n(this,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,t))})}function F(t,e="Timeout exceeded",i=500,s=50){return n(this,void 0,void 0,function*(){return new Promise((n,r)=>{setTimeout(()=>{clearInterval(o),r(new Error(e))},i);const o=setInterval(()=>{t()&&(clearInterval(o),n(null))},s)})})}function D(t,e,i="EXECUTION TIMEOUT"){return n(this,void 0,void 0,function*(){let s=null;const n=new Promise((t,n)=>{s=setTimeout(()=>{n(i)},e)});try{return yield Promise.race([t(),n])}finally{s&&clearTimeout(s)}})}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]),P("_first",()=>{w("_first",async()=>{})});const H=/\{(\*\.)+/g,B=/\.(\*\.)+/g,G=/(\.\*)+\}/g;function V(t){const e=[];if(null!=(t=Y(t,"$")[0])&&""!==t){const i=Y(t,"|");for(let s=0;s<i.length;++s){let n=(t=z(i[s]).str).indexOf("{");n=(t=t.substring(n+1)).indexOf("}");const r=Y(t=t.substring(0,n),".");for(const t of r)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const i=U(t,1,"[","]"),s=t.substring(1,i);e.push(s);const n=t.substring(i+1);r.push(n)}else if(t.includes("[")&&t.endsWith("]")){const i=W(t,t.length-2,"[","]"),s=t.substring(i+1,t.length-1);e.push(s);const n=t.substring(0,i);r.push(n)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),i=t.substring(t.lastIndexOf(")")+1),s=[e,t.substring(e.length+1,t.length-i.length-1),i];for(const t of s)r.push(t)}else e.push(t)}}return e}function U(t,e,i,s){let n=e,r=0;for(;n<t.length;){if(t[n]===i&&r++,t[n]===s){if(0===r)return n;r--}n++}return-1}function W(t,e,i,s){let n=e,r=0;for(;n>=0;){if(t[n]===s&&r++,t[n]===i){if(0===r)return n;r--}n--}return-1}function Y(t,e){const i=[];let s="",n=0,r=0,o=0,l=0;for(let a=0;a<t.length;++a){let c=t.substring(a,a+1);if(c==e&&0==r&&0==n&&0==o&&0==l)i.push(s),s="";else{if(s+=c,l>0&&"\\"==c&&a+1<t.length){++a;const e=t.substring(a,a+1);s+=e,c+=e}'"'==c?a>0&&"\\"==t.substring(a-1,a)||(l=0==l?1:0):"["==c?++r:"]"==c?--r:"("==c?++n:")"==c?--n:"{"==c?++o:"}"==c&&--o}}return i.push(s),i}function z(t){const e=q(t,'"');if(null!=e.tag)return e;const i=q(t,"'");return{tag:e.tag,repeat:i.tag,str:i.str}}function q(t,e){let i=null;if(t.endsWith(e)){let s=t.length-1;for(;s>0&&(s=t.lastIndexOf(e,s-1),!(s<=0||"\\"!=t.substring(s-1,s))););s>0&&s<t.length-1&&(i=t.substring(s+1,t.length-1),t=t.substring(0,s))}return null!=i&&(i=function(t){return null==t||""===t?t:t.replace(/[\\]./g,function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}})}(i.replace(new RegExp("\\"+e,"g"),e))),{tag:i,str:t}}const K=ui;t.JsInputBase;async function j(){const e="Helm",i=t.Func.find({package:e,name:"getHelmHelper"});if(0===i.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await i[0].prepare().call()).getOutputParamValue()}async function Q(){await j()}async function X(t,e=5e3){await R(100),await v(t.onAfterDrawContent,()=>{},()=>{t.invalidate()},e)}async function J(e){const i=await async function(t){return await Ti.files.readAsText(t)}(e),s=t.DataFrame.fromCsv(i);return s.name=e.replace(".csv",""),s}async function Z(){const e=t.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}Error,K.input.helmAsync=async function(t,e){return(await j()).createHelmInput(t,e)},P("Helm",()=>{const t=[["L-hArg(Et,Et)","E","F","G","C","E"],["L-hArg(Et,Et)","L-hArg(Et,Et)","E","F","G"],["dhp","m1A","p","r","T","p","r","T","p","r","G","p"],["r","mo6pur","p","r","T","p","r","T","p","r","G","p"],["afhna","mo6pur","36SS","r","T","p"]],e=["complex-monomer","complex-monomer+side-chain","complex-monomer+side-chain-RNA","complex-side-chain","complex+side-chain+linker"];k(async()=>{await Q()}),w("parseHelm",async()=>{const t=[["meI","hHis","Aca","N","T","dK","Thr_PO3H2","D-Tyr_Et","Aze","dV","E","Phe_4Me"],["A","C","T","G","W","E","Q"],["R","U","P","T","A"],["A","*","G","C"]],e=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.Aze.dV.E.N.dV.Phe_4Me}$$$","PEPTIDE1{A.C.T.G.C.T.W.G.T.W.E.C.W.C.Q.W}|PEPTIDE2{A.C.T.G.C.T.W.G.T.W.E.Q}$PEPTIDE1,PEPTIDE1,5:R3-14:R3|PEPTIDE2,PEPTIDE1,2:R3-12:R3$$$","RNA1{R(U)P.R(T)P}|RNA2{P.R(A)P.R(A)}$RNA1,RNA2,2:pair-6:pair|RNA1,RNA2,5:pair-3:pair$$$","PEPTIDE1{A.*.G.C}$$$$V2.0"];for(let i=0;i<e.length;++i){const s=new Set(V(e[i])),n=Array.from(s);T(JSON.stringify(n),JSON.stringify(t[i]))}}),["PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0","PEPTIDE1{[L-hArg(Et,Et)]([L-hArg(Et,Et)]).E.F.G}$$$$","RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{r([mo6pur])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{[afhna]([mo6pur])[36SS].r(T)p}$$$$V2.0"].forEach((i,s)=>{w(e[s],async()=>{const e=V(i);e.sort();const n=t[s];n.sort(),E(e,n)})})});const tt=grok,et="Libraries",it="Settings",st="DuplicateMonomerPreferences",nt=4e3,rt="nextChunk";let ot=Promise.resolve();async function lt(){let t;return ot=ot.then(async()=>{const e=await tt.userSettings.getValue(et,it,!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const i=await async function(){let t=await tt.userSettings.getValue(et,st,!0)??"";if(!t)return{};let e=1;for(;t.endsWith(rt);){const i=e.toString().length,s=new Array(i).fill(0).reduce((e,s,n)=>e+t.charAt(t.length-i+n-9),""),n=`${st}${s}`,r=await tt.userSettings.getValue(et,n,!0)??"";t=t.slice(0,t.length-9-s.length)+r,e++}try{return JSON.parse(t)}catch(t){return console.error(`Failed to parse duplicateMonomerPreferences from user settings: ${t}`),{}}}();t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{};for(const e in i){t.duplicateMonomerPreferences[e]=t.duplicateMonomerPreferences[e]??{};for(const s in i[e])for(const n of i[e][s])t.duplicateMonomerPreferences[e][n]=s}}),await ot,t}async function at(t){ot=ot.then(async()=>{t.duplicateMonomerPreferences=t.duplicateMonomerPreferences??{};const e={};for(const i in t.duplicateMonomerPreferences){e[i]={};for(const s in t.duplicateMonomerPreferences[i]){const n=t.duplicateMonomerPreferences[i][s];e[i][n]=e[i][n]??[],e[i][n].push(s)}}await async function(t){const e=JSON.stringify(t),i=Math.ceil(e.length/nt);for(let t=0;t<i;t++){const s=0===t?st:`${st}${t}`,n=t<i-1?`${t+1}`:"",r=e.slice(t*nt,(t+1)*nt),o=n?r+n+rt:r;await tt.userSettings.add(et,s,o,!0)}}(e),await tt.userSettings.add(et,it,JSON.stringify(t),!0)}),await ot}P("findMonomers",()=>{let t,e;k(async()=>{await Q(),t=await Z(),e=await lt(),await t.loadMonomerLibForTests()}),S(async()=>{await at(e),await t.loadMonomerLib(!0)});const i={withoutMissed:{test:"PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set},withMissed:{test:"PEPTIDE1{meI.missed2.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set(["missed2"])}};for(const[t,e]of Object.entries(i))w(t,async()=>{s(e.test,e.tgt)});function s(e,i){const s=t.getMonomerLib(),n=function(t,e){return new Set(t.filter(t=>e?.getMonomer(null,t)))}(V(e),s);A(n,i)}});const ct=$;var ht=i.n(ct);const dt=rxjs;var ut,pt,ft;class gt{constructor(t,e,i){this.name=t,this.alphabet=e,this.cutoff=i}}!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(ut||(ut={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(pt||(pt={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(ft||(ft={}));const mt=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 gt(pt.PT,mt.fasta.peptide,.5),new gt(pt.DNA,mt.fasta.dna,.55),new gt(pt.RNA,mt.fasta.rna,.55),ut.FASTA,ut.SEPARATOR,ut.HELM,ut.BILN,wu;class yt{static makePalette(t,e=!1,i=yt){const s={};return t.forEach(t=>{const i=t[0],n=t[1];i.forEach((t,i)=>{s[t]=this.colourPalette[n][e?0:i]})}),new i(s)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}yt.undefinedColor="rgb(100,100,100)",yt.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 bt extends yt{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,bt)),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,bt)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new bt({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 bt.aaSynonyms?bt.aaSynonyms[t]:t;return super.get(e)}}bt.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class _t{static getPalette(t="grok"){switch(t){case"grok":return bt.GrokGroups;case"lesk":return bt.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,i="",s="";for(const n of t)"("==n?e++:")"==n?e--:e?i+=n:s+=n;return isNaN(parseInt(i))?[s,i]:[s,""]}static getColorAAPivot(t="",e="grok"){const i=this.getPalette(e);let[s,n]=this.getInnerOuter(t);if(s=s.length>6?`${s.slice(0,3)}...`:s,n=n.length>6?`${n.slice(0,3)}...`:n,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in i?[i.get(e),e,n,1]:[this.undefinedColor,s,n,1]}if("d"==t[0]&&t[1]in i&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in i?[i.get(e),e,n,2]:[this.undefinedColor,s,n,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 i?[i.get(e),e,n,3]:[this.undefinedColor,s,n,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 i?[i.get(e),e,n,4]:[this.undefinedColor,s,n,4]}return[this.undefinedColor,s,n,0]}}_t.SemType="Aminoacids",_t.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",_t.undefinedColor="rgb(100,100,100)",_t.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"},_t.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"},_t.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(*)*"},_t.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 Ct{}Ct.SemType="Nucleotides",Ct.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",Ct.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"},"object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,new Set;const vt="object"==typeof process&&process?process:{};let wt=globalThis.AbortController,Tt=globalThis.AbortSignal;if(void 0===wt){Tt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},wt=class{constructor(){e()}signal=new Tt;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==vt.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{var i,s,n,r;t&&(t=!1,i="AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",s="NO_ABORT_CONTROLLER",n="ENOTSUP",r=e,"function"==typeof vt.emitWarning?vt.emitWarning(i,s,n,r):console.error(`[${n}] ${s}: ${i}`))}}Symbol("type"),Symbol.iterator,Symbol.toStringTag;Error;new Map([[123,"lbrace"],[125,"rbrace"],[40,"lparen"],[41,"rparen"],[93,"rbracket"],[124,"pipe"],[46,"dot"],[44,"comma"],[43,"plus"],[58,"colon"],[45,"dash"],[36,"dollar"],[62,"gt"],[63,"question"],[42,"asterisk"],[95,"underscore"],[39,"apos"]]);new Map;var xt="HELM_AA",At="HELM_SUGAR",Et="HELM_BASE",Pt="HELM_LINKER",kt="HELM_CHEM",St="HELM_BLOB",$t="HELM_NUCLEOTIDE",It={PEPTIDE:"PEPTIDE",RNA:"RNA",CHEM:"CHEM",BLOB:"BLOB",G:"G"};var Mt=class{constructor(){this._listeners=new Set,this._completed=!1}subscribe(t){return this._completed?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}next(t){if(!this._completed)for(let e of[...this._listeners])e(t)}complete(){this._completed=!0,this._listeners.clear()}get observerCount(){return this._listeners.size}};function Nt(t){return{line:"#202020",text:"#000000",background:t}}function Lt(t){return{line:"#e0e0e0",text:"#ffffff",background:Yt(t,.25)}}function Ot(t){let e=/^#([0-9a-fA-F]{6})$/.exec(t),i=/^#([0-9a-fA-F]{3})$/.exec(t);if(null!==e){let t=e[1];return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}if(null!==i){let t=i[1];return[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)]}return null}function Rt(t){return t.toString(16).padStart(2,"0")}function Ft(t,e,i){return`#${Rt(t)}${Rt(e)}${Rt(i)}`}function Dt(t,e,i){let s=t/255,n=e/255,r=i/255,o=Math.max(s,n,r),l=Math.min(s,n,r),a=(o+l)/2;if(o===l)return[0,0,a];let c,h=o-l;return c=o===s?60*((n-r)/h+(n<r?6:0)):o===n?60*((r-s)/h+2):60*((s-n)/h+4),[c,a>.5?h/(2-o-l):h/(o+l),a]}function Ht(t,e,i){let s=i;return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function Bt(t,e,i){if(0===e){let t=Math.round(255*i);return[t,t,t]}let s=i<.5?i*(1+e):i+e-i*e,n=2*i-s,r=t/360;return[Math.round(255*Ht(n,s,r+1/3)),Math.round(255*Ht(n,s,r)),Math.round(255*Ht(n,s,r-1/3))]}function Gt(t,e=.3,i=.1){let s=Ot(t);if(null===s)return t;let[n,r,o]=Dt(s[0],s[1],s[2]),l=Math.max(0,Math.min(1,r*(1-e))),a=Math.max(0,Math.min(.95,o+i*(1-o))),[c,h,d]=Bt(n,l,a);return Ft(c,h,d)}function Vt(t){let e=Ot(t);if(null===e)return 0;let i=t=>{let e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)};return.2126*i(e[0])+.7152*i(e[1])+.0722*i(e[2])}function Ut(t){let e=Ot(t);if(null===e)return"#1f2937";let[i,s,n]=Dt(e[0],e[1],e[2]);if(n>.85||s<.15&&n>.7)return"#1f2937";let r=Math.max(.08,n-.3);return function(t){let e=(t.h%360+360)%360,i=Math.max(0,Math.min(1,t.s)),s=Math.max(0,Math.min(1,t.l)),[n,r,o]=Bt(e,i,s);return Ft(n,r,o)}({h:i,s:Math.min(1,s+.1),l:r})}function Wt(t){let e=function(t){let e=Ot(t);return null===e?null:{r:e[0]/255,g:e[1]/255,b:e[2]/255}}(t);if(null===e)return"#1f2937";let i=t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),s=.2126*i(e.r)+.7152*i(e.g)+.0722*i(e.b);return 1.05/(s+.05)>(s+.05)/.05?"#ffffff":"#1f2937"}function Yt(t,e){let i=Ot(t);if(null===i)return t;let s=1-e;return Ft(Math.max(0,Math.min(255,Math.round(i[0]*s))),Math.max(0,Math.min(255,Math.round(i[1]*s))),Math.max(0,Math.min(255,Math.round(i[2]*s))))}var zt={A:Nt("#A0A0FF"),G:Nt("#FF7070"),T:Nt("#A0FFA0"),C:Nt("#FF8C4B"),U:Nt("#FF8080")},qt={R:Nt("#7a85c1"),r:Nt("#7a85c1")},Kt={P:Nt("#9aa5e1"),p:Nt("#9aa5e1")},jt={A:Nt("#C8C8C8"),R:Nt("#145AFF"),N:Nt("#00DCDC"),D:Nt("#E60A0A"),C:Nt("#E6E600"),E:Nt("#00DCDC"),Q:Nt("#E60A0A"),G:Nt("#EBEBEB"),H:Nt("#8282D2"),I:Nt("#0F820F"),L:Nt("#0F820F"),K:Nt("#145AFF"),M:Nt("#E6E600"),F:Nt("#3232AA"),P:Nt("#DC9682"),S:Nt("#FA9600"),T:Nt("#FA9600"),W:Nt("#B45AB4"),Y:Nt("#3232AA"),V:Nt("#0F820F")},Qt={R:Nt("#eeeeee")},Xt={B:Nt("#999999"),G:Nt("#e2e2e2")},Jt={P:Nt("#9aa5e1")},Zt={name:"light",fallback:{line:"#202020",text:"#000000",background:"#eeeeee"},errorTriple:{line:"#cc0000",text:"#000000",background:"#FFFF00"},palette:{[Et]:zt,[At]:qt,[Pt]:Kt,[xt]:jt,[kt]:Qt,[St]:Xt,[$t]:Jt}};function te(t){let e={};for(let[i,s]of Object.entries(t))e[i]=Lt(s.background);return e}var ee={name:"dark",fallback:{line:"#e0e0e0",text:"#ffffff",background:Yt("#eeeeee",.5)},errorTriple:{line:"#ff5050",text:"#ffffff",background:Yt("#FFFF00",.4)},palette:{[Et]:te(zt),[At]:te(qt),[Pt]:te(Kt),[xt]:te(jt),[kt]:te(Qt),[St]:te(Xt),[$t]:te(Jt)}};function ie(t,e,i=Zt){if(null===t)return{...i.errorTriple};let s=t.meta?.colors;if(void 0!==s){let t="light"===i.name?s.light:"dark"===i.name?s.dark:void 0;if(void 0!==t)return{...t,line:Ut(t.background)};if(void 0!==s.default)return{...s.default,line:Ut(s.default.background)}}let n=t.naturalAnalog;if(void 0!==n&&""!==n){let t=i.palette[e];if(void 0!==t){let e=t[n];if(void 0!==e)return{...e,line:Ut(e.background),text:Wt(e.background)}}}return{...i.fallback,line:Ut(i.fallback.background),text:Wt(i.fallback.background)}}function se(t){switch(t.polymerType){case It.PEPTIDE:return xt;case It.CHEM:return kt;case It.BLOB:return St;case It.RNA:if("Branch"===t.monomerType)return Et;if("Backbone"===t.monomerType){let e=t.naturalAnalog;return"P"===e||"p"===e?Pt:At}return null;default:return null}}new Set(["PEPTIDE","RNA","CHEM","BLOB"]),new Set(["Backbone","Branch","Terminal","Undefined"]);new Set(["?","*","_","X","N"]);Math.PI;function ne(t,e){let i=Math.min(t.x,e.x),s=Math.min(t.y,e.y);return{x:i,y:s,width:Math.max(t.x+t.width,e.x+e.width)-i,height:Math.max(t.y+t.height,e.y+e.height)-s}}function re(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function oe(t){if(0===t.length)return"";let e=t[0],i=`M ${re(e.x)} ${re(e.y)}`;for(let e=1;e<t.length;e++){let s=t[e];i+=` L ${re(s.x)} ${re(s.y)}`}return i+=` L ${re(e.x)} ${re(e.y)} Z`,i}function le(t,e,i,s){let n=[],r=360/e;for(let o=0;o<e;o++){let e=(s+o*r)*Math.PI/180;n.push({x:t.x+i*Math.cos(e),y:t.y+i*Math.sin(e)})}return n}function ae(t,e,i,s){let n=Math.abs(e)/2,r=Math.abs(i)/2,o=Math.max(0,Math.min(s,n,r)),l=t.x-n,a=t.y-r,c=l+2*n,h=a+2*r,d=`M ${re(l+o)} ${re(a)}`;return d+=` L ${re(c-o)} ${re(a)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(c)} ${re(a+o)}`,d+=` L ${re(c)} ${re(h-o)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(c-o)} ${re(h)}`,d+=` L ${re(l+o)} ${re(h)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(l)} ${re(h-o)}`,d+=` L ${re(l)} ${re(a+o)}`,d+=` A ${re(o)} ${re(o)} 0 0 1 ${re(l+o)} ${re(a)}`,d+=" Z",d}function ce(t,e,i){let s=Math.abs(e),n=Math.abs(i);return`M ${re(t.x-s)} ${re(t.y)} A ${re(s)} ${re(n)} 0 1 0 ${re(t.x+s)} ${re(t.y)} A ${re(s)} ${re(n)} 0 1 0 ${re(t.x-s)} ${re(t.y)} Z`}function he(t,e,i,s){switch(t){case"hexagon":{let t=i*Math.sqrt(3)/2,s=i;return{x:e.x-t,y:e.y-s,width:2*t,height:2*s}}case"diamond":return{x:e.x-i,y:e.y-i,width:2*i,height:2*i};case"pentagon":{let t=Math.cos(18*Math.PI/180)*i,s=-i,n=Math.sin(54*Math.PI/180)*i;return{x:e.x-t,y:e.y+s,width:2*t,height:n-s}}case"rounded-rect":case"blob":{let t=s??i,n=Math.abs(i)/2,r=Math.abs(t)/2;return{x:e.x-n,y:e.y-r,width:2*n,height:2*r}}case"ellipse":{let t=Math.abs(i),n=Math.abs(s??i);return{x:e.x-t,y:e.y-n,width:2*t,height:2*n}}case"circle":{let t=Math.abs(i);return{x:e.x-t,y:e.y-t,width:2*t,height:2*t}}}}var de='"Helvetica Neue", Helvetica, Arial, sans-serif';function ue(t){return{aa:{size:.72*t,strokeWidth:5},sugar:{size:1.39*t,strokeWidth:5,cornerRadius:.3*t},base:{size:.88*t,strokeWidth:5},linker:{size:.63*t,strokeWidth:5},chem:{size:1.49*t,strokeWidth:5,cornerRadius:.5*t},blob:{size:1.64*t,strokeWidth:5,cornerRadius:.8*t},nucleotide:{size:.98*t,strokeWidth:5}}}var pe={name:"light",background:"#ffffff",defaultStroke:"#202020",defaultFill:"#ffffff",selectionColor:"#FFC107",highlightColor:"#A4E2DC",errorColor:"#cc0000",fontSize:14,fontFamily:de,bondLength:28,textColor:"#000000",idColor:"#00aa00",annotationColor:"#FFA500",tagDotColor:"#dd2222",hbondColor:"#888888",nonCanonicalHbondColor:"#cc8800",crossPolymerBondColor:"#1f5fcd",colorTheme:Zt,palette:{softenCanvas:!1},shapes:ue(14)};ue(14);function fe(t,e){switch(e){case xt:return t.shapes.aa;case At:return t.shapes.sugar;case Et:return t.shapes.base;case Pt:return t.shapes.linker;case kt:return t.shapes.chem;case St:return t.shapes.blob;case $t:return t.shapes.nucleotide}}function ge(t){switch(t){case xt:return"hexagon";case At:return"rounded-rect";case Et:return"diamond";case Pt:return"circle";case kt:return"rounded-rect";case St:return"blob";case $t:return"pentagon"}}function me(t,e,i=0){let s=fe(e,t.biotype);if("*"===t.symbol)return function(t,e){return ce(t,e,e)}(t.p,s.size+i);switch(ge(t.biotype)){case"hexagon":{let e=0===i?0:i/Math.cos(Math.PI/6);return function(t,e,i=-30){return oe(le(t,6,e,i))}(t.p,s.size+e)}case"diamond":{let e=0===i?0:i/Math.cos(Math.PI/4);return function(t,e){return oe([{x:t.x,y:t.y-e},{x:t.x+e,y:t.y},{x:t.x,y:t.y+e},{x:t.x-e,y:t.y}])}(t.p,s.size+e)}case"pentagon":{let e=0===i?0:i/Math.cos(Math.PI/5);return function(t,e,i=-90){return oe(le(t,5,e,i))}(t.p,s.size+e)}case"rounded-rect":return ae(t.p,s.size+2*i,s.size+2*i,(s.cornerRadius??0)+i);case"blob":return function(t,e,i,s){return ae(t,e,i,s)}(t.p,s.size+2*i,s.size+2*i,(s.cornerRadius??0)+i);case"circle":return ce(t.p,s.size+i,s.size+i)}}function ye(t,e){let i,s=fe(e,t.biotype),n="*"===t.symbol?"circle":ge(t.biotype);switch(n){case"hexagon":case"diamond":case"pentagon":case"circle":i=he(n,t.p,s.size);break;case"rounded-rect":case"blob":i=he(n,t.p,s.size,s.size)}let r=s.strokeWidth/2;return{x:i.x-r,y:i.y-r,width:i.width+2*r,height:i.height+2*r}}function be(t,e){return fe(e,t.biotype)}var _e=/[&"'<>]/;function Ce(t){return _e.test(t)?t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):t}function ve(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function we(t,e,i){let s=`<${t}`;if(void 0!==e)for(let t in e){let i=e[t];if(void 0!==i&&!1!==i){if(!0===i){s+=` ${t}`;continue}s+="number"==typeof i?` ${t}="${ve(i)}"`:` ${t}="${Ce(i)}"`}}return void 0===i?`${s}/>`:"string"==typeof i?`${s}>${i}</${t}>`:`${s}>${i.join("")}</${t}>`}function Te(t,e,i){if(0===i.size)return we("g",{class:"hw-layer hw-highlights"},"");let s=[];for(let n of t.atoms){if(!i.has(n.id))continue;let t=me(n,e,(be(n,e).strokeWidth+3)/2);s.push(we("path",{d:t,class:"hw-highlight",fill:"none",stroke:e.highlightColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":n.symbol,"data-ring-atom-id":n.id,"data-testid":`highlight-ring-${n.id}`}))}return we("g",{class:"hw-layer hw-highlights"},s.join(""))}function xe(t,e,i){if(0===i.size)return we("g",{class:"hw-layer hw-selections"},"");let s=[];for(let n of t.atoms){if(!i.has(n.id))continue;let t=me(n,e,(be(n,e).strokeWidth+3)/2);s.push(we("path",{d:t,class:"hw-selection",fill:"none",stroke:e.selectionColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":n.symbol,"data-ring-atom-id":n.id,"data-testid":`selection-ring-${n.id}`}))}return we("g",{class:"hw-layer hw-selections"},s.join(""))}new WeakMap;new Map;var Ae=class{constructor(t,e){this.atoms=t,this.bonds=e,this.isEmpty=0===t.size&&0===e.size,Object.freeze(this)}};new Ae(new Set,new Set);function Ee(t){let e=t.ownerDocument;if(null!=e)return e;let i=globalThis;if(void 0!==i.document)return i.document;throw new Error("EditorView: no Document available (host.ownerDocument is null).")}function Pe(t,e,i,s){let n=t.createElement(e);if(void 0!==i)for(let t of Object.keys(i)){let e=i[t];!1===e||void 0===e||n.setAttribute(t,!0===e?"":String(e))}if(void 0!==s)for(let e of s)"string"==typeof e?n.appendChild(t.createTextNode(e)):n.appendChild(e);return n}function ke(t,e,i=220,s=140){if(null==t||""===e)return null;try{let n=t.get_mol(e);if(null===n)return null;let r=n.get_svg(i,s);return n.delete(),r}catch{return null}}function Se(t,e,i){let s="data-testid";for(let i=0;i<t.body.children.length;i++){let n=t.body.children[i];if(void 0!==n&&n.getAttribute(s)===e)return n}let n=Pe(t,"div",{class:i,[s]:e});return n.style.display="none",t.body.appendChild(n),n}function $e(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(e.appendChild(Pe(t,"div",{class:"hw-tooltip__symbol"},[i.symbol])),void 0!==i.name&&""!==i.name&&i.name!==i.symbol&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__name"},[i.name])),void 0!==i.rdkitSvg&&null!==i.rdkitSvg&&""!==i.rdkitSvg){let s={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(s["data-testid"]=i.rdkitTestid);let n=Pe(t,"div",s);n.innerHTML=i.rdkitSvg,e.appendChild(n)}void 0!==i.hint&&""!==i.hint&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__hint"},[i.hint]))}function Ie(t,e,i){let s=t.style;s.display="block",s.left=`${e+12}px`,s.top=`${i+12}px`}function Me(t){null!==t&&(t.style.display="none")}function Ne(t){let e=t.body;if(null!=e)for(let t=0;t<e.children.length;t++){let i=e.children[t];if(void 0===i)continue;let s=void 0===i.getAttribute?null:i.getAttribute("data-testid");null!=s&&s.endsWith("-tooltip")&&Me(i)}}var Le=class t{constructor(t,e,i){this._baseTransform="",this._viewport={scale:1,offset:{x:0,y:0}},this._pinnedBbox=null,this._tooltip=null,this._bondTooltip=null,this._rdkitSvgCache=new Map,this._unsubs=[],this._destroyed=!1,this.host=t,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._width=i?.width??400,this._height=i?.height??200,function(t){let e=Ee(t);if(null!==e.querySelector("style[data-hw-editor-view-styles]"))return;let i=e.createElement("style");i.setAttribute("data-hw-editor-view-styles",""),i.textContent=".hw-editor-view{position:relative;display:block;overflow:hidden;outline:none;}.hw-editor-view svg{display:block;user-select:none;}.hw-editor-view.hw-view-only{cursor:default;}";let s=e.head??e.documentElement;null!==s&&s.appendChild(i)}(t);let s=this._doc.createElement("div");s.setAttribute("class","hw-editor-view"),t.appendChild(s),this._tooltip=Se(this._doc,"atom-tooltip","hw-atom-tooltip"),this._bondTooltip=Se(this._doc,"bond-tooltip","hw-bond-tooltip"),this._svgRoot=this._renderFresh(),this._unsubs.push(e.on("mol:changed",t=>{this._hideTooltip(),this._hideBondTooltip(),("setHelm"===t.reason||"cleanLayout"===t.reason||"initial"===t.reason)&&(this._pinnedBbox=null),this._renderFresh()})),this._unsubs.push(e.on("selection:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("highlight:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("theme:change",()=>{this._renderFresh()})),this._unsubs.push(e.on("view:resize",t=>{this._applyResize(t.width,t.height)})),this._unsubs.push(e.on("view:viewport-change",t=>{this._viewport=t.viewport,this._applyViewport(t.viewport)})),this._unsubs.push(e.on("view:fit-to-content",()=>{this._pinnedBbox=null,this._renderFresh()})),this._unsubs.push(e.on("monomer:hover",t=>{this._showTooltip(t.atom,t.clientX,t.clientY)})),this._unsubs.push(e.on("monomer:hover-end",()=>{this._hideTooltip()})),this._unsubs.push(e.on("bond:hover",t=>{this._showBondTooltip(t.bond,t.clientX,t.clientY)})),this._unsubs.push(e.on("bond:hover-end",()=>{this._hideBondTooltip()})),this._unsubs.push(e.on("bond:preview",t=>{this._paintBondPreview(t.start.p,t.cursor,null!==t.candidate)})),this._unsubs.push(e.on("bond:preview-end",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("bond:cancel",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("selection:rectangle-start",t=>{this._paintSelectionRect(t.origin,t.origin)})),this._unsubs.push(e.on("selection:rectangle-update",t=>{this._paintSelectionRectFromRect(t.rect)})),this._unsubs.push(e.on("selection:rectangle-end",()=>{this._clearSelectionRect()}))}get svgRoot(){return this._svgRoot}get width(){return this._width}get height(){return this._height}resize(t,e){this._destroyed||(this._width=t,this._height=e,this._renderFresh())}redraw(){this._destroyed||this._renderFresh()}destroy(){if(this._destroyed)return;this._destroyed=!0;for(let t of this._unsubs)t();this._unsubs.length=0;let t=this.host.querySelector(".hw-editor-view");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t),Me(this._tooltip),Me(this._bondTooltip),this._tooltip=null,this._bondTooltip=null}_renderFresh(){let t=this._editor.getService(),e=this._currentTheme(),i=this._editor.getMol();null===this._pinnedBbox&&(this._pinnedBbox=function(t,e=pe){if(0===t.atoms.length)return{x:0,y:0,width:0,height:0};let i=ye(t.atoms[0],e);for(let s=1;s<t.atoms.length;s++)i=ne(i,ye(t.atoms[s],e));return i}(i,e));let s=t.renderMol(i,{width:this._width,height:this._height,theme:e,fixedModelBbox:this._pinnedBbox});this._svgRoot=function(t,e){let i=Ee(t),s=t.querySelector(".hw-editor-view");if(null===s)throw new Error("EditorView.replaceSvg: missing .hw-editor-view wrapper.");let n=i.createElement("div");n.innerHTML=e;let r=n.querySelector("svg");if(null===r)throw new Error("EditorView.replaceSvg: rendered output contained no <svg>.");for(;null!==s.firstChild;)s.removeChild(s.firstChild);return s.appendChild(r),r}(this.host,s);let n=this._svgRoot.querySelector(".hw-content");return this._baseTransform=null!==n?n.getAttribute("transform")??"":"",this._svgRoot.setAttribute("data-testid","editor-svg"),this._applyOverlaysToCurrent(),(1!==this._viewport.scale||0!==this._viewport.offset.x||0!==this._viewport.offset.y)&&this._applyViewport(this._viewport),this._svgRoot}_refreshOverlays(t){this._applyOverlaysToCurrent()}_applyOverlaysToCurrent(){let t=this._editor.getMol(),e=this._editor.getSelection(),i=function(t,e={}){let i=e.theme??pe,s=e.selectedAtomIds??new Set;return{highlightLayer:Te(t,i,e.highlightedAtomIds??new Set),selectionLayer:xe(t,i,s)}}(t,{theme:this._currentTheme(),selectedAtomIds:e.atoms,highlightedAtomIds:this._editorHighlights()});this._spliceLayer("hw-highlights",i.highlightLayer),this._spliceLayer("hw-selections",i.selectionLayer)}_spliceLayer(t,e){let i=this._svgRoot.querySelector(`.${t}`);if(null===i||null===i.parentNode)return;let s=this._doc.createElementNS("http://www.w3.org/2000/svg","svg");s.innerHTML=e;let n=s.querySelector(`.${t}`);null!==n&&i.parentNode.replaceChild(n,i)}_editorHighlights(){let t=this._editor;return"function"==typeof t._currentHighlights?t._currentHighlights():new Set}_currentTheme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyResize(t,e){this._width=t,this._height=e,this._pinnedBbox=null,this._renderFresh()}_applyViewport(t){let e=this._svgRoot.querySelector(".hw-content");if(null===e)return;let i=`translate(${t.offset.x} ${t.offset.y}) scale(${t.scale})`,s=""===this._baseTransform?i:`${i} ${this._baseTransform}`;e.setAttribute("transform",s)}_showTooltip(t,e,i){let s=this._tooltip;if(null===s)return;let n=""===t.symbol?"?":t.symbol,r=t.monomer?.name??"",o=t.bio.positionInChain,l=""===t.bio.chainId?"?":t.bio.chainId,a=""!==r&&r!==n?`${r} @ ${l}:${o}`:`${n} @ ${l}:${o}`,c=this._renderRdkitTooltipSvg(t);$e(this._doc,s,{symbol:n,name:a,rdkitSvg:c,rdkitTestid:"atom-tooltip-rdkit-svg"});let h=""!==r&&r!==n?`${n} — ${r} @ ${l}:${o}`:`${n} @ ${l}:${o}`,d=this._doc.createElement("div");d.setAttribute("class","hw-atom-tooltip__text"),d.style.display="none",d.appendChild(this._doc.createTextNode(h)),s.appendChild(d),Ie(s,e,i)}_renderRdkitTooltipSvg(e){let i=this._editor.getService().options.rdkitModule;if(null==i)return null;let s=e.monomer;if(null===s)return null;let n=s.smiles;if(void 0===n||""===n)return null;let r=`${s.polymerType}:${s.symbol}`;if(this._rdkitSvgCache.has(r))return this._rdkitSvgCache.get(r)??null;let o=ke(i,n,220,140);if(this._rdkitSvgCache.size>=t._RDKIT_CACHE_LIMIT){let t=this._rdkitSvgCache.keys().next().value;void 0!==t&&this._rdkitSvgCache.delete(t)}return this._rdkitSvgCache.set(r,o),o}_hideTooltip(){Me(this._tooltip)}_showBondTooltip(t,e,i){let s=this._bondTooltip;if(null===s)return;let n=Oe(t.r1),r=Oe(t.r2),o=`${t.a1.symbol}@${t.a1.bio.chainId}:${t.a1.bio.positionInChain}`,l=`${t.a2.symbol}@${t.a2.bio.chainId}:${t.a2.bio.positionInChain}`;$e(this._doc,s,{symbol:`${n}-${r} (${t.kind})`,name:`${o} ↔ ${l}`}),Ie(s,e,i)}_hideBondTooltip(){Me(this._bondTooltip)}_paintBondPreview(t,e,i){let s=this._svgRoot.querySelector(".hw-content");if(null===s)return;let n=s.querySelector(".hw-bond-preview");null===n&&(n=this._doc.createElementNS("http://www.w3.org/2000/svg","line"),n.setAttribute("class","hw-bond-preview"),n.setAttribute("data-testid","bond-preview"),n.setAttribute("stroke-dasharray","6 4"),n.setAttribute("stroke-width","2"),n.setAttribute("fill","none"),n.setAttribute("pointer-events","none"),s.appendChild(n)),n.setAttribute("x1",String(t.x)),n.setAttribute("y1",String(t.y)),n.setAttribute("x2",String(e.x)),n.setAttribute("y2",String(e.y)),n.setAttribute("stroke",i?"#1f5fcd":"#999999")}_clearBondPreview(){let t=this._svgRoot.querySelector(".hw-bond-preview");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}_paintSelectionRect(t,e){let i=Math.min(t.x,e.x),s=Math.min(t.y,e.y),n=Math.abs(t.x-e.x),r=Math.abs(t.y-e.y);this._paintSelectionRectAt(i,s,n,r)}_paintSelectionRectFromRect(t){this._paintSelectionRectAt(t.x,t.y,t.width,t.height)}_paintSelectionRectAt(t,e,i,s){let n=this._svgRoot.querySelector(".hw-content");if(null===n)return;let r=n.querySelector(".hw-selection-rect");null===r&&(r=this._doc.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("class","hw-selection-rect"),r.setAttribute("data-testid","selection-rect"),r.setAttribute("fill","rgba(31, 95, 205, 0.08)"),r.setAttribute("stroke","#1f5fcd"),r.setAttribute("stroke-width","1"),r.setAttribute("stroke-dasharray","4 3"),r.setAttribute("pointer-events","none"),n.appendChild(r)),r.setAttribute("x",String(t)),r.setAttribute("y",String(e)),r.setAttribute("width",String(i)),r.setAttribute("height",String(s))}_clearSelectionRect(){let t=this._svgRoot.querySelector(".hw-selection-rect");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}};Le._RDKIT_CACHE_LIMIT=256;function Oe(t){switch(t.kind){case"numeric":return`R${t.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair";case"positional":return`${t.position}pos:R${t.r}`}}var Re=class t{constructor(t,e){this._onClose=null,this._primaryAction=null,this._host=t,this._doc=e.documentImpl??Ee(t);let i=this._doc,s={class:"hw-modal-backdrop",role:"presentation"};void 0!==e.testId&&(s["data-testid"]=`dialog-${e.testId}`);let n=Pe(i,"div",s),r={class:"hw-modal",role:"dialog","aria-modal":"true","aria-label":e.title};void 0!==e.testId&&(r["data-testid"]=`dialog-${e.testId}-frame`);let o=Pe(i,"div",r),l=Pe(i,"div",{class:"hw-modal__header"},[e.title]),a=Pe(i,"div",{class:"hw-modal__body"});o.appendChild(l),o.appendChild(a),n.appendChild(o);let c=t=>{t.stopPropagation()};for(let t of["mousedown","mousemove","mouseup","mouseover","mouseenter","mouseleave","wheel","contextmenu","dblclick","keydown","keyup","keypress"])n.addEventListener(t,c);o.addEventListener("keydown",t=>{let e=t;if("Enter"!==e.key||"TEXTAREA"===e.target?.tagName)return;let i=this._primaryAction;null!==i&&(e.preventDefault?.(),e.stopImmediatePropagation?.(),i())}),n.addEventListener("click",t=>{t.target!==n?t.stopPropagation():this.close()}),this.root=n,this.body=a}static anyOpen(){return t._openStack.length>0}static closeTopmost(){let e=t._openStack[t._openStack.length-1];return void 0!==e&&(e.close(),!0)}open(e){this._onClose=e??null,null===this.root.parentNode&&this._host.appendChild(this.root),t._openStack.includes(this)||t._openStack.push(this),Ne(this._doc)}close(){let e=t._openStack.indexOf(this);e>=0&&t._openStack.splice(e,1),null!==this.root.parentNode&&this.root.parentNode.removeChild(this.root);let i=this._onClose;this._onClose=null,null!==i&&i()}setPrimaryAction(t){this._primaryAction=t}get isOpen(){return null!==this.root.parentNode}};Re._openStack=[];Object.freeze(new Set);function Fe(t){return t.startsWith("[")&&t.endsWith("]")||1===t.length&&/^[A-Za-z]$/.test(t)?t:`[${t}]`}function De(t,e,i){return`${Fe(t)}(${Fe(e)})${Fe(i)}`}var He="http://www.w3.org/2000/svg",Be={sugar:At,base:Et,linker:Pt},Ge={sugar:["r","R"],base:["A"],linker:["p","P"]},Ve={x:70,y:60},Ue={x:140,y:60},We={x:70,y:130},Ye=class t{constructor(t,e,i){this.onValueSet=new Mt,this.onPickModeChange=new Mt,this._slots=new Map,this._favStar=null,this._pickMode=null,this._destroyed=!1,this._builderRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._hooks=i?.paletteHooks??null,this._favHooks=i?.favoriteHooks??null,this.element=Pe(this._doc,"div",{class:"hw-rna-builder","data-testid":"rna-builder"});let s=Pe(this._doc,"div",{class:"hw-rna-builder__header"});if(s.appendChild(Pe(this._doc,"div",{class:"hw-rna-builder__title"},["RNA builder"])),null!==this._favHooks){let t=Pe(this._doc,"span",{class:"hw-rna-builder__fav hw-rna-builder__fav--disabled",role:"button",tabindex:"0","data-testid":"rna-builder-fav-star",title:"Favorite this triplet","aria-pressed":"false","aria-disabled":"true"},["☆"]),e=t=>{t.stopPropagation();let e=this.getSelection();""===e.preview||null===this._favHooks||this._favHooks.toggleFavoriteTriplet(e.sugar,e.base,e.linker)};t.addEventListener("click",e),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&e(t)}),this._favStar=t,s.appendChild(t)}this.element.appendChild(s),this._hintEl=Pe(this._doc,"div",{class:"hw-rna-builder__hint","data-testid":"rna-builder-hint",hidden:!0}),this.element.appendChild(this._hintEl);let n=this._buildSvg();this.element.appendChild(n),this._preview=Pe(this._doc,"div",{class:"hw-rna-builder__preview","data-testid":"rna-builder-preview"}),this.element.appendChild(this._preview),this._addBtn=Pe(this._doc,"button",{class:"hw-rna-builder__add",type:"button","data-testid":"rna-builder-add-btn"},["Add triplet"]),this._addBtn.addEventListener("click",()=>this._onAddClicked()),this.element.appendChild(this._addBtn),t.appendChild(this.element);let r=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),o=e.on("theme:change",()=>{this._destroyed||this._repaintSlotColors()});this._libUnsub=()=>{try{r()}catch{}try{o()}catch{}},this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}refresh(){this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}getSelection(){let t=this._slots.get("sugar")?.value??"",e=this._slots.get("base")?.value??"",i=this._slots.get("linker")?.value??"";return{sugar:t,base:e,linker:i,preview:""!==t&&""!==e&&""!==i?De(t,e,i):""}}setField(t,e){let i=this._slots.get(t);void 0!==i&&(i.value=e,this._setLabelText(i.labelEl,e),this._repaintSlot(i),this._updatePreview(),this.onValueSet.next({field:t,symbol:e}))}startPickMode(t){this._pickMode!==t?(null!==this._pickMode&&this._setSlotPressed(this._pickMode,!1),this._pickMode=t,this._setSlotPressed(t,!0),this._setHintActive(t),this.onPickModeChange.next({field:t}),null!==this._hooks&&this._hooks.beginBiotypeFilter(Be[t],e=>{this.setField(t,e),this._exitPickMode()},()=>{this._exitPickMode()})):this.cancelPickMode()}cancelPickMode(){null!==this._pickMode&&(null!==this._hooks&&this._hooks.endBiotypeFilter(),this._exitPickMode())}getPickMode(){return this._pickMode}triggerAdd(){this._onAddClicked()}destroy(){this._destroyed||(this._destroyed=!0,null!==this._pickMode&&null!==this._hooks&&this._hooks.endBiotypeFilter(),this._libUnsub(),this.onValueSet.complete(),this.onPickModeChange.complete(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}_buildSvg(){let t=this._doc.createElementNS(He,"svg");t.setAttribute("class","hw-rna-builder__triplet"),t.setAttribute("viewBox","0 0 200 180"),t.setAttribute("data-testid","rna-builder-triplet-svg"),t.setAttribute("role","group"),t.setAttribute("aria-label","Triplet preview");let e=this._doc.createElementNS(He,"line");e.setAttribute("class","hw-rna-builder__bond"),e.setAttribute("x1",String(Ve.x+18)),e.setAttribute("y1",String(Ve.y)),e.setAttribute("x2",String(Ue.x-18)),e.setAttribute("y2",String(Ue.y)),t.appendChild(e);let i=this._doc.createElementNS(He,"line");i.setAttribute("class","hw-rna-builder__bond"),i.setAttribute("x1",String(Ve.x)),i.setAttribute("y1",String(Ve.y+18)),i.setAttribute("x2",String(We.x)),i.setAttribute("y2",String(We.y-22)),t.appendChild(i);let s=this._doc.createElementNS(He,"rect");s.setAttribute("class","hw-rna-builder__slot-shape"),s.setAttribute("x",String(-18)),s.setAttribute("y",String(-18)),s.setAttribute("width",String(36)),s.setAttribute("height",String(36)),s.setAttribute("rx","8"),s.setAttribute("ry","8");let n=this._buildSlot("sugar","Pick sugar (backbone)",Ve,s),r=this._doc.createElementNS(He,"circle");r.setAttribute("class","hw-rna-builder__slot-shape"),r.setAttribute("cx","0"),r.setAttribute("cy","0"),r.setAttribute("r",String(18));let o=this._buildSlot("linker","Pick linker",Ue,r),l=this._doc.createElementNS(He,"path");l.setAttribute("class","hw-rna-builder__slot-shape"),l.setAttribute("d","M -22 0 L 0 -22 L 22 0 L 0 22 Z");let a=this._buildSlot("base","Pick base",We,l);return t.appendChild(o.groupEl),t.appendChild(n.groupEl),t.appendChild(a.groupEl),this._slots.set("sugar",n),this._slots.set("linker",o),this._slots.set("base",a),t}_buildSlot(t,e,i,s){let n=this._doc.createElementNS(He,"g");n.setAttribute("class","hw-rna-builder__slot"),n.setAttribute("data-slot",t),n.setAttribute("data-testid",`rna-builder-slot-${t}`),n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label",e),n.setAttribute("aria-pressed","false"),n.setAttribute("transform",`translate(${i.x} ${i.y})`),n.appendChild(s);let r=this._doc.createElementNS(He,"text");r.setAttribute("class","hw-rna-builder__slot-label"),r.setAttribute("data-testid",`rna-builder-${t}-value`),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("text-anchor","middle"),r.setAttribute("dominant-baseline","central"),n.appendChild(r);let o=e=>{e.stopPropagation(),this.startPickMode(t)};return n.addEventListener("click",o),n.addEventListener("keydown",t=>{let e=t;("Enter"===e.key||" "===e.key)&&o(t)}),n.addEventListener("mouseenter",e=>this._showSlotTooltip(t,e)),n.addEventListener("mouseleave",()=>this._hideSlotTooltip()),n.addEventListener("focus",()=>this._showSlotTooltip(t,null)),n.addEventListener("blur",()=>this._hideSlotTooltip()),{id:t,biotype:Be[t],groupEl:n,shapeEl:s,labelEl:r,value:""}}_setLabelText(t,e){let i=[];for(let e=t.firstChild;null!==e;e=e.nextSibling)"title"===e.nodeName||"TITLE"===e.nodeName||i.push(e);for(let e of i)t.removeChild(e);let s=function(t){let e=t.length;return e<=2?16:e<=4?11:e<=7?8:e<=10?6:5}(e);t.setAttribute("font-size",String(s)),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","central");let n=e.length>10?`${e.slice(0,9)}…`:e;t.appendChild(this._doc.createTextNode(n));let r=t.parentNode;if(null!==r){let t=null;for(let e=r.firstChild;null!==e;e=e.nextSibling)if("title"===e.nodeName||"TITLE"===e.nodeName){t=e;break}for(null===t&&(t=this._doc.createElementNS(He,"title"),r.insertBefore(t,r.firstChild));null!==t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._doc.createTextNode(e))}}_repaintSlotColors(){for(let t of this._slots.values())this._repaintSlot(t)}_repaintSlot(t){let e=this._editor.getService().monomerLib,i=this._theme(),s=""===t.value?null:function(t,e,i){return t.getMonomerSet(e).get(i)??null}(e,t.biotype,t.value),n=ie(s,t.biotype,i.colorTheme);t.shapeEl.style.fill=n.background,t.shapeEl.style.stroke=n.line,t.labelEl.style.fill=n.text}_populateDefaults(){let t=this._editor.getService().monomerLib;for(let[e,i]of this._slots.entries()){let s=qe(t,i.biotype),n=Ke(s,Ge[e]),r=""!==i.value&&s.some(t=>t.symbol===i.value)?i.value:n??s[0]?.symbol??"";i.value=r,this._setLabelText(i.labelEl,r)}}_updatePreview(){let t=this.getSelection();for(;null!==this._preview.firstChild;)this._preview.removeChild(this._preview.firstChild);this._preview.appendChild(this._doc.createTextNode(""===t.preview?"-":t.preview)),this._updateFavStar(t)}_updateFavStar(t){if(null===this._favStar||null===this._favHooks)return;let e=""!==t.preview,i=e&&this._favHooks.isFavoriteTriplet(t.sugar,t.base,t.linker);for(;null!==this._favStar.firstChild;)this._favStar.removeChild(this._favStar.firstChild);this._favStar.appendChild(this._doc.createTextNode(i?"★":"☆")),this._favStar.setAttribute("aria-pressed",i?"true":"false"),e?this._favStar.removeAttribute("aria-disabled"):this._favStar.setAttribute("aria-disabled","true");let s="hw-rna-builder__fav"+(i?" hw-rna-builder__fav--active":"")+(e?"":" hw-rna-builder__fav--disabled");this._favStar.setAttribute("class",s)}_onAddClicked(){let t=this.getSelection();""!==t.preview&&this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)}_exitPickMode(){if(null===this._pickMode)return;let t=this._pickMode;this._setSlotPressed(t,!1),this._pickMode=null,this._setHintActive(null),this.onPickModeChange.next({field:null})}_setHintActive(t){let e=this._hintEl;for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(null===t)return void e.setAttribute("hidden","");e.removeAttribute("hidden");let i="sugar"===t?"sugar":"base"===t?"base":"linker";e.appendChild(this._doc.createTextNode(`Pick ${i} from palette`))}_setSlotPressed(t,e){let i=this._slots.get(t);if(void 0===i)return;i.groupEl.setAttribute("aria-pressed",e?"true":"false");let s=(i.groupEl.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-rna-builder__slot--active"!==t).join(" ");i.groupEl.setAttribute("class",e?`${s} hw-rna-builder__slot--active`:s)}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_builderRdkitSvgFor(e){if(null===e)return null;let i=e.smiles;if(void 0===i||""===i)return null;let s=this._rdkit();if(null===s)return null;let n=`${e.polymerType}:${e.symbol}`;if(this._builderRdkitCache.has(n))return this._builderRdkitCache.get(n)??null;let r=ke(s,i,220,140);if(this._builderRdkitCache.size>=t._BUILDER_RDKIT_CACHE_LIMIT){let t=this._builderRdkitCache.keys().next().value;void 0!==t&&this._builderRdkitCache.delete(t)}return this._builderRdkitCache.set(n,r),r}_slotHint(t){switch(t){case"sugar":return"Click to choose a different sugar";case"base":return"Click to choose a different base";case"linker":return"Click to choose a different linker"}}_slotTitle(t,e){let i=""===e?"?":e;switch(t){case"sugar":return`Sugar: ${i}`;case"base":return`Base: ${i}`;case"linker":return`Linker: ${i}`}}_showSlotTooltip(t,e){let i=this._slots.get(t);if(void 0===i)return;let s=this._editor.getService().monomerLib.getMonomerSet(i.biotype),n=""===i.value?null:s.get(i.value)??null,r=Se(this._doc,"builder-tooltip","hw-builder-tooltip");$e(this._doc,r,{symbol:this._slotTitle(t,i.value),name:n?.name??"",rdkitSvg:this._builderRdkitSvgFor(n),rdkitTestid:"builder-tooltip-rdkit-svg",hint:this._slotHint(t)});let o=e;if(null!==o&&"number"==typeof o.clientX&&"number"==typeof o.clientY)Ie(r,o.clientX,o.clientY);else{let t=i.groupEl,e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null;null!==e?Ie(r,e.left+e.width/2,e.top+e.height/2):Ie(r,0,0)}}_hideSlotTooltip(){Me(this._doc.body.querySelector('[data-testid="builder-tooltip"]'))}};Ye._BUILDER_RDKIT_CACHE_LIMIT=256;var ze=Ye;function qe(t,e){let i=t.getMonomerSet(e),s=[];for(let t of i.values())s.push(t);return s.sort((t,e)=>t.symbol.localeCompare(e.symbol)),s}function Ke(t,e){let i=new Set;for(let e of t)i.add(e.symbol);for(let t of e)if(i.has(t))return t;return null}var je="Favorites",Qe={[je]:"★ Favorites",[It.PEPTIDE]:"Peptides",[It.RNA]:"RNA",[It.CHEM]:"CHEM",[It.BLOB]:"BLOB",G:"G"},Xe=[je,It.PEPTIDE,It.RNA,It.CHEM,It.BLOB,"G"],Je="hwe:palette:favorites",Ze="hwe:palette:active-tab";function ti(t){return`${t.sugar}|${t.base}|${t.linker}`}var ei=class t{constructor(t,e,i){this.favoritesChanged=new Mt,this._nextAddUnsub=()=>{},this._favorites=new Set,this._favoriteTriplets=[],this._pendingRnaSelection=null,this._visibleTabs=[je],this._activeTab=je,this._searchInput=null,this._filter="",this._destroyed=!1,this._rnaBuilder=null,this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,this._pickEscapeListener=null,this._pickOutsideClickListener=null,this._paletteRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??Ee(t),this._opts={documentImpl:this._doc,groupByNaturalAnalog:i?.groupByNaturalAnalog??!0,allowFavorites:i?.allowFavorites??!0},this._loadFavorites(),this._activeTab=this._resolveInitialTab(i?.initialTab),this.element=Pe(this._doc,"div",{class:"hw-palette","data-testid":"palette"}),t.appendChild(this.element),this._render(),this._libUnsub=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),this._themeUnsub=e.on("theme:change",()=>{this._destroyed||this.refresh()}),this._nextAddUnsub=e.on("option:change",t=>{this._destroyed||"nextAdd"===t.key&&this._updatePrimedClasses()})}refresh(){this._render()}setFilter(t){this._filter=t.trim().toLowerCase(),null!==this._searchInput&&this._searchInput.value!==t&&(this._searchInput.value=t),this._applyFilter()}setActiveTab(t){this._visibleTabs.includes(t)&&(this._activeTab=t,this._persistActiveTab(),this._applyActiveTabClasses(),this._applyFilter())}getActiveTab(){return this._activeTab}getFavorites(){let t=this._editor.getService().monomerLib,e=[];for(let i of this._favorites)null!==this._findMonomer(t,i)&&e.push(i);return e}setFavorite(t,e){e!==this._favorites.has(t)&&(e?this._favorites.add(t):this._favorites.delete(t),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}clearFavorites(){0===this._favorites.size&&0===this._favoriteTriplets.length||(this._favorites.clear(),this._favoriteTriplets.length=0,this._saveFavorites(),this._render(),this._emitFavoritesChanged())}getFavoriteTriplets(){return this._favoriteTriplets.map(t=>({...t}))}isFavoriteTriplet(t,e,i){let s=ti({sugar:t,base:e,linker:i});return this._favoriteTriplets.some(t=>ti(t)===s)}setFavoriteTriplet(t,e,i,s){let n=ti({sugar:t,base:e,linker:i}),r=this._favoriteTriplets.findIndex(t=>ti(t)===n);s!==r>=0&&(s?this._favoriteTriplets.push({sugar:t,base:e,linker:i}):this._favoriteTriplets.splice(r,1),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}_hidePaletteTooltips(){let t=this._doc.body;Me(t.querySelector('[data-testid="palette-tooltip"]')),Me(t.querySelector('[data-testid="palette-triplet-tooltip"]'))}_emitFavoritesChanged(){this.favoritesChanged.next({favorites:this.getFavorites(),triplets:this.getFavoriteTriplets()})}destroy(){this._destroyed||(this._destroyed=!0,null!==this._rnaBuilder&&(this._rnaBuilder.destroy(),this._rnaBuilder=null),this._libUnsub(),this._themeUnsub(),this._nextAddUnsub(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}getRnaBuilder(){return this._rnaBuilder}hasActiveBiotypeFilter(){return null!==this._activeBiotypeFilter}getActiveBiotypeFilter(){return this._activeBiotypeFilter}cancelBiotypeFilter(){if(null===this._activeBiotypeFilter)return;let t=this._pickCanceller;this._teardownPickMode(),t?.()}_buildPaletteFilterHooks(){return{beginBiotypeFilter:(t,e,i)=>{null!==this._activeBiotypeFilter&&this._teardownPickMode(),this._activeBiotypeFilter=t,this._pickResolver=e,this._pickCanceller=i,this._applyFilter();let s=t=>{"Escape"===t.key&&this.cancelBiotypeFilter()};this._pickEscapeListener=s,this._doc.defaultView?.addEventListener("keydown",s);let n=t=>{if(null===this._activeBiotypeFilter)return;let e=t.target;if(null==e)return;let i=this._activeBiotypeFilter,s=e;for(;null!==s;){let t=void 0===s.getAttribute?null:s.getAttribute("class");if(null!==t){let e=t.split(/\s+/);if(e.includes("hw-palette__tile")){if((s.getAttribute("data-biotype")??"")===i)return;break}if(e.includes("hw-rna-builder__slot")){if(this._isInsideOwnPalette(s))return;break}}s=s.parentElement}this.cancelBiotypeFilter()};this._pickOutsideClickListener=n,this._doc.addEventListener("mousedown",n,!0)},endBiotypeFilter:()=>this._teardownPickMode()}}_scrollActivePaneToTop(){let t=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`);if(null===t)return;let e=t;try{if("function"==typeof e.scrollTo)return void e.scrollTo({top:0,behavior:"smooth"})}catch{}"number"==typeof e.scrollTop&&(e.scrollTop=0)}_isInsideOwnPalette(t){let e=t;for(;null!==e;){if(e===this.element)return!0;e=e.parentElement}return!1}_teardownPickMode(){null!==this._activeBiotypeFilter&&(this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,null!==this._pickEscapeListener&&(this._doc.defaultView?.removeEventListener("keydown",this._pickEscapeListener),this._pickEscapeListener=null),null!==this._pickOutsideClickListener&&(this._doc.removeEventListener("mousedown",this._pickOutsideClickListener,!0),this._pickOutsideClickListener=null),this._applyFilter())}_render(){for(null!==this._rnaBuilder&&(this._pendingRnaSelection=this._rnaBuilder.getSelection(),this._rnaBuilder.destroy(),this._rnaBuilder=null);null!==this.element.firstChild;)this.element.removeChild(this.element.firstChild);let t=this._doc.createElement("input");t.setAttribute("type","search"),t.setAttribute("class","hw-palette__search"),t.setAttribute("placeholder","Search monomers..."),t.setAttribute("data-testid","palette-search"),""!==this._filter&&(t.value=this._filter),t.addEventListener("input",()=>this.setFilter(t.value)),this._searchInput=t,this.element.appendChild(t),this._visibleTabs=this._computeVisibleTabs(),this._visibleTabs.includes(this._activeTab)||(this._activeTab=je);let e=Pe(this._doc,"div",{class:"hw-palette__tabs",role:"tablist","data-testid":"palette-tabs"});for(let t of this._visibleTabs){let i=t===this._activeTab,s=Pe(this._doc,"button",{class:"hw-palette__tab",type:"button",role:"tab","aria-controls":`hw-palette-pane-${t}`,"aria-selected":i?"true":"false","data-testid":`palette-tab-${t}`,"data-tab":t,title:Qe[t]},[Qe[t]]);s.addEventListener("click",()=>this.setActiveTab(t)),e.appendChild(s)}this.element.appendChild(e);let i=Pe(this._doc,"div",{class:"hw-palette__panes"}),s=this._theme(),n=this._editor.getService().monomerLib;for(let t of this._visibleTabs){let e=t===this._activeTab,r=Pe(this._doc,"div",{class:"hw-palette__pane",id:`hw-palette-pane-${t}`,role:"tabpanel","data-testid":`palette-pane-${t}`,"data-tab":t,hidden:!e});t===je?this._buildFavoritesPane(r,n,s):this._buildPolymerPane(r,t,n,s),i.appendChild(r)}this.element.appendChild(i),this._applyFilter()}_computeVisibleTabs(){let t=this._editor.getService().monomerLib,e=new Set;for(let i of t.getPolymerTypes())e.add(i);let i=[];i.push(je);for(let t of Xe)t!==je&&e.has(t)&&i.push(t);return i}_buildFavoritesPane(t,e,i){let s=this._resolveFavoriteMonomers(e),n=this._favoriteTriplets;if(0===s.length&&0===n.length){let e=Pe(this._doc,"div",{class:"hw-palette__placeholder","data-testid":"palette-favorites-empty"},["No favorites yet — click the ☆ on any tile to add one."]);return void t.appendChild(e)}for(let[e,i]of this._groupByPolymerAndType(s))t.appendChild(this._renderGroup(e,i));n.length>0&&t.appendChild(this._renderTripletGroup("RNA · Triplets",n,e))}_groupByPolymerAndType(t){let e=new Map;for(let i of t){let t=i.polymerType,s=i.monomerType??"Undefined",n=`${t}|${s}`,r=e.get(n);void 0===r&&(r={pt:t,mt:s,list:[]},e.set(n,r)),r.list.push(i)}let i=t=>{let e=Xe.indexOf(t);return e<0?99:e},s={Backbone:0,Branch:1,Terminal:2,Undefined:3};return Array.from(e.values()).sort((t,e)=>i(t.pt)-i(e.pt)||(s[t.mt]??9)-(s[e.mt]??9)||t.mt.localeCompare(e.mt)).map(t=>[`${this._polymerLabel(t.pt)} · ${t.mt}`,t.list])}_polymerLabel(t){return Qe[t]??t}_renderTripletGroup(t,e,i){let s=Pe(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),n=Pe(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),r=Pe(this._doc,"div",{class:"hw-triplet-chips","data-testid":"palette-triplet-favorites"});for(let t of e)r.appendChild(this._renderTripletChip(t,i));return s.appendChild(n),s.appendChild(r),s}_renderTripletChip(t,e){let i=De(t.sugar,t.base,t.linker),s=e.getMonomerSet(Et).get(t.base)??null,n=ie(s,Et,this._theme().colorTheme),r=this.isFavoriteTriplet(t.sugar,t.base,t.linker),o=void 0!==s?.name&&""!==s.name?`${i} — ${s.name}`:i,{root:l}=function(t,e){let i=!1!==e.showStar,s=Pe(t,"span",{class:"hw-triplet-chip__star"},[e.favorite?"★":"☆"]),n=Pe(t,"span",{class:"hw-triplet-chip__label"},[e.label]),r=["hw-triplet-chip"];e.favorite&&r.push("hw-triplet-chip--favorite");let o=i?[s,n]:[n];return{root:Pe(t,"div",{class:r.join(" "),role:"button",tabindex:"0","aria-label":e.title,"data-sugar":e.sugar,"data-base":e.base,"data-linker":e.linker,"data-triplet":e.label,"data-testid":`palette-triplet-${e.label}`,title:e.title,style:`background:${e.background};color:${e.textColor};`},o),star:s}}(this._doc,{sugar:t.sugar,base:t.base,linker:t.linker,label:i,title:o,background:Gt(n.background),textColor:n.text,favorite:r,showStar:this._opts.allowFavorites});return this._wireTripletChip(l,t),l}_wireTripletChip(t,e){t.addEventListener("mouseenter",t=>{let i=t,s=Se(this._doc,"palette-triplet-tooltip","hw-palette-tooltip hw-triplet-tooltip");(function(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);e.appendChild(Pe(t,"div",{class:"hw-tooltip__symbol"},[i.title]));let s=Pe(t,"div",{class:"hw-tooltip__triplet"});for(let e of i.parts){let n=Pe(t,"div",{class:"hw-tooltip__triplet-part"});if(n.appendChild(Pe(t,"div",{class:"hw-tooltip__triplet-role"},[`${e.role}: ${e.symbol}`])),void 0!==e.name&&""!==e.name&&e.name!==e.symbol&&n.appendChild(Pe(t,"div",{class:"hw-tooltip__name"},[e.name])),void 0!==e.rdkitSvg&&null!==e.rdkitSvg&&""!==e.rdkitSvg){let s={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(s["data-testid"]=i.rdkitTestid);let r=Pe(t,"div",s);r.innerHTML=e.rdkitSvg,n.appendChild(r)}s.appendChild(n)}e.appendChild(s),void 0!==i.hint&&""!==i.hint&&e.appendChild(Pe(t,"div",{class:"hw-tooltip__hint"},[i.hint]))})(this._doc,s,{title:De(e.sugar,e.base,e.linker),parts:this._tripletTooltipParts(e),hint:"Click to add this triplet",rdkitTestid:"palette-triplet-tooltip-rdkit-svg"}),Ie(s,"number"==typeof i.clientX?i.clientX:0,"number"==typeof i.clientY?i.clientY:0)}),t.addEventListener("mouseleave",()=>{Me(this._doc.body.querySelector('[data-testid="palette-triplet-tooltip"]'))}),t.addEventListener("click",t=>{let i=t.target;if(this._opts.allowFavorites&&!0===i?.classList?.contains("hw-triplet-chip__star"))return this.setFavoriteTriplet(e.sugar,e.base,e.linker,!this.isFavoriteTriplet(e.sugar,e.base,e.linker)),void t.stopPropagation();this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)}),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)})}_buildRnaDefaultChips(e){let i=this._pickSymbol(e.getMonomerSet(At),["r","R"]),s=this._pickSymbol(e.getMonomerSet(Pt),["p","P"]),n=e.getMonomerSet(Et);if(null===i||null===s)return null;let r=t._DEFAULT_TRIPLET_BASES.filter(t=>n.has(t));if(0===r.length)return null;let o=Pe(this._doc,"div",{class:"hw-triplet-chips hw-triplet-chips--defaults","data-testid":"rna-default-triplets"});for(let t of r)o.appendChild(this._renderTripletChip({sugar:i,base:t,linker:s},e));return o}_tripletTooltipParts(t){let e=this._editor.getService().monomerLib,i=(t,i,s)=>{let n=e.getMonomerSet(i).get(s)??null;return{role:t,symbol:s,...void 0!==n?.name?{name:n.name}:{},rdkitSvg:null===n?null:this._paletteRdkitSvg(n)}};return[i("Sugar",At,t.sugar),i("Base",Et,t.base),i("Linker",Pt,t.linker)]}_pickSymbol(t,e){for(let i of e)if(t.has(i))return i;let i=t.keys().next();return!0===i.done?null:i.value}_restoreRnaSelection(){let t=this._pendingRnaSelection;if(this._pendingRnaSelection=null,null===t||null===this._rnaBuilder)return;let e=this._editor.getService().monomerLib;""!==t.sugar&&e.getMonomerSet(At).has(t.sugar)&&this._rnaBuilder.setField("sugar",t.sugar),""!==t.base&&e.getMonomerSet(Et).has(t.base)&&this._rnaBuilder.setField("base",t.base),""!==t.linker&&e.getMonomerSet(Pt).has(t.linker)&&this._rnaBuilder.setField("linker",t.linker)}_resolveFavoriteMonomers(t){let e=[];for(let i of this._favorites){let s=this._findMonomer(t,i);null!==s&&e.push(s)}return e}_findMonomer(t,e){for(let i of t.getPolymerTypes()){let s=t.getMonomer(i,e);if(null!==s)return s}return null}_buildPolymerPane(t,e,i,s){let n=e,r=this._monomersForPolymer(n,i);if(0===r.length)return;if(n===It.RNA){this._rnaBuilder=new ze(t,this._editor,{documentImpl:this._doc,paletteHooks:this._buildPaletteFilterHooks(),favoriteHooks:this._opts.allowFavorites?{isFavoriteTriplet:(t,e,i)=>this.isFavoriteTriplet(t,e,i),toggleFavoriteTriplet:(t,e,i)=>this.setFavoriteTriplet(t,e,i,!this.isFavoriteTriplet(t,e,i))}:null}),this._restoreRnaSelection();let e=this._buildRnaDefaultChips(i);null!==e&&t.appendChild(e);let s=this._groupRna(r);for(let[e,i]of s)0!==i.length&&t.appendChild(this._renderGroup(e,i));return}if(n===It.PEPTIDE&&this._opts.groupByNaturalAnalog){let e=this._groupByAnalog(r);for(let[i,s]of e){let e=""===i?"Other":i;t.appendChild(this._renderGroup(e,s))}return}let o=Pe(this._doc,"div",{class:"hw-palette__group-tiles"}),l=this._editor.getNextAddSymbol(),a=this._sortByColor(r);for(let t of a){let e=this._biotype(t,n);o.appendChild(this._renderTile(t,e,l))}t.appendChild(o)}_renderGroup(t,e){let i=Pe(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),s=Pe(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),n=Pe(this._doc,"div",{class:"hw-palette__group-tiles"}),r=this._editor.getNextAddSymbol(),o=this._sortByColor(e);for(let t of o){let e=this._biotype(t,t.polymerType);n.appendChild(this._renderTile(t,e,r))}return i.appendChild(s),i.appendChild(n),i}_sortByColor(t){let e=this._theme(),i=t.map((t,i)=>{let s=function(t){let e=Ot(t);if(null===e)return{h:0,s:0,l:0};let[i,s,n]=Dt(e[0],e[1],e[2]);return{h:i,s,l:n}}(ie(t,this._biotype(t,t.polymerType),e.colorTheme).background),n=0===s.s?1:0;return{m:t,idx:i,h:s.h,s:s.s,l:s.l,isGrey:n}});return i.sort((t,e)=>t.isGrey!==e.isGrey?t.isGrey-e.isGrey:t.h!==e.h?t.h-e.h:t.s!==e.s?t.s-e.s:t.l!==e.l?t.l-e.l:t.idx-e.idx),i.map(t=>t.m)}_monomersForPolymer(t,e){let i=e.getMonomerSymbolsByType(t),s=[];for(let n of i){let i=e.getMonomer(t,n);null!==i&&s.push(i)}return s.sort((t,e)=>t.symbol.localeCompare(e.symbol)),s}_groupByAnalog(t){let e=new Map;for(let i of t){let t=i.naturalAnalog??"",s=e.get(t);void 0===s&&(s=[],e.set(t,s)),s.push(i)}let i=[],s=Array.from(e.keys()).sort((t,e)=>""===t&&""!==e?1:""===e&&""!==t?-1:t.localeCompare(e));for(let t of s)i.push([t,e.get(t)]);return new Map(i)}_groupRna(t){let e=[],i=[],s=[],n=[];for(let r of t){let t=se(r);t===At?e.push(r):t===Et?i.push(r):t===Pt?s.push(r):n.push(r)}let r=new Map;return r.set("Backbones",e),r.set("Bases",i),r.set("Linkers",s),n.length>0&&r.set("Other",n),r}_renderTile(t,e,i){let s=this._favorites.has(t.symbol),n=null!==i&&i.symbol===t.symbol&&i.biotype===e,{root:r,star:o}=function(t,e){let i=ie(e.monomer,e.biotype,e.theme.colorTheme),s=Gt(i.background),n=i.text,r=function(t,e){let i=Vt(t),s=Vt(e);return(Math.max(i,s)+.05)/(Math.min(i,s)+.05)}(n,s)<5,o=e.monomer.symbol,l=function(t){return t<=3?14:t<=6?11:t<=9?9:8}(o.length),a=`font-size:${l}px;${o.length>=10?"line-height:1.1;letter-spacing:-0.02em;":""}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80px;display:inline-block;`,c=Pe(t,"span",{class:"hw-palette__star"},[e.favorite?"★":"☆"]),h=Pe(t,"span",{class:"hw-palette__label",style:a},[o]),d=["hw-palette__tile"];e.primed&&d.push("hw-palette__tile--primed"),e.favorite&&d.push("hw-palette__tile--favorite"),r&&d.push("hw-palette__tile--low-contrast");let u=void 0!==e.monomer.name?`${o} — ${e.monomer.name}`:o,p=`background:${s};color:${n};width:100%;min-width:48px;padding:4px 6px;height:40px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;`;return{root:Pe(t,"div",{class:d.join(" "),draggable:"true",role:"button","aria-pressed":e.primed?"true":"false","aria-label":u,"data-symbol":o,"data-biotype":e.biotype,"data-bg":s,"data-raw-bg":i.background,"data-testid":`palette-tile-${o}`,title:u,style:p},[c,h]),star:c}}(this._doc,{monomer:t,biotype:e,theme:this._theme(),favorite:s,primed:n});return this._wireTile(r,o,t,e),r}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_paletteRdkitSvg(e){let i=e.smiles;if(void 0===i||""===i)return null;let s=this._rdkit();if(null===s)return null;let n=`${e.polymerType}:${e.symbol}`;if(this._paletteRdkitCache.has(n))return this._paletteRdkitCache.get(n)??null;let r=ke(s,i,220,140);if(this._paletteRdkitCache.size>=t._PALETTE_RDKIT_CACHE_LIMIT){let t=this._paletteRdkitCache.keys().next().value;void 0!==t&&this._paletteRdkitCache.delete(t)}return this._paletteRdkitCache.set(n,r),r}_wireTile(t,e,i,s){t.addEventListener("mouseenter",t=>{let e=t,s=Se(this._doc,"palette-tooltip","hw-palette-tooltip");$e(this._doc,s,{symbol:i.symbol,name:i.name??"",rdkitSvg:this._paletteRdkitSvg(i),rdkitTestid:"palette-tooltip-rdkit-svg"}),Ie(s,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),t.addEventListener("mouseleave",()=>{Me(this._doc.body.querySelector('[data-testid="palette-tooltip"]'))}),t.addEventListener("click",t=>{let e=t.target;if(this._opts.allowFavorites&&void 0!==e&&!0===e?.classList?.contains("hw-palette__star"))return this.setFavorite(i.symbol,!this._favorites.has(i.symbol)),void t.stopPropagation();if(null!==this._activeBiotypeFilter&&this._activeBiotypeFilter===s){let e=this._pickResolver;return this._teardownPickMode(),e?.(i.symbol),this._scrollActivePaneToTop(),void t.stopPropagation()}let n=this._editor.getSelection();if(n.atoms.size>0){let e=this._editor.getMol(),r=[];for(let t of n.atoms){let i=e.atoms.find(e=>e.id===t);void 0!==i&&r.push(i)}return r.length>0&&r.every(t=>t.biotype===s)?(this._editor.replaceMonomers(r,i.symbol),void t.stopPropagation()):(this._editor.fire("editor:status",{message:`Cannot bulk-replace ${r.length} selected atom(s) with ${i.symbol}: selection contains incompatible biotypes for ${s}.`,severity:"warn",durationMs:3e3}),void t.stopPropagation())}let r=this._editor.getNextAddSymbol();if(null!==r&&r.symbol===i.symbol&&r.biotype===s)return this._editor.setNextAddSymbol(null),void this._updatePrimedClasses();this._editor.setNextAddSymbol(i.symbol,s),this._updatePrimedClasses()}),t.addEventListener("dragstart",t=>{let e=t.dataTransfer;if(null!=e)try{e.setData("application/x-hwe-monomer",JSON.stringify({symbol:i.symbol,biotype:s})),e.effectAllowed="copy"}catch{}Me(this._doc.body.querySelector('[data-testid="palette-tooltip"]')),this._editor.startPaletteDrag(i.symbol,s)})}_biotype(t,e){let i=se(t);if(null!==i)return i;switch(e){case It.PEPTIDE:return xt;case It.RNA:return At;case It.CHEM:return kt;case It.BLOB:return St;default:return kt}}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyFilter(){let t=this._filter,e=this._activeBiotypeFilter,i=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`),s=(i??this.element).querySelectorAll(".hw-palette__tile");for(let i=0;i<s.length;i++){let n=s[i],r=(n.getAttribute("data-symbol")??"").toLowerCase(),o=(n.getAttribute("title")??"").toLowerCase(),l=n.getAttribute("data-biotype")??"",a=(""===t||r.indexOf(t)>=0||o.indexOf(t)>=0)&&(null===e||l===e);n.style.display=a?"":"none"}let n=(i??this.element).querySelectorAll(".hw-triplet-chip");for(let i=0;i<n.length;i++){let s=n[i],r=[s.getAttribute("data-triplet")??"",s.getAttribute("data-sugar")??"",s.getAttribute("data-base")??"",s.getAttribute("data-linker")??""].join(" ").toLowerCase(),o=(""===t||r.indexOf(t)>=0)&&null===e;s.style.display=o?"":"none"}let r=(i??this.element).querySelectorAll(".hw-palette__group");for(let t=0;t<r.length;t++){let e=r[t],i=e.querySelectorAll(".hw-palette__tile, .hw-triplet-chip"),s=!1;for(let t=0;t<i.length;t++)if("none"!==i[t].style.display){s=!0;break}s?(e.removeAttribute("hidden"),e.removeAttribute("data-section-empty")):(e.setAttribute("hidden",""),e.setAttribute("data-section-empty","true"))}}_updatePrimedClasses(){let t=this._editor.getNextAddSymbol(),e=this.element.querySelectorAll(".hw-palette__tile");for(let i=0;i<e.length;i++){let s=e[i],n=s.getAttribute("data-symbol")??"",r=s.getAttribute("data-biotype")??"",o=null!==t&&t.symbol===n&&t.biotype===r,l=(s.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-palette__tile--primed"!==t).join(" ");s.setAttribute("class",o?`${l} hw-palette__tile--primed`:l),s.setAttribute("aria-pressed",o?"true":"false")}}_applyActiveTabClasses(){let t=this.element.querySelectorAll(".hw-palette__tab");for(let e=0;e<t.length;e++){let i=t[e],s=i.getAttribute("data-tab")??"";i.setAttribute("aria-selected",s===this._activeTab?"true":"false")}let e=this.element.querySelectorAll(".hw-palette__pane");for(let t=0;t<e.length;t++){let i=e[t];(i.getAttribute("data-tab")??"")===this._activeTab?i.removeAttribute("hidden"):i.setAttribute("hidden","")}}_localStorage(){if(!this._opts.allowFavorites)return null;let t=this._doc.defaultView;if(null==t)return null;try{return t.localStorage??null}catch{return null}}_resolveInitialTab(t){if(void 0!==t&&Xe.includes(t))return t;let e=this._localStorage();if(null!==e)try{let t=e.getItem(Ze);if(null!==t&&Xe.includes(t))return t}catch{}return je}_persistActiveTab(){let t=this._localStorage();if(null!==t)try{t.setItem(Ze,this._activeTab)}catch{}}_loadFavorites(){let t=this._localStorage();if(null!==t){try{let e=t.getItem(Je);if(null!==e&&""!==e){let t=JSON.parse(e),i=this._extractSymbols(t);for(let t of i)this._favorites.add(t);for(let e of this._extractTriplets(t))this._favoriteTriplets.push(e);return}}catch{}try{let e=t.getItem("hwe.palette.favorites");if(null===e||""===e)return;let i=JSON.parse(e);if(Array.isArray(i)){for(let t of i){if("string"!=typeof t)continue;let e=t.indexOf("|"),i=e>=0?t.slice(e+1):t;""!==i&&this._favorites.add(i)}this._saveFavorites()}}catch{}}}_extractSymbols(t){if(Array.isArray(t)){let e=[];for(let i of t)"string"==typeof i&&e.push(i);return e}if(null!==t&&"object"==typeof t){let e=t;if(Array.isArray(e.symbols)){let t=[];for(let i of e.symbols)"string"==typeof i&&t.push(i);return t}}return[]}_extractTriplets(t){if(null===t||"object"!=typeof t)return[];let e=t;if(!Array.isArray(e.triplets))return[];let i=[];for(let t of e.triplets){if(null===t||"object"!=typeof t)continue;let e=t;"string"==typeof e.sugar&&"string"==typeof e.base&&"string"==typeof e.linker&&i.push({sugar:e.sugar,base:e.base,linker:e.linker})}return i}_saveFavorites(){let t=this._localStorage();if(null!==t)try{let e={symbols:Array.from(this._favorites)};this._favoriteTriplets.length>0&&(e.triplets=this._favoriteTriplets.map(t=>({...t}))),t.setItem(Je,JSON.stringify(e))}catch{}}};ei._DEFAULT_TRIPLET_BASES=["A","C","G","U","T"],ei._PALETTE_RDKIT_CACHE_LIMIT=256;new Set([It.PEPTIDE,It.RNA,It.CHEM,It.BLOB]),new Set(["Backbone","Branch","Terminal","Undefined"]);var ii,si,ni;function ri(e,i=!0){if(null==e)return"rgb(100,100,100)";const s=t.Color.fromHtml(e);if(i){const e=t.Color.g(s),i=t.Color.r(s),n=t.Color.b(s),r=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-e,2)+Math.pow(0-n,2));if(r>210)return`rgb(${i/r*210},${e/r*210},${n/r*210})`}return t.Color.toRgb(s)}!function(t){t[t.default=0]="default",t[t.continuous=1]="continuous"}(ii||(ii={})),function(t){t.Sequence="sequence",t.Helm="notation",t.Properties="properties",t.StructureView="structureview"}(si||(si={}));class oi{static hashCode(t){let e=0;if(0===t.length)return e;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e|=0;return e}}class li{}class ai extends li{static get palette(){return ai._pallete||(ai._pallete=ai.buildPalette()),ai._pallete}static buildPalette(){return Z().then(t=>{t.awaitLoaded(1/0).then(()=>{const e=t.getMonomerLib();e.onChanged.subscribe(()=>{ai.customMonomerColors={},ai.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const i=e.getMonomerSymbolsByType(t);for(const s of i){const i=e.getMonomer(t,s);i?.meta?.colors?.default?.background&&(this.customMonomerColors[s]||(this.customMonomerColors[s]={}),this.customMonomerColors[s][t]=ri(i.meta.colors.default.background))}}})})}),[].concat(...Object.values(yt.colourPalette))}get(t,e){const i=ai.palette.length,s=ai.customMonomerColors[t],n=e??It.PEPTIDE;if(s&&s[n])return s[n];const r=oi.hashCode(t)%i;return ri(ai.palette[r])}}ai._pallete=null,ai.customMonomerColors={},ai.polymerTypes=[],P("renderers",()=>{let e,i;k(async()=>{await Q(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("missedInLib",async()=>{await async function(){const e=await tt.dapi.files.readCsv("System:AppData/Helm/tests/sample_HELM-missedInLib.csv"),i=e.getCol("HELM"),s=tt.shell.addTableView(e);await F(()=>ht()(s.root).find(".d4-grid canvas").length>0,"Table view canvas not found",100),await tt.data.detectSemanticTypes(e),T(i.semType,t.SEMTYPE.MACROMOLECULE),T(i.meta.units,ut.HELM),T(i.getTag(t.TAGS.CELL_RENDERER),"helm");const n=i.getTag(".cell-renderer.render.error");if(n){const t=JSON.parse(n),e=new Error(t.message);throw e.stack=t.stack,e}}()}),w("scatterPlotTooltip",async()=>{await async function(){const e=t.DataFrame.fromCsv(s);e.currentRowIdx=0;const i=tt.shell.addTableView(e);await tt.data.detectSemanticTypes(e);const n=e.plot.scatter({x:"x",y:"y"});i.dockManager.dock(n,t.DOCK_TYPE.RIGHT,null),await Promise.all([v(n.onAfterDrawScene,()=>{},()=>{n.invalidateCanvas()},1e3),X(i.grid,500)]);const r=n.root.getBoundingClientRect(),o=n.worldToScreen(1,0),l=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:r.left+o.x,clientY:r.top+o.y}),a=ht()(n.root).find("canvas").get()[0];await v((0,dt.fromEvent)(a,"mousemove"),()=>{Ti.logger.debug(`Test: event, currentRowIdx=${e.currentRowIdx}`),T(ht()(K.tooltip.root).find("div table.d4-row-tooltip-table tr td canvas").length,1),T(n.hitTest(o.x,o.y),1)},()=>{a.dispatchEvent(l)},500),await X(i.grid,1e3)}()});const s="seq,x,y\nPEPTIDE1{I.H.A.N.T.Thr_PO3H2.Aca.D-Tyr_Et}$$$$,0,0\nRNA1{r(A)p.r(C)p.r(G)p.r(U)p}$$$$,1,0\nRNA1{d(A)p.d(C)p.d(G)p.d(U)p}|PEPTIDE1{I.H.A.N.T.Thr_PO3H2}$$$$,0,1\n"}),function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(ni||(ni={}));class ci{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 i=t;const s=this.isWhitespace(i)?e:e-1;for(let t=0;t<s;t++)i=this.getNextColumnIdx(i);return i}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let i=this.getAtomBlockIdx();for(let s=0;s<t;s++)i=this.shiftIdxToAtomType(i),e[s]=this.parseAtomType(i),i=this.getNextLineIdx(i);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),i=new Float32Array(this.atomCount);let s=this.getAtomBlockIdx();for(let n=0;n<this.atomCount;n++){s=this.shiftIdxToXColumn(s);for(const r of[t,e,i])r[n]=this.parseFloatValue(s),s=this.getNextColumnIdx(s);s=this.getNextLineIdx(s)}return{x:t,y:e,z:i}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let i=0;i<this.bondCount;i++){e=this.shiftIdxToBondedAtomsPair(e);const s=new Uint16Array(2);s[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),s[1]=this.parseIntValue(e),t[i]=s,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let i=this.getBondBlockIdx();for(let s=0;s<t;s++)i=this.shiftIdxToBondType(i),e[s]=this.parseIntValue(i),i=this.getNextLineIdx(i);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 i=e+1;for(;!this.isWhitespace(i);)++i;return t(this.fileContent.substring(e,i))}}class hi extends ci{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,i=e;return this.isQuote(e)?(i=this.getNextIdenticalChar(e),e++):i=this.fileContent.indexOf(" ",i),this.fileContent.substring(e,i)}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&&!((i=this.fileContent.charCodeAt(e+1))>64&&i<91||i>96&&i<123);var i})}isFragment(){return this.isQueryOrFragment(t=>82===t||42===t)}isQueryOrFragment(t){const e=this.atomCount;let i=this.getAtomBlockIdx();for(let s=0;s<e;s++){if(i=this.shiftIdxToAtomType(i),t(this.fileContent.charCodeAt(i),i))return!0;i=this.getNextLineIdx(i)}return!1}}class di extends hi{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter(t=>t.startsWith(ni.RGP_LINE_START)).forEach(e=>{const i=this.getAtomIdxToRgpIdxList(e);for(const[e,s]of i){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,s)}});const i=e.map((t,e)=>{if(t.startsWith(ni.ATOM_ALIAS_LINE_START))return e}).filter(t=>void 0!==t),s=i.map(t=>e[t]),n=i.map(t=>e[t+1]);s.forEach((e,i)=>{const s=parseInt(e.split(/\s+/)[1])-1,r=parseInt(n[i].substring(1));if(t.has(r))throw new Error(`R group ${r} is already in the map`);t.set(r,s)});const r=this.getRGroupAtomicIndices().filter(e=>!Array.from(t.values()).includes(e));if(0!==r.length)throw new Error(`Unaccounted R group indices: ${r}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter(t=>t).slice(3).map(t=>parseInt(t)),i=new Array(e.length/2);for(let t=0;t<e.length;t+=2)i[t/2]=[e[t+1],e[t]-1];return i}getRGroupAtomicIndices(){return this.atomTypes.map((t,e)=>{if(t.includes("R#"))return e}).filter(t=>void 0!==t)}static isValidMolfile(t){return-1!==t.indexOf(ni.TYPE)&&-1!==t.indexOf(ni.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ni.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ni.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,ni.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ni.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+ni.NUM_OF_COUNTS_DIGITS;const i=parseInt(this.fileContent.substring(t,e));return t=e,e+=ni.NUM_OF_COUNTS_DIGITS,{atomCount:i,bondCount:parseInt(this.fileContent.substring(t,e))}}}class pi extends hi{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach((e,i)=>{const s=e.match(/RGROUPS=\(([\d\s]+)\)/);if(s){const e=s[1].split(/\s+/).map(t=>parseInt(t));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const n=e[1];if(t.has(n))throw new Error(`R group ${n} is already in the map`);t.set(n,i)}}),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const i=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:i,bondCount:parseInt(this.fileContent.substring(t,e))}}}class fi{constructor(){}static getInstance(t){if(fi.isMolfileV2K(t))return new di(t);if(fi.isMolfileV3K(t))return new pi(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return di.isValidMolfile(t)}static isMolfileV3K(t){return pi.isValidMolfile(t)}}async function gi(){const e=t.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}P("getMolfiles",()=>{let e,i;k(async()=>{await Q(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("linear1",async()=>{const e=t.DataFrame.fromCsv("Helm, atoms, bonds\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV}$$$$,11,10\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV}$$$$,11,10\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$,9,8"),i=e.getCol("Helm"),s=tt.shell.addTableView(e);Ti.logger.debug("Helm/getMolfiles/linear1, grid awaiting 1"),await X(s.grid,5e3),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaited 1");const n=await tt.functions.call("Helm:getMolfiles",{col:i});T(n.length,i.length);const r=n.toList().map(t=>fi.getInstance(t));E(r.map(t=>t.atomCount),e.getCol("atoms").toList()),E(r.map(t=>t.bondCount),e.getCol("bonds").toList()),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaiting 2"),await X(s.grid,5e3),Ti.logger.debug("Helm/getMolfiles/linear1, grid awaited 2")})});class mi extends Error{constructor(t,e){super(t,e)}}async function yi(t,e){const i=K.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(i);try{if(t.length>1e3)throw new mi("Too long sequence to calculate molecular properties.");const s=(e.isHelm()?t:e.getConverter(ut.HELM)(t)).replaceAll(H,"{").replaceAll(B,".").replaceAll(G,"}").replace("{*}","{}"),n=(await j()).createHelmWebEditor(i).editor;n.setHelm(s);const r=n.getFormula(!0),o=Math.round(100*n.getMolWeight())/100,l=Math.round(100*n.getExtinctionCoefficient())/100;return{formula:r.replace(/<sub>/g,"").replace(/<\/sub>/g,""),"molecular weight":o,"extinction coefficient":l}}finally{ht()(i).empty(),i.remove()}}const bi={Helm:{seq:"PEPTIDE1{I.H.A.C.T.[Thr_PO3H2].[Aca].[D-Tyr_Et]}|PEPTIDE2{E.A.[meG]}$PEPTIDE1,PEPTIDE2,4:R3-1:R1$$$V2.0",units:ut.HELM,res:{formula:"C58H94N13O21SP","molecular weight":1372.49,"extinction coefficient":1.55}},separator:{seq:"I/H/A/C/T/Thr_PO3H2/Aca/D-Tyr_Et",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C47H77N10O15SP","molecular weight":1085.22,"extinction coefficient":1.55}},separator2:{seq:"meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca/D-Tyr_Et/Aze/dV/E/N////Phe_4Me",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C91H146N19O25P","molecular weight":1937.25,"extinction coefficient":1.49}},"separator-gaps":{seq:"I/H/A//T/Thr_PO3H2/Aca/D-Tyr_Et",units:ut.SEPARATOR,separator:"/",alphabet:pt.UN,res:{formula:"C44H72N9O14P","molecular weight":982.08,"extinction coefficient":1.49}},"fasta-PT":{seq:"IHACTTAY",units:ut.FASTA,alphabet:pt.PT,res:{formula:"C38H58N10O12S","molecular weight":879,"extinction coefficient":1.55}},"fasta-RNA":{seq:"ACGUAUUCC",units:ut.FASTA,alphabet:pt.RNA,res:{formula:"C84H107N30O65P9","molecular weight":2855.69,"extinction coefficient":86.96}},"fasta-DNA":{seq:"ACGTATTCC",units:ut.FASTA,alphabet:pt.DNA,res:{formula:"C87H113N30O56P9","molecular weight":2753.78,"extinction coefficient":86.96}}};function _i(t,e,i){const s=i.parse(t);T(s.atoms.length,e.atomCount),T(s.bonds.length,e.bondCount),T(s.atoms.every(t=>!t.elem.startsWith("[")&&!t.elem.endsWith("]")),!0,"Atoms should not contain square braces.")}var Ci;P("properties-widget",()=>{let e,i,s=null;k(async()=>{await Q(),e=await gi(),i=await Z(),s=lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)});for(const[t,e]of Object.entries(bi))w(t,async()=>{await n(e.seq,e.units,e.separator,e.alphabet,e.res)});async function n(i,s,n,r,o){const l=t.Column.fromStrings("seq",[i]);l.semType=t.SEMTYPE.MACROMOLECULE,l.meta.units=s,n&&l.setTag(ft.separator,n),r&&l.setTag(ft.alphabet,r);const a=e.getSeqHandler(l);A(await yi(i,a),o)}w("too-long",async()=>{const i=function(e=1e4){const i="meI/hHis/Aca/N//dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe".repeat(Math.ceil(e/10)).slice(0,-1),s=t.Column.fromList(t.COLUMN_TYPE.STRING,"MSA",new Array(100).fill(i));s.semType=t.SEMTYPE.MACROMOLECULE,s.meta.units=ut.SEPARATOR,s.setTag(ft.separator,"/"),s.setTag(ft.alphabet,pt.UN),s.setTag(ft.alphabetIsMultichar,"true");const n=[];return n.push(s),n.push(t.Column.fromList(t.COLUMN_TYPE.FLOAT,"Activity",new Array(100).fill(7.30751))),n}(),s=t.DataFrame.fromColumns(i).getCol("MSA"),n=e.getSeqHandler(s);let r=!0;try{await yi(s.get(0),n)}catch(t){t instanceof mi&&(r=!0)}T(r,!0)})}),P("parseHelm",()=>{const t={PT:{src:"PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0",tgt:{atomCount:6,bondCount:5,helm:"PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0"}},"PT-cyclic":{src:"PEPTIDE1{[meI].C.[Aca].[Cys_SEt].T.C.[Thr_PO3H2].[Aca]}$PEPTIDE1,PEPTIDE1,8:R2-1:R1$$$V2.0",tgt:{atomCount:8,bondCount:8,helm:"PEPTIDE1{[meI].C.[Aca].[Cys_SEt].T.C.[Thr_PO3H2].[Aca]}$PEPTIDE1,PEPTIDE1,8:R2-1:R1$$$V2.0"}},RNA:{src:"RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0",tgt:{atomCount:12,bondCount:11,helm:"RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0"}},"PT-with-gap":{src:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$$$$V2.0",tgt:{atomCount:8,bondCount:7,helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$$$$V2.0"}},"PT-with-gap-at-connection":{src:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0",tgt:{atomCount:8,bondCount:8,helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"}}};let e,i,s;k(async()=>{await Q(),e=await j(),i=await Z(),s=await lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)});for(const[i,{src:s,tgt:n}]of Object.entries(t))w(`HelmHelper-${i}`,async()=>{_i(s,n,e)})}),P("helm-web-editor",async()=>{let t,e,i;k(async()=>{await Q(),t=await Z(),e=await lt(),await t.loadMonomerLibForTests(),i=await j()}),S(async()=>{await at(e),await t.loadMonomerLib(!0)}),w("helm-web-editor",async()=>{i.createHelmWebEditor()}),w("web-editor-app",async()=>{const t=K.div([],{style:{width:"700px",height:"432px"}});i.createWebEditorApp(t,"PEPTIDE1{I.H.A.N.T.Thr_PO3H2.Aca.D-Tyr_Et}$$$$"),K.dialog().add(t).show().close()})}),P("HelmInput",()=>{let t,e,i;k(async()=>{t=await j(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("inDialog",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$",K.dialog("Helm Input Test").add(t).show(),await R(500);const e=t.molValue;T(e.atoms.length,4),T(e.bonds.length,3)}),w("renders-with-nonzero-height (root in a dialog)",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Height Test").add(t).show();try{await R(500);const e=t.getInput();T(e.clientHeight>0,!0,`editor host height must be > 0 (was ${e.clientHeight})`);const i=e.querySelector("svg");T(null!=i,!0,"an SVG must be mounted in the editor host");const s=i.getBoundingClientRect().height;T(s>0,!0,`mounted SVG height must be > 0 (was ${s})`)}finally{e.close()}}),w("default size is 250x250",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Default Size").add(t).show();try{await R(500);const e=t.getInput();T(Math.abs(e.clientWidth-250)<=4,!0,`default width ~250 (was ${e.clientWidth})`),T(Math.abs(e.clientHeight-250)<=4,!0,`default height ~250 (was ${e.clientHeight})`)}finally{e.close()}}),w("editorOptions.width/height override the default size",async()=>{const t=await K.input.helmAsync("Macromolecule",{editable:!0,editorOptions:{width:320,height:180}});t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm Input Custom Size").add(t).show();try{await R(500);const e=t.getInput();T(Math.abs(e.clientWidth-320)<=4,!0,`width ~320 from editorOptions (was ${e.clientWidth})`),T(Math.abs(e.clientHeight-180)<=4,!0,`height ~180 from editorOptions (was ${e.clientHeight})`)}finally{e.close()}}),w("editor canvas sizes from getInput() box (consumer sets height on the host)",async()=>{const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=K.dialog("Helm getInput() Size Test").add(t).show();try{await R(300);const e=t.getInput();e.style.setProperty("width","360px","important"),e.style.setProperty("height","260px","important"),await R(500),T(e.clientWidth,360,`host width (was ${e.clientWidth})`),T(e.clientHeight,260,`host height (was ${e.clientHeight})`);const i=e.querySelector("svg");T(null!=i,!0,"an SVG must be mounted");const s=i.getBoundingClientRect();T(s.height>=e.clientHeight-8,!0,`SVG height should track the host's ${e.clientHeight} (was ${s.height})`),T(s.width>=e.clientWidth-8,!0,`SVG width should track the host's ${e.clientWidth} (was ${s.width})`)}finally{e.close()}}),w("tooltip",async()=>{await async function(){const t=await K.input.helmAsync("Macromolecule");t.stringValue="PEPTIDE1{[meY].A.G.T}$$$$";const e=tt.shell.v?tt.shell.v.root.getBoundingClientRect():null,i=K.dialog("Helm Input Test").add(t).show({...e?{x:e.right+20,y:e.top+20}:{}});try{const e=ht()(i.root).find("div.d4-dialog-contents > div.ui-input-helm > div.ui-input-editor").get(0);T(t.getInput(),e);const s={i:0,elem:"meY"},n=t.molValue.atoms[s.i],r=t.getInput(),o=r.getBoundingClientRect(),l=new MouseEvent("mousemove",{cancelable:!0,bubbles:!0,view:window,button:0,clientX:o.left+n.p.x,clientY:o.top+n.p.y});await v(K.tooltip.onTooltipShown,()=>{},()=>{r.dispatchEvent(l)},100,"timeout await ui.tooltip.onTooltipShown");const a=ht()(document).find("body > div.d4-tooltip").get(0),c=ht()(a).find("div > div.d4-flex-row.ui-div > div:nth-child(1)").get(0);T("none"!=a.style.display,!0),T(c?.innerText,s.elem)}finally{await R(50),K.tooltip.hide()}}()},{timeout:3e5})}),P("HelmHelper: removeGaps",()=>{let t,e,i;k(async()=>{t=await j(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)});const s={"single-linear-start":{src:{helm:"PEPTIDE1{*.[meY].A.G.T}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[1,0],[2,1],[3,2],[4,3]]}},"single-linear-end":{src:{helm:"PEPTIDE1{[meY].A.G.T.*}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3]]}},"single-linear-middle":{src:{helm:"PEPTIDE1{[meY].A.*.G.T}$$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].A.G.T}$$$$V2.0",map:[[0,0],[1,1],[3,2],[4,3]]}},"single-cycle-start":{src:{helm:"PEPTIDE1{*.[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,3:R3-7:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6]]}},"single-cycle-end":{src:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T.*}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]]}},"single-cycle-middle":{src:{helm:"PEPTIDE1{[meY].C.R.N.*.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"},tgt:{helm:"PEPTIDE1{[meY].C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-6:R3$$$V2.0",map:[[0,0],[1,1],[2,2],[3,3],[5,4],[6,5],[7,6]]}},"single-cycle-gap-at-connection":{src:{helm:"PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0"},tgt:{helm:null,map:[],errType:"HelmNotSupportedError"}}};for(const[e,i]of Object.entries(s))w(`${e}`,async()=>{let e=null;try{const e=t.removeGaps(i.src.helm);T(e.resHelm,i.tgt.helm),E(Array.from(e.monomerMap.entries()),i.tgt.map)}catch(t){e=t}i.tgt.errType&&T(e?.type,i.tgt.errType,"HelmNotSupportedError thrown expected")})});class vi{constructor(t,e=!0,i){return this.substructure=t,this.readOnly=e,this.logger=i,new Proxy(this,{set:(t,e,i)=>{if(this.logger?.debug(`BioFilterProps.set ${e.toString()}( '${i}' )`),this.readOnly)throw new Error("Properties are immutable.");return t[e]=i,!0}})}}P("bio-substructure-filters",async()=>{let t,e,i;async function s(t,e){if(!e.columns.names().includes(t))throw new Error(`The column '${t}' not found. Available in data frame are ${JSON.stringify(e.columns.names())}`);const i=await tt.functions.call("Bio:bioSubstructureFilterTest");return i.attach(e),i.applyState({columnName:t}),i.column=e.col(t),i.columnName=t,i}k(async()=>{t=await gi(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)}),w("helm-dialog",async()=>{const t="Bio tests: substructureFilters/helm-dialog",e=await J("tests/filter_HELM.csv"),i=tt.shell.addTableView(e);await tt.data.detectSemanticTypes(e),await e.meta.detectSemanticTypes(),Ti.logger.debug(`${t}, filter attaching.`);const s=await tt.functions.call("Bio:bioSubstructureFilterTest");s.attach(e);const n=K.dialog("Test filters").add(s.root).show();await s.awaitRendered();try{const n=s.bioFilter;T(null!==s.bioFilter,!0,"bioFilter is not created"),Ti.logger.debug(`${t}, filter 1 change awaiting...`),await v(e.onRowsFiltered,()=>{},()=>{n.props=new vi("PEPTIDE1{A.C}$$$$V2.0",void 0,Ti.logger)},2e4),Ti.logger.debug(`${t}, filter 1 changed.`),T(s.dataFrame.filter.trueCount,1),T(s.dataFrame.filter.toBinaryString(),"0001"),Ti.logger.debug(`${t}, filter 2 change awaiting...`),await v(e.onRowsFiltered,()=>{},()=>{n.props=new vi("PEPTIDE1{C}$$$$V2.0",void 0,Ti.logger)},2e4),setTimeout(()=>i.grid.invalidate(),500),await X(i.grid),await R(1e3),Ti.logger.debug(`${t}, filter 2 changed.`),T(s.dataFrame.filter.trueCount,2),T(s.dataFrame.filter.toBinaryString(),"1001")}finally{n.close()}await s.awaitRendered(),await R(3e3)},{}),w("helm-view",async()=>{const t=await J("tests/filter_HELM.csv");t.getCol("HELM string"),await tt.data.detectSemanticTypes(t);const e=tt.shell.addTableView(t);e.getFiltersGroup(),await X(e.grid)}),w("sync-helm",async()=>{const t=await Ti.files.readCsv("tests/filter_HELM.csv");await tt.data.detectSemanticTypes(t);const e=tt.shell.addTableView(t),i="PEPTIDE1{A.C}$$$$V2.0",n=await s("HELM string",t),r=await s("HELM string",t),o=K.dialog("Test filters").add(n.root).add(r.root).show();await Promise.all([n.awaitRendered(),r.awaitRendered()]);try{T(!!n.bioFilter,!0),T(!!r.bioFilter,!0),T(n.bioFilter.type,"HelmBioFilter"),T(r.bioFilter.type,"HelmBioFilter");const s=n.bioFilter,o=r.bioFilter;await v(t.onRowsFiltered,()=>{},()=>{s.props=new vi(i,void 0,Ti.logger)},6e4,"await onRowsFiltered"),await X(e.grid),Ti.logger.debug("Bio tests: substructureFilters/sync-helm, before changed event"),await R(2*n.debounceTime),Ti.logger.debug("Bio tests: substructureFilters/sync-helm, after changed event"),T(t.filter.trueCount,1),await n.awaitRendered(),T(o.props.substructure,i)}finally{n.detach(),r.detach(),o.close()}await Promise.all([n.awaitRendered(),r.awaitRendered()]),await X(e.grid),await R(3e3)})}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(Ci||(Ci={}));new Uint32Array(65536);var wi;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(wi||(wi={})),wi.HAMMING,wi.LEVENSHTEIN,wi.NEEDLEMANN_WUNSCH,wi.MONOMER_CHEMICAL_DISTANCE;P("activityCliffs",async()=>{let e,i,s;const n=t.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0];k(async()=>{e=await j(),i=await Z(),s=await lt(),await i.loadMonomerLibForTests()}),S(async()=>{await at(s),await i.loadMonomerLib(!0)}),w("Helm",async()=>{const e=await Ti.files.readCsv("samples/HELM_50.csv"),i=tt.shell.addTableView(e);await async function(e,i,s,n,r,o,l,a,c){await tt.data.detectSemanticTypes(i),await tt.functions.call("Bio:activityCliffs",{table:i,molecules:i.getCol("HELM"),activities:i.getCol("Activity"),similarity:65,methodName:s,similarityMetric:a,preprocessingFunction:c,options:{bypassLargeDataWarning:!0},demo:!1});const h=Array.from(e.viewers).find(e=>e.type===t.VIEWER.SCATTER_PLOT);T(null!=h,!0);await F(()=>(()=>{const t=h.root.getElementsByClassName("scatter_plot_link");return t.length>0&&"311 cliffs"===t[0].innerText.toLowerCase()})(),"activity cliffs failed")}(i,e,Ci.UMAP,0,0,0,0,wi.HAMMING,n)})}),P("toAtomicLevel-ui",()=>{let e,i,s,n;k(async()=>{n=await async function(){const e=t.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}(),e=await Z(),i=await lt(),await e.loadMonomerLibForTests(),s=e.getMonomerLib()}),S(async()=>{await at(i),await e.loadMonomerLib(!0)});const r={fasta:{src:{seq:"MDYKETLLMPK",units:ut.FASTA},tgt:{atomCount:94,bondCount:95}},"fasta-with-gap":{src:{seq:"MD-YKETLLMPK",units:ut.FASTA},tgt:{atomCount:94,bondCount:95}},helm:{src:{seq:"PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2}$$$$",units:ut.HELM},tgt:{atomCount:68,bondCount:68}},"helm-with-gap":{src:{seq:"PEPTIDE1{meI.hHis.*.Aca.N.T.dK.Thr_PO3H2}$$$$",units:ut.HELM},tgt:{atomCount:68,bondCount:68}}},o=async e=>{const i=e.src.seq,s=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,"seq",[i])]);return await tt.data.detectSemanticTypes(s),{df:s,seqCol:s.getCol("seq")}};for(const[t,e]of Object.entries(r))w(`${t}-nonlinear`,async()=>{const t=await o(e);await l(t.df,t.seqCol,0,e.tgt)});async function l(e,i,s,r){await tt.functions.call("Bio:toAtomicLevel",{table:e,seqCol:i,nonlinear:!0,highlight:!1});const o=e.col("molfile(seq)");T(o?.semType,t.SEMTYPE.MOLECULE);const l=o?.get(0),a=n.get_mol(l);T(null!=a,!0,"No molecule generated");try{const t=a.get_num_atoms(),e=a.get_num_bonds();T(t,r.atomCount),T(e,r.bondCount)}finally{a.delete()}}});const Ti=new t.Package;async function xi(e,i,s){const u=await function(t){var e,i,s;return n(this,void 0,void 0,function*(){const u=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!u)throw new Error("Can't run tests outside of the package");const p=null===(e=u.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),f=p?p[1]:"";null!=u&&(yield M(u));const g=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(i=(s=t).testContext)&&void 0!==i||(s.testContext=new _),grok.shell.clearLastError();const m=function(){const t=[];return console.log=(...e)=>{t.push(...e),l(...e)},console.info=(...e)=>{t.push(...e),a(...e)},console.warn=(...e)=>{t.push(...e),c(...e)},console.error=(...e)=>{t.push(...e),h(...e)},t}();yield function(t,e){var i,s,r,o,d,p;return n(this,void 0,void 0,function*(){try{let a=null!=(null==e?void 0:e.skipToCategory),c=!1;for(const[h,m]of Object.entries(t)){if(null===(i=e.exclude)||void 0===i?void 0:i.some(t=>h.startsWith(t)))continue;if(null!=(null==e?void 0:e.category)&&!h.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(a)if(c)a=!1;else{if(null==(null==e?void 0:e.skipToCategory)||h.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;c=!0}const t=null===(s=m.tests)||void 0===s?void 0:s.every(t=>{var i;return(null===(i=t.options)||void 0===i?void 0:i.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()});if(!t){const t=(null!==(r=m.tests)&&void 0!==r?r:[]).filter(t=>{var i;return(null===(i=t.options)||void 0===i?void 0:i.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}).length;l(`Package testing: Started {{${h}}}${t>0?` skipped {{${t}}}`:""}`),m.beforeStatus=yield y(m.before,h)}let _,C=null!==(o=m.tests)&&void 0!==o?o:[];e.stressTest&&(C=C.filter(t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest}),C=O(C)),(null!==(p=null===(d=e.tags)||void 0===d?void 0:d.length)&&void 0!==p?p:0)>0&&(C=C.filter(t=>{var i,s;return null===(s=null===(i=t.options)||void 0===i?void 0:i.tags)||void 0===s?void 0:s.some(t=>{var i;return(null!==(i=null==e?void 0:e.tags)&&void 0!==i?i:[]).includes(t)})})),m.beforeStatus?(_=Array.from(C.map(t=>({date:(new Date).toISOString(),category:h,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing}))),_.forEach(t=>n(this,void 0,void 0,function*(){return yield grok.shell.reportTest("package",t)}))):_=yield b(m,e,a);const v=_.filter(t=>"skipped"!=t.result);if(t||(m.afterStatus=yield y(m.after,h)),m.afterStatus&&(l(`Package testing: Category after() {{${h}}} failed`),l(`Package testing: Result for {{${h}}} after: ${m.afterStatus}`),v.push({date:(new Date).toISOString(),category:h,name:"after",success:!1,result:m.afterStatus,ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),m.beforeStatus&&(l(`Package testing: Category before() {{${h}}} failed`),l(`Package testing: Result for {{${h}}} before: ${m.beforeStatus}`),v.push({date:(new Date).toISOString(),category:h,name:"before",success:!1,result:m.beforeStatus,ms:0,skipped:!1,logs:"",owner:f,package:u.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.push(...v),e.returnOnFail&&v.some(t=>!t.success&&!t.skipped&&t.name!==e.skipToTest))break}}finally{console.log=l,console.info=a,console.warn=c,console.error=h}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=f?f:"",package:u.name,widgetsDifference:0};l(`Package testing: Unhandled Exception: ${t}`),g.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=u.name,yield grok.shell.reportTest("package",e)}}})}(d,t);for(let t of g)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return g;function y(t,e){return n(this,void 0,void 0,function*(){let i;try{void 0!==t&&(yield D(()=>n(this,void 0,void 0,function*(){yield t()}),1e5,`before ${e}: timeout error`))}catch(t){i=yield N(t)}return i})}function b(t,e,i){var s,l,a,c,h,d,p,g,y,b,_,v,w,T,x,A,E,P,k;return n(this,void 0,void 0,function*(){let n=null!==(s=t.tests)&&void 0!==s?s:[];const S=[],$=C();if(t.clear){let s=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){n[i].options&&void 0===(null===(l=n[i].options)||void 0===l?void 0:l.benchmark)&&(n[i].options||(n[i].options={}),n[i].options.benchmark=null!==(a=t.benchmarks)&&void 0!==a&&a);let w=n[i];if(e.test&&e.test.toLowerCase()!==w.name.toLowerCase())continue;if(s){if(null==(null==e?void 0:e.skipToTest)||w.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;s=!1}(null==w?void 0:w.options)&&(w.options.owner=null!==(p=null!==(d=null!==(h=null===(c=n[i].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==d?d:f)&&void 0!==p?p:"");let T=yield L(w,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(y=null===(g=n[i].options)||void 0===g?void 0:g.benchmarkTimeout)&&void 0!==y?y:o:null!==(_=null===(b=n[i].options)||void 0===b?void 0:b.timeout)&&void 0!==_?_:r,u.name,e.verbose);if(T&&(S.push(Object.assign(Object.assign({},T),{widgetsDifference:C()-$})),e.returnOnFail&&e.skipToTest!==w.name&&!T.success&&!T.skipped))return S;e.nodeOptions||!1===(null===(v=e.testContext)||void 0===v?void 0:v.closeAll)||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let s=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){let r=n[i];if(e.test&&e.test.toLowerCase()!==r.name.toLowerCase())continue;if(s){null!=(null==e?void 0:e.skipToTest)&&r.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(s=!1);continue}(null==r?void 0:r.options)&&(r.options.owner=null!==(A=null!==(x=null!==(T=null===(w=n[i].options)||void 0===w?void 0:w.owner)&&void 0!==T?T:null==t?void 0:t.owner)&&void 0!==x?x:f)&&void 0!==A?A:"");let l=yield L(r,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(P=null===(E=n[i].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==P?P:o:null===(k=n[i].options)||void 0===k?void 0:k.timeout,u.name,e.verbose);if(l&&(S.push(Object.assign(Object.assign({},l),{widgetsDifference:C()-$})),e.returnOnFail&&e.skipToTest!==r.name&&!l.success&&!l.skipped))return S}}return S})}function C(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}})}({category:e,test:i,testContext:s,verbose:!0});return t.DataFrame.fromObjects(u)}async function Ai(){await M(Ti,Ti.getModule("package-test.js"))}})(),helm_test=s})();
|
|
2
2
|
//# sourceMappingURL=package-test.js.map
|