jbrowse-plugin-msaview 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@jbrowse/core/Plugin"),require("@jbrowse/core/util"),require("react"),require("mobx-react"),require("@material-ui/core"),require("mobx"),require("@jbrowse/core/ui"),require("@material-ui/core/utils"),require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"),require("mobx-state-tree"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("prop-types"),require("@jbrowse/core/pluggableElementTypes/ViewType")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/util","react","mobx-react","@material-ui/core","mobx","@jbrowse/core/ui","@material-ui/core/utils","@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail","mobx-state-tree","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","prop-types","@jbrowse/core/pluggableElementTypes/ViewType"],t):t((e=e||self).JBrowsePluginMsaView={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports.react,e.JBrowseExports["mobx-react"],e.JBrowseExports["@material-ui/core"],e.JBrowseExports.mobx,e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["@material-ui/core/utils"],e.JBrowseExports["@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"],e.JBrowseExports["mobx-state-tree"],e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["prop-types"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/ViewType"])}(this,(function(e,t,n,r,o,a,i,l,s,c,u,f,h,d,m){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var p="default"in r?r.default:r,g="default"in o?o.default:o;s=s&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s;var v="default"in u?u.default:u;function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=y(e);if(t){var o=y(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return E(this,n)}}d=d&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d,m=m&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m;var M=function(e){var t=e.onClick,n=e.model;return p.createElement("li",null,p.createElement(a.Link,{onClick:function(e){n.setError(void 0),e.preventDefault(),t()},href:"#"},p.createElement(a.Typography,null,e.children)))},x=o.observer((function(e){var t=e.model,n=r.useState(),o=n[0],s=n[1],c=r.useState(),u=c[0],f=c[1],h=t.error;return p.createElement(a.Container,null,p.createElement("div",{style:{width:"50%"}},h?p.createElement("div",{style:{padding:20}},p.createElement(a.Typography,{color:"error"},"Error: ",""+h)):null,p.createElement(a.Typography,null,"Open an MSA file (stockholm or clustal format) and/or a tree file (newick format)."),p.createElement(a.Typography,{color:"error"},"Note: you can open up just an MSA or just a tree, both are not required. Some MSA files e.g. stockholm format have an embedded tree also and this is fine, and opening a separate tree file is not required.")),p.createElement(a.Grid,{container:!0,spacing:10,justifyContent:"center",alignItems:"center"},p.createElement(a.Grid,{item:!0},p.createElement(a.Typography,null,"MSA file or URL"),p.createElement(l.FileSelector,{location:o,setLocation:s}),p.createElement(a.Typography,null,"Tree file or URL"),p.createElement(l.FileSelector,{location:u,setLocation:f})),p.createElement(a.Grid,{item:!0},p.createElement(a.Button,{onClick:function(){t.setError(void 0),o&&t.setMSAFilehandle(o),u&&t.setTreeFilehandle(u)},variant:"contained",color:"primary",disabled:!o&&!u},"Open")),p.createElement(a.Grid,{item:!0},p.createElement(a.Typography,null,"Examples"),p.createElement("ul",null,p.createElement(M,{model:t,onClick:function(){t.setTreeFilehandle({uri:"https://jbrowse.org/genomes/newick_trees/sarscov2phylo.pub.ft.nh"})}},"230k COVID-19 samples (tree only)"),p.createElement(M,{model:t,onClick:function(){t.setData({msa:"CLUSTAL O(1.2.3) multiple sequence alignment\nUniProt/Swiss-Prot|P26898|IL2RA_SHEEP MEPSLLMWRFFVFIVVPGCVTEACHDDPPSLRNA----------MFKVLRYE----VGTM\nUniProt/Swiss-Prot|P01590|IL2RA_MOUSE MEPRLLMLGFLSLTIVPSCRAELCLYDPPEVPNA----------TFKALSYK----NGTI\nUniProt/Swiss-Prot|P41690|IL2RA_FELCA MEPSLLLWGILTFVVVHGHVTELCDENPPDIQHA----------TFKALTYK----TGTM\nUniProt/Swiss-Prot|P01589|IL2RA_HUMAN MDSYLLMWGLLTFIMVPGCQAELCDDDPPEIPHA----------TFKAMAYK----EGTM\nUniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU MDPYLLMWGLLTFITVPGCQAELCDDDPPKITHA----------TFKAVAYK----EGTM\nUniProt/Swiss-Prot|Q95118|IL2RG_BOVIN -----------------------------------LLMWGLLT-----------------\nUniProt/Swiss-Prot|P40321|IL2RG_CANFA MLKPPLPLRSLLFLQLSLLGVGLNSTVPMPNGNEDIT------PDFFLTATPSETLSVSS\nUniProt/Swiss-Prot|P26896|IL2RB_RAT MATVDLSWRLPLYILLLLLATT--------------------------------WVSAAV\nUniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE PLPLRSLLFLQLPLLGVGLNP------------------PLPLRSLLFLQLPLLGVGLNP\nUniProt/Swiss-Prot|P36835|IL2_CAPHI -----------LLGVGLNPKFLTP------------------------------------\nUniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO MLKPPLPLRSLLFLQLPLLGVGLNPKFLTPSGNEDIGGKPGTGGDFFLTSTPAGTLDVST\nUniProt/Swiss-Prot|Q29416|IL2_CANFA --------------LFLQLSLLG-------------------------------------\n",tree:"(((UniProt/Swiss-Prot|P26898|IL2RA_SHEEP:0.24036,(UniProt/Swiss-Prot|P41690|IL2RA_FELCA:0.17737,(UniProt/Swiss-Prot|P01589|IL2RA_HUMAN:0.03906,UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU:0.03787):0.13033):0.04964):0.02189,UniProt/Swiss-Prot|P01590|IL2RA_MOUSE:0.23072):0.06814,(((UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN:0.09600,UniProt/Swiss-Prot|P40321|IL2RG_CANFA:0.09845):0.25333,UniProt/Swiss-Prot|Q29416|IL2_CANFA:-0.35055):0.10231,(UniProt/Swiss-Prot|P26896|IL2RB_RAT:0.33631,UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO:-0.33631):0.10166):0.01607,(UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE:0.32378,UniProt/Swiss-Prot|P36835|IL2_CAPHI:-0.32378):0.09999)"})}},"Small protein MSA+tree"),p.createElement(M,{model:t,onClick:function(){t.setData({msa:"CLUSTAL O(1.2.4) multiple sequence alignment\n\n\nsp|P69905|HBA_HUMAN MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHGSAQVKGHG\t60\nsp|P01942|HBA_MOUSE MVLSGEDKSNIKAAWGKIGGHGAEYGAEALERMFASFPTTKTYFPHFDVSHGSAQVKGHG\t60\nsp|P13786|HBAZ_CAPHI MSLTRTERTIILSLWSKISTQADVIGTETLERLFSCYPQAKTYFPHFDLHSGSAQLRAHG\t60\n * *: ::: : : *.*:. :. *:*:***:* .:* :********: ****::.**\n\nsp|P69905|HBA_HUMAN KKVADALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKLLSHCLLVTLAAHLPAEFTP\t120\nsp|P01942|HBA_MOUSE KKVADALASAAGHLDDLPGALSALSDLHAHKLRVDPVNFKLLSHCLLVTLASHHPADFTP\t120\nsp|P13786|HBAZ_CAPHI SKVVAAVGDAVKSIDNVTSALSKLSELHAYVLRVDPVNFKFLSHCLLVTLASHFPADFTA\t120\n .**. *: .*. :*:: .*** **:***: *********:**********:* **:**\n\nsp|P69905|HBA_HUMAN AVHASLDKFLASVSTVLTSKYR\t142\nsp|P01942|HBA_MOUSE AVHASLDKFLASVSTVLTSKYR\t142\nsp|P13786|HBAZ_CAPHI DAHAAWDKFLSIVSGVLTEKYR\t142\n .**: ****: ** ***.***"})}},"Small MSA only"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://ihh.github.io/abrowse/build/pfam-cov2.stock"})}},"PFAM SARS-CoV2 multi-stockholm"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/Lysine.stock"})}},"Lysine stockholm file"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/PF01601_full.txt"})}},"PF01601 stockholm file (SARS-CoV2 spike protein)"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/europe_covid.fa"})}},"Europe COVID full genomes (LR883044.1 and 199 other sequences)"),p.createElement(M,{model:t,onClick:function(){i.transaction((function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.fa"}),t.setTreeFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.nh"})}))}},"MAFFT+VeryFastTree(17.9k samples)")))))}));function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function k(e,t){return e(t={exports:{}},t.exports),t.exports}var L=k((function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.default=e.exports,e.exports.__esModule=!0}));A(L);var C=k((function(e){function t(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=t=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),t(n)}e.exports=t,e.exports.default=e.exports,e.exports.__esModule=!0}));A(C);var P=k((function(e){var t=C.default;function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}e.exports=function(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return{default:e};var o=n(r);if(o&&o.has(e))return o.get(e);var a={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if("default"!==l&&Object.prototype.hasOwnProperty.call(e,l)){var s=i?Object.getOwnPropertyDescriptor(e,l):null;s&&(s.get||s.set)?Object.defineProperty(a,l,s):a[l]=e[l]}return a.default=e,o&&o.set(e,a),a},e.exports.default=e.exports,e.exports.__esModule=!0}));A(P);var T=k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return s.createSvgIcon}})}));A(T);var O,R,D,N,j,I,F,_,B,Y,H,X,V,q,G,W=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}),"Assignment");t.default=r}))),U=a.makeStyles((function(e){return{rubberband:{height:"100%",background:a.alpha(e.palette.tertiary?e.palette.tertiary.main:e.palette.primary.main,.7),position:"absolute",zIndex:10,textAlign:"center",overflow:"hidden"},rubberbandControl:{cursor:"crosshair",width:"100%",minHeight:8},rubberbandText:{color:e.palette.tertiary?e.palette.tertiary.contrastText:e.palette.primary.contrastText},popover:{mouseEvents:"none",cursor:"crosshair"},paper:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},guide:{pointerEvents:"none",height:"100%",width:1,position:"absolute",zIndex:10}}})),z=o.observer((function(e){var t=e.model,n=e.coordX,r=t.treeAreaWidth,o=U();return p.createElement(p.Fragment,null,p.createElement(a.Tooltip,{open:!0,placement:"top",title:""+(t.pxToBp(n)+1),arrow:!0},p.createElement("div",{style:{left:n+r,position:"absolute",height:1}})),p.createElement("div",{className:o.guide,style:{left:n+r,background:"red"}}))})),K=o.observer((function(e){var t=e.model,n=e.ControlComponent,o=void 0===n?p.createElement("div",null):n,i=t.treeAreaWidth,s=r.useState(),c=s[0],u=s[1],f=r.useState(),h=f[0],d=f[1],m=r.useState(),g=m[0],v=m[1],b=r.useState(),y=b[0],w=b[1],E=r.useRef(null),S=r.useRef(null),M=U(),x=void 0!==c&&void 0===g;function A(e){e.preventDefault(),e.stopPropagation();var t=e.clientX-e.target.getBoundingClientRect().left;u(t),d(t)}function k(e){w(e.clientX-e.target.getBoundingClientRect().left)}function L(){w(void 0),t.clearAnnotPos()}function C(){v(void 0),u(void 0),d(void 0)}if(r.useEffect((function(){function e(e){if(E.current&&x){var t=e.clientX-E.current.getBoundingClientRect().left;d(t)}}function t(e){if(void 0!==c&&E.current){var t=e.clientX,n=e.clientY,r=t-E.current.getBoundingClientRect().left;v({offsetX:r,clientX:t,clientY:n}),w(void 0)}}return x?(window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),function(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}):function(){}}),[c,x,g]),r.useEffect((function(){!x&&void 0!==h&&void 0!==c&&Math.abs(h-c)<=3&&C()}),[x,h,c,t.colWidth]),void 0===c)return p.createElement(p.Fragment,null,void 0!==y?p.createElement(z,{model:t,coordX:y}):null,p.createElement("div",{"data-testid":"rubberband_controls",className:M.rubberbandControl,role:"presentation",ref:E,onMouseDown:A,onMouseOut:L,onMouseMove:k},o));var P=g?g.offsetX:h||0,T=P<c?P:c,O=Math.abs(P-c),R=t.pxToBp(T),D=t.pxToBp(T+O),N=Math.ceil(O/t.colWidth),j=[{label:"Create annotation",icon:W,onClick:function(){t.setOffsets(R,D),C()}}];return p.createElement(p.Fragment,null,S.current?p.createElement(p.Fragment,null,p.createElement(a.Popover,{className:M.popover,classes:{paper:M.paper},open:!0,anchorEl:S.current,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,disableRestoreFocus:!0},p.createElement(a.Typography,null,R+1)),p.createElement(a.Popover,{className:M.popover,classes:{paper:M.paper},open:!0,anchorEl:S.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,disableRestoreFocus:!0},p.createElement(a.Typography,null,D+1))):null,p.createElement("div",{ref:S,className:M.rubberband,style:{left:T+i,width:O}},p.createElement(a.Typography,{variant:"h6",className:M.rubberbandText},N.toLocaleString("en-US")," bp")),p.createElement("div",{"data-testid":"rubberband_controls",className:M.rubberbandControl,role:"presentation",ref:E,onMouseDown:A,onMouseOut:L,onMouseMove:k},o),g?p.createElement(l.Menu,{anchorReference:"anchorPosition",anchorPosition:{left:g.clientX,top:g.clientY},onMenuItemClick:function(e,t){t(),C()},open:Boolean(g),onClose:C,menuItems:j}):null)})),Q=!1;function J(){if(!Q){Q=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),n=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(X=/\b(iPhone|iP[ao]d)/.exec(e),V=/\b(iP[ao]d)/.exec(e),Y=/Android/i.exec(e),q=/FBAN\/\w+;/i.exec(e),G=/Mobile/i.exec(e),H=!!/Win64/.exec(e),t){(O=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN)&&document&&document.documentMode&&(O=document.documentMode);var r=/(?:Trident\/(\d+.\d+))/.exec(e);I=r?parseFloat(r[1])+4:O,R=t[2]?parseFloat(t[2]):NaN,D=t[3]?parseFloat(t[3]):NaN,(N=t[4]?parseFloat(t[4]):NaN)?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),j=t&&t[1]?parseFloat(t[1]):NaN):j=NaN}else O=R=D=j=N=NaN;if(n){if(n[1]){var o=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);F=!o||parseFloat(o[1].replace("_","."))}else F=!1;_=!!n[2],B=!!n[3]}else F=_=B=!1}}var $,Z={ie:function(){return J()||O},ieCompatibilityMode:function(){return J()||I>O},ie64:function(){return Z.ie()&&H},firefox:function(){return J()||R},opera:function(){return J()||D},webkit:function(){return J()||N},safari:function(){return Z.webkit()},chrome:function(){return J()||j},windows:function(){return J()||_},osx:function(){return J()||F},linux:function(){return J()||B},iphone:function(){return J()||X},mobile:function(){return J()||X||V||Y||G},nativeApp:function(){return J()||q},android:function(){return J()||Y},ipad:function(){return J()||V}},ee=Z,te=!("undefined"==typeof window||!window.document||!window.document.createElement),ne=te;function re(e){var t=0,n=0,r=0,o=0;return"detail"in e&&(n=e.detail),"wheelDelta"in e&&(n=-e.wheelDelta/120),"wheelDeltaY"in e&&(n=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=10*t,o=10*n,"deltaY"in e&&(o=e.deltaY),"deltaX"in e&&(r=e.deltaX),(r||o)&&e.deltaMode&&(1==e.deltaMode?(r*=40,o*=40):(r*=800,o*=800)),r&&!t&&(t=r<1?-1:1),o&&!n&&(n=o<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:o}}te&&!window.addEventListener&&window,te&&window,ne&&($=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),re.getEventType=function(){return ee.firefox()?"DOMMouseScroll":function(e,t){if(!ne)return!1;var n="onwheel"in document;if(!n){var r=document.createElement("div");r.setAttribute("onwheel","return;"),n="function"==typeof r.onwheel}return!n&&$&&(n=document.implementation.hasFeature("Events.wheel","3.0")),n}()?"wheel":"mousewheel"};var oe=re;function ae(e,t,n,r,o){!function e(t,n,r,o,a){for(;o>r;){if(o-r>600){var i=o-r+1,l=n-r+1,s=Math.log(i),c=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*c*(i-c)/i)*(l-i/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-l*c/i+u)),Math.min(o,Math.floor(n+(i-l)*c/i+u)),a)}var f=t[n],h=r,d=o;for(ie(t,r,n),a(t[o],f)>0&&ie(t,r,o);h<d;){for(ie(t,h,d),h++,d--;a(t[h],f)<0;)h++;for(;a(t[d],f)>0;)d--}0===a(t[r],f)?ie(t,r,d):ie(t,++d,o),d<=n&&(r=d+1),n<=d&&(o=d-1)}}(e,t,n||0,r||e.length-1,o||le)}function ie(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function le(e,t){return e<t?-1:e>t?1:0}class se{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!ye(e,t))return n;const r=this.toBBox,o=[];for(;t;){for(let a=0;a<t.children.length;a++){const i=t.children[a],l=t.leaf?r(i):i;ye(e,l)&&(t.leaf?n.push(i):be(e,l)?this._all(i,n):o.push(i))}t=o.pop()}return n}collides(e){let t=this.data;if(!ye(e,t))return!1;const n=[];for(;t;){for(let r=0;r<t.children.length;r++){const o=t.children[r],a=t.leaf?this.toBBox(o):o;if(ye(e,a)){if(t.leaf||be(e,a))return!0;n.push(o)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=we([]),this}remove(e,t){if(!e)return this;let n=this.data;const r=this.toBBox(e),o=[],a=[];let i,l,s;for(;n||o.length;){if(n||(n=o.pop(),l=o[o.length-1],i=a.pop(),s=!0),n.leaf){const r=ce(e,n.children,t);if(-1!==r)return n.children.splice(r,1),o.push(n),this._condense(o),this}s||n.leaf||!be(n,r)?l?(i++,n=l.children[i],s=!1):n=null:(o.push(n),a.push(i),i=0,l=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){const o=n-t+1;let a,i=this._maxEntries;if(o<=i)return a=we(e.slice(t,n+1)),ue(a,this.toBBox),a;r||(r=Math.ceil(Math.log(o)/Math.log(i)),i=Math.ceil(o/Math.pow(i,r-1))),a=we([]),a.leaf=!1,a.height=r;const l=Math.ceil(o/i),s=l*Math.ceil(Math.sqrt(i));Ee(e,t,n,s,this.compareMinX);for(let o=t;o<=n;o+=s){const t=Math.min(o+s-1,n);Ee(e,o,t,l,this.compareMinY);for(let n=o;n<=t;n+=l){const o=Math.min(n+l-1,t);a.children.push(this._build(e,n,o,r-1))}}return ue(a,this.toBBox),a}_chooseSubtree(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){let n,r=Infinity,i=Infinity;for(let l=0;l<t.children.length;l++){const s=t.children[l],c=pe(s),u=(o=e,a=s,(Math.max(a.maxX,o.maxX)-Math.min(a.minX,o.minX))*(Math.max(a.maxY,o.maxY)-Math.min(a.minY,o.minY))-c);u<i?(i=u,r=c<r?c:r,n=s):u===i&&c<r&&(r=c,n=s)}t=n||t.children[0]}var o,a;return t}_insert(e,t,n){const r=n?e:this.toBBox(e),o=[],a=this._chooseSubtree(r,this.data,t,o);for(a.children.push(e),he(a,r);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(r,o,t)}_split(e,t){const n=e[t],r=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,r);const a=this._chooseSplitIndex(n,o,r),i=we(n.children.splice(a,n.children.length-a));i.height=n.height,i.leaf=n.leaf,ue(n,this.toBBox),ue(i,this.toBBox),t?e[t-1].children.push(i):this._splitRoot(n,i)}_splitRoot(e,t){this.data=we([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ue(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,o=Infinity,a=Infinity;for(let i=t;i<=n-t;i++){const t=fe(e,0,i,this.toBBox),l=fe(e,i,n,this.toBBox),s=ve(t,l),c=pe(t)+pe(l);s<o?(o=s,r=i,a=c<a?c:a):s===o&&c<a&&(a=c,r=i)}return r||n-t}_chooseSplitAxis(e,t,n){const r=e.leaf?this.compareMinX:de,o=e.leaf?this.compareMinY:me;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,o)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);const o=this.toBBox,a=fe(e,0,t,o),i=fe(e,n-t,n,o);let l=ge(a)+ge(i);for(let r=t;r<n-t;r++){const t=e.children[r];he(a,e.leaf?o(t):t),l+=ge(a)}for(let r=n-t-1;r>=t;r--){const t=e.children[r];he(i,e.leaf?o(t):t),l+=ge(i)}return l}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)he(t[r],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)0===e[n].children.length?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():ue(e[n],this.toBBox)}}function ce(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function ue(e,t){fe(e,0,e.children.length,t,e)}function fe(e,t,n,r,o){o||(o=we(null)),o.minX=Infinity,o.minY=Infinity,o.maxX=-Infinity,o.maxY=-Infinity;for(let a=t;a<n;a++){const t=e.children[a];he(o,e.leaf?r(t):t)}return o}function he(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function de(e,t){return e.minX-t.minX}function me(e,t){return e.minY-t.minY}function pe(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ge(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ve(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,a-r)}function be(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function ye(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function we(e){return{children:e,height:1,leaf:!0,minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}}function Ee(e,t,n,r,o){const a=[t,n];for(;a.length;){if((n=a.pop())-(t=a.pop())<=r)continue;const i=t+Math.ceil((n-t)/r/2)*r;ae(e,i,t,n,o),a.push(t,i,i,n)}}var Se=o.observer((function(e){var t=e.info,n=e.onClose;return p.createElement(a.Dialog,{onClose:function(){return n()},open:!0},p.createElement(a.DialogTitle,null,"Metadata"),p.createElement(a.DialogContent,null,p.createElement(c.Attributes,{attributes:t})))})),Me=function(){return(Me=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},xe=o.observer((function(e){var t,n,r=e.node,o=e.onClose,i=e.model,l=i.structures,s=r?i.getRowDetails(r.name):void 0;return p.createElement(p.Fragment,null,p.createElement(a.Menu,{anchorReference:"anchorPosition",anchorPosition:{top:r.y,left:r.x},transitionDuration:0,keepMounted:!0,open:Boolean(r),onClose:o},p.createElement(a.MenuItem,{dense:!0,disabled:!0},r.name),p.createElement(a.MenuItem,{dense:!0,onClick:function(){i.setDialogComponent(Se,{info:i.getRowDetails(r.name)}),o()}},"More info..."),null===(t=l[r.name])||void 0===t?void 0:t.map((function(e){return i.selectedStructures.find((function(e){return e.id===r.name}))?p.createElement(a.MenuItem,{key:JSON.stringify(e),dense:!0,onClick:function(){i.removeStructureFromSelection({structure:e,id:r.name}),o()}},"Remove PDB from selection (",e.pdb,")"):p.createElement(a.MenuItem,{key:JSON.stringify(e),dense:!0,onClick:function(){i.addStructureToSelection({structure:e,id:r.name}),o()}},"Add PDB to selection (",e.pdb,")")})),null===(n=s.accession)||void 0===n?void 0:n.map((function(e){return p.createElement(a.MenuItem,{dense:!0,key:e,onClick:function(){i.addUniprotTrack({name:s.name,accession:e}),o()}},"Open UniProt track (",e,")")}))))})),Ae=o.observer((function(e){var t=e.node,n=e.model,r=e.onClose;return p.createElement(a.Menu,{anchorReference:"anchorPosition",anchorPosition:{left:t.x,top:t.y},transitionDuration:0,keepMounted:!0,open:Boolean(t),onClose:r},p.createElement(a.MenuItem,{dense:!0,disabled:!0},t.name),p.createElement(a.MenuItem,{dense:!0,onClick:function(){n.toggleCollapsed(t.id),r()}},n.collapsed.includes(t.id)?"Expand this node":"Collapse this node"),p.createElement(a.MenuItem,{dense:!0,onClick:function(){n.setShowOnly(n.showOnly===t.id?void 0:t.id),r()}},n.showOnly===t.id?"Disable show only this node":"Show only this node"))})),ke=o.observer((function(e){var t=e.model,n=e.offsetY,o=r.useRef(null),a=r.useRef(new se),i=r.useRef(null),l=r.useState(),s=l[0],c=l[1],u=r.useState(),f=u[0],h=u[1],d=r.useState(),m=d[0],g=d[1],v=t.hierarchy,b=t.rowHeight,y=t.scrollY,w=t.treeWidth,E=t.showBranchLen,S=t.collapsed,M=t.margin,x=t.labelsAlignRight,A=t.noTree,k=t.blockSize,L=t.drawNodeBubbles,C=t.drawTree,P=t.treeAreaWidth,T=t.structures,O=t.highResScaleFactor;function R(e){var t=e.nativeEvent.offsetX-M.left,r=e.nativeEvent.offsetY,o=a.current.search({minX:t,maxX:t+1,minY:r+n,maxY:r+1+n})[0];return o&&o.branch?Me(Me({},o),{x:e.clientX,y:e.clientY}):void 0}function D(e){var t=e.nativeEvent.offsetX-M.left,r=e.nativeEvent.offsetY,o=a.current.search({minX:t,maxX:t+1,minY:r+n,maxY:r+1+n})[0];return o&&!o.branch?Me(Me({},o),{x:e.clientX,y:e.clientY}):void 0}return r.useEffect((function(){if(a.current.clear(),o.current){var e=o.current.getContext("2d");e&&(e.resetTransform(),e.scale(O,O),e.clearRect(0,0,w+600,k),e.translate(M.left,-n),e.font=e.font.replace(/\d+px/,Math.max(8,b-8)+"px"),!A&&C&&(v.links().forEach((function(t){var r=t.source,o=t.target,a=E?"len":"y",i=r.x,l=r[a],s=o.x,c=o[a],u=Math.min(i,s),f=Math.max(i,s);n+k>=u&&f>=n&&(e.beginPath(),e.moveTo(l,i),e.lineTo(l,s),e.lineTo(c,s),e.stroke())})),L&&v.descendants().forEach((function(t){var r=t.x,o=t[E?"len":"y"],i=t.data,l=i.id,s=void 0===l?"":l,c=i.name,u=void 0===c?"":c;r>n-5&&r<n+k+5&&(e.strokeStyle="black",e.fillStyle=S.includes(s)?"black":"white",e.beginPath(),e.arc(o,r,3.5,0,2*Math.PI),e.fill(),e.stroke(),a.current.insert({minX:o-3.5,maxX:o-3.5+7,minY:r-3.5,maxY:r-3.5+7,branch:!0,id:s,name:u}))}))),b>=10&&(x?(e.textAlign="right",e.setLineDash([1,3])):e.textAlign="start",v.leaves().forEach((function(t){var r=t.x,o=t.data,i=o.name,l=o.id;if(r>n-5&&r<n+k+5){var s=r+b/4,c=E?t.len:t.y,u=e.measureText(i).width,f=e.measureText("M").width;if(e.fillStyle=T[i]?"blue":"black",C||x)if(x){var h=P-2-M.left;if(C&&!A){var d=e.measureText(i).width;e.moveTo(c+3.5+2,r),e.lineTo(h-2-d,r),e.stroke()}e.fillText(i,h,s),a.current.insert({minX:P-M.left-u,maxX:P-M.left,minY:s-f,maxY:s,name:i,id:l})}else e.fillText(i,c+7,s),a.current.insert({minX:c+7,maxX:c+7+u,minY:s-f,maxY:s,name:i,id:l});else e.fillText(i,0,s),a.current.insert({minX:0,maxX:u,minY:s-f,maxY:s,name:i,id:l})}})),e.setLineDash([])))}}),[S,b,M.left,v,n,w,E,A,k,L,C,x,P,T]),r.useEffect((function(){var e=i.current;if(e){var t=e.getContext("2d");if(t&&(t.resetTransform(),t.clearRect(0,0,w+600,k),t.translate(M.left,-n),m)){var r=m.minX,o=m.maxX,a=m.minY,l=m.maxY;t.fillStyle="rgba(0,0,0,0.1)",t.fillRect(r,a,o-r,l-a)}}}),[m,M.left,n,k,w]),p.createElement(p.Fragment,null,(null==s?void 0:s.id)?p.createElement(Ae,{node:s,model:t,onClose:function(){return c(void 0)}}):null,(null==f?void 0:f.id)?p.createElement(xe,{node:f,model:t,onClose:function(){return h(void 0)}}):null,p.createElement("canvas",{width:(w+600)*O,height:k*O,style:{width:w+600,height:k,top:y+n,left:0,position:"absolute"},onMouseMove:function(e){if(o.current){var t=D(e)||R(e);o.current.style.cursor=t?"pointer":"default",g(D(e))}},onClick:function(e){var t=e.clientX,n=e.clientY,r=R(e);(null==r?void 0:r.id)&&c(Me(Me({},r),{x:t,y:n}));var o=D(e);(null==o?void 0:o.id)&&h(Me(Me({},o),{x:t,y:n}))},ref:o}),p.createElement("canvas",{style:{width:w+600,height:k,top:y+n,left:0,position:"absolute",pointerEvents:"none",zIndex:100},width:w+600,height:k,ref:i}))})),Le=o.observer((function(e){var t=e.model,n=r.useRef(null),o=r.useRef(!1),a=r.useRef(0),i=r.useRef(0),l=t.treeWidth,s=t.height,c=t.blocksY,u=r.useState(!1),f=u[0],h=u[1];return r.useEffect((function(){var e=n.current;if(e)return e.addEventListener("wheel",r),function(){e.removeEventListener("wheel",r)};function r(e){var n=oe(e);a.current+=n.pixelY,o.current||(o.current=!0,requestAnimationFrame((function(){t.doScrollY(-a.current),a.current=0,o.current=!1}))),e.preventDefault()}}),[t]),r.useEffect((function(){var e=function(){};function n(e){e.preventDefault();var n=e.clientY-i.current;n&&(o.current||(o.current=!0,window.requestAnimationFrame((function(){t.doScrollY(n),o.current=!1,i.current=e.clientY}))))}function r(){i.current=0,f&&h(!1)}return f&&(window.addEventListener("mousemove",n,!0),window.addEventListener("mouseup",r,!0),e=function(){window.removeEventListener("mousemove",n,!0),window.removeEventListener("mouseup",r,!0)}),e}),[t,f]),p.createElement("div",{ref:n,onMouseDown:function(e){var t=e.target;t.draggable||t.dataset.resizer||0===e.button&&(i.current=e.clientY,h(!0))},onMouseUp:function(e){e.preventDefault(),h(!1)},onMouseLeave:function(e){e.preventDefault()},style:{height:s,position:"relative",overflow:"hidden",width:l+600}},c.map((function(e){return p.createElement(ke,{key:e,model:t,offsetY:e})})))})),Ce={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Pe=k((function(e){var t=Array.prototype.concat,n=Array.prototype.slice,r=e.exports=function(e){for(var r,o=[],a=0,i=e.length;a<i;a++){var l=e[a];(r=l)&&"string"!=typeof r&&(r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&"String"!==r.constructor.name))?o=t.call(o,n.call(l)):o.push(l)}return o};r.wrap=function(e){return function(){return e(r(arguments))}}})),Te=k((function(e){var t={};for(var n in Ce)Ce.hasOwnProperty(n)&&(t[Ce[n]]=n);var r=e.exports={to:{},get:{}};function o(e,t,n){return Math.min(Math.max(t,e),n)}function a(e){var t=e.toString(16).toUpperCase();return t.length<2?"0"+t:t}r.get=function(e){var t,n;switch(e.substring(0,3).toLowerCase()){case"hsl":t=r.get.hsl(e),n="hsl";break;case"hwb":t=r.get.hwb(e),n="hwb";break;default:t=r.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},r.get.rgb=function(e){if(!e)return null;var t,n,r,a=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=t[2],t=t[1],n=0;n<3;n++){var i=2*n;a[n]=parseInt(t.slice(i,i+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(r=(t=t[1])[3],n=0;n<3;n++)a[n]=parseInt(t[n]+t[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/)){for(n=0;n<3;n++)a[n]=parseInt(t[n+1],0);t[4]&&(a[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/)))return(t=e.match(/(\D+)/))?"transparent"===t[1]?[0,0,0,0]:(a=Ce[t[1]])?(a[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(t[n+1]));t[4]&&(a[3]=parseFloat(t[4]))}for(n=0;n<3;n++)a[n]=o(a[n],0,255);return a[3]=o(a[3],0,1),a},r.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])+360)%360,o(parseFloat(t[2]),0,100),o(parseFloat(t[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},r.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,o(parseFloat(t[2]),0,100),o(parseFloat(t[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},r.to.hex=function(){var e=Pe(arguments);return"#"+a(e[0])+a(e[1])+a(e[2])+(e[3]<1?a(Math.round(255*e[3])):"")},r.to.rgb=function(){var e=Pe(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},r.to.rgb.percent=function(){var e=Pe(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},r.to.hsl=function(){var e=Pe(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},r.to.hwb=function(){var e=Pe(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},r.to.keyword=function(e){return t[e.slice(0,3)]}})),Oe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Re=k((function(e){var t={};for(var n in Oe)Oe.hasOwnProperty(n)&&(t[Oe[n]]=n);var r=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var o in r)if(r.hasOwnProperty(o)){if(!("channels"in r[o]))throw new Error("missing channels property: "+o);if(!("labels"in r[o]))throw new Error("missing channel labels property: "+o);if(r[o].labels.length!==r[o].channels)throw new Error("channel and label counts mismatch: "+o);var a=r[o].channels,i=r[o].labels;delete r[o].channels,delete r[o].labels,Object.defineProperty(r[o],"channels",{value:a}),Object.defineProperty(r[o],"labels",{value:i})}r.rgb.hsl=function(e){var t,n,r=e[0]/255,o=e[1]/255,a=e[2]/255,i=Math.min(r,o,a),l=Math.max(r,o,a),s=l-i;return l===i?t=0:r===l?t=(o-a)/s:o===l?t=2+(a-r)/s:a===l&&(t=4+(r-o)/s),(t=Math.min(60*t,360))<0&&(t+=360),n=(i+l)/2,[t,100*(l===i?0:n<=.5?s/(l+i):s/(2-l-i)),100*n]},r.rgb.hsv=function(e){var t,n,r,o,a,i=e[0]/255,l=e[1]/255,s=e[2]/255,c=Math.max(i,l,s),u=c-Math.min(i,l,s),f=function(e){return(c-e)/6/u+.5};return 0===u?o=a=0:(a=u/c,t=f(i),n=f(l),r=f(s),i===c?o=r-n:l===c?o=1/3+t-r:s===c&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*a,100*c]},r.rgb.hwb=function(e){var t=e[0],n=e[1],o=e[2];return[r.rgb.hsl(e)[0],1/255*Math.min(t,Math.min(n,o))*100,100*(o=1-1/255*Math.max(t,Math.max(n,o)))]},r.rgb.cmyk=function(e){var t,n=e[0]/255,r=e[1]/255,o=e[2]/255;return[100*((1-n-(t=Math.min(1-n,1-r,1-o)))/(1-t)||0),100*((1-r-t)/(1-t)||0),100*((1-o-t)/(1-t)||0),100*t]},r.rgb.keyword=function(e){var n=t[e];if(n)return n;var r,o,a,i=Infinity;for(var l in Oe)if(Oe.hasOwnProperty(l)){var s=(o=e,a=Oe[l],Math.pow(o[0]-a[0],2)+Math.pow(o[1]-a[1],2)+Math.pow(o[2]-a[2],2));s<i&&(i=s,r=l)}return r},r.keyword.rgb=function(e){return Oe[e]},r.rgb.xyz=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},r.rgb.lab=function(e){var t=r.rgb.xyz(e),n=t[0],o=t[1],a=t[2];return o/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(o=o>.008856?Math.pow(o,1/3):7.787*o+16/116)-16,500*(n-o),200*(o-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},r.hsl.rgb=function(e){var t,n,r,o,a,i=e[0]/360,l=e[1]/100,s=e[2]/100;if(0===l)return[a=255*s,a,a];t=2*s-(n=s<.5?s*(1+l):s+l-s*l),o=[0,0,0];for(var c=0;c<3;c++)(r=i+1/3*-(c-1))<0&&r++,r>1&&r--,o[c]=255*(a=6*r<1?t+6*(n-t)*r:2*r<1?n:3*r<2?t+(n-t)*(2/3-r)*6:t);return o},r.hsl.hsv=function(e){var t=e[0],n=e[1]/100,r=e[2]/100,o=n,a=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,o*=a<=1?a:2-a,[t,100*(0===r?2*o/(a+o):2*n/(r+n)),(r+n)/2*100]},r.hsv.rgb=function(e){var t=e[0]/60,n=e[1]/100,r=e[2]/100,o=Math.floor(t)%6,a=t-Math.floor(t),i=255*r*(1-n),l=255*r*(1-n*a),s=255*r*(1-n*(1-a));switch(r*=255,o){case 0:return[r,s,i];case 1:return[l,r,i];case 2:return[i,r,s];case 3:return[i,l,r];case 4:return[s,i,r];case 5:return[r,i,l]}},r.hsv.hsl=function(e){var t,n,r,o=e[0],a=e[1]/100,i=e[2]/100,l=Math.max(i,.01);return r=(2-a)*i,n=a*l,[o,100*(n=(n/=(t=(2-a)*l)<=1?t:2-t)||0),100*(r/=2)]},r.hwb.rgb=function(e){var t,n,r,o,a,i,l,s=e[0]/360,c=e[1]/100,u=e[2]/100,f=c+u;switch(f>1&&(c/=f,u/=f),r=6*s-(t=Math.floor(6*s)),0!=(1&t)&&(r=1-r),o=c+r*((n=1-u)-c),t){default:case 6:case 0:a=n,i=o,l=c;break;case 1:a=o,i=n,l=c;break;case 2:a=c,i=n,l=o;break;case 3:a=c,i=o,l=n;break;case 4:a=o,i=c,l=n;break;case 5:a=n,i=c,l=o}return[255*a,255*i,255*l]},r.cmyk.rgb=function(e){var t=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,e[0]/100*(1-r)+r)),255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},r.xyz.rgb=function(e){var t,n,r,o=e[0]/100,a=e[1]/100,i=e[2]/100;return n=-.9689*o+1.8758*a+.0415*i,r=.0557*o+-.204*a+1.057*i,t=(t=3.2406*o+-1.5372*a+-.4986*i)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(t=Math.min(Math.max(0,t),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},r.xyz.lab=function(e){var t=e[0],n=e[1],r=e[2];return n/=100,r/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(t-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},r.lab.xyz=function(e){var t,n,r;t=e[1]/500+(n=(e[0]+16)/116),r=n-e[2]/200;var o=Math.pow(n,3),a=Math.pow(t,3),i=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,t=a>.008856?a:(t-16/116)/7.787,r=i>.008856?i:(r-16/116)/7.787,[t*=95.047,n*=100,r*=108.883]},r.lab.lch=function(e){var t,n=e[0],r=e[1],o=e[2];return(t=360*Math.atan2(o,r)/2/Math.PI)<0&&(t+=360),[n,Math.sqrt(r*r+o*o),t]},r.lch.lab=function(e){var t,n=e[1];return t=e[2]/360*2*Math.PI,[e[0],n*Math.cos(t),n*Math.sin(t)]},r.rgb.ansi16=function(e){var t=e[0],n=e[1],o=e[2],a=1 in arguments?arguments[1]:r.rgb.hsv(e)[2];if(0===(a=Math.round(a/50)))return 30;var i=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return 2===a&&(i+=60),i},r.hsv.ansi16=function(e){return r.rgb.ansi16(r.hsv.rgb(e),e[2])},r.rgb.ansi256=function(e){var t=e[0],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},r.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];var n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},r.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}var n;return e-=16,[Math.floor(e/36)/5*255,Math.floor((n=e%36)/6)/5*255,n%6/5*255]},r.rgb.hex=function(e){var t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},r.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var n=t[0];3===t[0].length&&(n=n.split("").map((function(e){return e+e})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},r.rgb.hcg=function(e){var t,n=e[0]/255,r=e[1]/255,o=e[2]/255,a=Math.max(Math.max(n,r),o),i=Math.min(Math.min(n,r),o),l=a-i;return t=l<=0?0:a===n?(r-o)/l%6:a===r?2+(o-n)/l:4+(n-r)/l+4,t/=6,[360*(t%=1),100*l,100*(l<1?i/(1-l):0)]},r.hsl.hcg=function(e){var t,n=e[1]/100,r=e[2]/100,o=0;return(t=r<.5?2*n*r:2*n*(1-r))<1&&(o=(r-.5*t)/(1-t)),[e[0],100*t,100*o]},r.hsv.hcg=function(e){var t=e[2]/100,n=e[1]/100*t,r=0;return n<1&&(r=(t-n)/(1-n)),[e[0],100*n,100*r]},r.hcg.rgb=function(e){var t=e[1]/100,n=e[2]/100;if(0===t)return[255*n,255*n,255*n];var r,o=[0,0,0],a=e[0]/360%1*6,i=a%1,l=1-i;switch(Math.floor(a)){case 0:o[0]=1,o[1]=i,o[2]=0;break;case 1:o[0]=l,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=i;break;case 3:o[0]=0,o[1]=l,o[2]=1;break;case 4:o[0]=i,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=l}return[255*(t*o[0]+(r=(1-t)*n)),255*(t*o[1]+r),255*(t*o[2]+r)]},r.hcg.hsv=function(e){var t=e[1]/100,n=t+e[2]/100*(1-t),r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},r.hcg.hsl=function(e){var t=e[1]/100,n=e[2]/100*(1-t)+.5*t,r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},r.hcg.hwb=function(e){var t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},r.hwb.hcg=function(e){var t=1-e[2]/100,n=t-e[1]/100,r=0;return n<1&&(r=(t-n)/(1-n)),[e[0],100*n,100*r]},r.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},r.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},r.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},r.gray.hsl=r.gray.hsv=function(e){return[0,0,e[0]]},r.gray.hwb=function(e){return[0,100,e[0]]},r.gray.cmyk=function(e){return[0,0,0,e[0]]},r.gray.lab=function(e){return[e[0],0,0]},r.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},r.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}}));function De(e,t){return function(n){return t(e(n))}}function Ne(e,t){for(var n=[t[e].parent,e],r=Re[t[e].parent][e],o=t[e].parent;t[o].parent;)n.unshift(t[o].parent),r=De(Re[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}var je={};Object.keys(Re).forEach((function(e){je[e]={},Object.defineProperty(je[e],"channels",{value:Re[e].channels}),Object.defineProperty(je[e],"labels",{value:Re[e].labels});var t=function(e){for(var t=function(e){var t=function(){for(var e={},t=Object.keys(Re),n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}(),n=[e];for(t[e].distance=0;n.length;)for(var r=n.pop(),o=Object.keys(Re[r]),a=o.length,i=0;i<a;i++){var l=o[i],s=t[l];-1===s.distance&&(s.distance=t[r].distance+1,s.parent=r,n.unshift(l))}return t}(e),n={},r=Object.keys(t),o=r.length,a=0;a<o;a++){var i=r[a];null!==t[i].parent&&(n[i]=Ne(i,t))}return n}(e);Object.keys(t).forEach((function(n){var r=t[n];je[e][n]=function(e){var t=function(t){if(null==t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var n=e(t);if("object"==typeof n)for(var r=n.length,o=0;o<r;o++)n[o]=Math.round(n[o]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(r),je[e][n].raw=function(e){var t=function(t){return null==t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)}))}));var Ie=je,Fe=[].slice,_e=["keyword","gray","hex"],Be={};Object.keys(Ie).forEach((function(e){Be[Fe.call(Ie[e].labels).sort().join("")]=e}));var Ye={};function He(e,t){if(!(this instanceof He))return new He(e,t);if(t&&t in _e&&(t=null),t&&!(t in Ie))throw new Error("Unknown model: "+t);var n,r;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof He)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if("string"==typeof e){var o=Te.get(e);if(null===o)throw new Error("Unable to parse color from string: "+e);this.model=o.model,this.color=o.value.slice(0,r=Ie[this.model].channels),this.valpha="number"==typeof o.value[r]?o.value[r]:1}else if(e.length){this.model=t||"rgb";var a=Fe.call(e,0,r=Ie[this.model].channels);this.color=Ge(a,r),this.valpha="number"==typeof e[r]?e[r]:1}else if("number"==typeof e)e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;var i=Object.keys(e);"alpha"in e&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);var l=i.sort().join("");if(!(l in Be))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=Be[l];var s=Ie[this.model].labels,c=[];for(n=0;n<s.length;n++)c.push(e[s[n]]);this.color=Ge(c)}if(Ye[this.model])for(r=Ie[this.model].channels,n=0;n<r;n++){var u=Ye[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function Xe(e,t,n){return(e=Array.isArray(e)?e:[e]).forEach((function(e){(Ye[e]||(Ye[e]=[]))[t]=n})),e=e[0],function(r){var o;return arguments.length?(n&&(r=n(r)),(o=this[e]()).color[t]=r,o):(o=this[e]().color[t],n&&(o=n(o)),o)}}function Ve(e){return function(t){return Math.max(0,Math.min(e,t))}}function qe(e){return Array.isArray(e)?e:[e]}function Ge(e,t){for(var n=0;n<t;n++)"number"!=typeof e[n]&&(e[n]=0);return e}He.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var t=this.model in Te.to?this:this.rgb(),n=1===(t=t.round("number"==typeof e?e:1)).valpha?t.color:t.color.concat(this.valpha);return Te.to[t.model](n)},percentString:function(e){var t=this.rgb().round("number"==typeof e?e:1),n=1===t.valpha?t.color:t.color.concat(this.valpha);return Te.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},t=Ie[this.model].channels,n=Ie[this.model].labels,r=0;r<t;r++)e[n[r]]=this.color[r];return 1!==this.valpha&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,1!==this.valpha&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,1!==this.valpha&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new He(this.color.map(function(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new He(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:Xe("rgb",0,Ve(255)),green:Xe("rgb",1,Ve(255)),blue:Xe("rgb",2,Ve(255)),hue:Xe(["hsl","hsv","hsl","hwb","hcg"],0,(function(e){return(e%360+360)%360})),saturationl:Xe("hsl",1,Ve(100)),lightness:Xe("hsl",2,Ve(100)),saturationv:Xe("hsv",1,Ve(100)),value:Xe("hsv",2,Ve(100)),chroma:Xe("hcg",1,Ve(100)),gray:Xe("hcg",2,Ve(100)),white:Xe("hwb",1,Ve(100)),wblack:Xe("hwb",2,Ve(100)),cyan:Xe("cmyk",0,Ve(100)),magenta:Xe("cmyk",1,Ve(100)),yellow:Xe("cmyk",2,Ve(100)),black:Xe("cmyk",3,Ve(100)),x:Xe("xyz",0,Ve(100)),y:Xe("xyz",1,Ve(100)),z:Xe("xyz",2,Ve(100)),l:Xe("lab",0,Ve(100)),a:Xe("lab",1),b:Xe("lab",2),keyword:function(e){return arguments.length?new He(e):Ie[this.model].keyword(this.color)},hex:function(e){return arguments.length?new He(e):Te.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity:function(){for(var e=this.rgb().color,t=[],n=0;n<e.length;n++){var r=e[n]/255;t[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast:function(e){var t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level:function(e){var t=this.contrast(e);return t>=7.1?"AAA":t>=4.5?"AA":""},isDark:function(){var e=this.rgb().color;return(299*e[0]+587*e[1]+114*e[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten:function(e){var t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken:function(e){var t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate:function(e){var t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate:function(e){var t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten:function(e){var t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken:function(e){var t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale:function(){var e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return He.rgb(t,t,t)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var t=this.hsl(),n=t.color[0];return t.color[0]=n=(n=(n+e)%360)<0?360+n:n,t},mix:function(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var n=e.rgb(),r=this.rgb(),o=void 0===t?.5:t,a=2*o-1,i=n.alpha()-r.alpha(),l=((a*i==-1?a:(a+i)/(1+a*i))+1)/2,s=1-l;return He.rgb(l*n.red()+s*r.red(),l*n.green()+s*r.green(),l*n.blue()+s*r.blue(),n.alpha()*o+r.alpha()*(1-o))}},Object.keys(Ie).forEach((function(e){if(-1===_e.indexOf(e)){var t=Ie[e].channels;He.prototype[e]=function(){if(this.model===e)return new He(this);if(arguments.length)return new He(arguments,e);var n="number"==typeof arguments[t]?t:this.valpha;return new He(qe(Ie[this.model][e].raw(this.color)).concat(n),e)},He[e]=function(n){return"number"==typeof n&&(n=Ge(Fe.call(arguments),t)),new He(n,e)}}}));var We=He,Ue=function(){return(Ue=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function ze(e,t){return Object.fromEntries(Object.entries(e).map(t))}function Ke(e,t,n){var r;void 0===t&&(t="node"),void 0===n&&(n=0);var o=t+"-"+n;return Ue(Ue({},e),{id:o,branchset:(null===(r=e.branchset)||void 0===r?void 0:r.map((function(e,t){return Ke(e,o+"-"+t,n+1)})))||[]})}function Qe(e,t){return ze(e,(function(e){return[e[0],t.palette.getContrastText(We(e[1]).hex())]}))}var Je=ze({clustal:{G:"orange",P:"orange",S:"orange",T:"orange",H:"red",K:"red",R:"red",F:"blue",W:"blue",Y:"blue",I:"green",L:"green",M:"green",V:"green"},lesk:{G:"orange",A:"orange",S:"orange",T:"orange",C:"green",V:"green",I:"green",L:"green",P:"green",F:"green",Y:"green",M:"green",W:"green",N:"magenta",Q:"magenta",H:"magenta",D:"red",E:"red",K:"blue",R:"blue"},maeditor:{A:"lightgreen",G:"lightgreen",C:"green",D:"darkgreen",E:"darkgreen",N:"darkgreen",Q:"darkgreen",I:"blue",L:"blue",M:"blue",V:"blue",F:"#c8a2c8",W:"#c8a2c8",Y:"#c8a2c8",H:"darkblue",K:"orange",R:"orange",P:"pink",S:"red",T:"red"},percent_identity_dynamic:{},flower:{A:"#b18a51",C:"#ff5701",D:"#01a578",E:"#2da0a1",F:"#fa559d",G:"#b1c23c",H:"#0194f9",I:"#f27663",K:"#7fc3d7",L:"#df6e75",M:"#fe9daf",N:"#0bcec6",P:"#4fa32a",Q:"#7295ae",R:"#83bff1",S:"#b4bd9b",T:"#d2b576",V:"#fd997b",W:"#ff2ded",Y:"#c96ecf"},rainbow_dna:{A:"#3737f5",C:"#37f537",G:"#f5f537",T:"#f53737",U:"#f53737"},clustalx_protein:{A:"#197fe5",C:"#e57f7f",D:"#cc4ccc",E:"#cc4ccc",F:"#197fe5",G:"#e5994c",H:"#19b2b2",I:"#197fe5",K:"#e53319",L:"#197fe5",M:"#197fe5",N:"#19cc19",P:"#cccc00",Q:"#19cc19",R:"#e53319",S:"#19cc19",T:"#19cc19",V:"#197fe5",W:"#197fe5",Y:"#19b2b2"},clustalx_protein_dynamic:{},clustalx_dna:{A:"#e53319",C:"#197fe5",G:"#e5994c",T:"#19cc19",U:"#19cc19"},jalview_buried:{A:"#00a35c",R:"#00fc03",N:"#00eb14",D:"#00eb14",C:"#0000ff",Q:"#00f10e",E:"#00f10e",G:"#009d62",H:"#00d52a",I:"#0054ab",L:"#007b84",K:"#00ff00",M:"#009768",F:"#008778",P:"#00e01f",S:"#00d52a",T:"#00db24",W:"#00a857",Y:"#00e619",V:"#005fa0",B:"#00eb14",X:"#00b649",Z:"#00f10e"},jalview_hydrophobicity:{A:"#ad0052",R:"#0000ff",N:"#0c00f3",D:"#0c00f3",C:"#c2003d",Q:"#0c00f3",E:"#0c00f3",G:"#6a0095",H:"#1500ea",I:"#ff0000",L:"#ea0015",K:"#0000ff",M:"#b0004f",F:"#cb0034",P:"#4600b9",S:"#5e00a1",T:"#61009e",W:"#5b00a4",Y:"#4f00b0",V:"#f60009",B:"#0c00f3",X:"#680097",Z:"#0c00f3"},jalview_prophelix:{A:"#e718e7",R:"#6f906f",N:"#1be41b",D:"#778877",C:"#23dc23",Q:"#926d92",E:"#ff00ff",G:"#00ff00",H:"#758a75",I:"#8a758a",L:"#ae51ae",K:"#a05fa0",M:"#ef10ef",F:"#986798",P:"#00ff00",S:"#36c936",T:"#47b847",W:"#8a758a",Y:"#21de21",V:"#857a85",B:"#49b649",X:"#758a75",Z:"#c936c9"},jalview_propstrand:{A:"#5858a7",R:"#6b6b94",N:"#64649b",D:"#2121de",C:"#9d9d62",Q:"#8c8c73",E:"#0000ff",G:"#4949b6",H:"#60609f",I:"#ecec13",L:"#b2b24d",K:"#4747b8",M:"#82827d",F:"#c2c23d",P:"#2323dc",S:"#4949b6",T:"#9d9d62",W:"#c0c03f",Y:"#d3d32c",V:"#ffff00",B:"#4343bc",X:"#797986",Z:"#4747b8"},jalview_propturn:{A:"#2cd3d3",R:"#708f8f",N:"#ff0000",D:"#e81717",C:"#a85757",Q:"#3fc0c0",E:"#778888",G:"#ff0000",H:"#708f8f",I:"#00ffff",L:"#1ce3e3",K:"#7e8181",M:"#1ee1e1",F:"#1ee1e1",P:"#f60909",S:"#e11e1e",T:"#738c8c",W:"#738c8c",Y:"#9d6262",V:"#07f8f8",B:"#f30c0c",X:"#7c8383",Z:"#5ba4a4"},jalview_taylor:{A:"#ccff00",R:"#0000ff",N:"#cc00ff",D:"#ff0000",C:"#ffff00",Q:"#ff00cc",E:"#ff0066",G:"#ff9900",H:"#0066ff",I:"#66ff00",L:"#33ff00",K:"#6600ff",M:"#00ff00",F:"#00ff66",P:"#ffcc00",S:"#ff3300",T:"#ff6600",W:"#00ccff",Y:"#00ffcc",V:"#99ff00"},jalview_zappo:{A:"#ffafaf",R:"#6464ff",N:"#00ff00",D:"#ff0000",C:"#ffff00",Q:"#00ff00",E:"#ff0000",G:"#ff00ff",H:"#6464ff",I:"#ffafaf",L:"#ffafaf",K:"#6464ff",M:"#ffafaf",F:"#ffc800",P:"#ff00ff",S:"#00ff00",T:"#00ff00",W:"#ffc800",Y:"#ffc800",V:"#ffafaf"},cinema:{H:"blue",K:"blue",R:"blue",D:"red",E:"red",S:"green",T:"green",N:"green",Q:"green",A:"white",V:"white",L:"white",I:"white",M:"white",F:"magenta",W:"magenta",Y:"magenta",P:"brown",G:"brown",C:"yellow",B:"gray",Z:"gray",X:"gray","-":"gray",".":"gray"}},(function(e){return[e[0],ze(e[1],(function(e){return[e[0],We(e[1]).hex()]}))]}));function $e(e,t,n,r){var o=Object.values(e).reduce((function(e,t){return e+t}),0),a=t.columns[n][r],i=e.W,l=void 0===i?0:i,s=e.L,c=void 0===s?0:s,u=e.V,f=void 0===u?0:u,h=e.I,d=void 0===h?0:h,m=e.M,p=void 0===m?0:m,g=e.A,v=void 0===g?0:g,b=e.F,y=void 0===b?0:b,w=e.C,E=void 0===w?0:w,S=e.H,M=void 0===S?0:S,x=e.P,A=void 0===x?0:x,k=e.R,L=void 0===k?0:k,C=e.K,P=void 0===C?0:C,T=e.Q,O=void 0===T?0:T,R=e.E,D=void 0===R?0:R,N=e.D,j=void 0===N?0:N,I=e.T,F=void 0===I?0:I,_=e.S,B=void 0===_?0:_,Y=e.G,H=e.Y,X=void 0===H?0:H,V=e.N,q=l+c+f+d+p+v+y+E+M+A+X,G=P+L,W=O+D;return q/o>.6&&("W"===a||"L"===a||"V"===a||"A"===a||"I"===a||"M"===a||"F"===a||"C"===a)?"rgb(128,179,230)":"K"!==a&&"R"!==a||!(G/o>.6||P/o>.8||L/o>.8||O/o>.8)?"E"===a&&(G/o>.6||W/o>.5||D/o>.8||O/o>.8||j/o>.8)?"rgb(192, 72, 192)":"D"===a&&(G/o>.6||(D+j)/o>.5||P/o>.8||L/o>.8||O/o>.8)?"rgb(204, 77, 204)":"N"===a&&((void 0===V?0:V)/o>.5||X/o>.85)||"Q"===a&&(G/o>.6||W/o>.6||O/o>.85||D/o>.85||P/o>.85||L/o>.85)?"#8f8":"S"!==a&&"T"!==a||!(q/o>.6||(F+B)/o>.5||B/o>.85||F/o>.85)?"C"===a&&E/o>.85?"rgb(240, 128, 128)":"G"===a&&(void 0===Y?0:Y)/o>0?"rgb(240, 144, 72)":"P"===a&&A/o>0?"rgb(204, 204, 0)":"H"!==a&&"Y"!==a||!(q/o>.6||l>.85||X>.85||v>.85||E>.85||A>.85||O>.85||y>.85||M>.85||d>.85||c>.85||p>.85||f>.85)?void 0:"rgb(26, 179, 179)":"rgb(26,204,26)":"#d88"}function Ze(e,t,n,r){for(var o=Object.values(e).reduce((function(e,t){return e+t}),0),a=t.columns[n][r],i=Object.entries(e),l=0,s="",c=0;c<i.length;c++)i[c][1]>l&&"-"!==i[c][0]&&(s=i[c][0],l=i[c][1]);var u=l/o,f="hsl(240, 30%, "+100*Math.max(1-l/o/3,.3)+"%)";if(u>.4&&a===s)return f}var et=o.observer((function(e){var t=e.model,n=e.offsetX,o=e.offsetY,i=t.MSA,l=t.colWidth,s=t.bgColor,c=t.columns,u=t.rowHeight,f=t.scrollY,h=t.scrollX,d=t.hierarchy,m=t.colorScheme,g=t.colorSchemeName,v=t.blockSize,b=t.highResScaleFactor,y=t.colStats,w=a.useTheme(),E=r.useMemo((function(){return Qe(m,w)}),[m,w]),S=r.useRef(null);return r.useEffect((function(){if(S.current){var e=S.current.getContext("2d");if(e){e.resetTransform(),e.scale(b,b),e.clearRect(0,0,v,v),e.translate(-n,u/2-o),e.textAlign="center",e.font=e.font.replace(/\d+px/,Math.max(8,u-8)+"px");var r=d.leaves(),a=v,i=Math.max(0,Math.floor((o-u)/u)),f=Math.max(0,Math.ceil((o+a+u)/u)),h=Math.max(0,Math.floor(n/l)),p=Math.max(0,Math.ceil((n+a)/l)),w=r.slice(i,f);w.forEach((function(r){for(var o,a=r.x,i=r.data.name,f=null===(o=c[i])||void 0===o?void 0:o.slice(h,p),d=0;d<(null==f?void 0:f.length);d++){var v=f[d],b="clustalx_protein_dynamic"===g?$e(y[h+d],t,i,h+d):"percent_identity_dynamic"===g?Ze(y[h+d],t,i,h+d):m[v.toUpperCase()];if(s){var w=d*l+n-n%l;e.fillStyle=b||"white",e.fillRect(w,a-u,l,u)}}})),u>=10&&l>=u/2&&w.forEach((function(t){for(var r,o=t.x,a=null===(r=c[t.data.name])||void 0===r?void 0:r.slice(h,p),i=0;i<(null==a?void 0:a.length);i++){var f=a[i],d=m[f.toUpperCase()],g=E[f.toUpperCase()]||"black",v=i*l+n-n%l;e.fillStyle=s?g:d||"black",e.fillText(f,v+l/2,o-u/4)}}))}}}),[i,b,c,m,E,s,u,l,d,n,o,v]),p.createElement("canvas",{ref:S,onMouseMove:function(e){if(S.current){var r=S.current.getBoundingClientRect(),a=e.clientY-r.top;t.setMousePos(Math.floor((e.clientX-r.left+n)/l)+1,Math.floor((a+o)/u))}},onMouseLeave:function(){return t.setMousePos()},width:v*b,height:v*b,style:{position:"absolute",top:f+o,left:h+n,width:v,height:v}})})),tt=o.observer((function(e){var t=e.model,n=t.MSA,o=t.msaFilehandle,i=t.height,l=t.msaAreaWidth,s=t.blocks2d,c=r.useRef(null),u=r.useRef(!1),f=r.useRef(0),h=r.useRef(0),d=r.useRef(0),m=r.useRef(0),g=r.useState(!1),v=g[0],b=g[1];return r.useEffect((function(){var e=c.current;if(e)return e.addEventListener("wheel",n),function(){e.removeEventListener("wheel",n)};function n(e){var n=oe(e);f.current+=n.pixelX,h.current+=n.pixelY,u.current||(u.current=!0,requestAnimationFrame((function(){t.doScrollX(-f.current),t.doScrollY(-h.current),f.current=0,h.current=0,u.current=!1}))),e.preventDefault()}}),[t]),r.useEffect((function(){var e=function(){};function n(e){e.preventDefault();var n=e.clientX-d.current,r=e.clientY-m.current;(n||r)&&(u.current||(u.current=!0,window.requestAnimationFrame((function(){t.doScrollX(n),t.doScrollY(r),u.current=!1,d.current=e.clientX,m.current=e.clientY}))))}function r(){d.current=0,v&&b(!1)}return v&&(window.addEventListener("mousemove",n,!0),window.addEventListener("mouseup",r,!0),e=function(){window.removeEventListener("mousemove",n,!0),window.removeEventListener("mouseup",r,!0)}),e}),[t,v]),p.createElement("div",{ref:c,onMouseDown:function(e){var t=e.target;t.draggable||t.dataset.resizer||0===e.button&&(d.current=e.clientX,m.current=e.clientY,b(!0))},onMouseUp:function(e){e.preventDefault(),b(!1)},onMouseLeave:function(e){e.preventDefault()},style:{position:"relative",height:i,width:l,overflow:"hidden"}},n||o?n?s.map((function(e){var n=e[0],r=e[1];return p.createElement(et,{key:n+"_"+r,model:t,offsetX:n,offsetY:r})})):p.createElement("div",{style:{position:"absolute",left:"50%",top:"50%"}},p.createElement(a.CircularProgress,null),p.createElement(a.Typography,null,"Loading...")):null)})),nt=a.makeStyles((function(){return{majorTickLabel:{fontSize:"11px"},majorTick:{stroke:"#555"},minorTick:{stroke:"#999"}}}));function rt(e){var t=e.start,n=e.end,r=e.bpPerPx,o=e.reversed,a=e.major,i=e.minor,l=nt(),s=function(e,t,n,r,o){var a;void 0===r&&(r=!0),void 0===o&&(o=!0);var i=function(e,t,n){for(var r=60*(e=Math.abs(e)),o=parseInt(Number(r).toExponential().split(/e/i)[1],10),a=Math.pow(10,o);a<r&&!((a*=2)>=r);)a*=2.5;var i=(a=Math.max(a,5))/e,l=0;return!(a%10)&&i/10>=15?l=a/10:!(a%5)&&i/5>=15?l=a/5:!(a%2)&&i/2>=15&&(l=a/2),{majorPitch:a,minorPitch:l}}(n),l=e,s=t;if(null===l||null===s)return[];n<0&&(l=(a=[s,l])[0],s=a[1]),l-=Math.abs(20*n),s+=Math.abs(20*n)+1;for(var c=i.minorPitch||i.majorPitch,u=0,f=[],h=Math.ceil(l/c)*c;h<s;h+=c)o&&h%(2*i.majorPitch)?(f.push({type:"minor",base:h-1,index:u}),u+=1):!r||h%(2*i.majorPitch)||(f.push({type:"major",base:h-1,index:u}),u+=1);return f}(t,n,r,a,i);return p.createElement(p.Fragment,null,s.map((function(e){var a=(o?n-e.base:e.base-t)/r;return p.createElement("line",{key:e.base,x1:a,x2:a,y1:11,y2:"major"===e.type?17:15,strokeWidth:1,stroke:"major"===e.type?"#555":"#999",className:"major"===e.type?l.majorTick:l.minorTick,"data-bp":e.base})})),s.filter((function(e){return"major"===e.type})).map((function(e){return p.createElement("text",{x:(o?n-e.base:e.base-t)/r,y:10,key:"label-"+e.base,textAnchor:"middle",style:{fontSize:"11px"},className:l.majorTickLabel},function e(t){return t<999?String(t):e(~~(t/1e3))+","+("00"+~~(t%1e3)).substr(-3,3)}(e.base+1))})))}var ot=o.observer((function(e){var t=e.model,n=t.MSA,o=t.colWidth,a=t.msaAreaWidth,i=t.resizeHandleWidth,l=t.scrollX,s=t.blocksX,c=t.blockSize,u=r.useRef(null),f=s[0];return n?p.createElement("div",{ref:u,style:{position:"relative",width:a,cursor:"crosshair",overflow:"hidden",height:20,background:"#ccc"}},p.createElement("svg",{style:{width:s.length*c,position:"absolute",left:l+f+i,pointerEvents:"none"}},p.createElement(rt,{key:f,start:f/o,end:f/o+c*s.length/o,bpPerPx:1/o}))):null})),at=o.observer((function(e){return p.createElement("div",{style:{width:e.model.treeWidth}})})),it=o.observer((function(e){var t=e.model,n=e.onClose,o=e.open,i=t.colWidth,l=t.treeWidth,s=t.colorSchemeName,c=t.noTree,u=r.useState(""+t.rowHeight),f=u[0],h=u[1],d=r.useState(""+i),m=d[0],g=d[1],v=r.useState(""+l),b=v[0],y=v[1];function w(e){return Number.isNaN(+e)||+e<0}var E=w(f),S=w(m),M=w(b);return p.createElement(a.Dialog,{onClose:function(){return n()},open:o},p.createElement(a.DialogTitle,null,"Settings"),p.createElement(a.DialogContent,null,p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.showBranchLen,onChange:function(){return t.toggleBranchLen()}}),label:"Show branch length"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.bgColor,onChange:function(){return t.toggleBgColor()}}),label:"Color background"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.drawNodeBubbles,onChange:function(){return t.toggleNodeBubbles()}}),label:"Draw node bubbles"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.drawTree,onChange:function(){return t.toggleDrawTree()}}),label:"Draw tree (if available)"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.labelsAlignRight,onChange:function(){return t.toggleLabelsAlignRight()}}),label:"Labels align right (note: labels may draw over tree, but can adjust tree width or tree area width in UI)"}),p.createElement(a.TextField,{label:"Row height (px)",value:f,error:E,onChange:function(e){return h(e.target.value)}}),p.createElement(a.TextField,{label:"Column width (px)",value:m,error:S,onChange:function(e){return g(e.target.value)}}),p.createElement("br",null),c?null:p.createElement(a.TextField,{label:"Tree width (px)",value:b,error:M,onChange:function(e){return y(e.target.value)}}),p.createElement("br",null),p.createElement(a.TextField,{select:!0,label:"Color scheme",value:s,onChange:function(e){return t.setColorSchemeName(e.target.value)}},Object.keys(Je).map((function(e){return p.createElement(a.MenuItem,{key:e,value:e},e)}))),p.createElement(a.DialogActions,null,p.createElement(a.Button,{disabled:E||S||M,onClick:function(){t.setRowHeight(+f),t.setColWidth(+m),c||t.setTreeWidth(+b),n()},variant:"contained",color:"primary"},"Submit"))))}));function lt(e){var t=e.onClose;return p.createElement(a.Dialog,{onClose:function(){return t()},open:e.open},p.createElement(a.DialogTitle,null,"Biotite License"),p.createElement(a.DialogContent,null,p.createElement("pre",{style:{height:100,overflow:"auto"}},'\nCopyright 2017 - 2020, The Biotite contributors\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation and/or\nother materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors\nmay be used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n ')))}function st(e){var t=e.onClose,n=e.open,o=r.useState(!1),i=o[1];return p.createElement(p.Fragment,null,p.createElement(lt,{onClose:function(){return i(!1)},open:o[0]}),p.createElement(a.Dialog,{onClose:function(){return t()},open:n},p.createElement(a.DialogTitle,null,"About this plugin"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"JBrowse 2 MSAView plugin ","1.2.10"," (",p.createElement(a.Link,{href:"https://github.com/gmod/jbrowse-plugin-msaview"},"Github"),")"),p.createElement("ul",null,p.createElement("li",null,p.createElement(a.Typography,null,"We use some color schemes from the"," ",p.createElement(a.Link,{href:"https://github.com/biotite-dev/biotite"},"biotite")," ","project, and their license is reproduced"," ",p.createElement(a.Link,{onClick:function(){return i(!0)}},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this page for some information on jalview colorings"," ",p.createElement(a.Link,{href:"https://www.jalview.org/help/html/colourSchemes/"},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this page for some info on the clustal, cinema, maeditor, and lesk color schemes"," ",p.createElement(a.Link,{href:"http://www.bioinformatics.nl/~berndb/aacolour.html"},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this paper about the flower color scheme"," ",p.createElement(a.Link,{href:"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7245768/"},"here")))))))}var ct=o.observer((function(e){var t=e.onClose,n=e.model.alignmentDetails;return p.createElement(a.Dialog,{onClose:function(){return t()},open:e.open},p.createElement(a.DialogTitle,null,"Metadata"),p.createElement(a.DialogContent,null,p.createElement(c.Attributes,{attributes:n})))})),ut=o.observer((function(e){var t=e.model,n=e.onClose,r=t.tracks;return p.createElement(a.Dialog,{onClose:function(){return n()},open:e.open},p.createElement(a.DialogTitle,null,"Add track"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"Open relevant per-alignment tracks e.g. protein domains"),p.createElement(a.FormGroup,null,r.map((function(e){return p.createElement(a.FormControlLabel,{key:e.model.id,control:p.createElement(a.Checkbox,{checked:!t.turnedOffTracks.has(e.model.id),onChange:function(){t.toggleTrack(e.model.id)}}),label:e.model.name})}))),p.createElement(a.DialogActions,null,p.createElement(a.Button,{onClick:function(){return n()},variant:"contained",color:"primary"},"Close"))))})),ft=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"}),"FolderOpen");t.default=r}))),ht=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"}),"Settings");t.default=r}))),dt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help");t.default=r}))),mt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"}),"List");t.default=r}))),pt=o.observer((function(e){var t=e.model,n=t.mouseCol;return p.createElement("div",null,p.createElement(a.Typography,{display:"inline"},"Row name: ",t.mouseOverRowName),p.createElement("span",{style:{marginLeft:10}}),p.createElement(a.Typography,{display:"inline"},"Position: ",n))})),gt=o.observer((function(e){var t=e.model,n=r.useState(!1),o=n[0],i=n[1],l=r.useState(!1),s=l[0],c=l[1],u=r.useState(!1),f=u[0],h=u[1],d=r.useState(!1),m=d[0],g=d[1],v=t.currentAlignment,b=t.alignmentNames;return p.createElement("div",{style:{display:"flex"}},p.createElement(a.IconButton,{onClick:function(){t.setData({tree:"",msa:""}),t.setTreeFilehandle(void 0),t.setMSAFilehandle(void 0),t.setScrollY(0),t.setScrollX(0),t.setCurrentAlignment(0)}},p.createElement(ft,null)),p.createElement(a.IconButton,{onClick:function(){return i(!0)}},p.createElement(ht,null)),p.createElement(a.IconButton,{onClick:function(){return h(!0)}},p.createElement(W,null)),p.createElement(a.IconButton,{onClick:function(){return g(!0)}},p.createElement(mt,null)),o?p.createElement(it,{open:!0,model:t,onClose:function(){return i(!1)}}):null,s?p.createElement(st,{open:!0,onClose:function(){return c(!1)}}):null,f?p.createElement(ct,{open:!0,model:t,onClose:function(){return h(!1)}}):null,m?p.createElement(ut,{open:!0,model:t,onClose:function(){return g(!1)}}):null,b.length>0?p.createElement(a.Select,{native:!0,value:v,onChange:function(e){t.setCurrentAlignment(+e.target.value),t.setScrollX(0),t.setScrollY(0)}},b.map((function(e,t){return p.createElement("option",{key:e+"-"+t,value:t},e)}))):null,p.createElement(pt,{model:t}),p.createElement("div",{style:{flex:1}}),p.createElement(a.IconButton,{onClick:function(){return c(!0)}},p.createElement(dt,null)))})),vt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M7 10l5 5 5-5z"}),"ArrowDropDown");t.default=r}))),bt={"text/plain":"Text","text/html":"Url",default:"Text"},yt=a.makeStyles((function(e){return{textArea:{padding:e.spacing(2),overflow:"auto",background:"#ddd",wordBreak:"break-word"}}})),wt=o.observer((function(e){var t=e.model,n=e.onClose,o=r.useState("Copy to clipboard"),i=o[0],l=o[1],s=yt();return p.createElement(a.Dialog,{open:!0,onClose:n,fullWidth:!0,maxWidth:"lg"},p.createElement(a.DialogTitle,null,"Track info - ",t.name),p.createElement(a.DialogContent,null,p.createElement(a.Button,{variant:"contained",color:"primary",onClick:function(){(function(e,t){var n,r,o,a,i,l;t||(t={}),n=t.debug||!1;try{if(o=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}}(),a=document.createRange(),i=document.getSelection(),(l=document.createElement("span")).textContent=e,l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",(function(r){r.stopPropagation(),t.format&&(r.preventDefault(),void 0===r.clipboardData?(n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData(),window.clipboardData.setData(bt[t.format]||bt.default,e)):(r.clipboardData.clearData(),r.clipboardData.setData(t.format,e))),t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(l),a.selectNodeContents(l),i.addRange(a),!document.execCommand("copy"))throw new Error("copy command was unsuccessful")}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData)}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),r=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(r,e)}}finally{i&&("function"==typeof i.removeRange?i.removeRange(a):i.removeAllRanges()),l&&document.body.removeChild(l),o()}})(t.data),l("Copied!"),setTimeout((function(){l("Copy to clipboard")}),300)}},i),p.createElement("pre",{className:s.textArea},t.data)),p.createElement(a.DialogActions,null,p.createElement(a.Button,{variant:"contained",onClick:n,color:"secondary"},"Close")))})),Et=a.makeStyles((function(){return{button:{padding:0}}})),St=o.observer((function(e){var t=e.model,n=e.track,o=r.useState(),i=o[0],l=o[1],s=r.useState(!1),c=s[0],u=s[1],f=t.rowHeight,h=t.treeAreaWidth,d=n.height,m=n.model.name,g=Et(),v=Math.max(8,f-8);return p.createElement("div",{style:{width:h,height:d,flexShrink:0,textAlign:"right",fontSize:v}},m,p.createElement(a.IconButton,{className:g.button,style:{width:v,height:v},onClick:function(e){l(e.target)}},p.createElement(vt,null)),i?p.createElement(a.Menu,{anchorEl:i,transitionDuration:0,open:!0,onClose:function(){l(void 0)}},p.createElement(a.MenuItem,{dense:!0,onClick:function(){t.toggleTrack(n.model.id),l(void 0)}},"Close"),p.createElement(a.MenuItem,{dense:!0,onClick:function(){u(!0),l(void 0)}},"Get info")):null,c?p.createElement(wt,{model:n.model,onClose:function(){return u(!1)}}):null)})),Mt=o.observer((function(e){var t=e.model,n=e.track,o=t.resizeHandleWidth,a=n.model.height,i=r.useRef(null),l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){var e=i.current;if(e)return e.addEventListener("wheel",n),function(){e.removeEventListener("wheel",n)};function n(e){var n=oe(e);s.current+=n.pixelX,l.current||(l.current=!0,requestAnimationFrame((function(){t.doScrollX(-s.current),s.current=0,l.current=!1}))),e.preventDefault()}}),[t]),p.createElement("div",{key:n.id,style:{display:"flex",height:a}},p.createElement(St,{model:t,track:n}),p.createElement("div",{style:{width:o,flexShrink:0}}),p.createElement("div",{ref:i},p.createElement(n.ReactComponent,{model:t,track:n})))})),xt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");t.default=r}))),At=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},kt=o.observer((function(e){var t=e.name,n=e.value,r=e.setValue,o=e.setName;return p.createElement("div",null,p.createElement(a.IconButton,{onClick:e.onDelete,style:{margin:10}},p.createElement(xt,null)),p.createElement(a.TextField,{value:t,onChange:function(e){return o(e.target.value)},label:"Key"}),p.createElement(a.TextField,{value:n,onChange:function(e){return r(e.target.value)},label:"Value"}))})),Lt=o.observer((function(e){var t=e.onClose,n=e.data,o=e.model,i=o.blanks,l=n.left,s=n.right,c=r.useState([["Name",""],["ID",""],["Note",""]]),u=c[0],f=c[1];return p.createElement(a.Dialog,{onClose:function(){return t()},open:!0},p.createElement(a.DialogTitle,null,"Create new region annotation"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"Do you want to add an annotation to the MSA at ",l,"..",s," ",i.length?" (gapped "+o.getPos(l)+".."+o.getPos(s):""),u.map((function(e,t){return p.createElement(kt,{key:t,name:e[0],value:e[1],setValue:function(e){var n=At([],u,!0);n[t][1]=e,f(n)},setName:function(e){var n=At([],u,!0);n[t][0]=e,f(n)},onDelete:function(){u.splice(t,1),f(At([],u,!0))}})})),p.createElement(a.Button,{onClick:function(){f(At(At([],u,!0),[["",""]],!1))}},"Add row"),p.createElement(a.DialogActions,null,p.createElement(a.Button,{onClick:function(){var e;o.addAnnotation(l,s,(e={},u.forEach((function(t){var n=t[0],r=t[1];e[n]||(e[n]=[]),e[n].push(r)})),e)),t()},variant:"contained",color:"primary"},"Submit"),p.createElement(a.Button,{variant:"contained",color:"secondary",onClick:function(){return t()}},"Cancel"))))})),Ct=o.observer((function(e){var t=e.model,n=t.resizeHandleWidth,o=r.useState(!1),a=o[0],i=o[1],l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){function e(e){e.preventDefault();var n=e.clientX;if(0===s.current)s.current=e.clientX;else{var r=n-s.current;r&&(l.current||(l.current=!0,window.requestAnimationFrame((function(){t.setTreeAreaWidth(t.treeAreaWidth+r),l.current=!1,s.current=e.clientX}))))}}function n(){s.current=0,a&&i(!1)}return a?(document.addEventListener("mousemove",e,!0),document.addEventListener("mouseup",n,!0),function(){document.removeEventListener("mousemove",e,!0),document.removeEventListener("mouseup",n,!0)}):function(){}}),[a,t]),p.createElement("div",null,p.createElement("div",{onMouseDown:function(){return i(!0)},style:{cursor:"ew-resize",height:"100%",width:n,background:"rgba(200,200,200)",position:"relative"}}))})),Pt=o.observer((function(e){var t=e.model,n=t.resizeHandleWidth,o=r.useState(!1),a=o[0],i=o[1],l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){function e(e){e.preventDefault();var n=e.clientY;if(0===s.current)s.current=e.clientY;else{var r=n-s.current;r&&(l.current||(l.current=!0,window.requestAnimationFrame((function(){t.setHeight(t.height+r),l.current=!1,s.current=e.clientY}))))}}function n(){s.current=0,a&&i(!1)}return a?(document.addEventListener("mousemove",e,!0),document.addEventListener("mouseup",n,!0),function(){document.removeEventListener("mousemove",e,!0),document.removeEventListener("mouseup",n,!0)}):function(){}}),[a,t]),p.createElement("div",null,p.createElement("div",{onMouseDown:function(){return i(!0)},style:{cursor:"ns-resize",width:"100%",height:n,background:"rgba(200,200,200)",position:"relative"}}))})),Tt=function(){return(Tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ot=o.observer((function(e){var t=e.model,n=r.useRef(null),o=t.height,a=t.width,i=t.treeAreaWidth,l=t.resizeHandleWidth,s=t.scrollX,c=t.mouseCol,u=t.colWidth;return r.useEffect((function(){if(n.current){var e=n.current.getContext("2d");if(e&&(e.resetTransform(),e.clearRect(0,0,a,o),void 0!==c)){var t=(c-1)*u+s+i+l;e.fillStyle="rgba(100,100,100,0.5)",e.fillRect(t,0,u,o)}}}),[c,u,s,o,l,i,a]),p.createElement("canvas",{ref:n,width:a,height:o,style:{position:"absolute",top:0,left:0,width:a,height:o,zIndex:1e3,pointerEvents:"none"}})})),Rt=o.observer((function(e){var t=e.model,n=t.treeAreaWidth,r=t.turnedOnTracks;return p.createElement("div",null,t.initialized?t.done?p.createElement("div",null,p.createElement("div",{style:{height:t.height,overflow:"hidden"}},p.createElement(gt,{model:t}),p.createElement("div",null,p.createElement("div",{style:{position:"relative"}},p.createElement("div",{style:{display:"flex"}},p.createElement("div",{style:{flexShrink:0,width:n}},p.createElement(at,{model:t})),p.createElement(K,{model:t,ControlComponent:p.createElement(ot,{model:t})})),null==r?void 0:r.map((function(e){return p.createElement(Mt,{key:e.model.id,model:t,track:e})})),p.createElement("div",{style:{display:"flex"}},p.createElement("div",{style:{flexShrink:0,width:n}},p.createElement(Le,{model:t})),p.createElement(Ct,{model:t}),p.createElement(tt,{model:t}),p.createElement(Ot,{model:t}))))),p.createElement(Pt,{model:t})):p.createElement(a.Typography,{variant:"h4"},"Loading..."):p.createElement(x,{model:t}),t.DialogComponent?p.createElement(t.DialogComponent,Tt({},t.DialogProps||{},{onClose:function(){t.setDialogComponent(void 0,void 0)}})):null,t.annotPos?p.createElement(Lt,{data:t.annotPos,model:t,onClose:function(){return t.clearAnnotPos()}}):null)}));function Dt(e,t){return e.parent===t.parent?1:2}function Nt(e,t){return e+t.x}function jt(e,t){return Math.max(e,t.y)}function It(e){var t=0,n=e.children,r=n&&n.length;if(r)for(;--r>=0;)t+=n[r].value;else t=1;e.value=t}function Ft(e,t){e instanceof Map?(e=[void 0,e],void 0===t&&(t=Bt)):void 0===t&&(t=_t);for(var n,r,o,a,i,l=new Xt(e),s=[l];n=s.pop();)if((o=t(n.data))&&(i=(o=Array.from(o)).length))for(n.children=o,a=i-1;a>=0;--a)s.push(r=o[a]=new Xt(o[a])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(Ht)}function _t(e){return e.children}function Bt(e){return Array.isArray(e)?e[1]:null}function Yt(e){void 0!==e.data.value&&(e.value=e.data.value),e.data=e.data.data}function Ht(e){var t=0;do{e.height=t}while((e=e.parent)&&e.height<++t)}function Xt(e){this.data=e,this.depth=this.height=0,this.parent=null}Xt.prototype=Ft.prototype={constructor:Xt,count:function(){return this.eachAfter(It)},each:function(e,t){let n=-1;for(const r of this)e.call(t,r,++n,this);return this},eachAfter:function(e,t){for(var n,r,o,a=this,i=[a],l=[],s=-1;a=i.pop();)if(l.push(a),n=a.children)for(r=0,o=n.length;r<o;++r)i.push(n[r]);for(;a=l.pop();)e.call(t,a,++s,this);return this},eachBefore:function(e,t){for(var n,r,o=this,a=[o],i=-1;o=a.pop();)if(e.call(t,o,++i,this),n=o.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(e,t){let n=-1;for(const r of this)if(e.call(t,r,++n,this))return r},sum:function(e){return this.eachAfter((function(t){for(var n=+e(t.data)||0,r=t.children,o=r&&r.length;--o>=0;)n+=r[o].value;t.value=n}))},sort:function(e){return this.eachBefore((function(t){t.children&&t.children.sort(e)}))},path:function(e){for(var t=this,n=function(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),o=null;for(e=n.pop(),t=r.pop();e===t;)o=e,e=n.pop(),t=r.pop();return o}(t,e),r=[t];t!==n;)r.push(t=t.parent);for(var o=r.length;e!==n;)r.splice(o,0,e),e=e.parent;return r},ancestors:function(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t},descendants:function(){return Array.from(this)},leaves:function(){var e=[];return this.eachBefore((function(t){t.children||e.push(t)})),e},links:function(){var e=this,t=[];return e.each((function(n){n!==e&&t.push({source:n.parent,target:n})})),t},copy:function(){return Ft(this).eachBefore(Yt)},[Symbol.iterator]:function*(){var e,t,n,r,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(yield o,t=o.children)for(n=0,r=t.length;n<r;++n)a.push(t[n])}while(a.length)}};var Vt=k((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o},e.exports.default=e.exports,e.exports.__esModule=!0}));A(Vt);var qt=k((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o=Vt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.default=e.exports,e.exports.__esModule=!0}));A(qt);var Gt,Wt,Ut,zt=1,Kt=function(){return(zt=(9301*zt+49297)%233280)/233280},Qt=function(e){zt=e},Jt="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function $t(){Ut=!1}function Zt(e){if(e){if(e!==Gt){if(e.length!==Jt.length)throw new Error("Custom alphabet for shortid must be "+Jt.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,n){return t!==n.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+Jt.length+" unique characters. These characters were not unique: "+t.join(", "));Gt=e,$t()}}else Gt!==Jt&&(Gt=Jt,$t())}function en(){return Ut||(Ut=function(){Gt||Zt(Jt);for(var e,t=Gt.split(""),n=[],r=Kt();t.length>0;)r=Kt(),e=Math.floor(r*t.length),n.push(t.splice(e,1)[0]);return n.join("")}())}var tn,nn,rn={get:function(){return Gt||Jt},characters:function(e){return Zt(e),Gt},seed:function(e){Qt(e),Wt!==e&&($t(),Wt=e)},lookup:function(e){return en()[e]},shuffled:en},on="object"==typeof window&&(window.crypto||window.msCrypto),an=on&&on.getRandomValues?function(e){return on.getRandomValues(new Uint8Array(e))}:function(e){for(var t=[],n=0;n<e;n++)t.push(Math.floor(256*Math.random()));return t},ln=function(e,t,n){for(var r=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*r*n/t.length),a="";;)for(var i=e(o),l=o;l--;)if((a+=t[i[l]&r]||"").length===+n)return a},sn=function(e){for(var t,n=0,r="";!t;)r+=ln(an,rn.get(),1),t=e<Math.pow(16,n+1),n++;return r},cn=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+rn.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))},un=k((function(e){var t=0;function n(){return function(e){var t="",n=Math.floor(.001*(Date.now()-1567752802062));return n===nn?tn++:(tn=0,nn=n),t+=sn(7),t+=sn(e),tn>0&&(t+=sn(tn)),t+sn(n)}(t)}e.exports=n,e.exports.generate=n,e.exports.seed=function(t){return rn.seed(t),e.exports},e.exports.worker=function(n){return t=n,e.exports},e.exports.characters=function(e){return void 0!==e&&rn.characters(e),rn.shuffled()},e.exports.isValid=cn})),fn=k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.FileLocation=t.UriLocation=t.UriLocationRaw=t.BlobLocation=t.LocalPathLocation=t.Region=t.NoAssemblyRegion=t.PropTypes=t.ElementId=void 0;var n=L(qt),r=L(un),o=L(d),a=["baseUri"],i=v.types.optional(v.types.identifier,r.default.generate);t.ElementId=i;var l={Region:o.default.shape({refName:o.default.string.isRequired,start:o.default.number.isRequired,end:o.default.number.isRequired}),ConfigSchema:g.PropTypes.objectOrObservableObject,Feature:o.default.shape({get:o.default.func.isRequired,id:o.default.func.isRequired})};t.PropTypes=l;var s=v.types.model("NoAssemblyRegion",{refName:v.types.string,start:v.types.number,end:v.types.number,reversed:v.types.optional(v.types.boolean,!1)}).actions((function(e){return{setRefName:function(t){e.refName=t}}}));t.NoAssemblyRegion=s;var c=v.types.compose("Region",s,v.types.model({assemblyName:v.types.string}));t.Region=c;var u=v.types.model("LocalPathLocation",{localPath:v.types.string});t.LocalPathLocation=u;var f=v.types.model("BlobLocation",{name:v.types.string,blobId:v.types.string});t.BlobLocation=f;var h=v.types.model("UriLocation",{uri:v.types.string,baseUri:v.types.maybe(v.types.string)});t.UriLocationRaw=h;var m=v.types.snapshotProcessor(h,{postProcessor:function(e){var t=e.baseUri,r=(0,n.default)(e,a);return t?e:r}});t.UriLocation=m;var p=v.types.union(u,m,f);t.FileLocation=p}));A(fn);var hn=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=v.types.model("BaseView",{id:fn.ElementId,displayName:v.types.maybe(v.types.string)}).volatile((function(){return{width:800}})).views((function(){return{menuItems:function(){return[]}}})).actions((function(e){return{setDisplayName:function(t){e.displayName=t},setWidth:function(t){e.width=t}}}));t.default=n}))),dn=k((function(e){const t=function(){let e={gf:{},gc:{},gs:{},gr:{},seqname:[],seqdata:{}};return Object.keys(e).forEach(t=>this[t]=e[t]),this},n=/^# STOCKHOLM 1.0/,r=/^\/\/\s*$/,o=/^#=GF\s+(\S+)\s+(.*?)\s*$/,a=/^#=GC\s+(\S+)\s+(.*?)\s*$/,i=/^#=GS\s+(\S+)\s+(\S+)\s+(.*?)\s*$/,l=/^#=GR\s+(\S+)\s+(\S+)\s+(.*?)\s*$/,s=/^\s*(\S+)\s+(\S+)\s*$/,c=/\S/,u=e=>"(At line "+(e+1)+") ",f=e=>{throw new Error(e)},h=e=>console.warn(e),d=(e,d)=>{const m=(d=d||{}).strict?f:d.quiet?()=>null:h;let p=[],g=null;return e.split("\n").forEach((e,h)=>{const d=()=>{g||(m(u(h)+"No format header: # STOCKHOLM 1.0"),g=new t)};let v;n.test(e)?(g&&m(u(h)+"No format footer: //"),g=new t):r.test(e)?(g?p.push(g):m(u(h)+"No format header: # STOCKHOLM 1.0"),g=null):(v=o.exec(e))?(d(),g.gf[v[1]]=g.gf[v[1]]||[],g.gf[v[1]].push(v[2])):(v=a.exec(e))?(d(),g.gc[v[1]]=g.gc[v[1]]||"",g.gc[v[1]]+=v[2]):(v=i.exec(e))?(d(),g.gs[v[2]]=g.gs[v[2]]||{},g.gs[v[2]][v[1]]=g.gs[v[2]][v[1]]||[],g.gs[v[2]][v[1]].push(v[3])):(v=l.exec(e))?(d(),g.gr[v[2]]=g.gr[v[2]]||{},g.gr[v[2]][v[1]]=g.gr[v[2]][v[1]]||"",g.gr[v[2]][v[1]]+=v[3]):(v=s.exec(e))?(d(),g.seqdata[v[1]]||(g.seqdata[v[1]]="",g.seqname.push(v[1])),g.seqdata[v[1]]+=v[2]):c.test(e)&&f(u(h)+"Malformed line")}),g&&(m("Warning: no end line //"),p.push(g)),p};function m(e,t){for(;e.length<t;)e=" "+e;return e}function p(e,t){for(;e.length<t;)e+=" ";return e}t.prototype.rows=function(){return this.seqname.length},t.prototype.columns=function(){let e=0;return this.seqname.forEach(t=>{e=Math.max(e,this.seqdata[t].length)}),Object.keys(this.gr).forEach(t=>Object.keys(this.gr[t]).forEach(n=>{e=Math.max(e,this.gr[t][n].length)})),e},t.prototype.allNames=function(){let e={},t=[],n=n=>{e[n]||(e[n]=!0,t.push(n))},r=e=>e.forEach(n);return r(this.seqname),r(Object.keys(this.seqdata)),Object.keys(this.gr).forEach(e=>r(Object.keys(this.gr[e]))),Object.keys(this.gs).forEach(e=>r(Object.keys(this.gs[e]))),t},t.prototype.allTags=function(){let e={};const t=t=>Object.keys(t).forEach(t=>e[t]=!0);return t(this.gc),t(this.gf),t(this.gr),t(this.gs),Object.keys(e).sort()},t.prototype.addRow=function(e,t){return this.seqdata[e]&&f("Duplicate row name"),this.seqname.push(e),this.seqdata[e]=t||"",this},t.prototype.deleteRow=function(e){return this.seqdata[e]||f("Row not found"),this.seqname=this.seqname.filter(t=>t!==e),delete this.seqdata[e],this},t.prototype.toString=function(e){e=e||{width:80,indentNames:!1};const t=this.allNames(),n=this.columns(),r=Math.max.apply(null,t.map(e=>e.length).concat([0])),o=Math.max.apply(null,this.allTags().map(e=>e.length).concat([0])),a=o?o+6:0,i=e.width?Math.max(1,e.width-r-a-1):n,l=e.indentNames?m:p,s=e.indentNames?(e,t)=>m(e,o)+" "+m(t,r):(e,t)=>p(e+" "+t,o+r+1);let c=[0];for(let e=i;e<n;e+=i)c.push(e);return"# STOCKHOLM 1.0\n"+Object.keys(this.gf).sort().map(e=>this.gf[e].map(t=>"#=GF "+l(e,o)+" "+t+"\n").join("")).join("")+Object.keys(this.gs).sort().map(e=>Object.keys(this.gs[e]).map(t=>this.gs[e][t].map(n=>"#=GS "+s(e,t)+" "+n+"\n").join("")).join("")).join("")+c.map(e=>Object.keys(this.gc).sort().map(t=>"#=GC "+l(t,o)+function(e){return m("",e)}(r+2)+this.gc[t].substr(e,i)+"\n").join("")+t.map(t=>Object.keys(this.gr).filter(e=>this.gr[e][t]).sort().map(n=>"#=GR "+s(n,t)+" "+this.gr[n][t].substr(e,i)+"\n").join("")+(this.seqdata[t]?l(t,r+a)+" "+this.seqdata[t].substr(e,i)+"\n":"")).join("")).join("\n")+"//\n"},t.prototype.toFasta=function(e){e=e||{width:80};const t=this.columns(),n=e.width||t;let r=[0];for(let e=n;e<t;e+=n)r.push(e);return this.allNames().map(e=>this.seqdata[e]?">"+e+"\n"+r.map(t=>this.seqdata[e].substr(t,n)+"\n").join(""):"").join("")},t.prototype.toRowList=function(e){return this.allNames().filter(e=>this.seqdata[e]).map(e=>[e,this.seqdata[e]])},e.exports={sniff:e=>n.test(e),validate:e=>{try{d(e,{strict:!0})}catch(e){return!1}return!0},parse:(e,t)=>{const n=d(e,t);return 0===n.length&&f("No alignments found"),n.length>1&&f("More than one alignment found"),n[0]},parseAll:d,fromSeqIndex:(e,n)=>{let r=new t;return(n=n||Object.keys(e)).forEach(t=>r.addRow(t,e[t])),r},fromRowList:e=>{let n=new t;return e.forEach(e=>n.addRow(e[0],e[1])),n},Stockholm:t}})),mn=k((function(e,t){function n(e){const t=e.match(/\(?(\d+(\.\d+)+)\)?/);return t&&t.length>1?t[1]:""}function r(e){let t=e.next();for(;!t.done&&""===t.value.trim();)t=e.next();return t.value}function o(e){const t=e.split(/\s+/),n=e.slice(t[0].length),r=t[0].length+n.indexOf(t[1]);return[r,r+t[1].length]}function a(e){let t=r(e);const n=[];let a="";if(!t)return;for(;t;)" "!==t[0]?n.push(t):a=t,t=e.next().value;const[i,l]=o(n[0]),s=n.map(e=>e.split(/\s+/)).map(e=>e[0]),c=n.map(e=>e.slice(i,l));let u=a.slice(i,l);const f=c[0].length-u.length;return f&&(u+=" ".repeat(f)),{ids:s,seqs:c,consensus:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.parseBlocks=t.parseBlock=t.getSeqBounds=t.getFirstNonEmptyLine=t.parseHeader=t.parseVersion=void 0,t.parseVersion=n,t.parseHeader=function(e){const t=["CLUSTAL","PROBCONS","MUSCLE","MSAPROBS","Kalign"];t.find(t=>e.startsWith(t))||console.warn(`${e} is not a known CLUSTAL header: ${t.join(",")}, proceeding but could indicate an issue`);const r=n(e);return{info:e,version:r}},t.getFirstNonEmptyLine=r,t.getSeqBounds=o,t.parseBlock=a,t.parseBlocks=function(e){let t;const n=a(e);if(void 0!==n)for(;t=a(e);){for(let e=0;e<t.seqs.length;e++)n.seqs[e]+=t.seqs[e];n.consensus+=t.consensus}return n}}));A(mn);var pn=k((function(e,t){function n(e){const t=mn.getFirstNonEmptyLine(e);if(!t)throw new Error("Empty file received");const n=mn.parseHeader(t),r=mn.parseBlocks(e);if(void 0===r)throw new Error("No blocks parsed");const o=r.seqs.map((e,t)=>({id:r.ids[t],seq:e})),{consensus:a}=r;if(a.length!=o[0].seq.length)throw new Error(`Consensus length != sequence length. Con ${a.length} seq ${o[0].seq.length}`);return{consensus:a,alns:o,header:n}}Object.defineProperty(t,"__esModule",{value:!0}),t.parse=t.parseIter=void 0,t.parseIter=n,t.parse=function(e){return n(e.split("\n")[Symbol.iterator]())}}));A(pn);var gn=pn.parse,vn=function(){function e(e){this.MSA=gn(e)}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getRow=function(e){var t;return null===(t=this.MSA.alns.find((function(t){return t.id===e})))||void 0===t?void 0:t.seq.split("")},e.prototype.getWidth=function(){return this.MSA.alns[0].seq.length},e.prototype.getDetails=function(){return this.MSA.header},e.prototype.getNames=function(){return this.MSA.alns.map((function(e){return e.id}))},e.prototype.getStructures=function(){return{}},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return[]},enumerable:!1,configurable:!0}),e.prototype.getTree=function(){return{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){return this.MSA.consensus},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){var e;return(null===(e=this.seqConsensus)||void 0===e?void 0:e.trim())?[{id:"seqConsensus",name:"Sequence consensus",data:this.seqConsensus,customColorScheme:{"*":"white",":":"grey",".":"darkgrey"," ":"black"}}]:[]},enumerable:!1,configurable:!0}),e}();function bn(e){for(var t=[],n={},r=e.split(/\s*(;|\(|\)|,|:)\s*/),o=0;o<r.length;o++){var a=r[o],i={};switch(a){case"(":n.branchset=[i],t.push(n),n=i;break;case",":t[t.length-1].branchset.push(i),n=i;break;case")":n=t.pop();break;case":":break;default:var l=r[o-1];")"===l||"("===l||","===l?n.name=a:":"===l&&(n.length=parseFloat(a))}}return n}var yn=function(){function e(e,t){var n=dn.parseAll(e);this.data=n,this.MSA=n[t]}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getRow=function(e){var t,n;return null===(n=null===(t=this.MSA)||void 0===t?void 0:t.seqdata[e])||void 0===n?void 0:n.split("")},e.prototype.getWidth=function(){var e,t=Object.keys(null===(e=this.MSA)||void 0===e?void 0:e.seqdata)[0];return this.getRow(t).length},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return this.data.map((function(e,t){var n;return(null===(n=e.gf.DE)||void 0===n?void 0:n[0])||"Alignment "+(t+1)}))},enumerable:!1,configurable:!0}),e.prototype.getDetails=function(){var e,t;return{General:this.MSA.gf,Accessions:null===(e=this.MSA.gs)||void 0===e?void 0:e.AC,Dbxref:null===(t=this.MSA.gs)||void 0===t?void 0:t.DR}},e.prototype.getRowDetails=function(e){var t,n;return{name:e,accession:null===(t=this.MSA.gs)||void 0===t?void 0:t.AC[e],dbxref:null===(n=this.MSA.gs)||void 0===n?void 0:n.DR[e]}},e.prototype.getNames=function(){return Object.keys(this.MSA.seqdata)},e.prototype.getSeqCoords=function(){},e.prototype.getStructures=function(){var e,t=/PDB; +(\S+) +(\S); ([0-9]+)-([0-9]+)/;return Object.entries((null===(e=this.MSA.gs)||void 0===e?void 0:e.DR)||{}).map((function(e){return[e[0],t.exec(e[1])]})).filter((function(e){return!!e[1]})).map((function(e){var t=e[1];return{id:e[0],pdb:t[1].toLowerCase(),chain:t[2],startPos:+t[3],endPos:+t[4]}})).reduce((function(e,t){var n=t.id,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["id"]);return e[n]||(e[n]=[]),e[n].push(r),e}),{})},e.prototype.getTree=function(){var e,t,n,r=null===(n=null===(t=null===(e=this.MSA)||void 0===e?void 0:e.gf)||void 0===t?void 0:t.NH)||void 0===n?void 0:n[0];return r?Ke(bn(r)):{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){var e;return null===(e=this.MSA.gc)||void 0===e?void 0:e.seq_cons},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){var e;return null===(e=this.MSA.gc)||void 0===e?void 0:e.SS_cons},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){return[{id:"seqConsensus",name:"Sequence consensus",data:this.seqConsensus,customColorScheme:{}},{id:"secondaryStruct",name:"Secondary-structure",data:this.secondaryStructureConsensus,customColorScheme:{">":"pink","<":"lightblue"}}]},enumerable:!1,configurable:!0}),e}(),wn=function(){function e(e){var t={},n="",r=/^>(\S+)/;e.split("\n").forEach((function(e){var o=r.exec(e);o?t[n=o[1]]="":n&&(t[n]=t[n]+e.replace(/[ \t]/g,""))})),this.MSA={seqdata:t}}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getNames=function(){return Object.keys(this.MSA.seqdata)},e.prototype.getRow=function(e){var t,n;return null===(n=null===(t=this.MSA)||void 0===t?void 0:t.seqdata[e])||void 0===n?void 0:n.split("")},e.prototype.getWidth=function(){var e,t=Object.keys(null===(e=this.MSA)||void 0===e?void 0:e.seqdata)[0];return this.getRow(t).length},e.prototype.getStructures=function(){return{}},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return[]},enumerable:!1,configurable:!0}),e.prototype.getDetails=function(){return{}},e.prototype.getTree=function(){return{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){return[]},enumerable:!1,configurable:!0}),e}(),En=o.observer((function(e){var t=e.model,n=e.offsetX,o=t.blockSize,i=t.scrollX,l=t.bgColor,s=t.colWidth,c=t.rowHeight,u=t.highResScaleFactor,f=e.track.model,h=f.data,d=f.customColorScheme||t.colorScheme,m=a.useTheme(),g=r.useRef(null),v=r.useMemo((function(){return Qe(d,m)}),[d,m]);return r.useEffect((function(){if(g.current){var e=g.current.getContext("2d");if(e){e.resetTransform(),e.scale(u,u),e.clearRect(0,0,o,c),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,Math.max(8,c-8)+"px");for(var t=Math.max(0,Math.floor(n/s)),r=Math.max(0,Math.ceil((n+o)/s)),a=null==h?void 0:h.slice(t,r),i=0;a&&i<a.length;i++){var f=a[i],m=d[f.toUpperCase()];if(l){var p=i*s+n-n%s;e.fillStyle=m||"white",e.fillRect(p,0,s,c),c>=10&&s>=c/2&&(e.fillStyle=v[f.toUpperCase()]||"black",e.fillText(f,p+s/2,c/2+1))}}}}}),[l,o,s,c,n,v,d,u,h]),p.createElement("canvas",{ref:g,height:c*u,width:o*u,style:{position:"absolute",left:i+n,width:o,height:c}})})),Sn=o.observer((function(e){var t=e.track,n=e.model;return p.createElement("div",{style:{position:"relative",height:n.rowHeight,width:n.msaAreaWidth,overflow:"hidden"}},n.blocksX.map((function(e){return p.createElement(En,{key:e,track:t,model:n,offsetX:e})})))})),Mn=function(){function e(e){var t=(void 0===e?{}:e).maxHeight,n=void 0===t?1e4:t;this.maxHeightReached=!1,this.rbush=new se,this.rectangles=new Map,this.maxHeight=Math.ceil(n),this.pTotalHeight=0}return e.prototype.addRect=function(e,t,n,r,o){var a=this.rectangles.get(e);if(a)return a.minY;for(var i=0;this.rbush.collides({minX:t,minY:i,maxX:n,maxY:i+r})&&i<=this.maxHeight;)i+=1;var l={minX:t,minY:i,maxX:n,maxY:i+r,id:e,data:o};return this.rbush.insert(l),this.rectangles.set(e,l),this.pTotalHeight=Math.max(this.pTotalHeight,i),i},Object.defineProperty(e.prototype,"totalHeight",{get:function(){return this.pTotalHeight},enumerable:!1,configurable:!0}),e}(),xn=o.observer((function(e){var t=e.model,n=e.offsetX,o=t.blockSize,a=t.colWidth,i=t.blanks,l=t.rowHeight,s=t.highResScaleFactor,c=t.scrollX,f=e.track.model,h=f.height,d=f.features,m=f.associatedRowName,g=u.isStateTreeNode(d)?u.getSnapshot(d):d,v=r.useMemo((function(){var e=new Mn;return null==g||g.forEach((function(n,r){var o=n.start,a=n.end;if(m){var i=t.rowSpecificBpToPx(m,o-1),s=t.rowSpecificBpToPx(m,a);e.addRect(""+r,i,s,l,n)}else i=t.globalBpToPx(o-1),s=t.globalBpToPx(a),e.addRect(""+r,i,s,l,n)})),e}),[l,g,m,t,i]),b=r.useRef(null),y=r.useRef(null),w=r.useRef(null);return r.useEffect((function(){if(b.current){var e=b.current.getContext("2d");if(e){e.resetTransform(),e.scale(s,s),e.clearRect(0,0,o,h),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,Math.max(8,l-8)+"px");var t=Math.max(0,Math.floor(n/a));e.fillStyle="goldenrod",v.rectangles.forEach((function(r){var o=r.minY,i=(r.minX-t)*a+n-n%a,l=(r.maxX-t)*a+n-n%a;l-i>0&&e.fillRect(i,o,l-i,(r.maxY-o)/2)}))}}}),[m,o,a,v.rectangles,t,l,h,n,s,d,i]),r.useEffect((function(){if(y.current){var e=y.current.getContext("2d");e&&(e.resetTransform(),e.scale(s,s),e.clearRect(0,0,o,h),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,Math.max(8,l-8)+"px"),e.fillStyle="black",e.textAlign="left",v.rectangles.forEach((function(t){var n,r,o,i,l=t.maxY,s=t.minY,u=t.data,f=t.minX*a,h=t.maxX*a;if(h-f>0){var d=null===(r=null===(n=u.attributes)||void 0===n?void 0:n.Note)||void 0===r?void 0:r[0],m=null===(i=null===(o=u.attributes)||void 0===o?void 0:o.Name)||void 0===i?void 0:i[0];e.fillText([u.type,m,d].filter((function(e){return!!e})).join(" - "),Math.max(Math.min(-c,h),f),s+(l-s))}})))}}),[o,a,c,s,h,v.rectangles,n,d,t,l,i]),d?p.createElement(p.Fragment,null,p.createElement("canvas",{ref:b,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}}),p.createElement("canvas",{ref:y,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}}),p.createElement("canvas",{ref:w,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}})):null})),An=o.observer((function(e){var t=e.model,n=e.track;return p.createElement("div",{style:{position:"relative",height:n.model.height,width:t.msaAreaWidth,overflow:"hidden"}},t.blocksX.map((function(e){return p.createElement(xn,{track:n,key:e,model:t,offsetX:e})})))})),kn=function(){return(kn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ln=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))},Cn=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},Pn=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function Tn(e,t){for(var n="",r=0,o=0;o<t.length;o++)o===e[r]?r++:n+=t[o];return n}function On(e){return(e.data.length||1)+(e.children?function(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n<t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let o of e)null!=(o=t(o,++r,e))&&(n<o||void 0===n&&o>=o)&&(n=o)}return n}(e.children,On):0)}function Rn(e){e.children&&(e._children=e.children,e._children.forEach(Rn),e.children=null)}function Dn(e,t,n){return Math.min(Math.max(t,e),n)}var Nn=u.types.model({id:u.types.identifier,structure:u.types.model({pdb:u.types.string,startPos:u.types.number,endPos:u.types.number}),range:u.types.maybe(u.types.string)}),jn=u.types.model({id:u.types.string,accession:u.types.string,name:u.types.string,associatedRowName:u.types.string,height:u.types.optional(u.types.number,100)}).volatile((function(){return{error:void 0,data:void 0}})).actions((function(e){return{setError:function(t){e.error=t},setData:function(t){e.data=t}}})).actions((function(e){return{afterCreate:function(){var t=this;u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r,o;return Cn(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),t="https://www.uniprot.org/uniprot/"+e.accession+".gff",[4,fetch(t)];case 1:if(!(n=a.sent()).ok)throw new Error("HTTP "+n.status+" "+n.statusText+" fetching "+t);return[4,n.text()];case 2:return r=a.sent(),e.setData(r),[3,4];case 3:return o=a.sent(),e.setError(o),[3,4];case 4:return[2]}}))}))})))}}})).views((function(e){return{get loading(){return!e.data},get features(){var t;return null===(t=e.data)||void 0===t?void 0:t.split("\n").map((function(e){return e.trim()})).filter((function(e){return!!e})).filter((function(e){return!e.startsWith("#")})).map((function(e){var t=e.split("\t");return kn({seq_id:t[0],source:t[1],type:t[2],start:+t[3],end:+t[4],score:+t[5],strand:t[6],phase:t[7]},Object.fromEntries(t[8].split(";").map((function(e){return e.trim()})).filter((function(e){return!!e})).map((function(e){return e.split("=")})).map((function(e){var t=e[1];return[e[0].trim(),decodeURIComponent(t).trim().split(",").join(" ")]}))))}))}}})),In=u.types.model("MsaView",{id:f.ElementId,type:u.types.literal("MsaView"),height:u.types.optional(u.types.number,550),treeAreaWidth:u.types.optional(u.types.number,400),treeWidth:u.types.optional(u.types.number,300),rowHeight:20,scrollY:0,scrollX:0,resizeHandleWidth:5,blockSize:1e3,mouseRow:u.types.maybe(u.types.number),mouseCol:u.types.maybe(u.types.number),selectedStructures:u.types.array(Nn),labelsAlignRight:!1,colWidth:16,showBranchLen:!0,bgColor:!0,drawTree:!0,drawNodeBubbles:!0,highResScaleFactor:2,colorSchemeName:"maeditor",treeFilehandle:u.types.maybe(f.FileLocation),msaFilehandle:u.types.maybe(f.FileLocation),currentAlignment:0,collapsed:u.types.array(u.types.string),showOnly:u.types.maybe(u.types.string),boxTracks:u.types.array(jn),turnedOffTracks:u.types.map(u.types.boolean),annotatedRegions:u.types.array(u.types.model({start:u.types.number,end:u.types.number,attributes:u.types.frozen()})),data:u.types.optional(u.types.model({tree:u.types.maybe(u.types.string),msa:u.types.maybe(u.types.string)}).actions((function(e){return{setTree:function(t){e.tree=t},setMSA:function(t){e.msa=t}}})),{tree:"",msa:""})}).volatile((function(){return{error:void 0,margin:{left:20,top:20},DialogComponent:void 0,DialogProps:void 0,annotPos:void 0}})).actions((function(e){return{setDialogComponent:function(t,n){e.DialogComponent=t,e.DialogProps=n},setHeight:function(t){e.height=t},addStructureToSelection:function(t){e.selectedStructures.push(t)},removeStructureFromSelection:function(t){var n=e.selectedStructures.find((function(e){return e.id===t.id}));n&&e.selectedStructures.remove(n)},toggleStructureSelection:function(t){var n=e.selectedStructures.find((function(e){return e.id===t.id}));n?e.selectedStructures.remove(n):e.selectedStructures.push(t)},clearSelectedStructures:function(){e.selectedStructures=[]},setError:function(t){console.error(t),e.error=t},setMousePos:function(t,n){e.mouseCol=t,e.mouseRow=n},setRowHeight:function(t){e.rowHeight=t},setColWidth:function(t){e.colWidth=t},setColorSchemeName:function(t){e.colorSchemeName=t},setScrollY:function(t){e.scrollY=t},setScrollX:function(t){e.scrollX=t},setTreeAreaWidth:function(t){e.treeAreaWidth=t},setTreeWidth:function(t){e.treeWidth=t},setCurrentAlignment:function(t){e.currentAlignment=t},toggleLabelsAlignRight:function(){e.labelsAlignRight=!e.labelsAlignRight},toggleDrawTree:function(){e.drawTree=!e.drawTree},toggleCollapsed:function(t){e.collapsed.includes(t)?e.collapsed.remove(t):e.collapsed.push(t)},setShowOnly:function(t){e.showOnly=t},toggleBranchLen:function(){e.showBranchLen=!e.showBranchLen},toggleBgColor:function(){e.bgColor=!e.bgColor},toggleNodeBubbles:function(){e.drawNodeBubbles=!e.drawNodeBubbles},setData:function(t){e.data=u.cast(t)},setMSAFilehandle:function(t){return Ln(this,void 0,void 0,(function(){return Cn(this,(function(n){return e.msaFilehandle=t,[2]}))}))},setTreeFilehandle:function(t){return Ln(this,void 0,void 0,(function(){var n;return Cn(this,(function(r){switch(r.label){case 0:return t&&"blobId"in t?[4,h.openLocation(t).readFile("utf8")]:[3,2];case 1:return n=r.sent(),this.setTree(n),[3,3];case 2:e.treeFilehandle=t,r.label=3;case 3:return[2]}}))}))},setMSA:function(t){e.data.setMSA(t)},setTree:function(t){e.data.setTree(t)},afterCreate:function(){var t=this;u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r;return Cn(this,(function(o){switch(o.label){case 0:if(!(t=e.treeFilehandle))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),n=this.setTree,[4,h.openLocation(t).readFile("utf8")];case 2:return n.apply(this,[o.sent()]),[3,4];case 3:return r=o.sent(),this.setError(r),[3,4];case 4:return[2]}}))}))}))),u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r;return Cn(this,(function(o){switch(o.label){case 0:if(!(t=e.msaFilehandle))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),n=this.setMSA,[4,h.openLocation(t).readFile("utf8")];case 2:return n.apply(this,[o.sent()]),[3,4];case 3:return r=o.sent(),this.setError(r),[3,4];case 4:return[2]}}))}))})))}}})).views((function(e){var t=[],n=[],r=0,o=0;return{get initialized(){return(e.data.msa||e.data.tree||e.msaFilehandle||e.treeFilehandle)&&!e.error},get blocksX(){for(var n=e.blockSize,o=e.colWidth,a=-n*Math.floor(e.scrollX/n)-n,i=[],l=a;l<a+3*n;l+=n)l+n>0&&i.push(l);return JSON.stringify(i)===JSON.stringify(t)&&o===r||(t=i,r=o),t},get blocksY(){for(var t=e.blockSize,r=e.rowHeight,a=-t*Math.floor(e.scrollY/t)-2*t,i=[],l=a;l<a+3*t;l+=t)l+t>0&&i.push(l);return JSON.stringify(i)===JSON.stringify(n)&&r===o||(n=i,o=r),n}}})).views((function(e){return{get blocks2d(){return e.blocksY.map((function(t){return e.blocksX.map((function(e){return[e,t]}))})).flat()},get done(){return e.initialized&&(e.data.msa||e.data.tree)},get colorScheme(){return Je[e.colorSchemeName]},get alignmentDetails(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.getDetails())||{}},getRowDetails:function(e){var t,n=null===(t=this.MSA)||void 0===t?void 0:t.getRowDetails(e),r=e.match(/\S+\/(\d+)-(\d+)/);return kn(kn({},n),r&&{range:{start:+r[1],end:+r[2]}})},get currentAlignmentName(){return this.alignmentNames[e.currentAlignment]},get alignmentNames(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.alignmentNames)||[]},get noTree(){return!!this.tree.noTree},get menuItems(){return[]},get MSA(){var t=e.data.msa;return t?dn.sniff(t)?new yn(t,e.currentAlignment):t.startsWith(">")?new wn(t):new vn(t):null},get numColumns(){var t;return(((null===(t=this.MSA)||void 0===t?void 0:t.getWidth())||0)-this.blanks.length)*e.colWidth},get tree(){var t;return e.data.tree?Ke(bn(e.data.tree)):(null===(t=this.MSA)||void 0===t?void 0:t.getTree())||{noTree:!0}},get rowNames(){return this.hierarchy.leaves().map((function(e){return e.data.name}))},get mouseOverRowName(){return void 0!==e.mouseRow?this.rowNames[e.mouseRow]:void 0},getMouseOverResidue:function(e){return this.columns[e]},get root(){var t=Ft(this.tree,(function(e){return e.branchset})).sum((function(e){return e.branchset?0:1})).sort((function(e,t){return function(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}(e.data.length||1,t.data.length||1)}));if(e.showOnly){var n=t.find((function(t){return t.data.id===e.showOnly}));n&&(t=n)}return e.collapsed.length&&e.collapsed.map((function(e){return t.find((function(t){return t.data.id===e}))})).filter((function(e){return!!e})).map((function(e){return Rn(e)})),t},get structures(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.getStructures())||{}},get inverseStructures(){var e=Object.entries(this.structures).map((function(e){var t=e[0];return e[1].map((function(e){return[e.pdb,{id:t}]}))})).flat();return Object.fromEntries(e)},get msaAreaWidth(){return e.width-e.treeAreaWidth},get blanks(){for(var e,t=this,n=[],r=this.hierarchy.leaves().map((function(e){var n;return null===(n=t.MSA)||void 0===n?void 0:n.getRow(e.data.name)})).filter((function(e){return!!e})),o=0;o<(null===(e=r[0])||void 0===e?void 0:e.length);o++){for(var a=0,i=0;i<r.length;i++)"-"===r[i][o]&&a++;a===r.length&&n.push(o)}return n},get rows(){var e=this;return this.hierarchy.leaves().map((function(t){var n,r=t.data;return[r.name,null===(n=e.MSA)||void 0===n?void 0:n.getRow(r.name)]})).filter((function(e){return!!e[1]}))},get columns(){var e=this.columns2d;return Object.fromEntries(this.rows.map((function(t,n){return[t[0],e[n]]})))},get columns2d(){for(var e=this.rows.map((function(e){return e[1]})),t=[],n=0;n<e.length;n++)t.push(Tn(this.blanks,e[n]));return t},get colStats(){for(var e=[],t=this.columns2d,n=0;n<t.length;n++)for(var r=0;r<t[n].length;r++){var o=e[r]||{};o[t[n][r]]||(o[t[n][r]]=0),o[t[n][r]]++,e[r]=o}return e},get hierarchy(){var t=this.root;return function(){var e=Dt,t=1,n=1,r=!1;function o(o){var a,i=0;o.eachAfter((function(t){var n=t.children;n?(t.x=function(e){return e.reduce(Nt,0)/e.length}(n),t.y=function(e){return 1+e.reduce(jt,0)}(n)):(t.x=a?i+=e(t,a):0,t.y=0,a=t)}));var l=function(e){for(var t;t=e.children;)e=t[0];return e}(o),s=function(e){for(var t;t=e.children;)e=t[t.length-1];return e}(o),c=l.x-e(l,s)/2,u=s.x+e(s,l)/2;return o.eachAfter(r?function(e){e.x=(e.x-o.x)*t,e.y=(o.y-e.y)*n}:function(e){e.x=(e.x-c)/(u-c)*t,e.y=(1-(o.y?e.y/o.y:1))*n})}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],o):r?null:[t,n]},o.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],o):r?[t,n]:null},o}().size([this.totalHeight,e.treeWidth]).separation((function(){return 1}))(t),function e(t,n,r){var o;t.len=(n+=Math.max(t.data.length||0,0))*r,null===(o=t.children)||void 0===o||o.forEach((function(t){e(t,n,r)}))}(t,t.data.length=0,e.treeWidth/On(t)),t},get totalHeight(){return this.root.leaves().length*e.rowHeight}}})).actions((function(e){return{addUniprotTrack:function(t){e.boxTracks.find((function(e){return e.name===t.name}))?e.turnedOffTracks.has(t.name)&&this.toggleTrack(t.name):e.boxTracks.push(kn(kn({},t),{id:t.name,associatedRowName:t.name}))},doScrollY:function(t){e.scrollY=Dn(10-e.totalHeight,e.scrollY+t,0)},doScrollX:function(t){e.scrollX=Dn(e.msaAreaWidth-100-e.numColumns,e.scrollX+t,0)},setMouseoveredColumn:function(t,n,r){var o,a=0,i=0,l=(e.inverseStructures[r.slice(0,-4)]||{}).id,s=null===(o=e.MSA)||void 0===o?void 0:o.getRow(l);if(s){for(i=0;i<s.length&&a<t;i++)"-"!==s[i]&&a++;e.mouseCol=a+1}else e.mouseCol=void 0},toggleTrack:function(t){e.turnedOffTracks.has(t)?e.turnedOffTracks.delete(t):e.turnedOffTracks.set(t,!0)}}})).views((function(e){return{get secondaryStructureConsensus(){var t;return null===(t=e.MSA)||void 0===t?void 0:t.secondaryStructureConsensus},get seqConsensus(){var t;return null===(t=e.MSA)||void 0===t?void 0:t.seqConsensus},get conservation(){var t=e.columns2d;if(t.length)for(var n=0;n<t[0].length;n++)for(var r=[],o=0;o<t.length;o++)r.push(t[o][n]);return["a"]},get tracks(){var t=e.blanks,n=e.MSA?e.MSA.tracks.map((function(n){var r=n.data;return{model:kn(kn({},n),{data:r?Tn(t,r):void 0,height:e.rowHeight}),ReactComponent:Sn}})):[],r=e.boxTracks.filter((function(t){return!!e.rows.find((function(e){return e[0]===t.name}))})).map((function(e){return{model:e,ReactComponent:An}})),o=e.annotatedRegions.length>0?[{model:{features:e.annotatedRegions,height:100,id:"annotations",name:"User-created annotations",data:e.annotatedRegions.map((function(e){var t=e.attributes?Object.entries(e.attributes).map((function(e){return e[0]+"="+e[1].join(",")})).join(";"):".";return["MSA_refcoord",".",".",e.start,e.end,".",".",".",t].join("\t")})).join("\n")},ReactComponent:An}]:[];return Pn(Pn(Pn([],n,!0),r,!0),o,!0)},get turnedOnTracks(){return this.tracks.filter((function(t){return!e.turnedOffTracks.has(t.model.id)}))},pxToBp:function(t){return Math.floor((t-e.scrollX)/e.colWidth)},rowSpecificBpToPx:function(t,n){var r,o=e.blanks,a=e.rows[e.rowNames.indexOf(t)][1],i=n-((null===(r=e.getRowDetails(t).range)||void 0===r?void 0:r.start)||0);if(i<0)return 0;for(var l=0,s=0;s<a.length&&("-"===a[s]||l++!==i);s++);for(var c=0,u=0;u<a.length;u++)-1!==o.indexOf(u)&&u<s+1&&c++;return s-c},globalBpToPx:function(t){for(var n,r=0,o=0;o<(null===(n=e.rows[0])||void 0===n?void 0:n[1].length);o++)-1!==e.blanks.indexOf(o)&&o<t+1&&r++;return t-r},relativePxToBp:function(t,n){for(var r=e.rows[e.rowNames.indexOf(t)][1],o=0,a=0;a<n;a++)if("-"!==r[a])o++;else if(o>=n)break;return o},getPos:function(t){for(var n=0,r=0,o=0;r<t;r++,n++)for(;n===e.blanks[o];)o++,n++;return n}}})).actions((function(e){return{addAnnotation:function(t,n,r){e.annotatedRegions.push({start:e.getPos(t),end:e.getPos(n),attributes:r})},setOffsets:function(t,n){e.annotPos={left:t,right:n}},clearAnnotPos:function(){e.annotPos=void 0}}})),Fn=u.types.snapshotProcessor(u.types.compose(hn,In),{postProcessor:function(e){var t=e.data,n=t.tree,r=t.msa,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["data"]);return kn({data:kn(kn({},!e.treeFilehandle&&{tree:n}),!e.msaFilehandle&&{msa:r})},o)}}),_n={__proto__:null,MSAModel:Fn,MSAView:Rt},Bn=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=P(p),r=(0,L(T).default)(n.createElement("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"}),"GridOn");t.default=r})));e.default=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(o,e);var t,r=S(o);function o(){var e;return b(this,o),(e=r.apply(this,arguments)).name="MsaViewPlugin",e.version="1.0.17",e}return(t=[{key:"install",value:function(e){console.log({MSA:_n}),e.addViewType((function(){return new m({name:"MsaView",stateModel:Fn,ReactComponent:Rt})}))}},{key:"configure",value:function(e){n.isAbstractMenuManager(e.rootModel)&&e.rootModel.appendToSubMenu(["Add"],{label:"Multiple sequence alignment view",icon:Bn,onClick:function(e){e.addView("MsaView",{})}})}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(o.prototype,t),o}(t),Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@jbrowse/core/Plugin"),require("@jbrowse/core/util"),require("react"),require("mobx-react"),require("@material-ui/core"),require("mobx"),require("@jbrowse/core/ui"),require("@material-ui/core/utils"),require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"),require("mobx-state-tree"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("prop-types"),require("@jbrowse/core/pluggableElementTypes/ViewType")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/util","react","mobx-react","@material-ui/core","mobx","@jbrowse/core/ui","@material-ui/core/utils","@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail","mobx-state-tree","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","prop-types","@jbrowse/core/pluggableElementTypes/ViewType"],t):t((e=e||self).JBrowsePluginMsaView={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports.react,e.JBrowseExports["mobx-react"],e.JBrowseExports["@material-ui/core"],e.JBrowseExports.mobx,e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["@material-ui/core/utils"],e.JBrowseExports["@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail"],e.JBrowseExports["mobx-state-tree"],e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["prop-types"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/ViewType"])}(this,(function(e,t,n,r,o,a,i,l,s,c,u,f,h,d,m){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var p="default"in r?r.default:r,g="default"in o?o.default:o;s=s&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s;var v="default"in u?u.default:u;function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=y(e);if(t){var o=y(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return E(this,n)}}d=d&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d,m=m&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m;var M=function(e){var t=e.onClick,n=e.model;return p.createElement("li",null,p.createElement(a.Link,{onClick:function(e){n.setError(void 0),e.preventDefault(),t()},href:"#"},p.createElement(a.Typography,null,e.children)))},x=o.observer((function(e){var t=e.model,n=r.useState(),o=n[0],s=n[1],c=r.useState(),u=c[0],f=c[1],h=t.error;return p.createElement(a.Container,null,p.createElement("div",{style:{width:"50%"}},h?p.createElement("div",{style:{padding:20}},p.createElement(a.Typography,{color:"error"},"Error: ","".concat(h))):null,p.createElement(a.Typography,null,"Open an MSA file (stockholm or clustal format) and/or a tree file (newick format)."),p.createElement(a.Typography,{color:"error"},"Note: you can open up just an MSA or just a tree, both are not required. Some MSA files e.g. stockholm format have an embedded tree also and this is fine, and opening a separate tree file is not required.")),p.createElement(a.Grid,{container:!0,spacing:10,justifyContent:"center",alignItems:"center"},p.createElement(a.Grid,{item:!0},p.createElement(a.Typography,null,"MSA file or URL"),p.createElement(l.FileSelector,{location:o,setLocation:s}),p.createElement(a.Typography,null,"Tree file or URL"),p.createElement(l.FileSelector,{location:u,setLocation:f})),p.createElement(a.Grid,{item:!0},p.createElement(a.Button,{onClick:function(){t.setError(void 0),o&&t.setMSAFilehandle(o),u&&t.setTreeFilehandle(u)},variant:"contained",color:"primary",disabled:!o&&!u},"Open")),p.createElement(a.Grid,{item:!0},p.createElement(a.Typography,null,"Examples"),p.createElement("ul",null,p.createElement(M,{model:t,onClick:function(){t.setTreeFilehandle({uri:"https://jbrowse.org/genomes/newick_trees/sarscov2phylo.pub.ft.nh",locationType:"UriLocation"})}},"230k COVID-19 samples (tree only)"),p.createElement(M,{model:t,onClick:function(){t.setData({msa:"CLUSTAL O(1.2.3) multiple sequence alignment\nUniProt/Swiss-Prot|P26898|IL2RA_SHEEP MEPSLLMWRFFVFIVVPGCVTEACHDDPPSLRNA----------MFKVLRYE----VGTM\nUniProt/Swiss-Prot|P01590|IL2RA_MOUSE MEPRLLMLGFLSLTIVPSCRAELCLYDPPEVPNA----------TFKALSYK----NGTI\nUniProt/Swiss-Prot|P41690|IL2RA_FELCA MEPSLLLWGILTFVVVHGHVTELCDENPPDIQHA----------TFKALTYK----TGTM\nUniProt/Swiss-Prot|P01589|IL2RA_HUMAN MDSYLLMWGLLTFIMVPGCQAELCDDDPPEIPHA----------TFKAMAYK----EGTM\nUniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU MDPYLLMWGLLTFITVPGCQAELCDDDPPKITHA----------TFKAVAYK----EGTM\nUniProt/Swiss-Prot|Q95118|IL2RG_BOVIN -----------------------------------LLMWGLLT-----------------\nUniProt/Swiss-Prot|P40321|IL2RG_CANFA MLKPPLPLRSLLFLQLSLLGVGLNSTVPMPNGNEDIT------PDFFLTATPSETLSVSS\nUniProt/Swiss-Prot|P26896|IL2RB_RAT MATVDLSWRLPLYILLLLLATT--------------------------------WVSAAV\nUniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE PLPLRSLLFLQLPLLGVGLNP------------------PLPLRSLLFLQLPLLGVGLNP\nUniProt/Swiss-Prot|P36835|IL2_CAPHI -----------LLGVGLNPKFLTP------------------------------------\nUniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO MLKPPLPLRSLLFLQLPLLGVGLNPKFLTPSGNEDIGGKPGTGGDFFLTSTPAGTLDVST\nUniProt/Swiss-Prot|Q29416|IL2_CANFA --------------LFLQLSLLG-------------------------------------\n",tree:"(((UniProt/Swiss-Prot|P26898|IL2RA_SHEEP:0.24036,(UniProt/Swiss-Prot|P41690|IL2RA_FELCA:0.17737,(UniProt/Swiss-Prot|P01589|IL2RA_HUMAN:0.03906,UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU:0.03787):0.13033):0.04964):0.02189,UniProt/Swiss-Prot|P01590|IL2RA_MOUSE:0.23072):0.06814,(((UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN:0.09600,UniProt/Swiss-Prot|P40321|IL2RG_CANFA:0.09845):0.25333,UniProt/Swiss-Prot|Q29416|IL2_CANFA:-0.35055):0.10231,(UniProt/Swiss-Prot|P26896|IL2RB_RAT:0.33631,UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO:-0.33631):0.10166):0.01607,(UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE:0.32378,UniProt/Swiss-Prot|P36835|IL2_CAPHI:-0.32378):0.09999)"})}},"Small protein MSA+tree"),p.createElement(M,{model:t,onClick:function(){t.setData({msa:"CLUSTAL O(1.2.4) multiple sequence alignment\n\n\nsp|P69905|HBA_HUMAN MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHGSAQVKGHG\t60\nsp|P01942|HBA_MOUSE MVLSGEDKSNIKAAWGKIGGHGAEYGAEALERMFASFPTTKTYFPHFDVSHGSAQVKGHG\t60\nsp|P13786|HBAZ_CAPHI MSLTRTERTIILSLWSKISTQADVIGTETLERLFSCYPQAKTYFPHFDLHSGSAQLRAHG\t60\n * *: ::: : : *.*:. :. *:*:***:* .:* :********: ****::.**\n\nsp|P69905|HBA_HUMAN KKVADALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKLLSHCLLVTLAAHLPAEFTP\t120\nsp|P01942|HBA_MOUSE KKVADALASAAGHLDDLPGALSALSDLHAHKLRVDPVNFKLLSHCLLVTLASHHPADFTP\t120\nsp|P13786|HBAZ_CAPHI SKVVAAVGDAVKSIDNVTSALSKLSELHAYVLRVDPVNFKFLSHCLLVTLASHFPADFTA\t120\n .**. *: .*. :*:: .*** **:***: *********:**********:* **:**\n\nsp|P69905|HBA_HUMAN AVHASLDKFLASVSTVLTSKYR\t142\nsp|P01942|HBA_MOUSE AVHASLDKFLASVSTVLTSKYR\t142\nsp|P13786|HBAZ_CAPHI DAHAAWDKFLSIVSGVLTEKYR\t142\n .**: ****: ** ***.***"})}},"Small MSA only"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://ihh.github.io/abrowse/build/pfam-cov2.stock",locationType:"UriLocation"})}},"PFAM SARS-CoV2 multi-stockholm"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/Lysine.stock",locationType:"UriLocation"})}},"Lysine stockholm file"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/PF01601_full.txt",locationType:"UriLocation"})}},"PF01601 stockholm file (SARS-CoV2 spike protein)"),p.createElement(M,{model:t,onClick:function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/europe_covid.fa",locationType:"UriLocation"})}},"Europe COVID full genomes (LR883044.1 and 199 other sequences)"),p.createElement(M,{model:t,onClick:function(){i.transaction((function(){t.setMSAFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.fa",locationType:"UriLocation"}),t.setTreeFilehandle({uri:"https://jbrowse.org/genomes/multiple_sequence_alignments/rhv_test-only.aligned_with_mafft_auto.nh",locationType:"UriLocation"})}))}},"MAFFT+VeryFastTree(17.9k samples)")))))}));function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function k(e,t){return e(t={exports:{}},t.exports),t.exports}var L=k((function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.default=e.exports,e.exports.__esModule=!0}));A(L);var T=k((function(e){function t(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=t=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),t(n)}e.exports=t,e.exports.default=e.exports,e.exports.__esModule=!0}));A(T);var C=k((function(e){var t=T.default;function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}e.exports=function(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return{default:e};var o=n(r);if(o&&o.has(e))return o.get(e);var a={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if("default"!==l&&Object.prototype.hasOwnProperty.call(e,l)){var s=i?Object.getOwnPropertyDescriptor(e,l):null;s&&(s.get||s.set)?Object.defineProperty(a,l,s):a[l]=e[l]}return a.default=e,o&&o.set(e,a),a},e.exports.default=e.exports,e.exports.__esModule=!0}));A(C);var P=k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return s.createSvgIcon}})}));A(P);var O,R,D,N,j,I,F,_,B,Y,H,X,V,q,G,U=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}),"Assignment");t.default=r}))),W=a.makeStyles((function(e){return{rubberband:{height:"100%",background:a.alpha(e.palette.tertiary?e.palette.tertiary.main:e.palette.primary.main,.7),position:"absolute",zIndex:10,textAlign:"center",overflow:"hidden"},rubberbandControl:{cursor:"crosshair",width:"100%",minHeight:8},rubberbandText:{color:e.palette.tertiary?e.palette.tertiary.contrastText:e.palette.primary.contrastText},popover:{mouseEvents:"none",cursor:"crosshair"},paper:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},guide:{pointerEvents:"none",height:"100%",width:1,position:"absolute",zIndex:10}}})),z=o.observer((function(e){var t=e.model,n=e.coordX,r=t.treeAreaWidth,o=W();return p.createElement(p.Fragment,null,p.createElement(a.Tooltip,{open:!0,placement:"top",title:"".concat(t.pxToBp(n)+1),arrow:!0},p.createElement("div",{style:{left:n+r,position:"absolute",height:1}})),p.createElement("div",{className:o.guide,style:{left:n+r,background:"red"}}))})),K=o.observer((function(e){var t=e.model,n=e.ControlComponent,o=void 0===n?p.createElement("div",null):n,i=t.treeAreaWidth,s=r.useState(),c=s[0],u=s[1],f=r.useState(),h=f[0],d=f[1],m=r.useState(),g=m[0],v=m[1],b=r.useState(),y=b[0],w=b[1],E=r.useRef(null),S=r.useRef(null),M=W(),x=void 0!==c&&void 0===g;function A(e){e.preventDefault(),e.stopPropagation();var t=e.clientX-e.target.getBoundingClientRect().left;u(t),d(t)}function k(e){w(e.clientX-e.target.getBoundingClientRect().left)}function L(){w(void 0),t.clearAnnotPos()}function T(){v(void 0),u(void 0),d(void 0)}if(r.useEffect((function(){function e(e){if(E.current&&x){var t=e.clientX-E.current.getBoundingClientRect().left;d(t)}}function t(e){if(void 0!==c&&E.current){var t=e.clientX,n=e.clientY,r=t-E.current.getBoundingClientRect().left;v({offsetX:r,clientX:t,clientY:n}),w(void 0)}}return x?(window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),function(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}):function(){}}),[c,x,g]),r.useEffect((function(){!x&&void 0!==h&&void 0!==c&&Math.abs(h-c)<=3&&T()}),[x,h,c,t.colWidth]),void 0===c)return p.createElement(p.Fragment,null,void 0!==y?p.createElement(z,{model:t,coordX:y}):null,p.createElement("div",{"data-testid":"rubberband_controls",className:M.rubberbandControl,role:"presentation",ref:E,onMouseDown:A,onMouseOut:L,onMouseMove:k},o));var C=g?g.offsetX:h||0,P=C<c?C:c,O=Math.abs(C-c),R=t.pxToBp(P),D=t.pxToBp(P+O),N=Math.ceil(O/t.colWidth),j=[{label:"Create annotation",icon:U,onClick:function(){t.setOffsets(R,D),T()}}];return p.createElement(p.Fragment,null,S.current?p.createElement(p.Fragment,null,p.createElement(a.Popover,{className:M.popover,classes:{paper:M.paper},open:!0,anchorEl:S.current,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,disableRestoreFocus:!0},p.createElement(a.Typography,null,R+1)),p.createElement(a.Popover,{className:M.popover,classes:{paper:M.paper},open:!0,anchorEl:S.current,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,disableRestoreFocus:!0},p.createElement(a.Typography,null,D+1))):null,p.createElement("div",{ref:S,className:M.rubberband,style:{left:P+i,width:O}},p.createElement(a.Typography,{variant:"h6",className:M.rubberbandText},N.toLocaleString("en-US")," bp")),p.createElement("div",{"data-testid":"rubberband_controls",className:M.rubberbandControl,role:"presentation",ref:E,onMouseDown:A,onMouseOut:L,onMouseMove:k},o),g?p.createElement(l.Menu,{anchorReference:"anchorPosition",anchorPosition:{left:g.clientX,top:g.clientY},onMenuItemClick:function(e,t){t(),T()},open:Boolean(g),onClose:T,menuItems:j}):null)})),Q=!1;function J(){if(!Q){Q=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),n=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(X=/\b(iPhone|iP[ao]d)/.exec(e),V=/\b(iP[ao]d)/.exec(e),Y=/Android/i.exec(e),q=/FBAN\/\w+;/i.exec(e),G=/Mobile/i.exec(e),H=!!/Win64/.exec(e),t){(O=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN)&&document&&document.documentMode&&(O=document.documentMode);var r=/(?:Trident\/(\d+.\d+))/.exec(e);I=r?parseFloat(r[1])+4:O,R=t[2]?parseFloat(t[2]):NaN,D=t[3]?parseFloat(t[3]):NaN,(N=t[4]?parseFloat(t[4]):NaN)?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),j=t&&t[1]?parseFloat(t[1]):NaN):j=NaN}else O=R=D=j=N=NaN;if(n){if(n[1]){var o=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);F=!o||parseFloat(o[1].replace("_","."))}else F=!1;_=!!n[2],B=!!n[3]}else F=_=B=!1}}var $,Z={ie:function(){return J()||O},ieCompatibilityMode:function(){return J()||I>O},ie64:function(){return Z.ie()&&H},firefox:function(){return J()||R},opera:function(){return J()||D},webkit:function(){return J()||N},safari:function(){return Z.webkit()},chrome:function(){return J()||j},windows:function(){return J()||_},osx:function(){return J()||F},linux:function(){return J()||B},iphone:function(){return J()||X},mobile:function(){return J()||X||V||Y||G},nativeApp:function(){return J()||q},android:function(){return J()||Y},ipad:function(){return J()||V}},ee=Z,te=!("undefined"==typeof window||!window.document||!window.document.createElement),ne=te;function re(e){var t=0,n=0,r=0,o=0;return"detail"in e&&(n=e.detail),"wheelDelta"in e&&(n=-e.wheelDelta/120),"wheelDeltaY"in e&&(n=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=10*t,o=10*n,"deltaY"in e&&(o=e.deltaY),"deltaX"in e&&(r=e.deltaX),(r||o)&&e.deltaMode&&(1==e.deltaMode?(r*=40,o*=40):(r*=800,o*=800)),r&&!t&&(t=r<1?-1:1),o&&!n&&(n=o<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:o}}te&&!window.addEventListener&&window,te&&window,ne&&($=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),re.getEventType=function(){return ee.firefox()?"DOMMouseScroll":function(e,t){if(!ne)return!1;var n="onwheel"in document;if(!n){var r=document.createElement("div");r.setAttribute("onwheel","return;"),n="function"==typeof r.onwheel}return!n&&$&&(n=document.implementation.hasFeature("Events.wheel","3.0")),n}()?"wheel":"mousewheel"};var oe=re;function ae(e,t,n,r,o){!function e(t,n,r,o,a){for(;o>r;){if(o-r>600){var i=o-r+1,l=n-r+1,s=Math.log(i),c=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*c*(i-c)/i)*(l-i/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-l*c/i+u)),Math.min(o,Math.floor(n+(i-l)*c/i+u)),a)}var f=t[n],h=r,d=o;for(ie(t,r,n),a(t[o],f)>0&&ie(t,r,o);h<d;){for(ie(t,h,d),h++,d--;a(t[h],f)<0;)h++;for(;a(t[d],f)>0;)d--}0===a(t[r],f)?ie(t,r,d):ie(t,++d,o),d<=n&&(r=d+1),n<=d&&(o=d-1)}}(e,t,n||0,r||e.length-1,o||le)}function ie(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function le(e,t){return e<t?-1:e>t?1:0}class se{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!ye(e,t))return n;const r=this.toBBox,o=[];for(;t;){for(let a=0;a<t.children.length;a++){const i=t.children[a],l=t.leaf?r(i):i;ye(e,l)&&(t.leaf?n.push(i):be(e,l)?this._all(i,n):o.push(i))}t=o.pop()}return n}collides(e){let t=this.data;if(!ye(e,t))return!1;const n=[];for(;t;){for(let r=0;r<t.children.length;r++){const o=t.children[r],a=t.leaf?this.toBBox(o):o;if(ye(e,a)){if(t.leaf||be(e,a))return!0;n.push(o)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=we([]),this}remove(e,t){if(!e)return this;let n=this.data;const r=this.toBBox(e),o=[],a=[];let i,l,s;for(;n||o.length;){if(n||(n=o.pop(),l=o[o.length-1],i=a.pop(),s=!0),n.leaf){const r=ce(e,n.children,t);if(-1!==r)return n.children.splice(r,1),o.push(n),this._condense(o),this}s||n.leaf||!be(n,r)?l?(i++,n=l.children[i],s=!1):n=null:(o.push(n),a.push(i),i=0,l=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){const o=n-t+1;let a,i=this._maxEntries;if(o<=i)return a=we(e.slice(t,n+1)),ue(a,this.toBBox),a;r||(r=Math.ceil(Math.log(o)/Math.log(i)),i=Math.ceil(o/Math.pow(i,r-1))),a=we([]),a.leaf=!1,a.height=r;const l=Math.ceil(o/i),s=l*Math.ceil(Math.sqrt(i));Ee(e,t,n,s,this.compareMinX);for(let o=t;o<=n;o+=s){const t=Math.min(o+s-1,n);Ee(e,o,t,l,this.compareMinY);for(let n=o;n<=t;n+=l){const o=Math.min(n+l-1,t);a.children.push(this._build(e,n,o,r-1))}}return ue(a,this.toBBox),a}_chooseSubtree(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){let n,r=Infinity,i=Infinity;for(let l=0;l<t.children.length;l++){const s=t.children[l],c=pe(s),u=(o=e,a=s,(Math.max(a.maxX,o.maxX)-Math.min(a.minX,o.minX))*(Math.max(a.maxY,o.maxY)-Math.min(a.minY,o.minY))-c);u<i?(i=u,r=c<r?c:r,n=s):u===i&&c<r&&(r=c,n=s)}t=n||t.children[0]}var o,a;return t}_insert(e,t,n){const r=n?e:this.toBBox(e),o=[],a=this._chooseSubtree(r,this.data,t,o);for(a.children.push(e),he(a,r);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(r,o,t)}_split(e,t){const n=e[t],r=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,r);const a=this._chooseSplitIndex(n,o,r),i=we(n.children.splice(a,n.children.length-a));i.height=n.height,i.leaf=n.leaf,ue(n,this.toBBox),ue(i,this.toBBox),t?e[t-1].children.push(i):this._splitRoot(n,i)}_splitRoot(e,t){this.data=we([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ue(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,o=Infinity,a=Infinity;for(let i=t;i<=n-t;i++){const t=fe(e,0,i,this.toBBox),l=fe(e,i,n,this.toBBox),s=ve(t,l),c=pe(t)+pe(l);s<o?(o=s,r=i,a=c<a?c:a):s===o&&c<a&&(a=c,r=i)}return r||n-t}_chooseSplitAxis(e,t,n){const r=e.leaf?this.compareMinX:de,o=e.leaf?this.compareMinY:me;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,o)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);const o=this.toBBox,a=fe(e,0,t,o),i=fe(e,n-t,n,o);let l=ge(a)+ge(i);for(let r=t;r<n-t;r++){const t=e.children[r];he(a,e.leaf?o(t):t),l+=ge(a)}for(let r=n-t-1;r>=t;r--){const t=e.children[r];he(i,e.leaf?o(t):t),l+=ge(i)}return l}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)he(t[r],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)0===e[n].children.length?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():ue(e[n],this.toBBox)}}function ce(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function ue(e,t){fe(e,0,e.children.length,t,e)}function fe(e,t,n,r,o){o||(o=we(null)),o.minX=Infinity,o.minY=Infinity,o.maxX=-Infinity,o.maxY=-Infinity;for(let a=t;a<n;a++){const t=e.children[a];he(o,e.leaf?r(t):t)}return o}function he(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function de(e,t){return e.minX-t.minX}function me(e,t){return e.minY-t.minY}function pe(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ge(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ve(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,a-r)}function be(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function ye(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function we(e){return{children:e,height:1,leaf:!0,minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}}function Ee(e,t,n,r,o){const a=[t,n];for(;a.length;){if((n=a.pop())-(t=a.pop())<=r)continue;const i=t+Math.ceil((n-t)/r/2)*r;ae(e,i,t,n,o),a.push(t,i,i,n)}}var Se=o.observer((function(e){var t=e.info,n=e.onClose;return p.createElement(a.Dialog,{onClose:function(){return n()},open:!0},p.createElement(a.DialogTitle,null,"Metadata"),p.createElement(a.DialogContent,null,p.createElement(c.Attributes,{attributes:t})))})),Me=function(){return(Me=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},xe=o.observer((function(e){var t,n,r=e.node,o=e.onClose,i=e.model,l=i.structures,s=r?i.getRowDetails(r.name):void 0;return p.createElement(p.Fragment,null,p.createElement(a.Menu,{anchorReference:"anchorPosition",anchorPosition:{top:r.y,left:r.x},transitionDuration:0,keepMounted:!0,open:Boolean(r),onClose:o},p.createElement(a.MenuItem,{dense:!0,disabled:!0},r.name),p.createElement(a.MenuItem,{dense:!0,onClick:function(){i.setDialogComponent(Se,{info:i.getRowDetails(r.name)}),o()}},"More info..."),null===(t=l[r.name])||void 0===t?void 0:t.map((function(e){return i.selectedStructures.find((function(e){return e.id===r.name}))?p.createElement(a.MenuItem,{key:JSON.stringify(e),dense:!0,onClick:function(){i.removeStructureFromSelection({structure:e,id:r.name}),o()}},"Remove PDB from selection (",e.pdb,")"):p.createElement(a.MenuItem,{key:JSON.stringify(e),dense:!0,onClick:function(){i.addStructureToSelection({structure:e,id:r.name}),o()}},"Add PDB to selection (",e.pdb,")")})),null===(n=s.accession)||void 0===n?void 0:n.map((function(e){return p.createElement(a.MenuItem,{dense:!0,key:e,onClick:function(){i.addUniprotTrack({name:s.name,accession:e}),o()}},"Open UniProt track (",e,")")}))))})),Ae=o.observer((function(e){var t=e.node,n=e.model,r=e.onClose;return p.createElement(a.Menu,{anchorReference:"anchorPosition",anchorPosition:{left:t.x,top:t.y},transitionDuration:0,keepMounted:!0,open:Boolean(t),onClose:r},p.createElement(a.MenuItem,{dense:!0,disabled:!0},t.name),p.createElement(a.MenuItem,{dense:!0,onClick:function(){n.toggleCollapsed(t.id),r()}},n.collapsed.includes(t.id)?"Expand this node":"Collapse this node"),p.createElement(a.MenuItem,{dense:!0,onClick:function(){n.setShowOnly(n.showOnly===t.id?void 0:t.id),r()}},n.showOnly===t.id?"Disable show only this node":"Show only this node"))})),ke=o.observer((function(e){var t=e.model,n=e.offsetY,o=r.useRef(null),a=r.useRef(new se),i=r.useRef(null),l=r.useState(),s=l[0],c=l[1],u=r.useState(),f=u[0],h=u[1],d=r.useState(),m=d[0],g=d[1],v=t.hierarchy,b=t.rowHeight,y=t.scrollY,w=t.treeWidth,E=t.showBranchLen,S=t.collapsed,M=t.margin,x=t.labelsAlignRight,A=t.noTree,k=t.blockSize,L=t.drawNodeBubbles,T=t.drawTree,C=t.treeAreaWidth,P=t.structures,O=t.highResScaleFactor;function R(e){var t=e.nativeEvent.offsetX-M.left,r=e.nativeEvent.offsetY,o=a.current.search({minX:t,maxX:t+1,minY:r+n,maxY:r+1+n})[0];return o&&o.branch?Me(Me({},o),{x:e.clientX,y:e.clientY}):void 0}function D(e){var t=e.nativeEvent.offsetX-M.left,r=e.nativeEvent.offsetY,o=a.current.search({minX:t,maxX:t+1,minY:r+n,maxY:r+1+n})[0];return o&&!o.branch?Me(Me({},o),{x:e.clientX,y:e.clientY}):void 0}return r.useEffect((function(){if(a.current.clear(),o.current){var e=o.current.getContext("2d");e&&(e.resetTransform(),e.scale(O,O),e.clearRect(0,0,w+600,k),e.translate(M.left,-n),e.font=e.font.replace(/\d+px/,"".concat(Math.max(8,b-8),"px")),!A&&T&&(v.links().forEach((function(t){var r=t.source,o=t.target,a=E?"len":"y",i=r.x,l=r[a],s=o.x,c=o[a],u=Math.min(i,s),f=Math.max(i,s);n+k>=u&&f>=n&&(e.beginPath(),e.moveTo(l,i),e.lineTo(l,s),e.lineTo(c,s),e.stroke())})),L&&v.descendants().forEach((function(t){var r=t.x,o=t[E?"len":"y"],i=t.data,l=i.id,s=void 0===l?"":l,c=i.name,u=void 0===c?"":c;r>n-5&&r<n+k+5&&(e.strokeStyle="black",e.fillStyle=S.includes(s)?"black":"white",e.beginPath(),e.arc(o,r,3.5,0,2*Math.PI),e.fill(),e.stroke(),a.current.insert({minX:o-3.5,maxX:o-3.5+7,minY:r-3.5,maxY:r-3.5+7,branch:!0,id:s,name:u}))}))),b>=10&&(x?(e.textAlign="right",e.setLineDash([1,3])):e.textAlign="start",v.leaves().forEach((function(t){var r=t.x,o=t.data,i=o.name,l=o.id;if(r>n-5&&r<n+k+5){var s=r+b/4,c=E?t.len:t.y,u=e.measureText(i).width,f=e.measureText("M").width;if(e.fillStyle=P[i]?"blue":"black",T||x)if(x){var h=C-2-M.left;if(T&&!A){var d=e.measureText(i).width;e.moveTo(c+3.5+2,r),e.lineTo(h-2-d,r),e.stroke()}e.fillText(i,h,s),a.current.insert({minX:C-M.left-u,maxX:C-M.left,minY:s-f,maxY:s,name:i,id:l})}else e.fillText(i,c+7,s),a.current.insert({minX:c+7,maxX:c+7+u,minY:s-f,maxY:s,name:i,id:l});else e.fillText(i,0,s),a.current.insert({minX:0,maxX:u,minY:s-f,maxY:s,name:i,id:l})}})),e.setLineDash([])))}}),[S,b,M.left,v,n,w,E,A,k,L,T,x,C,P,O]),r.useEffect((function(){var e=i.current;if(e){var t=e.getContext("2d");if(t&&(t.resetTransform(),t.clearRect(0,0,w+600,k),t.translate(M.left,-n),m)){var r=m.minX,o=m.maxX,a=m.minY,l=m.maxY;t.fillStyle="rgba(0,0,0,0.1)",t.fillRect(r,a,o-r,l-a)}}}),[m,M.left,n,k,w]),p.createElement(p.Fragment,null,(null==s?void 0:s.id)?p.createElement(Ae,{node:s,model:t,onClose:function(){return c(void 0)}}):null,(null==f?void 0:f.id)?p.createElement(xe,{node:f,model:t,onClose:function(){return h(void 0)}}):null,p.createElement("canvas",{width:(w+600)*O,height:k*O,style:{width:w+600,height:k,top:y+n,left:0,position:"absolute"},onMouseMove:function(e){if(o.current){var t=D(e)||R(e);o.current.style.cursor=t?"pointer":"default",g(D(e))}},onClick:function(e){var t=e.clientX,n=e.clientY,r=R(e);(null==r?void 0:r.id)&&c(Me(Me({},r),{x:t,y:n}));var o=D(e);(null==o?void 0:o.id)&&h(Me(Me({},o),{x:t,y:n}))},ref:o}),p.createElement("canvas",{style:{width:w+600,height:k,top:y+n,left:0,position:"absolute",pointerEvents:"none",zIndex:100},width:w+600,height:k,ref:i}))})),Le=o.observer((function(e){var t=e.model,n=r.useRef(null),o=r.useRef(!1),a=r.useRef(0),i=r.useRef(0),l=t.treeWidth,s=t.height,c=t.blocksY,u=r.useState(!1),f=u[0],h=u[1];return r.useEffect((function(){var e=n.current;if(e)return e.addEventListener("wheel",r),function(){e.removeEventListener("wheel",r)};function r(e){var n=oe(e);a.current+=n.pixelY,o.current||(o.current=!0,requestAnimationFrame((function(){t.doScrollY(-a.current),a.current=0,o.current=!1}))),e.preventDefault()}}),[t]),r.useEffect((function(){var e=function(){};function n(e){e.preventDefault();var n=e.clientY-i.current;n&&(o.current||(o.current=!0,window.requestAnimationFrame((function(){t.doScrollY(n),o.current=!1,i.current=e.clientY}))))}function r(){i.current=0,f&&h(!1)}return f&&(window.addEventListener("mousemove",n,!0),window.addEventListener("mouseup",r,!0),e=function(){window.removeEventListener("mousemove",n,!0),window.removeEventListener("mouseup",r,!0)}),e}),[t,f]),p.createElement("div",{ref:n,onMouseDown:function(e){var t=e.target;t.draggable||t.dataset.resizer||0===e.button&&(i.current=e.clientY,h(!0))},onMouseUp:function(e){e.preventDefault(),h(!1)},onMouseLeave:function(e){e.preventDefault()},style:{height:s,position:"relative",overflow:"hidden",width:l+600}},c.map((function(e){return p.createElement(ke,{key:e,model:t,offsetY:e})})))})),Te={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Ce=k((function(e){var t=Array.prototype.concat,n=Array.prototype.slice,r=e.exports=function(e){for(var r,o=[],a=0,i=e.length;a<i;a++){var l=e[a];(r=l)&&"string"!=typeof r&&(r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&"String"!==r.constructor.name))?o=t.call(o,n.call(l)):o.push(l)}return o};r.wrap=function(e){return function(){return e(r(arguments))}}})),Pe=k((function(e){var t=Object.hasOwnProperty,n={};for(var r in Te)t.call(Te,r)&&(n[Te[r]]=r);var o=e.exports={to:{},get:{}};function a(e,t,n){return Math.min(Math.max(t,e),n)}function i(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}o.get=function(e){var t,n;switch(e.substring(0,3).toLowerCase()){case"hsl":t=o.get.hsl(e),n="hsl";break;case"hwb":t=o.get.hwb(e),n="hwb";break;default:t=o.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},o.get.rgb=function(e){if(!e)return null;var n,r,o,i=[0,0,0,1];if(n=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(o=n[2],n=n[1],r=0;r<3;r++){var l=2*r;i[r]=parseInt(n.slice(l,l+2),16)}o&&(i[3]=parseInt(o,16)/255)}else if(n=e.match(/^#([a-f0-9]{3,4})$/i)){for(o=(n=n[1])[3],r=0;r<3;r++)i[r]=parseInt(n[r]+n[r],16);o&&(i[3]=parseInt(o+o,16)/255)}else if(n=e.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(r=0;r<3;r++)i[r]=parseInt(n[r+1],0);n[4]&&(i[3]=n[5]?.01*parseFloat(n[4]):parseFloat(n[4]))}else{if(!(n=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(n=e.match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:t.call(Te,n[1])?((i=Te[n[1]])[3]=1,i):null:null;for(r=0;r<3;r++)i[r]=Math.round(2.55*parseFloat(n[r+1]));n[4]&&(i[3]=n[5]?.01*parseFloat(n[4]):parseFloat(n[4]))}for(r=0;r<3;r++)i[r]=a(i[r],0,255);return i[3]=a(i[3],0,1),i},o.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,a(parseFloat(t[2]),0,100),a(parseFloat(t[3]),0,100),a(isNaN(n)?1:n,0,1)]}return null},o.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,a(parseFloat(t[2]),0,100),a(parseFloat(t[3]),0,100),a(isNaN(n)?1:n,0,1)]}return null},o.to.hex=function(){var e=Ce(arguments);return"#"+i(e[0])+i(e[1])+i(e[2])+(e[3]<1?i(Math.round(255*e[3])):"")},o.to.rgb=function(){var e=Ce(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},o.to.rgb.percent=function(){var e=Ce(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},o.to.hsl=function(){var e=Ce(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},o.to.hwb=function(){var e=Ce(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},o.to.keyword=function(e){return n[e.slice(0,3)]}})),Oe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Re=k((function(e){var t={};for(var n in Oe)Oe.hasOwnProperty(n)&&(t[Oe[n]]=n);var r=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var o in r)if(r.hasOwnProperty(o)){if(!("channels"in r[o]))throw new Error("missing channels property: "+o);if(!("labels"in r[o]))throw new Error("missing channel labels property: "+o);if(r[o].labels.length!==r[o].channels)throw new Error("channel and label counts mismatch: "+o);var a=r[o].channels,i=r[o].labels;delete r[o].channels,delete r[o].labels,Object.defineProperty(r[o],"channels",{value:a}),Object.defineProperty(r[o],"labels",{value:i})}r.rgb.hsl=function(e){var t,n,r=e[0]/255,o=e[1]/255,a=e[2]/255,i=Math.min(r,o,a),l=Math.max(r,o,a),s=l-i;return l===i?t=0:r===l?t=(o-a)/s:o===l?t=2+(a-r)/s:a===l&&(t=4+(r-o)/s),(t=Math.min(60*t,360))<0&&(t+=360),n=(i+l)/2,[t,100*(l===i?0:n<=.5?s/(l+i):s/(2-l-i)),100*n]},r.rgb.hsv=function(e){var t,n,r,o,a,i=e[0]/255,l=e[1]/255,s=e[2]/255,c=Math.max(i,l,s),u=c-Math.min(i,l,s),f=function(e){return(c-e)/6/u+.5};return 0===u?o=a=0:(a=u/c,t=f(i),n=f(l),r=f(s),i===c?o=r-n:l===c?o=1/3+t-r:s===c&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*a,100*c]},r.rgb.hwb=function(e){var t=e[0],n=e[1],o=e[2];return[r.rgb.hsl(e)[0],1/255*Math.min(t,Math.min(n,o))*100,100*(o=1-1/255*Math.max(t,Math.max(n,o)))]},r.rgb.cmyk=function(e){var t,n=e[0]/255,r=e[1]/255,o=e[2]/255;return[100*((1-n-(t=Math.min(1-n,1-r,1-o)))/(1-t)||0),100*((1-r-t)/(1-t)||0),100*((1-o-t)/(1-t)||0),100*t]},r.rgb.keyword=function(e){var n=t[e];if(n)return n;var r,o,a,i=Infinity;for(var l in Oe)if(Oe.hasOwnProperty(l)){var s=(o=e,a=Oe[l],Math.pow(o[0]-a[0],2)+Math.pow(o[1]-a[1],2)+Math.pow(o[2]-a[2],2));s<i&&(i=s,r=l)}return r},r.keyword.rgb=function(e){return Oe[e]},r.rgb.xyz=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},r.rgb.lab=function(e){var t=r.rgb.xyz(e),n=t[0],o=t[1],a=t[2];return o/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(o=o>.008856?Math.pow(o,1/3):7.787*o+16/116)-16,500*(n-o),200*(o-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},r.hsl.rgb=function(e){var t,n,r,o,a,i=e[0]/360,l=e[1]/100,s=e[2]/100;if(0===l)return[a=255*s,a,a];t=2*s-(n=s<.5?s*(1+l):s+l-s*l),o=[0,0,0];for(var c=0;c<3;c++)(r=i+1/3*-(c-1))<0&&r++,r>1&&r--,o[c]=255*(a=6*r<1?t+6*(n-t)*r:2*r<1?n:3*r<2?t+(n-t)*(2/3-r)*6:t);return o},r.hsl.hsv=function(e){var t=e[0],n=e[1]/100,r=e[2]/100,o=n,a=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,o*=a<=1?a:2-a,[t,100*(0===r?2*o/(a+o):2*n/(r+n)),(r+n)/2*100]},r.hsv.rgb=function(e){var t=e[0]/60,n=e[1]/100,r=e[2]/100,o=Math.floor(t)%6,a=t-Math.floor(t),i=255*r*(1-n),l=255*r*(1-n*a),s=255*r*(1-n*(1-a));switch(r*=255,o){case 0:return[r,s,i];case 1:return[l,r,i];case 2:return[i,r,s];case 3:return[i,l,r];case 4:return[s,i,r];case 5:return[r,i,l]}},r.hsv.hsl=function(e){var t,n,r,o=e[0],a=e[1]/100,i=e[2]/100,l=Math.max(i,.01);return r=(2-a)*i,n=a*l,[o,100*(n=(n/=(t=(2-a)*l)<=1?t:2-t)||0),100*(r/=2)]},r.hwb.rgb=function(e){var t,n,r,o,a,i,l,s=e[0]/360,c=e[1]/100,u=e[2]/100,f=c+u;switch(f>1&&(c/=f,u/=f),r=6*s-(t=Math.floor(6*s)),0!=(1&t)&&(r=1-r),o=c+r*((n=1-u)-c),t){default:case 6:case 0:a=n,i=o,l=c;break;case 1:a=o,i=n,l=c;break;case 2:a=c,i=n,l=o;break;case 3:a=c,i=o,l=n;break;case 4:a=o,i=c,l=n;break;case 5:a=n,i=c,l=o}return[255*a,255*i,255*l]},r.cmyk.rgb=function(e){var t=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,e[0]/100*(1-r)+r)),255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},r.xyz.rgb=function(e){var t,n,r,o=e[0]/100,a=e[1]/100,i=e[2]/100;return n=-.9689*o+1.8758*a+.0415*i,r=.0557*o+-.204*a+1.057*i,t=(t=3.2406*o+-1.5372*a+-.4986*i)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(t=Math.min(Math.max(0,t),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},r.xyz.lab=function(e){var t=e[0],n=e[1],r=e[2];return n/=100,r/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(t-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},r.lab.xyz=function(e){var t,n,r;t=e[1]/500+(n=(e[0]+16)/116),r=n-e[2]/200;var o=Math.pow(n,3),a=Math.pow(t,3),i=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,t=a>.008856?a:(t-16/116)/7.787,r=i>.008856?i:(r-16/116)/7.787,[t*=95.047,n*=100,r*=108.883]},r.lab.lch=function(e){var t,n=e[0],r=e[1],o=e[2];return(t=360*Math.atan2(o,r)/2/Math.PI)<0&&(t+=360),[n,Math.sqrt(r*r+o*o),t]},r.lch.lab=function(e){var t,n=e[1];return t=e[2]/360*2*Math.PI,[e[0],n*Math.cos(t),n*Math.sin(t)]},r.rgb.ansi16=function(e){var t=e[0],n=e[1],o=e[2],a=1 in arguments?arguments[1]:r.rgb.hsv(e)[2];if(0===(a=Math.round(a/50)))return 30;var i=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return 2===a&&(i+=60),i},r.hsv.ansi16=function(e){return r.rgb.ansi16(r.hsv.rgb(e),e[2])},r.rgb.ansi256=function(e){var t=e[0],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},r.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];var n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},r.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}var n;return e-=16,[Math.floor(e/36)/5*255,Math.floor((n=e%36)/6)/5*255,n%6/5*255]},r.rgb.hex=function(e){var t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},r.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var n=t[0];3===t[0].length&&(n=n.split("").map((function(e){return e+e})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},r.rgb.hcg=function(e){var t,n=e[0]/255,r=e[1]/255,o=e[2]/255,a=Math.max(Math.max(n,r),o),i=Math.min(Math.min(n,r),o),l=a-i;return t=l<=0?0:a===n?(r-o)/l%6:a===r?2+(o-n)/l:4+(n-r)/l+4,t/=6,[360*(t%=1),100*l,100*(l<1?i/(1-l):0)]},r.hsl.hcg=function(e){var t,n=e[1]/100,r=e[2]/100,o=0;return(t=r<.5?2*n*r:2*n*(1-r))<1&&(o=(r-.5*t)/(1-t)),[e[0],100*t,100*o]},r.hsv.hcg=function(e){var t=e[2]/100,n=e[1]/100*t,r=0;return n<1&&(r=(t-n)/(1-n)),[e[0],100*n,100*r]},r.hcg.rgb=function(e){var t=e[1]/100,n=e[2]/100;if(0===t)return[255*n,255*n,255*n];var r,o=[0,0,0],a=e[0]/360%1*6,i=a%1,l=1-i;switch(Math.floor(a)){case 0:o[0]=1,o[1]=i,o[2]=0;break;case 1:o[0]=l,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=i;break;case 3:o[0]=0,o[1]=l,o[2]=1;break;case 4:o[0]=i,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=l}return[255*(t*o[0]+(r=(1-t)*n)),255*(t*o[1]+r),255*(t*o[2]+r)]},r.hcg.hsv=function(e){var t=e[1]/100,n=t+e[2]/100*(1-t),r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},r.hcg.hsl=function(e){var t=e[1]/100,n=e[2]/100*(1-t)+.5*t,r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},r.hcg.hwb=function(e){var t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},r.hwb.hcg=function(e){var t=1-e[2]/100,n=t-e[1]/100,r=0;return n<1&&(r=(t-n)/(1-n)),[e[0],100*n,100*r]},r.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},r.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},r.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},r.gray.hsl=r.gray.hsv=function(e){return[0,0,e[0]]},r.gray.hwb=function(e){return[0,100,e[0]]},r.gray.cmyk=function(e){return[0,0,0,e[0]]},r.gray.lab=function(e){return[e[0],0,0]},r.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},r.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}}));function De(e,t){return function(n){return t(e(n))}}function Ne(e,t){for(var n=[t[e].parent,e],r=Re[t[e].parent][e],o=t[e].parent;t[o].parent;)n.unshift(t[o].parent),r=De(Re[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}var je={};Object.keys(Re).forEach((function(e){je[e]={},Object.defineProperty(je[e],"channels",{value:Re[e].channels}),Object.defineProperty(je[e],"labels",{value:Re[e].labels});var t=function(e){for(var t=function(e){var t=function(){for(var e={},t=Object.keys(Re),n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}(),n=[e];for(t[e].distance=0;n.length;)for(var r=n.pop(),o=Object.keys(Re[r]),a=o.length,i=0;i<a;i++){var l=o[i],s=t[l];-1===s.distance&&(s.distance=t[r].distance+1,s.parent=r,n.unshift(l))}return t}(e),n={},r=Object.keys(t),o=r.length,a=0;a<o;a++){var i=r[a];null!==t[i].parent&&(n[i]=Ne(i,t))}return n}(e);Object.keys(t).forEach((function(n){var r=t[n];je[e][n]=function(e){var t=function(t){if(null==t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var n=e(t);if("object"==typeof n)for(var r=n.length,o=0;o<r;o++)n[o]=Math.round(n[o]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(r),je[e][n].raw=function(e){var t=function(t){return null==t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)}))}));var Ie=je,Fe=[].slice,_e=["keyword","gray","hex"],Be={};Object.keys(Ie).forEach((function(e){Be[Fe.call(Ie[e].labels).sort().join("")]=e}));var Ye={};function He(e,t){if(!(this instanceof He))return new He(e,t);if(t&&t in _e&&(t=null),t&&!(t in Ie))throw new Error("Unknown model: "+t);var n,r;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof He)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if("string"==typeof e){var o=Pe.get(e);if(null===o)throw new Error("Unable to parse color from string: "+e);this.model=o.model,this.color=o.value.slice(0,r=Ie[this.model].channels),this.valpha="number"==typeof o.value[r]?o.value[r]:1}else if(e.length){this.model=t||"rgb";var a=Fe.call(e,0,r=Ie[this.model].channels);this.color=Ge(a,r),this.valpha="number"==typeof e[r]?e[r]:1}else if("number"==typeof e)e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;var i=Object.keys(e);"alpha"in e&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);var l=i.sort().join("");if(!(l in Be))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=Be[l];var s=Ie[this.model].labels,c=[];for(n=0;n<s.length;n++)c.push(e[s[n]]);this.color=Ge(c)}if(Ye[this.model])for(r=Ie[this.model].channels,n=0;n<r;n++){var u=Ye[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function Xe(e,t,n){return(e=Array.isArray(e)?e:[e]).forEach((function(e){(Ye[e]||(Ye[e]=[]))[t]=n})),e=e[0],function(r){var o;return arguments.length?(n&&(r=n(r)),(o=this[e]()).color[t]=r,o):(o=this[e]().color[t],n&&(o=n(o)),o)}}function Ve(e){return function(t){return Math.max(0,Math.min(e,t))}}function qe(e){return Array.isArray(e)?e:[e]}function Ge(e,t){for(var n=0;n<t;n++)"number"!=typeof e[n]&&(e[n]=0);return e}He.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var t=this.model in Pe.to?this:this.rgb(),n=1===(t=t.round("number"==typeof e?e:1)).valpha?t.color:t.color.concat(this.valpha);return Pe.to[t.model](n)},percentString:function(e){var t=this.rgb().round("number"==typeof e?e:1),n=1===t.valpha?t.color:t.color.concat(this.valpha);return Pe.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},t=Ie[this.model].channels,n=Ie[this.model].labels,r=0;r<t;r++)e[n[r]]=this.color[r];return 1!==this.valpha&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,1!==this.valpha&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,1!==this.valpha&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new He(this.color.map(function(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new He(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:Xe("rgb",0,Ve(255)),green:Xe("rgb",1,Ve(255)),blue:Xe("rgb",2,Ve(255)),hue:Xe(["hsl","hsv","hsl","hwb","hcg"],0,(function(e){return(e%360+360)%360})),saturationl:Xe("hsl",1,Ve(100)),lightness:Xe("hsl",2,Ve(100)),saturationv:Xe("hsv",1,Ve(100)),value:Xe("hsv",2,Ve(100)),chroma:Xe("hcg",1,Ve(100)),gray:Xe("hcg",2,Ve(100)),white:Xe("hwb",1,Ve(100)),wblack:Xe("hwb",2,Ve(100)),cyan:Xe("cmyk",0,Ve(100)),magenta:Xe("cmyk",1,Ve(100)),yellow:Xe("cmyk",2,Ve(100)),black:Xe("cmyk",3,Ve(100)),x:Xe("xyz",0,Ve(100)),y:Xe("xyz",1,Ve(100)),z:Xe("xyz",2,Ve(100)),l:Xe("lab",0,Ve(100)),a:Xe("lab",1),b:Xe("lab",2),keyword:function(e){return arguments.length?new He(e):Ie[this.model].keyword(this.color)},hex:function(e){return arguments.length?new He(e):Pe.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity:function(){for(var e=this.rgb().color,t=[],n=0;n<e.length;n++){var r=e[n]/255;t[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast:function(e){var t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level:function(e){var t=this.contrast(e);return t>=7.1?"AAA":t>=4.5?"AA":""},isDark:function(){var e=this.rgb().color;return(299*e[0]+587*e[1]+114*e[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten:function(e){var t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken:function(e){var t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate:function(e){var t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate:function(e){var t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten:function(e){var t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken:function(e){var t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale:function(){var e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return He.rgb(t,t,t)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var t=this.hsl(),n=t.color[0];return t.color[0]=n=(n=(n+e)%360)<0?360+n:n,t},mix:function(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var n=e.rgb(),r=this.rgb(),o=void 0===t?.5:t,a=2*o-1,i=n.alpha()-r.alpha(),l=((a*i==-1?a:(a+i)/(1+a*i))+1)/2,s=1-l;return He.rgb(l*n.red()+s*r.red(),l*n.green()+s*r.green(),l*n.blue()+s*r.blue(),n.alpha()*o+r.alpha()*(1-o))}},Object.keys(Ie).forEach((function(e){if(-1===_e.indexOf(e)){var t=Ie[e].channels;He.prototype[e]=function(){if(this.model===e)return new He(this);if(arguments.length)return new He(arguments,e);var n="number"==typeof arguments[t]?t:this.valpha;return new He(qe(Ie[this.model][e].raw(this.color)).concat(n),e)},He[e]=function(n){return"number"==typeof n&&(n=Ge(Fe.call(arguments),t)),new He(n,e)}}}));var Ue=He,We=function(){return(We=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function ze(e,t){return Object.fromEntries(Object.entries(e).map(t))}function Ke(e,t,n){var r;void 0===t&&(t="node"),void 0===n&&(n=0);var o="".concat(t,"-").concat(n);return We(We({},e),{id:o,branchset:(null===(r=e.branchset)||void 0===r?void 0:r.map((function(e,t){return Ke(e,"".concat(o,"-").concat(t),n+1)})))||[]})}function Qe(e,t){return ze(e,(function(e){return[e[0],t.palette.getContrastText(Ue(e[1]).hex())]}))}var Je=ze({clustal:{G:"orange",P:"orange",S:"orange",T:"orange",H:"red",K:"red",R:"red",F:"blue",W:"blue",Y:"blue",I:"green",L:"green",M:"green",V:"green"},lesk:{G:"orange",A:"orange",S:"orange",T:"orange",C:"green",V:"green",I:"green",L:"green",P:"green",F:"green",Y:"green",M:"green",W:"green",N:"magenta",Q:"magenta",H:"magenta",D:"red",E:"red",K:"blue",R:"blue"},maeditor:{A:"lightgreen",G:"lightgreen",C:"green",D:"darkgreen",E:"darkgreen",N:"darkgreen",Q:"darkgreen",I:"blue",L:"blue",M:"blue",V:"blue",F:"#c8a2c8",W:"#c8a2c8",Y:"#c8a2c8",H:"darkblue",K:"orange",R:"orange",P:"pink",S:"red",T:"red"},percent_identity_dynamic:{},flower:{A:"#b18a51",C:"#ff5701",D:"#01a578",E:"#2da0a1",F:"#fa559d",G:"#b1c23c",H:"#0194f9",I:"#f27663",K:"#7fc3d7",L:"#df6e75",M:"#fe9daf",N:"#0bcec6",P:"#4fa32a",Q:"#7295ae",R:"#83bff1",S:"#b4bd9b",T:"#d2b576",V:"#fd997b",W:"#ff2ded",Y:"#c96ecf"},rainbow_dna:{A:"#3737f5",C:"#37f537",G:"#f5f537",T:"#f53737",U:"#f53737"},clustalx_protein:{A:"#197fe5",C:"#e57f7f",D:"#cc4ccc",E:"#cc4ccc",F:"#197fe5",G:"#e5994c",H:"#19b2b2",I:"#197fe5",K:"#e53319",L:"#197fe5",M:"#197fe5",N:"#19cc19",P:"#cccc00",Q:"#19cc19",R:"#e53319",S:"#19cc19",T:"#19cc19",V:"#197fe5",W:"#197fe5",Y:"#19b2b2"},clustalx_protein_dynamic:{},clustalx_dna:{A:"#e53319",C:"#197fe5",G:"#e5994c",T:"#19cc19",U:"#19cc19"},jalview_buried:{A:"#00a35c",R:"#00fc03",N:"#00eb14",D:"#00eb14",C:"#0000ff",Q:"#00f10e",E:"#00f10e",G:"#009d62",H:"#00d52a",I:"#0054ab",L:"#007b84",K:"#00ff00",M:"#009768",F:"#008778",P:"#00e01f",S:"#00d52a",T:"#00db24",W:"#00a857",Y:"#00e619",V:"#005fa0",B:"#00eb14",X:"#00b649",Z:"#00f10e"},jalview_hydrophobicity:{A:"#ad0052",R:"#0000ff",N:"#0c00f3",D:"#0c00f3",C:"#c2003d",Q:"#0c00f3",E:"#0c00f3",G:"#6a0095",H:"#1500ea",I:"#ff0000",L:"#ea0015",K:"#0000ff",M:"#b0004f",F:"#cb0034",P:"#4600b9",S:"#5e00a1",T:"#61009e",W:"#5b00a4",Y:"#4f00b0",V:"#f60009",B:"#0c00f3",X:"#680097",Z:"#0c00f3"},jalview_prophelix:{A:"#e718e7",R:"#6f906f",N:"#1be41b",D:"#778877",C:"#23dc23",Q:"#926d92",E:"#ff00ff",G:"#00ff00",H:"#758a75",I:"#8a758a",L:"#ae51ae",K:"#a05fa0",M:"#ef10ef",F:"#986798",P:"#00ff00",S:"#36c936",T:"#47b847",W:"#8a758a",Y:"#21de21",V:"#857a85",B:"#49b649",X:"#758a75",Z:"#c936c9"},jalview_propstrand:{A:"#5858a7",R:"#6b6b94",N:"#64649b",D:"#2121de",C:"#9d9d62",Q:"#8c8c73",E:"#0000ff",G:"#4949b6",H:"#60609f",I:"#ecec13",L:"#b2b24d",K:"#4747b8",M:"#82827d",F:"#c2c23d",P:"#2323dc",S:"#4949b6",T:"#9d9d62",W:"#c0c03f",Y:"#d3d32c",V:"#ffff00",B:"#4343bc",X:"#797986",Z:"#4747b8"},jalview_propturn:{A:"#2cd3d3",R:"#708f8f",N:"#ff0000",D:"#e81717",C:"#a85757",Q:"#3fc0c0",E:"#778888",G:"#ff0000",H:"#708f8f",I:"#00ffff",L:"#1ce3e3",K:"#7e8181",M:"#1ee1e1",F:"#1ee1e1",P:"#f60909",S:"#e11e1e",T:"#738c8c",W:"#738c8c",Y:"#9d6262",V:"#07f8f8",B:"#f30c0c",X:"#7c8383",Z:"#5ba4a4"},jalview_taylor:{A:"#ccff00",R:"#0000ff",N:"#cc00ff",D:"#ff0000",C:"#ffff00",Q:"#ff00cc",E:"#ff0066",G:"#ff9900",H:"#0066ff",I:"#66ff00",L:"#33ff00",K:"#6600ff",M:"#00ff00",F:"#00ff66",P:"#ffcc00",S:"#ff3300",T:"#ff6600",W:"#00ccff",Y:"#00ffcc",V:"#99ff00"},jalview_zappo:{A:"#ffafaf",R:"#6464ff",N:"#00ff00",D:"#ff0000",C:"#ffff00",Q:"#00ff00",E:"#ff0000",G:"#ff00ff",H:"#6464ff",I:"#ffafaf",L:"#ffafaf",K:"#6464ff",M:"#ffafaf",F:"#ffc800",P:"#ff00ff",S:"#00ff00",T:"#00ff00",W:"#ffc800",Y:"#ffc800",V:"#ffafaf"},cinema:{H:"blue",K:"blue",R:"blue",D:"red",E:"red",S:"green",T:"green",N:"green",Q:"green",A:"white",V:"white",L:"white",I:"white",M:"white",F:"magenta",W:"magenta",Y:"magenta",P:"brown",G:"brown",C:"yellow",B:"gray",Z:"gray",X:"gray","-":"gray",".":"gray"}},(function(e){return[e[0],ze(e[1],(function(e){return[e[0],Ue(e[1]).hex()]}))]}));function $e(e,t,n,r){var o=Object.values(e).reduce((function(e,t){return e+t}),0),a=t.columns[n][r],i=e.W,l=void 0===i?0:i,s=e.L,c=void 0===s?0:s,u=e.V,f=void 0===u?0:u,h=e.I,d=void 0===h?0:h,m=e.M,p=void 0===m?0:m,g=e.A,v=void 0===g?0:g,b=e.F,y=void 0===b?0:b,w=e.C,E=void 0===w?0:w,S=e.H,M=void 0===S?0:S,x=e.P,A=void 0===x?0:x,k=e.R,L=void 0===k?0:k,T=e.K,C=void 0===T?0:T,P=e.Q,O=void 0===P?0:P,R=e.E,D=void 0===R?0:R,N=e.D,j=void 0===N?0:N,I=e.T,F=void 0===I?0:I,_=e.S,B=void 0===_?0:_,Y=e.G,H=e.Y,X=void 0===H?0:H,V=e.N,q=l+c+f+d+p+v+y+E+M+A+X,G=C+L,U=O+D;return q/o>.6&&("W"===a||"L"===a||"V"===a||"A"===a||"I"===a||"M"===a||"F"===a||"C"===a)?"rgb(128,179,230)":"K"!==a&&"R"!==a||!(G/o>.6||C/o>.8||L/o>.8||O/o>.8)?"E"===a&&(G/o>.6||U/o>.5||D/o>.8||O/o>.8||j/o>.8)?"rgb(192, 72, 192)":"D"===a&&(G/o>.6||(D+j)/o>.5||C/o>.8||L/o>.8||O/o>.8)?"rgb(204, 77, 204)":"N"===a&&((void 0===V?0:V)/o>.5||X/o>.85)||"Q"===a&&(G/o>.6||U/o>.6||O/o>.85||D/o>.85||C/o>.85||L/o>.85)?"#8f8":"S"!==a&&"T"!==a||!(q/o>.6||(F+B)/o>.5||B/o>.85||F/o>.85)?"C"===a&&E/o>.85?"rgb(240, 128, 128)":"G"===a&&(void 0===Y?0:Y)/o>0?"rgb(240, 144, 72)":"P"===a&&A/o>0?"rgb(204, 204, 0)":"H"!==a&&"Y"!==a||!(q/o>.6||l>.85||X>.85||v>.85||E>.85||A>.85||O>.85||y>.85||M>.85||d>.85||c>.85||p>.85||f>.85)?void 0:"rgb(26, 179, 179)":"rgb(26,204,26)":"#d88"}function Ze(e,t,n,r){for(var o=Object.values(e).reduce((function(e,t){return e+t}),0),a=t.columns[n][r],i=Object.entries(e),l=0,s="",c=0;c<i.length;c++)i[c][1]>l&&"-"!==i[c][0]&&(s=i[c][0],l=i[c][1]);var u=l/o,f="hsl(240, 30%, ".concat(100*Math.max(1-l/o/3,.3),"%)");if(u>.4&&a===s)return f}var et=o.observer((function(e){var t=e.model,n=e.offsetX,o=e.offsetY,i=t.MSA,l=t.colWidth,s=t.bgColor,c=t.columns,u=t.rowHeight,f=t.scrollY,h=t.scrollX,d=t.hierarchy,m=t.colorScheme,g=t.colorSchemeName,v=t.blockSize,b=t.highResScaleFactor,y=t.colStats,w=a.useTheme(),E=r.useMemo((function(){return Qe(m,w)}),[m,w]),S=r.useRef(null);return r.useEffect((function(){if(S.current){var e=S.current.getContext("2d");if(e){e.resetTransform(),e.scale(b,b),e.clearRect(0,0,v,v),e.translate(-n,u/2-o),e.textAlign="center",e.font=e.font.replace(/\d+px/,"".concat(Math.max(8,u-8),"px"));var r=d.leaves(),a=v,i=Math.max(0,Math.floor((o-u)/u)),f=Math.max(0,Math.ceil((o+a+u)/u)),h=Math.max(0,Math.floor(n/l)),p=Math.max(0,Math.ceil((n+a)/l)),w=r.slice(i,f);w.forEach((function(r){for(var o,a=r.x,i=r.data.name,f=null===(o=c[i])||void 0===o?void 0:o.slice(h,p),d=0;d<(null==f?void 0:f.length);d++){var v=f[d],b="clustalx_protein_dynamic"===g?$e(y[h+d],t,i,h+d):"percent_identity_dynamic"===g?Ze(y[h+d],t,i,h+d):m[v.toUpperCase()];if(s){var w=d*l+n-n%l;e.fillStyle=b||"white",e.fillRect(w,a-u,l,u)}}})),u>=10&&l>=u/2&&w.forEach((function(t){for(var r,o=t.x,a=null===(r=c[t.data.name])||void 0===r?void 0:r.slice(h,p),i=0;i<(null==a?void 0:a.length);i++){var f=a[i],d=m[f.toUpperCase()],g=E[f.toUpperCase()]||"black",v=i*l+n-n%l;e.fillStyle=s?g:d||"black",e.fillText(f,v+l/2,o-u/4)}}))}}}),[i,b,c,m,E,s,u,l,d,n,o,v]),p.createElement("canvas",{ref:S,onMouseMove:function(e){if(S.current){var r=S.current.getBoundingClientRect(),a=e.clientY-r.top;t.setMousePos(Math.floor((e.clientX-r.left+n)/l)+1,Math.floor((a+o)/u))}},onMouseLeave:function(){return t.setMousePos()},width:v*b,height:v*b,style:{position:"absolute",top:f+o,left:h+n,width:v,height:v}})})),tt=o.observer((function(e){var t=e.model,n=t.MSA,o=t.msaFilehandle,i=t.height,l=t.msaAreaWidth,s=t.blocks2d,c=r.useRef(null),u=r.useRef(!1),f=r.useRef(0),h=r.useRef(0),d=r.useRef(0),m=r.useRef(0),g=r.useState(!1),v=g[0],b=g[1];return r.useEffect((function(){var e=c.current;if(e)return e.addEventListener("wheel",n),function(){e.removeEventListener("wheel",n)};function n(e){var n=oe(e);f.current+=n.pixelX,h.current+=n.pixelY,u.current||(u.current=!0,requestAnimationFrame((function(){t.doScrollX(-f.current),t.doScrollY(-h.current),f.current=0,h.current=0,u.current=!1}))),e.preventDefault()}}),[t]),r.useEffect((function(){var e=function(){};function n(e){e.preventDefault();var n=e.clientX-d.current,r=e.clientY-m.current;(n||r)&&(u.current||(u.current=!0,window.requestAnimationFrame((function(){t.doScrollX(n),t.doScrollY(r),u.current=!1,d.current=e.clientX,m.current=e.clientY}))))}function r(){d.current=0,v&&b(!1)}return v&&(window.addEventListener("mousemove",n,!0),window.addEventListener("mouseup",r,!0),e=function(){window.removeEventListener("mousemove",n,!0),window.removeEventListener("mouseup",r,!0)}),e}),[t,v]),p.createElement("div",{ref:c,onMouseDown:function(e){var t=e.target;t.draggable||t.dataset.resizer||0===e.button&&(d.current=e.clientX,m.current=e.clientY,b(!0))},onMouseUp:function(e){e.preventDefault(),b(!1)},onMouseLeave:function(e){e.preventDefault()},style:{position:"relative",height:i,width:l,overflow:"hidden"}},n||o?n?s.map((function(e){var n=e[0],r=e[1];return p.createElement(et,{key:"".concat(n,"_").concat(r),model:t,offsetX:n,offsetY:r})})):p.createElement("div",{style:{position:"absolute",left:"50%",top:"50%"}},p.createElement(a.CircularProgress,null),p.createElement(a.Typography,null,"Loading...")):null)})),nt=a.makeStyles((function(){return{majorTickLabel:{fontSize:"11px"},majorTick:{stroke:"#555"},minorTick:{stroke:"#999"}}}));function rt(e){var t=e.start,n=e.end,r=e.bpPerPx,o=e.reversed,a=e.major,i=e.minor,l=nt(),s=function(e,t,n,r,o){var a;void 0===r&&(r=!0),void 0===o&&(o=!0);var i=function(e,t,n){for(var r=60*(e=Math.abs(e)),o=parseInt(Number(r).toExponential().split(/e/i)[1],10),a=Math.pow(10,o);a<r&&!((a*=2)>=r);)a*=2.5;var i=(a=Math.max(a,5))/e,l=0;return!(a%10)&&i/10>=15?l=a/10:!(a%5)&&i/5>=15?l=a/5:!(a%2)&&i/2>=15&&(l=a/2),{majorPitch:a,minorPitch:l}}(n),l=e,s=t;if(null===l||null===s)return[];n<0&&(l=(a=[s,l])[0],s=a[1]),l-=Math.abs(20*n),s+=Math.abs(20*n)+1;for(var c=i.minorPitch||i.majorPitch,u=0,f=[],h=Math.ceil(l/c)*c;h<s;h+=c)o&&h%(2*i.majorPitch)?(f.push({type:"minor",base:h-1,index:u}),u+=1):!r||h%(2*i.majorPitch)||(f.push({type:"major",base:h-1,index:u}),u+=1);return f}(t,n,r,a,i);return p.createElement(p.Fragment,null,s.map((function(e){var a=(o?n-e.base:e.base-t)/r;return p.createElement("line",{key:e.base,x1:a,x2:a,y1:11,y2:"major"===e.type?17:15,strokeWidth:1,stroke:"major"===e.type?"#555":"#999",className:"major"===e.type?l.majorTick:l.minorTick,"data-bp":e.base})})),s.filter((function(e){return"major"===e.type})).map((function(e){return p.createElement("text",{x:(o?n-e.base:e.base-t)/r,y:10,key:"label-".concat(e.base),textAnchor:"middle",style:{fontSize:"11px"},className:l.majorTickLabel},function e(t){return t<999?String(t):"".concat(e(~~(t/1e3)),",").concat("00".concat(~~(t%1e3)).substr(-3,3))}(e.base+1))})))}var ot=o.observer((function(e){var t=e.model,n=t.MSA,o=t.colWidth,a=t.msaAreaWidth,i=t.resizeHandleWidth,l=t.scrollX,s=t.blocksX,c=t.blockSize,u=r.useRef(null),f=s[0];return n?p.createElement("div",{ref:u,style:{position:"relative",width:a,cursor:"crosshair",overflow:"hidden",height:20,background:"#ccc"}},p.createElement("svg",{style:{width:s.length*c,position:"absolute",left:l+f+i,pointerEvents:"none"}},p.createElement(rt,{key:f,start:f/o,end:f/o+c*s.length/o,bpPerPx:1/o}))):null})),at=o.observer((function(e){return p.createElement("div",{style:{width:e.model.treeWidth}})})),it=o.observer((function(e){var t=e.model,n=e.onClose,o=e.open,i=t.colWidth,l=t.treeWidth,s=t.colorSchemeName,c=t.noTree,u=r.useState("".concat(t.rowHeight)),f=u[0],h=u[1],d=r.useState("".concat(i)),m=d[0],g=d[1],v=r.useState("".concat(l)),b=v[0],y=v[1];function w(e){return Number.isNaN(+e)||+e<0}var E=w(f),S=w(m),M=w(b);return p.createElement(a.Dialog,{onClose:function(){return n()},open:o},p.createElement(a.DialogTitle,null,"Settings"),p.createElement(a.DialogContent,null,p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.showBranchLen,onChange:function(){return t.toggleBranchLen()}}),label:"Show branch length"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.bgColor,onChange:function(){return t.toggleBgColor()}}),label:"Color background"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.drawNodeBubbles,onChange:function(){return t.toggleNodeBubbles()}}),label:"Draw node bubbles"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.drawTree,onChange:function(){return t.toggleDrawTree()}}),label:"Draw tree (if available)"}),p.createElement(a.FormControlLabel,{control:p.createElement(a.Checkbox,{checked:t.labelsAlignRight,onChange:function(){return t.toggleLabelsAlignRight()}}),label:"Labels align right (note: labels may draw over tree, but can adjust tree width or tree area width in UI)"}),p.createElement(a.TextField,{label:"Row height (px)",value:f,error:E,onChange:function(e){return h(e.target.value)}}),p.createElement(a.TextField,{label:"Column width (px)",value:m,error:S,onChange:function(e){return g(e.target.value)}}),p.createElement("br",null),c?null:p.createElement(a.TextField,{label:"Tree width (px)",value:b,error:M,onChange:function(e){return y(e.target.value)}}),p.createElement("br",null),p.createElement(a.TextField,{select:!0,label:"Color scheme",value:s,onChange:function(e){return t.setColorSchemeName(e.target.value)}},Object.keys(Je).map((function(e){return p.createElement(a.MenuItem,{key:e,value:e},e)}))),p.createElement(a.DialogActions,null,p.createElement(a.Button,{disabled:E||S||M,onClick:function(){t.setRowHeight(+f),t.setColWidth(+m),c||t.setTreeWidth(+b),n()},variant:"contained",color:"primary"},"Submit"))))}));function lt(e){var t=e.onClose;return p.createElement(a.Dialog,{onClose:function(){return t()},open:e.open},p.createElement(a.DialogTitle,null,"Biotite License"),p.createElement(a.DialogContent,null,p.createElement("pre",{style:{height:100,overflow:"auto"}},'\nCopyright 2017 - 2020, The Biotite contributors\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation and/or\nother materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors\nmay be used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n ')))}function st(e){var t=e.onClose,n=e.open,o=r.useState(!1),i=o[1];return p.createElement(p.Fragment,null,p.createElement(lt,{onClose:function(){return i(!1)},open:o[0]}),p.createElement(a.Dialog,{onClose:function(){return t()},open:n},p.createElement(a.DialogTitle,null,"About this plugin"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"MSAView ","1.3.1"," (",p.createElement(a.Link,{href:"https://github.com/gmod/jbrowse-plugin-msaview"},"Github"),")"),p.createElement("ul",null,p.createElement("li",null,p.createElement(a.Typography,null,"We use some color schemes from the"," ",p.createElement(a.Link,{href:"https://github.com/biotite-dev/biotite"},"biotite")," ","project, and their license is reproduced"," ",p.createElement(a.Link,{onClick:function(){return i(!0)}},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this page for some information on jalview colorings"," ",p.createElement(a.Link,{href:"https://www.jalview.org/help/html/colourSchemes/"},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this page for some info on the clustal, cinema, maeditor, and lesk color schemes"," ",p.createElement(a.Link,{href:"http://www.bioinformatics.nl/~berndb/aacolour.html"},"here"))),p.createElement("li",null,p.createElement(a.Typography,null,"See this paper about the flower color scheme"," ",p.createElement(a.Link,{href:"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7245768/"},"here")))))))}var ct=o.observer((function(e){var t=e.onClose,n=e.model.alignmentDetails;return p.createElement(a.Dialog,{onClose:function(){return t()},open:e.open},p.createElement(a.DialogTitle,null,"Metadata"),p.createElement(a.DialogContent,null,p.createElement(c.Attributes,{attributes:n})))})),ut=o.observer((function(e){var t=e.model,n=e.onClose,r=t.tracks;return p.createElement(a.Dialog,{onClose:function(){return n()},open:e.open},p.createElement(a.DialogTitle,null,"Add track"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"Open relevant per-alignment tracks e.g. protein domains"),p.createElement(a.FormGroup,null,r.map((function(e){return p.createElement(a.FormControlLabel,{key:e.model.id,control:p.createElement(a.Checkbox,{checked:!t.turnedOffTracks.has(e.model.id),onChange:function(){t.toggleTrack(e.model.id)}}),label:e.model.name})}))),p.createElement(a.DialogActions,null,p.createElement(a.Button,{onClick:function(){return n()},variant:"contained",color:"primary"},"Close"))))})),ft=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"}),"FolderOpen");t.default=r}))),ht=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"}),"Settings");t.default=r}))),dt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help");t.default=r}))),mt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"}),"List");t.default=r}))),pt=o.observer((function(e){var t=e.model,n=t.mouseCol;return p.createElement("div",null,p.createElement(a.Typography,{display:"inline"},"Row name: ",t.mouseOverRowName),p.createElement("span",{style:{marginLeft:10}}),p.createElement(a.Typography,{display:"inline"},"Position: ",n))})),gt=o.observer((function(e){var t=e.model,n=r.useState(!1),o=n[0],i=n[1],l=r.useState(!1),s=l[0],c=l[1],u=r.useState(!1),f=u[0],h=u[1],d=r.useState(!1),m=d[0],g=d[1],v=t.currentAlignment,b=t.alignmentNames;return p.createElement("div",{style:{display:"flex"}},p.createElement(a.IconButton,{onClick:function(){t.setData({tree:"",msa:""}),t.setTreeFilehandle(void 0),t.setMSAFilehandle(void 0),t.setScrollY(0),t.setScrollX(0),t.setCurrentAlignment(0)}},p.createElement(ft,null)),p.createElement(a.IconButton,{onClick:function(){return i(!0)}},p.createElement(ht,null)),p.createElement(a.IconButton,{onClick:function(){return h(!0)}},p.createElement(U,null)),p.createElement(a.IconButton,{onClick:function(){return g(!0)}},p.createElement(mt,null)),o?p.createElement(it,{open:!0,model:t,onClose:function(){return i(!1)}}):null,s?p.createElement(st,{open:!0,onClose:function(){return c(!1)}}):null,f?p.createElement(ct,{open:!0,model:t,onClose:function(){return h(!1)}}):null,m?p.createElement(ut,{open:!0,model:t,onClose:function(){return g(!1)}}):null,b.length>0?p.createElement(a.Select,{native:!0,value:v,onChange:function(e){t.setCurrentAlignment(+e.target.value),t.setScrollX(0),t.setScrollY(0)}},b.map((function(e,t){return p.createElement("option",{key:"".concat(e,"-").concat(t),value:t},e)}))):null,p.createElement(pt,{model:t}),p.createElement("div",{style:{flex:1}}),p.createElement(a.IconButton,{onClick:function(){return c(!0)}},p.createElement(dt,null)))})),vt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M7 10l5 5 5-5z"}),"ArrowDropDown");t.default=r}))),bt={"text/plain":"Text","text/html":"Url",default:"Text"},yt=a.makeStyles((function(e){return{textArea:{padding:e.spacing(2),overflow:"auto",background:"#ddd",wordBreak:"break-word"}}})),wt=o.observer((function(e){var t=e.model,n=e.onClose,o=r.useState("Copy to clipboard"),i=o[0],l=o[1],s=yt();return p.createElement(a.Dialog,{open:!0,onClose:n,fullWidth:!0,maxWidth:"lg"},p.createElement(a.DialogTitle,null,"Track info - ",t.name),p.createElement(a.DialogContent,null,p.createElement(a.Button,{variant:"contained",color:"primary",onClick:function(){(function(e,t){var n,r,o,a,i,l;t||(t={}),n=t.debug||!1;try{if(o=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}}(),a=document.createRange(),i=document.getSelection(),(l=document.createElement("span")).textContent=e,l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",(function(r){r.stopPropagation(),t.format&&(r.preventDefault(),void 0===r.clipboardData?(n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData(),window.clipboardData.setData(bt[t.format]||bt.default,e)):(r.clipboardData.clearData(),r.clipboardData.setData(t.format,e))),t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(l),a.selectNodeContents(l),i.addRange(a),!document.execCommand("copy"))throw new Error("copy command was unsuccessful")}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData)}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),r=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(r,e)}}finally{i&&("function"==typeof i.removeRange?i.removeRange(a):i.removeAllRanges()),l&&document.body.removeChild(l),o()}})(t.data),l("Copied!"),setTimeout((function(){l("Copy to clipboard")}),300)}},i),p.createElement("pre",{className:s.textArea},t.data)),p.createElement(a.DialogActions,null,p.createElement(a.Button,{variant:"contained",onClick:n,color:"secondary"},"Close")))})),Et=a.makeStyles((function(){return{button:{padding:0}}})),St=o.observer((function(e){var t=e.model,n=e.track,o=r.useState(),i=o[0],l=o[1],s=r.useState(!1),c=s[0],u=s[1],f=t.rowHeight,h=t.treeAreaWidth,d=n.height,m=n.model.name,g=Et(),v=Math.max(8,f-8);return p.createElement("div",{style:{width:h,height:d,flexShrink:0,textAlign:"right",fontSize:v}},m,p.createElement(a.IconButton,{className:g.button,style:{width:v,height:v},onClick:function(e){l(e.target)}},p.createElement(vt,null)),i?p.createElement(a.Menu,{anchorEl:i,transitionDuration:0,open:!0,onClose:function(){l(void 0)}},p.createElement(a.MenuItem,{dense:!0,onClick:function(){t.toggleTrack(n.model.id),l(void 0)}},"Close"),p.createElement(a.MenuItem,{dense:!0,onClick:function(){u(!0),l(void 0)}},"Get info")):null,c?p.createElement(wt,{model:n.model,onClose:function(){return u(!1)}}):null)})),Mt=o.observer((function(e){var t=e.model,n=e.track,o=t.resizeHandleWidth,a=n.model.height,i=r.useRef(null),l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){var e=i.current;if(e)return e.addEventListener("wheel",n),function(){e.removeEventListener("wheel",n)};function n(e){var n=oe(e);s.current+=n.pixelX,l.current||(l.current=!0,requestAnimationFrame((function(){t.doScrollX(-s.current),s.current=0,l.current=!1}))),e.preventDefault()}}),[t]),p.createElement("div",{key:n.id,style:{display:"flex",height:a}},p.createElement(St,{model:t,track:n}),p.createElement("div",{style:{width:o,flexShrink:0}}),p.createElement("div",{ref:i},p.createElement(n.ReactComponent,{model:t,track:n})))})),xt=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");t.default=r}))),At=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},kt=o.observer((function(e){var t=e.name,n=e.value,r=e.setValue,o=e.setName;return p.createElement("div",null,p.createElement(a.IconButton,{onClick:e.onDelete,style:{margin:10}},p.createElement(xt,null)),p.createElement(a.TextField,{value:t,onChange:function(e){return o(e.target.value)},label:"Key"}),p.createElement(a.TextField,{value:n,onChange:function(e){return r(e.target.value)},label:"Value"}))})),Lt=o.observer((function(e){var t=e.onClose,n=e.data,o=e.model,i=o.blanks,l=n.left,s=n.right,c=r.useState([["Name",""],["ID",""],["Note",""]]),u=c[0],f=c[1];return p.createElement(a.Dialog,{onClose:function(){return t()},open:!0},p.createElement(a.DialogTitle,null,"Create new region annotation"),p.createElement(a.DialogContent,null,p.createElement(a.Typography,null,"Do you want to add an annotation to the MSA at ",l,"..",s," ",i.length?" (gapped ".concat(o.getPos(l),"..").concat(o.getPos(s)):""),u.map((function(e,t){return p.createElement(kt,{key:t,name:e[0],value:e[1],setValue:function(e){var n=At([],u,!0);n[t][1]=e,f(n)},setName:function(e){var n=At([],u,!0);n[t][0]=e,f(n)},onDelete:function(){u.splice(t,1),f(At([],u,!0))}})})),p.createElement(a.Button,{onClick:function(){f(At(At([],u,!0),[["",""]],!1))}},"Add row"),p.createElement(a.DialogActions,null,p.createElement(a.Button,{onClick:function(){var e;o.addAnnotation(l,s,(e={},u.forEach((function(t){var n=t[0],r=t[1];e[n]||(e[n]=[]),e[n].push(r)})),e)),t()},variant:"contained",color:"primary"},"Submit"),p.createElement(a.Button,{variant:"contained",color:"secondary",onClick:function(){return t()}},"Cancel"))))})),Tt=o.observer((function(e){var t=e.model,n=t.resizeHandleWidth,o=r.useState(!1),a=o[0],i=o[1],l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){function e(e){e.preventDefault();var n=e.clientX;if(0===s.current)s.current=e.clientX;else{var r=n-s.current;r&&(l.current||(l.current=!0,window.requestAnimationFrame((function(){t.setTreeAreaWidth(t.treeAreaWidth+r),l.current=!1,s.current=e.clientX}))))}}function n(){s.current=0,a&&i(!1)}return a?(document.addEventListener("mousemove",e,!0),document.addEventListener("mouseup",n,!0),function(){document.removeEventListener("mousemove",e,!0),document.removeEventListener("mouseup",n,!0)}):function(){}}),[a,t]),p.createElement("div",null,p.createElement("div",{onMouseDown:function(){return i(!0)},style:{cursor:"ew-resize",height:"100%",width:n,background:"rgba(200,200,200)",position:"relative"}}))})),Ct=o.observer((function(e){var t=e.model,n=t.resizeHandleWidth,o=r.useState(!1),a=o[0],i=o[1],l=r.useRef(!1),s=r.useRef(0);return r.useEffect((function(){function e(e){e.preventDefault();var n=e.clientY;if(0===s.current)s.current=e.clientY;else{var r=n-s.current;r&&(l.current||(l.current=!0,window.requestAnimationFrame((function(){t.setHeight(t.height+r),l.current=!1,s.current=e.clientY}))))}}function n(){s.current=0,a&&i(!1)}return a?(document.addEventListener("mousemove",e,!0),document.addEventListener("mouseup",n,!0),function(){document.removeEventListener("mousemove",e,!0),document.removeEventListener("mouseup",n,!0)}):function(){}}),[a,t]),p.createElement("div",null,p.createElement("div",{onMouseDown:function(){return i(!0)},style:{cursor:"ns-resize",width:"100%",height:n,background:"rgba(200,200,200)",position:"relative"}}))})),Pt=function(){return(Pt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ot=o.observer((function(e){var t=e.model,n=r.useRef(null),o=t.height,a=t.width,i=t.treeAreaWidth,l=t.resizeHandleWidth,s=t.scrollX,c=t.mouseCol,u=t.colWidth;return r.useEffect((function(){if(n.current){var e=n.current.getContext("2d");if(e&&(e.resetTransform(),e.clearRect(0,0,a,o),void 0!==c)){var t=(c-1)*u+s+i+l;e.fillStyle="rgba(100,100,100,0.5)",e.fillRect(t,0,u,o)}}}),[c,u,s,o,l,i,a]),p.createElement("canvas",{ref:n,width:a,height:o,style:{position:"absolute",top:0,left:0,width:a,height:o,zIndex:1e3,pointerEvents:"none"}})})),Rt=o.observer((function(e){var t=e.model,n=t.treeAreaWidth,r=t.turnedOnTracks;return p.createElement("div",null,t.initialized?t.done?p.createElement("div",null,p.createElement("div",{style:{height:t.height,overflow:"hidden"}},p.createElement(gt,{model:t}),p.createElement("div",null,p.createElement("div",{style:{position:"relative"}},p.createElement("div",{style:{display:"flex"}},p.createElement("div",{style:{flexShrink:0,width:n}},p.createElement(at,{model:t})),p.createElement(K,{model:t,ControlComponent:p.createElement(ot,{model:t})})),null==r?void 0:r.map((function(e){return p.createElement(Mt,{key:e.model.id,model:t,track:e})})),p.createElement("div",{style:{display:"flex"}},p.createElement("div",{style:{flexShrink:0,width:n}},p.createElement(Le,{model:t})),p.createElement(Tt,{model:t}),p.createElement(tt,{model:t}),p.createElement(Ot,{model:t}))))),p.createElement(Ct,{model:t})):p.createElement(a.Typography,{variant:"h4"},"Loading..."):p.createElement(x,{model:t}),t.DialogComponent?p.createElement(t.DialogComponent,Pt({},t.DialogProps||{},{onClose:function(){t.setDialogComponent(void 0,void 0)}})):null,t.annotPos?p.createElement(Lt,{data:t.annotPos,model:t,onClose:function(){return t.clearAnnotPos()}}):null)}));function Dt(e,t){return e.parent===t.parent?1:2}function Nt(e,t){return e+t.x}function jt(e,t){return Math.max(e,t.y)}function It(e){var t=0,n=e.children,r=n&&n.length;if(r)for(;--r>=0;)t+=n[r].value;else t=1;e.value=t}function Ft(e,t){e instanceof Map?(e=[void 0,e],void 0===t&&(t=Bt)):void 0===t&&(t=_t);for(var n,r,o,a,i,l=new Xt(e),s=[l];n=s.pop();)if((o=t(n.data))&&(i=(o=Array.from(o)).length))for(n.children=o,a=i-1;a>=0;--a)s.push(r=o[a]=new Xt(o[a])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(Ht)}function _t(e){return e.children}function Bt(e){return Array.isArray(e)?e[1]:null}function Yt(e){void 0!==e.data.value&&(e.value=e.data.value),e.data=e.data.data}function Ht(e){var t=0;do{e.height=t}while((e=e.parent)&&e.height<++t)}function Xt(e){this.data=e,this.depth=this.height=0,this.parent=null}Xt.prototype=Ft.prototype={constructor:Xt,count:function(){return this.eachAfter(It)},each:function(e,t){let n=-1;for(const r of this)e.call(t,r,++n,this);return this},eachAfter:function(e,t){for(var n,r,o,a=this,i=[a],l=[],s=-1;a=i.pop();)if(l.push(a),n=a.children)for(r=0,o=n.length;r<o;++r)i.push(n[r]);for(;a=l.pop();)e.call(t,a,++s,this);return this},eachBefore:function(e,t){for(var n,r,o=this,a=[o],i=-1;o=a.pop();)if(e.call(t,o,++i,this),n=o.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(e,t){let n=-1;for(const r of this)if(e.call(t,r,++n,this))return r},sum:function(e){return this.eachAfter((function(t){for(var n=+e(t.data)||0,r=t.children,o=r&&r.length;--o>=0;)n+=r[o].value;t.value=n}))},sort:function(e){return this.eachBefore((function(t){t.children&&t.children.sort(e)}))},path:function(e){for(var t=this,n=function(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),o=null;for(e=n.pop(),t=r.pop();e===t;)o=e,e=n.pop(),t=r.pop();return o}(t,e),r=[t];t!==n;)r.push(t=t.parent);for(var o=r.length;e!==n;)r.splice(o,0,e),e=e.parent;return r},ancestors:function(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t},descendants:function(){return Array.from(this)},leaves:function(){var e=[];return this.eachBefore((function(t){t.children||e.push(t)})),e},links:function(){var e=this,t=[];return e.each((function(n){n!==e&&t.push({source:n.parent,target:n})})),t},copy:function(){return Ft(this).eachBefore(Yt)},[Symbol.iterator]:function*(){var e,t,n,r,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(yield o,t=o.children)for(n=0,r=t.length;n<r;++n)a.push(t[n])}while(a.length)}};var Vt=k((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o},e.exports.default=e.exports,e.exports.__esModule=!0}));A(Vt);var qt=k((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o=Vt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.default=e.exports,e.exports.__esModule=!0}));A(qt);var Gt,Ut,Wt,zt=1,Kt=function(){return(zt=(9301*zt+49297)%233280)/233280},Qt=function(e){zt=e},Jt="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function $t(){Wt=!1}function Zt(e){if(e){if(e!==Gt){if(e.length!==Jt.length)throw new Error("Custom alphabet for shortid must be "+Jt.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,n){return t!==n.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+Jt.length+" unique characters. These characters were not unique: "+t.join(", "));Gt=e,$t()}}else Gt!==Jt&&(Gt=Jt,$t())}function en(){return Wt||(Wt=function(){Gt||Zt(Jt);for(var e,t=Gt.split(""),n=[],r=Kt();t.length>0;)r=Kt(),e=Math.floor(r*t.length),n.push(t.splice(e,1)[0]);return n.join("")}())}var tn,nn,rn={get:function(){return Gt||Jt},characters:function(e){return Zt(e),Gt},seed:function(e){Qt(e),Ut!==e&&($t(),Ut=e)},lookup:function(e){return en()[e]},shuffled:en},on="object"==typeof window&&(window.crypto||window.msCrypto),an=on&&on.getRandomValues?function(e){return on.getRandomValues(new Uint8Array(e))}:function(e){for(var t=[],n=0;n<e;n++)t.push(Math.floor(256*Math.random()));return t},ln=function(e,t,n){for(var r=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*r*n/t.length),a="";;)for(var i=e(o),l=o;l--;)if((a+=t[i[l]&r]||"").length===+n)return a},sn=function(e){for(var t,n=0,r="";!t;)r+=ln(an,rn.get(),1),t=e<Math.pow(16,n+1),n++;return r},cn=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+rn.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))},un=k((function(e){var t=0;function n(){return function(e){var t="",n=Math.floor(.001*(Date.now()-1567752802062));return n===nn?tn++:(tn=0,nn=n),t+=sn(7),t+=sn(e),tn>0&&(t+=sn(tn)),t+sn(n)}(t)}e.exports=n,e.exports.generate=n,e.exports.seed=function(t){return rn.seed(t),e.exports},e.exports.worker=function(n){return t=n,e.exports},e.exports.characters=function(e){return void 0!==e&&rn.characters(e),rn.shuffled()},e.exports.isValid=cn})),fn=k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.FileLocation=t.UriLocation=t.UriLocationRaw=t.BlobLocation=t.LocalPathLocation=t.Region=t.NoAssemblyRegion=t.PropTypes=t.ElementId=void 0;var n=L(qt),r=L(un),o=L(d),a=["baseUri"],i=v.types.optional(v.types.identifier,r.default.generate);t.ElementId=i;var l={Region:o.default.shape({refName:o.default.string.isRequired,start:o.default.number.isRequired,end:o.default.number.isRequired}),ConfigSchema:g.PropTypes.objectOrObservableObject,Feature:o.default.shape({get:o.default.func.isRequired,id:o.default.func.isRequired})};t.PropTypes=l;var s=v.types.model("NoAssemblyRegion",{refName:v.types.string,start:v.types.number,end:v.types.number,reversed:v.types.optional(v.types.boolean,!1)}).actions((function(e){return{setRefName:function(t){e.refName=t}}}));t.NoAssemblyRegion=s;var c=v.types.compose("Region",s,v.types.model({assemblyName:v.types.string}));t.Region=c;var u=v.types.model("LocalPathLocation",{localPath:v.types.string});t.LocalPathLocation=u;var f=v.types.model("BlobLocation",{name:v.types.string,blobId:v.types.string});t.BlobLocation=f;var h=v.types.model("UriLocation",{uri:v.types.string,baseUri:v.types.maybe(v.types.string)});t.UriLocationRaw=h;var m=v.types.snapshotProcessor(h,{postProcessor:function(e){var t=e.baseUri,r=(0,n.default)(e,a);return t?e:r}});t.UriLocation=m;var p=v.types.union(u,m,f);t.FileLocation=p}));A(fn);var hn=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=v.types.model("BaseView",{id:fn.ElementId,displayName:v.types.maybe(v.types.string)}).volatile((function(){return{width:800}})).views((function(){return{menuItems:function(){return[]}}})).actions((function(e){return{setDisplayName:function(t){e.displayName=t},setWidth:function(t){e.width=t}}}));t.default=n}))),dn=k((function(e){const t=function(){let e={gf:{},gc:{},gs:{},gr:{},seqname:[],seqdata:{}};return Object.keys(e).forEach(t=>this[t]=e[t]),this},n=/^# STOCKHOLM 1.0/,r=/^\/\/\s*$/,o=/^#=GF\s+(\S+)\s+(.*?)\s*$/,a=/^#=GC\s+(\S+)\s+(.*?)\s*$/,i=/^#=GS\s+(\S+)\s+(\S+)\s+(.*?)\s*$/,l=/^#=GR\s+(\S+)\s+(\S+)\s+(.*?)\s*$/,s=/^\s*(\S+)\s+(\S+)\s*$/,c=/\S/,u=e=>"(At line "+(e+1)+") ",f=e=>{throw new Error(e)},h=e=>console.warn(e),d=(e,d)=>{const m=(d=d||{}).strict?f:d.quiet?()=>null:h;let p=[],g=null;return e.split("\n").forEach((e,h)=>{const d=()=>{g||(m(u(h)+"No format header: # STOCKHOLM 1.0"),g=new t)};let v;n.test(e)?(g&&m(u(h)+"No format footer: //"),g=new t):r.test(e)?(g?p.push(g):m(u(h)+"No format header: # STOCKHOLM 1.0"),g=null):(v=o.exec(e))?(d(),g.gf[v[1]]=g.gf[v[1]]||[],g.gf[v[1]].push(v[2])):(v=a.exec(e))?(d(),g.gc[v[1]]=g.gc[v[1]]||"",g.gc[v[1]]+=v[2]):(v=i.exec(e))?(d(),g.gs[v[2]]=g.gs[v[2]]||{},g.gs[v[2]][v[1]]=g.gs[v[2]][v[1]]||[],g.gs[v[2]][v[1]].push(v[3])):(v=l.exec(e))?(d(),g.gr[v[2]]=g.gr[v[2]]||{},g.gr[v[2]][v[1]]=g.gr[v[2]][v[1]]||"",g.gr[v[2]][v[1]]+=v[3]):(v=s.exec(e))?(d(),g.seqdata[v[1]]||(g.seqdata[v[1]]="",g.seqname.push(v[1])),g.seqdata[v[1]]+=v[2]):c.test(e)&&f(u(h)+"Malformed line")}),g&&(m("Warning: no end line //"),p.push(g)),p};function m(e,t){for(;e.length<t;)e=" "+e;return e}function p(e,t){for(;e.length<t;)e+=" ";return e}t.prototype.rows=function(){return this.seqname.length},t.prototype.columns=function(){let e=0;return this.seqname.forEach(t=>{e=Math.max(e,this.seqdata[t].length)}),Object.keys(this.gr).forEach(t=>Object.keys(this.gr[t]).forEach(n=>{e=Math.max(e,this.gr[t][n].length)})),e},t.prototype.allNames=function(){let e={},t=[],n=n=>{e[n]||(e[n]=!0,t.push(n))},r=e=>e.forEach(n);return r(this.seqname),r(Object.keys(this.seqdata)),Object.keys(this.gr).forEach(e=>r(Object.keys(this.gr[e]))),Object.keys(this.gs).forEach(e=>r(Object.keys(this.gs[e]))),t},t.prototype.allTags=function(){let e={};const t=t=>Object.keys(t).forEach(t=>e[t]=!0);return t(this.gc),t(this.gf),t(this.gr),t(this.gs),Object.keys(e).sort()},t.prototype.addRow=function(e,t){return this.seqdata[e]&&f("Duplicate row name"),this.seqname.push(e),this.seqdata[e]=t||"",this},t.prototype.deleteRow=function(e){return this.seqdata[e]||f("Row not found"),this.seqname=this.seqname.filter(t=>t!==e),delete this.seqdata[e],this},t.prototype.toString=function(e){e=e||{width:80,indentNames:!1};const t=this.allNames(),n=this.columns(),r=Math.max.apply(null,t.map(e=>e.length).concat([0])),o=Math.max.apply(null,this.allTags().map(e=>e.length).concat([0])),a=o?o+6:0,i=e.width?Math.max(1,e.width-r-a-1):n,l=e.indentNames?m:p,s=e.indentNames?(e,t)=>m(e,o)+" "+m(t,r):(e,t)=>p(e+" "+t,o+r+1);let c=[0];for(let e=i;e<n;e+=i)c.push(e);return"# STOCKHOLM 1.0\n"+Object.keys(this.gf).sort().map(e=>this.gf[e].map(t=>"#=GF "+l(e,o)+" "+t+"\n").join("")).join("")+Object.keys(this.gs).sort().map(e=>Object.keys(this.gs[e]).map(t=>this.gs[e][t].map(n=>"#=GS "+s(e,t)+" "+n+"\n").join("")).join("")).join("")+c.map(e=>Object.keys(this.gc).sort().map(t=>"#=GC "+l(t,o)+function(e){return m("",e)}(r+2)+this.gc[t].substr(e,i)+"\n").join("")+t.map(t=>Object.keys(this.gr).filter(e=>this.gr[e][t]).sort().map(n=>"#=GR "+s(n,t)+" "+this.gr[n][t].substr(e,i)+"\n").join("")+(this.seqdata[t]?l(t,r+a)+" "+this.seqdata[t].substr(e,i)+"\n":"")).join("")).join("\n")+"//\n"},t.prototype.toFasta=function(e){e=e||{width:80};const t=this.columns(),n=e.width||t;let r=[0];for(let e=n;e<t;e+=n)r.push(e);return this.allNames().map(e=>this.seqdata[e]?">"+e+"\n"+r.map(t=>this.seqdata[e].substr(t,n)+"\n").join(""):"").join("")},t.prototype.toRowList=function(e){return this.allNames().filter(e=>this.seqdata[e]).map(e=>[e,this.seqdata[e]])},e.exports={sniff:e=>n.test(e),validate:e=>{try{d(e,{strict:!0})}catch(e){return!1}return!0},parse:(e,t)=>{const n=d(e,t);return 0===n.length&&f("No alignments found"),n.length>1&&f("More than one alignment found"),n[0]},parseAll:d,fromSeqIndex:(e,n)=>{let r=new t;return(n=n||Object.keys(e)).forEach(t=>r.addRow(t,e[t])),r},fromRowList:e=>{let n=new t;return e.forEach(e=>n.addRow(e[0],e[1])),n},Stockholm:t}})),mn=k((function(e,t){function n(e){const t=e.match(/\(?(\d+(\.\d+)+)\)?/);return t&&t.length>1?t[1]:""}function r(e){let t=e.next();for(;!t.done&&""===t.value.trim();)t=e.next();return t.value}function o(e){const t=e.split(/\s+/),n=e.slice(t[0].length),r=t[0].length+n.indexOf(t[1]);return[r,r+t[1].length]}function a(e){let t=r(e);const n=[];let a="";if(!t)return;for(;t;)" "!==t[0]?n.push(t):a=t,t=e.next().value;const[i,l]=o(n[0]),s=n.map(e=>e.split(/\s+/)).map(e=>e[0]),c=n.map(e=>e.slice(i,l));let u=a.slice(i,l);const f=c[0].length-u.length;return f&&(u+=" ".repeat(f)),{ids:s,seqs:c,consensus:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.parseBlocks=t.parseBlock=t.getSeqBounds=t.getFirstNonEmptyLine=t.parseHeader=t.parseVersion=void 0,t.parseVersion=n,t.parseHeader=function(e){const t=["CLUSTAL","PROBCONS","MUSCLE","MSAPROBS","Kalign"];t.find(t=>e.startsWith(t))||console.warn(`${e} is not a known CLUSTAL header: ${t.join(",")}, proceeding but could indicate an issue`);const r=n(e);return{info:e,version:r}},t.getFirstNonEmptyLine=r,t.getSeqBounds=o,t.parseBlock=a,t.parseBlocks=function(e){let t;const n=a(e);if(void 0!==n)for(;t=a(e);){for(let e=0;e<t.seqs.length;e++)n.seqs[e]+=t.seqs[e];n.consensus+=t.consensus}return n}}));A(mn);var pn=k((function(e,t){function n(e){const t=mn.getFirstNonEmptyLine(e);if(!t)throw new Error("Empty file received");const n=mn.parseHeader(t),r=mn.parseBlocks(e);if(void 0===r)throw new Error("No blocks parsed");const o=r.seqs.map((e,t)=>({id:r.ids[t],seq:e})),{consensus:a}=r;if(a.length!=o[0].seq.length)throw new Error(`Consensus length != sequence length. Con ${a.length} seq ${o[0].seq.length}`);return{consensus:a,alns:o,header:n}}Object.defineProperty(t,"__esModule",{value:!0}),t.parse=t.parseIter=void 0,t.parseIter=n,t.parse=function(e){return n(e.split("\n")[Symbol.iterator]())}}));A(pn);var gn=pn.parse,vn=function(){function e(e){this.MSA=gn(e)}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getRow=function(e){var t;return null===(t=this.MSA.alns.find((function(t){return t.id===e})))||void 0===t?void 0:t.seq.split("")},e.prototype.getWidth=function(){return this.MSA.alns[0].seq.length},e.prototype.getDetails=function(){return this.MSA.header},e.prototype.getNames=function(){return this.MSA.alns.map((function(e){return e.id}))},e.prototype.getStructures=function(){return{}},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return[]},enumerable:!1,configurable:!0}),e.prototype.getTree=function(){return{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){return this.MSA.consensus},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){var e;return(null===(e=this.seqConsensus)||void 0===e?void 0:e.trim())?[{id:"seqConsensus",name:"Sequence consensus",data:this.seqConsensus,customColorScheme:{"*":"white",":":"grey",".":"darkgrey"," ":"black"}}]:[]},enumerable:!1,configurable:!0}),e}();function bn(e){for(var t=[],n={},r=e.split(/\s*(;|\(|\)|,|:)\s*/),o=0;o<r.length;o++){var a=r[o],i={};switch(a){case"(":n.branchset=[i],t.push(n),n=i;break;case",":t[t.length-1].branchset.push(i),n=i;break;case")":n=t.pop();break;case":":break;default:var l=r[o-1];")"===l||"("===l||","===l?n.name=a:":"===l&&(n.length=parseFloat(a))}}return n}var yn=function(){function e(e,t){var n=dn.parseAll(e);this.data=n,this.MSA=n[t]}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getRow=function(e){var t,n;return null===(n=null===(t=this.MSA)||void 0===t?void 0:t.seqdata[e])||void 0===n?void 0:n.split("")},e.prototype.getWidth=function(){var e,t=Object.keys(null===(e=this.MSA)||void 0===e?void 0:e.seqdata)[0];return this.getRow(t).length},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return this.data.map((function(e,t){var n;return(null===(n=e.gf.DE)||void 0===n?void 0:n[0])||"Alignment ".concat(t+1)}))},enumerable:!1,configurable:!0}),e.prototype.getDetails=function(){var e,t;return{General:this.MSA.gf,Accessions:null===(e=this.MSA.gs)||void 0===e?void 0:e.AC,Dbxref:null===(t=this.MSA.gs)||void 0===t?void 0:t.DR}},e.prototype.getRowDetails=function(e){var t,n;return{name:e,accession:null===(t=this.MSA.gs)||void 0===t?void 0:t.AC[e],dbxref:null===(n=this.MSA.gs)||void 0===n?void 0:n.DR[e]}},e.prototype.getNames=function(){return Object.keys(this.MSA.seqdata)},e.prototype.getSeqCoords=function(){},e.prototype.getStructures=function(){var e,t=/PDB; +(\S+) +(\S); ([0-9]+)-([0-9]+)/;return Object.entries((null===(e=this.MSA.gs)||void 0===e?void 0:e.DR)||{}).map((function(e){return[e[0],t.exec(e[1])]})).filter((function(e){return!!e[1]})).map((function(e){var t=e[1];return{id:e[0],pdb:t[1].toLowerCase(),chain:t[2],startPos:+t[3],endPos:+t[4]}})).reduce((function(e,t){var n=t.id,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["id"]);return e[n]||(e[n]=[]),e[n].push(r),e}),{})},e.prototype.getTree=function(){var e,t,n,r=null===(n=null===(t=null===(e=this.MSA)||void 0===e?void 0:e.gf)||void 0===t?void 0:t.NH)||void 0===n?void 0:n[0];return r?Ke(bn(r)):{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){var e;return null===(e=this.MSA.gc)||void 0===e?void 0:e.seq_cons},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){var e;return null===(e=this.MSA.gc)||void 0===e?void 0:e.SS_cons},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){return[{id:"seqConsensus",name:"Sequence consensus",data:this.seqConsensus,customColorScheme:{}},{id:"secondaryStruct",name:"Secondary-structure",data:this.secondaryStructureConsensus,customColorScheme:{">":"pink","<":"lightblue"}}]},enumerable:!1,configurable:!0}),e}(),wn=function(){function e(e){var t={},n="",r=/^>(\S+)/;e.split("\n").forEach((function(e){var o=r.exec(e);o?t[n=o[1]]="":n&&(t[n]=t[n]+e.replace(/[ \t]/g,""))})),this.MSA={seqdata:t}}return e.prototype.getMSA=function(){return this.MSA},e.prototype.getNames=function(){return Object.keys(this.MSA.seqdata)},e.prototype.getRow=function(e){var t,n;return null===(n=null===(t=this.MSA)||void 0===t?void 0:t.seqdata[e])||void 0===n?void 0:n.split("")},e.prototype.getWidth=function(){var e,t=Object.keys(null===(e=this.MSA)||void 0===e?void 0:e.seqdata)[0];return this.getRow(t).length},e.prototype.getStructures=function(){return{}},Object.defineProperty(e.prototype,"alignmentNames",{get:function(){return[]},enumerable:!1,configurable:!0}),e.prototype.getDetails=function(){return{}},e.prototype.getTree=function(){return{id:"root",noTree:!0,branchset:this.getNames().map((function(e){return{id:e,name:e}}))}},Object.defineProperty(e.prototype,"seqConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"secondaryStructureConsensus",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tracks",{get:function(){return[]},enumerable:!1,configurable:!0}),e}(),En=o.observer((function(e){var t=e.model,n=e.offsetX,o=t.blockSize,i=t.scrollX,l=t.bgColor,s=t.colWidth,c=t.rowHeight,u=t.highResScaleFactor,f=e.track.model,h=f.data,d=f.customColorScheme||t.colorScheme,m=a.useTheme(),g=r.useRef(null),v=r.useMemo((function(){return Qe(d,m)}),[d,m]);return r.useEffect((function(){if(g.current){var e=g.current.getContext("2d");if(e){e.resetTransform(),e.scale(u,u),e.clearRect(0,0,o,c),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,"".concat(Math.max(8,c-8),"px"));for(var t=Math.max(0,Math.floor(n/s)),r=Math.max(0,Math.ceil((n+o)/s)),a=null==h?void 0:h.slice(t,r),i=0;a&&i<a.length;i++){var f=a[i],m=d[f.toUpperCase()];if(l){var p=i*s+n-n%s;e.fillStyle=m||"white",e.fillRect(p,0,s,c),c>=10&&s>=c/2&&(e.fillStyle=v[f.toUpperCase()]||"black",e.fillText(f,p+s/2,c/2+1))}}}}}),[l,o,s,c,n,v,d,u,h]),p.createElement("canvas",{ref:g,height:c*u,width:o*u,style:{position:"absolute",left:i+n,width:o,height:c}})})),Sn=o.observer((function(e){var t=e.track,n=e.model;return p.createElement("div",{style:{position:"relative",height:n.rowHeight,width:n.msaAreaWidth,overflow:"hidden"}},n.blocksX.map((function(e){return p.createElement(En,{key:e,track:t,model:n,offsetX:e})})))})),Mn=function(){function e(e){var t=(void 0===e?{}:e).maxHeight,n=void 0===t?1e4:t;this.maxHeightReached=!1,this.rbush=new se,this.rectangles=new Map,this.maxHeight=Math.ceil(n),this.pTotalHeight=0}return e.prototype.addRect=function(e,t,n,r,o){var a=this.rectangles.get(e);if(a)return a.minY;for(var i=0;this.rbush.collides({minX:t,minY:i,maxX:n,maxY:i+r})&&i<=this.maxHeight;)i+=1;var l={minX:t,minY:i,maxX:n,maxY:i+r,id:e,data:o};return this.rbush.insert(l),this.rectangles.set(e,l),this.pTotalHeight=Math.max(this.pTotalHeight,i),i},Object.defineProperty(e.prototype,"totalHeight",{get:function(){return this.pTotalHeight},enumerable:!1,configurable:!0}),e}(),xn=o.observer((function(e){var t=e.model,n=e.offsetX,o=t.blockSize,a=t.colWidth,i=t.blanks,l=t.rowHeight,s=t.highResScaleFactor,c=t.scrollX,f=e.track.model,h=f.height,d=f.features,m=f.associatedRowName,g=u.isStateTreeNode(d)?u.getSnapshot(d):d,v=r.useMemo((function(){var e=new Mn;return null==g||g.forEach((function(n,r){var o=n.start,a=n.end;if(m){var i=t.rowSpecificBpToPx(m,o-1),s=t.rowSpecificBpToPx(m,a);e.addRect("".concat(r),i,s,l,n)}else i=t.globalBpToPx(o-1),s=t.globalBpToPx(a),e.addRect("".concat(r),i,s,l,n)})),e}),[l,g,m,t,i]),b=r.useRef(null),y=r.useRef(null),w=r.useRef(null);return r.useEffect((function(){if(b.current){var e=b.current.getContext("2d");if(e){e.resetTransform(),e.scale(s,s),e.clearRect(0,0,o,h),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,"".concat(Math.max(8,l-8),"px"));var t=Math.max(0,Math.floor(n/a));e.fillStyle="goldenrod",v.rectangles.forEach((function(r){var o=r.minY,i=(r.minX-t)*a+n-n%a,l=(r.maxX-t)*a+n-n%a;l-i>0&&e.fillRect(i,o,l-i,(r.maxY-o)/2)}))}}}),[m,o,a,v.rectangles,t,l,h,n,s,d,i]),r.useEffect((function(){if(y.current){var e=y.current.getContext("2d");e&&(e.resetTransform(),e.scale(s,s),e.clearRect(0,0,o,h),e.translate(-n,0),e.textAlign="center",e.font=e.font.replace(/\d+px/,"".concat(Math.max(8,l-8),"px")),e.fillStyle="black",e.textAlign="left",v.rectangles.forEach((function(t){var n,r,o,i,l=t.maxY,s=t.minY,u=t.data,f=t.minX*a,h=t.maxX*a;if(h-f>0){var d=null===(r=null===(n=u.attributes)||void 0===n?void 0:n.Note)||void 0===r?void 0:r[0],m=null===(i=null===(o=u.attributes)||void 0===o?void 0:o.Name)||void 0===i?void 0:i[0];e.fillText([u.type,m,d].filter((function(e){return!!e})).join(" - "),Math.max(Math.min(-c,h),f),s+(l-s))}})))}}),[o,a,c,s,h,v.rectangles,n,d,t,l,i]),d?p.createElement(p.Fragment,null,p.createElement("canvas",{ref:b,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}}),p.createElement("canvas",{ref:y,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}}),p.createElement("canvas",{ref:w,height:h*s,width:o*s,style:{position:"absolute",left:c+n,width:o,height:h}})):null})),An=o.observer((function(e){var t=e.model,n=e.track;return p.createElement("div",{style:{position:"relative",height:n.model.height,width:t.msaAreaWidth,overflow:"hidden"}},t.blocksX.map((function(e){return p.createElement(xn,{track:n,key:e,model:t,offsetX:e})})))})),kn=function(){return(kn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ln=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))},Tn=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},Cn=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function Pn(e,t){for(var n="",r=0,o=0;o<t.length;o++)o===e[r]?r++:n+=t[o];return n}function On(e){return(e.data.length||1)+(e.children?function(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n<t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let o of e)null!=(o=t(o,++r,e))&&(n<o||void 0===n&&o>=o)&&(n=o)}return n}(e.children,On):0)}function Rn(e){e.children&&(e._children=e.children,e._children.forEach(Rn),e.children=null)}function Dn(e,t,n){return Math.min(Math.max(t,e),n)}var Nn=u.types.model({id:u.types.identifier,structure:u.types.model({pdb:u.types.string,startPos:u.types.number,endPos:u.types.number}),range:u.types.maybe(u.types.string)}),jn=u.types.model({id:u.types.string,accession:u.types.string,name:u.types.string,associatedRowName:u.types.string,height:u.types.optional(u.types.number,100)}).volatile((function(){return{error:void 0,data:void 0}})).actions((function(e){return{setError:function(t){e.error=t},setData:function(t){e.data=t}}})).actions((function(e){return{afterCreate:function(){var t=this;u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r,o;return Tn(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),t="https://www.uniprot.org/uniprot/".concat(e.accession,".gff"),[4,fetch(t)];case 1:if(!(n=a.sent()).ok)throw new Error("HTTP ".concat(n.status," ").concat(n.statusText," fetching ").concat(t));return[4,n.text()];case 2:return r=a.sent(),e.setData(r),[3,4];case 3:return o=a.sent(),e.setError(o),[3,4];case 4:return[2]}}))}))})))}}})).views((function(e){return{get loading(){return!e.data},get features(){var t;return null===(t=e.data)||void 0===t?void 0:t.split("\n").map((function(e){return e.trim()})).filter((function(e){return!!e})).filter((function(e){return!e.startsWith("#")})).map((function(e){var t=e.split("\t");return kn({seq_id:t[0],source:t[1],type:t[2],start:+t[3],end:+t[4],score:+t[5],strand:t[6],phase:t[7]},Object.fromEntries(t[8].split(";").map((function(e){return e.trim()})).filter((function(e){return!!e})).map((function(e){return e.split("=")})).map((function(e){var t=e[1];return[e[0].trim(),decodeURIComponent(t).trim().split(",").join(" ")]}))))}))}}})),In=u.types.model("MsaView",{id:f.ElementId,type:u.types.literal("MsaView"),height:u.types.optional(u.types.number,550),treeAreaWidth:u.types.optional(u.types.number,400),treeWidth:u.types.optional(u.types.number,300),rowHeight:20,scrollY:0,scrollX:0,resizeHandleWidth:5,blockSize:1e3,mouseRow:u.types.maybe(u.types.number),mouseCol:u.types.maybe(u.types.number),selectedStructures:u.types.array(Nn),labelsAlignRight:!1,colWidth:16,showBranchLen:!0,bgColor:!0,drawTree:!0,drawNodeBubbles:!0,highResScaleFactor:2,colorSchemeName:"maeditor",treeFilehandle:u.types.maybe(f.FileLocation),msaFilehandle:u.types.maybe(f.FileLocation),currentAlignment:0,collapsed:u.types.array(u.types.string),showOnly:u.types.maybe(u.types.string),boxTracks:u.types.array(jn),turnedOffTracks:u.types.map(u.types.boolean),annotatedRegions:u.types.array(u.types.model({start:u.types.number,end:u.types.number,attributes:u.types.frozen()})),data:u.types.optional(u.types.model({tree:u.types.maybe(u.types.string),msa:u.types.maybe(u.types.string)}).actions((function(e){return{setTree:function(t){e.tree=t},setMSA:function(t){e.msa=t}}})),{tree:"",msa:""})}).volatile((function(){return{error:void 0,margin:{left:20,top:20},DialogComponent:void 0,DialogProps:void 0,annotPos:void 0}})).actions((function(e){return{setDialogComponent:function(t,n){e.DialogComponent=t,e.DialogProps=n},setHeight:function(t){e.height=t},addStructureToSelection:function(t){e.selectedStructures.push(t)},removeStructureFromSelection:function(t){var n=e.selectedStructures.find((function(e){return e.id===t.id}));n&&e.selectedStructures.remove(n)},toggleStructureSelection:function(t){var n=e.selectedStructures.find((function(e){return e.id===t.id}));n?e.selectedStructures.remove(n):e.selectedStructures.push(t)},clearSelectedStructures:function(){e.selectedStructures=[]},setError:function(t){t&&console.error(t),e.error=t},setMousePos:function(t,n){e.mouseCol=t,e.mouseRow=n},setRowHeight:function(t){e.rowHeight=t},setColWidth:function(t){e.colWidth=t},setColorSchemeName:function(t){e.colorSchemeName=t},setScrollY:function(t){e.scrollY=t},setScrollX:function(t){e.scrollX=t},setTreeAreaWidth:function(t){e.treeAreaWidth=t},setTreeWidth:function(t){e.treeWidth=t},setCurrentAlignment:function(t){e.currentAlignment=t},toggleLabelsAlignRight:function(){e.labelsAlignRight=!e.labelsAlignRight},toggleDrawTree:function(){e.drawTree=!e.drawTree},toggleCollapsed:function(t){e.collapsed.includes(t)?e.collapsed.remove(t):e.collapsed.push(t)},setShowOnly:function(t){e.showOnly=t},toggleBranchLen:function(){e.showBranchLen=!e.showBranchLen},toggleBgColor:function(){e.bgColor=!e.bgColor},toggleNodeBubbles:function(){e.drawNodeBubbles=!e.drawNodeBubbles},setData:function(t){e.data=u.cast(t)},setMSAFilehandle:function(t){return Ln(this,void 0,void 0,(function(){return Tn(this,(function(n){return e.msaFilehandle=t,[2]}))}))},setTreeFilehandle:function(t){return Ln(this,void 0,void 0,(function(){var n;return Tn(this,(function(r){switch(r.label){case 0:return t&&"blobId"in t?[4,h.openLocation(t).readFile("utf8")]:[3,2];case 1:return n=r.sent(),this.setTree(n),[3,3];case 2:e.treeFilehandle=t,r.label=3;case 3:return[2]}}))}))},setMSA:function(t){e.data.setMSA(t)},setTree:function(t){e.data.setTree(t)},afterCreate:function(){var t=this;u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r;return Tn(this,(function(o){switch(o.label){case 0:if(!(t=e.treeFilehandle))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),n=this.setTree,[4,h.openLocation(t).readFile("utf8")];case 2:return n.apply(this,[o.sent()]),[3,4];case 3:return r=o.sent(),this.setError(r),[3,4];case 4:return[2]}}))}))}))),u.addDisposer(e,i.autorun((function(){return Ln(t,void 0,void 0,(function(){var t,n,r;return Tn(this,(function(o){switch(o.label){case 0:if(!(t=e.msaFilehandle))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),n=this.setMSA,[4,h.openLocation(t).readFile("utf8")];case 2:return n.apply(this,[o.sent()]),[3,4];case 3:return r=o.sent(),this.setError(r),[3,4];case 4:return[2]}}))}))})))}}})).views((function(e){var t=[],n=[],r=0,o=0;return{get initialized(){return(e.data.msa||e.data.tree||e.msaFilehandle||e.treeFilehandle)&&!e.error},get blocksX(){for(var n=e.blockSize,o=e.colWidth,a=-n*Math.floor(e.scrollX/n)-n,i=[],l=a;l<a+3*n;l+=n)l+n>0&&i.push(l);return JSON.stringify(i)===JSON.stringify(t)&&o===r||(t=i,r=o),t},get blocksY(){for(var t=e.blockSize,r=e.rowHeight,a=-t*Math.floor(e.scrollY/t)-2*t,i=[],l=a;l<a+3*t;l+=t)l+t>0&&i.push(l);return JSON.stringify(i)===JSON.stringify(n)&&r===o||(n=i,o=r),n}}})).views((function(e){return{get blocks2d(){return e.blocksY.map((function(t){return e.blocksX.map((function(e){return[e,t]}))})).flat()},get done(){return e.initialized&&(e.data.msa||e.data.tree)},get colorScheme(){return Je[e.colorSchemeName]},get alignmentDetails(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.getDetails())||{}},getRowDetails:function(e){var t,n,r=null===(n=null===(t=this.MSA)||void 0===t?void 0:t.getRowDetails)||void 0===n?void 0:n.call(t,e),o=e.match(/\S+\/(\d+)-(\d+)/);return kn(kn({},r),o&&{range:{start:+o[1],end:+o[2]}})},get currentAlignmentName(){return this.alignmentNames[e.currentAlignment]},get alignmentNames(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.alignmentNames)||[]},get noTree(){return!!this.tree.noTree},get menuItems(){return[]},get MSA(){var t=e.data.msa;return t?dn.sniff(t)?new yn(t,e.currentAlignment):t.startsWith(">")?new wn(t):new vn(t):null},get numColumns(){var t;return(((null===(t=this.MSA)||void 0===t?void 0:t.getWidth())||0)-this.blanks.length)*e.colWidth},get tree(){var t;return e.data.tree?Ke(bn(e.data.tree)):(null===(t=this.MSA)||void 0===t?void 0:t.getTree())||{noTree:!0}},get rowNames(){return this.hierarchy.leaves().map((function(e){return e.data.name}))},get mouseOverRowName(){return void 0!==e.mouseRow?this.rowNames[e.mouseRow]:void 0},getMouseOverResidue:function(e){return this.columns[e]},get root(){var t=Ft(this.tree,(function(e){return e.branchset})).sum((function(e){return e.branchset?0:1})).sort((function(e,t){return function(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}(e.data.length||1,t.data.length||1)}));if(e.showOnly){var n=t.find((function(t){return t.data.id===e.showOnly}));n&&(t=n)}return e.collapsed.length&&e.collapsed.map((function(e){return t.find((function(t){return t.data.id===e}))})).filter((function(e){return!!e})).map((function(e){return Rn(e)})),t},get structures(){var e;return(null===(e=this.MSA)||void 0===e?void 0:e.getStructures())||{}},get inverseStructures(){var e=Object.entries(this.structures).map((function(e){var t=e[0];return e[1].map((function(e){return[e.pdb,{id:t}]}))})).flat();return Object.fromEntries(e)},get msaAreaWidth(){return e.width-e.treeAreaWidth},get blanks(){for(var e,t=this,n=[],r=this.hierarchy.leaves().map((function(e){var n;return null===(n=t.MSA)||void 0===n?void 0:n.getRow(e.data.name)})).filter((function(e){return!!e})),o=0;o<(null===(e=r[0])||void 0===e?void 0:e.length);o++){for(var a=0,i=0;i<r.length;i++)"-"===r[i][o]&&a++;a===r.length&&n.push(o)}return n},get rows(){var e=this;return this.hierarchy.leaves().map((function(t){var n,r=t.data;return[r.name,null===(n=e.MSA)||void 0===n?void 0:n.getRow(r.name)]})).filter((function(e){return!!e[1]}))},get columns(){var e=this.columns2d;return Object.fromEntries(this.rows.map((function(t,n){return[t[0],e[n]]})))},get columns2d(){for(var e=this.rows.map((function(e){return e[1]})),t=[],n=0;n<e.length;n++)t.push(Pn(this.blanks,e[n]));return t},get colStats(){for(var e=[],t=this.columns2d,n=0;n<t.length;n++)for(var r=0;r<t[n].length;r++){var o=e[r]||{};o[t[n][r]]||(o[t[n][r]]=0),o[t[n][r]]++,e[r]=o}return e},get hierarchy(){var t=this.root;return function(){var e=Dt,t=1,n=1,r=!1;function o(o){var a,i=0;o.eachAfter((function(t){var n=t.children;n?(t.x=function(e){return e.reduce(Nt,0)/e.length}(n),t.y=function(e){return 1+e.reduce(jt,0)}(n)):(t.x=a?i+=e(t,a):0,t.y=0,a=t)}));var l=function(e){for(var t;t=e.children;)e=t[0];return e}(o),s=function(e){for(var t;t=e.children;)e=t[t.length-1];return e}(o),c=l.x-e(l,s)/2,u=s.x+e(s,l)/2;return o.eachAfter(r?function(e){e.x=(e.x-o.x)*t,e.y=(o.y-e.y)*n}:function(e){e.x=(e.x-c)/(u-c)*t,e.y=(1-(o.y?e.y/o.y:1))*n})}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],o):r?null:[t,n]},o.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],o):r?[t,n]:null},o}().size([this.totalHeight,e.treeWidth]).separation((function(){return 1}))(t),function e(t,n,r){var o;t.len=(n+=Math.max(t.data.length||0,0))*r,null===(o=t.children)||void 0===o||o.forEach((function(t){e(t,n,r)}))}(t,t.data.length=0,e.treeWidth/On(t)),t},get totalHeight(){return this.root.leaves().length*e.rowHeight}}})).actions((function(e){return{addUniprotTrack:function(t){e.boxTracks.find((function(e){return e.name===t.name}))?e.turnedOffTracks.has(t.name)&&this.toggleTrack(t.name):e.boxTracks.push(kn(kn({},t),{id:t.name,associatedRowName:t.name}))},doScrollY:function(t){e.scrollY=Dn(10-e.totalHeight,e.scrollY+t,0)},doScrollX:function(t){e.scrollX=Dn(e.msaAreaWidth-100-e.numColumns,e.scrollX+t,0)},setMouseoveredColumn:function(t,n,r){var o,a=0,i=0,l=(e.inverseStructures[r.slice(0,-4)]||{}).id,s=null===(o=e.MSA)||void 0===o?void 0:o.getRow(l);if(s){for(i=0;i<s.length&&a<t;i++)"-"!==s[i]&&a++;e.mouseCol=a+1}else e.mouseCol=void 0},toggleTrack:function(t){e.turnedOffTracks.has(t)?e.turnedOffTracks.delete(t):e.turnedOffTracks.set(t,!0)}}})).views((function(e){return{get secondaryStructureConsensus(){var t;return null===(t=e.MSA)||void 0===t?void 0:t.secondaryStructureConsensus},get seqConsensus(){var t;return null===(t=e.MSA)||void 0===t?void 0:t.seqConsensus},get conservation(){var t=e.columns2d;if(t.length)for(var n=0;n<t[0].length;n++)for(var r=[],o=0;o<t.length;o++)r.push(t[o][n]);return["a"]},get tracks(){var t=e.blanks,n=e.MSA?e.MSA.tracks.map((function(n){var r=n.data;return{model:kn(kn({},n),{data:r?Pn(t,r):void 0,height:e.rowHeight}),ReactComponent:Sn}})):[],r=e.boxTracks.filter((function(t){return!!e.rows.find((function(e){return e[0]===t.name}))})).map((function(e){return{model:e,ReactComponent:An}})),o=e.annotatedRegions.length>0?[{model:{features:e.annotatedRegions,height:100,id:"annotations",name:"User-created annotations",data:e.annotatedRegions.map((function(e){var t=e.attributes?Object.entries(e.attributes).map((function(e){var t=e[1];return"".concat(e[0],"=").concat(t.join(","))})).join(";"):".";return["MSA_refcoord",".",".",e.start,e.end,".",".",".",t].join("\t")})).join("\n")},ReactComponent:An}]:[];return Cn(Cn(Cn([],n,!0),r,!0),o,!0)},get turnedOnTracks(){return this.tracks.filter((function(t){return!e.turnedOffTracks.has(t.model.id)}))},pxToBp:function(t){return Math.floor((t-e.scrollX)/e.colWidth)},rowSpecificBpToPx:function(t,n){var r,o=e.blanks,a=e.rows[e.rowNames.indexOf(t)][1],i=n-((null===(r=e.getRowDetails(t).range)||void 0===r?void 0:r.start)||0);if(i<0)return 0;for(var l=0,s=0;s<a.length&&("-"===a[s]||l++!==i);s++);for(var c=0,u=0;u<a.length;u++)-1!==o.indexOf(u)&&u<s+1&&c++;return s-c},globalBpToPx:function(t){for(var n,r=0,o=0;o<(null===(n=e.rows[0])||void 0===n?void 0:n[1].length);o++)-1!==e.blanks.indexOf(o)&&o<t+1&&r++;return t-r},relativePxToBp:function(t,n){for(var r=e.rows[e.rowNames.indexOf(t)][1],o=0,a=0;a<n;a++)if("-"!==r[a])o++;else if(o>=n)break;return o},getPos:function(t){for(var n=0,r=0,o=0;r<t;r++,n++)for(;n===e.blanks[o];)o++,n++;return n}}})).actions((function(e){return{addAnnotation:function(t,n,r){e.annotatedRegions.push({start:e.getPos(t),end:e.getPos(n),attributes:r})},setOffsets:function(t,n){e.annotPos={left:t,right:n}},clearAnnotPos:function(){e.annotPos=void 0}}})),Fn=u.types.snapshotProcessor(u.types.compose(hn,In),{postProcessor:function(e){var t=e.data,n=t.tree,r=t.msa,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["data"]);return kn({data:kn(kn({},!e.treeFilehandle&&{tree:n}),!e.msaFilehandle&&{msa:r})},o)}}),_n={__proto__:null,MSAModel:Fn,MSAView:Rt},Bn=A(k((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=C(p),r=(0,L(P).default)(n.createElement("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"}),"GridOn");t.default=r})));e.default=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(o,e);var t,r=S(o);function o(){var e;return b(this,o),(e=r.apply(this,arguments)).name="MsaViewPlugin",e.version="1.0.18",e}return(t=[{key:"install",value:function(e){console.log({MSA:_n}),e.addViewType((function(){return new m({name:"MsaView",stateModel:Fn,ReactComponent:Rt})}))}},{key:"configure",value:function(e){n.isAbstractMenuManager(e.rootModel)&&e.rootModel.appendToSubMenu(["Add"],{label:"Multiple sequence alignment view",icon:Bn,onClick:function(e){e.addView("MsaView",{})}})}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(o.prototype,t),o}(t),Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=jbrowse-plugin-msaview.umd.production.min.js.map