@apollo-annotation/jbrowse-plugin-apollo 0.3.12 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts +1 -1
- package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts.map +1 -1
- package/dist/BackendDrivers/BackendDriver.d.ts +29 -4
- package/dist/BackendDrivers/BackendDriver.d.ts.map +1 -1
- package/dist/BackendDrivers/CollaborationServerDriver.d.ts +3 -1
- package/dist/BackendDrivers/CollaborationServerDriver.d.ts.map +1 -1
- package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts +22 -0
- package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts.map +1 -0
- package/dist/BackendDrivers/LocalDriver/db.d.ts +4 -0
- package/dist/BackendDrivers/LocalDriver/db.d.ts.map +1 -0
- package/dist/BackendDrivers/index.d.ts +1 -2
- package/dist/BackendDrivers/index.d.ts.map +1 -1
- package/dist/ChangeManager.d.ts +3 -3
- package/dist/ChangeManager.d.ts.map +1 -1
- package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts +0 -6
- package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts.map +1 -1
- package/dist/FeatureDetailsWidget/TranscriptWidgetEditLocation.d.ts.map +1 -1
- package/dist/FeatureDetailsWidget/model.d.ts +0 -2
- package/dist/FeatureDetailsWidget/model.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/components/CheckResultWarnings.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/components/LinearApolloDisplay.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts +7 -0
- package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts.map +1 -0
- package/dist/LinearApolloDisplay/components/Tooltip.d.ts +10 -0
- package/dist/LinearApolloDisplay/components/Tooltip.d.ts.map +1 -0
- package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts +0 -1
- package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts +3 -0
- package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts.map +1 -0
- package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts +3 -0
- package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts.map +1 -0
- package/dist/LinearApolloDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/glyphs/GenericChildGlyph.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts +26 -20
- package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts +3 -0
- package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts.map +1 -0
- package/dist/LinearApolloDisplay/glyphs/util.d.ts +13 -0
- package/dist/LinearApolloDisplay/glyphs/util.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/stateModel/base.d.ts +17 -0
- package/dist/LinearApolloDisplay/stateModel/base.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/stateModel/index.d.ts +35 -17
- package/dist/LinearApolloDisplay/stateModel/index.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/stateModel/layouts.d.ts +29 -7
- package/dist/LinearApolloDisplay/stateModel/layouts.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts +69 -23
- package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts.map +1 -1
- package/dist/LinearApolloDisplay/stateModel/rendering.d.ts +26 -9
- package/dist/LinearApolloDisplay/stateModel/rendering.d.ts.map +1 -1
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts +6 -0
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts.map +1 -1
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts +6 -0
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts.map +1 -1
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts +6 -0
- package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts.map +1 -1
- package/dist/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.d.ts.map +1 -1
- package/dist/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
- package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts +1 -1
- package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts.map +1 -1
- package/dist/LinearApolloSixFrameDisplay/stateModel/layouts.d.ts.map +1 -1
- package/dist/LinearApolloSixFrameDisplay/stateModel/rendering.d.ts.map +1 -1
- package/dist/OntologyManager/OntologyStore/fulltext.d.ts +1 -1
- package/dist/OntologyManager/OntologyStore/fulltext.d.ts.map +1 -1
- package/dist/OntologyManager/OntologyStore/index.d.ts +2 -2
- package/dist/OntologyManager/OntologyStore/index.d.ts.map +1 -1
- package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts +1 -1
- package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts.map +1 -1
- package/dist/OntologyManager/OntologyStore/types.d.ts +18 -0
- package/dist/OntologyManager/OntologyStore/types.d.ts.map +1 -0
- package/dist/TabularEditor/HybridGrid/featureContextMenuItems.d.ts.map +1 -1
- package/dist/components/AddChildFeature.d.ts.map +1 -1
- package/dist/components/ColorFeature.d.ts +13 -0
- package/dist/components/ColorFeature.d.ts.map +1 -0
- package/dist/components/CreateApolloAnnotation.d.ts.map +1 -1
- package/dist/components/DownloadGFF3.d.ts +4 -1
- package/dist/components/DownloadGFF3.d.ts.map +1 -1
- package/dist/components/DuplicateTranscript.d.ts.map +1 -1
- package/dist/components/ViewChangeLog.d.ts +2 -1
- package/dist/components/ViewChangeLog.d.ts.map +1 -1
- package/dist/components/ViewCheckResults.d.ts +2 -1
- package/dist/components/ViewCheckResults.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/extensions/annotationFromJBrowseFeature.d.ts.map +1 -1
- package/dist/extensions/annotationFromPileup.d.ts.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +6325 -5997
- package/dist/index.esm.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.development.js +5869 -5541
- package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js +1 -1
- package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.umd.development.js +16782 -25897
- package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -1
- package/dist/jbrowse-plugin-apollo.umd.production.min.js +1 -1
- package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -1
- package/dist/makeDisplayComponent.d.ts.map +1 -1
- package/dist/menus/Icons.d.ts +3 -0
- package/dist/menus/Icons.d.ts.map +1 -0
- package/dist/menus/topLevelMenu.d.ts.map +1 -1
- package/dist/session/changeHandlers.d.ts +9 -0
- package/dist/session/changeHandlers.d.ts.map +1 -0
- package/dist/util/annotationFeatureUtils.d.ts +2 -1
- package/dist/util/annotationFeatureUtils.d.ts.map +1 -1
- package/dist/util/glyphUtils.d.ts +3 -3
- package/dist/util/glyphUtils.d.ts.map +1 -1
- package/dist/util/index.d.ts +0 -1
- package/dist/util/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ApolloInternetAccount/model.ts +68 -4
- package/src/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.ts +6 -3
- package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +1 -1
- package/src/BackendDrivers/BackendDriver.ts +36 -3
- package/src/BackendDrivers/CollaborationServerDriver.ts +78 -23
- package/src/BackendDrivers/LocalDriver/LocalDriver.ts +367 -0
- package/src/BackendDrivers/LocalDriver/db.ts +37 -0
- package/src/BackendDrivers/index.ts +1 -2
- package/src/ChangeManager.ts +27 -25
- package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +1 -1
- package/src/FeatureDetailsWidget/TranscriptWidgetEditLocation.tsx +69 -53
- package/src/LinearApolloDisplay/components/CheckResultWarnings.tsx +1 -5
- package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +95 -115
- package/src/LinearApolloDisplay/components/OverlayCanvas.tsx +76 -0
- package/src/LinearApolloDisplay/components/Tooltip.tsx +42 -0
- package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +60 -302
- package/src/LinearApolloDisplay/glyphs/CDSGlyph.ts +145 -0
- package/src/LinearApolloDisplay/glyphs/ExonGlyph.ts +212 -0
- package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +65 -999
- package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +71 -181
- package/src/LinearApolloDisplay/glyphs/Glyph.ts +42 -66
- package/src/LinearApolloDisplay/glyphs/TranscriptGlyph.ts +291 -0
- package/src/LinearApolloDisplay/glyphs/util.ts +87 -0
- package/src/LinearApolloDisplay/stateModel/base.ts +83 -0
- package/src/LinearApolloDisplay/stateModel/layouts.ts +198 -138
- package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +252 -158
- package/src/LinearApolloDisplay/stateModel/rendering.ts +103 -21
- package/src/LinearApolloReferenceSequenceDisplay/drawSequenceOverlay.ts +3 -3
- package/src/LinearApolloReferenceSequenceDisplay/stateModel/base.ts +20 -2
- package/src/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.tsx +7 -2
- package/src/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.ts +8 -13
- package/src/LinearApolloSixFrameDisplay/glyphs/Glyph.ts +1 -1
- package/src/LinearApolloSixFrameDisplay/stateModel/layouts.ts +4 -3
- package/src/LinearApolloSixFrameDisplay/stateModel/mouseEvents.ts +1 -1
- package/src/LinearApolloSixFrameDisplay/stateModel/rendering.ts +2 -1
- package/src/OntologyManager/OntologyStore/__snapshots__/index.test.ts.snap +18262 -8519
- package/src/OntologyManager/OntologyStore/fulltext.ts +1 -2
- package/src/OntologyManager/OntologyStore/index.test.ts +5 -2
- package/src/OntologyManager/OntologyStore/index.ts +7 -8
- package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +2 -2
- package/src/OntologyManager/OntologyStore/types.ts +27 -0
- package/src/OntologyManager/index.ts +15 -26
- package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +4 -5
- package/src/components/AddChildFeature.tsx +15 -8
- package/src/components/ColorFeature.tsx +167 -0
- package/src/components/CreateApolloAnnotation.tsx +35 -9
- package/src/components/DownloadGFF3.tsx +92 -121
- package/src/components/DuplicateTranscript.tsx +10 -0
- package/src/components/ViewChangeLog.tsx +123 -83
- package/src/components/ViewCheckResults.tsx +15 -73
- package/src/components/index.ts +1 -1
- package/src/config.ts +37 -19
- package/src/extensions/annotationFromJBrowseFeature.test.ts +1 -1
- package/src/extensions/annotationFromJBrowseFeature.ts +91 -63
- package/src/extensions/annotationFromPileup.ts +40 -40
- package/src/index.ts +45 -1
- package/src/makeDisplayComponent.tsx +10 -3
- package/src/menus/Icons.tsx +49 -0
- package/src/menus/topLevelMenu.ts +24 -96
- package/src/session/ClientDataStore.ts +16 -17
- package/src/session/changeHandlers.ts +261 -0
- package/src/session/session.ts +77 -46
- package/src/util/annotationFeatureUtils.ts +29 -1
- package/src/util/glyphUtils.ts +74 -31
- package/src/util/index.ts +0 -1
- package/dist/BackendDrivers/DesktopFileDriver.d.ts +0 -160
- package/dist/BackendDrivers/DesktopFileDriver.d.ts.map +0 -1
- package/dist/BackendDrivers/InMemoryFileDriver.d.ts +0 -162
- package/dist/BackendDrivers/InMemoryFileDriver.d.ts.map +0 -1
- package/dist/LinearApolloDisplay/glyphs/index.d.ts +0 -4
- package/dist/LinearApolloDisplay/glyphs/index.d.ts.map +0 -1
- package/dist/components/OpenLocalFile.d.ts +0 -15
- package/dist/components/OpenLocalFile.d.ts.map +0 -1
- package/dist/util/loadAssemblyIntoClient.d.ts +0 -5
- package/dist/util/loadAssemblyIntoClient.d.ts.map +0 -1
- package/src/BackendDrivers/DesktopFileDriver.ts +0 -184
- package/src/BackendDrivers/InMemoryFileDriver.ts +0 -107
- package/src/LinearApolloDisplay/glyphs/index.ts +0 -3
- package/src/components/OpenLocalFile.tsx +0 -189
- package/src/util/loadAssemblyIntoClient.ts +0 -94
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@jbrowse/core/Plugin"),require("@jbrowse/core/configuration"),require("@jbrowse/core/pluggableElementTypes"),require("@jbrowse/core/util"),require("react/jsx-runtime"),require("@mui/material/utils"),require("@mui/material"),require("@jbrowse/mobx-state-tree"),require("mobx"),require("react"),require("@mui/x-data-grid"),require("@jbrowse/core/ui"),require("mobx-react"),require("@mui/material/styles"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("@jbrowse/core/pluggableElementTypes/AdapterType"),require("@jbrowse/core/data_adapters/BaseAdapter"),require("@jbrowse/core/util/rxjs"),require("@jbrowse/core/util/tracks")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/configuration","@jbrowse/core/pluggableElementTypes","@jbrowse/core/util","react/jsx-runtime","@mui/material/utils","@mui/material","@jbrowse/mobx-state-tree","mobx","react","@mui/x-data-grid","@jbrowse/core/ui","mobx-react","@mui/material/styles","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","@jbrowse/core/pluggableElementTypes/AdapterType","@jbrowse/core/data_adapters/BaseAdapter","@jbrowse/core/util/rxjs","@jbrowse/core/util/tracks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBrowsePluginApollo={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/configuration"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports["react/jsx-runtime"],e.JBrowseExports["@mui/material/utils"],e.JBrowseExports["@mui/material"],e.JBrowseExports["@jbrowse/mobx-state-tree"],e.JBrowseExports.mobx,e.JBrowseExports.react,e.JBrowseExports["@mui/x-data-grid"],e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["mobx-react"],e.JBrowseExports["@mui/material/styles"],e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/AdapterType"],e.JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],e.JBrowseExports["@jbrowse/core/util/rxjs"],e.JBrowseExports["@jbrowse/core/util/tracks"])}(this,(function(e,t,n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v){"use strict";function b(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,t}var C=b(u);function I(e,t){this.v=e,this.k=t}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function E(e){var t,n,r,o=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,r=Symbol.iterator);o--;){if(n&&null!=(t=e[n]))return t.call(e);if(r&&null!=(t=e[r]))return new x(t.call(e));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function x(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return x=function(e){this.s=e,this.n=e.next},x.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return void 0===n?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return void 0===n?Promise.reject(e):t(n.apply(this.s,arguments))}},new x(e)}function S(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function B(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){S(i,r,o,a,s,"next",e)}function s(e){S(i,r,o,a,s,"throw",e)}a(void 0)}))}}function k(e){return new I(e,0)}function Q(e,t,n){return t=M(t),function(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)}(e,L()?Reflect.construct(t,n||[],M(e).constructor):t.apply(e,n))}function N(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(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)}}function D(e,t,n){return t&&R(e.prototype,t),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function F(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Z(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function T(e,t,n){return(t=$(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(){return j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=M(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},j.apply(null,arguments)}function M(e){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},M(e)}function O(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&z(e,t)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){T(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function J(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)-1===t.indexOf(n=i[r])&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function U(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=Object.create((r&&r.prototype instanceof s?r:s).prototype);return G(c,"_invoke",function(n,r,o){var i,s,c,l=0,u=o||[],d=!1,A={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return i=t,s=0,c=e,A.n=n,a}};function f(n,r){for(s=n,c=r,t=0;!d&&l&&!o&&t<u.length;t++){var o,i=u[t],f=A.p,h=i[2];n>3?(o=h===r)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=f&&((o=n<2&&f<i[1])?(s=0,A.v=r,A.n=i[1]):f<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,A.n=h,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,h){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,h),s=u,c=h;(t=s<2?e:c)||!d;){i||(s?s<3?(s>1&&(A.n=-1),f(s,c)):A.n=c:A.v=c);try{if(l=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=A.n<0)?c:n.call(r,A))!==a)break}catch(t){i=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,o,i),!0),c}var a={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(G(t={},r,(function(){return this})),t),d=l.prototype=s.prototype=Object.create(u);function A(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,G(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=l,G(d,"constructor",l),G(l,"constructor",c),c.displayName="GeneratorFunction",G(l,o,"GeneratorFunction"),G(d),G(d,o,"Generator"),G(d,r,(function(){return this})),G(d,"toString",(function(){return"[object Generator]"})),(U=function(){return{w:i,m:A}})()}function G(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}G=function(e,t,n,r){function i(t,n){G(e,t,(function(e){return this._invoke(t,n,e)}))}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},G(e,t,n,r)}function H(e){var t=Object(e),n=[];for(var r in t)n.unshift(r);return function e(){for(;n.length;)if((r=n.pop())in t)return e.value=r,e.done=!1,e;return e.done=!0,e}}function Y(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function z(e,t){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},z(e,t)}function K(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||Z(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e,t,n,r){var o=j(M(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function V(e){return function(e){if(Array.isArray(e))return w(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Z(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function Z(e,t){if(e){if("string"==typeof e)return w(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function ee(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof I;Promise.resolve(s?a.v:a).then((function(n){if(s){var c="return"===t?"return":"next";if(!a.k||n.done)return r(c,n);n=e[c](n).value}o(i.done?"return":"normal",n)}),(function(e){r("throw",e)}))}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise((function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))}))},"function"!=typeof e.return&&(this.return=void 0)}function te(e){var t="function"==typeof Map?new Map:void 0;return te=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(L())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&z(o,n.prototype),o}(e,arguments,M(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),z(n,e)},te(e)}ee.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},ee.prototype.next=function(e){return this._invoke("next",e)},ee.prototype.throw=function(e){return this._invoke("throw",e)},ee.prototype.return=function(e){return this._invoke("return",e)};var ne=new(function(){return D((function e(){N(this,e),T(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),re=function(){return D((function e(t,n){var r;N(this,e),T(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"execute",value:(e=B(U().m((function e(t){var n,r;return U().w((function(e){for(;;)switch(e.n){case 0:if("Server"!==(n=t.typeName)){e.n=1;break}return r=this.executeOnServer(t),e.a(2,t.pluginsService.evaluateExtensionPoint("".concat(this.typeName,"-transformResults"),r,{operation:this,backend:t}));case 1:if("LocalGFF3"!==n){e.n=2;break}return e.a(2,this.executeOnLocalGFF3(t));case 2:throw new Error("no operation implementation for backend type '".concat(n,"'"));case 3:return e.a(2)}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e}(),oe=function(e){function t(){return N(this,t),Q(this,t,arguments)}return O(t,e),D(t,[{key:"notification",get:function(){return""}},{key:"execute",value:(n=B(U().m((function e(n){var r;return U().w((function(e){for(;;)switch(e.n){case 0:if("LocalGFF3"!==(r=n.typeName)&&"Server"!==r){e.n=1;break}return e.a(2,W(t,"execute",this,3)([n]));case 1:if("Client"!==r){e.n=2;break}return e.a(2,this.executeOnClient(n));case 2:throw new Error("no change implementation for backend type '".concat(r,"'"));case 3:return e.a(2)}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"fromJSON",value:function(e,t){return new(ne.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}]);var n}(re);function ie(e){return function(e){return void 0!==e.executeOnClient}(e)&&void 0!==e.assembly}var ae=new(function(){return D((function e(){N(this,e),T(this,"checks",new Map)}),[{key:"registerCheck",value:function(e,t){if(this.checks.has(e))throw new Error('check "'.concat(e,'" has already been registered'));this.checks.set(e,t)}},{key:"getCheck",value:function(e){var t=this.checks.get(e);if(!t)throw new Error('No check constructor registered for "'.concat(e,'"'));return t}},{key:"getChecks",value:function(){return this.checks}}])}()),se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var le="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ue={env:{}},de=[],Ae=[],fe="undefined"!=typeof Uint8Array?Uint8Array:Array,he=!1;function ge(){he=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)de[t]=e[t],Ae[e.charCodeAt(t)]=t;Ae["-".charCodeAt(0)]=62,Ae["_".charCodeAt(0)]=63}function pe(e,t,n){for(var r,o=[],i=t;i<n;i+=3)o.push(de[(r=(e[i]<<16)+(e[i+1]<<8)+e[i+2])>>18&63]+de[r>>12&63]+de[r>>6&63]+de[63&r]);return o.join("")}function me(e,t,n,r,o){var i,a,s=8*o-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?o-1:0,A=n?-1:1,f=e[t+d];for(d+=A,i=f&(1<<-u)-1,f>>=-u,u+=s;u>0;i=256*i+e[t+d],d+=A,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=A,u-=8);if(0===i)i=1-l;else{if(i===c)return a?NaN:Infinity*(f?-1:1);a+=Math.pow(2,r),i-=l}return(f?-1:1)*a*Math.pow(2,i-r)}function ye(e,t,n,r,o,i){var a,s,c,l=8*i-o-1,u=(1<<l)-1,d=u>>1,A=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,h=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?A/c:A*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*c-1)*Math.pow(2,o),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+f]=255&s,f+=h,s/=256,o-=8);for(a=a<<o|s,l+=o;l>0;e[n+f]=255&a,f+=h,a/=256,l-=8);e[n+f-h]|=128*g}var _e={}.toString,ve=Array.isArray||function(e){return"[object Array]"==_e.call(e)};function be(){return Ie.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ce(e,t){if(be()<t)throw new RangeError("Invalid typed array length");return Ie.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Ie.prototype:(null===e&&(e=new Ie(t)),e.length=t),e}function Ie(e,t,n){if(!(Ie.TYPED_ARRAY_SUPPORT||this instanceof Ie))return new Ie(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return xe(this,e)}return we(this,e,t,n)}function we(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Ie.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Ie.prototype:e=Se(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Ie.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Qe(t,n),o=(e=Ce(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(ke(t)){var n=0|Be(t.length);return 0===(e=Ce(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Ce(e,0):Se(e,t);if("Buffer"===t.type&&ve(t.data))return Se(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Ee(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function xe(e,t){if(Ee(t),e=Ce(e,t<0?0:0|Be(t)),!Ie.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Se(e,t){var n=t.length<0?0:0|Be(t.length);e=Ce(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Be(e){if(e>=be())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+be().toString(16)+" bytes");return 0|e}function ke(e){return!(null==e||!e._isBuffer)}function Qe(e,t){if(ke(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return it(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return at(e).length;default:if(r)return it(e).length;t=(""+t).toLowerCase(),r=!0}}function Ne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ye(this,t,n);case"utf8":case"utf-8":return Je(this,t,n);case"ascii":return Ge(this,t,n);case"latin1":case"binary":return He(this,t,n);case"base64":return qe(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ze(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Re(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function De(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=Ie.from(t,r)),ke(t))return 0===t.length?-1:Fe(e,t,n,r,o);if("number"==typeof t)return t&=255,Ie.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Fe(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Fe(e,t,n,r,o){var i,a=1,s=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,n/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(i=n;i<s;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*a}else-1!==u&&(i-=i-u),u=-1}else for(n+c>s&&(n=s-c),i=n;i>=0;i--){for(var d=!0,A=0;A<c;A++)if(l(e,i+A)!==l(t,A)){d=!1;break}if(d)return i}return-1}function Te(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function je(e,t,n,r){return st(it(t,e.length-n),e,n,r)}function Me(e,t,n,r){return st(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Oe(e,t,n,r){return Me(e,t,n,r)}function Le(e,t,n,r){return st(at(t),e,n,r)}function Pe(e,t,n,r){return st(function(e,t){for(var n,r,o=[],i=0;i<e.length&&!((t-=2)<0);++i)r=(n=e.charCodeAt(i))>>8,o.push(n%256),o.push(r);return o}(t,e.length-n),e,n,r)}function qe(e,t,n){return function(e){var t;he||ge();for(var n=e.length,r=n%3,o="",i=[],a=16383,s=0,c=n-r;s<c;s+=a)i.push(pe(e,s,s+a>c?c:s+a));return 1===r?(o+=de[(t=e[n-1])>>2],o+=de[t<<4&63],o+="=="):2===r&&(o+=de[(t=(e[n-2]<<8)+e[n-1])>>10],o+=de[t>>4&63],o+=de[t<<2&63],o+="="),i.push(o),i.join("")}(0===t&&n===e.length?e:e.slice(t,n))}function Je(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,a,s,c,l=e[o],u=null,d=l>239?4:l>223?3:l>191?2:1;if(o+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:a=e[o+2],128==(192&(i=e[o+1]))&&128==(192&a)&&(c=(15&l)<<12|(63&i)<<6|63&a)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:a=e[o+2],s=e[o+3],128==(192&(i=e[o+1]))&&128==(192&a)&&128==(192&s)&&(c=(15&l)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(u=c)}null===u?(u=65533,d=1):u>65535&&(r.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=d}return function(e){var t=e.length;if(t<=Ue)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Ue));return n}(r)}Ie.TYPED_ARRAY_SUPPORT=void 0===le.TYPED_ARRAY_SUPPORT||le.TYPED_ARRAY_SUPPORT,Ie.poolSize=8192,Ie._augment=function(e){return e.__proto__=Ie.prototype,e},Ie.from=function(e,t,n){return we(null,e,t,n)},Ie.TYPED_ARRAY_SUPPORT&&(Ie.prototype.__proto__=Uint8Array.prototype,Ie.__proto__=Uint8Array),Ie.alloc=function(e,t,n){return function(e,t,n,r){return Ee(t),t<=0?Ce(e,t):void 0!==n?"string"==typeof r?Ce(e,t).fill(n,r):Ce(e,t).fill(n):Ce(e,t)}(null,e,t,n)},Ie.allocUnsafe=function(e){return xe(null,e)},Ie.allocUnsafeSlow=function(e){return xe(null,e)},Ie.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ct(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ct(e.slice(0,0))}(e))},Ie.compare=function(e,t){if(!ke(e)||!ke(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},Ie.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ie.concat=function(e,t){if(!ve(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Ie.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Ie.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!ke(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},Ie.byteLength=Qe,Ie.prototype._isBuffer=!0,Ie.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Re(this,t,t+1);return this},Ie.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Re(this,t,t+3),Re(this,t+1,t+2);return this},Ie.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Re(this,t,t+7),Re(this,t+1,t+6),Re(this,t+2,t+5),Re(this,t+3,t+4);return this},Ie.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Je(this,0,e):Ne.apply(this,arguments)},Ie.prototype.equals=function(e){if(!ke(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Ie.compare(this,e)},Ie.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Ie.prototype.compare=function(e,t,n,r,o){if(!ke(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(i,a),c=this.slice(r,o),l=e.slice(t,n),u=0;u<s;++u)if(c[u]!==l[u]){i=c[u],a=l[u];break}return i<a?-1:a<i?1:0},Ie.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Ie.prototype.indexOf=function(e,t,n){return De(this,e,t,n,!0)},Ie.prototype.lastIndexOf=function(e,t,n){return De(this,e,t,n,!1)},Ie.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Te(this,e,t,n);case"utf8":case"utf-8":return je(this,e,t,n);case"ascii":return Me(this,e,t,n);case"latin1":case"binary":return Oe(this,e,t,n);case"base64":return Le(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Ie.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ue=4096;function Ge(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function He(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function Ye(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=ot(e[i]);return o}function ze(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function Ke(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function We(e,t,n,r,o,i){if(!ke(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Ve(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function $e(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function Xe(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ze(e,t,n,r,o){return o||Xe(e,0,n,4),ye(e,t,n,r,23,4),n+4}function et(e,t,n,r,o){return o||Xe(e,0,n,8),ye(e,t,n,r,52,8),n+8}Ie.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Ie.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Ie.prototype;else{var o=t-e;n=new Ie(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},Ie.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Ke(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},Ie.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Ke(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},Ie.prototype.readUInt8=function(e,t){return t||Ke(e,1,this.length),this[e]},Ie.prototype.readUInt16LE=function(e,t){return t||Ke(e,2,this.length),this[e]|this[e+1]<<8},Ie.prototype.readUInt16BE=function(e,t){return t||Ke(e,2,this.length),this[e]<<8|this[e+1]},Ie.prototype.readUInt32LE=function(e,t){return t||Ke(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Ie.prototype.readUInt32BE=function(e,t){return t||Ke(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Ie.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Ke(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},Ie.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Ke(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},Ie.prototype.readInt8=function(e,t){return t||Ke(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Ie.prototype.readInt16LE=function(e,t){t||Ke(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Ie.prototype.readInt16BE=function(e,t){t||Ke(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Ie.prototype.readInt32LE=function(e,t){return t||Ke(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Ie.prototype.readInt32BE=function(e,t){return t||Ke(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Ie.prototype.readFloatLE=function(e,t){return t||Ke(e,4,this.length),me(this,e,!0,23,4)},Ie.prototype.readFloatBE=function(e,t){return t||Ke(e,4,this.length),me(this,e,!1,23,4)},Ie.prototype.readDoubleLE=function(e,t){return t||Ke(e,8,this.length),me(this,e,!0,52,8)},Ie.prototype.readDoubleBE=function(e,t){return t||Ke(e,8,this.length),me(this,e,!1,52,8)},Ie.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||We(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},Ie.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||We(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},Ie.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,1,255,0),Ie.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Ie.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,2,65535,0),Ie.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},Ie.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,2,65535,0),Ie.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},Ie.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,4,4294967295,0),Ie.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):$e(this,e,t,!0),t+4},Ie.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,4,4294967295,0),Ie.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):$e(this,e,t,!1),t+4},Ie.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);We(this,e,t,n,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i<n&&(a*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},Ie.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);We(this,e,t,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},Ie.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,1,127,-128),Ie.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Ie.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,2,32767,-32768),Ie.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},Ie.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,2,32767,-32768),Ie.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},Ie.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,4,2147483647,-2147483648),Ie.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):$e(this,e,t,!0),t+4},Ie.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||We(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Ie.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):$e(this,e,t,!1),t+4},Ie.prototype.writeFloatLE=function(e,t,n){return Ze(this,e,t,!0,n)},Ie.prototype.writeFloatBE=function(e,t,n){return Ze(this,e,t,!1,n)},Ie.prototype.writeDoubleLE=function(e,t,n){return et(this,e,t,!0,n)},Ie.prototype.writeDoubleBE=function(e,t,n){return et(this,e,t,!1,n)},Ie.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!Ie.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},Ie.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Ie.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var a=ke(e)?e:it(new Ie(e,r).toString()),s=a.length;for(i=0;i<n-t;++i)this[i+t]=a[i%s]}return this};var tt,nt,rt=/[^+\/0-9A-Za-z-_]/g;function ot(e){return e<16?"0"+e.toString(16):e.toString(16)}function it(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function at(e){return function(e){var t,n,r,o,i,a;he||ge();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=new fe(3*s/4-(i="="===e[s-2]?2:"="===e[s-1]?1:0)),r=i>0?s-4:s;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)o=Ae[e.charCodeAt(t)]<<18|Ae[e.charCodeAt(t+1)]<<12|Ae[e.charCodeAt(t+2)]<<6|Ae[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===i?(o=Ae[e.charCodeAt(t)]<<2|Ae[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===i&&(o=Ae[e.charCodeAt(t)]<<10|Ae[e.charCodeAt(t+1)]<<4|Ae[e.charCodeAt(t+2)]>>2,a[c++]=o>>8&255,a[c++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(rt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function st(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ct(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var lt=function(){if(nt)return tt;nt=1;for(var e=Math.floor(16777215*Math.random()),t=l.index=parseInt(16777215*Math.random(),10),n=(void 0===ue||"number"!=typeof ue.pid?Math.floor(1e5*Math.random()):ue.pid)%65535,r=function(){try{return _Buffer}catch(e){try{return Ie}catch(e){return null}}}(),o=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))},i=[],a=0;a<256;a++)i[a]=(a<=15?"0":"")+a.toString(16);var s=new RegExp("^[0-9a-fA-F]{24}$"),c=[];for(a=0;a<10;)c[48+a]=a++;for(;a<16;)c[55+a]=c[87+a]=a++;function l(e){if(!(this instanceof l))return new l(e);if(e&&(e instanceof l||"ObjectID"===e._bsontype))return e;if(this._bsontype="ObjectID",null!=e&&"number"!=typeof e){var t=l.isValid(e);if(!t&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(t&&"string"==typeof e&&24===e.length)return l.createFromHexString(e);if(null==e||12!==e.length){if(null!=e&&"function"==typeof e.toHexString)return e;throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=e}else this.id=this.generate(e)}tt=l,l.default=l,l.createFromTime=function(e){return new l(function(e,t){return 8===(t=t.toString(16)).length?t:"00000000".substring(t.length,8)+t}(0,e=parseInt(e,10)%4294967295)+"0000000000000000")},l.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");for(var t="",n=0;n<24;)t+=String.fromCharCode(c[e.charCodeAt(n++)]<<4|c[e.charCodeAt(n++)]);return new l(t)},l.isValid=function(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&s.test(e):e instanceof l||(o(e)?l.isValid(e.toString("hex")):!("function"!=typeof e.toHexString||!r||!(e.id instanceof r||"string"==typeof e.id))&&(12===e.id.length||24===e.id.length&&s.test(e.id)))))},l.prototype={constructor:l,toHexString:function(){if(!this.id||!this.id.length)throw new Error("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(24===this.id.length)return this.id;if(o(this.id))return this.id.toString("hex");for(var e="",t=0;t<this.id.length;t++)e+=i[this.id.charCodeAt(t)];return e},equals:function(e){return e instanceof l?this.toString()===e.toString():"string"==typeof e&&l.isValid(e)&&12===e.length&&o(this.id)?e===this.id.toString("binary"):"string"==typeof e&&l.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&l.isValid(e)&&12===e.length?e===this.id:!(null==e||!(e instanceof l||e.toHexString))&&e.toHexString()===this.toHexString()},getTimestamp:function(){var e,t=new Date;return e=o(this.id)?this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24:this.id.charCodeAt(3)|this.id.charCodeAt(2)<<8|this.id.charCodeAt(1)<<16|this.id.charCodeAt(0)<<24,t.setTime(1e3*Math.floor(e)),t},generate:function(r){"number"!=typeof r&&(r=~~(Date.now()/1e3)),r=parseInt(r,10)%4294967295;var o=t=(t+1)%16777215;return String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,255&r,e>>16&255,e>>8&255,255&e,n>>8&255,255&n,o>>16&255,o>>8&255,255&o)}};var u=Symbol&&Symbol.for&&Symbol.for("nodejs.util.inspect.custom")||"inspect";return l.prototype[u]=function(){return"ObjectID("+this+")"},l.prototype.toJSON=l.prototype.toHexString,l.prototype.toString=l.prototype.toHexString,tt}(),ut=ce(lt),dt=new(function(){return D((function e(){N(this,e),T(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),At=function(){return D((function e(t,n){var r;N(this,e),T(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"execute",value:(e=B(U().m((function e(t){var n,r;return U().w((function(e){for(;;)switch(e.n){case 0:if("Server"!==(n=t.typeName)){e.n=1;break}return r=this.executeOnServer(t),e.a(2,t.pluginsService.evaluateExtensionPoint("".concat(this.typeName,"-transformResults"),r,{operation:this,backend:t}));case 1:if("LocalGFF3"!==n){e.n=2;break}return e.a(2,this.executeOnLocalGFF3(t));case 2:throw new Error("no operation implementation for backend type '".concat(n,"'"));case 3:return e.a(2)}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ft=function(e){function t(){return N(this,t),Q(this,t,arguments)}return O(t,e),D(t,[{key:"notification",get:function(){return""}},{key:"execute",value:(n=B(U().m((function e(n){var r;return U().w((function(e){for(;;)switch(e.n){case 0:if("LocalGFF3"!==(r=n.typeName)&&"Server"!==r){e.n=1;break}return e.a(2,W(t,"execute",this,3)([n]));case 1:if("Client"!==r){e.n=2;break}return e.a(2,this.executeOnClient(n));case 2:throw new Error("no change implementation for backend type '".concat(r,"'"));case 3:return e.a(2)}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"fromJSON",value:function(e,t){return new(dt.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}]);var n}(At),ht=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"assembly",void 0),r.assembly=e.assembly,r}return O(t,e),D(t,[{key:"getIndexedIds",value:function(e,t){var n,r=[],o=F(null!=t?t:[]);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=e.attributes,s=a instanceof Map?a.get(i):null==a?void 0:a[i];null!=s&&s[0]&&r.push(s[0])}}catch(e){o.e(e)}finally{o.f()}if(e.children){var c,l=F(e.children instanceof Map?e.children.values():Object.values(e.children));try{for(l.s();!(c=l.n()).done;){var u=this.getIndexedIds(c.value,t);r.push.apply(r,V(u))}}catch(e){l.e(e)}finally{l.f()}}return r}}])}(ft),gt=D((function e(){N(this,e)})),pt=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"changedIds",void 0),r.changedIds=e.changedIds,r}return O(t,e),D(t,[{key:"getFeatureFromId",value:function(e,t){var n,r,o,i,a=this.logger;if(null===(n=a.verbose)||void 0===n||n.call(a,"Entry=".concat(JSON.stringify(e))),e._id.equals(t))return null===(i=a.debug)||void 0===i||i.call(a,"Top level featureId matches in the object ".concat(JSON.stringify(e))),e;null===(r=a.debug)||void 0===r||r.call(a,"FeatureId was not found on top level so lets make recursive call...");var s,c=F(null!==(o=e.children)&&void 0!==o?o:new Map);try{for(c.s();!(s=c.n()).done;){var l=K(s.value,2),u=this.getFeatureFromId(l[1],t);if(u)return u}}catch(e){c.e(e)}finally{c.f()}return null}},{key:"getChildFeatureIds",value:function(e){if(!e.children)return[];var t,n=[],r=F((e.children instanceof Map?e.children:new Map(Object.entries(e.children)))||new Map);try{for(r.s();!(t=r.n()).done;){var o=K(t.value,2);n.push.apply(n,[o[0]].concat(V(this.getChildFeatureIds(o[1]))))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"generateNewIds",value:function(e,t){var n=(new ut).toHexString();t.push(n);var r={};if(e.children)for(var o=0,i=Object.values(e.children);o<i.length;o++){var a=this.generateNewIds(i[o],t);r[a._id]=a}var s="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return q(q({},e),{},{refSeq:s,children:e.children&&r,_id:n})}},{key:"addChild",value:function(e,t){var n;if(null===(n=e.attributes)||void 0===n||!n._id){var r=e.attributes;r||(r={}),r=q({_id:[e._id.toString()]},JSON.parse(JSON.stringify(r))),e.attributes=r}var o=t._id;e.children||(e.children=new Map),e.children.set(o,q(q({allIds:[]},t),{},{_id:o})),e.children=new Map(V(e.children.entries()).sort((function(e,t){return e[1].min-t[1].min})))}},{key:"findAndDeleteChildFeature",value:function(e,t){if(!e.children)throw new Error("Feature ".concat(e._id.toHexString()," has no children"));var n=e._id,r=e.children,o=r.get(t);if(o){var i=this.getChildFeatureIds(o);return r.delete(t),i}var a,s=F(r);try{for(s.s();!(a=s.n()).done;){var c=K(a.value,2)[1];try{return this.findAndDeleteChildFeature(c,t)}catch(e){}}}catch(e){s.e(e)}finally{s.f()}throw new Error('Feature "'.concat(t,'" not found in ').concat(n.toHexString()))}}])}(ht),mt=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddAssemblyAliasesChange"),T(r,"aliases",void 0),r.aliases=e.aliases,r}return O(t,e),D(t,[{key:"executeOnClient",value:function(e){var t=o.getSession(e).assemblyManager.get(this.assembly);if(!t)throw new Error("assembly ".concat(this.assembly," not found"));return t.configuration.aliases.set(this.aliases),Promise.resolve()}},{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,aliases:this.aliases}}},{key:"executeOnServer",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.n){case 0:return r=t.assemblyModel,o=this.assembly,a=this.aliases,null===(n=(i=this.logger).debug)||void 0===n||n.call(i,"Updating assembly aliases for assembly: ".concat(o,", aliases: ").concat(JSON.stringify(a))),e.n=1,r.findById(o);case 1:if(s=e.v){e.n=2;break}throw new Error("Assembly with ID ".concat(o," not found"));case 2:return s.aliases=a,e.n=3,s.save();case 3:return e.a(2)}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:function(e){throw new Error("Method not implemented.")}},{key:"notification",get:function(){return"Assembly aliases have been added."}}]);var n}(ht);function yt(e,t,n){var r;return("apollo_feature_container"===e.type?Object.values(null!==(r=e.children)&&void 0!==r?r:{}):[e]).map((function(e){var n,r,o,i,a,s=JSON.parse(JSON.stringify(null!==(n=e.attributes)&&void 0!==n?n:{})),c=[],l=null!==(r=null===(o=e.attributes)||void 0===o||null===(o=o.gff_source)||void 0===o?void 0:o[0])&&void 0!==r?r:null;delete s.gff_source,t&&(s.Parent=[t]),s.gff_id?(s.ID=s.gff_id,delete s.gff_id):e.children&&(s.ID=[e._id]),s.gff_name&&(s.Name=s.gff_name,delete s.gff_name),s.gff_alias&&(s.Alias=s.gff_alias,delete s.gff_alias),s.gff_target&&(s.Target=s.gff_target,delete s.gff_target),s.gff_gap&&(s.Gap=s.gff_gap,delete s.gff_gap),s.gff_derives_from&&(s.Derives_from=s.gff_derives_from,delete s.gff_derives_from),s.gff_note&&(s.Note=s.gff_note,delete s.gff_note),s.gff_dbxref&&(s.Dbxref=s.gff_dbxref,delete s.gff_dbxref),s.gff_is_circular&&(s.Is_circular=s.gff_is_circular,delete s.gff_is_circular),s.gff_ontology_term&&(c.push.apply(c,V(s.gff_ontology_term)),delete s.gff_ontology_term),s["Gene Ontology"]&&(c.push.apply(c,V(s["Gene Ontology"])),delete s["Gene Ontology"]),s["Sequence Ontology"]&&(c.push.apply(c,V(s["Sequence Ontology"])),delete s["Sequence Ontology"]),c.length>0&&(s.Ontology_term=c);var u=null===(i=e.attributes)||void 0===i?void 0:i.gff_score,d=null;return u&&u.length>0&&(u[0]&&(d=Number(u[0]),Number.isNaN(d)&&(d=null)),delete s.gff_score),{start:Number(e.min)+1,end:Number(e.max),seq_id:e.refSeq,source:l,type:e.type,score:d,strand:e.strand?1===e.strand?"+":"-":null,phase:null,attributes:Object.keys(s).length>0?s:null,derived_features:[],child_features:_t(e,null===(a=s.ID)||void 0===a?void 0:a[0])}}))}function _t(e,t,n){if(!e.children)return[];if("mRNA"===e.type){for(var r=[],i=function(e){var t=[];try{t=function(e){if("mRNA"!==e.type)throw new Error('Only features of type "mRNA" or equivalent can calculate CDS locations');if(!e.children)throw new Error("no CDS or exons in mRNA");var t=Object.values(e.children),n=t.filter((function(e){return"CDS"===e.type}));if(0===n.length)throw new Error("no CDS in mRNA");var r,i=[],a=F(n);try{var s=function(){for(var n=r.value,a=n.max,s=n.min,c=[],l=!1,u=[],d=0,A=t;d<A.length;d++){var f=A[d];"exon"===f.type&&u.push({min:f.min,max:f.max})}u.sort((function(e,t){return e.min-t.min}));for(var h=0,g=u;h<g.length;h++){var p=g[h],m=c.at(-1);m&&c.push({min:m.max,max:p.min,type:"intron"});var y,_=K(o.intersection2(s,a,p.min,p.max),2),v=_[0],b=_[1];y=l?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==v&&void 0!==b?(l=!0,v===p.min&&b===p.max?c.push({min:v,max:b,phase:0,type:"CDS"}):v===p.min?c.push({min:v,max:b,phase:0,type:"CDS"},{min:b,max:p.max,type:y}):b===p.max?c.push({min:p.min,max:v,type:y},{min:v,max:b,phase:0,type:"CDS"}):c.push({min:p.min,max:v,type:y},{min:v,max:b,phase:0,type:"CDS"},{min:b,max:p.max,type:"fivePrimeUTR"===y?"threePrimeUTR":"fivePrimeUTR"})):c.push({min:p.min,max:p.max,type:y})}c.sort((function(e,t){return e.min-t.min})),-1===e.strand&&c.reverse();var C=0,I=c.map((function(e){if("CDS"!==e.type)return e;var t=C;return C=(3-(e.max-e.min-t+3)%3)%3,q(q({},e),{},{phase:t})}));i.push(I)};for(a.s();!(r=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return i}(e)}catch(e){return[]}return t.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}(e),a=0,s=0,c=Object.values(e.children);s<c.length;s++){var l=c[s],u=yt(l,t);if("CDS"===l.type){var d,A=F(i[a]);try{for(A.s();!(d=A.n()).done;){var f=d.value,h=JSON.parse(JSON.stringify(u));if(1!=h.length)throw new Error("Unexpected CDS: ".concat(JSON.stringify(h,null,2)));h[0].start=f.min+1,h[0].end=f.max,h[0].phase=f.phase.toString(),h[0].type=f.type,r.push(h)}}catch(e){A.e(e)}finally{A.f()}a++}else r.push(u)}return r}return Object.values(e.children).map((function(e){return yt(e,t)}))}var vt={ID:"gff_id",Name:"gff_name",Alias:"gff_alias",Parent:"gff_parent",Target:"gff_target",Gap:"gff_gap",Derives_from:"gff_derives_from",Note:"gff_note",Dbxref:"gff_dbxref",Ontology_term:"gff_ontology_term",Is_circular:"gff_is_circular"},bt={gff_id:"ID",gff_name:"Name",gff_alias:"Alias",gff_parent:"Parent",gff_target:"Target",gff_gap:"Gap",gff_derives_from:"Derives_from",gff_note:"Note",gff_dbxref:"Dbxref",gff_ontology_term:"Ontology_term",gff_is_circular:"Is_circular"},Ct={gff_score:"score",gff_source:"source"};function It(e,t){var n=K(e,1)[0],r=n.end,i=n.seq_id,a=n.start,s=n.strand;if(!i)throw new Error("feature does not have seq_id: ".concat(JSON.stringify(n)));if(null===a)throw new Error("feature does not have start: ".concat(JSON.stringify(n)));if(null===r)throw new Error("feature does not have end: ".concat(JSON.stringify(n)));var c=function(e){var t=e.map((function(e){return e.start})).filter((function(e){return null!==e})),n=e.map((function(e){return e.end})).filter((function(e){return null!==e}));return[Math.min.apply(Math,V(t))-1,Math.max.apply(Math,V(n))]}(e),l=K(c,2),u=l[0],d=l[1],A=function(e,t,n){var r={},i=e.filter((function(e){return e.child_features.length>0}));if(i.length>1)throw new Error("Features with multiple locations may not have children");if(e.length>1&&"CDS"!==e[0].type){var a,s=F(e);try{for(s.s();!(a=s.n()).done;){var c=It([a.value],t);r[c._id]=c}}catch(e){s.e(e)}finally{s.f()}return r}if(0!==i.length){var l,u=[],d=[],A=[],f=F(K(i,1)[0].child_features);try{for(f.s();!(l=f.n()).done;){var h=l.value,g=K(h,1)[0];if("exon"===g.type&&d.push(h),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type||A.push(h),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type&&"intron"!==g.type&&"start_codon"!==g.type&&"stop_codon"!==g.type)if("CDS"===g.type)u.push(h);else{var p=It(h,t);r[p._id]=p}}}catch(e){f.e(e)}finally{f.f()}if(u.length>0){var m,y=function(e,t){var n=e.map((function(e){return e.length}));if(n.some((function(e){return e>1})))return e.map((function(e){return It(e,t)}));var r=e.map((function(e){return e[0]})).filter((function(e){return null!==e.start&&null!==e.end})).sort((function(e,t){return e.start-t.start}));if(!r.some((function(e,t){var n=r.at(t+1);return!!n&&o.doesIntersect2(e.start,e.end,n.start,n.end)})))return[It(r,t)];var i,a=e.map((function(e){return e[0]})),s=[],c=F(a);try{var l=function(){var e=i.value,t=s.at(-1);if(!t)return s.push([e]),1;t.some((function(t){return o.doesIntersect2(t.start,t.end,e.start,e.end)}))?s.push([e]):t.push(e)};for(c.s();!(i=c.n()).done;)l()}catch(e){c.e(e)}finally{c.f()}return s.map((function(e){return It(e,t)}))}(u,t),_=F(y);try{for(_.s();!(m=_.n()).done;){var v=m.value;r[v._id]=v}}catch(e){_.e(e)}finally{_.f()}var b,C=function(e,t,n,r,o){var i,a=[],s=F(n);try{for(s.s();!(i=s.n()).done;){var c,l=F(i.value);try{for(l.s();!(c=l.n()).done;){var u=c.value;if(!u.start||!u.end)throw new Error("UTR has undefined start and/or end\n: ".concat(JSON.stringify(u,null,2)));var d=void 0;"+"===u.strand?d=1:"-"===u.strand&&(d=-1),a.push({_id:(new ut).toHexString(),refSeq:r,type:"exon",min:u.start-1,max:u.end,strand:d})}}catch(e){l.e(e)}finally{l.f()}}}catch(e){s.e(e)}finally{s.f()}a.sort((function(e,t){return e.min-t.min}));var A,f=[],h=F(e);try{for(h.s();!(A=h.n()).done;){var g=A.value;g.sort((function(e,t){if(!e.start||!t.start)throw new Error("CDS has undefined start");return e.start-t.start}));for(var p=0;p<g.length;p++){var m,y=g[p],_=!1,v=F(t);try{for(v.s();!(m=v.n()).done;){var b=m.value;if(1!=b.length)throw new Error("Unexpected number of exons");var C=K(b,1)[0];if(C.start&&C.end&&y.start&&y.end&&C.start<=y.start&&C.end>=y.end){_=!0;break}}}catch(e){v.e(e)}finally{v.f()}if(!_){if(!y.start||!y.end)throw new Error("CDS has undefined start and/or end: ".concat(JSON.stringify(y,null,2)));var I=void 0;"+"===y.strand?I=1:"-"===y.strand&&(I=-1);var w={_id:(new ut).toHexString(),refSeq:r,type:"exon",min:y.start-1,max:y.end,strand:I};if(0===p){var E,x=F(a);try{for(x.s();!(E=x.n()).done;){var S=E.value;if(S.max>w.min)break;S.max===w.min?w.min=S.min:f.push(S)}}catch(e){x.e(e)}finally{x.f()}}if(p===g.length-1){var B,k=F(a);try{for(k.s();!(B=k.n()).done;){var Q=B.value;Q.min<w.max||(Q.min===w.max?w.max=Q.max:f.push(Q))}}catch(e){k.e(e)}finally{k.f()}}f.push(w)}}}}catch(e){h.e(e)}finally{h.f()}var N=function(e){if(0===e.length)return[];e.sort((function(e,t){return e.min-t.min}));var t=[];t.push(e[0]);for(var n=1;n<e.length;n++){var r=t.at(-1),o=e[n];r&&o.min<=r.max?r.max=Math.max(r.max,o.max):t.push(o)}return t}(f);return N}(u,d,A,y[0].refSeq),I=F(C);try{for(I.s();!(b=I.n()).done;){var w=b.value;r[w._id]=w}}catch(e){I.e(e)}finally{I.f()}}return Object.keys(r).length>0?r:void 0}}(e,t),f=function(e){var t={},n=e.map((function(e){return e.score})).filter((function(e){return null!==e})),r=e.map((function(e){return e.source})).filter((function(e){return null!==e})),o=e.map((function(e){return e.attributes})).filter((function(e){return null!==e}));if(n.length>0){var i=K(n,1)[0];n.length>1&&(i=n.reduce((function(e,t){return e+t}),0)/n.length),t.gff_score=[String(i)]}if(r.length>0){var a=K(r,1)[0];r.length>1&&(a=V(new Set(r)).join(",")),t.gff_source=[a]}if(o.length>0){var s,c=F(o);try{for(c.s();!(s=c.n()).done;)for(var l=0,u=Object.entries(s.value);l<u.length;l++){var d=K(u[l],2),A=d[0],f=d[1];if("Parent"!==A){var h=A in vt?vt[A]:A,g=t[h];if(g){var p=new Set([].concat(V(g),V(f)));t[h]=V(p)}else t[h]=f}}}catch(e){c.e(e)}finally{c.f()}}if(Object.keys(t).length>0)return t}(e),h={_id:(new ut).toHexString(),refSeq:null!=t?t:i,type:wt(e),min:u,max:d};if(s)if("+"===s)h.strand=1;else{if("-"!==s)throw new Error('Unknown strand: "'.concat(s,'"'));h.strand=-1}return A&&(h.children=A),f&&(h.attributes=f),h}function wt(e){var t=K(e,1)[0];if(1===e.length||"CDS"===t.type){var n=t.type;if(!n)throw new Error("feature does not have type: ".concat(JSON.stringify(t)));return n}return"apollo_feature_container"}var Et=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"refSeqCache",new Map),e}return O(t,e),D(t,[{key:"addRefSeqIntoDb",value:(o=B(U().m((function e(t,n,r){var o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,x,S,B,k,Q,N,R,D,T,j,M,O,L,P,J,G,H,Y,z,W,V,$,X,Z;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:i=this.logger,a=r.filesService,s=r.refSeqChunkModel,c=r.refSeqModel,l=r.user,d=(u=ue.env.CHUNK_SIZE)&&Number(u),A=0,f=0,g="text/x-gff3"!==t.type,p=a.getFileStream(t),m="",y="",_=!0,v=!1,null===(o=i.debug)||void 0===o||o.call(i,"starting sequence stream"),b=0,C=new TextDecoder,I=!1,w=!1,e.p=1,S=E(p);case 2:return e.n=3,S.next();case 3:if(!(I=!(B=e.v).done)){e.n=21;break}k=C.decode(B.value),_=!k.endsWith("\n"),Q=k.split(/\r?\n/),y&&(Q[0]="".concat(y).concat(Q[0]),y=""),_&&(y=null!==(N=Q.pop())&&void 0!==N?N:""),R=F(Q),e.p=4,R.s();case 5:if((D=R.n()).done){e.n=17;break}if(T=D.value,++b%1e6==0&&(null===(j=i.debug)||void 0===j||j.call(i,"Processed ".concat(b," lines"))),g){e.n=6;break}return"##FASTA"===T.trim()&&(g=!0),e.a(3,16);case 6:if(!(M=/^>\s*(\S+)\s*(.*)/.exec(T))){e.n=12;break}if(v=!0,null===(O=i.debug)||void 0===O||O.call(i,'Reference sequence information line "'.concat(M[0],'"')),""===m){e.n=9;break}if(h){e.n=7;break}throw new Error("No refSeq document found");case 7:return f+=m.length,e.n=8,s.create([{refSeq:h._id,n:A,sequence:m,user:l,status:-1}]);case 8:m="";case 9:return e.n=10,null===(L=h)||void 0===L?void 0:L.updateOne({length:f});case 10:return f=0,A=0,J=M[1].trim(),G=M[2]?M[2].trim():"",e.n=11,c.create([q(q({name:J,description:G,assembly:n,length:0},d?{chunkSize:d}:null),{},{user:l,status:-1})]);case 11:H=K(e.v,1),Y=H[0],null===(P=i.debug)||void 0===P||P.call(i,'Added new refSeq "'.concat(J,'", desc "').concat(G,'", docId "').concat(Y._id,'"')),h=Y,e.n=16;break;case 12:if(!/\S/.test(T)){e.n=16;break}if(h){e.n=13;break}throw new Error("No refSeq document found");case 13:W=(z=h)._id,V=z.chunkSize,m+=T.replaceAll(/\s/g,"");case 14:if(!(m.length>=V)){e.n=16;break}return $=m.slice(0,V),f+=$.length,e.n=15,s.create([{refSeq:W,n:A,sequence:$,user:l,status:-1}]);case 15:A++,m=m.slice(V),e.n=14;break;case 16:e.n=5;break;case 17:e.n=19;break;case 18:e.p=18,R.e(e.v);case 19:return e.p=19,R.f(),e.f(19);case 20:I=!1,e.n=2;break;case 21:e.n=23;break;case 22:e.p=22,w=!0,x=e.v;case 23:if(e.p=23,e.p=24,!I||null==S.return){e.n=25;break}return e.n=25,S.return();case 25:if(e.p=25,!w){e.n=26;break}throw x;case 26:return e.f(25);case 27:return e.f(23);case 28:if(v){e.n=29;break}throw new Error("No reference sequences found in file");case 29:if(!m&&!_){e.n=32;break}if(h){e.n=30;break}throw new Error("No refSeq document found");case 30:return _&&(m+=y),f+=m.length,null===(X=i.verbose)||void 0===X||X.call(i,'*** Add the very last chunk to ref seq ("'.concat(h._id,'", index ').concat(A," and total length for ref seq is ").concat(f,'): "').concat(m,'"')),null===(Z=i.debug)||void 0===Z||Z.call(i,"Creating refSeq chunk number ".concat(A,' of "').concat(h._id,'"')),e.n=31,s.create([{refSeq:h._id,n:A,sequence:m,user:l,status:-1}]);case 31:return e.n=32,h.updateOne({length:f});case 32:return e.a(2)}}),e,this,[[24,,25,27],[4,18,19,20],[1,22,23,28]])}))),function(e,t,n){return o.apply(this,arguments)})},{key:"removeExistingFeatures",value:(r=B(U().m((function e(t){var n,r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return r=t.featureModel,o=t.refSeqModel,i=this.assembly,null===(n=(a=this.logger).debug)||void 0===n||n.call(a,"Removing existing features for assembly = ".concat(i)),e.n=1,o.find({assembly:i}).exec();case 1:s=F(e.v),e.p=2,s.s();case 3:if((c=s.n()).done){e.n=5;break}return l=c.value,e.n=4,r.deleteMany({refSeq:l._id});case 4:e.n=3;break;case 5:e.n=7;break;case 6:e.p=6,s.e(e.v);case 7:return e.p=7,s.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[2,6,7,8]])}))),function(e){return r.apply(this,arguments)})},{key:"addFeatureIntoDb",value:(n=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_;return U().w((function(e){for(;;)switch(e.n){case 0:if((r=ue.env.INDEXED_IDS)&&(o=r.split(",")),i=this.assembly,a=this.refSeqCache,s=n.featureModel,c=n.refSeqModel,l=n.user,u=K(t,1),d=u[0].seq_id){e.n=1;break}throw new Error("Valid seq_id not found in feature ".concat(JSON.stringify(t)));case 1:if(A=a.get(d)){e.n=6;break}return e.n=2,c.findOne({assembly:i,name:d}).exec();case 2:if(y=f=e.v,!(m=null!==y)){e.n=3;break}m=void 0!==f;case 3:if(!m){e.n=4;break}_=f,e.n=5;break;case 4:_=void 0;case 5:(A=_)&&a.set(d,A);case 6:if(A){e.n=7;break}throw new Error('RefSeq was not found by assembly "'.concat(i,'" and seq_id "').concat(d,'" not found'));case 7:return h=It(t,A._id),g=this.getAllIds(h),p=this.getIndexedIds(h,o),e.n=8,s.create([q(q({allIds:g,indexedIds:p},h),{},{user:l,status:-1})]);case 8:return e.a(2)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getAllIds",value:function(e){var t=[e._id];if(e.children)for(var n=0,r=Object.values(e.children);n<r.length;n++){var o=this.getAllIds(r[n]);t.push.apply(t,V(o))}return t}}]);var n,r,o}(ht),xt=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddAssemblyAndFeaturesFromFileChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=K(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,x,S,B,k,Q,N,R,D,T,j,M,O,L;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.assemblyModel,r=t.checkModel,o=t.fileModel,i=t.filesService,a=t.user,s=this.assembly,c=this.logger,l=F(this.changes),e.p=1,l.s();case 2:if((u=l.n()).done){e.n=28;break}if(g=(h=u.value).assemblyName,p=h.parseOptions,m=h.fileIds.fa,ue.env.FILE_UPLOAD_FOLDER){e.n=3;break}throw new Error("No FILE_UPLOAD_FOLDER found in .env file");case 3:return e.n=4,o.findById(m).exec();case 4:if(y=e.v){e.n=5;break}throw new Error('File "'.concat(m,'" not found in Mongo'));case 5:return null===(d=c.debug)||void 0===d||d.call(c,'FileId "'.concat(m,'", checksum "').concat(y.checksum,'"')),e.n=6,n.findOne({name:g}).exec();case 6:if(!e.v){e.n=7;break}throw new Error('Assembly "'.concat(g,'" already exists'));case 7:return e.n=8,r.find({isDefault:!0}).exec();case 8:return _=e.v.map((function(e){return e._id.toHexString()})),e.n=9,n.create([{_id:s,name:g,user:a,status:-1,fileId:m,checks:_}]);case 9:return v=K(e.v,1),b=v[0],null===(A=c.debug)||void 0===A||A.call(c,'Added new assembly "'.concat(g,'", docId "').concat(b._id.toHexString(),'"')),null===(f=c.debug)||void 0===f||f.call(c,'File type: "'.concat(y.type,'"')),e.n=10,this.addRefSeqIntoDb(y,b._id.toString(),t);case 10:w=void 0===(I=(C=null!=p?p:{}).bufferSize)?1e4:I,S=void 0===(x=C.strict)||x,B=i.parseGFF3(i.getFileStream(y),{bufferSize:w}),k=0,Q=0,N=!1,R=!1,e.p=11,T=E(B);case 12:return e.n=13,T.next();case 13:if(!(N=!(j=e.v).done)){e.n=20;break}return M=j.value,e.p=14,e.n=15,this.addFeatureIntoDb(M,t);case 15:e.n=18;break;case 16:if(e.p=16,L=e.v,!S&&0!==k){e.n=17;break}throw L;case 17:Q<=99&&(c.warn("Error parsing feature"),c.warn(L),99===Q&&c.warn("Reached 100 parsing errors, omitting further warnings from log")),Q++;case 18:++k%1e3==0&&(null===(O=c.debug)||void 0===O||O.call(c,"Processed ".concat(k," features")));case 19:N=!1,e.n=12;break;case 20:e.n=22;break;case 21:e.p=21,R=!0,D=e.v;case 22:if(e.p=22,e.p=23,!N||null==T.return){e.n=24;break}return e.n=24,T.return();case 24:if(e.p=24,!R){e.n=25;break}throw D;case 25:return e.f(24);case 26:return e.f(22);case 27:e.n=2;break;case 28:e.n=30;break;case 29:e.p=29,l.e(e.v);case 30:return e.p=30,l.f(),e.f(30);case 31:return e.a(2)}}),e,this,[[23,,24,26],[14,16],[11,21,22,27],[1,29,30,31]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}]);var n,r,o}(Et),St=["encoding"];function Bt(e){return("object"===X(e)&&null!==e&&"message"in e?e.message:"".concat(e)).replace(/\.$/,"")}var kt=function(){return D((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};N(this,e),this.baseOverrides={},this.url=t;var r=n.fetch||globalThis.fetch.bind(globalThis);n.overrides&&(this.baseOverrides=n.overrides),this.fetchImplementation=r}),[{key:"fetch",value:(o=B(U().m((function e(t,n){var r,o,i;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return r=function(e){return new Error("".concat(Bt(e)," fetching ").concat(t),{cause:e})},e.p=1,e.n=2,this.fetchImplementation(t,n);case 2:o=e.v,e.n=9;break;case 3:if(e.p=3,!"".concat(i=e.v).includes("Failed to fetch")){e.n=8;break}return console.warn("generic-filehandle: refetching ".concat(t," to attempt to work around chrome CORS header caching bug")),e.p=4,e.n=5,this.fetchImplementation(t,q(q({},n),{},{cache:"reload"}));case 5:o=e.v,e.n=7;break;case 6:throw e.p=6,r(e.v);case 7:e.n=9;break;case 8:throw r(i);case 9:return e.a(2,o)}}),e,this,[[4,6],[1,3]])}))),function(e,t){return o.apply(this,arguments)})},{key:"read",value:(r=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u,d,A,f,h,g=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=g.length>2&&void 0!==g[2]?g[2]:{},0!==t){e.n=1;break}return e.a(2,new Uint8Array(0));case 1:return i=void 0===(o=r.headers)?{}:o,a=r.signal,c=void 0===(s=r.overrides)?{}:s,t<Infinity?i.range="bytes=".concat(n,"-").concat(n+t-1):Infinity===t&&0!==n&&(i.range="bytes=".concat(n,"-")),e.n=2,this.fetch(this.url,q(q(q({},this.baseOverrides),c),{},{headers:q(q(q({},this.baseOverrides.headers),c.headers),i),method:"GET",redirect:"follow",mode:"cors",signal:a}));case 2:if((l=e.v).ok){e.n=3;break}throw new Error("HTTP ".concat(l.status," fetching ").concat(this.url));case 3:if((200!==l.status||0!==n)&&206!==l.status){e.n=8;break}if(u=l.headers.get("content-range"),null!=(d=/\/(\d+)$/.exec(u||""))&&d[1]&&(this._stat={size:parseInt(d[1],10)}),!l.bytes){e.n=5;break}return e.n=4,l.bytes();case 4:f=e.v,e.n=7;break;case 5:return h=Uint8Array,e.n=6,l.arrayBuffer();case 6:f=new h(e.v);case 7:return e.a(2,(A=f).byteLength<=t?A:A.subarray(0,t));case 8:throw new Error(200===l.status?"".concat(this.url," fetch returned status 200, expected 206"):"HTTP ".concat(l.status," fetching ").concat(this.url));case 9:return e.a(2)}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"readFile",value:(n=B(U().m((function e(){var t,n,r,o,i,a,s,c,l,u,d,A,f,h=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:return"string"==typeof(t=h.length>0&&void 0!==h[0]?h[0]:{})?(n=t,r={}):(n=t.encoding,o=J(t,St),r=o),s=void 0===(a=(i=r).headers)?{}:a,c=i.signal,u=void 0===(l=i.overrides)?{}:l,e.n=1,this.fetch(this.url,q(q(q({},this.baseOverrides),u),{},{headers:q(q(q({},this.baseOverrides.headers),u.headers),s),method:"GET",redirect:"follow",mode:"cors",signal:c}));case 1:if((d=e.v).ok){e.n=2;break}throw new Error("HTTP ".concat(d.status," fetching ").concat(this.url));case 2:if("utf8"!==n){e.n=3;break}return e.a(2,d.text());case 3:if(!n){e.n=4;break}throw new Error("unsupported encoding: ".concat(n));case 4:if(!d.bytes){e.n=5;break}A=d.bytes(),e.n=7;break;case 5:return f=Uint8Array,e.n=6,d.arrayBuffer();case 6:A=new f(e.v);case 7:return e.a(2,A);case 8:return e.a(2)}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"stat",value:(t=B(U().m((function e(){return U().w((function(e){for(;;)switch(e.n){case 0:if(this._stat){e.n=2;break}return e.n=1,this.read(10,0);case 1:if(this._stat){e.n=2;break}throw new Error("unable to determine size of file at ".concat(this.url));case 2:return e.a(2,this._stat)}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:(e=B(U().m((function e(){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Qt=function(){return D((function e(){N(this,e)}),[{key:"readFile",value:function(){throw new Error("unimplemented")}},{key:"read",value:function(){throw new Error("unimplemented")}},{key:"close",value:function(){throw new Error("unimplemented")}}])}();function Nt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 4294967296*((e[t+4]|e[t+5]<<8|e[t+6]<<16|e[t+7]<<24)>>>0)+((e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0)}function Rt(e,t,n){var r=t[1];return r<=e&&(n?n[1]:Infinity)>e?0:r<e?-1:1}var Dt=function(){return D((function e(t){var n=t.filehandle;N(this,e),T(this,"filehandle",void 0),T(this,"index",void 0),this.filehandle=n}),[{key:"_getIndex",value:function(){var e=this;return this.index||(this.index=this._readIndex().catch((function(t){throw e.index=void 0,t}))),this.index}},{key:"_readIndex",value:(n=B(U().m((function e(){var t,n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.filehandle.read(8,0);case 1:if(t=Nt(e.v)){e.n=2;break}return e.a(2,[[0,0]]);case 2:if((n=new Array(t+1))[0]=[0,0],!((r=16*t)>Number.MAX_SAFE_INTEGER)){e.n=3;break}throw new TypeError("integer overflow");case 3:return e.n=4,this.filehandle.read(r,8);case 4:for(o=e.v,i=0;i<t;i+=1)a=Nt(o,16*i),s=Nt(o,16*i+8),n[i+1]=[a,s];return e.a(2,n)}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getLastBlock",value:(t=B(U().m((function e(){return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndex();case 1:return e.a(2,e.v.at(-1))}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getRelevantBlocksForRead",value:(e=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n+t,0!==t){e.n=1;break}return e.a(2,[]);case 1:return e.n=2,this._getIndex();case 2:for(i=[],a=0,s=(o=e.v).length-1,c=Math.floor(o.length/2),l=Rt(n,o[c],o[c+1]);0!==l;)l>0?s=c-1:l<0&&(a=c+1),c=Math.ceil((s-a)/2)+a,l=Rt(n,o[c],o[c+1]);i.push(o[c]),u=c+1;case 3:if(!(u<o.length)){e.n=5;break}if(i.push(o[u]),!(o[u][1]>=r)){e.n=4;break}return e.a(3,5);case 4:u+=1,e.n=3;break;case 5:return i[i.length-1][1]<r&&i.push([]),e.a(2,i)}}),e,this)}))),function(t,n){return e.apply(this,arguments)})}]);var e,t,n}();function Ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Tt(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)}var jt={arraySet:function(e,t,n,r,o){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),o);else for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){var t,n,r,o,i,a;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(a=new Uint8Array(r),o=0,t=0,n=e.length;t<n;t++)a.set(i=e[t],o),o+=i.length;return a},Buf8:function(e){return new Uint8Array(e)},Buf16:function(e){return new Uint16Array(e)},Buf32:function(e){return new Int32Array(e)}},Mt={arraySet:function(e,t,n,r,o){for(var i=0;i<r;i++)e[o+i]=t[n+i]},flattenChunks:function(e){return[].concat.apply([],e)},Buf8:function(e){return new Array(e)},Buf16:function(e){return new Array(e)},Buf32:function(e){return new Array(e)}},Ot=function(){var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;return Ot=function(){return e},e},Lt=function(e,t,n,r,o){return(Lt=Ot()?jt.arraySet:Mt.arraySet)(e,t,n,r,o)},Pt=function(e){return(Pt=Ot()?jt.flattenChunks:Mt.flattenChunks)(e)},qt=function(e){return(qt=Ot()?jt.Buf8:Mt.Buf8)(e)},Jt=function(e){return(Jt=Ot()?jt.Buf16:Mt.Buf16)(e)},Ut=function(e){return(Ut=Ot()?jt.Buf32:Mt.Buf32)(e)},Gt=function(){var e=!0;try{String.fromCharCode.apply(null,[0])}catch(t){e=!1}return Gt=function(){return e},e},Ht=function(){var e=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){e=!1}return Ht=function(){return e},e},Yt=function(e){for(var t=qt(256),n=0;n<256;n++)t[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;return t[254]=t[254]=1,Yt=function(e){return t[e]},t[e]};function zt(e){var t,n,r,o,i,a=e.length,s=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(r=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(r-56320),o++),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),i=0,o=0;i<s;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(r=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(r-56320),o++),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t}function Kt(e,t){var n,r,o,i,a=t||e.length,s=new Array(2*a);for(r=0,n=0;n<a;)if((o=e[n++])<128)s[r++]=o;else if((i=Yt(o))>4)s[r++]=65533,n+=i-1;else{for(o&=2===i?31:3===i?15:7;i>1&&n<a;)o=o<<6|63&e[n++],i--;i>1?s[r++]=65533:o<65536?s[r++]=o:(s[r++]=55296|(o-=65536)>>10&1023,s[r++]=56320|1023&o)}return function(e,t){if(t<65534&&(e.subarray&&Ht()||!e.subarray&&Gt()))return String.fromCharCode.apply(null,Tt(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}(s,r)}function Wt(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Yt(e[n])>t?n:t}function Vt(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}function $t(e,t,n,r){for(var o=65535&e|0,i=e>>>16&65535|0,a=0;0!==n;){n-=a=n>2e3?2e3:n;do{i=i+(o=o+t[r++]|0)|0}while(--a);o%=65521,i%=65521}return o|i<<16|0}var Xt=function(){var e=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();return Xt=function(){return e},e};function Zt(e,t,n,r){var o=Xt(),i=r+n;e^=-1;for(var a=r;a<i;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}var en=30,tn=12;function nn(e,t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x;E=e.input,o=(r=e.next_in)+(e.avail_in-5),x=e.output,a=(i=e.next_out)-(t-e.avail_out),s=i+(e.avail_out-257),c=(n=e.state).dmax,l=n.wsize,u=n.whave,d=n.wnext,A=n.window,f=n.hold,h=n.bits,g=n.lencode,p=n.distcode,m=(1<<n.lenbits)-1,y=(1<<n.distbits)-1;e:do{h<15&&(f+=E[r++]<<h,f+=E[r++]<<(h+=8),h+=8),_=g[f&m];t:for(;;){if(f>>>=v=_>>>24,h-=v,0==(v=_>>>16&255))x[i++]=65535&_;else{if(!(16&v)){if(0==(64&v)){_=g[(65535&_)+(f&(1<<v)-1)];continue t}if(32&v){n.mode=tn;break e}e.msg="invalid literal/length code",n.mode=en;break e}b=65535&_,(v&=15)&&(h<v&&(f+=E[r++]<<h,h+=8),b+=f&(1<<v)-1,f>>>=v,h-=v),h<15&&(f+=E[r++]<<h,f+=E[r++]<<(h+=8),h+=8),_=p[f&y];n:for(;;){if(f>>>=v=_>>>24,h-=v,!(16&(v=_>>>16&255))){if(0==(64&v)){_=p[(65535&_)+(f&(1<<v)-1)];continue n}e.msg="invalid distance code",n.mode=en;break e}if(C=65535&_,h<(v&=15)&&(f+=E[r++]<<h,(h+=8)<v&&(f+=E[r++]<<h,h+=8)),(C+=f&(1<<v)-1)>c){e.msg="invalid distance too far back",n.mode=en;break e}if(f>>>=v,h-=v,C>(v=i-a)){if((v=C-v)>u&&n.sane){e.msg="invalid distance too far back",n.mode=en;break e}if(I=0,w=A,0===d){if(I+=l-v,v<b){b-=v;do{x[i++]=A[I++]}while(--v);I=i-C,w=x}}else if(d<v){if(I+=l+d-v,(v-=d)<b){b-=v;do{x[i++]=A[I++]}while(--v);if(I=0,d<b){b-=v=d;do{x[i++]=A[I++]}while(--v);I=i-C,w=x}}}else if(I+=d-v,v<b){b-=v;do{x[i++]=A[I++]}while(--v);I=i-C,w=x}for(;b>2;)x[i++]=w[I++],x[i++]=w[I++],x[i++]=w[I++],b-=3;b&&(x[i++]=w[I++],b>1&&(x[i++]=w[I++]))}else{I=i-C;do{x[i++]=x[I++],x[i++]=x[I++],x[i++]=x[I++],b-=3}while(b>2);b&&(x[i++]=x[I++],b>1&&(x[i++]=x[I++]))}break}}break}}while(r<o&&i<s);f&=(1<<(h-=(b=h>>3)<<3))-1,e.next_in=r-=b,e.next_out=i,e.avail_in=r<o?o-r+5:5-(r-o),e.avail_out=i<s?s-i+257:257-(i-s),n.hold=f,n.bits=h}var rn=15,on=852,an=592,sn=0,cn=1,ln=2,un=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],dn=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],An=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],fn=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function hn(e,t,n,r,o,i,a,s){var c,l,u,d,A,f,h,g,p,m=s.bits,y=0,_=0,v=0,b=0,C=0,I=0,w=0,E=0,x=0,S=0,B=null,k=0,Q=Jt(rn+1),N=Jt(rn+1),R=null,D=0;for(y=0;y<=rn;y++)Q[y]=0;for(_=0;_<r;_++)Q[t[n+_]]++;for(C=m,b=rn;b>=1&&0===Q[b];b--);if(C>b&&(C=b),0===b)return o[i++]=20971520,o[i++]=20971520,s.bits=1,0;for(v=1;v<b&&0===Q[v];v++);for(C<v&&(C=v),E=1,y=1;y<=rn;y++)if(E<<=1,(E-=Q[y])<0)return-1;if(E>0&&(e===sn||1!==b))return-1;for(N[1]=0,y=1;y<rn;y++)N[y+1]=N[y]+Q[y];for(_=0;_<r;_++)0!==t[n+_]&&(a[N[t[n+_]]++]=_);if(e===sn?(B=R=a,f=19):e===cn?(B=un,k-=257,R=dn,D-=257,f=256):(B=An,R=fn,f=-1),S=0,_=0,y=v,A=i,I=C,w=0,u=-1,d=(x=1<<C)-1,e===cn&&x>on||e===ln&&x>an)return 1;for(;;){h=y-w,a[_]<f?(g=0,p=a[_]):a[_]>f?(g=R[D+a[_]],p=B[k+a[_]]):(g=96,p=0),c=1<<y-w,v=l=1<<I;do{o[A+(S>>w)+(l-=c)]=h<<24|g<<16|p|0}while(0!==l);for(c=1<<y-1;S&c;)c>>=1;if(0!==c?(S&=c-1,S+=c):S=0,_++,0==--Q[y]){if(y===b)break;y=t[n+a[_]]}if(y>C&&(S&d)!==u){for(0===w&&(w=C),A+=v,E=1<<(I=y-w);I+w<b&&!((E-=Q[I+w])<=0);)I++,E<<=1;if(x+=1<<I,e===cn&&x>on||e===ln&&x>an)return 1;o[u=S&d]=C<<24|I<<16|A-i|0}}return 0!==S&&(o[A+S]=y-w<<24|64<<16|0),s.bits=C,0}var gn=1,pn=2,mn=-2,yn=12,_n=30;function vn(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function bn(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=Jt(320),this.work=Jt(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Cn,In,wn=!0;function En(e){if(wn){var t;for(Cn=Ut(512),In=Ut(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(hn(gn,e.lens,0,288,Cn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;hn(pn,e.lens,0,32,In,0,e.work,{bits:5}),wn=!1}e.lencode=Cn,e.lenbits=9,e.distcode=In,e.distbits=5}function xn(e,t,n,r){var o,i=e.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=qt(i.wsize)),r>=i.wsize?(Lt(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):((o=i.wsize-i.wnext)>r&&(o=r),Lt(i.window,t,n-r,o,i.wnext),(r-=o)?(Lt(i.window,t,n-r,r,0),i.wnext=r,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=o))),0}function Sn(e,t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x=0,S=qt(4),B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return mn;(n=e.state).mode===yn&&(n.mode=13),a=e.next_out,o=e.output,i=e.next_in,r=e.input,l=n.hold,u=n.bits,d=s=e.avail_in,A=c=e.avail_out,I=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;u<16;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(2&n.wrap&&35615===l){n.check=0,S[0]=255&l,S[1]=l>>>8&255,n.check=Zt(n.check,S,2,0),l=0,u=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=_n;break}if(8!=(15&l)){e.msg="unknown compression method",n.mode=_n;break}if(u-=4,C=8+(15&(l>>>=4)),0===n.wbits)n.wbits=C;else if(C>n.wbits){e.msg="invalid window size",n.mode=_n;break}n.dmax=1<<C,e.adler=n.check=1,n.mode=512&l?10:yn,l=0,u=0;break;case 2:for(;u<16;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(n.flags=l,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=_n;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=_n;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&(S[0]=255&l,S[1]=l>>>8&255,n.check=Zt(n.check,S,2,0)),l=0,u=0,n.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.head&&(n.head.time=l),512&n.flags&&(S[0]=255&l,S[1]=l>>>8&255,S[2]=l>>>16&255,S[3]=l>>>24&255,n.check=Zt(n.check,S,4,0)),l=0,u=0,n.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&(S[0]=255&l,S[1]=l>>>8&255,n.check=Zt(n.check,S,2,0)),l=0,u=0,n.mode=5;case 5:if(1024&n.flags){for(;u<16;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&(S[0]=255&l,S[1]=l>>>8&255,n.check=Zt(n.check,S,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((f=n.length)>s&&(f=s),f&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Lt(n.head.extra,r,i,f,C)),512&n.flags&&(n.check=Zt(n.check,r,f,i)),s-=f,i+=f,n.length-=f),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===s)break e;f=0;do{C=r[i+f++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C))}while(C&&f<s);if(512&n.flags&&(n.check=Zt(n.check,r,f,i)),s-=f,i+=f,C)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===s)break e;f=0;do{C=r[i+f++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C))}while(C&&f<s);if(512&n.flags&&(n.check=Zt(n.check,r,f,i)),s-=f,i+=f,C)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;u<16;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(l!==(65535&n.check)){e.msg="header crc mismatch",n.mode=_n;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=yn;break;case 10:for(;u<32;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}e.adler=n.check=vn(l),l=0,u=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=a,e.avail_out=c,e.next_in=i,e.avail_in=s,n.hold=l,n.bits=u,2;e.adler=n.check=1,n.mode=yn;case yn:case 13:if(n.last){l>>>=7&u,u-=7&u,n.mode=27;break}for(;u<3;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}switch(n.last=1&l,u-=1,3&(l>>>=1)){case 0:n.mode=14;break;case 1:En(n),n.mode=20;break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=_n}l>>>=2,u-=2;break;case 14:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=_n;break}n.length=65535&l,l=0,u=0,n.mode=15;case 15:n.mode=16;case 16:if(f=n.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;Lt(o,r,i,f,a),s-=f,i+=f,c-=f,a+=f,n.length-=f;break}n.mode=yn;break;case 17:for(;u<14;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(n.nlen=257+(31&l),u-=5,n.ndist=1+(31&(l>>>=5)),u-=5,n.ncode=4+(15&(l>>>=5)),l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=_n;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;u<3;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.lens[B[n.have++]]=7&l,l>>>=3,u-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,I=hn(0,n.lens,0,19,n.lencode,0,n.work,w={bits:n.lenbits}),n.lenbits=w.bits,I){e.msg="invalid code lengths set",n.mode=_n;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;m=(x=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&x,!((p=x>>>24)<=u);){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(y<16)l>>>=p,u-=p,n.lens[n.have++]=y;else{if(16===y){for(E=p+2;u<E;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(l>>>=p,u-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=_n;break}C=n.lens[n.have-1],f=3+(3&l),l>>>=2,u-=2}else if(17===y){for(E=p+3;u<E;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}u-=p,C=0,f=3+(7&(l>>>=p)),l>>>=3,u-=3}else{for(E=p+7;u<E;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}u-=p,C=0,f=11+(127&(l>>>=p)),l>>>=7,u-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=_n;break}for(;f--;)n.lens[n.have++]=C}}if(n.mode===_n)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=_n;break}if(n.lenbits=9,I=hn(gn,n.lens,0,n.nlen,n.lencode,0,n.work,w={bits:n.lenbits}),n.lenbits=w.bits,I){e.msg="invalid literal/lengths set",n.mode=_n;break}if(n.distbits=6,n.distcode=n.distdyn,I=hn(pn,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,w={bits:n.distbits}),n.distbits=w.bits,I){e.msg="invalid distances set",n.mode=_n;break}n.mode=20;case 20:n.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=i,e.avail_in=s,n.hold=l,n.bits=u,nn(e,A),a=e.next_out,o=e.output,c=e.avail_out,i=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===yn&&(n.back=-1);break}for(n.back=0;m=(x=n.lencode[l&(1<<n.lenbits)-1])>>>16&255,y=65535&x,!((p=x>>>24)<=u);){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(m&&0==(240&m)){for(_=p,v=m,b=y;m=(x=n.lencode[b+((l&(1<<_+v)-1)>>_)])>>>16&255,y=65535&x,!(_+(p=x>>>24)<=u);){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}l>>>=_,u-=_,n.back+=_}if(l>>>=p,u-=p,n.back+=p,n.length=y,0===m){n.mode=26;break}if(32&m){n.back=-1,n.mode=yn;break}if(64&m){e.msg="invalid literal/length code",n.mode=_n;break}n.extra=15&m,n.mode=22;case 22:if(n.extra){for(E=n.extra;u<E;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;m=(x=n.distcode[l&(1<<n.distbits)-1])>>>16&255,y=65535&x,!((p=x>>>24)<=u);){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(0==(240&m)){for(_=p,v=m,b=y;m=(x=n.distcode[b+((l&(1<<_+v)-1)>>_)])>>>16&255,y=65535&x,!(_+(p=x>>>24)<=u);){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}l>>>=_,u-=_,n.back+=_}if(l>>>=p,u-=p,n.back+=p,64&m){e.msg="invalid distance code",n.mode=_n;break}n.offset=y,n.extra=15&m,n.mode=24;case 24:if(n.extra){for(E=n.extra;u<E;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=_n;break}n.mode=25;case 25:if(0===c)break e;if(n.offset>(f=A-c)){if((f=n.offset-f)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=_n;break}h=f>n.wnext?n.wsize-(f-=n.wnext):n.wnext-f,f>n.length&&(f=n.length),g=n.window}else g=o,h=a-n.offset,f=n.length;f>c&&(f=c),c-=f,n.length-=f;do{o[a++]=g[h++]}while(--f);0===n.length&&(n.mode=21);break;case 26:if(0===c)break e;o[a++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;u<32;){if(0===s)break e;s--,l|=r[i++]<<u,u+=8}if(e.total_out+=A-=c,n.total+=A,A&&(e.adler=n.check=n.flags?Zt(n.check,o,A,a-A):$t(n.check,o,A,a-A)),A=c,(n.flags?l:vn(l))!==n.check){e.msg="incorrect data check",n.mode=_n;break}l=0,u=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;u<32;){if(0===s)break e;s--,l+=r[i++]<<u,u+=8}if(l!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=_n;break}l=0,u=0}n.mode=29;case 29:I=1;break e;case _n:I=-3;break e;case 31:return-4;default:return mn}return e.next_out=a,e.avail_out=c,e.next_in=i,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||A!==e.avail_out&&n.mode<_n&&(n.mode<27||4!==t))&&xn(e,e.output,e.next_out,A-e.avail_out),A-=e.avail_out,e.total_in+=d-=e.avail_in,e.total_out+=A,n.total+=A,n.wrap&&A&&(e.adler=n.check=n.flags?Zt(n.check,o,A,e.next_out-A):$t(n.check,o,A,e.next_out-A)),e.data_type=n.bits+(n.last?64:0)+(n.mode===yn?128:0)+(20===n.mode||15===n.mode?256:0),(0===d&&0===A||4===t)&&0===I&&(I=-5),I}function Bn(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?mn:11===n.mode&&$t(1,t,r,0)!==n.check?-3:xn(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):mn}var kn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Qn(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Nn=Object.prototype.toString,Rn=function(){return D((function e(t){if(N(this,e),!(this instanceof e))return new e(t);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==X(n))throw new TypeError(n+"must be non-object");for(var r in n)Ft(n,r)&&(e[r]=n[r])}}return e}({chunkSize:16384,windowBits:0,to:""},t||{});var n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,0===n.windowBits&&(n.windowBits=-15)),!(n.windowBits>=0&&n.windowBits<16)||t&&t.windowBits||(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&0==(15&n.windowBits)&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qn,this.strm.avail_out=0;var r,o,i,a=function(e,t){var n,r;return e?(r=new bn,e.state=r,r.window=null,n=function(e,t){var n,r;return e&&e.state?(t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?mn:(null!==(r=e.state).window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,function(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(e.total_in=e.total_out=(t=e.state).total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=Ut(852),t.distcode=t.distdyn=Ut(592),t.sane=1,t.back=-1,0):mn}(e)):mn}(e))):mn}(e,t),0!==n&&(e.state=null),n):mn}(this.strm,n.windowBits);if(0!==a)throw new Error(kn[a]);if(this.header=new Vt,o=this.header,(r=this.strm)&&r.state&&(0==(2&(i=r.state).wrap)||(i.head=o,o.done=!1)),n.dictionary&&("string"==typeof n.dictionary?n.dictionary=zt(n.dictionary):"[object ArrayBuffer]"===Nn.call(n.dictionary)&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&0!==(a=Bn(this.strm,n.dictionary))))throw new Error(kn[a])}),[{key:"push",value:function(e,t){var n,r,o,i,a,s,c=this.strm,l=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?4:0,c.input="string"==typeof e?function(e){for(var t=new Uint8Array(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t}(e):"[object ArrayBuffer]"===Nn.call(e)?new Uint8Array(e):e,c.next_in=0,c.avail_in=c.input.length;do{if(0===c.avail_out&&(c.output=qt(l),c.next_out=0,c.avail_out=l),2===(n=Sn(c,0))&&u&&(s="string"==typeof u?zt(u):"[object ArrayBuffer]"===Nn.call(u)?new Uint8Array(u):u,n=Bn(this.strm,s)),-5===n&&!0===d&&(n=0,d=!1),1!==n&&0!==n)return this.onEnd(n),this.ended=!0,!1;c.next_out&&(0!==c.avail_out&&1!==n&&(0!==c.avail_in||4!==r&&2!==r)||("string"===this.options.to?(o=Wt(c.output,c.next_out),i=c.next_out-o,a=Kt(c.output,o),c.next_out=i,c.avail_out=l-i,i&&Lt(c.output,c.output,o,i,0),this.onData(a)):this.onData(Tt(c.output,c.next_out)))),0===c.avail_in&&0===c.avail_out&&(d=!0)}while((c.avail_in>0||0===c.avail_out)&&1!==n);return 1===n&&(r=4),4===r?(n=function(e){if(!e||!e.state)return mn;var t=e.state;return t.window&&(t.window=null),e.state=null,0}(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==r||(this.onEnd(0),c.avail_out=0,!0)}},{key:"onData",value:function(e){this.chunks.push(e)}},{key:"onEnd",value:function(e){0===e&&(this.result="string"===this.options.to?this.chunks.join(""):Pt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}}])}(),Dn=function(e,t){var n=new Rn(t);if(n.push(e,!0),n.err)throw n.msg||kn[n.err];return n.result},Fn={d:function(e,t){for(var n in t)Fn.o(t,n)&&!Fn.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},Tn={};Fn.r(Tn),Fn.d(Tn,{ChunkSliceResult:function(){return Mn},DecompressResult:function(){return On},__wbg_Error_8c4e43fe74559d73:function(){return Jn},__wbg___wbindgen_throw_be289d5034ed271b:function(){return Un},__wbg_set_wasm:function(){return lr},decompress_all:function(){return Ln},decompress_block:function(){return Pn},decompress_chunk_slice:function(){return qn}});var jn="data:application/wasm;base64,AGFzbQEAAAABfRFgAABgAAF/YAF/AGABfwF/YAJ/fwBgAn9/AX9gA39/fwBgA39/fwF/YAR/f39/AGAEf39/fwF/YAV/f39/fwBgBX9/f39/AX9gBn9/f39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gCH9/f39/f39/AX9gB39/f3x8fHwAAm4CES4vYmd6Zl93YXNtX2JnLmpzJ19fd2JnX19fd2JpbmRnZW5fdGhyb3dfYmUyODlkNTAzNGVkMjcxYgAEES4vYmd6Zl93YXNtX2JnLmpzHF9fd2JnX0Vycm9yXzhjNGU0M2ZlNzQ1NTlkNzMABQNragMODxAFCQ0CBwcGCAQFBAQFBQQGBAQEBAQQBgQKBAwMCgIGBQIMAgQGBgYGBgYDBAMHAgUDBAgGCwAFAgIGBAIFBAMBBQQCAgQEBAQFBg0CBwkFBAYEAwUFAAQABQQEBQQFAgICBAEFAAAEBQFwARgYBQMBABEGCQF/AUGAgMAACwfaAg4GbWVtb3J5AgAbX193YmdfY2h1bmtzbGljZXJlc3VsdF9mcmVlABgbX193YmdfZGVjb21wcmVzc3Jlc3VsdF9mcmVlAB0XY2h1bmtzbGljZXJlc3VsdF9idWZmZXIAGRtjaHVua3NsaWNlcmVzdWx0X2Nwb3NpdGlvbnMAFhtjaHVua3NsaWNlcmVzdWx0X2Rwb3NpdGlvbnMAFw5kZWNvbXByZXNzX2FsbAAcEGRlY29tcHJlc3NfYmxvY2sAFRZkZWNvbXByZXNzX2NodW5rX3NsaWNlABsbZGVjb21wcmVzc3Jlc3VsdF9ieXRlc19yZWFkADIVZGVjb21wcmVzc3Jlc3VsdF9kYXRhABofX193YmluZGdlbl9hZGRfdG9fc3RhY2tfcG9pbnRlcgBYEV9fd2JpbmRnZW5fZXhwb3J0AE8SX193YmluZGdlbl9leHBvcnQyADwJHQEAQQELF0RJKRJCMUNnSDMTXlQ3VV9BJRQfTEthCsPRAWrOJAIJfwF+IwBBEGsiASQAAkACQAJAAkACQAJAIABB9QFJDQACQCAAQcz/e00NAEEAIQAMBgsgAEELaiICQXhxIQNBACgCiJxAIgRFDQRBHyEFAkAgAEH0//8HSw0AIANBJiACQQh2ZyIAa3ZBAXEgAEEBdGtBPmohBQtBACADayECAkAgBUECdEHsmMAAaigCACIGDQBBACEHQQAhAAwCC0EAIQcgA0EAQRkgBUEBdmsgBUEfRht0IQhBACEAA0ACQCAGIgYoAgRBeHEiCSADSQ0AIAkgA2siCSACTw0AIAYhByAJIQIgCQ0AQQAhAiAGIQAgBiEHDAQLIAYoAhQiCSAAIAkgBiAIQR12QQRxaigCECIGRxsgACAJGyEAIAhBAXQhCCAGRQ0CDAALCwJAAkACQAJAAkACQEEAKAKEnEAiBkEQIABBC2pB+ANxIABBC0kbIgNBA3YiAnYiAEEDcUUNACAAQX9zQQFxIAJqIghBA3QiA0H8mcAAaiIAIANBhJrAAGooAgAiAigCCCIHRg0BIAcgADYCDCAAIAc2AggMAgsgA0EAKAKMnEBNDQggAA0CQQAoAoicQCIARQ0IIABoQQJ0QeyYwABqKAIAIgYoAgRBeHEgA2shAiAGIQcDQAJAIAcoAhAiAA0AIAcoAhQiAA0AIAYoAhghBQJAAkACQCAGKAIMIgAgBkcNACAGQRRBECAGKAIUIgAbaigCACIHDQFBACEADAILIAYoAggiByAANgIMIAAgBzYCCAwBCyAGQRRqIAZBEGogABshCANAIAghCSAHIgBBFGogAEEQaiAAKAIUIgcbIQggAEEUQRAgBxtqKAIAIgcNAAsgCUEANgIACyAFRQ0GAkACQCAGIAYoAhxBAnRB7JjAAGoiBygCAEYNAAJAIAUoAhAgBkYNACAFIAA2AhQgAA0CDAkLIAUgADYCECAADQEMCAsgByAANgIAIABFDQYLIAAgBTYCGAJAIAYoAhAiB0UNACAAIAc2AhAgByAANgIYCyAGKAIUIgdFDQYgACAHNgIUIAcgADYCGAwGCyAAKAIEQXhxIANrIgcgAiAHIAJJIgcbIQIgACAGIAcbIQYgACEHDAALC0EAIAZBfiAId3E2AoScQAsgAkEIaiEAIAIgA0EDcjYCBCACIANqIgMgAygCBEEBcjYCBAwHCwJAAkAgACACdEECIAJ0IgBBACAAa3JxaCIJQQN0IgJB/JnAAGoiByACQYSawABqKAIAIgAoAggiCEYNACAIIAc2AgwgByAINgIIDAELQQAgBkF+IAl3cTYChJxACyAAIANBA3I2AgQgACADaiIGIAIgA2siB0EBcjYCBCAAIAJqIAc2AgACQEEAKAKMnEAiAkUNAEEAKAKUnEAhAwJAAkBBACgChJxAIghBASACQQN2dCIJcQ0AQQAgCCAJcjYChJxAIAJBeHFB/JnAAGoiAiEIDAELIAJBeHEiAkH8mcAAaiEIIAJBhJrAAGooAgAhAgsgCCADNgIIIAIgAzYCDCADIAg2AgwgAyACNgIICyAAQQhqIQBBACAGNgKUnEBBACAHNgKMnEAMBgtBAEEAKAKInEBBfiAGKAIcd3E2AoicQAsCQAJAAkAgAkEQSQ0AIAYgA0EDcjYCBCAGIANqIgcgAkEBcjYCBCAHIAJqIAI2AgBBACgCjJxAIghFDQFBACgClJxAIQACQAJAQQAoAoScQCIJQQEgCEEDdnQiBXENAEEAIAkgBXI2AoScQCAIQXhxQfyZwABqIgghCQwBCyAIQXhxIghB/JnAAGohCSAIQYSawABqKAIAIQgLIAkgADYCCCAIIAA2AgwgACAJNgIMIAAgCDYCCAwBCyAGIAIgA2oiAEEDcjYCBCAGIABqIgAgACgCBEEBcjYCBAwBC0EAIAc2ApScQEEAIAI2AoycQAsgBkEIaiIARQ0DDAQLAkAgACAHcg0AQQAhB0ECIAV0IgBBACAAa3IgBHEiAEUNAyAAaEECdEHsmMAAaigCACEACyAARQ0BCwNAIAAoAgRBeHEiBiADayIIIAIgCCACSSIJGyEFIAYgA0khCCAAIAcgCRshCQJAIAAoAhAiBg0AIAAoAhQhBgsgAiAFIAgbIQIgByAJIAgbIQcgBiEAIAYNAAsLIAdFDQACQEEAKAKMnEAiACADSQ0AIAIgACADa08NAQsgBygCGCEFAkACQAJAIAcoAgwiACAHRw0AIAdBFEEQIAcoAhQiABtqKAIAIgYNAUEAIQAMAgsgBygCCCIGIAA2AgwgACAGNgIIDAELIAdBFGogB0EQaiAAGyEIA0AgCCEJIAYiAEEUaiAAQRBqIAAoAhQiBhshCCAAQRRBECAGG2ooAgAiBg0ACyAJQQA2AgALAkAgBUUNAAJAAkACQCAHIAcoAhxBAnRB7JjAAGoiBigCAEYNAAJAIAUoAhAgB0YNACAFIAA2AhQgAA0CDAQLIAUgADYCECAADQEMAwsgBiAANgIAIABFDQELIAAgBTYCGAJAIAcoAhAiBkUNACAAIAY2AhAgBiAANgIYCyAHKAIUIgZFDQEgACAGNgIUIAYgADYCGAwBC0EAQQAoAoicQEF+IAcoAhx3cTYCiJxACwJAAkAgAkEQSQ0AIAcgA0EDcjYCBCAHIANqIgAgAkEBcjYCBCAAIAJqIAI2AgACQCACQYACSQ0AIAAgAhARDAILAkACQEEAKAKEnEAiBkEBIAJBA3Z0IghxDQBBACAGIAhyNgKEnEAgAkH4AXFB/JnAAGoiAiEGDAELIAJB+AFxIgJB/JnAAGohBiACQYSawABqKAIAIQILIAYgADYCCCACIAA2AgwgACAGNgIMIAAgAjYCCAwBCyAHIAIgA2oiAEEDcjYCBCAHIABqIgAgACgCBEEBcjYCBAsgB0EIaiIADQELAkACQAJAAkACQAJAQQAoAoycQCIAIANPDQACQEEAKAKQnEAiACADSw0AIAFBBGpBsJzAACADQa+ABGpBgIB8cRAuAkAgASgCBCIGDQBBACEADAgLIAEoAgwhBUEAQQAoApycQCABKAIIIglqIgA2ApycQEEAIABBACgCoJxAIgIgACACSxs2AqCcQAJAAkACQEEAKAKYnEAiAkUNAEHsmcAAIQADQCAGIAAoAgAiByAAKAIEIghqRg0CIAAoAggiAA0ADAMLCwJAAkBBACgCqJxAIgBFDQAgBiAATw0BC0EAIAY2AqicQAtBAEH/HzYCrJxAQQAgBTYC+JlAQQAgCTYC8JlAQQAgBjYC7JlAQQBB/JnAADYCiJpAQQBBhJrAADYCkJpAQQBB/JnAADYChJpAQQBBjJrAADYCmJpAQQBBhJrAADYCjJpAQQBBlJrAADYCoJpAQQBBjJrAADYClJpAQQBBnJrAADYCqJpAQQBBlJrAADYCnJpAQQBBpJrAADYCsJpAQQBBnJrAADYCpJpAQQBBrJrAADYCuJpAQQBBpJrAADYCrJpAQQBBtJrAADYCwJpAQQBBrJrAADYCtJpAQQBBvJrAADYCyJpAQQBBtJrAADYCvJpAQQBBvJrAADYCxJpAQQBBxJrAADYC0JpAQQBBxJrAADYCzJpAQQBBzJrAADYC2JpAQQBBzJrAADYC1JpAQQBB1JrAADYC4JpAQQBB1JrAADYC3JpAQQBB3JrAADYC6JpAQQBB3JrAADYC5JpAQQBB5JrAADYC8JpAQQBB5JrAADYC7JpAQQBB7JrAADYC+JpAQQBB7JrAADYC9JpAQQBB9JrAADYCgJtAQQBB9JrAADYC/JpAQQBB/JrAADYCiJtAQQBBhJvAADYCkJtAQQBB/JrAADYChJtAQQBBjJvAADYCmJtAQQBBhJvAADYCjJtAQQBBlJvAADYCoJtAQQBBjJvAADYClJtAQQBBnJvAADYCqJtAQQBBlJvAADYCnJtAQQBBpJvAADYCsJtAQQBBnJvAADYCpJtAQQBBrJvAADYCuJtAQQBBpJvAADYCrJtAQQBBtJvAADYCwJtAQQBBrJvAADYCtJtAQQBBvJvAADYCyJtAQQBBtJvAADYCvJtAQQBBxJvAADYC0JtAQQBBvJvAADYCxJtAQQBBzJvAADYC2JtAQQBBxJvAADYCzJtAQQBB1JvAADYC4JtAQQBBzJvAADYC1JtAQQBB3JvAADYC6JtAQQBB1JvAADYC3JtAQQBB5JvAADYC8JtAQQBB3JvAADYC5JtAQQBB7JvAADYC+JtAQQBB5JvAADYC7JtAQQBB9JvAADYCgJxAQQBB7JvAADYC9JtAQQAgBkEPakF4cSIAQXhqIgI2ApicQEEAQfSbwAA2AvybQEEAIAYgAGsgCUFYaiIAakEIaiIHNgKQnEAgAiAHQQFyNgIEIAYgAGpBKDYCBEEAQYCAgAE2AqScQAwICyACIAZPDQAgByACSw0AIAAoAgwiB0EBcQ0AIAdBAXYgBUYNAwtBAEEAKAKonEAiACAGIAAgBkkbNgKonEAgBiAJaiEHQeyZwAAhAAJAAkACQANAIAAoAgAiCCAHRg0BIAAoAggiAA0ADAILCyAAKAIMIgdBAXENACAHQQF2IAVGDQELQeyZwAAhAAJAA0ACQCAAKAIAIgcgAksNACACIAcgACgCBGoiB0kNAgsgACgCCCEADAALC0EAIAZBD2pBeHEiAEF4aiIINgKYnEBBACAGIABrIAlBWGoiAGpBCGoiBDYCkJxAIAggBEEBcjYCBCAGIABqQSg2AgRBAEGAgIABNgKknEAgAiAHQWBqQXhxQXhqIgAgACACQRBqSRsiCEEbNgIEQQApAuyZQCEKIAhBEGpBACkC9JlANwIAIAhBCGoiACAKNwIAQQAgBTYC+JlAQQAgCTYC8JlAQQAgBjYC7JlAQQAgADYC9JlAIAhBHGohAANAIABBBzYCACAAQQRqIgAgB0kNAAsgCCACRg0HIAggCCgCBEF+cTYCBCACIAggAmsiAEEBcjYCBCAIIAA2AgACQCAAQYACSQ0AIAIgABARDAgLAkACQEEAKAKEnEAiB0EBIABBA3Z0IgZxDQBBACAHIAZyNgKEnEAgAEH4AXFB/JnAAGoiACEHDAELIABB+AFxIgBB/JnAAGohByAAQYSawABqKAIAIQALIAcgAjYCCCAAIAI2AgwgAiAHNgIMIAIgADYCCAwHCyAAIAY2AgAgACAAKAIEIAlqNgIEIAZBD2pBeHFBeGoiByADQQNyNgIEIAhBD2pBeHFBeGoiAiAHIANqIgBrIQMgAkEAKAKYnEBGDQMgAkEAKAKUnEBGDQQCQCACKAIEIgZBA3FBAUcNACACIAZBeHEiBhAQIAYgA2ohAyACIAZqIgIoAgQhBgsgAiAGQX5xNgIEIAAgA0EBcjYCBCAAIANqIAM2AgACQCADQYACSQ0AIAAgAxARDAYLAkACQEEAKAKEnEAiAkEBIANBA3Z0IgZxDQBBACACIAZyNgKEnEAgA0H4AXFB/JnAAGoiAyECDAELIANB+AFxIgNB/JnAAGohAiADQYSawABqKAIAIQMLIAIgADYCCCADIAA2AgwgACACNgIMIAAgAzYCCAwFC0EAIAAgA2siAjYCkJxAQQBBACgCmJxAIgAgA2oiBzYCmJxAIAcgAkEBcjYCBCAAIANBA3I2AgQgAEEIaiEADAYLQQAoApScQCECAkACQCAAIANrIgdBD0sNAEEAQQA2ApScQEEAQQA2AoycQCACIABBA3I2AgQgAiAAaiIAIAAoAgRBAXI2AgQMAQtBACAHNgKMnEBBACACIANqIgY2ApScQCAGIAdBAXI2AgQgAiAAaiAHNgIAIAIgA0EDcjYCBAsgAkEIaiEADAULIAAgCCAJajYCBEEAQQAoApicQCIAQQ9qQXhxIgJBeGoiBzYCmJxAQQAgACACa0EAKAKQnEAgCWoiAmpBCGoiBjYCkJxAIAcgBkEBcjYCBCAAIAJqQSg2AgRBAEGAgIABNgKknEAMAwtBACAANgKYnEBBAEEAKAKQnEAgA2oiAzYCkJxAIAAgA0EBcjYCBAwBC0EAIAA2ApScQEEAQQAoAoycQCADaiIDNgKMnEAgACADQQFyNgIEIAAgA2ogAzYCAAsgB0EIaiEADAELQQAhAEEAKAKQnEAiAiADTQ0AQQAgAiADayICNgKQnEBBAEEAKAKYnEAiACADaiIHNgKYnEAgByACQQFyNgIEIAAgA0EDcjYCBCAAQQhqIQALIAFBEGokACAAC7wdARZ/IAEgAmoiByACQREgAkERSRtrIQggAyAEaiIJIARBlwIgBEGXAkkbayEKIABBpNoAaiELIABBmMkAaiEMIABB4NUAaiENIABBzANqIQ5BACEPQQAhEEEAIQIgASERIAMhBAJAAkADQAJAAkAgByARa0EDSw0AIAIhEiAQQf8BcSICQRdLDQEDQAJAAkAgESAHRg0AIBEtAAAgAnQgEnIhEiARQQFqIREMAQtBASETIA9BAWoiD0EESw0FCyAQQQhqIhBB/wFxIgJBGEkNAAwCCwsgESgAACAQQf8BcXQgAnIhEiARIBBBA3ZBB3FrQQNqIREgEEEYciEQC0EBIRMCQAJAAkACQAJAAkAgEkEBdkEDcQ4EBAEABwQLQQAhFCAAQQA6AKBaIBBBb2ohAiASQRF2IRUgEkENdiIWQQ9xIhdBBGohECASQQh2QR9xQQFqIRggEkEDdkEfcUGBAmohGQNAAkACQCACQf8BcSITQQJNDQAgAiEaDAELAkAgByARa0EDSw0AIAIhGgNAAkACQCARIAdGDQAgES0AACATdCAVciEVIBFBAWohEQwBC0EBIRMgD0EBaiIPQQRLDQsLIBpBCGoiGkH/AXEiE0EYSQ0ADAILCyACQRhyIRogESgAACATdCAVciEVIBEgAkEDdkEHcWtBA2ohEQsgACAUQfCGwABqLQAAaiAVQQdxOgAAIBpBfWohAiAVQQN2IRUgFEEBaiIUIBBHDQALAkAgF0EPRg0AAkAgFkEDcSIaQQNGDQBBBCEQA0AgACAXIBBqQfCGwABqLQAAakEAOgAAIBBBfWohFCAQQQFqIhMhECAaIBRzQQNHDQALIBcgE2ohEAsgF0F0akEDSQ0AA0AgACAQQfCGwABqLQAAakEAOgAAIAAgEEHxhsAAai0AAGpBADoAACAAIBBB8obAAGotAABqQQA6AAAgACAQQfOGwABqLQAAakEAOgAAIBBBBGoiEEETRw0ACwsCQCAOIABBE0GQh8AAQQdBByANQQAQBA0AQQEPCyAZIBhqIRdBACEQA0ACQAJAIAJB/wFxIhRBDU0NACACIRoMAQsCQCAHIBFrQQNLDQAgAiEaA0ACQAJAIBEgB0YNACARLQAAIBR0IBVyIRUgEUEBaiERDAELQQEhEyAPQQFqIg9BBEsNCwsgGkEIaiIaQf8BcSIUQRhJDQAMAgsLIAJBGHIhGiARKAAAIBR0IBVyIRUgESACQQN2QQdxa0EDaiERCyAOIBVB/wBxQQJ0aigCACIUQRB2IRMgGiAUayECIBUgFEH/AXF2IRUCQAJAIBRB//8/Sw0AIAAgEGogEzoAACAQQQFqIRAMAQsCQAJAAkACQCATQXBqDgIAAQILAkAgEA0AQQEPCyAAIBBqIhRBBWogFEF/ai0AACIaOgAAIBRBBGogGjoAACAUQQNqIBo6AAAgFEECaiAaOgAAIBRBAWogGjoAACAUIBo6AAAgAkF+aiECIBVBA3FBA2ohFCAVQQJ2IRUMAgsgACAQaiIUQgA3AAAgFEEIakEAOwAAIAJBfWohAiAVQQdxQQNqIRQgFUEDdiEVDAELAkAgFUH/AHFBC2oiFEUNACAAIBBqQQAgFPwLAAsgAkF5aiECIBVBB3YhFQsgFCAQaiEQCyAQIBdJDQALIBAgF0YNAUEBDwsgEEF9aiECIBJBA3YhFSAALQCgWg0BIABBAToAoFpBACEQA0AgACAQaiIUQoiQoMCAgYKECDcAACAUQQhqQQg6AAAgEEEJaiIQQZABRw0AC0GQfyEQA0AgACAQakGAAmpCiZKkyJChwoQJNwAAIBBBCGoiEA0ACyAAQoWKlKjQoMGCBTcAuAIgAEKFipSo0KDBggU3ALACIABChYqUqNCgwYIFNwCoAiAAQoWKlKjQoMGCBTcAoAIgAEKIkKDAgIGChAg3AJgCIABCh46cuPDgwYMHNwCQAiAAQoeOnLjw4MGDBzcAiAIgAEKHjpy48ODBgwc3AIACQSAhGEGgAiEZCwJAIAwgACAZaiAYQeCHwABBCEEPIA1BABAEDQBBAQ8LIAAgACAZQeCIwABBC0EPIA0gCxAEDQBBAQ8LQX8gCygCAHRBf3MhFwJAAkAgESAITw0AIAQgCk8NACACQRhyIRAgESACQQN2QQdxa0EDaiEUIAAgESgAACACQf8BcXQgFXIiFSAXcUECdGooAgAhGANAIBAgGGshECAVIBhB/wFxIhN2IQICQAJAAkACQCAYQQBIDQACQCAYQYCAAnENACACIREMAwsCQCAYQYDAAHFFDQAgFCERDAkLIBAgACACQX8gGEEIdnRBf3NxIBhBEHZqQQJ0aigCACIYayEQIAIgGEH/AXEiE3YhESAYQQBODQEgESECCyAEIBhBEHY6AAAgBEEBaiEEIBQoAAAgEEH/AXF0IAJyIRUgFCAQQQN2QQdxa0EDaiEUIAAgAiAXcUECdGooAgAhGAwCCyACIRUgGEGAwABxRQ0AIBEhAiAUIREMBgsgEEEYciEZIBQoAAAgEEH/AXF0IBFyIRogFCAQQQN2QQdxa0EDaiEUAkAgDCARQf8BcUECdGooAgAiEUGAgAJxRQ0AIBQoAAAgGUF4aiICQfcBcXQgGkEIdiIQciEaIAwgEEF/IBFBCHZBP3F0QX9zcSARQRB2akECdGooAgAhESACQRhyIRkgFCACQQN2QQZxa0EDaiEUCwJAIBpBfyARQf8BcSIWdEF/c3EgEUEIdkH/AXF2IhsgEUEQdiIcaiICIAQgA2tNDQBBAQ8LIBVBfyATdEF/c3EhEyAUKAAAIBkgEWsiEEH/AXF0IBogFnYiGXIhFSAEIAJrIRogBCAYQRB2aiATIBhBCHZB/wFxdmohESAUIBBBA3ZBB3FrQQNqIRQgACAZIBdxQQJ0aigCACEYAkACQCACQQRJDQAgBCAaKAAANgAAIAQgGigABDYABCAEIBooAAg2AAggBCAaKAAMNgAMIAQgGigAEDYAECAEQRRqIBFPDQFBACACayETA0AgBEEUaiIaIAQgE2oiAkEUaigAADYAACAEQRhqIAJBGGooAAA2AAAgBEEcaiACQRxqKAAANgAAIARBIGogAkEgaigAADYAACAEQSRqIAJBJGooAAA2AAAgBEEoaiECIBohBCACIBFJDQAMAgsLAkAgAkEBRw0AIAQgGi0AAEGBgoQIbCIaNgAMIAQgGjYACCAEIBo2AAQgBCAaNgAAIARBEGoiAiARTw0BA0AgAiAaNgAAIAJBDGogGjYAACACQQhqIBo2AAAgAkEEaiAaNgAAIAJBEGoiAiARSQ0ADAILCyAEIBooAAAiGjYAACAEIAJqIBo2AAAgG0EBdCAcQQF0aiEaIAJBA2whFgNAIAQgGmogBCACaiITKAAAIhk2AAAgBCAWaiAZNgAAIBMgAmoiBCAaaiARSQ0ACwsgESEECyAQQRhyIRAgFCAITw0CIAQgCkkNAAwCCwsgAiEQIBEhFAsDQAJAAkAgByAUa0EDSw0AIBBB/wFxIgJBF0sNAQNAAkACQCAUIAdGDQAgFC0AACACdCAVciEVIBRBAWohFAwBC0EBIRMgD0EBaiIPQQRLDQgLIBBBCGoiEEH/AXEiAkEYSQ0ADAILCyAUKAAAIBBB/wFxdCAVciEVIBQgEEEDdkEHcWtBA2ohFCAQQRhyIRALIBAgACAVIBdxQQJ0aigCACICayEQIBUgAkH/AXF2IRECQAJAIAJBgIABcQ0AIBUhGiARIRUMAQsgECAAIBFBfyACQQh2QT9xdEF/c3EgAkEQdmpBAnRqKAIAIgJrIRAgESACQf8BcXYhFSARIRoLIAJBEHYhEQJAIAJBf0oNAAJAIAQgCUcNAEEDDwsgBCAROgAAIARBAWohBAwBCwJAIAJBgMAAcUUNACAVIQIgFCERDAMLAkAgGkF/IAJB/wFxdEF/c3EgAkEIdkHfAXF2IBFqIhogCSAEa00NAEEDDwsCQAJAIAcgFGtBA0sNACAQQf8BcSICQRdLDQEDQAJAAkAgFCAHRg0AIBQtAAAgAnQgFXIhFSAUQQFqIRQMAQtBASETIA9BAWoiD0EESw0ICyAQQQhqIhBB/wFxIgJBGEkNAAwCCwsgFCgAACAQQf8BcXQgFXIhFSAUIBBBA3ZBB3FrQQNqIRQgEEEYciEQCwJAIAwgFUH/AXFBAnRqKAIAIgJBgIACcUUNACAMIBVBCHYiFUF/IAJBCHZBP3F0QX9zcSACQRB2akECdGooAgAhAiAQQXhqIRECQAJAIAcgFGtBA0sNACARQf8BcSITQRdNDQEgESEQDAILIBFBGHIhECAUKAAAIBFB/wFxdCAVciEVIBQgEUEDdkEHcWtBA2ohFAwBCwNAAkACQCAUIAdGDQAgFC0AACATdCAVciEVIBRBAWohFAwBC0EBIRMgD0EBaiIPQQRLDQcLIBBB/wFxIRMgEEEIaiIRIRAgE0EYSQ0ACyARQXhqIRALAkAgFUF/IAJB/wFxIhN0QX9zcSACQQh2Qf8BcXYgAkEQdmoiESAEIANrTQ0AQQEPCyAQIAJrIRAgFSATdiEVIAQgBCARayICLQAAOgAAIAQgAi0AAToAASAEQQJqIQIgBCAaaiEEQQAgEWshEQNAIAIgAiARai0AADoAACACQQFqIgIgBEkNAAwBCwsLAkAgDyAQQf0BakEDdkEfcSICTQ0AQQEPCwJAIAcgESAPIAJraiIRa0EETg0AQQEPCwJAIBEvAAIgES8AACICc0H//wNxQf//A0YNAEEBDwsCQCAJIARrIAJODQBBAw8LAkAgByARQQRqIhFrIAJODQBBAQ8LAkAgAkUNACAEIBEgAvwKAAALIAQgAmohBCARIAJqIRFBACEPQQAhEEEAIQILIBJBAXFFDQALQQEhEyAPIBBBA3ZBH3EiAksNAAJAIAVFDQAgBSARIA8gAmtqIAFrNgIACwJAIAZFDQAgBiAEIANrNgIADAILIAQgCUYNAUECIRMLIBMPC0EAC5UPAQ9/IwBBgAFrIQggBUEBaiIJQQdxIQogCUECdEFgcSELQQAhDANAIAhBwABqIAxqIglCADcDACAJQRhqQgA3AwAgCUEQakIANwMAIAlBCGpCADcDACALIAxBIGoiDEcNAAsCQCAKRQ0AIAhBwABqIAxqIQkDQCAJQQA2AgAgCUEEaiEJIApBf2oiCg0ACwsCQCACRQ0AIAJBA3EhCkEAIQwCQCACQQRJDQAgAkF8cSENQQAhDANAIAhBwABqIAEgDGoiCS0AAEECdGoiCyALKAIAQQFqNgIAIAhBwABqIAlBAWotAABBAnRqIgsgCygCAEEBajYCACAIQcAAaiAJQQJqLQAAQQJ0aiILIAsoAgBBAWo2AgAgCEHAAGogCUEDai0AAEECdGoiCSAJKAIAQQFqNgIAIA0gDEEEaiIMRw0ACwsgCkUNACABIAxqIQkDQCAIQcAAaiAJLQAAQQJ0aiIMIAwoAgBBAWo2AgAgCUEBaiEJIApBf2oiCg0ACwsgCEHAAGogBUECdGohCQJAA0ACQCAJKAIARQ0AIAUhCgwCCyAJQXxqIQlBASEKIAVBf2oiBUEBSw0ACwsCQCAHRQ0AIAcgBCAKIAQgCkkbIgQ2AgALQQAhDiAIQQA2AgAgCCAIKAJAIgs2AgRBASEJQQAhDAJAIApBAkkNAEEBIQkgCkF/aiIMQQFxIQ8CQAJAIApBAkcNAEEAIQwMAQsgDEF+cSEQIAhBwABqQQhyIQkgCEEMciEMQQAhBUEAIQ0DQCAMQXxqIAlBfGooAgAiByALaiILNgIAIAwgCSgCACIRIAtqIgs2AgAgESAFQQJ0IAdBAXRqaiEFIAlBCGohCSAMQQhqIQwgECANQQJqIg1HDQALIA1BAWohCSAFQQF0IQwLAkAgD0UNACAJQQJ0IgkgCGpBBGogCEHAAGogCWooAgAiCSALajYCACAJIAxqIQULIAVBAXQhDCAKIQkLIAhBwABqIAlBAnRqKAIAIAxqIRECQCACRQ0AIAJBAXEhB0EAIQkCQCACQQFGDQAgAkF+cSENQQAhCQNAIAYgCCABIAlqIgwtAABBAnRqIgUoAgAiC0EBdGogCTsBACAFIAtBAWo2AgAgCCAMQQFqLQAAQQJ0aiIMIAwoAgAiDEEBajYCACAGIAxBAXRqIAlBAWo7AQAgDSAJQQJqIglHDQALCwJAIAdFDQAgCCABIAlqLQAAQQJ0aiIMIAwoAgAiDEEBajYCACAGIAxBAXRqIAk7AQALIAgoAgAhDgsCQAJAIBFBASAKdCIJTQ0AQQAhBQwBCyAGIA5BAXRqIQcCQAJAAkAgESAJSQ0AIAhBwABqQQRyIQlBACENA0AgDUEBaiENIAkoAgAhBiAJQQRqIQkgBkUNAAtBACEPIA0gBE0NAUEAIQEMAgsCQAJAIBENAEEAIQkMAQtBACEFIBFBASAKQX9qdEcNAyAIKAJEQQFHDQMgBy8BACEJCyADIAlBAnRqKAIAQYECaiEMQQEhBUEBIQkDQCAAIAw2AgAgAEEEaiEAIAkgBHYhCCAJQQFqIQkgCEUNAAwDCwtBASANdCEMIAhBwABqQQRyIQtBACEBA0AgDEF/aiEJIA1BgQJsIQUDQCAAIAFBAnRqIAUgAyAHLwEAQQJ0aigCAGo2AgACQCABIAlHDQBBASEFIAQgDU0NBCANQQFqIQkCQCAEIA1rQQFxRQ0AAkAgDEECdCIIRQ0AIAAgCGogACAI/AoAAAsgDUEBaiENIAxBAXQhDAsgBCAJRg0EIAQgDWshCANAAkAgDEECdCIJRQ0AIAAgCWogACAJ/AoAAAsCQCAMQQN0IgxFDQAgACAMaiAAIAz8CgAACyAJIQwgCEF+aiIIRQ0FDAALC0GAgICAeCABIAlzZ3YiCkF/aiABcSAKciEBIAdBAmohByAGQX9qIgYNAAsgCyANQQJ0aiEJA0ACQCANQQFqIg0gBEsNAAJAIAxBAnQiCkUNACAAIApqIAAgCvwKAAALIAxBAXQhDAsgCSgCACEGIAlBBGohCSAGRQ0ACyANIARNDQALCyAEQYCAA3IhEkEBIAR0IhBBf2ohEyAIQcAAakEEciEUQX8hCQNAIBQgDUECdGohEUF/IA10QX9zIQ4gDSAEayIVQYECbCEWQQEgFXQiCkECdCELA0ACQAJAIAEgE3EiAiAJRw0AIBAhDCAJIQIMAQsgFSEIIAohBQJAIAYgCk8NACARIQkgFSEIIAYhDANAIAkoAgAhBSAJQQRqIQkgBSAMQQF0aiIMQQEgCEEBaiIIdCIFSQ0ACwsgACACQQJ0aiAQQRB0IAhBCHRyIBJyNgIAIAUgEGohDCAQIQ8LIAAgDyABIAR2aiIIQQJ0aiEJIBYgAyAHLwEAQQJ0aigCAGohBQNAIAkgBTYCACAJIAtqIQkgCCAKaiIIIAxJDQALAkAgASAORw0AQQEPC0GAgICAeCABIA5zZ3YiCUF/aiABcSAJciEBIAdBAmohByAMIRAgAiEJIAZBf2oiBg0ACwNAIA1BAWohDSARKAIAIQYgEUEEaiERIAZFDQALIAwhECACIQkMAAsLIAULgg0DDX8CfgJ8IwBB0ABrIgckACAHEEU2AgAQagJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAQYABQQgQWSIIRQ0AQQAhCSAHQQA2AgwgByAINgIIIAdBEDYCBBBqQYABQQgQWSIKRQ0BIAdBADYCGCAHIAo2AhQgB0EQNgIQIAJBAnQiC0EASA0CAkACQCALDQBBASEMDAELEGpBASEJIAtBARBZIgxFDQMLIAdBADYCJCAHIAw2AiAgByALNgIcIAMgA6EiFiACuCIXY0UNCCACIBb8AyIJSQ0JIAMhFiACIAlrIg1BGkkNByADIRYgASAJaiIJLQAAQR9HDQcgAyEWIAktAAFBiwFHDQcgAyEWIAktAAJBCEcNByADIRYgCS0AA0EERw0HIAMhFiAJLQAKQQZHDQcgAyEWIAktAAxBwgBHDQcgAyEWIAktAA1BwwBHDQcgAyEWIA0gCS8AECIOTQ0HIAMhFiAOQRlJDQcgB0EoaiAJIA0gBxANIAcoAigiCUGAgICAeEYNCiAHKAIsIQ4gBykCMCIUQoCAgIAQVA0GIAT8AyEPIAb8A0EBaiEQIBRCIIinIREgFKchDSAIIAM5AwAgCiAEOQMAQQEhCCAHQQE2AgwgB0EBNgIYAkACQCADIAVmIhINACANIQogDSAPSw0BIAMgEbigIRYgBCANIA9ruKAhBEEAIQwMBQsgDyANIBAgDSAQSRsiCkkNAEEAIQtBASESQQAhCgwFCwJAIAogD0kNAEEAIRMCQCAKIA9rIgggC00NACAHQRxqQQAgCBAkIAcoAiAhDCAHKAIkIRMLAkAgCEUNACAMIBNqIA4gD2ogCPwKAAALIAcgEyAIaiIMNgIkIAMgEbigIRYgBCANIA9ruKAhBCASRQ0EQQAhC0EBIQhBASESQQAhCgwGCyAPIAogDUHkg8AAEDgAC0EIQYABEE0AC0EIQYABEE0ACyAJIAsQTQALAkAgCUUNACAOIAlBARBWCyAWIAOhIgYgF2NFDQQDQCACIAb8AyIJSQ0GIAIgCWsiCEEaSQ0EIAEgCWoiCy0AAEEfRw0EIAstAAFBiwFHDQQgCy0AAkEIRw0EIAstAANBBEcNBCALLQAKQQZHDQQgCy0ADEHCAEcNBCALLQANQcMARw0EIAggCy8AECIKTQ0EIApBGE0NBCAHQShqIAsgCCAHEA0gBygCKCIJQYCAgIB4Rg0HIAcoAiwhDiAHKQIwIhRCgICAgBBUDQMCQCAHKAIMIgogBygCBEcNACAHQQRqECgLIBRCIIghFSAHKAIIIApBA3RqIBY5AwAgByAKQQFqIhI2AgwCQCAHKAIYIgsgBygCEEcNACAHQRBqECgLIBWnIREgFKchDSAHKAIUIAtBA3RqIAQ5AwAgByALQQFqIgg2AhgCQAJAAkAgFiAFZiITDQAgDSEPIA0NASAEIA24oCEEIBYgEbigIRYMAgsgDSAQIA0gEEkbIg8NAEEAIQ8gFiEDDAMLAkAgDyAHKAIcIAxrTQ0AIAdBHGogDCAPECQgBygCJCEMCwJAIA9FDQAgBygCICAMaiAOIA/8CgAACyAHIAwgD2oiDDYCJCAEIA24oCEEIBYgEbigIRYgEw0DCwJAIAlFDQAgDiAJQQEQVgsgFiADoSIGIBdjDQAMBQsLIAMgEbigIRYgBCANIA9ruKAhBAsCQCASIAcoAgRHDQAgB0EEahAoCyAHKAIIIBJBA3RqIBY5AwAgByAKQQJqNgIMAkAgCCAHKAIQRw0AIAdBEGoQKAsgBygCFCAIQQN0aiAEOQMAIAcgC0ECajYCGAsgCUUNASAOIAlBARBWDAELIBYgA2INAEG/gMAAQRMQYyECDAMLIAdBKGpBCGoiAiAHQRxqQQhqKAIANgIAIAdBPGogB0EEakEIaigCADYCACAAIAcpAhw3AgAgAEEYaiAHKQIQNwIAIABBIGogB0EQakEIaigCADYCACAHIAcpAgQ3AjQgAEEIaiACKQMANwIAIABBEGogB0EoakEQaikDADcCAAwDCyAJIAIgAkH0g8AAEDgACyAHKAIsIAcoAjAQYyECCyAAQYCAgIB4NgIAIAAgAjYCBAJAIAcoAhwiAEUNACAHKAIgIABBARBWCwJAIAcoAhAiAEUNACAHKAIUIABBA3RBCBBWCyAHKAIEIgBFDQAgBygCCCAAQQN0QQgQVgsgBxBkIAdB0ABqJAAL7QYBCH8CQAJAIAEgAEEDakF8cSICIABrIgNJDQAgASADayIEQQRJDQAgBEEDcSEFQQAhBkEAIQECQCACIABGDQBBACEHQQAhAQJAIAAgAmsiCEF8Sw0AQQAhB0EAIQEDQCABIAAgB2oiAiwAAEG/f0pqIAJBAWosAABBv39KaiACQQJqLAAAQb9/SmogAkEDaiwAAEG/f0pqIQEgB0EEaiIHDQALCyAAIAdqIQIDQCABIAIsAABBv39KaiEBIAJBAWohAiAIQQFqIggNAAsLIAAgA2ohCAJAIAVFDQAgCCAEQXxxaiICLAAAQb9/SiEGIAVBAUYNACAGIAIsAAFBv39KaiEGIAVBAkYNACAGIAIsAAJBv39KaiEGCyAEQQJ2IQMgBiABaiEHA0AgCCEGIANFDQIgA0HAASADQcABSRsiBEEDcSEFAkACQCAEQQJ0IglB8AdxIggNAEEAIQIMAQtBACECIAYhAQNAIAFBDGooAgAiAEF/c0EHdiAAQQZ2ckGBgoQIcSABQQhqKAIAIgBBf3NBB3YgAEEGdnJBgYKECHEgAUEEaigCACIAQX9zQQd2IABBBnZyQYGChAhxIAEoAgAiAEF/c0EHdiAAQQZ2ckGBgoQIcSACampqaiECIAFBEGohASAIQXBqIggNAAsLIAMgBGshAyAGIAlqIQggAkEIdkH/gfwHcSACQf+B/AdxakGBgARsQRB2IAdqIQcgBUUNAAsgBiAEQfwBcUECdGoiAigCACIBQX9zQQd2IAFBBnZyQYGChAhxIQECQCAFQQFGDQAgAigCBCIIQX9zQQd2IAhBBnZyQYGChAhxIAFqIQEgBUECRg0AIAIoAggiAkF/c0EHdiACQQZ2ckGBgoQIcSABaiEBCyABQQh2Qf+BHHEgAUH/gfwHcWpBgYAEbEEQdiAHaiEHDAELAkAgAQ0AQQAPCyABQQNxIQgCQAJAIAFBBE8NAEEAIQJBACEHDAELIAFBfHEhA0EAIQJBACEHA0AgByAAIAJqIgEsAABBv39KaiABQQFqLAAAQb9/SmogAUECaiwAAEG/f0pqIAFBA2osAABBv39KaiEHIAMgAkEEaiICRw0ACwsgCEUNACAAIAJqIQEDQCAHIAEsAABBv39KaiEHIAFBAWohASAIQX9qIggNAAsLIAcL9QYBBn8CQAJAAkACQAJAAkACQAJAIABBfGoiBCgCACIFQXhxIgZBBEEIIAVBA3EiBxsgAWpJDQAgAUEnaiEIAkAgB0UNACAGIAhLDQILAkACQCACQQlJDQAgAiADEA8iAg0BQQAPC0EAIQIgA0HM/3tLDQhBECADQQtqQXhxIANBC0kbIQEgAEF4aiEIAkAgBw0AIAFBgAJJDQcgCEUNByAGIAFNDQcgBiABa0GAgAhLDQcgAA8LIAggBmohBwJAAkAgBiABTw0AIAdBACgCmJxARg0BAkAgB0EAKAKUnEBGDQAgBygCBCIFQQJxDQkgBUF4cSIJIAZqIgUgAUkNCSAHIAkQEAJAIAUgAWsiB0EQSQ0AIAQgASAEKAIAQQFxckECcjYCACAIIAFqIgEgB0EDcjYCBCAIIAVqIgUgBSgCBEEBcjYCBCABIAcQDgwJCyAEIAUgBCgCAEEBcXJBAnI2AgAgCCAFaiIBIAEoAgRBAXI2AgQMCAtBACgCjJxAIAZqIgcgAUkNCAJAAkAgByABayIGQQ9LDQAgBCAFQQFxIAdyQQJyNgIAIAggB2oiASABKAIEQQFyNgIEQQAhBkEAIQEMAQsgBCABIAVBAXFyQQJyNgIAIAggAWoiASAGQQFyNgIEIAggB2oiByAGNgIAIAcgBygCBEF+cTYCBAtBACABNgKUnEBBACAGNgKMnEAMBwsgBiABayIGQQ9NDQYgBCABIAVBAXFyQQJyNgIAIAggAWoiASAGQQNyNgIEIAcgBygCBEEBcjYCBCABIAYQDgwGC0EAKAKQnEAgBmoiByABSw0EDAYLAkAgAyABIAMgAUkbIgNFDQAgAiAAIAP8CgAACyAEKAIAIgNBeHEiB0EEQQggA0EDcSIDGyABakkNAiADRQ0GIAcgCE0NBkGAlMAAQS5BsJTAABA5AAtBwJPAAEEuQfCTwAAQOQALQYCUwABBLkGwlMAAEDkAC0HAk8AAQS5B8JPAABA5AAsgBCABIAVBAXFyQQJyNgIAIAggAWoiBSAHIAFrIgFBAXI2AgRBACABNgKQnEBBACAFNgKYnEALIAhFDQAgAA8LIAMQAiIBRQ0BAkAgA0F8QXggBCgCACICQQNxGyACQXhxaiICIAMgAkkbIgNFDQAgASAAIAP8CgAACyABIQILIAAQCQsgAgvxBQIIfwF+AkACQCABDQAgBUEBaiEGIAAoAgghB0EtIQgMAQtBK0GAgMQAIAAoAggiB0GAgIABcSIBGyEIIAFBFXYgBWohBgsCQAJAIAdBgICABHENAEEAIQIMAQsCQAJAIANBEEkNACACIAMQBiEBDAELAkAgAw0AQQAhAQwBCyADQQNxIQkCQAJAIANBBE8NAEEAIQpBACEBDAELIANBDHEhC0EAIQpBACEBA0AgASACIApqIgwsAABBv39KaiAMQQFqLAAAQb9/SmogDEECaiwAAEG/f0pqIAxBA2osAABBv39KaiEBIAsgCkEEaiIKRw0ACwsgCUUNACACIApqIQwDQCABIAwsAABBv39KaiEBIAxBAWohDCAJQX9qIgkNAAsLIAEgBmohBgsCQAJAIAYgAC8BDCILTw0AAkACQAJAIAdBgICACHENACALIAZrIQ1BACEBQQAhCwJAAkACQCAHQR12QQNxDgQCAAEAAgsgDSELDAELIA1B/v8DcUEBdiELCyAHQf///wBxIQYgACgCBCEJIAAoAgAhCgNAIAFB//8DcSALQf//A3FPDQJBASEMIAFBAWohASAKIAYgCSgCEBEFAEUNAAwFCwsgACAAKQIIIg6nQYCAgP95cUGwgICAAnI2AghBASEMIAAoAgAiCiAAKAIEIgkgCCACIAMQOg0DQQAhASALIAZrQf//A3EhAgNAIAFB//8DcSACTw0CQQEhDCABQQFqIQEgCkEwIAkoAhARBQBFDQAMBAsLQQEhDCAKIAkgCCACIAMQOg0CIAogBCAFIAkoAgwRBwANAkEAIQEgDSALa0H//wNxIQADQCABQf//A3EiAiAASSEMIAIgAE8NAyABQQFqIQEgCiAGIAkoAhARBQBFDQAMAwsLQQEhDCAKIAQgBSAJKAIMEQcADQEgACAONwIIQQAPC0EBIQwgACgCACIBIAAoAgQiCiAIIAIgAxA6DQAgASAEIAUgCigCDBEHACEMCyAMC44GAQV/IABBeGoiASAAQXxqKAIAIgJBeHEiAGohAwJAAkAgAkEBcQ0AIAJBAnFFDQEgASgCACICIABqIQACQCABIAJrIgFBACgClJxARw0AIAMoAgRBA3FBA0cNAUEAIAA2AoycQCADIAMoAgRBfnE2AgQgASAAQQFyNgIEIAMgADYCAA8LIAEgAhAQCwJAAkACQAJAAkACQCADKAIEIgJBAnENACADQQAoApicQEYNAiADQQAoApScQEYNAyADIAJBeHEiAhAQIAEgAiAAaiIAQQFyNgIEIAEgAGogADYCACABQQAoApScQEcNAUEAIAA2AoycQA8LIAMgAkF+cTYCBCABIABBAXI2AgQgASAAaiAANgIACyAAQYACSQ0CIAEgABARQQAhAUEAQQAoAqycQEF/aiIANgKsnEAgAA0EAkBBACgC9JlAIgBFDQBBACEBA0AgAUEBaiEBIAAoAggiAA0ACwtBACABQf8fIAFB/x9LGzYCrJxADwtBACABNgKYnEBBAEEAKAKQnEAgAGoiADYCkJxAIAEgAEEBcjYCBAJAIAFBACgClJxARw0AQQBBADYCjJxAQQBBADYClJxACyAAQQAoAqScQCIETQ0DQQAoApicQCIARQ0DQQAhAkEAKAKQnEAiBUEpSQ0CQeyZwAAhAQNAAkAgASgCACIDIABLDQAgACADIAEoAgRqSQ0ECyABKAIIIQEMAAsLQQAgATYClJxAQQBBACgCjJxAIABqIgA2AoycQCABIABBAXI2AgQgASAAaiAANgIADwsCQAJAQQAoAoScQCIDQQEgAEEDdnQiAnENAEEAIAMgAnI2AoScQCAAQfgBcUH8mcAAaiIAIQMMAQsgAEH4AXEiAEH8mcAAaiEDIABBhJrAAGooAgAhAAsgAyABNgIIIAAgATYCDCABIAM2AgwgASAANgIIDwsCQEEAKAL0mUAiAUUNAEEAIQIDQCACQQFqIQIgASgCCCIBDQALC0EAIAJB/x8gAkH/H0sbNgKsnEAgBSAETQ0AQQBBfzYCpJxACwuOBQEHfwJAAkAgACgCCCIDQYCAgMABcUUNAAJAAkACQAJAAkAgA0GAgICAAXFFDQAgAC8BDiIEDQFBACECDAILAkAgAkEQSQ0AIAEgAhAGIQUMBAsCQCACDQBBACEFQQAhAgwECyACQQNxIQYCQAJAIAJBBE8NAEEAIQdBACEFDAELIAJBDHEhBEEAIQdBACEFA0AgBSABIAdqIggsAABBv39KaiAIQQFqLAAAQb9/SmogCEECaiwAAEG/f0pqIAhBA2osAABBv39KaiEFIAQgB0EEaiIHRw0ACwsgBkUNAyABIAdqIQgDQCAFIAgsAABBv39KaiEFIAhBAWohCCAGQX9qIgYNAAwECwsgASACaiEGQQAhAiABIQggBCEHA0AgCCIFIAZGDQICQAJAIAUsAAAiCEF/TA0AIAVBAWohCAwBCwJAIAhBYE8NACAFQQJqIQgMAQsCQCAIQXBPDQAgBUEDaiEIDAELIAVBBGohCAsgCCAFayACaiECIAdBf2oiBw0ACwtBACEHCyAEIAdrIQULIAUgAC8BDCIITw0AIAggBWshCUEAIQVBACEEAkACQAJAIANBHXZBA3EOBAIAAQICCyAJIQQMAQsgCUH+/wNxQQF2IQQLIANB////AHEhBiAAKAIEIQcgACgCACEAAkADQCAFQf//A3EgBEH//wNxTw0BQQEhCCAFQQFqIQUgACAGIAcoAhARBQANAwwACwtBASEIIAAgASACIAcoAgwRBwANAUEAIQUgCSAEa0H//wNxIQIDQCAFQf//A3EiBCACSSEIIAQgAk8NAiAFQQFqIQUgACAGIAcoAhARBQANAgwACwsgACgCACABIAIgACgCBCgCDBEHACEICyAIC9cEAQh/IwBBEGsiAyQAIAMgATYCBCADIAA2AgAgA0KggICADjcCCAJAAkACQAJAAkAgAigCECIERQ0AIAIoAhQiAQ0BDAILIAIoAgwiAEUNASACKAIIIgEgAEEDdCIAaiEFIABBeGpBA3ZBAWohBiACKAIAIQADQAJAIABBBGooAgAiB0UNACADKAIAIAAoAgAgByADKAIEKAIMEQcARQ0AQQEhAQwFCwJAIAEoAgAgAyABQQRqKAIAEQUARQ0AQQEhAQwFCyAAQQhqIQAgAUEIaiIBIAVGDQMMAAsLIAFBGGwhCCABQX9qQf////8BcUEBaiEGIAIoAgghCSACKAIAIQBBACEHA0ACQCAAQQRqKAIAIgFFDQAgAygCACAAKAIAIAEgAygCBCgCDBEHAEUNAEEBIQEMBAtBACEFQQAhCgJAAkACQCAEIAdqIgFBCGovAQAOAwABAgALIAFBCmovAQAhCgwBCyAJIAFBDGooAgBBA3RqLwEEIQoLAkACQAJAIAEvAQAOAwABAgALIAFBAmovAQAhBQwBCyAJIAFBBGooAgBBA3RqLwEEIQULIAMgBTsBDiADIAo7AQwgAyABQRRqKAIANgIIAkAgCSABQRBqKAIAQQN0aiIBKAIAIAMgASgCBBEFAEUNAEEBIQEMBAsgAEEIaiEAIAggB0EYaiIHRg0CDAALC0EAIQYLAkAgBiACKAIETw0AIAMoAgAgAigCACAGQQN0aiIBKAIAIAEoAgQgAygCBCgCDBEHAEUNAEEBIQEMAQtBACEBCyADQRBqJAAgAQugBAIIfwJ+IwBBIGsiAyQAIAMQRTYCAEEAIQQCQCACQQJ0IgVBAEgNAAJAAkAgBQ0AQQEhBgwBCxBqQQEhBCAFQQEQWSIGRQ0BC0EAIQcgA0EANgIMIAMgBjYCCCADIAU2AgQCQAJAIAJFDQBBACEEA0ACQAJAAkAgAiAEayIIQRpJDQAgASAEaiIFLQAAQR9HDQAgBS0AAUGLAUcNACAFLQACQQhHDQAgBS0AA0EERw0AIAUtAApBBkcNACAFLQAMQcIARw0AIAUtAA1BwwBHDQAgCCAFLwAQIglNDQAgCUEZSQ0AIANBEGogBSAIIAMQDSADKAIQIghBgICAgHhHDQIgAygCFCADKAIYEGMhBQwBCyAEDQNBv4DAAEETEGMhBQsgAEGAgICAeDYCACAAIAU2AgQgAygCBCIFRQ0DIAMoAgggBUEBEFYMAwsgAygCFCEJAkAgAykCGCILQv////8PVg0AIAhFDQIgCSAIQQEQVgwCCyALQiCIIQwCQCALpyIFIAMoAgQgB2tNDQAgA0EEaiAHIAUQJCADKAIIIQYgAygCDCEHCyAMpyEKAkAgBUUNACAGIAdqIAkgBfwKAAALIAMgByAFaiIHNgIMIAQgCmohBAJAIAhFDQAgCSAIQQEQVgsgBCACSQ0ACwsgACADKQIENwIAIABBCGogA0EEakEIaigCADYCAAsgAxBkIANBIGokAA8LIAQgBRBNAAv4AwEGfyMAQRBrIgQkAAJAAkACQAJAAkACQAJAAkAgAkEaSQ0AIAEtAABBH0cNACABLQABQYsBRw0AIAEtAAJBCEcNACABLQADQQRHDQAgAS0ACkEGRw0AIAEtAAxBwgBHDQAgAS0ADUHDAEcNACACIAEvABAiBU0NACAFQRlJDQAgBUF9aiIGIAJPDQEgBUF+aiIHIAJPDQIgBUF/aiIIIAJPDQMgBSACTw0EIAVBeWoiCUESSQ0FIAkgAksNBSABIAdqLQAAQQh0IAEgBmotAAByIAEgCGotAABBEHRyIAEgBWotAABBGHQiCXIhAkEAIQYgCUEASA0GQQEhCQJAIAJFDQAQakEBIQYgAkEBEFoiCUUNBwsgBEEIaiADIAFBEmogBUFnaiAJIAIQJwJAIAQtAAhBAUcNACAAQRQ2AgggAEHAg8AANgIEIABBgICAgHg2AgAgAkUNCCAJIAJBARBWDAgLIAAgBUEBajYCDCAAIAI2AgggACAJNgIEIAAgAjYCAAwHCyAAQRM2AgggAEG/gMAANgIEIABBgICAgHg2AgAMBgsgBiACQYCDwAAQKgALIAcgAkGQg8AAECoACyAIIAJBoIPAABAqAAsgBSACQbCDwAAQKgALQRIgCSACQdSDwAAQOAALIAYgAhBNAAsgBEEQaiQAC4UEAQJ/IAAgAWohAgJAAkAgACgCBCIDQQFxDQAgA0ECcUUNASAAKAIAIgMgAWohAQJAIAAgA2siAEEAKAKUnEBHDQAgAigCBEEDcUEDRw0BQQAgATYCjJxAIAIgAigCBEF+cTYCBCAAIAFBAXI2AgQgAiABNgIADAILIAAgAxAQCwJAAkACQAJAIAIoAgQiA0ECcQ0AIAJBACgCmJxARg0CIAJBACgClJxARg0DIAIgA0F4cSIDEBAgACADIAFqIgFBAXI2AgQgACABaiABNgIAIABBACgClJxARw0BQQAgATYCjJxADwsgAiADQX5xNgIEIAAgAUEBcjYCBCAAIAFqIAE2AgALAkAgAUGAAkkNACAAIAEQEQ8LAkACQEEAKAKEnEAiAkEBIAFBA3Z0IgNxDQBBACACIANyNgKEnEAgAUH4AXFB/JnAAGoiASECDAELIAFB+AFxIgFB/JnAAGohAiABQYSawABqKAIAIQELIAIgADYCCCABIAA2AgwgACACNgIMIAAgATYCCA8LQQAgADYCmJxAQQBBACgCkJxAIAFqIgE2ApCcQCAAIAFBAXI2AgQgAEEAKAKUnEBHDQFBAEEANgKMnEBBAEEANgKUnEAPC0EAIAA2ApScQEEAQQAoAoycQCABaiIBNgKMnEAgACABQQFyNgIEIAAgAWogATYCAA8LC+8CAQV/QQAhAgJAIAFBzf97IABBECAAQRBLGyIAa08NACAAQRAgAUELakF4cSABQQtJGyIDakEMahACIgFFDQAgAUF4aiECAkACQCAAQX9qIgQgAXENACACIQAMAQsgAUF8aiIFKAIAIgZBeHEgBCABakEAIABrcUF4aiIBQQAgACABIAJrQRBLG2oiACACayIBayEEAkAgBkEDcUUNACAAIAQgACgCBEEBcXJBAnI2AgQgACAEaiIEIAQoAgRBAXI2AgQgBSABIAUoAgBBAXFyQQJyNgIAIAIgAWoiBCAEKAIEQQFyNgIEIAIgARAODAELIAIoAgAhAiAAIAQ2AgQgACACIAFqNgIACwJAIAAoAgQiAUEDcUUNACABQXhxIgIgA0EQak0NACAAIAMgAUEBcXJBAnI2AgQgACADaiIBIAIgA2siA0EDcjYCBCAAIAJqIgIgAigCBEEBcjYCBCABIAMQDgsgAEEIaiECCyACC4kDAQR/IAAoAgwhAgJAAkACQAJAIAFBgAJJDQAgACgCGCEDAkACQAJAIAIgAEcNACAAQRRBECAAKAIUIgIbaigCACIBDQFBACECDAILIAAoAggiASACNgIMIAIgATYCCAwBCyAAQRRqIABBEGogAhshBANAIAQhBSABIgJBFGogAkEQaiACKAIUIgEbIQQgAkEUQRAgARtqKAIAIgENAAsgBUEANgIACyADRQ0CAkACQCAAIAAoAhxBAnRB7JjAAGoiASgCAEYNACADKAIQIABGDQEgAyACNgIUIAINAwwECyABIAI2AgAgAkUNBAwCCyADIAI2AhAgAg0BDAILAkAgAiAAKAIIIgRGDQAgBCACNgIMIAIgBDYCCA8LQQBBACgChJxAQX4gAUEDdndxNgKEnEAPCyACIAM2AhgCQCAAKAIQIgFFDQAgAiABNgIQIAEgAjYCGAsgACgCFCIBRQ0AIAIgATYCFCABIAI2AhgPCw8LQQBBACgCiJxAQX4gACgCHHdxNgKInEALyAIBBH9BACECAkAgAUGAAkkNAEEfIQIgAUH///8HSw0AIAFBJiABQQh2ZyICa3ZBAXEgAkEBdGtBPmohAgsgAEIANwIQIAAgAjYCHCACQQJ0QeyYwABqIQMCQEEAKAKInEBBASACdCIEcQ0AIAMgADYCACAAIAM2AhggACAANgIMIAAgADYCCEEAQQAoAoicQCAEcjYCiJxADwsCQAJAAkAgAygCACIEKAIEQXhxIAFHDQAgBCECDAELIAFBAEEZIAJBAXZrIAJBH0YbdCEDA0AgBCADQR12QQRxaiIFKAIQIgJFDQIgA0EBdCEDIAIhBCACKAIEQXhxIAFHDQALCyACKAIIIgMgADYCDCACIAA2AgggAEEANgIYIAAgAjYCDCAAIAM2AggPCyAFQRBqIAA2AgAgACAENgIYIAAgADYCDCAAIAA2AggLrQIBB38jAEEQayICJABBCiEDIAAoAgAiBCEFAkAgBEHoB0kNAEEKIQMgBCEAA0AgAkEGaiADaiIGQXxqIAAgAEGQzgBuIgVBkM4AbGsiB0H//wNxQeQAbiIIQQF0LwCElUA7AAAgBkF+aiAHIAhB5ABsa0H//wNxQQF0LwCElUA7AAAgA0F8aiEDIABB/6ziBEshBiAFIQAgBg0ACwsCQAJAIAVBCUsNACAFIQAMAQsgAkEGaiADQX5qIgNqIAUgBUH//wNxQeQAbiIAQeQAbGtB//8DcUEBdC8AhJVAOwAACwJAAkAgBEUNACAARQ0BCyACQQZqIANBf2oiA2ogAEEBdC0AhZVAOgAACyABQQFBAUEAIAJBBmogA2pBCiADaxAIIQAgAkEQaiQAIAALpQIBBn8gACgCCCECAkACQCABQYABTw0AQQEhAwwBCwJAIAFBgBBPDQBBAiEDDAELQQNBBCABQYCABEkbIQMLIAIhBAJAIAMgACgCACACa00NACAAIAIgA0EBQQEQIiAAKAIIIQQLIAAoAgQgBGohBAJAAkAgAUGAAUkNACABQT9xQYB/ciEFIAFBBnYhBgJAIAFBgBBPDQAgBCAFOgABIAQgBkHAAXI6AAAMAgsgAUEMdiEHIAZBP3FBgH9yIQYCQCABQf//A0sNACAEIAU6AAIgBCAGOgABIAQgB0HgAXI6AAAMAgsgBCAFOgADIAQgBjoAAiAEIAdBP3FBgH9yOgABIAQgAUESdkFwcjoAAAwBCyAEIAE6AAALIAAgAyACajYCCEEAC7ICAgN/AX4jAEHAAGsiAiQAAkAgASgCAEGAgICAeEcNACABKAIMIQMgAkEcakEIaiIEQQA2AgAgAkKAgICAEDcCHCACQShqQQhqIAMoAgAiA0EIaikCADcDACACQShqQRBqIANBEGopAgA3AwAgAiADKQIANwMoIAJBHGpB4JLAACACQShqEAsaIAJBEGpBCGogBCgCACIDNgIAIAIgAikCHCIFNwMQIAFBCGogAzYCACABIAU3AgALIAEpAgAhBSABQoCAgIAQNwIAIAJBCGoiAyABQQhqIgEoAgA2AgAgAUEANgIAIAIgBTcDABBqAkBBDEEEEFkiAQ0AQQRBDBBgAAsgASACKQMANwIAIAFBCGogAygCADYCACAAQcCUwAA2AgQgACABNgIAIAJBwABqJAALnQICBH8BfiMAQSBrIgMkAAJAAkACQAJAAkAgAg0AQQEhBEEAIQFBACEFQQAhBgwBCyADEEU2AgwgA0EQaiABIAIgA0EMahANIAMoAhAiBkGAgICAeEYNASADKAIUIQQgAykCGCEHIANBDGoQZCABIAJBARBWIAdCIIinIQEgB6chBQsQakEcQQQQWSICRQ0BIAIgATYCGCACIAU2AhQgAiAENgIQIAIgBjYCDEEAIQYgAkEANgIIIAJCgYCAgBA3AgAgAkEIaiEEDAILIAMoAhQgAygCGBBjIQQgA0EMahBkQQEhBiABIAJBARBWDAELQQRBHBBgAAsgACAGNgIIIAAgBEEAIAYbNgIEIABBACAEIAYbNgIAIANBIGokAAuSAgEHfyMAQRBrIgIkAAJAAkACQAJAIAFFDQAgAUF4aiIDIAMoAgBBAWoiBDYCACAERQ0BIAEoAgAiBEF/Rg0CIAEgBEEBajYCACACIAM2AgwgAiABNgIIIAIgAUEEajYCBCABKAIYIgVBA3QhBEEAIQYgBUH/////AUsNAyAEQfj///8HSw0DIAEoAhQhBwJAAkAgBA0AQQghCAwBCxBqQQghBiAEQQgQWSIIRQ0ECwJAIARFDQAgCCAHIAT8CgAACyABIAEoAgBBf2o2AgAgAyADKAIAQX9qIgE2AgACQCABDQAgAkEMahAmCyAAIAU2AgQgACAINgIAIAJBEGokAA8LEFsLAAsQXQALIAYgBBBNAAuSAgEHfyMAQRBrIgIkAAJAAkACQAJAIAFFDQAgAUF4aiIDIAMoAgBBAWoiBDYCACAERQ0BIAEoAgAiBEF/Rg0CIAEgBEEBajYCACACIAM2AgwgAiABNgIIIAIgAUEEajYCBCABKAIkIgVBA3QhBEEAIQYgBUH/////AUsNAyAEQfj///8HSw0DIAEoAiAhBwJAAkAgBA0AQQghCAwBCxBqQQghBiAEQQgQWSIIRQ0ECwJAIARFDQAgCCAHIAT8CgAACyABIAEoAgBBf2o2AgAgAyADKAIAQX9qIgE2AgACQCABDQAgAkEMahAmCyAAIAU2AgQgACAINgIAIAJBEGokAA8LEFsLAAsQXQALIAYgBBBNAAuCAgEHfyMAQRBrIgIkAAJAAkACQAJAIAENACAARQ0BIABBeGoiASgCAEEBRw0CIAAoAiAhAyAAKAIcIQQgACgCFCEFIAAoAhAhBiAAKAIIIQcgACgCBCEIIAFBADYCAAJAIAFBf0YNACAAQXxqIgAgACgCAEF/aiIANgIAIAANACABQTBBBBBWCwJAIAhFDQAgByAIQQEQVgsCQCAGRQ0AIAUgBkEDdEEIEFYLIARFDQMgAyAEQQN0QQgQVgwDCyAARQ0AIABBeGoiACAAKAIAQX9qIgE2AgAgAiAANgIMIAENAiACQQxqECYMAgsQWwALQYCAwABBPxBcAAsgAkEQaiQAC/gBAQZ/IwBBEGsiAiQAAkACQAJAAkAgAUUNACABQXhqIgMgAygCAEEBaiIENgIAIARFDQEgASgCACIEQX9GDQJBASEFIAEgBEEBajYCACACIAM2AgwgAiABNgIIIAIgAUEEajYCBEEAIQYgASgCDCIEQQBIDQMgASgCCCEHAkAgBEUNABBqQQEhBiAEQQEQWSIFRQ0ECwJAIARFDQAgBSAHIAT8CgAACyABIAEoAgBBf2o2AgAgAyADKAIAQX9qIgE2AgACQCABDQAgAkEMahAmCyAAIAQ2AgQgACAFNgIAIAJBEGokAA8LEFsLAAsQXQALIAYgBBBNAAv4AQEGfyMAQRBrIgIkAAJAAkACQAJAIAFFDQAgAUF4aiIDIAMoAgBBAWoiBDYCACAERQ0BIAEoAgAiBEF/Rg0CQQEhBSABIARBAWo2AgAgAiADNgIMIAIgATYCCCACIAFBBGo2AgRBACEGIAEoAgwiBEEASA0DIAEoAgghBwJAIARFDQAQakEBIQYgBEEBEFkiBUUNBAsCQCAERQ0AIAUgByAE/AoAAAsgASABKAIAQX9qNgIAIAMgAygCAEF/aiIBNgIAAkAgAQ0AIAJBDGoQNAsgACAENgIEIAAgBTYCACACQRBqJAAPCxBbCwALEF0ACyAGIAQQTQAL+QEBAX8jAEEwayIHJAAgB0EMaiABIAIgAyAEIAUgBhAFAkAgAkUNACABIAJBARBWCwJAAkACQCAHKAIMQYCAgIB4Rw0AQQEhASAHKAIQIQIMAQsQakEwQQQQWSICRQ0BQQAhASACQQA2AgggAkKBgICAEDcCACACIAcpAgw3AgwgAkEUaiAHQQxqQQhqKQIANwIAIAJBHGogB0EcaikCADcCACACQSRqIAdBJGopAgA3AgAgAkEsaiAHQSxqKAIANgIAIAJBCGohAgsgACABNgIIIAAgAkEAIAEbNgIEIABBACACIAEbNgIAIAdBMGokAA8LQQRBMBBgAAvMAQEDfyMAQRBrIgMkACADQQRqIAEgAhAMAkAgAkUNACABIAJBARBWCwJAAkACQCADKAIEIgRBgICAgHhHDQBBASEEQQAhASADKAIIIQVBACECDAELIAMoAgghBQJAAkAgBCADKAIMIgJLDQAgBSEBDAELAkAgAg0AQQEhASAFIARBARBWDAELIAUgBEEBIAIQUyIBRQ0CC0EAIQVBACEECyAAIAQ2AgwgACAFNgIIIAAgAjYCBCAAIAE2AgAgA0EQaiQADwtBASACEE0AC8ABAQN/IwBBEGsiAiQAAkACQAJAAkAgAQ0AIABFDQEgAEF4aiIBKAIAQQFHDQIgACgCCCEDIAAoAgQhBCABQQA2AgACQCABQX9GDQAgAEF8aiIAIAAoAgBBf2oiADYCACAADQAgAUEcQQQQVgsgBEUNAyADIARBARBWDAMLIABFDQAgAEF4aiIAIAAoAgBBf2oiATYCACACIAA2AgwgAQ0CIAJBDGoQNAwCCxBbAAtBgIDAAEE/EFwACyACQRBqJAAL3AEBAn8jAEEgayIFJAACQAJAQQEQNkH/AXEiBkECRg0AIAZBAXFFDQEgBUEIaiAAIAEoAhgRBAAMAQtBACgCwJxAIgZBf0wNAEEAIAZBAWo2AsCcQAJAAkBBACgCxJxARQ0AIAUgACABKAIUEQQAIAUgBDoAHSAFIAM6ABwgBSACNgIYIAUgBSkDADcCEEEAKALEnEAgBUEQakEAKALInEAoAhQRBAAMAQtBgICAgHggBRBHC0EAQQAoAsCcQEF/ajYCwJxAQQBBADoAuJxAIANFDQAgACABEFcACwALzAECA38BfiMAQTBrIgIkAAJAIAEoAgBBgICAgHhHDQAgASgCDCEDIAJBDGpBCGoiBEEANgIAIAJCgICAgBA3AgwgAkEYakEIaiADKAIAIgNBCGopAgA3AwAgAkEYakEQaiADQRBqKQIANwMAIAIgAykCADcDGCACQQxqQeCSwAAgAkEYahALGiACQQhqIAQoAgAiAzYCACACIAIpAgwiBTcDACABQQhqIAM2AgAgASAFNwIACyAAQcCUwAA2AgQgACABNgIAIAJBMGokAAu2AQICfwF+QQEhBkEEIQcCQAJAIAQgBWpBf2pBACAEa3GtIAOtfiIIQiCIp0UNAEEAIQMMAQsCQCAIpyIDQYCAgIB4IARrTQ0AQQAhAwwBCwJAAkACQAJAIAFFDQAgAiAFIAFsIAQgAxBTIQcMAQsCQCADDQAgBCEHDAILEGogAyAEEFkhBwsgBw0AIAAgBDYCBAwBCyAAIAc2AgRBACEGC0EIIQcLIAAgB2ogAzYCACAAIAY2AgALtgECAn8BfkEBIQZBBCEHAkACQCAEIAVqQX9qQQAgBGtxrSADrX4iCEIgiKdFDQBBACEDDAELAkAgCKciA0GAgICAeCAEa00NAEEAIQMMAQsCQAJAAkACQCABRQ0AIAIgBSABbCAEIAMQUyEHDAELAkAgAw0AIAQhBwwCCxBqIAMgBBBZIQcLIAcNACAAIAQ2AgQMAQsgACAHNgIEQQAhBgtBCCEHCyAAIAdqIAM2AgAgACAGNgIAC5UBAQF/IwBBEGsiBSQAAkAgAiABaiIBIAJPDQBBAEEAEE0ACyAFQQRqIAAoAgAiAiAAKAIEIAEgAkEBdCICIAEgAksbIgJBCEEEIARBAUYbIgEgAiABSxsiAiADIAQQIQJAIAUoAgRBAUcNACAFKAIIIAUoAgwQTQALIAUoAgghBCAAIAI2AgAgACAENgIEIAVBEGokAAuyAQEDfyMAQRBrIgEkACAAKAIAIgIoAgwhAwJAAkACQAJAIAIoAgQOAgABAgsgAw0BQQEhAkEAIQMMAgsgAw0AIAIoAgAiAigCBCEDIAIoAgAhAgwBCyABQYCAgIB4NgIAIAEgADYCDCABQZSTwAAgACgCBCAAKAIIIgAtAAggAC0ACRAeAAsgASADNgIEIAEgAjYCACABQfiSwAAgACgCBCAAKAIIIgAtAAggAC0ACRAeAAuLAQEBfyMAQRBrIgMkAAJAIAIgAWoiASACTw0AQQBBABBNAAsgA0EEaiAAKAIAIgIgACgCBCABIAJBAXQiAiABIAJLGyICQQggAkEISxsiAkEBQQEQIAJAIAMoAgRBAUcNACADKAIIIAMoAgwQTQALIAMoAgghASAAIAI2AgAgACABNgIEIANBEGokAAuHAQEBfyMAQSBrIgIkAAJAAkAgACgCAEGAgICAeEYNACABIAAoAgQgACgCCBBSIQAMAQsgAkEIakEIaiAAKAIMKAIAIgBBCGopAgA3AwAgAkEIakEQaiAAQRBqKQIANwMAIAIgACkCADcDCCABKAIAIAEoAgQgAkEIahALIQALIAJBIGokACAAC3wBAX8CQCAAKAIAIgAoAgwiAUUNACAAKAIQIAFBARBWCwJAIAAoAhgiAUUNACAAKAIcIAFBA3RBCBBWCwJAIAAoAiQiAUUNACAAKAIoIAFBA3RBCBBWCwJAIABBf0YNACAAIAAoAgRBf2oiATYCBCABDQAgAEEwQQQQVgsLhAEBAn8jAEEQayIGJABBACEHIAZBADYCDAJAAkACQAJAAkAgASgCACACIAMgBCAFIAZBDGoQUA4EAQIAAwALQZCFwABB7ABB/IXAABA/AAsgACAGKAIMNgIEDAILIABBADoAAUEBIQcMAQtBASEHIABBAToAAQsgACAHOgAAIAZBEGokAAtrAQN/IwBBEGsiASQAIAFBBGogACgCACICIAAoAgQgAkEBdCICQQQgAkEESxsiAkEIQQgQIAJAIAEoAgRBAUcNACABKAIIIAEoAgwQTQALIAEoAgghAyAAIAI2AgAgACADNgIEIAFBEGokAAtoAQF/IwBBMGsiAiQAAkAQaEH/AXENACACQTBqJAAPCyACIAE2AiQgAkECNgIQIAJBpJLAADYCDCACQgE3AhggAkEErUIghiACQSRqrYQ3AyggAiACQShqNgIUIAJBDGpBtJLAABBAAAtoAgF/AX4jAEEwayIDJAAgAyABNgIEIAMgADYCACADQQI2AgwgA0GcmMAANgIIIANCAjcCFCADQQStQiCGIgQgA62ENwMoIAMgBCADQQRqrYQ3AyAgAyADQSBqNgIQIANBCGogAhBAAAtoAgF/AX4jAEEwayIDJAAgAyABNgIEIAMgADYCACADQQI2AgwgA0G0l8AANgIIIANCAjcCFCADQQStQiCGIgQgA0EEaq2ENwMoIAMgBCADrYQ3AyAgAyADQSBqNgIQIANBCGogAhBAAAtoAgF/AX4jAEEwayIDJAAgAyABNgIEIAMgADYCACADQQI2AgwgA0HYl8AANgIIIANCAjcCFCADQQStQiCGIgQgA0EEaq2ENwMoIAMgBCADrYQ3AyAgAyADQSBqNgIQIANBCGogAhBAAAtoAgF/AX4jAEEwayIDJAAgAyABNgIEIAMgADYCACADQQI2AgwgA0GAl8AANgIIIANCAjcCFCADQQStQiCGIgQgA0EEaq2ENwMoIAMgBCADrYQ3AyAgAyADQSBqNgIQIANBCGogAhBAAAtgAQJ/AkACQCACQRB2IAJB//8DcUEAR2oiAkAAIgNBf0cNAEEAIQJBACEEDAELIAJBEHQiBEFwaiAEIANBEHQiAkEAIARrRhshBAsgAEEANgIIIAAgBDYCBCAAIAI2AgALYAECfwJAAkAgAEF8aigCACIDQXhxIgRBBEEIIANBA3EiAxsgAWpJDQACQCADRQ0AIAQgAUEnaksNAgsgABAJDwtBwJPAAEEuQfCTwAAQOQALQYCUwABBLkGwlMAAEDkAC2gBAn9BACEBAkAgACgCAEEMRw0AQQAhAUGs2gAgACgCBCICQQAoAuSYQCACGxEDACICRQ0AAkBBrNoARQ0AIAJBAEGs2gD8CwALIAIgACgCCCIAQQAoAuiYQCAAGzYCqFogAiEBCyABC1kBAn8gASgCACECIAFBADYCAAJAAkAgAkUNACABKAIEIQMQakEIQQQQWSIBRQ0BIAEgAzYCBCABIAI2AgAgAEGwk8AANgIEIAAgATYCAA8LAAtBBEEIEGAAC04BA38CQAJAAkAgAEUNACAAQXhqIgEgASgCACICQQFqIgM2AgAgA0UNASAAKAIAQX9GDQIgACgCECEAIAEgAjYCACAADwsQWwsACxBdAAtQAQF/AkAgAiAAKAIAIAAoAggiA2tNDQAgACADIAJBAUEBECIgACgCCCEDCwJAIAJFDQAgACgCBCADaiABIAL8CgAACyAAIAMgAmo2AghBAAtMAQF/AkAgACgCACIAQQxqKAIAIgFFDQAgAEEQaigCACABQQEQVgsCQCAAQX9GDQAgACAAKAIEQX9qIgE2AgQgAQ0AIABBHEEEEFYLC0UAAkACQCABQQlJDQAgASAAEA8hAQwBCyAAEAIhAQsCQCABRQ0AIAFBfGotAABBA3FFDQAgAEUNACABQQAgAPwLAAsgAQtSAQJ/QQAhAUEAQQAoArycQCICQQFqNgK8nEACQCACQQBIDQBBASEBQQAtALicQA0AQQAgADoAuJxAQQBBACgCtJxAQQFqNgK0nEBBAiEBCyABC0cBAn8gASgCBCECIAEoAgAhAxBqAkBBCEEEEFkiAQ0AQQRBCBBgAAsgASACNgIEIAEgAzYCACAAQbCTwAA2AgQgACABNgIACzgAAkACQCAAIAJLDQAgASACSw0BIAAgAU0NASAAIAEgAxArAAsgACACIAMQLAALIAEgAiADEC0AC0EBAX8jAEEgayIDJAAgA0EANgIQIANBATYCBCADQgQ3AgggAyABNgIcIAMgADYCGCADIANBGGo2AgAgAyACEEAACzkAAkAgAkGAgMQARg0AIAAgAiABKAIQEQUARQ0AQQEPCwJAIAMNAEEADwsgACADIAQgASgCDBEHAAs5AQF/IwBBIGsiACQAIABBADYCGCAAQQE2AgwgAEHklMAANgIIIABCBDcCECAAQQhqQeyUwAAQQAALJwACQCAAIAEQTkUNAAJAIABFDQAQaiAAIAEQWSIBRQ0BCyABDwsACywCAX8BfiMAQRBrIgEkACAAKQIAIQIgASAANgIMIAEgAjcCBCABQQRqEGUACy0BAX8jAEEQayIBJAAgASAAKQIANwIIIAFBCGpBxJLAACAAKAIIQQFBABAeAAsqAQF/IwBBEGsiAyQAIAMgAjYCDCADIAE2AgggAyAANgIEIANBBGoQZgALKgEBfyMAQRBrIgIkACACQQE7AQwgAiABNgIIIAIgADYCBCACQQRqED0ACykBAX8CQCAAKAIAIgFBgICAgHhyQYCAgIB4Rg0AIAAoAgQgAUEBEFYLCx4BAX8CQCAAKAIAIgJFDQAgASACIAAoAgQQUg8LAAsgAAJAIAEoAgBFDQAgAEGwk8AANgIEIAAgATYCAA8LAAsbAQF/EGogAEEEakEEEFkiASAANgIAIAFBBGoLIwEBfwJAQdiGwAAQMCIADQBBjIbAAEE6QciGwAAQPwALIAALFwACQCABQQlJDQAgASAAEA8PCyAAEAILHwACQCAAQYCAgIB4ckGAgICAeEYNACABIABBARBWCwscAQF/AkAgACgCACIBRQ0AIAAoAgQgAUEBEFYLCxUAIABBfGoiACAAKAIAQQRqQQQQVgsaAQF/IAEgAEEAKAKwnEAiAkEDIAIbEQQAAAsdACAAQQhqQQApAuiRQDcCACAAQQApAuCRQDcCAAsdACAAQQhqQQApAviRQDcCACAAQQApAvCRQDcCAAsUAAJAIABFDQAgACABEGAACxA7AAsVACABaUEBRiAAQYCAgIB4IAFrTXELEgACQCABRQ0AIAAgASACEFYLCxIAIAAgASACIAMgBEEAIAUQAwsVAAJAIABFDQAgACAAKAKoWhECAAsLFgAgACgCACABIAIgACgCBCgCDBEHAAsNACAAIAEgAiADEAcPCxAAIAEgACgCACAAKAIEEFILEwAgAEGwk8AANgIEIAAgATYCAAsLACAAIAEgAhAvDwsKACAAIAEQaRoACwsAIAAjAGokACMACwkAIAAgARBGDwsJACAAIAEQNQ8LDABBhITAAEEbEFwACwkAIAAgARBiAAsNAEGfhMAAQc8AEFwACw0AIABB4JLAACABEAsLDAAgACABKQIANwMACwkAIAEgABBKAAsNACABQayYwABBGBAKCwgAIAAgARAACwgAIAAgARABCwkAIAAoAgAQUQsHACAAECMACwcAIAAQPgALCQAgAEEANgIACwUAQQAPCwUAEGsACwMADwsDAAALC9oYAgBBgIDAAAvEGGF0dGVtcHRlZCB0byB0YWtlIG93bmVyc2hpcCBvZiBSdXN0IHZhbHVlIHdoaWxlIGl0IHdhcyBib3Jyb3dlZGludmFsaWQgYmd6ZiBoZWFkZXIvaG9tZS9jZGllc2gvLmNhcmdvL3JlZ2lzdHJ5L3NyYy9pbmRleC5jcmF0ZXMuaW8tMTk0OWNmOGM2YjViNTU3Zi93YXNtLWJpbmRnZW4tMC4yLjEwOC9zcmMvZXh0ZXJucmVmLnJzAGxpYnJhcnkvYWxsb2Mvc3JjL3Jhd192ZWMvbW9kLnJzAC9ydXN0L2RlcHMvZGxtYWxsb2MtMC4yLjEwL3NyYy9kbG1hbGxvYy5ycwBsaWJyYXJ5L3N0ZC9zcmMvYWxsb2MucnMAL2hvbWUvY2RpZXNoLy5jYXJnby9yZWdpc3RyeS9zcmMvaW5kZXguY3JhdGVzLmlvLTE5NDljZjhjNmI1YjU1N2YvbGliZGVmbGF0ZXItMS4yNS4wL3NyYy9saWIucnMAAHQBEAAKAAAAKQAAAAkAAAB0ARAACgAAACoAAAAJAAAAdAEQAAoAAAArAAAACQAAAHQBEAAKAAAALAAAAAkAAABkZWNvbXByZXNzaW9uIGZhaWxlZHQBEAAKAAAALwAAAB4AAAB0ARAACgAAANsAAAAxAAAAdAEQAAoAAAC3AAAAHwAAAG51bGwgcG9pbnRlciBwYXNzZWQgdG8gcnVzdHJlY3Vyc2l2ZSB1c2Ugb2YgYW4gb2JqZWN0IGRldGVjdGVkIHdoaWNoIHdvdWxkIGxlYWQgdG8gdW5zYWZlIGFsaWFzaW5nIGluIHJ1c3QAAFIAEABnAAAAfwAAABEAAABSABAAZwAAAIwAAAARAAAAbGliZGVmbGF0ZV9kZWZsYXRlX2RlY29tcHJlc3MgcmV0dXJuZWQgYW4gdW5rbm93biBlcnJvciB0eXBlOiB0aGlzIGlzIGFuIGludGVybmFsIGJ1ZyB0aGF0ICoqbXVzdCoqIGJlIGZpeGVkHwEQAF8AAAAMAQAAFQAAAGxpYmRlZmxhdGVfYWxsb2NfZGVjb21wcmVzc29yIHJldHVybmVkIE5VTEw6IG91dCBvZiBtZW1vcnkAAB8BEABfAAAAnAAAABEAAAAMAAAAAQAAAAIAAAAAAAAAAAAAAAAAAAAQERIACAcJBgoFCwQMAw0CDgEPAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAAAARAAAAEgAAAAAAAAABAAAAAgAAAAMAAAAEAAEABQABAAcAAgAJAAIADQADABEAAwAZAAQAIQAEADEABQBBAAUAYQAGAIEABgDBAAcAAQEHAIEBCAABAggAAQMJAAEECQABBgoAAQgKAAEMCwABEAsAARgMAAEgDAABMA0AAUANAAFgDQABYA0AAWAAAACAAAABgAAAAoAAAAOAAAAEgAAABYAAAAaAAAAHgAAACIAAAAmAAAAKgAAAC4AAAAyAAAANgAAADoAAAA+AAAAQgAAAEYAAABKAAAATgAAAFIAAABWAAAAWgAAAF4AAABiAAAAZgAAAGoAAABuAAAAcgAAAHYAAAB6AAAAfgAAAIIAAACGAAAAigAAAI4AAACSAAAAlgAAAJoAAACeAAAAogAAAKYAAACqAAAArgAAALIAAAC2AAAAugAAAL4AAADCAAAAxgAAAMoAAADOAAAA0gAAANYAAADaAAAA3gAAAOIAAADmAAAA6gAAAO4AAADyAAAA9gAAAPoAAAD+AAABAgAAAQYAAAEKAAABDgAAARIAAAEWAAABGgAAAR4AAAEiAAABJgAAASoAAAEuAAABMgAAATYAAAE6AAABPgAAAUIAAAFGAAABSgAAAU4AAAFSAAABVgAAAVoAAAFeAAABYgAAAWYAAAFqAAABbgAAAXIAAAF2AAABegAAAX4AAAGCAAABhgAAAYoAAAGOAAABkgAAAZYAAAGaAAABngAAAaIAAAGmAAABqgAAAa4AAAGyAAABtgAAAboAAAG+AAABwgAAAcYAAAHKAAABzgAAAdIAAAHWAAAB2gAAAd4AAAHiAAAB5gAAAeoAAAHuAAAB8gAAAfYAAAH6AAAB/gAAAgIAAAIGAAACCgAAAg4AAAISAAACFgAAAhoAAAIeAAACIgAAAiYAAAIqAAACLgAAAjIAAAI2AAACOgAAAj4AAAJCAAACRgAAAkoAAAJOAAACUgAAAlYAAAJaAAACXgAAAmIAAAJmAAACagAAAm4AAAJyAAACdgAAAnoAAAJ+AAACggAAAoYAAAKKAAACjgAAApIAAAKWAAACmgAAAp4AAAKiAAACpgAAAqoAAAKuAAACsgAAArYAAAK6AAACvgAAAsIAAALGAAACygAAAs4AAALSAAAC1gAAAtoAAALeAAAC4gAAAuYAAALqAAAC7gAAAvIAAAL2AAAC+gAAAv4AAAMCAAADBgAAAwoAAAMOAAADEgAAAxYAAAMaAAADHgAAAyIAAAMmAAADKgAAAy4AAAMyAAADNgAAAzoAAAM+AAADQgAAA0YAAANKAAADTgAAA1IAAANWAAADWgAAA14AAANiAAADZgAAA2oAAANuAAADcgAAA3YAAAN6AAADfgAAA4IAAAOGAAADigAAA44AAAOSAAADlgAAA5oAAAOeAAADogAAA6YAAAOqAAADrgAAA7IAAAO2AAADugAAA74AAAPCAAADxgAAA8oAAAPOAAAD0gAAA9YAAAPaAAAD3gAAA+IAAAPmAAAD6gAAA+4AAAPyAAAD9gAAA/oAAAP+AAKAAAAAAAwAAAAQAAAAFAAAABgAAAAcAAAAIAAAACQAAAAoAAQALAAEADQABAA8AAQARAAIAEwACABcAAgAbAAIAHwADACMAAwArAAMAMwADADsABABDAAQAUwAEAGMABABzAAUAgwAFAKMABQDDAAUA4wAAAAIBAAACAQAAAgF8/YsyV+ZX+QLfRL/jSOevbV3L1ixQ62N4QaZXcRuLuW1lbW9yeSBhbGxvY2F0aW9uIG9mICBieXRlcyBmYWlsZWQAAAAJEAAVAAAAFQkQAA0AAAAGARAAGAAAAGQBAAAJAAAAAAAAAAgAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAMAAAABAAAAAoAAAALAAAADAAAAAAAAAAIAAAABAAAAA0AAAAOAAAADwAAABAAAAARAAAAEAAAAAQAAAASAAAAEwAAABQAAAAIAAAAAAAAAAgAAAAEAAAAFQAAAGFzc2VydGlvbiBmYWlsZWQ6IHBzaXplID49IHNpemUgKyBtaW5fb3ZlcmhlYWQAANsAEAAqAAAAsQQAAAkAAABhc3NlcnRpb24gZmFpbGVkOiBwc2l6ZSA8PSBzaXplICsgbWF4X292ZXJoZWFkAADbABAAKgAAALcEAAANAAAACQAAAAwAAAAEAAAAFgAAAGNhcGFjaXR5IG92ZXJmbG93AAAAUAoQABEAAAC6ABAAIAAAABwAAAAFAAAAAQAAAAAAAAAwMDAxMDIwMzA0MDUwNjA3MDgwOTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNzI4MjkzMDMxMzIzMzM0MzUzNjM3MzgzOTQwNDE0MjQzNDQ0NTQ2NDc0ODQ5NTA1MTUyNTM1NDU1NTY1NzU4NTk2MDYxNjI2MzY0NjU2NjY3Njg2OTcwNzE3MjczNzQ3NTc2Nzc3ODc5ODA4MTgyODM4NDg1ODY4Nzg4ODk5MDkxOTI5Mzk0OTU5Njk3OTg5OXJhbmdlIGVuZCBpbmRleCAgb3V0IG9mIHJhbmdlIGZvciBzbGljZSBvZiBsZW5ndGggAABMCxAAEAAAAFwLEAAiAAAAc2xpY2UgaW5kZXggc3RhcnRzIGF0ICBidXQgZW5kcyBhdCAAkAsQABYAAACmCxAADQAAAHJhbmdlIHN0YXJ0IGluZGV4IAAAxAsQABIAAABcCxAAIgAAAGluZGV4IG91dCBvZiBib3VuZHM6IHRoZSBsZW4gaXMgIGJ1dCB0aGUgaW5kZXggaXMgAADoCxAAIAAAAAgMEAASAAAAUmVmQ2VsbCBhbHJlYWR5IGJvcnJvd2VkAEHEmMAACwQEAAAAACkEbmFtZQEiAVgfX193YmluZGdlbl9hZGRfdG9fc3RhY2tfcG9pbnRlcgA8CXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AgZ3YWxydXMGMC4yNC40DHdhc20tYmluZGdlbgcwLjIuMTA4",Mn=function(){function e(){N(this,e)}return D(e,[{key:"__destroy_into_raw",value:function(){var e=this.__wbg_ptr;return this.__wbg_ptr=0,Gn.unregister(this),e}},{key:"free",value:function(){var e=this.__destroy_into_raw();ir.__wbg_chunksliceresult_free(e,0)}},{key:"buffer",get:function(){try{var e=ir.__wbindgen_add_to_stack_pointer(-16);ir.chunksliceresult_buffer(e,this.__wbg_ptr);var t=Wn().getInt32(e+0,!0),n=Wn().getInt32(e+4,!0),r=zn(t,n).slice();return ir.__wbindgen_export(t,1*n,1),r}finally{ir.__wbindgen_add_to_stack_pointer(16)}}},{key:"cpositions",get:function(){try{var e=ir.__wbindgen_add_to_stack_pointer(-16);ir.chunksliceresult_cpositions(e,this.__wbg_ptr);var t=Wn().getInt32(e+0,!0),n=Wn().getInt32(e+4,!0),r=Yn(t,n).slice();return ir.__wbindgen_export(t,8*n,8),r}finally{ir.__wbindgen_add_to_stack_pointer(16)}}},{key:"dpositions",get:function(){try{var e=ir.__wbindgen_add_to_stack_pointer(-16);ir.chunksliceresult_dpositions(e,this.__wbg_ptr);var t=Wn().getInt32(e+0,!0),n=Wn().getInt32(e+4,!0),r=Yn(t,n).slice();return ir.__wbindgen_export(t,8*n,8),r}finally{ir.__wbindgen_add_to_stack_pointer(16)}}}],[{key:"__wrap",value:function(t){t>>>=0;var n=Object.create(e.prototype);return n.__wbg_ptr=t,Gn.register(n,n.__wbg_ptr,n),n}}])}();Symbol.dispose&&(Mn.prototype[Symbol.dispose]=Mn.prototype.free);var On=function(){function e(){N(this,e)}return D(e,[{key:"__destroy_into_raw",value:function(){var e=this.__wbg_ptr;return this.__wbg_ptr=0,Hn.unregister(this),e}},{key:"free",value:function(){var e=this.__destroy_into_raw();ir.__wbg_decompressresult_free(e,0)}},{key:"bytes_read",get:function(){return ir.decompressresult_bytes_read(this.__wbg_ptr)>>>0}},{key:"data",get:function(){try{var e=ir.__wbindgen_add_to_stack_pointer(-16);ir.decompressresult_data(e,this.__wbg_ptr);var t=Wn().getInt32(e+0,!0),n=Wn().getInt32(e+4,!0),r=zn(t,n).slice();return ir.__wbindgen_export(t,1*n,1),r}finally{ir.__wbindgen_add_to_stack_pointer(16)}}}],[{key:"__wrap",value:function(t){t>>>=0;var n=Object.create(e.prototype);return n.__wbg_ptr=t,Hn.register(n,n.__wbg_ptr,n),n}}])}();function Ln(e){try{var t=ir.__wbindgen_add_to_stack_pointer(-16),n=nr(e,ir.__wbindgen_export2);ir.decompress_all(t,n,cr);var r=Wn().getInt32(t+0,!0),o=Wn().getInt32(t+4,!0),i=Wn().getInt32(t+8,!0);if(Wn().getInt32(t+12,!0))throw rr(i);var a=zn(r,o).slice();return ir.__wbindgen_export(r,1*o,1),a}finally{ir.__wbindgen_add_to_stack_pointer(16)}}function Pn(e){try{var t=ir.__wbindgen_add_to_stack_pointer(-16),n=nr(e,ir.__wbindgen_export2);ir.decompress_block(t,n,cr);var r=Wn().getInt32(t+0,!0),o=Wn().getInt32(t+4,!0);if(Wn().getInt32(t+8,!0))throw rr(o);return On.__wrap(r)}finally{ir.__wbindgen_add_to_stack_pointer(16)}}function qn(e,t,n,r,o){try{var i=ir.__wbindgen_add_to_stack_pointer(-16),a=nr(e,ir.__wbindgen_export2);ir.decompress_chunk_slice(i,a,cr,t,n,r,o);var s=Wn().getInt32(i+0,!0),c=Wn().getInt32(i+4,!0);if(Wn().getInt32(i+8,!0))throw rr(c);return Mn.__wrap(s)}finally{ir.__wbindgen_add_to_stack_pointer(16)}}function Jn(e,t){return function(e){tr===er.length&&er.push(er.length+1);var t=tr;return tr=er[t],er[t]=e,t}(Error($n(e,t)))}function Un(e,t){throw new Error($n(e,t))}Symbol.dispose&&(On.prototype[Symbol.dispose]=On.prototype.free);var Gn="undefined"==typeof FinalizationRegistry?{register:function(){},unregister:function(){}}:new FinalizationRegistry((function(e){return ir.__wbg_chunksliceresult_free(e>>>0,1)})),Hn="undefined"==typeof FinalizationRegistry?{register:function(){},unregister:function(){}}:new FinalizationRegistry((function(e){return ir.__wbg_decompressresult_free(e>>>0,1)}));function Yn(e,t){return e>>>=0,(null!==Vn&&0!==Vn.byteLength||(Vn=new Float64Array(ir.memory.buffer)),Vn).subarray(e/8,e/8+t)}function zn(e,t){return e>>>=0,Zn().subarray(e/1,e/1+t)}var Kn=null;function Wn(){return(null===Kn||!0===Kn.buffer.detached||void 0===Kn.buffer.detached&&Kn.buffer!==ir.memory.buffer)&&(Kn=new DataView(ir.memory.buffer)),Kn}var Vn=null;function $n(e,t){return function(e,t){return(sr+=t)>=ar&&((or=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0})).decode(),sr=t),or.decode(Zn().subarray(e,e+t))}(e>>>=0,t)}var Xn=null;function Zn(){return null!==Xn&&0!==Xn.byteLength||(Xn=new Uint8Array(ir.memory.buffer)),Xn}var er=new Array(128).fill(void 0);er.push(void 0,null,!0,!1);var tr=er.length;function nr(e,t){var n=t(1*e.length,1)>>>0;return Zn().set(e,n/1),cr=e.length,n}function rr(e){var t=function(e){return er[e]}(e);return function(e){e<132||(er[e]=tr,tr=e)}(e),t}var or=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});or.decode();var ir,ar=2146435072,sr=0,cr=0;function lr(e){ir=e}var ur=null,dr=null;function Ar(){return fr.apply(this,arguments)}function fr(){return(fr=B(U().m((function e(){return U().w((function(e){for(;;)switch(e.n){case 0:if(!ur){e.n=1;break}return e.a(2,ur);case 1:return dr||(dr=B(U().m((function e(){var t,n;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,fetch(jn);case 1:return t=e.v,e.n=2,t.arrayBuffer();case 2:return n=e.v,e.n=3,WebAssembly.instantiate(n,{"./bgzf_wasm_bg.js":Tn});case 3:return lr(ur=e.v.instance.exports),e.a(2,ur)}}),e)})))()),e.a(2,dr)}}),e)})))).apply(this,arguments)}function hr(e){return gr.apply(this,arguments)}function gr(){return(gr=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Ar();case 1:return e.a(2,Ln(t))}}),e)})))).apply(this,arguments)}function pr(e){return mr.apply(this,arguments)}function mr(){return mr=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h;return U().w((function(e){for(;;)switch(e.n){case 0:if("undefined"==typeof DecompressionStream){e.n=6;break}n=new DecompressionStream("gzip"),r=n.writable.getWriter(),o=r.write(t).then((function(){return r.close()})),i=[],a=n.readable.getReader();case 1:return e.n=2,a.read();case 2:if(c=(s=e.v).value,!s.done){e.n=3;break}return e.a(3,4);case 3:i.push(c),e.n=1;break;case 4:return e.n=5,o;case 5:for(l=i.reduce((function(e,t){return e+t.length}),0),u=new Uint8Array(l),d=0,A=0,f=i;A<f.length;A++)u.set(h=f[A],d),d+=h.length;return e.a(2,u);case 6:return e.a(2,Dn(t,void 0));case 7:return e.a(2)}}),e)}))),mr.apply(this,arguments)}function yr(e){return _r.apply(this,arguments)}function _r(){return(_r=B(U().m((function e(t){var n;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,hr(t);case 1:return e.a(2,e.v);case 2:if(e.p=2,!/invalid bgzf header/.exec("".concat(n=e.v))){e.n=4;break}if(!((r=t).length>=2&&31===r[0]&&139===r[1])){e.n=3;break}return e.a(2,pr(t));case 3:throw new Error("problem decompressing block: not a valid bgzf or gzip block");case 4:if(!/invalid gzip header/.exec("".concat(n))){e.n=5;break}throw new Error("problem decompressing block: incorrect gzip header check");case 5:throw n;case 6:return e.a(2)}var r}),e,null,[[0,2]])})))).apply(this,arguments)}function vr(e,t){var n,r=new Uint8Array(function(e){var t,n=0,r=F(e);try{for(r.s();!(t=r.n()).done;)n+=t.value.length}catch(e){r.e(e)}finally{r.f()}return n}(e)),o=0,i=F(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;r.set(a,o),o+=a.length}}catch(e){i.e(e)}finally{i.f()}return r}var br=function(){return D((function e(t){var n=t.filehandle,r=t.gziFilehandle;N(this,e),T(this,"filehandle",void 0),T(this,"gzi",void 0),this.filehandle=n,this.gzi=new Dt({filehandle:r})}),[{key:"_readAndUncompressBlock",value:(t=B(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n){e.n=2;break}return e.n=1,this.filehandle.stat();case 1:r=e.v.size;case 2:return o=r-t,e.n=3,this.filehandle.read(o,t);case 3:return e.a(2,yr(e.v))}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"read",value:(e=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this.gzi.getRelevantBlocksForRead(t,n);case 1:r=e.v,o=[],i=0;case 2:if(!(i<r.length-1)){e.n=5;break}return e.n=3,this._readAndUncompressBlock(r[i][0],r[i+1][0]);case 3:a=e.v,s=K(r[i],2),l=(c=s[1])>=n?0:n-c,u=Math.min(n+t,c+a.length)-c,l>=0&&l<a.length&&o.push(a.subarray(l,u));case 4:i+=1,e.n=2;break;case 5:return e.a(2,vr(o))}}),e,this)}))),function(t,n){return e.apply(this,arguments)})}]);var e,t}();function Cr(e,t,n,r){return e+t*Math.floor(r/n)+r%n}function Ir(e){return wr.apply(this,arguments)}function wr(){return wr=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:return n=C.length>1&&void 0!==C[1]?C[1]:{},r=new TextDecoder("utf8"),b=r,e.n=1,t.readFile(n);case 1:o=b.decode.call(b,e.v),i=[],a=[],s=[],c=[],l=[],u={},d=0,A=o.length,f=0;case 2:if(!(d<A)){e.n=5;break}if(-1===(h=o.indexOf("\n",d))&&(h=A),(g=o.slice(d,h)).endsWith("\r")&&(g=g.slice(0,-1)),g=g.trim(),d=h+1,0!==g.length){e.n=3;break}return e.a(3,2);case 3:if(p=g.indexOf("\t"),m=g.indexOf("\t",p+1),y=g.indexOf("\t",m+1),_=g.indexOf("\t",y+1),!(v=g.slice(0,p)).startsWith(">")){e.n=4;break}throw new Error("found > in sequence name, might have supplied FASTA file for the FASTA index");case 4:i.push(v),s.push(+g.slice(p+1,m)),a.push(+g.slice(m+1,y)),c.push(+g.slice(y+1,_)),l.push(+g.slice(_+1)),u[v]=f,f++,e.n=2;break;case 5:return e.a(2,{names:i,nameToIndex:u,offsets:a,lengths:s,lineLengths:c,lineBytes:l})}}),e)}))),wr.apply(this,arguments)}var Er=function(){return D((function e(t){var n=t.fasta,r=t.fai,o=t.path,i=t.faiPath;if(N(this,e),n)this.fasta=n;else{if(!o)throw new Error("Need to pass filehandle for fasta or path to localfile");this.fasta=new Qt(o)}if(r)this.fai=r;else if(i)this.fai=new Qt(i);else{if(!o)throw new Error("Need to pass filehandle for or path to localfile");this.fai=new Qt("".concat(o,".fai"))}}),[{key:"_getIndexes",value:(s=B(U().m((function e(t){var n=this;return U().w((function(e){for(;;)if(0===e.n)return this.indexes||(this.indexes=Ir(this.fai,t).catch((function(e){throw n.indexes=void 0,e}))),e.a(2,this.indexes)}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getSequenceNames",value:(a=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndexes(t);case 1:return e.a(2,e.v.names)}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getSequenceSizes",value:(i=B(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndexes(t);case 1:if(!(n=e.v).sizesCache){for(r={},o=0;o<n.names.length;o++)r[n.names[o]]=n.lengths[o];n.sizesCache=r}return e.a(2,n.sizesCache)}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSequenceSize",value:(o=B(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndexes(n);case 1:return e.a(2,void 0!==(o=(r=e.v).nameToIndex[t])?r.lengths[o]:void 0)}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"hasReferenceSequence",value:(r=B(U().m((function e(t,n){return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndexes(n);case 1:return e.a(2,void 0!==e.v.nameToIndex[t])}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getResiduesByName",value:(n=B(U().m((function e(t,n,r,o){var i,a;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,this._getIndexes(o);case 1:if(void 0!==(a=(i=e.v).nameToIndex[t])){e.n=2;break}return e.a(2,void 0);case 2:return e.a(2,this._fetchFromIndex(i.offsets[a],i.lineBytes[a],i.lineLengths[a],i.lengths[a],n,r,o))}}),e,this)}))),function(e,t,r,o){return n.apply(this,arguments)})},{key:"getSequence",value:(t=B(U().m((function e(t,n,r,o){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,this.getResiduesByName(t,n,r,o))}),e,this)}))),function(e,n,r,o){return t.apply(this,arguments)})},{key:"_fetchFromIndex",value:(e=B(U().m((function e(t,n,r,o){var i,a,s,c,l,u,d,A,f=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if(a=f.length>6?f[6]:void 0,s=f.length>5?f[5]:void 0,!((i=f.length>4&&void 0!==f[4]?f[4]:0)<0)){e.n=1;break}throw new TypeError("regionStart cannot be less than 0");case 1:if((void 0===s||s>o)&&(s=o),!(i>=s)){e.n=2;break}return e.a(2,"");case 2:return c=Cr(t,n,r,i),l=Cr(t,n,r,s)-c,u=new TextDecoder("utf8"),A=u,e.n=3,this.fasta.read(l,c,a);case 3:if(d=A.decode.call(A,e.v).replace(/\s+/g,""),!/[^\x20-\x7e]/.test(d.slice(0,1e3))){e.n=4;break}throw new Error("Non-ASCII characters detected in sequence. The file may be gzip compressed. Use BgzipIndexedFasta for bgzip files, or decompress the file.");case 4:return e.a(2,d)}}),e,this)}))),function(t,n,r,o){return e.apply(this,arguments)})}]);var e,t,n,r,o,i,a,s}(),xr=function(e){function t(e){var n,r=e.fasta,o=e.path,i=e.fai,a=e.faiPath,s=e.gzi,c=e.gziPath;return N(this,t),n=Q(this,t,[{fasta:r,path:o,fai:i,faiPath:a}]),r&&s?n.fasta=new br({filehandle:r,gziFilehandle:s}):o&&c&&(n.fasta=new br({filehandle:new Qt(o),gziFilehandle:new Qt(c)})),n}return O(t,e),D(t)}(Er),Sr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddAssemblyFromExternalChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=K(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,externalLocation:r.externalLocation}}return{typeName:n,assembly:e,changes:t}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x,S,B,k,Q;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.assemblyModel,r=t.checkModel,o=t.refSeqModel,i=t.user,a=this.assembly,s=this.changes,c=this.logger,u=(l=ue.env.CHUNK_SIZE)&&Number(l),d=F(s),e.p=1,d.s();case 2:if((A=d.n()).done){e.n=12;break}return g=(h=A.value).assemblyName,m=(p=h.externalLocation).fa,y=p.fai,v=(_=p.gzi)?new xr({fasta:new kt(m,{fetch:fetch}),fai:new kt(y,{fetch:fetch}),gzi:new kt(_,{fetch:fetch})}):new Er({fasta:new kt(m,{fetch:fetch}),fai:new kt(y,{fetch:fetch})}),e.n=3,v.getSequenceSizes();case 3:if(b=e.v){e.n=4;break}throw new Error("No data read from indexed fasta getSequenceSizes");case 4:return e.n=5,n.findOne({name:g}).exec();case 5:if(!e.v){e.n=6;break}throw new Error('Assembly "'.concat(g,'" already exists'));case 6:return e.n=7,r.find({default:!0}).exec();case 7:return C=e.v.map((function(e){return e._id.toHexString()})),e.n=8,n.create([{_id:a,name:g,user:i,status:-1,externalLocation:p,checks:C}]);case 8:I=K(e.v,1),w=I[0],null===(f=c.debug)||void 0===f||f.call(c,'Added new assembly "'.concat(g,'", docId "').concat(w._id,'"')),k=H(b);case 9:if((Q=k()).done){e.n=11;break}return E=Q.value,e.n=10,o.create([q(q({name:E,assembly:w._id,length:b[E]},u?{chunkSize:u}:null),{},{user:i,status:-1})]);case 10:S=K(e.v,1),B=S[0],null===(x=c.debug)||void 0===x||x.call(c,'Added new refSeq "'.concat(E,'", docId "').concat(B._id,'"')),e.n=9;break;case 11:e.n=2;break;case 12:e.n=14;break;case 13:e.p=13,d.e(e.v);case 14:return e.p=14,d.f(),e.f(14);case 15:return e.a(2)}}),e,this,[[1,13,14,15]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}]);var n,r,o}(ht),Br=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddAssemblyFromFileChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=K(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"executeOnServer",value:(a=B(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=F(this.changes),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=4;break}return i=(o=r.value).assemblyName,a=o.fileIds,e.n=3,"gzi"in a?this.executeOnServerIndexed(t,i,a):this.executeOnServerFasta(t,i,a.fa);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,n.e(e.v);case 6:return e.p=6,n.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return a.apply(this,arguments)})},{key:"executeOnServerIndexed",value:(i=B(U().m((function e(t,n,r){var o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x,S,B,k,Q,N,R,D,F;return U().w((function(e){for(;;)switch(e.n){case 0:if(s=(a=ue.env.CHUNK_SIZE)&&Number(a),ue.env.FILE_UPLOAD_FOLDER){e.n=1;break}throw new Error("No FILE_UPLOAD_FOLDER found in .env file");case 1:return c=r.fa,l=r.fai,u=r.gzi,d=t.assemblyModel,A=t.checkModel,f=t.fileModel,h=t.filesService,g=t.refSeqModel,p=t.user,e.n=2,f.findById(c);case 2:if(null==(m=e.v)?void 0:m.checksum){e.n=3;break}throw new Error("No checksum for file document ".concat(null==m?void 0:m.id));case 3:return e.n=4,f.findById(l);case 4:if(null==(y=e.v)?void 0:y.checksum){e.n=5;break}throw new Error("No checksum for file document ".concat(null==y?void 0:y.id));case 5:return e.n=6,f.findById(u);case 6:if(null==(_=e.v)?void 0:_.checksum){e.n=7;break}throw new Error("No checksum for file document ".concat(null==_?void 0:_.id));case 7:return v=h.getFileHandle(m),b=h.getFileHandle(y),C=h.getFileHandle(_),I=new xr({fasta:v,fai:b,gzi:C}),e.n=8,I.getSequenceSizes();case 8:return w=e.v,e.n=9,Promise.all([v.close(),b.close(),C.close()]);case 9:return e.n=10,d.findOne({name:n}).exec();case 10:if(!e.v){e.n=11;break}throw new Error('Assembly "'.concat(n,'" already exists'));case 11:return e.n=12,A.find({isDefault:!0}).exec();case 12:return E=e.v.map((function(e){return e._id.toHexString()})),e.n=13,d.create([{_id:this.assembly,name:n,user:p,status:-1,fileIds:r,checks:E}]);case 13:x=K(e.v,1),S=x[0],null===(o=(i=this.logger).debug)||void 0===o||o.call(i,'Added new assembly "'.concat(n,'", docId "').concat(S._id,'"')),D=H(w);case 14:if((F=D()).done){e.n=16;break}return B=F.value,e.n=15,g.create([q(q({name:B,assembly:S._id,length:w[B]},s?{chunkSize:s}:null),{},{user:p,status:-1})]);case 15:N=K(e.v,1),R=N[0],null===(k=(Q=this.logger).debug)||void 0===k||k.call(Q,'Added new refSeq "'.concat(B,'", docId "').concat(R._id,'"')),e.n=14;break;case 16:return e.a(2)}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"executeOnServerFasta",value:(o=B(U().m((function e(t,n,r){var o,i,a,s,c,l,u,d,A,f,h,g,p,m;return U().w((function(e){for(;;)switch(e.n){case 0:return u=t.assemblyModel,d=t.checkModel,A=t.fileModel,f=t.user,e.n=1,A.findById(r).exec();case 1:if(h=e.v){e.n=2;break}throw new Error('File "'.concat(r,'" not found in Mongo'));case 2:return null===(o=(i=this.logger).debug)||void 0===o||o.call(i,'FileId "'.concat(r,'", checksum "').concat(h.checksum,'"')),e.n=3,u.findOne({name:n}).exec();case 3:if(!e.v){e.n=4;break}throw new Error('Assembly "'.concat(n,'" already exists'));case 4:return e.n=5,d.find({default:!0}).exec();case 5:return g=e.v.map((function(e){return e._id.toHexString()})),e.n=6,u.create([{_id:this.assembly,name:n,user:f,status:-1,fileIds:{fa:r},checks:g}]);case 6:return p=K(e.v,1),m=p[0],null===(a=(s=this.logger).debug)||void 0===a||a.call(s,'Added new assembly "'.concat(n,'", docId "').concat(m._id,'"')),null===(c=(l=this.logger).debug)||void 0===c||c.call(l,'File type: "'.concat(h.type,'", assemblyId: "').concat(m._id,'"')),e.n=7,this.addRefSeqIntoDb(h,m._id.toString(),t);case 7:return e.a(2)}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}]);var n,r,o,i,a}(Et),kr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","DeleteFeatureChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return"Feature deleted successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,deletedFeature:o.deletedFeature,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.changes,i=this.logger,(a=ue.env.INDEXED_IDS)&&(s=a.split(",")),c=F(o),e.p=1,u=U().m((function e(){var t,o,a,c,u,A,f,h,g,p,m;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return a=(o=l.value).deletedFeature,c=o.parentFeatureId,e.n=1,n.findOne({allIds:a._id}).session(r).exec();case 1:if(u=e.v){e.n=2;break}throw A="*** ERROR: The following featureId was not found in database ='".concat(a._id,"'"),i.error(A),new Error(A);case 2:if(!u._id.equals(a._id)){e.n=5;break}if(!c){e.n=3;break}throw new Error('Feature "'.concat(a._id,'" is top-level, but received a parent feature ID'));case 3:return e.n=4,n.findByIdAndDelete(u._id);case 4:return null===(f=i.debug)||void 0===f||f.call(i,'Feature "'.concat(a._id,'" deleted from document "').concat(u._id,'". Whole document deleted.')),e.a(2,1);case 5:return(h=Qr(u,a._id,d)).push(a._id),u.allIds=u.allIds.filter((function(e){return!h.includes(e)})),g=d.getIndexedIds(u,s),u.indexedIds?g.length>0?u.indexedIds=g:delete u.indexedIds:g.length>0&&(u.indexedIds=g),u.markModified("children"),e.p=6,e.n=7,u.save();case 7:e.n=9;break;case 8:throw e.p=8,m=e.v,null===(p=i.debug)||void 0===p||p.call(i,"*** FAILED: ".concat(m)),m;case 9:null===(t=i.debug)||void 0===t||t.call(i,'Feature "'.concat(a._id,'" deleted from document "').concat(u._id,'"'));case 10:return e.a(2)}}),e,null,[[6,8]])})),c.s();case 2:if((l=c.n()).done){e.n=5;break}return e.d(Y(u()),3);case 3:if(!e.v){e.n=4;break}return e.a(3,4);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,c.e(e.v);case 7:return e.p=7,c.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=7;break}if(i=(o=r.value).deletedFeature,!(a=o.parentFeatureId)){e.n=5;break}if(s=t.getFeature(a)){e.n=4;break}throw new Error('Could not find parent feature "'.concat(a,'"'));case 4:s.deleteChild(i._id),e.n=6;break;case 5:t.getFeature(i._id)&&t.deleteFeature(i._id);case 6:e.n=3;break;case 7:e.n=9;break;case 8:e.p=8,n.e(e.v);case 9:return e.p=9,n.f(),e.f(9);case 10:return e.a(2)}}),e,this,[[2,8,9,10]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=V(this.changedIds).reverse(),i=V(n).reverse().map((function(e){return{addedFeature:e.deletedFeature,parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Nr({changedIds:o,typeName:"AddFeatureChange",changes:i,assembly:t},{logger:r})}}]);var n,r,o}(pt);function Qr(e,t,n){if(!e.children)throw new Error("Feature ".concat(e._id," has no children"));var r=e._id,o=e.children,i=o.get(t);if(i){var a=n.getChildFeatureIds(i);return o.delete(t),a}var s,c=F(o);try{for(c.s();!(s=c.n()).done;){var l=K(s.value,2)[1];try{return Qr(l,t,n)}catch(e){}}}catch(e){c.e(e)}finally{c.f()}throw new Error('Feature "'.concat(t,'" not found in ').concat(r))}var Nr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddFeatureChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return"Feature added successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,addedFeature:o.addedFeature,parentFeatureId:o.parentFeatureId,copyFeature:o.copyFeature,allIds:o.allIds}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x,S,B,k,Q,N,R,D,T,j,M,O,L,P,J;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return o=t.assemblyModel,i=t.featureModel,a=t.refSeqModel,s=t.session,c=t.user,l=this.assembly,u=this.changes,d=this.logger,e.n=1,o.findById(l).session(s).exec();case 1:if(e.v){e.n=2;break}throw A='*** ERROR: Assembly with id "'.concat(l,'" not found'),d.error(A),new Error(A);case 2:f=0,null===(n=d.debug)||void 0===n||n.call(d,"changes: ".concat(JSON.stringify(u))),(h=ue.env.INDEXED_IDS)&&(g=h.split(",")),p=F(u),e.p=3,p.s();case 4:if((m=p.n()).done){e.n=17;break}return _=m.value,null===(y=d.debug)||void 0===y||y.call(d,"change: ".concat(JSON.stringify(_))),b=_.allIds,C=_.copyFeature,I=_.parentFeatureId,w=(v=_.addedFeature)._id,E=v.refSeq,e.n=5,a.findById(E).session(s).exec();case 5:if(e.v){e.n=6;break}throw new Error('RefSeq was not found by assembly "'.concat(l,'" and seq_id "').concat(E,'" not found'));case 6:if(!C){e.n=8;break}return S=this.getIndexedIds(v,g),e.n=7,i.create([q(q({},v),{},{allIds:b,indexedIds:S,status:-1,user:c})],{session:s});case 7:B=K(e.v,1),k=B[0],null===(x=d.debug)||void 0===x||x.call(d,'Copied feature, docId "'.concat(k._id,'" to assembly "').concat(l,'"')),f++,e.n=15;break;case 8:if(Q=this.getIndexedIds(v,g),!I){e.n=13;break}return e.n=9,i.findOne({allIds:I}).session(s).exec();case 9:if(D=e.v){e.n=10;break}throw new Error('Could not find feature with ID "'.concat(I,'"'));case 10:if(T=this.getFeatureFromId(D,I)){e.n=11;break}throw new Error('Could not find feature with ID "'.concat(I,'" in feature "').concat(D._id,'"'));case 11:return this.addChild(T,v),j=this.getChildFeatureIds(v),(N=D.allIds).push.apply(N,[w].concat(V(j))),Q.length>0&&!D.indexedIds&&(D.indexedIds=[]),null===(R=D.indexedIds)||void 0===R||R.push.apply(R,V(Q)),e.n=12,D.save();case 12:e.n=15;break;case 13:return O=this.getChildFeatureIds(v),L=[w].concat(V(O)),e.n=14,i.create([q({allIds:L,indexedIds:Q,status:0},v)],{session:s});case 14:P=K(e.v,1),J=P[0],null===(M=d.verbose)||void 0===M||M.call(d,'Added docId "'.concat(J._id,'"'));case 15:f++;case 16:e.n=4;break;case 17:e.n=19;break;case 18:e.p=18,p.e(e.v);case 19:return e.p=19,p.f(),e.f(19);case 20:null===(r=d.debug)||void 0===r||r.call(d,"Added ".concat(f," new feature(s) into database."));case 21:return e.a(2)}}),e,this,[[3,18,19,20]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=this.assembly,r=F(this.changes),e.p=2,r.s();case 3:if((o=r.n()).done){e.n=8;break}if(a=(i=o.value).addedFeature,!(s=i.parentFeatureId)){e.n=6;break}if(c=t.getFeature(s)){e.n=5;break}return e.n=4,t.loadFeatures([{assemblyName:n,refName:a.refSeq,start:a.min,end:a.max}]);case 4:if(c=t.getFeature(s)){e.n=5;break}throw new Error('Could not find parent feature "'.concat(s,'"'));case 5:c.attributes.get("_id")||c.setAttribute("_id",[c._id]),c.addChild(a),e.n=7;break;case 6:t.addFeature(n,a);case 7:e.n=3;break;case 8:e.n=10;break;case 9:e.p=9,r.e(e.v);case 10:return e.p=10,r.f(),e.f(10);case 11:return e.a(2)}}),e,this,[[2,9,10,11]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=V(this.changedIds).reverse(),o=V(t).reverse().map((function(e){return{deletedFeature:e.addedFeature,parentFeatureId:e.parentFeatureId}}));return new kr({changedIds:r,typeName:"DeleteFeatureChange",changes:o,assembly:e},{logger:n})}}]);var n,r,o}(pt),Rr=function(e){function t(e,n){var r,o;return N(this,t),T(o=Q(this,t,[e,n]),"typeName","AddFeaturesFromFileChange"),T(o,"changes",void 0),T(o,"deleteExistingFeatures",!1),o.deleteExistingFeatures=null!==(r=e.deleteExistingFeatures)&&void 0!==r&&r,o.changes="changes"in e?e.changes:[e],o}return O(t,e),D(t,[{key:"notification",get:function(){return"Features have been added. To see them, please refresh the page."}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.deleteExistingFeatures,r=this.typeName;return 1===t.length?{typeName:r,assembly:e,fileId:K(t,1)[0].fileId,deleteExistingFeatures:n}:{typeName:r,assembly:e,changes:t,deleteExistingFeatures:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(r=t.fileModel,o=t.filesService,i=this.changes,a=this.logger,!this.deleteExistingFeatures){e.n=1;break}return e.n=1,this.removeExistingFeatures(t);case 1:s=F(i),e.p=2,l=U().m((function e(){var n,i,s,l,p,m,y,_,v,b,C,I,w,x,S,B,k;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(s=(i=c.value).fileId,l=i.parseOptions,ue.env.FILE_UPLOAD_FOLDER){e.n=1;break}throw new Error("No FILE_UPLOAD_FOLDER found in .env file");case 1:return e.n=2,r.findById(s).exec();case 2:if(p=e.v){e.n=3;break}throw new Error('File "'.concat(s,'" not found in Mongo'));case 3:null===(n=a.debug)||void 0===n||n.call(a,'FileId "'.concat(s,'", checksum "').concat(p.checksum,'"')),m=0,y=function(e){m<=99&&(a.warn("Error parsing or adding feature"),a.warn(e),99===m&&a.warn("Reached 100 feature errors, omitting further warnings from log")),m++},b=void 0===(v=(_=null!=l?l:{}).bufferSize)?1e4:v,I=void 0===(C=_.strict)||C,w=o.parseGFF3(o.getFileStream(p),{bufferSize:b,errorCallback:I?void 0:y}),x=0,u=!1,d=!1,e.p=4,f=E(w);case 5:return e.n=6,f.next();case 6:if(!(u=!(h=e.v).done)){e.n=13;break}return S=h.value,e.p=7,e.n=8,g.addFeatureIntoDb(S,t);case 8:e.n=11;break;case 9:if(e.p=9,k=e.v,!I&&0!==x){e.n=10;break}throw k;case 10:y(k);case 11:++x%1e3==0&&(null===(B=a.debug)||void 0===B||B.call(a,"Processed ".concat(x," features")));case 12:u=!1,e.n=5;break;case 13:e.n=15;break;case 14:e.p=14,d=!0,A=e.v;case 15:if(e.p=15,e.p=16,!u||null==f.return){e.n=17;break}return e.n=17,f.return();case 17:if(e.p=17,!d){e.n=18;break}throw A;case 18:return e.f(17);case 19:return e.f(15);case 20:return e.a(2)}}),e,null,[[16,,17,19],[7,9],[4,14,15,20]])})),s.s();case 3:if((c=s.n()).done){e.n=5;break}return e.d(Y(l()),4);case 4:e.n=3;break;case 5:e.n=7;break;case 6:e.p=6,s.e(e.v);case 7:return e.p=7,s.f(),e.f(7);case 8:null===(n=a.debug)||void 0===n||n.call(a,"New features added into database!");case 9:return e.a(2)}}),e,this,[[2,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}]);var n,r,o}(Et),Dr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","AddRefSeqAliasesChange"),T(r,"refSeqAliases",void 0),r.refSeqAliases=e.refSeqAliases,r}return O(t,e),D(t,[{key:"executeOnClient",value:function(e){var t,n=o.getSession(e).assemblyManager.get(this.assembly);if(!n)throw new Error("assembly ".concat(this.assembly," not found"));var r,i=null!==(t=n.refNameAliases)&&void 0!==t?t:{},a=F(this.refSeqAliases);try{for(a.s();!(r=a.n()).done;){var s,c=r.value,l=c.refName,u=F(c.aliases);try{for(u.s();!(s=u.n()).done;)i[s.value]=l}catch(e){u.e(e)}finally{u.f()}}}catch(e){a.e(e)}finally{a.f()}return n.setRefNameAliases(i),Promise.resolve()}},{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,refSeqAliases:this.refSeqAliases}}},{key:"executeOnServer",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.refSeqModel,r=t.session,o=this.assembly,i=this.logger,a=F(this.refSeqAliases),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=4;break}return l=s.value,null===(c=i.debug)||void 0===c||c.call(i,"Updating Refname alias for assembly: ".concat(o,", refSeqAlias: ").concat(JSON.stringify(l))),u=l.aliases,d=l.refName,e.n=3,n.updateOne({assembly:o,name:d},{$set:{aliases:u}}).session(r);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a.e(e.v);case 6:return e.p=6,a.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return n.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:function(e){throw new Error("Method not implemented.")}},{key:"notification",get:function(){return"RefSeq aliases have been added."}}]);var n}(ht),Fr=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"typeName","DeleteAssemblyChange"),e}return O(t,e),D(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.assembly,'" deleted successfully.')}},{key:"toJSON",value:function(){return{typeName:this.typeName,assembly:this.assembly}}},{key:"executeOnServer",value:(i=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d;return U().w((function(e){for(;;)switch(e.n){case 0:return r=t.assemblyModel,o=t.featureModel,i=t.refSeqChunkModel,a=t.refSeqModel,s=t.session,c=this.assembly,l=this.logger,e.n=1,r.findById(c).session(s).exec();case 1:if(e.v){e.n=2;break}throw u='*** ERROR: Assembly with id "'.concat(c,'" not found'),l.error(u),new Error(u);case 2:return e.n=3,a.find({assembly:c}).exec();case 3:return d=e.v.map((function(e){return e._id})),e.n=4,i.deleteMany({refSeq:d}).exec();case 4:return e.n=5,o.deleteMany({refSeq:d}).exec();case 5:return e.n=6,a.deleteMany({assembly:c}).exec();case 6:return e.n=7,r.findByIdAndDelete(c).exec();case 7:null===(n=l.debug)||void 0===n||n.call(l,'Assembly "'.concat(c,'" deleted from database.'));case 8:return e.a(2)}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,i,a;return U().w((function(e){for(;;)switch(e.n){case 0:if(i=this.assembly,t){e.n=1;break}throw new Error("No data store");case 1:return a=o.getSession(t),t.assemblies.has(i)&&t.deleteAssembly(i),e.n=2,null===(n=a.removeAssembly)||void 0===n?void 0:n.call(a,i);case 2:return e.n=3,null===(r=a.removeSessionAssembly)||void 0===r?void 0:r.call(a,i);case 3:return e.a(2)}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:"DeleteAssemblyChange",assembly:this.assembly},{logger:this.logger})}}]);var n,r,i}(ht),Tr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","DeleteUserChange"),T(r,"changes",void 0),T(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return O(t,e),D(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,userId:this.userId}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.n){case 0:return n=t.session,r=t.userModel,o=this.logger,i=this.userId,e.n=1,r.findOneAndDelete({_id:i}).session(n).exec();case 1:if(e.v){e.n=2;break}throw a='*** ERROR: User with id "'.concat(i,'" not found'),o.error(a),new Error(a);case 2:return e.a(2)}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,userId:this.userId},{logger:this.logger})}}]);var n,r,o}(ft),jr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","FeatureAttributeChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldAttributes:o.oldAttributes,newAttributes:o.newAttributes}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,i=this.logger,a=[],s=F(o=this.changes),e.p=1,s.s();case 2:if((c=s.n()).done){e.n=7;break}return d=c.value.featureId,e.n=3,n.findOne({allIds:d}).session(r).exec();case 3:if(A=e.v){e.n=4;break}throw f="*** ERROR: The following featureId was not found in database ='".concat(d,"'"),i.error(f),new Error(f);case 4:if(null===(l=i.debug)||void 0===l||l.call(i,"*** Feature found: ".concat(JSON.stringify(A))),h=this.getFeatureFromId(A,d)){e.n=5;break}throw i.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 5:null===(u=i.debug)||void 0===u||u.call(i,"*** Found feature: ".concat(JSON.stringify(h))),a.push({feature:h,topLevelFeature:A});case 6:e.n=2;break;case 7:e.n=9;break;case 8:e.p=8,s.e(e.v);case 9:return e.p=9,s.f(),e.f(9);case 10:(g=ue.env.INDEXED_IDS)&&(p=g.split(",")),m=F(o.entries()),e.p=11,_=U().m((function e(){var t,n,r,o,s,c,l,u,d,A,f;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:return r=K(y.value,2),o=r[1].newAttributes,c=(s=a[r[0]]).feature,l=s.topLevelFeature,u=null===(t=p)||void 0===t?void 0:t.some((function(e){var t;return e in o||e in(null!==(t=null==c?void 0:c.attributes)&&void 0!==t?t:{})})),c.attributes=o,u&&(d=v.getIndexedIds(l,p),l.indexedIds=d,l.markModified("indexedIds")),l._id.equals(c._id)?l.markModified("attributes"):l.markModified("children"),e.p=1,e.n=2,l.save();case 2:e.n=4;break;case 3:throw e.p=3,f=e.v,null===(A=i.debug)||void 0===A||A.call(i,"*** FAILED: ".concat(f)),f;case 4:null===(n=i.debug)||void 0===n||n.call(i,"*** Feature attributes modified (added, edited or deleted), docId: ".concat(JSON.stringify(l)));case 5:return e.a(2)}}),e,null,[[1,3]])})),m.s();case 12:if((y=m.n()).done){e.n=14;break}return e.d(Y(_()),13);case 13:e.n=12;break;case 14:e.n=16;break;case 15:e.p=15,m.e(e.v);case 16:return e.p=16,m.f(),e.f(16);case 17:return e.a(2)}}),e,this,[[11,15,16,17],[1,8,9,10]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("applyToLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changedIds.entries()),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(o=K(r.value,2),i=o[0],s=t.getFeature(a=o[1])){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(a,'"'));case 4:s.setAttributes(new Map(Object.entries(this.changes[i].newAttributes)));case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger;return new t({changedIds:V(this.changedIds).reverse(),typeName:"FeatureAttributeChange",changes:V(n).reverse().map((function(e){return{featureId:e.featureId,oldAttributes:e.newAttributes,newAttributes:e.oldAttributes}})),assembly:e},{logger:r})}}]);var n,r,o}(pt),Mr=["__v","_id","assemblies","configuration","internetAccounts","plugins","tracks"],Or=["hasRole"];function Lr(e){var t,n=e.assemblies,r=e.configuration,o=e.internetAccounts,i=e.plugins,a=e.tracks,s=J(e,Mr);if(n&&(s.assemblies=n.filter((function(e){return"ApolloSequenceAdapter"!==e.sequence.adapter.type}))),null!=r&&null!==(t=r.ApolloPlugin)&&void 0!==t&&t.hasRole){var c=J(r.ApolloPlugin,Or);s.configuration=q(q({},r),{},{ApolloPlugin:c})}return o&&(s.internetAccounts=o.filter((function(e){return"ApolloInternetAccount"!==e.type}))),i&&(s.plugins=i.filter((function(e){return"Apollo"!==e.name}))),a&&(s.tracks=a.filter((function(e){return"ApolloTrack"!==e.type}))),s}var Pr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","ImportJBrowseConfigChange"),T(r,"oldJBrowseConfig",void 0),T(r,"newJBrowseConfig",void 0),r.oldJBrowseConfig=e.oldJBrowseConfig,r.newJBrowseConfig=e.newJBrowseConfig,r}return O(t,e),D(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,oldJBrowseConfig:this.oldJBrowseConfig,newJBrowseConfig:this.newJBrowseConfig}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.n){case 0:return r=t.jbrowseConfigModel,o=this.logger,i=this.newJBrowseConfig,e.n=1,r.deleteMany();case 1:if(i){e.n=2;break}return e.a(2);case 2:return a=Lr(i),e.n=3,r.create(a);case 3:null===(n=o.debug)||void 0===n||n.call(o,"Stored new JBrowse Config");case 4:return e.a(2)}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:this.newJBrowseConfig,newJBrowseConfig:this.oldJBrowseConfig},{logger:this.logger})}}]);var n,r,o}(ft),qr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","LocationEndChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldEnd:o.oldEnd,newEnd:o.newEnd}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.logger,i=[],a=F(this.changes),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=16;break}d=(u=s.value).featureId,A=u.oldEnd,f=u.newEnd,h=void 0,g=void 0,p=F(i),e.p=3,p.s();case 4:if((m=p.n()).done){e.n=6;break}if(!(_=this.getFeatureFromId(y=m.value,d))){e.n=5;break}return h=y,g=_,e.a(3,6);case 5:e.n=4;break;case 6:e.n=8;break;case 7:e.p=7,p.e(e.v);case 8:return e.p=8,p.f(),e.f(8);case 9:if(h){e.n=11;break}return e.n=10,n.findOne({allIds:d}).session(r).exec();case 10:(h=e.v)&&i.push(h);case 11:if(h){e.n=12;break}throw v="*** ERROR: The following featureId was not found in database ='".concat(d,"'"),o.error(v),new Error(v);case 12:if(null===(c=o.debug)||void 0===c||c.call(o,"*** TOP level feature found: ".concat(JSON.stringify(h))),g||(g=this.getFeatureFromId(h,d)),g){e.n=13;break}throw o.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 13:if(null===(l=o.debug)||void 0===l||l.call(o,"*** Found feature: ".concat(JSON.stringify(g))),g.max===A){e.n=14;break}throw o.error("Expected previous max does not match"),new Error("Expected previous max does not match");case 14:g.max=f,h._id.equals(g._id)?h.markModified("end"):h.markModified("children");case 15:e.n=2;break;case 16:e.n=18;break;case 17:e.p=17,a.e(e.v);case 18:return e.p=18,a.f(),e.f(18);case 19:b=0,C=i;case 20:if(!(b<C.length)){e.n=25;break}return I=C[b],e.p=21,e.n=22,I.save();case 22:e.n=24;break;case 23:throw e.p=23,E=e.v,null===(w=o.debug)||void 0===w||w.call(o,"*** FAILED: ".concat(E)),E;case 24:b++,e.n=20;break;case 25:return e.a(2)}}),e,this,[[21,23],[3,7,8,9],[1,17,18,19]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(a=(o=r.value).newEnd,s=t.getFeature(i=o.featureId)){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(i,'"'));case 4:s.setMax(a);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:V(this.changedIds).reverse(),typeName:o,changes:V(n).reverse().map((function(e){return{featureId:e.featureId,oldEnd:e.newEnd,newEnd:e.oldEnd}})),assembly:e},{logger:r})}}]);var n,r,o}(pt);function Jr(e){return"LocationEndChange"===e.typeName}var Ur=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","LocationStartChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStart:o.oldStart,newStart:o.newStart}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.logger,i=[],a=F(this.changes),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=16;break}d=(u=s.value).featureId,A=u.oldStart,f=u.newStart,h=void 0,g=void 0,p=F(i),e.p=3,p.s();case 4:if((m=p.n()).done){e.n=6;break}if(!(_=this.getFeatureFromId(y=m.value,d))){e.n=5;break}return h=y,g=_,e.a(3,6);case 5:e.n=4;break;case 6:e.n=8;break;case 7:e.p=7,p.e(e.v);case 8:return e.p=8,p.f(),e.f(8);case 9:if(h){e.n=11;break}return e.n=10,n.findOne({allIds:d}).session(r).exec();case 10:(h=e.v)&&i.push(h);case 11:if(h){e.n=12;break}throw v="*** ERROR: The following featureId was not found in database ='".concat(d,"'"),o.error(v),new Error(v);case 12:if(null===(c=o.debug)||void 0===c||c.call(o,"*** TOP level feature found: ".concat(JSON.stringify(h))),g||(g=this.getFeatureFromId(h,d)),g){e.n=13;break}throw o.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 13:if(null===(l=o.debug)||void 0===l||l.call(o,"*** Found feature: ".concat(JSON.stringify(g))),g.min===A){e.n=14;break}throw o.error("Expected previous max does not match"),new Error("Expected previous max does not match");case 14:g.min=f,h._id.equals(g._id)?h.markModified("start"):h.markModified("children");case 15:e.n=2;break;case 16:e.n=18;break;case 17:e.p=17,a.e(e.v);case 18:return e.p=18,a.f(),e.f(18);case 19:b=0,C=i;case 20:if(!(b<C.length)){e.n=25;break}return I=C[b],e.p=21,e.n=22,I.save();case 22:e.n=24;break;case 23:throw e.p=23,E=e.v,null===(w=o.debug)||void 0===w||w.call(o,"*** FAILED: ".concat(E)),E;case 24:b++,e.n=20;break;case 25:return e.a(2)}}),e,this,[[21,23],[3,7,8,9],[1,17,18,19]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(a=(o=r.value).newStart,s=t.getFeature(i=o.featureId)){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(i,'"'));case 4:s.setMin(a);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:V(this.changedIds).reverse(),typeName:o,changes:V(n).reverse().map((function(e){return{featureId:e.featureId,oldStart:e.newStart,newStart:e.oldStart}})),assembly:e},{logger:r})}}]);var n,r,o}(pt);function Gr(e){return"LocationStartChange"===e.typeName}function Hr(e,t){for(var n=[],r=0;r<e.length;r+=t){var o=e.slice(r,r+t);n.push(o)}return n}function Yr(e){var t,n,r=e,o=null===(t=r.attributes.get("gff_id"))||void 0===t?void 0:t.join(",");if(o)return"ID=".concat(o," (_id: ").concat(e._id.toString(),")");var i=null===(n=r.attributes.get("gff_name"))||void 0===n?void 0:n.join(",");return i?"Name=".concat(i," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}function zr(e){var t={};if(!e)return t;for(var n=0,r=Object.entries(e);n<r.length;n++){var o=K(r[n],2),i=o[1];t[o[0]]=null==i?void 0:i.slice()}return t}function Kr(e){if(!e)return"";for(var t=[],n=0,r=Object.entries(e);n<r.length;n++){var o=K(r[n],2),i=o[1],a=o[0];a.startsWith("gff_")&&(a=(a=a.slice(4)).charAt(0).toUpperCase()+a.slice(1)),t.push(i?"".concat(a,"=").concat(i.join(",")):a)}return encodeURIComponent(t.join(";"))}var Wr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","UndoMergeExonsChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonsToRestore:o.exonsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=F(this.changes),e.p=1,o.s();case 2:if((i=o.n()).done){e.n=8;break}if(c=(a=i.value).parentFeatureId,2===(s=a.exonsToRestore).length){e.n=3;break}throw new Error("Expected exactly two exons to restore. Got :".concat(s.length));case 3:return e.n=4,n.findOne({allIds:c}).session(r).exec();case 4:if(l=e.v){e.n=5;break}throw new Error('Could not find feature with ID "'.concat(c,'"'));case 5:if(u=this.getFeatureFromId(l,c)){e.n=6;break}throw new Error('Could not find feature with ID "'.concat(c,'" in feature "').concat(l._id.toString(),'"'));case 6:u.children||(u.children=new Map),d=F(s);try{for(d.s();!(A=d.n()).done;)this.addChild(u,h=A.value),g=this.getChildFeatureIds(h),(f=l.allIds).push.apply(f,[h._id].concat(V(g)))}catch(e){d.e(e)}finally{d.f()}return e.n=7,l.save();case 7:e.n=2;break;case 8:e.n=10;break;case 9:e.p=9,o.e(e.v);case 10:return e.p=10,o.f(),e.f(10);case 11:return e.a(2)}}),e,this,[[1,9,10,11]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=7;break}if(i=(o=r.value).exonsToRestore,a=o.parentFeatureId){e.n=4;break}throw new Error("Parent ID is missing");case 4:if(s=t.getFeature(a)){e.n=5;break}throw new Error('Could not find parent feature "'.concat(a,'"'));case 5:s.attributes.get("_id")||s.setAttribute("_id",[s._id]),c=F(i);try{for(c.s();!(l=c.n()).done;)s.addChild(l.value)}catch(e){c.e(e)}finally{c.f()}case 6:e.n=3;break;case 7:e.n=9;break;case 8:e.p=8,n.e(e.v);case 9:return e.p=9,n.f(),e.f(9);case 10:return e.a(2)}}),e,this,[[2,8,9,10]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=V(this.changedIds).reverse(),o=V(t).reverse().map((function(e){return{firstExon:e.exonsToRestore[0],secondExon:e.exonsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new Vr({changedIds:r,typeName:"MergeExonsChange",changes:o,assembly:e},{logger:n})}}]);var n,r,o}(pt),Vr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","MergeExonsChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return"Exons successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstExon:o.firstExon,secondExon:o.secondExon,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.logger,i=F(this.changes),e.p=1,s=U().m((function e(){var t,i,s,l,u,d,A,f;return U().w((function(e){for(;;)switch(e.n){case 0:return i=(t=a.value).firstExon,s=t.secondExon,e.n=1,n.findOne({allIds:i._id}).session(r).exec();case 1:if(l=e.v){e.n=2;break}throw u="*** ERROR: The following featureId was not found in database ='".concat(i._id,"'"),o.error(u),new Error(u);case 2:if(d=c.getFeatureFromId(l,i._id)){e.n=3;break}throw o.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 3:return d.min=Math.min(i.min,s.min),d.max=Math.max(i.max,s.max),(A=d.attributes?JSON.parse(JSON.stringify(d.attributes)):{}).merged_with=[Kr(zr(s.attributes))],d.attributes=A,(f=Qr(l,s._id,c)).push(s._id),l.allIds=l.allIds.filter((function(e){return!f.includes(e)})),e.n=4,l.save();case 4:return e.a(2)}}),e)})),i.s();case 2:if((a=i.n()).done){e.n=4;break}return e.d(Y(s()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,i.e(e.v);case 6:return e.p=6,i.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(l=(s=r.value).secondExon,u=t.getFeature((c=s.firstExon)._id)){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(c._id,'"'));case 4:u.setMin(Math.min(c.min,l.min)),u.setMax(Math.max(c.max,l.max)),d=null!==(o=null===(i=u.attributes.get("merged_with"))||void 0===i?void 0:i.slice())&&void 0!==o?o:[],A=Kr(zr(l.attributes)),d.includes(A)||d.push(A),u.setAttribute("merged_with",d),null===(a=u.parent)||void 0===a||a.deleteChild(l._id);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=V(this.changedIds).reverse(),i=V(n).reverse().map((function(e){return{exonsToRestore:[e.firstExon,e.secondExon],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Wr({changedIds:o,typeName:"UndoMergeExonsChange",changes:i,assembly:t},{logger:r})}}]);var n,r,o}(pt),$r=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","UndoMergeTranscriptsChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,transcriptsToRestore:o.transcriptsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=F(this.changes),e.p=1,o.s();case 2:if((i=o.n()).done){e.n=8;break}if(c=(a=i.value).parentFeatureId,2===(s=a.transcriptsToRestore).length){e.n=3;break}throw new Error("Expected exactly two transcripts to restore. Got :".concat(s.length));case 3:return e.n=4,n.findOne({allIds:c}).session(r).exec();case 4:if(l=e.v){e.n=5;break}throw new Error('Could not find feature with ID "'.concat(c,'"'));case 5:if(u=this.getFeatureFromId(l,c)){e.n=6;break}throw new Error('Could not find feature with ID "'.concat(c,'" in feature "').concat(l._id.toString(),'"'));case 6:u.children||(u.children=new Map),d=F(s);try{for(d.s();!(A=d.n()).done;)this.addChild(u,h=A.value),g=this.getChildFeatureIds(h),(f=l.allIds).push.apply(f,[h._id].concat(V(g)))}catch(e){d.e(e)}finally{d.f()}return e.n=7,l.save();case 7:e.n=2;break;case 8:e.n=10;break;case 9:e.p=9,o.e(e.v);case 10:return e.p=10,o.f(),e.f(10);case 11:return e.a(2)}}),e,this,[[1,9,10,11]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=7;break}if(i=(o=r.value).transcriptsToRestore,a=o.parentFeatureId){e.n=4;break}throw new Error("Parent ID is missing");case 4:if(s=t.getFeature(a)){e.n=5;break}throw new Error('Could not find parent feature "'.concat(a,'"'));case 5:s.attributes.get("_id")||s.setAttribute("_id",[s._id]),c=F(i);try{for(c.s();!(l=c.n()).done;)s.addChild(l.value)}catch(e){c.e(e)}finally{c.f()}case 6:e.n=3;break;case 7:e.n=9;break;case 8:e.p=8,n.e(e.v);case 9:return e.p=9,n.f(),e.f(9);case 10:return e.a(2)}}),e,this,[[2,8,9,10]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=V(this.changedIds).reverse(),o=V(t).reverse().map((function(e){return{firstTranscript:e.transcriptsToRestore[0],secondTranscript:e.transcriptsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new Xr({changedIds:r,typeName:"MergeTranscriptsChange",changes:o,assembly:e},{logger:n})}}]);var n,r,o}(pt),Xr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","MergeTranscriptsChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return"Transcripts successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstTranscript:o.firstTranscript,secondTranscript:o.secondTranscript,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(i=B(U().m((function e(t){var n,r,o,i,a,s,c=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.logger,i=F(this.changes),e.p=1,s=U().m((function e(){var t,i,s,l,u,d,A;return U().w((function(e){for(;;)switch(e.n){case 0:return i=(t=a.value).firstTranscript,s=t.secondTranscript,e.n=1,n.findOne({allIds:i._id}).session(r).exec();case 1:if(l=e.v){e.n=2;break}throw u="*** ERROR: The following featureId was not found in database ='".concat(i._id,"'"),o.error(u),new Error(u);case 2:if(d=c.getFeatureFromId(l,i._id)){e.n=3;break}throw o.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 3:return c.mergeTranscriptsOnServer(d,s),(A=Qr(l,s._id,c)).push(s._id),l.allIds=l.allIds.filter((function(e){return!A.includes(e)})),e.n=4,l.save();case 4:return e.a(2)}}),e)})),i.s();case 2:if((a=i.n()).done){e.n=4;break}return e.d(Y(s()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,i.e(e.v);case 6:return e.p=6,i.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return i.apply(this,arguments)})},{key:"mergeTranscriptsOnServer",value:function(e,t){e.min=Math.min(e.min,t.min),e.max=Math.max(e.max,t.max);var n=e.attributes?JSON.parse(JSON.stringify(e.attributes)):{};if(t.attributes&&(Object.keys(n).includes("merged_with")||(n.merged_with=[]),n.merged_with.push(Kr(zr(t.attributes)))),e.attributes=n,t.children)for(var r=0,o=Object.entries(t.children);r<o.length;r++){var i=K(o[r],2);this.mergeFeatureIntoTranscriptOnServer(i[1],e)}}},{key:"mergeFeatureIntoTranscriptOnServer",value:function(e,t){var n=this;t.children||(t.children=new Map);var r,i,a,s=!1,c=F(t.children);try{for(c.s();!(a=c.n()).done;){var l=K(a.value,2)[1];if(s&&r?i=!0:(i=!1,r=l),r.type===e.type&&r.type===l.type&&o.doesIntersect2(e.min,e.max,r.min,r.max)&&o.doesIntersect2(l.min,l.max,r.min,r.max)){r.min=Math.min(e.min,r.min,l.min),r.max=Math.max(e.max,r.max,l.max),r.attributes||(r.attributes={});var u=JSON.parse(JSON.stringify(r.attributes));Object.keys(u).includes("merged_with")||(u.merged_with=[]);var d=u.merged_with;if(d.push(Kr(zr(e.attributes))),i){var A=l.attributes?JSON.parse(JSON.stringify(l.attributes)):void 0;d.push(Kr(A)),t.children.delete(l._id.toString())}u.merged_with=V(new Set(d)),r.attributes=u,s=!0}}}catch(e){c.e(e)}finally{c.f()}s&&r&&e.children&&Object.entries(e.children).map((function(e){var t=K(e,2);n.addChild(r,t[1])})),this.addChild(t,s&&r?r:e)}},{key:"executeOnClient",value:(r=B(U().m((function e(t){var n,r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changedIds.entries()),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(i=K(r.value,2),a=i[1],c=(s=this.changes[i[0]]).secondTranscript,l=t.getFeature(s.firstTranscript._id)){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(a,'"'));case 4:this.mergeTranscriptsOnClient(l,c),null===(o=l.parent)||void 0===o||o.deleteChild(c._id);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return r.apply(this,arguments)})},{key:"mergeTranscriptsOnClient",value:function(e,t){var n,r;e.setMin(Math.min(e.min,t.min)),e.setMax(Math.max(e.max,t.max));var o=null!==(n=null===(r=e.attributes.get("merged_with"))||void 0===r?void 0:r.slice())&&void 0!==n?n:[],i=Kr(zr(t.attributes));if(o.includes(i)||o.push(i),e.setAttribute("merged_with",o),t.children)for(var a=0,s=Object.entries(t.children);a<s.length;a++){var c=K(s[a],2);this.mergeFeatureIntoTranscriptOnClient(c[1],e)}}},{key:"mergeFeatureIntoTranscriptOnClient",value:function(e,t){t.children||(t.children=new Map);var n,r,i,a=!1,s=F(t.children);try{for(s.s();!(i=s.n()).done;){var l=K(i.value,2)[1];if(a&&n?r=!0:(r=!1,n=l),n.type===e.type&&n.type===l.type&&o.doesIntersect2(e.min,e.max,n.min,n.max)&&o.doesIntersect2(l.min,l.max,n.min,n.max)){var u,d;n.setMin(Math.min(e.min,n.min,l.min)),n.setMax(Math.max(e.max,n.max,l.max));var A=null!==(u=null===(d=n.attributes.get("merged_with"))||void 0===d?void 0:d.slice())&&void 0!==u?u:[];A.push(Kr(zr(e.attributes))),r&&(A.push(Kr(c.getSnapshot(l).attributes)),t.deleteChild(l._id)),n.setAttribute("merged_with",V(new Set(A))),a=!0}}}catch(e){s.e(e)}finally{s.f()}a&&n&&e.children&&Object.entries(e.children).map((function(e){var t=K(e,2);n.addChild(t[1])})),t.addChild(a&&n?c.getSnapshot(n):e)}},{key:"executeOnLocalGFF3",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=V(this.changedIds).reverse(),i=V(n).reverse().map((function(e){return{transcriptsToRestore:[e.firstTranscript,e.secondTranscript],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new $r({changedIds:o,typeName:"UndoMergeTranscriptsChange",changes:i,assembly:t},{logger:r})}}]);var n,r,i}(pt),Zr=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","UndoSplitExonChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToRestore:o.exonToRestore,parentFeatureId:o.parentFeatureId,idsToDelete:o.idsToDelete,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=F(this.changes),e.p=1,a=U().m((function e(){var t,o,a,c,l,u,d,A;return U().w((function(e){for(;;)switch(e.n){case 0:return a=(o=i.value).exonToRestore,c=o.parentFeatureId,l=o.idsToDelete,e.n=1,n.findOne({allIds:c}).session(r).exec();case 1:if(u=e.v){e.n=2;break}throw new Error('Could not find feature with ID "'.concat(c,'"'));case 2:if(d=s.getFeatureFromId(u,c)){e.n=3;break}throw new Error('Could not find feature with ID "'.concat(c,'" in feature "').concat(u._id.toString(),'"'));case 3:return d.children||(d.children=new Map),s.addChild(d,a),A=s.getChildFeatureIds(a),(t=u.allIds).push.apply(t,[a._id].concat(V(A))),u.allIds=u.allIds.filter((function(e){return!l.includes(e)})),l.map((function(e){return Qr(u,e,s)})),e.n=4,u.save();case 4:return e.a(2)}}),e)})),o.s();case 2:if((i=o.n()).done){e.n=4;break}return e.d(Y(a()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,o.e(e.v);case 6:return e.p=6,o.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changes),e.p=2,o=U().m((function e(){var n,o,i,a,s;return U().w((function(e){for(;;)switch(e.n){case 0:if(o=(n=r.value).exonToRestore,a=n.idsToDelete,i=n.parentFeatureId){e.n=1;break}throw new Error("Parent ID is missing");case 1:if(s=t.getFeature(i)){e.n=2;break}throw new Error('Could not find parent feature "'.concat(i,'"'));case 2:s.attributes.get("_id")||s.setAttribute("_id",[s._id]),s.addChild(o),a.map((function(e){s.deleteChild(e)}));case 3:return e.a(2)}}),e)})),n.s();case 3:if((r=n.n()).done){e.n=5;break}return e.d(Y(o()),4);case 4:e.n=3;break;case 5:e.n=7;break;case 6:e.p=6,n.e(e.v);case 7:return e.p=7,n.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[2,6,7,8]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=V(this.changedIds).reverse(),o=V(t).reverse().map((function(e){return{parentFeatureId:e.parentFeatureId,exonToBeSplit:e.exonToRestore,upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return new eo({changedIds:r,typeName:"SplitExonChange",changes:o,assembly:e},{logger:n})}}]);var n,r,o}(pt),eo=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","SplitExonChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"notification",get:function(){return"Exon successfully split"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToBeSplit:o.exonToBeSplit,parentFeatureId:o.parentFeatureId,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c=this;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,o=this.logger,i=F(this.changes),e.p=1,s=U().m((function e(){var t,i,s,l,u,d,A,f,h,g,p,m,y,_,v;return U().w((function(e){for(;;)switch(e.n){case 0:return i=(t=a.value).exonToBeSplit,s=t.parentFeatureId,l=t.upstreamCut,u=t.downstreamCut,d=t.leftExonId,A=t.rightExonId,e.n=1,n.findOne({allIds:i._id}).session(r).exec();case 1:if(f=e.v){e.n=2;break}throw h="*** ERROR: The following featureId was not found in database ='".concat(i._id,"'"),o.error(h),new Error(h);case 2:if(null!=(g=c.getFeatureFromId(f,s))&&g.children){e.n=3;break}throw new Error("ERROR: There should be at least one child (i.e. the exon to be split)");case 3:return p=c.makeSplitExons(i,l,u,d,A),m=K(p,2),_=m[1],g.children.set((y=m[0])._id,q(q({allIds:[]},y),{},{_id:y._id})),g.children.set(_._id,q(q({allIds:[]},_),{},{_id:_._id})),g.children=new Map(V(g.children.entries()).sort((function(e,t){return e[1].min-t[1].min}))),(v=Qr(f,i._id,c)).push(i._id),f.allIds=f.allIds.filter((function(e){return!v.includes(e)})),f.allIds.push(y._id,_._id),e.n=4,f.save();case 4:return e.a(2)}}),e)})),i.s();case 2:if((a=i.n()).done){e.n=4;break}return e.d(Y(s()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,i.e(e.v);case 6:return e.p=6,i.f(),e.f(6);case 7:return e.a(2)}}),e,this,[[1,5,6,7]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changedIds.entries()),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=7;break}if(o=K(r.value,1),a=(i=this.changes[o[0]]).exonToBeSplit,c=i.upstreamCut,l=i.downstreamCut,u=i.leftExonId,d=i.rightExonId,s=i.parentFeatureId){e.n=4;break}throw new Error("TODO: Split exon without parent");case 4:if(A=this.makeSplitExons(a,c,l,u,d),f=K(A,2),h=f[0],g=f[1],p=t.getFeature(s)){e.n=5;break}throw new Error('Could not find parent feature "'.concat(s,'"'));case 5:p.addChild(h),p.addChild(g),t.getFeature(a._id)&&t.deleteFeature(a._id);case 6:e.n=3;break;case 7:e.n=9;break;case 8:e.p=8,n.e(e.v);case 9:return e.p=9,n.f(),e.f(9);case 10:return e.a(2)}}),e,this,[[2,8,9,10]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=V(this.changedIds).reverse(),i=V(n).reverse().map((function(e){return{exonToRestore:e.exonToBeSplit,parentFeatureId:e.parentFeatureId,idsToDelete:[e.leftExonId,e.rightExonId],upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Zr({changedIds:o,typeName:"UndoSplitExonChange",changes:i,assembly:t},{logger:r})}},{key:"makeSplitExons",value:function(e,t,n,r,o){var i=JSON.parse(JSON.stringify(e));delete i.attributes._id,delete i.attributes.gff_id;var a=structuredClone(i);a._id=r,a.max=t;var s=structuredClone(i);return s.min=n,s._id=o,[a,s]}}]);var n,r,o}(pt),to=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","StrandChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStrand:o.oldStrand,newStrand:o.newStrand}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,i=this.logger,a=[],s=F(o=this.changes),e.p=1,s.s();case 2:if((c=s.n()).done){e.n=8;break}return A=(d=c.value).featureId,f=d.oldStrand,e.n=3,n.findOne({allIds:A}).session(r).exec();case 3:if(h=e.v){e.n=4;break}throw g="*** ERROR: The following featureId was not found in database ='".concat(A,"'"),i.error(g),new Error(g);case 4:if(null===(l=i.debug)||void 0===l||l.call(i,"*** Feature found: ".concat(JSON.stringify(h))),p=this.getFeatureFromId(h,A)){e.n=5;break}throw i.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 5:if(null===(u=i.debug)||void 0===u||u.call(i,"*** Found feature: ".concat(JSON.stringify(p))),p.strand===f){e.n=6;break}throw m="*** ERROR: Feature's current strand \"".concat(h.strand,'" doesn\'t match with expected value "').concat(f,'"'),i.error(m),new Error(m);case 6:a.push({feature:p,topLevelFeature:h});case 7:e.n=2;break;case 8:e.n=10;break;case 9:e.p=9,s.e(e.v);case 10:return e.p=10,s.f(),e.f(10);case 11:y=F(o.entries()),e.p=12,y.s();case 13:if((_=y.n()).done){e.n=19;break}return b=K(_.value,2),w=(C=a[b[0]]).topLevelFeature,(I=C.feature).strand=b[1].newStrand,w._id.equals(I._id)?w.markModified("strand"):w.markModified("children"),e.p=14,e.n=15,w.save();case 15:e.n=17;break;case 16:throw e.p=16,x=e.v,null===(E=i.debug)||void 0===E||E.call(i,"*** FAILED: ".concat(x)),x;case 17:null===(v=i.debug)||void 0===v||v.call(i,"*** Object updated in Mongo. New object: ".concat(JSON.stringify(w)));case 18:e.n=13;break;case 19:e.n=21;break;case 20:e.p=20,y.e(e.v);case 21:return e.p=21,y.f(),e.f(21);case 22:return e.a(2)}}),e,this,[[14,16],[12,20,21,22],[1,9,10,11]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changedIds.entries()),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(o=K(r.value,2),i=o[0],s=t.getFeature(a=o[1])){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(a,'"'));case 4:s.setStrand(this.changes[i].newStrand);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:V(this.changedIds).reverse(),typeName:o,changes:V(n).reverse().map((function(e){return{featureId:e.featureId,oldStrand:e.newStrand,newStrand:e.oldStrand}})),assembly:e},{logger:r})}}]);var n,r,o}(pt),no=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","TypeChange"),T(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=K(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldType:o.oldType,newType:o.newType}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.featureModel,r=t.session,i=this.logger,a=[],s=F(o=this.changes),e.p=1,s.s();case 2:if((c=s.n()).done){e.n=8;break}return A=(d=c.value).featureId,f=d.oldType,e.n=3,n.findOne({allIds:A}).session(r).exec();case 3:if(h=e.v){e.n=4;break}throw g="*** ERROR: The following featureId was not found in database ='".concat(A,"'"),i.error(g),new Error(g);case 4:if(null===(l=i.debug)||void 0===l||l.call(i,"*** Feature found: ".concat(JSON.stringify(h))),p=this.getFeatureFromId(h,A)){e.n=5;break}throw i.error("ERROR when searching feature by featureId"),new Error("ERROR when searching feature by featureId");case 5:if(null===(u=i.debug)||void 0===u||u.call(i,"*** Found feature: ".concat(JSON.stringify(p))),p.type===f){e.n=6;break}throw m="*** ERROR: Feature's current type \"".concat(h.type,'" doesn\'t match with expected value "').concat(f,'"'),i.error(m),new Error(m);case 6:a.push({feature:p,topLevelFeature:h});case 7:e.n=2;break;case 8:e.n=10;break;case 9:e.p=9,s.e(e.v);case 10:return e.p=10,s.f(),e.f(10);case 11:y=F(o.entries()),e.p=12,y.s();case 13:if((_=y.n()).done){e.n=19;break}return b=K(_.value,2),w=(C=a[b[0]]).topLevelFeature,(I=C.feature).type=b[1].newType,w._id.equals(I._id)?w.markModified("type"):w.markModified("children"),e.p=14,e.n=15,w.save();case 15:e.n=17;break;case 16:throw e.p=16,x=e.v,null===(E=i.debug)||void 0===E||E.call(i,"*** FAILED: ".concat(x)),x;case 17:null===(v=i.debug)||void 0===v||v.call(i,"*** Object updated in Mongo. New object: ".concat(JSON.stringify(w)));case 18:e.n=13;break;case 19:e.n=21;break;case 20:e.p=20,y.e(e.v);case 21:return e.p=21,y.f(),e.f(21);case 22:return e.a(2)}}),e,this,[[14,16],[12,20,21,22],[1,9,10,11]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){var n,r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw new Error("No data store");case 1:n=F(this.changedIds.entries()),e.p=2,n.s();case 3:if((r=n.n()).done){e.n=6;break}if(o=K(r.value,2),i=o[0],s=t.getFeature(a=o[1])){e.n=4;break}throw new Error('Could not find feature with identifier "'.concat(a,'"'));case 4:s.setType(this.changes[i].newType);case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,n.e(e.v);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2)}}),e,this,[[2,7,8,9]])}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:V(this.changedIds).reverse(),typeName:o,changes:V(n).reverse().map((function(e){return{featureId:e.featureId,oldType:e.newType,newType:e.oldType}})),assembly:e},{logger:r})}}]);var n,r,o}(pt),ro=function(e){function t(e,n){var r;return N(this,t),T(r=Q(this,t,[e,n]),"typeName","UserChange"),T(r,"changes",void 0),T(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return O(t,e),D(t,[{key:"toJSON",value:function(){var e=this.changes,t=this.typeName,n=this.userId;return 1===e.length?{typeName:t,userId:n,role:K(e,1)[0].role}:{typeName:t,userId:n,changes:e}}},{key:"executeOnServer",value:(o=B(U().m((function e(t){var n,r,o,i,a,s,c,l,u,d,A;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=t.session,r=t.userModel,i=this.logger,a=this.userId,s=F(o=this.changes),e.p=1,s.s();case 2:if((c=s.n()).done){e.n=5;break}return u=c.value,null===(l=i.debug)||void 0===l||l.call(i,"change: ".concat(JSON.stringify(o))),d=u.role,e.n=3,r.findByIdAndUpdate(a,{role:d}).session(n).exec();case 3:if(e.v){e.n=4;break}throw A='*** ERROR: User with id "'.concat(a,'" not found'),i.error(A),new Error(A);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,s.e(e.v);case 7:return e.p=7,s.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"executeOnLocalGFF3",value:(r=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:throw new Error("executeOnLocalGFF3 not implemented");case 1:return e.a(2)}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"executeOnClient",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2)}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,userId:this.userId},{logger:this.logger})}}]);var n,r,o}(ft),oo={AddAssemblyAndFeaturesFromFileChange:xt,AddAssemblyFromFileChange:Br,AddAssemblyFromExternalChange:Sr,AddFeatureChange:Nr,AddFeaturesFromFileChange:Rr,DeleteAssemblyChange:Fr,DeleteFeatureChange:kr,DeleteUserChange:Tr,FeatureAttributeChange:jr,ImportJBrowseConfigChange:Pr,LocationEndChange:qr,LocationStartChange:Ur,MergeExonsChange:Vr,SplitExonChange:eo,MergeTranscriptsChange:Xr,UndoMergeExonsChange:Wr,UndoSplitExonChange:Zr,UndoMergeTranscriptsChange:$r,StrandChange:to,TypeChange:no,UserChange:ro,AddRefSeqAliasesChange:Dr,AddAssemblyAliasesChange:mt},io=function(){return D((function e(){N(this,e)}),[{key:"frontendPreValidate",value:(o=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=B(U().m((function e(t,n){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=B(U().m((function e(t,n){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=B(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,void 0)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),ao=function(){return D((function e(){N(this,e),T(this,"results",[]),T(this,"ok",!0)}),[{key:"resultsMessages",get:function(){return this.results.map((function(e){var t;return null===(t=e.error)||void 0===t?void 0:t.message})).filter(Boolean).join(", ")}},{key:"add",value:function(e){this.results.push(e),e.error&&(this.ok=!1)}}])}(),so=function(){return D((function e(){N(this,e),T(this,"validations",new Set)}),[{key:"registerValidation",value:function(e){this.validations.add(e)}},{key:"frontendPreValidate",value:(o=B(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new ao,r=F(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=B(U().m((function e(t,n){var r,o,i,a,s;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=new ao,o=F(this.validations),e.p=1,o.s();case 2:if((i=o.n()).done){e.n=5;break}return a=i.value,e.n=3,a.frontendPostValidate(t,n);case 3:if(r.add(s=e.v),!s.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,o.e(e.v);case 7:return e.p=7,o.f(),e.f(7);case 8:return e.a(2,r)}}),e,this,[[1,6,7,8]])}))),function(e,t){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=B(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new ao,r=F(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.backendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=B(U().m((function e(t,n){var r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=new ao,a=F(this.validations),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=5;break}return c=s.value,e.n=3,c.backendPostValidate(t,{featureModel:r,session:o});case 3:if(i.add(l=e.v),!l.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,a.e(e.v);case 7:return e.p=7,a.f(),e.f(7);case 8:return e.a(2,i)}}),e,this,[[1,6,7,8]])}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=B(U().m((function e(t){var n,r,o,i;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=F(this.validations),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=5;break}return o=r.value,e.n=3,o.possibleValues(t);case 3:if(!(i=e.v)){e.n=4;break}return e.a(2,i);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,n.e(e.v);case 7:return e.p=7,n.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),co=new so,lo=["2A_self_cleaving_peptide_region","4_methylcytosine","5S_SINE_retrotransposon","5_carboxylcytosine","5_formylcytosine","5_hydroxymethylcytosine","5_methylcytosine","7SL_SINE_retrotransposon","8_oxoadenine","8_oxoguanine","AACCCT_box","AFLP_fragment","AP_1_binding_site","ARIA","ARRET","ARS","ARS_consensus_sequence","ASPE_primer","AUG_initiated_uORF","AU_rich_element","A_box","A_box_type_1","A_box_type_2","A_minor_RNA_motif","A_to_C_transversion","A_to_G_transition","A_to_T_transversion","Ace2_UAS","Alu_deletion","Alu_insertion","BAC","BAC_cloned_genomic_insert","BAC_end","BAC_read_contig","BREd_motif","BREu_motif","B_box","Bel_Pao_LTR_retrotransposon","Bruno_response_element","C-D_H_ACA_box_scaRNA","C-D_H_ACA_box_scaRNA_gene","CAAT_signal","CAAX_box","CACTA_TIR_transposon","CAGE_cluster","CAGE_tag","CArG_box","CCAAT_motif","CCA_tail","CDRE_motif","CDS","CDS_extension","CDS_five_prime_extension","CDS_fragment","CDS_independently_known","CDS_predicted","CDS_region","CDS_supported_by_EST_or_cDNA_data","CDS_supported_by_domain_match_data","CDS_supported_by_peptide_spectrum_match","CDS_supported_by_sequence_similarity_data","CDS_three_prime_extension","CRE","CRISPR","CSL_response_element","CTCF_binding_site","CTG_start_codon","C_D_box_scaRNA","C_D_box_scaRNA_gene","C_D_box_snoRNA","C_D_box_snoRNA_gene","C_D_box_snoRNA_primary_transcript","C_box","C_cluster","C_gene_segment","C_region","C_to_A_transversion","C_to_G_transversion","C_to_T_transition","C_to_T_transition_at_pCpG_site","ChIP_seq_region","Copia_LTR_retrotransposon","CpG_island","Crick_strand","Crypton_YR_transposon","CsrB_RsmB_RNA","CuRE","DArT_marker","DCE","DCE_SI","DCE_SII","DCE_SIII","DDB_box","DHU_loop","DIRS_YR_retrotransposon","DJ_C_cluster","DJ_J_C_cluster","DJ_J_cluster","DJ_gene_segment","DMv1_motif","DMv2_motif","DMv3_motif","DMv4_motif","DMv5_motif","DNA_aptamer","DNA_binding_site","DNA_chromosome","DNA_constraint_sequence","DNA_loop","DNA_loop_anchor","DNA_motif","DNA_sequence_secondary_structure","DNA_transposon","DNAzyme","DNaseI_hypersensitive_site","DPE1_motif","DPE_motif","DRE","DRE_motif","DSR_motif","D_DJ_C_cluster","D_DJ_J_C_cluster","D_DJ_J_cluster","D_DJ_cluster","D_J_C_cluster","D_J_cluster","D_cluster","D_gene_recombination_feature","D_gene_segment","D_loop","DsrA_RNA","ER_retention_signal","EST","EST_match","E_box_motif","Endogenous_Retrovirus_LTR_retrotransposon","FLEX_element","FRE","FRT_site","GAGA_motif","GATA_box","GC_rich_promoter_region","GNA_oligo","GTT_trinucleotide_repeat","GT_dinucleotide_repeat","G_box","G_quartet","G_to_A_transition","G_to_C_transversion","G_to_T_transversion","GcvB_RNA","Gypsy_LTR_retrotransposon","H2AK5_acetylation_site","H2AK9_acetylation_site","H2AZK11_acetylation_site","H2AZK13_acetylation_site","H2AZK15_acetylation_site","H2AZK4_acetylation_site","H2AZK7_acetylation_site","H2BK120_acetylation_site","H2BK12_acetylation_site","H2BK15_acetylation_site","H2BK20_acetylation_site","H2BK5_acetylation_site","H2BK5_monomethylation_site","H2B_ubiquitination_site","H3K14_acetylation_site","H3K18_acetylation_site","H3K20_trimethylation_site","H3K23_acetylation_site","H3K23_dimethylation_site","H3K27_acetylation_site","H3K27_dimethylation_site","H3K27_methylation_site","H3K27_monomethylation_site","H3K27_trimethylation_site","H3K36_acetylation_site","H3K36_dimethylation_site","H3K36_methylation_site","H3K36_monomethylation_site","H3K36_trimethylation_site","H3K4_acetylation_site","H3K4_dimethylation_site","H3K4_methylation_site","H3K4_monomethylation_site","H3K4_trimethylation","H3K56_acetylation_site","H3K79_dimethylation_site","H3K79_methylation_site","H3K79_monomethylation_site","H3K79_trimethylation_site","H3K9_acetylation_site","H3K9_dimethylation_site","H3K9_methylation_site","H3K9_monomethylation_site","H3K9_trimethylation_site","H3R2_dimethylation_site","H3R2_monomethylation_site","H4K12_acetylation_site","H4K16_acetylation_site","H4K20_monomethylation_site","H4K4_trimethylation_site","H4K5_acetylation_site","H4K8_acetylation_site","H4K91_acetylation_site","H4K_acylation_region","H4R3_dimethylation_site","HERV_deletion","HERV_insertion","HSE","H_ACA_box_scaRNA","H_ACA_box_scaRNA_gene","H_ACA_box_snoRNA","H_ACA_box_snoRNA_gene","H_ACA_box_snoRNA_primary_transcript","H_pseudoknot","Hoogsteen_base_pair","I-box","IG_C_gene","IG_C_pseudogene","IG_D_gene","IG_J_gene","IG_J_pseudogene","IG_V_gene","IG_V_pseudogene","INR1_motif","INR_motif","IRLinv_site","IRRinv_site","ISRE","I_LINE_retrotransposon","J_C_cluster","J_cluster","J_gene_recombination_feature","J_gene_segment","J_heptamer","J_nonamer","J_spacer","Jockey_LINE_retrotransposon","KEN_box","K_turn_RNA_motif","L1_LINE_retrotransposon","LARD","LINE1_deletion","LINE1_insertion","LINE_element","LNA_oligo","LOZ1_response_element","LTR_component","LTR_retrotransposon","L_box","MCB","MITE","MNP","MNV","MNV_artifact","MTE","Mat2P","Mat3M","Merlin_TIR_transposon","MicF_RNA","Mutator_TIR_transposon","N2_2_prime_O_dimethylguanosine","N2_7_2prirme_O_trimethylguanosine","N2_7_dimethylguanosine","N2_N2_2_prime_O_trimethylguanosine","N2_N2_7_trimethylguanosine","N2_N2_dimethylguanosine","N2_methylguanosine","N4_2_prime_O_dimethylcytidine","N4_N4_2_prime_O_trimethylcytidine","N4_acetyl_2_prime_O_methylcytidine","N4_acetylcytidine","N4_methylcytidine","N6_2_prime_O_dimethyladenosine","N6_N6_2_prime_O_trimethyladenosine","N6_N6_dimethyladenosine","N6_acetyladenosine","N6_cis_hydroxyisopentenyl_adenosine","N6_glycinylcarbamoyladenosine","N6_hydroxynorvalylcarbamoyladenosine","N6_isopentenyladenosine","N6_methyl_N6_threonylcarbamoyladenosine","N6_methyladenine","N6_methyladenosine","N6_threonylcarbamoyladenosine","NDM2_motif","NDM3_motif","NMD_polymorphic_pseudogene_transcript","NMD_transcript","NSD_transcript","N_region","Ngaro_YR_retrotransposon","ORF","Okazaki_fragment","OxyS_RNA","PAC","PAC_end","PCB","PCR_product","PIF_Harbinger_TIR_transposon","PIP_box","PNA_oligo","PSE_motif","P_TIR_transposon","Penelope_retrotransposon","Phage_RNA_Polymerase_Promoter","Pho7_binding_site","QTL","R2_LINE_retrotransposon","RAPD","RFLP_fragment","RH_map","RNA_6S","RNA_7SK","RNA_7SK_gene","RNA_aptamer","RNA_chromosome","RNA_hook_turn","RNA_internal_loop","RNA_junction_loop","RNA_motif","RNA_polymerase_III_TATA_box","RNA_polymerase_II_TATA_box","RNA_sequence_secondary_structure","RNA_stability_element","RNA_thermometer","RNAi_reagent","RNApol_III_promoter","RNApol_III_promoter_type_1","RNApol_III_promoter_type_2","RNApol_III_promoter_type_3","RNApol_II_core_promoter","RNApol_II_promoter","RNApol_I_promoter","RNase_MRP_RNA","RNase_MRP_RNA_gene","RNase_P_RNA","RNase_P_RNA_gene","RRE_RNA","RR_tract","RST","RST_match","RTE_LINE_retrotransposon","R_GNA_oligo","R_LTR_region","R_five_prime_LTR_region","R_three_prime_LTR_region","Retrovirus_LTR_retrotransposon","Robertsonian_fusion","RprA_RNA","SAGE_tag","SECIS_element","SHP_box","SINE_element","SL10_acceptor_site","SL11_acceptor_site","SL12_acceptor_site","SL1_acceptor_site","SL2_acceptor_site","SL3_acceptor_site","SL4_acceptor_site","SL5_acceptor_site","SL6_acceptor_site","SL7_acceptor_site","SL8_acceptor_site","SL9_acceptor_site","SNP","SNV","SNV_artifact","SP6_RNA_Polymerase_Promoter","SRP_RNA","SRP_RNA_gene","SRP_RNA_primary_transcript","STREP_motif","STS","STS_map","SUMO_interaction_motif","SVA_deletion","SVA_insertion","S_GNA_oligo","S_region","Sap1_recognition_motif","Shine_Dalgarno_sequence","T3_RNA_Polymerase_Promoter","T7_RNA_Polymerase_Promoter","TATA_box","TCS_element","TCT_motif","TERRA","TFRS_collection","TFRS_module","TF_binding_site","TNA_oligo","TRIM","TR_C_Gene","TR_D_Gene","TR_J_Gene","TR_J_pseudogene","TR_V_Gene","TR_V_pseudogene","TR_box","TSS","T_cell_receptor_gene","T_cell_receptor_pseudogene","T_loop","T_to_A_transversion","T_to_C_transition","T_to_G_transversion","Tc1_Mariner_TIR_transposon","Transib_TIR_transposon","U11_snRNA","U12_intron","U12_snRNA","U14_snoRNA","U14_snoRNA_gene","U14_snoRNA_primary_transcript","U1_snRNA","U2_intron","U2_snRNA","U3_LTR_region","U3_five_prime_LTR_region","U3_snoRNA","U3_snoRNA_gene","U3_three_prime_LTR_region","U4_snRNA","U4atac_snRNA","U5_LTR_region","U5_five_prime_LTR_region","U5_snRNA","U5_three_prime_LTR_region","U6_snRNA","U6atac_snRNA","U7_snRNA","UAA_stop_codon_signal","UAG_stop_codon_signal","UGA_stop_codon_signal","UNAAAC_motif","UPD","UST","UST_match","UTR","UTR_intron","UTR_region","U_box","VDJ_C_cluster","VDJ_J_C_cluster","VDJ_J_cluster","VDJ_gene_segment","VD_gene_segment","VJ_C_cluster","VJ_J_C_cluster","VJ_J_cluster","VJ_gene_segment","V_DJ_C_cluster","V_DJ_J_C_cluster","V_DJ_J_cluster","V_DJ_cluster","V_D_DJ_C_cluster","V_D_DJ_J_C_cluster","V_D_DJ_J_cluster","V_D_DJ_cluster","V_D_J_C_cluster","V_D_J_cluster","V_J_C_cluster","V_J_cluster","V_VDJ_C_cluster","V_VDJ_J_C_cluster","V_VDJ_J_cluster","V_VDJ_cluster","V_VJ_C_cluster","V_VJ_J_C_cluster","V_VJ_J_cluster","V_VJ_cluster","V_cluster","V_gene_recombination_feature","V_gene_segment","V_heptamer","V_nonamer","V_region","V_spacer","Viper_YR_retrotransposon","WC_base_pair","W_region","Watson_strand","X_element","X_element_combinatorial_repeat","X_region","YAC","YAC_end","YR_retrotransposon","Y_RNA","Y_RNA_gene","Y_RNA_primary_transcript","Y_prime_element","Y_region","Z1_region","Z2_region","Zas1_recognition_motif","aberrant_processed_transcript","accessible_DNA_region","active_peptide","adaptive_island","alanine","alanine_tRNA_primary_transcript","alanyl_tRNA","allelic_pseudogene","allelic_pseudogenic_rRNA","allelic_pseudogenic_tRNA","allelically_excluded_gene","alpha_beta_motif","alpha_helix","alternate_sequence_site","alternatively_spliced_transcript","amber_stop_codon","ambisense_ssRNA_viral_sequence","amino_acid","amplification_origin","anchor_binding_site","anchor_region","androgen_response_element","anti_ARRET","anticodon","anticodon_loop","antiparallel_beta_strand","antisense_RNA","antisense_lncRNA","antisense_lncRNA_gene","antisense_primary_transcript","apicoplast_chromosome","apicoplast_gene","aptamer","archaeal_intron","archaeosine","arginine","arginine_tRNA_primary_transcript","arginyl_tRNA","asparagine","asparagine_tRNA_primary_transcript","asparaginyl_tRNA","aspartic_acid","aspartic_acid_tRNA_primary_transcript","aspartyl_tRNA","assembly","assembly_component","assembly_error_correction","asx_motif","asx_turn","asx_turn_left_handed_type_one","asx_turn_left_handed_type_two","asx_turn_right_handed_type_one","asx_turn_right_handed_type_two","asymmetric_RNA_internal_loop","attB_site","attC_site","attCtn_site","attI_site","attL_site","attP_site","attR_site","attenuator","autocatalytically_spliced_intron","bacterial_RNApol_promoter","bacterial_RNApol_promoter_sigma54_element","bacterial_RNApol_promoter_sigma_70_element","bacterial_RNApol_promoter_sigma_ecf_element","bacterial_terminator","base","base_call_error_correction","base_pair","beta_bulge","beta_bulge_loop","beta_bulge_loop_five","beta_bulge_loop_six","beta_strand","beta_turn","beta_turn_left_handed_type_one","beta_turn_left_handed_type_two","beta_turn_right_handed_type_one","beta_turn_right_handed_type_two","beta_turn_type_eight","beta_turn_type_six","beta_turn_type_six_a","beta_turn_type_six_a_one","beta_turn_type_six_a_two","beta_turn_type_six_b","bidirectional_promoter","bidirectional_promoter_lncRNA","binding_site","biochemical_region_of_peptide","biological_region","biomaterial_region","biosynthetic_gene_cluster","blocked_reading_frame","blunt_end_restriction_enzyme_cleavage_junction","blunt_end_restriction_enzyme_cleavage_site","boundary_element","branch_site","cDNA_clone","cDNA_match","c_terminal_region","candidate_gene","canonical_five_prime_splice_site","canonical_three_prime_splice_site","cap","capped_mRNA","capped_primary_transcript","cassette_pseudogene","catalytic_residue","catmat_left_handed_four","catmat_left_handed_three","catmat_right_handed_four","catmat_right_handed_three","central_hydrophobic_region_of_signal_peptide","centromere","centromere_DNA_Element_I","centromere_DNA_Element_II","centromere_DNA_Element_III","centromeric_repeat","chimeric_cDNA_clone","chloroplast_DNA_read","chloroplast_chromosome","chromatin_regulatory_region","chromoplast_chromosome","chromoplast_gene","chromosomal_regulatory_element","chromosomal_structural_element","chromosomal_translocation","chromosome","chromosome_arm","chromosome_band","chromosome_breakage_sequence","chromosome_breakpoint","chromosome_part","circular_double_stranded_DNA_chromosome","circular_double_stranded_RNA_chromosome","circular_mRNA","circular_ncRNA","circular_plasmid","circular_single_stranded_DNA_chromosome","circular_single_stranded_RNA_chromosome","cis_acting_homologous_chromosome_pairing_region","cis_regulatory_frameshift_element","cis_regulatory_module","cis_splice_site","class_II_RNA","class_I_RNA","cleaved_for_gpi_anchor_region","cleaved_initiator_methionine","cleaved_peptide_region","clip","clone","clone_end","clone_insert","clone_insert_end","clone_insert_start","cloned_cDNA_insert","cloned_genomic_insert","cloned_region","coding_conserved_region","coding_end","coding_exon","coding_region_of_exon","coding_start","coding_transcript_with_retained_intron","codon","coiled_coil","cointegrated_plasmid","common_fragile_site","complex_chromosomal_rearrangement","complex_operon","complex_regulon","complex_structural_alteration","complex_substitution","compositionally_biased_region_of_peptide","conformational_switch","conjugative_transposon","consensus_AFLP_fragment","consensus_gDNA","consensus_mRNA","consensus_region","conserved_region","constitutive_promoter","contig","contig_collection","contig_read","copy_number_gain","copy_number_loss","copy_number_variation","core_eukaryotic_promoter_element","core_prokaryotic_promoter_element","core_promoter_element","core_viral_promoter_element","cosmid","cross_genome_match","cryptic_gene","cryptic_promoter","cryptic_prophage","cryptic_splice_site","cryptogene","ct_gene","cyanelle_chromosome","cyanelle_gene","cyclic_translocation","cysteine","cysteine_tRNA_primary_transcript","cysteinyl_tRNA","cytoplasmic_polypeptide_region","cytosolic_16S_rRNA","cytosolic_18S_rRNA","cytosolic_23S_rRNA","cytosolic_25S_rRNA","cytosolic_28S_rRNA","cytosolic_2S_rRNA","cytosolic_5S_rRNA","cytosolic_5_8S_rRNA","cytosolic_LSU_rRNA","cytosolic_LSU_rRNA_gene","cytosolic_SSU_rRNA","cytosolic_SSU_rRNA_gene","cytosolic_rRNA","cytosolic_rRNA_16S_gene","cytosolic_rRNA_18S_gene","cytosolic_rRNA_23S_gene","cytosolic_rRNA_25S_gene","cytosolic_rRNA_28S_gene","cytosolic_rRNA_2S_gene","cytosolic_rRNA_5S_gene","cytosolic_rRNA_5_8S_gene","cytosolic_rRNA_gene","dCAPS_primer","databank_entry","decayed_exon","defective_conjugative_transposon","deficient_translocation","deletion","deletion_artifact","deletion_breakpoint","deletion_junction","delins","destruction_box","dg_repeat","dh_repeat","dicistronic_mRNA","dicistronic_primary_transcript","dicistronic_transcript","dif_site","dihydrouridine","dinucleotide_repeat_microsatellite_feature","direct_repeat","direct_tandem_duplication","disabled_reading_frame","dispersed_repeat","distal_duplication","distal_promoter_element","distant_three_prime_recoding_signal","double_stranded_DNA_chromosome","double_stranded_RNA_chromosome","ds_DNA_viral_sequence","ds_RNA_viral_sequence","ds_oligo","duplicated_pseudogene","duplication","duplication_artifact","dye_terminator_read","early_origin_of_replication","edited_CDS","edited_mRNA","edited_transcript","edited_transcript_by_A_to_I_substitution","edited_transcript_feature","editing_block","editing_domain","endogenous_retroviral_gene","endonuclease_spliced_intron","endosomal_localization_signal","engineered_episome","engineered_foreign_gene","engineered_foreign_region","engineered_foreign_repetitive_element","engineered_foreign_transposable_element","engineered_foreign_transposable_element_gene","engineered_fusion_gene","engineered_gene","engineered_insert","engineered_plasmid","engineered_region","engineered_rescue_region","engineered_tag","engineered_transposable_element","enhancer","enhancerRNA","enhancer_binding_site","enhancer_blocking_element","enhancer_bound_by_factor","enhancer_trap_construct","enzymatic_RNA","enzymatic_RNA_gene","epigenetically_modified_gene","epigenetically_modified_region","epigenomically_modified_region","episome","epitope","epoxyqueuosine","eukaryotic_promoter","eukaryotic_terminator","exemplar_mRNA","exon","exon_junction","exon_of_single_exon_gene","exon_region","exonic_splice_enhancer","exonic_splicing_silencer","experimental_feature","experimental_result_region","experimentally_defined_binding_region","expressed_sequence_assembly","expressed_sequence_match","extended_cis_splice_site","extended_intronic_splice_region","external_transcribed_spacer_region","extrachromosomal_mobile_genetic_element","extramembrane_polypeptide_region","fingerprint_map","five_aminomethyl_two_thiouridine","five_carbamoylmethyl_two_prime_O_methyluridine","five_carbamoylmethyluridine","five_carboxyhydroxymethyl_uridine","five_carboxyhydroxymethyl_uridine_methyl_ester","five_carboxymethylaminomethyl_two_prime_O_methyluridine","five_carboxymethylaminomethyl_two_thiouridine","five_carboxymethylaminomethyluridine","five_carboxymethyluridine","five_formyl_two_prime_O_methylcytidine","five_formylcytidine","five_hydroxymethylcytidine","five_hydroxyuridine","five_isopentenylaminomethyl_two_prime_O_methyluridine","five_isopentenylaminomethyl_two_thiouridine","five_isopentenylaminomethyl_uridine","five_methoxycarbonylmethyl_two_prime_O_methyluridine","five_methoxycarbonylmethyl_two_thiouridine","five_methoxycarbonylmethyluridine","five_methoxyuridine","five_methyl_2_thiouridine","five_methylaminomethyl_two_selenouridine","five_methylaminomethyl_two_thiouridine","five_methylaminomethyluridine","five_methylcytidine","five_methyldihydrouridine","five_methyluridine","five_prime_D_heptamer","five_prime_D_nonamer","five_prime_D_recombination_signal_sequence","five_prime_D_spacer","five_prime_EST","five_prime_LTR","five_prime_LTR_component","five_prime_RST","five_prime_UST","five_prime_UTR","five_prime_UTR_intron","five_prime_cis_splice_site","five_prime_clip","five_prime_coding_exon","five_prime_coding_exon_coding_region","five_prime_coding_exon_noncoding_region","five_prime_flanking_region","five_prime_intron","five_prime_noncoding_exon","five_prime_open_reading_frame","five_prime_recoding_site","five_prime_restriction_enzyme_junction","five_prime_sticky_end_restriction_enzyme_cleavage_site","five_prime_terminal_inverted_repeat","five_taurinomethyl_two_thiouridine","five_taurinomethyluridine","five_two_prime_O_dimethylcytidine","five_two_prime_O_dimethyluridine","flanking_region","flanking_repeat","flanking_three_prime_quadruplet_recoding_signal","floxed_gene","foldback_element","foreign_gene","foreign_transposable_element","forkhead_motif","forward_primer","fosmid","four_bp_start_codon","four_demethylwyosine","four_thiouridine","fragile_site","fragment_assembly","functional_candidate_gene","functional_gene_region","fusion_gene","gRNA_gene","galactosyl_queuosine","gamma_turn","gamma_turn_classic","gamma_turn_inverse","gap","gene","gene_array","gene_cassette","gene_cassette_array","gene_component_region","gene_fragment","gene_group","gene_member_region","gene_rearranged_at_DNA_level","gene_segment","gene_silenced_by_DNA_methylation","gene_silenced_by_DNA_modification","gene_silenced_by_RNA_interference","gene_silenced_by_histone_deacetylation","gene_silenced_by_histone_methylation","gene_silenced_by_histone_modification","gene_subarray","gene_trap_construct","gene_with_dicistronic_mRNA","gene_with_dicistronic_primary_transcript","gene_with_dicistronic_transcript","gene_with_edited_transcript","gene_with_mRNA_recoded_by_translational_bypass","gene_with_mRNA_with_frameshift","gene_with_non_canonical_start_codon","gene_with_polyadenylated_mRNA","gene_with_polycistronic_transcript","gene_with_recoded_mRNA","gene_with_start_codon_CUG","gene_with_stop_codon_read_through","gene_with_stop_codon_redefined_as_pyrrolysine","gene_with_stop_codon_redefined_as_selenocysteine","gene_with_trans_spliced_transcript","gene_with_transcript_with_translational_frameshift","genetic_marker","genomic_DNA_contig","genomic_DNA_read","genomic_clone","genomic_island","genomically_contaminated_cDNA_clone","glutamic_acid","glutamic_acid_tRNA_primary_transcript","glutamine","glutamine_tRNA_primary_transcript","glutaminyl_tRNA","glutamyl_tRNA","glycine","glycine_tRNA_primary_transcript","glycyl_tRNA","golden_path","golden_path_fragment","group_1_intron_homing_endonuclease_target_region","group_IIA_intron","group_IIB_intron","group_IIC_intron","group_III_intron","group_II_intron","group_I_intron","guide_RNA","guide_RNA_region","hAT_TIR_transposon","hammerhead_ribozyme","haplotype_block","helitron","helix_turn_helix","heptamer_of_recombination_feature_of_vertebrate_immune_system_gene","heritable_phenotypic_marker","high_identity_region","histidine","histidine_tRNA_primary_transcript","histidyl_tRNA","histone_2AZ_acetylation_site","histone_2A_acetylation_site","histone_2B_acetylation_site","histone_3_acetylation_site","histone_4_acetylation_site","histone_acetylation_site","histone_acylation_region","histone_binding_site","histone_methylation_site","histone_modification","histone_ubiqitination_site","homing_endonuclease_binding_site","homol_D_box","homol_E_box","homologous_chromosome_recognition_and_pairing_locus","homologous_region","hpRNA","hpRNA_gene","hydrophobic_region_of_peptide","hydroxywybutosine","iDNA","i_motif","immature_peptide_region","immunoglobulin_gene","immunoglobulin_pseudogene","immunoglobulin_region","imprinting_control_region","indel_artifact","inducible_promoter","inert_DNA_spacer","inosine","insertion","insertion_artifact","insertion_breakpoint","insertion_sequence","insertion_site","insulator","insulator_binding_site","integrated_mobile_genetic_element","integrated_plasmid","integration_excision_site","integron","intein","intein_encoding_region","interband","interchromosomal_breakpoint","interchromosomal_translocation","intergenic_region","interior_coding_exon","interior_exon","interior_intron","intermediate_element","internal_Shine_Dalgarno_sequence","internal_UTR","internal_eliminated_sequence","internal_guide_sequence","internal_ribosome_entry_site","internal_transcribed_spacer_region","intrachromosomal_breakpoint","intrachromosomal_translocation","intramembrane_polypeptide_region","intrinsically_unstructured_polypeptide_region","introgressed_chromosome_region","intron","intron_base_5","intron_domain","intronic_regulatory_region","intronic_splice_enhancer","intronic_splicing_silencer","invalidated_cDNA_clone","inversion","inversion_breakpoint","inversion_cum_translocation","inversion_site","inversion_site_part","inverted_intrachromosomal_transposition","inverted_repeat","inverted_tandem_duplication","iron_repressed_GATA_element","iron_responsive_element","isoleucine","isoleucine_tRNA_primary_transcript","isoleucyl_tRNA","isomiR","isowyosine","junction","kinetoplast_gene","knob","kozak_sequence","lambda_vector","lariat_intron","late_origin_of_replication","left_handed_peptide_helix","leucine","leucine_tRNA_primary_transcript","leucoplast_chromosome","leucoplast_gene","leucyl_tRNA","ligand_binding_site","ligation_based_read","lincRNA","lincRNA_gene","linear_double_stranded_DNA_chromosome","linear_double_stranded_RNA_chromosome","linear_plasmid","linear_single_stranded_DNA_chromosome","linear_single_stranded_RNA_chromosome","linkage_group","lipoprotein_signal_peptide","lncRNA","lncRNA_gene","lncRNA_primary_transcript","lncRNA_with_retained_intron","loR","locus_control_region","long_terminal_repeat","long_terminal_repeat_transcript","loop","low_complexity_region","loxP_site","lysidine","lysine","lysine_tRNA_primary_transcript","lysosomal_localization_signal","lysyl_tRNA","mRNA","mRNA_contig","mRNA_read","mRNA_recoded_by_codon_redefinition","mRNA_recoded_by_translational_bypass","mRNA_region","mRNA_with_frameshift","mRNA_with_minus_1_frameshift","mRNA_with_minus_2_frameshift","mRNA_with_plus_1_frameshift","mRNA_with_plus_2_frameshift","macronuclear_chromosome","macronucleus_destined_segment","major_TSS","mannosyl_queuosine","match","match_part","maternal_uniparental_disomy","maternally_imprinted_gene","mathematically_defined_repeat","mating_type_M_box","mating_type_region","mating_type_region_motif","mating_type_region_replication_fork_barrier","matrix_attachment_site","mature_protein_region","mature_protein_region_of_CDS","mature_transcript","mature_transcript_region","maxicircle","maxicircle_gene","meiotic_recombination_region","membrane_peptide_loop","membrane_structure","metabolic_island","metal_binding_site","methionine","methionine_tRNA_primary_transcript","methionyl_tRNA","methylated_DNA_base_feature","methylated_adenine","methylated_cytosine","methylation_guide_snoRNA","methylation_guide_snoRNA_gene","methylation_guide_snoRNA_primary_transcript","methylinosine","methylwyosine","miRNA","miRNA_antiguide","miRNA_gene","miRNA_loop","miRNA_primary_transcript","miRNA_primary_transcript_region","miRNA_stem","miRNA_target_site","miR_encoding_Y_RNA_primary_transcript","miR_encoding_lncRNA_primary_transcript","miR_encoding_shRNA_primary_transcript","miR_encoding_snoRNA_primary_transcript","miR_encoding_tRNA_primary_transcript","miR_encoding_vaultRNA_primary_transcript","miRtron","microarray_oligo","micronuclear_chromosome","microsatellite","mini_exon_donor_RNA","mini_gene","minicircle","minicircle_gene","minisatellite","minor_TSS","minus_10_signal","minus_12_signal","minus_1_translational_frameshift","minus_24_signal","minus_2_translational_frameshift","minus_35_signal","mitochondrial_DNA_read","mitochondrial_D_loop","mitochondrial_chromosome","mitochondrial_contig","mitochondrial_control_region","mitochondrial_supercontig","mitochondrial_targeting_signal","mitotic_recombination_region","moR","mobile_element_deletion","mobile_element_insertion","mobile_genetic_element","mobile_intron","modified_DNA_base","modified_L_alanine","modified_L_arginine","modified_L_asparagine","modified_L_aspartic_acid","modified_L_cysteine","modified_L_glutamic_acid","modified_L_glutamine","modified_L_histidine","modified_L_isoleucine","modified_L_leucine","modified_L_lysine","modified_L_methionine","modified_L_phenylalanine","modified_L_proline","modified_L_selenocysteine","modified_L_serine","modified_L_threonine","modified_L_tryptophan","modified_L_tyrosine","modified_L_valine","modified_RNA_base_feature","modified_adenine","modified_adenosine","modified_amino_acid_feature","modified_cytidine","modified_cytosine","modified_glycine","modified_guanine","modified_guanosine","modified_inosine","modified_uridine","molecular_contact_region","monocistronic_mRNA","monocistronic_primary_transcript","monocistronic_transcript","monomeric_repeat","morpholino_oligo","mt_LSU_rRNA","mt_LSU_rRNA_gene","mt_SSU_rRNA","mt_SSU_rRNA_gene","mt_gene","mt_rRNA","mt_rRNA_gene","mt_tRNA","multiplexing_sequence_identifier","mutated_variant_site","mutational_hotspot","n_terminal_region","natural_plasmid","natural_transposable_element","natural_variant_site","ncRNA","ncRNA_gene","nc_conserved_region","nc_primary_transcript","negative_sense_ssRNA_viral_sequence","negatively_autoregulated_gene","nested_repeat","nested_tandem_repeat","nested_transposon","no_output","no_sequence_alteration","non_AUG_initiated_uORF","non_LTR_retrotransposon","non_LTR_retrotransposon_polymeric_tract","non_adjacent_residues","non_allelic_homologous_recombination_region","non_canonical_five_prime_splice_site","non_canonical_start_codon","non_canonical_three_prime_splice_site","non_complimentary_stem","non_cytoplasmic_polypeptide_region","non_processed_pseudogene","non_terminal_residue","non_transcribed_region","nonamer_of_recombination_feature_of_vertebrate_immune_system_gene","noncoding_exon","noncoding_region_of_exon","novel_sequence_insertion","nuclear_chromosome","nuclear_export_signal","nuclear_gene","nuclear_localization_signal","nuclear_mt_pseudogene","nuclear_rim_localization_signal","nuclease_binding_site","nuclease_hypersensitive_site","nuclease_sensitive_site","nucleomorph_gene","nucleomorphic_chromosome","nucleotide_binding_site","nucleotide_cleavage_site","nucleotide_match","nucleotide_motif","nucleotide_to_protein_binding_site","ochre_stop_codon","octamer_motif","oligo","oligo_U_tail","one_methyl_three_three_amino_three_carboxypropyl_pseudouridine","one_methyladenosine","one_methylguanosine","one_methylinosine","one_methylpseudouridine","one_two_prime_O_dimethyladenosine","one_two_prime_O_dimethylguanosine","one_two_prime_O_dimethylinosine","opal_stop_codon","open_chromatin_region","operator","operon","oriC","oriT","oriV","origin_of_replication","orphan_CDS","orthologous_region","outron","overlapping_EST_set","overlapping_feature_set","paired_end_fragment","parallel_beta_strand","paralogous_region","partial_genomic_sequence_assembly","partially_processed_cDNA_clone","paternal_uniparental_disomy","paternally_imprinted_gene","pathogenic_island","peptide_coil","peptide_helix","peptide_localization_signal","peroxywybutosine","phage_sequence","phagemid","phenylalanine","phenylalanine_tRNA_primary_transcript","phenylalanyl_tRNA","pheromone_response_element","phosphorylation_site","piRNA","piRNA_gene","pi_helix","piggyBac_TIR_transposon","plasmid","plasmid_gene","plasmid_vector","plastid_LSU_rRNA","plastid_LSU_rRNA_gene","plastid_SSU_rRNA","plastid_SSU_rRNA_gene","plastid_gene","plastid_rRNA","plastid_rRNA_gene","plus_1_translational_frameshift","plus_2_translational_frameshift","point_centromere","point_mutation","polinton","polyA_primed_cDNA_clone","polyA_sequence","polyA_signal_sequence","polyA_site","polyA_site_cluster","polyadenylated_mRNA","polycistronic_mRNA","polycistronic_primary_transcript","polycistronic_transcript","polymerase_synthesis_read","polymorphic_pseudogene","polymorphic_pseudogene_processed_transcript","polymorphic_pseudogene_with_retained_intron","polypeptide","polypeptide_DNA_contact","polypeptide_binding_motif","polypeptide_calcium_ion_contact_site","polypeptide_catalytic_motif","polypeptide_cobalt_ion_contact_site","polypeptide_conserved_motif","polypeptide_conserved_region","polypeptide_copper_ion_contact_site","polypeptide_domain","polypeptide_iron_ion_contact_site","polypeptide_ligand_contact","polypeptide_magnesium_ion_contact_site","polypeptide_manganese_ion_contact_site","polypeptide_metal_contact","polypeptide_molybdenum_ion_contact_site","polypeptide_motif","polypeptide_nest_left_right_motif","polypeptide_nest_motif","polypeptide_nest_right_left_motif","polypeptide_nickel_ion_contact_site","polypeptide_region","polypeptide_repeat","polypeptide_secondary_structure","polypeptide_sequencing_information","polypeptide_structural_motif","polypeptide_structural_region","polypeptide_tungsten_ion_contact_site","polypeptide_turn_motif","polypeptide_variation_site","polypeptide_zinc_ion_contact_site","polypyrimidine_tract","positional_candidate_gene","positive_sense_ssRNA_viral_sequence","positively_autoregulated_gene","possible_assembly_error","possible_base_call_error","post_translationally_modified_region","post_translationally_regulated_gene","pre_edited_mRNA","pre_edited_region","pre_miRNA","predicted_gene","predicted_transcript","presence_absence_variation","priRNA","primary_transcript","primary_transcript_region","primer","primer_binding_site","primer_match","probe","processed_pseudogene","processed_pseudogenic_rRNA","processed_pseudogenic_tRNA","processed_transcript","prokaryotic_promoter","proline","proline_tRNA_primary_transcript","prolyl_tRNA","promoter","promoter_element","promoter_flanking_region","promoter_targeting_sequence","promoter_trap_construct","propeptide","propeptide_cleavage_site","propeptide_region_of_CDS","prophage","proplastid_gene","protease_site","protein_binding_site","protein_coding_gene","protein_coding_primary_transcript","protein_hmm_match","protein_match","protein_protein_contact","protein_stability_element","proviral_gene","proviral_region","proximal_promoter_element","pseudogene","pseudogene_by_unequal_crossing_over","pseudogene_processed_transcript","pseudogenic_CDS","pseudogenic_exon","pseudogenic_gene_segment","pseudogenic_rRNA","pseudogenic_region","pseudogenic_tRNA","pseudogenic_transcript","pseudogenic_transcript_with_retained_intron","pseudoknot","pseudouridine","pseudouridylation_guide_snoRNA","pseudouridylation_guide_snoRNA_gene","pumilio_response_element","purine_to_pyrimidine_transversion","purine_transition","pyrimidine_to_purine_transversion","pyrimidine_transition","pyrosequenced_read","pyrrolysine","pyrrolysine_tRNA_primary_transcript","pyrrolysyl_tRNA","queuosine","rDNA_intergenic_spacer_element","rDNA_replication_fork_barrier","rRNA","rRNA_21S_gene","rRNA_cleavage_RNA","rRNA_cleavage_snoRNA_primary_transcript","rRNA_gene","rRNA_large_subunit_primary_transcript","rRNA_primary_transcript","rRNA_primary_transcript_region","rRNA_small_subunit_primary_transcript","rare_fragile_site","rasiRNA","read","read_pair","reading_frame","reagent","rearrangement_region","reciprocal_chromosomal_translocation","recoded_codon","recoded_mRNA","recoding_pseudoknot","recoding_stimulatory_region","recombination_enhancer","recombination_feature","recombination_feature_of_rearranged_gene","recombination_hotspot","recombination_regulatory_region","recombination_signal_sequence","recombinationally_inverted_gene","recombinationally_rearranged_gene","recombinationally_rearranged_vertebrate_immune_system_gene","recursive_splice_site","ref_miRNA","region","regional_centromere","regional_centromere_central_core","regional_centromere_inner_repeat_region","regional_centromere_outer_repeat_region","regional_centromere_outer_repeat_transcript","regulatory_promoter_element","regulatory_region","regulon","remark","repeat_component","repeat_fragment","repeat_instability_region","repeat_region","repeat_unit","replication_regulatory_region","replication_start_site","replicon","rescue_gene","rescue_mini_gene","rescue_region","resolution_site","response_element","restriction_enzyme_assembly_scar","restriction_enzyme_binding_site","restriction_enzyme_cleavage_junction","restriction_enzyme_five_prime_single_strand_overhang","restriction_enzyme_recognition_site","restriction_enzyme_region","restriction_enzyme_single_strand_overhang","restriction_enzyme_three_prime_single_strand_overhang","restriction_fragment","retinoic_acid_responsive_element","retrogene","retron","retrotransposon","reverse_Hoogsteen_base_pair","reverse_primer","rho_dependent_bacterial_terminator","rho_independent_bacterial_terminator","ribonuclease_site","ribosome_entry_site","riboswitch","ribothymidine","ribozyme","ribozyme_gene","right_handed_peptide_helix","sORF","sarcin_like_RNA_motif","satellite_DNA","sbRNA","sbRNA_gene","scRNA","scRNA_gene","scRNA_primary_transcript","scaRNA","scaRNA_gene","schellmann_loop","schellmann_loop_seven","schellmann_loop_six","selection_marker","selenocysteine","selenocysteine_tRNA_primary_transcript","selenocysteinyl_tRNA","self_cleaving_ribozyme","sense_intronic_ncRNA","sense_intronic_ncRNA_gene","sense_overlap_ncRNA","sense_overlap_ncRNA_gene","sequence_alteration","sequence_alteration_artifact","sequence_assembly","sequence_comparison","sequence_conflict","sequence_difference","sequence_feature","sequence_length_alteration","sequence_motif","sequence_rearrangement_feature","sequence_secondary_structure","sequence_uncertainty","sequencing_primer","serine","serine_tRNA_primary_transcript","serine_threonine_motif","serine_threonine_staple_motif","serine_threonine_turn","seryl_tRNA","seven_aminomethyl_seven_deazaguanosine","seven_cyano_seven_deazaguanosine","seven_deazaguanosine","seven_methylguanine","seven_methylguanosine","sgRNA","shRNA","shRNA_primary_transcript","shadow_enhancer","short_tandem_repeat_variation","siRNA","signal_anchor","signal_peptide","signal_peptide_region_of_CDS","signature","silenced_gene","silencer","silent_mating_type_cassette_array","simple_operon","simple_regulon","simple_sequence_length_variation","single_strand_restriction_enzyme_cleavage_site","single_stranded_DNA_chromosome","single_stranded_RNA_chromosome","sisRNA","site_specific_recombination_target_region","smFISH_probe","small_regulatory_ncRNA","snRNA","snRNA_gene","snRNA_primary_transcript","sncRNA","sncRNA_gene","snoRNA","snoRNA_gene","snoRNA_primary_transcript","solo_LTR","sonicate_fragment","specific_recombination_site","splice_enhancer","splice_junction","splice_region","splice_site","spliced_leader_RNA","spliceosomal_intron","spliceosomal_intron_region","splicing_regulatory_region","spot_42_RNA","spurious_protein","ss_RNA_viral_sequence","ss_oligo","st_turn_left_handed_type_one","st_turn_left_handed_type_two","st_turn_right_handed_type_one","st_turn_right_handed_type_two","start_codon","stem","stem_loop","stem_loop_region","sterol_regulatory_element","sticky_end_restriction_enzyme_cleavage_site","stop_codon","stop_codon_read_through","stop_codon_redefined_as_pyrrolysine","stop_codon_redefined_as_selenocysteine","stop_codon_signal","structural_alteration","substitution","substitution_artifact","subtelomere","sugar_edge_base_pair","supercontig","symbiosis_island","symmetric_RNA_internal_loop","syntenic_region","synthetic_oligo","tRNA","tRNA_SINE_retrotransposon","tRNA_gene","tRNA_intron","tRNA_primary_transcript","tRNA_region","tag","tandem_duplication","tandem_repeat","target_site_duplication","targeting_vector","tasiRNA","tasiRNA_primary_transcript","teb1_recognition_motif","telomerase_RNA","telomerase_RNA_gene","telomere","telomeric_D_loop","telomeric_repeat","telomeric_transcript","template_region","terminal_inverted_repeat","terminal_inverted_repeat_element","terminal_repeat","terminator","terminator_of_type_2_RNApol_III_promoter","tetraloop","tetranucleotide_repeat_microsatellite_feature","three_methylcytidine","three_methylpseudouridine","three_methyluridine","three_prime_D_heptamer","three_prime_D_nonamer","three_prime_D_recombination_signal_sequence","three_prime_D_spacer","three_prime_EST","three_prime_LTR","three_prime_LTR_component","three_prime_RACE_clone","three_prime_RST","three_prime_UST","three_prime_UTR","three_prime_UTR_intron","three_prime_cis_splice_site","three_prime_clip","three_prime_coding_exon","three_prime_coding_exon_coding_region","three_prime_coding_exon_noncoding_region","three_prime_flanking_region","three_prime_intron","three_prime_noncoding_exon","three_prime_overlapping_ncrna","three_prime_recoding_site","three_prime_repeat_recoding_signal","three_prime_restriction_enzyme_junction","three_prime_stem_loop_structure","three_prime_sticky_end_restriction_enzyme_cleavage_site","three_prime_terminal_inverted_repeat","three_ten_helix","three_three_amino_three_carboxypropyl_uridine","three_two_prime_O_dimethyluridine","threonine","threonine_tRNA_primary_transcript","threonyl_tRNA","tiling_path","tiling_path_clone","tiling_path_fragment","tmRNA","tmRNA_acceptor_piece","tmRNA_coding_piece","tmRNA_gene","tmRNA_primary_transcript","tmRNA_region","tnaORF","topologically_associated_domain","topologically_associated_domain_boundary","topologically_defined_region","trans_splice_acceptor_site","trans_splice_donor_site","trans_splice_junction","trans_splice_site","trans_spliced_mRNA","trans_spliced_transcript","transcribed_cluster","transcribed_fragment","transcribed_processed_pseudogene","transcribed_spacer_region","transcribed_unitary_pseudogene","transcribed_unprocessed_pseudogene","transcript","transcript_bound_by_nucleic_acid","transcript_bound_by_protein","transcript_region","transcript_with_translational_frameshift","transcription_end_site","transcription_factor_regulatory_site","transcription_pause_site","transcription_start_cluster","transcription_termination_signal","transcription_unit","transcriptional_cis_regulatory_region","transgene","transgenic_insertion","transgenic_transposable_element","transit_peptide","transit_peptide_region_of_CDS","transition","translated_nucleotide_match","translated_processed_pseudogene","translated_unprocessed_pseudogene","translation_regulatory_region","translational_frameshift","translationally_regulated_gene","translocation","translocation_breakpoint","translocation_element","transmembrane_helix","transmembrane_polypeptide_region","transposable_element","transposable_element_CDS","transposable_element_flanking_region","transposable_element_gene","transposable_element_insertion_site","transposable_element_pseudogene","transposon_fragment","transversion","trinucleotide_repeat_microsatellite_feature","tryptophan","tryptophan_tRNA_primary_transcript","tryptophanyl_tRNA","twintron","two_methyladenosine","two_methylthio_N6_cis_hydroxyisopentenyl_adenosine","two_methylthio_N6_hydroxynorvalyl_carbamoyladenosine","two_methylthio_N6_isopentenyladenosine","two_methylthio_N6_methyladenosine","two_methylthio_N6_threonyl_carbamoyladenosine","two_prime_O_methyladenosine","two_prime_O_methylcytidine","two_prime_O_methylguanosine","two_prime_O_methylinosine","two_prime_O_methylpseudouridine","two_prime_O_methyluridine","two_prime_O_ribosyladenosine_phosphate","two_prime_O_ribosylguanosine_phosphate","two_thio_two_prime_O_methyluridine","two_thiocytidine","two_thiouridine","tyrosine","tyrosine_tRNA_primary_transcript","tyrosyl_tRNA","uORF","ultracontig","unassigned_supercontig","unconfirmed_transcript","undermodified_hydroxywybutosine","unedited_region","unigene_cluster","unit_of_gene_expression","unitary_pseudogene","unitary_pseudogenic_rRNA","unitary_pseudogenic_tRNA","unprocessed_pseudogenic_rRNA","unprocessed_pseudogenic_tRNA","unspecified_indel","untranslated_region_polycistronic_mRNA","upstream_AUG_codon","uridine_five_oxyacetic_acid","uridine_five_oxyacetic_acid_methyl_ester","vacuolar_sorting_signal","validated_cDNA_clone","valine","valine_tRNA_primary_transcript","valyl_tRNA","vaultRNA_primary_transcript","vault_RNA","vault_RNA_gene","vector_replicon","vertebrate_immune_system_gene","vertebrate_immune_system_gene_recombination_feature","vertebrate_immune_system_gene_recombination_signal_feature","vertebrate_immune_system_gene_recombination_spacer","vertebrate_immune_system_pseudogene","vertebrate_immunoglobulin_T_cell_receptor_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_segment","vertebrate_immunoglobulin_T_cell_receptor_segment","viral_promoter","viral_sequence","virtual_sequence","wild_type_rescue_gene","wobble_base_pair","wybutosine","wyosine","zinc_finger_binding_site","zinc_repressed_element"],uo=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"name","Core"),e}return O(t,e),D(t,[{key:"frontendPreValidate",value:(r=B(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(!("oldType"in(i=t))||!("newType"in i)){e.n=7;break}n=F(t.changes),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=4;break}if(lo.includes((o=r.value).newType)){e.n=3;break}return e.a(2,{validationName:this.name,error:{message:'"'.concat(o.newType,'" is not a valid SO sequence_feature term')}});case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,n.e(e.v);case 6:return e.p=6,n.f(),e.f(6);case 7:return e.a(2,{validationName:this.name})}var i}),e,this,[[1,5,6,7]])}))),function(e){return r.apply(this,arguments)})},{key:"possibleValues",value:(n=B(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:if("type"!==t){e.n=1;break}return e.a(2,lo);case 1:return e.a(2)}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(io),Ao=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"name","ParentChildValidation"),e}return O(t,e),D(t,[{key:"backendPostValidate",value:(r=B(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n.featureModel,o=n.session,!Jr(t)&&!Gr(t)){e.n=1;break}return e.a(2,this.validateParentChildRelationships(t,{session:o,featureModel:r}));case 1:return e.a(2,{validationName:this.name})}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"validateParentChildRelationships",value:(n=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u,d;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=[],a=F(t.changes),e.p=1,c=U().m((function e(){var t,n,a;return U().w((function(e){for(;;)switch(e.n){case 0:return t=s.value.featureId,e.n=1,r.findOne({allIds:t}).session(o).exec();case 1:if(n=e.v){e.n=2;break}throw a="ERROR: The following featureId was not found in database ='".concat(t,"'"),new Error(a);case 2:i.some((function(e){return e._id===n._id}))||i.push(n);case 3:return e.a(2)}}),e)})),a.s();case 2:if((s=a.n()).done){e.n=4;break}return e.d(Y(c()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a.e(e.v);case 6:return e.p=6,a.f(),e.f(6);case 7:l=0,u=i;case 8:if(!(l<u.length)){e.n=12;break}d=u[l],e.p=9,this.checkChildFeatureBoundaries(d),e.n=11;break;case 10:return e.p=10,e.a(2,{validationName:this.name,error:{message:String(e.v)}});case 11:l++,e.n=8;break;case 12:return e.a(2,{validationName:this.name})}}),e,this,[[9,10],[1,5,6,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"checkChildFeatureBoundaries",value:function(e){if(e.children){var t,n=F(e.children||new Map);try{for(n.s();!(t=n.n()).done;){var r=K(t.value,2)[1];if(null!==e.min&&null!==e.max&&null!==r.min&&null!==r.max&&(r.max>e.max||r.min<e.min))throw new Error("Feature ".concat(Yr(r)," exceeds the bounds of its parent, ").concat(Yr(e)));this.checkChildFeatureBoundaries(r)}}catch(e){n.e(e)}finally{n.f()}}}}]);var n,r}(io);function fo(e){this.message=e}(fo.prototype=new Error).name="InvalidCharacterError";var ho,go,po="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new fo("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,a="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function mo(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(po(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return po(t)}}function yo(e){this.message=e}function _o(e,t){if("string"!=typeof e)throw new yo("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(mo(e.split(".")[n]))}catch(e){throw new yo("Invalid token specified: "+e.message)}}function vo(e){var t="string"==typeof e?_o(e):e;return"".concat(t.id,"-").concat(t.iat)}function bo(e){return _o(e)}function Co(e){var t,n,r=null===(t=e.attributes)||void 0===t||null===(t=t.gff_id)||void 0===t?void 0:t.join(", ");if(r)return"".concat(r," (_id: ").concat(e._id.toString(),")");var o=null===(n=e.attributes)||void 0===n||null===(n=n.gff_name)||void 0===n?void 0:n.join(", ");return o?"".concat(o," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}(yo.prototype=new Error).name="InvalidTokenError",function(e){e[e.TAG=0]="TAG",e[e.TAA=1]="TAA",e[e.TGA=2]="TGA"}(ho||(ho={})),function(e){e[e.ATG=0]="ATG"}(go||(go={}));var Io,wo="CDSCheck";!function(e){e[e.InternalStopCodon=0]="InternalStopCodon",e[e.MissingStartCodon=1]="MissingStartCodon",e[e.MissingStopCodon=2]="MissingStopCodon"}(Io||(Io={}));var Eo={G:"C",A:"T",T:"A",C:"G",R:"Y",Y:"R",M:"K",K:"M",S:"S",W:"W",H:"D",B:"V",V:"B",D:"H",N:"N"};function xo(e){var t,n=[],r=F(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=Eo[o.toUpperCase()];if(void 0===i)throw new TypeError('Cannot complement nucleotide: "'.concat(o,'"'));o===o.toLowerCase()?n.push(i.toLowerCase()):n.push(i)}}catch(e){r.e(e)}finally{r.f()}return n.reverse().join("")}function So(e,t,n){return Bo.apply(this,arguments)}function Bo(){return(Bo=B(U().m((function e(t,n,r){var o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.all(t.map((function(e){return r(e.min,e.max)})));case 1:return o=e.v.join(""),-1===n&&(o=xo(o)),e.a(2,o)}}),e)})))).apply(this,arguments)}function ko(e){for(var t=[],n=0;n<=e.length-3;n+=3)t.push(e.slice(n,n+3));return t}function Qo(e,t,n){return-1===n?e>t:e<t}function No(e,t,n){for(var r=e.toSorted(-1===t?function(e,t){return e.min<t.min?1:-1}:function(e,t){return e.min<t.min?-1:1}),o=0,i=void 0,a=void 0,s=0;s<r.length;s++)for(var c=r[s],l=c.phase,u=-1===t?c.min:c.max,d=-1===t?c.max-l:c.min+l;Qo(d,u,t);d=-1===t?d-3:d+3){if(i=d,a=-1===t?i-3:i+3,-1===t&&a<c.min?a=r[s+1].max-r[s+1].phase:a>c.max&&(a=r[s+1].min+r[s+1].phase),o===n)return[i,a].sort((function(e,t){return e-t}));o++}}function Ro(e,t){return Do.apply(this,arguments)}function Do(){return(Do=B(U().m((function e(t,n){var r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y,_,v,b,C,I,w,E,x,S,B,k,Q,N,R,D,T,j,M;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(r=[],o=t._id,i=t.max,a=t.min,s=t.refSeq,c=t.strand,l=Fo(t)){e.n=1;break}return e.a(2,r);case 1:u=[o],d=F(l),e.p=2,d.s();case 3:if((A=d.n()).done){e.n=13;break}return m=A.value,e.n=4,So(m,c,n);case 4:_=ko(y=e.v),v=-1===c?null!==(f=null===(h=m.at(0))||void 0===h?void 0:h.min)&&void 0!==f?f:a:null!==(g=null===(p=m.at(-1))||void 0===p?void 0:p.max)&&void 0!==g?g:i,y.length%3==0?((b=_.at(0))&&!(b.toUpperCase()in go)&&(x=-1===c?null!==(C=null===(I=m.at(-1))||void 0===I?void 0:I.max)&&void 0!==C?C:i:null!==(w=null===(E=m.at(0))||void 0===E?void 0:E.min)&&void 0!==w?w:a,x=-1===c?x-3:x,r.push({_id:(new ut).toHexString(),name:wo,cause:Io[Io.MissingStartCodon],ids:u,refSeq:s.toString(),start:x,end:x,message:'Unexpected start codon "'.concat(b,'" in feature "').concat(Co(t),'": ')})),(S=_.at(-1))&&!(S.toUpperCase()in ho)&&r.push({_id:(new ut).toHexString(),name:wo,cause:Io[Io.MissingStopCodon],ids:u,refSeq:s.toString(),start:v,end:v,message:'Missing stop codon in feature "'.concat(Co(t),'"')})):r.push({_id:(new ut).toHexString(),name:wo,cause:Io[Io.MissingStopCodon],ids:u,refSeq:s.toString(),start:v,end:v,message:'Missing stop codon in feature "'.concat(Co(t),'"')}),B=F(_.entries()),e.p=5,B.s();case 6:if((k=B.n()).done){e.n=9;break}if(Q=K(k.value,2),R=Q[1],(N=Q[0])!==_.length-1){e.n=7;break}return e.a(3,9);case 7:(D=No(m,c,N))&&R.toUpperCase()in ho&&(T=K(D,2),j=T[0],M=T[1],r.push({_id:(new ut).toHexString(),name:wo,cause:Io[Io.InternalStopCodon],ids:u,refSeq:s.toString(),start:j,end:M,message:'Internal stop codon in feature "'.concat(Co(t),'"')}));case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,B.e(e.v);case 11:return e.p=11,B.f(),e.f(11);case 12:e.n=3;break;case 13:e.n=15;break;case 14:e.p=14,d.e(e.v);case 15:return e.p=15,d.f(),e.f(15);case 16:return e.a(2,r)}}),e,null,[[5,10,11,12],[2,14,15,16]])})))).apply(this,arguments)}function Fo(e){if("mRNA"===e.type){var t=e.children,n=e.strand;if(t){var r=Object.values(t).filter((function(e){return"CDS"===e.type}));if(0!==r.length){var i,a=[],s=F(r);try{var c=function(){for(var e=i.value,r=e.max,s=e.min,c=[],l=0,u=Object.values(t);l<u.length;l++){var d=u[l];if("exon"===d.type){var A=K(o.intersection2(s,r,d.min,d.max),2),f=A[0],h=A[1];void 0!==f&&void 0!==h&&c.push({min:f,max:h})}}c.sort((function(e,t){return e.min-t.min})),-1===n&&c.reverse();var g=0,p=c.map((function(e){var t=g;return g=(3-(e.max-e.min-t+3)%3)%3,q(q({},e),{},{phase:t})}));p.sort((function(e,t){return e.min<t.min?-1:1})),a.push(p)};for(s.s();!(i=s.n()).done;)c()}catch(e){s.e(e)}finally{s.f()}return a.length>1&&a.sort((function(e,t){return e[0].min<t[0].min?-1:1})),a}}}}var To,jo=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"name",wo),T(e,"causes",Object.values(Io).filter((function(e){return Number.isNaN(Number(e))}))),T(e,"version",1),T(e,"isDefault",!0),e}return O(t,e),D(t,[{key:"checkFeature",value:(n=B(U().m((function e(t,n){var r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type){e.n=1;break}return e.a(2,Ro(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,c=r,l=V,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,c,l(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(gt);!function(e){e[e.NonCanonicalSpliceSiteAtFivePrime=0]="NonCanonicalSpliceSiteAtFivePrime",e[e.NonCanonicalSpliceSiteAtThreePrime=1]="NonCanonicalSpliceSiteAtThreePrime"}(To||(To={}));var Mo="TranscriptCheck";function Oo(e,t){return Lo.apply(this,arguments)}function Lo(){return Lo=B(U().m((function e(t,n){var r,i,a,s,c,l,u,d,A,f,h,g;return U().w((function(e){for(;;)switch(e.n){case 0:if(t.children){e.n=1;break}return e.a(2,[]);case 1:for(r=[],i=0,a=Object.entries(t.children);i<a.length;i++)s=K(a[i],2),"exon"===(c=s[1]).type&&r.push(c);if(!(r.length<2)){e.n=2;break}return e.a(2,[]);case 2:r.sort((function(e,t){return e.min<t.min?-1:1})),l=[],u=0;case 3:if(!(u<r.length-1)){e.n=7;break}return d=r[u].max,A=r[u+1].min,-1===t.strand?(A=(f=[d,A])[0],d=f[1],d-=2):A-=2,e.n=4,n(d,d+2);case 4:return h=e.v,e.n=5,n(A,A+2);case 5:g=e.v,-1===t.strand&&(g=o.revcom(g),h=o.revcom(h)),l.push({fivePrimeSeq:h,fivePrimeMin:d,threePrimeSeq:g,threePrimeMin:A});case 6:u++,e.n=3;break;case 7:return e.a(2,l)}}),e)}))),Lo.apply(this,arguments)}function Po(e,t){return qo.apply(this,arguments)}function qo(){return(qo=B(U().m((function e(t,n){var r,o,i,a,s,c;return U().w((function(e){for(;;)switch(e.n){case 0:return r=[],o=new Set(["GT"]),i=new Set(["AG"]),e.n=1,Oo(t,n);case 1:a=F(e.v);try{for(a.s();!(s=a.n()).done;)o.has((c=s.value).fivePrimeSeq.toUpperCase())||r.push({_id:(new ut).toHexString(),name:Mo,cause:To[To.NonCanonicalSpliceSiteAtFivePrime],ids:[t._id],refSeq:t.refSeq.toString(),start:c.fivePrimeMin,end:c.fivePrimeMin+2,message:'Unexpected 5′ splice site in "'.concat(Co(t),'". Expected: ').concat(V(o).join("|"),", got: ").concat(c.fivePrimeSeq)}),i.has(c.threePrimeSeq.toUpperCase())||r.push({_id:(new ut).toHexString(),name:Mo,cause:To[To.NonCanonicalSpliceSiteAtThreePrime],ids:[t._id],refSeq:t.refSeq.toString(),start:c.threePrimeMin,end:c.threePrimeMin+2,message:'Unexpected 3′ splice site in "'.concat(Co(t),'". Expected: ').concat(V(i).join("|"),", got: ").concat(c.threePrimeSeq)})}catch(e){a.e(e)}finally{a.f()}return e.a(2,r)}}),e)})))).apply(this,arguments)}var Jo=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"name","TranscriptCheck"),T(e,"causes",Object.values(To).filter((function(e){return Number.isNaN(Number(e))}))),T(e,"version",1),T(e,"isDefault",!0),e}return O(t,e),D(t,[{key:"checkFeature",value:(n=B(U().m((function e(t,n){var r,o,i,a,s,c,l;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type&&"transcript"!==t.type&&"pseudogenic_transcript"!==t.type){e.n=1;break}return e.a(2,Po(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,c=r,l=V,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,c,l(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(gt),Uo=a.createSvgIcon(i.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add");const Go=n.ConfigurationSchema("ApolloInternetAccount",{baseURL:{description:"Location of Apollo server",type:"string",defaultValue:""},tokenType:{description:"A custom name for a token to include in the header",type:"string",defaultValue:"Bearer"}},{baseConfiguration:r.BaseInternetAccountConfig,explicitlyTyped:!0});var Ho=Object.create(null);Ho.open="0",Ho.close="1",Ho.ping="2",Ho.pong="3",Ho.message="4",Ho.upgrade="5",Ho.noop="6";var Yo=Object.create(null);Object.keys(Ho).forEach((function(e){Yo[Ho[e]]=e}));var zo,Ko={type:"error",data:"parser error"},Wo="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Vo="function"==typeof ArrayBuffer,$o=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},Xo=function(e,t,n){var r=e.type,o=e.data;return Wo&&o instanceof Blob?t?n(o):Zo(o,n):Vo&&(o instanceof ArrayBuffer||$o(o))?t?n(o):Zo(new Blob([o]),n):n(Ho[r]+(o||""))},Zo=function(e,t){var n=new FileReader;return n.onload=function(){var e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function ei(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(var ti="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ni=0;ni<64;ni++)ti["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(ni)]=ni;var ri,oi="function"==typeof ArrayBuffer,ii=function(e,t){if("string"!=typeof e)return{type:"message",data:si(e,t)};var n=e.charAt(0);return"b"===n?{type:"message",data:ai(e.substring(1),t)}:Yo[n]?e.length>1?{type:Yo[n],data:e.substring(1)}:{type:Yo[n]}:Ko},ai=function(e,t){if(oi){var n=function(e){var t,n,r,o,i,a=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),u=new Uint8Array(l);for(t=0;t<s;t+=4)n=ti[e.charCodeAt(t)],r=ti[e.charCodeAt(t+1)],o=ti[e.charCodeAt(t+2)],i=ti[e.charCodeAt(t+3)],u[c++]=n<<2|r>>4,u[c++]=(15&r)<<4|o>>2,u[c++]=(3&o)<<6|63&i;return l}(e);return si(n,t)}return{base64:!0,data:e}},si=function(e,t){return"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},ci=String.fromCharCode(30);function li(e){return e.reduce((function(e,t){return e+t.length}),0)}function ui(e,t){if(e[0].length===t)return e.shift();for(var n=new Uint8Array(t),r=0,o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function di(e){if(e)return function(e){for(var t in di.prototype)e[t]=di.prototype[t];return e}(e)}di.prototype.on=di.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},di.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},di.prototype.off=di.prototype.removeListener=di.prototype.removeAllListeners=di.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},di.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},di.prototype.emitReserved=di.prototype.emit,di.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},di.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Ai=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()}();function fi(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return e.hasOwnProperty(n)&&(t[n]=e[n]),t}),{})}var hi=Ai.setTimeout,gi=Ai.clearTimeout;function pi(e,t){t.useNativeTimers?(e.setTimeoutFn=hi.bind(Ai),e.clearTimeoutFn=gi.bind(Ai)):(e.setTimeoutFn=Ai.setTimeout.bind(Ai),e.clearTimeoutFn=Ai.clearTimeout.bind(Ai))}var mi,yi=function(e){function t(e,n,r){var o;return N(this,t),(o=Q(this,t,[e])).description=n,o.context=r,o.type="TransportError",o}return O(t,e),D(t)}(te(Error)),_i=function(e){function t(e){var n;return N(this,t),(n=Q(this,t)).writable=!1,pi(n,e),n.opts=e,n.query=e.query,n.socket=e.socket,n}return O(t,e),D(t,[{key:"onError",value:function(e,n,r){return W(t,"emitReserved",this,3)(["error",new yi(e,n,r)]),this}},{key:"open",value:function(){return this.readyState="opening",this.doOpen(),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(e){"open"===this.readyState&&this.write(e)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,W(t,"emitReserved",this,3)(["open"])}},{key:"onData",value:function(e){var t=ii(e,this.socket.binaryType);this.onPacket(t)}},{key:"onPacket",value:function(e){W(t,"emitReserved",this,3)(["packet",e])}},{key:"onClose",value:function(e){this.readyState="closed",W(t,"emitReserved",this,3)(["close",e])}},{key:"pause",value:function(e){}},{key:"createUri",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}},{key:"_hostname",value:function(){var e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}},{key:"_port",value:function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}},{key:"_query",value:function(e){var t=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}])}(di),vi="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),bi=64,Ci=0;function Ii(e){var t="";do{t=vi[e%bi]+t,e=Math.floor(e/bi)}while(e>0);return t}function wi(){var e=Ii(+new Date);return e!==mi?(Ci=0,mi=e):e+"."+Ii(Ci++)}var Ei=!1;try{Ei="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}var xi=Ei;function Si(e){var t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||xi))return new XMLHttpRequest}catch(e){}if(!t)try{return new(Ai[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function Bi(){}var ki=function(){return null!=new Si({xdomain:!1}).responseType}(),Qi=function(e){function t(e){var n;if(N(this,t),(n=Q(this,t,[e])).polling=!1,"undefined"!=typeof location){var r="https:"===location.protocol,o=location.port;o||(o=r?"443":"80"),n.xd="undefined"!=typeof location&&e.hostname!==location.hostname||o!==e.port}return n.supportsBinary=ki&&!(e&&e.forceBase64),n.opts.withCredentials&&(n.cookieJar=void 0),n}return O(t,e),D(t,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(e){var t=this;this.readyState="pausing";var n=function(){t.readyState="paused",e()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(e){var t=this;(function(e,t){for(var n=e.split(ci),r=[],o=0;o<n.length;o++){var i=ii(n[o],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((function(e){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose({description:"transport closed by the server"}),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var e=this,t=function(){e.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}},{key:"write",value:function(e){var t=this;this.writable=!1,function(e,n){var r=e.length,o=new Array(r),i=0;e.forEach((function(e,n){Xo(e,!1,(function(e){var a;o[n]=e,++i===r&&(a=o.join(ci),t.doWrite(a,(function(){t.writable=!0,t.emitReserved("drain")})))}))}))}(e)}},{key:"uri",value:function(){var e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=wi()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ni(this.uri(),e)}},{key:"doWrite",value:function(e,t){var n=this,r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(function(e,t){n.onError("xhr post error",e,t)}))}},{key:"doPoll",value:function(){var e=this,t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(function(t,n){e.onError("xhr poll error",t,n)})),this.pollXhr=t}}])}(_i),Ni=function(e){function t(e,n){var r;return N(this,t),pi(r=Q(this,t),n),r.opts=n,r.method=n.method||"GET",r.uri=e,r.data=void 0!==n.data?n.data:null,r.create(),r}return O(t,e),D(t,[{key:"create",value:function(){var e,n=this,r=fi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;var o=this.xhr=new Si(r);try{o.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders)for(var i in o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&o.setRequestHeader(i,this.opts.extraHeaders[i])}catch(e){}if("POST"===this.method)try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{o.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(o),"withCredentials"in o&&(o.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(o.timeout=this.opts.requestTimeout),o.onreadystatechange=function(){var e;3===o.readyState&&(null===(e=n.opts.cookieJar)||void 0===e||e.parseCookies(o)),4===o.readyState&&(200===o.status||1223===o.status?n.onLoad():n.setTimeoutFn((function(){n.onError("number"==typeof o.status?o.status:0)}),0))},o.send(this.data)}catch(e){return void this.setTimeoutFn((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=t.requestsCount++,t.requests[this.index]=this)}},{key:"onError",value:function(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(e){if(null!=this.xhr){if(this.xhr.onreadystatechange=Bi,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete t.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}])}(di);function Ri(){for(var e in Ni.requests)Ni.requests.hasOwnProperty(e)&&Ni.requests[e].abort()}Ni.requestsCount=0,Ni.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Ri):"function"==typeof addEventListener&&addEventListener("onpagehide"in Ai?"pagehide":"unload",Ri,!1));var Di=function(){return"function"==typeof Promise&&"function"==typeof Promise.resolve?function(e){return Promise.resolve().then(e)}:function(e,t){return t(e,0)}}(),Fi=Ai.WebSocket||Ai.MozWebSocket,Ti="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),ji=function(e){function t(e){var n;return N(this,t),(n=Q(this,t,[e])).supportsBinary=!e.forceBase64,n}return O(t,e),D(t,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var e=this.uri(),t=this.opts.protocols,n=Ti?{}:fi(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=Ti?new Fi(e,t,n):t?new Fi(e,t):new Fi(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}}},{key:"addEventListeners",value:function(){var e=this;this.ws.onopen=function(){e.opts.autoUnref&&e.ws._socket.unref(),e.onOpen()},this.ws.onclose=function(t){return e.onClose({description:"websocket connection closed",context:t})},this.ws.onmessage=function(t){return e.onData(t.data)},this.ws.onerror=function(t){return e.onError("websocket error",t)}}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;Xo(e[r],t.supportsBinary,(function(e){try{t.ws.send(e)}catch(e){}n&&Di((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=wi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},{key:"check",value:function(){return!!Fi}}])}(_i),Mi=function(e){function t(){return N(this,t),Q(this,t,arguments)}return O(t,e),D(t,[{key:"name",get:function(){return"webtransport"}},{key:"doOpen",value:function(){var e=this;"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((function(){e.onClose()})).catch((function(t){e.onError("webtransport error",t)})),this.transport.ready.then((function(){e.transport.createBidirectionalStream().then((function(t){var n=function(e,t){ri||(ri=new TextDecoder);var n=[],r=0,o=-1,i=!1;return new TransformStream({transform:function(a,s){for(n.push(a);;){if(0===r){if(li(n)<1)break;var c=ui(n,1);i=128==(128&c[0]),r=(o=127&c[0])<126?3:126===o?1:2}else if(1===r){if(li(n)<2)break;var l=ui(n,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(2===r){if(li(n)<8)break;var u=ui(n,8),d=new DataView(u.buffer,u.byteOffset,u.length),A=d.getUint32(0);if(A>Math.pow(2,21)-1){s.enqueue(Ko);break}o=A*Math.pow(2,32)+d.getUint32(4),r=3}else{if(li(n)<o)break;var f=ui(n,o);s.enqueue(ii(i?f:ri.decode(f),t)),r=0}if(0===o||o>e){s.enqueue(Ko);break}}}})}(Number.MAX_SAFE_INTEGER,e.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=new TransformStream({transform:function(e,t){!function(e,t){Wo&&e.data instanceof Blob?e.data.arrayBuffer().then(ei).then(t):Vo&&(e.data instanceof ArrayBuffer||$o(e.data))?t(ei(e.data)):Xo(e,!1,(function(e){zo||(zo=new TextEncoder),t(zo.encode(e))}))}(e,(function(n){var r,o=n.length;if(o<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,o);else if(o<65536){r=new Uint8Array(3);var i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,o)}else{r=new Uint8Array(9);var a=new DataView(r.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(o))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}});o.readable.pipeTo(t.writable),e.writer=o.writable.getWriter();var i=function(){r.read().then((function(t){t.done||(e.onPacket(t.value),i())})).catch((function(e){}))};i();var a={type:"open"};e.query.sid&&(a.data='{"sid":"'.concat(e.query.sid,'"}')),e.writer.write(a).then((function(){return e.onOpen()}))}))})))}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;t.writer.write(e[r]).then((function(){n&&Di((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){var e;null===(e=this.transport)||void 0===e||e.close()}}])}(_i),Oi={websocket:ji,webtransport:Mi,polling:Qi},Li=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Pi=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function qi(e){var t,n,r=e,o=e.indexOf("["),i=e.indexOf("]");-1!=o&&-1!=i&&(e=e.substring(0,o)+e.substring(o,i).replace(/:/g,";")+e.substring(i,e.length));for(var a,s=Li.exec(e||""),c={},l=14;l--;)c[Pi[l]]=s[l]||"";return-1!=o&&-1!=i&&(c.source=r,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=(n=(t=c.path).replace(/\/{2,9}/g,"/").split("/"),"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n),c.queryKey=(a={},c.query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(a[t]=n)})),a),c}var Ji=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return N(this,t),(n=Q(this,t)).binaryType="arraybuffer",n.writeBuffer=[],e&&"object"===X(e)&&(r=e,e=null),e?(e=qi(e),r.hostname=e.host,r.secure="https"===e.protocol||"wss"===e.protocol,r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=qi(r.host).host),pi(n,r),n.secure=null!=r.secure?r.secure:"undefined"!=typeof location&&"https:"===location.protocol,r.hostname&&!r.port&&(r.port=n.secure?"443":"80"),n.hostname=r.hostname||("undefined"!=typeof location?location.hostname:"localhost"),n.port=r.port||("undefined"!=typeof location&&location.port?location.port:n.secure?"443":"80"),n.transports=r.transports||["polling","websocket","webtransport"],n.writeBuffer=[],n.prevBufferLen=0,n.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),n.opts.path=n.opts.path.replace(/\/$/,"")+(n.opts.addTrailingSlash?"/":""),"string"==typeof n.opts.query&&(n.opts.query=function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}(n.opts.query)),n.id=null,n.upgrades=null,n.pingInterval=null,n.pingTimeout=null,n.pingTimeoutTimer=null,"function"==typeof addEventListener&&(n.opts.closeOnBeforeunload&&(n.beforeunloadEventListener=function(){n.transport&&(n.transport.removeAllListeners(),n.transport.close())},addEventListener("beforeunload",n.beforeunloadEventListener,!1)),"localhost"!==n.hostname&&(n.offlineEventListener=function(){n.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",n.offlineEventListener,!1))),n.open(),n}return O(t,e),D(t,[{key:"createTransport",value:function(e){var t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);var n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Oi[e](n)}},{key:"open",value:function(){var e,n=this;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){n.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}},{key:"setTransport",value:function(e){var t=this;this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(e){return t.onClose("transport close",e)}))}},{key:"probe",value:function(e){var n=this,r=this.createTransport(e),o=!1;t.priorWebsocketSuccess=!1;var i=function(){o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(function(e){if(!o)if("pong"===e.type&&"probe"===e.data){if(n.upgrading=!0,n.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,n.transport.pause((function(){o||"closed"!==n.readyState&&(d(),n.setTransport(r),r.send([{type:"upgrade"}]),n.emitReserved("upgrade",r),r=null,n.upgrading=!1,n.flush())}))}else{var i=new Error("probe error");i.transport=r.name,n.emitReserved("upgradeError",i)}})))};function a(){o||(o=!0,d(),r.close(),r=null)}var s=function(e){var t=new Error("probe error: "+e);t.transport=r.name,a(),n.emitReserved("upgradeError",t)};function c(){s("transport closed")}function l(){s("socket closed")}function u(e){r&&e.name!==r.name&&a()}var d=function(){r.removeListener("open",i),r.removeListener("error",s),r.removeListener("close",c),n.off("close",l),n.off("upgrading",u)};r.once("open",i),r.once("error",s),r.once("close",c),this.once("close",l),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((function(){o||r.open()}),200):r.open()}},{key:"onOpen",value:function(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(var e=0,n=this.upgrades.length;e<n;e++)this.probe(this.upgrades[e])}},{key:"onPacket",value:function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}},{key:"onHandshake",value:function(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var e=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){e.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var e,t=1,n=0;n<this.writeBuffer.length;n++){var r=this.writeBuffer[n].data;if(r&&(t+="string"==typeof(e=r)?function(e){for(var t=0,n=0,r=0,o=e.length;r<o;r++)(t=e.charCodeAt(r))<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}},{key:"write",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"send",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"sendPacket",value:function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var e=this,t=function(){e.onClose("forced close"),e.transport.close()},n=function(){e.off("upgrade",n),e.off("upgradeError",n),t()},r=function(){e.once("upgrade",n),e.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){e.upgrading?r():t()})):this.upgrading?r():t()),this}},{key:"onError",value:function(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}},{key:"onClose",value:function(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(e){for(var t=[],n=0,r=e.length;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}])}(di);Ji.protocol=4;var Ui="function"==typeof ArrayBuffer,Gi=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer},Hi=Object.prototype.toString,Yi="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Hi.call(Blob),zi="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Hi.call(File);function Ki(e){return Ui&&(e instanceof ArrayBuffer||Gi(e))||Yi&&e instanceof Blob||zi&&e instanceof File}function Wi(e,t){if(!e||"object"!==X(e))return!1;if(Array.isArray(e)){for(var n=0,r=e.length;n<r;n++)if(Wi(e[n]))return!0;return!1}if(Ki(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Wi(e.toJSON(),!0);for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&Wi(e[o]))return!0;return!1}function Vi(e){var t=[],n=e;return n.data=$i(e.data,t),n.attachments=t.length,{packet:n,buffers:t}}function $i(e,t){if(!e)return e;if(Ki(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=$i(e[o],t);return r}if("object"===X(e)&&!(e instanceof Date)){var i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=$i(e[a],t));return i}return e}function Xi(e,t){return e.data=Zi(e.data,t),delete e.attachments,e}function Zi(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n]=Zi(e[n],t);else if("object"===X(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Zi(e[r],t));return e}var ea,ta=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(ea||(ea={}));var na=function(){return D((function e(t){N(this,e),this.replacer=t}),[{key:"encode",value:function(e){return e.type!==ea.EVENT&&e.type!==ea.ACK||!Wi(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===ea.EVENT?ea.BINARY_EVENT:ea.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}},{key:"encodeAsString",value:function(e){var t=""+e.type;return e.type!==ea.BINARY_EVENT&&e.type!==ea.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}},{key:"encodeAsBinary",value:function(e){var t=Vi(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}])}();function ra(e){return"[object Object]"===Object.prototype.toString.call(e)}var oa=function(e){function t(e){var n;return N(this,t),(n=Q(this,t)).reviver=e,n}return O(t,e),D(t,[{key:"add",value:function(e){var n;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");var r=(n=this.decodeString(e)).type===ea.BINARY_EVENT;r||n.type===ea.BINARY_ACK?(n.type=r?ea.EVENT:ea.ACK,this.reconstructor=new ia(n),0===n.attachments&&W(t,"emitReserved",this,3)(["decoded",n])):W(t,"emitReserved",this,3)(["decoded",n])}else{if(!Ki(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,W(t,"emitReserved",this,3)(["decoded",n]))}}},{key:"decodeString",value:function(e){var n=0,r={type:Number(e.charAt(0))};if(void 0===ea[r.type])throw new Error("unknown packet type "+r.type);if(r.type===ea.BINARY_EVENT||r.type===ea.BINARY_ACK){for(var o=n+1;"-"!==e.charAt(++n)&&n!=e.length;);var i=e.substring(o,n);if(i!=Number(i)||"-"!==e.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(n+1)){for(var a=n+1;++n&&","!==e.charAt(n)&&n!==e.length;);r.nsp=e.substring(a,n)}else r.nsp="/";var s=e.charAt(n+1);if(""!==s&&Number(s)==s){for(var c=n+1;++n;){var l=e.charAt(n);if(null==l||Number(l)!=l){--n;break}if(n===e.length)break}r.id=Number(e.substring(c,n+1))}if(e.charAt(++n)){var u=this.tryParse(e.substr(n));if(!t.isPayloadValid(r.type,u))throw new Error("invalid payload");r.data=u}return r}},{key:"tryParse",value:function(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}},{key:"destroy",value:function(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}],[{key:"isPayloadValid",value:function(e,t){switch(e){case ea.CONNECT:return ra(t);case ea.DISCONNECT:return void 0===t;case ea.CONNECT_ERROR:return"string"==typeof t||ra(t);case ea.EVENT:case ea.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===ta.indexOf(t[0]));case ea.ACK:case ea.BINARY_ACK:return Array.isArray(t)}}}])}(di),ia=function(){return D((function e(t){N(this,e),this.packet=t,this.buffers=[],this.reconPack=t}),[{key:"takeBinaryData",value:function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=Xi(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}])}(),aa={__proto__:null,Decoder:oa,Encoder:na,get PacketType(){return ea}};function sa(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var ca=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),la=function(e){function t(e,n,r){var o;return N(this,t),(o=Q(this,t)).connected=!1,o.recovered=!1,o.receiveBuffer=[],o.sendBuffer=[],o._queue=[],o._queueSeq=0,o.ids=0,o.acks={},o.flags={},o.io=e,o.nsp=n,r&&r.auth&&(o.auth=r.auth),o._opts=Object.assign({},r),o.io._autoConnect&&o.open(),o}return O(t,e),D(t,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var e=this.io;this.subs=[sa(e,"open",this.onopen.bind(this)),sa(e,"packet",this.onpacket.bind(this)),sa(e,"error",this.onerror.bind(this)),sa(e,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.unshift("message"),this.emit.apply(this,t),this}},{key:"emit",value:function(e){if(ca.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;var o={type:ea.EVENT,data:n,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var i=this.ids++,a=n.pop();this._registerAckCallback(i,a),o.id=i}return this.flags.volatile&&(!(this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable)||!this.connected)||(this.connected?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}},{key:"_registerAckCallback",value:function(e,t){var n,r=this,o=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0!==o){var i=this.io.setTimeoutFn((function(){delete r.acks[e];for(var n=0;n<r.sendBuffer.length;n++)r.sendBuffer[n].id===e&&r.sendBuffer.splice(n,1);t.call(r,new Error("operation has timed out"))}),o);this.acks[e]=function(){r.io.clearTimeoutFn(i);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.apply(r,[null].concat(n))}}else this.acks[e]=t}},{key:"emitWithAck",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise((function(n,o){r.push((function(e,t){return i?e?o(e):n(t):n(e)})),t.emit.apply(t,[e].concat(r))}))}},{key:"_addToQueue",value:function(e){var t,n=this;"function"==typeof e[e.length-1]&&(t=e.pop());var r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((function(e){if(r===n._queue[0]){if(null!==e)r.tryCount>n._opts.retries&&(n._queue.shift(),t&&t(e));else if(n._queue.shift(),t){for(var o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t.apply(void 0,[null].concat(i))}return r.pending=!1,n._drainQueue()}})),this._queue.push(r),this._drainQueue()}},{key:"_drainQueue",value:function(){if(this.connected&&0!==this._queue.length){var e=this._queue[0];e.pending&&!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}}},{key:"packet",value:function(e){e.nsp=this.nsp,this.io._packet(e)}},{key:"onopen",value:function(){var e=this;"function"==typeof this.auth?this.auth((function(t){e._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(e){this.packet({type:ea.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}},{key:"onerror",value:function(e){this.connected||this.emitReserved("connect_error",e)}},{key:"onclose",value:function(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}},{key:"onpacket",value:function(e){if(e.nsp===this.nsp)switch(e.type){case ea.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ea.EVENT:case ea.BINARY_EVENT:this.onevent(e);break;case ea.ACK:case ea.BINARY_ACK:this.onack(e);break;case ea.DISCONNECT:this.ondisconnect();break;case ea.CONNECT_ERROR:this.destroy();var t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}},{key:"onevent",value:function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}},{key:"emitEvent",value:function(e){if(this._anyListeners&&this._anyListeners.length){var n,r=F(this._anyListeners.slice());try{for(r.s();!(n=r.n()).done;)n.value.apply(this,e)}catch(e){r.e(e)}finally{r.f()}}W(t,"emit",this,1).apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}},{key:"ack",value:function(e){var t=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];t.packet({type:ea.ACK,id:e,data:o})}}}},{key:"onack",value:function(e){var t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}},{key:"onconnect",value:function(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}},{key:"emitBuffered",value:function(){var e=this;this.receiveBuffer.forEach((function(t){return e.emitEvent(t)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(t){e.notifyOutgoingListeners(t),e.packet(t)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(e){return e()})),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:ea.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(e){return this.flags.compress=e,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(e){return this.flags.timeout=e,this}},{key:"onAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}},{key:"prependAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}},{key:"offAny",value:function(e){if(!this._anyListeners)return this;if(e){for(var t=this._anyListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}},{key:"prependAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}},{key:"offAnyOutgoing",value:function(e){if(!this._anyOutgoingListeners)return this;if(e){for(var t=this._anyOutgoingListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var t,n=F(this._anyOutgoingListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e.data)}catch(e){n.e(e)}finally{n.f()}}}}])}(di);function ua(e){this.ms=(e=e||{}).min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}ua.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},ua.prototype.reset=function(){this.attempts=0},ua.prototype.setMin=function(e){this.ms=e},ua.prototype.setMax=function(e){this.max=e},ua.prototype.setJitter=function(e){this.jitter=e};var da=function(e){function t(e,n){var r,o;N(this,t),(r=Q(this,t)).nsps={},r.subs=[],e&&"object"===X(e)&&(n=e,e=void 0),(n=n||{}).path=n.path||"/socket.io",r.opts=n,pi(r,n),r.reconnection(!1!==n.reconnection),r.reconnectionAttempts(n.reconnectionAttempts||Infinity),r.reconnectionDelay(n.reconnectionDelay||1e3),r.reconnectionDelayMax(n.reconnectionDelayMax||5e3),r.randomizationFactor(null!==(o=n.randomizationFactor)&&void 0!==o?o:.5),r.backoff=new ua({min:r.reconnectionDelay(),max:r.reconnectionDelayMax(),jitter:r.randomizationFactor()}),r.timeout(null==n.timeout?2e4:n.timeout),r._readyState="closed",r.uri=e;var i=n.parser||aa;return r.encoder=new i.Encoder,r.decoder=new i.Decoder,r._autoConnect=!1!==n.autoConnect,r._autoConnect&&r.open(),r}return O(t,e),D(t,[{key:"reconnection",value:function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}},{key:"reconnectionAttempts",value:function(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}},{key:"reconnectionDelay",value:function(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}},{key:"randomizationFactor",value:function(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}},{key:"reconnectionDelayMax",value:function(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}},{key:"timeout",value:function(e){return arguments.length?(this._timeout=e,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(e){var t=this;if(~this._readyState.indexOf("open"))return this;this.engine=new Ji(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var o=sa(n,"open",(function(){r.onopen(),e&&e()})),i=function(n){t.cleanup(),t._readyState="closed",t.emitReserved("error",n),e?e(n):t.maybeReconnectOnOpen()},a=sa(n,"error",i);if(!1!==this._timeout){var s=this.setTimeoutFn((function(){o(),i(new Error("timeout")),n.close()}),this._timeout);this.opts.autoUnref&&s.unref(),this.subs.push((function(){t.clearTimeoutFn(s)}))}return this.subs.push(o),this.subs.push(a),this}},{key:"connect",value:function(e){return this.open(e)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var e=this.engine;this.subs.push(sa(e,"ping",this.onping.bind(this)),sa(e,"data",this.ondata.bind(this)),sa(e,"error",this.onerror.bind(this)),sa(e,"close",this.onclose.bind(this)),sa(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}},{key:"ondecoded",value:function(e){var t=this;Di((function(){t.emitReserved("packet",e)}),this.setTimeoutFn)}},{key:"onerror",value:function(e){this.emitReserved("error",e)}},{key:"socket",value:function(e,t){var n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new la(this,e,t),this.nsps[e]=n),n}},{key:"_destroy",value:function(e){for(var t=0,n=Object.keys(this.nsps);t<n.length;t++)if(this.nsps[n[t]].active)return;this._close()}},{key:"_packet",value:function(e){for(var t=this.encoder.encode(e),n=0;n<t.length;n++)this.engine.write(t[n],e.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(e){return e()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var e=this;if(this._reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){t.skipReconnect||(e.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((function(n){n?(t._reconnecting=!1,t.reconnect(),e.emitReserved("reconnect_error",n)):t.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){e.clearTimeoutFn(r)}))}}},{key:"onreconnect",value:function(){var e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}])}(di),Aa={};function fa(e,t){"object"===X(e)&&(t=e,e=void 0);var n,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=qi(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),o=r.source,i=r.id;return t.forceNew||t["force new connection"]||!1===t.multiplex||Aa[i]&&r.path in Aa[i].nsps?n=new da(o,t):(Aa[i]||(Aa[i]=new da(o,t)),n=Aa[i]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(fa,{Manager:da,Socket:la,io:fa,connect:fa});var ha=a.createSvgIcon([i.jsx("path",{d:"M17 11c.34 0 .67.04 1 .09V6.27L10.5 3 3 6.27v4.91c0 4.54 3.2 8.79 7.5 9.82.55-.13 1.08-.32 1.6-.55-.69-.98-1.1-2.17-1.1-3.45 0-3.31 2.69-6 6-6"},"0"),i.jsx("path",{d:"M17 13c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 1.38c.62 0 1.12.51 1.12 1.12s-.51 1.12-1.12 1.12-1.12-.51-1.12-1.12.5-1.12 1.12-1.12m0 5.37c-.93 0-1.74-.46-2.24-1.17.05-.72 1.51-1.08 2.24-1.08s2.19.36 2.24 1.08c-.5.71-1.31 1.17-2.24 1.17"},"1")],"AdminPanelSettings"),ga=a.createSvgIcon(i.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete"),pa=a.createSvgIcon(i.jsx("path",{d:"M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2M11 16l4-4-4-4v3H1v2h10z"}),"Input"),ma=a.createSvgIcon(i.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"Person"),ya=a.createSvgIcon(i.jsx("path",{d:"M16.54 11 13 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zM11 7H2v2h9zm10 6.41L19.59 12 17 14.59 14.41 12 13 13.41 15.59 16 13 18.59 14.41 20 17 17.41 19.59 20 21 18.59 18.41 16zM11 15H2v2h9z"}),"Rule"),_a=function(){function e(e){var t=this;this._insertTag=function(e){t.container.insertBefore(e,0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling),t.tags.push(e)},this.isSpeedy=void 0===e.speedy?"production"===ue.env.NODE_ENV:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if("production"!==ue.env.NODE_ENV){var n=64===e.charCodeAt(0)&&105===e.charCodeAt(1);n&&this._alreadyInsertedOrderInsensitiveRule&&console.error("You're attempting to insert the following rule:\n"+e+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!n}if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"===ue.env.NODE_ENV||/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(e)||console.error('There was a problem inserting the following rule: "'+e+'"',t)}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0,"production"!==ue.env.NODE_ENV&&(this._alreadyInsertedOrderInsensitiveRule=!1)},e}(),va="-ms-",ba="-moz-",Ca="-webkit-",Ia="comm",wa="rule",Ea="decl",xa="@keyframes",Sa=Math.abs,Ba=String.fromCharCode,ka=Object.assign;function Qa(e){return e.trim()}function Na(e,t,n){return e.replace(t,n)}function Ra(e,t){return e.indexOf(t)}function Da(e,t){return 0|e.charCodeAt(t)}function Fa(e,t,n){return e.slice(t,n)}function Ta(e){return e.length}function ja(e){return e.length}function Ma(e,t){return t.push(e),e}var Oa=1,La=1,Pa=0,qa=0,Ja=0,Ua="";function Ga(e,t,n,r,o,i,a){return{value:e,root:t,parent:n,type:r,props:o,children:i,line:Oa,column:La,length:a,return:""}}function Ha(e,t){return ka(Ga("",null,null,"",null,null,0),e,{length:-e.length},t)}function Ya(){return Ja=qa>0?Da(Ua,--qa):0,La--,10===Ja&&(La=1,Oa--),Ja}function za(){return Ja=qa<Pa?Da(Ua,qa++):0,La++,10===Ja&&(La=1,Oa++),Ja}function Ka(){return Da(Ua,qa)}function Wa(){return qa}function Va(e,t){return Fa(Ua,e,t)}function $a(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Xa(e){return Oa=La=1,Pa=Ta(Ua=e),qa=0,[]}function Za(e){return Ua="",e}function es(e){return Qa(Va(qa-1,rs(91===e?e+2:40===e?e+1:e)))}function ts(e){for(;(Ja=Ka())&&Ja<33;)za();return $a(e)>2||$a(Ja)>3?"":" "}function ns(e,t){for(;--t&&za()&&!(Ja<48||Ja>102||Ja>57&&Ja<65||Ja>70&&Ja<97););return Va(e,Wa()+(t<6&&32==Ka()&&32==za()))}function rs(e){for(;za();)switch(Ja){case e:return qa;case 34:case 39:34!==e&&39!==e&&rs(Ja);break;case 40:41===e&&rs(e);break;case 92:za()}return qa}function os(e,t){for(;za()&&e+Ja!==57&&(e+Ja!==84||47!==Ka()););return"/*"+Va(t,qa-1)+"*"+Ba(47===e?e:za())}function is(e){for(;!$a(Ka());)za();return Va(e,qa)}function as(e){return Za(ss("",null,null,null,[""],e=Xa(e),0,[0],e))}function ss(e,t,n,r,o,i,a,s,c){for(var l=0,u=0,d=a,A=0,f=0,h=0,g=1,p=1,m=1,y=0,_="",v=o,b=i,C=r,I=_;p;)switch(h=y,y=za()){case 40:if(108!=h&&58==Da(I,d-1)){-1!=Ra(I+=Na(es(y),"&","&\f"),"&\f")&&(m=-1);break}case 34:case 39:case 91:I+=es(y);break;case 9:case 10:case 13:case 32:I+=ts(h);break;case 92:I+=ns(Wa()-1,7);continue;case 47:switch(Ka()){case 42:case 47:Ma(ls(os(za(),Wa()),t,n),c);break;default:I+="/"}break;case 123*g:s[l++]=Ta(I)*m;case 125*g:case 59:case 0:switch(y){case 0:case 125:p=0;case 59+u:-1==m&&(I=Na(I,/\f/g,"")),f>0&&Ta(I)-d&&Ma(f>32?us(I+";",r,n,d-1):us(Na(I," ","")+";",r,n,d-2),c);break;case 59:I+=";";default:if(Ma(C=cs(I,t,n,l,u,o,s,_,v=[],b=[],d),i),123===y)if(0===u)ss(I,t,C,C,v,i,d,s,b);else switch(99===A&&110===Da(I,3)?100:A){case 100:case 108:case 109:case 115:ss(e,C,C,r&&Ma(cs(e,C,C,0,0,o,s,_,o,v=[],d),b),o,b,d,s,r?v:b);break;default:ss(I,C,C,C,[""],b,0,s,b)}}l=u=f=0,g=m=1,_=I="",d=a;break;case 58:d=1+Ta(I),f=h;default:if(g<1)if(123==y)--g;else if(125==y&&0==g++&&125==Ya())continue;switch(I+=Ba(y),y*g){case 38:m=u>0?1:(I+="\f",-1);break;case 44:s[l++]=(Ta(I)-1)*m,m=1;break;case 64:45===Ka()&&(I+=es(za())),A=Ka(),u=d=Ta(_=I+=is(Wa())),y++;break;case 45:45===h&&2==Ta(I)&&(g=0)}}return i}function cs(e,t,n,r,o,i,a,s,c,l,u){for(var d=o-1,A=0===o?i:[""],f=ja(A),h=0,g=0,p=0;h<r;++h)for(var m=0,y=Fa(e,d+1,d=Sa(g=a[h])),_=e;m<f;++m)(_=Qa(g>0?A[m]+" "+y:Na(y,/&\f/g,A[m])))&&(c[p++]=_);return Ga(e,t,n,0===o?wa:s,c,l,u)}function ls(e,t,n){return Ga(e,t,n,Ia,Ba(Ja),Fa(e,2,-2),0)}function us(e,t,n,r){return Ga(e,t,n,Ea,Fa(e,0,r),Fa(e,r+1,-1),r)}function ds(e,t){for(var n="",r=ja(e),o=0;o<r;o++)n+=t(e[o],o,e,t)||"";return n}function As(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Ea:return e.return=e.return||e.value;case Ia:return"";case xa:return e.return=e.value+"{"+ds(e.children,r)+"}";case wa:e.value=e.props.join(",")}return Ta(n=ds(e.children,r))?e.return=e.value+"{"+n+"}":""}function fs(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var hs=function(e,t,n){for(var r=0,o=0;r=o,o=Ka(),38===r&&12===o&&(t[n]=1),!$a(o);)za();return Va(e,qa)},gs=new WeakMap,ps=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||gs.get(n))&&!r){gs.set(e,!0);for(var o=[],i=function(e,t){return Za(function(e,t){var n=-1,r=44;do{switch($a(r)){case 0:38===r&&12===Ka()&&(t[n]=1),e[n]+=hs(qa-1,t,n);break;case 2:e[n]+=es(r);break;case 4:if(44===r){e[++n]=58===Ka()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=Ba(r)}}while(r=za());return e}(Xa(e),t))}(t,o),a=n.props,s=0,c=0;s<i.length;s++)for(var l=0;l<a.length;l++,c++)e.props[c]=o[s]?i[s].replace(/&\f/g,a[l]):a[l]+" "+i[s]}}},ms=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},ys=function(e){return"comm"===e.type&&e.children.indexOf("emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason")>-1},_s=function(e){return 105===e.type.charCodeAt(1)&&64===e.type.charCodeAt(0)},vs=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},bs=function(e,t,n){_s(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),vs(e)):function(e,t){for(var n=e-1;n>=0;n--)if(!_s(t[n]))return!0;return!1}(t,n)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),vs(e)))};function Cs(e,t){switch(function(e,t){return 45^Da(e,0)?(((t<<2^Da(e,0))<<2^Da(e,1))<<2^Da(e,2))<<2^Da(e,3):0}(e,t)){case 5103:return Ca+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ca+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ca+e+ba+e+va+e+e;case 6828:case 4268:return Ca+e+va+e+e;case 6165:return Ca+e+va+"flex-"+e+e;case 5187:return Ca+e+Na(e,/(\w+).+(:[^]+)/,Ca+"box-$1$2"+va+"flex-$1$2")+e;case 5443:return Ca+e+va+"flex-item-"+Na(e,/flex-|-self/,"")+e;case 4675:return Ca+e+va+"flex-line-pack"+Na(e,/align-content|flex-|-self/,"")+e;case 5548:return Ca+e+va+Na(e,"shrink","negative")+e;case 5292:return Ca+e+va+Na(e,"basis","preferred-size")+e;case 6060:return Ca+"box-"+Na(e,"-grow","")+Ca+e+va+Na(e,"grow","positive")+e;case 4554:return Ca+Na(e,/([^-])(transform)/g,"$1"+Ca+"$2")+e;case 6187:return Na(Na(Na(e,/(zoom-|grab)/,Ca+"$1"),/(image-set)/,Ca+"$1"),e,"")+e;case 5495:case 3959:return Na(e,/(image-set\([^]*)/,Ca+"$1$`$1");case 4968:return Na(Na(e,/(.+:)(flex-)?(.*)/,Ca+"box-pack:$3"+va+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ca+e+e;case 4095:case 3583:case 4068:case 2532:return Na(e,/(.+)-inline(.+)/,Ca+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Ta(e)-1-t>6)switch(Da(e,t+1)){case 109:if(45!==Da(e,t+4))break;case 102:return Na(e,/(.+:)(.+)-([^]+)/,"$1"+Ca+"$2-$3$1"+ba+(108==Da(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Ra(e,"stretch")?Cs(Na(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==Da(e,t+1))break;case 6444:switch(Da(e,Ta(e)-3-(~Ra(e,"!important")&&10))){case 107:return Na(e,":",":"+Ca)+e;case 101:return Na(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ca+(45===Da(e,14)?"inline-":"")+"box$3$1"+Ca+"$2$3$1"+va+"$2box$3")+e}break;case 5936:switch(Da(e,t+11)){case 114:return Ca+e+va+Na(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ca+e+va+Na(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ca+e+va+Na(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ca+e+va+e+e}return e}var Is=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Ea:e.return=Cs(e.value,e.length);break;case xa:return ds([Ha(e,{value:Na(e.value,"@","@"+Ca)})],r);case wa:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return ds([Ha(e,{props:[Na(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return ds([Ha(e,{props:[Na(t,/:(plac\w+)/,":"+Ca+"input-$1")]}),Ha(e,{props:[Na(t,/:(plac\w+)/,":-moz-$1")]}),Ha(e,{props:[Na(t,/:(plac\w+)/,va+"input-$1")]})],r)}return""}))}}],ws=function(e){var t=e.key;if("production"!==ue.env.NODE_ENV&&!t)throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\nIf multiple caches share the same key they might \"fight\" for each other's style elements.");if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r=e.stylisPlugins||Is;if("production"!==ue.env.NODE_ENV&&/[^a-z-]/.test(t))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+t+'" was passed');var o,i,a={},s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)a[t[n]]=!0;s.push(e)}));var c=[ps,ms];"production"!==ue.env.NODE_ENV&&c.push(function(e){return function(t,n,r){if("rule"===t.type&&!e.compat){var o=t.value.match(/(:first|:nth|:nth-last)-child/g);if(o){for(var i=t.parent?t.parent.children:r,a=i.length-1;a>=0;a--){var s=i[a];if(s.line<t.line)break;if(s.column<t.column){if(ys(s))return;break}}o.forEach((function(e){console.error('The pseudo class "'+e+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+e.split("-child")[0]+'-of-type".')}))}}}}({get compat(){return f.compat}}),bs);var l,u,d=[As,"production"!==ue.env.NODE_ENV?function(e){e.root||(e.return?l.insert(e.return):e.value&&e.type!==Ia&&l.insert(e.value+"{}"))}:(u=function(e){l.insert(e)},function(e){e.root||(e=e.return)&&u(e)})],A=function(e){var t=ja(e);return function(n,r,o,i){for(var a="",s=0;s<t;s++)a+=e[s](n,r,o,i)||"";return a}}(c.concat(r,d));i=function(e,t,n,r){l=n,"production"!==ue.env.NODE_ENV&&void 0!==t.map&&(l={insert:function(e){n.insert(e+t.map)}}),function(e){ds(as(e),A)}(e?e+"{"+t.styles+"}":t.styles),r&&(f.inserted[t.name]=!0)};var f={key:t,sheet:new _a({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:i};return f.sheet.hydrate(s),f};function Es(){return Es=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Es.apply(this,arguments)}function xs(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r}var Ss=function(e,t,n){var r=e.key+"-"+t.name;!1===n&&void 0===e.registered[r]&&(e.registered[r]=t.styles)},Bs=function(e,t,n){Ss(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}},ks={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Qs="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",Ns=/[A-Z]|^ms/g,Rs=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ds=function(e){return 45===e.charCodeAt(1)},Fs=function(e){return null!=e&&"boolean"!=typeof e},Ts=fs((function(e){return Ds(e)?e:e.replace(Ns,"-$&").toLowerCase()})),js=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Rs,(function(e,t,n){return Ys={name:t,styles:n,next:Ys},t}))}return 1===ks[e]||Ds(e)||"number"!=typeof t||0===t?t:t+"px"};if("production"!==ue.env.NODE_ENV){var Ms=/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/,Os=["normal","none","initial","inherit","unset"],Ls=js,Ps=/^-ms-/,qs=/-(.)/g,Js={};js=function(e,t){if("content"===e&&("string"!=typeof t||-1===Os.indexOf(t)&&!Ms.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0))))throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`");var n=Ls(e,t);return""===n||Ds(e)||-1===e.indexOf("-")||void 0!==Js[e]||(Js[e]=!0,console.error("Using kebab-case for css properties in objects is not supported. Did you mean "+e.replace(Ps,"ms-").replace(qs,(function(e,t){return t.toUpperCase()}))+"?")),n}}var Us="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Gs(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles){if("production"!==ue.env.NODE_ENV&&"NO_COMPONENT_SELECTOR"===n.toString())throw new Error(Us);return n}switch(X(n)){case"boolean":return"";case"object":if(1===n.anim)return Ys={name:n.name,styles:n.styles,next:Ys},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)Ys={name:r.name,styles:r.styles,next:Ys},r=r.next;var o=n.styles+";";return"production"!==ue.env.NODE_ENV&&void 0!==n.map&&(o+=n.map),o}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=Gs(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==X(a))null!=t&&void 0!==t[a]?r+=i+"{"+t[a]+"}":Fs(a)&&(r+=Ts(i)+":"+js(i,a)+";");else{if("NO_COMPONENT_SELECTOR"===i&&"production"!==ue.env.NODE_ENV)throw new Error(Us);if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var s=Gs(e,t,a);switch(i){case"animation":case"animationName":r+=Ts(i)+":"+s+";";break;default:"production"!==ue.env.NODE_ENV&&"undefined"===i&&console.error("You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key)."),r+=i+"{"+s+"}"}}else for(var c=0;c<a.length;c++)Fs(a[c])&&(r+=Ts(i)+":"+js(i,a[c])+";")}}return r}(e,t,n);case"function":if(void 0!==e){var i=Ys,a=n(e);return Ys=i,Gs(e,t,a)}"production"!==ue.env.NODE_ENV&&console.error("Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`");break;case"string":if("production"!==ue.env.NODE_ENV){var s=[],c=n.replace(Rs,(function(e,t,n){var r="animation"+s.length;return s.push("const "+r+" = keyframes`"+n.replace(/^@keyframes animation-\w+/,"")+"`"),"${"+r+"}"}));s.length&&console.error("`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\nInstead of doing this:\n\n"+[].concat(s,["`"+c+"`"]).join("\n")+"\n\nYou should wrap it with `css` like this:\n\ncss`"+c+"`")}}if(null==t)return n;var l=t[n];return void 0!==l?l:n}var Hs,Ys,zs=/label:\s*([^\s;\n{]+)\s*(;|$)/g;"production"!==ue.env.NODE_ENV&&(Hs=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g);var Ks=function(e,t,n){if(1===e.length&&"object"===X(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";Ys=void 0;var i,a=e[0];null==a||void 0===a.raw?(r=!1,o+=Gs(n,t,a)):("production"!==ue.env.NODE_ENV&&void 0===a[0]&&console.error(Qs),o+=a[0]);for(var s=1;s<e.length;s++)o+=Gs(n,t,e[s]),r&&("production"!==ue.env.NODE_ENV&&void 0===a[s]&&console.error(Qs),o+=a[s]);"production"!==ue.env.NODE_ENV&&(o=o.replace(Hs,(function(e){return i=e,""}))),zs.lastIndex=0;for(var c,l="";null!==(c=zs.exec(o));)l+="-"+c[1];var u=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+l;return"production"!==ue.env.NODE_ENV?{name:u,styles:o,map:i,next:Ys,toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}:{name:u,styles:o,next:Ys}},Ws=!!C.useInsertionEffect&&C.useInsertionEffect||function(e){return e()},Vs={}.hasOwnProperty,$s=C.createContext("undefined"!=typeof HTMLElement?ws({key:"css"}):null);"production"!==ue.env.NODE_ENV&&($s.displayName="EmotionCacheContext");var Xs=function(e){return u.forwardRef((function(t,n){var r=u.useContext($s);return e(t,r,n)}))},Zs=C.createContext({});"production"!==ue.env.NODE_ENV&&(Zs.displayName="EmotionThemeContext");var ec="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",tc="__EMOTION_LABEL_PLEASE_DO_NOT_USE__",nc=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return Ss(t,n,r),Ws((function(){return Bs(t,n,r)})),null},rc=Xs((function(e,t,n){var r=e.css;"string"==typeof r&&void 0!==t.registered[r]&&(r=t.registered[r]);var o=e[ec],i=[r],a="";"string"==typeof e.className?a=xs(t.registered,i,e.className):null!=e.className&&(a=e.className+" ");var s=Ks(i,void 0,C.useContext(Zs));if("production"!==ue.env.NODE_ENV&&-1===s.name.indexOf("-")){var c=e[tc];c&&(s=Ks([s,"label:"+c+";"]))}a+=t.key+"-"+s.name;var l={};for(var u in e)!Vs.call(e,u)||"css"===u||u===ec||"production"!==ue.env.NODE_ENV&&u===tc||(l[u]=e[u]);return l.ref=n,l.className=a,C.createElement(C.Fragment,null,C.createElement(nc,{cache:t,serialized:s,isStringTag:"string"==typeof o}),C.createElement(o,l))}));"production"!==ue.env.NODE_ENV&&(rc.displayName="EmotionCssPropInternal");var oc={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function ic(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ac=/[A-Z]|^ms/g,sc=/_EMO_([^_]+?)_([^]*?)_EMO_/g,cc=function(e){return 45===e.charCodeAt(1)},lc=function(e){return null!=e&&"boolean"!=typeof e},uc=ic((function(e){return cc(e)?e:e.replace(ac,"-$&").toLowerCase()})),dc=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(sc,(function(e,t,n){return fc={name:t,styles:n,next:fc},t}))}return 1===oc[e]||cc(e)||"number"!=typeof t||0===t?t:t+"px"};function Ac(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(X(n)){case"boolean":return"";case"object":if(1===n.anim)return fc={name:n.name,styles:n.styles,next:fc},n.name;var r=n;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)fc={name:o.name,styles:o.styles,next:fc},o=o.next;return r.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=Ac(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==X(a)){var s=a;null!=t&&void 0!==t[s]?r+=i+"{"+t[s]+"}":lc(s)&&(r+=uc(i)+":"+dc(i,s)+";")}else if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var c=Ac(e,t,a);switch(i){case"animation":case"animationName":r+=uc(i)+":"+c+";";break;default:r+=i+"{"+c+"}"}}else for(var l=0;l<a.length;l++)lc(a[l])&&(r+=uc(i)+":"+dc(i,a[l])+";")}return r}(e,t,n)}if(null==t)return n;var i=t[n];return void 0!==i?i:n}var fc,hc=/label:\s*([^\s;{]+)\s*(;|$)/g,gc=function(e){for(var t=e.length,n=0,r="";n<t;n++){var o=e[n];if(null!=o){var i=void 0;switch(X(o)){case"boolean":break;case"object":if(Array.isArray(o))i=gc(o);else{var a=o;for(var s in i="",a)a[s]&&s&&(i&&(i+=" "),i+=s)}break;default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},pc=function(){return{createCssAndCx:function(e){var t=e.cache,n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var o=function(e,t,n){if(1===e.length&&"object"===X(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";fc=void 0;var i=e[0];null==i||void 0===i.raw?(r=!1,o+=Ac(n,t,i)):o+=i[0];for(var a=1;a<e.length;a++)o+=Ac(n,t,e[a]),r&&(o+=i[a]);hc.lastIndex=0;for(var s,c="";null!==(s=hc.exec(o));)c+="-"+s[1];var l=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+c;return{name:l,styles:o,next:fc}}(n,t.registered);!function(e,t,n){!function(e,t,n){var r=e.key+"-"+t.name;void 0===e.registered[r]&&(e.registered[r]=t.styles)}(e,t);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}}(t,o);var i="".concat(t.key,"-").concat(o.name),a=n[0];return function(e){return e instanceof Object&&!("styles"in e)&&!("length"in e)&&!("__emotion_styles"in e)}(a)&&yc.saveClassNameCSSObjectMapping(t,i,a),i};return{css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=gc(r),a=yc.fixClassName(t,i,n);return function(e,t,n){var r=[],o=function(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(r+=n+" ")})),r}(e,r,n);return r.length<2?n:o+t(r)}(t.registered,n,a)}}}}}(),mc=pc.createCssAndCx,yc=function(){var e=new WeakMap;return{saveClassNameCSSObjectMapping:function(t,n,r){var o=e.get(t);void 0===o&&(o=new Map,e.set(t,o)),o.set(n,r)},fixClassName:function(t,n,r){if(!n.includes(" "))return n;var o,i,a=e.get(t);return gc((o=n.split(" ").map((function(e){return[e,null==a?void 0:a.get(e)]})),i=!1,o.map((function(e){var t,n=K(e,2),r=n[0],o=n[1];if(void 0===o)return r;if(i)t={"&&":o};else for(var a in t=r,o)if(a.startsWith("@media")){i=!0;break}return t}))).map((function(e){return"string"==typeof e?e:r(e)})))}}}(),_c=function(){return u.useContext($s)};function vc(e){var t=e.useTheme,n=function(e){var t=e.useCache;return{useCssAndCx:function(){var e=t(),n=u.useMemo((function(){return mc({cache:e})}),[e]);return{css:n.css,cx:n.cx}}}}({useCache:_c}),r=n.useCssAndCx;return{makeStyles:function(){return function(e){var n="function"==typeof e?e:function(){return e};return function(e,o){var i=t(),a=r(),s=a.css,c=a.cx,l=u.useMemo((function(){for(var e=n(i),t={},r=0,o=Object.keys(e);r<o.length;r++){var a=o[r];t[a]=s(e[a])}return t}),[s,i]),d=null==o?void 0:o.props.classes,A=function(e){if(!(e instanceof Object)||"function"==typeof e)return e;var t=[];for(var n in e){var r=e[n],o=X(r);if("string"!==o&&("number"!==o||isNaN(r))&&"boolean"!==o&&null!=r)return e;t.push("".concat(n,":").concat(o,"_").concat(r))}return"xSqLiJdLMd9s".concat(t.join("|"))}(d),f=u.useMemo((function(){return d?function(e,t,n){if(!(t instanceof Object))return e;var r=Object.keys(t);if(0===r.length)return e;for(var o={},i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];o[s]=n(e[s],t[s])}for(var c=0,l=r;c<l.length;c++){var u=l[c];if(!(u in e)){var d=t[u];"string"==typeof d&&(o[u]=d)}}return o}(l,d,c):l}),[l,A,c]);return{classes:f,theme:i,css:s,cx:c}}}}}}var bc,Cc,Ic,wc,Ec=vc({useTheme:h.useTheme}).makeStyles,xc=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),Sc=a.createSvgIcon(i.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link"),Bc=a.createSvgIcon(i.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),kc=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonUnchecked"),Qc={},Nc={},Rc={},Dc={};function Fc(){if(bc)return Dc;function e(e){return decodeURIComponent(e)}function t(e,t){return String(t).replaceAll(e,(function(e){return encodeURIComponent(e).toUpperCase()}))}function n(e){return t(/[\n;\r\t=%&,\u0000-\u001f\u007f]/g,e)}function r(e){return t(/[\n\r\t%\u0000-\u001f\u007f]/g,e)}function o(t){if(null==t||!t.length||"."===t)return{};var n={};return t.replace(/\r\n|[\r\n]$/,"").split(";").forEach((function(t){var r,o,i=t.split("=",2);if(null!==(r=i[1])&&void 0!==r&&r.length){i[0]=i[0].trim();var a=n[i[0].trim()];a||(n[i[0]]=a=[]),(o=a).push.apply(o,V(i[1].split(",").map((function(e){return e.trim()})).map(e)))}})),n}function i(e){var t=[];return Object.entries(e).forEach((function(e){var r=K(e,2),o=r[0],i=r[1].map(n).join(",");t.push("".concat(n(o),"=").concat(i))})),t.length?t.join(";"):"."}function a(e,t){var n=null==e.attributes?".":i(e.attributes),o=[null===e.seq_id?".":r(e.seq_id),null===e.source?".":r(e.source),null===e.type?".":r(e.type),null===e.start?".":r(e.start),null===e.end?".":r(e.end),null===e.score?".":r(e.score),null===e.strand?".":r(e.strand),null===e.phase?".":r(e.phase),n],a="".concat(o.join("\t"),"\n");return t[a]?"":(t[a]=!0,a)}function s(e,t){if(Array.isArray(e))return e.map((function(e){return s(e,t)})).join("");var n,r=[a(e,t)];return void 0!==(n=e).child_features&&void 0!==n.derived_features&&r.push.apply(r,V(e.child_features.map((function(e){return s(e,t)}))).concat(V(e.derived_features.map((function(e){return s(e,t)}))))),r.join("")}function c(e){return s(e,{})}function l(e){var t="##".concat(e.directive);return e.value&&(t+=" ".concat(e.value)),t+"\n"}function u(e){return"# ".concat(e.comment,"\n")}function d(e){for(var t=">".concat(e.id).concat(e.description?" ".concat(e.description):"","\n"),n=Math.ceil(e.sequence.length/80),r=new Array(n),o=0;o<n;o+=1){var i=80*o;r[o]=e.sequence.slice(i,i+80)}return"".concat(t).concat(r.join("\n"),"\n")}function A(e){return"attributes"in e?c(e):"directive"in e?l(e):"sequence"in e?d(e):"comment"in e?u(e):"# (invalid item found during format)\n"}return bc=1,Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.unescape=e,Dc.escape=n,Dc.escapeColumn=r,Dc.parseAttributes=o,Dc.parseFeature=function(t){var n=t.trim().split("\t").map((function(e){return"."===e||""===e?null:e}));return{seq_id:n[0]&&e(n[0]),source:n[1]&&e(n[1]),type:n[2]&&e(n[2]),start:null===n[3]?null:parseInt(n[3],10),end:null===n[4]?null:parseInt(n[4],10),score:null===n[5]?null:parseFloat(n[5]),strand:n[6],phase:n[7],attributes:null===n[8]?null:o(n[8])}},Dc.parseDirective=function(e){var t=/^\s*##\s*(\S+)\s*(.*)/.exec(e);if(!t)return null;var n=K(t,2)[1],r=K(t,3)[2],o={directive:n};if(r.length&&(r=r.replace(/\r\n|[\r\n]$/,""),o.value=r),"sequence-region"===n){var i,a,s=r.split(/\s+/,3);return q(q({},o),{},{seq_id:s[0],start:null===(i=s[1])||void 0===i?void 0:i.replaceAll(/\D/g,""),end:null===(a=s[2])||void 0===a?void 0:a.replaceAll(/\D/g,"")})}if("genome-build"===n){var c=K(r.split(/\s+/,2),2),l=c[0],u=c[1];return q(q({},o),{},{source:l,buildName:u})}return o},Dc.formatAttributes=i,Dc.formatFeature=c,Dc.formatDirective=l,Dc.formatComment=u,Dc.formatSequence=d,Dc.formatItem=function(e){return Array.isArray(e)?e.map(A):A(e)},Dc}function Tc(){if(Ic)return Nc;Ic=1,Object.defineProperty(Nc,"__esModule",{value:!0}),Nc.GFFFormattingTransformer=Nc.GFFTransformer=void 0,Nc.parseStringSync=function(t,r){if(!t)return[];var o=n(null!=r?r:{}),i=[],a=i.push.bind(i),s={errorCallback:o.errorCallback};o.parseFeatures&&(s.featureCallback=a),o.parseDirectives&&(s.directiveCallback=a),o.parseComments&&(s.commentCallback=a),o.parseSequences&&(s.sequenceCallback=a);var c=new e.GFF3Parser({disableDerivesFromReferences:o.disableDerivesFromReferences||!1,bufferSize:Infinity});return t.split(/\r\n|[\r\n]/).forEach((function(e){return c.addLine.bind(c)(e,s)})),c.finish(s),i},Nc.formatSync=function(e){var n=[],r=[];e.forEach((function(e){"sequence"in e?r.push(e):n.push(e)}));var o=n.map((function(e){return Array.isArray(e)?(0,t.formatItem)(e).join(""):(0,t.formatItem)(e)})).join("");return r.length&&(o+="##FASTA\n",o+=r.map(t.formatSequence).join("")),o};var e=function(){if(Cc)return Rc;Cc=1,Object.defineProperty(Rc,"__esModule",{value:!0}),Rc.GFF3Parser=Rc.FASTAParser=void 0;var e=Fc(),t=function(){return D((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};N(this,e),T(this,"seqCallback",void 0),T(this,"currentSequence",void 0),this.seqCallback=t,this.currentSequence=void 0}),[{key:"addLine",value:function(e){var t=/^>\s*(\S+)\s*(.*)/.exec(e);t?(this.flush(),this.currentSequence={id:t[1],sequence:""},t[2]&&(this.currentSequence.description=t[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replaceAll(/\s/g,""))}},{key:"flush",value:function(){this.currentSequence&&this.seqCallback(this.currentSequence)}},{key:"finish",value:function(){this.flush()}}])}();Rc.FASTAParser=t;var n=function(){return D((function e(t){N(this,e),T(this,"endCallback",void 0),T(this,"disableDerivesFromReferences",void 0),T(this,"bufferSize",void 0),T(this,"fastaParser",void 0),T(this,"eof",!1),T(this,"lineNumber",0),T(this,"underConstructionTopLevel",[]),T(this,"underConstructionById",{}),T(this,"completedReferences",{}),T(this,"underConstructionOrphans",new Map),this.endCallback=t.endCallback||function(){},this.disableDerivesFromReferences=t.disableDerivesFromReferences||!1,this.bufferSize=void 0===t.bufferSize?Infinity:t.bufferSize}),[{key:"addLine",value:function(n,r){if(this.fastaParser)this.fastaParser.addLine(n);else if(!this.eof)if(this.lineNumber+=1,/^\s*[^#\s>]/.test(n))this.bufferLine(n,r);else{var o=/^\s*(#+)(.*)/.exec(n);if(o){var i=K(o,2)[1],a=K(o,3)[2];if(3===i.length)this.emitAllUnderConstructionFeatures(r);else if(2===i.length){var s=(0,e.parseDirective)(n);s&&("FASTA"===s.directive?(this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback)):this.emitItem(s,r))}else a=a.replace(/\s*/,""),this.emitItem({comment:a},r)}else if(/^\s*$/.test(n));else if(/^\s*>/.test(n))this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback),this.fastaParser.addLine(n);else{var c=n.replaceAll(/\r\n|[\r\n]$/g,"");this.parseError("GFF3 parse error. Cannot parse '".concat(c,"'."),r)}}}},{key:"finish",value:function(e){this.emitAllUnderConstructionFeatures(e),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}},{key:"emitItem",value:function(e,t){Array.isArray(e)&&t.featureCallback?t.featureCallback(e):"directive"in e&&t.directiveCallback?t.directiveCallback(e):"comment"in e&&t.commentCallback&&t.commentCallback(e)}},{key:"enforceBufferSizeLimit",value:function(){for(var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1?arguments[1]:void 0,r=function(t){var n;t&&Array.isArray(t)&&null!==(n=t[0].attributes)&&void 0!==n&&null!==(n=n.ID)&&void 0!==n&&n[0]&&(t[0].attributes.ID.forEach((function(t){delete e.underConstructionById[t],delete e.completedReferences[t]})),t.forEach((function(e){e.child_features&&e.child_features.forEach((function(e){return r(e)})),e.derived_features&&e.derived_features.forEach((function(e){return r(e)}))})))};this.underConstructionTopLevel.length+t>this.bufferSize;){var o=this.underConstructionTopLevel.shift();o&&(this.emitItem(o,n),r(o))}}},{key:"emitAllUnderConstructionFeatures",value:function(e){var t=this;this.underConstructionTopLevel.forEach((function(n){return t.emitItem.bind(t)(n,e)})),this.underConstructionTopLevel=[],this.underConstructionById={},this.completedReferences={},this.underConstructionOrphans.size&&this.parseError("some features reference other features that do not exist in the file (or in the same '###' scope). ".concat(Array.from(this.underConstructionOrphans.keys()).join(",")),e)}},{key:"bufferLine",value:function(t,n){var r,o,i,a=this,s=q(q({},(0,e.parseFeature)(t)),{},{child_features:[],derived_features:[]}),c=(null===(r=s.attributes)||void 0===r?void 0:r.ID)||[],l=(null===(o=s.attributes)||void 0===o?void 0:o.Parent)||[],u=this.disableDerivesFromReferences?[]:(null===(i=s.attributes)||void 0===i?void 0:i.Derives_from)||[];if(c.length||l.length||u.length){var d=void 0;c.forEach((function(e){var t=a.underConstructionById[e];t?(t[t.length-1].type!==s.type&&a.parseError('multi-line feature "'.concat(e,'" has inconsistent types: "').concat(s.type,'", "').concat(t[t.length-1].type,'"'),n),t.push(s),d=t):(d=[s],a.enforceBufferSizeLimit(1,n),l.length||u.length||a.underConstructionTopLevel.push(d),a.underConstructionById[e]=d,a.resolveReferencesTo(d,e))})),this.resolveReferencesFrom(d||[s],{Parent:l,Derives_from:u},c)}else this.emitItem([s],n)}},{key:"resolveReferencesTo",value:function(e,t){var n=this.underConstructionOrphans.get(t);n&&(e.forEach((function(e){var t;(t=e.child_features).push.apply(t,V(n.Parent))})),e.forEach((function(e){var t;(t=e.derived_features).push.apply(t,V(n.Derives_from))})),this.underConstructionOrphans.delete(t))}},{key:"parseError",value:function(e,t){var n;this.eof=!0,null===(n=t.errorCallback)||void 0===n||n.call(t,"".concat(this.lineNumber,": ").concat(e))}},{key:"postSet",value:function(e,t,n){var r=e[t];r||(e[t]=r={});var o=r[n]||!1;return r[n]=!0,o}},{key:"resolveReferencesFrom",value:function(e,t,n){var r=this;t.Parent.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Parent,".concat(t))})).length||o.forEach((function(t){t.child_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Parent.push(e)}})),t.Derives_from.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Derives_from,".concat(t))})).length||o.forEach((function(t){t.derived_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Derives_from.push(e)}}))}}])}();return Rc.GFF3Parser=n,Rc}(),t=Fc();function n(e){return q({parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:Infinity,disableDerivesFromReferences:!1,errorCallback:function(e){throw new Error(e)}},e)}Nc.GFFTransformer=function(){return D((function t(r){N(this,t),T(this,"decoder",void 0),T(this,"parser",void 0),T(this,"lastString",""),T(this,"parseFeatures",void 0),T(this,"parseDirectives",void 0),T(this,"parseComments",void 0),T(this,"parseSequences",void 0),this.decoder=new TextDecoder;var o=n(null!=r?r:{});this.parser=new e.GFF3Parser({bufferSize:o.bufferSize,disableDerivesFromReferences:o.disableDerivesFromReferences}),this.parseFeatures=o.parseFeatures,this.parseDirectives=o.parseDirectives,this.parseComments=o.parseComments,this.parseSequences=o.parseSequences,this.errorCallback=null==r?void 0:r.errorCallback}),[{key:"makeCallbacks",value:function(e){var t={errorCallback:this.emitErrorMessage.bind(this,e)};return this.parseFeatures&&(t.featureCallback=function(t){e.enqueue(t)}),this.parseDirectives&&(t.directiveCallback=function(t){e.enqueue(t)}),this.parseComments&&(t.commentCallback=function(t){e.enqueue(t)}),this.parseSequences&&(t.sequenceCallback=function(t){e.enqueue(t)}),t}},{key:"emitErrorMessage",value:function(e,t){this.errorCallback?this.errorCallback(t):e.error(t)}},{key:"transform",value:function(e,t){var n="".concat(this.lastString).concat(this.decoder.decode(e,{stream:!0})).split(/\r\n|[\r\n]/g);this.lastString=n.pop()||"";var r,o=F(n);try{for(o.s();!(r=o.n()).done;)this.parser.addLine(r.value,this.makeCallbacks(t))}catch(e){o.e(e)}finally{o.f()}}},{key:"flush",value:function(e){var t=this.makeCallbacks(e);this.lastString="".concat(this.lastString).concat(this.decoder.decode()),this.lastString&&(this.parser.addLine(this.lastString,t),this.lastString=""),this.parser.finish(t)}}])}();var r=function(){return D((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N(this,e),T(this,"linesSinceLastSyncMark",0),T(this,"haveWeEmittedData",!1),T(this,"fastaMode",!1),T(this,"minLinesBetweenSyncMarks",void 0),T(this,"insertVersionDirective",void 0),this.minLinesBetweenSyncMarks=t.minSyncLines||100,this.insertVersionDirective=!1!==t.insertVersionDirective}),[{key:"transform",value:function(e,n){!this.haveWeEmittedData&&this.insertVersionDirective&&(!("directive"in e)||"directive"in e&&"gff-version"!==e.directive)&&n.enqueue("##gff-version 3\n"),"sequence"in e&&!this.fastaMode&&(n.enqueue("##FASTA\n"),this.fastaMode=!0);var r=Array.isArray(e)?e.map((function(e){return(0,t.formatItem)(e)})).join(""):(0,t.formatItem)(e);if(n.enqueue(r),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)n.enqueue("###\n"),this.linesSinceLastSyncMark=0;else{for(var o=0,i=0;i<r.length;i+=1)"\n"===r[i]&&(o+=1);this.linesSinceLastSyncMark+=o}this.haveWeEmittedData=!0}}])}();return Nc.GFFFormattingTransformer=r,Nc}var jc=(wc||(wc=1,function(e){var t,n=Qc&&Qc.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=Qc&&Qc.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=Qc&&Qc.__importStar||(t=function(e){return t=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},t(e)},function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var i=t(e),a=0;a<i.length;a++)"default"!==i[a]&&n(o,e,i[a]);return r(o,e),o}),i=Qc&&Qc.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.util=e.defaultExport=void 0;var a=o(Tc());i(Tc(),e);var s=o(Fc());e.defaultExport=q(q({},a),{},{util:s}),e.default=e.defaultExport,e.util=o(Fc())}(Qc)),Qc);async function Mc(e,t,n){const r=jc.parseStringSync(t,{parseSequences:!0,parseComments:!0,parseDirectives:!1,parseFeatures:!0});if(0===r.length)throw new Error("No features found in GFF3 file");let o=0,i=n.assemblies.get(e);i||(i=n.addAssembly(e,"InMemoryFileDriver"));for(const e of r)if(Array.isArray(e)){const t=It(e),n=i.refSeqs.get(t.refSeq)??i.addRefSeq(t.refSeq,t.refSeq);n.features.has(t._id)||n.addFeature(t)}else if("comment"in e)i.addComment(e.comment);else{o++;let t=i.refSeqs.get(e.id);t||(t=i.addRefSeq(e.id,e.id,e.description)),e.description&&!t.description&&t.setDescription(e.description),t.addSequence({start:0,stop:e.sequence.length,sequence:e.sequence})}if(0===o)throw new Error("No embedded FASTA section found in GFF3");const a=await Oc(i);return n.addCheckResults(a),i}async function Oc(e){const t=[];for(const n of e.refSeqs.values())for(const e of n.features.values())for(const r of ae.getChecks().values()){const o=await r.checkFeature(c.getSnapshot(e),((e,t)=>Promise.resolve(n.getSequence(e,t))));t.push(...o)}return t}function Lc(e){const{attributes:t}=e,n=t.get("gff_name");return n?n[0]:""}function Pc(e){const{attributes:t}=e,n=t.get("gff_id"),r=t.get("transcript_id"),o=t.get("exon_id"),i=t.get("protein_id");return n?n[0]:r?r[0]:o?o[0]:i?i[0]:""}function qc(e){const t=Lc(e),n=Pc(e);return t?`: ${t}`:n?`: ${n}`:""}function Jc(e,t,n=!1){const r=[];r.push(e);for(const t of function(e){const t=[];let{parent:n}=e;for(;n;)t.push(n),({parent:n}=n);return t}(e))r.push(t);const o=function(e){const t=[];if(e.children)for(const[,n]of e.children)t.push(n);return t}(e);for(const e of o)e.min<t&&e.max>=t&&r.push(e);if(!n)return r;if(e.parent){const n=e.parent.children;if(n)for(const[,o]of n)o._id!=e._id&&o.min<t&&o.max>=t&&r.push(o)}return r}var Uc=a.createSvgIcon(i.jsx("path",{d:"m7.58 16.89 5.77-4.07c.56-.4.56-1.24 0-1.63L7.58 7.11C6.91 6.65 6 7.12 6 7.93v8.14c0 .81.91 1.28 1.58.82M16 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1"}),"SkipNextRounded"),Gc=a.createSvgIcon(i.jsx("path",{d:"M7 6c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1s-1-.45-1-1V7c0-.55.45-1 1-1m3.66 6.82 5.77 4.07c.66.47 1.58-.01 1.58-.82V7.93c0-.81-.91-1.28-1.58-.82l-5.77 4.07c-.57.4-.57 1.24 0 1.64"}),"SkipPreviousRounded");function Hc(e,t){if(e.apolloDragging)return;e.setSelectedFeature(t);const{session:n}=e,{apolloDataStore:r}=n,{featureTypeOntology:o}=r.ontologyManager;if(!o)throw new Error("featureTypeOntology is undefined");let i=!1;for(const[,e]of t.children??[])if(o.isTypeOf(e.type,"CDS")||o.isTypeOf(e.type,"exon")){i=!0;break}(o.isTypeOf(t.type,"transcript")||o.isTypeOf(t.type,"pseudogenic_transcript"))&&i?e.showFeatureDetailsWidget(t,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(t)}function Yc(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")}function zc(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"exon")}function Kc(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"CDS")}function Wc(e,t,n,r){const i=o.getContainingView(t),a=n.bp-i.bpPerPx*n.x,s=a+i.coarseTotalBp;if(!e.parent)return{upstream:void 0,downstream:void 0};const c=e.parent;if(!c.children)throw new Error(`Error getting children of ${c._id}`);const{featureTypeOntology:l}=r.apolloDataStore.ontologyManager;if(!l)throw new Error("featureTypeOntology is undefined");let u=[];for(const[,e]of c.children)l.isTypeOf(e.type,"exon")&&u.push(e);const d={upstream:void 0,downstream:void 0};u=u.sort(((e,t)=>e.min<t.min?-1:1));for(const e of u)if(e.min>s){d.downstream=e;break}u=u.sort(((e,t)=>e.min>t.min?-1:1));for(const e of u)if(e.max<a){d.upstream=e;break}if(-1===c.strand){const e=d.downstream;d.downstream=d.upstream,d.upstream=e}return d}function Vc(e,t,n){let r=Uc;return-1===e&&(r=Gc),t&&(r=r===Gc?Uc:Gc),n&&(r=r===Gc?Uc:Gc),r}function $c(e,t,n,r){const o=r.bpToPx({refName:t,coord:e.min,regionNumber:n}),i=r.bpToPx({refName:t,coord:e.max,regionNumber:n});if(void 0===o||void 0===i)return;const{offsetPx:a}=r;return[o.offsetPx-a,i.offsetPx-a]}function Xc(e,t,n){const[r,o]=n;if(!(Math.abs(o-r)<8))return Math.abs(r-t)<4?{feature:e,edge:"min"}:Math.abs(o-t)<4?{feature:e,edge:"max"}:void 0}function Zc(e,t){return Boolean(t&&e._id===t._id)}function el(e,t){return!!t&&(e._id===t._id||e.hasDescendant(t._id))}function tl(e){let t;t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id;const n=`(${(e.min+1).toLocaleString("en")}..${e.max.toLocaleString("en")})`;if(t&&t.length+n.length>65){const e=60-n.length;t=e>0?t.slice(0,e):"",t=`${t}[...]`}return`${t} ${n}`}function nl(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,c=[],l=n?n.role:"admin",u="admin"===l,d=!(l&&["admin","user"].includes(l)),[A]=i,f=e.getAssemblyId(A.assemblyName),h=e.getAssemblyId(A.assemblyName);return c.push({label:tl(t),type:"subHeader"},{label:"Add child feature",disabled:d,onClick:()=>{s.queueDialog((e=>[Bu,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:f,internetAccount:n}]))}},{label:"Copy features and annotations",disabled:d,onClick:()=>{s.queueDialog((e=>[Ou,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}},{label:"Delete feature",disabled:!u,onClick:()=>{s.queueDialog((n=>[Pu,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:h,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),o.isSessionModelWithWidgets(s)&&c.push({label:"Open feature details",onClick:()=>{const e=s.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:t,assembly:h,refName:A.refName});s.showWidget(e)}}),c}function rl(e,t,n){const r=(e.max-e.min)*t,o=Math.max(e.min-r,1),i=Math.min(e.max+r,n);return{refName:e.refSeq,start:o,end:i}}function ol(e,t,n){const r=[{featureId:e._id,oldLocation:e[n],newLocation:t}],{parent:o}=e;return o&&("min"===n&&o[n]>t||"max"===n&&o[n]<t)&&r.push(...ol(o,t,n)),r}function il(e,t,n,r,o){const i=e._id,a=[{featureId:i,oldLocation:e[n],newLocation:t}],{parent:s,children:c}=e;if(c)for(const[,e]of c)e._id!==o&&("min"===n&&e[n]<t||"max"===n&&e[n]>t)&&a.push(...il(e,t,n,r));if(s&&r){const e=[];if(s.children)for(const[,t]of s.children)t._id!==i&&e.push(t);if(0===e.length)a.push(...il(s,t,n,r,i));else{const o=s[n],c=Math[n](...e.map((e=>e[n])),t);c!==o&&a.push(...il(s,c,n,r,i))}}return a}function al(e,t,n,r=!1){const o=e[n];if(t===o)throw new Error(`New and existing locations are the same: "${t}"`);return"min"===n?t>o?il(e,t,n,r):ol(e,t,n):t<o?il(e,t,n,r):ol(e,t,n)}function sl(e){return"feature"in e}function cl(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,c=o-a,{coord:l,index:u,refName:d}=t.pxToBp(s);return{x:s,y:c,refName:d,bp:l,regionNumber:u}}async function ll(e,t){let n;try{n=await e.text()}catch{n=""}return`${t?`${t} — `:""}${e.status} ${e.statusText}${n?` (${n})`:""}`}var ul=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");const dl=Ec()((e=>({dialogTitle:{background:e.palette.primary.main,color:e.palette.primary.contrastText,padding:e.spacing(2)},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1.5),color:e.palette.primary.contrastText}}))),Al=f.observer((function(e){const{classes:t}=dl(),{handleClose:n,title:r,...o}=e;return i.jsx(A.Dialog,{...o,header:i.jsxs(i.Fragment,{children:[i.jsx(s.DialogTitle,{className:t.dialogTitle,children:r}),i.jsx(s.IconButton,{"aria-label":"close",onClick:n,className:t.closeButton,children:i.jsx(ul,{})})]})})}));var fl;!function(e){e.GFF3="text/x-gff3",e.FASTA="text/x-fasta",e.BGZIP_FASTA="application/x-bgzip-fasta",e.FAI="text/x-fai",e.GZI="application/x-gzi",e.EXTERNAL="text/x-external"}(fl||(fl={}));const hl=Ec()((e=>({accordion:{border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{borderBottom:0}},accordionSummary:{flexDirection:"row-reverse"},accordionDetails:{padding:e.spacing(2),borderTop:"1px solid rgba(0, 0, 0, .125)"},radioIcon:{color:e.palette.tertiary.contrastText},dialog:{minWidth:550,maxWidth:800}})));function gl(e,t,n,r,o,i,a,s,c){return!(!e||!(t&&r||n===fl.GFF3&&r||r&&o&&i||a&&s&&c))}function pl({changeManager:e,handleClose:t,session:r}){const{classes:o}=hl(),{internetAccounts:a}=c.getRoot(r),{notify:l}=r,d=a.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[A,f]=u.useState(""),[h,g]=u.useState(""),[p,m]=u.useState(!1),[y,_]=u.useState(fl.BGZIP_FASTA),[v,b]=u.useState(!0),[C,I]=u.useState(!1),[w,E]=u.useState(!1),[x,S]=u.useState(!0),[B,k]=u.useState(null),[Q,N]=u.useState(null),[R,D]=u.useState(null),[F,T]=u.useState(""),[j,M]=u.useState(""),[O,L]=u.useState(""),[P,q]=u.useState(!1),[J,U]=u.useState(!1),[G,H]=u.useState(!1);async function Y(e,t){const{jobsManager:n}=r,o=new AbortController,[{baseURL:i,getFetcher:a}]=d,s=new URL("files",i);s.searchParams.set("type",t);const c=s.href,l=new FormData;let u=e.name;const f=t===fl.BGZIP_FASTA||t===fl.FASTA&&(!C||J)||t===fl.GFF3&&G;f&&!e.name.toLocaleLowerCase().endsWith(".gz")?u=`${u}.gz`:!f&&e.name.toLocaleLowerCase().endsWith(".gz")&&(u=`${u}.txt`),l.append("file",e,u),l.append("type",t);const h=a({locationType:"UriLocation",uri:c}),p={name:`UploadAssemblyFile for ${A}`,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{o.abort(new DOMException(`Canceling adding of assembly "${A}"`,"AbortError")),n.abortJob(p.name)}};n.runJob(p),n.update(p.name,`Uploading ${e.name}, this may take awhile`);const{signal:m}=o,y=await h(c,{method:"POST",body:l,signal:m});if(!y.ok){const e=await ll(y,"Error when inserting new assembly (while uploading file)");return n.abortJob(p.name,e),g(e),""}const _=(await y.json())._id;return n.done(p),_}let z=!1;try{const e=new URL(F);"http:"!==e.protocol&&"https:"!==e.protocol||(z=!0)}catch{}let K=!1;try{const e=new URL(j);"http:"!==e.protocol&&"https:"!==e.protocol||(K=!0)}catch{}let W=!1;try{const e=new URL(O);"http:"!==e.protocol&&"https:"!==e.protocol||(W=!0)}catch{}const[V,$]=u.useState("panelFastaInput"),X=e=>(t,n)=>{n&&$(e)};return i.jsxs(Al,{open:!0,handleClose:t,"data-testid":"add-assembly-dialog",title:"Add new assembly",maxWidth:!1,children:[i.jsxs("form",{onSubmit:async function(n){let r;if(n.preventDefault(),g(""),E(!0),q(!0),l(`Assembly "${A}" is being added`,"info"),t(),n.preventDefault(),y===fl.EXTERNAL)r=new Sr({typeName:"AddAssemblyFromExternalChange",assembly:(new ut).toHexString(),assemblyName:A,externalLocation:{fa:F,fai:j,gzi:O}});else{if(!B)throw new Error("Missing fasta file");if(y===fl.GFF3&&v){const e=await Y(B,fl.GFF3);r=new xt({typeName:"AddAssemblyAndFeaturesFromFileChange",assembly:(new ut).toHexString(),assemblyName:A,fileIds:{fa:e},parseOptions:{strict:x}})}else if(y===fl.GFF3){const e=await Y(B,fl.GFF3);r=new Br({typeName:"AddAssemblyFromFileChange",assembly:(new ut).toHexString(),assemblyName:A,fileIds:{fa:e}})}else if(C){const e=await Y(B,fl.FASTA);r=new Br({typeName:"AddAssemblyFromFileChange",assembly:(new ut).toHexString(),assemblyName:A,fileIds:{fa:e}})}else{if(!Q||!R)throw new Error("Missing fasta index files");const e=await Y(B,fl.BGZIP_FASTA),t=await Y(Q,fl.FAI),n=await Y(R,fl.GZI);r=new Br({typeName:"AddAssemblyFromFileChange",assembly:(new ut).toHexString(),assemblyName:A,fileIds:{fa:e,fai:t,gzi:n}})}}const[{internetAccountId:o}]=d;await e.submit(r,{internetAccountId:o,updateJobsManager:!0}),E(!1),q(!1)},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{className:o.dialog,children:[P?i.jsx(s.LinearProgress,{}):null,i.jsx(s.TextField,{margin:"dense",id:"name",label:"Assembly name",type:"TextField",fullWidth:!0,variant:"outlined",onChange:e=>{E(!1),f(e.target.value),function(e){const{assemblies:t}=r;t.find((t=>n.readConfObject(t,"displayName")===e))?(m(!1),g(`Assembly ${e} already exists.`)):(m(!0),g(""))}(e.target.value)},disabled:w&&!h}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelFastaInput"===V,onChange:X("panelFastaInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelFastaInput"===V?i.jsx(Bc,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(kc,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelFastaInputd-content",id:"panelFastaInputd-header",children:i.jsx(s.Typography,{component:"span",children:"FASTA input"})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.FormGroup,{children:[i.jsx(s.FormControlLabel,{"data-testid":"files-on-url-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{_(y===fl.EXTERNAL?fl.BGZIP_FASTA:fl.EXTERNAL),y===fl.EXTERNAL&&I(!1)},checked:y===fl.EXTERNAL,disabled:C&&y!==fl.GFF3}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Use external URLs",i.jsx(s.Tooltip,{title:"Use external URLs to provide FASTA and index files. Does not copy the files to the Apollo collaboration server, so ensure the URLs are stable.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"sequence-is-editable-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{I(!C)}}),checked:C,disabled:y===fl.EXTERNAL,label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Store sequence in database",i.jsx(s.Tooltip,{title:"Enables users to edit the genomic sequence, but comes with performance impacts. Use with care.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"fasta-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:!C||J,onChange:()=>{U(!C||!J)},disabled:!C}),label:"FASTA is gzip compressed"}),i.jsx(s.Table,y===fl.BGZIP_FASTA||y===fl.GFF3?{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:'Unless "Store sequence in database" enabled, FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent). Compression is optional for sequences stored in the database.',children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fasta-input-file",type:"file",onChange:e=>{const t=e.target.files?.item(0);t&&(k(t),t.name.endsWith(".gz")&&U(!0))},disabled:w&&!h})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fai-input-file",type:"file",onChange:e=>{N(e.target.files?.item(0)??null)},disabled:w&&!h||C})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"gzi-input-file",type:"file",onChange:e=>{D(e.target.files?.item(0)??null)},disabled:w&&!h||C})})]})]})}:{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:"Remote FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent)",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fasta-input-url",variant:"outlined",value:F,error:!z,onChange:e=>{const{value:t}=e.target;T(t),M(t?`${t}.fai`:""),L(t?`${t}.gzi`:"")},disabled:w&&!h,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(Sc,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fai-input-url",variant:"outlined",value:j,error:!K,onChange:e=>{M(e.target.value)},disabled:w&&!h,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(Sc,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"gzi-input-url",variant:"outlined",value:O,error:!W,onChange:e=>{L(e.target.value)},disabled:w&&!h,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(Sc,{})})}}})})]})]})})]})})]}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelGffInput"===V,onChange:X("panelGffInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelGffInput"===V?i.jsx(Bc,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(kc,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelGffInputd-content",children:i.jsxs(s.Typography,{component:"span",children:["GFF3 input",i.jsx(s.Tooltip,{title:"GFF3 must includes FASTA sequences. File can be gzip compressed.",children:i.jsx(xc,{className:o.radioIcon,sx:{fontSize:18}})})]})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.Box,{style:{marginTop:20},children:[i.jsx("input",{"data-testid":"gff3-input-file",type:"file",disabled:w&&!h,onChange:e=>{const t=e.target.files?.item(0);t&&(k(t),_(fl.GFF3),t.name.endsWith(".gz")&&H(!0))}}),i.jsxs(s.FormGroup,{style:{display:"grid"},children:[i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:v,onChange:()=>{b(!v)},disabled:w&&!h}),label:"Load features from GFF3 file"}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:!v||w&&!h,control:i.jsx(s.Checkbox,{checked:x,onChange:e=>{S(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),i.jsx(s.FormControlLabel,{"data-testid":"gff3-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:G,onChange:()=>{H(!G)},disabled:w&&!h}),label:"GFF3 is gzip compressed"})]})]})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!gl(p,C,y,B,Q,R,z,K,W)||w,variant:"contained",type:"submit","data-testid":"submit-button",children:w?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),h?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:h})}):null]})}const ml=[{field:"name",headerName:"Assembly Name",width:150,editable:!1},{field:"aliases",headerName:"Aliases",width:300,editable:!0}];function yl({changeManager:e,handleClose:t,session:n}){const{apolloDataStore:r}=n,{collaborationServerDriver:o}=r,a=o.getAssemblies().map((e=>({id:e.name,name:e.displayName,aliases:e.aliases.join(", ")}))),[c,l]=u.useState("");return i.jsxs(Al,{open:!0,title:"Add assembly aliases",handleClose:t,maxWidth:"sm","data-testid":"add-assembly-alias",fullWidth:!0,children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.Box,{sx:{height:400,width:"100%"},children:i.jsx(d.DataGrid,{rows:a,columns:ml,initialState:{pagination:{paginationModel:{pageSize:5}}},pageSizeOptions:[5],processRowUpdate:(n,r)=>{const o=new mt({typeName:"AddAssemblyAliasesChange",assembly:n.id,aliases:n.aliases.split(",")});return e.submit(o).catch((()=>{l("Error submitting change")})),t(),n},disableRowSelectionOnClick:!0})})}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}var _l,vl,bl=function(e,t){return t.some((function(t){return e instanceof t}))},Cl=new WeakMap,Il=new WeakMap,wl=new WeakMap,El=new WeakMap,xl=new WeakMap,Sl={get:function(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Il.get(e);if("objectStoreNames"===t)return e.objectStoreNames||wl.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return kl(e[t])},set:function(e,t,n){return e[t]=n,!0},has:function(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function Bl(e){Sl=e(Sl)}function kl(e){if(e instanceof IDBRequest)return t=e,(n=new Promise((function(e,n){var r=function(){t.removeEventListener("success",o),t.removeEventListener("error",i)},o=function(){e(kl(t.result)),r()},i=function(){n(t.error),r()};t.addEventListener("success",o),t.addEventListener("error",i)}))).then((function(e){e instanceof IDBCursor&&Cl.set(e,t)})).catch((function(){})),xl.set(n,t),n;var t,n;if(El.has(e))return El.get(e);var r=function(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(vl||(vl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(Ql(this),n),kl(Cl.get(this))}:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return kl(t.apply(Ql(this),n))}:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.call.apply(t,[Ql(this),e].concat(r));return wl.set(i,e.sort?e.sort():[e]),kl(i)}:(e instanceof IDBTransaction&&function(e){if(!Il.has(e)){var t=new Promise((function(t,n){var r=function(){e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=function(){t(),r()},i=function(){n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));Il.set(e,t)}}(e),bl(e,_l||(_l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Sl):e);var t}(e);return r!==e&&(El.set(e,r),xl.set(r,e)),r}var Ql=function(e){return xl.get(e)},Nl=["get","getKey","getAll","getAllKeys","count"],Rl=["put","add","delete","clear"],Dl=new Map;function Fl(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(Dl.get(t))return Dl.get(t);var n=t.replace(/FromIndex$/,""),r=t!==n,o=Rl.includes(n);if(n in(r?IDBIndex:IDBObjectStore).prototype&&(o||Nl.includes(n))){var i=function(){var e=B(U().m((function e(t){var i,a,s,c,l,u,d=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:for(a=this.transaction(t,o?"readwrite":"readonly"),s=a.store,c=d.length,l=new Array(c>1?c-1:0),u=1;u<c;u++)l[u-1]=d[u];return r&&(s=s.index(l.shift())),e.n=1,Promise.all([(i=s)[n].apply(i,l),o&&a.done]);case 1:return e.a(2,e.v[0])}}),e,this)})));return function(t){return e.apply(this,arguments)}}();return Dl.set(t,i),i}}}Bl((function(e){return q(q({},e),{},{get:function(t,n,r){return Fl(t,n)||e.get(t,n,r)},has:function(t,n){return!!Fl(t,n)||e.has(t,n)}})}));var Tl=["continue","continuePrimaryKey","advance"],jl={},Ml=new WeakMap,Ol=new WeakMap,Ll={get:function(e,t){if(!Tl.includes(t))return e[t];var n=jl[t];return n||(n=jl[t]=function(){var e;Ml.set(this,(e=Ol.get(this))[t].apply(e,arguments))}),n}};function Pl(){return ql.apply(this,arguments)}function ql(){return ql=function(e){return function(){return new ee(e.apply(this,arguments))}}(U().m((function e(){var t,n,r,o=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if((t=this)instanceof IDBCursor){e.n=2;break}return e.n=1,k((n=t).openCursor.apply(n,o));case 1:t=e.v;case 2:if(t){e.n=3;break}return e.a(2);case 3:r=new Proxy(t,Ll),Ol.set(r,t),xl.set(r,Ql(t));case 4:if(!t){e.n=7;break}return e.n=5,r;case 5:return e.n=6,k(Ml.get(r)||t.continue());case 6:t=e.v,Ml.delete(r),e.n=4;break;case 7:return e.a(2)}}),e,this)}))),ql.apply(this,arguments)}function Jl(e,t){return t===Symbol.asyncIterator&&bl(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&bl(e,[IDBIndex,IDBObjectStore])}Bl((function(e){return q(q({},e),{},{get:function(t,n,r){return Jl(t,n)?Pl:e.get(t,n,r)},has:function(t,n){return Jl(t,n)||e.has(t,n)}})}));var Ul=function(e){function t(){var e;N(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return T(e=Q(this,t,[].concat(r)),"code",void 0),e}return O(t,e),D(t)}(te(Error));function Gl(e){if(e){if(!(e instanceof AbortSignal))throw new TypeError("must pass an AbortSignal");if(e.aborted)throw function(){if("undefined"!=typeof DOMException)return new DOMException("aborted","AbortError");var e=new Ul("aborted");return e.code="ERR_ABORTED",e}()}}function Hl(e){return e instanceof Error&&("AbortError"===e.name||"ERR_ABORTED"===e.code||/\b(aborted|aborterror)\b/i.test(e.message))}function Yl(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zl,Kl={exports:{}},Wl=(zl||(zl=1,function(e,t){e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(!s&&Yl)return Yl(a);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return o(t[a][1][e]||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var i=Yl,a=0;a<r.length;a++)o(r[a]);return o}({"./aesprim":[function(e,t,n){var r;r=function(e){var t,n,r,o,i,a,s,c,l,u,d,A,f,h,g,p,m,y;function _(e,t){if(!e)throw new Error("ASSERT: "+t)}function v(e){return e>=48&&e<=57}function b(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function C(e){return"01234567".indexOf(e)>=0}function I(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function w(e){return 10===e||13===e||8232===e||8233===e}function E(e){return 64==e||36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&s.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function x(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&s.NonAsciiIdentifierPart.test(String.fromCharCode(e))}function S(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function B(e){return"eval"===e||"arguments"===e}function k(e){if(u&&S(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function Q(e,t,n,r,o){var i;_("number"==typeof n,"Comment must have valid position"),m.lastCommentStart>=n||(m.lastCommentStart=n,i={type:e,value:t},y.range&&(i.range=[n,r]),y.loc&&(i.loc=o),y.comments.push(i),y.attachComment&&(y.leadingComments.push(i),y.trailingComments.push(i)))}function N(e){var t,n,r,o;for(t=d-e,n={start:{line:A,column:d-f-e}};d<h;)if(r=l.charCodeAt(d),++d,w(r))return y.comments&&(o=l.slice(t+e,d-1),n.end={line:A,column:d-f-1},Q("Line",o,t,d-1,n)),13===r&&10===l.charCodeAt(d)&&++d,++A,void(f=d);y.comments&&(o=l.slice(t+e,d),n.end={line:A,column:d-f},Q("Line",o,t,d,n))}function R(){var e,t,n,r;for(y.comments&&(e=d-2,t={start:{line:A,column:d-f-2}});d<h;)if(w(n=l.charCodeAt(d)))13===n&&10===l.charCodeAt(d+1)&&++d,++A,++d,f=d,d>=h&&K({},a.UnexpectedToken,"ILLEGAL");else if(42===n){if(47===l.charCodeAt(d+1))return++d,++d,void(y.comments&&(r=l.slice(e+2,d-2),t.end={line:A,column:d-f},Q("Block",r,e,d,t)));++d}else++d;K({},a.UnexpectedToken,"ILLEGAL")}function D(){var e,t;for(t=0===d;d<h;)if(I(e=l.charCodeAt(d)))++d;else if(w(e))++d,13===e&&10===l.charCodeAt(d)&&++d,++A,f=d,t=!0;else if(47===e)if(47===(e=l.charCodeAt(d+1)))++d,++d,N(2),t=!0;else{if(42!==e)break;++d,++d,R()}else if(t&&45===e){if(45!==l.charCodeAt(d+1)||62!==l.charCodeAt(d+2))break;d+=3,N(3)}else{if(60!==e)break;if("!--"!==l.slice(d+1,d+4))break;++d,++d,++d,++d,N(4)}}function F(e){var t,n,r,o=0;for(n="u"===e?4:2,t=0;t<n;++t){if(!(d<h&&b(l[d])))return"";r=l[d++],o=16*o+"0123456789abcdef".indexOf(r.toLowerCase())}return String.fromCharCode(o)}function T(){var e,t;for(e=l.charCodeAt(d++),t=String.fromCharCode(e),92===e&&(117!==l.charCodeAt(d)&&K({},a.UnexpectedToken,"ILLEGAL"),++d,(e=F("u"))&&"\\"!==e&&E(e.charCodeAt(0))||K({},a.UnexpectedToken,"ILLEGAL"),t=e);d<h&&x(e=l.charCodeAt(d));)++d,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==l.charCodeAt(d)&&K({},a.UnexpectedToken,"ILLEGAL"),++d,(e=F("u"))&&"\\"!==e&&x(e.charCodeAt(0))||K({},a.UnexpectedToken,"ILLEGAL"),t+=e);return t}function j(){var e,t;for(e=d++;d<h;){if(92===(t=l.charCodeAt(d)))return d=e,T();if(!x(t))break;++d}return l.slice(e,d)}function M(){var e,n,r,o,i=d,s=l.charCodeAt(d),c=l[d];switch(s){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++d,y.tokenize&&(40===s?y.openParenToken=y.tokens.length:123===s&&(y.openCurlyToken=y.tokens.length)),{type:t.Punctuator,value:String.fromCharCode(s),lineNumber:A,lineStart:f,start:i,end:d};default:if(61===(e=l.charCodeAt(d+1)))switch(s){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return d+=2,{type:t.Punctuator,value:String.fromCharCode(s)+String.fromCharCode(e),lineNumber:A,lineStart:f,start:i,end:d};case 33:case 61:return 61===l.charCodeAt(d+=2)&&++d,{type:t.Punctuator,value:l.slice(i,d),lineNumber:A,lineStart:f,start:i,end:d}}}return">>>="===(o=l.substr(d,4))?{type:t.Punctuator,value:o,lineNumber:A,lineStart:f,start:i,end:d+=4}:">>>"===(r=o.substr(0,3))||"<<="===r||">>="===r?{type:t.Punctuator,value:r,lineNumber:A,lineStart:f,start:i,end:d+=3}:c===(n=r.substr(0,2))[1]&&"+-<>&|".indexOf(c)>=0||"=>"===n?{type:t.Punctuator,value:n,lineNumber:A,lineStart:f,start:i,end:d+=2}:"<>=!+-*%&|^/".indexOf(c)>=0?(++d,{type:t.Punctuator,value:c,lineNumber:A,lineStart:f,start:i,end:d}):void K({},a.UnexpectedToken,"ILLEGAL")}function O(){var e,n,r;if(_(v((r=l[d]).charCodeAt(0))||"."===r,"Numeric literal must start with a decimal digit or a decimal point"),n=d,e="","."!==r){if(e=l[d++],r=l[d],"0"===e){if("x"===r||"X"===r)return++d,function(e){for(var n="";d<h&&b(l[d]);)n+=l[d++];return 0===n.length&&K({},a.UnexpectedToken,"ILLEGAL"),E(l.charCodeAt(d))&&K({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt("0x"+n,16),lineNumber:A,lineStart:f,start:e,end:d}}(n);if(C(r))return function(e){for(var n="0"+l[d++];d<h&&C(l[d]);)n+=l[d++];return(E(l.charCodeAt(d))||v(l.charCodeAt(d)))&&K({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt(n,8),octal:!0,lineNumber:A,lineStart:f,start:e,end:d}}(n);r&&v(r.charCodeAt(0))&&K({},a.UnexpectedToken,"ILLEGAL")}for(;v(l.charCodeAt(d));)e+=l[d++];r=l[d]}if("."===r){for(e+=l[d++];v(l.charCodeAt(d));)e+=l[d++];r=l[d]}if("e"===r||"E"===r)if(e+=l[d++],"+"!==(r=l[d])&&"-"!==r||(e+=l[d++]),v(l.charCodeAt(d)))for(;v(l.charCodeAt(d));)e+=l[d++];else K({},a.UnexpectedToken,"ILLEGAL");return E(l.charCodeAt(d))&&K({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseFloat(e),lineNumber:A,lineStart:f,start:n,end:d}}function L(){var e,n,r,o;return p=null,D(),e=d,n=function(){var e,t,n,r;for(_("/"===(e=l[d]),"Regular expression literal must start with a slash"),t=l[d++],n=!1,r=!1;d<h;)if(t+=e=l[d++],"\\"===e)w((e=l[d++]).charCodeAt(0))&&K({},a.UnterminatedRegExp),t+=e;else if(w(e.charCodeAt(0)))K({},a.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){r=!0;break}"["===e&&(n=!0)}return r||K({},a.UnterminatedRegExp),{value:t.substr(1,t.length-2),literal:t}}(),r=function(){var e,t,n,r;for(t="",n="";d<h&&x((e=l[d]).charCodeAt(0));)if(++d,"\\"===e&&d<h)if("u"===(e=l[d])){if(r=++d,e=F("u"))for(n+=e,t+="\\u";r<d;++r)t+=l[r];else d=r,n+="u",t+="\\u";W({},a.UnexpectedToken,"ILLEGAL")}else t+="\\",W({},a.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}(),o=function(e,t){var n;try{n=new RegExp(e,t)}catch(e){K({},a.InvalidRegExp)}return n}(n.value,r.value),y.tokenize?{type:t.RegularExpression,value:o,lineNumber:A,lineStart:f,start:e,end:d}:{literal:n.literal+r.literal,value:o,start:e,end:d}}function P(){var e,t,n,r;return D(),e=d,t={start:{line:A,column:d-f}},n=L(),t.end={line:A,column:d-f},y.tokenize||(y.tokens.length>0&&(r=y.tokens[y.tokens.length-1]).range[0]===e&&"Punctuator"===r.type&&("/"!==r.value&&"/="!==r.value||y.tokens.pop()),y.tokens.push({type:"RegularExpression",value:n.literal,range:[e,d],loc:t})),n}function q(){var e,n,o;return D(),d>=h?{type:t.EOF,lineNumber:A,lineStart:f,start:d,end:d}:E(e=l.charCodeAt(d))?(n=d,{type:1===(o=92===l.charCodeAt(d)?T():j()).length?t.Identifier:k(o)?t.Keyword:"null"===o?t.NullLiteral:"true"===o||"false"===o?t.BooleanLiteral:t.Identifier,value:o,lineNumber:A,lineStart:f,start:n,end:d}):40===e||41===e||59===e?M():39===e||34===e?function(){var e,n,r,o,i,s,c,u,g="",p=!1;for(c=A,u=f,_("'"===(e=l[d])||'"'===e,"String literal must starts with a quote"),n=d,++d;d<h;){if((r=l[d++])===e){e="";break}if("\\"===r)if((r=l[d++])&&w(r.charCodeAt(0)))++A,"\r"===r&&"\n"===l[d]&&++d,f=d;else switch(r){case"u":case"x":s=d,(i=F(r))?g+=i:(d=s,g+=r);break;case"n":g+="\n";break;case"r":g+="\r";break;case"t":g+="\t";break;case"b":g+="\b";break;case"f":g+="\f";break;case"v":g+="\v";break;default:C(r)?(0!==(o="01234567".indexOf(r))&&(p=!0),d<h&&C(l[d])&&(p=!0,o=8*o+"01234567".indexOf(l[d++]),"0123".indexOf(r)>=0&&d<h&&C(l[d])&&(o=8*o+"01234567".indexOf(l[d++]))),g+=String.fromCharCode(o)):g+=r}else{if(w(r.charCodeAt(0)))break;g+=r}}return""!==e&&K({},a.UnexpectedToken,"ILLEGAL"),{type:t.StringLiteral,value:g,octal:p,startLineNumber:c,startLineStart:u,lineNumber:A,lineStart:f,start:n,end:d}}():46===e?v(l.charCodeAt(d+1))?O():M():v(e)?O():y.tokenize&&47===e?function(){var e,t;if(!(e=y.tokens[y.tokens.length-1]))return P();if("Punctuator"===e.type){if("]"===e.value)return M();if(")"===e.value)return!(t=y.tokens[y.openParenToken-1])||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?M():P();if("}"===e.value){if(y.tokens[y.openCurlyToken-3]&&"Keyword"===y.tokens[y.openCurlyToken-3].type){if(!(t=y.tokens[y.openCurlyToken-4]))return M()}else{if(!y.tokens[y.openCurlyToken-4]||"Keyword"!==y.tokens[y.openCurlyToken-4].type)return M();if(!(t=y.tokens[y.openCurlyToken-5]))return P()}return r.indexOf(t.value)>=0?M():P()}return P()}return"Keyword"===e.type?P():M()}():M()}function J(){var e,r,o;return D(),e={start:{line:A,column:d-f}},r=q(),e.end={line:A,column:d-f},r.type!==t.EOF&&(o=l.slice(r.start,r.end),y.tokens.push({type:n[r.type],value:o,range:[r.start,r.end],loc:e})),r}function U(){var e;return d=(e=p).end,A=e.lineNumber,f=e.lineStart,p=void 0!==y.tokens?J():q(),d=e.end,A=e.lineNumber,f=e.lineStart,e}function G(){var e,t,n;e=d,t=A,n=f,p=void 0!==y.tokens?J():q(),d=e,A=t,f=n}function H(e,t){this.line=e,this.column=t}function Y(e,t,n,r){this.start=new H(e,t),this.end=new H(n,r)}function z(){var e,t,n,r;return e=d,t=A,n=f,D(),r=A!==t,d=e,A=t,f=n,r}function K(e,t){var n,r=Array.prototype.slice.call(arguments,2),o=t.replace(/%(\d)/g,(function(e,t){return _(t<r.length,"Message reference must be in range"),r[t]}));throw"number"==typeof e.lineNumber?((n=new Error("Line "+e.lineNumber+": "+o)).index=e.start,n.lineNumber=e.lineNumber,n.column=e.start-f+1):((n=new Error("Line "+A+": "+o)).index=d,n.lineNumber=A,n.column=d-f+1),n.description=o,n}function W(){try{K.apply(null,arguments)}catch(e){if(!y.errors)throw e;y.errors.push(e)}}function V(e){if(e.type===t.EOF&&K(e,a.UnexpectedEOS),e.type===t.NumericLiteral&&K(e,a.UnexpectedNumber),e.type===t.StringLiteral&&K(e,a.UnexpectedString),e.type===t.Identifier&&K(e,a.UnexpectedIdentifier),e.type===t.Keyword){if(function(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}(e.value))K(e,a.UnexpectedReserved);else if(u&&S(e.value))return void W(e,a.StrictReservedWord);K(e,a.UnexpectedToken,e.value)}K(e,a.UnexpectedToken,e.value)}function $(e){var n=U();n.type===t.Punctuator&&n.value===e||V(n)}function X(e){var n=U();n.type===t.Keyword&&n.value===e||V(n)}function Z(e){return p.type===t.Punctuator&&p.value===e}function ee(e){return p.type===t.Keyword&&p.value===e}function te(){var e;59===l.charCodeAt(d)||Z(";")?U():(e=A,D(),A===e&&(p.type===t.EOF||Z("}")||V(p)))}function ne(e){return e.type===o.Identifier||e.type===o.MemberExpression}function re(e,t){var n,r,o;return n=u,o=p,r=Ce(),t&&u&&B(e[0].name)&&W(t,a.StrictParamName),u=n,g.markEnd(g.createFunctionExpression(null,e,[],r),o)}function oe(){var e,n;return n=p,(e=U()).type===t.StringLiteral||e.type===t.NumericLiteral?(u&&e.octal&&W(e,a.StrictOctalLiteral),g.markEnd(g.createLiteral(e),n)):g.markEnd(g.createIdentifier(e.value),n)}function ie(){var e,n,r,o,i,s;return s=p,(e=p).type===t.Identifier?(r=oe(),"get"!==e.value||Z(":")?"set"!==e.value||Z(":")?($(":"),o=he(),g.markEnd(g.createProperty("init",r,o),s)):(n=oe(),$("("),(e=p).type!==t.Identifier?($(")"),W(e,a.UnexpectedToken,e.value),o=re([])):(i=[me()],$(")"),o=re(i,e)),g.markEnd(g.createProperty("set",n,o),s)):(n=oe(),$("("),$(")"),o=re([]),g.markEnd(g.createProperty("get",n,o),s))):e.type!==t.EOF&&e.type!==t.Punctuator?(n=oe(),$(":"),o=he(),g.markEnd(g.createProperty("init",n,o),s)):void V(e)}function ae(){var e,n,r,s;if(Z("("))return function(){var e;return $("("),e=ge(),$(")"),e}();if(Z("["))return function(){var e,t=[];for(e=p,$("[");!Z("]");)Z(",")?(U(),t.push(null)):(t.push(he()),Z("]")||$(","));return U(),g.markEnd(g.createArrayExpression(t),e)}();if(Z("{"))return function(){var e,t,n,r,s,c=[],l={},d=String;for(s=p,$("{");!Z("}");)t=(e=ie()).key.type===o.Identifier?e.key.name:d(e.key.value),r="init"===e.kind?i.Data:"get"===e.kind?i.Get:i.Set,n="$"+t,Object.prototype.hasOwnProperty.call(l,n)?(l[n]===i.Data?u&&r===i.Data?W({},a.StrictDuplicateProperty):r!==i.Data&&W({},a.AccessorDataProperty):r===i.Data?W({},a.AccessorDataProperty):l[n]&r&&W({},a.AccessorGetSet),l[n]|=r):l[n]=r,c.push(e),Z("}")||$(",");return $("}"),g.markEnd(g.createObjectExpression(c),s)}();if(s=p,(e=p.type)===t.Identifier)r=g.createIdentifier(U().value);else if(e===t.StringLiteral||e===t.NumericLiteral)u&&p.octal&&W(p,a.StrictOctalLiteral),r=g.createLiteral(U());else if(e===t.Keyword){if(ee("function"))return function(){var e,t,n,r,o,i,s,c,l,d=null;return c=p,X("function"),Z("(")||(e=p,d=me(),u?B(e.value)&&W(e,a.StrictFunctionName):B(e.value)?(n=e,r=a.StrictFunctionName):S(e.value)&&(n=e,r=a.StrictReservedWord)),l=(o=Ie(n)).params,t=o.stricted,n=o.firstRestricted,o.message&&(r=o.message),s=u,i=Ce(),u&&n&&K(n,r),u&&t&&W(t,r),u=s,g.markEnd(g.createFunctionExpression(d,l,[],i),c)}();ee("this")?(U(),r=g.createThisExpression()):V(U())}else e===t.BooleanLiteral?((n=U()).value="true"===n.value,r=g.createLiteral(n)):e===t.NullLiteral?((n=U()).value=null,r=g.createLiteral(n)):Z("/")||Z("/=")?(r=g.createLiteral(void 0!==y.tokens?P():L()),G()):V(U());return g.markEnd(r,s)}function se(){var e=[];if($("("),!Z(")"))for(;d<h&&(e.push(he()),!Z(")"));)$(",");return $(")"),e}function ce(){return $("."),function(){var e,n;return n=p,function(e){return e.type===t.Identifier||e.type===t.Keyword||e.type===t.BooleanLiteral||e.type===t.NullLiteral}(e=U())||V(e),g.markEnd(g.createIdentifier(e.value),n)}()}function le(){var e;return $("["),e=ge(),$("]"),e}function ue(){var e,t,n;return n=p,X("new"),e=function(){var e,t,n,r;for(r=p,e=m.allowIn,t=ee("new")?ue():ae(),m.allowIn=e;Z(".")||Z("[");)Z("[")?(n=le(),t=g.createMemberExpression("[",t,n)):(n=ce(),t=g.createMemberExpression(".",t,n)),g.markEnd(t,r);return t}(),t=Z("(")?se():[],g.markEnd(g.createNewExpression(e,t),n)}function de(){var e,n,r=p;return e=function(){var e,t,n,r,o;for(o=p,e=m.allowIn,m.allowIn=!0,t=ee("new")?ue():ae(),m.allowIn=e;;){if(Z("."))r=ce(),t=g.createMemberExpression(".",t,r);else if(Z("("))n=se(),t=g.createCallExpression(t,n);else{if(!Z("["))break;r=le(),t=g.createMemberExpression("[",t,r)}g.markEnd(t,o)}return t}(),p.type===t.Punctuator&&(!Z("++")&&!Z("--")||z()||(u&&e.type===o.Identifier&&B(e.name)&&W({},a.StrictLHSPostfix),ne(e)||W({},a.InvalidLHSInAssignment),n=U(),e=g.markEnd(g.createPostfixExpression(n.value,e),r))),e}function Ae(){var e,n,r;return p.type!==t.Punctuator&&p.type!==t.Keyword?n=de():Z("++")||Z("--")?(r=p,e=U(),n=Ae(),u&&n.type===o.Identifier&&B(n.name)&&W({},a.StrictLHSPrefix),ne(n)||W({},a.InvalidLHSInAssignment),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):Z("+")||Z("-")||Z("~")||Z("!")?(r=p,e=U(),n=Ae(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):ee("delete")||ee("void")||ee("typeof")?(r=p,e=U(),n=Ae(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r),u&&"delete"===n.operator&&n.argument.type===o.Identifier&&W({},a.StrictDelete)):n=de(),n}function fe(e,n){var r=0;if(e.type!==t.Punctuator&&e.type!==t.Keyword)return 0;switch(e.value){case"||":r=1;break;case"&&":r=2;break;case"|":r=3;break;case"^":r=4;break;case"&":r=5;break;case"==":case"!=":case"===":case"!==":r=6;break;case"<":case">":case"<=":case">=":case"instanceof":r=7;break;case"in":r=n?7:0;break;case"<<":case">>":case">>>":r=8;break;case"+":case"-":r=9;break;case"*":case"/":case"%":r=11}return r}function he(){var e,n,r,i,s,c;return e=p,s=p,i=n=function(){var e,t,n,r,o;return o=p,e=function(){var e,t,n,r,o,i,a,s,c,l;if(e=p,c=Ae(),0===(o=fe(r=p,m.allowIn)))return c;for(r.prec=o,U(),t=[e,p],i=[c,r,a=Ae()];(o=fe(p,m.allowIn))>0;){for(;i.length>2&&o<=i[i.length-2].prec;)a=i.pop(),s=i.pop().value,c=i.pop(),n=g.createBinaryExpression(s,c,a),t.pop(),g.markEnd(n,e=t[t.length-1]),i.push(n);(r=U()).prec=o,i.push(r),t.push(p),n=Ae(),i.push(n)}for(n=i[l=i.length-1],t.pop();l>1;)n=g.createBinaryExpression(i[l-1].value,i[l-2],n),l-=2,e=t.pop(),g.markEnd(n,e);return n}(),Z("?")&&(U(),t=m.allowIn,m.allowIn=!0,n=he(),m.allowIn=t,$(":"),r=he(),e=g.createConditionalExpression(e,n,r),g.markEnd(e,o)),e}(),p.type===t.Punctuator&&("="===(c=p.value)||"*="===c||"/="===c||"%="===c||"+="===c||"-="===c||"<<="===c||">>="===c||">>>="===c||"&="===c||"^="===c||"|="===c)&&(ne(n)||W({},a.InvalidLHSInAssignment),u&&n.type===o.Identifier&&B(n.name)&&W(e,a.StrictLHSAssignment),e=U(),r=he(),i=g.markEnd(g.createAssignmentExpression(e.value,n,r),s)),i}function ge(){var e,t=p;if(e=he(),Z(",")){for(e=g.createSequenceExpression([e]);d<h&&Z(",");)U(),e.expressions.push(he());g.markEnd(e,t)}return e}function pe(){var e,t;return t=p,$("{"),e=function(){for(var e,t=[];d<h&&!Z("}")&&void 0!==(e=Ee());)t.push(e);return t}(),$("}"),g.markEnd(g.createBlockStatement(e),t)}function me(){var e,n;return n=p,(e=U()).type!==t.Identifier&&V(e),g.markEnd(g.createIdentifier(e.value),n)}function ye(e){var t,n,r=null;return n=p,t=me(),u&&B(t.name)&&W({},a.StrictVarName),"const"===e?($("="),r=he()):Z("=")&&(U(),r=he()),g.markEnd(g.createVariableDeclarator(t,r),n)}function _e(e){var t=[];do{if(t.push(ye(e)),!Z(","))break;U()}while(d<h);return t}function ve(){var e,t,n,r=[];for(n=p,ee("default")?(U(),e=null):(X("case"),e=ge()),$(":");d<h&&!(Z("}")||ee("default")||ee("case"));)t=be(),r.push(t);return g.markEnd(g.createSwitchCase(e,r),n)}function be(){var e,n,r,i,s,c,A,f,y,_,v=p.type;if(v===t.EOF&&V(p),v===t.Punctuator&&"{"===p.value)return pe();if(i=p,v===t.Punctuator)switch(p.value){case";":return g.markEnd(($(";"),g.createEmptyStatement()),i);case"(":return g.markEnd(function(){var e=ge();return te(),g.createExpressionStatement(e)}(),i)}if(v===t.Keyword)switch(p.value){case"break":return g.markEnd((_=null,X("break"),59===l.charCodeAt(d)?(U(),m.inIteration||m.inSwitch||K({},a.IllegalBreak),g.createBreakStatement(null)):z()?(m.inIteration||m.inSwitch||K({},a.IllegalBreak),g.createBreakStatement(null)):(p.type===t.Identifier&&(_=me(),Object.prototype.hasOwnProperty.call(m.labelSet,"$"+_.name)||K({},a.UnknownLabel,_.name)),te(),null!==_||m.inIteration||m.inSwitch||K({},a.IllegalBreak),g.createBreakStatement(_))),i);case"continue":return g.markEnd(function(){var e=null;return X("continue"),59===l.charCodeAt(d)?(U(),m.inIteration||K({},a.IllegalContinue),g.createContinueStatement(null)):z()?(m.inIteration||K({},a.IllegalContinue),g.createContinueStatement(null)):(p.type===t.Identifier&&(e=me(),Object.prototype.hasOwnProperty.call(m.labelSet,"$"+e.name)||K({},a.UnknownLabel,e.name)),te(),null!==e||m.inIteration||K({},a.IllegalContinue),g.createContinueStatement(e))}(),i);case"debugger":return g.markEnd((X("debugger"),te(),g.createDebuggerStatement()),i);case"do":return g.markEnd((X("do"),y=m.inIteration,m.inIteration=!0,A=be(),m.inIteration=y,X("while"),$("("),f=ge(),$(")"),Z(";")&&U(),g.createDoWhileStatement(A,f)),i);case"for":return g.markEnd(function(){var e,t,n,r,o,i,s;return e=t=n=null,X("for"),$("("),Z(";")?U():(ee("var")||ee("let")?(m.allowIn=!1,e=function(){var e,t,n;return n=p,e=U(),t=_e(),g.markEnd(g.createVariableDeclaration(t,e.value),n)}(),m.allowIn=!0,1===e.declarations.length&&ee("in")&&(U(),r=e,o=ge(),e=null)):(m.allowIn=!1,e=ge(),m.allowIn=!0,ee("in")&&(ne(e)||W({},a.InvalidLHSInForIn),U(),r=e,o=ge(),e=null)),void 0===r&&$(";")),void 0===r&&(Z(";")||(t=ge()),$(";"),Z(")")||(n=ge())),$(")"),s=m.inIteration,m.inIteration=!0,i=be(),m.inIteration=s,void 0===r?g.createForStatement(e,t,n,i):g.createForInStatement(r,o,i)}(),i);case"function":return g.markEnd(we(),i);case"if":return g.markEnd(function(){var e,t,n;return X("if"),$("("),e=ge(),$(")"),t=be(),ee("else")?(U(),n=be()):n=null,g.createIfStatement(e,t,n)}(),i);case"return":return g.markEnd((c=null,X("return"),m.inFunctionBody||W({},a.IllegalReturn),32===l.charCodeAt(d)&&E(l.charCodeAt(d+1))?(c=ge(),te(),g.createReturnStatement(c)):z()?g.createReturnStatement(null):(Z(";")||Z("}")||p.type===t.EOF||(c=ge()),te(),g.createReturnStatement(c))),i);case"switch":return g.markEnd(function(){var e,t,n,r,o;if(X("switch"),$("("),e=ge(),$(")"),$("{"),t=[],Z("}"))return U(),g.createSwitchStatement(e,t);for(r=m.inSwitch,m.inSwitch=!0,o=!1;d<h&&!Z("}");)null===(n=ve()).test&&(o&&K({},a.MultipleDefaultsInSwitch),o=!0),t.push(n);return m.inSwitch=r,$("}"),g.createSwitchStatement(e,t)}(),i);case"throw":return g.markEnd(function(){var e;return X("throw"),z()&&K({},a.NewlineAfterThrow),e=ge(),te(),g.createThrowStatement(e)}(),i);case"try":return g.markEnd(function(){var e,t,n,r,o=[],i=null;return X("try"),e=pe(),ee("catch")&&o.push((r=p,X("catch"),$("("),Z(")")&&V(p),t=me(),u&&B(t.name)&&W({},a.StrictCatchVariable),$(")"),n=pe(),g.markEnd(g.createCatchClause(t,n),r))),ee("finally")&&(U(),i=pe()),0!==o.length||i||K({},a.NoCatchOrFinally),g.createTryStatement(e,[],o,i)}(),i);case"var":return g.markEnd((X("var"),s=_e(),te(),g.createVariableDeclaration(s,"var")),i);case"while":return g.markEnd(function(){var e,t,n;return X("while"),$("("),e=ge(),$(")"),n=m.inIteration,m.inIteration=!0,t=be(),m.inIteration=n,g.createWhileStatement(e,t)}(),i);case"with":return g.markEnd(function(){var e,t;return u&&(D(),W({},a.StrictModeWith)),X("with"),$("("),e=ge(),$(")"),t=be(),g.createWithStatement(e,t)}(),i)}return(e=ge()).type===o.Identifier&&Z(":")?(U(),r="$"+e.name,Object.prototype.hasOwnProperty.call(m.labelSet,r)&&K({},a.Redeclaration,"Label",e.name),m.labelSet[r]=!0,n=be(),delete m.labelSet[r],g.markEnd(g.createLabeledStatement(e,n),i)):(te(),g.markEnd(g.createExpressionStatement(e),i))}function Ce(){var e,n,r,i,s,c,A,f,y=[];for(f=p,$("{");d<h&&p.type===t.StringLiteral&&(n=p,e=Ee(),y.push(e),e.expression.type===o.Literal);)"use strict"===l.slice(n.start+1,n.end-1)?(u=!0,r&&W(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(i=m.labelSet,s=m.inIteration,c=m.inSwitch,A=m.inFunctionBody,m.labelSet={},m.inIteration=!1,m.inSwitch=!1,m.inFunctionBody=!0;d<h&&!Z("}")&&void 0!==(e=Ee());)y.push(e);return $("}"),m.labelSet=i,m.inIteration=s,m.inSwitch=c,m.inFunctionBody=A,g.markEnd(g.createBlockStatement(y),f)}function Ie(e){var t,n,r,o,i,s,c=[];if($("("),!Z(")"))for(o={};d<h&&(n=p,t=me(),i="$"+n.value,u?(B(n.value)&&(r=n,s=a.StrictParamName),Object.prototype.hasOwnProperty.call(o,i)&&(r=n,s=a.StrictParamDupe)):e||(B(n.value)?(e=n,s=a.StrictParamName):S(n.value)?(e=n,s=a.StrictReservedWord):Object.prototype.hasOwnProperty.call(o,i)&&(e=n,s=a.StrictParamDupe)),c.push(t),o[i]=!0,!Z(")"));)$(",");return $(")"),{params:c,stricted:r,firstRestricted:e,message:s}}function we(){var e,t,n,r,o,i,s,c,l,d;return l=p,X("function"),n=p,e=me(),u?B(n.value)&&W(n,a.StrictFunctionName):B(n.value)?(i=n,s=a.StrictFunctionName):S(n.value)&&(i=n,s=a.StrictReservedWord),d=(o=Ie(i)).params,r=o.stricted,i=o.firstRestricted,o.message&&(s=o.message),c=u,t=Ce(),u&&i&&K(i,s),u&&r&&W(r,s),u=c,g.markEnd(g.createFunctionDeclaration(e,d,[],t),l)}function Ee(){if(p.type===t.Keyword)switch(p.value){case"const":case"let":return r=p,X(e=p.value),n=_e(e),te(),g.markEnd(g.createVariableDeclaration(n,e),r);case"function":return we();default:return be()}var e,n,r;if(p.type!==t.EOF)return be()}function xe(){var e,t,n,r=[];for(e=0;e<y.tokens.length;++e)n={type:(t=y.tokens[e]).type,value:t.value},y.range&&(n.range=t.range),y.loc&&(n.loc=t.loc),r.push(n);y.tokens=r}(n={})[(t={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9}).BooleanLiteral]="Boolean",n[t.EOF]="<end>",n[t.Identifier]="Identifier",n[t.Keyword]="Keyword",n[t.NullLiteral]="Null",n[t.NumericLiteral]="Numeric",n[t.Punctuator]="Punctuator",n[t.StringLiteral]="String",n[t.RegularExpression]="RegularExpression",r=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],o={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},i={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},s={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},c={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===o.Program&&e.body.length>0)){for(y.trailingComments.length>0?y.trailingComments[0].range[0]>=e.range[1]?(n=y.trailingComments,y.trailingComments=[]):y.trailingComments.length=0:y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=y.bottomRightStack[y.bottomRightStack.length-1].trailingComments,delete y.bottomRightStack[y.bottomRightStack.length-1].trailingComments);y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].range[0]>=e.range[0];)t=y.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):y.leadingComments.length>0&&y.leadingComments[y.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=y.leadingComments,y.leadingComments=[]),n&&(e.trailingComments=n),y.bottomRightStack.push(e)}},markEnd:function(e,t){return y.range&&(e.range=[t.start,d]),y.loc&&(e.loc=new Y(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),A,d-f),this.postProcess(e)),y.attachComment&&this.processComment(e),e},postProcess:function(e){return y.source&&(e.loc.source=y.source),e},createArrayExpression:function(e){return{type:o.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:o.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){return{type:"||"===e||"&&"===e?o.LogicalExpression:o.BinaryExpression,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:o.BlockStatement,body:e}},createBreakStatement:function(e){return{type:o.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:o.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:o.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:o.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:o.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:o.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:o.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:o.EmptyStatement}},createExpressionStatement:function(e){return{type:o.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:o.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:o.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:o.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:o.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:o.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:o.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:o.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:o.Literal,value:e.value,raw:l.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:o.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:o.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:o.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:o.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:o.Program,body:e}},createProperty:function(e,t,n){return{type:o.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:o.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:o.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:o.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:o.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:o.ThisExpression}},createThrowStatement:function(e){return{type:o.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:o.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:o.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:o.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:o.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:o.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:o.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:o.WithStatement,object:e,body:t}}},e.version="1.2.2",e.tokenize=function(e,n){var r;"string"==typeof e||e instanceof String||(e=String(e)),g=c,d=0,A=(l=e).length>0?1:0,f=0,h=l.length,p=null,m={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},(n=n||{}).tokens=!0,y.tokens=[],y.tokenize=!0,y.openParenToken=-1,y.openCurlyToken=-1,y.range="boolean"==typeof n.range&&n.range,y.loc="boolean"==typeof n.loc&&n.loc,"boolean"==typeof n.comment&&n.comment&&(y.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(y.errors=[]);try{if(G(),p.type===t.EOF)return y.tokens;for(U();p.type!==t.EOF;)try{U()}catch(e){if(y.errors){y.errors.push(e);break}throw e}xe(),r=y.tokens,void 0!==y.comments&&(r.comments=y.comments),void 0!==y.errors&&(r.errors=y.errors)}catch(e){throw e}finally{y={}}return r},e.parse=function(e,n){var r,i,s,_;i=String,"string"==typeof e||e instanceof String||(e=i(e)),g=c,d=0,A=(l=e).length>0?1:0,f=0,h=l.length,p=null,m={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},void 0!==n&&(y.range="boolean"==typeof n.range&&n.range,y.loc="boolean"==typeof n.loc&&n.loc,y.attachComment="boolean"==typeof n.attachComment&&n.attachComment,y.loc&&null!=n.source&&(y.source=i(n.source)),"boolean"==typeof n.tokens&&n.tokens&&(y.tokens=[]),"boolean"==typeof n.comment&&n.comment&&(y.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(y.errors=[]),y.attachComment&&(y.range=!0,y.comments=[],y.bottomRightStack=[],y.trailingComments=[],y.leadingComments=[]));try{D(),G(),_=p,u=!1,s=function(){for(var e,n,r,i=[];d<h&&(n=p).type===t.StringLiteral&&(e=Ee(),i.push(e),e.expression.type===o.Literal);)"use strict"===l.slice(n.start+1,n.end-1)?(u=!0,r&&W(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(;d<h&&void 0!==(e=Ee());)i.push(e);return i}(),r=g.markEnd(g.createProgram(s),_),void 0!==y.comments&&(r.comments=y.comments),void 0!==y.tokens&&(xe(),r.tokens=y.tokens),void 0!==y.errors&&(r.errors=y.errors)}catch(e){throw e}finally{y={}}return r},e.Syntax=function(){var e,t={};for(e in"function"==typeof Object.create&&(t=Object.create(null)),o)o.hasOwnProperty(e)&&(t[e]=o[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()},r(void 0!==n?n:this.esprima={})},{}],1:[function(e,t,n){(function(r){var o=function(){var e={trace:function(){},yy:{},symbols_:{error:2,JSON_PATH:3,DOLLAR:4,PATH_COMPONENTS:5,LEADING_CHILD_MEMBER_EXPRESSION:6,PATH_COMPONENT:7,MEMBER_COMPONENT:8,SUBSCRIPT_COMPONENT:9,CHILD_MEMBER_COMPONENT:10,DESCENDANT_MEMBER_COMPONENT:11,DOT:12,MEMBER_EXPRESSION:13,DOT_DOT:14,STAR:15,IDENTIFIER:16,SCRIPT_EXPRESSION:17,INTEGER:18,END:19,CHILD_SUBSCRIPT_COMPONENT:20,DESCENDANT_SUBSCRIPT_COMPONENT:21,"[":22,SUBSCRIPT:23,"]":24,SUBSCRIPT_EXPRESSION:25,SUBSCRIPT_EXPRESSION_LIST:26,SUBSCRIPT_EXPRESSION_LISTABLE:27,",":28,STRING_LITERAL:29,ARRAY_SLICE:30,FILTER_EXPRESSION:31,QQ_STRING:32,Q_STRING:33,$accept:0,$end:1},terminals_:{2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},productions_:[0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],performAction:function(e,n,r,o,i,a,s){o.ast||(o.ast=t,t.initialize());var c=a.length-1;switch(i){case 1:return o.ast.set({expression:{type:"root",value:a[c]}}),o.ast.unshift(),o.ast.yield();case 2:return o.ast.set({expression:{type:"root",value:a[c-1]}}),o.ast.unshift(),o.ast.yield();case 3:return o.ast.unshift(),o.ast.yield();case 4:return o.ast.set({operation:"member",scope:"child",expression:{type:"identifier",value:a[c-1]}}),o.ast.unshift(),o.ast.yield();case 5:case 6:case 11:case 13:case 18:case 21:case 22:case 23:break;case 7:o.ast.set({operation:"member"}),o.ast.push();break;case 8:o.ast.set({operation:"subscript"}),o.ast.push();break;case 9:case 19:o.ast.set({scope:"child"});break;case 10:case 20:o.ast.set({scope:"descendant"});break;case 12:o.ast.set({scope:"child",operation:"member"});break;case 14:o.ast.set({expression:{type:"wildcard",value:a[c]}});break;case 15:o.ast.set({expression:{type:"identifier",value:a[c]}});break;case 16:o.ast.set({expression:{type:"script_expression",value:a[c]}});break;case 17:o.ast.set({expression:{type:"numeric_literal",value:parseInt(a[c])}});break;case 24:a[c].length>1?o.ast.set({expression:{type:"union",value:a[c]}}):this.$=a[c];break;case 25:this.$=[a[c]];break;case 26:this.$=a[c-2].concat(a[c]);break;case 27:this.$={expression:{type:"numeric_literal",value:parseInt(a[c])}},o.ast.set(this.$);break;case 28:this.$={expression:{type:"string_literal",value:a[c]}},o.ast.set(this.$);break;case 29:this.$={expression:{type:"slice",value:a[c]}},o.ast.set(this.$);break;case 30:this.$={expression:{type:"wildcard",value:a[c]}},o.ast.set(this.$);break;case 31:this.$={expression:{type:"script_expression",value:a[c]}},o.ast.set(this.$);break;case 32:this.$={expression:{type:"filter_expression",value:a[c]}},o.ast.set(this.$);break;case 33:case 34:this.$=a[c]}},table:[{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],defaultActions:{27:[2,23],29:[2,30],30:[2,31],31:[2,32]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],o=[],i=this.table,a="",s=0,c=0,l=o.slice.call(arguments,1);this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;o.push(u);var d=this.lexer.options&&this.lexer.options.ranges;function A(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var f,h,g,p,m,y,_,v={};;){if(this.defaultActions[h=n[n.length-1]]?g=this.defaultActions[h]:(null==f&&(f=A()),g=i[h]&&i[h][f]),void 0===g||!g.length||!g[0]){var b;for(m in _=[],i[h])this.terminals_[m]&&m>2&&_.push("'"+this.terminals_[m]+"'");b=this.lexer.showPosition?"Parse error on line "+(s+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+_.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(b,{text:this.lexer.match,token:this.terminals_[f]||f,line:this.lexer.yylineno,loc:u,expected:_})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+h+", token: "+f);switch(g[0]){case 1:n.push(f),r.push(this.lexer.yytext),o.push(this.lexer.yylloc),n.push(g[1]),f=null,c=this.lexer.yyleng,a=this.lexer.yytext,s=this.lexer.yylineno,u=this.lexer.yylloc;break;case 2:if(v.$=r[r.length-(y=this.productions_[g[1]][1])],v._$={first_line:o[o.length-(y||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(y||1)].first_column,last_column:o[o.length-1].last_column},d&&(v._$.range=[o[o.length-(y||1)].range[0],o[o.length-1].range[1]]),void 0!==(p=this.performAction.apply(v,[a,c,s,this.yy,g[1],r,o].concat(l))))return p;y&&(n=n.slice(0,-1*y*2),r=r.slice(0,-1*y),o=o.slice(0,-1*y)),n.push(this.productions_[g[1]][0]),r.push(v.$),o.push(v._$),n.push(i[n[n.length-2]][n[n.length-1]]);break;case 3:return!0}}return!0}},t={initialize:function(){this._nodes=[],this._node={},this._stash=[]},set:function(e){for(var t in e)this._node[t]=e[t];return this._node},node:function(e){return arguments.length&&(this._node=e),this._node},push:function(){this._nodes.push(this._node),this._node={}},unshift:function(){this._nodes.unshift(this._node),this._node={}},yield:function(){var e=this._nodes;return this.initialize(),e}},n=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in o)this[i]=o[i];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),i=0;i<o.length;i++)if((n=this._input.match(this.rules[o[i]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=i,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,o[i])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,o[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 4;case 1:return 14;case 2:return 12;case 3:return 15;case 4:return 16;case 5:return 22;case 6:return 24;case 7:return 28;case 8:return 30;case 9:return 18;case 10:return t.yytext=t.yytext.substr(1,t.yyleng-2),32;case 11:return t.yytext=t.yytext.substr(1,t.yyleng-2),33;case 12:return 17;case 13:return 31}},rules:[/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return e}();function r(){this.yy={}}return e.lexer=n,r.prototype=e,e.Parser=r,new r}();void 0!==e&&void 0!==n&&(n.parser=o,n.Parser=o.Parser,n.parse=function(){return o.parse.apply(o,arguments)},n.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),r.exit(1));var o=e("fs").readFileSync(e("path").normalize(t[1]),"utf8");return n.parser.parse(o)},void 0!==t&&e.main===t&&n.main(r.argv.slice(1)))}).call(this,e("_process"))},{_process:14,fs:12,path:13}],2:[function(e,t,n){t.exports={identifier:"[a-zA-Z_]+[a-zA-Z0-9_]*",integer:"-?(?:0|[1-9][0-9]*)",qq_string:'"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^"\\\\])*"',q_string:"'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*'"}},{}],3:[function(e,t,n){var r=e("./dict"),o=e("fs"),i={lex:{macros:{esc:"\\\\",int:r.integer},rules:[["\\$","return 'DOLLAR'"],["\\.\\.","return 'DOT_DOT'"],["\\.","return 'DOT'"],["\\*","return 'STAR'"],[r.identifier,"return 'IDENTIFIER'"],["\\[","return '['"],["\\]","return ']'"],[",","return ','"],["({int})?\\:({int})?(\\:({int})?)?","return 'ARRAY_SLICE'"],["{int}","return 'INTEGER'"],[r.qq_string,"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],[r.q_string,"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],["\\(.+?\\)(?=\\])","return 'SCRIPT_EXPRESSION'"],["\\?\\(.+?\\)(?=\\])","return 'FILTER_EXPRESSION'"]]},start:"JSON_PATH",bnf:{JSON_PATH:[["DOLLAR",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["DOLLAR PATH_COMPONENTS",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["LEADING_CHILD_MEMBER_EXPRESSION","yy.ast.unshift(); return yy.ast.yield()"],["LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS",'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()']],PATH_COMPONENTS:[["PATH_COMPONENT",""],["PATH_COMPONENTS PATH_COMPONENT",""]],PATH_COMPONENT:[["MEMBER_COMPONENT",'yy.ast.set({ operation: "member" }); yy.ast.push()'],["SUBSCRIPT_COMPONENT",'yy.ast.set({ operation: "subscript" }); yy.ast.push() ']],MEMBER_COMPONENT:[["CHILD_MEMBER_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_MEMBER_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_MEMBER_COMPONENT:[["DOT MEMBER_EXPRESSION",""]],LEADING_CHILD_MEMBER_EXPRESSION:[["MEMBER_EXPRESSION",'yy.ast.set({ scope: "child", operation: "member" })']],DESCENDANT_MEMBER_COMPONENT:[["DOT_DOT MEMBER_EXPRESSION",""]],MEMBER_EXPRESSION:[["STAR",'yy.ast.set({ expression: { type: "wildcard", value: $1 } })'],["IDENTIFIER",'yy.ast.set({ expression: { type: "identifier", value: $1 } })'],["SCRIPT_EXPRESSION",'yy.ast.set({ expression: { type: "script_expression", value: $1 } })'],["INTEGER",'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })'],["END",""]],SUBSCRIPT_COMPONENT:[["CHILD_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_SUBSCRIPT_COMPONENT:[["[ SUBSCRIPT ]",""]],DESCENDANT_SUBSCRIPT_COMPONENT:[["DOT_DOT [ SUBSCRIPT ]",""]],SUBSCRIPT:[["SUBSCRIPT_EXPRESSION",""],["SUBSCRIPT_EXPRESSION_LIST",'$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1']],SUBSCRIPT_EXPRESSION_LIST:[["SUBSCRIPT_EXPRESSION_LISTABLE","$$ = [$1]"],["SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE","$$ = $1.concat($3)"]],SUBSCRIPT_EXPRESSION_LISTABLE:[["INTEGER",'$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)'],["STRING_LITERAL",'$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)'],["ARRAY_SLICE",'$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)']],SUBSCRIPT_EXPRESSION:[["STAR",'$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)'],["SCRIPT_EXPRESSION",'$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)'],["FILTER_EXPRESSION",'$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)']],STRING_LITERAL:[["QQ_STRING","$$ = $1"],["Q_STRING","$$ = $1"]]}};o.readFileSync&&(i.moduleInclude=o.readFileSync(e.resolve("../include/module.js")),i.actionInclude=o.readFileSync(e.resolve("../include/action.js"))),t.exports=i},{"./dict":2,fs:12}],4:[function(e,t,n){var r=e("./aesprim"),o=e("./slice"),i=e("static-eval"),a=e("underscore").uniq,s=function(){return this.initialize.apply(this,arguments)};function c(t,n,o){var i=e("./index"),a=f(r.parse(n).body[0].expression,{"@":t.value}),s=o.replace(/\{\{\s*value\s*\}\}/g,a),c=i.nodes(t.value,s);return c.forEach((function(e){e.path=t.path.concat(e.path.slice(1))})),c}function l(e){return Array.isArray(e)}function u(e){return function(t,n,r,o){var i=t.value,a=t.path,s=[],c=function(t,i){var a;l(t)?(t.forEach((function(e,t){s.length>=o||r(t,e,n)&&s.push({path:i.concat(t),value:e})})),t.forEach((function(t,n){s.length>=o||e&&c(t,i.concat(n))}))):(a=t)&&!(a instanceof Array)&&a instanceof Object&&(this.keys(t).forEach((function(e){s.length>=o||r(e,t[e],n)&&s.push({path:i.concat(e),value:t[e]})})),this.keys(t).forEach((function(n){s.length>=o||e&&c(t[n],i.concat(n))})))}.bind(this);return c(i,a),s}}function d(e){return function(t,n,r){return this.descend(n,t.expression.value,e,r)}}function A(e){return function(t,n,r){return this.traverse(n,t.expression.value,e,r)}}function f(){try{return i.apply(this,arguments)}catch(e){}}function h(e){return e=e.filter((function(e){return e})),a(e,(function(e){return e.path.map((function(e){return String(e).replace("-","--")})).join("-")}))}function g(e){var t=String(e);return t.match(/^-?[0-9]+$/)?parseInt(t):null}s.prototype.initialize=function(){this.traverse=u(!0),this.descend=u()},s.prototype.keys=Object.keys,s.prototype.resolve=function(e){var t=[e.operation,e.scope,e.expression.type].join("-"),n=this._fns[t];if(!n)throw new Error("couldn't resolve key: "+t);return n.bind(this)},s.prototype.register=function(e,t){if(!t instanceof Function)throw new Error("handler must be a function");this._fns[e]=t},s.prototype._fns={"member-child-identifier":function(e,t){var n=e.expression.value,r=t.value;if(r instanceof Object&&n in r)return[{value:r[n],path:t.path.concat(n)}]},"member-descendant-identifier":A((function(e,t,n){return e==n})),"subscript-child-numeric_literal":d((function(e,t,n){return e===n})),"member-child-numeric_literal":d((function(e,t,n){return String(e)===String(n)})),"subscript-descendant-numeric_literal":A((function(e,t,n){return e===n})),"member-child-wildcard":d((function(){return!0})),"member-descendant-wildcard":A((function(){return!0})),"subscript-descendant-wildcard":A((function(){return!0})),"subscript-child-wildcard":d((function(){return!0})),"subscript-child-slice":function(e,t){if(l(t.value)){var n=e.expression.value.split(":").map(g),r=t.value.map((function(e,n){return{value:e,path:t.path.concat(n)}}));return o.apply(null,[r].concat(n))}},"subscript-child-union":function(e,t){var n=[];return e.expression.value.forEach((function(e){var r={operation:"subscript",scope:"child",expression:e.expression},o=this.resolve(r)(r,t);o&&(n=n.concat(o))}),this),h(n)},"subscript-descendant-union":function(t,n,r){var o=e(".."),i=this,a=[];return o.nodes(n,"$..*").slice(1).forEach((function(e){a.length>=r||t.expression.value.forEach((function(t){var n={operation:"subscript",scope:"child",expression:t.expression},r=i.resolve(n)(n,e);a=a.concat(r)}))})),h(a)},"subscript-child-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.descend(t,null,(function(e,t){return f(i,{"@":t})}),n)},"subscript-descendant-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.traverse(t,null,(function(e,t){return f(i,{"@":t})}),n)},"subscript-child-script_expression":function(e,t){return c(t,e.expression.value.slice(1,-1),"$[{{value}}]")},"member-child-script_expression":function(e,t){return c(t,e.expression.value.slice(1,-1),"$.{{value}}")},"member-descendant-script_expression":function(e,t){return c(t,e.expression.value.slice(1,-1),"$..value")}},s.prototype._fns["subscript-child-string_literal"]=s.prototype._fns["member-child-identifier"],s.prototype._fns["member-descendant-numeric_literal"]=s.prototype._fns["subscript-descendant-string_literal"]=s.prototype._fns["member-descendant-identifier"],t.exports=s},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,underscore:12}],5:[function(e,t,n){var r=e("assert"),o=e("./dict"),i=e("./parser"),a=e("./handlers"),s=function(){this.initialize.apply(this,arguments)};function c(e){return"[object String]"==Object.prototype.toString.call(e)}s.prototype.initialize=function(){this.parser=new i,this.handlers=new a},s.prototype.parse=function(e){return r.ok(c(e),"we need a path"),this.parser.parse(e)},s.prototype.parent=function(e,t){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var n=this.nodes(e,t)[0];return n.path.pop(),this.value(e,n.path)},s.prototype.apply=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),r.equal(X(n),"function","fn needs to be function");var o=this.nodes(e,t).sort((function(e,t){return t.path.length-e.path.length}));return o.forEach((function(t){var r=t.path.pop(),o=this.value(e,this.stringify(t.path)),i=t.value=n.call(e,o[r]);o[r]=i}),this),o},s.prototype.value=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),arguments.length>=3){var o=this.nodes(e,t).shift();if(!o)return this._vivify(e,t,n);var i=o.path.slice(-1).shift();this.parent(e,this.stringify(o.path))[i]=n}return this.query(e,this.stringify(t),1).shift()},s.prototype._vivify=function(e,t,n){var o=this;r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var i=this.parser.parse(t).map((function(e){return e.expression.value})),a=function(t,n){var r=t.pop(),i=o.value(e,t);i||(a(t.concat(),"string"==typeof r?{}:[]),i=o.value(e,t)),i[r]=n};return a(i,n),this.query(e,t)[0]},s.prototype.query=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(c(t),"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.value}));return o},s.prototype.paths=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.path}));return o},s.prototype.nodes=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),0===n)return[];var o=this.parser.parse(t),i=this.handlers,a=[{path:["$"],value:e}],s=[];return o.length&&"root"==o[0].expression.type&&o.shift(),o.length?(o.forEach((function(e,t){if(!(s.length>=n)){var r=i.resolve(e),c=[];a.forEach((function(i){if(!(s.length>=n)){var a=r(e,i,n);t==o.length-1?s=s.concat(a||[]):c=c.concat(a||[])}})),a=c}})),n?s.slice(0,n):s):a},s.prototype.stringify=function(e){r.ok(e,"we need a path");var t="$",n={"descendant-member":"..{{value}}","child-member":".{{value}}","descendant-subscript":"..[{{value}}]","child-subscript":"[{{value}}]"};return(e=this._normalize(e)).forEach((function(e){if("root"!=e.expression.type){var r,o=[e.scope,e.operation].join("-"),i=n[o];if(r="string_literal"==e.expression.type?JSON.stringify(e.expression.value):e.expression.value,!i)throw new Error("couldn't find template "+o);t+=i.replace(/{{value}}/,r)}})),t},s.prototype._normalize=function(e){if(r.ok(e,"we need a path"),"string"==typeof e)return this.parser.parse(e);if(Array.isArray(e)&&"string"==typeof e[0]){var t=[{expression:{type:"root",value:"$"}}];return e.forEach((function(e,n){"$"==e&&0===n||("string"==typeof e&&e.match("^"+o.identifier+"$")?t.push({operation:"member",scope:"child",expression:{value:e,type:"identifier"}}):t.push({operation:"subscript",scope:"child",expression:{value:e,type:"number"==typeof e?"numeric_literal":"string_literal"}}))})),t}if(Array.isArray(e)&&"object"==X(e[0]))return e;throw new Error("couldn't understand path "+e)},s.Handlers=a,s.Parser=i;var l=new s;l.JSONPath=s,t.exports=l},{"./dict":2,"./handlers":4,"./parser":6,assert:8}],6:[function(e,t,n){var r=e("./grammar"),o=e("../generated/parser"),i=function(){var e=new o.Parser,t=e.parseError;return e.yy.parseError=function(){e.yy.ast&&e.yy.ast.initialize(),t.apply(e,arguments)},e};i.grammar=r,t.exports=i},{"../generated/parser":1,"./grammar":3}],7:[function(e,t,n){function r(e){return String(e).match(/^[0-9]+$/)?parseInt(e):Number.isFinite(e)?parseInt(e,10):0}t.exports=function(e,t,n,o){if("string"==typeof t)throw new Error("start cannot be a string");if("string"==typeof n)throw new Error("end cannot be a string");if("string"==typeof o)throw new Error("step cannot be a string");var i=e.length;if(0===o)throw new Error("step cannot be zero");if(o=o?r(o):1,n=n<0?i+n:n,t=r(0===(t=t<0?i+t:t)?0:t||(o>0?0:i-1)),n=r(0===n?0:n||(o>0?i:-1)),t=o>0?Math.max(0,t):Math.min(i,t),n=o>0?Math.min(n,i):Math.max(-1,n),o>0&&n<=t)return[];if(o<0&&t<=n)return[];for(var a=[],s=t;s!=n&&!(o<0&&s<=n||o>0&&s>=n);s+=o)a.push(e[s]);return a}},{}],8:[function(e,t,n){var r=e("util/"),o=Array.prototype.slice,i=Object.prototype.hasOwnProperty,a=t.exports=u;function s(e,t){return r.isUndefined(t)?""+t:r.isNumber(t)&&!isFinite(t)||r.isFunction(t)||r.isRegExp(t)?t.toString():t}function c(e,t){return r.isString(e)?e.length<t?e:e.slice(0,t):e}function l(e,t,n,r,o){throw new a.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:o})}function u(e,t){e||l(e,!0,t,"==",a.ok)}function d(e,t){if(e===t)return!0;if(r.isBuffer(e)&&r.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return r.isDate(e)&&r.isDate(t)?e.getTime()===t.getTime():r.isRegExp(e)&&r.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:r.isObject(e)||r.isObject(t)?function(e,t){if(r.isNullOrUndefined(e)||r.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(r.isPrimitive(e)||r.isPrimitive(t))return e===t;var n=A(e),i=A(t);if(n&&!i||!n&&i)return!1;if(n)return d(e=o.call(e),t=o.call(t));var a,s,c=g(e),l=g(t);if(c.length!=l.length)return!1;for(c.sort(),l.sort(),s=c.length-1;s>=0;s--)if(c[s]!=l[s])return!1;for(s=c.length-1;s>=0;s--)if(!d(e[a=c[s]],t[a]))return!1;return!0}(e,t):e==t}function A(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function f(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function h(e,t,n,o){var i;r.isString(n)&&(o=n,n=null);try{t()}catch(e){i=e}if(o=(n&&n.name?" ("+n.name+").":".")+(o?" "+o:"."),e&&!i&&l(i,n,"Missing expected exception"+o),!e&&f(i,n)&&l(i,n,"Got unwanted exception"+o),e&&i&&n&&!f(i,n)||!e&&i)throw i}a.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return c(JSON.stringify(e.actual,s),128)+" "+e.operator+" "+c(JSON.stringify(e.expected,s),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||l;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,o=r.indexOf("\n"+t.name);if(o>=0){var i=r.indexOf("\n",o+1);r=r.substring(i+1)}this.stack=r}}},r.inherits(a.AssertionError,Error),a.fail=l,a.ok=u,a.equal=function(e,t,n){e!=t&&l(e,t,n,"==",a.equal)},a.notEqual=function(e,t,n){e==t&&l(e,t,n,"!=",a.notEqual)},a.deepEqual=function(e,t,n){d(e,t)||l(e,t,n,"deepEqual",a.deepEqual)},a.notDeepEqual=function(e,t,n){d(e,t)&&l(e,t,n,"notDeepEqual",a.notDeepEqual)},a.strictEqual=function(e,t,n){e!==t&&l(e,t,n,"===",a.strictEqual)},a.notStrictEqual=function(e,t,n){e===t&&l(e,t,n,"!==",a.notStrictEqual)},a.throws=function(e,t,n){h.apply(this,[!0].concat(o.call(arguments)))},a.doesNotThrow=function(e,t){h.apply(this,[!1].concat(o.call(arguments)))},a.ifError=function(e){if(e)throw e};var g=Object.keys||function(e){var t=[];for(var n in e)i.call(e,n)&&t.push(n);return t}},{"util/":11}],9:[function(e,t,n){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],10:[function(e,t,n){t.exports=function(e){return e&&"object"===X(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],11:[function(e,t,n){(function(t,r){var o=/%[sdj%]/g;n.format=function(e){if(!m(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,a=String(e).replace(o,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n<i;c=r[++n])g(c)||!v(c)?a+=" "+c:a+=" "+s(c);return a},n.deprecate=function(e,o){if(y(r.process))return function(){return n.deprecate(e,o).apply(this,arguments)};if(!0===t.noDeprecation)return e;var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(o);t.traceDeprecation?console.trace(o):console.error(o),i=!0}return e.apply(this,arguments)}};var i,a={};function s(e,t){var r={seen:[],stylize:l};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),h(t)?r.showHidden=t:t&&n._extend(r,t),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),u(r,e,r.depth)}function c(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function l(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(r,e);return m(o)||(o=u(e,o,r)),o}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return p(t)?e.stylize(""+t,"number"):h(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var a=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),C(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return d(t);if(0===a.length){if(I(t))return e.stylize("[Function"+(t.name?": "+t.name:"")+"]","special");if(_(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(C(t))return d(t)}var c,l="",v=!1,w=["{","}"];return f(t)&&(v=!0,w=["[","]"]),I(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),_(t)&&(l=" "+RegExp.prototype.toString.call(t)),b(t)&&(l=" "+Date.prototype.toUTCString.call(t)),C(t)&&(l=" "+d(t)),0!==a.length||v&&0!=t.length?r<0?_(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=v?function(e,t,n,r,o){for(var i=[],a=0,s=t.length;a<s;++a)S(t,String(a))?i.push(A(e,t,n,r,String(a),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(A(e,t,n,r,o,!0))})),i}(e,t,r,s,a):a.map((function(n){return A(e,t,r,s,n,v)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,w)):w[0]+l+w[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function A(e,t,n,r,o,i){var a,s,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=e.stylize(c.set?"[Getter/Setter]":"[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),S(r,o)||(a="["+o+"]"),s||(e.seen.indexOf(c.value)<0?(s=g(n)?u(e,c.value,null):u(e,c.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),y(a)){if(i&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function f(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function g(e){return null===e}function p(e){return"number"==typeof e}function m(e){return"string"==typeof e}function y(e){return void 0===e}function _(e){return v(e)&&"[object RegExp]"===w(e)}function v(e){return"object"===X(e)&&null!==e}function b(e){return v(e)&&"[object Date]"===w(e)}function C(e){return v(e)&&("[object Error]"===w(e)||e instanceof Error)}function I(e){return"function"==typeof e}function w(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(y(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=t.pid;a[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else a[e]=function(){};return a[e]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=f,n.isBoolean=h,n.isNull=g,n.isNullOrUndefined=function(e){return null==e},n.isNumber=p,n.isString=m,n.isSymbol=function(e){return"symbol"===X(e)},n.isUndefined=y,n.isRegExp=_,n.isObject=v,n.isDate=b,n.isError=C,n.isFunction=I,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===X(e)||void 0===e},n.isBuffer=e("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(t=[E((e=new Date).getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":"),[e.getDate(),x[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),void 0!==se?se:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:14,inherits:9}],12:[function(e,t,n){},{}],13:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var a=i>=0?arguments[i]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(n=a+"/"+n,o="/"===a.charAt(0))}return(o?"/":"")+(n=t(r(n.split("/"),(function(e){return!!e})),!o).join("/"))||"."},n.normalize=function(e){var i=n.isAbsolute(e),a="/"===o(e,-1);return(e=t(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),a=Math.min(o.length,i.length),s=a,c=0;c<a;c++)if(o[c]!==i[c]){s=c;break}var l=[];for(c=s;c<o.length;c++)l.push("..");return(l=l.concat(i.slice(s))).join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(o=!1,r=a+1),46===s?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=a+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:14}],14:[function(e,t,n){var r,o,i=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}}();var l,u=[],d=!1,A=-1;function f(){d&&l&&(d=!1,l.length?u=l.concat(u):A=-1,u.length&&h())}function h(){if(!d){var e=c(f);d=!0;for(var t=u.length;t;){for(l=u,u=[];++A<t;)l&&l[A].run();A=-1,t=u.length}l=null,d=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===s||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||d||c(h)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],15:[function(e,t,n){var r=e("escodegen").generate;t.exports=function(e,t){t||(t={});var n={},o=function e(o,i){if("Literal"===o.type)return o.value;if("UnaryExpression"===o.type){var a=e(o.argument);return"+"===o.operator?+a:"-"===o.operator?-a:"~"===o.operator?~a:"!"===o.operator?!a:n}if("ArrayExpression"===o.type){for(var s=[],c=0,l=o.elements.length;c<l;c++){if((m=e(o.elements[c]))===n)return n;s.push(m)}return s}if("ObjectExpression"===o.type){var u={};for(c=0;c<o.properties.length;c++){var d=null===(y=o.properties[c]).value?y.value:e(y.value);if(d===n)return n;u[y.key.value||y.key.name]=d}return u}if("BinaryExpression"===o.type||"LogicalExpression"===o.type){if((l=e(o.left))===n)return n;var A=e(o.right);if(A===n)return n;var f=o.operator;return"=="===f?l==A:"==="===f?l===A:"!="===f?l!=A:"!=="===f?l!==A:"+"===f?l+A:"-"===f?l-A:"*"===f?l*A:"/"===f?l/A:"%"===f?l%A:"<"===f?l<A:"<="===f?l<=A:">"===f?l>A:">="===f?l>=A:"|"===f?l|A:"&"===f?l&A:"^"===f?l^A:"&&"===f?l&&A:"||"===f?l||A:n}if("Identifier"===o.type)return{}.hasOwnProperty.call(t,o.name)?t[o.name]:n;if("ThisExpression"===o.type)return{}.hasOwnProperty.call(t,"this")?t.this:n;if("CallExpression"===o.type){var h=e(o.callee);if(h===n)return n;if("function"!=typeof h)return n;var g=o.callee.object?e(o.callee.object):n;g===n&&(g=null);var p=[];for(c=0,l=o.arguments.length;c<l;c++){var m;if((m=e(o.arguments[c]))===n)return n;p.push(m)}return h.apply(g,p)}var y;if("MemberExpression"===o.type)return(u=e(o.object))===n||"function"==typeof u?n:"Identifier"===o.property.type?u[o.property.name]:(y=e(o.property))===n?n:u[y];if("ConditionalExpression"===o.type)return(a=e(o.test))===n?n:e(a?o.consequent:o.alternate);if("ExpressionStatement"===o.type)return(a=e(o.expression))===n?n:a;if("ReturnStatement"===o.type)return e(o.argument);if("FunctionExpression"===o.type){var _=o.body.body,v={};for(Object.keys(t).forEach((function(e){v[e]=t[e]})),c=0;c<o.params.length;c++){var b=o.params[c];if("Identifier"!=b.type)return n;t[b.name]=null}for(var c in _)if(e(_[c])===n)return n;t=v;var C=Object.keys(t),I=C.map((function(e){return t[e]}));return Function(C.join(", "),"return "+r(o)).apply(null,I)}if("TemplateLiteral"===o.type){var w="";for(c=0;c<o.expressions.length;c++)w+=e(o.quasis[c]),w+=e(o.expressions[c]);return w+e(o.quasis[c])}if("TaggedTemplateExpression"===o.type){var E=e(o.tag),x=o.quasi,S=x.quasis.map(e),B=x.expressions.map(e);return E.apply(null,[S].concat(B))}return"TemplateElement"===o.type?o.value.cooked:n}(e);return o===n?void 0:o}},{escodegen:12}],jsonpath:[function(e,t,n){t.exports=e("./lib/index")},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")}(Kl)),Kl.exports),Vl=ce(Wl);const $l=new Set(["i","me","my","myself","we","our","ours","ourselves","you","your","yours","yourself","yourselves","he","him","his","himself","she","her","hers","herself","it","its","itself","they","them","their","theirs","themselves","what","which","who","whom","this","that","these","those","am","is","are","was","were","be","been","being","have","has","had","having","do","does","did","doing","a","an","the","and","but","if","or","because","as","until","while","of","at","by","for","with","about","against","between","into","through","during","before","after","above","below","to","from","up","down","in","out","on","off","over","under","again","further","then","once","here","there","when","where","why","how","all","any","both","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","s","t","can","will","just","don","should","now","0","1","2","3","4","5","6","7","8","9"]);function Xl(e,t){for(const[n,r]of t.entries())if(e.startsWith(r))return e.replace(r,String(n));return e}const Zl="$PREFIXED_ID";function eu(e,t,n){if(t===Zl)return[Xl(e.id,n)];let r;try{r=Vl.query(e,t)}catch{r=Vl.query(JSON.parse(JSON.stringify(e)),t)}return r}function tu(e){return e.toLowerCase().split(/[^\d:A-Za-z]+/).filter((e=>e&&!$l.has(e)))}function*nu(e){for(const t of e)yield*tu(t)}function*ru(e){for(const t of e)if("string"==typeof t)yield t;else if("object"==typeof t){const e=Vl.query(t,"$..*");yield*ru(e)}}function*ou(e,t,n){for(const r of t){const t=eu(e,r,n);if(t.length>0)for(const e of nu(ru(t)))yield[r,e]}}async function iu(e,t,n){const r=await this.db,o=t??r.transaction(["nodes"]);Gl(n);const i=[...tu(e)],a=[],s=new Map;a.push(...i.map((async(e,t)=>{Gl(n);const r=o.objectStore("nodes").index("full-text-words");for await(const o of r.iterate(IDBKeyRange.bound(e,`${e}`,!1,!1))){Gl(n);const e=o.value,r=s.get(e.id)??[e,new Set];r[1].add(t),s.set(e.id,r)}}))),await Promise.all(a),Gl(n);const c=[];for(const[,[e,t]]of s)Gl(n),c.push(...au(this.textIndexFields,e,t,i,this.prefixes));return c.sort(((e,t)=>t.score-e.score)),c.slice(0,this.options.maxSearchResults??this.DEFAULT_MAX_SEARCH_RESULTS)}function au(e,t,n,r,o){const i=[...n].sort().map((e=>r[e])),a=i.map((e=>{const t=e.replaceAll(/[$()*+./?[\\\]^{|}-]/g,String.raw`\$&`);return new RegExp(`\\b${t}`,"gi")}));let s=[],c=0;for(const[n,i]of e.entries()){const l=new Set,u=e.length-n-1,d=[...ru(eu(t,i.jsonPath,o))];for(const e of d){let n=0;const o=[];for(const[t,i]of a.entries())for(const a of e.matchAll(i)){n+=1+1*u,l.add(t);const i=a.index,s=r[t];void 0!==i&&(n+=.01*s.length,n+=s.length/e.length*100*.05,o.push({wordIndex:t,position:i}))}n+=100*l.size,c<n&&(c=n),o.sort(((e,t)=>e.position-t.position)),o.length>0&&s.push({term:t,field:i,str:e,score:n,wordMatches:o})}}s=s.filter((e=>e.score===c));for(const e of s){const{wordMatches:t}=e;for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1],a=o.wordIndex-r.wordIndex;if(1===a||-1===a){e.score+=1,1===a&&(e.score+=1);const t=Math.abs(o.position-(r.position+i[r.wordIndex].length))-1;e.score-=.05*t}}}return s}function su(e){return"string"==typeof e.id}function cu(e){return"string"==typeof e.sub&&"string"==typeof e.pred&&"string"==typeof e.obj}function lu(e){return Boolean(e.meta?.deprecated)}var uu,du,Au=(du||(du=1,uu=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==X(t)&&"object"==X(n)){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var a,s=F(t.entries());try{for(s.s();!(a=s.n()).done;)if(!n.has((o=a.value)[0]))return!1}catch(e){s.e(e)}finally{s.f()}var c,l=F(t.entries());try{for(l.s();!(c=l.n()).done;)if(!e((o=c.value)[1],n.get(o[0])))return!1}catch(e){l.e(e)}finally{l.f()}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u,d=F(t.entries());try{for(d.s();!(u=d.n()).done;)if(!n.has((o=u.value)[0]))return!1}catch(e){d.e(e)}finally{d.f()}return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var A=i[o];if(!e(t[A],n[A]))return!1}return!0}return t!=t&&n!=n}),uu),fu=ce(Au);async function hu(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.blocked,o=n.upgrade,i=n.blocking,a=n.terminated,s=indexedDB.open(e,t),c=kl(s);return o&&s.addEventListener("upgradeneeded",(function(e){o(kl(s.result),e.oldVersion,e.newVersion,kl(s.transaction),e)})),r&&s.addEventListener("blocked",(function(e){return r(e.oldVersion,e.newVersion,e)})),c.then((function(e){a&&e.addEventListener("close",(function(){return a()})),i&&e.addEventListener("versionchange",(function(e){return i(e.oldVersion,e.newVersion,e)}))})).catch((function(){})),c}(e,2,{upgrade(e,t,n,r,o){if(t<2&&(e.objectStoreNames.contains("meta")&&e.deleteObjectStore("meta"),e.objectStoreNames.contains("nodes")&&e.deleteObjectStore("nodes"),e.objectStoreNames.contains("edges")&&e.deleteObjectStore("edges")),e.objectStoreNames.contains("meta")||e.createObjectStore("meta"),!e.objectStoreNames.contains("nodes")){e.createObjectStore("nodes",{keyPath:"id"});const t=r.objectStore("nodes");t.createIndex("by-label","lbl"),t.createIndex("by-type","type"),t.createIndex("by-synonym",["meta","synonyms","val"]),t.createIndex("full-text-words","fullTextWords",{multiEntry:!0})}if(!e.objectStoreNames.contains("edges")){e.createObjectStore("edges",{autoIncrement:!0});const t=r.objectStore("edges");t.createIndex("by-subject","sub"),t.createIndex("by-object","obj"),t.createIndex("by-predicate","pred")}}})}function gu(e){const t=new Set;for(const[,n]of e)t.add(n);return[...t]}async function pu(e){const t=Date.now();let n,r=1;this.options.update?.("Parsing JSON",r);try{n=JSON.parse(await p.openLocation(this.sourceLocation).readFile("utf8"))}catch{throw new Error("Error in loading ontology")}r+=5,this.options.update?.("Parsing JSON complete",r);const o=Date.now(),[i,...a]=n.graphs??[];if(i){if(a.length>0)throw new Error("multiple graphs not supported");try{const n=e.transaction(["meta","nodes","edges"],"readwrite");await n.objectStore("meta").clear(),await n.objectStore("nodes").clear(),await n.objectStore("edges").clear();const a=n.objectStore("nodes"),s=mu.call(this).map((e=>e.jsonPath));if(i.nodes){let e=Math.round(r);for(const[,t]of i.nodes.entries())r+=1/i.nodes.length*64,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing nodes",r),e=Math.round(r)),su(t)&&await a.add({...t,fullTextWords:gu(ou(t,s,this.prefixes))})}const c=n.objectStore("edges");if(i.edges){let e=Math.round(r);for(const[,t]of i.edges.entries())r+=1/i.edges.length*30,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing edges",r),e=Math.round(r)),cu(t)&&await c.add(t)}await n.done;const l=e.transaction("meta","readwrite"),{update:u,...d}=this.options;await l.objectStore("meta").add({ontologyRecord:{name:this.ontologyName,version:this.ontologyVersion,sourceLocation:this.sourceLocation},storeOptions:d,graphMeta:i.meta,timestamp:String(new Date),schemaVersion:2,timings:{overall:Date.now()-t,load:Date.now()-o}},"meta"),await l.done}catch(t){throw await e.transaction("meta","readwrite").objectStore("meta").clear(),t}}}function mu(){return[{displayName:"ID",jsonPath:Zl},...this.options.textIndexing?.indexFields??Cu]}async function yu(e){const[t]=await e.transaction("meta").objectStore("meta").getAll();return!!t&&fu(this.options.prefixes,t.storeOptions.prefixes)&&fu(this.options.textIndexing,t.storeOptions.textIndexing)}class _u{ontologyName;ontologyVersion;sourceLocation;db;options;loadOboGraphJson=pu;getTermsByFulltext=iu;openDatabase=hu;isDatabaseCurrent=yu;get textIndexFields(){return mu.call(this)}get prefixes(){return this.options.prefixes??new Map}DEFAULT_MAX_SEARCH_RESULTS=100;constructor(e,t,n,r){this.ontologyName=e,this.ontologyVersion=t,this.sourceLocation=n,this.options=r??{},this.db=this.prepareDatabase()}validate(){const e=[],{sourceLocation:t,sourceType:n}=this;return n?"obo-graph-json"!==n&&e.push(new Error(`ontology source file ${JSON.stringify(t)} has type ${n}, which is not yet supported`)):e.push(new Error(`unable to determine format of ontology source file ${JSON.stringify(t)}, file name must end with ".json", ".obo", or ".owl"`)),e}get sourceType(){if(o.isUriLocation(this.sourceLocation)){if(this.sourceLocation.uri.endsWith(".json"))return"obo-graph-json"}else if(o.isLocalPathLocation(this.sourceLocation)&&this.sourceLocation.localPath.endsWith(".json"))return"obo-graph-json"}get dbName(){return`Apollo Ontology "${this.ontologyName}" "${this.ontologyVersion}"`}async prepareDatabase(){const e=this.validate();if(e.length>0)throw e;const t=await this.openDatabase(this.dbName);if(await this.isDatabaseCurrent(t))return t;try{const{options:e,sourceLocation:n,sourceType:r}=this;if("obo-graph-json"!==r)throw new Error(`ontology source file ${JSON.stringify(n)} has type ${r}, which is not yet supported`);return e.update?.("",0),await this.loadOboGraphJson(t),e.update?.("",100),t}catch(e){throw t.close(),await function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).blocked,n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(function(e){return t(e.oldVersion,e)})),kl(n).then((function(){}))}(this.dbName),e}}async termCount(e){const t=await this.db;return(e??t.transaction("nodes")).objectStore("nodes").count()}unique(e){const t=new Map,n=[];for(const r of e)t.has(r.id)||(t.set(r.id,!0),n.push(r));return n}async getTermsWithLabelOrSynonym(e,t,n){const r=t?.includeSubclasses??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=i.objectStore("nodes"),s=[...await a.index("by-label").getAll(e),...await a.index("by-synonym").getAll(e)];if(r){const e=await this.recurseEdges("by-object",s.map((e=>e.id)),(e=>"is_a"===e.pred),"sub",i);for(const t of e){const e=await a.get(t);e&&s.push(e)}}return s}async getPropertiesByLabel(e,t,n){const r=t?.includeSubProperties??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=(await this.getTermsWithLabelOrSynonym(e,{includeSubclasses:!1},i)).filter((e=>Eu(e)));if(r){const e=await this.recurseEdges("by-object",a.map((e=>e.id)),(e=>"subPropertyOf"===e.pred),"sub",i),t=i.objectStore("nodes");for(const n of e){const e=await t.get(n);e&&Eu(e)&&a.push(e)}}return a}async recurseEdges(e,t,n,r,o){const i=new Set;return await async function t(a){await Promise.all([...a].map((async a=>{const s=(await o.objectStore("edges").index(e).getAll(a)).filter((e=>n(e))).map((e=>e[r]));if(s.length>0){for(const e of s)i.add(e);await t(s)}})))}(t),i.values()}async*expandNodeSet(e,t="is_a",n,r){const o=await this.db,i=r??o.transaction(["edges"]),a=[...e],s=await this.recurseEdges("subclasses"===n?"by-object":"by-subject",a,(e=>e.pred===t),"subclasses"===n?"sub":"obj",i);for(const e of a)yield e;for(const e of s)yield e}expandSubclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"subclasses",n)}expandSuperclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"superclasses",n)}async getClassesThat(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=await this.getPropertiesByLabel(e,{includeSubProperties:!0},o),a=new Set(i.map((e=>e.id))),s=await async function(e){const t=[];for await(const n of e)t.push(n);return t}(this.expandSuperclasses(t.map((e=>e.id)),"is_a",o)),c=await this.recurseEdges("by-object",s,(e=>a.has(e.pred)),"sub",o),l=this.expandSubclasses(c,"is_a",o),u=[];for await(const e of l){const t=await o.objectStore("nodes").get(e);t&&wu(t)&&!lu(t)&&u.push(t)}return u}async getClassesWithoutPropertyLabeled(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=o.objectStore("nodes"),a=o.objectStore("edges"),s=(await this.getPropertiesByLabel(e,t,o)).map((e=>e.id)),c=await(async()=>{const e=new Set;for(const t of s)for await(const n of a.index("by-predicate").iterate(t))e.add(n.value.sub);const t=new Set;for await(const n of this.expandSubclasses(e,"is_a",o))t.add(n);return t})(),l=[];for await(const e of i){const t=e.value;wu(t)&&!c.has(t.id)&&l.push(t.id)}const u=[];for(const e of l){const t=await o.objectStore("nodes").get(e);t&&wu(t)&&!lu(t)&&u.push(t)}return u}async getAllClasses(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").index("by-type").getAll("CLASS")).filter((e=>!lu(e)))}async getAllTerms(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").getAll()).filter((e=>!lu(e)))}}const vu=c.types.model("OntologyRecord",{name:c.types.string,version:"unversioned",source:c.types.union(g.LocalPathLocation,g.UriLocation,g.BlobLocation),options:c.types.frozen(),equivalentTypes:c.types.map(c.types.array(c.types.string))}).volatile((e=>({dataStore:void 0,startedEquivalentTypeRequests:new Set}))).actions((e=>({ping(){},initDataStore(){e.dataStore=new _u(e.name,e.version,c.getSnapshot(e.source),e.options)},afterCreate(){c.addDisposer(e,l.autorun((()=>{this.initDataStore()})))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).actions((e=>({loadEquivalentTypes:c.flow((function*(t){if(!e.dataStore)return;if(e.startedEquivalentTypeRequests.has(t))return;e.startedEquivalentTypeRequests.add(t);const n=(yield e.dataStore.getTermsWithLabelOrSynonym(t)).map((e=>e.lbl)).filter((e=>null!=e));c.isAlive(e)&&e.setEquivalentTypes(t,n)}))}))).actions((e=>({afterCreate(){l.autorun((t=>{e.dataStore&&(e.loadEquivalentTypes("gene"),e.loadEquivalentTypes("pseudogene"),e.loadEquivalentTypes("transcript"),e.loadEquivalentTypes("pseudogenic_transcript"),e.loadEquivalentTypes("CDS"),e.loadEquivalentTypes("mRNA"),t.dispose())}))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).views((e=>({isTypeOf(t,n){if(t===n)return!0;if(!e.dataStore)return!1;const r=e.equivalentTypes.get(n);return r?r.includes(t):(e.loadEquivalentTypes(n),!1)}}))),bu=c.types.model("OntologyManager",{ontologies:c.types.array(vu),prefixes:c.types.optional(c.types.map(c.types.string),{"GO:":"http://purl.obolibrary.org/obo/GO_","SO:":"http://purl.obolibrary.org/obo/SO_"})}).views((e=>({get featureTypeOntologyName(){const t=c.getRoot(e).jbrowse.configuration;return n.readConfObject(t.ApolloPlugin,"featureTypeOntologyName")}}))).views((e=>({get featureTypeOntology(){return this.findOntology(e.featureTypeOntologyName)},findOntology:(t,n)=>e.ontologies.find((e=>e.name===t&&(void 0===n||e.version===n))),openOntology(e,t){return this.findOntology(e,t)?.dataStore},applyPrefixes:t=>Xl(t,e.prefixes),expandPrefixes:t=>function(e,t){for(const[n,r]of t.entries())if(e.startsWith(String(n)))return e.replace(String(n),r);return e}(t,e.prefixes)}))).actions((e=>({addOntology(t,n,r,o){const i=e.ontologies.push({name:t,version:n,source:r,options:{prefixes:new Map(e.prefixes.entries()),...o}});e.ontologies[i-1].ping()}}))),Cu=[{displayName:"Label",jsonPath:"$.lbl"},{displayName:"Synonym",jsonPath:"$.meta.synonyms[*].val"},{displayName:"Definition",jsonPath:"$.meta.definition.val"}],Iu=n.ConfigurationSchema("OntologyRecord",{name:{type:"string",description:'the full name of the ontology, e.g. "Gene Ontology"',defaultValue:"My Ontology"},version:{type:"string",description:"the ontology's version string",defaultValue:"unversioned"},source:{type:"fileLocation",description:"the download location for the ontology's source file",defaultValue:{locationType:"UriLocation",uri:"http://example.com/myontology.json"}},textIndexFields:{type:"frozen",description:"JSON paths for text fields that will be indexed for text searching",defaultValue:Cu}});function wu(e){return"CLASS"===e.type}function Eu(e){return"PROPERTY"===e.type}async function xu(e,t,n){if(!e)return;const r=await t.getTermsWithLabelOrSynonym(e.type,{includeSubclasses:!1}),o=r.filter(wu);if(0===r.length)return;const i=await t.getClassesThat("part_of",o);return 0!==i.length?i:void 0}function Su({fetchValidTerms:e,filterTerms:t,includeDeprecated:n,onChange:r,ontologyName:o,ontologyVersion:a,renderInput:c,session:l,style:d,value:A}){const[f,h]=u.useState(!1),[g,p]=u.useState(),[m,y]=u.useState(""),[_,v]=u.useState(),{ontologyManager:b}=l.apolloDataStore,C=b.findOntology(o,a)?.dataStore,I=C&&f&&!g,w=C&&!_,E=u.useCallback((e=>(n||!lu(e))&&(!t||t(e))),[t,n]);u.useEffect((()=>{const e=new AbortController,{signal:t}=e;return w&&async function(e,t,n,r){if(!t)return;const o=(await e.getTermsWithLabelOrSynonym(t,{includeSubclasses:!1})).find((e=>(n??(()=>!0))(e)));if(!o)throw new Error(`not a valid ${e.ontologyName} term`);return o}(C,A,E).then((e=>{y(""),t.aborted||v(e)}),(e=>{t.aborted||Hl(e)||y(String(e))})),()=>{e.abort(new DOMException("Cancel getting current term from ontology store","AbortError"))}}),[l,A,E,C,w]),u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return I&&async function(e,t,n,r){let o;if(t){const n=await t(e,r);n&&(o=n)}return o||(o=await e.getAllTerms()),n?o.filter((e=>n(e))):o}(C,e,E,n).then((e=>{e&&!n.aborted&&p(e)}),(e=>{n.aborted||Hl(e)||l.notify(e instanceof Error?e.message:String(e),"error")})),()=>{t.abort(new DOMException("Canceling getting valid terms from ontology store","AbortError"))}}),[I,E,C,l,e]);const x={};return m&&(x.error=!0,x.helperText=m),i.jsx(s.Autocomplete,{style:d,autoComplete:!0,filterSelectedOptions:!0,disableClearable:!0,selectOnFocus:!0,clearOnBlur:!0,handleHomeEndKeys:!0,freeSolo:!0,value:A,options:g??[],onOpen:()=>{h(!0)},onClose:()=>{h(!1)},loading:I,renderInput:c??(e=>i.jsx(s.TextField,{...e,...x})),getOptionLabel:e=>"string"==typeof e?e:e.lbl??"",isOptionEqualToValue:(e,t)=>e.lbl===t.lbl,onChange:(e,t)=>{t&&("string"==typeof t?(v(void 0),r(A,t)):t.lbl!==A&&(y(""),v(t),r(A,t.lbl)))}})}function Bu({changeManager:e,handleClose:t,session:n,sourceAssemblyId:r,sourceFeature:o}){const[a,c]=u.useState(String(o.max)),[l,d]=u.useState(String(o.min+1)),[A,f]=u.useState(""),[h,g]=u.useState(""),[p,m]=u.useState(""),y=Number(a)<=Number(l);return i.jsxs(Al,{open:!0,title:"Add new child feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),g("");const s=(new ut).toHexString(),c=new Nr({changedIds:[o._id],typeName:"AddFeatureChange",assembly:r,addedFeature:{_id:s,refSeq:o.refSeq,min:Number(l)-1,max:Number(a),type:A},parentFeatureId:o._id});e.submit(c).then((()=>{n.apolloSetSelectedFeature(s)})),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:l,onChange:e=>{d(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:a,onChange:e=>{c(e.target.value)},error:y,helperText:y?'"End" must be greater than "Start"':null}),i.jsx(Su,{session:n,ontologyName:"Sequence Ontology",style:{width:170},value:A,filterTerms:wu,fetchValidTerms:async function(e,t,n){const r=await xu(e,t);if(r)return r;m(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,o),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(p),helperText:p}),onChange:(e,t)=>{var n;t&&(n=t,g(""),f(n))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:y||!(l&&a&&A),children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),h?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:h})}):null]})}class ku{clientStore;constructor(e){this.clientStore=e}}class Qu{dataStore;constructor(e){this.dataStore=e}recentChanges=[];undoneChanges=[];async submit(e,t={}){const{addToRecents:n=!0,submitToBackend:r=!0,updateJobsManager:i=!1}=t,a=o.getSession(this.dataStore),s=new AbortController,{jobsManager:c,isLocked:l,changeInProgress:u,setChangeInProgress:d}=o.getSession(this.dataStore);if(l)return a.notify("Cannot submit changes in locked mode"),void d(!1);if(u)return void a.notify("Could not submit change, there is another change still in progress");d(!0);const A={name:e.typeName,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{s.abort(new DOMException(`Cancelling change "${e.typeName}"`,"AbortError"))}};i&&c.runJob(A);const f=await co.frontendPreValidate(e);if(!f.ok){const e=`Pre-validation failed: "${f.resultsMessages}"`;return i&&c.abortJob(A.name,e),a.notify(e,"error"),void d(!1)}try{await e.execute(this.dataStore)}catch(e){return i&&c.abortJob(A.name,String(e)),console.error(e),a.notify(`Error encountered in client: ${String(e)}. Data may be out of sync, please refresh the page`,"error"),void d(!1)}if((await co.frontendPostValidate(e,this.dataStore)).ok||await this.undo(e),r){i&&c.update(A.name,"Submitting to driver");const{collaborationServerDriver:r,getBackendDriver:o}=this.dataStore,s=ie(e)?o(e.assembly)??r:r;let l;try{l=await s.submitChange(e,t)}catch(t){return i&&c.abortJob(A.name,String(t)),console.error(t),a.notify(String(t),"error"),await this.undo(e,!1),void d(!1)}if(!l.ok){const t=`Post-validation failed: "${f.resultsMessages}"`;return i&&c.abortJob(A.name,t),a.notify(t,"error"),await this.undo(e,!1),void d(!1)}e.notification&&a.notify(e.notification,"success"),n&&(this.recentChanges.push(e),this.undoneChanges=[])}i&&c.done(A),d(!1)}async undo(e,t=!0){const n=e.getInverse();return this.submit(n,{submitToBackend:t,addToRecents:!1})}async redo(e,t=!0){return this.submit(e,{submitToBackend:t,addToRecents:!1})}async undoLastChange(){const e=o.getSession(this.dataStore),t=this.recentChanges.pop();if(t)return this.undoneChanges.push(t),this.undo(t);e.notify("No changes to undo!","info")}async redoLastChange(){const e=o.getSession(this.dataStore),t=this.undoneChanges.pop();if(t)return this.recentChanges.push(t),this.redo(t);e.notify("No changes to redo!","info")}}class Nu extends ku{inFlight=new Map;refSeqMaps=new Map;async fetch(e,t,n){return e.getFetcher({locationType:"UriLocation",uri:t.toString()})(t,n)}async searchFeatures(e,t){const n=this.clientStore.getInternetAccount(t[0]),{baseURL:r}=n,o=new URL("features/searchFeatures",r),i=new URLSearchParams({assemblies:t.join(","),term:e});o.search=i.toString();const a=o.toString(),s=await this.fetch(n,a);if(!s.ok){const e=await ll(s,"searchFeatures failed");throw new Error(e)}return s.json()}async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:i}=e,{assemblyManager:a}=o.getSession(this.clientStore);if(!a.get(t))throw new Error(`Could not find assembly with name "${t}"`);const s=(await this.getRefSeqMapping(t)).get(r);if(!s)throw new Error(`Could not find refSeq "${r}"`);const c=s.id,l=this.clientStore.getInternetAccount(t),{baseURL:u}=l,d=new URL("features/getFeatures",u),A=new URLSearchParams({refSeq:c,start:String(i),end:String(n)});d.search=A.toString();const f=d.toString(),h=await this.fetch(l,f);if(!h.ok){const e=await ll(h,"getFeatures failed");throw new Error(e)}return this.checkSocket(t,r,l),h.json()}checkSocket(e,t,n){const{socket:r}=n,o=n.retrieveToken();if(!o)return;const i=vo(o),a=`${e}-${t}`,s=new Qu(this.clientStore);r.hasListeners(a)||r.on(a,(async e=>{if(n.setLastChangeSequenceNumber(Number(e.changeSequence)),e.userSessionId===i)return;const t=oe.fromJSON(e.changeInfo);var r;ie(r=t)&&void 0!==r.changedIds&&this.haveDataForChange(t)&&await s.submit(t,{submitToBackend:!1})}))}haveDataForChange(e){const{assembly:t,changedIds:n}=e;if(!this.clientStore.assemblies.get(t))return!1;for(const e of n)if(this.clientStore.getFeature(e))return!0;return!1}async getSequence(e){const t=`${e.refName}:${e.start}-${e.end}`,n=this.inFlight.get(t),{assemblyName:r,end:i,refName:a,start:s}=e,{assemblyManager:c}=o.getSession(this.clientStore);if(!c.get(r))throw new Error(`Could not find assembly with name "${r}"`);const l=(await this.getRefSeqMapping(r)).get(a);if(!l)throw new Error(`Could not find refSeq "${a}"`);const u=l.id;if(n)return{seq:await n,refSeq:u};let d=this.clientStore.assemblies.get(r);d||(d=this.clientStore.addAssembly(r));let A=d.refSeqs.get(u);A||(A=d.addRefSeq(u,a));const f=A.getSequence(s,i);if(f.length===i-s)return{seq:f,refSeq:u};const h=this.clientStore.getInternetAccount(r),{baseURL:g}=h,p=new URL("sequence",g),m=new URLSearchParams({refSeq:u,start:String(s),end:String(i)});p.search=m.toString();const y=p.toString(),_=this.getSeqFromServer(h,y,A,s,i);this.inFlight.set(t,_);const v=await _;return this.checkSocket(r,a,h),this.inFlight.delete(t),{seq:v,refSeq:u}}async getSeqFromServer(e,t,n,r,o){const i=await this.fetch(e,t);if(!i.ok){let e;try{e=await i.text()}catch{e=""}throw new Error(`getSequence failed: ${i.status} (${i.statusText})${e?` (${e})`:""}`)}const a=await i.text();return n.addSequence({sequence:a,start:r,stop:o}),a}async getRefSeqMapping(e){const t=this.refSeqMaps.get(e);if(t)return t;const{assemblyManager:n}=o.getSession(this.clientStore);if(!n.get(e))throw new Error(`Could not find assembly with name "${e}"`);const r=this.clientStore.getInternetAccount(e),{baseURL:i}=r,a=new URL("refSeqs",i),s=new URLSearchParams({assembly:e});a.search=s.toString();const c=a.toString(),l=await this.fetch(r,c);if(!l.ok){let e;try{e=await l.text()}catch{e=""}throw new Error(`getRefNameAliases failed: ${l.status} (${l.statusText})${e?` (${e})`:""}`)}const u=await l.json(),d=new Map(u.map((e=>[e.name,{refName:e.name,id:e._id,aliases:e.aliases}])));return this.refSeqMaps.set(e,d),d}async getRefNameAliases(e){return[...(await this.getRefSeqMapping(e)).values()].map((e=>({refName:e.refName,aliases:[...new Set([e.id,...e.aliases])],uniqueId:`alias-${e.id}`})))}async getRefSeqId(e,t){const n=await this.getRefSeqMapping(e);if(!n)return;const r=n.get(t);return r?.id}async getRegions(e){const{assemblyManager:t}=o.getSession(this.clientStore);if(!t.get(e))throw new Error(`Could not find assembly with name "${e}"`);const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,i=new URL("refSeqs",r),a=new URLSearchParams({assembly:e});i.search=a.toString();const s=i.toString(),c=await this.fetch(n,s);if(!c.ok){let e;try{e=await c.text()}catch{e=""}throw new Error(`getRegions failed: ${c.status} (${c.statusText})${e?` (${e})`:""}`)}return(await c.json()).map((e=>({refName:e.name,start:0,end:e.length})))}getAssemblies(e){const{assemblyManager:t}=o.getSession(this.clientStore);return t.assemblies.filter((t=>{const r=n.getConf(t,["sequence","metadata"]);return!(!(r&&r.apollo&&r.internetAccountConfigId)||e&&r.internetAccountConfigId!==e)}))}async submitChange(e,t={}){const{internetAccountId:n}=t,r=this.clientStore.getInternetAccount("assembly"in e?e.assembly:void 0,n),{baseURL:o}=r,i=new URL("changes",o).href,a=await this.fetch(r,i,{method:"POST",body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"}});if(!a.ok){const e=await ll(a,"submitChange failed");throw new Error(e)}const s=new ao;return a.ok||(s.ok=!1),s}}class Ru extends ku{async getFeatures(){return[[],[]]}async getSequence(e){const{assemblyName:t,end:n,refName:r,start:o}=e,i=this.clientStore.assemblies.get(t);if(!i)return{seq:"",refSeq:r};const a=i.refSeqs.get(r);return a?{seq:a.getSequence(o,n),refSeq:r}:{seq:"",refSeq:r}}async getRefNameAliases(e){const t=this.clientStore.assemblies.get(e),n=[];if(!t)return n;for(const[,e]of t.refSeqs)n.push({refName:e.name,aliases:[e._id],uniqueId:`alias-${e._id}`});return n}async getRegions(e){const t=this.clientStore.assemblies.get(e);if(!t)return[];const n=[];for(const[,r]of t.refSeqs)n.push({assemblyName:e,refName:r.name,start:r.sequence[0].start,end:r.sequence[0].stop});return n}getAssemblies(){const{assemblyManager:e}=o.getSession(this.clientStore);return e.assemblies.filter((e=>{const t=n.getConf(e,["sequence","metadata"]);return Boolean(t&&t.apollo&&!t.file&&!t.internetAccountConfigId)}))}async submitChange(e,t={}){const{clientStore:n}=this,{assemblies:r}=n;n.clearCheckResults();for(const[,e]of r)if("InMemoryFileDriver"===e.backendDriverType){const t=await Oc(e);n.addCheckResults(t)}return new ao}async searchFeatures(e,t){return[]}}class Du extends ku{async loadAssembly(e){const{assemblyManager:t}=o.getSession(this.clientStore),r=t.get(e);if(!r)throw new Error(`Assembly ${e} not found`);const{file:i}=n.getConf(r,["sequence","metadata"]),a=require("node:fs");return Mc(e,await a.promises.readFile(i,"utf8"),this.clientStore)}async getAssembly(e){let t=this.clientStore.assemblies.get(e);return t||(t=await this.loadAssembly(e)),t}async getRefNameAliases(e){const t=await this.getAssembly(e),n=[];for(const[,e]of t.refSeqs)n.push({refName:e.name,aliases:[e._id],uniqueId:`alias-${e._id}`});return n}async getFeatures(e){return await this.getAssembly(e.assemblyName),[[],[]]}async getSequence(e){const{assemblyName:t,end:n,refName:r,start:o}=e,i=(await this.getAssembly(t)).refSeqs.get(r);if(!i)throw new Error(`refSeq ${r} not found in client data store`);return{seq:i.getSequence(o,n),refSeq:r}}async getRegions(e){const t=await this.getAssembly(e),n=[];for(const[,r]of t.refSeqs)n.push({assemblyName:e,refName:r.name,start:r.sequence[0].start,end:r.sequence[0].stop});return n}getAssemblies(){const{assemblyManager:e}=o.getSession(this.clientStore);return e.assemblies.filter((e=>{const t=n.getConf(e,["sequence","metadata"]);return Boolean(t&&t.apollo&&!t.internetAccountConfigId&&t.file)}))}async submitChange(e){if(!ie(e))throw new Error(`Cannot use this type of change with local file: "${e.typeName}"`);const{assemblyManager:t}=o.getSession(this.clientStore),r=t.get(e.assembly);if(!r)throw new Error(`Could not find assembly with name "${e.assembly}"`);const{file:i}=n.getConf(r,["sequence","metadata"]),a=this.clientStore.assemblies.get(e.assembly);if(!a)throw new Error(`Could not find assembly in client with name "${e.assembly}"`);const s=new Set(...a.refSeqs.keys()),{checkResults:l}=this.clientStore;for(const e of l.values())s.has(e.refSeq)&&l.delete(e._id);const u=await Oc(a);this.clientStore.addCheckResults(u);const d=[{directive:"gff-version",value:"3"}];for(const[,e]of a.refSeqs)d.push({directive:"sequence-region",value:`${e.name} 1 ${e.sequence[0].stop}`});for(const e of a.comments)d.push({comment:e});for(const[,e]of a.refSeqs){const{features:t}=e;for(const[,e]of t)d.push(yt(c.getSnapshot(e)))}for(const[,e]of a.refSeqs){const[t]=e.sequence,n=Hr(t.sequence,80).join("\n");d.push({id:e.name,description:e.description,sequence:n})}const A=jc.formatSync(d),f=require("node:fs");return await f.promises.writeFile(i,A,"utf8"),new ao}async searchFeatures(e,t){return[]}}var Fu;function Tu(e,t,n,r){const o={_id:(new ut).toHexString(),refSeq:e,type:"CDS",min:n,max:r,strand:t},i={_id:(new ut).toHexString(),refSeq:e,type:"exon",min:n,max:r,strand:t},a={};return a[o._id]=o,a[i._id]=i,{_id:(new ut).toHexString(),refSeq:e,type:"mRNA",min:n,max:r,strand:t,children:a}}function ju({changeManager:e,handleClose:t,region:n,session:r}){const[o,a]=u.useState(String(n.end)),[c,l]=u.useState(String(n.start+1)),[d,A]=u.useState(Fu.GENE_AND_SUBFEATURES),[f,h]=u.useState(""),[g,p]=u.useState(),[m,y]=u.useState(""),_=Number(o)<=Number(c);let v=Boolean(_)||!(c&&o&&d);return(d===Fu.CUSTOM&&!f||!g&&d===Fu.GENE_AND_SUBFEATURES||!g&&d===Fu.TRANSCRIPT_AND_SUBFEATURES)&&(v=!0),i.jsxs(Al,{open:!0,title:"Add new feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:async function(i){i.preventDefault(),y("");const a=r.apolloDataStore.getBackendDriver(n.assemblyName);if(!a)return void y("No backend driver found");let s=n.refName;if(a instanceof Nu){const e=await a.getRefSeqId(n.assemblyName,n.refName);if(!e)return void y(`Could not find refSeq for "${n.refName}"`);s=e}if(d===Fu.GENE_AND_SUBFEATURES){const i=Tu(s,g,Number(c)-1,Number(o)),a={};a[i._id]=i;const l=(new ut).toHexString(),u=new Nr({changedIds:[l],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:l,refSeq:s,min:Number(c)-1,max:Number(o),type:"gene",strand:g,children:a}});return e.submit(u).then((()=>{r.apolloSetSelectedFeature(l)})),void t()}if(d===Fu.TRANSCRIPT_AND_SUBFEATURES){const i=Tu(s,g,Number(c)-1,Number(o)),a=new Nr({changedIds:[i._id],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:i});return e.submit(a).then((()=>{r.apolloSetSelectedFeature(i._id)})),void t()}if(!f)return void y("No type selected");const l=(new ut).toHexString(),u=new Nr({changedIds:[l],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:l,refSeq:s,min:Number(c)-1,max:Number(o),type:f,strand:g}});e.submit(u).then((()=>{r.apolloSetSelectedFeature(l)})),t()},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:Number(c),onChange:e=>{l(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:o,onChange:e=>{a(e.target.value)},error:_,helperText:_?'"End" must be greater than "Start"':null}),i.jsxs(s.FormControl,{children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Strand"}),i.jsxs(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Strand",value:g?.toString(),onChange:function(e){switch(y(""),Number(e.target.value)){case 1:p(1);break;case-1:p(-1);break;default:p(void 0)}},children:[i.jsx(s.MenuItem,{value:void 0}),i.jsx(s.MenuItem,{value:1,children:"+"}),i.jsx(s.MenuItem,{value:-1,children:"-"})]})]}),i.jsx(s.FormControl,{style:{marginTop:20},children:i.jsxs(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:Fu.GENE_AND_SUBFEATURES,name:"radio-buttons-group",value:d,onChange:e=>{y("");const{value:t}=e.target;Object.keys(Fu).includes(t)&&A(Fu[t])},children:[i.jsx(s.FormControlLabel,{value:Fu.GENE_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add gene and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a gene with a single mRNA, exon, and CDS",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Fu.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add transcript and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a single mRNA with exon and CDS, but without a parent gene",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(xc,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Fu.CUSTOM,checked:d!==Fu.GENE_AND_SUBFEATURES&&d!==Fu.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:"Add feature with a sequence ontology type"})]})}),d===Fu.CUSTOM?i.jsx(Su,{session:r,ontologyName:"Sequence Ontology",style:{width:170},value:f,filterTerms:wu,renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{var n;t&&(n=t,y(""),h(n))}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:v,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),m?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:m})}):null]})}function Mu(e,t){const n=(new ut).toHexString();t.push(n);const r={};if(e.children)for(const n of Object.values(e.children)){const e=Mu(n,t);r[e._id]=e}const o="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return{...e,refSeq:o,children:e.children&&r,_id:n}}function Ou({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a}){const{assemblyManager:l}=r,d=l.assemblyList,[A,f]=u.useState(d.find((e=>e.name!==o))?.name),[h,g]=u.useState([]),[p,m]=u.useState(""),[y,_]=u.useState(a.min),[v,b]=u.useState("");function C(e,t){const n={};if(e.children)for(const r of Object.values(e.children)){const e=C(r,t);e.refSeq=p,e.min=e.min+t,e.max=e.max+t,n[e._id]=e}const r="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString(),o="string"==typeof e._id?e._id:e._id.toHexString();return{...e,refSeq:r,children:e.children&&n,_id:o}}return u.useEffect((()=>{(async function(){if(m(""),!A)return void b("No assemblies to copy to");const e=await l.waitForAssembly(A);if(!e)return;const{refNameAliases:t}=e;if(!t)return;const n=[...Object.entries(t)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t})));g(n),m(n[0]?._id||"")})().catch((e=>{b(String(e))}))}),[A,l]),i.jsxs(Al,{open:!0,title:"Copy features and annotations",handleClose:t,maxWidth:!1,"data-testid":"copy-feature",children:[i.jsxs("form",{onSubmit:async function(n){if(!A)return;n.preventDefault(),b("");const o=a.length,i=await l.waitForAssembly(A);if(!i)return void b(`Assembly not found: ${A}.`);const s=i.getCanonicalRefName(p),u=i.regions?.find((e=>e.refName===s));if(!u)return void b(`RefSeq not found: ${p}.`);const d=y+o;if(d>u.end)return void b(`Feature would extend beyond the bounds of the selected reference sequence. (Feature would end at ${d}, but reference sequence ends at ${u.end})`);if(y<u.start)return void b(`Reference sequence starts at ${u.start}, feature cannot start before that.`);const f=[],h=Mu(c.getSnapshot(a),f),g={...h.attributes};"Parent"in g&&delete g.Parent,h.refSeq=p;const m=y-h.min;h.min=y,h.max=y+o;const _=C(h,m),v=new Nr({changedIds:[h._id],typeName:"AddFeatureChange",assembly:A,addedFeature:{_id:h._id,refSeq:h.refSeq,min:h.min,max:h.max,type:h.type,children:_.children,attributes:g,strand:h.strand},copyFeature:!0,allIds:f});e.submit(v).then((()=>{r.apolloSetSelectedFeature(h._id)})),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Target assembly"}),i.jsx(s.Select,{labelId:"label",value:A,onChange:function(e){f(e.target.value)},children:d.filter((e=>e.name!==o)).map((e=>i.jsx(s.MenuItem,{value:e.name,children:n.readConfObject(e,"displayName")},e.name)))}),i.jsx(s.DialogContentText,{children:"Target reference sequence"}),i.jsx(s.Select,{labelId:"label",value:p,onChange:function(e){m(e.target.value)},children:h.map((e=>i.jsx(s.MenuItem,{value:e._id,children:e.name},e._id)))}),i.jsx(s.DialogContentText,{children:"Start position in target reference sequence"}),i.jsx(s.TextField,{margin:"dense",type:"number",fullWidth:!0,variant:"outlined",value:y,onChange:e=>{_(Number(e.target.value))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!A||!p||!y,variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),v?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:v})}):null]})}function Lu({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=c.getRoot(n),[o,a]=u.useState(""),[l,d]=u.useState(!1),[A,f]=u.useState(!1),h=r.filter((e=>"ApolloInternetAccount"===e.type));if(0===h.length)throw new Error("No Apollo internet account found");const[g,p]=u.useState(h[0]),{collaborationServerDriver:m}=n.apolloDataStore,y=m.getAssemblies(),[_,v]=u.useState(y.at(0));return i.jsxs(Al,{open:!0,title:"Delete Assembly",handleClose:t,maxWidth:!1,"data-testid":"delete-assembly",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),f(!0),a(""),!_)return void a("Must select assembly!");const r=new Fr({typeName:"DeleteAssemblyChange",assembly:_.name});await e.submit(r,{internetAccountId:g.internetAccountId}),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[h.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:g.internetAccountId,onChange:function(e){f(!1);const t=h.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);p(t)},disabled:A&&!o,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:_?.name??"",onChange:function(e){const t=y.find((t=>t.name===e.target.value));v(t)},disabled:0===y.length,children:y.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx(s.DialogContentText,{children:i.jsx("strong",{style:{color:"red"},children:"NOTE: All assembly data will be deleted and this operation cannot be undone!"})}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:l,onChange:()=>{d(!l)}}),label:"I understand that all assembly data will be deleted"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!_||!l,variant:"contained",type:"submit",children:"Delete"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}function Pu({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:l}){const[d,A]=u.useState(""),{ontologyManager:f}=r.apolloDataStore,{featureTypeOntology:h}=f;function g(e){if(!e.parent?.children||1===e.parent.children.size)return;const t=[];for(const n of e.parent.children.values())h?.isTypeOf(n.type,"CDS")||t.push(n);t.sort(((e,t)=>e.min-t.min));const n=[];for(const t of e.parent.children.values())h?.isTypeOf(t.type,"CDS")||n.push(t);if(n.sort(((e,t)=>t.max-e.max)),e.min===t[0].min){let n;for(const r of t)if(r._id!==e._id&&r.min>=e.min){n=r.min;break}if(n&&n!=e.parent.min)return{typeName:"LocationStartChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.min,newLocation:n}}if(e.max===n[0].max){let t;for(const r of n)if(r._id!=e._id&&r.max<=e.max){t=r.max;break}if(t&&t!=e.parent.max)return{typeName:"LocationEndChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.max,newLocation:t}}}return i.jsxs(Al,{open:!0,title:"Delete feature",handleClose:t,maxWidth:!1,"data-testid":"delete-feature",children:[i.jsxs("form",{onSubmit:r=>{!async function(r){r.preventDefault(),A(""),n?._id===l._id&&o();const i=[],s=new kr({changedIds:[l._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:c.getSnapshot(l),parentFeatureId:l.parent?._id}]});if(h&&(h.isTypeOf(l.type,"transcript")||h.isTypeOf(l.type,"pseudogenic_transcript"))){const e=g(l);e&&i.push(e)}if(h&&h.isTypeOf(l.type,"exon")){const e=function(e){if(!h)return;if(!h.isTypeOf(e.type,"exon"))return;if(!e.parent?.cdsLocations||0===e.parent.cdsLocations.length||0===e.parent.cdsLocations[0].length)return;if(!e.parent.children)throw new Error("Unable to find parent of CDS");if(1!=e.parent.cdsLocations.length)throw new Error("Unable to handle a transcript with multiple CDSs");const t=(e.parent.cdsLocations.at(0)??[]).sort((({min:e},{min:t})=>e-t));let n;for(const r of e.parent.children.values())if(r.type===t[0].type){n=r;break}if(!n)throw new Error("Unable to find CDS");const r=t[0].min,o=t[t.length-1].max;if(!(e.min>r&&e.max<o||e.max<r||e.min>o)){if(e.min<=r&&e.max>=o)return new kr({changedIds:[n._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:c.getSnapshot(n),parentFeatureId:n.parent?._id}]});if(e.min<=r&&e.max>r){let r;for(const n of t)if(n.min>e.max){r=n.min;break}if(!r)throw new Error("Error setting new CDS start");return{typeName:"LocationStartChange",changedId:n._id,featureId:n._id,oldLocation:n.min,newLocation:r}}if(e.min<o&&e.max>=o){let r;for(const n of t.reverse())if(n.max<e.min){r=n.max;break}if(!r)throw new Error("Error setting new CDS end");return{typeName:"LocationEndChange",changedId:n._id,featureId:n._id,oldLocation:n.max,newLocation:r}}throw new Error("Unexpected relationship between exon and CDS")}}(l);e&&("DeleteFeatureChange"===e.typeName?(s.changedIds.push(...e.changedIds),s.changes.push(...e.changes)):i.push(e));const t=g(l);if(t){i.push(t);const e=l.parent?.parent;if(e?.children)if("LocationStartChange"===t.typeName){let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.min<n&&(n=r.min);n!=e.min&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.min,newLocation:n})}else{let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.max>n&&(n=r.max);n!=e.max&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.max,newLocation:n})}}}const u=function(e,t){if(0===e.length)return;const n=new Ur({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:t}),r=new qr({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:t});for(const t of e)"LocationStartChange"===t.typeName&&(n.changedIds.push(t.changedId),n.changes.push({featureId:t.featureId,oldStart:t.oldLocation,newStart:t.newLocation})),"LocationEndChange"===t.typeName&&(r.changedIds.push(t.changedId),r.changes.push({featureId:t.featureId,oldEnd:t.oldLocation,newEnd:t.newLocation}));if(n.changedIds.length>0&&0===r.changedIds.length)return n;if(r.changedIds.length>0&&0===n.changedIds.length)return r;throw new Error("Unexpected list of changes")}(i,a);await e.submit(s),u&&await e.submit(u),t(),r.preventDefault()}(r)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to delete the selected feature?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}!function(e){e.GENE_AND_SUBFEATURES="GENE_AND_SUBFEATURES",e.TRANSCRIPT_AND_SUBFEATURES="TRANSCRIPT_AND_SUBFEATURES",e.CUSTOM="CUSTOM"}(Fu||(Fu={}));var qu,Ju={exports:{}},Uu=(qu||(qu=1,function(e,t){!function(){function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){a(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==("undefined"==typeof window?"undefined":X(window))&&window.window===window?window:"object"==("undefined"==typeof self?"undefined":X(self))&&self.self===self?self:"object"==X(se)&&se.global===se?se:void 0,i=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=o.saveAs||("object"!=("undefined"==typeof window?"undefined":X(window))||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(e,i,a){var s=o.URL||o.webkitURL,c=document.createElement("a");c.download=i=i||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?r(c):n(c.href)?t(e,i,a):r(c,c.target="_blank")):(c.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(c.href)}),4e4),setTimeout((function(){r(c)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=X(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(n(e))t(e,o,i);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){r(a)}))}}:function(e,n,r,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var s="application/octet-stream"===e.type,c=/constructor/i.test(o.HTMLElement)||o.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||s&&c||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=e:location=e,a=null},u.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,A=d.createObjectURL(e);a?a.location=A:location.href=A,a=null,setTimeout((function(){d.revokeObjectURL(A)}),4e4)}});o.saveAs=a.saveAs=a,e.exports=a}()}(Ju)),Ju.exports);function Gu({handleClose:e,session:t}){const[r,o]=u.useState(!1),[a,l]=u.useState(),[d,A]=u.useState(""),{collaborationServerDriver:f,getInternetAccount:h,inMemoryFileDriver:g}=t.apolloDataStore,p=[...f.getAssemblies(),...g.getAssemblies()];return i.jsxs(Al,{open:!0,title:"Export GFF3",handleClose:e,maxWidth:!1,"data-testid":"download-gff3",children:[i.jsxs("form",{onSubmit:async function(o){if(o.preventDefault(),A(""),!a)return void A("Must select assembly to download");const{internetAccountConfigId:i}=n.getConf(a,["sequence","metadata"]);i?await async function(e){if(!a)return void A("Must select assembly to download");const t=h(a.configuration.name,e),n=new URL("export/getID",t.baseURL),o=new URLSearchParams({assembly:a.name});n.search=o.toString();const i=n.toString(),s=t.getFetcher({locationType:"UriLocation",uri:i}),c=await s(i,{method:"GET"});if(!c.ok){const e=await ll(c,"Error when exporting ID");return void A(e)}const{exportID:l}=await c.json(),u=new URL("export",t.baseURL),d=new URLSearchParams({exportID:l,includeFASTA:r?"true":"false"});u.search=d.toString();const f=u.toString();window.open(f,"_blank")}(i):function(e){if(!a)return void A("Must select assembly to download");const{assemblies:t}=e.apolloDataStore,r=t.get(a.name),o=r?.refSeqs;if(!o)return void A(`No refSeqs found for assembly "${a.name}"`);const i=[{directive:"gff-version",value:"3"}],s=n.getConf(a,["sequence","adapter","features"]);for(const e of s){const{end:t,refName:n,start:r}=e;i.push({directive:"sequence-region",value:`${n} ${r+1} ${t}`})}for(const[,e]of o){const{features:t}=e;if(t)for(const[,e]of t)i.push(yt(c.getSnapshot(e)))}for(const e of s){const{refName:t,seq:n}=e;i.push({id:t,description:"",sequence:n})}const l=jc.formatSync(i),u=new Blob([l],{type:"text/plain;charset=utf-8"});Uu.saveAs(u,`${a.displayName??a.name}.gff3`)}(t),e()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:a?.name??"",onChange:function(e){const t=p.find((t=>t.name===e.target.value));l(t)},disabled:0===p.length,children:p.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName??e.name},e.name)))}),i.jsx(s.DialogContentText,{children:"Select assembly to export to GFF3"}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{"data-testid":"include-fasta-checkbox",control:i.jsx(s.Checkbox,{checked:r,onChange:()=>{o(!r)}}),label:"Include fasta sequence in GFF output"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!a,variant:"contained",type:"submit",children:"Download"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}function Hu({changeManager:e,handleClose:t,session:r}){const{apolloDataStore:o}=r,[a,c]=u.useState(),[l,d]=u.useState(),[A,f]=u.useState(""),[h,g]=u.useState(!1),[p,m]=u.useState(),[y,_]=u.useState(!1),[v,b]=u.useState(!0),[C,I]=u.useState(!1),{collaborationServerDriver:w,getInternetAccount:E}=o,x=w.getAssemblies();return u.useEffect((()=>{l&&(async()=>{const{internetAccountConfigId:e}=n.getConf(l,["sequence","metadata"]),t=E(l.name,e);if(!t)throw new Error("No Apollo internet account found");const{baseURL:r}=t,o=new URL("features/count",r),i=new URLSearchParams({assemblyId:l.name});o.search=i.toString();const a=t.getFetcher({locationType:"UriLocation",uri:o.toString()});I(!0);const s=await a(o.toString(),{method:"GET"});if(!s.ok)throw new Error(await ll(s));{const e=await s.json();m(e.count)}I(!1)})().catch((e=>{console.error(e),f(e.message??e)}))}),[E,r,l]),i.jsxs(Al,{open:!0,title:"Import Features from GFF3 file",handleClose:t,maxWidth:!1,"data-testid":"import-features-dialog",children:[C?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(o){o.preventDefault(),f(""),I(!0),g(!0);let i="";if(!a)return void f("must select a file");if(!l)return void f("Must select assembly to download");const{internetAccountConfigId:s}=n.getConf(l,["sequence","metadata"]),c=E(l.name,s),{baseURL:u}=c,d=new URL("files",u);d.searchParams.set("type","text/x-gff3");const A=d.href,h=new FormData;h.append("file",a),h.append("fileName",a.name),h.append("type","text/x-gff3");const p=c.getFetcher({locationType:"UriLocation",uri:A});t();const{jobsManager:m}=r,_=new AbortController,b={name:`Importing features for ${l.displayName}`,statusMessage:"Uploading file, this may take awhile",progressPct:0,cancelCallback:()=>{_.abort(new DOMException(`Canceling importing of features to ${l.displayName}`,"AbortError")),m.abortJob(b.name)}};if(m.runJob(b),p){const{signal:e}=_,t=await p(A,{method:"POST",body:h,signal:e});if(!t.ok){const e=await ll(t,"Error when inserting new features (while uploading file)");return m.abortJob(b.name,e),void f(e)}i=(await t.json())._id}const C=new Rr({typeName:"AddFeaturesFromFileChange",assembly:l.name,fileId:i,parseOptions:{strict:v},deleteExistingFeatures:y});m.done(b),await e.submit(C,{updateJobsManager:!0})},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:l?.name??"",onChange:function(e){const t=x.find((t=>t.name===e.target.value));d(t),g(!1)},disabled:h&&!A,children:x.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName??e.name},e.name)))}),i.jsx(s.DialogContentText,{children:"Upload GFF3 to load features"}),i.jsx("input",{type:"file",onChange:function(e){g(!1),e.target.files&&c(e.target.files[0])},disabled:h&&!A}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:h&&!A,control:i.jsx(s.Checkbox,{checked:v,onChange:function(e){b(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),p&&p>0?i.jsxs(i.Fragment,{children:[i.jsx(s.FormControlLabel,{label:"Delete existing features",disabled:h&&!A,control:i.jsx(s.Checkbox,{checked:y,onChange:function(e){_(e.target.checked)},slotProps:{input:{"aria-label":"controlled"}},color:"warning"})}),i.jsxs(s.FormHelperText,{children:["This assembly has ",p," features that will be deleted"]})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!(l&&a&&void 0!==p)||h,variant:"contained",type:"submit",children:h?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]})]}),A?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:A})}):null]})}function Yu({handleClose:e,session:t}){const{internetAccounts:n}=c.getRoot(t),[r,o]=u.useState(""),a=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===a.length)throw new Error("No Apollo internet account found");const[l,d]=u.useState(a[0]);return i.jsxs(Al,{open:!0,title:"Log out",handleClose:e,maxWidth:!1,"data-testid":"log-out",children:[i.jsxs("form",{onSubmit:function(e){e.preventDefault(),o(""),l.removeToken(),globalThis.location.reload()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[a.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:l.internetAccountId,onChange:function(e){const t=a.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);d(t)},children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Are you sure you want to log out?"})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!l,variant:"contained",type:"submit",children:"Log Out"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function zu({handleClose:e,session:t}){const{internetAccounts:n}=c.getRoot(t),[r,o]=u.useState(""),[a,l]=u.useState(!1),d=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[A,f]=u.useState(d[0]),[h,g]=u.useState([]),[p,m]=u.useState([]),{collaborationServerDriver:y}=t.apolloDataStore,_=y.getAssemblies(),[v,b]=u.useState(_.at(0));function C(e,t){const n=[...p],r=e.target.value;if(t)n.includes(r)||(n.push(r),m(n));else{const e=n.indexOf(r,0);-1!==e&&n.splice(e,1),m(n)}}return u.useEffect((()=>{(async function(){const{baseURL:e,getFetcher:t}=A,n=new URL("checks/types",e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await ll(i,"Error when retrieving checks from server");return void o(e)}const a=await i.json();g(a)})().catch((e=>{o(String(e))}))}),[A]),u.useEffect((()=>{(async function(){if(!v)return;const{baseURL:e,getFetcher:t}=A,n=new URL(`assemblies/${v.name}`,e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await ll(i,"Error when retrieving assembly from server");return void o(e)}const a=await i.json();m(a.checks)})().catch((e=>{o(String(e))}))}),[v,A]),i.jsxs(Al,{open:!0,title:"Manage Checks",handleClose:e,"data-testid":"manage-checks",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),!v)return void o("Must select assembly!");const{notify:r}=t,{baseURL:i,getFetcher:a}=A,s=new URL("assemblies/checks",i).href,c=a({locationType:"UriLocation",uri:s}),l=await c(s,{method:"POST",body:JSON.stringify({_id:v.name,checks:p,name:""}),headers:{"Content-Type":"application/json"}});if(l.ok)r("Assembly checks updated successfully","success"),e();else{const e=await ll(l,"Error when updating assembly checks");o(e)}},children:[i.jsxs(s.DialogContent,{children:[d.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:A.internetAccountId,onChange:function(e){l(!1);const t=d.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);f(t)},disabled:a&&!r,children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{style:{width:300},labelId:"label",value:v?.name??"",onChange:function(e){const t=_.find((t=>t.name===e.target.value));b(t)},disabled:0===_.length,children:_.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx("br",{}),i.jsx("br",{}),i.jsx(s.TableContainer,{component:s.Paper,children:i.jsxs(s.Table,{children:[i.jsx(s.TableHead,{children:i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:"Check name"}),i.jsx(s.TableCell,{children:"Use check"})]})}),i.jsx(s.TableBody,{children:h.map((e=>i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:e.name}),i.jsx(s.TableCell,{children:i.jsx(s.Checkbox,{value:e._id,checked:p.includes(e._id),onChange:C})})]},e._id)))})]})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Ku({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=c.getRoot(n),o=r.filter((e=>"ApolloInternetAccount"===e.type)).filter((e=>e.role?.includes("admin")));if(0===o.length)throw new Error("No Apollo internet account found");const[a,l]=u.useState(""),[A,f]=u.useState(o[0]),[h,g]=u.useState([]);function p(e){return e===A.getUserId()}u.useEffect((()=>{(async function(){const{baseURL:e}=A,t=new URL("users",e).href,n=A.getFetcher({locationType:"UriLocation",uri:t}),r=await n(t,{method:"GET"});if(!r.ok){const e=await ll(r,"Error when getting user data from db");return void l(e)}const o=await r.json();g(o.map((e=>void 0===e.role?{...e,role:""}:e)))})().catch((e=>{l(String(e))}))}),[A]);const m=[{field:"username",headerName:"User",width:140},{field:"email",headerName:"Email",width:160},{field:"role",headerName:"Role",width:140,type:"singleSelect",valueOptions:["readOnly","user","admin","none"],getOptionLabel(e){switch(e){case"readOnly":return"Read-only";case"user":return"User";case"admin":return"Admin";case"none":return"None";default:return"unknown"}},editable:!0},{field:"actions",type:"actions",getActions:t=>[i.jsx(d.GridActionsCellItem,{icon:i.jsx(ga,{}),onClick:async()=>{globalThis.confirm("Delete this user?")&&await async function(t){const n=new Tr({typeName:"DeleteUserChange",userId:t});await e.submit(n,{internetAccountId:A.internetAccountId}),g((e=>e.filter((e=>e._id!==t))))}(t.id)},disabled:p(t.id),label:"Delete"},`delete-${t.id}`)]}];return i.jsxs(Al,{open:!0,fullScreen:!0,title:"Manage users",handleClose:t,"data-testid":"manage-users",children:[i.jsxs(s.DialogContent,{children:[o.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:A.internetAccountId,onChange:function(e){const t=o.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);f(t)},disabled:!a,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx("div",{style:{height:"100%",width:"100%"},children:i.jsx(d.DataGrid,{pagination:!0,rows:h,columns:m,getRowId:e=>e._id,slots:{toolbar:d.GridToolbar},getRowHeight:()=>"auto",isCellEditable:e=>!p(e.id),processRowUpdate:async function(t){const n=new ro({typeName:"UserChange",role:t.role,userId:t._id});return await e.submit(n,{internetAccountId:A.internetAccountId}),t},onProcessRowUpdateError:e=>{l(String(e))}})})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})}),a?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:a})}):null]})}function Wu(e,t){const n=t[e];let r;if("three_prime"===e)r=`3'end (coords: ${n.min+1}-${n.max})`;else{if("five_prime"!==e)throw new Error(`Unexpected direction: "${e}"`);r=`5'end (coords: ${n.min+1}-${n.max})`}return r}function Vu({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[l,d]=u.useState(""),[A,f]=u.useState(),h=function(e){const t={},n=e.parent;if(!n)throw new Error("Unable to find parent of reference exon");let r=[];if(n.children)for(const[,e]of n.children)"exon"===e.type&&r.push(e);r=r.sort(((e,t)=>e.min===t.min?e.max-t.max:e.min-t.min)),n.strand&&-1===n.strand&&(r=r.reverse());let o=0;for(const n of r){if(n._id===e._id){r.length>o+1&&(t.three_prime=r[o+1]),o>0&&(t.five_prime=r[o-1]);break}o++}return t}(a);return i.jsxs(Al,{open:!0,title:"Merge exons",handleClose:t,maxWidth:!1,"data-testid":"merge-exons",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d("");const{parent:s}=a;if(!A||!s)return;n?._id===a._id&&r();const l=new Vr({changedIds:[a._id],typeName:"MergeExonsChange",assembly:o,firstExon:c.getSnapshot(a),secondExon:c.getSnapshot(A),parentFeatureId:s._id});e.submit(l),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(h).length?"There are no neighbouring exons to merge with":"Merge with exon on:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:A,onChange:e=>{d("");const{value:t}=e.target;f(h[t])},children:Object.keys(h).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:Wu(e,h)})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(h).length||void 0===A,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function $u(e){let t;return t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id,`${t} [${e.min+1}-${e.max}]`}function Xu({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:l}){const[d,A]=u.useState(""),f=function(e,t){const n=e.parent;if(!n)throw new Error("Unable to find parent of reference transcript");const{featureTypeOntology:r}=t.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");const o={};if(n.children)for(const[,t]of n.children)r.isTypeOf(t.type,"transcript")&&t._id!==e._id&&(o[t._id]=t);return o}(l,r),h=Object.keys(f).at(0),[g,p]=u.useState(h);return i.jsxs(Al,{open:!0,title:"Merge transcripts",handleClose:t,maxWidth:!1,"data-testid":"merge-transcripts",children:[i.jsxs("form",{onSubmit:function(r){if(r.preventDefault(),A(""),!g)return;const i=f[g];if(n?._id===l._id&&o(),!l.parent)throw new Error("Cannot find parent");const s=new Xr({changedIds:[l._id],typeName:"MergeTranscriptsChange",assembly:a,firstTranscript:c.getSnapshot(l),secondTranscript:c.getSnapshot(i),parentFeatureId:l.parent._id});e.submit(s),t()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(f).length?"There are no transcripts to merge with":"Merge with transcript:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:g,onChange:e=>{A("");const{value:t}=e.target;p(t)},children:Object.keys(f).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:$u(f[e])})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(f).length||void 0===g,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}var Zu=function(){return crypto.getRandomValues(new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21)).reduce((function(e,t){return e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")}),"")};function ed({handleClose:e,session:t}){const{apolloDataStore:n}=t,{addAssembly:r,addSessionAssembly:a,assemblyManager:c,notify:l}=t,[d,A]=u.useState(null),[f,h]=u.useState(""),[g,p]=u.useState(""),[m,y]=u.useState(!1),_=s.useTheme();return i.jsxs(Al,{open:!0,title:"Open local GFF3 file",handleClose:e,maxWidth:!1,"data-testid":"open-local-file",children:[i.jsxs("form",{onSubmit:async function(i){if(i.preventDefault(),p(""),y(!0),!d)throw new Error("No file selected");const s=await new Response(d).text(),u=`${f}-${d.name}-${Zu(8)}`;try{await Mc(u,s,n)}catch(t){return console.error(t),l(`Error loading GFF3 ${d.name}, ${String(t)}`,"error"),void e()}const A={};if(o.isElectron){const{webUtils:e}=globalThis.require("electron");A.file=e.getPathForFile(d)}const h={name:u,aliases:[f],displayName:f,sequence:{trackId:`sequenceConfigId-${f}`,type:"ReferenceSequenceTrack",adapter:{type:"ApolloSequenceAdapter",assemblyId:u},metadata:{apollo:!0,...A}}};await(o.isElectron?r?.(h):(a||r)(h));const g=await c.waitForAssembly(h.name);g?(t.addApolloTrackConfig(g),l(`Loaded GFF3 ${d.name}`,"success")):l(`Error loading GFF3 ${d.name}`,"error"),e()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.FormControl,{children:[i.jsxs("div",{style:{flexDirection:"row"},children:[i.jsxs(s.Button,{variant:"contained",component:"label",style:{marginRight:_.spacing()},children:["Choose File",i.jsx("input",{type:"file",required:!0,hidden:!0,onChange:function(e){const t=e.target.files?.item(0);if(t&&(p(""),A(t),!f)){const e=t.name,n=e.lastIndexOf(".");h(-1===n?e:e.slice(0,n))}}})]}),d?d.name:"No file chosen"]}),i.jsx(s.FormHelperText,{children:"Make sure your GFF3 has an embedded FASTA section"})]}),i.jsx(s.TextField,{required:!0,label:"Assembly name",value:f,onChange:function(e){h(e.target.value)}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!1,variant:"contained",type:"submit",children:m?"Submitting...":"Submit"}),i.jsx(s.Button,{disabled:m,variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),g?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:g})}):null]})}const td=Ec()((e=>({changeTextarea:{fontFamily:"monospace",width:600,resize:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius}})));function nd({handleClose:e,session:t}){const{internetAccounts:n}=c.getRoot(t),r=n.find((e=>"ApolloInternetAccount"===e.type));if(!r)throw new Error("No Apollo internet account found");const{baseURL:o}=r,{classes:a}=td(),[l,A]=u.useState(),[f,h]=u.useState([]),{collaborationServerDriver:g}=t.apolloDataStore,p=g.getAssemblies(),[m,y]=u.useState(p.at(0)),_=[{field:"sequence"},{field:"typeName",headerName:"Change type",width:200,type:"singleSelect",valueOptions:[...ne.changes.keys()]},{field:"changes",headerName:"Change JSON",width:600,renderCell:({value:e})=>i.jsx("textarea",{className:a.changeTextarea,value:JSON.stringify(e),readOnly:!0})},{field:"user",headerName:"User",width:140},{field:"createdAt",headerName:"Time",width:160,type:"dateTime",valueGetter:e=>e&&new Date(e)}];return u.useEffect((()=>{(async function(){if(!m)return;const e=new URL("changes",o),t=new URLSearchParams({assembly:m.name});e.search=t.toString();const n=e.toString(),i=r?.getFetcher({locationType:"UriLocation",uri:n});if(i){const e=await i(n,{headers:new Headers({"Content-Type":"application/json"})});if(!e.ok){const t=await ll(e,"Error when retrieving changes");return void A(t)}const t=await e.json();h(t)}})().catch((e=>{A(String(e))}))}),[r,o,m]),i.jsxs(Al,{open:!0,fullScreen:!0,title:"View change log",handleClose:e,"data-testid":"view-changelog",children:[i.jsx(s.Select,{style:{width:200,marginLeft:40},value:m?.name??"",onChange:function(e){const t=p.find((t=>t.name===e.target.value));y(t)},children:p.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName||e.name},e.name)))}),i.jsx(s.DialogContent,{children:i.jsx(d.DataGrid,{pagination:!0,rows:f,columns:_,getRowId:e=>e._id,slots:{toolbar:d.GridToolbar},initialState:{sorting:{sortModel:[{field:"sequence",sort:"desc"}]},columns:{columnVisibilityModel:{sequence:!1}}}})}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}const rd=[{field:"refName",headerName:"Ref Name"},{field:"aliases",headerName:"Aliases",editable:!0,flex:1}],od=e=>/^[\da-f]{24}$/i.test(e),id=f.observer((function({changeManager:e,handleClose:t,session:n}){const r=u.useRef(null),[o,a]=u.useState(""),[c,l]=u.useState(!1),[A,f]=u.useState(),[h,g]=u.useState([]),[p,m]=u.useState(new Map),{apolloDataStore:y}=n,{collaborationServerDriver:_}=y,v=_.getAssemblies();u.useEffect((()=>{v.length>0&&(f(v[0]),_.getRefNameAliases(v[0].name).then((e=>{b(e)})).catch((()=>{m(new Map),a("Error fetching refName aliases for assembly")})))}),[]);const b=e=>{const t=new Map;for(const n of e){const e=n.refName;od(e)||t.set(e,n.aliases)}m(t)},C=()=>[...p].map(((e,t)=>({id:t,refName:e[0],aliases:e[1].filter((t=>t!==e[0])).join(", ")})));return i.jsxs(Al,{open:!0,title:"Add reference sequence aliases",handleClose:t,maxWidth:"sm","data-testid":"add-refseq-alias",fullWidth:!0,children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{children:i.jsxs(s.FormControl,{disabled:c&&!o,fullWidth:!0,children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Assembly"}),i.jsx(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Assembly",value:A?.name??"",onChange:e=>{const t=v.find((t=>t.name===e.target.value));f(t),t?.name&&(_.getRefNameAliases(t.name).then((e=>{b(e),a("")})).catch((()=>{m(new Map),a("Error fetching refName aliases for assembly")})),l(!1),r.current&&(r.current.value=""))},style:{minWidth:150},children:v.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))})]})}),i.jsxs(s.Grid,{children:[i.jsx(s.InputLabel,{children:"Load RefName alias"}),i.jsx("input",{type:"file",onChange:e=>{(async e=>{if(!e.target.files)return;const t=e.target.files[0],n=(await t.text()).split("\n"),r=new Map(p);a("");for(const e of n){const t=e.split("\t");for(const e of t)r.has(e)&&r.set(e,[...r.get(e)??[],...t])}m(r)})(e).catch((()=>{a("Error reading file")}))},ref:r,disabled:c&&!o||!A})]})]}),A&&p.size>0?i.jsxs("div",{style:{height:200,width:"100%",marginTop:20},children:[i.jsx(s.InputLabel,{children:"Refname aliases found for selected assembly."}),i.jsx(d.DataGrid,{rows:C(),columns:rd,initialState:{pagination:{paginationModel:{page:0,pageSize:5}}},pageSizeOptions:[5,10],onRowSelectionModelChange:e=>{const{ids:t}=e;if(t.size>0){l(!0);const e=[...t.values()].flatMap((e=>C().filter((t=>String(t.id)===String(e)))));g(e)}else l(!1),g([])},processRowUpdate:(e,t)=>{const n=new Map(p);return n.set(e.refName,e.aliases.split(",")),m(n),e},checkboxSelection:!0,disableRowSelectionExcludeModel:!0})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!c,onClick:()=>{const n=[];for(const e of h){const{refName:t}=e,r=e.aliases.split(",").map((e=>e.trim())).filter((e=>e.length>0));n.push({refName:t,aliases:r})}if(a(""),!A)return void a("No assembly selected");const r=new Dr({typeName:"AddRefSeqAliasesChange",assembly:A.name,refSeqAliases:n});e.submit(r).catch((()=>{a("Error submitting change")})),t()},children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}));function ad({handleClose:e,session:t}){const{internetAccounts:n}=c.getRoot(t),{collaborationServerDriver:r}=t.apolloDataStore,o=n.find((e=>"ApolloInternetAccount"===e.type));if(!o)throw new Error("No Apollo internet account found");const{baseURL:a}=o,[l,A]=u.useState(),[f,h]=u.useState([]),g=r.getAssemblies(),[p,m]=u.useState(g.at(0));return u.useEffect((()=>{(async function(){const e=p?.name;if(!e)return;const t=new URL("checks",a),n=new URLSearchParams({assembly:e});t.search=n.toString();const r=t.toString(),i=o?.getFetcher({locationType:"UriLocation",uri:r});if(i){const e=await i(r,{headers:new Headers({"Content-Type":"application/json"})});if(!e.ok){const t=await ll(e,"Error when retrieving checks");return void A(t)}const t=await e.json();h(t)}})().catch((e=>{A(String(e))}))}),[p,o,a]),i.jsxs(Al,{open:!0,fullScreen:!0,title:"View check results",handleClose:e,"data-testid":"view-check-results",children:[i.jsx(s.Select,{style:{width:200,marginLeft:40},value:p?.name??"",onChange:function(e){const t=g.find((t=>t.name===e.target.value));m(t)},disabled:0===g.length,children:g.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx(s.DialogContent,{children:i.jsx(d.DataGrid,{pagination:!0,rows:f,columns:[{field:"_id",headerName:"id",width:50},{field:"name",headerName:"Check name",width:200},{field:"refSeq",headerName:"Reference sequence ID",width:200},{field:"ids",headerName:"Feature IDs",width:200},{field:"message",headerName:"Message",flex:1}],getRowId:e=>e._id,slots:{toolbar:d.GridToolbar},initialState:{sorting:{sortModel:[{field:"name",sort:"asc"}]},columns:{columnVisibilityModel:{name:!0}}}})}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function sd(e){return e.max-e.min<2?{isSplittable:!1,comment:"This exon is too short to be split"}:{isSplittable:!0,comment:""}}function cd(e){const t=sd(e);return t.isSplittable?"Are you sure you want to split the selected exon?":t.comment}function ld({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[l,d]=u.useState(""),A=c.getSnapshot(a);return i.jsxs(Al,{open:!0,title:"Split exon",handleClose:t,maxWidth:!1,"data-testid":"split-exon",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d(""),n?._id===a._id&&r();const s=A.min+(A.max-A.min)/2,c=Math.floor(s),l=Math.ceil(s);if(!a.parent?._id)throw new Error("Splitting an exon without parent is not possible yet");const u=new eo({changedIds:[a._id],typeName:"SplitExonChange",assembly:o,exonToBeSplit:A,parentFeatureId:a.parent._id,upstreamCut:c,downstreamCut:l,leftExonId:(new ut).toHexString(),rightExonId:(new ut).toHexString()});e.submit(u),t(),i.preventDefault()},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:cd(A)})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!sd(A).isSplittable,children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function ud({changeManager:e,handleClose:t,session:n,sourceAssemblyId:r,sourceFeature:o,setSelectedFeature:a}){const[l,d]=u.useState(""),{notify:A}=n;return i.jsxs(Al,{open:!0,title:"Duplicate transcript",handleClose:t,maxWidth:!1,"data-testid":"duplicate-transcript",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){i.preventDefault(),d("");try{const i=o.parent;if(!i)return void d("No parent gene found for this transcript");const s=c.getSnapshot(o),l=(new ut).toHexString(),u={...s,_id:l};if(u.children){const e={};for(const[,t]of Object.entries(u.children)){const n=(new ut).toHexString();e[n]={...t,_id:n}}u.children=e}const f=new Nr({parentFeatureId:i._id,changedIds:[i._id],typeName:"AddFeatureChange",assembly:r,addedFeature:u});await e.submit(f).then((()=>{a(void 0),n.apolloSetSelectedFeature(l),A("Successfully duplicated transcript","success")})),t()}catch(e){d(e instanceof Error?e.message:"Failed to duplicate transcript")}}(i)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to create a duplicate of this transcript?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}var dd=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle");function Ad(e){const{color:t}=e;return i.jsx(s.SvgIcon,{viewBox:"0 0 18 18",style:{fontSize:18,marginRight:4},...e,children:"disabled"===t?i.jsx("path",{d:"M9.001,10.71 l0,-3.348 l8.424,0 c0.126,0.567,0.225,1.098,0.225,1.845 c0,5.139,-3.447,8.793,-8.64,8.793 c-4.968,0,-9,-4.032,-9,-9 c0,-4.968,4.032,-9,9,-9 c2.43,0,4.464,0.891,6.021,2.349 l-2.556,2.484 c-0.648,-0.612,-1.782,-1.332,-3.465,-1.332 c-2.979,0,-5.409,2.475,-5.409,5.508 c0,3.033,2.43,5.508,5.409,5.508 c3.447,0,4.716,-2.385,4.95,-3.798 l-4.959,0 l0,-0.009 z"}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17.64,9.20454545 c0,-0.638,-0.057,-1.252,-0.164,-1.841 l-8.476,0 l0,3.481 l4.844,0 c-0.209,1.125,-0.843,2.079,-1.796,2.717 l0,2.258 l2.908,0 c1.702,-1.567,2.684,-3.874,2.684,-6.615 l0,0 z",fill:"#4285F4"}),i.jsx("path",{d:"M9,18 c2.43,0,4.467,-0.806,5.956,-2.18 l-2.908,-2.259 c-0.806,0.54,-1.837,0.859,-3.048,0.859 c-2.344,0,-4.328,-1.583,-5.036,-3.71 l-3.007,0 l0,2.332 c1.481,2.941,4.525,4.958,8.043,4.958 l0,0 z",fill:"#34A853"}),i.jsx("path",{d:"M3.96409091,10.71 c-0.18,-0.54,-0.282,-1.117,-0.282,-1.71 c0,-0.593,0.102,-1.17,0.282,-1.71 l0,-2.332 l-3.007,0 c-0.609,1.215,-0.957,2.59,-0.957,4.042 c0,1.452,0.348,2.827,0.957,4.042 l3.007,-2.332 l0,0 z",fill:"#FBBC05"}),i.jsx("path",{d:"M9,3.57954545 c1.321,0,2.508,0.454,3.44,1.346 l2.582,-2.581 c-1.559,-1.453,-3.596,-2.345,-6.022,-2.345 c-3.518,0,-6.562,2.017,-8.043,4.959 l3.007,2.331 c0.708,-2.127,2.692,-3.71,5.036,-3.71 l0,0 z",fill:"#EA4335"})]})})}function fd(e){const{color:t}=e;return i.jsxs(s.SvgIcon,{viewBox:"0 0 21 21",style:{fontSize:21},...e,children:[i.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#F25022"}),i.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#00A4EF"}),i.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"disabled"===t?"#939393":"#7FBA00"}),i.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"disabled"===t?"#B9B9B9":"#FFB900"})]})}const hd=Ec()((e=>({loginButton:{marginBottom:e.spacing(1),width:"220px",height:"40px",fontSize:"16px",textTransform:"none",justifyContent:"left",padding:"3px 12px"}})));function gd(e){const{classes:t}=hd(),{disabled:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(Ad,{color:n?"disabled":void 0}),...e,children:"Sign in with Google"})}function pd(e){const{classes:t}=hd(),{disabled:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(fd,{color:n?"disabled":void 0}),...e,children:"Sign in with Microsoft"})}function md(e){const{classes:t}=hd();return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(dd,{fontSize:"small"}),...e,children:"Continue as Guest"})}const yd=Ec()((e=>({divider:{marginTop:e.spacing(4),marginBottom:e.spacing(5)}}))),_d=({baseURL:e,handleClose:t,name:n})=>{const{classes:r}=yd(),[o,a]=u.useState(""),[c,l]=u.useState([]);function d(e){t("google"===e?"google":"microsoft"===e?"microsoft":"guest")}u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return async function(){const t=new URL("auth/types",e).href,r=await fetch(t,{method:"GET",signal:n});if(!r.ok){const e=await ll(r,"Error when retrieving auth types from server");return void a(e)}const o=await r.json();l(o)}().catch((e=>{Hl(e)||a(String(e))})),()=>{t.abort(new DOMException("Error retrieving valid authentication types","AbortError"))}}),[e]);const A=c.includes("google"),f=c.includes("microsoft"),h=c.includes("guest");return i.jsxs(Al,{open:!0,title:`Log in to ${n}`,handleClose:t,maxWidth:!1,"data-testid":"login-apollo",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column",paddingTop:8},children:[A?i.jsx(gd,{disabled:!A,onClick:()=>{d("google")}}):null,f?i.jsx(pd,{disabled:!f,onClick:()=>{d("microsoft")}}):null,h?i.jsxs(i.Fragment,{children:[i.jsx(s.Divider,{className:r.divider}),i.jsx(md,{onClick:()=>{d("guest")}})]}):null]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})},vd="undefined"==typeof sessionStorage,bd=e=>r.InternetAccount.named("ApolloInternetAccount").props({type:c.types.literal("ApolloInternetAccount"),configuration:n.ConfigurationReference(e)}).views((e=>({get baseURL(){return n.getConf(e,"baseURL")},getUserId(){const t=e.retrieveToken();if(t)return bo(t).id}}))).volatile((()=>({role:void 0,controller:new AbortController}))).actions((e=>({setRole(){const t=e.retrieveToken();if(!t)return void(e.role=void 0);const n=bo(t),{role:r}=n;e.role!==r&&(e.role=r)}}))).actions((e=>{let t;return{addMessageChannel(e,n){t=t=>{this.finishOAuthWindow(t,e,n)},window.addEventListener("message",t)},deleteMessageChannel(){window.removeEventListener("message",t)},finishOAuthWindow(t,n,r){if(t.data.name!==`JBrowseAuthWindow-${e.internetAccountId}`)return;const o=t.data.redirectUri.replace("#","?"),i=new URL(o),a=new URLSearchParams(i.search).get("access_token");this.deleteMessageChannel(),a?(e.storeToken(a),e.setRole(),n(a)):r(new Error("Error with token endpoint"))},async openAuthWindow(t,n,r){const i=o.isElectron?"http://localhost/auth":globalThis.location.origin+globalThis.location.pathname,a=new URL("auth/login",e.baseURL),s=new URLSearchParams({type:t,redirect_uri:i});a.search=s.toString();const c=`JBrowseAuthWindow-${e.internetAccountId}`;if(o.isElectron){const{ipcRenderer:t}=globalThis.require("electron"),o=await t.invoke("openAuthWindow",{internetAccountId:e.internetAccountId,data:{redirect_uri:i},url:a.toString()}),s=new MessageEvent("message",{data:{name:c,redirectUri:o}});this.finishOAuthWindow(s,n,r)}else this.addMessageChannel(n,r),window.open(a,c,"width=500,height=600")}}})).actions((e=>({async getTokenFromUser(t,n){const{baseURL:r}=e,o=await new Promise(((t,n)=>{const{session:r}=c.getRoot(e),{baseURL:o,name:i}=e;r.queueDialog((e=>[_d,{name:i,handleClose:r=>{r?r instanceof Error?n(r):t(r):n(new Error("user cancelled entry")),e()},baseURL:o}]))}));if("guest"!==o)return void e.openAuthWindow(o,t,n);const i=new URL("auth/login",r),a=new URLSearchParams({type:o});i.search=a.toString();const s=i.toString(),l=await fetch(s,{signal:e.controller.signal});if(!l.ok){const e=await ll(l,"Error when logging in");return void n(new Error(e))}const{token:u}=await l.json();t(u)}}))).volatile((()=>({lastChangeSequenceNumber:void 0}))).actions((e=>({setLastChangeSequenceNumber(t){e.lastChangeSequenceNumber=t}}))).actions((e=>({updateLastChangeSequenceNumber:c.flow((function*(){const{baseURL:t}=e,n=new URL("changes",t),r=new URLSearchParams({limit:"1"});n.search=r.toString();const o=n.toString(),i=e.getFetcher({locationType:"UriLocation",uri:o});let a;try{a=yield i(o,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!a.ok){const e=yield ll(a,"Error when fetching server LastChangeSequence");throw new Error(e)}const s=yield a.json();e.setLastChangeSequenceNumber(s.length>0?s[0].sequence:0)})),getMissingChanges:c.flow((function*(){const{session:t}=c.getRoot(e),{changeManager:n}=t.apolloDataStore;if(!e.lastChangeSequenceNumber)throw new Error("No LastChangeSequence stored in session. Please, refresh you browser to get last updates from server");const{baseURL:r,lastChangeSequenceNumber:o}=e,i=new URL("changes",r),a=new URLSearchParams({since:String(o),sort:"1"});i.search=a.toString();const s=i.toString(),l=e.getFetcher({locationType:"UriLocation",uri:s});let u;try{u=yield l(s,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!u.ok)return void console.error(`Error when fetching the last updates to recover socket connection — ${u.status}`);const d=yield u.json();for(const e of d){const t=oe.fromJSON(e);n.submit(t,{submitToBackend:!1})}}))}))).volatile((e=>{const{origin:t,pathname:n}=new URL("socket.io/",e.baseURL);return{socket:fa(t,{path:n})}})).actions((e=>({addSocketListeners(){const{session:t}=c.getRoot(e),{notify:n}=t,r=e.retrieveToken();if(!r)throw new Error("No Token found");const o=vo(bo(r)),{socket:i}=e,{addCheckResult:a,changeManager:s,deleteCheckResult:l}=t.apolloDataStore;i.on("connect",(()=>{e.getMissingChanges()})),i.on("connect_error",(e=>{console.error(e),n("Could not connect to the Apollo server.","error")})),i.on("COMMON",(e=>{if("checkResult"in e)return void(e.deleted?l(e.checkResult._id.toString()):a(e.checkResult));if(sessionStorage.setItem("LastChangeSequence",String(e.changeSequence)),e.userSessionId===o)return;const t=oe.fromJSON(e.changeInfo);s.submit(t,{submitToBackend:!1})})),i.on("USER_LOCATION",(e=>{const{channel:n,locations:r,userName:i,userSessionId:a}=e;"USER_LOCATION"===n&&a!==o&&t.addOrUpdateCollaborator({name:i,id:a,locations:r})})),i.on("REQUEST_INFORMATION",(e=>{const{channel:n,userSessionId:o}=e;"REQUEST_INFORMATION"===n&&o!==r&&t.broadcastLocations()}))}}))).actions((e=>({postUserLocation:(t=>{let n;return t=>{clearTimeout(n),n=setTimeout((()=>{!async function(t){if(!c.isAlive(e)||"none"===e.role)return;const{baseURL:n,controller:r}=e,o=new URL("users/userLocation",n).href,i=new URLSearchParams(JSON.stringify(t)),a=e.getFetcher({locationType:"UriLocation",uri:o});try{if(!(await a(o,{method:"POST",body:i,signal:r.signal})).ok)throw new Error("ignore")}catch{console.error("Broadcasting user location failed")}}(t)}),300)}})()}))).volatile((()=>({roleNotificationSent:!1}))).actions((e=>{function t(){e.postUserLocation([])}function n(){if("hidden"===document.visibilityState&&e.postUserLocation([]),"visible"===document.visibilityState){const{session:t}=c.getRoot(e);t.broadcastLocations()}}return{initialize:c.flow((function*(r){if("none"===r){if(!e.roleNotificationSent){const{session:t}=c.getRoot(e);t.notify("You have registered as an Apollo user but have not been given access. Ask your administrator to enable access for your account.","warning"),e.roleNotificationSent=!0}return}if("admin"===r){const t=c.getRoot(e);o.isAbstractMenuManager(t)&&function(e){e.appendToMenu("Apollo",{label:"Admin",type:"subMenu",icon:ha,subMenu:[{label:"Add Assembly",icon:Uo,onClick:e=>{e.queueDialog((t=>[pl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Delete Assembly",icon:ga,onClick:e=>{e.queueDialog((t=>[Lu,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Import Features",icon:pa,onClick:e=>{e.queueDialog((t=>[Hu,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add reference sequence aliases",onClick:e=>{e.queueDialog((t=>[id,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add Assembly aliases",onClick:e=>{e.queueDialog((t=>[yl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Users",icon:ma,onClick:e=>{e.queueDialog((t=>[Ku,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Checks",icon:ya,onClick:e=>{e.queueDialog((t=>[zu,{session:e,handleClose:()=>{t()}}]))}}]})}(t)}yield e.updateLastChangeSequenceNumber(),e.addSocketListeners();const{baseURL:i}=e,a=new URL("users/locations",i).href,s=e.getFetcher({locationType:"UriLocation",uri:a});yield s(a,{method:"GET",signal:e.controller.signal}),window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",n)})),removeBeforeUnloadListener(){window.removeEventListener("beforeunload",t)},removeVisibilityChangeListener(){document.removeEventListener("visibilitychange",n)}}})).actions((e=>({afterAttach(){e.setRole(),l.autorun((async t=>{if(vd)return;const{session:n}=c.getRoot(e);if(n&&e.role)try{await e.initialize(e.role),t.dispose()}catch{}}),{name:"ApolloInternetAccount"})},beforeDestroy(){e.removeBeforeUnloadListener(),e.removeVisibilityChangeListener(),e.controller.abort(new DOMException("Cleaning up Apollo connection","AbortError")),e.socket.close()}}))),Cd="undefined"==typeof sessionStorage;class Id extends y.BaseAdapter{refNameAliases;async getRefNameAliases(){const e=n.readConfObject(this.config,"assemblyId");if(!Cd){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");return await n.getRefNameAliases(e)}const t=await new Promise(((t,n)=>{const r=setTimeout((()=>{n(new Error("timeout"))}),2e4),o=Zu(),i=e=>{const n=e.data;(function(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo&&"refNameAliases"in e})(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.refNameAliases))};addEventListener("message",i),rpcServer.emit("apollo",{apollo:!0,method:"getRefNameAliases",assembly:e,messageId:o})}));return this.refNameAliases=t,t}freeResources(){}}var wd=n.ConfigurationSchema("ApolloRefNameAliasAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0});function Ed(e){return"uniqueId"in e&&"object"!==X(e.data)}var xd=function(){function e(t){var n=this;N(this,e),T(this,"data",void 0),T(this,"subfeatures",void 0),T(this,"parentHandle",void 0),T(this,"uniqueId",void 0),Ed(t)?this.data=t:(this.data=t.data,this.parentHandle=t.parent);var r,o=Ed(t)?t.uniqueId:t.id;if(null==o)throw new Error("SimpleFeature requires a unique `id` or `data.uniqueId` attribute");if(this.uniqueId=String(o),!(this.data.aliases||this.data.end-this.data.start>=0))throw new Error("invalid feature data, end less than start. end: ".concat(this.data.end," start: ").concat(this.data.start));this.data.subfeatures&&(this.subfeatures=null===(r=this.data.subfeatures)||void 0===r?void 0:r.map((function(t,r){return"function"!=typeof t.get?new e({id:t.uniqueId||"".concat(o,"-").concat(r),data:q({strand:n.data.strand},t),parent:n}):t})))}return D(e,[{key:"get",value:function(e){return"subfeatures"===e?this.subfeatures:"parent"===e?this.parent():this.data[e]}},{key:"set",value:function(e,t){this.data[e]=t}},{key:"tags",value:function(){return Object.keys(this.data)}},{key:"id",value:function(){return this.uniqueId}},{key:"parent",value:function(){return this.parentHandle}},{key:"children",value:function(){return this.get("subfeatures")}},{key:"toJSON",value:function(){var e=q(q({},this.data),{},{uniqueId:this.id()}),t=this.parent();t&&(e.parentId=t.id());var n=this.children();return n&&(e.subfeatures=n.map((function(e){return e.toJSON()}))),e}}],[{key:"fromJSON",value:function(t){return new e(q({},t))}}])}();function Sd(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo}const Bd="undefined"==typeof sessionStorage;class kd extends y.BaseSequenceAdapter{regions;async getRefNames(){return(await this.getRegions()).map((e=>e.refName))}async getRegions(){if(this.regions)return this.regions;const e=n.readConfObject(this.config,"assemblyId");if(!Bd){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");const r=await n.getRegions(e);return this.regions=r,r}const t=await new Promise(((t,n)=>{const r=setTimeout((()=>{n("timeout")}),2e4),o=Zu(),i=e=>{const{data:n}=e;Sd(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.regions))};addEventListener("message",i),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getRegions",assembly:e,messageId:o})}));return this.regions=t,t}getFeatures(e){const{end:t,refName:r,start:o}=e,i=n.readConfObject(this.config,"assemblyId"),a={...e,assemblyName:i};return _.ObservableCreate((async e=>{if(!Bd){const n=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!n)return void e.error("No Apollo data store found");const s=n.getBackendDriver(i);if(!s)return void e.error("No backend driver found");const c=(await s.getRegions(a.assemblyName)).find((e=>e.refName===a.refName));if(!c)return void e.error("Cannot get region");a.end>c.end&&(a.end=c.end);const{seq:l}=await s.getSequence(a);return e.next(new xd({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:l}})),void e.complete()}const n=await new Promise(((e,t)=>{const n=setTimeout((()=>{t("timeout")}),2e4),r=Zu(),o=t=>{const{data:i}=t;Sd(i)&&i.messageId===r&&(clearTimeout(n),removeEventListener("message",o),e(i.sequence))};addEventListener("message",o),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getSequence",region:a,messageId:r})}));e.next(new xd({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:n}})),e.complete()}))}freeResources(){}}var Qd=n.ConfigurationSchema("ApolloSequenceAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),Nd=function(){return D((function e(t){N(this,e),T(this,"label",void 0),T(this,"renderingComponent",void 0),T(this,"displayString",void 0),T(this,"matchedAttribute",void 0),T(this,"matchedObject",void 0),T(this,"textSearchAdapter",void 0),T(this,"relevance",void 0),T(this,"trackId",void 0),T(this,"score",void 0),T(this,"locString",void 0),T(this,"results",void 0),this.label=t.label,this.locString=t.locString,this.renderingComponent=t.renderingComponent,this.displayString=t.displayString,this.matchedAttribute=t.matchedAttribute,this.matchedObject=t.matchedObject,this.textSearchAdapter=t.textSearchAdapter,this.relevance=t.relevance,this.trackId=t.trackId,this.score=t.score||1,this.results=t.results||[]}),[{key:"getLabel",value:function(){return this.label}},{key:"getDisplayString",value:function(){return this.displayString||this.label}},{key:"getRenderingComponent",value:function(){return this.renderingComponent}},{key:"getTrackId",value:function(){return this.trackId}},{key:"getScore",value:function(){return this.score}},{key:"updateScore",value:function(e){return this.score=e,this.score}},{key:"getId",value:function(){return"".concat(this.getLabel(),"-").concat(this.getLocation(),"-").concat(this.getTrackId())}},{key:"hasLocation",value:function(){return!!this.locString}},{key:"getLocation",value:function(){return this.locString}},{key:"getComboResults",value:function(){return this.results}}])}();function Rd(e,t){const{children:n,indexedIds:r,...o}=t;if(JSON.stringify(o).includes(e))return t;if(n)for(const t of Object.values(n)){const n=Rd(e,t);if(n)return n}}class Dd extends y.BaseAdapter{get baseURL(){return n.readConfObject(this.config,"baseURL").uri}get trackId(){return n.readConfObject(this.config,"trackId")}get assemblyNames(){return n.readConfObject(this.config,"assemblyNames")}mapBaseResult(e,t,n){return e.map((e=>{const r=Rd(n,e)??e,o=t.getCanonicalRefName(e.refSeq);return new Nd({label:n,trackId:this.trackId,locString:`${o}:${r.min+1}..${r.max}`,matchedObject:r})}))}async searchIndex(e){const t=e.queryString,n=[],r=this.pluginManager?.rootModel?.session;if(!r)return n;const{apolloDataStore:o}=r,{assemblyManager:i}=r;for(const r of this.assemblyNames){const a=o.getBackendDriver(r),s=i.get(r);if(!a||!s)continue;const c=await a.searchFeatures(e.queryString,[r]);n.push(...this.mapBaseResult(c,s,t))}return n}freeResources(){}}var Fd=n.ConfigurationSchema("ApolloTextSearchAdapter",{assemblyNames:{type:"stringArray",defaultValue:[],description:"List of assemblies covered by text search adapter"},trackId:{type:"string",defaultValue:""},baseURL:{type:"fileLocation",defaultValue:{uri:"",locationType:"UriLocation"}}},{explicitlyTyped:!0,explicitIdentifier:"textSearchAdapterId"}),Td=a.createSvgIcon(i.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),jd=a.createSvgIcon(i.jsx("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit"),Md=a.createSvgIcon(i.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreHoriz");const Od=Ec()((e=>({attributeKey:{fontWeight:"bold",marginRight:e.spacing(2)}})));function Ld({attributeKey:e}){const{classes:t}=Od(),n=/^[A-Z]/.test(e);let r,o=e;return e in bt?(o=bt[e],r=`On GFF3 export, this will be assigned to the GFF3's reserved "${o}" attribute`):function(e){return e in Ct}(e)?(o=Ct[e],r=`On GFF3 export, this will be placed in the GFF3's "${o}" column`):n&&(r="On GFF3 export, this attribute will be changed to start with a lower-case letter because attributes starting with an upper-case letter are reserved in GFF3"),i.jsxs("div",{style:{display:"flex"},children:[i.jsx(s.Typography,{className:t.attributeKey,children:o}),r?i.jsx(s.Tooltip,{title:r,children:i.jsx(s.Chip,{icon:i.jsx(xc,{}),label:"GFF3",size:"small",variant:"outlined"})}):null]})}const Pd="Custom",qd={[Pd]:"custom"};for(const[e,t]of Object.entries(vt))qd[`GFF ${t}`]=e;for(const[e,t]of Object.entries({score:"gff_score",source:"gff_source"}))qd[`GFF ${t}`]=e;const Jd=f.observer((function({setKey:e,session:t}){const{pluginManager:n}=o.getEnv(t),r=n.evaluateExtensionPoint("Apollo-ReservedAttributeKeys",qd),a=Object.keys(r).at(0)??Pd,[c,l]=u.useState(a),[d,A]=u.useState(),f=c===Pd;return i.jsxs("form",{onSubmit:function(t){t.preventDefault(),e(f?d:r[c])},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:8},children:[i.jsxs(s.FormControl,{variant:"outlined",children:[i.jsx(s.InputLabel,{id:"attribute-key-select-label",children:"Key"}),i.jsx(s.Select,{labelId:"attribute-key-select-label",value:c,label:"Key",onChange:e=>{l(e.target.value)},children:Object.keys(r).map((e=>i.jsx(s.MenuItem,{value:e,children:e},e)))})]}),f?i.jsx(s.TextField,{label:"Attribute key",variant:"outlined",id:"attributeKey",onChange:e=>{A(e.target.value)}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",type:"submit",disabled:f&&!d,children:"Add"}),i.jsx(s.Button,{variant:"outlined",onClick:function(){e()},children:"Cancel"})]})]})}));var Ud=a.createSvgIcon(i.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");const Gd=f.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,c]=u.useState(!1),[l,d]=u.useState(null);return u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(l?.blur(),c(!1))}),[a,l]),i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?l?.blur():"Escape"===e.key&&(o(String(t)),c(!0))},onBlur:()=>{r!==String(t)&&e(r)},inputRef:e=>{d(e)}})})),Hd=f.observer((function({attributeValues:e,setAttribute:t,isNew:n=!1}){const[r,o]=u.useState(e&&e.length>0?e:[""]);return i.jsxs(i.Fragment,{children:[r.map(((e,t)=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx(Gd,{value:e,onChangeCommitted:e=>{!function(e,t){o((n=>{const r=[...n];return r[e]=t,r}))}(t,e)},variant:"outlined",fullWidth:!0}),i.jsx(s.IconButton,{"aria-label":"delete",size:"medium",edge:"end",onClick:()=>{!function(e){o((t=>{const n=[...t];return n.splice(e,1),n}))}(t)},children:i.jsx(ga,{fontSize:"inherit"})})]},`${t}-${e}`))),i.jsx(s.IconButton,{"aria-label":"add",size:"medium",color:"secondary",edge:"start",onClick:function(){o((e=>{const t=[...e];return t.push(""),t}))},children:i.jsx(Ud,{fontSize:"inherit"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",onClick:()=>{t(r.filter(Boolean))},children:n?"Add":"Update"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})]})]})}));function Yd({values:e}){return i.jsx(i.Fragment,{children:e?.map(((e,t)=>i.jsx(s.Typography,{variant:"body2",color:"textSecondary",children:e},`${t}.${e}`)))})}const zd=Ec()((e=>({list:{"li:nth-of-type(odd)":{backgroundColor:e.palette.action.focus},"li:nth-of-type(even)":{backgroundColor:e.palette.action.hover}}}))),Kd=f.observer((function({assembly:e,editable:t,feature:n,session:r}){const{pluginManager:a}=o.getEnv(r),{classes:d}=zd(),[A,f]=u.useState(null),[h,g]=u.useState(null),[p,m]=u.useState(null),[y,_]=u.useState(!1),[v,b]=u.useState(),C=Boolean(A),{changeManager:I}=r.apolloDataStore,{notify:w}=r;function E(){f(null),g(null)}const{_id:x,attributes:S}=n,B=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Hd,{key:v});return i.jsxs(i.Fragment,{children:[i.jsxs(s.List,{className:d.list,children:[l.entries(S).map((([o,l])=>{const u=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Hd,{key:o}),d=a.evaluateExtensionPoint("Apollo-AttributeViewerComponent",Yd,{key:o});return i.jsx(s.ListItem,{secondaryAction:t&&!p?i.jsx(s.IconButton,{edge:"end",onClick:e=>{!function(e,t){f(e.currentTarget),g(t)}(e,o)},children:i.jsx(Md,{})}):null,children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Ld,{attributeKey:o}),secondary:p===o?i.jsx(u,{session:r,attributeValues:l,setAttribute:t=>{m(null),t&&function(t,r){const o={...c.getSnapshot(S)},i=structuredClone(o);if(!(t in o))return void w(`"${t}" not found in feature attributes`,"error");if(o[t].toString()===r.toString())return;o[t]=r;const a=new jr({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});I.submit(a)}(o,t)}}):i.jsx(d,{values:l})})},o)})),v?i.jsx(s.ListItem,{children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Ld,{attributeKey:v}),secondary:i.jsx(B,{session:r,attributeValues:[],setAttribute:t=>{t&&function(t,r){const o={...c.getSnapshot(S)},i=structuredClone(o);if(t in o)return void w(`Feature already has attribute "${t}"`,"error");o[t]=r;const a=new jr({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});I.submit(a)}(v,t),b(void 0)},isNew:!0})})}):null]}),t?i.jsx(s.Button,{color:"primary",variant:"contained",disabled:y||Boolean(v),onClick:()=>{_(!0)},children:"Add new"}):null,y?i.jsx(s.Paper,{variant:"outlined",style:{marginTop:8},children:i.jsx(Jd,{session:r,setKey:e=>{b(e),_(!1)}})}):null,i.jsxs(s.Menu,{anchorEl:A,open:C,onClose:E,children:[i.jsxs(s.MenuItem,{onClick:function(){h&&function(t){const n=c.getSnapshot(S),{[t]:r,...o}=n,i=new jr({changedIds:[x],typeName:"FeatureAttributeChange",assembly:e,featureId:x,oldAttributes:n,newAttributes:o});I.submit(i)}(h),E()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(ga,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Delete"})]}),i.jsxs(s.MenuItem,{onClick:function(){h&&m(h),E()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(jd,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Edit"})]})]})]})})),Wd=f.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,c]=u.useState(!1),[l,d]=u.useState(null);u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(l?.blur(),c(!1))}),[a,l]);const A=Number.isNaN(Number(r));return i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?l?.blur():"Escape"===e.key&&(o(String(t)),c(!0))},onBlur:()=>{const n=Number(r);r!==String(t)&&(Number.isNaN(n)?o(String(t)):e(n)||o(String(t)))},inputRef:e=>{d(e)},error:A,helperText:A?"Not a valid number":void 0})})),Vd=f.observer((function({assembly:e,feature:t,session:n}){const[r,o]=u.useState(""),[a,c]=u.useState(""),{_id:l,assemblyId:d,max:A,min:f,strand:h,type:g}=t,p=e=>{n.notify(e.message,"error")},{changeManager:m}=n.apolloDataStore;function y(t){const{value:n}=t.target,r=n?Number(n):void 0,o=new to({typeName:"StrandChange",changedIds:[l],featureId:l,oldStrand:h,newStrand:r,assembly:e});return m.submit(o)}return i.jsxs("div",{"data-testid":"basic_information",children:[i.jsx(Wd,{margin:"dense",id:"start",label:"Start",fullWidth:!0,variant:"outlined",value:f+1,onChangeCommitted:function(t){t--;const n=new Ur({typeName:"LocationStartChange",changedIds:[l],featureId:l,oldStart:f,newStart:t,assembly:e});return m.submit(n),!0}}),i.jsx(Wd,{margin:"dense",id:"end",label:"End",fullWidth:!0,variant:"outlined",value:A,onChangeCommitted:function(t){const n=new qr({typeName:"LocationEndChange",changedIds:[l],featureId:l,oldEnd:A,newEnd:t,assembly:e});return m.submit(n),!0}}),i.jsx(Su,{session:n,ontologyName:"Sequence Ontology",value:g,filterTerms:wu,fetchValidTerms:async function(e,t,n){const r=await xu(e,t);if(r)return r;c(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,t),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(a),helperText:a}),onChange:(e,t)=>{t&&function(e){o("");const t=new no({typeName:"TypeChange",changedIds:[l],featureId:l,oldType:g,newType:e,assembly:d});return m.submit(t)}(t).catch(p)}}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"1",checked:1===h,onChange:y}),"Positive Strand (+)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"-1",checked:-1===h,onChange:y}),"Negative Strand (-)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"",checked:void 0===h,onChange:y}),"No Strand Information"]}),r?i.jsx(s.Typography,{color:"error",children:r}):null]})})),$d=f.observer((function(e){const{feature:t,model:n}=e,{children:r,parent:o}=t,a=[];if(r)for(const[,e]of r)a.push(e);return o??a.length>0?i.jsxs("div",{style:{marginTop:10},children:[o&&i.jsxs("div",{children:[i.jsx(s.Typography,{variant:"h6",children:"Parent:"}),i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(o)},children:[o.type,qc(o)," (",o.min,"..",o.max,")"]})]}),a.length>0&&i.jsxs("div",{children:[i.jsxs(s.Typography,{variant:"h6",children:[1===a.length?"Child":"Children",":"]}),a.map((e=>i.jsx("div",{style:{marginBottom:5},children:i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(e)},children:[e.type,qc(e)," (",e.min,"..",e.max,")"]})},e._id)))]})]}):null})),Xd=Ec()({sequence:{width:"100%",resize:"vertical"}}),Zd=f.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),{classes:a}=Xd();if(!t||!o)return null;const s=o.getByRefName(n);if(!s)return null;const{max:c,min:l}=t;let u=s.getSequence(l,c);return u?u=function(e,t,n,r,o){return`>${t}:${n+1}–${r}\n${e}`}(u,n,l,c):r.apolloDataStore.loadRefSeq([{assemblyName:e,refName:n,start:l,end:c}]),i.jsx("div",{children:i.jsx("textarea",{readOnly:!0,rows:20,className:a.sequence,value:u})})})),eA=Ec()((e=>({root:{padding:e.spacing(2)}}))),tA=f.observer((function(e){const{model:t}=e,{assembly:n,feature:r,refName:a}=t,c=o.getSession(t),l=c.apolloDataStore.assemblies.get(n),{classes:d}=eA(),[A,f]=u.useState(["attributes"]);if(u.useEffect((()=>{f(["attributes"])}),[r]),!r||!l)return null;const h=l.getByRefName(a);if(!h)return null;const{max:g,min:p}=r;function m(e,t){f(e?[...A,t]:A.filter((e=>e!==t)))}return h.getSequence(p,g)||c.apolloDataStore.loadRefSeq([{assemblyName:n,refName:a,start:p,end:g}]),i.jsxs("div",{className:d.root,children:[i.jsx(Vd,{feature:r,session:c,assembly:l._id}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:A.includes("attributes"),onChange:(e,t)=>{m(t,"attributes")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",children:"Attributes"})}),i.jsx(s.AccordionDetails,{children:i.jsx(Kd,{feature:r,session:c,assembly:l._id,editable:!0})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:A.includes("sequence"),onChange:(e,t)=>{m(t,"sequence")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",children:"Sequence"})}),i.jsx(s.AccordionDetails,{children:A.includes("sequence")&&i.jsx(Zd,{feature:r,session:c,assembly:l._id,refName:a})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:A.includes("related_features"),onChange:(e,t)=>{m(t,"related_features")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsx(s.Typography,{component:"span",children:"Related features"})}),i.jsx(s.AccordionDetails,{children:i.jsx($d,{model:t,feature:r})})]})]})}));var nA=c.types.late((function(){return rA})),rA=c.types.model("AnnotationFeatureModel",{_id:c.types.identifier,refSeq:c.types.string,type:c.types.string,min:c.types.number,max:c.types.number,strand:c.types.maybe(c.types.union(c.types.literal(1),c.types.literal(-1))),children:c.types.maybe(c.types.map(nA)),attributes:c.types.map(c.types.array(c.types.string))}).views((function(e){return{get length(){return e.max-e.min},get featureId(){return e.attributes.get("id")},get minWithChildren(){var t=e.min,n=e.children;if(!n)return t;var r,o=F(n);try{for(o.s();!(r=o.n()).done;){var i=K(r.value,2);t=Math.min(t,i[1].min)}}catch(e){o.e(e)}finally{o.f()}return t},get maxWithChildren(){var t=e.max,n=e.children;if(!n)return t;var r,o=F(n);try{for(o.s();!(r=o.n()).done;){var i=K(r.value,2);t=Math.max(t,i[1].max)}}catch(e){o.e(e)}finally{o.f()}return t},hasDescendant:function(t){var n=e.children;if(!n)return!1;var r,o=F(n);try{for(o.s();!(r=o.n()).done;){var i=K(r.value,2);if(i[0]===t)return!0;if(i[1].hasDescendant(t))return!0}}catch(e){o.e(e)}finally{o.f()}return!1},get transcriptExonParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent, cannot calculate exon locations");var n=e.children;if(!n)throw new Error("No exons in transcript");var r,i=V(n.values()).filter((function(e){return t.isTypeOf(e.type,"exon")})).sort((function(e,t){return e.min-t.min})),a=e.min,s=[],c=F(i);try{for(c.s();!(r=c.n()).done;){var l=r.value;l.min>a&&s.push({min:a,max:l.min,type:"intron"}),s.push({min:l.min,max:l.max,type:"exon"}),a=l.max}}catch(e){c.e(e)}finally{c.f()}return a<e.max&&s.push({min:a,max:e.max,type:"intron"}),-1===e.strand&&s.reverse(),s},get transcriptParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error('Only features of type "transcript" or equivalent can calculate CDS locations');var n=e.children;if(!n)throw new Error("no CDS or exons in transcript");var r=V(n.values()).filter((function(e){return t.isTypeOf(e.type,"CDS")})),i=[];if(0===r.length)return i.push(this.transcriptExonParts),i;var a,s=F(r);try{var c=function(){var r,s=a.value,c=s.max,l=s.min,u=[],d=!1,A=[],f=F(n);try{for(f.s();!(r=f.n()).done;){var h=K(r.value,2)[1];t.isTypeOf(h.type,"exon")&&A.push({min:h.min,max:h.max})}}catch(e){f.e(e)}finally{f.f()}A.sort((function(e,t){return e.min-t.min}));for(var g=0,p=A;g<p.length;g++){var m=p[g],y=u.at(-1);y&&u.push({min:y.max,max:m.min,type:"intron"});var _,v=K(o.intersection2(l,c,m.min,m.max),2),b=v[0],C=v[1];_=d?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==b&&void 0!==C?(d=!0,b===m.min&&C===m.max?u.push({min:b,max:C,phase:0,type:"CDS"}):b===m.min?u.push({min:b,max:C,phase:0,type:"CDS"},{min:C,max:m.max,type:_}):C===m.max?u.push({min:m.min,max:b,type:_},{min:b,max:C,phase:0,type:"CDS"}):u.push({min:m.min,max:b,type:_},{min:b,max:C,phase:0,type:"CDS"},{min:C,max:m.max,type:"fivePrimeUTR"===_?"threePrimeUTR":"fivePrimeUTR"})):u.push({min:m.min,max:m.max,type:_})}u.sort((function(e,t){return e.min-t.min})),-1===e.strand&&u.reverse();var I=0,w=u.map((function(e){if("CDS"!==e.type)return e;var t=I;return I=(3-(e.max-e.min-t+3)%3)%3,q(q({},e),{},{phase:t})}));i.push(w)};for(s.s();!(a=s.n()).done;)c()}catch(e){s.e(e)}finally{s.f()}return i}}})).views((function(e){return{get cdsLocations(){return e.transcriptParts.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))},get looksLikeGene(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t)return!1;var n=e.children;if(null==n||!n.size)return!1;if(!t.isTypeOf(e.type,"gene")&&!t.isTypeOf(e.type,"pseudogene"))return!1;var r,i=F(n);try{for(i.s();!(r=i.n()).done;){var a=K(r.value,2)[1];if(t.isTypeOf(a.type,"transcript")||t.isTypeOf(a.type,"pseudogenic_transcript")){var s=a.children;return!(null==s||!s.size)&&V(s.values()).some((function(e){return t.isTypeOf(e.type,"exon")}))}}}catch(e){i.e(e)}finally{i.f()}return!1}}})).actions((function(e){return{setAttributes:function(t){e.attributes.clear();var n,r=F(t.entries());try{for(r.s();!(n=r.n()).done;){var o=K(n.value,2);e.attributes.set(o[0],o[1])}}catch(e){r.e(e)}finally{r.f()}},setAttribute:function(t,n){e.attributes.merge(T({},t,n))},setType:function(t){e.type=t},setRefSeq:function(t){e.refSeq=t},setMin:function(t){if(t>e.max)throw new Error('Min "'.concat(t+1,'" is greater than max "').concat(e.max,'"'));e.min!==t&&(e.min=t)},setMax:function(t){if(t<e.min)throw new Error('Max "'.concat(t,'" is less than Min "').concat(e.min,'"'));e.max!==t&&(e.max=t)},setStrand:function(t){e.strand=t},addChild:function(t){if(e.children&&e.children.size>0){var n=c.getSnapshot(e.children);e.children.clear();var r,o=F(Object.entries(q(q({},n),{},T({},t._id,t))).sort((function(e,t){var n=K(e,2)[1],r=K(t,2);return n.min-r[1].min})));try{for(o.s();!(r=o.n()).done;){var i=K(r.value,2);e.children.put(i[1])}}catch(e){o.e(e)}finally{o.f()}}else{var a;e.children=c.cast({}),null===(a=e.children)||void 0===a||a.put(t)}},deleteChild:function(t){var n;null===(n=e.children)||void 0===n||n.delete(t)}}})).actions((function(e){return{update:function(t){var n=t.children,r=t.max,o=t.min,i=t.strand;e.setRefSeq(t.refSeq),e.setMin(o),e.setMax(r),e.setStrand(i),n&&(e.children=c.cast(n))}}})).views((function(e){return{get parent(){var t;try{t=c.getParentOfType(e,rA)}catch(e){}return t},get topLevelFeature(){var t,n=e;do{try{n=t=c.getParentOfType(n,rA)}catch(e){t=void 0}}while(t);return n},get assemblyId(){return c.getParentOfType(e,aA)._id}}})),oA=c.types.model({start:c.types.number,stop:c.types.number,sequence:c.types.string}),iA=c.types.model("ApolloRefSeq",{_id:c.types.identifier,name:c.types.string,description:"",features:c.types.map(rA),sequence:c.types.array(oA)}).actions((function(e){return{addFeature:function(t){e.features.put(t)},deleteFeature:function(t){return e.features.delete(t)},setDescription:function(t){e.description=t},addSequence:function(t){var n;if(t.sequence.length!==t.stop-t.start)throw new Error("sequence does not match declared length: ".concat(JSON.stringify(t)));if(0!==e.sequence.length){var r=e.sequence.map((function(e){return{start:e.start,stop:e.stop,sequence:e.sequence}}));r.push({start:t.start,stop:t.stop,sequence:t.sequence}),r.sort((function(e,t){return e.start===t.start?e.stop-t.stop:e.start-t.start}));var o,i=r.reduce((function(e,t){var n=e.at(-1);if(void 0===n)return[t];if(n.stop>=t.start){if(t.stop>n.stop){var r=n.stop-t.start;n.stop=t.stop,n.sequence+=t.sequence.slice(r)}}else e.push(t);return e}),[]),a=F(i);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(s.sequence.length!==s.stop-s.start)throw new Error("Consolidated sequence does not match declared length")}}catch(e){a.e(e)}finally{a.f()}e.sequence.length===i.length&&e.sequence.every((function(e,t){var n;return e.start===(null===(n=i[t])||void 0===n?void 0:n.start)&&e.stop===i[t].stop}))||(e.sequence.clear(),(n=e.sequence).push.apply(n,V(i)))}else e.sequence.push(t)}}})).views((function(e){return{getSequence:function(t,n){var r,i=F(e.sequence);try{for(i.s();!(r=i.n()).done;){var a=r.value,s=a.sequence,c=a.start;if(o.isContainedWithin(t,n,c,a.stop))return s.slice(t-c,n-c)}}catch(e){i.e(e)}finally{i.f()}return""},getFeatures:function(t,n){var r,i=[],a=F(e.features);try{for(a.s();!(r=a.n()).done;){var s=K(r.value,2)[1];o.doesIntersect2(s.min,s.max,t,n)&&i.push(s)}}catch(e){a.e(e)}finally{a.f()}return i}}})),aA=c.types.model("ApolloAssembly",{_id:c.types.identifier,refSeqs:c.types.map(iA),comments:c.types.array(c.types.string),backendDriverType:c.types.optional(c.types.enumeration("backendDriverType",["CollaborationServerDriver","InMemoryFileDriver","DesktopFileDriver"]),"CollaborationServerDriver")}).views((function(e){return{getByRefName:function(t){return V(e.refSeqs.values()).find((function(e){return e.name===t}))}}})).actions((function(e){return{addRefSeq:function(t,n,r){return e.refSeqs.put({_id:t,name:n,description:r})},addComment:function(t){return e.comments.push(t)}}})),sA=c.types.model("CheckResult",{_id:c.types.identifier,name:c.types.string,cause:c.types.string,ids:c.types.array(c.types.safeReference(rA)),refSeq:c.types.string,start:c.types.number,end:c.types.number,ignored:!1,message:c.types.string});const cA=c.types.model("ApolloFeatureDetailsWidget",{id:g.ElementId,type:c.types.literal("ApolloFeatureDetailsWidget"),feature:c.types.maybe(c.types.reference(rA,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:c.types.string,refName:c.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}}))),lA=c.types.model("ApolloTranscriptDetails",{id:g.ElementId,type:c.types.literal("ApolloTranscriptDetails"),feature:c.types.maybe(c.types.reference(rA,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:c.types.string,refName:c.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}})));var uA=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,dA=fs((function(e){return uA.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),AA=function(e){return"theme"!==e},fA=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?dA:AA},hA=function(e,t,n){var r;if(t){var o=t.shouldForwardProp;r=e.__emotion_forwardProp&&o?function(t){return e.__emotion_forwardProp(t)&&o(t)}:o}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},gA="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",pA=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return Ss(t,n,r),Ws((function(){return Bs(t,n,r)})),null},mA=function e(t,n){if("production"!==ue.env.NODE_ENV&&void 0===t)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var r,o,i=t.__emotion_real===t,a=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,o=n.target);var s=hA(t,n,i),c=s||fA(a),l=!c("as");return function(){var u=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==u[0]||void 0===u[0].raw)d.push.apply(d,u);else{"production"!==ue.env.NODE_ENV&&void 0===u[0][0]&&console.error(gA),d.push(u[0][0]);for(var A=u.length,f=1;f<A;f++)"production"!==ue.env.NODE_ENV&&void 0===u[0][f]&&console.error(gA),d.push(u[f],u[0][f])}var h=Xs((function(e,t,n){var r=l&&e.as||a,i="",u=[],A=e;if(null==e.theme){for(var f in A={},e)A[f]=e[f];A.theme=C.useContext(Zs)}"string"==typeof e.className?i=xs(t.registered,u,e.className):null!=e.className&&(i=e.className+" ");var h=Ks(d.concat(u),t.registered,A);i+=t.key+"-"+h.name,void 0!==o&&(i+=" "+o);var g=l&&void 0===s?fA(r):c,p={};for(var m in e)l&&"as"===m||g(m)&&(p[m]=e[m]);return p.className=i,p.ref=n,C.createElement(C.Fragment,null,C.createElement(pA,{cache:t,serialized:h,isStringTag:"string"==typeof r}),C.createElement(r,p))}));return h.displayName=void 0!==r?r:"Styled("+("string"==typeof a?a:a.displayName||a.name||"Component")+")",h.defaultProps=t.defaultProps,h.__emotion_real=h,h.__emotion_base=a,h.__emotion_styles=d,h.__emotion_forwardProp=s,Object.defineProperty(h,"toString",{value:function(){return void 0===o&&"production"!==ue.env.NODE_ENV?"NO_COMPONENT_SELECTOR":"."+o}}),h.withComponent=function(t,r){return e(t,Es({},n,r,{shouldForwardProp:hA(h,r,!0)})).apply(void 0,d)},h}}.bind();async function yA(e){if(isSecureContext){const t=new Blob([e.outerText],{type:"text/plain"}),n=new Blob([e.outerHTML],{type:"text/html"}),r=new ClipboardItem({[t.type]:t,[n.type]:n});return navigator.clipboard.write([r])}const t=t=>{t.clipboardData?.setData("text/plain",e.outerText),t.clipboardData?.setData("text/html",e.outerHTML),t.preventDefault()};document.addEventListener("copy",t),document.execCommand("copy"),document.removeEventListener("copy",t)}function _A(e){let t=0;for(const n of e)t+=n.sequence.length;return t}function vA(e,t,n){const r=[],{cdsLocations:i,strand:a,transcriptParts:s}=t;switch(e){case"genomic":case"cDNA":{const[t]=s;for(const i of t){if("cDNA"===e&&"intron"===i.type)continue;let t=n(i.min,i.max);-1===a&&(t=o.revcom(t));const s="fivePrimeUTR"===i.type||"threePrimeUTR"===i.type?"UTR":i.type,c=r.at(-1);c&&c.type===s?(c.sequence+=t,c.locs.push({min:i.min,max:i.max})):r.push({type:s,sequence:t,locs:[{min:i.min,max:i.max}]})}return r}case"CDS":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}return r.push({type:"CDS",sequence:e,locs:s}),r}case"protein":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}let c="";for(let t=0;t<e.length;t+=3){const n=e.slice(t,t+3).toUpperCase();c+=o.defaultCodonTable[n]||"&"}return r.push({type:"protein",sequence:c,locs:s}),r}}}function bA(e){switch(e){case"upOrDownstream":return"rgb(255,255,255)";case"exon":case"UTR":return"rgb(194,106,119)";case"CDS":return"rgb(93,168,153)";case"intron":return"rgb(187,187,187)";case"protein":return"rgb(148,203,236)"}}function CA(e){const t=[],n=e.flatMap((e=>e.locs));let[r]=n;for(let e=1;e<n.length;e++)r.min===n[e].max||r.max===n[e].min?r={min:Math.min(r.min,n[e].min),max:Math.max(r.max,n[e].max)}:(t.push(r),r=n[e]);return t.push(r),t}["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){mA[e]=mA(e)}));const IA=f.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),a=o?.getByRefName(n),{featureTypeOntology:c}=r.apolloDataStore.ontologyManager,l="genomic",d=["genomic","cDNA"],[A,f]=u.useState(d),[h,g]=u.useState(l),[p,m]=u.useState((()=>a?vA(l,t,((e,t)=>a.getSequence(e,t))):[])),[y,_]=u.useState((()=>CA(p))),v=s.useTheme(),b=u.useRef(null);if(u.useEffect((()=>{const{cdsLocations:e}=t,[n]=e;f(n.length>0?[...d,"CDS","protein"]:d)}),[t]),!o||!a)return null;const C=o.getByRefName(n);if(!C)return null;if(!c)throw new Error("featureTypeOntology is undefined");return c.isTypeOf(t.type,"transcript")?i.jsxs(i.Fragment,{children:[i.jsx(s.Select,{defaultValue:"genomic",value:h,onChange:function(e){const n=e.target.value;g(n);const r=a?vA(n,t,((e,t)=>a.getSequence(e,t))):[],o=CA(r);m(r),_(o)},size:"small","data-testid":"sequenceOptionSelector",children:A.map((e=>i.jsx(s.MenuItem,{value:e,"data-testid":`sequenceOption-${e}`,children:e},e)))}),i.jsx(s.Button,{variant:"contained",onClick:()=>{const e=b.current;e&&yA(e)},style:{marginLeft:10},size:"medium",children:"Copy sequence"}),i.jsxs(s.Paper,{style:{fontFamily:"monospace",padding:v.spacing(),overflowX:"auto"},ref:b,children:[">",C.name,":",y.map((e=>1===t.strand?`${e.min+1}-${e.max}`:`${e.max}-${e.min+1}`)).join(";"),"(strand=",1===t.strand?"+":"-",";length=",_A(p),")",i.jsx("br",{}),function(e,t){const n=[];let r=0;for(const[t,o]of e.entries()){const e=r%60,a=r>0&&0===e?"\n":"";r+=o.sequence.length;const s=a+o.sequence.slice(0,60-e),c=[s,...Hr(o.sequence.slice(s.length),60)],l=i.jsx("span",{style:{background:bA(o.type),color:v.palette.getContrastText(bA(o.type)),whiteSpace:"pre-line"},children:c.join("\n")},`${o.type}-${t}`);n.push(l)}return n}(p)]})]}):null}));var wA=a.createSvgIcon(i.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),EA=a.createSvgIcon(i.jsx("path",{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5M19 3l-6 6 2 2 7-7V3z"}),"ContentCut"),xA=a.createSvgIcon(i.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove");const SA=mA(Wd)((()=>({"&.MuiFormControl-root":{marginTop:0,marginBottom:0,width:"100%"},"& .MuiInputBase-input":{fontSize:12,height:20,padding:1,paddingLeft:10}}))),BA=mA("div")({display:"flex",justifyContent:"center",alignItems:"center",textAlign:"left",width:"100%",overflowWrap:"break-word",wordWrap:"break-word",wordBreak:"break-all","& span":{fontSize:12}}),kA=e=>{const{strand:t}=e;return i.jsx("div",{children:1===t?i.jsx(Uo,{}):-1===t?i.jsx(xA,{}):i.jsx(s.Typography,{component:"span",children:"N/A"})})},QA=f.observer((function({assembly:e,feature:t,refName:n,session:r}){const{notify:a}=r,c=r.apolloDataStore.assemblies.get(e),l=c?.getByRefName(n),{changeManager:d}=r.apolloDataStore,A=u.useRef(null),{changeInProgress:f}=r;if(!l)return null;const{apolloDataStore:h}=r,{featureTypeOntology:g}=h.ontologyManager;if(!g.isTypeOf(t.type,"transcript")&&!g.isTypeOf(t.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent");const{cdsLocations:p,transcriptExonParts:m,strand:y}=t,[_]=p,[v,b]=((e,t)=>{const{transcriptExonParts:n}=e,r=n.filter((e=>t.isTypeOf(e.type,"exon"))).sort((({min:e},{min:t})=>e-t)),o=r[0]?.min,i=r[r.length-1]?.max;return[o,i]})(t,g);let C=v,I=b;const w=_.length>0;if(w){const e=_.toSorted((({min:e},{min:t})=>e-t));C=e[0].min,I=e[e.length-1].max}const E=(t,n,r,o,i)=>{if(!r.children)throw new Error("Transcript should have child features");if(t===n)return!0;const s=k(r,g,t,o);if(!s)return a("No matching CDS feature found","error"),!1;if(o&&n>=s.max)return a("Start location should be less than CDS end location","error"),!1;if(!o&&n<=s.min)return a("End location should be greater than CDS start location","error"),!1;if(!D(r,g,n,o))return a("There should be an overlapping exon for the new CDS location","error"),!1;const c=o?new Ur({typeName:"LocationStartChange",changedIds:[s._id],featureId:s._id,oldStart:s.min,newStart:n,assembly:e}):new qr({typeName:"LocationEndChange",changedIds:[s._id],featureId:s._id,oldEnd:s.max,newEnd:n,assembly:e});return d.submit(c).then((()=>{i&&i()})).catch((()=>{a("Error updating feature CDS position","error")})),!0};function x(t,n,r,o){if(!r.children)throw new Error("Transcript should have child features");const{matchingExon:i,prevExon:s,nextExon:c}=F(r,g,t,o);if(!i)return a("No matching exon found","error"),!1;if(o&&n>=i.max)return a("Start location should be less than end location","error"),!1;if(!o&&n<=i.min)return a("End location should be greater than start location","error"),!1;if(s&&s.max+2>n)return a("Error while changing start location","error"),!1;if(c&&c.min-2<n)return a("Error while changing end location","error"),!1;const l=N(r,i.min,i.max,g);if(!l)return a("No matching exon feature found","error"),!1;const u=Q(r,g);if(o&&n!==i.min){const t=new Ur({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:e});if(s)B(l,t,n);else{const e=r.min,i=r.parent;if(n<e)i&&n<i.min&&B(i,t,n),B(r,t,n),B(l,t,n);else if(n>e&&(B(l,t,n),B(r,t,n),i)){const[e]=R(i,r,n,g,o);i.min!=e&&B(i,t,e)}}u&&u.min>=i.min&&u.min<=i.max&&n>u.min&&B(u,t,n),d.submit(t).catch((()=>{a("Error updating feature exon start position","error")}))}if(!o&&n!==i.max){const t=new qr({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:e});if(c)S(l,t,n);else{const e=r.max,i=r.parent;if(n>e)i&&n>i.max&&S(i,t,n),S(r,t,n),S(l,t,n);else if(n<e&&(S(l,t,n),S(r,t,n),i)){const[,e]=R(i,r,n,g,o);i.max!=e&&S(i,t,e)}}u&&u.max>=i.min&&u.max<=i.max&&n<u.max&&S(u,t,n),d.submit(t).catch((()=>{a("Error updating feature exon end position","error")}))}return!0}const S=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldEnd:e.max,newEnd:n})},B=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldStart:e.min,newStart:n})},k=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(t.isTypeOf(i.type,"CDS")){if(r&&n===i.min){o=i;break}if(!r&&n===i.max){o=i;break}}return o},Q=(e,t)=>{let n;for(const[,r]of e.children??[])if(t.isTypeOf(r.type,"CDS")){n=r;break}return n},N=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(r.isTypeOf(i.type,"exon")&&t===i.min&&n===i.max){o=i;break}return o},R=(e,t,n,r,o)=>{const i=[],a=[];for(const[,s]of e.children?.entries()??[])r.isTypeOf(s.type,"transcript")&&(s._id===t._id?o?(i.push(n),a.push(s.max)):(a.push(n),i.push(s.min)):(i.push(s.min),a.push(s.max)));return[Math.min(...i),Math.max(...a)]},D=(e,t,n,r)=>{const{transcriptExonParts:o}=e;let i;for(const[,e]of o.entries())if(t.isTypeOf(e.type,"exon")){if(!r&&n>=e.min&&n<=e.max){i=e;break}if(r&&n>=e.min&&n<=e.max){i=e;break}}return i},F=(e,t,n,r)=>{const{transcriptExonParts:o,strand:i}=e;let a,s,c,l;for(const[e,i]of o.entries())if(t.isTypeOf(i.type,"exon")){if(r&&i.min===n){a=i,s=e;break}if(!r&&i.max===n){a=i,s=e;break}}if(a&&void 0!==s){if(1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}if(-1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}if(1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(-1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}}return{matchingExon:a,prevExon:c,nextExon:l}},T=(e,t)=>{let n="";if(t>0){const r=m[t-1];1===y?"intron"===r.type&&(n=l.getSequence(e.min-2,e.min)):"intron"===r.type&&(n=o.revcom(l.getSequence(e.max,e.max+2)))}return n=n.toUpperCase(),[{spliceSite:n,color:"AG"===n?"green":"red"}]},j=(e,t)=>{let n="";if(t<m.length-1){const r=m[t+1];1===y?"intron"===r.type&&(n=l.getSequence(e.max,e.max+2)):"intron"===r.type&&(n=o.revcom(l.getSequence(e.min-2,e.min)))}return n=n.toUpperCase(),[{spliceSite:n,color:"GT"===n?"green":"red"}]},M=()=>{let e="";const[n]=p,r=n.toSorted((({min:e},{min:t})=>e-t));for(const t of r)e+=l.getSequence(t.min,t.max);-1===y&&(e=o.revcom(e));const a=[];for(let n=0;n<e.length;n+=3){const r=e.slice(n,n+3).toUpperCase(),c=o.defaultCodonTable[r]||"&";"ATG"===r?a.push(i.jsx(s.Typography,{component:"span",style:{backgroundColor:f?"lightgray":"yellow",cursor:"pointer",border:"1px solid black"},onClick:()=>{if(f)return;const e=O(n);e!==C&&1===y&&E(C,e,t,!0),e!==I&&-1===y&&E(I,e,t,!1)},children:c},n)):["TAA","TAG","TGA"].includes(r)?a.push(i.jsx(s.Typography,{style:{backgroundColor:"red",color:"white"},component:"span",children:c},n)):a.push(i.jsx(s.Typography,{component:"span",children:c},n))}return a},O=e=>{const[t]=p;let n=0;const r=t.toSorted((({min:e},{min:t})=>e-t));if(1===y)for(const t of r){const r=t.max-t.min;if(n+r>e)return t.min+(e-n);n+=r}else if(-1===y)for(let t=r.length-1;t>=0;t--){const o=r[t],i=o.max-o.min;if(n+i>e)return o.max-(e-n);n+=i}return 1===y?C:I};return i.jsxs("div",{children:[w&&i.jsxs("div",{children:[i.jsxs(s.Accordion,{children:[i.jsx(FA,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Translation"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(BA,{children:i.jsx(s.Typography,{component:"span",ref:A,style:{maxHeight:120,overflowY:"scroll"},children:M()})}),i.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"row",alignItems:"center",gap:10},children:[i.jsx(s.Tooltip,{title:"Copy",children:i.jsx("button",{onClick:()=>{const e=A.current;e&&yA(e)},style:{border:"none",background:"none",padding:0},disabled:f,children:i.jsx(wA,{style:{fontSize:15}})})}),i.jsx(s.Tooltip,{title:"Trim",children:i.jsx("button",{onClick:()=>{const e=M(),n=e.map((e=>e.props.children)).join("");if(n.startsWith("M")&&n.endsWith("*"))return;const r=[];for(const t of e)r.push({codonGenomicPos:t.key,sequenceLetter:t.props.children});if(0===r.length)return;const o=n.indexOf("M"),i=n.indexOf("*"),s=r[o].codonGenomicPos,c=r[i].codonGenomicPos;if(!s||!c)return;const l=O(s);let u=O(c);if(1===y){if(l>u)return void a("Start codon genomic location should be less than stop codon genomic location","error");let e;u+=3,l!==C&&(e=new Promise((e=>{E(C,l,t,!0,(()=>{e(!0)}))}))),u!==I&&(e?e.then((()=>{E(I,u,t,!1)})):E(I,u,t,!1))}if(-1===y){if(l<u)return void a("Start codon genomic location should be less than stop codon genomic location","error");let e;u-=3,l!==I&&(e=new Promise((e=>{E(I,l,t,!1,(()=>{e(!0)}))}))),u!==C&&(e?e.then((()=>{E(C,u,t,!0)})):E(C,u,t,!0))}a("Translation sequence trimmed to start and stop codons","success")},style:{border:"none",background:"none",padding:0},disabled:f,children:i.jsx(EA,{style:{fontSize:15}})})})]})]})]}),i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center",marginTop:10},children:[i.jsx(s.Grid,{size:1}),i.jsx(s.Grid,1===y?{size:4,children:i.jsx(SA,{margin:"dense",variant:"outlined",value:C+1,onChangeCommitted:e=>E(C,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:f})}:{size:4,children:i.jsx(SA,{margin:"dense",variant:"outlined",value:I,onChangeCommitted:e=>E(I,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:f})}),i.jsx(s.Grid,{size:2,children:i.jsx(s.Typography,{component:"span",children:"CDS"})}),i.jsx(s.Grid,1===y?{size:4,children:i.jsx(SA,{margin:"dense",variant:"outlined",value:I,onChangeCommitted:e=>E(I,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:f})}:{size:4,children:i.jsx(SA,{margin:"dense",variant:"outlined",value:C+1,onChangeCommitted:e=>E(C,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:f})}),i.jsx(s.Grid,{size:1})]})]}),i.jsx("div",{style:{marginTop:5},children:m.map(((e,n)=>i.jsx("div",{children:"exon"===e.type&&i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1,children:0!==n&&T(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))}),i.jsx(s.Grid,1===y?{size:4,style:{padding:0},children:i.jsx(SA,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>x(e.min,n-1,t,!0),disabled:f})}:{size:4,style:{padding:0},children:i.jsx(SA,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>x(e.max,n,t,!1),disabled:f})}),i.jsx(s.Grid,{size:2,children:i.jsx(kA,{strand:t.strand})}),i.jsx(s.Grid,1===y?{size:4,style:{padding:0},children:i.jsx(SA,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>x(e.max,n,t,!1),disabled:f})}:{size:4,style:{padding:0},children:i.jsx(SA,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>x(e.min,n-1,t,!0),disabled:f})}),i.jsx(s.Grid,{size:1,children:n!==m.length-1&&j(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))})]})},n)))})]})})),NA=mA(s.TableCell)((()=>({fontWeight:"bold"}))),RA=f.observer((function(e){const{feature:t}=e,n=Lc(t),r=Pc(t);return i.jsx(s.Table,{size:"small",sx:{fontSize:"0.75rem","& .MuiTableCell-root":{padding:"4px"}},children:i.jsxs(s.TableBody,{children:[""!==n&&i.jsxs(s.TableRow,{children:[i.jsx(NA,{children:"Name"}),i.jsx(s.TableCell,{children:Lc(t)})]}),""!==r&&i.jsxs(s.TableRow,{children:[i.jsx(NA,{children:"ID"}),i.jsx(s.TableCell,{children:Pc(t)})]}),i.jsxs(s.TableRow,{children:[i.jsx(NA,{children:"Type"}),i.jsx(s.TableCell,{children:t.type})]}),i.jsxs(s.TableRow,{children:[i.jsx(NA,{children:"Location"}),i.jsxs(s.TableCell,{children:[e.refName,":",t.min,"..",t.max]})]}),i.jsxs(s.TableRow,{children:[i.jsx(NA,{children:"Strand"}),i.jsx(s.TableCell,{children:(o=t.strand,1===o?"Forward":-1===o?"Reverse":"")})]})]})});var o})),DA=Ec()((e=>({root:{padding:e.spacing(2)}}))),FA=mA(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function TA(e){return null}const jA=f.observer((function(e){const{classes:t}=DA(),n=["summary","location"],[r,a]=u.useState(n),{model:l}=e,{assembly:d,feature:A,refName:f}=l;u.useEffect((()=>{a(n)}),[A]);const h=o.getSession(l),{pluginManager:g}=o.getEnv(h),p=o.getSession(l),m=p.apolloDataStore.assemblies.get(d),{internetAccounts:y}=c.getRoot(h),_=y.find((e=>"ApolloInternetAccount"===e.type)),v=["admin","user"].includes((_?_.role:"admin")??"");if(!A||!m)return null;const b=m.getByRefName(f);if(!b)return null;const{max:C,min:I}=A;function w(e,t){a(e?[...r,t]:r.filter((e=>e!==t)))}b.getSequence(I,C)||p.apolloDataStore.loadRefSeq([{assemblyName:d,refName:f,start:I,end:C}]);const E=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSummary",TA,{feature:A,session:h}),x=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSummary",TA,{feature:A,session:h}),S=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideLocation",TA,{feature:A,session:h}),B=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterLocation",TA,{feature:A,session:h}),k=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideAttributes",TA,{feature:A,session:h}),Q=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterAttributes",TA,{feature:A,session:h}),N=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSequence",TA,{feature:A,session:h}),R=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSequence",TA,{feature:A,session:h});return i.jsxs("div",{className:t.root,children:[i.jsxs(s.Accordion,{expanded:r.includes("summary"),onChange:(e,t)=>{w(t,"summary")},children:[i.jsx(FA,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Summary"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(RA,{feature:A,refName:f}),i.jsx(E,{session:h,feature:A})]})]}),i.jsx(x,{session:h,feature:A}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("location"),onChange:(e,t)=>{w(t,"location")},children:[i.jsx(FA,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Location"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(QA,{feature:A,refName:f,session:p,assembly:m._id||""}),i.jsx(S,{session:h,feature:A})]})]}),i.jsx(B,{session:h,feature:A}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("attrs"),onChange:(e,t)=>{w(t,"attrs")},children:[i.jsx(FA,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[i.jsxs(s.Typography,{component:"span",fontWeight:"bold",children:["Attributes"," "]}),i.jsx(s.Tooltip,{title:"Separate multiple values for the attribute with commas",children:i.jsx(xc,{style:{color:"white",fontSize:15,marginLeft:10}})})]})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Kd,{feature:A,session:p,assembly:m._id||"",editable:v}),i.jsx(k,{session:h,feature:A})]})]}),i.jsx(Q,{session:h,feature:A}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("sequence"),onChange:(e,t)=>{w(t,"sequence")},children:[i.jsx(FA,{expandIcon:i.jsx(Td,{style:{color:"white"}}),"aria-controls":"panel4-content",id:"panel4-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Sequence"})}),i.jsxs(s.AccordionDetails,{children:[r.includes("sequence")&&i.jsx(IA,{feature:A,session:p,assembly:m._id||"",refName:f}),i.jsx(N,{session:h,feature:A})]})]}),i.jsx(R,{feature:A,session:h})]})})),MA=n.ConfigurationSchema("LinearApolloDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),OA=Ec()({highlighted:{background:"orange"}}),LA=({highlight:e,text:t})=>{const{classes:n}=OA();if(!e)return i.jsx(i.Fragment,{children:t});const r=t.split(e);if(1===r.length)return i.jsx(i.Fragment,{children:t});const o=[];for(let t=0;t<r.length-1;t++)o.push(r[t],i.jsx("span",{className:n.highlighted,children:e}));return i.jsxs(i.Fragment,{children:[o,r.at(-1)]})},PA=f.observer((function({feature:e,filterText:t}){const n=[...e.attributes.entries()].map((([e,t])=>{if(e.startsWith("gff_")){const n=e.slice(4);return[n.charAt(0).toUpperCase()+n.slice(1),c.getSnapshot(t)]}return"_id"===e?["ID",c.getSnapshot(t)]:[e,c.getSnapshot(t)]})).filter((([e])=>e)).map((([e,t])=>`${e}=${Array.isArray(t)?t.join(", "):t}`)).join(", ");return i.jsx(LA,{text:n,highlight:t})})),qA=Ec()((e=>({inputWrapper:{position:"relative"},hiddenWidthSpan:{padding:e.spacing(.5),color:"transparent"},numberTextInput:{border:"none",background:"inherit",font:"inherit",position:"absolute",width:"100%",left:0}}))),JA=f.observer((function({initialValue:e,notifyError:t,onChangeCommitted:n}){const[r,o]=u.useState(e),[a,s]=u.useState(!1),[c,l]=u.useState(null),{classes:d}=qA();return u.useEffect((()=>{e!==r&&o(e)}),[e]),u.useEffect((()=>{a&&(c?.blur(),s(!1))}),[a,c]),i.jsxs("span",{className:d.inputWrapper,children:[i.jsx("span",{className:d.hiddenWidthSpan,"aria-hidden":!0,children:r}),i.jsx("input",{type:"text",value:r,className:d.numberTextInput,onChange:function(e){const t=Number(e.target.value);Number.isNaN(t)||o(t)},onKeyDown:t=>{"Enter"===t.key?c?.blur():"Escape"===t.key&&(o(e),s(!0))},onBlur:()=>{r!==e&&n(r).catch(t)},ref:e=>{l(e)}})]})})),UA=Ec()((e=>({typeContent:{display:"inline-block",width:"174px",height:"100%",cursor:"text"},feature:{td:{position:"relative",verticalAlign:"top",paddingLeft:"0.5em"}},arrow:{display:"inline-block",width:"1.6em",textAlign:"center",cursor:"pointer"},arrowExpanded:{transform:"rotate(90deg)"},hoveredFeature:{backgroundColor:e.palette.action.hover},typeInputElement:{border:"none",background:"none"},typeErrorMessage:{color:"red"}})));function GA(e,t){const{changeManager:n,getAssemblyId:r,regions:i,selectedFeature:a,session:s,setSelectedFeature:l,filteredTranscripts:u,updateFilteredTranscripts:d}=e;return function(e,t,n,r,i,a,s,l,u){const d=function(e){const{internetAccounts:t}=c.getParent(e);return t.find((e=>"ApolloInternetAccount"===e.type))}(a),A=d?d.role:"admin",f="admin"===A,h=!(A&&["admin","user"].includes(A)),g=[];if(e){const c=e.attributes.get("gff_id")?.toString(),A=n(t.assemblyName),p=n(t.assemblyName);g.push({label:"Edit feature details",onClick:()=>{const n=a.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:e,assembly:p,refName:t.refName});a.showWidget(n)}},{label:"Add child feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Bu,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:A,internetAccount:d}]))}},{label:"Copy features and annotations",disabled:h,onClick:()=>{a.queueDialog((t=>[Ou,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p}]))}},{label:"Delete feature",disabled:!f,onClick:()=>{a.queueDialog((t=>[Pu,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge transcripts",disabled:!f,onClick:()=>{a.queueDialog((t=>[Xu,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge exons",disabled:!f,onClick:()=>{a.queueDialog((t=>[Vu,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Split exon",disabled:!f,onClick:()=>{a.queueDialog((t=>[ld,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p,selectedFeature:r,setSelectedFeature:i}]))}});const{featureTypeOntology:m}=a.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");(m.isTypeOf(e.type,"transcript")||m.isTypeOf(e.type,"pseudogenic_transcript"))&&o.isSessionModelWithWidgets(a)&&g.push({label:"Edit transcript details",onClick:()=>{const n=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:e,assembly:p,changeManager:s,refName:t.refName});a.showWidget(n)}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((t=>[ud,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:p,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Visible",type:"checkbox",checked:!c||!l.includes(c),onClick:()=>{if(c){const e=l.includes(c)?l.filter((e=>e!==c)):[...l,c];u(e)}}})}return g}(t,i[0],r,a,l,s,n,u,d)}const HA=f.observer((function e({depth:t,feature:n,isHovered:r,isSelected:o,model:a,selectedFeatureClass:s,setContextMenu:c}){const{classes:l}=UA(),{changeManager:u,hoveredFeature:d,selectedFeature:A,session:f,tabularEditor:h}=a,{featureCollapsed:g,filterText:p}=h,{_id:m,children:y,max:_,min:v,strand:b,type:C}=n,I=!g.get(m),w=e=>{f.notify(e.message,"error")};return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{onMouseEnter:e=>{a.setHoveredFeature({feature:n,bp:v})},className:l.feature+(o?` ${s}`:r?` ${l.hoveredFeature}`:""),onClick:e=>{e.stopPropagation(),a.setSelectedFeature(n)},onDoubleClick:()=>{a.setSelectedFeature(n),function(e,t){e.lgv.navTo(rl(t,.1,e.lgv.totalBp))}(a,n)},onContextMenu:e=>(e.preventDefault(),c({position:{left:e.clientX+2,top:e.clientY-6},items:GA(a,n)}),!1),children:[i.jsxs("td",{style:{whiteSpace:"nowrap",borderLeft:2*t+"em solid transparent"},children:[y?.size?i.jsx("div",{onClick:e=>{e.stopPropagation(),h.setFeatureCollapsed(m,I)},className:l.arrow+(I?` ${l.arrowExpanded}`:""),children:"❯"}):null,i.jsx("div",{className:l.typeContent,children:i.jsx(Su,{session:f,ontologyName:"Sequence Ontology",style:{width:170},value:C,filterTerms:wu,fetchValidTerms:YA.bind(null,n),renderInput:e=>i.jsxs("div",{ref:e.InputProps.ref,children:[i.jsx("input",{type:"text",...e.inputProps,className:l.typeInputElement,style:{width:170}}),e.error?i.jsx("div",{className:l.typeErrorMessage,children:e.errorMessage??"unknown error"}):null]}),onChange:(e,t)=>{t&&function(e,t,n,r){const o=t._id,i=new no({typeName:"TypeChange",changedIds:[o],featureId:o,oldType:String(n),newType:String(r),assembly:t.assemblyId});return e.submit(i)}(u,n,e,t).catch(w)}})})]}),i.jsx("td",{children:i.jsx(JA,{initialValue:v+1,notifyError:w,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Ur({typeName:"LocationStartChange",changedIds:[o],featureId:o,oldStart:n,newStart:r,assembly:t.assemblyId});return e.submit(i)}(u,n,v,e-1)})}),i.jsx("td",{children:i.jsx(JA,{initialValue:_,notifyError:w,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new qr({typeName:"LocationEndChange",changedIds:[o],featureId:o,oldEnd:n,newEnd:r,assembly:t.assemblyId});return e.submit(i)}(u,n,_,e)})}),i.jsx("td",{children:1===b?"+":-1===b?"-":void 0}),i.jsx("td",{children:i.jsx(PA,{filterText:p,feature:n})})]}),I&&y?[...y.entries()].filter((e=>{if(!p)return!0;const[,t]=e;return JSON.stringify(t).includes(p)})).map((([n,r])=>i.jsx(e,{isHovered:d?.feature._id===r._id,isSelected:A?._id===r._id,selectedFeatureClass:s,depth:(t||0)+1,feature:r,model:a,setContextMenu:c},n))):null]})}));async function YA(e,t,n){const{parent:r}=e;if(r){const e=(await t.getTermsWithLabelOrSynonym(r.type,{includeSubclasses:!1})).filter(wu);if(e.length>0)return await t.getClassesThat("part_of",e)}}const zA=Ec()((e=>({scrollableTable:{width:"100%",height:"100%",th:{position:"sticky",top:0,zIndex:2,textAlign:"left",background:e.palette.background.paper,paddingTop:"3.2em"},td:{whiteSpace:"normal"}},selectedFeature:{backgroundColor:e.palette.action.selected}}))),KA=f.observer((function({model:e}){const{hoveredFeature:t,seenFeatures:n,selectedFeature:r,tabularEditor:o}=e,a=s.useTheme(),{classes:c}=zA(),l=u.useRef(null),[d,f]=u.useState(null),{filterText:h}=o;return u.useEffect((()=>{const e=l.current;if(e&&r){const t=e.querySelector(`.${c.selectedFeature}`);if(t){const n=e.scrollTop,r=t.offsetTop-25;r>n&&r<n+e.offsetHeight||e.scroll({top:r-40,behavior:"smooth"})}}}),[r,n,c.selectedFeature]),i.jsxs("div",{ref:l,style:{width:"100%",overflowY:"auto",height:"100%"},children:[i.jsxs("table",{className:c.scrollableTable,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"Strand"}),i.jsx("th",{children:"Attributes"})]})}),i.jsx("tbody",{children:[...n.entries()].filter((e=>{if(!h)return!0;const[,t]=e;return JSON.stringify(t).includes(h)})).sort(((e,t)=>e[1].min-t[1].min)).map((([n,o])=>i.jsx(HA,{isSelected:r?._id===n,isHovered:t?.feature._id===n,selectedFeatureClass:c.selectedFeature,feature:o,model:e,depth:0,setContextMenu:f},n)))})]}),i.jsx(A.Menu,{open:Boolean(d),onMenuItemClick:(e,t)=>{t(),f(null)},onClose:()=>{f(null)},slotProps:{transition:{onExit:()=>{f(null)}}},style:{zIndex:a.zIndex.tooltip},menuItems:d?.items??[],anchorReference:"anchorPosition",anchorPosition:d?.position})]})}));var WA=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),VA=a.createSvgIcon(i.jsx("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");const $A=Ec()({toolbar:{width:"100%",display:"flex",paddingRight:"2em",flexDirection:"row",justifyContent:"space-between",position:"absolute",zIndex:4},filterText:{}}),XA=f.observer((function({model:e}){const t=e.tabularEditor,{classes:n}=$A();return i.jsxs("div",{className:n.toolbar,children:[i.jsx(s.Tooltip,{title:"Collapse all",children:i.jsx(s.IconButton,{"aria-label":"collapse",sx:{marginTop:0},onClick:t.collapseAllFeatures,children:i.jsx(VA,{})})}),i.jsx(s.TextField,{className:n.filterText,label:"Filter features",value:t.filterText,sx:{marginTop:0},variant:"outlined",onChange:e=>{t.setFilterText(e.target.value)},slotProps:{input:{endAdornment:i.jsx(s.InputAdornment,{position:"end",children:i.jsx(s.IconButton,{onClick:()=>{t.clearFilterText()},children:i.jsx(WA,{})})})}}})]})}));function ZA(e){e.stopPropagation()}const ef=f.observer((function({model:e}){return e.tabularEditor.isShown?i.jsxs("div",{onMouseDown:ZA,onClick:ZA,style:{width:"100%",height:"100%",position:"relative"},children:[i.jsx(XA,{model:e}),i.jsx(KA,{model:e})]}):null})),tf=c.types.model("TabularEditor",{isShown:!0,featureCollapsed:c.types.map(c.types.boolean),filterText:""}).actions((e=>({setFeatureCollapsed(t,n){e.featureCollapsed.set(t,n)},setFilterText(t){e.filterText=t},clearFilterText(){e.filterText=""},collapseAllFeatures(){const t=c.getParent(e);for(const[n]of t.seenFeatures.entries())e.featureCollapsed.set(n,!0)},togglePane(){e.isShown=!e.isShown},hidePane(){e.isShown=!1},showPane(){e.isShown=!0}})));function nf(e,t,n,r=!1){const{apolloRowHeight:o,lgv:i,theme:a}=e,s=e.getFeatureLayoutPosition(n);if(!s)return;const{bpPerPx:c,displayedRegions:l,offsetPx:u}=i,{layoutIndex:d,layoutRow:A}=s,f=l[d],{refName:h,reversed:g}=f,{length:p,max:m,min:y}=n,_=(i.bpToPx({refName:h,coord:g?m:y,regionNumber:d})?.offsetPx??0)-u,v=A*o,b=p/c;t.fillStyle=r?a.palette.action.disabled:a.palette.action.focus,t.fillRect(_,v,b,o)}function rf(e,t,n,r,o,i){e.fillStyle=i,e.fillRect(t,n,r,o)}function of(e,t,n){const{refName:r,regionNumber:o,x:i}=e,{lgv:a}=n,{offsetPx:s}=a,c=a.bpToPx({refName:r,coord:t.min,regionNumber:o}),l=a.bpToPx({refName:r,coord:t.max,regionNumber:o});if(void 0!==c&&void 0!==l){const e=c.offsetPx-s,t=l.offsetPx-s;if(Math.abs(t-e)<8)return;if(Math.abs(e-i)<4)return"min";if(Math.abs(t-i)<4)return"max"}}const af={draw:function(e,t,n,r,o){const{apolloRowHeight:i,lgv:a,selectedFeature:s,theme:c}=r,{bpPerPx:l,displayedRegions:u,offsetPx:d}=a,A=u[o],f=(a.bpToPx({refName:A.refName,coord:t.min,regionNumber:o})?.offsetPx??0)-d,{reversed:h}=A,g=t.length/l,p=h?f-g:f,m=n*i,y=c.palette.background.default;!function(e,t,n,r,o,i){rf(e,t,n,r,o,i),r<=2||e.clearRect(t+1,n+1,r-2,o-2)}(e,p,m,g,i,c.palette.text.primary),g<=2||(function(e,t,n,r,o,i){rf(e,t+1,n+1,r-2,o-2,i)}(e,p,m,g,i,y),Zc(t,s)&&nf(r,e,t,!0))},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:c,offsetPx:l}=o;if(!n)return;const{current:u,edge:d,feature:A,start:f}=n,h=Math.floor(f.y/r),g=c[f.regionNumber],p=(g.reversed?g.end-A[d]:A[d]-g.start)/a-l,m=Math.min(u.x,p),y=h*r,_=Math.abs(u.x-p),v=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(m,y,_,v),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(m,y,_,v)},drawHover:function(e,t){const{hoveredFeature:n}=e;n&&nf(e,t,n.feature)},drawTooltip:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,lgv:o,theme:i}=e;if(!n)return;const{feature:a}=n,c=e.getFeatureLayoutPosition(a);if(!c)return;const{featureRow:l,layoutIndex:u,layoutRow:d}=c,{bpPerPx:A,displayedRegions:f,offsetPx:h}=o,g=f[u],{refName:p,reversed:m}=g;let y="Loc: ";const{length:_,max:v,min:b}=a;y+=`${b+1}–${v}`;let C=(o.bpToPx({refName:p,coord:m?v:b,regionNumber:u})?.offsetPx??0)-h;const I=(d+l)*r,w=_/A,E=`Type: ${a.type}`,{attributes:x}=a,S=x.get("gff_name")?.find((e=>""!==e)),B=[t.measureText(E).width,t.measureText(y).width];S&&B.push(t.measureText(`Name: ${S}`).width);const k=Math.max(...B);C=C+w+5,t.fillStyle=s.alpha(i.palette.text.primary,.7),t.fillRect(C,I,k+4,3===B.length?45:35),t.beginPath(),t.moveTo(C,I),t.lineTo(C-5,I+5),t.lineTo(C,I+10),t.fill(),t.fillStyle=i.palette.background.default;let Q=I+12;t.fillText(E,C+2,Q),S&&(Q+=12,t.fillText(`Name: ${S}`,C+2,Q)),Q+=12,t.fillText(y,C+2,Q)},getContextMenuItemsForFeature:nl,getContextMenuItems:function(e){const{hoveredFeature:t}=e;return t?nl(e,t.feature):[]},getFeatureFromLayout:function(e,t,n){return e},getRowCount:function(e){return 1},getRowForFeature:function(e,t){return 0},onMouseDown:function(e,t,n){const{feature:r}=t,o=of(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,r,o))},onMouseLeave:function(){},onMouseMove:function(e,t){if(sl(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),of(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(e.apolloDragging)return;const{feature:n}=t;n&&(e.setSelectedFeature(n),e.showFeatureDetailsWidget(n))}};let sf=null,cf=null,lf=null,uf=null;const df=globalThis.document.createElement("canvas");if(df?.getContext)for(const e of["forward","backward"])for(const t of["light","dark"]){const n=document.createElement("canvas"),r=10;n.width=n.height=r;const o=n.getContext("2d");if(o){const i="light"===t?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",a="light"===t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",s="forward"===e?o.createLinearGradient(0,r,r,0):o.createLinearGradient(0,0,r,r);s.addColorStop(0,i),s.addColorStop(.25,i),s.addColorStop(.25,a),s.addColorStop(.5,a),s.addColorStop(.5,i),s.addColorStop(.75,i),s.addColorStop(.75,a),s.addColorStop(1,a),o.fillStyle=s,o.fillRect(0,0,10,10),"forward"===e?"light"===t?sf=o.createPattern(n,"repeat"):lf=o.createPattern(n,"repeat"):"light"===t?cf=o.createPattern(n,"repeat"):uf=o.createPattern(n,"repeat")}}function Af(e,t,n,r,o,i,a,s,c){const{apolloRowHeight:l,lgv:u,theme:d}=t,{bpPerPx:A,displayedRegions:f,offsetPx:h}=u,g=f[n],{refName:p,reversed:m}=g,y=(u.bpToPx({refName:p,coord:o.min,regionNumber:n})?.offsetPx??0)-h,_=o.length/A,v=m?y-_:y,b=(r+i)*l,C=Math.round(.6*l),I=b+(l-C)/2;if(e.fillStyle=d.palette.text.primary,e.fillRect(v,I,_,C),_>2&&(e.clearRect(v+1,I+1,_-2,C-2),e.fillStyle="rgb(211,211,211)",e.fillRect(v+1,I+1,_-2,C-2),s&&c&&a)){const t=m?-1:1,[n,r]=a*t==1?[s,c]:[c,s];e.fillStyle=n,e.fillRect(v+1,I+1,_-2,(C-2)/2),e.fillStyle=r,e.fillRect(v+1,I+1+(C-2)/2,_-2,(C-2)/2)}}function*ff(e,t,n=1){if(e!==t)if(e<t)for(let r=e;r<t;r+=n)yield r;else for(let r=e;r>t;r-=n)yield r}function hf(e,t,n,r,o,i){const{apolloRowHeight:a,lgv:s,theme:c}=t,{bpPerPx:l,displayedRegions:u,offsetPx:d}=s,A=u[n],{refName:f,reversed:h}=A,g=(s.bpToPx({refName:f,coord:o.min,regionNumber:n})?.offsetPx??0)-d,p=Math.round(o.length/l),m=h?g-p:g,y=Math.round((i+.5)*a)+r*a;e.strokeStyle=c.palette.text.primary;const{strand:_=1}=o;e.beginPath();const v=_*(h?-1:1),b=m-(-1===v?5:0),C=m+p+(-1===v?0:5);e.moveTo(b,y),e.lineTo(C,y);const I=b+(-1===v?0:3),w=C-(-1===v?3:0),E=-1===v?3:-3,x=-1===v?ff(I,w,20):ff(w,I,20);for(const t of x)e.moveTo(t+E,y+E),e.lineTo(t,y),e.lineTo(t+E,y-E);e.stroke()}function gf(e,t,n,r=!1){const{apolloRowHeight:o,lgv:i,session:a,theme:s}=e,{featureTypeOntology:c}=a.apolloDataStore.ontologyManager,l=e.getFeatureLayoutPosition(n);if(!l)return;const{bpPerPx:u,displayedRegions:d,offsetPx:A}=i,{featureRow:f,layoutIndex:h,layoutRow:g}=l,p=d[h],{refName:m,reversed:y}=p,{length:_,max:v,min:b}=n,C=(i.bpToPx({refName:m,coord:y?v:b,regionNumber:h})?.offsetPx??0)-A,I=(g+f)*o,w=_/u;if(t.fillStyle=r?s.palette.action.disabled:s.palette.action.focus,!c)throw new Error("featureTypeOntology is undefined");t.fillRect(C,I,w,o*mf(n,c))}function pf(e,t){const{children:n,type:r}=e;if(!n)return 0;let o=0;if(t.isTypeOf(r,"transcript"))for(const[,e]of n)t.isTypeOf(e.type,"CDS")&&(o+=1);return o}function mf(e,t,n){const{children:r,type:o}=e;if(!r)return 1;let i=0;if(t.isTypeOf(o,"transcript")||t.isTypeOf(o,"pseudogenic_transcript")){for(const[,e]of r)t.isTypeOf(e.type,"CDS")&&(i+=1);return 0===i?1:i}for(const[,e]of r)i+=mf(e,t);return i}function yf(e,t){if(!t.isTypeOf(e.type,"gene")&&!t.isTypeOf(e.type,"pseudogene"))throw new Error('Top level feature for GeneGlyph must have type "gene"');const{children:n}=e;if(!n)return[[e]];const r=[];for(const[,o]of n){if(!t.isTypeOf(o.type,"transcript")&&!t.isTypeOf(o.type,"pseudogenic_transcript")){r.push([o,e]);continue}if(!o.children)continue;const n=[],i=[];for(const[,e]of o.children)t.isTypeOf(e.type,"CDS")?n.push(e):t.isTypeOf(e.type,"exon")&&i.push(e);for(const t of n)r.push([t,...i,o,e]);0===n.length&&r.push([...i,o,e])}return r}function _f(e,t,n){const{session:r}=n,{apolloDataStore:i}=r,{featureTypeOntology:a}=i.ontologyManager;if(!a)throw new Error("featureTypeOntology is undefined");const s=a.isTypeOf(t.type,"gene")||a.isTypeOf(t.type,"pseudogene"),c=a.isTypeOf(t.type,"transcript")||a.isTypeOf(t.type,"pseudogenic_transcript"),l=a.isTypeOf(t.type,"CDS");if(s||c)return;const{bp:u,refName:d,regionNumber:A,x:f}=e,{lgv:h}=n;if(l){const e=t.parent;if(!e?.children)return;const n=[];for(const t of e.children.values())a.isTypeOf(t.type,"exon")&&n.push(t);const r=n.find((e=>{const[t,n]=o.intersection2(u-1,u,e.min,e.max);return void 0!==t&&void 0!==n}));if(r){const e=$c(r,d,A,h);if(e){const t=Xc(r,f,e);if(t)return t}}}const g=$c(t,d,A,h);if(g){const e=Xc(t,f,g);if(e)return e}}const{drawTooltip:vf,getContextMenuItemsForFeature:bf,onMouseLeave:Cf}=af,If={draw:function(e,t,r,i,a){const{apolloRowHeight:c,lgv:l,selectedFeature:u,session:d,theme:A}=i,{bpPerPx:f,displayedRegions:h,offsetPx:g}=l,p=h[a],{refName:m,reversed:y}=p,_=c,v=Math.round(.9*_),{children:b,strand:C}=t;if(!b)return;const{apolloDataStore:I}=d,{featureTypeOntology:w}=I.ontologyManager;if(!w)throw new Error("featureTypeOntology is undefined");!function(e,t,r,o,i,a){const{apolloRowHeight:c,lgv:l,session:u,theme:d}=r,{bpPerPx:A,displayedRegions:f,offsetPx:h}=l,g=f[o],{refName:p,reversed:m}=g,{apolloDataStore:y}=u,{featureTypeOntology:_}=y.ontologyManager;if(!_)throw new Error("featureTypeOntology is undefined");const v=(l.bpToPx({refName:p,coord:t.min,regionNumber:o})?.offsetPx??0)-h,b=t.length/A,C=m?v-b:v,I=i*c,w=mf(t,_)*c;let E;E=n.readConfObject(u.getPluginConfiguration(),"geneBackgroundColor",{featureType:t.type}),E||(E=s.alpha(d.palette.background.paper,.6)),e.fillStyle=E,e.fillRect(C,I,b,w)}(e,t,i,a,r);let E=0;for(const[,t]of b){if(!w.isTypeOf(t.type,"transcript")&&!w.isTypeOf(t.type,"pseudogenic_transcript")){E+=1;continue}const{children:n}=t;if(!n)continue;const o=pf(t,w);for(const[,o]of n)w.isTypeOf(o.type,"CDS")&&(hf(e,i,a,r,t,E),E+=1);0===o&&(hf(e,i,a,r,t,E),E+=1)}const x="dark"===A.palette.mode?lf:sf,S="dark"===A.palette.mode?uf:cf;E=0;for(const[,t]of b){if(!w.isTypeOf(t.type,"transcript")&&!w.isTypeOf(t.type,"pseudogenic_transcript")){af.draw(e,t,r,i,a),E+=1;continue}const n=pf(t,w);if(0!=n)for(const n of t.cdsLocations){const{children:s}=t;if(s){for(const[,t]of s)w.isTypeOf(t.type,"exon")&&Af(e,i,a,r,t,E,C,x,S);for(const i of n){const n=(i.max-i.min)/f,s=(l.bpToPx({refName:m,coord:i.min,regionNumber:a})?.offsetPx??0)-g,c=y?s-n:s;e.fillStyle=A.palette.text.primary;const u=(r+E)*_+(_-v)/2;if(e.fillRect(c,u,n,v),n>2){e.clearRect(c+1,u+1,n-2,v-2);const r=o.getFrame(i.min,i.max,t.strand??1,i.phase),a=A.palette.framesCDS.at(r)?.main;if(e.fillStyle=a??"black",e.fillRect(c+1,u+1,n-2,v-2),x&&S&&C){const t=y?-1:1,[r,o]=C*t==1?[x,S]:[S,x];e.fillStyle=r,e.fillRect(c+1,u+1,n-2,(v-2)/2),e.fillStyle=o,e.fillRect(c+1,u+(v-2)/2,n-2,(v-2)/2)}}}E+=1}}const{children:s}=t;if(0===n&&s){for(const[,t]of s)w.isTypeOf(t.type,"exon")&&Af(e,i,a,r,t,E,C,x,S);E+=1}}u&&el(t,u)&&gf(i,e,u,!0)},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:c,offsetPx:l}=o;if(!n)return;const{current:u,edge:d,feature:A,start:f}=n,h=Math.floor(f.y/r),g=c[f.regionNumber],p=(g.reversed?g.end-A[d]:A[d]-g.start)/a-l,m=Math.min(u.x,p),y=h*r,_=Math.abs(u.x-p),v=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(m,y,_,v),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(m,y,_,v)},drawHover:function(e,t){const{hoveredFeature:n}=e;n&&gf(e,t,n.feature)},drawTooltip:vf,getContextMenuItems:function(e,t){const{apolloInternetAccount:n,hoveredFeature:r,changeManager:i,regions:a,selectedFeature:s,session:c}=e,[l]=a,u=e.getAssemblyId(l.assemblyName),d=[],A="admin"===(n?n.role:"admin");if(!r)return d;if(sl(t)){const{bp:n,feature:r}=t;let a=Jc(r,n);Kc(r,c)&&(a=Jc(r,n,!0));for(const n of a){const r=af.getContextMenuItemsForFeature(e,n);if(zc(n,c)){const a=Wc(n,e,t,c),l=o.getContainingView(e);if(a.upstream){const t=a.upstream;r.push({label:"Go to upstream exon",icon:Vc(n.strand,!0,l.displayedRegions.at(0)?.reversed),onClick:()=>{l.navTo(rl(t,.1,l.totalBp)),Hc(e,t)}})}if(a.downstream){const t=a.downstream;r.push({label:"Go to downstream exon",icon:Vc(n.strand,!1,l.displayedRegions.at(0)?.reversed),onClick:()=>{l.navTo(rl(t,.1,l.totalBp)),Hc(e,t)}})}r.push({label:"Merge exons",disabled:!A,onClick:()=>{c.queueDialog((t=>[Vu,{session:c,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:u,selectedFeature:s,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:!A,onClick:()=>{c.queueDialog((t=>[ld,{session:c,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:u,selectedFeature:s,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}})}Yc(n,c)&&(r.push({label:"Merge transcript",onClick:()=>{c.queueDialog((t=>[Xu,{session:c,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:u,selectedFeature:s,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Duplicate feature",onClick:()=>{c.queueDialog((t=>[ud,{session:c,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:u,selectedFeature:s,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),o.isSessionModelWithWidgets(c)&&r.splice(1,0,{label:"Open transcript editor",onClick:()=>{const e=c.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:n,assembly:u,changeManager:i,refName:l.refName});c.showWidget(e)}})),d.push({label:n.type,subMenu:r})}}return d},getContextMenuItemsForFeature:bf,getFeatureFromLayout:function(e,t,n,r){const o=yf(e,r)[n]||[];for(const e of o){let n;if(t>=e.min&&t<=e.max&&e.parent&&(n=e),n){if(r.isTypeOf(n.type,"CDS")&&n.parent&&(r.isTypeOf(n.parent.type,"transcript")||r.isTypeOf(n.parent.type,"pseudogenic_transcript"))){const{cdsLocations:e}=n.parent;for(const r of e)for(const e of r)if(t>=e.min&&t<=e.max)return n;return n.parent}return n}}return e},getRowCount:mf,getRowForFeature:function(e,t,n){const r=yf(e,n);for(const[e,n]of r.entries())if(n.some((e=>e._id===t._id)))return e},onMouseDown:function(e,t,n){const{feature:r}=t,o=_f(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,o.feature,o.edge,!0))},onMouseLeave:Cf,onMouseMove:function(e,t){if(sl(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),_f(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(e.apolloDragging)return;const{feature:n}=t;n&&Hc(e,n)}};function wf(e){const t=[[e]];if(e.children)for(const[,n]of e.children)t.push(...wf(n));return t}function Ef(e){return wf(e).length}function xf(e,t,n,r,o,i){const a=wf(t)[n-r];for(const t of a)Sf(e,t,n,o,i)}function Sf(e,t,n,r,o){const{apolloRowHeight:i,lgv:a,theme:c}=r,{bpPerPx:l,displayedRegions:u,offsetPx:d}=a,A=u[o],f=(a.bpToPx({refName:A.refName,coord:t.min,regionNumber:o})?.offsetPx??0)-d,{reversed:h}=A,g=t.length/l,p=h?f-g:f,m=n*i,y=Ef(t),_=s.alpha(c.palette.background.paper,.6);y>1&&rf(e,p,m,g,y*i,_),af.draw(e,t,n,r,o)}function Bf(e,t,n,r=!1){const{apolloRowHeight:o,lgv:i,theme:a}=e,s=e.getFeatureLayoutPosition(n);if(!s)return;const{featureRow:c,layoutIndex:l,layoutRow:u}=s,{bpPerPx:d,displayedRegions:A,offsetPx:f}=i,h=A[l],{refName:g,reversed:p}=h,{length:m,max:y,min:_}=n,v=(i.bpToPx({refName:g,coord:p?y:_,regionNumber:l})?.offsetPx??0)-f,b=(u+c)*o,C=m/d;t.fillStyle=r?a.palette.action.disabled:a.palette.action.focus,t.fillRect(v,b,C,o*Ef(n))}const{drawDragPreview:kf,drawTooltip:Qf,getContextMenuItemsForFeature:Nf,onMouseDown:Rf,onMouseLeave:Df,onMouseMove:Ff,onMouseUp:Tf}=af,jf={draw:function(e,t,n,r,o){const{selectedFeature:i}=r;for(let i=0;i<Ef(t);i++)xf(e,t,n+i,n,r,o);i&&el(t,i)&&Bf(r,e,i)},drawDragPreview:kf,drawHover:function(e,t){const{hoveredFeature:n}=e;n&&Bf(e,t,n.feature)},drawTooltip:Qf,getContextMenuItemsForFeature:Nf,getContextMenuItems:function(e,t){const{hoveredFeature:n,session:r}=e,o=[];if(!n)return o;const{featureTypeOntology:i}=r.apolloDataStore.ontologyManager;if(!i)throw new Error("featureTypeOntology is undefined");const a=af.getContextMenuItems(e,t);if(o.push({label:n.feature.type,subMenu:a}),sl(t)){const{bp:r,feature:i}=t;for(const t of Jc(i,r)){if(t._id===n.feature._id)continue;const r=af.getContextMenuItemsForFeature(e,t);o.push({label:t.type,subMenu:r})}}return o},getFeatureFromLayout:function(e,t,n){return wf(e)[n].find((e=>t>=e.min&&t<=e.max))},getRowCount:Ef,getRowForFeature:function(e,t){const n=wf(e);for(const[e,r]of n.entries())if(r.some((e=>e._id===t._id)))return e},onMouseDown:Rf,onMouseLeave:Df,onMouseMove:Ff,onMouseUp:Tf},Mf=f.observer((function({featureTypes:e,handleClose:t,onUpdate:n,session:r}){const[o,a]=u.useState(""),[c,l]=u.useState(e);return i.jsx(Al,{open:!0,maxWidth:!1,"data-testid":"filter-features-dialog",title:"Filter features by type",handleClose:t,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the feature types you want to display in the apollo track"}),i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{size:8,children:i.jsx(Su,{session:r,ontologyName:"Sequence Ontology",style:{width:"100%"},value:o,filterTerms:wu,renderInput:e=>i.jsx(s.TextField,{...e,label:"Feature type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{t&&(e=>{a(e)})(t)}})}),i.jsx(s.Grid,{size:4,children:i.jsx(s.Button,{variant:"contained",onClick:()=>{if(o){if(c.includes(o))return;n([...c,o]),l([...c,o])}},disabled:!o,style:{marginTop:9},size:"medium",children:"Add"})})]}),c.length>0&&i.jsxs("div",{children:[i.jsx("hr",{}),i.jsxs("div",{style:{width:300},children:[i.jsx(s.DialogContentText,{children:"Selected feature types:"}),i.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:c.map((e=>i.jsx(s.Chip,{label:e,onDelete:()=>{(e=>{const t=c.filter((t=>t!==e));n(t),l(t)})(e)}},e)))})]})]})]})})})),Of=f.observer((function({model:e,handleClose:t}){const[n,r]=u.useState(`${e.zoomThresholdSetting}`);return i.jsx(A.Dialog,{open:!0,onClose:t,title:"Edit zoom threshold setting",children:i.jsxs(s.DialogContent,{children:[i.jsx(s.Typography,{children:"The zoom level in base pairs (bp) per pixel at which features are rendered in this Annotations track. Increasing the value will allow features to render when zooming out, but might impact performance."}),i.jsx(s.TextField,{label:"Threshold value (bpPerPx)",value:n,onChange:e=>{r(e.target.value)}}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:()=>{e.setZoomThresholdSetting({zoomThreshold:+n}),t()},children:"Submit"}),i.jsx(s.Button,{variant:"contained",color:"secondary",onClick:()=>{t()},children:"Cancel"})]})]})})})),Lf=Ec()((e=>({canvasContainer:{position:"relative",left:0},canvas:{position:"absolute",left:0},center:{display:"flex",justifyContent:"center"},ellipses:{textOverflow:"ellipsis",overflow:"hidden"},avatar:{position:"static",height:"100%",width:"100%",overflow:"visible",color:e.palette.warning.light,backgroundColor:e.palette.warning.contrastText},box:{position:"absolute",overflow:"visible"},badge:{display:"inline-block"},loading:{position:"absolute",right:e.spacing(3),zIndex:10,pointerEvents:"none",textAlign:"right"},locked:{position:"absolute",right:e.spacing(3),top:e.spacing(6),zIndex:1,pointerEvents:"none",textAlign:"right"}})));function Pf(e,t,n){const r=new Map;for(const t of e)(r.get(t.message)??r.set(t.message,[]).get(t.message)).push(t);const o=[];for(const[e,n]of r.entries()){if(0===n.length)continue;n.sort(((e,t)=>e.start-t.start));let r=[n[0]],i=n[0].start,a=n[0].start+t;const s=()=>{const t=r.map((e=>e.start)).sort(((e,t)=>e-t)),n=Math.floor(t.length/2),s=r[0].ids;o.push({_id:r[0]._id,message:e,start:t.length%2?t[n]:(t[n-1]+t[n])/2,count:r.length,members:[...r],range:{min:i,max:a},featureIds:s})};for(let e=1;e<n.length;e++){const o=n[e],c=o.start,l=c+t;c<=a?(r.push(o),c<i&&(i=c),l>a&&(a=l)):(s(),r=[o],i=c,a=l)}s()}return o.sort(((e,t)=>e.message.localeCompare(t.message)||e.start-t.start)),o}function qf(e,t,n){return"M"===e?t.palette.startCodon:"*"===e?n?t.palette.text.primary:t.palette.stopCodon:void 0}function Jf(e,t){const n=e.toUpperCase();return"A"===n||"C"===n||"G"===n||"T"===n?t.palette.bases[n].main.toString():"lightgray"}function Uf(e,t,n){const r=[];for(let o=e;o<e+t;o++){const e=n.get(o);e&&r.push(e)}return r}function Gf(e,t){for(const n of e)for(const[e,r]of n)if(o.doesIntersect2(t.min,t.max,e,r)||o.doesIntersect2(e,r,t.min,t.max))return!1;return!0}function Hf(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloDisplay").props({type:c.types.literal("LinearApolloDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showCheckResults:!0,zoomThreshold:200,heightPreConfig:c.types.maybe(c.types.refinement("displayHeight",c.types.number,(e=>e>=20))),filteredFeatureTypes:c.types.array(c.types.string),loadingState:!1}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...v.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?400:e.graphical?100:200},get loading(){return e.loadingState},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=c.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=c.cast(t)},setLoading(t){e.loadingState=t},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showCheckResults:a}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Check Results",type:"checkbox",checked:a,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[Of,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const n=e.session;e.session.queueDialog((r=>[Mf,{session:n,handleClose:()=>{r()},featureTypes:c.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:c}=s.apolloDataStore,[l,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(l,u,{feature:t,assembly:a,refName:i,changeManager:c});s.showWidget(d)},afterAttach(){c.addDisposer(e,l.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.setLoading(!0),e.session.apolloDataStore.loadFeatures(e.regions).then((()=>{setTimeout((()=>{e.setLoading(!1)}),1e3)})))}),{name:"LinearApolloDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloDisplayLayouts").props({cleanupBoundary:2e5}).volatile((()=>({seenFeatures:l.observable.map()}))).views((e=>({getAnnotationFeatureById:t=>e.seenFeatures.get(t),getGlyph(e){const{topLevelFeature:t}=e;return t.looksLikeGene?If:t.children?.size?jf:af}}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({get featureLayouts(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map((n=>{const r=t.get(n.assemblyName),i=new Map,a=new Map,{end:s,refName:l,start:u}=n;for(const[t,n]of e.seenFeatures.entries()){if(!c.isAlive(n)){e.deleteSeenFeature(t);continue}if(l!==r?.getCanonicalRefName(n.refSeq)||!o.doesIntersect2(u,s,n.min,n.max)||e.filteredFeatureTypes.length>0&&!e.filteredFeatureTypes.includes(n.type))continue;const{featureTypeOntology:d}=e.session.apolloDataStore.ontologyManager;if(!d)throw new Error("featureTypeOntology is undefined");const A=e.getGlyph(n).getRowCount(n,d,e.lgv.bpPerPx);let f=0,h=!1;for(;!h;){let e=Uf(f,A,a);if(e.length<A){for(let t=0;t<A-e.length;t++){const e=a.size;a.set(e,[]),i.set(e,[])}e=Uf(f,A,a)}if(Gf(e,n)){for(let e=f;e<f+A;e++){a.get(e)?.push([n.min,n.max]);const t=i.get(e);t?.push([e-f,n._id])}h=!0}else f+=1}}return i}))},getFeatureLayoutPosition(t){const{featureLayouts:n}=this,{featureTypeOntology:r}=e.session.apolloDataStore.ontologyManager;for(const[o,i]of n.entries())for(const[n,a]of i)for(const[i,s]of a){if(0!==i)continue;const a=e.getAnnotationFeatureById(s);if(a){if(t._id===a._id)return{layoutIndex:o,layoutRow:n,featureRow:i};if(a.hasDescendant(t._id)){if(!r)throw new Error("featureTypeOntology is undefined");const i=e.getGlyph(a).getRowForFeature(a,t,r);if(void 0!==i)return{layoutIndex:o,layoutRow:n,featureRow:i}}}}}}))).views((e=>({get highestRow(){return Math.max(0,...e.featureLayouts.map((e=>Math.max(...e.keys()))))}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered()){for(const[t,n]of e.seenFeatures.entries()){let r=!1;for(const t of e.regions)if(o.doesIntersect2(t.start-e.cleanupBoundary,t.end+e.cleanupBoundary,n.min,n.max)){r=!0;break}r||e.deleteSeenFeature(t)}for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}}),{name:"LinearApolloDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,lastRowTooltipBufferHeight:40,isShown:!0,filteredTranscripts:c.types.array(c.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({get featuresHeight(){return(e.highestRow+1)*e.apolloRowHeight+e.lastRowTooltipBufferHeight}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:c}=a,l=e.lgv.bpToPx({refName:s,coord:c,regionNumber:o});if(!l)continue;const u=l.offsetPx-e.lgv.offsetPx,d=(r-c)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloDisplayRenderCollaborators"})),c.addDisposer(e,l.autorun((()=>{const{canvas:t,featureLayouts:n,featuresHeight:r,lgv:i}=e;if(!i.initialized||e.regionCannotBeRendered())return;const{displayedRegions:a,dynamicBlocks:s}=i,c=t?.getContext("2d");if(c){c.clearRect(0,0,s.totalWidthPx,r);for(const[t,r]of n.entries()){const n=a[t];for(const[i,a]of r.entries())for(const[r,s]of a){const a=e.getAnnotationFeatureById(s);r>0||!a||o.doesIntersect2(n.start,n.end,a.min,a.max)&&e.getGlyph(a).draw(c,a,i,e,t)}}}}),{name:"LinearApolloDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition(t){const n=cl(t,e.lgv),{bp:r,regionNumber:o,y:i}=n,a=Math.floor(i/e.apolloRowHeight),s=e.featureLayouts[o].get(a);if(!s)return n;const c=s.find((t=>{const n=e.getAnnotationFeatureById(t[1]);return n&&r>=n.min&&r<=n.max}));if(!c)return n;const[l,u]=c,d=e.getAnnotationFeatureById(u);if(!d)return n;const A=e.getGlyph(d),{featureTypeOntology:f}=e.session.apolloDataStore.ontologyManager;if(!f)throw new Error("featureTypeOntology is undefined");const h=A.getFeatureFromLayout(d,r,l,f);return h?{...n,feature:h}:n}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(e){}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const{hoveredFeature:n}=e;if(!n)return[];const r=e.getMousePosition(t),{topLevelFeature:o}=n.feature,i=e.getGlyph(o);return sl(r)?i.getContextMenuItems(e,r):[]}}))).actions((e=>({startDrag(t,n,r,o=!1){e.apolloDragging={start:t,current:t,feature:n,edge:r,shrinkParent:o}},endDrag(){if(!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:t,edge:n,feature:r,start:o,shrinkParent:i}=e.apolloDragging;if(Math.abs(t.x-o.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:a}=e.lgv,s=e.getAssemblyId(a[o.regionNumber].assemblyName),c=al(r,t.bp,n,i),l="max"===n?new qr({typeName:"LocationEndChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:s}):new Ur({typeName:"LocationStartChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:s});e.changeManager.submit(l),e.setDragging(),e.setCursor()}}))).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t);sl(n)&&e.getGlyph(n.feature).onMouseDown(e,n,t)},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);sl(n)?e.getGlyph(n.feature).onMouseMove(e,n,t):(e.setHoveredFeature(),e.setCursor())},onMouseLeave(t){e.setDragging(),e.setHoveredFeature();const n=e.getMousePosition(t);sl(n)&&e.getGlyph(n.feature).onMouseLeave(e,n,t)},onMouseUp(t){const n=e.getMousePosition(t);sl(n)?e.getGlyph(n.feature).onMouseUp(e,n,t):e.setSelectedFeature(),e.apolloDragging&&e.endDrag()}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.overlayCanvas?.getContext("2d");if(!t)return;t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);const{apolloDragging:n,hoveredFeature:r}=e;if(!r)return;const o=e.getGlyph(r.feature);o.drawHover(e,t),o.drawTooltip(e,t),n&&e.getGlyph(n.feature.topLevelFeature).drawDragPreview(e,t)}),{name:"LinearApolloDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:c.types.optional(tf,{})}).named("LinearApolloDisplay")}const Yf=n.ConfigurationSchema("LinearApolloReferenceSequenceDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0});function zf(e,t,n){const r=t<=1?[2,1,0,7,6,5]:[2,1,0,5,4,3];n&&r.reverse(),r.unshift(0);const o=r.at(e);if(void 0===o)throw new Error("could not find row");return o}function Kf(e,t,n,r){return r.offsetPx-n+(r.reversed?r.end-e.max:e.min-r.start)/t}function Wf(e,t,n,r,o,i,a=!1){e.fillStyle=a?i.palette.action.disabled:i.palette.action.focus,e.fillRect(t,n,r,o),e.strokeStyle=a?i.palette.text.secondary:i.palette.text.primary,e.strokeStyle=i.palette.text.primary,e.strokeRect(t,n,r,o)}function Vf(e,t,n,r,o,i,a,s=!1){const c=function(e,t,n){if(!(t>1||void 0===e))return n?1===e?4:3:1===e?3:4}(t.strand,n,i.reversed);c&&Wf(e,Kf(t,n,r,i),c*o,t.length/n,o,a,s)}function $f(e,t,n,r,i,a,s,c=!1){const l=t.parent;if(!l)return;const u=l.cdsLocations.find((e=>{const n=e.at(1===t.strand?0:-1)?.min,r=e.at(1===t.strand?-1:0)?.max;return t.min===n&&t.max===r}));if(u)for(const l of u){const u=zf(o.getFrame(l.min,l.max,t.strand??1,l.phase),n,a.reversed);Wf(e,Kf(l,n,r,a),u*i,(l.max-l.min)/n,i,s,c)}}function Xf(e,t,n,r,o,i){e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t+.5,n+.5,r-1,o-1)}function Zf(e,t,n,r,o){const i=Math.min(r,10);e.fillStyle="#000",e.font=`${i}px`;const a=e.measureText(o).width,s=Math.round(t+(r-a)/2);e.fillText(o,s,n+10)}function eh(e,t,n,r,o,i,a,s){const c=t<=1?[3,2,1,0,0,-1,-2,-3]:[3,2,1,-1,-2,-3];s&&c.reverse();for(const[t,s]of c.entries()){const c=n.palette.framesCDS.at(s)?.main;if(!c)continue;const l=t*a;e.fillStyle=r?n.palette.background.default:c,e.fillRect(o,l,i,a),r&&Xf(e,o,l,i,a,n.palette.grey[200])}}function th(e,t,n,r,i,a,s){if(1/i<1)return;const c=Math.round(r+n/i),l=Math.round(r+(n+1)/i)-c,u=[-1,1];for(const n of u){const r=(1===n?3:4)*a,u=1===n?t:o.revcom(t);e.fillStyle=Jf(u,s),e.fillRect(c,r,l,a),1/i>=12&&(Xf(e,c,r,l,a,s.palette.text.disabled),Zf(e,c,r,l,u))}}function nh(e,t,n,r,i,a,s,c,l,u,d){const A=(s<=1?[0,2,1,0,7,6,5]:[0,2,1,0,5,4,3]).map((e=>e*l)),f=[-1,1];for(const h of f){const f=o.getFrame(c,c+3,h,0),g=A.at(f);if(void 0===g)continue;const p=Math.round(n+r/s),m=Math.round(n+(r+3)/s)-p,y=1===h?t:o.revcom(t),_=o.defaultCodonTable[y],v=qf(_,i,a);v&&(d&&"*"==_||u&&"*"!=_)&&(e.fillStyle=v,e.fillRect(p,g,m,l)),1/s>=4&&(Xf(e,p,g,m,l,i.palette.text.disabled),Zf(e,p,g,m,_))}}function rh(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloReferenceSequenceDisplay").props({type:c.types.literal("LinearApolloReferenceSequenceDisplay"),configuration:n.ConfigurationReference(t),showStartCodons:!1,showStopCodons:!0,highContrast:!1,heightPreConfig:c.types.maybe(c.types.refinement("displayHeight",c.types.number,(e=>e>=20))),sequenceRowHeight:15}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...v.getParentRenderProps(e),config:t.renderer})}})).views((e=>({get lgv(){return o.getContainingView(e)}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=3)return"Zoom in to see sequence"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=c.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature},get height(){const{sequenceRowHeight:t}=e;return e.lgv.bpPerPx<=1?8*t:6*t}}))).volatile((()=>({scrollTop:0}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleHighContrast(){e.highContrast=!e.highContrast}}))).views((e=>{const{trackMenuItems:t}=e;return{trackMenuItems(){const{showStartCodons:n,showStopCodons:r,highContrast:o}=e;return[...t(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show start codons",type:"checkbox",checked:n,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:r,onClick:()=>{e.toggleShowStopCodons()}},{label:"Use high contrast colors",type:"checkbox",checked:o,onClick:()=>{e.toggleHighContrast()}}]}]}}})).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&e.lgv.bpPerPx<=3&&e.session.apolloDataStore.loadRefSeq(e.regions)}),{name:"LinearApolloReferenceSequenceDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloReferenceSequenceDisplayRendering").volatile((()=>({seqTrackCanvas:null,seqTrackOverlayCanvas:null,theme:s.createTheme()}))).actions((e=>({setSeqTrackCanvas(t){e.seqTrackCanvas=t},setSeqTrackOverlayCanvas(t){e.seqTrackOverlayCanvas=t},setTheme(t){e.theme=t},afterAttach(){c.addDisposer(e,l.autorun((()=>{const{lgv:t,seqTrackCanvas:n,theme:r,highContrast:i,showStartCodons:a,showStopCodons:s,sequenceRowHeight:c,session:l}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;if(3/t.bpPerPx<1)return;const{bpPerPx:u,offsetPx:d,dynamicBlocks:A}=t;!function(e,t,n,r,i,a,s,c,l,u){const d=e.getContext("2d");if(!d)return;d.clearRect(0,0,e.width,e.height);const{apolloDataStore:A}=u;for(const e of i.contentBlocks){const i=e.offsetPx-r;eh(d,n,t,a,i,e.widthPx,l,e.reversed);const u=A.assemblies.get(e.assemblyName),f=u?.getByRefName(e.refName),h=Math.floor(e.start),g=Math.ceil(e.end);let p=f?.getSequence(h,g);if(!p)return;p=p.toUpperCase(),e.reversed&&(p=o.revcom(p));const m=i-(e.reversed?g-e.end:e.start-h)/n;for(let r=0;r<p.length;r++){const o=e.reversed?g-r:h+r,i=p.slice(r,r+3);th(d,p[r],r,m,n,l,t),3===i.length&&nh(d,i,m,r,t,a,n,o,l,s,c)}}}(n,r,u,d,A,i,a,s,c,l)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequence"})),c.addDisposer(e,l.autorun((()=>{const{seqTrackOverlayCanvas:t}=e;if(!e.lgv.initialized||e.regionCannotBeRendered()||!t)return;const n=t.getContext("2d");if(!n)return;n.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.height);const{hoveredFeature:r,selectedFeature:o,lgv:i,sequenceRowHeight:a,session:s,theme:c}=e;if(!r&&!o)return;const{bpPerPx:l,dynamicBlocks:u,offsetPx:d}=i;!function(e,t,n,r,o,i,a,s,c,l){const{featureTypeOntology:u}=a.apolloDataStore.ontologyManager;if(!u)throw new Error("featureTypeOntology is undefined");for(const a of l.contentBlocks){t.save(),t.beginPath(),t.rect(a.offsetPx-c,0,a.widthPx,e.height),t.clip();for(const e of[r,n?.feature].filter((e=>void 0!==e)))u.isTypeOf(e.type,"CDS")?$f(t,e,s,c,o,a,i,e._id===r?._id):Vf(t,e,s,c,o,a,i,e._id===r?._id);t.restore()}}(t,n,r,o,a,c,s,l,d,u)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequenceHighlight"}))}})))}(0,t).named("LinearApolloReferenceSequenceDisplay")}const oh=f.observer((function(e){const t=s.useTheme(),{model:n}=e,{height:r,regionCannotBeRendered:a,setSeqTrackCanvas:c,setSeqTrackOverlayCanvas:l,setTheme:d}=n,{classes:A}=Lf();u.useEffect((()=>{d(t)}),[t,d]);const f=o.getContainingView(n),h=a();return h?i.jsx(s.Alert,{severity:"warning",classes:{message:A.ellipses},slotProps:{root:{className:A.center}},children:i.jsx(s.Tooltip,{title:h,children:i.jsx("div",{children:h})})}):i.jsx(i.Fragment,{children:3/f.bpPerPx>=1?i.jsxs("div",{className:A.canvasContainer,style:{width:f.dynamicBlocks.totalWidthPx,height:r},children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),c(e)},width:f.dynamicBlocks.totalWidthPx,height:r,className:A.canvas,"data-testid":"seqTrackCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),l(e)},width:f.dynamicBlocks.totalWidthPx,height:r,className:A.canvas,"data-testid":"seqTrackOverlayCanvas"})]}):null})})),ih=n.ConfigurationSchema("LinearApolloSixFrameDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),ah=f.observer((function({sourceFeature:e,filteredTranscripts:t,handleClose:n,onUpdate:r}){const o=[];if(e.children)for(const[,t]of e.children){const e=t.attributes.get("gff_id")?.toString();e&&o.push(e)}const[a,c]=u.useState(t);return i.jsx(Al,{open:!0,maxWidth:!1,"data-testid":"filter-transcripts-dialog",title:"Filter transcripts by ID",handleClose:n,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the alternate transcripts you want to display in the apollo track"}),i.jsx(s.Grid,{container:!0,spacing:2,children:i.jsx(s.Grid,{size:8,children:i.jsx(s.FormGroup,{children:o.map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:!a.includes(e),onChange:()=>{(e=>{const t=a.includes(e)?a.filter((t=>t!==e)):[...a,e];r(t),c(t)})(e)},slotProps:{input:{"aria-label":"controlled"}}}),label:e})))})})})]})})}));let sh=null,ch=null,lh=null,uh=null;const dh=globalThis.document.createElement("canvas");if(dh?.getContext)for(const e of["forward","backward"])for(const t of["light","dark"]){const n=document.createElement("canvas"),r=10;n.width=n.height=r;const o=n.getContext("2d");if(o){const i="light"===t?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",a="light"===t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",s="forward"===e?o.createLinearGradient(0,r,r,0):o.createLinearGradient(0,0,r,r);s.addColorStop(0,i),s.addColorStop(.25,i),s.addColorStop(.25,a),s.addColorStop(.5,a),s.addColorStop(.5,i),s.addColorStop(.75,i),s.addColorStop(.75,a),s.addColorStop(1,a),o.fillStyle=s,o.fillRect(0,0,10,10),"forward"===e?"light"===t?sh=o.createPattern(n,"repeat"):lh=o.createPattern(n,"repeat"):"light"===t?ch=o.createPattern(n,"repeat"):uh=o.createPattern(n,"repeat")}}function Ah(e,t){for(const n of e)if(fu(n,t))return!0;return!1}function fh(e,t,n){const{filteredTranscripts:r,session:i}=n,{apolloDataStore:a}=i,{featureTypeOntology:s}=a.ontologyManager;if(!s)throw new Error("featureTypeOntology is undefined");const c=s.isTypeOf(t.type,"transcript"),l=t.attributes.get("gff_id")?.toString();if(l&&r.includes(l))return;const{bp:u,refName:d,regionNumber:A,x:f}=e,{lgv:h}=n;if(c){const e=t;if(!e.children)return;const n=[],r=[];for(const t of e.children.values()){const e=s.isTypeOf(t.type,"exon"),o=s.isTypeOf(t.type,"CDS");e?n.push(t):o&&r.push(t)}const i=n.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(i){const e=$c(i,d,A,h);if(e){const t=Xc(i,f,e);if(t)return t}}for(const t of e.cdsLocations)for(const e of t){const t=$c(e,d,A,h);if(t){const e=r.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(e){const n=Xc(e,f,t);if(n)return n}}}}}const hh={draw:function(e,t,n,r,i){const{apolloRowHeight:a,lgv:c,session:l,theme:u,highestRow:d,filteredTranscripts:A,selectedFeature:f,showFeatureLabels:h}=r,{bpPerPx:g,displayedRegions:p,offsetPx:m}=c,y=p[i],{refName:_,reversed:v}=y,b=a,C=b,I=b,w=b,E=h?2:1,x=u.palette.text.primary,{attributes:S,children:B,min:k,strand:Q}=t;if(!B)return;const{apolloDataStore:N}=l,{featureTypeOntology:R}=N.ontologyManager;if(!R)throw new Error("featureTypeOntology is undefined");const D=[],F=(c.bpToPx({refName:_,coord:k,regionNumber:i})?.offsetPx??0)-m,T=t.length/g,j=v?F-T:F,M=(1==Q?3:4)*E*b;e.fillStyle=u.palette.text.primary,e.fillRect(j,M,T,w),e.fillStyle=Zc(t,f)?s.alpha("rgb(0,0,0)",.7):s.alpha(u.palette.background.paper,.7),e.fillRect(j+1,M+1,T-2,w-2);const O=Zc(t,f),L={x:j,y:M,h:w,text:S.get("gff_id")?.toString(),color:x,isSelected:O};O?D.unshift(L):D.push(L);const P="dark"===u.palette.mode?lh:sh,q="dark"===u.palette.mode?uh:ch,J=v?-1:1;let U=null,G=null;Q&&([U,G]=Q*J==1?[P,q]:[q,P]),U&&G&&(e.fillStyle=U,e.fillRect(j+1,M+1,T-2,(w-2)/2),e.fillStyle=G,e.fillRect(j+1,M+(w-2)/2,T-2,(w-2)/2));const H=new Set;for(const[,t]of B){if(!R.isTypeOf(t.type,"transcript")&&!R.isTypeOf(t.type,"pseudogenic_transcript"))continue;const{children:n,cdsLocations:r}=t;if(!n)continue;const a=t.attributes.get("gff_id")?.toString();if(a&&A.includes(a))continue;for(const[,t]of n){if(!R.isTypeOf(t.type,"exon"))continue;const n=(c.bpToPx({refName:_,coord:t.min,regionNumber:i})?.offsetPx??0)-m,r=t.length/g,o=v?n-r:n,a=M+(w-C)/2,l=Zc(t,f);if(e.fillStyle=u.palette.text.primary,e.fillRect(o,a,r,C),r>2){e.clearRect(o+1,a+1,r-2,C-2),e.fillStyle=l?"rgb(0,0,0)":s.alpha("#f5f500",.6),e.fillRect(o+1,a+1,r-2,C-2),U&&G&&(e.fillStyle=U,e.fillRect(o+1,a+1,r-2,(C-2)/2),e.fillStyle=G,e.fillRect(o+1,a+1+(C-2)/2,r-2,(C-2)/2));const n={x:o,y:a,h:C,text:t.attributes.get("gff_id")?.toString(),color:x,isSelected:l};l?D.unshift(n):D.push(n)}}const l=Zc(t,f?.parent);let p=0,y=0;for(const n of r){let r=0,a=0,s=1;for(const A of n.sort(((e,t)=>e.max-t.max)))if(f&&l&&R.isTypeOf(f.type,"CDS")||!Ah(H,A)){const n=(A.max-A.min)/g,C=(c.bpToPx({refName:_,coord:A.min,regionNumber:i})?.offsetPx??0)-m;p=v?C-n:C,e.fillStyle=u.palette.text.primary;const w=o.getFrame(A.min,A.max,t.strand??1,A.phase),x=(h?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(w);if(void 0===x)continue;if(y=x*b,e.fillRect(p,y,n,I),s>1){const t=[(p-a)/2+a,Math.max(w<0?b*E*d+1:1,Math.min(r,y)-b/2)];e.strokeStyle="rgb(0, 128, 128)",e.beginPath(),e.moveTo(a,r),e.lineTo(...t),e.stroke(),e.moveTo(...t),e.lineTo(p,y+b/2),e.stroke()}if(a=p+n,r=y+b/2,s+=1,n>2){e.clearRect(p+1,y+1,n-2,I-2);const t=u.palette.framesCDS.at(w)?.main,r=t??"rgb(171,71,188)";e.fillStyle=r,e.fillStyle=f&&l&&R.isTypeOf(f.type,"CDS")?"rgb(0,0,0)":r,e.fillRect(p+1,y+1,n-2,I-2),U&&G&&(e.fillStyle=U,e.fillRect(p+1,y+1,n-2,(I-2)/2),e.fillStyle=G,e.fillRect(p+1,y+(I-2)/2,n-2,(I-2)/2))}H.add(A)}}const S={x:p,y:y,h:I,text:t.attributes.get("gff_id")?.toString(),color:x,isSelected:l};l?D.unshift(S):D.push(S)}h&&function(e,t,n="10px sans-serif"){for(let r=t.length-1;r>=0;--r){const i=t[r];e.fillStyle=i.color;const a=i.x+1,s=i.y+i.h,c=o.measureText(i.text,10);i.isSelected&&(e.font="bold ".concat(n)),i.text&&(e.clearRect(a-5,s,c+10,i.h),e.fillText(i.text,a,s+11,c),e.font=n)}}(e,D)},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:c,offsetPx:l}=o;if(!n)return;const{current:u,edge:d,feature:A,start:f}=n,h=Math.floor(f.y/r),g=c[f.regionNumber],p=(g.reversed?g.end-A[d]:A[d]-g.start)/a-l,m=Math.min(u.x,p),y=h*r,_=Math.abs(u.x-p),v=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(m,y,_,v),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(m,y,_,v)},drawHover:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,highestRow:s,session:c,showFeatureLabels:l}=e;if(!n)return;const{feature:u}=n,{apolloDataStore:d}=c,{featureTypeOntology:A}=d.ontologyManager;if(!A)throw new Error("featureTypeOntology is undefined");if(!A.isTypeOf(u.type,"transcript"))return;const f=u.attributes.get("gff_id")?.toString();if(f&&i.includes(f))return;const h=e.getFeatureLayoutPosition(u);if(!h)return;const{bpPerPx:g,displayedRegions:p,offsetPx:m}=a,{layoutIndex:y}=h,_=p[y],{refName:v,reversed:b}=_,C=r,I=C,w=l?2:1,{cdsLocations:E,strand:x}=u;for(const e of E){let n=0,r=0,i=1;for(const c of e.sort(((e,t)=>e.max-t.max))){const e=(c.max-c.min)/g,u=(a.bpToPx({refName:v,coord:c.min,regionNumber:y})?.offsetPx??0)-m,d=b?u-e:u,A=o.getFrame(c.min,c.max,x??1,c.phase),f=(l?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(A);if(void 0===f)continue;const h=f*C;if(i>1){const e=[(d-r)/2+r,Math.max(A<0?C*w*s+1:1,Math.min(n,h)-C/2)];t.strokeStyle="rgb(0, 0, 0)",t.lineWidth=2,t.beginPath(),t.moveTo(r,n),t.lineTo(...e),t.stroke(),t.moveTo(...e),t.lineTo(d,h+C/2),t.stroke()}r=d+e,n=h+C/2,i+=1,e>2&&(t.fillStyle="rgba(255,0,0,0.6)",t.fillRect(d,h,e,I))}}},drawTooltip:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,session:c,showFeatureLabels:l,theme:u}=e;if(!n)return;const{feature:d,bp:A}=n,{featureTypeOntology:f}=c.apolloDataStore.ontologyManager;if(!f)throw new Error("featureTypeOntology is undefined");if(!f.isTypeOf(d.type,"transcript"))return;const{attributes:h,strand:g,type:p}=d,m=e.getFeatureLayoutPosition(d);if(!m)return;const y=h.get("gff_id")?.toString();if(y&&i.includes(y))return;const{layoutIndex:_}=m,{bpPerPx:v,displayedRegions:b,offsetPx:C}=a,I=b[_],{refName:w,reversed:E}=I,x=r;let S,B="Loc: ";for(const e of d.cdsLocations)for(const t of e)if(A>=t.min&&A<=t.max){S=t;break}if(!S)return;const{max:k,min:Q,phase:N}=S;B+=`${Q+1}–${k}`;let R=(a.bpToPx({refName:w,coord:E?k:Q,regionNumber:_})?.offsetPx??0)-C;const D=o.getFrame(Q,k,g??1,N),F=(l?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(D);if(void 0===F)return;const T=F*x,j=(k-Q)/v,M=`Type: ${S.type}`,O=h.get("gff_name")?.find((e=>""!==e)),L=[t.measureText(M).width,t.measureText(B).width];O&&L.push(t.measureText(`Parent Type: ${p}`).width,t.measureText(`Parent Name: ${O}`).width);const P=Math.max(...L);R=R+j+5,t.fillStyle=s.alpha(u.palette.text.primary,.7),t.fillRect(R,T,P+4,4===L.length?55:35),t.beginPath(),t.moveTo(R,T),t.lineTo(R-5,T+5),t.lineTo(R,T+10),t.fill(),t.fillStyle=u.palette.background.default;let q=T+12;t.fillText(M,R+2,q),O&&(q+=12,t.fillText(`Parent Type: ${p}`,R+2,q),q+=12,t.fillText(`Parent Name: ${O}`,R+2,q)),q+=12,t.fillText(B,R+2,q)},getContextMenuItems:function(e,t){const{apolloInternetAccount:n,hoveredFeature:r,changeManager:i,filteredTranscripts:a,regions:s,selectedFeature:l,session:u}=e,[d]=s,A=e.getAssemblyId(d.assemblyName),f=[],h="admin"===(n?n.role:"admin");if(!r)return f;const{featureTypeOntology:g}=u.apolloDataStore.ontologyManager;if(!g)throw new Error("featureTypeOntology is undefined");if(sl(t)){const{bp:n,feature:r}=t;let s=Jc(r,n);Kc(r,u)&&(s=Jc(r,n,!0));for(const n of s){const r=n.attributes.get("gff_id")?.toString();if(r&&a.includes(r))continue;const s=nl(e,n);if(zc(n,u)){const r=Wc(n,e,t,u),a=o.getContainingView(e);if(r.upstream){const t=r.upstream;s.push({label:"Go to upstream exon",icon:Vc(n.strand,!0,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(rl(t,.1,a.totalBp)),Hc(e,t)}})}if(r.downstream){const t=r.downstream;s.push({label:"Go to downstream exon",icon:Vc(n.strand,!1,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(rl(t,.1,a.totalBp)),Hc(e,t)}})}s.push({label:"Merge exons",disabled:!h,onClick:()=>{u.queueDialog((t=>[Vu,{session:u,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:A,selectedFeature:l,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:!h,onClick:()=>{u.queueDialog((t=>[ld,{session:u,handleClose:()=>{t()},changeManager:i,sourceFeature:n,sourceAssemblyId:A,selectedFeature:l,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}})}g.isTypeOf(n.type,"gene")&&s.push({label:"Filter alternate transcripts",onClick:()=>{u.queueDialog((t=>[ah,{handleClose:()=>{t()},sourceFeature:n,filteredTranscripts:c.getSnapshot(a),onUpdate:t=>{e.updateFilteredTranscripts(t)}}]))}}),f.push({label:n.type,subMenu:s})}}return f},getContextMenuItemsForFeature:nl,onMouseDown:function(e,t,n){const{feature:r}=t,o=fh(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,o.feature,o.edge,!0))},onMouseLeave:function(){},onMouseMove:function(e,t){if(sl(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),fh(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(!e.apolloDragging&&sl(t)){const{feature:n}=t,{session:r}=e,{apolloDataStore:o}=r,{featureTypeOntology:i}=o.ontologyManager;if(e.setSelectedFeature(n),!i)throw new Error("featureTypeOntology is undefined");let a=!1;for(const[,e]of n.children??[])if(i.isTypeOf(e.type,"CDS")||i.isTypeOf(e.type,"exon")){a=!0;break}(i.isTypeOf(n.type,"transcript")||i.isTypeOf(n.type,"pseudogenic_transcript"))&&a?e.showFeatureDetailsWidget(n,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(n)}}};function gh(e,t,n,r,i,a,s,c,l,u,d,A){const f=(u?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).map((e=>e*l)),h=[-1,1];for(const u of h){const h=o.getFrame(c,c+3,u,0),g=f.at(h);if(void 0===g)continue;const p=Math.round(n+r/s),m=0===Math.round(3/s)?1:Math.round(3/s),y=1===u?t:o.revcom(t),_=o.defaultCodonTable[y],v=qf(_,i,a);v&&(A&&"*"==_||d&&"*"!=_)&&(e.fillStyle=v,e.fillRect(p,g,m,l))}}function ph(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloSixFrameDisplay").props({type:c.types.literal("LinearApolloSixFrameDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showFeatureLabels:!0,showStartCodons:!1,showStopCodons:!0,showCheckResults:!0,zoomThreshold:200,heightPreConfig:c.types.maybe(c.types.refinement("displayHeight",c.types.number,(e=>e>=20))),filteredFeatureTypes:c.types.array(c.types.string)}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...v.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?500:e.graphical?e.showFeatureLabels?400:200:300},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=c.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowFeatureLabels(){e.showFeatureLabels=!e.showFeatureLabels},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=c.cast(t)},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showFeatureLabels:a,showStartCodons:s,showStopCodons:l,showCheckResults:u}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Feature Labels",type:"checkbox",checked:a,onClick:()=>{e.toggleShowFeatureLabels()}},{label:"Show start codons",type:"checkbox",checked:s,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:l,onClick:()=>{e.toggleShowStopCodons()}},{label:"Check Results",type:"checkbox",checked:u,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[Of,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const n=e.session;e.session.queueDialog((r=>[Mf,{session:n,handleClose:()=>{r()},featureTypes:c.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:c}=s.apolloDataStore,[l,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(l,u,{feature:t,assembly:a,refName:i,changeManager:c});s.showWidget(d)},afterAttach(){c.addDisposer(e,l.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.session.apolloDataStore.loadFeatures(e.regions),e.lgv.bpPerPx<=e.zoomThreshold&&e.session.apolloDataStore.loadRefSeq(e.regions))}),{name:"LinearApolloSixFrameDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayLayouts").props({featuresMinMaxLimit:5e5}).volatile((()=>({seenFeatures:l.observable.map()}))).views((e=>({get featuresMinMax(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map((n=>{const r=t.get(n.assemblyName);let i,a;const{end:s,refName:c,start:l}=n;for(const[,t]of e.seenFeatures)c!==r?.getCanonicalRefName(t.refSeq)||!o.doesIntersect2(l,s,t.min,t.max)||t.length>e.featuresMinMaxLimit||(void 0===i&&({min:i}=t),void 0===a&&({max:a}=t),t.minWithChildren<i&&({min:i}=t),t.maxWithChildren>a&&({max:a}=t));if(void 0!==i&&void 0!==a)return[i,a]}))},getGlyph:e=>hh,featureLabelSpacer:t=>e.showFeatureLabels?2*t-1:t}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({get geneTrackRowNums(){return[4,5].map((t=>e.featureLabelSpacer(t)))}}))).views((e=>({get featureLayouts(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map(((n,r)=>{const i=t.get(n.assemblyName),a=new Map;if(!e.featuresMinMax[r])return a;const{end:s,refName:l,start:u}=n;for(const[t,n]of e.seenFeatures.entries()){if(!c.isAlive(n)){e.deleteSeenFeature(t);continue}if(l!==i?.getCanonicalRefName(n.refSeq)||!o.doesIntersect2(u,s,n.min,n.max))continue;const{featureTypeOntology:r}=e.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");if(n.looksLikeGene){const t=1==n.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1];a.get(t)||a.set(t,[]);const i=a.get(t);i?.push({rowNum:t,feature:n});const{children:s}=n;if(!s)continue;for(const[,t]of s)if(r.isTypeOf(t.type,"transcript")){const{cdsLocations:n,strand:i,children:s}=t;if(s)for(const[,t]of s){if(!r.isTypeOf(t.type,"exon"))continue;const n=1==t.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1],o=a.get(n);o?.push({rowNum:n,feature:t})}for(const r of n)for(const n of r){const r=o.getFrame(n.min,n.max,i??1,n.phase),s=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(r);if(!s)continue;a.get(s)||a.set(s,[]);const c=a.get(s);c?.push({rowNum:s,feature:t})}}}}return a}))},getFeatureLayoutPosition(e){const{featureLayouts:t}=this;for(const[n,r]of t.entries())for(const[,t]of r)for(const{feature:r}of t)if(e._id===r._id)return{layoutIndex:n,layoutRow:0,featureRow:0}}}))).views((e=>({get highestRow(){return 5}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered())for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}),{name:"LinearApolloSixFrameDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloSixFrameDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,lastRowTooltipBufferHeight:120,isShown:!0,filteredTranscripts:c.types.array(c.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({get featuresHeight(){return(e.highestRow+1)*e.apolloRowHeight*(e.showFeatureLabels?2:1)+e.lastRowTooltipBufferHeight}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:c}=a,l=e.lgv.bpToPx({refName:s,coord:c,regionNumber:o});if(!l)continue;const u=l.offsetPx-e.lgv.offsetPx,d=(r-c)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloSixFrameDisplayRenderCollaborators"})),c.addDisposer(e,l.autorun((()=>{const{apolloRowHeight:t,canvas:n,featureLayouts:r,featuresHeight:i,lgv:a,session:s,theme:c,showFeatureLabels:l,showStartCodons:u,showStopCodons:d}=e;if(!a.initialized||e.regionCannotBeRendered())return;const{bpPerPx:A,offsetPx:f,displayedRegions:h,dynamicBlocks:g}=a,p=n?.getContext("2d");if(p){p.clearRect(0,0,g.totalWidthPx,i);for(const[t,n]of r.entries()){const r=h[t];for(const[i,a]of n.entries())for(const{feature:n}of a){if(!n.looksLikeGene)continue;if(!o.doesIntersect2(r.start,r.end,n.min,n.max))continue;const{topLevelFeature:a}=n,s=e.getGlyph(a);void 0!==s&&s.draw(p,a,i,e,t)}}if(u||d){const{apolloDataStore:e}=s;for(const n of g.contentBlocks){const r=e.assemblies.get(n.assemblyName),o=r?.getByRefName(n.refName),i=Math.floor(n.start),a=Math.ceil(n.end);let s=o?.getSequence(i,a);if(!s)break;s=s.toUpperCase();const h=Math.round(n.offsetPx-f-(n.start-i)/A);for(let e=0;e<s.length;e++){const n=i+e;gh(p,s.slice(e,e+3),h,e,c,!0,A,n,t,l,u,d)}}}}}),{name:"LinearApolloSixFrameDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition(t){const n=cl(t,e.lgv),{bp:r,regionNumber:i,y:a}=n,s=Math.floor(a/e.apolloRowHeight)+1,c=e.featureLayouts[i].get(s);if(!c)return n;const{featureTypeOntology:l}=e.session.apolloDataStore.ontologyManager;if(!l)throw new Error("featureTypeOntology is undefined");let u;if(e.geneTrackRowNums.includes(s)?(u=c.find((e=>"exon"==e.feature.type&&r>=e.feature.min&&r<=e.feature.max)),u||(u=c.find((e=>r>=e.feature.min&&r<=e.feature.max)))):u=c.find((t=>{const{feature:n}=t,i=n.attributes.get("gff_id")?.toString();if(!l.isTypeOf(n.type,"transcript"))return!1;for(const t of n.cdsLocations)for(const a of t){const t=o.getFrame(a.min,a.max,n.strand??1,a.phase),c=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(t);if(s===c&&r>=a.min&&r<=a.max)return void 0===i||!e.filteredTranscripts.includes(i)}return!1})),!u)return n;const{feature:d}=u;return{...n,feature:d}}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(t){e.filteredTranscripts=c.cast(t)}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const{hoveredFeature:n}=e;if(!n)return[];const r=e.getMousePosition(t),{topLevelFeature:o}=n.feature,i=e.getGlyph(o);return sl(r)?i.getContextMenuItems(e,r):[]}}))).actions((e=>({startDrag(t,n,r,o=!1){e.apolloDragging={start:t,current:t,feature:n,edge:r,shrinkParent:o}},endDrag(){if(!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:t,edge:n,feature:r,start:o,shrinkParent:i}=e.apolloDragging;if(Math.abs(t.x-o.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:a}=e.lgv,s=e.getAssemblyId(a[o.regionNumber].assemblyName),c=al(r,t.bp,n,i),l="max"===n?new qr({typeName:"LocationEndChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:s}):new Ur({typeName:"LocationStartChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:s});e.changeManager.submit(l),e.setDragging(),e.setCursor()}}))).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t);sl(n)&&e.getGlyph(n.feature).onMouseDown(e,n,t)},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);sl(n)?e.getGlyph(n.feature).onMouseMove(e,n,t):(e.setHoveredFeature(),e.setCursor())},onMouseLeave(t){e.setDragging(),e.setHoveredFeature();const n=e.getMousePosition(t);sl(n)&&e.getGlyph(n.feature).onMouseLeave(e,n,t)},onMouseUp(t){const n=e.getMousePosition(t);sl(n)?e.getGlyph(n.feature).onMouseUp(e,n,t):e.setSelectedFeature(),e.apolloDragging&&e.endDrag()}}))).actions((e=>({afterAttach(){c.addDisposer(e,l.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.overlayCanvas?.getContext("2d");if(!t)return;t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);const{apolloDragging:n,hoveredFeature:r}=e;if(!r)return;const o=e.getGlyph(r.feature);o.drawHover(e,t),o.drawTooltip(e,t),n&&e.getGlyph(n.feature.topLevelFeature).drawDragPreview(e,t)}),{name:"LinearApolloSixFrameDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:c.types.optional(tf,{})}).named("LinearApolloSixFrameDisplay")}const mh=n.ConfigurationSchema("ApolloPlugin",{ontologies:c.types.array(Iu),featureTypeOntologyName:{description:"Name of the feature type ontology",type:"string",defaultValue:"Sequence Ontology"},hasRole:{description:"Flag used internally by jbrowse-plugin-apollo",type:"boolean",defaultValue:!1},geneBackgroundColor:{description:"Color for feature background",type:"string",defaultValue:"jexl:geneBackgroundColor(featureType)",contextVariable:["featureType"]}}),yh=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogene")||n.isTypeOf(e.type,"pseudogenic_transcript")},_h=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")},vh=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")};function bh(e){const{attributes:t}=e,n=["gene_name","gene_id","gene_stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}const Ch=e=>{const t=function(e){const{attributes:t}=e,n=["name","gff_name","transcript_name","gene_name"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e),n=function(e){const{attributes:t}=e,n=["id","gff_id","transcript_id","gene_id","gene_stable_id","stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e);return t?`${e.type} - ${t}`:n?`${e.type} - ${n}`:e.type};function Ih({annotationFeature:e,assembly:t,handleClose:n,refSeqId:r,session:o,region:a}){const l=o,{featureTypeOntology:d}=l.apolloDataStore.ontologyManager,A=u.useMemo((()=>Object.keys(e.children??{})),[e]),[f,h]=u.useState(!0),[g,p]=u.useState(A),[m,y]=u.useState(""),[_,v]=u.useState([]),[b,C]=u.useState(!1),[I,w]=u.useState(),E=l.apolloDataStore.assemblies.get(t.name),x=E?.refSeqs.get(r),S=x?.getFeatures(a.start,a.end),B=()=>{const e=[];for(const t of S??[])if(!(t.min>a.end||t.max<a.start)&&d?.isTypeOf(t.type,"gene")){const n=c.getSnapshot(t);e.push(n)}return e};u.useEffect((()=>{y("");const e=B();v(e),w(e[0])}),[g,f,a]);const k=async e=>{if(I)for(const n of Object.keys(e)){const r=e[n];if(r.strand=I.strand,r.children)for(const e of Object.keys(r.children))r.children[e].strand=I.strand;const o=new Nr({parentFeatureId:I._id,changedIds:[I._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:r});await R(o,n)}},Q=async n=>{const o=(new ut).toHexString(),i=Math.min(...Object.values(n).map((e=>e.min))),a=Math.max(...Object.values(n).map((e=>e.max))),s=new Nr({changedIds:[o],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{_id:o,refSeq:r,min:i,max:a,strand:e.strand,type:"gene",children:n,attributes:{name:[bh(e)],gene_name:[bh(e)]}}});await R(s,o)},N=async(e,n)=>{if(!I)return;const r=[];e!==I.min&&r.push(new Ur({typeName:"LocationStartChange",changedIds:[I._id],featureId:I._id,assembly:t.name,oldStart:I.min,newStart:e})),n!==I.max&&r.push(new qr({typeName:"LocationEndChange",changedIds:[I._id],featureId:I._id,assembly:t.name,oldEnd:I.max,newEnd:n}));for(const e of r)await R(e)},R=async(e,t)=>{await l.apolloDataStore.changeManager.submit(e).then((()=>{l.apolloSetSelectedFeature(t)}))};return i.jsxs(Al,{open:!0,title:"Create Apollo Annotation",handleClose:n,fullWidth:!0,maxWidth:"sm",children:[i.jsx(s.DialogTitle,{fontSize:15,children:"Select the feature to be copied to apollo track"}),i.jsxs(s.DialogContent,{children:[i.jsxs(s.Box,{sx:{ml:3},children:[yh(e,l)&&i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:f,onChange:e=>{const t=e.target.checked;h(t),p(t?A:[])}}),label:`${Ch(e)} (${e.min+1}..${e.max})`}),e.children&&i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",ml:3},children:Object.values(e.children).filter((e=>vh(e,l))).map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:g.includes(e._id),onChange:t=>{((e,t)=>{p((n=>e.target.checked?[...n,t._id]:n.filter((e=>e!==t._id))))})(t,e)}}),label:`${Ch(e)} (${e.min+1}..${e.max})`},e._id)))})]}),_.length>0&&(!f&&g.length>0||f&&vh(e,l))&&i.jsxs("div",{style:{border:"1px solid #ccc",marginTop:20,padding:10,borderRadius:5},children:[i.jsxs(s.Box,{sx:{ml:3},children:[i.jsx(s.Typography,{variant:"caption",fontSize:12,children:"Select the destination feature to copy the selected features"}),i.jsx(s.Box,{sx:{mt:1},children:i.jsx(s.Select,{labelId:"label",style:{width:"100%"},value:I?._id??"",onChange:e=>{const t=_.find((t=>t._id===e.target.value));w(t)},disabled:b,children:_.map((e=>i.jsx(s.MenuItem,{value:e._id,children:`${Ch(e)} (${e.min+1}..${e.max})`},e._id)))})})]}),i.jsx(s.Box,{sx:{ml:3},children:i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:b,onChange:e=>{C(e.target.checked)}}),label:"Create new gene"})})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===g.length||!f&&g.length>0&&!I,onClick:async()=>{if(f){if(_h(e,l)&&(await(async()=>{let n;if(e.children&&g.length!==Object.values(e.children).length){const r={};for(const t of g)r[t]=e.children[t];n=new Nr({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{...e,children:r}})}else n=new Nr({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:e});await R(n,e._id)})(),o.notify("Successfully copied selected gene and transcript(s)","success")),vh(e,l))if(I&&!b){const t={};if(t[e._id]=e,I.max<e.max||I.min>e.min){const n=Math.min(I.min,e.min),r=Math.max(I.max,e.max);await N(n,r),await k(t)}else await k(t);o.notify("Successfully copied selected transcripts to destination gene","success")}else{const t={};t[e._id]=e,await Q(t),o.notify("Successfully created a new gene with selected transcripts","success")}}else{if(!e.children)return;if(I&&!b){const t={};for(const n of g)t[n]=e.children[n];const n=Math.min(...Object.values(t).map((e=>e.min))),r=Math.max(...Object.values(t).map((e=>e.max)));if(I.min>n||I.max<r){const e=Math.min(I.min,n),o=Math.max(I.max,r);await N(e,o),await k(t)}else await k(t);o.notify("Successfully copied transcript to destination gene","success")}else{const t={};for(const n of g)t[n]=e.children[n];await Q(t),o.notify("Successfully created a new gene with selected transcript","success")}}n()},children:"Create"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:n,children:"Cancel"})]}),m?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:m})}):null]})}function wh(e){if("LinearPileupDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=e.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a},getRefSeqId(t){const n=e.getFirstRegion(),{refName:r}=n,{refNameAliases:o}=t;if(!o)throw new Error(`Could not find aliases for ${t.name}`);const i=[...Object.entries(o)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t}))),a=i.find((e=>e.name===r))?._id;if(!a)throw new Error(`Could not find refSeqId named ${r}`);return a},getAnnotationFeature(){const t=e.contextMenuFeature,n=e.getAssembly(),r=e.getRefSeqId(n),o=t.get("start"),i=t.get("end"),a=t.get("strand"),s=t.get("name"),c=function(e){const t=/(\d+)([MIDNSHPX=])/g,n=[];let r;for(;null!==(r=t.exec(e));)n.push([r[2],Number.parseInt(r[1],10)]);return n}(t.get("CIGAR"));let l,u=o;const d=[];for(const[e,t]of c)switch(e){case"M":case"=":case"X":void 0===l&&(l=u),u+=t;break;case"N":void 0!==l&&(d.push({start:l,end:u}),l=void 0),u+=t;break;case"D":u+=t;break;case"I":case"S":case"H":case"P":break;default:throw new Error(`Unknown CIGAR operation: ${e}`)}void 0!==l&&d.push({start:l,end:u});const A={_id:ut().toHexString(),refSeq:r,min:o,max:i,type:"mRNA",strand:a,attributes:{name:[s]}};if(0===d.length)return A;A.children={};for(const e of d){const t={_id:ut().toHexString(),refSeq:r,min:e.start,max:e.end,type:"exon",strand:a};A.children[t._id]=t}return A}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion();return e.contextMenuFeature?[...t(),{label:"Create Apollo annotation",icon:Uo,onClick:()=>{n.queueDialog((t=>[Ih,{session:n,handleClose:()=>{t()},annotationFeature:e.getAnnotationFeature(r),assembly:r,refSeqId:e.getRefSeqId(r),region:i}]))}}]:t()}}}));return e.stateModel=n,e}function Eh(e,t){const n=e.get("subfeatures");return[{start:e.get("start")+1,end:e.get("end"),seq_id:t,source:e.get("source")??null,type:e.get("type")??null,score:e.get("score")??null,strand:e.get("strand")?1===e.get("strand")?"+":"-":null,phase:null!==e.get("phase")||void 0!==e.get("phase")?e.get("phase"):null,attributes:Sh(e),derived_features:[],child_features:n?n.map((e=>Eh(e,t))):[]}]}function xh(e,t){return It(Eh(e,t))}function Sh(e){const t={},n=new Set(["start","end","type","strand","refName","subfeatures","derived_features","phase","source","score"]);for(const[r,o]of Object.entries(e.toJSON()))n.has(r)||(t[r]=Array.isArray(o)?o.map(String):[String(o)]);return t}function Bh(e){if("LinearBasicDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=e.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a},getRefSeqId(t){const n=e.getFirstRegion(),{refName:r}=n,{refNameAliases:o}=t;if(!o)throw new Error(`Could not find aliases for ${t.name}`);const i=[...Object.entries(o)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t}))),a=i.find((e=>e.name===r))?._id;if(!a)throw new Error(`Could not find refSeqId named ${r}`);return a},getAnnotationFeature:(t,n)=>xh(n,e.getRefSeqId(t))}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;return a?[...t(),{label:"Create Apollo annotation",icon:Uo,onClick:()=>{n.queueDialog((t=>[Ih,{session:n,handleClose:()=>{t()},annotationFeature:e.getAnnotationFeature(r,a),assembly:r,refSeqId:e.getRefSeqId(r),region:i}]))}}]:t()}}}));return e.stateModel=n,e}var kh=a.createSvgIcon(i.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Qh=a.createSvgIcon(i.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"}),"Lock"),Nh=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");const Rh=f.observer((function({display:e}){const{classes:t}=Lf(),{apolloDragging:n,apolloRowHeight:r,lgv:a,session:c,showCheckResults:l}=e,{assemblyManager:u}=c;return l?a.dynamicBlocks.contentBlocks.map((l=>{const d=a.bpPerPx*r,A=u.get(l.assemblyName);return A?Pf([...c.apolloDataStore.checkResults.values()].filter((e=>A.isValidRefName(e.refSeq)&&A.getCanonicalRefName(e.refSeq)===l.refName&&o.doesIntersect2(l.start,l.end,e.start,e.end))),d).map((o=>{const a=Math.round(function(e,t,n){const{lgv:r}=e,{bpPerPx:o,offsetPx:i}=r;return n.offsetPx-i+(n.reversed?n.end-t.max:t.min-n.start)/o}(e,o.range,l)),[c]=o.featureIds;if(!c)return null;let u=0;const d=e.getFeatureLayoutPosition(c);return d&&(u=d.layoutRow+d.featureRow),i.jsx(s.Tooltip,{title:o.message,children:i.jsx(s.Box,{className:t.box,style:{top:u*r,left:a,height:r,width:r,pointerEvents:n?"none":"auto"},children:i.jsx(s.Badge,{className:t.badge,badgeContent:o.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:o.count<=1,children:i.jsx(s.Avatar,{className:t.avatar,children:i.jsx(Nh,{"data-testid":`ErrorIcon-${o.start}`})})})})},o._id)})):null})):null})),Dh=f.observer((function(e){const t=s.useTheme(),{model:n}=e,{loading:r,contextMenuItems:a,cursor:c,featuresHeight:l,isShown:d,onMouseDown:f,onMouseLeave:h,onMouseMove:g,onMouseUp:p,regionCannotBeRendered:m,session:y,setCanvas:_,setCollaboratorCanvas:v,setOverlayCanvas:b,setTheme:C}=n,{classes:I}=Lf(),w=o.getContainingView(n);u.useEffect((()=>{C(t)}),[t,C]);const[E,x]=u.useState(),[S,B]=u.useState([]),k=m();return d?i.jsx(i.Fragment,{children:i.jsxs("div",{className:I.canvasContainer,style:{width:w.dynamicBlocks.totalWidthPx,height:l},onContextMenu:e=>{e.preventDefault(),S.length>0?B([]):(x([e.clientX,e.clientY]),B(a(e)))},children:[y.isLocked?i.jsx("div",{className:I.locked,"data-testid":"lock-icon",children:i.jsx(Qh,{})}):null,r?i.jsx("div",{className:I.loading,children:i.jsx(s.CircularProgress,{size:"18px"})}):null,k?i.jsx(s.Alert,{severity:"warning",classes:{message:I.ellipses},slotProps:{root:{className:I.center}},children:i.jsx(s.Tooltip,{title:k,children:i.jsx("div",{children:k})})}):i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),v(e)},width:w.dynamicBlocks.totalWidthPx,height:l,className:I.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),_(e)},width:w.dynamicBlocks.totalWidthPx,height:l,className:I.canvas,"data-testid":"canvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),b(e)},width:w.dynamicBlocks.totalWidthPx,height:l,onMouseMove:g,onMouseLeave:h,onMouseDown:f,onMouseUp:p,className:I.canvas,style:{cursor:c??"default"},"data-testid":"overlayCanvas"}),i.jsx(Rh,{display:n}),i.jsx(A.Menu,{open:S.length>0,onMenuItemClick:(e,t)=>{t(),B([])},onClose:()=>{B([])},slotProps:{transition:{onExit:()=>{B([])}}},anchorReference:"anchorPosition",anchorPosition:E?{top:E[1],left:E[0]}:void 0,menuItems:S})]})]})}):null})),Fh=f.observer((function({model:e,hrStyle:t={margin:0,top:0,color:"black"},idx:n=0}){const{apolloRowHeight:r,highestRow:o,showFeatureLabels:a}=e,s=a?2:1;return i.jsx("div",{style:{position:"absolute",left:0,top:r*s*(o+1)/2+n*s*r,width:"100%"},children:i.jsx("hr",{style:t})})})),Th=f.observer((function(e,t){const n=s.useTheme(),{model:r}=e,{apolloRowHeight:a,contextMenuItems:c,cursor:l,featuresHeight:d,geneTrackRowNums:f,isShown:h,onMouseDown:g,onMouseLeave:p,onMouseMove:m,onMouseUp:y,regionCannotBeRendered:_,session:v,setCanvas:b,setCollaboratorCanvas:C,setOverlayCanvas:I,setTheme:w,showCheckResults:E,showFeatureLabels:x}=r,{classes:S}=Lf(),B=o.getContainingView(r);u.useEffect((()=>{w(n)}),[n,w]);const[k,Q]=u.useState(),[N,R]=u.useState([]),D=_();if(!h)return null;const{assemblyManager:F}=v;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:S.canvasContainer,style:{width:B.dynamicBlocks.totalWidthPx,height:d},onContextMenu:e=>{e.preventDefault(),N.length>0?R([]):(Q([e.clientX,e.clientY]),R(c(e)))},children:[v.isLocked?i.jsx("div",{className:S.locked,"data-testid":"lock-icon",children:i.jsx(Qh,{})}):null,D?i.jsx(s.Alert,{severity:"warning",classes:{message:S.ellipses},slotProps:{root:{className:S.center}},children:i.jsx(s.Tooltip,{title:D,children:i.jsx("div",{children:D})})}):i.jsxs(i.Fragment,{children:[i.jsx(Fh,{model:r,idx:0}),i.jsx(Fh,{model:r,hrStyle:{margin:0,top:0,color:"grey",opacity:.4},idx:1}),i.jsx(Fh,{model:r,idx:2}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),C(e)},width:B.dynamicBlocks.totalWidthPx,height:d,className:S.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),b(e)},width:B.dynamicBlocks.totalWidthPx,height:d,className:S.canvas,"data-testid":"canvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),I(e)},width:B.dynamicBlocks.totalWidthPx,height:d,onMouseMove:m,onMouseLeave:p,onMouseDown:g,onMouseUp:y,className:S.canvas,style:{cursor:l??"default"},"data-testid":"overlayCanvas"}),B.displayedRegions.flatMap(((e,n)=>{const r=B.bpPerPx*a,c=F.get(e.assemblyName);return E?Pf([...v.apolloDataStore.checkResults.values()].filter((t=>c?.isValidRefName(t.refSeq)&&c.getCanonicalRefName(t.refSeq)===e.refName&&o.doesIntersect2(e.start,e.end,t.start,t.end))),r).map((r=>{const c=(B.bpToPx({refName:e.refName,coord:r.start,regionNumber:n})?.offsetPx??0)-B.offsetPx,[l]=r.featureIds;if(!l||!l.parent?.looksLikeGene)return null;let u;for(const e of l.cdsLocations)for(const t of e){const e=o.getFrame(t.min,t.max,l.strand??1,t.phase),n=(x?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(e);if(n&&r.start>=t.min&&r.start<=t.max){u=n-1;break}}return void 0===u&&(u=(1==l.strand?f[0]:f[1])-1),i.jsx(s.Tooltip,{title:r.message,children:i.jsx(s.Box,{className:S.box,style:{top:u*a,left:c,height:a,width:a,pointerEvents:t?"none":"auto"},children:i.jsx(s.Badge,{className:S.badge,badgeContent:r.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:r.count<=1,children:i.jsx(s.Avatar,{className:S.avatar,children:i.jsx(Nh,{"data-testid":`ErrorIcon-${r.start}`})})})})},r._id)})):null})),i.jsx(A.Menu,{open:N.length>0,onMenuItemClick:(e,t)=>{t(),R([])},onClose:()=>{R([])},slotProps:{transition:{onExit:()=>{R([])}}},anchorReference:"anchorPosition",anchorPosition:k?{top:k[1],left:k[0]}:void 0,style:{zIndex:n.zIndex.tooltip},menuItems:N})]})]})})})),jh=Ec()((e=>({shading:{background:s.alpha(e.palette.primary.main,.2),overflowX:"hidden"},details:{background:e.palette.background.paper},accordionControl:{height:12,width:"100%","&:hover":{background:e.palette.action.hover},display:"flex",alignItems:"center",justifyContent:"center"},accordionRoot:{background:e.palette.divider},resizeHandle:{width:"100%",height:4,position:"absolute",cursor:"row-resize",zIndex:100},expandIcon:{},title:{userSelect:"none"},alertContainer:{display:"flex",alignItems:"center",justifyContent:"center"}})));function Mh(e,t){const{apolloRowHeight:n,selectedFeature:r}=e;if(t.current&&r){const o=e.getFeatureLayoutPosition(r);o&&t.current.scroll({top:(o.layoutRow+o.featureRow)*n,behavior:"smooth"})}}const Oh=({onResize:e})=>{const{classes:t}=jh(),n=u.useCallback((t=>{t.stopPropagation(),t.preventDefault(),e(t.movementY)}),[e]);return i.jsx("div",{onMouseDown:e=>{e.stopPropagation();const t=new AbortController,{signal:r}=t;function o(){t.abort(new DOMException("Canceling drag event listener","AbortError"))}globalThis.addEventListener("mousemove",n,{signal:r}),globalThis.addEventListener("mouseup",o,{signal:r}),globalThis.addEventListener("mouseleave",o,{signal:r})},onClick:e=>{e.stopPropagation(),e.preventDefault()},className:t.resizeHandle})},Lh=f.observer((function({onClick:e,onResize:t,open:n,title:r}){const{classes:o}=jh();return i.jsxs("div",{className:o.accordionRoot,children:[n&&t?i.jsx(Oh,{onResize:t}):null,i.jsxs("div",{className:o.accordionControl,onClick:e,children:[i.jsx(n?kh:Td,{className:o.expandIcon}),r?i.jsx(s.Typography,{className:o.title,variant:"caption",component:"span",children:r}):null]})]})})),Ph=f.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,c=a?.dataStore,{classes:l}=jh(),{graphical:d,height:A,isShown:f,selectedFeature:h,table:g,tabularEditor:p,toggleShown:m}=e,y=u.useRef(null);u.useEffect((()=>{Mh(e,y)}),[e,h]);const _=t=>{e.setDetailsHeight(e.detailsHeight-t)};if(!c)return i.jsx("div",{className:l.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(d&&g){const n=p.isShown?e.detailsHeight:0,r=f?A-e.detailsHeight-24:0;return i.jsxs("div",{style:{height:A},children:[i.jsx(Lh,{open:f,title:"Graphical",onClick:m}),i.jsx("div",{className:l.shading,ref:y,style:{height:r},children:i.jsx(Dh,{model:e,...t})}),i.jsx(Lh,{title:"Table",open:p.isShown,onClick:p.togglePane,onResize:_}),i.jsx("div",{className:l.details,style:{height:n},children:i.jsx(ef,{model:e})})]})}return i.jsx("div",d?{className:l.shading,ref:y,style:{height:A},children:i.jsx(Dh,{model:e,...t})}:{className:l.details,style:{height:A},children:i.jsx(ef,{model:e})})})),qh=f.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,c=a?.dataStore,{classes:l}=jh(),{detailsHeight:d,graphical:A,height:f,isShown:h,selectedFeature:g,table:p,tabularEditor:m,toggleShown:y}=e,_=u.useRef(null);u.useEffect((()=>{Mh(e,_)}),[e,g]);const v=t=>{e.setDetailsHeight(d-t)};if(!c)return i.jsx("div",{className:l.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(A&&p){const n=m.isShown?d:0,r=h?f-d-24:0;return i.jsxs("div",{style:{height:f},children:[i.jsx(Lh,{open:h,title:"Graphical",onClick:y}),i.jsx("div",{className:l.shading,ref:_,style:{height:r},children:i.jsx(Th,{model:e,...t})}),i.jsx(Lh,{title:"Table",open:m.isShown,onClick:m.togglePane,onResize:v}),i.jsx("div",{className:l.details,style:{height:n},children:i.jsx(ef,{model:e})})]})}return i.jsx("div",A?{className:l.shading,ref:_,style:{height:f},children:i.jsx(Th,{model:e,...t})}:{className:l.details,style:{height:f},children:i.jsx(ef,{model:e})})}));var Jh=a.createSvgIcon(i.jsx("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}),"Download"),Uh=a.createSvgIcon(i.jsx("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M10 17H5v-2h5zm0-4H5v-2h5zm0-4H5V7h5zm4.82 6L12 12.16l1.41-1.41 1.41 1.42L17.99 9l1.42 1.42z"}),"FactCheck"),Gh=a.createSvgIcon(i.jsx("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H15v-8h5V8zm-1 7V3.5L18.5 9zm4 12.66V16h5.66v2h-2.24l2.95 2.95-1.41 1.41L19 19.41v2.24h-2z"}),"FileOpen"),Hh=a.createSvgIcon(i.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"}),"Logout"),Yh=a.createSvgIcon(i.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"}),"Redo"),zh=a.createSvgIcon(i.jsx("path",{d:"m19.07 4.93-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07"}),"TrackChanges"),Kh=a.createSvgIcon(i.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo"),Wh=a.createSvgIcon(i.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save");const Vh=c.types.model("JobsManager",{}).views((e=>({get jobStatusWidget(){const{widgets:t}=o.getSession(e);let n=t.get("JobsList");return n||(n=o.getSession(e).addWidget("JobsListWidget","JobsList")),n}}))).actions((e=>({update(t,n,r){e.jobStatusWidget.updateJobStatusMessage(t,n),r&&e.jobStatusWidget.updateJobProgressPct(t,r)},abortJob(t,n){const r=o.getSession(e);if(o.isSessionModelWithWidgets(r)){r.showWidget(e.jobStatusWidget),e.jobStatusWidget.updateJobStatusMessage(t,n??"Aborted unexpectedly");const o=e.jobStatusWidget.jobs.findIndex((e=>e.name===t));e.jobStatusWidget.addAbortedJob({...e.jobStatusWidget.jobs[o]}),e.jobStatusWidget.removeJob(t),r.notify("Job aborted","info")}},runJob(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.addJob(t))},done(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.removeJob(t.name),e.jobStatusWidget.addFinishedJob({name:t.name,statusMessage:"All operations successful",progressPct:100,cancelCallback:t.cancelCallback}))}})));function $h(e,t){const r=e.evaluateExtensionPoint("Apollo-extendAnnotationFeature",rA),i=function(e){return c.types.model("ClientDataStore",{typeName:c.types.optional(c.types.literal("Client"),"Client"),assemblies:c.types.map(aA),checkResults:c.types.map(sA),ontologyManager:c.types.optional(bu,{})}).views((t=>({get internetAccounts(){return c.getRoot(t).internetAccounts},get pluginConfiguration(){return c.getRoot(t).jbrowse.configuration.ApolloPlugin},getFeature:n=>c.resolveIdentifier(e,t.assemblies,n)}))).actions((e=>({addAssembly(t,n){const r={_id:t,refSeqs:{}};return n&&(r.backendDriverType=n),e.assemblies.put(r)}}))).actions((e=>({addFeature(t,n){const r=o.getSession(e),{assemblyManager:i}=r;let a=e.assemblies.get(t);if(!a){if(!i.get(t))throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);a=e.addAssembly(t)}let s=a.refSeqs.get(n.refSeq);if(!s){const e=i.get(t);if(!e)throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);const r=e.getCanonicalRefName(n.refSeq);if(!r)throw new Error(`Could not find refSeq "${n.refSeq}" to add feature "${n._id}"`);s=a.addRefSeq(n.refSeq,r)}s.features.put(n)},deleteFeature(t){const n=e.getFeature(t);if(!n)throw new Error(`Could not find feature "${t}" to delete`);const{_id:r,parent:o}=n;o?o.deleteChild(t):c.getParentOfType(n,iA).deleteFeature(r)},deleteAssembly(t){e.assemblies.delete(t)},addCheckResult(t){e.checkResults.put(t)},addCheckResults(t){for(const n of t)e.checkResults.has(n._id)||e.checkResults.put(n)},deleteCheckResult(t){e.checkResults.delete(t)},clearCheckResults(){e.checkResults.clear()}}))).volatile((e=>({changeManager:new Qu(e),collaborationServerDriver:new Nu(e),inMemoryFileDriver:new Ru(e),desktopFileDriver:o.isElectron?new Du(e):void 0}))).actions((e=>({afterCreate(){c.addDisposer(e,l.autorun((()=>{const{ontologyManager:t,pluginConfiguration:r}=e,i=r.ontologies;for(const r of i||[]){const[i,a,s,c]=[n.readConfObject(r,"name"),n.readConfObject(r,"version"),n.readConfObject(r,"source"),n.readConfObject(r,"textIndexFields")];if(!t.findOntology(i)){const n=o.getSession(e),{jobsManager:r}=n,l=new AbortController,u=`Loading ontology "${i}"`,d={name:u,statusMessage:`Loading ontology "${i}", version "${a}", this may take a while`,progressPct:0,cancelCallback:()=>{l.abort(new DOMException(`Canceling loading of ontology "${i}"`,"AbortError")),r.abortJob(d.name)}};t.addOntology(i,a,s,{textIndexing:{indexFields:c},update:(e,t)=>{0!==t?100!==t?r.update(u,e,t):r.done(d):r.runJob(d)}})}}})))}}))).views((e=>({getBackendDriver(t){const r=o.getSession(e),{assemblyManager:i}=r,a=i.get(t);if(!a)return;const{file:s,internetAccountConfigId:c}=n.getConf(a,["sequence","metadata"]);return o.isElectron&&s?e.desktopFileDriver:c?e.collaborationServerDriver:e.inMemoryFileDriver},getInternetAccount(t,r){if(!(t??r))throw new Error("Must provide either assemblyName or internetAccountId");let i=r;if(t&&!i){const{assemblyManager:r}=o.getSession(e),a=r.get(t);if(!a)throw new Error(`No assembly found with name ${t}`);({internetAccountConfigId:i}=n.getConf(a,["sequence","metadata"]))}const{internetAccounts:a}=e,s=a.find((e=>e.internetAccountId===i));if(!s)throw new Error(`No InternetAccount found with config id ${r}`);return s}}))).actions((e=>({loadFeatures:c.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const[r,o]=yield t.getFeatures(n);if(0===r.length)continue;const{assemblyName:i,refName:a}=n;let s=e.assemblies.get(i);s||(s=e.assemblies.put({_id:i,refSeqs:{}}));const[c]=r;let l=s.refSeqs.get(c.refSeq);l||(l=s.refSeqs.put({_id:c.refSeq,name:a,features:{}}));for(const e of r)l.features.has(e._id)||l.features.put(e);e.addCheckResults(o)}})),loadRefSeq:c.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const{refSeq:r,seq:o}=yield t.getSequence(n),{assemblyName:i,end:a,refName:s,start:c}=n;let l=e.assemblies.get(i);l||(l=e.assemblies.put({_id:i,refSeqs:{}}));let u=l.refSeqs.get(r);u||(u=l.refSeqs.put({_id:r,name:s,sequence:[]})),u.addSequence({start:c,stop:a,sequence:o})}}))})))}(r),a=t.props({apolloDataStore:c.types.optional(i,{typeName:"Client"}),apolloSelectedFeature:c.types.safeReference(r),jobsManager:c.types.optional(Vh,{}),isLocked:c.types.optional(c.types.boolean,!1),changeInProgress:c.types.optional(c.types.boolean,!1)}).volatile((()=>({apolloHoveredFeature:void 0,abortController:new AbortController}))).extend((()=>{const e=l.observable.array([]);return{views:{get collaborators(){return e}},actions:{addOrUpdateCollaborator(t){const n=e.find((e=>e.id===t.id));n?n.locations=t.locations:e.push(t)}}}})).actions((e=>({apolloSetSelectedFeature(t){e.apolloSelectedFeature=t},apolloSetHoveredFeature(t){e.apolloHoveredFeature=t},addApolloTrackConfig(t,r){const o=`apollo_track_${t.name}`;e.tracks.some((e=>e.trackId===o))||e.addTrackConf({type:"ApolloTrack",trackId:o,name:`Annotations (${n.getConf(t,"displayName")||t.name})`,assemblyNames:[t.name],textSearching:{textSearchAdapter:{type:"ApolloTextSearchAdapter",trackId:o,assemblyNames:[t.name],textSearchAdapterId:`apollo_search_${t.name}`,...r?{baseURL:{uri:r,locationType:"UriLocation"}}:{}}}})},toggleLocked(){e.isLocked=!e.isLocked},setChangeInProgress(t){e.changeInProgress=t},getPluginConfiguration(){const{jbrowse:t}=c.getRoot(e);return t.configuration.ApolloPlugin},broadcastLocations(){const{internetAccounts:t}=c.getRoot(e),n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);s&&"CollaborationServerDriver"===s.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)"baseURL"in e&&e.postUserLocation([]);return}const r=[];for(const e of t)if("baseURL"in e){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}}))).actions((e=>({apolloSetEventualSelectedFeature:l.flow((function*(t){yield l.when((()=>Boolean(e.apolloDataStore.getFeature(t)))),e.apolloSetSelectedFeature(t)}))}))).volatile((e=>({previousSnapshot:c.getSnapshot(e)}))).actions((e=>({afterCreate(){c.applySnapshot(e,{name:e.name,id:e.id});const{internetAccounts:t,jbrowse:r,reloadPluginManagerCallback:o}=c.getRoot(e);c.addDisposer(e,l.autorun((()=>{const n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);s&&"CollaborationServerDriver"===s.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)"baseURL"in e&&e.postUserLocation([]);return}const r=[];for(const e of t)if("baseURL"in e){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}),{name:"ApolloSessionBroadcastLocations"})),c.addDisposer(e,l.autorun((async i=>{if(n.readConfObject(r.configuration.ApolloPlugin,"hasRole"))return c.applySnapshot(e,e.previousSnapshot),void i.dispose();const{signal:a}=e.abortController;for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const{baseURL:t}=n,r=new URL("jbrowse/config.json",t).href,s=n.getFetcher({locationType:"UriLocation",uri:r});let c,l;try{c=await s(r,{signal:a})}catch(t){e.abortController.signal.aborted||console.error(t);continue}if(c.ok){try{l=await c.json()}catch(e){console.error(e);continue}l.configuration.ApolloPlugin.hasRole&&(o(l,e.previousSnapshot),i.dispose())}else{const e=await ll(c,"Failed to fetch assemblies");console.error(e)}}}),{name:"ApolloSessionLoadConfig"}))},beforeDestroy(){e.abortController.abort(new DOMException("Clean up Apollo session","AbortError"))}}))).views((e=>{const t=e.getTrackActionMenuItems;return{getTrackActionMenuItems(r){if("ApolloTrack"===r.type||"ReferenceSequenceTrack"===r.type)return t?.(r);const o=n.readConfObject(r,"trackId");return o.endsWith("-sessionTrack")?[...t?.(r)??[],{label:"Save track to Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=c.getRoot(e);let i;i=Lr(c.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a={...c.getSnapshot(r),trackId:o.slice(0,o.length-13)};for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Pr({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:i?.tracks&&[...i.tracks,a]}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track added","success")}e.deleteTrackConf(r),n.addTrackConf(a)},icon:Wh}]:[...t?.(r)??[],{label:"Remove track from Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=c.getRoot(e);let i;i=Lr(c.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a=i?.tracks?.filter((e=>e.trackId!==o));for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Pr({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:a}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track removed","success")}e.deleteTrackConf(r),n.deleteTrackConf(r)},icon:Wh}]}}}));return c.types.snapshotProcessor(a,{postProcessor(e,t){e.apolloSelectedFeature=void 0;const n=Object.fromEntries(Object.entries(e.apolloDataStore.assemblies).filter((([,e])=>"InMemoryFileDriver"===e.backendDriverType)));if(e.apolloDataStore={typeName:"Client",assemblies:n,checkResults:{}},!t)return e;const{apolloDataStore:r}=t,{checkResults:o}=r;for(const[,t]of o){const[n]=t.ids;if(!n)continue;const o=r.assemblies.get(n.assemblyId);o&&"InMemoryFileDriver"===o.backendDriverType&&(e.apolloDataStore.checkResults[t._id]=c.getSnapshot(t))}return e}})}const Xh="WorkerGlobalScope"in globalThis;for(const[e,t]of Object.entries(oo))ne.registerChange(e,t);const Zh=new jo;ae.registerCheck(Zh.name,Zh);const eg=new Jo;ae.registerCheck(eg.name,eg),co.registerValidation(new uo),co.registerValidation(new Ao),e.default=class extends t{name="ApolloPlugin";version="0.3.12";configurationSchema=mh;install(e){!function(e){e.addAdapterType((()=>new m({name:"ApolloSequenceAdapter",configSchema:Qd,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:kd})))}(e),function(e){e.addAdapterType((()=>new m({name:"ApolloRefNameAliasAdapter",configSchema:wd,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Id})))}(e),function(e){e.addTextSearchAdapterType((()=>new r.TextSearchAdapterType({name:"ApolloTextSearchAdapter",displayName:"Apollo text search adapter",configSchema:Fd,AdapterClass:Dd,description:"Apollo Text Search adapter"})))}(e),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloFeatureDetailsWidget",{});return new r.WidgetType({name:"ApolloFeatureDetailsWidget",heading:"Apollo feature details",configSchema:e,stateModel:cA,ReactComponent:tA})})),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloTranscriptDetails",{});return new r.WidgetType({name:"ApolloTranscriptDetails",heading:"Apollo transcript details",configSchema:e,stateModel:lA,ReactComponent:jA})})),e.addTrackType((()=>{const t=n.ConfigurationSchema("ApolloTrack",{adapter:""},{baseConfiguration:r.createBaseTrackConfig(e),explicitIdentifier:"trackId"});return new r.TrackType({name:"ApolloTrack",configSchema:t,stateModel:r.createBaseTrackModel(e,"ApolloTrack",t)})})),e.addInternetAccountType((()=>new r.InternetAccountType({name:"ApolloInternetAccount",configSchema:Go,stateModel:bd(Go)}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloDisplay",configSchema:MA,stateModel:Hf(0,MA),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Ph}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloSixFrameDisplay",configSchema:ih,stateModel:ph(0,ih),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:qh}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloReferenceSequenceDisplay",configSchema:Yf,stateModel:rh(0,Yf),displayName:"Apollo reference sequence display",trackType:"ReferenceSequenceTrack",viewType:"LinearGenomeView",ReactComponent:oh}))),e.addToExtensionPoint("Core-extendSession",$h.bind(this,e)),e.addToExtensionPoint("Core-extendPluggableElement",(e=>{if("LinearGenomeView"===e.name){const{stateModel:t}=e,n=t.views((e=>{const t=e.rubberBandMenuItems;return{rubberBandMenuItems:()=>[...t(),{label:"Add new feature",icon:Uo,onClick:()=>{const t=o.getSession(e),{leftOffset:n,rightOffset:r}=e,i=e.getSelectedRegions(n,r);t.queueDialog((e=>[ju,{session:t,handleClose:()=>{e()},region:i[0],changeManager:t.apolloDataStore.changeManager}]))}}]}}));e.stateModel=n}return e})),e.addToExtensionPoint("Core-extendPluggableElement",wh),e.addToExtensionPoint("Core-extendPluggableElement",Bh),e.addToExtensionPoint("LinearGenomeView-searchResultSelected",((e,t)=>{const{session:n,result:r}=t,o=r.getTrackId(),i=r.matchedObject;return o?.startsWith("apollo_track_")&&i&&n.apolloSetEventualSelectedFeature(i._id),e})),Xh||e.addToExtensionPoint("Core-extendWorker",(t=>"on"in t&&t.on?(t.on("apollo",(async n=>{if("object"!=typeof(r=n)||null===r||!("apollo"in r)||!0!==r.apollo)return;var r;const{apollo:o,messageId:i,method:a}=n;switch(a){case"getSequence":{const{region:r}=n,{assemblyName:a}=r,s=e.rootModel?.session?.apolloDataStore;if(!s)break;const c=s.getBackendDriver(a);if(!c)break;const{seq:l}=await c.getSequence(r);t.workers[0].postMessage({apollo:o,messageId:i,sequence:l});break}case"getRegions":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const c=await s.getRegions(r);t.workers[0].postMessage({apollo:o,messageId:i,regions:c});break}case"getRefNameAliases":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const c=await s.getRefNameAliases(r);t.workers[0].postMessage({apollo:o,messageId:i,refNameAliases:c});break}}})),t):t))}configure(e){var t;o.isAbstractMenuManager(e.rootModel)&&(e.jexl.addFunction("geneBackgroundColor",(e=>"pseudogene"===e?s.alpha("rgb(148, 203, 236)",.6):"ncRNA_gene"===e?s.alpha("rgb(194, 106, 119)",.6):void 0)),(t=e.rootModel).insertInMenu("Apollo",{label:"Redo",icon:Yh,onClick(e){const{apolloDataStore:t}=e;t.changeManager.redoLastChange()}},0),t.insertInMenu("Apollo",{label:"Undo",icon:Kh,onClick(e){const{apolloDataStore:t}=e;t.changeManager.undoLastChange()}},0),t.appendToMenu("Apollo",{label:"Download GFF3",icon:Jh,onClick:e=>{e.queueDialog((t=>[Gu,{session:e,handleClose:()=>{t()}}]))}}),t.appendToMenu("Apollo",{label:"View Change Log",icon:zh,onClick:e=>{e.queueDialog((t=>[nd,{session:e,handleClose:()=>{t()}}]))}}),t.appendToMenu("Apollo",{label:"Open local GFF3 file",icon:Gh,onClick:e=>{e.queueDialog((t=>[ed,{session:e,handleClose:()=>{t()},inMemoryFileDriver:e.apolloDataStore.inMemoryFileDriver}]))}}),t.appendToMenu("Apollo",{label:"View check results",icon:Uh,onClick:e=>{e.queueDialog((t=>[ad,{session:e,handleClose:()=>{t()}}]))}}),t.appendToMenu("Apollo",{label:"Lock/Unlock session",onClick:e=>{e.toggleLocked()}}),t.appendToMenu("Apollo",{label:"Log out",icon:Hh,onClick:e=>{e.queueDialog((t=>[Yu,{session:e,handleClose:()=>{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/configuration"),require("@jbrowse/core/pluggableElementTypes"),require("@jbrowse/core/util"),require("react/jsx-runtime"),require("@mui/material/utils"),require("@mui/material"),require("@jbrowse/mobx-state-tree"),require("mobx"),require("react"),require("@jbrowse/core/util/types/mst"),require("@jbrowse/core/util/io"),require("@jbrowse/core/ui"),require("mobx-react"),require("@mui/material/styles"),require("@mui/x-data-grid"),require("@jbrowse/core/pluggableElementTypes/AdapterType"),require("@jbrowse/core/data_adapters/BaseAdapter"),require("@jbrowse/core/util/rxjs"),require("@jbrowse/core/util/tracks")):"function"==typeof define&&define.amd?define(["exports","@jbrowse/core/Plugin","@jbrowse/core/configuration","@jbrowse/core/pluggableElementTypes","@jbrowse/core/util","react/jsx-runtime","@mui/material/utils","@mui/material","@jbrowse/mobx-state-tree","mobx","react","@jbrowse/core/util/types/mst","@jbrowse/core/util/io","@jbrowse/core/ui","mobx-react","@mui/material/styles","@mui/x-data-grid","@jbrowse/core/pluggableElementTypes/AdapterType","@jbrowse/core/data_adapters/BaseAdapter","@jbrowse/core/util/rxjs","@jbrowse/core/util/tracks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBrowsePluginApollo={},e.JBrowseExports["@jbrowse/core/Plugin"],e.JBrowseExports["@jbrowse/core/configuration"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes"],e.JBrowseExports["@jbrowse/core/util"],e.JBrowseExports["react/jsx-runtime"],e.JBrowseExports["@mui/material/utils"],e.JBrowseExports["@mui/material"],e.JBrowseExports["@jbrowse/mobx-state-tree"],e.JBrowseExports.mobx,e.JBrowseExports.react,e.JBrowseExports["@jbrowse/core/util/types/mst"],e.JBrowseExports["@jbrowse/core/util/io"],e.JBrowseExports["@jbrowse/core/ui"],e.JBrowseExports["mobx-react"],e.JBrowseExports["@mui/material/styles"],e.JBrowseExports["@mui/x-data-grid"],e.JBrowseExports["@jbrowse/core/pluggableElementTypes/AdapterType"],e.JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],e.JBrowseExports["@jbrowse/core/util/rxjs"],e.JBrowseExports["@jbrowse/core/util/tracks"])}(this,(function(e,t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b){"use strict";function x(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,t}var w=x(u);function S(e,t){this.v=e,this.k=t}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function A(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){A(i,r,o,a,s,"next",e)}function s(e){A(i,r,o,a,s,"throw",e)}a(void 0)}))}}function N(e){return new S(e,0)}function T(e,t,n){return t=F(t),function(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)}(e,L()?Reflect.construct(t,n||[],F(e).constructor):t.apply(e,n))}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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,J(r.key),r)}}function I(e,t,n){return t&&E(e.prototype,t),n&&E(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Y(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function D(e,t,n){return(t=J(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=F(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},O.apply(null,arguments)}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function M(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&H(e,t)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){D(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function q(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)-1===t.indexOf(n=i[r])&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function U(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=Object.create((r&&r.prototype instanceof s?r:s).prototype);return $(l,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),l}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):($(t={},r,(function(){return this})),t),d=c.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,$(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,$(d,"constructor",c),$(c,"constructor",l),l.displayName="GeneratorFunction",$(c,o,"GeneratorFunction"),$(d),$(d,o,"Generator"),$(d,r,(function(){return this})),$(d,"toString",(function(){return"[object Generator]"})),(U=function(){return{w:i,m:f}})()}function $(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}$=function(e,t,n,r){function i(t,n){$(e,t,(function(e){return this._invoke(t,n,e)}))}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},$(e,t,n,r)}function z(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function H(e,t){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(e,t)}function G(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function V(e,t,n,r){var o=O(F(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function W(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function K(e){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},K(e)}function Y(e,t){if(e){if("string"==typeof e)return C(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function X(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof S;Promise.resolve(s?a.v:a).then((function(n){if(s){var l="return"===t?"return":"next";if(!a.k||n.done)return r(l,n);n=e[l](n).value}o(i.done?"return":"normal",n)}),(function(e){r("throw",e)}))}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise((function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))}))},"function"!=typeof e.return&&(this.return=void 0)}function Z(e){var t="function"==typeof Map?new Map:void 0;return Z=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(L())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&H(o,n.prototype),o}(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),H(n,e)},Z(e)}X.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},X.prototype.next=function(e){return this._invoke("next",e)},X.prototype.throw=function(e){return this._invoke("throw",e)},X.prototype.return=function(e){return this._invoke("return",e)};var Q=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ee=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(Q.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}();function te(e){return function(e){return void 0!==e.getInverse}(e)&&void 0!==e.assembly}var ne=new(function(){return I((function e(){R(this,e),D(this,"checks",new Map)}),[{key:"registerCheck",value:function(e,t){if(this.checks.has(e))throw new Error('check "'.concat(e,'" has already been registered'));this.checks.set(e,t)}},{key:"getCheck",value:function(e){var t=this.checks.get(e);if(!t)throw new Error('No check constructor registered for "'.concat(e,'"'));return t}},{key:"getChecks",value:function(){return this.checks}}])}()),re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ie="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ae={env:{}},se=[],le=[],ce="undefined"!=typeof Uint8Array?Uint8Array:Array,ue=!1;function de(){ue=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)se[t]=e[t],le[e.charCodeAt(t)]=t;le["-".charCodeAt(0)]=62,le["_".charCodeAt(0)]=63}function fe(e,t,n){for(var r,o=[],i=t;i<n;i+=3)o.push(se[(r=(e[i]<<16)+(e[i+1]<<8)+e[i+2])>>18&63]+se[r>>12&63]+se[r>>6&63]+se[63&r]);return o.join("")}function he(e,t,n,r,o){var i,a,s=8*o-r-1,l=(1<<s)-1,c=l>>1,u=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,i=h&(1<<-u)-1,h>>=-u,u+=s;u>0;i=256*i+e[t+d],d+=f,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=f,u-=8);if(0===i)i=1-c;else{if(i===l)return a?NaN:Infinity*(h?-1:1);a+=Math.pow(2,r),i-=c}return(h?-1:1)*a*Math.pow(2,i-r)}function pe(e,t,n,r,o,i){var a,s,l,c=8*i-o-1,u=(1<<c)-1,d=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?f/l:f*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,o),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&s,h+=p,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;e[n+h]=255&a,h+=p,a/=256,c-=8);e[n+h-p]|=128*g}var ge={}.toString,me=Array.isArray||function(e){return"[object Array]"==ge.call(e)};function ye(){return ve.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _e(e,t){if(ye()<t)throw new RangeError("Invalid typed array length");return ve.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ve.prototype:(null===e&&(e=new ve(t)),e.length=t),e}function ve(e,t,n){if(!(ve.TYPED_ARRAY_SUPPORT||this instanceof ve))return new ve(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return we(this,e)}return be(this,e,t,n)}function be(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),ve.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ve.prototype:e=Se(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!ve.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ke(t,n),o=(e=_e(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(Ae(t)){var n=0|Ce(t.length);return 0===(e=_e(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?_e(e,0):Se(e,t);if("Buffer"===t.type&&me(t.data))return Se(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function xe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function we(e,t){if(xe(t),e=_e(e,t<0?0:0|Ce(t)),!ve.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Se(e,t){var n=t.length<0?0:0|Ce(t.length);e=_e(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Ce(e){if(e>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ae(e){return!(null==e||!e._isBuffer)}function ke(e,t){if(Ae(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return nt(e).length;default:if(r)return tt(e).length;t=(""+t).toLowerCase(),r=!0}}function Ne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return $e(this,t,n);case"utf8":case"utf-8":return Pe(this,t,n);case"ascii":return qe(this,t,n);case"latin1":case"binary":return Ue(this,t,n);case"base64":return Le(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ze(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Te(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Re(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=ve.from(t,r)),Ae(t))return 0===t.length?-1:Ee(e,t,n,r,o);if("number"==typeof t)return t&=255,ve.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Ee(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Ee(e,t,n,r,o){var i,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(i=n;i<s;i++)if(c(e,i)===c(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*a}else-1!==u&&(i-=i-u),u=-1}else for(n+l>s&&(n=s-l),i=n;i>=0;i--){for(var d=!0,f=0;f<l;f++)if(c(e,i+f)!==c(t,f)){d=!1;break}if(d)return i}return-1}function Ie(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function je(e,t,n,r){return rt(tt(t,e.length-n),e,n,r)}function De(e,t,n,r){return rt(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Oe(e,t,n,r){return De(e,t,n,r)}function Fe(e,t,n,r){return rt(nt(t),e,n,r)}function Me(e,t,n,r){return rt(function(e,t){for(var n,r,o=[],i=0;i<e.length&&!((t-=2)<0);++i)r=(n=e.charCodeAt(i))>>8,o.push(n%256),o.push(r);return o}(t,e.length-n),e,n,r)}function Le(e,t,n){return function(e){var t;ue||de();for(var n=e.length,r=n%3,o="",i=[],a=16383,s=0,l=n-r;s<l;s+=a)i.push(fe(e,s,s+a>l?l:s+a));return 1===r?(o+=se[(t=e[n-1])>>2],o+=se[t<<4&63],o+="=="):2===r&&(o+=se[(t=(e[n-2]<<8)+e[n-1])>>10],o+=se[t>>4&63],o+=se[t<<2&63],o+="="),i.push(o),i.join("")}(0===t&&n===e.length?e:e.slice(t,n))}function Pe(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,a,s,l,c=e[o],u=null,d=c>239?4:c>223?3:c>191?2:1;if(o+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(i=e[o+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:a=e[o+2],128==(192&(i=e[o+1]))&&128==(192&a)&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=e[o+2],s=e[o+3],128==(192&(i=e[o+1]))&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(r.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=d}return function(e){var t=e.length;if(t<=Be)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Be));return n}(r)}ve.TYPED_ARRAY_SUPPORT=void 0===ie.TYPED_ARRAY_SUPPORT||ie.TYPED_ARRAY_SUPPORT,ve.poolSize=8192,ve._augment=function(e){return e.__proto__=ve.prototype,e},ve.from=function(e,t,n){return be(null,e,t,n)},ve.TYPED_ARRAY_SUPPORT&&(ve.prototype.__proto__=Uint8Array.prototype,ve.__proto__=Uint8Array),ve.alloc=function(e,t,n){return function(e,t,n,r){return xe(t),t<=0?_e(e,t):void 0!==n?"string"==typeof r?_e(e,t).fill(n,r):_e(e,t).fill(n):_e(e,t)}(null,e,t,n)},ve.allocUnsafe=function(e){return we(null,e)},ve.allocUnsafeSlow=function(e){return we(null,e)},ve.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ot(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ot(e.slice(0,0))}(e))},ve.compare=function(e,t){if(!Ae(e)||!Ae(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},ve.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},ve.concat=function(e,t){if(!me(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ve.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=ve.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!Ae(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},ve.byteLength=ke,ve.prototype._isBuffer=!0,ve.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Te(this,t,t+1);return this},ve.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Te(this,t,t+3),Te(this,t+1,t+2);return this},ve.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Te(this,t,t+7),Te(this,t+1,t+6),Te(this,t+2,t+5),Te(this,t+3,t+4);return this},ve.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Pe(this,0,e):Ne.apply(this,arguments)},ve.prototype.equals=function(e){if(!Ae(e))throw new TypeError("Argument must be a Buffer");return this===e||0===ve.compare(this,e)},ve.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ve.prototype.compare=function(e,t,n,r,o){if(!Ae(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(i,a),l=this.slice(r,o),c=e.slice(t,n),u=0;u<s;++u)if(l[u]!==c[u]){i=l[u],a=c[u];break}return i<a?-1:a<i?1:0},ve.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},ve.prototype.indexOf=function(e,t,n){return Re(this,e,t,n,!0)},ve.prototype.lastIndexOf=function(e,t,n){return Re(this,e,t,n,!1)},ve.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Ie(this,e,t,n);case"utf8":case"utf-8":return je(this,e,t,n);case"ascii":return De(this,e,t,n);case"latin1":case"binary":return Oe(this,e,t,n);case"base64":return Fe(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Me(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},ve.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Be=4096;function qe(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Ue(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function $e(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=et(e[i]);return o}function ze(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function He(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,n,r,o,i){if(!Ae(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Ve(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function We(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function Je(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ke(e,t,n,r,o){return o||Je(e,0,n,4),pe(e,t,n,r,23,4),n+4}function Ye(e,t,n,r,o){return o||Je(e,0,n,8),pe(e,t,n,r,52,8),n+8}ve.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),ve.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=ve.prototype;else{var o=t-e;n=new ve(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},ve.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},ve.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},ve.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},ve.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},ve.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},ve.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ve.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ve.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},ve.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||He(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},ve.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ve.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},ve.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ve.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ve.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),he(this,e,!0,23,4)},ve.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),he(this,e,!1,23,4)},ve.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),he(this,e,!0,52,8)},ve.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),he(this,e,!1,52,8)},ve.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},ve.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ge(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},ve.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,255,0),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ve.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,65535,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):We(this,e,t,!0),t+4},ve.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,4294967295,0),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i<n&&(a*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Ge(this,e,t,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},ve.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,1,127,-128),ve.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ve.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ve(this,e,t,!0),t+2},ve.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,2,32767,-32768),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ve(this,e,t,!1),t+2},ve.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),ve.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):We(this,e,t,!0),t+4},ve.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ve.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):We(this,e,t,!1),t+4},ve.prototype.writeFloatLE=function(e,t,n){return Ke(this,e,t,!0,n)},ve.prototype.writeFloatBE=function(e,t,n){return Ke(this,e,t,!1,n)},ve.prototype.writeDoubleLE=function(e,t,n){return Ye(this,e,t,!0,n)},ve.prototype.writeDoubleBE=function(e,t,n){return Ye(this,e,t,!1,n)},ve.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!ve.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},ve.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!ve.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var a=Ae(e)?e:tt(new ve(e,r).toString()),s=a.length;for(i=0;i<n-t;++i)this[i+t]=a[i%s]}return this};var Xe,Ze,Qe=/[^+\/0-9A-Za-z-_]/g;function et(e){return e<16?"0"+e.toString(16):e.toString(16)}function tt(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function nt(e){return function(e){var t,n,r,o,i,a;ue||de();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=new ce(3*s/4-(i="="===e[s-2]?2:"="===e[s-1]?1:0)),r=i>0?s-4:s;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)o=le[e.charCodeAt(t)]<<18|le[e.charCodeAt(t+1)]<<12|le[e.charCodeAt(t+2)]<<6|le[e.charCodeAt(t+3)],a[l++]=o>>16&255,a[l++]=o>>8&255,a[l++]=255&o;return 2===i?(o=le[e.charCodeAt(t)]<<2|le[e.charCodeAt(t+1)]>>4,a[l++]=255&o):1===i&&(o=le[e.charCodeAt(t)]<<10|le[e.charCodeAt(t+1)]<<4|le[e.charCodeAt(t+2)]>>2,a[l++]=o>>8&255,a[l++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Qe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function rt(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ot(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var it=function(){if(Ze)return Xe;Ze=1;for(var e=Math.floor(16777215*Math.random()),t=c.index=parseInt(16777215*Math.random(),10),n=(void 0===ae||"number"!=typeof ae.pid?Math.floor(1e5*Math.random()):ae.pid)%65535,r=function(){try{return _Buffer}catch(e){try{return ve}catch(e){return null}}}(),o=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))},i=[],a=0;a<256;a++)i[a]=(a<=15?"0":"")+a.toString(16);var s=new RegExp("^[0-9a-fA-F]{24}$"),l=[];for(a=0;a<10;)l[48+a]=a++;for(;a<16;)l[55+a]=l[87+a]=a++;function c(e){if(!(this instanceof c))return new c(e);if(e&&(e instanceof c||"ObjectID"===e._bsontype))return e;if(this._bsontype="ObjectID",null!=e&&"number"!=typeof e){var t=c.isValid(e);if(!t&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(t&&"string"==typeof e&&24===e.length)return c.createFromHexString(e);if(null==e||12!==e.length){if(null!=e&&"function"==typeof e.toHexString)return e;throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=e}else this.id=this.generate(e)}Xe=c,c.default=c,c.createFromTime=function(e){return new c(function(e,t){return 8===(t=t.toString(16)).length?t:"00000000".substring(t.length,8)+t}(0,e=parseInt(e,10)%4294967295)+"0000000000000000")},c.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");for(var t="",n=0;n<24;)t+=String.fromCharCode(l[e.charCodeAt(n++)]<<4|l[e.charCodeAt(n++)]);return new c(t)},c.isValid=function(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&s.test(e):e instanceof c||(o(e)?c.isValid(e.toString("hex")):!("function"!=typeof e.toHexString||!r||!(e.id instanceof r||"string"==typeof e.id))&&(12===e.id.length||24===e.id.length&&s.test(e.id)))))},c.prototype={constructor:c,toHexString:function(){if(!this.id||!this.id.length)throw new Error("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(24===this.id.length)return this.id;if(o(this.id))return this.id.toString("hex");for(var e="",t=0;t<this.id.length;t++)e+=i[this.id.charCodeAt(t)];return e},equals:function(e){return e instanceof c?this.toString()===e.toString():"string"==typeof e&&c.isValid(e)&&12===e.length&&o(this.id)?e===this.id.toString("binary"):"string"==typeof e&&c.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&c.isValid(e)&&12===e.length?e===this.id:!(null==e||!(e instanceof c||e.toHexString))&&e.toHexString()===this.toHexString()},getTimestamp:function(){var e,t=new Date;return e=o(this.id)?this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24:this.id.charCodeAt(3)|this.id.charCodeAt(2)<<8|this.id.charCodeAt(1)<<16|this.id.charCodeAt(0)<<24,t.setTime(1e3*Math.floor(e)),t},generate:function(r){"number"!=typeof r&&(r=~~(Date.now()/1e3)),r=parseInt(r,10)%4294967295;var o=t=(t+1)%16777215;return String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,255&r,e>>16&255,e>>8&255,255&e,n>>8&255,255&n,o>>16&255,o>>8&255,255&o)}};var u=Symbol&&Symbol.for&&Symbol.for("nodejs.util.inspect.custom")||"inspect";return c.prototype[u]=function(){return"ObjectID("+this+")"},c.prototype.toJSON=c.prototype.toHexString,c.prototype.toString=c.prototype.toHexString,Xe}(),at=oe(it);function st(e){return te(e)&&void 0!==e.changedIds}var lt=new(function(){return I((function e(){R(this,e),D(this,"changes",new Map)}),[{key:"registerChange",value:function(e,t){if(this.changes.has(e))throw new Error('change type "'.concat(e,'" has already been registered'));this.changes.set(e,t)}},{key:"getChangeType",value:function(e){var t=this.changes.get(e);if(!t)throw new Error('No change constructor registered for "'.concat(e,'"'));return t}}])}()),ct=function(){return I((function e(t,n){var r;R(this,e),D(this,"logger",void 0),this.logger=null!==(r=null==n?void 0:n.logger)&&void 0!==r?r:console}),[{key:"notification",get:function(){return""}}],[{key:"fromJSON",value:function(e,t){return new(lt.getChangeType(e.typeName))(e,(null==t?void 0:t.logger)&&{logger:t.logger})}}])}(),ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"assembly",void 0),r.assembly=e.assembly,r}return M(t,e),I(t,[{key:"getIndexedIds",value:function(e,t){var n,r=[],o=j(null!=t?t:[]);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=e.attributes,s=a instanceof Map?a.get(i):null==a?void 0:a[i];null!=s&&s[0]&&r.push(s[0])}}catch(e){o.e(e)}finally{o.f()}if(e.children){var l,c=j(e.children instanceof Map?e.children.values():Object.values(e.children));try{for(c.s();!(l=c.n()).done;){var u=this.getIndexedIds(l.value,t);r.push.apply(r,W(u))}}catch(e){c.e(e)}finally{c.f()}}return r}}])}(ct),dt=I((function e(){R(this,e)})),ft=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"changedIds",void 0),r.changedIds=e.changedIds,r}return M(t,e),I(t,[{key:"getFeatureFromId",value:function(e,t){var n,r,o,i,a=this.logger;if(null===(n=a.verbose)||void 0===n||n.call(a,"Entry=".concat(JSON.stringify(e))),e._id.equals(t))return null===(i=a.debug)||void 0===i||i.call(a,"Top level featureId matches in the object ".concat(JSON.stringify(e))),e;null===(r=a.debug)||void 0===r||r.call(a,"FeatureId was not found on top level so lets make recursive call...");var s,l=j(null!==(o=e.children)&&void 0!==o?o:new Map);try{for(l.s();!(s=l.n()).done;){var c=G(s.value,2),u=this.getFeatureFromId(c[1],t);if(u)return u}}catch(e){l.e(e)}finally{l.f()}return null}},{key:"getChildFeatureIds",value:function(e){if(!e.children)return[];var t,n=[],r=j((e.children instanceof Map?e.children:new Map(Object.entries(e.children)))||new Map);try{for(r.s();!(t=r.n()).done;){var o=G(t.value,2);n.push.apply(n,[o[0]].concat(W(this.getChildFeatureIds(o[1]))))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"generateNewIds",value:function(e,t){var n=(new at).toHexString();t.push(n);var r={};if(e.children)for(var o=0,i=Object.values(e.children);o<i.length;o++){var a=this.generateNewIds(i[o],t);r[a._id]=a}var s="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return B(B({},e),{},{refSeq:s,children:e.children&&r,_id:n})}},{key:"addChild",value:function(e,t){var n;if(null===(n=e.attributes)||void 0===n||!n._id){var r=e.attributes;r||(r={}),r=B({_id:[e._id.toString()]},JSON.parse(JSON.stringify(r))),e.attributes=r}var o=t._id;e.children||(e.children=new Map),e.children.set(o,B(B({allIds:[]},t),{},{_id:o})),e.children=new Map(W(e.children.entries()).sort((function(e,t){return e[1].min-t[1].min})))}},{key:"findAndDeleteChildFeature",value:function(e,t){if(!e.children)throw new Error("Feature ".concat(e._id.toHexString()," has no children"));var n=e._id,r=e.children,o=r.get(t);if(o){var i=this.getChildFeatureIds(o);return r.delete(t),i}var a,s=j(r);try{for(s.s();!(a=s.n()).done;){var l=G(a.value,2)[1];try{return this.findAndDeleteChildFeature(l,t)}catch(e){}}}catch(e){s.e(e)}finally{s.f()}throw new Error('Feature "'.concat(t,'" not found in ').concat(n.toHexString()))}}])}(ut),ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature added successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,addedFeature:o.addedFeature,parentFeatureId:o.parentFeatureId,copyFeature:o.copyFeature,allIds:o.allIds}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{deletedFeature:e.addedFeature,parentFeatureId:e.parentFeatureId}}));return new pt({changedIds:r,typeName:"DeleteFeatureChange",changes:o,assembly:e},{logger:n})}}])}(ft),pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteFeatureChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Feature deleted successfully"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,deletedFeature:o.deletedFeature,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{addedFeature:e.deletedFeature,parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new ht({changedIds:o,typeName:"AddFeatureChange",changes:i,assembly:t},{logger:r})}}])}(ft),gt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAliasesChange"),D(r,"aliases",void 0),r.aliases=e.aliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,aliases:this.aliases}}},{key:"notification",get:function(){return"Assembly aliases have been added."}}])}(ut),mt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyAndFeaturesFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),yt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromExternalChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,externalLocation:r.externalLocation}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),_t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddAssemblyFromFileChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.changes[0].assemblyName,'" added successfully. To use it, please refresh the page.')}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.typeName;if(1===t.length){var r=G(t,1)[0];return{typeName:n,assembly:e,assemblyName:r.assemblyName,fileIds:r.fileIds}}return{typeName:n,assembly:e,changes:t}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),vt=function(e){function t(e,n){var r,o;return R(this,t),D(o=T(this,t,[e,n]),"typeName","AddFeaturesFromFileChange"),D(o,"changes",void 0),D(o,"deleteExistingFeatures",!1),o.deleteExistingFeatures=null!==(r=e.deleteExistingFeatures)&&void 0!==r&&r,o.changes="changes"in e?e.changes:[e],o}return M(t,e),I(t,[{key:"notification",get:function(){return"Features have been added. To see them, please refresh the page."}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changes,n=this.deleteExistingFeatures,r=this.typeName;return 1===t.length?{typeName:r,assembly:e,fileId:G(t,1)[0].fileId,deleteExistingFeatures:n}:{typeName:r,assembly:e,changes:t,deleteExistingFeatures:n}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,assembly:this.assembly},{logger:this.logger})}}])}(ut),bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","AddRefSeqAliasesChange"),D(r,"refSeqAliases",void 0),r.refSeqAliases=e.refSeqAliases,r}return M(t,e),I(t,[{key:"getInverse",value:function(){throw new Error("Method not implemented.")}},{key:"toJSON",value:function(){return{assembly:this.assembly,typeName:this.typeName,refSeqAliases:this.refSeqAliases}}},{key:"notification",get:function(){return"RefSeq aliases have been added."}}])}(ut),xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"typeName","DeleteAssemblyChange"),e}return M(t,e),I(t,[{key:"notification",get:function(){return'Assembly "'.concat(this.assembly,'" deleted successfully.')}},{key:"toJSON",value:function(){return{typeName:this.typeName,assembly:this.assembly}}},{key:"getInverse",value:function(){return new t({typeName:"DeleteAssemblyChange",assembly:this.assembly},{logger:this.logger})}}])}(ut),wt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","DeleteUserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,userId:this.userId}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,userId:this.userId},{logger:this.logger})}}])}(ct),St=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","FeatureAttributeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldAttributes:o.oldAttributes,newAttributes:o.newAttributes}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger;return new t({changedIds:W(this.changedIds).reverse(),typeName:"FeatureAttributeChange",changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldAttributes:e.newAttributes,newAttributes:e.oldAttributes}})),assembly:e},{logger:r})}}])}(ft),Ct=["__v","_id","assemblies","configuration","internetAccounts","plugins","tracks"],At=["hasRole"];function kt(e){var t,n=e.assemblies,r=e.configuration,o=e.internetAccounts,i=e.plugins,a=e.tracks,s=q(e,Ct);if(n&&(s.assemblies=n.filter((function(e){return"ApolloSequenceAdapter"!==e.sequence.adapter.type}))),null!=r&&null!==(t=r.ApolloPlugin)&&void 0!==t&&t.hasRole){var l=q(r.ApolloPlugin,At);s.configuration=B(B({},r),{},{ApolloPlugin:l})}return o&&(s.internetAccounts=o.filter((function(e){return"ApolloInternetAccount"!==e.type}))),i&&(s.plugins=i.filter((function(e){return"Apollo"!==e.name}))),a&&(s.tracks=a.filter((function(e){return"ApolloTrack"!==e.type}))),s}var Nt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","ImportJBrowseConfigChange"),D(r,"oldJBrowseConfig",void 0),D(r,"newJBrowseConfig",void 0),r.oldJBrowseConfig=e.oldJBrowseConfig,r.newJBrowseConfig=e.newJBrowseConfig,r}return M(t,e),I(t,[{key:"toJSON",value:function(){return{typeName:this.typeName,oldJBrowseConfig:this.oldJBrowseConfig,newJBrowseConfig:this.newJBrowseConfig}}},{key:"getInverse",value:function(){return new t({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:this.newJBrowseConfig,newJBrowseConfig:this.oldJBrowseConfig},{logger:this.logger})}}])}(ct),Tt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationEndChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldEnd:o.oldEnd,newEnd:o.newEnd}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldEnd:e.newEnd,newEnd:e.oldEnd}})),assembly:e},{logger:r})}}])}(ft);function Rt(e){return"LocationEndChange"===e.typeName}var Et=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","LocationStartChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStart:o.oldStart,newStart:o.newStart}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStart:e.newStart,newStart:e.oldStart}})),assembly:e},{logger:r})}}])}(ft);function It(e){return"LocationStartChange"===e.typeName}var jt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exons successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstExon:o.firstExon,secondExon:o.secondExon,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonsToRestore:[e.firstExon,e.secondExon],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Dt({changedIds:o,typeName:"UndoMergeExonsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Dt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeExonsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonsToRestore:o.exonsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstExon:e.exonsToRestore[0],secondExon:e.exonsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new jt({changedIds:r,typeName:"MergeExonsChange",changes:o,assembly:e},{logger:n})}}])}(ft);function Ot(e,t){for(var n=[],r=0;r<e.length;r+=t){var o=e.slice(r,r+t);n.push(o)}return n}function Ft(e){var t,n,r=e,o=null===(t=r.attributes.get("gff_id"))||void 0===t?void 0:t.join(",");if(o)return"ID=".concat(o," (_id: ").concat(e._id.toString(),")");var i=null===(n=r.attributes.get("gff_name"))||void 0===n?void 0:n.join(",");return i?"Name=".concat(i," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}function Mt(e){var t={};if(!e)return t;for(var n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1];t[o[0]]=null==i?void 0:i.slice()}return t}function Lt(e){if(!e)return"";for(var t=[],n=0,r=Object.entries(e);n<r.length;n++){var o=G(r[n],2),i=o[1],a=o[0];a.startsWith("gff_")&&(a=(a=a.slice(4)).charAt(0).toUpperCase()+a.slice(1)),t.push(i?"".concat(a,"=").concat(i.join(",")):a)}return encodeURIComponent(t.join(";"))}var Pt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","MergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Transcripts successfully merged"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,firstTranscript:o.firstTranscript,secondTranscript:o.secondTranscript,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"mergeTranscriptsOnServer",value:function(e,t){e.min=Math.min(e.min,t.min),e.max=Math.max(e.max,t.max);var n=e.attributes?JSON.parse(JSON.stringify(e.attributes)):{};if(t.attributes&&(Object.keys(n).includes("merged_with")||(n.merged_with=[]),n.merged_with.push(Lt(Mt(t.attributes)))),e.attributes=n,t.children)for(var r=0,o=Object.entries(t.children);r<o.length;r++){var i=G(o[r],2);this.mergeFeatureIntoTranscriptOnServer(i[1],e)}}},{key:"mergeFeatureIntoTranscriptOnServer",value:function(e,t){var n=this;t.children||(t.children=new Map);var r,i,a,s=!1,l=j(t.children);try{for(l.s();!(a=l.n()).done;){var c=G(a.value,2)[1];if(s&&r?i=!0:(i=!1,r=c),r.type===e.type&&r.type===c.type&&o.doesIntersect2(e.min,e.max,r.min,r.max)&&o.doesIntersect2(c.min,c.max,r.min,r.max)){r.min=Math.min(e.min,r.min,c.min),r.max=Math.max(e.max,r.max,c.max),r.attributes||(r.attributes={});var u=JSON.parse(JSON.stringify(r.attributes));Object.keys(u).includes("merged_with")||(u.merged_with=[]);var d=u.merged_with;if(d.push(Lt(Mt(e.attributes))),i){var f=c.attributes?JSON.parse(JSON.stringify(c.attributes)):void 0;d.push(Lt(f)),t.children.delete(c._id.toString())}u.merged_with=W(new Set(d)),r.attributes=u,s=!0}}}catch(e){l.e(e)}finally{l.f()}s&&r&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);n.addChild(r,t[1])})),this.addChild(t,s&&r?r:e)}},{key:"mergeTranscriptsOnClient",value:function(e,t){var n,r;e.setMin(Math.min(e.min,t.min)),e.setMax(Math.max(e.max,t.max));var o=null!==(n=null===(r=e.attributes.get("merged_with"))||void 0===r?void 0:r.slice())&&void 0!==n?n:[],i=Lt(Mt(t.attributes));if(o.includes(i)||o.push(i),e.setAttribute("merged_with",o),t.children)for(var a=0,s=Object.entries(t.children);a<s.length;a++){var l=G(s[a],2);this.mergeFeatureIntoTranscriptOnClient(l[1],e)}}},{key:"mergeFeatureIntoTranscriptOnClient",value:function(e,t){t.children||(t.children=new Map);var n,r,i,a=!1,s=j(t.children);try{for(s.s();!(i=s.n()).done;){var c=G(i.value,2)[1];if(a&&n?r=!0:(r=!1,n=c),n.type===e.type&&n.type===c.type&&o.doesIntersect2(e.min,e.max,n.min,n.max)&&o.doesIntersect2(c.min,c.max,n.min,n.max)){var u,d;n.setMin(Math.min(e.min,n.min,c.min)),n.setMax(Math.max(e.max,n.max,c.max));var f=null!==(u=null===(d=n.attributes.get("merged_with"))||void 0===d?void 0:d.slice())&&void 0!==u?u:[];f.push(Lt(Mt(e.attributes))),r&&(f.push(Lt(l.getSnapshot(c).attributes)),t.deleteChild(c._id)),n.setAttribute("merged_with",W(new Set(f))),a=!0}}}catch(e){s.e(e)}finally{s.f()}a&&n&&e.children&&Object.entries(e.children).map((function(e){var t=G(e,2);n.addChild(t[1])})),t.addChild(a&&n?l.getSnapshot(n):e)}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{transcriptsToRestore:[e.firstTranscript,e.secondTranscript],parentFeatureId:e.parentFeatureId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Bt({changedIds:o,typeName:"UndoMergeTranscriptsChange",changes:i,assembly:t},{logger:r})}}])}(ft),Bt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoMergeTranscriptsChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,transcriptsToRestore:o.transcriptsToRestore,parentFeatureId:o.parentFeatureId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{firstTranscript:e.transcriptsToRestore[0],secondTranscript:e.transcriptsToRestore[1],parentFeatureId:e.parentFeatureId}}));return new Pt({changedIds:r,typeName:"MergeTranscriptsChange",changes:o,assembly:e},{logger:n})}}])}(ft),qt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","SplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"notification",get:function(){return"Exon successfully split"}},{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToBeSplit:o.exonToBeSplit,parentFeatureId:o.parentFeatureId,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e,t=this.assembly,n=this.changes,r=this.logger,o=W(this.changedIds).reverse(),i=W(n).reverse().map((function(e){return{exonToRestore:e.exonToBeSplit,parentFeatureId:e.parentFeatureId,idsToDelete:[e.leftExonId,e.rightExonId],upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return null===(e=r.debug)||void 0===e||e.call(r,"INVERSE CHANGE '".concat(JSON.stringify(i),"'")),new Ut({changedIds:o,typeName:"UndoSplitExonChange",changes:i,assembly:t},{logger:r})}},{key:"makeSplitExons",value:function(e,t,n,r,o){var i=JSON.parse(JSON.stringify(e));delete i.attributes._id,delete i.attributes.gff_id;var a=structuredClone(i);a._id=r,a.max=t;var s=structuredClone(i);return s.min=n,s._id=o,[a,s]}}])}(ft),Ut=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UndoSplitExonChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,exonToRestore:o.exonToRestore,parentFeatureId:o.parentFeatureId,idsToDelete:o.idsToDelete,upstreamCut:o.upstreamCut,downstreamCut:o.downstreamCut,leftExonId:o.leftExonId,rightExonId:o.rightExonId}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,t=this.changes,n=this.logger,r=W(this.changedIds).reverse(),o=W(t).reverse().map((function(e){return{parentFeatureId:e.parentFeatureId,exonToBeSplit:e.exonToRestore,upstreamCut:e.upstreamCut,downstreamCut:e.downstreamCut,leftExonId:e.leftExonId,rightExonId:e.rightExonId}}));return new qt({changedIds:r,typeName:"SplitExonChange",changes:o,assembly:e},{logger:n})}}])}(ft),$t=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","StrandChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldStrand:o.oldStrand,newStrand:o.newStrand}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldStrand:e.newStrand,newStrand:e.oldStrand}})),assembly:e},{logger:r})}}])}(ft),zt=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","TypeChange"),D(r,"changes",void 0),r.changes="changes"in e?e.changes:[e],r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.assembly,t=this.changedIds,n=this.changes,r=this.typeName;if(1===n.length){var o=G(n,1)[0];return{typeName:r,changedIds:t,assembly:e,featureId:o.featureId,oldType:o.oldType,newType:o.newType}}return{typeName:r,changedIds:t,assembly:e,changes:n}}},{key:"getInverse",value:function(){var e=this.assembly,n=this.changes,r=this.logger,o=this.typeName;return new t({changedIds:W(this.changedIds).reverse(),typeName:o,changes:W(n).reverse().map((function(e){return{featureId:e.featureId,oldType:e.newType,newType:e.oldType}})),assembly:e},{logger:r})}}])}(ft),Ht=function(e){function t(e,n){var r;return R(this,t),D(r=T(this,t,[e,n]),"typeName","UserChange"),D(r,"changes",void 0),D(r,"userId",void 0),r.changes="changes"in e?e.changes:[e],r.userId=e.userId,r}return M(t,e),I(t,[{key:"toJSON",value:function(){var e=this.changes,t=this.typeName,n=this.userId;return 1===e.length?{typeName:t,userId:n,role:G(e,1)[0].role}:{typeName:t,userId:n,changes:e}}},{key:"getInverse",value:function(){return new t({typeName:this.typeName,changes:this.changes,userId:this.userId},{logger:this.logger})}}])}(ct),Gt=B(B({},{AddFeatureChange:ht,DeleteFeatureChange:pt,FeatureAttributeChange:St,LocationEndChange:Tt,LocationStartChange:Et,MergeExonsChange:jt,SplitExonChange:qt,MergeTranscriptsChange:Pt,UndoMergeExonsChange:Dt,UndoSplitExonChange:Ut,UndoMergeTranscriptsChange:Bt,StrandChange:$t,TypeChange:zt}),{},{AddAssemblyAndFeaturesFromFileChange:mt,AddAssemblyFromFileChange:_t,AddAssemblyFromExternalChange:yt,AddFeaturesFromFileChange:vt,DeleteAssemblyChange:xt,DeleteUserChange:wt,ImportJBrowseConfigChange:Nt,UserChange:Ht,AddRefSeqAliasesChange:bt,AddAssemblyAliasesChange:gt}),Vt=function(){return I((function e(){R(this,e)}),[{key:"frontendPreValidate",value:(o=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,{validationName:this.name})}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){return U().w((function(e){for(;;)if(0===e.n)return e.a(2,void 0)}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Wt=function(){return I((function e(){R(this,e),D(this,"results",[]),D(this,"ok",!0)}),[{key:"resultsMessages",get:function(){return this.results.map((function(e){var t;return null===(t=e.error)||void 0===t?void 0:t.message})).filter(Boolean).join(", ")}},{key:"add",value:function(e){this.results.push(e),e.error&&(this.ok=!1)}}])}(),Jt=function(){return I((function e(){R(this,e),D(this,"validations",new Set)}),[{key:"registerValidation",value:function(e){this.validations.add(e)}},{key:"frontendPreValidate",value:(o=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return o.apply(this,arguments)})},{key:"frontendPostValidate",value:(r=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.frontendPostValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return r.apply(this,arguments)})},{key:"backendPreValidate",value:(n=k(U().m((function e(t){var n,r,o,i,a;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=new Wt,r=j(this.validations),e.p=1,r.s();case 2:if((o=r.n()).done){e.n=5;break}return i=o.value,e.n=3,i.backendPreValidate(t);case 3:if(n.add(a=e.v),!a.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,r.e(e.v);case 7:return e.p=7,r.f(),e.f(7);case 8:return e.a(2,n)}}),e,this,[[1,6,7,8]])}))),function(e){return n.apply(this,arguments)})},{key:"backendPostValidate",value:(t=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=new Wt,a=j(this.validations),e.p=1,a.s();case 2:if((s=a.n()).done){e.n=5;break}return l=s.value,e.n=3,l.backendPostValidate(t,{featureModel:r,session:o});case 3:if(i.add(c=e.v),!c.error){e.n=4;break}return e.a(3,5);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,a.e(e.v);case 7:return e.p=7,a.f(),e.f(7);case 8:return e.a(2,i)}}),e,this,[[1,6,7,8]])}))),function(e,n){return t.apply(this,arguments)})},{key:"possibleValues",value:(e=k(U().m((function e(t){var n,r,o,i;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:n=j(this.validations),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=5;break}return o=r.value,e.n=3,o.possibleValues(t);case 3:if(!(i=e.v)){e.n=4;break}return e.a(2,i);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,n.e(e.v);case 7:return e.p=7,n.f(),e.f(7);case 8:return e.a(2)}}),e,this,[[1,6,7,8]])}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o}(),Kt=new Jt,Yt=["2A_self_cleaving_peptide_region","4_methylcytosine","5S_SINE_retrotransposon","5_carboxylcytosine","5_formylcytosine","5_hydroxymethylcytosine","5_methylcytosine","7SL_SINE_retrotransposon","8_oxoadenine","8_oxoguanine","AACCCT_box","AFLP_fragment","AP_1_binding_site","ARIA","ARRET","ARS","ARS_consensus_sequence","ASPE_primer","AUG_initiated_uORF","AU_rich_element","A_box","A_box_type_1","A_box_type_2","A_minor_RNA_motif","A_to_C_transversion","A_to_G_transition","A_to_T_transversion","Ace2_UAS","Alu_deletion","Alu_insertion","BAC","BAC_cloned_genomic_insert","BAC_end","BAC_read_contig","BREd_motif","BREu_motif","B_box","Bel_Pao_LTR_retrotransposon","Bruno_response_element","C-D_H_ACA_box_scaRNA","C-D_H_ACA_box_scaRNA_gene","CAAT_signal","CAAX_box","CACTA_TIR_transposon","CAGE_cluster","CAGE_tag","CArG_box","CCAAT_motif","CCA_tail","CDRE_motif","CDS","CDS_extension","CDS_five_prime_extension","CDS_fragment","CDS_independently_known","CDS_predicted","CDS_region","CDS_supported_by_EST_or_cDNA_data","CDS_supported_by_domain_match_data","CDS_supported_by_peptide_spectrum_match","CDS_supported_by_sequence_similarity_data","CDS_three_prime_extension","CRE","CRISPR","CSL_response_element","CTCF_binding_site","CTG_start_codon","C_D_box_scaRNA","C_D_box_scaRNA_gene","C_D_box_snoRNA","C_D_box_snoRNA_gene","C_D_box_snoRNA_primary_transcript","C_box","C_cluster","C_gene_segment","C_region","C_to_A_transversion","C_to_G_transversion","C_to_T_transition","C_to_T_transition_at_pCpG_site","ChIP_seq_region","Copia_LTR_retrotransposon","CpG_island","Crick_strand","Crypton_YR_transposon","CsrB_RsmB_RNA","CuRE","DArT_marker","DCE","DCE_SI","DCE_SII","DCE_SIII","DDB_box","DHU_loop","DIRS_YR_retrotransposon","DJ_C_cluster","DJ_J_C_cluster","DJ_J_cluster","DJ_gene_segment","DMv1_motif","DMv2_motif","DMv3_motif","DMv4_motif","DMv5_motif","DNA_aptamer","DNA_binding_site","DNA_chromosome","DNA_constraint_sequence","DNA_loop","DNA_loop_anchor","DNA_motif","DNA_sequence_secondary_structure","DNA_transposon","DNAzyme","DNaseI_hypersensitive_site","DPE1_motif","DPE_motif","DRE","DRE_motif","DSR_motif","D_DJ_C_cluster","D_DJ_J_C_cluster","D_DJ_J_cluster","D_DJ_cluster","D_J_C_cluster","D_J_cluster","D_cluster","D_gene_recombination_feature","D_gene_segment","D_loop","DsrA_RNA","ER_retention_signal","EST","EST_match","E_box_motif","Endogenous_Retrovirus_LTR_retrotransposon","FLEX_element","FRE","FRT_site","GAGA_motif","GATA_box","GC_rich_promoter_region","GNA_oligo","GTT_trinucleotide_repeat","GT_dinucleotide_repeat","G_box","G_quartet","G_to_A_transition","G_to_C_transversion","G_to_T_transversion","GcvB_RNA","Gypsy_LTR_retrotransposon","H2AK5_acetylation_site","H2AK9_acetylation_site","H2AZK11_acetylation_site","H2AZK13_acetylation_site","H2AZK15_acetylation_site","H2AZK4_acetylation_site","H2AZK7_acetylation_site","H2BK120_acetylation_site","H2BK12_acetylation_site","H2BK15_acetylation_site","H2BK20_acetylation_site","H2BK5_acetylation_site","H2BK5_monomethylation_site","H2B_ubiquitination_site","H3K14_acetylation_site","H3K18_acetylation_site","H3K20_trimethylation_site","H3K23_acetylation_site","H3K23_dimethylation_site","H3K27_acetylation_site","H3K27_dimethylation_site","H3K27_methylation_site","H3K27_monomethylation_site","H3K27_trimethylation_site","H3K36_acetylation_site","H3K36_dimethylation_site","H3K36_methylation_site","H3K36_monomethylation_site","H3K36_trimethylation_site","H3K4_acetylation_site","H3K4_dimethylation_site","H3K4_methylation_site","H3K4_monomethylation_site","H3K4_trimethylation","H3K56_acetylation_site","H3K79_dimethylation_site","H3K79_methylation_site","H3K79_monomethylation_site","H3K79_trimethylation_site","H3K9_acetylation_site","H3K9_dimethylation_site","H3K9_methylation_site","H3K9_monomethylation_site","H3K9_trimethylation_site","H3R2_dimethylation_site","H3R2_monomethylation_site","H4K12_acetylation_site","H4K16_acetylation_site","H4K20_monomethylation_site","H4K4_trimethylation_site","H4K5_acetylation_site","H4K8_acetylation_site","H4K91_acetylation_site","H4K_acylation_region","H4R3_dimethylation_site","HERV_deletion","HERV_insertion","HSE","H_ACA_box_scaRNA","H_ACA_box_scaRNA_gene","H_ACA_box_snoRNA","H_ACA_box_snoRNA_gene","H_ACA_box_snoRNA_primary_transcript","H_pseudoknot","Hoogsteen_base_pair","I-box","IG_C_gene","IG_C_pseudogene","IG_D_gene","IG_J_gene","IG_J_pseudogene","IG_V_gene","IG_V_pseudogene","INR1_motif","INR_motif","IRLinv_site","IRRinv_site","ISRE","I_LINE_retrotransposon","J_C_cluster","J_cluster","J_gene_recombination_feature","J_gene_segment","J_heptamer","J_nonamer","J_spacer","Jockey_LINE_retrotransposon","KEN_box","K_turn_RNA_motif","L1_LINE_retrotransposon","LARD","LINE1_deletion","LINE1_insertion","LINE_element","LNA_oligo","LOZ1_response_element","LTR_component","LTR_retrotransposon","L_box","MCB","MITE","MNP","MNV","MNV_artifact","MTE","Mat2P","Mat3M","Merlin_TIR_transposon","MicF_RNA","Mutator_TIR_transposon","N2_2_prime_O_dimethylguanosine","N2_7_2prirme_O_trimethylguanosine","N2_7_dimethylguanosine","N2_N2_2_prime_O_trimethylguanosine","N2_N2_7_trimethylguanosine","N2_N2_dimethylguanosine","N2_methylguanosine","N4_2_prime_O_dimethylcytidine","N4_N4_2_prime_O_trimethylcytidine","N4_acetyl_2_prime_O_methylcytidine","N4_acetylcytidine","N4_methylcytidine","N6_2_prime_O_dimethyladenosine","N6_N6_2_prime_O_trimethyladenosine","N6_N6_dimethyladenosine","N6_acetyladenosine","N6_cis_hydroxyisopentenyl_adenosine","N6_glycinylcarbamoyladenosine","N6_hydroxynorvalylcarbamoyladenosine","N6_isopentenyladenosine","N6_methyl_N6_threonylcarbamoyladenosine","N6_methyladenine","N6_methyladenosine","N6_threonylcarbamoyladenosine","NDM2_motif","NDM3_motif","NMD_polymorphic_pseudogene_transcript","NMD_transcript","NSD_transcript","N_region","Ngaro_YR_retrotransposon","ORF","Okazaki_fragment","OxyS_RNA","PAC","PAC_end","PCB","PCR_product","PIF_Harbinger_TIR_transposon","PIP_box","PNA_oligo","PSE_motif","P_TIR_transposon","Penelope_retrotransposon","Phage_RNA_Polymerase_Promoter","Pho7_binding_site","QTL","R2_LINE_retrotransposon","RAPD","RFLP_fragment","RH_map","RNA_6S","RNA_7SK","RNA_7SK_gene","RNA_aptamer","RNA_chromosome","RNA_hook_turn","RNA_internal_loop","RNA_junction_loop","RNA_motif","RNA_polymerase_III_TATA_box","RNA_polymerase_II_TATA_box","RNA_sequence_secondary_structure","RNA_stability_element","RNA_thermometer","RNAi_reagent","RNApol_III_promoter","RNApol_III_promoter_type_1","RNApol_III_promoter_type_2","RNApol_III_promoter_type_3","RNApol_II_core_promoter","RNApol_II_promoter","RNApol_I_promoter","RNase_MRP_RNA","RNase_MRP_RNA_gene","RNase_P_RNA","RNase_P_RNA_gene","RRE_RNA","RR_tract","RST","RST_match","RTE_LINE_retrotransposon","R_GNA_oligo","R_LTR_region","R_five_prime_LTR_region","R_three_prime_LTR_region","Retrovirus_LTR_retrotransposon","Robertsonian_fusion","RprA_RNA","SAGE_tag","SECIS_element","SHP_box","SINE_element","SL10_acceptor_site","SL11_acceptor_site","SL12_acceptor_site","SL1_acceptor_site","SL2_acceptor_site","SL3_acceptor_site","SL4_acceptor_site","SL5_acceptor_site","SL6_acceptor_site","SL7_acceptor_site","SL8_acceptor_site","SL9_acceptor_site","SNP","SNV","SNV_artifact","SP6_RNA_Polymerase_Promoter","SRP_RNA","SRP_RNA_gene","SRP_RNA_primary_transcript","STREP_motif","STS","STS_map","SUMO_interaction_motif","SVA_deletion","SVA_insertion","S_GNA_oligo","S_region","Sap1_recognition_motif","Shine_Dalgarno_sequence","T3_RNA_Polymerase_Promoter","T7_RNA_Polymerase_Promoter","TATA_box","TCS_element","TCT_motif","TERRA","TFRS_collection","TFRS_module","TF_binding_site","TNA_oligo","TRIM","TR_C_Gene","TR_D_Gene","TR_J_Gene","TR_J_pseudogene","TR_V_Gene","TR_V_pseudogene","TR_box","TSS","T_cell_receptor_gene","T_cell_receptor_pseudogene","T_loop","T_to_A_transversion","T_to_C_transition","T_to_G_transversion","Tc1_Mariner_TIR_transposon","Transib_TIR_transposon","U11_snRNA","U12_intron","U12_snRNA","U14_snoRNA","U14_snoRNA_gene","U14_snoRNA_primary_transcript","U1_snRNA","U2_intron","U2_snRNA","U3_LTR_region","U3_five_prime_LTR_region","U3_snoRNA","U3_snoRNA_gene","U3_three_prime_LTR_region","U4_snRNA","U4atac_snRNA","U5_LTR_region","U5_five_prime_LTR_region","U5_snRNA","U5_three_prime_LTR_region","U6_snRNA","U6atac_snRNA","U7_snRNA","UAA_stop_codon_signal","UAG_stop_codon_signal","UGA_stop_codon_signal","UNAAAC_motif","UPD","UST","UST_match","UTR","UTR_intron","UTR_region","U_box","VDJ_C_cluster","VDJ_J_C_cluster","VDJ_J_cluster","VDJ_gene_segment","VD_gene_segment","VJ_C_cluster","VJ_J_C_cluster","VJ_J_cluster","VJ_gene_segment","V_DJ_C_cluster","V_DJ_J_C_cluster","V_DJ_J_cluster","V_DJ_cluster","V_D_DJ_C_cluster","V_D_DJ_J_C_cluster","V_D_DJ_J_cluster","V_D_DJ_cluster","V_D_J_C_cluster","V_D_J_cluster","V_J_C_cluster","V_J_cluster","V_VDJ_C_cluster","V_VDJ_J_C_cluster","V_VDJ_J_cluster","V_VDJ_cluster","V_VJ_C_cluster","V_VJ_J_C_cluster","V_VJ_J_cluster","V_VJ_cluster","V_cluster","V_gene_recombination_feature","V_gene_segment","V_heptamer","V_nonamer","V_region","V_spacer","Viper_YR_retrotransposon","WC_base_pair","W_region","Watson_strand","X_element","X_element_combinatorial_repeat","X_region","YAC","YAC_end","YR_retrotransposon","Y_RNA","Y_RNA_gene","Y_RNA_primary_transcript","Y_prime_element","Y_region","Z1_region","Z2_region","Zas1_recognition_motif","aberrant_processed_transcript","accessible_DNA_region","active_peptide","adaptive_island","alanine","alanine_tRNA_primary_transcript","alanyl_tRNA","allelic_pseudogene","allelic_pseudogenic_rRNA","allelic_pseudogenic_tRNA","allelically_excluded_gene","alpha_beta_motif","alpha_helix","alternate_sequence_site","alternatively_spliced_transcript","amber_stop_codon","ambisense_ssRNA_viral_sequence","amino_acid","amplification_origin","anchor_binding_site","anchor_region","androgen_response_element","anti_ARRET","anticodon","anticodon_loop","antiparallel_beta_strand","antisense_RNA","antisense_lncRNA","antisense_lncRNA_gene","antisense_primary_transcript","apicoplast_chromosome","apicoplast_gene","aptamer","archaeal_intron","archaeosine","arginine","arginine_tRNA_primary_transcript","arginyl_tRNA","asparagine","asparagine_tRNA_primary_transcript","asparaginyl_tRNA","aspartic_acid","aspartic_acid_tRNA_primary_transcript","aspartyl_tRNA","assembly","assembly_component","assembly_error_correction","asx_motif","asx_turn","asx_turn_left_handed_type_one","asx_turn_left_handed_type_two","asx_turn_right_handed_type_one","asx_turn_right_handed_type_two","asymmetric_RNA_internal_loop","attB_site","attC_site","attCtn_site","attI_site","attL_site","attP_site","attR_site","attenuator","autocatalytically_spliced_intron","bacterial_RNApol_promoter","bacterial_RNApol_promoter_sigma54_element","bacterial_RNApol_promoter_sigma_70_element","bacterial_RNApol_promoter_sigma_ecf_element","bacterial_terminator","base","base_call_error_correction","base_pair","beta_bulge","beta_bulge_loop","beta_bulge_loop_five","beta_bulge_loop_six","beta_strand","beta_turn","beta_turn_left_handed_type_one","beta_turn_left_handed_type_two","beta_turn_right_handed_type_one","beta_turn_right_handed_type_two","beta_turn_type_eight","beta_turn_type_six","beta_turn_type_six_a","beta_turn_type_six_a_one","beta_turn_type_six_a_two","beta_turn_type_six_b","bidirectional_promoter","bidirectional_promoter_lncRNA","binding_site","biochemical_region_of_peptide","biological_region","biomaterial_region","biosynthetic_gene_cluster","blocked_reading_frame","blunt_end_restriction_enzyme_cleavage_junction","blunt_end_restriction_enzyme_cleavage_site","boundary_element","branch_site","cDNA_clone","cDNA_match","c_terminal_region","candidate_gene","canonical_five_prime_splice_site","canonical_three_prime_splice_site","cap","capped_mRNA","capped_primary_transcript","cassette_pseudogene","catalytic_residue","catmat_left_handed_four","catmat_left_handed_three","catmat_right_handed_four","catmat_right_handed_three","central_hydrophobic_region_of_signal_peptide","centromere","centromere_DNA_Element_I","centromere_DNA_Element_II","centromere_DNA_Element_III","centromeric_repeat","chimeric_cDNA_clone","chloroplast_DNA_read","chloroplast_chromosome","chromatin_regulatory_region","chromoplast_chromosome","chromoplast_gene","chromosomal_regulatory_element","chromosomal_structural_element","chromosomal_translocation","chromosome","chromosome_arm","chromosome_band","chromosome_breakage_sequence","chromosome_breakpoint","chromosome_part","circular_double_stranded_DNA_chromosome","circular_double_stranded_RNA_chromosome","circular_mRNA","circular_ncRNA","circular_plasmid","circular_single_stranded_DNA_chromosome","circular_single_stranded_RNA_chromosome","cis_acting_homologous_chromosome_pairing_region","cis_regulatory_frameshift_element","cis_regulatory_module","cis_splice_site","class_II_RNA","class_I_RNA","cleaved_for_gpi_anchor_region","cleaved_initiator_methionine","cleaved_peptide_region","clip","clone","clone_end","clone_insert","clone_insert_end","clone_insert_start","cloned_cDNA_insert","cloned_genomic_insert","cloned_region","coding_conserved_region","coding_end","coding_exon","coding_region_of_exon","coding_start","coding_transcript_with_retained_intron","codon","coiled_coil","cointegrated_plasmid","common_fragile_site","complex_chromosomal_rearrangement","complex_operon","complex_regulon","complex_structural_alteration","complex_substitution","compositionally_biased_region_of_peptide","conformational_switch","conjugative_transposon","consensus_AFLP_fragment","consensus_gDNA","consensus_mRNA","consensus_region","conserved_region","constitutive_promoter","contig","contig_collection","contig_read","copy_number_gain","copy_number_loss","copy_number_variation","core_eukaryotic_promoter_element","core_prokaryotic_promoter_element","core_promoter_element","core_viral_promoter_element","cosmid","cross_genome_match","cryptic_gene","cryptic_promoter","cryptic_prophage","cryptic_splice_site","cryptogene","ct_gene","cyanelle_chromosome","cyanelle_gene","cyclic_translocation","cysteine","cysteine_tRNA_primary_transcript","cysteinyl_tRNA","cytoplasmic_polypeptide_region","cytosolic_16S_rRNA","cytosolic_18S_rRNA","cytosolic_23S_rRNA","cytosolic_25S_rRNA","cytosolic_28S_rRNA","cytosolic_2S_rRNA","cytosolic_5S_rRNA","cytosolic_5_8S_rRNA","cytosolic_LSU_rRNA","cytosolic_LSU_rRNA_gene","cytosolic_SSU_rRNA","cytosolic_SSU_rRNA_gene","cytosolic_rRNA","cytosolic_rRNA_16S_gene","cytosolic_rRNA_18S_gene","cytosolic_rRNA_23S_gene","cytosolic_rRNA_25S_gene","cytosolic_rRNA_28S_gene","cytosolic_rRNA_2S_gene","cytosolic_rRNA_5S_gene","cytosolic_rRNA_5_8S_gene","cytosolic_rRNA_gene","dCAPS_primer","databank_entry","decayed_exon","defective_conjugative_transposon","deficient_translocation","deletion","deletion_artifact","deletion_breakpoint","deletion_junction","delins","destruction_box","dg_repeat","dh_repeat","dicistronic_mRNA","dicistronic_primary_transcript","dicistronic_transcript","dif_site","dihydrouridine","dinucleotide_repeat_microsatellite_feature","direct_repeat","direct_tandem_duplication","disabled_reading_frame","dispersed_repeat","distal_duplication","distal_promoter_element","distant_three_prime_recoding_signal","double_stranded_DNA_chromosome","double_stranded_RNA_chromosome","ds_DNA_viral_sequence","ds_RNA_viral_sequence","ds_oligo","duplicated_pseudogene","duplication","duplication_artifact","dye_terminator_read","early_origin_of_replication","edited_CDS","edited_mRNA","edited_transcript","edited_transcript_by_A_to_I_substitution","edited_transcript_feature","editing_block","editing_domain","endogenous_retroviral_gene","endonuclease_spliced_intron","endosomal_localization_signal","engineered_episome","engineered_foreign_gene","engineered_foreign_region","engineered_foreign_repetitive_element","engineered_foreign_transposable_element","engineered_foreign_transposable_element_gene","engineered_fusion_gene","engineered_gene","engineered_insert","engineered_plasmid","engineered_region","engineered_rescue_region","engineered_tag","engineered_transposable_element","enhancer","enhancerRNA","enhancer_binding_site","enhancer_blocking_element","enhancer_bound_by_factor","enhancer_trap_construct","enzymatic_RNA","enzymatic_RNA_gene","epigenetically_modified_gene","epigenetically_modified_region","epigenomically_modified_region","episome","epitope","epoxyqueuosine","eukaryotic_promoter","eukaryotic_terminator","exemplar_mRNA","exon","exon_junction","exon_of_single_exon_gene","exon_region","exonic_splice_enhancer","exonic_splicing_silencer","experimental_feature","experimental_result_region","experimentally_defined_binding_region","expressed_sequence_assembly","expressed_sequence_match","extended_cis_splice_site","extended_intronic_splice_region","external_transcribed_spacer_region","extrachromosomal_mobile_genetic_element","extramembrane_polypeptide_region","fingerprint_map","five_aminomethyl_two_thiouridine","five_carbamoylmethyl_two_prime_O_methyluridine","five_carbamoylmethyluridine","five_carboxyhydroxymethyl_uridine","five_carboxyhydroxymethyl_uridine_methyl_ester","five_carboxymethylaminomethyl_two_prime_O_methyluridine","five_carboxymethylaminomethyl_two_thiouridine","five_carboxymethylaminomethyluridine","five_carboxymethyluridine","five_formyl_two_prime_O_methylcytidine","five_formylcytidine","five_hydroxymethylcytidine","five_hydroxyuridine","five_isopentenylaminomethyl_two_prime_O_methyluridine","five_isopentenylaminomethyl_two_thiouridine","five_isopentenylaminomethyl_uridine","five_methoxycarbonylmethyl_two_prime_O_methyluridine","five_methoxycarbonylmethyl_two_thiouridine","five_methoxycarbonylmethyluridine","five_methoxyuridine","five_methyl_2_thiouridine","five_methylaminomethyl_two_selenouridine","five_methylaminomethyl_two_thiouridine","five_methylaminomethyluridine","five_methylcytidine","five_methyldihydrouridine","five_methyluridine","five_prime_D_heptamer","five_prime_D_nonamer","five_prime_D_recombination_signal_sequence","five_prime_D_spacer","five_prime_EST","five_prime_LTR","five_prime_LTR_component","five_prime_RST","five_prime_UST","five_prime_UTR","five_prime_UTR_intron","five_prime_cis_splice_site","five_prime_clip","five_prime_coding_exon","five_prime_coding_exon_coding_region","five_prime_coding_exon_noncoding_region","five_prime_flanking_region","five_prime_intron","five_prime_noncoding_exon","five_prime_open_reading_frame","five_prime_recoding_site","five_prime_restriction_enzyme_junction","five_prime_sticky_end_restriction_enzyme_cleavage_site","five_prime_terminal_inverted_repeat","five_taurinomethyl_two_thiouridine","five_taurinomethyluridine","five_two_prime_O_dimethylcytidine","five_two_prime_O_dimethyluridine","flanking_region","flanking_repeat","flanking_three_prime_quadruplet_recoding_signal","floxed_gene","foldback_element","foreign_gene","foreign_transposable_element","forkhead_motif","forward_primer","fosmid","four_bp_start_codon","four_demethylwyosine","four_thiouridine","fragile_site","fragment_assembly","functional_candidate_gene","functional_gene_region","fusion_gene","gRNA_gene","galactosyl_queuosine","gamma_turn","gamma_turn_classic","gamma_turn_inverse","gap","gene","gene_array","gene_cassette","gene_cassette_array","gene_component_region","gene_fragment","gene_group","gene_member_region","gene_rearranged_at_DNA_level","gene_segment","gene_silenced_by_DNA_methylation","gene_silenced_by_DNA_modification","gene_silenced_by_RNA_interference","gene_silenced_by_histone_deacetylation","gene_silenced_by_histone_methylation","gene_silenced_by_histone_modification","gene_subarray","gene_trap_construct","gene_with_dicistronic_mRNA","gene_with_dicistronic_primary_transcript","gene_with_dicistronic_transcript","gene_with_edited_transcript","gene_with_mRNA_recoded_by_translational_bypass","gene_with_mRNA_with_frameshift","gene_with_non_canonical_start_codon","gene_with_polyadenylated_mRNA","gene_with_polycistronic_transcript","gene_with_recoded_mRNA","gene_with_start_codon_CUG","gene_with_stop_codon_read_through","gene_with_stop_codon_redefined_as_pyrrolysine","gene_with_stop_codon_redefined_as_selenocysteine","gene_with_trans_spliced_transcript","gene_with_transcript_with_translational_frameshift","genetic_marker","genomic_DNA_contig","genomic_DNA_read","genomic_clone","genomic_island","genomically_contaminated_cDNA_clone","glutamic_acid","glutamic_acid_tRNA_primary_transcript","glutamine","glutamine_tRNA_primary_transcript","glutaminyl_tRNA","glutamyl_tRNA","glycine","glycine_tRNA_primary_transcript","glycyl_tRNA","golden_path","golden_path_fragment","group_1_intron_homing_endonuclease_target_region","group_IIA_intron","group_IIB_intron","group_IIC_intron","group_III_intron","group_II_intron","group_I_intron","guide_RNA","guide_RNA_region","hAT_TIR_transposon","hammerhead_ribozyme","haplotype_block","helitron","helix_turn_helix","heptamer_of_recombination_feature_of_vertebrate_immune_system_gene","heritable_phenotypic_marker","high_identity_region","histidine","histidine_tRNA_primary_transcript","histidyl_tRNA","histone_2AZ_acetylation_site","histone_2A_acetylation_site","histone_2B_acetylation_site","histone_3_acetylation_site","histone_4_acetylation_site","histone_acetylation_site","histone_acylation_region","histone_binding_site","histone_methylation_site","histone_modification","histone_ubiqitination_site","homing_endonuclease_binding_site","homol_D_box","homol_E_box","homologous_chromosome_recognition_and_pairing_locus","homologous_region","hpRNA","hpRNA_gene","hydrophobic_region_of_peptide","hydroxywybutosine","iDNA","i_motif","immature_peptide_region","immunoglobulin_gene","immunoglobulin_pseudogene","immunoglobulin_region","imprinting_control_region","indel_artifact","inducible_promoter","inert_DNA_spacer","inosine","insertion","insertion_artifact","insertion_breakpoint","insertion_sequence","insertion_site","insulator","insulator_binding_site","integrated_mobile_genetic_element","integrated_plasmid","integration_excision_site","integron","intein","intein_encoding_region","interband","interchromosomal_breakpoint","interchromosomal_translocation","intergenic_region","interior_coding_exon","interior_exon","interior_intron","intermediate_element","internal_Shine_Dalgarno_sequence","internal_UTR","internal_eliminated_sequence","internal_guide_sequence","internal_ribosome_entry_site","internal_transcribed_spacer_region","intrachromosomal_breakpoint","intrachromosomal_translocation","intramembrane_polypeptide_region","intrinsically_unstructured_polypeptide_region","introgressed_chromosome_region","intron","intron_base_5","intron_domain","intronic_regulatory_region","intronic_splice_enhancer","intronic_splicing_silencer","invalidated_cDNA_clone","inversion","inversion_breakpoint","inversion_cum_translocation","inversion_site","inversion_site_part","inverted_intrachromosomal_transposition","inverted_repeat","inverted_tandem_duplication","iron_repressed_GATA_element","iron_responsive_element","isoleucine","isoleucine_tRNA_primary_transcript","isoleucyl_tRNA","isomiR","isowyosine","junction","kinetoplast_gene","knob","kozak_sequence","lambda_vector","lariat_intron","late_origin_of_replication","left_handed_peptide_helix","leucine","leucine_tRNA_primary_transcript","leucoplast_chromosome","leucoplast_gene","leucyl_tRNA","ligand_binding_site","ligation_based_read","lincRNA","lincRNA_gene","linear_double_stranded_DNA_chromosome","linear_double_stranded_RNA_chromosome","linear_plasmid","linear_single_stranded_DNA_chromosome","linear_single_stranded_RNA_chromosome","linkage_group","lipoprotein_signal_peptide","lncRNA","lncRNA_gene","lncRNA_primary_transcript","lncRNA_with_retained_intron","loR","locus_control_region","long_terminal_repeat","long_terminal_repeat_transcript","loop","low_complexity_region","loxP_site","lysidine","lysine","lysine_tRNA_primary_transcript","lysosomal_localization_signal","lysyl_tRNA","mRNA","mRNA_contig","mRNA_read","mRNA_recoded_by_codon_redefinition","mRNA_recoded_by_translational_bypass","mRNA_region","mRNA_with_frameshift","mRNA_with_minus_1_frameshift","mRNA_with_minus_2_frameshift","mRNA_with_plus_1_frameshift","mRNA_with_plus_2_frameshift","macronuclear_chromosome","macronucleus_destined_segment","major_TSS","mannosyl_queuosine","match","match_part","maternal_uniparental_disomy","maternally_imprinted_gene","mathematically_defined_repeat","mating_type_M_box","mating_type_region","mating_type_region_motif","mating_type_region_replication_fork_barrier","matrix_attachment_site","mature_protein_region","mature_protein_region_of_CDS","mature_transcript","mature_transcript_region","maxicircle","maxicircle_gene","meiotic_recombination_region","membrane_peptide_loop","membrane_structure","metabolic_island","metal_binding_site","methionine","methionine_tRNA_primary_transcript","methionyl_tRNA","methylated_DNA_base_feature","methylated_adenine","methylated_cytosine","methylation_guide_snoRNA","methylation_guide_snoRNA_gene","methylation_guide_snoRNA_primary_transcript","methylinosine","methylwyosine","miRNA","miRNA_antiguide","miRNA_gene","miRNA_loop","miRNA_primary_transcript","miRNA_primary_transcript_region","miRNA_stem","miRNA_target_site","miR_encoding_Y_RNA_primary_transcript","miR_encoding_lncRNA_primary_transcript","miR_encoding_shRNA_primary_transcript","miR_encoding_snoRNA_primary_transcript","miR_encoding_tRNA_primary_transcript","miR_encoding_vaultRNA_primary_transcript","miRtron","microarray_oligo","micronuclear_chromosome","microsatellite","mini_exon_donor_RNA","mini_gene","minicircle","minicircle_gene","minisatellite","minor_TSS","minus_10_signal","minus_12_signal","minus_1_translational_frameshift","minus_24_signal","minus_2_translational_frameshift","minus_35_signal","mitochondrial_DNA_read","mitochondrial_D_loop","mitochondrial_chromosome","mitochondrial_contig","mitochondrial_control_region","mitochondrial_supercontig","mitochondrial_targeting_signal","mitotic_recombination_region","moR","mobile_element_deletion","mobile_element_insertion","mobile_genetic_element","mobile_intron","modified_DNA_base","modified_L_alanine","modified_L_arginine","modified_L_asparagine","modified_L_aspartic_acid","modified_L_cysteine","modified_L_glutamic_acid","modified_L_glutamine","modified_L_histidine","modified_L_isoleucine","modified_L_leucine","modified_L_lysine","modified_L_methionine","modified_L_phenylalanine","modified_L_proline","modified_L_selenocysteine","modified_L_serine","modified_L_threonine","modified_L_tryptophan","modified_L_tyrosine","modified_L_valine","modified_RNA_base_feature","modified_adenine","modified_adenosine","modified_amino_acid_feature","modified_cytidine","modified_cytosine","modified_glycine","modified_guanine","modified_guanosine","modified_inosine","modified_uridine","molecular_contact_region","monocistronic_mRNA","monocistronic_primary_transcript","monocistronic_transcript","monomeric_repeat","morpholino_oligo","mt_LSU_rRNA","mt_LSU_rRNA_gene","mt_SSU_rRNA","mt_SSU_rRNA_gene","mt_gene","mt_rRNA","mt_rRNA_gene","mt_tRNA","multiplexing_sequence_identifier","mutated_variant_site","mutational_hotspot","n_terminal_region","natural_plasmid","natural_transposable_element","natural_variant_site","ncRNA","ncRNA_gene","nc_conserved_region","nc_primary_transcript","negative_sense_ssRNA_viral_sequence","negatively_autoregulated_gene","nested_repeat","nested_tandem_repeat","nested_transposon","no_output","no_sequence_alteration","non_AUG_initiated_uORF","non_LTR_retrotransposon","non_LTR_retrotransposon_polymeric_tract","non_adjacent_residues","non_allelic_homologous_recombination_region","non_canonical_five_prime_splice_site","non_canonical_start_codon","non_canonical_three_prime_splice_site","non_complimentary_stem","non_cytoplasmic_polypeptide_region","non_processed_pseudogene","non_terminal_residue","non_transcribed_region","nonamer_of_recombination_feature_of_vertebrate_immune_system_gene","noncoding_exon","noncoding_region_of_exon","novel_sequence_insertion","nuclear_chromosome","nuclear_export_signal","nuclear_gene","nuclear_localization_signal","nuclear_mt_pseudogene","nuclear_rim_localization_signal","nuclease_binding_site","nuclease_hypersensitive_site","nuclease_sensitive_site","nucleomorph_gene","nucleomorphic_chromosome","nucleotide_binding_site","nucleotide_cleavage_site","nucleotide_match","nucleotide_motif","nucleotide_to_protein_binding_site","ochre_stop_codon","octamer_motif","oligo","oligo_U_tail","one_methyl_three_three_amino_three_carboxypropyl_pseudouridine","one_methyladenosine","one_methylguanosine","one_methylinosine","one_methylpseudouridine","one_two_prime_O_dimethyladenosine","one_two_prime_O_dimethylguanosine","one_two_prime_O_dimethylinosine","opal_stop_codon","open_chromatin_region","operator","operon","oriC","oriT","oriV","origin_of_replication","orphan_CDS","orthologous_region","outron","overlapping_EST_set","overlapping_feature_set","paired_end_fragment","parallel_beta_strand","paralogous_region","partial_genomic_sequence_assembly","partially_processed_cDNA_clone","paternal_uniparental_disomy","paternally_imprinted_gene","pathogenic_island","peptide_coil","peptide_helix","peptide_localization_signal","peroxywybutosine","phage_sequence","phagemid","phenylalanine","phenylalanine_tRNA_primary_transcript","phenylalanyl_tRNA","pheromone_response_element","phosphorylation_site","piRNA","piRNA_gene","pi_helix","piggyBac_TIR_transposon","plasmid","plasmid_gene","plasmid_vector","plastid_LSU_rRNA","plastid_LSU_rRNA_gene","plastid_SSU_rRNA","plastid_SSU_rRNA_gene","plastid_gene","plastid_rRNA","plastid_rRNA_gene","plus_1_translational_frameshift","plus_2_translational_frameshift","point_centromere","point_mutation","polinton","polyA_primed_cDNA_clone","polyA_sequence","polyA_signal_sequence","polyA_site","polyA_site_cluster","polyadenylated_mRNA","polycistronic_mRNA","polycistronic_primary_transcript","polycistronic_transcript","polymerase_synthesis_read","polymorphic_pseudogene","polymorphic_pseudogene_processed_transcript","polymorphic_pseudogene_with_retained_intron","polypeptide","polypeptide_DNA_contact","polypeptide_binding_motif","polypeptide_calcium_ion_contact_site","polypeptide_catalytic_motif","polypeptide_cobalt_ion_contact_site","polypeptide_conserved_motif","polypeptide_conserved_region","polypeptide_copper_ion_contact_site","polypeptide_domain","polypeptide_iron_ion_contact_site","polypeptide_ligand_contact","polypeptide_magnesium_ion_contact_site","polypeptide_manganese_ion_contact_site","polypeptide_metal_contact","polypeptide_molybdenum_ion_contact_site","polypeptide_motif","polypeptide_nest_left_right_motif","polypeptide_nest_motif","polypeptide_nest_right_left_motif","polypeptide_nickel_ion_contact_site","polypeptide_region","polypeptide_repeat","polypeptide_secondary_structure","polypeptide_sequencing_information","polypeptide_structural_motif","polypeptide_structural_region","polypeptide_tungsten_ion_contact_site","polypeptide_turn_motif","polypeptide_variation_site","polypeptide_zinc_ion_contact_site","polypyrimidine_tract","positional_candidate_gene","positive_sense_ssRNA_viral_sequence","positively_autoregulated_gene","possible_assembly_error","possible_base_call_error","post_translationally_modified_region","post_translationally_regulated_gene","pre_edited_mRNA","pre_edited_region","pre_miRNA","predicted_gene","predicted_transcript","presence_absence_variation","priRNA","primary_transcript","primary_transcript_region","primer","primer_binding_site","primer_match","probe","processed_pseudogene","processed_pseudogenic_rRNA","processed_pseudogenic_tRNA","processed_transcript","prokaryotic_promoter","proline","proline_tRNA_primary_transcript","prolyl_tRNA","promoter","promoter_element","promoter_flanking_region","promoter_targeting_sequence","promoter_trap_construct","propeptide","propeptide_cleavage_site","propeptide_region_of_CDS","prophage","proplastid_gene","protease_site","protein_binding_site","protein_coding_gene","protein_coding_primary_transcript","protein_hmm_match","protein_match","protein_protein_contact","protein_stability_element","proviral_gene","proviral_region","proximal_promoter_element","pseudogene","pseudogene_by_unequal_crossing_over","pseudogene_processed_transcript","pseudogenic_CDS","pseudogenic_exon","pseudogenic_gene_segment","pseudogenic_rRNA","pseudogenic_region","pseudogenic_tRNA","pseudogenic_transcript","pseudogenic_transcript_with_retained_intron","pseudoknot","pseudouridine","pseudouridylation_guide_snoRNA","pseudouridylation_guide_snoRNA_gene","pumilio_response_element","purine_to_pyrimidine_transversion","purine_transition","pyrimidine_to_purine_transversion","pyrimidine_transition","pyrosequenced_read","pyrrolysine","pyrrolysine_tRNA_primary_transcript","pyrrolysyl_tRNA","queuosine","rDNA_intergenic_spacer_element","rDNA_replication_fork_barrier","rRNA","rRNA_21S_gene","rRNA_cleavage_RNA","rRNA_cleavage_snoRNA_primary_transcript","rRNA_gene","rRNA_large_subunit_primary_transcript","rRNA_primary_transcript","rRNA_primary_transcript_region","rRNA_small_subunit_primary_transcript","rare_fragile_site","rasiRNA","read","read_pair","reading_frame","reagent","rearrangement_region","reciprocal_chromosomal_translocation","recoded_codon","recoded_mRNA","recoding_pseudoknot","recoding_stimulatory_region","recombination_enhancer","recombination_feature","recombination_feature_of_rearranged_gene","recombination_hotspot","recombination_regulatory_region","recombination_signal_sequence","recombinationally_inverted_gene","recombinationally_rearranged_gene","recombinationally_rearranged_vertebrate_immune_system_gene","recursive_splice_site","ref_miRNA","region","regional_centromere","regional_centromere_central_core","regional_centromere_inner_repeat_region","regional_centromere_outer_repeat_region","regional_centromere_outer_repeat_transcript","regulatory_promoter_element","regulatory_region","regulon","remark","repeat_component","repeat_fragment","repeat_instability_region","repeat_region","repeat_unit","replication_regulatory_region","replication_start_site","replicon","rescue_gene","rescue_mini_gene","rescue_region","resolution_site","response_element","restriction_enzyme_assembly_scar","restriction_enzyme_binding_site","restriction_enzyme_cleavage_junction","restriction_enzyme_five_prime_single_strand_overhang","restriction_enzyme_recognition_site","restriction_enzyme_region","restriction_enzyme_single_strand_overhang","restriction_enzyme_three_prime_single_strand_overhang","restriction_fragment","retinoic_acid_responsive_element","retrogene","retron","retrotransposon","reverse_Hoogsteen_base_pair","reverse_primer","rho_dependent_bacterial_terminator","rho_independent_bacterial_terminator","ribonuclease_site","ribosome_entry_site","riboswitch","ribothymidine","ribozyme","ribozyme_gene","right_handed_peptide_helix","sORF","sarcin_like_RNA_motif","satellite_DNA","sbRNA","sbRNA_gene","scRNA","scRNA_gene","scRNA_primary_transcript","scaRNA","scaRNA_gene","schellmann_loop","schellmann_loop_seven","schellmann_loop_six","selection_marker","selenocysteine","selenocysteine_tRNA_primary_transcript","selenocysteinyl_tRNA","self_cleaving_ribozyme","sense_intronic_ncRNA","sense_intronic_ncRNA_gene","sense_overlap_ncRNA","sense_overlap_ncRNA_gene","sequence_alteration","sequence_alteration_artifact","sequence_assembly","sequence_comparison","sequence_conflict","sequence_difference","sequence_feature","sequence_length_alteration","sequence_motif","sequence_rearrangement_feature","sequence_secondary_structure","sequence_uncertainty","sequencing_primer","serine","serine_tRNA_primary_transcript","serine_threonine_motif","serine_threonine_staple_motif","serine_threonine_turn","seryl_tRNA","seven_aminomethyl_seven_deazaguanosine","seven_cyano_seven_deazaguanosine","seven_deazaguanosine","seven_methylguanine","seven_methylguanosine","sgRNA","shRNA","shRNA_primary_transcript","shadow_enhancer","short_tandem_repeat_variation","siRNA","signal_anchor","signal_peptide","signal_peptide_region_of_CDS","signature","silenced_gene","silencer","silent_mating_type_cassette_array","simple_operon","simple_regulon","simple_sequence_length_variation","single_strand_restriction_enzyme_cleavage_site","single_stranded_DNA_chromosome","single_stranded_RNA_chromosome","sisRNA","site_specific_recombination_target_region","smFISH_probe","small_regulatory_ncRNA","snRNA","snRNA_gene","snRNA_primary_transcript","sncRNA","sncRNA_gene","snoRNA","snoRNA_gene","snoRNA_primary_transcript","solo_LTR","sonicate_fragment","specific_recombination_site","splice_enhancer","splice_junction","splice_region","splice_site","spliced_leader_RNA","spliceosomal_intron","spliceosomal_intron_region","splicing_regulatory_region","spot_42_RNA","spurious_protein","ss_RNA_viral_sequence","ss_oligo","st_turn_left_handed_type_one","st_turn_left_handed_type_two","st_turn_right_handed_type_one","st_turn_right_handed_type_two","start_codon","stem","stem_loop","stem_loop_region","sterol_regulatory_element","sticky_end_restriction_enzyme_cleavage_site","stop_codon","stop_codon_read_through","stop_codon_redefined_as_pyrrolysine","stop_codon_redefined_as_selenocysteine","stop_codon_signal","structural_alteration","substitution","substitution_artifact","subtelomere","sugar_edge_base_pair","supercontig","symbiosis_island","symmetric_RNA_internal_loop","syntenic_region","synthetic_oligo","tRNA","tRNA_SINE_retrotransposon","tRNA_gene","tRNA_intron","tRNA_primary_transcript","tRNA_region","tag","tandem_duplication","tandem_repeat","target_site_duplication","targeting_vector","tasiRNA","tasiRNA_primary_transcript","teb1_recognition_motif","telomerase_RNA","telomerase_RNA_gene","telomere","telomeric_D_loop","telomeric_repeat","telomeric_transcript","template_region","terminal_inverted_repeat","terminal_inverted_repeat_element","terminal_repeat","terminator","terminator_of_type_2_RNApol_III_promoter","tetraloop","tetranucleotide_repeat_microsatellite_feature","three_methylcytidine","three_methylpseudouridine","three_methyluridine","three_prime_D_heptamer","three_prime_D_nonamer","three_prime_D_recombination_signal_sequence","three_prime_D_spacer","three_prime_EST","three_prime_LTR","three_prime_LTR_component","three_prime_RACE_clone","three_prime_RST","three_prime_UST","three_prime_UTR","three_prime_UTR_intron","three_prime_cis_splice_site","three_prime_clip","three_prime_coding_exon","three_prime_coding_exon_coding_region","three_prime_coding_exon_noncoding_region","three_prime_flanking_region","three_prime_intron","three_prime_noncoding_exon","three_prime_overlapping_ncrna","three_prime_recoding_site","three_prime_repeat_recoding_signal","three_prime_restriction_enzyme_junction","three_prime_stem_loop_structure","three_prime_sticky_end_restriction_enzyme_cleavage_site","three_prime_terminal_inverted_repeat","three_ten_helix","three_three_amino_three_carboxypropyl_uridine","three_two_prime_O_dimethyluridine","threonine","threonine_tRNA_primary_transcript","threonyl_tRNA","tiling_path","tiling_path_clone","tiling_path_fragment","tmRNA","tmRNA_acceptor_piece","tmRNA_coding_piece","tmRNA_gene","tmRNA_primary_transcript","tmRNA_region","tnaORF","topologically_associated_domain","topologically_associated_domain_boundary","topologically_defined_region","trans_splice_acceptor_site","trans_splice_donor_site","trans_splice_junction","trans_splice_site","trans_spliced_mRNA","trans_spliced_transcript","transcribed_cluster","transcribed_fragment","transcribed_processed_pseudogene","transcribed_spacer_region","transcribed_unitary_pseudogene","transcribed_unprocessed_pseudogene","transcript","transcript_bound_by_nucleic_acid","transcript_bound_by_protein","transcript_region","transcript_with_translational_frameshift","transcription_end_site","transcription_factor_regulatory_site","transcription_pause_site","transcription_start_cluster","transcription_termination_signal","transcription_unit","transcriptional_cis_regulatory_region","transgene","transgenic_insertion","transgenic_transposable_element","transit_peptide","transit_peptide_region_of_CDS","transition","translated_nucleotide_match","translated_processed_pseudogene","translated_unprocessed_pseudogene","translation_regulatory_region","translational_frameshift","translationally_regulated_gene","translocation","translocation_breakpoint","translocation_element","transmembrane_helix","transmembrane_polypeptide_region","transposable_element","transposable_element_CDS","transposable_element_flanking_region","transposable_element_gene","transposable_element_insertion_site","transposable_element_pseudogene","transposon_fragment","transversion","trinucleotide_repeat_microsatellite_feature","tryptophan","tryptophan_tRNA_primary_transcript","tryptophanyl_tRNA","twintron","two_methyladenosine","two_methylthio_N6_cis_hydroxyisopentenyl_adenosine","two_methylthio_N6_hydroxynorvalyl_carbamoyladenosine","two_methylthio_N6_isopentenyladenosine","two_methylthio_N6_methyladenosine","two_methylthio_N6_threonyl_carbamoyladenosine","two_prime_O_methyladenosine","two_prime_O_methylcytidine","two_prime_O_methylguanosine","two_prime_O_methylinosine","two_prime_O_methylpseudouridine","two_prime_O_methyluridine","two_prime_O_ribosyladenosine_phosphate","two_prime_O_ribosylguanosine_phosphate","two_thio_two_prime_O_methyluridine","two_thiocytidine","two_thiouridine","tyrosine","tyrosine_tRNA_primary_transcript","tyrosyl_tRNA","uORF","ultracontig","unassigned_supercontig","unconfirmed_transcript","undermodified_hydroxywybutosine","unedited_region","unigene_cluster","unit_of_gene_expression","unitary_pseudogene","unitary_pseudogenic_rRNA","unitary_pseudogenic_tRNA","unprocessed_pseudogenic_rRNA","unprocessed_pseudogenic_tRNA","unspecified_indel","untranslated_region_polycistronic_mRNA","upstream_AUG_codon","uridine_five_oxyacetic_acid","uridine_five_oxyacetic_acid_methyl_ester","vacuolar_sorting_signal","validated_cDNA_clone","valine","valine_tRNA_primary_transcript","valyl_tRNA","vaultRNA_primary_transcript","vault_RNA","vault_RNA_gene","vector_replicon","vertebrate_immune_system_gene","vertebrate_immune_system_gene_recombination_feature","vertebrate_immune_system_gene_recombination_signal_feature","vertebrate_immune_system_gene_recombination_spacer","vertebrate_immune_system_pseudogene","vertebrate_immunoglobulin_T_cell_receptor_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_gene_cluster","vertebrate_immunoglobulin_T_cell_receptor_rearranged_segment","vertebrate_immunoglobulin_T_cell_receptor_segment","viral_promoter","viral_sequence","virtual_sequence","wild_type_rescue_gene","wobble_base_pair","wybutosine","wyosine","zinc_finger_binding_site","zinc_repressed_element"],Xt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","Core"),e}return M(t,e),I(t,[{key:"frontendPreValidate",value:(r=k(U().m((function e(t){var n,r,o;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(!("oldType"in(i=t))||!("newType"in i)){e.n=7;break}n=j(t.changes),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=4;break}if(Yt.includes((o=r.value).newType)){e.n=3;break}return e.a(2,{validationName:this.name,error:{message:'"'.concat(o.newType,'" is not a valid SO sequence_feature term')}});case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,n.e(e.v);case 6:return e.p=6,n.f(),e.f(6);case 7:return e.a(2,{validationName:this.name})}var i}),e,this,[[1,5,6,7]])}))),function(e){return r.apply(this,arguments)})},{key:"possibleValues",value:(n=k(U().m((function e(t){return U().w((function(e){for(;;)switch(e.n){case 0:if("type"!==t){e.n=1;break}return e.a(2,Yt);case 1:return e.a(2)}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Vt),Zt=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","ParentChildValidation"),e}return M(t,e),I(t,[{key:"backendPostValidate",value:(r=k(U().m((function e(t,n){var r,o;return U().w((function(e){for(;;)switch(e.n){case 0:if(r=n.featureModel,o=n.session,!Rt(t)&&!It(t)){e.n=1;break}return e.a(2,this.validateParentChildRelationships(t,{session:o,featureModel:r}));case 1:return e.a(2,{validationName:this.name})}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"validateParentChildRelationships",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:r=n.featureModel,o=n.session,i=[],a=j(t.changes),e.p=1,l=U().m((function e(){var t,n,a;return U().w((function(e){for(;;)switch(e.n){case 0:return t=s.value.featureId,e.n=1,r.findOne({allIds:t}).session(o).exec();case 1:if(n=e.v){e.n=2;break}throw a="ERROR: The following featureId was not found in database ='".concat(t,"'"),new Error(a);case 2:i.some((function(e){return e._id===n._id}))||i.push(n);case 3:return e.a(2)}}),e)})),a.s();case 2:if((s=a.n()).done){e.n=4;break}return e.d(z(l()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a.e(e.v);case 6:return e.p=6,a.f(),e.f(6);case 7:c=0,u=i;case 8:if(!(c<u.length)){e.n=12;break}d=u[c],e.p=9,this.checkChildFeatureBoundaries(d),e.n=11;break;case 10:return e.p=10,e.a(2,{validationName:this.name,error:{message:String(e.v)}});case 11:c++,e.n=8;break;case 12:return e.a(2,{validationName:this.name})}}),e,this,[[9,10],[1,5,6,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"checkChildFeatureBoundaries",value:function(e){if(e.children){var t,n=j(e.children||new Map);try{for(n.s();!(t=n.n()).done;){var r=G(t.value,2)[1];if(null!==e.min&&null!==e.max&&null!==r.min&&null!==r.max&&(r.max>e.max||r.min<e.min))throw new Error("Feature ".concat(Ft(r)," exceeds the bounds of its parent, ").concat(Ft(e)));this.checkChildFeatureBoundaries(r)}}catch(e){n.e(e)}finally{n.f()}}}}]);var n,r}(Vt);function Qt(e){this.message=e}(Qt.prototype=new Error).name="InvalidCharacterError";var en,tn,nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Qt("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,i=0,a="";r=t.charAt(i++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function rn(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(nn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return nn(t)}}function on(e){this.message=e}function an(e,t){if("string"!=typeof e)throw new on("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(rn(e.split(".")[n]))}catch(e){throw new on("Invalid token specified: "+e.message)}}function sn(e){var t="string"==typeof e?an(e):e;return"".concat(t.id,"-").concat(t.iat)}function ln(e){return an(e)}function cn(e){var t,n,r=null===(t=e.attributes)||void 0===t||null===(t=t.gff_id)||void 0===t?void 0:t.join(", ");if(r)return"".concat(r," (_id: ").concat(e._id.toString(),")");var o=null===(n=e.attributes)||void 0===n||null===(n=n.gff_name)||void 0===n?void 0:n.join(", ");return o?"".concat(o," (_id: ").concat(e._id.toString(),")"):"_id: ".concat(e._id.toString())}(on.prototype=new Error).name="InvalidTokenError",function(e){e[e.TAG=0]="TAG",e[e.TAA=1]="TAA",e[e.TGA=2]="TGA"}(en||(en={})),function(e){e[e.ATG=0]="ATG"}(tn||(tn={}));var un,dn="CDSCheck";!function(e){e[e.InternalStopCodon=0]="InternalStopCodon",e[e.MissingStartCodon=1]="MissingStartCodon",e[e.MissingStopCodon=2]="MissingStopCodon"}(un||(un={}));var fn={G:"C",A:"T",T:"A",C:"G",R:"Y",Y:"R",M:"K",K:"M",S:"S",W:"W",H:"D",B:"V",V:"B",D:"H",N:"N"};function hn(e){var t,n=[],r=j(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=fn[o.toUpperCase()];if(void 0===i)throw new TypeError('Cannot complement nucleotide: "'.concat(o,'"'));o===o.toLowerCase()?n.push(i.toLowerCase()):n.push(i)}}catch(e){r.e(e)}finally{r.f()}return n.reverse().join("")}function pn(e,t,n){return gn.apply(this,arguments)}function gn(){return(gn=k(U().m((function e(t,n,r){var o;return U().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.all(t.map((function(e){return r(e.min,e.max)})));case 1:return o=e.v.join(""),-1===n&&(o=hn(o)),e.a(2,o)}}),e)})))).apply(this,arguments)}function mn(e){for(var t=[],n=0;n<=e.length-3;n+=3)t.push(e.slice(n,n+3));return t}function yn(e,t,n){return-1===n?e>t:e<t}function _n(e,t,n){for(var r=e.toSorted(-1===t?function(e,t){return e.min<t.min?1:-1}:function(e,t){return e.min<t.min?-1:1}),o=0,i=void 0,a=void 0,s=0;s<r.length;s++)for(var l=r[s],c=l.phase,u=-1===t?l.min:l.max,d=-1===t?l.max-c:l.min+c;yn(d,u,t);d=-1===t?d-3:d+3){if(i=d,a=-1===t?i-3:i+3,-1===t&&a<l.min?a=r[s+1].max-r[s+1].phase:a>l.max&&(a=r[s+1].min+r[s+1].phase),o===n)return[i,a].sort((function(e,t){return e-t}));o++}}function vn(e,t){return bn.apply(this,arguments)}function bn(){return(bn=k(U().m((function e(t,n){var r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_,v,b,x,w,S,C,A,k,N,T,R,E,I,D,O,F,M,L;return U().w((function(e){for(;;)switch(e.p=e.n){case 0:if(r=[],o=t._id,i=t.max,a=t.min,s=t.refSeq,l=t.strand,c=xn(t)){e.n=1;break}return e.a(2,r);case 1:u=[o],d=j(c),e.p=2,d.s();case 3:if((f=d.n()).done){e.n=13;break}return y=f.value,e.n=4,pn(y,l,n);case 4:v=mn(_=e.v),b=-1===l?null!==(h=null===(p=y.at(0))||void 0===p?void 0:p.min)&&void 0!==h?h:a:null!==(g=null===(m=y.at(-1))||void 0===m?void 0:m.max)&&void 0!==g?g:i,_.length%3==0?((x=v.at(0))&&!(x.toUpperCase()in tn)&&(k=-1===l?null!==(w=null===(S=y.at(-1))||void 0===S?void 0:S.max)&&void 0!==w?w:i:null!==(C=null===(A=y.at(0))||void 0===A?void 0:A.min)&&void 0!==C?C:a,k=-1===l?k-3:k,r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStartCodon],ids:u,refSeq:s.toString(),start:k,end:k,message:'Unexpected start codon "'.concat(x,'" in feature "').concat(cn(t),'": ')})),(N=v.at(-1))&&!(N.toUpperCase()in en)&&r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s.toString(),start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')})):r.push({_id:(new at).toHexString(),name:dn,cause:un[un.MissingStopCodon],ids:u,refSeq:s.toString(),start:b,end:b,message:'Missing stop codon in feature "'.concat(cn(t),'"')}),T=j(v.entries()),e.p=5,T.s();case 6:if((R=T.n()).done){e.n=9;break}if(E=G(R.value,2),D=E[1],(I=E[0])!==v.length-1){e.n=7;break}return e.a(3,9);case 7:(O=_n(y,l,I))&&D.toUpperCase()in en&&(F=G(O,2),M=F[0],L=F[1],r.push({_id:(new at).toHexString(),name:dn,cause:un[un.InternalStopCodon],ids:u,refSeq:s.toString(),start:M,end:L,message:'Internal stop codon in feature "'.concat(cn(t),'"')}));case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,T.e(e.v);case 11:return e.p=11,T.f(),e.f(11);case 12:e.n=3;break;case 13:e.n=15;break;case 14:e.p=14,d.e(e.v);case 15:return e.p=15,d.f(),e.f(15);case 16:return e.a(2,r)}}),e,null,[[5,10,11,12],[2,14,15,16]])})))).apply(this,arguments)}function xn(e){if("mRNA"===e.type){var t=e.children,n=e.strand;if(t){var r=Object.values(t).filter((function(e){return"CDS"===e.type}));if(0!==r.length){var i,a=[],s=j(r);try{var l=function(){for(var e=i.value,r=e.max,s=e.min,l=[],c=0,u=Object.values(t);c<u.length;c++){var d=u[c];if("exon"===d.type){var f=G(o.intersection2(s,r,d.min,d.max),2),h=f[0],p=f[1];void 0!==h&&void 0!==p&&l.push({min:h,max:p})}}l.sort((function(e,t){return e.min-t.min})),-1===n&&l.reverse();var g=0,m=l.map((function(e){var t=g;return g=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));m.sort((function(e,t){return e.min<t.min?-1:1})),a.push(m)};for(s.s();!(i=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return a.length>1&&a.sort((function(e,t){return e[0].min<t[0].min?-1:1})),a}}}}var wn,Sn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name",dn),D(e,"causes",Object.values(un).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type){e.n=1;break}return e.a(2,vn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);!function(e){e[e.NonCanonicalSpliceSiteAtFivePrime=0]="NonCanonicalSpliceSiteAtFivePrime",e[e.NonCanonicalSpliceSiteAtThreePrime=1]="NonCanonicalSpliceSiteAtThreePrime"}(wn||(wn={}));var Cn="TranscriptCheck";function An(e,t){return kn.apply(this,arguments)}function kn(){return kn=k(U().m((function e(t,n){var r,i,a,s,l,c,u,d,f,h,p,g;return U().w((function(e){for(;;)switch(e.n){case 0:if(t.children){e.n=1;break}return e.a(2,[]);case 1:for(r=[],i=0,a=Object.entries(t.children);i<a.length;i++)s=G(a[i],2),"exon"===(l=s[1]).type&&r.push(l);if(!(r.length<2)){e.n=2;break}return e.a(2,[]);case 2:r.sort((function(e,t){return e.min<t.min?-1:1})),c=[],u=0;case 3:if(!(u<r.length-1)){e.n=7;break}return d=r[u].max,f=r[u+1].min,-1===t.strand?(f=(h=[d,f])[0],d=h[1],d-=2):f-=2,e.n=4,n(d,d+2);case 4:return p=e.v,e.n=5,n(f,f+2);case 5:g=e.v,-1===t.strand&&(g=o.revcom(g),p=o.revcom(p)),c.push({fivePrimeSeq:p,fivePrimeMin:d,threePrimeSeq:g,threePrimeMin:f});case 6:u++,e.n=3;break;case 7:return e.a(2,c)}}),e)}))),kn.apply(this,arguments)}function Nn(e,t){return Tn.apply(this,arguments)}function Tn(){return(Tn=k(U().m((function e(t,n){var r,o,i,a,s,l;return U().w((function(e){for(;;)switch(e.n){case 0:return r=[],o=new Set(["GT"]),i=new Set(["AG"]),e.n=1,An(t,n);case 1:a=j(e.v);try{for(a.s();!(s=a.n()).done;)o.has((l=s.value).fivePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtFivePrime],ids:[t._id],refSeq:t.refSeq.toString(),start:l.fivePrimeMin,end:l.fivePrimeMin+2,message:'Unexpected 5′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(o).join("|"),", got: ").concat(l.fivePrimeSeq)}),i.has(l.threePrimeSeq.toUpperCase())||r.push({_id:(new at).toHexString(),name:Cn,cause:wn[wn.NonCanonicalSpliceSiteAtThreePrime],ids:[t._id],refSeq:t.refSeq.toString(),start:l.threePrimeMin,end:l.threePrimeMin+2,message:'Unexpected 3′ splice site in "'.concat(cn(t),'". Expected: ').concat(W(i).join("|"),", got: ").concat(l.threePrimeSeq)})}catch(e){a.e(e)}finally{a.f()}return e.a(2,r)}}),e)})))).apply(this,arguments)}var Rn=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"name","TranscriptCheck"),D(e,"causes",Object.values(wn).filter((function(e){return Number.isNaN(Number(e))}))),D(e,"version",1),D(e,"isDefault",!0),e}return M(t,e),I(t,[{key:"checkFeature",value:(n=k(U().m((function e(t,n){var r,o,i,a,s,l,c;return U().w((function(e){for(;;)switch(e.n){case 0:if("mRNA"!==t.type&&"transcript"!==t.type&&"pseudogenic_transcript"!==t.type){e.n=1;break}return e.a(2,Nn(t,n));case 1:if(t.children){e.n=2;break}return e.a(2,[]);case 2:r=[],o=0,i=Object.values(t.children);case 3:if(!(o<i.length)){e.n=6;break}return a=i[o],s=r.push,l=r,c=W,e.n=4,this.checkFeature(a,n);case 4:s.apply.call(s,l,c(e.v));case 5:o++,e.n=3;break;case 6:return e.a(2,r)}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}]);var n}(dt);function En(e,t,n){var r;return("apollo_feature_container"===e.type?Object.values(null!==(r=e.children)&&void 0!==r?r:{}):[e]).map((function(e){var n,r,o,i,a,s=JSON.parse(JSON.stringify(null!==(n=e.attributes)&&void 0!==n?n:{})),l=[],c=null!==(r=null===(o=e.attributes)||void 0===o||null===(o=o.gff_source)||void 0===o?void 0:o[0])&&void 0!==r?r:null;delete s.gff_source,t&&(s.Parent=[t]),s.gff_id?(s.ID=s.gff_id,delete s.gff_id):e.children&&(s.ID=[e._id]),s.gff_name&&(s.Name=s.gff_name,delete s.gff_name),s.gff_alias&&(s.Alias=s.gff_alias,delete s.gff_alias),s.gff_target&&(s.Target=s.gff_target,delete s.gff_target),s.gff_gap&&(s.Gap=s.gff_gap,delete s.gff_gap),s.gff_derives_from&&(s.Derives_from=s.gff_derives_from,delete s.gff_derives_from),s.gff_note&&(s.Note=s.gff_note,delete s.gff_note),s.gff_dbxref&&(s.Dbxref=s.gff_dbxref,delete s.gff_dbxref),s.gff_is_circular&&(s.Is_circular=s.gff_is_circular,delete s.gff_is_circular),s.gff_ontology_term&&(l.push.apply(l,W(s.gff_ontology_term)),delete s.gff_ontology_term),s["Gene Ontology"]&&(l.push.apply(l,W(s["Gene Ontology"])),delete s["Gene Ontology"]),s["Sequence Ontology"]&&(l.push.apply(l,W(s["Sequence Ontology"])),delete s["Sequence Ontology"]),l.length>0&&(s.Ontology_term=l);var u=null===(i=e.attributes)||void 0===i?void 0:i.gff_score,d=null;return u&&u.length>0&&(u[0]&&(d=Number(u[0]),Number.isNaN(d)&&(d=null)),delete s.gff_score),{start:Number(e.min)+1,end:Number(e.max),seq_id:e.refSeq,source:c,type:e.type,score:d,strand:e.strand?1===e.strand?"+":"-":null,phase:null,attributes:Object.keys(s).length>0?s:null,derived_features:[],child_features:In(e,null===(a=s.ID)||void 0===a?void 0:a[0])}}))}function In(e,t,n){if(!e.children)return[];if("mRNA"===e.type){for(var r=[],i=function(e){var t=[];try{t=function(e){if("mRNA"!==e.type)throw new Error('Only features of type "mRNA" or equivalent can calculate CDS locations');if(!e.children)throw new Error("no CDS or exons in mRNA");var t=Object.values(e.children),n=t.filter((function(e){return"CDS"===e.type}));if(0===n.length)throw new Error("no CDS in mRNA");var r,i=[],a=j(n);try{var s=function(){for(var n=r.value,a=n.max,s=n.min,l=[],c=!1,u=[],d=0,f=t;d<f.length;d++){var h=f[d];"exon"===h.type&&u.push({min:h.min,max:h.max})}u.sort((function(e,t){return e.min-t.min}));for(var p=0,g=u;p<g.length;p++){var m=g[p],y=l.at(-1);y&&l.push({min:y.max,max:m.min,type:"intron"});var _,v=G(o.intersection2(s,a,m.min,m.max),2),b=v[0],x=v[1];_=c?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==b&&void 0!==x?(c=!0,b===m.min&&x===m.max?l.push({min:b,max:x,phase:0,type:"CDS"}):b===m.min?l.push({min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:_}):x===m.max?l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"}):l.push({min:m.min,max:b,type:_},{min:b,max:x,phase:0,type:"CDS"},{min:x,max:m.max,type:"fivePrimeUTR"===_?"threePrimeUTR":"fivePrimeUTR"})):l.push({min:m.min,max:m.max,type:_})}l.sort((function(e,t){return e.min-t.min})),-1===e.strand&&l.reverse();var w=0,S=l.map((function(e){if("CDS"!==e.type)return e;var t=w;return w=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(S)};for(a.s();!(r=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return i}(e)}catch(e){return[]}return t.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}(e),a=0,s=0,l=Object.values(e.children);s<l.length;s++){var c=l[s],u=En(c,t);if("CDS"===c.type){var d,f=j(i[a]);try{for(f.s();!(d=f.n()).done;){var h=d.value,p=JSON.parse(JSON.stringify(u));if(1!=p.length)throw new Error("Unexpected CDS: ".concat(JSON.stringify(p,null,2)));p[0].start=h.min+1,p[0].end=h.max,p[0].phase=h.phase.toString(),p[0].type=h.type,r.push(p)}}catch(e){f.e(e)}finally{f.f()}a++}else r.push(u)}return r}return Object.values(e.children).map((function(e){return En(e,t)}))}var jn={ID:"gff_id",Name:"gff_name",Alias:"gff_alias",Parent:"gff_parent",Target:"gff_target",Gap:"gff_gap",Derives_from:"gff_derives_from",Note:"gff_note",Dbxref:"gff_dbxref",Ontology_term:"gff_ontology_term",Is_circular:"gff_is_circular"},Dn={gff_id:"ID",gff_name:"Name",gff_alias:"Alias",gff_parent:"Parent",gff_target:"Target",gff_gap:"Gap",gff_derives_from:"Derives_from",gff_note:"Note",gff_dbxref:"Dbxref",gff_ontology_term:"Ontology_term",gff_is_circular:"Is_circular"},On={gff_score:"score",gff_source:"source"};function Fn(e,t){var n=G(e,1)[0],r=n.end,i=n.seq_id,a=n.start,s=n.strand;if(!i)throw new Error("feature does not have seq_id: ".concat(JSON.stringify(n)));if(null===a)throw new Error("feature does not have start: ".concat(JSON.stringify(n)));if(null===r)throw new Error("feature does not have end: ".concat(JSON.stringify(n)));var l=function(e){var t=e.map((function(e){return e.start})).filter((function(e){return null!==e})),n=e.map((function(e){return e.end})).filter((function(e){return null!==e}));return[Math.min.apply(Math,W(t))-1,Math.max.apply(Math,W(n))]}(e),c=G(l,2),u=c[0],d=c[1],f=function(e,t,n){var r={},i=e.filter((function(e){return e.child_features.length>0}));if(i.length>1)throw new Error("Features with multiple locations may not have children");if(e.length>1&&"CDS"!==e[0].type){var a,s=j(e);try{for(s.s();!(a=s.n()).done;){var l=Fn([a.value],t);r[l._id]=l}}catch(e){s.e(e)}finally{s.f()}return r}if(0!==i.length){var c,u=[],d=[],f=[],h=j(G(i,1)[0].child_features);try{for(h.s();!(c=h.n()).done;){var p=c.value,g=G(p,1)[0];if("exon"===g.type&&d.push(p),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type||f.push(p),"three_prime_UTR"!==g.type&&"five_prime_UTR"!==g.type&&"intron"!==g.type&&"start_codon"!==g.type&&"stop_codon"!==g.type)if("CDS"===g.type)u.push(p);else{var m=Fn(p,t);r[m._id]=m}}}catch(e){h.e(e)}finally{h.f()}if(u.length>0){var y,_=function(e,t){var n=e.map((function(e){return e.length}));if(n.some((function(e){return e>1})))return e.map((function(e){return Fn(e,t)}));var r=e.map((function(e){return e[0]})).filter((function(e){return null!==e.start&&null!==e.end})).sort((function(e,t){return e.start-t.start}));if(!r.some((function(e,t){var n=r.at(t+1);return!!n&&o.doesIntersect2(e.start,e.end,n.start,n.end)})))return[Fn(r,t)];var i,a=e.map((function(e){return e[0]})),s=[],l=j(a);try{var c=function(){var e=i.value,t=s.at(-1);if(!t)return s.push([e]),1;t.some((function(t){return o.doesIntersect2(t.start,t.end,e.start,e.end)}))?s.push([e]):t.push(e)};for(l.s();!(i=l.n()).done;)c()}catch(e){l.e(e)}finally{l.f()}return s.map((function(e){return Fn(e,t)}))}(u,t),v=j(_);try{for(v.s();!(y=v.n()).done;){var b=y.value;r[b._id]=b}}catch(e){v.e(e)}finally{v.f()}var x,w=function(e,t,n,r,o){var i,a=[],s=j(n);try{for(s.s();!(i=s.n()).done;){var l,c=j(i.value);try{for(c.s();!(l=c.n()).done;){var u=l.value;if(!u.start||!u.end)throw new Error("UTR has undefined start and/or end\n: ".concat(JSON.stringify(u,null,2)));var d=void 0;"+"===u.strand?d=1:"-"===u.strand&&(d=-1),a.push({_id:(new at).toHexString(),refSeq:r,type:"exon",min:u.start-1,max:u.end,strand:d})}}catch(e){c.e(e)}finally{c.f()}}}catch(e){s.e(e)}finally{s.f()}a.sort((function(e,t){return e.min-t.min}));var f,h=[],p=j(e);try{for(p.s();!(f=p.n()).done;){var g=f.value;g.sort((function(e,t){if(!e.start||!t.start)throw new Error("CDS has undefined start");return e.start-t.start}));for(var m=0;m<g.length;m++){var y,_=g[m],v=!1,b=j(t);try{for(b.s();!(y=b.n()).done;){var x=y.value;if(1!=x.length)throw new Error("Unexpected number of exons");var w=G(x,1)[0];if(w.start&&w.end&&_.start&&_.end&&w.start<=_.start&&w.end>=_.end){v=!0;break}}}catch(e){b.e(e)}finally{b.f()}if(!v){if(!_.start||!_.end)throw new Error("CDS has undefined start and/or end: ".concat(JSON.stringify(_,null,2)));var S=void 0;"+"===_.strand?S=1:"-"===_.strand&&(S=-1);var C={_id:(new at).toHexString(),refSeq:r,type:"exon",min:_.start-1,max:_.end,strand:S};if(0===m){var A,k=j(a);try{for(k.s();!(A=k.n()).done;){var N=A.value;if(N.max>C.min)break;N.max===C.min?C.min=N.min:h.push(N)}}catch(e){k.e(e)}finally{k.f()}}if(m===g.length-1){var T,R=j(a);try{for(R.s();!(T=R.n()).done;){var E=T.value;E.min<C.max||(E.min===C.max?C.max=E.max:h.push(E))}}catch(e){R.e(e)}finally{R.f()}}h.push(C)}}}}catch(e){p.e(e)}finally{p.f()}var I=function(e){if(0===e.length)return[];e.sort((function(e,t){return e.min-t.min}));var t=[];t.push(e[0]);for(var n=1;n<e.length;n++){var r=t.at(-1),o=e[n];r&&o.min<=r.max?r.max=Math.max(r.max,o.max):t.push(o)}return t}(h);return I}(u,d,f,_[0].refSeq),S=j(w);try{for(S.s();!(x=S.n()).done;){var C=x.value;r[C._id]=C}}catch(e){S.e(e)}finally{S.f()}}return Object.keys(r).length>0?r:void 0}}(e,t),h=function(e){var t={},n=e.map((function(e){return e.score})).filter((function(e){return null!==e})),r=e.map((function(e){return e.source})).filter((function(e){return null!==e})),o=e.map((function(e){return e.attributes})).filter((function(e){return null!==e}));if(n.length>0){var i=G(n,1)[0];n.length>1&&(i=n.reduce((function(e,t){return e+t}),0)/n.length),t.gff_score=[String(i)]}if(r.length>0){var a=G(r,1)[0];r.length>1&&(a=W(new Set(r)).join(",")),t.gff_source=[a]}if(o.length>0){var s,l=j(o);try{for(l.s();!(s=l.n()).done;)for(var c=0,u=Object.entries(s.value);c<u.length;c++){var d=G(u[c],2),f=d[0],h=d[1];if("Parent"!==f){var p=f in jn?jn[f]:f,g=t[p];if(g){var m=new Set([].concat(W(g),W(h)));t[p]=W(m)}else t[p]=h}}}catch(e){l.e(e)}finally{l.f()}}if(Object.keys(t).length>0)return t}(e),p={_id:(new at).toHexString(),refSeq:i,type:Mn(e),min:u,max:d};if(s)if("+"===s)p.strand=1;else{if("-"!==s)throw new Error('Unknown strand: "'.concat(s,'"'));p.strand=-1}return f&&(p.children=f),h&&(p.attributes=h),p}function Mn(e){var t=G(e,1)[0];if(1===e.length||"CDS"===t.type){var n=t.type;if(!n)throw new Error("feature does not have type: ".concat(JSON.stringify(t)));return n}return"apollo_feature_container"}var Ln=a.createSvgIcon(i.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add");const Pn=n.ConfigurationSchema("ApolloInternetAccount",{baseURL:{description:"Location of Apollo server",type:"string",defaultValue:""},tokenType:{description:"A custom name for a token to include in the header",type:"string",defaultValue:"Bearer"}},{baseConfiguration:r.BaseInternetAccountConfig,explicitlyTyped:!0});var Bn=Object.create(null);Bn.open="0",Bn.close="1",Bn.ping="2",Bn.pong="3",Bn.message="4",Bn.upgrade="5",Bn.noop="6";var qn=Object.create(null);Object.keys(Bn).forEach((function(e){qn[Bn[e]]=e}));var Un,$n={type:"error",data:"parser error"},zn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Hn="function"==typeof ArrayBuffer,Gn=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},Vn=function(e,t,n){var r=e.type,o=e.data;return zn&&o instanceof Blob?t?n(o):Wn(o,n):Hn&&(o instanceof ArrayBuffer||Gn(o))?t?n(o):Wn(new Blob([o]),n):n(Bn[r]+(o||""))},Wn=function(e,t){var n=new FileReader;return n.onload=function(){var e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function Jn(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(var Kn="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Yn=0;Yn<64;Yn++)Kn["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(Yn)]=Yn;var Xn,Zn="function"==typeof ArrayBuffer,Qn=function(e,t){if("string"!=typeof e)return{type:"message",data:tr(e,t)};var n=e.charAt(0);return"b"===n?{type:"message",data:er(e.substring(1),t)}:qn[n]?e.length>1?{type:qn[n],data:e.substring(1)}:{type:qn[n]}:$n},er=function(e,t){if(Zn){var n=function(e){var t,n,r,o,i,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)n=Kn[e.charCodeAt(t)],r=Kn[e.charCodeAt(t+1)],o=Kn[e.charCodeAt(t+2)],i=Kn[e.charCodeAt(t+3)],u[l++]=n<<2|r>>4,u[l++]=(15&r)<<4|o>>2,u[l++]=(3&o)<<6|63&i;return c}(e);return tr(n,t)}return{base64:!0,data:e}},tr=function(e,t){return"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},nr=String.fromCharCode(30);function rr(e){return e.reduce((function(e,t){return e+t.length}),0)}function or(e,t){if(e[0].length===t)return e.shift();for(var n=new Uint8Array(t),r=0,o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function ir(e){if(e)return function(e){for(var t in ir.prototype)e[t]=ir.prototype[t];return e}(e)}ir.prototype.on=ir.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ir.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},ir.prototype.off=ir.prototype.removeListener=ir.prototype.removeAllListeners=ir.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},ir.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},ir.prototype.emitReserved=ir.prototype.emit,ir.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ir.prototype.hasListeners=function(e){return!!this.listeners(e).length};var ar=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()}();function sr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(t,n){return e.hasOwnProperty(n)&&(t[n]=e[n]),t}),{})}var lr=ar.setTimeout,cr=ar.clearTimeout;function ur(e,t){t.useNativeTimers?(e.setTimeoutFn=lr.bind(ar),e.clearTimeoutFn=cr.bind(ar)):(e.setTimeoutFn=ar.setTimeout.bind(ar),e.clearTimeoutFn=ar.clearTimeout.bind(ar))}var dr,fr=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t,[e])).description=n,o.context=r,o.type="TransportError",o}return M(t,e),I(t)}(Z(Error)),hr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).writable=!1,ur(n,e),n.opts=e,n.query=e.query,n.socket=e.socket,n}return M(t,e),I(t,[{key:"onError",value:function(e,n,r){return V(t,"emitReserved",this,3)(["error",new fr(e,n,r)]),this}},{key:"open",value:function(){return this.readyState="opening",this.doOpen(),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(e){"open"===this.readyState&&this.write(e)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,V(t,"emitReserved",this,3)(["open"])}},{key:"onData",value:function(e){var t=Qn(e,this.socket.binaryType);this.onPacket(t)}},{key:"onPacket",value:function(e){V(t,"emitReserved",this,3)(["packet",e])}},{key:"onClose",value:function(e){this.readyState="closed",V(t,"emitReserved",this,3)(["close",e])}},{key:"pause",value:function(e){}},{key:"createUri",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}},{key:"_hostname",value:function(){var e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}},{key:"_port",value:function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}},{key:"_query",value:function(e){var t=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}])}(ir),pr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),gr=64,mr=0;function yr(e){var t="";do{t=pr[e%gr]+t,e=Math.floor(e/gr)}while(e>0);return t}function _r(){var e=yr(+new Date);return e!==dr?(mr=0,dr=e):e+"."+yr(mr++)}var vr=!1;try{vr="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}var br=vr;function xr(e){var t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||br))return new XMLHttpRequest}catch(e){}if(!t)try{return new(ar[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function wr(){}var Sr=function(){return null!=new xr({xdomain:!1}).responseType}(),Cr=function(e){function t(e){var n;if(R(this,t),(n=T(this,t,[e])).polling=!1,"undefined"!=typeof location){var r="https:"===location.protocol,o=location.port;o||(o=r?"443":"80"),n.xd="undefined"!=typeof location&&e.hostname!==location.hostname||o!==e.port}return n.supportsBinary=Sr&&!(e&&e.forceBase64),n.opts.withCredentials&&(n.cookieJar=void 0),n}return M(t,e),I(t,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(e){var t=this;this.readyState="pausing";var n=function(){t.readyState="paused",e()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(e){var t=this;(function(e,t){for(var n=e.split(nr),r=[],o=0;o<n.length;o++){var i=Qn(n[o],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((function(e){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose({description:"transport closed by the server"}),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var e=this,t=function(){e.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}},{key:"write",value:function(e){var t=this;this.writable=!1,function(e,n){var r=e.length,o=new Array(r),i=0;e.forEach((function(e,n){Vn(e,!1,(function(e){var a;o[n]=e,++i===r&&(a=o.join(nr),t.doWrite(a,(function(){t.writable=!0,t.emitReserved("drain")})))}))}))}(e)}},{key:"uri",value:function(){var e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ar(this.uri(),e)}},{key:"doWrite",value:function(e,t){var n=this,r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(function(e,t){n.onError("xhr post error",e,t)}))}},{key:"doPoll",value:function(){var e=this,t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(function(t,n){e.onError("xhr poll error",t,n)})),this.pollXhr=t}}])}(hr),Ar=function(e){function t(e,n){var r;return R(this,t),ur(r=T(this,t),n),r.opts=n,r.method=n.method||"GET",r.uri=e,r.data=void 0!==n.data?n.data:null,r.create(),r}return M(t,e),I(t,[{key:"create",value:function(){var e,n=this,r=sr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this.opts.xd;var o=this.xhr=new xr(r);try{o.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders)for(var i in o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&o.setRequestHeader(i,this.opts.extraHeaders[i])}catch(e){}if("POST"===this.method)try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{o.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(o),"withCredentials"in o&&(o.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(o.timeout=this.opts.requestTimeout),o.onreadystatechange=function(){var e;3===o.readyState&&(null===(e=n.opts.cookieJar)||void 0===e||e.parseCookies(o)),4===o.readyState&&(200===o.status||1223===o.status?n.onLoad():n.setTimeoutFn((function(){n.onError("number"==typeof o.status?o.status:0)}),0))},o.send(this.data)}catch(e){return void this.setTimeoutFn((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=t.requestsCount++,t.requests[this.index]=this)}},{key:"onError",value:function(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(e){if(null!=this.xhr){if(this.xhr.onreadystatechange=wr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete t.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}])}(ir);function kr(){for(var e in Ar.requests)Ar.requests.hasOwnProperty(e)&&Ar.requests[e].abort()}Ar.requestsCount=0,Ar.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",kr):"function"==typeof addEventListener&&addEventListener("onpagehide"in ar?"pagehide":"unload",kr,!1));var Nr=function(){return"function"==typeof Promise&&"function"==typeof Promise.resolve?function(e){return Promise.resolve().then(e)}:function(e,t){return t(e,0)}}(),Tr=ar.WebSocket||ar.MozWebSocket,Rr="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),Er=function(e){function t(e){var n;return R(this,t),(n=T(this,t,[e])).supportsBinary=!e.forceBase64,n}return M(t,e),I(t,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var e=this.uri(),t=this.opts.protocols,n=Rr?{}:sr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=Rr?new Tr(e,t,n):t?new Tr(e,t):new Tr(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}}},{key:"addEventListeners",value:function(){var e=this;this.ws.onopen=function(){e.opts.autoUnref&&e.ws._socket.unref(),e.onOpen()},this.ws.onclose=function(t){return e.onClose({description:"websocket connection closed",context:t})},this.ws.onmessage=function(t){return e.onData(t.data)},this.ws.onerror=function(t){return e.onError("websocket error",t)}}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;Vn(e[r],t.supportsBinary,(function(e){try{t.ws.send(e)}catch(e){}n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=_r()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},{key:"check",value:function(){return!!Tr}}])}(hr),Ir=function(e){function t(){return R(this,t),T(this,t,arguments)}return M(t,e),I(t,[{key:"name",get:function(){return"webtransport"}},{key:"doOpen",value:function(){var e=this;"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((function(){e.onClose()})).catch((function(t){e.onError("webtransport error",t)})),this.transport.ready.then((function(){e.transport.createBidirectionalStream().then((function(t){var n=function(e,t){Xn||(Xn=new TextDecoder);var n=[],r=0,o=-1,i=!1;return new TransformStream({transform:function(a,s){for(n.push(a);;){if(0===r){if(rr(n)<1)break;var l=or(n,1);i=128==(128&l[0]),r=(o=127&l[0])<126?3:126===o?1:2}else if(1===r){if(rr(n)<2)break;var c=or(n,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(2===r){if(rr(n)<8)break;var u=or(n,8),d=new DataView(u.buffer,u.byteOffset,u.length),f=d.getUint32(0);if(f>Math.pow(2,21)-1){s.enqueue($n);break}o=f*Math.pow(2,32)+d.getUint32(4),r=3}else{if(rr(n)<o)break;var h=or(n,o);s.enqueue(Qn(i?h:Xn.decode(h),t)),r=0}if(0===o||o>e){s.enqueue($n);break}}}})}(Number.MAX_SAFE_INTEGER,e.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=new TransformStream({transform:function(e,t){!function(e,t){zn&&e.data instanceof Blob?e.data.arrayBuffer().then(Jn).then(t):Hn&&(e.data instanceof ArrayBuffer||Gn(e.data))?t(Jn(e.data)):Vn(e,!1,(function(e){Un||(Un=new TextEncoder),t(Un.encode(e))}))}(e,(function(n){var r,o=n.length;if(o<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,o);else if(o<65536){r=new Uint8Array(3);var i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,o)}else{r=new Uint8Array(9);var a=new DataView(r.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(o))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}});o.readable.pipeTo(t.writable),e.writer=o.writable.getWriter();var i=function(){r.read().then((function(t){t.done||(e.onPacket(t.value),i())})).catch((function(e){}))};i();var a={type:"open"};e.query.sid&&(a.data='{"sid":"'.concat(e.query.sid,'"}')),e.writer.write(a).then((function(){return e.onOpen()}))}))})))}},{key:"write",value:function(e){var t=this;this.writable=!1;for(var n=function(){var n=r===e.length-1;t.writer.write(e[r]).then((function(){n&&Nr((function(){t.writable=!0,t.emitReserved("drain")}),t.setTimeoutFn)}))},r=0;r<e.length;r++)n()}},{key:"doClose",value:function(){var e;null===(e=this.transport)||void 0===e||e.close()}}])}(hr),jr={websocket:Er,webtransport:Ir,polling:Cr},Dr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Or=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Fr(e){var t,n,r=e,o=e.indexOf("["),i=e.indexOf("]");-1!=o&&-1!=i&&(e=e.substring(0,o)+e.substring(o,i).replace(/:/g,";")+e.substring(i,e.length));for(var a,s=Dr.exec(e||""),l={},c=14;c--;)l[Or[c]]=s[c]||"";return-1!=o&&-1!=i&&(l.source=r,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=(n=(t=l.path).replace(/\/{2,9}/g,"/").split("/"),"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n),l.queryKey=(a={},l.query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(a[t]=n)})),a),l}var Mr=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return R(this,t),(n=T(this,t)).binaryType="arraybuffer",n.writeBuffer=[],e&&"object"===K(e)&&(r=e,e=null),e?(e=Fr(e),r.hostname=e.host,r.secure="https"===e.protocol||"wss"===e.protocol,r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=Fr(r.host).host),ur(n,r),n.secure=null!=r.secure?r.secure:"undefined"!=typeof location&&"https:"===location.protocol,r.hostname&&!r.port&&(r.port=n.secure?"443":"80"),n.hostname=r.hostname||("undefined"!=typeof location?location.hostname:"localhost"),n.port=r.port||("undefined"!=typeof location&&location.port?location.port:n.secure?"443":"80"),n.transports=r.transports||["polling","websocket","webtransport"],n.writeBuffer=[],n.prevBufferLen=0,n.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),n.opts.path=n.opts.path.replace(/\/$/,"")+(n.opts.addTrailingSlash?"/":""),"string"==typeof n.opts.query&&(n.opts.query=function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}(n.opts.query)),n.id=null,n.upgrades=null,n.pingInterval=null,n.pingTimeout=null,n.pingTimeoutTimer=null,"function"==typeof addEventListener&&(n.opts.closeOnBeforeunload&&(n.beforeunloadEventListener=function(){n.transport&&(n.transport.removeAllListeners(),n.transport.close())},addEventListener("beforeunload",n.beforeunloadEventListener,!1)),"localhost"!==n.hostname&&(n.offlineEventListener=function(){n.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",n.offlineEventListener,!1))),n.open(),n}return M(t,e),I(t,[{key:"createTransport",value:function(e){var t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);var n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new jr[e](n)}},{key:"open",value:function(){var e,n=this;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){n.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}},{key:"setTransport",value:function(e){var t=this;this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(e){return t.onClose("transport close",e)}))}},{key:"probe",value:function(e){var n=this,r=this.createTransport(e),o=!1;t.priorWebsocketSuccess=!1;var i=function(){o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(function(e){if(!o)if("pong"===e.type&&"probe"===e.data){if(n.upgrading=!0,n.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,n.transport.pause((function(){o||"closed"!==n.readyState&&(d(),n.setTransport(r),r.send([{type:"upgrade"}]),n.emitReserved("upgrade",r),r=null,n.upgrading=!1,n.flush())}))}else{var i=new Error("probe error");i.transport=r.name,n.emitReserved("upgradeError",i)}})))};function a(){o||(o=!0,d(),r.close(),r=null)}var s=function(e){var t=new Error("probe error: "+e);t.transport=r.name,a(),n.emitReserved("upgradeError",t)};function l(){s("transport closed")}function c(){s("socket closed")}function u(e){r&&e.name!==r.name&&a()}var d=function(){r.removeListener("open",i),r.removeListener("error",s),r.removeListener("close",l),n.off("close",c),n.off("upgrading",u)};r.once("open",i),r.once("error",s),r.once("close",l),this.once("close",c),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((function(){o||r.open()}),200):r.open()}},{key:"onOpen",value:function(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(var e=0,n=this.upgrades.length;e<n;e++)this.probe(this.upgrades[e])}},{key:"onPacket",value:function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}},{key:"onHandshake",value:function(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var e=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){e.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var e,t=1,n=0;n<this.writeBuffer.length;n++){var r=this.writeBuffer[n].data;if(r&&(t+="string"==typeof(e=r)?function(e){for(var t=0,n=0,r=0,o=e.length;r<o;r++)(t=e.charCodeAt(r))<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}},{key:"write",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"send",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"sendPacket",value:function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var e=this,t=function(){e.onClose("forced close"),e.transport.close()},n=function(){e.off("upgrade",n),e.off("upgradeError",n),t()},r=function(){e.once("upgrade",n),e.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){e.upgrading?r():t()})):this.upgrading?r():t()),this}},{key:"onError",value:function(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}},{key:"onClose",value:function(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(e){for(var t=[],n=0,r=e.length;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}])}(ir);Mr.protocol=4;var Lr="function"==typeof ArrayBuffer,Pr=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer},Br=Object.prototype.toString,qr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Br.call(Blob),Ur="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Br.call(File);function $r(e){return Lr&&(e instanceof ArrayBuffer||Pr(e))||qr&&e instanceof Blob||Ur&&e instanceof File}function zr(e,t){if(!e||"object"!==K(e))return!1;if(Array.isArray(e)){for(var n=0,r=e.length;n<r;n++)if(zr(e[n]))return!0;return!1}if($r(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return zr(e.toJSON(),!0);for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&zr(e[o]))return!0;return!1}function Hr(e){var t=[],n=e;return n.data=Gr(e.data,t),n.attachments=t.length,{packet:n,buffers:t}}function Gr(e,t){if(!e)return e;if($r(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=Gr(e[o],t);return r}if("object"===K(e)&&!(e instanceof Date)){var i={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(i[a]=Gr(e[a],t));return i}return e}function Vr(e,t){return e.data=Wr(e.data,t),delete e.attachments,e}function Wr(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n]=Wr(e[n],t);else if("object"===K(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Wr(e[r],t));return e}var Jr,Kr=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Jr||(Jr={}));var Yr=function(){return I((function e(t){R(this,e),this.replacer=t}),[{key:"encode",value:function(e){return e.type!==Jr.EVENT&&e.type!==Jr.ACK||!zr(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Jr.EVENT?Jr.BINARY_EVENT:Jr.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}},{key:"encodeAsString",value:function(e){var t=""+e.type;return e.type!==Jr.BINARY_EVENT&&e.type!==Jr.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}},{key:"encodeAsBinary",value:function(e){var t=Hr(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}}])}();function Xr(e){return"[object Object]"===Object.prototype.toString.call(e)}var Zr=function(e){function t(e){var n;return R(this,t),(n=T(this,t)).reviver=e,n}return M(t,e),I(t,[{key:"add",value:function(e){var n;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");var r=(n=this.decodeString(e)).type===Jr.BINARY_EVENT;r||n.type===Jr.BINARY_ACK?(n.type=r?Jr.EVENT:Jr.ACK,this.reconstructor=new Qr(n),0===n.attachments&&V(t,"emitReserved",this,3)(["decoded",n])):V(t,"emitReserved",this,3)(["decoded",n])}else{if(!$r(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,V(t,"emitReserved",this,3)(["decoded",n]))}}},{key:"decodeString",value:function(e){var n=0,r={type:Number(e.charAt(0))};if(void 0===Jr[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Jr.BINARY_EVENT||r.type===Jr.BINARY_ACK){for(var o=n+1;"-"!==e.charAt(++n)&&n!=e.length;);var i=e.substring(o,n);if(i!=Number(i)||"-"!==e.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(n+1)){for(var a=n+1;++n&&","!==e.charAt(n)&&n!==e.length;);r.nsp=e.substring(a,n)}else r.nsp="/";var s=e.charAt(n+1);if(""!==s&&Number(s)==s){for(var l=n+1;++n;){var c=e.charAt(n);if(null==c||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(l,n+1))}if(e.charAt(++n)){var u=this.tryParse(e.substr(n));if(!t.isPayloadValid(r.type,u))throw new Error("invalid payload");r.data=u}return r}},{key:"tryParse",value:function(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}},{key:"destroy",value:function(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}],[{key:"isPayloadValid",value:function(e,t){switch(e){case Jr.CONNECT:return Xr(t);case Jr.DISCONNECT:return void 0===t;case Jr.CONNECT_ERROR:return"string"==typeof t||Xr(t);case Jr.EVENT:case Jr.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Kr.indexOf(t[0]));case Jr.ACK:case Jr.BINARY_ACK:return Array.isArray(t)}}}])}(ir),Qr=function(){return I((function e(t){R(this,e),this.packet=t,this.buffers=[],this.reconPack=t}),[{key:"takeBinaryData",value:function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=Vr(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}])}(),eo={__proto__:null,Decoder:Zr,Encoder:Yr,get PacketType(){return Jr}};function to(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var no=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ro=function(e){function t(e,n,r){var o;return R(this,t),(o=T(this,t)).connected=!1,o.recovered=!1,o.receiveBuffer=[],o.sendBuffer=[],o._queue=[],o._queueSeq=0,o.ids=0,o.acks={},o.flags={},o.io=e,o.nsp=n,r&&r.auth&&(o.auth=r.auth),o._opts=Object.assign({},r),o.io._autoConnect&&o.open(),o}return M(t,e),I(t,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var e=this.io;this.subs=[to(e,"open",this.onopen.bind(this)),to(e,"packet",this.onpacket.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.unshift("message"),this.emit.apply(this,t),this}},{key:"emit",value:function(e){if(no.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;var o={type:Jr.EVENT,data:n,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var i=this.ids++,a=n.pop();this._registerAckCallback(i,a),o.id=i}return this.flags.volatile&&(!(this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable)||!this.connected)||(this.connected?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}},{key:"_registerAckCallback",value:function(e,t){var n,r=this,o=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0!==o){var i=this.io.setTimeoutFn((function(){delete r.acks[e];for(var n=0;n<r.sendBuffer.length;n++)r.sendBuffer[n].id===e&&r.sendBuffer.splice(n,1);t.call(r,new Error("operation has timed out"))}),o);this.acks[e]=function(){r.io.clearTimeoutFn(i);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.apply(r,[null].concat(n))}}else this.acks[e]=t}},{key:"emitWithAck",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise((function(n,o){r.push((function(e,t){return i?e?o(e):n(t):n(e)})),t.emit.apply(t,[e].concat(r))}))}},{key:"_addToQueue",value:function(e){var t,n=this;"function"==typeof e[e.length-1]&&(t=e.pop());var r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((function(e){if(r===n._queue[0]){if(null!==e)r.tryCount>n._opts.retries&&(n._queue.shift(),t&&t(e));else if(n._queue.shift(),t){for(var o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t.apply(void 0,[null].concat(i))}return r.pending=!1,n._drainQueue()}})),this._queue.push(r),this._drainQueue()}},{key:"_drainQueue",value:function(){if(this.connected&&0!==this._queue.length){var e=this._queue[0];e.pending&&!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}}},{key:"packet",value:function(e){e.nsp=this.nsp,this.io._packet(e)}},{key:"onopen",value:function(){var e=this;"function"==typeof this.auth?this.auth((function(t){e._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(e){this.packet({type:Jr.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}},{key:"onerror",value:function(e){this.connected||this.emitReserved("connect_error",e)}},{key:"onclose",value:function(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}},{key:"onpacket",value:function(e){if(e.nsp===this.nsp)switch(e.type){case Jr.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Jr.EVENT:case Jr.BINARY_EVENT:this.onevent(e);break;case Jr.ACK:case Jr.BINARY_ACK:this.onack(e);break;case Jr.DISCONNECT:this.ondisconnect();break;case Jr.CONNECT_ERROR:this.destroy();var t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}},{key:"onevent",value:function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}},{key:"emitEvent",value:function(e){if(this._anyListeners&&this._anyListeners.length){var n,r=j(this._anyListeners.slice());try{for(r.s();!(n=r.n()).done;)n.value.apply(this,e)}catch(e){r.e(e)}finally{r.f()}}V(t,"emit",this,1).apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}},{key:"ack",value:function(e){var t=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];t.packet({type:Jr.ACK,id:e,data:o})}}}},{key:"onack",value:function(e){var t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}},{key:"onconnect",value:function(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}},{key:"emitBuffered",value:function(){var e=this;this.receiveBuffer.forEach((function(t){return e.emitEvent(t)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(t){e.notifyOutgoingListeners(t),e.packet(t)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(e){return e()})),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:Jr.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(e){return this.flags.compress=e,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(e){return this.flags.timeout=e,this}},{key:"onAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}},{key:"prependAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}},{key:"offAny",value:function(e){if(!this._anyListeners)return this;if(e){for(var t=this._anyListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}},{key:"prependAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}},{key:"offAnyOutgoing",value:function(e){if(!this._anyOutgoingListeners)return this;if(e){for(var t=this._anyOutgoingListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var t,n=j(this._anyOutgoingListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e.data)}catch(e){n.e(e)}finally{n.f()}}}}])}(ir);function oo(e){this.ms=(e=e||{}).min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},oo.prototype.reset=function(){this.attempts=0},oo.prototype.setMin=function(e){this.ms=e},oo.prototype.setMax=function(e){this.max=e},oo.prototype.setJitter=function(e){this.jitter=e};var io=function(e){function t(e,n){var r,o;R(this,t),(r=T(this,t)).nsps={},r.subs=[],e&&"object"===K(e)&&(n=e,e=void 0),(n=n||{}).path=n.path||"/socket.io",r.opts=n,ur(r,n),r.reconnection(!1!==n.reconnection),r.reconnectionAttempts(n.reconnectionAttempts||Infinity),r.reconnectionDelay(n.reconnectionDelay||1e3),r.reconnectionDelayMax(n.reconnectionDelayMax||5e3),r.randomizationFactor(null!==(o=n.randomizationFactor)&&void 0!==o?o:.5),r.backoff=new oo({min:r.reconnectionDelay(),max:r.reconnectionDelayMax(),jitter:r.randomizationFactor()}),r.timeout(null==n.timeout?2e4:n.timeout),r._readyState="closed",r.uri=e;var i=n.parser||eo;return r.encoder=new i.Encoder,r.decoder=new i.Decoder,r._autoConnect=!1!==n.autoConnect,r._autoConnect&&r.open(),r}return M(t,e),I(t,[{key:"reconnection",value:function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}},{key:"reconnectionAttempts",value:function(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}},{key:"reconnectionDelay",value:function(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}},{key:"randomizationFactor",value:function(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}},{key:"reconnectionDelayMax",value:function(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}},{key:"timeout",value:function(e){return arguments.length?(this._timeout=e,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(e){var t=this;if(~this._readyState.indexOf("open"))return this;this.engine=new Mr(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var o=to(n,"open",(function(){r.onopen(),e&&e()})),i=function(n){t.cleanup(),t._readyState="closed",t.emitReserved("error",n),e?e(n):t.maybeReconnectOnOpen()},a=to(n,"error",i);if(!1!==this._timeout){var s=this.setTimeoutFn((function(){o(),i(new Error("timeout")),n.close()}),this._timeout);this.opts.autoUnref&&s.unref(),this.subs.push((function(){t.clearTimeoutFn(s)}))}return this.subs.push(o),this.subs.push(a),this}},{key:"connect",value:function(e){return this.open(e)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var e=this.engine;this.subs.push(to(e,"ping",this.onping.bind(this)),to(e,"data",this.ondata.bind(this)),to(e,"error",this.onerror.bind(this)),to(e,"close",this.onclose.bind(this)),to(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}},{key:"ondecoded",value:function(e){var t=this;Nr((function(){t.emitReserved("packet",e)}),this.setTimeoutFn)}},{key:"onerror",value:function(e){this.emitReserved("error",e)}},{key:"socket",value:function(e,t){var n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new ro(this,e,t),this.nsps[e]=n),n}},{key:"_destroy",value:function(e){for(var t=0,n=Object.keys(this.nsps);t<n.length;t++)if(this.nsps[n[t]].active)return;this._close()}},{key:"_packet",value:function(e){for(var t=this.encoder.encode(e),n=0;n<t.length;n++)this.engine.write(t[n],e.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(e){return e()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var e=this;if(this._reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){t.skipReconnect||(e.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((function(n){n?(t._reconnecting=!1,t.reconnect(),e.emitReserved("reconnect_error",n)):t.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){e.clearTimeoutFn(r)}))}}},{key:"onreconnect",value:function(){var e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}])}(ir),ao={};function so(e,t){"object"===K(e)&&(t=e,e=void 0);var n,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=Fr(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),o=r.source,i=r.id;return t.forceNew||t["force new connection"]||!1===t.multiplex||ao[i]&&r.path in ao[i].nsps?n=new io(o,t):(ao[i]||(ao[i]=new io(o,t)),n=ao[i]),r.query&&!t.query&&(t.query=r.queryKey),n.socket(r.path,t)}Object.assign(so,{Manager:io,Socket:ro,io:so,connect:so});var lo=a.createSvgIcon([i.jsx("path",{d:"M17 11c.34 0 .67.04 1 .09V6.27L10.5 3 3 6.27v4.91c0 4.54 3.2 8.79 7.5 9.82.55-.13 1.08-.32 1.6-.55-.69-.98-1.1-2.17-1.1-3.45 0-3.31 2.69-6 6-6"},"0"),i.jsx("path",{d:"M17 13c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 1.38c.62 0 1.12.51 1.12 1.12s-.51 1.12-1.12 1.12-1.12-.51-1.12-1.12.5-1.12 1.12-1.12m0 5.37c-.93 0-1.74-.46-2.24-1.17.05-.72 1.51-1.08 2.24-1.08s2.19.36 2.24 1.08c-.5.71-1.31 1.17-2.24 1.17"},"1")],"AdminPanelSettings"),co=a.createSvgIcon(i.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete"),uo=a.createSvgIcon(i.jsx("path",{d:"M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2M11 16l4-4-4-4v3H1v2h10z"}),"Input"),fo=a.createSvgIcon(i.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"}),"Person"),ho=a.createSvgIcon(i.jsx("path",{d:"M16.54 11 13 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zM11 7H2v2h9zm10 6.41L19.59 12 17 14.59 14.41 12 13 13.41 15.59 16 13 18.59 14.41 20 17 17.41 19.59 20 21 18.59 18.41 16zM11 15H2v2h9z"}),"Rule"),po=function(){function e(e){var t=this;this._insertTag=function(e){t.container.insertBefore(e,0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling),t.tags.push(e)},this.isSpeedy=void 0===e.speedy?"production"===ae.env.NODE_ENV:e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if("production"!==ae.env.NODE_ENV){var n=64===e.charCodeAt(0)&&105===e.charCodeAt(1);n&&this._alreadyInsertedOrderInsensitiveRule&&console.error("You're attempting to insert the following rule:\n"+e+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!n}if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"===ae.env.NODE_ENV||/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(e)||console.error('There was a problem inserting the following rule: "'+e+'"',t)}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0,"production"!==ae.env.NODE_ENV&&(this._alreadyInsertedOrderInsensitiveRule=!1)},e}(),go="-ms-",mo="-moz-",yo="-webkit-",_o="comm",vo="rule",bo="decl",xo="@keyframes",wo=Math.abs,So=String.fromCharCode,Co=Object.assign;function Ao(e){return e.trim()}function ko(e,t,n){return e.replace(t,n)}function No(e,t){return e.indexOf(t)}function To(e,t){return 0|e.charCodeAt(t)}function Ro(e,t,n){return e.slice(t,n)}function Eo(e){return e.length}function Io(e){return e.length}function jo(e,t){return t.push(e),e}var Do=1,Oo=1,Fo=0,Mo=0,Lo=0,Po="";function Bo(e,t,n,r,o,i,a){return{value:e,root:t,parent:n,type:r,props:o,children:i,line:Do,column:Oo,length:a,return:""}}function qo(e,t){return Co(Bo("",null,null,"",null,null,0),e,{length:-e.length},t)}function Uo(){return Lo=Mo>0?To(Po,--Mo):0,Oo--,10===Lo&&(Oo=1,Do--),Lo}function $o(){return Lo=Mo<Fo?To(Po,Mo++):0,Oo++,10===Lo&&(Oo=1,Do++),Lo}function zo(){return To(Po,Mo)}function Ho(){return Mo}function Go(e,t){return Ro(Po,e,t)}function Vo(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Wo(e){return Do=Oo=1,Fo=Eo(Po=e),Mo=0,[]}function Jo(e){return Po="",e}function Ko(e){return Ao(Go(Mo-1,Zo(91===e?e+2:40===e?e+1:e)))}function Yo(e){for(;(Lo=zo())&&Lo<33;)$o();return Vo(e)>2||Vo(Lo)>3?"":" "}function Xo(e,t){for(;--t&&$o()&&!(Lo<48||Lo>102||Lo>57&&Lo<65||Lo>70&&Lo<97););return Go(e,Ho()+(t<6&&32==zo()&&32==$o()))}function Zo(e){for(;$o();)switch(Lo){case e:return Mo;case 34:case 39:34!==e&&39!==e&&Zo(Lo);break;case 40:41===e&&Zo(e);break;case 92:$o()}return Mo}function Qo(e,t){for(;$o()&&e+Lo!==57&&(e+Lo!==84||47!==zo()););return"/*"+Go(t,Mo-1)+"*"+So(47===e?e:$o())}function ei(e){for(;!Vo(zo());)$o();return Go(e,Mo)}function ti(e){return Jo(ni("",null,null,null,[""],e=Wo(e),0,[0],e))}function ni(e,t,n,r,o,i,a,s,l){for(var c=0,u=0,d=a,f=0,h=0,p=0,g=1,m=1,y=1,_=0,v="",b=o,x=i,w=r,S=v;m;)switch(p=_,_=$o()){case 40:if(108!=p&&58==To(S,d-1)){-1!=No(S+=ko(Ko(_),"&","&\f"),"&\f")&&(y=-1);break}case 34:case 39:case 91:S+=Ko(_);break;case 9:case 10:case 13:case 32:S+=Yo(p);break;case 92:S+=Xo(Ho()-1,7);continue;case 47:switch(zo()){case 42:case 47:jo(oi(Qo($o(),Ho()),t,n),l);break;default:S+="/"}break;case 123*g:s[c++]=Eo(S)*y;case 125*g:case 59:case 0:switch(_){case 0:case 125:m=0;case 59+u:-1==y&&(S=ko(S,/\f/g,"")),h>0&&Eo(S)-d&&jo(h>32?ii(S+";",r,n,d-1):ii(ko(S," ","")+";",r,n,d-2),l);break;case 59:S+=";";default:if(jo(w=ri(S,t,n,c,u,o,s,v,b=[],x=[],d),i),123===_)if(0===u)ni(S,t,w,w,b,i,d,s,x);else switch(99===f&&110===To(S,3)?100:f){case 100:case 108:case 109:case 115:ni(e,w,w,r&&jo(ri(e,w,w,0,0,o,s,v,o,b=[],d),x),o,x,d,s,r?b:x);break;default:ni(S,w,w,w,[""],x,0,s,x)}}c=u=h=0,g=y=1,v=S="",d=a;break;case 58:d=1+Eo(S),h=p;default:if(g<1)if(123==_)--g;else if(125==_&&0==g++&&125==Uo())continue;switch(S+=So(_),_*g){case 38:y=u>0?1:(S+="\f",-1);break;case 44:s[c++]=(Eo(S)-1)*y,y=1;break;case 64:45===zo()&&(S+=Ko($o())),f=zo(),u=d=Eo(v=S+=ei(Ho())),_++;break;case 45:45===p&&2==Eo(S)&&(g=0)}}return i}function ri(e,t,n,r,o,i,a,s,l,c,u){for(var d=o-1,f=0===o?i:[""],h=Io(f),p=0,g=0,m=0;p<r;++p)for(var y=0,_=Ro(e,d+1,d=wo(g=a[p])),v=e;y<h;++y)(v=Ao(g>0?f[y]+" "+_:ko(_,/&\f/g,f[y])))&&(l[m++]=v);return Bo(e,t,n,0===o?vo:s,l,c,u)}function oi(e,t,n){return Bo(e,t,n,_o,So(Lo),Ro(e,2,-2),0)}function ii(e,t,n,r){return Bo(e,t,n,bo,Ro(e,0,r),Ro(e,r+1,-1),r)}function ai(e,t){for(var n="",r=Io(e),o=0;o<r;o++)n+=t(e[o],o,e,t)||"";return n}function si(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case bo:return e.return=e.return||e.value;case _o:return"";case xo:return e.return=e.value+"{"+ai(e.children,r)+"}";case vo:e.value=e.props.join(",")}return Eo(n=ai(e.children,r))?e.return=e.value+"{"+n+"}":""}function li(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ci=function(e,t,n){for(var r=0,o=0;r=o,o=zo(),38===r&&12===o&&(t[n]=1),!Vo(o);)$o();return Go(e,Mo)},ui=new WeakMap,di=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||ui.get(n))&&!r){ui.set(e,!0);for(var o=[],i=function(e,t){return Jo(function(e,t){var n=-1,r=44;do{switch(Vo(r)){case 0:38===r&&12===zo()&&(t[n]=1),e[n]+=ci(Mo-1,t,n);break;case 2:e[n]+=Ko(r);break;case 4:if(44===r){e[++n]=58===zo()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=So(r)}}while(r=$o());return e}(Wo(e),t))}(t,o),a=n.props,s=0,l=0;s<i.length;s++)for(var c=0;c<a.length;c++,l++)e.props[l]=o[s]?i[s].replace(/&\f/g,a[c]):a[c]+" "+i[s]}}},fi=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},hi=function(e){return"comm"===e.type&&e.children.indexOf("emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason")>-1},pi=function(e){return 105===e.type.charCodeAt(1)&&64===e.type.charCodeAt(0)},gi=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},mi=function(e,t,n){pi(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),gi(e)):function(e,t){for(var n=e-1;n>=0;n--)if(!pi(t[n]))return!0;return!1}(t,n)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),gi(e)))};function yi(e,t){switch(function(e,t){return 45^To(e,0)?(((t<<2^To(e,0))<<2^To(e,1))<<2^To(e,2))<<2^To(e,3):0}(e,t)){case 5103:return yo+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return yo+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return yo+e+mo+e+go+e+e;case 6828:case 4268:return yo+e+go+e+e;case 6165:return yo+e+go+"flex-"+e+e;case 5187:return yo+e+ko(e,/(\w+).+(:[^]+)/,yo+"box-$1$2"+go+"flex-$1$2")+e;case 5443:return yo+e+go+"flex-item-"+ko(e,/flex-|-self/,"")+e;case 4675:return yo+e+go+"flex-line-pack"+ko(e,/align-content|flex-|-self/,"")+e;case 5548:return yo+e+go+ko(e,"shrink","negative")+e;case 5292:return yo+e+go+ko(e,"basis","preferred-size")+e;case 6060:return yo+"box-"+ko(e,"-grow","")+yo+e+go+ko(e,"grow","positive")+e;case 4554:return yo+ko(e,/([^-])(transform)/g,"$1"+yo+"$2")+e;case 6187:return ko(ko(ko(e,/(zoom-|grab)/,yo+"$1"),/(image-set)/,yo+"$1"),e,"")+e;case 5495:case 3959:return ko(e,/(image-set\([^]*)/,yo+"$1$`$1");case 4968:return ko(ko(e,/(.+:)(flex-)?(.*)/,yo+"box-pack:$3"+go+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+yo+e+e;case 4095:case 3583:case 4068:case 2532:return ko(e,/(.+)-inline(.+)/,yo+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Eo(e)-1-t>6)switch(To(e,t+1)){case 109:if(45!==To(e,t+4))break;case 102:return ko(e,/(.+:)(.+)-([^]+)/,"$1"+yo+"$2-$3$1"+mo+(108==To(e,t+3)?"$3":"$2-$3"))+e;case 115:return~No(e,"stretch")?yi(ko(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==To(e,t+1))break;case 6444:switch(To(e,Eo(e)-3-(~No(e,"!important")&&10))){case 107:return ko(e,":",":"+yo)+e;case 101:return ko(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+yo+(45===To(e,14)?"inline-":"")+"box$3$1"+yo+"$2$3$1"+go+"$2box$3")+e}break;case 5936:switch(To(e,t+11)){case 114:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return yo+e+go+ko(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return yo+e+go+e+e}return e}var _i=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case bo:e.return=yi(e.value,e.length);break;case xo:return ai([qo(e,{value:ko(e.value,"@","@"+yo)})],r);case vo:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return ai([qo(e,{props:[ko(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return ai([qo(e,{props:[ko(t,/:(plac\w+)/,":"+yo+"input-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,":-moz-$1")]}),qo(e,{props:[ko(t,/:(plac\w+)/,go+"input-$1")]})],r)}return""}))}}],vi=function(e){var t=e.key;if("production"!==ae.env.NODE_ENV&&!t)throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\nIf multiple caches share the same key they might \"fight\" for each other's style elements.");if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r=e.stylisPlugins||_i;if("production"!==ae.env.NODE_ENV&&/[^a-z-]/.test(t))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+t+'" was passed');var o,i,a={},s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)a[t[n]]=!0;s.push(e)}));var l=[di,fi];"production"!==ae.env.NODE_ENV&&l.push(function(e){return function(t,n,r){if("rule"===t.type&&!e.compat){var o=t.value.match(/(:first|:nth|:nth-last)-child/g);if(o){for(var i=t.parent?t.parent.children:r,a=i.length-1;a>=0;a--){var s=i[a];if(s.line<t.line)break;if(s.column<t.column){if(hi(s))return;break}}o.forEach((function(e){console.error('The pseudo class "'+e+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+e.split("-child")[0]+'-of-type".')}))}}}}({get compat(){return h.compat}}),mi);var c,u,d=[si,"production"!==ae.env.NODE_ENV?function(e){e.root||(e.return?c.insert(e.return):e.value&&e.type!==_o&&c.insert(e.value+"{}"))}:(u=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&u(e)})],f=function(e){var t=Io(e);return function(n,r,o,i){for(var a="",s=0;s<t;s++)a+=e[s](n,r,o,i)||"";return a}}(l.concat(r,d));i=function(e,t,n,r){c=n,"production"!==ae.env.NODE_ENV&&void 0!==t.map&&(c={insert:function(e){n.insert(e+t.map)}}),function(e){ai(ti(e),f)}(e?e+"{"+t.styles+"}":t.styles),r&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new po({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:i};return h.sheet.hydrate(s),h};function bi(){return bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bi.apply(this,arguments)}function xi(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r}var wi=function(e,t,n){var r=e.key+"-"+t.name;!1===n&&void 0===e.registered[r]&&(e.registered[r]=t.styles)},Si=function(e,t,n){wi(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}},Ci={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ai="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",ki=/[A-Z]|^ms/g,Ni=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ti=function(e){return 45===e.charCodeAt(1)},Ri=function(e){return null!=e&&"boolean"!=typeof e},Ei=li((function(e){return Ti(e)?e:e.replace(ki,"-$&").toLowerCase()})),Ii=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Ni,(function(e,t,n){return Ui={name:t,styles:n,next:Ui},t}))}return 1===Ci[e]||Ti(e)||"number"!=typeof t||0===t?t:t+"px"};if("production"!==ae.env.NODE_ENV){var ji=/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/,Di=["normal","none","initial","inherit","unset"],Oi=Ii,Fi=/^-ms-/,Mi=/-(.)/g,Li={};Ii=function(e,t){if("content"===e&&("string"!=typeof t||-1===Di.indexOf(t)&&!ji.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0))))throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`");var n=Oi(e,t);return""===n||Ti(e)||-1===e.indexOf("-")||void 0!==Li[e]||(Li[e]=!0,console.error("Using kebab-case for css properties in objects is not supported. Did you mean "+e.replace(Fi,"ms-").replace(Mi,(function(e,t){return t.toUpperCase()}))+"?")),n}}var Pi="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Bi(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles){if("production"!==ae.env.NODE_ENV&&"NO_COMPONENT_SELECTOR"===n.toString())throw new Error(Pi);return n}switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return Ui={name:n.name,styles:n.styles,next:Ui},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)Ui={name:r.name,styles:r.styles,next:Ui},r=r.next;var o=n.styles+";";return"production"!==ae.env.NODE_ENV&&void 0!==n.map&&(o+=n.map),o}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=Bi(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a))null!=t&&void 0!==t[a]?r+=i+"{"+t[a]+"}":Ri(a)&&(r+=Ei(i)+":"+Ii(i,a)+";");else{if("NO_COMPONENT_SELECTOR"===i&&"production"!==ae.env.NODE_ENV)throw new Error(Pi);if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var s=Bi(e,t,a);switch(i){case"animation":case"animationName":r+=Ei(i)+":"+s+";";break;default:"production"!==ae.env.NODE_ENV&&"undefined"===i&&console.error("You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key)."),r+=i+"{"+s+"}"}}else for(var l=0;l<a.length;l++)Ri(a[l])&&(r+=Ei(i)+":"+Ii(i,a[l])+";")}}return r}(e,t,n);case"function":if(void 0!==e){var i=Ui,a=n(e);return Ui=i,Bi(e,t,a)}"production"!==ae.env.NODE_ENV&&console.error("Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`");break;case"string":if("production"!==ae.env.NODE_ENV){var s=[],l=n.replace(Ni,(function(e,t,n){var r="animation"+s.length;return s.push("const "+r+" = keyframes`"+n.replace(/^@keyframes animation-\w+/,"")+"`"),"${"+r+"}"}));s.length&&console.error("`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\nInstead of doing this:\n\n"+[].concat(s,["`"+l+"`"]).join("\n")+"\n\nYou should wrap it with `css` like this:\n\ncss`"+l+"`")}}if(null==t)return n;var c=t[n];return void 0!==c?c:n}var qi,Ui,$i=/label:\s*([^\s;\n{]+)\s*(;|$)/g;"production"!==ae.env.NODE_ENV&&(qi=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g);var zi=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";Ui=void 0;var i,a=e[0];null==a||void 0===a.raw?(r=!1,o+=Bi(n,t,a)):("production"!==ae.env.NODE_ENV&&void 0===a[0]&&console.error(Ai),o+=a[0]);for(var s=1;s<e.length;s++)o+=Bi(n,t,e[s]),r&&("production"!==ae.env.NODE_ENV&&void 0===a[s]&&console.error(Ai),o+=a[s]);"production"!==ae.env.NODE_ENV&&(o=o.replace(qi,(function(e){return i=e,""}))),$i.lastIndex=0;for(var l,c="";null!==(l=$i.exec(o));)c+="-"+l[1];var u=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+c;return"production"!==ae.env.NODE_ENV?{name:u,styles:o,map:i,next:Ui,toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}:{name:u,styles:o,next:Ui}},Hi=!!w.useInsertionEffect&&w.useInsertionEffect||function(e){return e()},Gi={}.hasOwnProperty,Vi=w.createContext("undefined"!=typeof HTMLElement?vi({key:"css"}):null);"production"!==ae.env.NODE_ENV&&(Vi.displayName="EmotionCacheContext");var Wi=function(e){return u.forwardRef((function(t,n){var r=u.useContext(Vi);return e(t,r,n)}))},Ji=w.createContext({});"production"!==ae.env.NODE_ENV&&(Ji.displayName="EmotionThemeContext");var Ki="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",Yi="__EMOTION_LABEL_PLEASE_DO_NOT_USE__",Xi=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},Zi=Wi((function(e,t,n){var r=e.css;"string"==typeof r&&void 0!==t.registered[r]&&(r=t.registered[r]);var o=e[Ki],i=[r],a="";"string"==typeof e.className?a=xi(t.registered,i,e.className):null!=e.className&&(a=e.className+" ");var s=zi(i,void 0,w.useContext(Ji));if("production"!==ae.env.NODE_ENV&&-1===s.name.indexOf("-")){var l=e[Yi];l&&(s=zi([s,"label:"+l+";"]))}a+=t.key+"-"+s.name;var c={};for(var u in e)!Gi.call(e,u)||"css"===u||u===Ki||"production"!==ae.env.NODE_ENV&&u===Yi||(c[u]=e[u]);return c.ref=n,c.className=a,w.createElement(w.Fragment,null,w.createElement(Xi,{cache:t,serialized:s,isStringTag:"string"==typeof o}),w.createElement(o,c))}));"production"!==ae.env.NODE_ENV&&(Zi.displayName="EmotionCssPropInternal");var Qi={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function ea(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var ta=/[A-Z]|^ms/g,na=/_EMO_([^_]+?)_([^]*?)_EMO_/g,ra=function(e){return 45===e.charCodeAt(1)},oa=function(e){return null!=e&&"boolean"!=typeof e},ia=ea((function(e){return ra(e)?e:e.replace(ta,"-$&").toLowerCase()})),aa=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(na,(function(e,t,n){return la={name:t,styles:n,next:la},t}))}return 1===Qi[e]||ra(e)||"number"!=typeof t||0===t?t:t+"px"};function sa(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(K(n)){case"boolean":return"";case"object":if(1===n.anim)return la={name:n.name,styles:n.styles,next:la},n.name;var r=n;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)la={name:o.name,styles:o.styles,next:la},o=o.next;return r.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var o=0;o<n.length;o++)r+=sa(e,t,n[o])+";";else for(var i in n){var a=n[i];if("object"!==K(a)){var s=a;null!=t&&void 0!==t[s]?r+=i+"{"+t[s]+"}":oa(s)&&(r+=ia(i)+":"+aa(i,s)+";")}else if(!Array.isArray(a)||"string"!=typeof a[0]||null!=t&&void 0!==t[a[0]]){var l=sa(e,t,a);switch(i){case"animation":case"animationName":r+=ia(i)+":"+l+";";break;default:r+=i+"{"+l+"}"}}else for(var c=0;c<a.length;c++)oa(a[c])&&(r+=ia(i)+":"+aa(i,a[c])+";")}return r}(e,t,n)}if(null==t)return n;var i=t[n];return void 0!==i?i:n}var la,ca=/label:\s*([^\s;{]+)\s*(;|$)/g,ua=function(e){for(var t=e.length,n=0,r="";n<t;n++){var o=e[n];if(null!=o){var i=void 0;switch(K(o)){case"boolean":break;case"object":if(Array.isArray(o))i=ua(o);else{var a=o;for(var s in i="",a)a[s]&&s&&(i&&(i+=" "),i+=s)}break;default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},da=function(){return{createCssAndCx:function(e){var t=e.cache,n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var o=function(e,t,n){if(1===e.length&&"object"===K(e[0])&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,o="";la=void 0;var i=e[0];null==i||void 0===i.raw?(r=!1,o+=sa(n,t,i)):o+=i[0];for(var a=1;a<e.length;a++)o+=sa(n,t,e[a]),r&&(o+=i[a]);ca.lastIndex=0;for(var s,l="";null!==(s=ca.exec(o));)l+="-"+s[1];var c=function(e){for(var t,n=0,r=0,o=e.length;o>=4;++r,o-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(o){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(o)+l;return{name:c,styles:o,next:la}}(n,t.registered);!function(e,t,n){!function(e,t,n){var r=e.key+"-"+t.name;void 0===e.registered[r]&&(e.registered[r]=t.styles)}(e,t);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}}(t,o);var i="".concat(t.key,"-").concat(o.name),a=n[0];return function(e){return e instanceof Object&&!("styles"in e)&&!("length"in e)&&!("__emotion_styles"in e)}(a)&&ha.saveClassNameCSSObjectMapping(t,i,a),i};return{css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=ua(r),a=ha.fixClassName(t,i,n);return function(e,t,n){var r=[],o=function(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(r+=n+" ")})),r}(e,r,n);return r.length<2?n:o+t(r)}(t.registered,n,a)}}}}}(),fa=da.createCssAndCx,ha=function(){var e=new WeakMap;return{saveClassNameCSSObjectMapping:function(t,n,r){var o=e.get(t);void 0===o&&(o=new Map,e.set(t,o)),o.set(n,r)},fixClassName:function(t,n,r){if(!n.includes(" "))return n;var o,i,a=e.get(t);return ua((o=n.split(" ").map((function(e){return[e,null==a?void 0:a.get(e)]})),i=!1,o.map((function(e){var t,n=G(e,2),r=n[0],o=n[1];if(void 0===o)return r;if(i)t={"&&":o};else for(var a in t=r,o)if(a.startsWith("@media")){i=!0;break}return t}))).map((function(e){return"string"==typeof e?e:r(e)})))}}}(),pa=function(){return u.useContext(Vi)};function ga(e){var t=e.useTheme,n=function(e){var t=e.useCache;return{useCssAndCx:function(){var e=t(),n=u.useMemo((function(){return fa({cache:e})}),[e]);return{css:n.css,cx:n.cx}}}}({useCache:pa}),r=n.useCssAndCx;return{makeStyles:function(){return function(e){var n="function"==typeof e?e:function(){return e};return function(e,o){var i=t(),a=r(),s=a.css,l=a.cx,c=u.useMemo((function(){for(var e=n(i),t={},r=0,o=Object.keys(e);r<o.length;r++){var a=o[r];t[a]=s(e[a])}return t}),[s,i]),d=null==o?void 0:o.props.classes,f=function(e){if(!(e instanceof Object)||"function"==typeof e)return e;var t=[];for(var n in e){var r=e[n],o=K(r);if("string"!==o&&("number"!==o||isNaN(r))&&"boolean"!==o&&null!=r)return e;t.push("".concat(n,":").concat(o,"_").concat(r))}return"xSqLiJdLMd9s".concat(t.join("|"))}(d),h=u.useMemo((function(){return d?function(e,t,n){if(!(t instanceof Object))return e;var r=Object.keys(t);if(0===r.length)return e;for(var o={},i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];o[s]=n(e[s],t[s])}for(var l=0,c=r;l<c.length;l++){var u=c[l];if(!(u in e)){var d=t[u];"string"==typeof d&&(o[u]=d)}}return o}(c,d,l):c}),[c,f,l]);return{classes:h,theme:i,css:s,cx:l}}}}}}var ma=ga({useTheme:g.useTheme}).makeStyles,ya=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info"),_a=a.createSvgIcon(i.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link"),va=a.createSvgIcon(i.jsx("path",{d:"M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5m0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonChecked"),ba=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"RadioButtonUnchecked");function xa(e){const{attributes:t}=e,n=t.get("gff_name");return n?n[0]:""}function wa(e){const{attributes:t}=e,n=t.get("gff_id"),r=t.get("transcript_id"),o=t.get("exon_id"),i=t.get("protein_id");return n?n[0]:r?r[0]:o?o[0]:i?i[0]:""}function Sa(e){const t=xa(e),n=wa(e);return t?`: ${t}`:n?`: ${n}`:""}function Ca(e,t,n=!1){const r=[];r.push(e);for(const t of function(e){const t=[];let{parent:n}=e;for(;n;)t.push(n),({parent:n}=n);return t}(e))r.push(t);const o=function(e){const t=[];if(e.children)for(const[,n]of e.children)t.push(n);return t}(e);for(const e of o)e.min<t&&e.max>=t&&r.push(e);if(!n)return r;if(e.parent){const n=e.parent.children;if(n)for(const[,o]of n)o._id!=e._id&&o.min<t&&o.max>=t&&r.push(o)}return r}function Aa(e,t){if(e.attributes){const n={};for(const[r,o]of Object.entries(e.attributes))t.has(r)||(n[r]=o);e.attributes=0===Object.keys(n).length?void 0:n}if(e.children){const n={};for(const[r,o]of Object.entries(e.children)){const e={...o};Aa(e,t),n[r]=e}e.children=n}}var ka,Na,Ta=a.createSvgIcon(i.jsx("path",{d:"m7.58 16.89 5.77-4.07c.56-.4.56-1.24 0-1.63L7.58 7.11C6.91 6.65 6 7.12 6 7.93v8.14c0 .81.91 1.28 1.58.82M16 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1"}),"SkipNextRounded"),Ra=a.createSvgIcon(i.jsx("path",{d:"M7 6c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1s-1-.45-1-1V7c0-.55.45-1 1-1m3.66 6.82 5.77 4.07c.66.47 1.58-.01 1.58-.82V7.93c0-.81-.91-1.28-1.58-.82l-5.77 4.07c-.57.4-.57 1.24 0 1.64"}),"SkipPreviousRounded"),Ea=function(e,t){return t.some((function(t){return e instanceof t}))},Ia=new WeakMap,ja=new WeakMap,Da=new WeakMap,Oa=new WeakMap,Fa=new WeakMap,Ma={get:function(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return ja.get(e);if("objectStoreNames"===t)return e.objectStoreNames||Da.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pa(e[t])},set:function(e,t,n){return e[t]=n,!0},has:function(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function La(e){Ma=e(Ma)}function Pa(e){if(e instanceof IDBRequest)return t=e,(n=new Promise((function(e,n){var r=function(){t.removeEventListener("success",o),t.removeEventListener("error",i)},o=function(){e(Pa(t.result)),r()},i=function(){n(t.error),r()};t.addEventListener("success",o),t.addEventListener("error",i)}))).then((function(e){e instanceof IDBCursor&&Ia.set(e,t)})).catch((function(){})),Fa.set(n,t),n;var t,n;if(Oa.has(e))return Oa.get(e);var r=function(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Na||(Na=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(Ba(this),n),Pa(Ia.get(this))}:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Pa(t.apply(Ba(this),n))}:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.call.apply(t,[Ba(this),e].concat(r));return Da.set(i,e.sort?e.sort():[e]),Pa(i)}:(e instanceof IDBTransaction&&function(e){if(!ja.has(e)){var t=new Promise((function(t,n){var r=function(){e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=function(){t(),r()},i=function(){n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));ja.set(e,t)}}(e),Ea(e,ka||(ka=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Ma):e);var t}(e);return r!==e&&(Oa.set(e,r),Fa.set(r,e)),r}var Ba=function(e){return Fa.get(e)};function qa(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.blocked,o=n.upgrade,i=n.blocking,a=n.terminated,s=indexedDB.open(e,t),l=Pa(s);return o&&s.addEventListener("upgradeneeded",(function(e){o(Pa(s.result),e.oldVersion,e.newVersion,Pa(s.transaction),e)})),r&&s.addEventListener("blocked",(function(e){return r(e.oldVersion,e.newVersion,e)})),l.then((function(e){a&&e.addEventListener("close",(function(){return a()})),i&&e.addEventListener("versionchange",(function(e){return i(e.oldVersion,e.newVersion,e)}))})).catch((function(){})),l}var Ua=["get","getKey","getAll","getAllKeys","count"],$a=["put","add","delete","clear"],za=new Map;function Ha(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(za.get(t))return za.get(t);var n=t.replace(/FromIndex$/,""),r=t!==n,o=$a.includes(n);if(n in(r?IDBIndex:IDBObjectStore).prototype&&(o||Ua.includes(n))){var i=function(){var e=k(U().m((function e(t){var i,a,s,l,c,u,d=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:for(a=this.transaction(t,o?"readwrite":"readonly"),s=a.store,l=d.length,c=new Array(l>1?l-1:0),u=1;u<l;u++)c[u-1]=d[u];return r&&(s=s.index(c.shift())),e.n=1,Promise.all([(i=s)[n].apply(i,c),o&&a.done]);case 1:return e.a(2,e.v[0])}}),e,this)})));return function(t){return e.apply(this,arguments)}}();return za.set(t,i),i}}}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Ha(t,n)||e.get(t,n,r)},has:function(t,n){return!!Ha(t,n)||e.has(t,n)}})}));var Ga=["continue","continuePrimaryKey","advance"],Va={},Wa=new WeakMap,Ja=new WeakMap,Ka={get:function(e,t){if(!Ga.includes(t))return e[t];var n=Va[t];return n||(n=Va[t]=function(){var e;Wa.set(this,(e=Ja.get(this))[t].apply(e,arguments))}),n}};function Ya(){return Xa.apply(this,arguments)}function Xa(){return Xa=function(e){return function(){return new X(e.apply(this,arguments))}}(U().m((function e(){var t,n,r,o=arguments;return U().w((function(e){for(;;)switch(e.n){case 0:if((t=this)instanceof IDBCursor){e.n=2;break}return e.n=1,N((n=t).openCursor.apply(n,o));case 1:t=e.v;case 2:if(t){e.n=3;break}return e.a(2);case 3:r=new Proxy(t,Ka),Ja.set(r,t),Fa.set(r,Ba(t));case 4:if(!t){e.n=7;break}return e.n=5,r;case 5:return e.n=6,N(Wa.get(r)||t.continue());case 6:t=e.v,Wa.delete(r),e.n=4;break;case 7:return e.a(2)}}),e,this)}))),Xa.apply(this,arguments)}function Za(e,t){return t===Symbol.asyncIterator&&Ea(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&Ea(e,[IDBIndex,IDBObjectStore])}La((function(e){return B(B({},e),{},{get:function(t,n,r){return Za(t,n)?Ya:e.get(t,n,r)},has:function(t,n){return Za(t,n)||e.has(t,n)}})}));var Qa=function(e){function t(){var e;R(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return D(e=T(this,t,[].concat(r)),"code",void 0),e}return M(t,e),I(t)}(Z(Error));function es(e){if(e){if(!(e instanceof AbortSignal))throw new TypeError("must pass an AbortSignal");if(e.aborted)throw function(){if("undefined"!=typeof DOMException)return new DOMException("aborted","AbortError");var e=new Qa("aborted");return e.code="ERR_ABORTED",e}()}}function ts(e){return e instanceof Error&&("AbortError"===e.name||"ERR_ABORTED"===e.code||/\b(aborted|aborterror)\b/i.test(e.message))}function ns(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rs,os={exports:{}},is=(rs||(rs=1,function(e,t){e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(!s&&ns)return ns(a);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return o(t[a][1][e]||e)}),c,c.exports,e,t,n,r)}return n[a].exports}for(var i=ns,a=0;a<r.length;a++)o(r[a]);return o}({"./aesprim":[function(e,t,n){var r;r=function(e){var t,n,r,o,i,a,s,l,c,u,d,f,h,p,g,m,y,_;function v(e,t){if(!e)throw new Error("ASSERT: "+t)}function b(e){return e>=48&&e<=57}function x(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function w(e){return"01234567".indexOf(e)>=0}function S(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function C(e){return 10===e||13===e||8232===e||8233===e}function A(e){return 64==e||36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&s.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function k(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&s.NonAsciiIdentifierPart.test(String.fromCharCode(e))}function N(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function T(e){return"eval"===e||"arguments"===e}function R(e){if(u&&N(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function E(e,t,n,r,o){var i;v("number"==typeof n,"Comment must have valid position"),y.lastCommentStart>=n||(y.lastCommentStart=n,i={type:e,value:t},_.range&&(i.range=[n,r]),_.loc&&(i.loc=o),_.comments.push(i),_.attachComment&&(_.leadingComments.push(i),_.trailingComments.push(i)))}function I(e){var t,n,r,o;for(t=d-e,n={start:{line:f,column:d-h-e}};d<p;)if(r=c.charCodeAt(d),++d,C(r))return _.comments&&(o=c.slice(t+e,d-1),n.end={line:f,column:d-h-1},E("Line",o,t,d-1,n)),13===r&&10===c.charCodeAt(d)&&++d,++f,void(h=d);_.comments&&(o=c.slice(t+e,d),n.end={line:f,column:d-h},E("Line",o,t,d,n))}function j(){var e,t,n,r;for(_.comments&&(e=d-2,t={start:{line:f,column:d-h-2}});d<p;)if(C(n=c.charCodeAt(d)))13===n&&10===c.charCodeAt(d+1)&&++d,++f,++d,h=d,d>=p&&J({},a.UnexpectedToken,"ILLEGAL");else if(42===n){if(47===c.charCodeAt(d+1))return++d,++d,void(_.comments&&(r=c.slice(e+2,d-2),t.end={line:f,column:d-h},E("Block",r,e,d,t)));++d}else++d;J({},a.UnexpectedToken,"ILLEGAL")}function D(){var e,t;for(t=0===d;d<p;)if(S(e=c.charCodeAt(d)))++d;else if(C(e))++d,13===e&&10===c.charCodeAt(d)&&++d,++f,h=d,t=!0;else if(47===e)if(47===(e=c.charCodeAt(d+1)))++d,++d,I(2),t=!0;else{if(42!==e)break;++d,++d,j()}else if(t&&45===e){if(45!==c.charCodeAt(d+1)||62!==c.charCodeAt(d+2))break;d+=3,I(3)}else{if(60!==e)break;if("!--"!==c.slice(d+1,d+4))break;++d,++d,++d,++d,I(4)}}function O(e){var t,n,r,o=0;for(n="u"===e?4:2,t=0;t<n;++t){if(!(d<p&&x(c[d])))return"";r=c[d++],o=16*o+"0123456789abcdef".indexOf(r.toLowerCase())}return String.fromCharCode(o)}function F(){var e,t;for(e=c.charCodeAt(d++),t=String.fromCharCode(e),92===e&&(117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&A(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t=e);d<p&&k(e=c.charCodeAt(d));)++d,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==c.charCodeAt(d)&&J({},a.UnexpectedToken,"ILLEGAL"),++d,(e=O("u"))&&"\\"!==e&&k(e.charCodeAt(0))||J({},a.UnexpectedToken,"ILLEGAL"),t+=e);return t}function M(){var e,t;for(e=d++;d<p;){if(92===(t=c.charCodeAt(d)))return d=e,F();if(!k(t))break;++d}return c.slice(e,d)}function L(){var e,n,r,o,i=d,s=c.charCodeAt(d),l=c[d];switch(s){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++d,_.tokenize&&(40===s?_.openParenToken=_.tokens.length:123===s&&(_.openCurlyToken=_.tokens.length)),{type:t.Punctuator,value:String.fromCharCode(s),lineNumber:f,lineStart:h,start:i,end:d};default:if(61===(e=c.charCodeAt(d+1)))switch(s){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return d+=2,{type:t.Punctuator,value:String.fromCharCode(s)+String.fromCharCode(e),lineNumber:f,lineStart:h,start:i,end:d};case 33:case 61:return 61===c.charCodeAt(d+=2)&&++d,{type:t.Punctuator,value:c.slice(i,d),lineNumber:f,lineStart:h,start:i,end:d}}}return">>>="===(o=c.substr(d,4))?{type:t.Punctuator,value:o,lineNumber:f,lineStart:h,start:i,end:d+=4}:">>>"===(r=o.substr(0,3))||"<<="===r||">>="===r?{type:t.Punctuator,value:r,lineNumber:f,lineStart:h,start:i,end:d+=3}:l===(n=r.substr(0,2))[1]&&"+-<>&|".indexOf(l)>=0||"=>"===n?{type:t.Punctuator,value:n,lineNumber:f,lineStart:h,start:i,end:d+=2}:"<>=!+-*%&|^/".indexOf(l)>=0?(++d,{type:t.Punctuator,value:l,lineNumber:f,lineStart:h,start:i,end:d}):void J({},a.UnexpectedToken,"ILLEGAL")}function P(){var e,n,r;if(v(b((r=c[d]).charCodeAt(0))||"."===r,"Numeric literal must start with a decimal digit or a decimal point"),n=d,e="","."!==r){if(e=c[d++],r=c[d],"0"===e){if("x"===r||"X"===r)return++d,function(e){for(var n="";d<p&&x(c[d]);)n+=c[d++];return 0===n.length&&J({},a.UnexpectedToken,"ILLEGAL"),A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt("0x"+n,16),lineNumber:f,lineStart:h,start:e,end:d}}(n);if(w(r))return function(e){for(var n="0"+c[d++];d<p&&w(c[d]);)n+=c[d++];return(A(c.charCodeAt(d))||b(c.charCodeAt(d)))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseInt(n,8),octal:!0,lineNumber:f,lineStart:h,start:e,end:d}}(n);r&&b(r.charCodeAt(0))&&J({},a.UnexpectedToken,"ILLEGAL")}for(;b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("."===r){for(e+=c[d++];b(c.charCodeAt(d));)e+=c[d++];r=c[d]}if("e"===r||"E"===r)if(e+=c[d++],"+"!==(r=c[d])&&"-"!==r||(e+=c[d++]),b(c.charCodeAt(d)))for(;b(c.charCodeAt(d));)e+=c[d++];else J({},a.UnexpectedToken,"ILLEGAL");return A(c.charCodeAt(d))&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.NumericLiteral,value:parseFloat(e),lineNumber:f,lineStart:h,start:n,end:d}}function B(){var e,n,r,o;return m=null,D(),e=d,n=function(){var e,t,n,r;for(v("/"===(e=c[d]),"Regular expression literal must start with a slash"),t=c[d++],n=!1,r=!1;d<p;)if(t+=e=c[d++],"\\"===e)C((e=c[d++]).charCodeAt(0))&&J({},a.UnterminatedRegExp),t+=e;else if(C(e.charCodeAt(0)))J({},a.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){r=!0;break}"["===e&&(n=!0)}return r||J({},a.UnterminatedRegExp),{value:t.substr(1,t.length-2),literal:t}}(),r=function(){var e,t,n,r;for(t="",n="";d<p&&k((e=c[d]).charCodeAt(0));)if(++d,"\\"===e&&d<p)if("u"===(e=c[d])){if(r=++d,e=O("u"))for(n+=e,t+="\\u";r<d;++r)t+=c[r];else d=r,n+="u",t+="\\u";K({},a.UnexpectedToken,"ILLEGAL")}else t+="\\",K({},a.UnexpectedToken,"ILLEGAL");else n+=e,t+=e;return{value:n,literal:t}}(),o=function(e,t){var n;try{n=new RegExp(e,t)}catch(e){J({},a.InvalidRegExp)}return n}(n.value,r.value),_.tokenize?{type:t.RegularExpression,value:o,lineNumber:f,lineStart:h,start:e,end:d}:{literal:n.literal+r.literal,value:o,start:e,end:d}}function q(){var e,t,n,r;return D(),e=d,t={start:{line:f,column:d-h}},n=B(),t.end={line:f,column:d-h},_.tokenize||(_.tokens.length>0&&(r=_.tokens[_.tokens.length-1]).range[0]===e&&"Punctuator"===r.type&&("/"!==r.value&&"/="!==r.value||_.tokens.pop()),_.tokens.push({type:"RegularExpression",value:n.literal,range:[e,d],loc:t})),n}function U(){var e,n,o;return D(),d>=p?{type:t.EOF,lineNumber:f,lineStart:h,start:d,end:d}:A(e=c.charCodeAt(d))?(n=d,{type:1===(o=92===c.charCodeAt(d)?F():M()).length?t.Identifier:R(o)?t.Keyword:"null"===o?t.NullLiteral:"true"===o||"false"===o?t.BooleanLiteral:t.Identifier,value:o,lineNumber:f,lineStart:h,start:n,end:d}):40===e||41===e||59===e?L():39===e||34===e?function(){var e,n,r,o,i,s,l,u,g="",m=!1;for(l=f,u=h,v("'"===(e=c[d])||'"'===e,"String literal must starts with a quote"),n=d,++d;d<p;){if((r=c[d++])===e){e="";break}if("\\"===r)if((r=c[d++])&&C(r.charCodeAt(0)))++f,"\r"===r&&"\n"===c[d]&&++d,h=d;else switch(r){case"u":case"x":s=d,(i=O(r))?g+=i:(d=s,g+=r);break;case"n":g+="\n";break;case"r":g+="\r";break;case"t":g+="\t";break;case"b":g+="\b";break;case"f":g+="\f";break;case"v":g+="\v";break;default:w(r)?(0!==(o="01234567".indexOf(r))&&(m=!0),d<p&&w(c[d])&&(m=!0,o=8*o+"01234567".indexOf(c[d++]),"0123".indexOf(r)>=0&&d<p&&w(c[d])&&(o=8*o+"01234567".indexOf(c[d++]))),g+=String.fromCharCode(o)):g+=r}else{if(C(r.charCodeAt(0)))break;g+=r}}return""!==e&&J({},a.UnexpectedToken,"ILLEGAL"),{type:t.StringLiteral,value:g,octal:m,startLineNumber:l,startLineStart:u,lineNumber:f,lineStart:h,start:n,end:d}}():46===e?b(c.charCodeAt(d+1))?P():L():b(e)?P():_.tokenize&&47===e?function(){var e,t;if(!(e=_.tokens[_.tokens.length-1]))return q();if("Punctuator"===e.type){if("]"===e.value)return L();if(")"===e.value)return!(t=_.tokens[_.openParenToken-1])||"Keyword"!==t.type||"if"!==t.value&&"while"!==t.value&&"for"!==t.value&&"with"!==t.value?L():q();if("}"===e.value){if(_.tokens[_.openCurlyToken-3]&&"Keyword"===_.tokens[_.openCurlyToken-3].type){if(!(t=_.tokens[_.openCurlyToken-4]))return L()}else{if(!_.tokens[_.openCurlyToken-4]||"Keyword"!==_.tokens[_.openCurlyToken-4].type)return L();if(!(t=_.tokens[_.openCurlyToken-5]))return q()}return r.indexOf(t.value)>=0?L():q()}return q()}return"Keyword"===e.type?q():L()}():L()}function $(){var e,r,o;return D(),e={start:{line:f,column:d-h}},r=U(),e.end={line:f,column:d-h},r.type!==t.EOF&&(o=c.slice(r.start,r.end),_.tokens.push({type:n[r.type],value:o,range:[r.start,r.end],loc:e})),r}function z(){var e;return d=(e=m).end,f=e.lineNumber,h=e.lineStart,m=void 0!==_.tokens?$():U(),d=e.end,f=e.lineNumber,h=e.lineStart,e}function H(){var e,t,n;e=d,t=f,n=h,m=void 0!==_.tokens?$():U(),d=e,f=t,h=n}function G(e,t){this.line=e,this.column=t}function V(e,t,n,r){this.start=new G(e,t),this.end=new G(n,r)}function W(){var e,t,n,r;return e=d,t=f,n=h,D(),r=f!==t,d=e,f=t,h=n,r}function J(e,t){var n,r=Array.prototype.slice.call(arguments,2),o=t.replace(/%(\d)/g,(function(e,t){return v(t<r.length,"Message reference must be in range"),r[t]}));throw"number"==typeof e.lineNumber?((n=new Error("Line "+e.lineNumber+": "+o)).index=e.start,n.lineNumber=e.lineNumber,n.column=e.start-h+1):((n=new Error("Line "+f+": "+o)).index=d,n.lineNumber=f,n.column=d-h+1),n.description=o,n}function K(){try{J.apply(null,arguments)}catch(e){if(!_.errors)throw e;_.errors.push(e)}}function Y(e){if(e.type===t.EOF&&J(e,a.UnexpectedEOS),e.type===t.NumericLiteral&&J(e,a.UnexpectedNumber),e.type===t.StringLiteral&&J(e,a.UnexpectedString),e.type===t.Identifier&&J(e,a.UnexpectedIdentifier),e.type===t.Keyword){if(function(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}(e.value))J(e,a.UnexpectedReserved);else if(u&&N(e.value))return void K(e,a.StrictReservedWord);J(e,a.UnexpectedToken,e.value)}J(e,a.UnexpectedToken,e.value)}function X(e){var n=z();n.type===t.Punctuator&&n.value===e||Y(n)}function Z(e){var n=z();n.type===t.Keyword&&n.value===e||Y(n)}function Q(e){return m.type===t.Punctuator&&m.value===e}function ee(e){return m.type===t.Keyword&&m.value===e}function te(){var e;59===c.charCodeAt(d)||Q(";")?z():(e=f,D(),f===e&&(m.type===t.EOF||Q("}")||Y(m)))}function ne(e){return e.type===o.Identifier||e.type===o.MemberExpression}function re(e,t){var n,r,o;return n=u,o=m,r=we(),t&&u&&T(e[0].name)&&K(t,a.StrictParamName),u=n,g.markEnd(g.createFunctionExpression(null,e,[],r),o)}function oe(){var e,n;return n=m,(e=z()).type===t.StringLiteral||e.type===t.NumericLiteral?(u&&e.octal&&K(e,a.StrictOctalLiteral),g.markEnd(g.createLiteral(e),n)):g.markEnd(g.createIdentifier(e.value),n)}function ie(){var e,n,r,o,i,s;return s=m,(e=m).type===t.Identifier?(r=oe(),"get"!==e.value||Q(":")?"set"!==e.value||Q(":")?(X(":"),o=pe(),g.markEnd(g.createProperty("init",r,o),s)):(n=oe(),X("("),(e=m).type!==t.Identifier?(X(")"),K(e,a.UnexpectedToken,e.value),o=re([])):(i=[ye()],X(")"),o=re(i,e)),g.markEnd(g.createProperty("set",n,o),s)):(n=oe(),X("("),X(")"),o=re([]),g.markEnd(g.createProperty("get",n,o),s))):e.type!==t.EOF&&e.type!==t.Punctuator?(n=oe(),X(":"),o=pe(),g.markEnd(g.createProperty("init",n,o),s)):void Y(e)}function ae(){var e,n,r,s;if(Q("("))return function(){var e;return X("("),e=ge(),X(")"),e}();if(Q("["))return function(){var e,t=[];for(e=m,X("[");!Q("]");)Q(",")?(z(),t.push(null)):(t.push(pe()),Q("]")||X(","));return z(),g.markEnd(g.createArrayExpression(t),e)}();if(Q("{"))return function(){var e,t,n,r,s,l=[],c={},d=String;for(s=m,X("{");!Q("}");)t=(e=ie()).key.type===o.Identifier?e.key.name:d(e.key.value),r="init"===e.kind?i.Data:"get"===e.kind?i.Get:i.Set,n="$"+t,Object.prototype.hasOwnProperty.call(c,n)?(c[n]===i.Data?u&&r===i.Data?K({},a.StrictDuplicateProperty):r!==i.Data&&K({},a.AccessorDataProperty):r===i.Data?K({},a.AccessorDataProperty):c[n]&r&&K({},a.AccessorGetSet),c[n]|=r):c[n]=r,l.push(e),Q("}")||X(",");return X("}"),g.markEnd(g.createObjectExpression(l),s)}();if(s=m,(e=m.type)===t.Identifier)r=g.createIdentifier(z().value);else if(e===t.StringLiteral||e===t.NumericLiteral)u&&m.octal&&K(m,a.StrictOctalLiteral),r=g.createLiteral(z());else if(e===t.Keyword){if(ee("function"))return function(){var e,t,n,r,o,i,s,l,c,d=null;return l=m,Z("function"),Q("(")||(e=m,d=ye(),u?T(e.value)&&K(e,a.StrictFunctionName):T(e.value)?(n=e,r=a.StrictFunctionName):N(e.value)&&(n=e,r=a.StrictReservedWord)),c=(o=Se(n)).params,t=o.stricted,n=o.firstRestricted,o.message&&(r=o.message),s=u,i=we(),u&&n&&J(n,r),u&&t&&K(t,r),u=s,g.markEnd(g.createFunctionExpression(d,c,[],i),l)}();ee("this")?(z(),r=g.createThisExpression()):Y(z())}else e===t.BooleanLiteral?((n=z()).value="true"===n.value,r=g.createLiteral(n)):e===t.NullLiteral?((n=z()).value=null,r=g.createLiteral(n)):Q("/")||Q("/=")?(r=g.createLiteral(void 0!==_.tokens?q():B()),H()):Y(z());return g.markEnd(r,s)}function se(){var e=[];if(X("("),!Q(")"))for(;d<p&&(e.push(pe()),!Q(")"));)X(",");return X(")"),e}function le(){return X("."),function(){var e,n;return n=m,function(e){return e.type===t.Identifier||e.type===t.Keyword||e.type===t.BooleanLiteral||e.type===t.NullLiteral}(e=z())||Y(e),g.markEnd(g.createIdentifier(e.value),n)}()}function ce(){var e;return X("["),e=ge(),X("]"),e}function ue(){var e,t,n;return n=m,Z("new"),e=function(){var e,t,n,r;for(r=m,e=y.allowIn,t=ee("new")?ue():ae(),y.allowIn=e;Q(".")||Q("[");)Q("[")?(n=ce(),t=g.createMemberExpression("[",t,n)):(n=le(),t=g.createMemberExpression(".",t,n)),g.markEnd(t,r);return t}(),t=Q("(")?se():[],g.markEnd(g.createNewExpression(e,t),n)}function de(){var e,n,r=m;return e=function(){var e,t,n,r,o;for(o=m,e=y.allowIn,y.allowIn=!0,t=ee("new")?ue():ae(),y.allowIn=e;;){if(Q("."))r=le(),t=g.createMemberExpression(".",t,r);else if(Q("("))n=se(),t=g.createCallExpression(t,n);else{if(!Q("["))break;r=ce(),t=g.createMemberExpression("[",t,r)}g.markEnd(t,o)}return t}(),m.type===t.Punctuator&&(!Q("++")&&!Q("--")||W()||(u&&e.type===o.Identifier&&T(e.name)&&K({},a.StrictLHSPostfix),ne(e)||K({},a.InvalidLHSInAssignment),n=z(),e=g.markEnd(g.createPostfixExpression(n.value,e),r))),e}function fe(){var e,n,r;return m.type!==t.Punctuator&&m.type!==t.Keyword?n=de():Q("++")||Q("--")?(r=m,e=z(),n=fe(),u&&n.type===o.Identifier&&T(n.name)&&K({},a.StrictLHSPrefix),ne(n)||K({},a.InvalidLHSInAssignment),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):Q("+")||Q("-")||Q("~")||Q("!")?(r=m,e=z(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r)):ee("delete")||ee("void")||ee("typeof")?(r=m,e=z(),n=fe(),n=g.createUnaryExpression(e.value,n),n=g.markEnd(n,r),u&&"delete"===n.operator&&n.argument.type===o.Identifier&&K({},a.StrictDelete)):n=de(),n}function he(e,n){var r=0;if(e.type!==t.Punctuator&&e.type!==t.Keyword)return 0;switch(e.value){case"||":r=1;break;case"&&":r=2;break;case"|":r=3;break;case"^":r=4;break;case"&":r=5;break;case"==":case"!=":case"===":case"!==":r=6;break;case"<":case">":case"<=":case">=":case"instanceof":r=7;break;case"in":r=n?7:0;break;case"<<":case">>":case">>>":r=8;break;case"+":case"-":r=9;break;case"*":case"/":case"%":r=11}return r}function pe(){var e,n,r,i,s,l;return e=m,s=m,i=n=function(){var e,t,n,r,o;return o=m,e=function(){var e,t,n,r,o,i,a,s,l,c;if(e=m,l=fe(),0===(o=he(r=m,y.allowIn)))return l;for(r.prec=o,z(),t=[e,m],i=[l,r,a=fe()];(o=he(m,y.allowIn))>0;){for(;i.length>2&&o<=i[i.length-2].prec;)a=i.pop(),s=i.pop().value,l=i.pop(),n=g.createBinaryExpression(s,l,a),t.pop(),g.markEnd(n,e=t[t.length-1]),i.push(n);(r=z()).prec=o,i.push(r),t.push(m),n=fe(),i.push(n)}for(n=i[c=i.length-1],t.pop();c>1;)n=g.createBinaryExpression(i[c-1].value,i[c-2],n),c-=2,e=t.pop(),g.markEnd(n,e);return n}(),Q("?")&&(z(),t=y.allowIn,y.allowIn=!0,n=pe(),y.allowIn=t,X(":"),r=pe(),e=g.createConditionalExpression(e,n,r),g.markEnd(e,o)),e}(),m.type===t.Punctuator&&("="===(l=m.value)||"*="===l||"/="===l||"%="===l||"+="===l||"-="===l||"<<="===l||">>="===l||">>>="===l||"&="===l||"^="===l||"|="===l)&&(ne(n)||K({},a.InvalidLHSInAssignment),u&&n.type===o.Identifier&&T(n.name)&&K(e,a.StrictLHSAssignment),e=z(),r=pe(),i=g.markEnd(g.createAssignmentExpression(e.value,n,r),s)),i}function ge(){var e,t=m;if(e=pe(),Q(",")){for(e=g.createSequenceExpression([e]);d<p&&Q(",");)z(),e.expressions.push(pe());g.markEnd(e,t)}return e}function me(){var e,t;return t=m,X("{"),e=function(){for(var e,t=[];d<p&&!Q("}")&&void 0!==(e=Ae());)t.push(e);return t}(),X("}"),g.markEnd(g.createBlockStatement(e),t)}function ye(){var e,n;return n=m,(e=z()).type!==t.Identifier&&Y(e),g.markEnd(g.createIdentifier(e.value),n)}function _e(e){var t,n,r=null;return n=m,t=ye(),u&&T(t.name)&&K({},a.StrictVarName),"const"===e?(X("="),r=pe()):Q("=")&&(z(),r=pe()),g.markEnd(g.createVariableDeclarator(t,r),n)}function ve(e){var t=[];do{if(t.push(_e(e)),!Q(","))break;z()}while(d<p);return t}function be(){var e,t,n,r=[];for(n=m,ee("default")?(z(),e=null):(Z("case"),e=ge()),X(":");d<p&&!(Q("}")||ee("default")||ee("case"));)t=xe(),r.push(t);return g.markEnd(g.createSwitchCase(e,r),n)}function xe(){var e,n,r,i,s,l,f,h,_,v,b=m.type;if(b===t.EOF&&Y(m),b===t.Punctuator&&"{"===m.value)return me();if(i=m,b===t.Punctuator)switch(m.value){case";":return g.markEnd((X(";"),g.createEmptyStatement()),i);case"(":return g.markEnd(function(){var e=ge();return te(),g.createExpressionStatement(e)}(),i)}if(b===t.Keyword)switch(m.value){case"break":return g.markEnd((v=null,Z("break"),59===c.charCodeAt(d)?(z(),y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):W()?(y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(null)):(m.type===t.Identifier&&(v=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+v.name)||J({},a.UnknownLabel,v.name)),te(),null!==v||y.inIteration||y.inSwitch||J({},a.IllegalBreak),g.createBreakStatement(v))),i);case"continue":return g.markEnd(function(){var e=null;return Z("continue"),59===c.charCodeAt(d)?(z(),y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):W()?(y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(null)):(m.type===t.Identifier&&(e=ye(),Object.prototype.hasOwnProperty.call(y.labelSet,"$"+e.name)||J({},a.UnknownLabel,e.name)),te(),null!==e||y.inIteration||J({},a.IllegalContinue),g.createContinueStatement(e))}(),i);case"debugger":return g.markEnd((Z("debugger"),te(),g.createDebuggerStatement()),i);case"do":return g.markEnd((Z("do"),_=y.inIteration,y.inIteration=!0,f=xe(),y.inIteration=_,Z("while"),X("("),h=ge(),X(")"),Q(";")&&z(),g.createDoWhileStatement(f,h)),i);case"for":return g.markEnd(function(){var e,t,n,r,o,i,s;return e=t=n=null,Z("for"),X("("),Q(";")?z():(ee("var")||ee("let")?(y.allowIn=!1,e=function(){var e,t,n;return n=m,e=z(),t=ve(),g.markEnd(g.createVariableDeclaration(t,e.value),n)}(),y.allowIn=!0,1===e.declarations.length&&ee("in")&&(z(),r=e,o=ge(),e=null)):(y.allowIn=!1,e=ge(),y.allowIn=!0,ee("in")&&(ne(e)||K({},a.InvalidLHSInForIn),z(),r=e,o=ge(),e=null)),void 0===r&&X(";")),void 0===r&&(Q(";")||(t=ge()),X(";"),Q(")")||(n=ge())),X(")"),s=y.inIteration,y.inIteration=!0,i=xe(),y.inIteration=s,void 0===r?g.createForStatement(e,t,n,i):g.createForInStatement(r,o,i)}(),i);case"function":return g.markEnd(Ce(),i);case"if":return g.markEnd(function(){var e,t,n;return Z("if"),X("("),e=ge(),X(")"),t=xe(),ee("else")?(z(),n=xe()):n=null,g.createIfStatement(e,t,n)}(),i);case"return":return g.markEnd((l=null,Z("return"),y.inFunctionBody||K({},a.IllegalReturn),32===c.charCodeAt(d)&&A(c.charCodeAt(d+1))?(l=ge(),te(),g.createReturnStatement(l)):W()?g.createReturnStatement(null):(Q(";")||Q("}")||m.type===t.EOF||(l=ge()),te(),g.createReturnStatement(l))),i);case"switch":return g.markEnd(function(){var e,t,n,r,o;if(Z("switch"),X("("),e=ge(),X(")"),X("{"),t=[],Q("}"))return z(),g.createSwitchStatement(e,t);for(r=y.inSwitch,y.inSwitch=!0,o=!1;d<p&&!Q("}");)null===(n=be()).test&&(o&&J({},a.MultipleDefaultsInSwitch),o=!0),t.push(n);return y.inSwitch=r,X("}"),g.createSwitchStatement(e,t)}(),i);case"throw":return g.markEnd(function(){var e;return Z("throw"),W()&&J({},a.NewlineAfterThrow),e=ge(),te(),g.createThrowStatement(e)}(),i);case"try":return g.markEnd(function(){var e,t,n,r,o=[],i=null;return Z("try"),e=me(),ee("catch")&&o.push((r=m,Z("catch"),X("("),Q(")")&&Y(m),t=ye(),u&&T(t.name)&&K({},a.StrictCatchVariable),X(")"),n=me(),g.markEnd(g.createCatchClause(t,n),r))),ee("finally")&&(z(),i=me()),0!==o.length||i||J({},a.NoCatchOrFinally),g.createTryStatement(e,[],o,i)}(),i);case"var":return g.markEnd((Z("var"),s=ve(),te(),g.createVariableDeclaration(s,"var")),i);case"while":return g.markEnd(function(){var e,t,n;return Z("while"),X("("),e=ge(),X(")"),n=y.inIteration,y.inIteration=!0,t=xe(),y.inIteration=n,g.createWhileStatement(e,t)}(),i);case"with":return g.markEnd(function(){var e,t;return u&&(D(),K({},a.StrictModeWith)),Z("with"),X("("),e=ge(),X(")"),t=xe(),g.createWithStatement(e,t)}(),i)}return(e=ge()).type===o.Identifier&&Q(":")?(z(),r="$"+e.name,Object.prototype.hasOwnProperty.call(y.labelSet,r)&&J({},a.Redeclaration,"Label",e.name),y.labelSet[r]=!0,n=xe(),delete y.labelSet[r],g.markEnd(g.createLabeledStatement(e,n),i)):(te(),g.markEnd(g.createExpressionStatement(e),i))}function we(){var e,n,r,i,s,l,f,h,_=[];for(h=m,X("{");d<p&&m.type===t.StringLiteral&&(n=m,e=Ae(),_.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(i=y.labelSet,s=y.inIteration,l=y.inSwitch,f=y.inFunctionBody,y.labelSet={},y.inIteration=!1,y.inSwitch=!1,y.inFunctionBody=!0;d<p&&!Q("}")&&void 0!==(e=Ae());)_.push(e);return X("}"),y.labelSet=i,y.inIteration=s,y.inSwitch=l,y.inFunctionBody=f,g.markEnd(g.createBlockStatement(_),h)}function Se(e){var t,n,r,o,i,s,l=[];if(X("("),!Q(")"))for(o={};d<p&&(n=m,t=ye(),i="$"+n.value,u?(T(n.value)&&(r=n,s=a.StrictParamName),Object.prototype.hasOwnProperty.call(o,i)&&(r=n,s=a.StrictParamDupe)):e||(T(n.value)?(e=n,s=a.StrictParamName):N(n.value)?(e=n,s=a.StrictReservedWord):Object.prototype.hasOwnProperty.call(o,i)&&(e=n,s=a.StrictParamDupe)),l.push(t),o[i]=!0,!Q(")"));)X(",");return X(")"),{params:l,stricted:r,firstRestricted:e,message:s}}function Ce(){var e,t,n,r,o,i,s,l,c,d;return c=m,Z("function"),n=m,e=ye(),u?T(n.value)&&K(n,a.StrictFunctionName):T(n.value)?(i=n,s=a.StrictFunctionName):N(n.value)&&(i=n,s=a.StrictReservedWord),d=(o=Se(i)).params,r=o.stricted,i=o.firstRestricted,o.message&&(s=o.message),l=u,t=we(),u&&i&&J(i,s),u&&r&&K(r,s),u=l,g.markEnd(g.createFunctionDeclaration(e,d,[],t),c)}function Ae(){if(m.type===t.Keyword)switch(m.value){case"const":case"let":return r=m,Z(e=m.value),n=ve(e),te(),g.markEnd(g.createVariableDeclaration(n,e),r);case"function":return Ce();default:return xe()}var e,n,r;if(m.type!==t.EOF)return xe()}function ke(){var e,t,n,r=[];for(e=0;e<_.tokens.length;++e)n={type:(t=_.tokens[e]).type,value:t.value},_.range&&(n.range=t.range),_.loc&&(n.loc=t.loc),r.push(n);_.tokens=r}(n={})[(t={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9}).BooleanLiteral]="Boolean",n[t.EOF]="<end>",n[t.Identifier]="Identifier",n[t.Keyword]="Keyword",n[t.NullLiteral]="Null",n[t.NumericLiteral]="Numeric",n[t.Punctuator]="Punctuator",n[t.StringLiteral]="String",n[t.RegularExpression]="RegularExpression",r=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],o={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},i={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},s={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},l={name:"SyntaxTree",processComment:function(e){var t,n;if(!(e.type===o.Program&&e.body.length>0)){for(_.trailingComments.length>0?_.trailingComments[0].range[0]>=e.range[1]?(n=_.trailingComments,_.trailingComments=[]):_.trailingComments.length=0:_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments&&_.bottomRightStack[_.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(n=_.bottomRightStack[_.bottomRightStack.length-1].trailingComments,delete _.bottomRightStack[_.bottomRightStack.length-1].trailingComments);_.bottomRightStack.length>0&&_.bottomRightStack[_.bottomRightStack.length-1].range[0]>=e.range[0];)t=_.bottomRightStack.pop();t?t.leadingComments&&t.leadingComments[t.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=t.leadingComments,delete t.leadingComments):_.leadingComments.length>0&&_.leadingComments[_.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=_.leadingComments,_.leadingComments=[]),n&&(e.trailingComments=n),_.bottomRightStack.push(e)}},markEnd:function(e,t){return _.range&&(e.range=[t.start,d]),_.loc&&(e.loc=new V(void 0===t.startLineNumber?t.lineNumber:t.startLineNumber,t.start-(void 0===t.startLineStart?t.lineStart:t.startLineStart),f,d-h),this.postProcess(e)),_.attachComment&&this.processComment(e),e},postProcess:function(e){return _.source&&(e.loc.source=_.source),e},createArrayExpression:function(e){return{type:o.ArrayExpression,elements:e}},createAssignmentExpression:function(e,t,n){return{type:o.AssignmentExpression,operator:e,left:t,right:n}},createBinaryExpression:function(e,t,n){return{type:"||"===e||"&&"===e?o.LogicalExpression:o.BinaryExpression,operator:e,left:t,right:n}},createBlockStatement:function(e){return{type:o.BlockStatement,body:e}},createBreakStatement:function(e){return{type:o.BreakStatement,label:e}},createCallExpression:function(e,t){return{type:o.CallExpression,callee:e,arguments:t}},createCatchClause:function(e,t){return{type:o.CatchClause,param:e,body:t}},createConditionalExpression:function(e,t,n){return{type:o.ConditionalExpression,test:e,consequent:t,alternate:n}},createContinueStatement:function(e){return{type:o.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:o.DebuggerStatement}},createDoWhileStatement:function(e,t){return{type:o.DoWhileStatement,body:e,test:t}},createEmptyStatement:function(){return{type:o.EmptyStatement}},createExpressionStatement:function(e){return{type:o.ExpressionStatement,expression:e}},createForStatement:function(e,t,n,r){return{type:o.ForStatement,init:e,test:t,update:n,body:r}},createForInStatement:function(e,t,n){return{type:o.ForInStatement,left:e,right:t,body:n,each:!1}},createFunctionDeclaration:function(e,t,n,r){return{type:o.FunctionDeclaration,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,t,n,r){return{type:o.FunctionExpression,id:e,params:t,defaults:n,body:r,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:o.Identifier,name:e}},createIfStatement:function(e,t,n){return{type:o.IfStatement,test:e,consequent:t,alternate:n}},createLabeledStatement:function(e,t){return{type:o.LabeledStatement,label:e,body:t}},createLiteral:function(e){return{type:o.Literal,value:e.value,raw:c.slice(e.start,e.end)}},createMemberExpression:function(e,t,n){return{type:o.MemberExpression,computed:"["===e,object:t,property:n}},createNewExpression:function(e,t){return{type:o.NewExpression,callee:e,arguments:t}},createObjectExpression:function(e){return{type:o.ObjectExpression,properties:e}},createPostfixExpression:function(e,t){return{type:o.UpdateExpression,operator:e,argument:t,prefix:!1}},createProgram:function(e){return{type:o.Program,body:e}},createProperty:function(e,t,n){return{type:o.Property,key:t,value:n,kind:e}},createReturnStatement:function(e){return{type:o.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:o.SequenceExpression,expressions:e}},createSwitchCase:function(e,t){return{type:o.SwitchCase,test:e,consequent:t}},createSwitchStatement:function(e,t){return{type:o.SwitchStatement,discriminant:e,cases:t}},createThisExpression:function(){return{type:o.ThisExpression}},createThrowStatement:function(e){return{type:o.ThrowStatement,argument:e}},createTryStatement:function(e,t,n,r){return{type:o.TryStatement,block:e,guardedHandlers:t,handlers:n,finalizer:r}},createUnaryExpression:function(e,t){return"++"===e||"--"===e?{type:o.UpdateExpression,operator:e,argument:t,prefix:!0}:{type:o.UnaryExpression,operator:e,argument:t,prefix:!0}},createVariableDeclaration:function(e,t){return{type:o.VariableDeclaration,declarations:e,kind:t}},createVariableDeclarator:function(e,t){return{type:o.VariableDeclarator,id:e,init:t}},createWhileStatement:function(e,t){return{type:o.WhileStatement,test:e,body:t}},createWithStatement:function(e,t){return{type:o.WithStatement,object:e,body:t}}},e.version="1.2.2",e.tokenize=function(e,n){var r;"string"==typeof e||e instanceof String||(e=String(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},(n=n||{}).tokens=!0,_.tokens=[],_.tokenize=!0,_.openParenToken=-1,_.openCurlyToken=-1,_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]);try{if(H(),m.type===t.EOF)return _.tokens;for(z();m.type!==t.EOF;)try{z()}catch(e){if(_.errors){_.errors.push(e);break}throw e}ke(),r=_.tokens,void 0!==_.comments&&(r.comments=_.comments),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.parse=function(e,n){var r,i,s,v;i=String,"string"==typeof e||e instanceof String||(e=i(e)),g=l,d=0,f=(c=e).length>0?1:0,h=0,p=c.length,m=null,y={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},_={},void 0!==n&&(_.range="boolean"==typeof n.range&&n.range,_.loc="boolean"==typeof n.loc&&n.loc,_.attachComment="boolean"==typeof n.attachComment&&n.attachComment,_.loc&&null!=n.source&&(_.source=i(n.source)),"boolean"==typeof n.tokens&&n.tokens&&(_.tokens=[]),"boolean"==typeof n.comment&&n.comment&&(_.comments=[]),"boolean"==typeof n.tolerant&&n.tolerant&&(_.errors=[]),_.attachComment&&(_.range=!0,_.comments=[],_.bottomRightStack=[],_.trailingComments=[],_.leadingComments=[]));try{D(),H(),v=m,u=!1,s=function(){for(var e,n,r,i=[];d<p&&(n=m).type===t.StringLiteral&&(e=Ae(),i.push(e),e.expression.type===o.Literal);)"use strict"===c.slice(n.start+1,n.end-1)?(u=!0,r&&K(r,a.StrictOctalLiteral)):!r&&n.octal&&(r=n);for(;d<p&&void 0!==(e=Ae());)i.push(e);return i}(),r=g.markEnd(g.createProgram(s),v),void 0!==_.comments&&(r.comments=_.comments),void 0!==_.tokens&&(ke(),r.tokens=_.tokens),void 0!==_.errors&&(r.errors=_.errors)}catch(e){throw e}finally{_={}}return r},e.Syntax=function(){var e,t={};for(e in"function"==typeof Object.create&&(t=Object.create(null)),o)o.hasOwnProperty(e)&&(t[e]=o[e]);return"function"==typeof Object.freeze&&Object.freeze(t),t}()},r(void 0!==n?n:this.esprima={})},{}],1:[function(e,t,n){(function(r){var o=function(){var e={trace:function(){},yy:{},symbols_:{error:2,JSON_PATH:3,DOLLAR:4,PATH_COMPONENTS:5,LEADING_CHILD_MEMBER_EXPRESSION:6,PATH_COMPONENT:7,MEMBER_COMPONENT:8,SUBSCRIPT_COMPONENT:9,CHILD_MEMBER_COMPONENT:10,DESCENDANT_MEMBER_COMPONENT:11,DOT:12,MEMBER_EXPRESSION:13,DOT_DOT:14,STAR:15,IDENTIFIER:16,SCRIPT_EXPRESSION:17,INTEGER:18,END:19,CHILD_SUBSCRIPT_COMPONENT:20,DESCENDANT_SUBSCRIPT_COMPONENT:21,"[":22,SUBSCRIPT:23,"]":24,SUBSCRIPT_EXPRESSION:25,SUBSCRIPT_EXPRESSION_LIST:26,SUBSCRIPT_EXPRESSION_LISTABLE:27,",":28,STRING_LITERAL:29,ARRAY_SLICE:30,FILTER_EXPRESSION:31,QQ_STRING:32,Q_STRING:33,$accept:0,$end:1},terminals_:{2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},productions_:[0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],performAction:function(e,n,r,o,i,a,s){o.ast||(o.ast=t,t.initialize());var l=a.length-1;switch(i){case 1:return o.ast.set({expression:{type:"root",value:a[l]}}),o.ast.unshift(),o.ast.yield();case 2:return o.ast.set({expression:{type:"root",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 3:return o.ast.unshift(),o.ast.yield();case 4:return o.ast.set({operation:"member",scope:"child",expression:{type:"identifier",value:a[l-1]}}),o.ast.unshift(),o.ast.yield();case 5:case 6:case 11:case 13:case 18:case 21:case 22:case 23:break;case 7:o.ast.set({operation:"member"}),o.ast.push();break;case 8:o.ast.set({operation:"subscript"}),o.ast.push();break;case 9:case 19:o.ast.set({scope:"child"});break;case 10:case 20:o.ast.set({scope:"descendant"});break;case 12:o.ast.set({scope:"child",operation:"member"});break;case 14:o.ast.set({expression:{type:"wildcard",value:a[l]}});break;case 15:o.ast.set({expression:{type:"identifier",value:a[l]}});break;case 16:o.ast.set({expression:{type:"script_expression",value:a[l]}});break;case 17:o.ast.set({expression:{type:"numeric_literal",value:parseInt(a[l])}});break;case 24:a[l].length>1?o.ast.set({expression:{type:"union",value:a[l]}}):this.$=a[l];break;case 25:this.$=[a[l]];break;case 26:this.$=a[l-2].concat(a[l]);break;case 27:this.$={expression:{type:"numeric_literal",value:parseInt(a[l])}},o.ast.set(this.$);break;case 28:this.$={expression:{type:"string_literal",value:a[l]}},o.ast.set(this.$);break;case 29:this.$={expression:{type:"slice",value:a[l]}},o.ast.set(this.$);break;case 30:this.$={expression:{type:"wildcard",value:a[l]}},o.ast.set(this.$);break;case 31:this.$={expression:{type:"script_expression",value:a[l]}},o.ast.set(this.$);break;case 32:this.$={expression:{type:"filter_expression",value:a[l]}},o.ast.set(this.$);break;case 33:case 34:this.$=a[l]}},table:[{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],defaultActions:{27:[2,23],29:[2,30],30:[2,31],31:[2,32]},parseError:function(e,t){if(!t.recoverable)throw new Error(e);this.trace(e)},parse:function(e){var t=this,n=[0],r=[null],o=[],i=this.table,a="",s=0,l=0,c=o.slice.call(arguments,1);this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;o.push(u);var d=this.lexer.options&&this.lexer.options.ranges;function f(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}this.parseError="function"==typeof this.yy.parseError?this.yy.parseError:Object.getPrototypeOf(this).parseError;for(var h,p,g,m,y,_,v,b={};;){if(this.defaultActions[p=n[n.length-1]]?g=this.defaultActions[p]:(null==h&&(h=f()),g=i[p]&&i[p][h]),void 0===g||!g.length||!g[0]){var x;for(y in v=[],i[p])this.terminals_[y]&&y>2&&v.push("'"+this.terminals_[y]+"'");x=this.lexer.showPosition?"Parse error on line "+(s+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[h]||h)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==h?"end of input":"'"+(this.terminals_[h]||h)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[h]||h,line:this.lexer.yylineno,loc:u,expected:v})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+h);switch(g[0]){case 1:n.push(h),r.push(this.lexer.yytext),o.push(this.lexer.yylloc),n.push(g[1]),h=null,l=this.lexer.yyleng,a=this.lexer.yytext,s=this.lexer.yylineno,u=this.lexer.yylloc;break;case 2:if(b.$=r[r.length-(_=this.productions_[g[1]][1])],b._$={first_line:o[o.length-(_||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(_||1)].first_column,last_column:o[o.length-1].last_column},d&&(b._$.range=[o[o.length-(_||1)].range[0],o[o.length-1].range[1]]),void 0!==(m=this.performAction.apply(b,[a,l,s,this.yy,g[1],r,o].concat(c))))return m;_&&(n=n.slice(0,-1*_*2),r=r.slice(0,-1*_),o=o.slice(0,-1*_)),n.push(this.productions_[g[1]][0]),r.push(b.$),o.push(b._$),n.push(i[n[n.length-2]][n[n.length-1]]);break;case 3:return!0}}return!0}},t={initialize:function(){this._nodes=[],this._node={},this._stash=[]},set:function(e){for(var t in e)this._node[t]=e[t];return this._node},node:function(e){return arguments.length&&(this._node=e),this._node},push:function(){this._nodes.push(this._node),this._node={}},unshift:function(){this._nodes.unshift(this._node),this._node={}},yield:function(){var e=this._nodes;return this.initialize(),e}},n=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var n,r,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(r=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],n=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in o)this[i]=o[i];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),i=0;i<o.length;i++)if((n=this._input.match(this.rules[o[i]]))&&(!t||n[0].length>t[0].length)){if(t=n,r=i,this.options.backtrack_lexer){if(!1!==(e=this.test_match(n,o[i])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,o[r]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,n,r){switch(n){case 0:return 4;case 1:return 14;case 2:return 12;case 3:return 15;case 4:return 16;case 5:return 22;case 6:return 24;case 7:return 28;case 8:return 30;case 9:return 18;case 10:return t.yytext=t.yytext.substr(1,t.yyleng-2),32;case 11:return t.yytext=t.yytext.substr(1,t.yyleng-2),33;case 12:return 17;case 13:return 31}},rules:[/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return e}();function r(){this.yy={}}return e.lexer=n,r.prototype=e,e.Parser=r,new r}();void 0!==e&&void 0!==n&&(n.parser=o,n.Parser=o.Parser,n.parse=function(){return o.parse.apply(o,arguments)},n.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),r.exit(1));var o=e("fs").readFileSync(e("path").normalize(t[1]),"utf8");return n.parser.parse(o)},void 0!==t&&e.main===t&&n.main(r.argv.slice(1)))}).call(this,e("_process"))},{_process:14,fs:12,path:13}],2:[function(e,t,n){t.exports={identifier:"[a-zA-Z_]+[a-zA-Z0-9_]*",integer:"-?(?:0|[1-9][0-9]*)",qq_string:'"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^"\\\\])*"',q_string:"'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*'"}},{}],3:[function(e,t,n){var r=e("./dict"),o=e("fs"),i={lex:{macros:{esc:"\\\\",int:r.integer},rules:[["\\$","return 'DOLLAR'"],["\\.\\.","return 'DOT_DOT'"],["\\.","return 'DOT'"],["\\*","return 'STAR'"],[r.identifier,"return 'IDENTIFIER'"],["\\[","return '['"],["\\]","return ']'"],[",","return ','"],["({int})?\\:({int})?(\\:({int})?)?","return 'ARRAY_SLICE'"],["{int}","return 'INTEGER'"],[r.qq_string,"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],[r.q_string,"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],["\\(.+?\\)(?=\\])","return 'SCRIPT_EXPRESSION'"],["\\?\\(.+?\\)(?=\\])","return 'FILTER_EXPRESSION'"]]},start:"JSON_PATH",bnf:{JSON_PATH:[["DOLLAR",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["DOLLAR PATH_COMPONENTS",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["LEADING_CHILD_MEMBER_EXPRESSION","yy.ast.unshift(); return yy.ast.yield()"],["LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS",'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()']],PATH_COMPONENTS:[["PATH_COMPONENT",""],["PATH_COMPONENTS PATH_COMPONENT",""]],PATH_COMPONENT:[["MEMBER_COMPONENT",'yy.ast.set({ operation: "member" }); yy.ast.push()'],["SUBSCRIPT_COMPONENT",'yy.ast.set({ operation: "subscript" }); yy.ast.push() ']],MEMBER_COMPONENT:[["CHILD_MEMBER_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_MEMBER_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_MEMBER_COMPONENT:[["DOT MEMBER_EXPRESSION",""]],LEADING_CHILD_MEMBER_EXPRESSION:[["MEMBER_EXPRESSION",'yy.ast.set({ scope: "child", operation: "member" })']],DESCENDANT_MEMBER_COMPONENT:[["DOT_DOT MEMBER_EXPRESSION",""]],MEMBER_EXPRESSION:[["STAR",'yy.ast.set({ expression: { type: "wildcard", value: $1 } })'],["IDENTIFIER",'yy.ast.set({ expression: { type: "identifier", value: $1 } })'],["SCRIPT_EXPRESSION",'yy.ast.set({ expression: { type: "script_expression", value: $1 } })'],["INTEGER",'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })'],["END",""]],SUBSCRIPT_COMPONENT:[["CHILD_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_SUBSCRIPT_COMPONENT:[["[ SUBSCRIPT ]",""]],DESCENDANT_SUBSCRIPT_COMPONENT:[["DOT_DOT [ SUBSCRIPT ]",""]],SUBSCRIPT:[["SUBSCRIPT_EXPRESSION",""],["SUBSCRIPT_EXPRESSION_LIST",'$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1']],SUBSCRIPT_EXPRESSION_LIST:[["SUBSCRIPT_EXPRESSION_LISTABLE","$$ = [$1]"],["SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE","$$ = $1.concat($3)"]],SUBSCRIPT_EXPRESSION_LISTABLE:[["INTEGER",'$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)'],["STRING_LITERAL",'$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)'],["ARRAY_SLICE",'$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)']],SUBSCRIPT_EXPRESSION:[["STAR",'$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)'],["SCRIPT_EXPRESSION",'$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)'],["FILTER_EXPRESSION",'$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)']],STRING_LITERAL:[["QQ_STRING","$$ = $1"],["Q_STRING","$$ = $1"]]}};o.readFileSync&&(i.moduleInclude=o.readFileSync(e.resolve("../include/module.js")),i.actionInclude=o.readFileSync(e.resolve("../include/action.js"))),t.exports=i},{"./dict":2,fs:12}],4:[function(e,t,n){var r=e("./aesprim"),o=e("./slice"),i=e("static-eval"),a=e("underscore").uniq,s=function(){return this.initialize.apply(this,arguments)};function l(t,n,o){var i=e("./index"),a=h(r.parse(n).body[0].expression,{"@":t.value}),s=o.replace(/\{\{\s*value\s*\}\}/g,a),l=i.nodes(t.value,s);return l.forEach((function(e){e.path=t.path.concat(e.path.slice(1))})),l}function c(e){return Array.isArray(e)}function u(e){return function(t,n,r,o){var i=t.value,a=t.path,s=[],l=function(t,i){var a;c(t)?(t.forEach((function(e,t){s.length>=o||r(t,e,n)&&s.push({path:i.concat(t),value:e})})),t.forEach((function(t,n){s.length>=o||e&&l(t,i.concat(n))}))):(a=t)&&!(a instanceof Array)&&a instanceof Object&&(this.keys(t).forEach((function(e){s.length>=o||r(e,t[e],n)&&s.push({path:i.concat(e),value:t[e]})})),this.keys(t).forEach((function(n){s.length>=o||e&&l(t[n],i.concat(n))})))}.bind(this);return l(i,a),s}}function d(e){return function(t,n,r){return this.descend(n,t.expression.value,e,r)}}function f(e){return function(t,n,r){return this.traverse(n,t.expression.value,e,r)}}function h(){try{return i.apply(this,arguments)}catch(e){}}function p(e){return e=e.filter((function(e){return e})),a(e,(function(e){return e.path.map((function(e){return String(e).replace("-","--")})).join("-")}))}function g(e){var t=String(e);return t.match(/^-?[0-9]+$/)?parseInt(t):null}s.prototype.initialize=function(){this.traverse=u(!0),this.descend=u()},s.prototype.keys=Object.keys,s.prototype.resolve=function(e){var t=[e.operation,e.scope,e.expression.type].join("-"),n=this._fns[t];if(!n)throw new Error("couldn't resolve key: "+t);return n.bind(this)},s.prototype.register=function(e,t){if(!t instanceof Function)throw new Error("handler must be a function");this._fns[e]=t},s.prototype._fns={"member-child-identifier":function(e,t){var n=e.expression.value,r=t.value;if(r instanceof Object&&n in r)return[{value:r[n],path:t.path.concat(n)}]},"member-descendant-identifier":f((function(e,t,n){return e==n})),"subscript-child-numeric_literal":d((function(e,t,n){return e===n})),"member-child-numeric_literal":d((function(e,t,n){return String(e)===String(n)})),"subscript-descendant-numeric_literal":f((function(e,t,n){return e===n})),"member-child-wildcard":d((function(){return!0})),"member-descendant-wildcard":f((function(){return!0})),"subscript-descendant-wildcard":f((function(){return!0})),"subscript-child-wildcard":d((function(){return!0})),"subscript-child-slice":function(e,t){if(c(t.value)){var n=e.expression.value.split(":").map(g),r=t.value.map((function(e,n){return{value:e,path:t.path.concat(n)}}));return o.apply(null,[r].concat(n))}},"subscript-child-union":function(e,t){var n=[];return e.expression.value.forEach((function(e){var r={operation:"subscript",scope:"child",expression:e.expression},o=this.resolve(r)(r,t);o&&(n=n.concat(o))}),this),p(n)},"subscript-descendant-union":function(t,n,r){var o=e(".."),i=this,a=[];return o.nodes(n,"$..*").slice(1).forEach((function(e){a.length>=r||t.expression.value.forEach((function(t){var n={operation:"subscript",scope:"child",expression:t.expression},r=i.resolve(n)(n,e);a=a.concat(r)}))})),p(a)},"subscript-child-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.descend(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-descendant-filter_expression":function(e,t,n){var o=e.expression.value.slice(2,-1),i=r.parse(o).body[0].expression;return this.traverse(t,null,(function(e,t){return h(i,{"@":t})}),n)},"subscript-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$[{{value}}]")},"member-child-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$.{{value}}")},"member-descendant-script_expression":function(e,t){return l(t,e.expression.value.slice(1,-1),"$..value")}},s.prototype._fns["subscript-child-string_literal"]=s.prototype._fns["member-child-identifier"],s.prototype._fns["member-descendant-numeric_literal"]=s.prototype._fns["subscript-descendant-string_literal"]=s.prototype._fns["member-descendant-identifier"],t.exports=s},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,underscore:12}],5:[function(e,t,n){var r=e("assert"),o=e("./dict"),i=e("./parser"),a=e("./handlers"),s=function(){this.initialize.apply(this,arguments)};function l(e){return"[object String]"==Object.prototype.toString.call(e)}s.prototype.initialize=function(){this.parser=new i,this.handlers=new a},s.prototype.parse=function(e){return r.ok(l(e),"we need a path"),this.parser.parse(e)},s.prototype.parent=function(e,t){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var n=this.nodes(e,t)[0];return n.path.pop(),this.value(e,n.path)},s.prototype.apply=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),r.equal(K(n),"function","fn needs to be function");var o=this.nodes(e,t).sort((function(e,t){return t.path.length-e.path.length}));return o.forEach((function(t){var r=t.path.pop(),o=this.value(e,this.stringify(t.path)),i=t.value=n.call(e,o[r]);o[r]=i}),this),o},s.prototype.value=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),arguments.length>=3){var o=this.nodes(e,t).shift();if(!o)return this._vivify(e,t,n);var i=o.path.slice(-1).shift();this.parent(e,this.stringify(o.path))[i]=n}return this.query(e,this.stringify(t),1).shift()},s.prototype._vivify=function(e,t,n){var o=this;r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var i=this.parser.parse(t).map((function(e){return e.expression.value})),a=function(t,n){var r=t.pop(),i=o.value(e,t);i||(a(t.concat(),"string"==typeof r?{}:[]),i=o.value(e,t)),i[r]=n};return a(i,n),this.query(e,t)[0]},s.prototype.query=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(l(t),"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.value}));return o},s.prototype.paths=function(e,t,n){r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path");var o=this.nodes(e,t,n).map((function(e){return e.path}));return o},s.prototype.nodes=function(e,t,n){if(r.ok(e instanceof Object,"obj needs to be an object"),r.ok(t,"we need a path"),0===n)return[];var o=this.parser.parse(t),i=this.handlers,a=[{path:["$"],value:e}],s=[];return o.length&&"root"==o[0].expression.type&&o.shift(),o.length?(o.forEach((function(e,t){if(!(s.length>=n)){var r=i.resolve(e),l=[];a.forEach((function(i){if(!(s.length>=n)){var a=r(e,i,n);t==o.length-1?s=s.concat(a||[]):l=l.concat(a||[])}})),a=l}})),n?s.slice(0,n):s):a},s.prototype.stringify=function(e){r.ok(e,"we need a path");var t="$",n={"descendant-member":"..{{value}}","child-member":".{{value}}","descendant-subscript":"..[{{value}}]","child-subscript":"[{{value}}]"};return(e=this._normalize(e)).forEach((function(e){if("root"!=e.expression.type){var r,o=[e.scope,e.operation].join("-"),i=n[o];if(r="string_literal"==e.expression.type?JSON.stringify(e.expression.value):e.expression.value,!i)throw new Error("couldn't find template "+o);t+=i.replace(/{{value}}/,r)}})),t},s.prototype._normalize=function(e){if(r.ok(e,"we need a path"),"string"==typeof e)return this.parser.parse(e);if(Array.isArray(e)&&"string"==typeof e[0]){var t=[{expression:{type:"root",value:"$"}}];return e.forEach((function(e,n){"$"==e&&0===n||("string"==typeof e&&e.match("^"+o.identifier+"$")?t.push({operation:"member",scope:"child",expression:{value:e,type:"identifier"}}):t.push({operation:"subscript",scope:"child",expression:{value:e,type:"number"==typeof e?"numeric_literal":"string_literal"}}))})),t}if(Array.isArray(e)&&"object"==K(e[0]))return e;throw new Error("couldn't understand path "+e)},s.Handlers=a,s.Parser=i;var c=new s;c.JSONPath=s,t.exports=c},{"./dict":2,"./handlers":4,"./parser":6,assert:8}],6:[function(e,t,n){var r=e("./grammar"),o=e("../generated/parser"),i=function(){var e=new o.Parser,t=e.parseError;return e.yy.parseError=function(){e.yy.ast&&e.yy.ast.initialize(),t.apply(e,arguments)},e};i.grammar=r,t.exports=i},{"../generated/parser":1,"./grammar":3}],7:[function(e,t,n){function r(e){return String(e).match(/^[0-9]+$/)?parseInt(e):Number.isFinite(e)?parseInt(e,10):0}t.exports=function(e,t,n,o){if("string"==typeof t)throw new Error("start cannot be a string");if("string"==typeof n)throw new Error("end cannot be a string");if("string"==typeof o)throw new Error("step cannot be a string");var i=e.length;if(0===o)throw new Error("step cannot be zero");if(o=o?r(o):1,n=n<0?i+n:n,t=r(0===(t=t<0?i+t:t)?0:t||(o>0?0:i-1)),n=r(0===n?0:n||(o>0?i:-1)),t=o>0?Math.max(0,t):Math.min(i,t),n=o>0?Math.min(n,i):Math.max(-1,n),o>0&&n<=t)return[];if(o<0&&t<=n)return[];for(var a=[],s=t;s!=n&&!(o<0&&s<=n||o>0&&s>=n);s+=o)a.push(e[s]);return a}},{}],8:[function(e,t,n){var r=e("util/"),o=Array.prototype.slice,i=Object.prototype.hasOwnProperty,a=t.exports=u;function s(e,t){return r.isUndefined(t)?""+t:r.isNumber(t)&&!isFinite(t)||r.isFunction(t)||r.isRegExp(t)?t.toString():t}function l(e,t){return r.isString(e)?e.length<t?e:e.slice(0,t):e}function c(e,t,n,r,o){throw new a.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:o})}function u(e,t){e||c(e,!0,t,"==",a.ok)}function d(e,t){if(e===t)return!0;if(r.isBuffer(e)&&r.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return r.isDate(e)&&r.isDate(t)?e.getTime()===t.getTime():r.isRegExp(e)&&r.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:r.isObject(e)||r.isObject(t)?function(e,t){if(r.isNullOrUndefined(e)||r.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(r.isPrimitive(e)||r.isPrimitive(t))return e===t;var n=f(e),i=f(t);if(n&&!i||!n&&i)return!1;if(n)return d(e=o.call(e),t=o.call(t));var a,s,l=g(e),c=g(t);if(l.length!=c.length)return!1;for(l.sort(),c.sort(),s=l.length-1;s>=0;s--)if(l[s]!=c[s])return!1;for(s=l.length-1;s>=0;s--)if(!d(e[a=l[s]],t[a]))return!1;return!0}(e,t):e==t}function f(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function h(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function p(e,t,n,o){var i;r.isString(n)&&(o=n,n=null);try{t()}catch(e){i=e}if(o=(n&&n.name?" ("+n.name+").":".")+(o?" "+o:"."),e&&!i&&c(i,n,"Missing expected exception"+o),!e&&h(i,n)&&c(i,n,"Got unwanted exception"+o),e&&i&&n&&!h(i,n)||!e&&i)throw i}a.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return l(JSON.stringify(e.actual,s),128)+" "+e.operator+" "+l(JSON.stringify(e.expected,s),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||c;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,o=r.indexOf("\n"+t.name);if(o>=0){var i=r.indexOf("\n",o+1);r=r.substring(i+1)}this.stack=r}}},r.inherits(a.AssertionError,Error),a.fail=c,a.ok=u,a.equal=function(e,t,n){e!=t&&c(e,t,n,"==",a.equal)},a.notEqual=function(e,t,n){e==t&&c(e,t,n,"!=",a.notEqual)},a.deepEqual=function(e,t,n){d(e,t)||c(e,t,n,"deepEqual",a.deepEqual)},a.notDeepEqual=function(e,t,n){d(e,t)&&c(e,t,n,"notDeepEqual",a.notDeepEqual)},a.strictEqual=function(e,t,n){e!==t&&c(e,t,n,"===",a.strictEqual)},a.notStrictEqual=function(e,t,n){e===t&&c(e,t,n,"!==",a.notStrictEqual)},a.throws=function(e,t,n){p.apply(this,[!0].concat(o.call(arguments)))},a.doesNotThrow=function(e,t){p.apply(this,[!1].concat(o.call(arguments)))},a.ifError=function(e){if(e)throw e};var g=Object.keys||function(e){var t=[];for(var n in e)i.call(e,n)&&t.push(n);return t}},{"util/":11}],9:[function(e,t,n){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],10:[function(e,t,n){t.exports=function(e){return e&&"object"===K(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],11:[function(e,t,n){(function(t,r){var o=/%[sdj%]/g;n.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,a=String(e).replace(o,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),l=r[n];n<i;l=r[++n])g(l)||!b(l)?a+=" "+l:a+=" "+s(l);return a},n.deprecate=function(e,o){if(_(r.process))return function(){return n.deprecate(e,o).apply(this,arguments)};if(!0===t.noDeprecation)return e;var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(o);t.traceDeprecation?console.trace(o):console.error(o),i=!0}return e.apply(this,arguments)}};var i,a={};function s(e,t){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(t)?r.showHidden=t:t&&n._extend(r,t),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function c(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(r,e);return y(o)||(o=u(e,o,r)),o}var i=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):p(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var a=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),w(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return d(t);if(0===a.length){if(S(t))return e.stylize("[Function"+(t.name?": "+t.name:"")+"]","special");if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(x(t))return e.stylize(Date.prototype.toString.call(t),"date");if(w(t))return d(t)}var l,c="",b=!1,C=["{","}"];return h(t)&&(b=!0,C=["[","]"]),S(t)&&(c=" [Function"+(t.name?": "+t.name:"")+"]"),v(t)&&(c=" "+RegExp.prototype.toString.call(t)),x(t)&&(c=" "+Date.prototype.toUTCString.call(t)),w(t)&&(c=" "+d(t)),0!==a.length||b&&0!=t.length?r<0?v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=b?function(e,t,n,r,o){for(var i=[],a=0,s=t.length;a<s;++a)N(t,String(a))?i.push(f(e,t,n,r,String(a),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(f(e,t,n,r,o,!0))})),i}(e,t,r,s,a):a.map((function(n){return f(e,t,r,s,n,b)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(l,c,C)):C[0]+c+C[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,o,i){var a,s,l;if((l=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=e.stylize(l.set?"[Getter/Setter]":"[Getter]","special"):l.set&&(s=e.stylize("[Setter]","special")),N(r,o)||(a="["+o+"]"),s||(e.seen.indexOf(l.value)<0?(s=g(n)?u(e,l.value,null):u(e,l.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),_(a)){if(i&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function v(e){return b(e)&&"[object RegExp]"===C(e)}function b(e){return"object"===K(e)&&null!==e}function x(e){return b(e)&&"[object Date]"===C(e)}function w(e){return b(e)&&("[object Error]"===C(e)||e instanceof Error)}function S(e){return"function"==typeof e}function C(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(_(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=t.pid;a[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else a[e]=function(){};return a[e]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=h,n.isBoolean=p,n.isNull=g,n.isNullOrUndefined=function(e){return null==e},n.isNumber=m,n.isString=y,n.isSymbol=function(e){return"symbol"===K(e)},n.isUndefined=_,n.isRegExp=v,n.isObject=b,n.isDate=x,n.isError=w,n.isFunction=S,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===K(e)||void 0===e},n.isBuffer=e("./support/isBuffer");var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(t=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),k[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),void 0!==re?re:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:14,inherits:9}],12:[function(e,t,n){},{}],13:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var a=i>=0?arguments[i]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(n=a+"/"+n,o="/"===a.charAt(0))}return(o?"/":"")+(n=t(r(n.split("/"),(function(e){return!!e})),!o).join("/"))||"."},n.normalize=function(e){var i=n.isAbsolute(e),a="/"===o(e,-1);return(e=t(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),a=Math.min(o.length,i.length),s=a,l=0;l<a;l++)if(o[l]!==i[l]){s=l;break}var c=[];for(l=s;l<o.length;l++)c.push("..");return(c=c.concat(i.slice(s))).join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(o=!1,r=a+1),46===s?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=a+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:14}],14:[function(e,t,n){var r,o,i=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}}();var c,u=[],d=!1,f=-1;function h(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!d){var e=l(h);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,d=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===s||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||d||l(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],15:[function(e,t,n){var r=e("escodegen").generate;t.exports=function(e,t){t||(t={});var n={},o=function e(o,i){if("Literal"===o.type)return o.value;if("UnaryExpression"===o.type){var a=e(o.argument);return"+"===o.operator?+a:"-"===o.operator?-a:"~"===o.operator?~a:"!"===o.operator?!a:n}if("ArrayExpression"===o.type){for(var s=[],l=0,c=o.elements.length;l<c;l++){if((y=e(o.elements[l]))===n)return n;s.push(y)}return s}if("ObjectExpression"===o.type){var u={};for(l=0;l<o.properties.length;l++){var d=null===(_=o.properties[l]).value?_.value:e(_.value);if(d===n)return n;u[_.key.value||_.key.name]=d}return u}if("BinaryExpression"===o.type||"LogicalExpression"===o.type){if((c=e(o.left))===n)return n;var f=e(o.right);if(f===n)return n;var h=o.operator;return"=="===h?c==f:"==="===h?c===f:"!="===h?c!=f:"!=="===h?c!==f:"+"===h?c+f:"-"===h?c-f:"*"===h?c*f:"/"===h?c/f:"%"===h?c%f:"<"===h?c<f:"<="===h?c<=f:">"===h?c>f:">="===h?c>=f:"|"===h?c|f:"&"===h?c&f:"^"===h?c^f:"&&"===h?c&&f:"||"===h?c||f:n}if("Identifier"===o.type)return{}.hasOwnProperty.call(t,o.name)?t[o.name]:n;if("ThisExpression"===o.type)return{}.hasOwnProperty.call(t,"this")?t.this:n;if("CallExpression"===o.type){var p=e(o.callee);if(p===n)return n;if("function"!=typeof p)return n;var g=o.callee.object?e(o.callee.object):n;g===n&&(g=null);var m=[];for(l=0,c=o.arguments.length;l<c;l++){var y;if((y=e(o.arguments[l]))===n)return n;m.push(y)}return p.apply(g,m)}var _;if("MemberExpression"===o.type)return(u=e(o.object))===n||"function"==typeof u?n:"Identifier"===o.property.type?u[o.property.name]:(_=e(o.property))===n?n:u[_];if("ConditionalExpression"===o.type)return(a=e(o.test))===n?n:e(a?o.consequent:o.alternate);if("ExpressionStatement"===o.type)return(a=e(o.expression))===n?n:a;if("ReturnStatement"===o.type)return e(o.argument);if("FunctionExpression"===o.type){var v=o.body.body,b={};for(Object.keys(t).forEach((function(e){b[e]=t[e]})),l=0;l<o.params.length;l++){var x=o.params[l];if("Identifier"!=x.type)return n;t[x.name]=null}for(var l in v)if(e(v[l])===n)return n;t=b;var w=Object.keys(t),S=w.map((function(e){return t[e]}));return Function(w.join(", "),"return "+r(o)).apply(null,S)}if("TemplateLiteral"===o.type){var C="";for(l=0;l<o.expressions.length;l++)C+=e(o.quasis[l]),C+=e(o.expressions[l]);return C+e(o.quasis[l])}if("TaggedTemplateExpression"===o.type){var A=e(o.tag),k=o.quasi,N=k.quasis.map(e),T=k.expressions.map(e);return A.apply(null,[N].concat(T))}return"TemplateElement"===o.type?o.value.cooked:n}(e);return o===n?void 0:o}},{escodegen:12}],jsonpath:[function(e,t,n){t.exports=e("./lib/index")},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")}(os)),os.exports),as=oe(is);const ss=new Set(["i","me","my","myself","we","our","ours","ourselves","you","your","yours","yourself","yourselves","he","him","his","himself","she","her","hers","herself","it","its","itself","they","them","their","theirs","themselves","what","which","who","whom","this","that","these","those","am","is","are","was","were","be","been","being","have","has","had","having","do","does","did","doing","a","an","the","and","but","if","or","because","as","until","while","of","at","by","for","with","about","against","between","into","through","during","before","after","above","below","to","from","up","down","in","out","on","off","over","under","again","further","then","once","here","there","when","where","why","how","all","any","both","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","s","t","can","will","just","don","should","now","0","1","2","3","4","5","6","7","8","9"]);function ls(e,t){for(const[n,r]of t.entries())if(e.startsWith(r))return e.replace(r,String(n));return e}const cs="$PREFIXED_ID";function us(e,t,n){if(t===cs)return[ls(e.id,n)];let r;try{r=as.query(e,t)}catch{r=as.query(JSON.parse(JSON.stringify(e)),t)}return r}function ds(e){return e.toLowerCase().split(/[^\d:A-Za-z]+/).filter((e=>e&&!ss.has(e)))}function*fs(e){for(const t of e)yield*ds(t)}function*hs(e){for(const t of e)if("string"==typeof t)yield t;else if("object"==typeof t){const e=as.query(t,"$..*");yield*hs(e)}}function*ps(e,t,n){for(const r of t){const t=us(e,r,n);if(t.length>0)for(const e of fs(hs(t)))yield[r,e]}}async function gs(e,t,n){const r=await this.db,o=t??r.transaction(["nodes"]);es(n);const i=[...ds(e)],a=[],s=new Map;a.push(...i.map((async(e,t)=>{es(n);const r=o.objectStore("nodes").index("full-text-words");for await(const o of r.iterate(IDBKeyRange.bound(e,`${e}`,!1,!1))){es(n);const e=o.value,r=s.get(e.id)??[e,new Set];r[1].add(t),s.set(e.id,r)}}))),await Promise.all(a),es(n);const l=[];for(const[,[e,t]]of s)es(n),l.push(...ms(this.textIndexFields,e,t,i,this.prefixes));return l.sort(((e,t)=>t.score-e.score)),l.slice(0,this.options.maxSearchResults??this.DEFAULT_MAX_SEARCH_RESULTS)}function ms(e,t,n,r,o){const i=[...n].sort().map((e=>r[e])),a=i.map((e=>{const t=e.replaceAll(/[$()*+./?[\\\]^{|}-]/g,String.raw`\$&`);return new RegExp(`\\b${t}`,"gi")}));let s=[],l=0;for(const[n,i]of e.entries()){const c=new Set,u=e.length-n-1,d=[...hs(us(t,i.jsonPath,o))];for(const e of d){let n=0;const o=[];for(const[t,i]of a.entries())for(const a of e.matchAll(i)){n+=1+1*u,c.add(t);const i=a.index,s=r[t];void 0!==i&&(n+=.01*s.length,n+=s.length/e.length*100*.05,o.push({wordIndex:t,position:i}))}n+=100*c.size,l<n&&(l=n),o.sort(((e,t)=>e.position-t.position)),o.length>0&&s.push({term:t,field:i,str:e,score:n,wordMatches:o})}}s=s.filter((e=>e.score===l));for(const e of s){const{wordMatches:t}=e;for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1],a=o.wordIndex-r.wordIndex;if(1===a||-1===a){e.score+=1,1===a&&(e.score+=1);const t=Math.abs(o.position-(r.position+i[r.wordIndex].length))-1;e.score-=.05*t}}}return s}function ys(e){return"string"==typeof e.id}function _s(e){return"string"==typeof e.sub&&"string"==typeof e.pred&&"string"==typeof e.obj}function vs(e){return Boolean(e.meta?.deprecated)}var bs,xs,ws=(xs||(xs=1,bs=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==K(t)&&"object"==K(n)){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;var a,s=j(t.entries());try{for(s.s();!(a=s.n()).done;)if(!n.has((o=a.value)[0]))return!1}catch(e){s.e(e)}finally{s.f()}var l,c=j(t.entries());try{for(c.s();!(l=c.n()).done;)if(!e((o=l.value)[1],n.get(o[0])))return!1}catch(e){c.e(e)}finally{c.f()}return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;var u,d=j(t.entries());try{for(d.s();!(u=d.n()).done;)if(!n.has((o=u.value)[0]))return!1}catch(e){d.e(e)}finally{d.f()}return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;0!=o--;){var f=i[o];if(!e(t[f],n[f]))return!1}return!0}return t!=t&&n!=n}),bs),Ss=oe(ws);function Cs(e){return"CLASS"===e.type}function As(e){return"PROPERTY"===e.type}const ks=[{displayName:"Label",jsonPath:"$.lbl"},{displayName:"Synonym",jsonPath:"$.meta.synonyms[*].val"},{displayName:"Definition",jsonPath:"$.meta.definition.val"}];async function Ns(e){return qa(e,2,{upgrade(e,t,n,r,o){if(t<2&&(e.objectStoreNames.contains("meta")&&e.deleteObjectStore("meta"),e.objectStoreNames.contains("nodes")&&e.deleteObjectStore("nodes"),e.objectStoreNames.contains("edges")&&e.deleteObjectStore("edges")),e.objectStoreNames.contains("meta")||e.createObjectStore("meta"),!e.objectStoreNames.contains("nodes")){e.createObjectStore("nodes",{keyPath:"id"});const t=r.objectStore("nodes");t.createIndex("by-label","lbl"),t.createIndex("by-type","type"),t.createIndex("by-synonym",["meta","synonyms","val"]),t.createIndex("full-text-words","fullTextWords",{multiEntry:!0})}if(!e.objectStoreNames.contains("edges")){e.createObjectStore("edges",{autoIncrement:!0});const t=r.objectStore("edges");t.createIndex("by-subject","sub"),t.createIndex("by-object","obj"),t.createIndex("by-predicate","pred")}}})}function Ts(e){const t=new Set;for(const[,n]of e)t.add(n);return[...t]}async function Rs(e){const t=Date.now();let n,r=1;this.options.update?.("Parsing JSON",r);try{n=JSON.parse(await f.openLocation(this.sourceLocation).readFile("utf8"))}catch{throw new Error("Error in loading ontology")}r+=5,this.options.update?.("Parsing JSON complete",r);const o=Date.now(),[i,...a]=n.graphs??[];if(i){if(a.length>0)throw new Error("multiple graphs not supported");try{const n=e.transaction(["meta","nodes","edges"],"readwrite");await n.objectStore("meta").clear(),await n.objectStore("nodes").clear(),await n.objectStore("edges").clear();const a=n.objectStore("nodes"),s=Es.call(this).map((e=>e.jsonPath));if(i.nodes){let e=Math.round(r);for(const[,t]of i.nodes.entries())r+=1/i.nodes.length*64,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing nodes",r),e=Math.round(r)),ys(t)&&await a.add({...t,fullTextWords:Ts(ps(t,s,this.prefixes))})}const l=n.objectStore("edges");if(i.edges){let e=Math.round(r);for(const[,t]of i.edges.entries())r+=1/i.edges.length*30,Math.round(r)!=e&&r<100&&(this.options.update?.("Processing edges",r),e=Math.round(r)),_s(t)&&await l.add(t)}await n.done;const c=e.transaction("meta","readwrite"),{update:u,...d}=this.options;await c.objectStore("meta").delete("meta"),await c.objectStore("meta").add({ontologyRecord:{name:this.ontologyName,version:this.ontologyVersion,sourceLocation:this.sourceLocation},storeOptions:d,graphMeta:i.meta,timestamp:String(new Date),schemaVersion:2,timings:{overall:Date.now()-t,load:Date.now()-o}},"meta"),await c.done}catch(t){throw await e.transaction("meta","readwrite").objectStore("meta").clear(),t}}}function Es(){return[{displayName:"ID",jsonPath:cs},...this.options.textIndexing?.indexFields??ks]}async function Is(e){const[t]=await e.transaction("meta").objectStore("meta").getAll();return!!t&&Ss(this.options.prefixes,t.storeOptions.prefixes)&&Ss(this.options.textIndexing,t.storeOptions.textIndexing)}class js{ontologyName;ontologyVersion;sourceLocation;db;options;loadOboGraphJson=Rs;getTermsByFulltext=gs;openDatabase=Ns;isDatabaseCurrent=Is;get textIndexFields(){return Es.call(this)}get prefixes(){return this.options.prefixes??new Map}DEFAULT_MAX_SEARCH_RESULTS=100;constructor(e,t,n,r){this.ontologyName=e,this.ontologyVersion=t,this.sourceLocation=n,this.options=r??{},this.db=this.prepareDatabase()}validate(){const e=[],{sourceLocation:t,sourceType:n}=this;return n?"obo-graph-json"!==n&&e.push(new Error(`ontology source file ${JSON.stringify(t)} has type ${n}, which is not yet supported`)):e.push(new Error(`unable to determine format of ontology source file ${JSON.stringify(t)}, file name must end with ".json", ".obo", or ".owl"`)),e}get sourceType(){if(o.isUriLocation(this.sourceLocation)){if(this.sourceLocation.uri.endsWith(".json"))return"obo-graph-json"}else if(o.isLocalPathLocation(this.sourceLocation)&&this.sourceLocation.localPath.endsWith(".json"))return"obo-graph-json"}get dbName(){return`Apollo Ontology "${this.ontologyName}" "${this.ontologyVersion}"`}async prepareDatabase(){const e=this.validate();if(e.length>0)throw e;const t=await this.openDatabase(this.dbName);if(await this.isDatabaseCurrent(t))return t;try{const{options:e,sourceLocation:n,sourceType:r}=this;if("obo-graph-json"!==r)throw new Error(`ontology source file ${JSON.stringify(n)} has type ${r}, which is not yet supported`);return e.update?.("",0),await this.loadOboGraphJson(t),e.update?.("",100),t}catch(e){throw t.close(),await function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).blocked,n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(function(e){return t(e.oldVersion,e)})),Pa(n).then((function(){}))}(this.dbName),e}}async termCount(e){const t=await this.db;return(e??t.transaction("nodes")).objectStore("nodes").count()}unique(e){const t=new Map,n=[];for(const r of e)t.has(r.id)||(t.set(r.id,!0),n.push(r));return n}async getTermsWithLabelOrSynonym(e,t,n){const r=t?.includeSubclasses??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=i.objectStore("nodes"),s=[...await a.index("by-label").getAll(e),...await a.index("by-synonym").getAll(e)];if(r){const e=await this.recurseEdges("by-object",s.map((e=>e.id)),(e=>"is_a"===e.pred),"sub",i);for(const t of e){const e=await a.get(t);e&&s.push(e)}}return s}async getPropertiesByLabel(e,t,n){const r=t?.includeSubProperties??!0,o=await this.db,i=n??o.transaction(["nodes","edges"]),a=(await this.getTermsWithLabelOrSynonym(e,{includeSubclasses:!1},i)).filter((e=>As(e)));if(r){const e=await this.recurseEdges("by-object",a.map((e=>e.id)),(e=>"subPropertyOf"===e.pred),"sub",i),t=i.objectStore("nodes");for(const n of e){const e=await t.get(n);e&&As(e)&&a.push(e)}}return a}async recurseEdges(e,t,n,r,o){const i=new Set;return await async function t(a){await Promise.all([...a].map((async a=>{const s=(await o.objectStore("edges").index(e).getAll(a)).filter((e=>n(e))).map((e=>e[r]));if(s.length>0){for(const e of s)i.add(e);await t(s)}})))}(t),i.values()}async*expandNodeSet(e,t="is_a",n,r){const o=await this.db,i=r??o.transaction(["edges"]),a=[...e],s=await this.recurseEdges("subclasses"===n?"by-object":"by-subject",a,(e=>e.pred===t),"subclasses"===n?"sub":"obj",i);for(const e of a)yield e;for(const e of s)yield e}expandSubclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"subclasses",n)}expandSuperclasses(e,t="is_a",n){return this.expandNodeSet(e,t,"superclasses",n)}async getClassesThat(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=await this.getPropertiesByLabel(e,{includeSubProperties:!0},o),a=new Set(i.map((e=>e.id))),s=await async function(e){const t=[];for await(const n of e)t.push(n);return t}(this.expandSuperclasses(t.map((e=>e.id)),"is_a",o)),l=await this.recurseEdges("by-object",s,(e=>a.has(e.pred)),"sub",o),c=this.expandSubclasses(l,"is_a",o),u=[];for await(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getClassesWithoutPropertyLabeled(e,t,n){const r=await this.db,o=n??r.transaction(["nodes","edges"]),i=o.objectStore("nodes"),a=o.objectStore("edges"),s=(await this.getPropertiesByLabel(e,t,o)).map((e=>e.id)),l=await(async()=>{const e=new Set;for(const t of s)for await(const n of a.index("by-predicate").iterate(t))e.add(n.value.sub);const t=new Set;for await(const n of this.expandSubclasses(e,"is_a",o))t.add(n);return t})(),c=[];for await(const e of i){const t=e.value;Cs(t)&&!l.has(t.id)&&c.push(t.id)}const u=[];for(const e of c){const t=await o.objectStore("nodes").get(e);t&&Cs(t)&&!vs(t)&&u.push(t)}return u}async getAllClasses(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").index("by-type").getAll("CLASS")).filter((e=>!vs(e)))}async getAllTerms(e){const t=await this.db,n=e??t.transaction(["nodes"]);return(await n.objectStore("nodes").getAll()).filter((e=>!vs(e)))}}const Ds=l.types.model("OntologyRecord",{name:l.types.string,version:"unversioned",source:l.types.union(d.LocalPathLocation,d.UriLocation,d.BlobLocation),options:l.types.frozen(),equivalentTypes:l.types.map(l.types.array(l.types.string))}).volatile((e=>({dataStore:void 0,startedEquivalentTypeRequests:new Set}))).actions((e=>({ping(){},initDataStore(){e.dataStore=new js(e.name,e.version,l.getSnapshot(e.source),e.options)},afterCreate(){l.addDisposer(e,c.autorun((()=>{this.initDataStore()})))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).actions((e=>({loadEquivalentTypes:l.flow((function*(t){if(!e.dataStore)return;if(e.startedEquivalentTypeRequests.has(t))return;e.startedEquivalentTypeRequests.add(t);const n=(yield e.dataStore.getTermsWithLabelOrSynonym(t)).map((e=>e.lbl)).filter((e=>null!=e));l.isAlive(e)&&e.setEquivalentTypes(t,n)}))}))).actions((e=>({afterCreate(){c.autorun((t=>{e.dataStore&&(e.loadEquivalentTypes("gene"),e.loadEquivalentTypes("pseudogene"),e.loadEquivalentTypes("transcript"),e.loadEquivalentTypes("pseudogenic_transcript"),e.loadEquivalentTypes("CDS"),e.loadEquivalentTypes("mRNA"),t.dispose())}))},setEquivalentTypes(t,n){e.equivalentTypes.set(t,n)}}))).views((e=>({isTypeOf(t,n){if(t===n)return!0;if(!e.dataStore)return!1;const r=e.equivalentTypes.get(n);return r?r.includes(t):(e.loadEquivalentTypes(n),!1)}}))),Os=l.types.model("OntologyManager",{ontologies:l.types.array(Ds),prefixes:l.types.optional(l.types.map(l.types.string),{"GO:":"http://purl.obolibrary.org/obo/GO_","SO:":"http://purl.obolibrary.org/obo/SO_"})}).views((e=>({get featureTypeOntologyName(){const t=l.getRoot(e).jbrowse.configuration;return n.readConfObject(t.ApolloPlugin,"featureTypeOntologyName")}}))).views((e=>({get featureTypeOntology(){return this.findOntology(e.featureTypeOntologyName)},findOntology:(t,n)=>e.ontologies.find((e=>e.name===t&&(void 0===n||e.version===n))),openOntology(e,t){return this.findOntology(e,t)?.dataStore},applyPrefixes:t=>ls(t,e.prefixes),expandPrefixes:t=>function(e,t){for(const[n,r]of t.entries())if(e.startsWith(String(n)))return e.replace(String(n),r);return e}(t,e.prefixes)}))).actions((e=>({addOntology(t,n,r,o){const i=e.ontologies.push({name:t,version:n,source:r,options:{prefixes:new Map(e.prefixes.entries()),...o}});e.ontologies[i-1].ping()}}))),Fs=n.ConfigurationSchema("OntologyRecord",{name:{type:"string",description:'the full name of the ontology, e.g. "Gene Ontology"',defaultValue:"My Ontology"},version:{type:"string",description:"the ontology's version string",defaultValue:"unversioned"},source:{type:"fileLocation",description:"the download location for the ontology's source file",defaultValue:{locationType:"UriLocation",uri:"http://example.com/myontology.json"}},textIndexFields:{type:"frozen",description:"JSON paths for text fields that will be indexed for text searching",defaultValue:ks}});async function Ms(e,t,n){if(!e)return;const r=await t.getTermsWithLabelOrSynonym(e.type,{includeSubclasses:!1}),o=r.filter(Cs);if(0===r.length)return;const i=await t.getClassesThat("part_of",o);return 0!==i.length?i:void 0}var Ls=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");const Ps=ma()((e=>({dialogTitle:{background:e.palette.primary.main,color:e.palette.primary.contrastText,padding:e.spacing(2)},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1.5),color:e.palette.primary.contrastText}}))),Bs=p.observer((function(e){const{classes:t}=Ps(),{handleClose:n,title:r,...o}=e;return i.jsx(h.Dialog,{...o,header:i.jsxs(i.Fragment,{children:[i.jsx(s.DialogTitle,{className:t.dialogTitle,children:r}),i.jsx(s.IconButton,{"aria-label":"close",onClick:n,className:t.closeButton,children:i.jsx(Ls,{})})]})})}));function qs({fetchValidTerms:e,filterTerms:t,includeDeprecated:n,onChange:r,ontologyName:o,ontologyVersion:a,renderInput:l,session:c,style:d,value:f}){const[h,p]=u.useState(!1),[g,m]=u.useState(),[y,_]=u.useState(""),[v,b]=u.useState(),{ontologyManager:x}=c.apolloDataStore,w=x.findOntology(o,a)?.dataStore,S=w&&h&&!g,C=w&&!v,A=u.useCallback((e=>(n||!vs(e))&&(!t||t(e))),[t,n]);u.useEffect((()=>{const e=new AbortController,{signal:t}=e;return C&&async function(e,t,n,r){if(!t)return;const o=(await e.getTermsWithLabelOrSynonym(t,{includeSubclasses:!1})).find((e=>(n??(()=>!0))(e)));if(!o)throw new Error(`not a valid ${e.ontologyName} term`);return o}(w,f,A).then((e=>{_(""),t.aborted||b(e)}),(e=>{t.aborted||ts(e)||_(String(e))})),()=>{e.abort(new DOMException("Cancel getting current term from ontology store","AbortError"))}}),[c,f,A,w,C]),u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return S&&async function(e,t,n,r){let o;if(t){const n=await t(e,r);n&&(o=n)}return o||(o=await e.getAllTerms()),n?o.filter((e=>n(e))):o}(w,e,A,n).then((e=>{e&&!n.aborted&&m(e)}),(e=>{n.aborted||ts(e)||c.notify(e instanceof Error?e.message:String(e),"error")})),()=>{t.abort(new DOMException("Canceling getting valid terms from ontology store","AbortError"))}}),[S,A,w,c,e]);const k={};return y&&(k.error=!0,k.helperText=y),i.jsx(s.Autocomplete,{style:d,autoComplete:!0,filterSelectedOptions:!0,disableClearable:!0,selectOnFocus:!0,clearOnBlur:!0,handleHomeEndKeys:!0,freeSolo:!0,value:f,options:g??[],onOpen:()=>{p(!0)},onClose:()=>{p(!1)},loading:S,renderInput:l??(e=>i.jsx(s.TextField,{...e,...k})),getOptionLabel:e=>"string"==typeof e?e:e.lbl??"",isOptionEqualToValue:(e,t)=>e.lbl===t.lbl,onChange:(e,t)=>{t&&("string"==typeof t?(b(void 0),r(f,t)):t.lbl!==f&&(_(""),b(t),r(f,t.lbl)))}})}function Us({changeManager:e,handleClose:t,session:n,sourceAssemblyId:r,sourceFeature:o}){const[a,l]=u.useState(String(o.max)),[c,d]=u.useState(String(o.min+1)),[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(""),_=Number(a)<=Number(c);return i.jsxs(Bs,{open:!0,title:"Add new child feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),g("");const s=(new at).toHexString(),l={_id:s,refSeq:o.refSeq,min:Number(c)-1,max:Number(a),type:f};o.strand&&(l.strand=o.strand);const u=new ht({changedIds:[o._id],typeName:"AddFeatureChange",assembly:r,addedFeature:l,parentFeatureId:o._id});e.submit(u).then((()=>{n.apolloSetSelectedFeature(s)})),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:c,onChange:e=>{d(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:a,onChange:e=>{l(e.target.value)},error:_,helperText:_?'"End" must be greater than "Start"':null}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",style:{width:170},value:f,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;y(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,o),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(m),helperText:m}),onChange:(e,t)=>{var n;t&&(n=t,g(""),h(n))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:_||!(c&&a&&f),children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const $s=["#cc79a7","#d65e00","#e69f00","#f0e442","#56b3e9","#0072b2","#009e73"];function zs({changeManager:e,handleClose:t,sourceAssemblyId:n,sourceFeature:r}){const o=r.attributes.get("apollo_color")?.[0],[a,c]=u.useState(o??$s[0]);return i.jsx(Bs,{open:!0,title:"Color feature",handleClose:t,maxWidth:!1,"data-testid":"color-feature",children:i.jsxs("form",{onSubmit:o=>{!async function(o){o.preventDefault();const i=r.attributes.get("apollo_color")?.[0];if(i===a)return void t();const s=l.getSnapshot(r.attributes),c={...s,apollo_color:[a]},u=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:s,newAttributes:c});await e.submit(u),t()}(o)},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Choose a color for this feature."}),i.jsx("div",{style:{display:"flex",gap:8,marginTop:8},children:$s.map((e=>{const t=a.toLowerCase()===e;return i.jsx("button",{type:"button","aria-label":e,"aria-pressed":t,onClick:()=>{c(e)},style:{width:32,height:32,padding:0,borderRadius:4,border:"1px solid rgba(0, 0, 0, 0.3)",outline:t?"2px solid currentColor":"none",outlineOffset:2,backgroundColor:e,cursor:"pointer"}},e)}))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:16},children:[i.jsx("label",{htmlFor:"color-feature-custom",children:"Custom:"}),i.jsx("input",{id:"color-feature-custom",type:"color",value:a,onChange:e=>{c(e.target.value)}})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",color:"error",type:"button",disabled:void 0===o,onClick:()=>{!async function(){const o=l.getSnapshot(r.attributes),{apollo_color:i,...a}=o,s=new St({changedIds:[r._id],typeName:"FeatureAttributeChange",assembly:n,featureId:r._id,oldAttributes:o,newAttributes:a});await e.submit(s),t()}()},children:"Remove color"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]})})}function Hs(e,t){const n=(new at).toHexString();t.push(n);const r={};if(e.children)for(const n of Object.values(e.children)){const e=Hs(n,t);r[e._id]=e}const o="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString();return{...e,refSeq:o,children:e.children&&r,_id:n}}function Gs({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a}){const{assemblyManager:c}=r,d=c.assemblyList,[f,h]=u.useState(d.find((e=>e.name!==o))?.name),[p,g]=u.useState([]),[m,y]=u.useState(""),[_,v]=u.useState(a.min),[b,x]=u.useState("");function w(e,t){const n={};if(e.children)for(const r of Object.values(e.children)){const e=w(r,t);e.refSeq=m,e.min=e.min+t,e.max=e.max+t,n[e._id]=e}const r="string"==typeof e.refSeq?e.refSeq:e.refSeq.toHexString(),o="string"==typeof e._id?e._id:e._id.toHexString();return{...e,refSeq:r,children:e.children&&n,_id:o}}return u.useEffect((()=>{(async function(){if(y(""),!f)return void x("No assemblies to copy to");const e=await c.waitForAssembly(f);if(!e)return;const{refNameAliases:t}=e;if(!t)return;const n=[...Object.entries(t)].filter((([e,t])=>e!==t)).map((([e,t])=>({_id:e,name:t})));g(n),y(n[0]?._id||"")})().catch((e=>{x(String(e))}))}),[f,c]),i.jsxs(Bs,{open:!0,title:"Copy features and annotations",handleClose:t,maxWidth:!1,"data-testid":"copy-feature",children:[i.jsxs("form",{onSubmit:async function(n){if(!f)return;n.preventDefault(),x("");const o=a.length,i=await c.waitForAssembly(f);if(!i)return void x(`Assembly not found: ${f}.`);const s=i.getCanonicalRefName(m),u=i.regions?.find((e=>e.refName===s));if(!u)return void x(`RefSeq not found: ${m}.`);const d=_+o;if(d>u.end)return void x(`Feature would extend beyond the bounds of the selected reference sequence. (Feature would end at ${d}, but reference sequence ends at ${u.end})`);if(_<u.start)return void x(`Reference sequence starts at ${u.start}, feature cannot start before that.`);const h=[],p=Hs(l.getSnapshot(a),h),g={...p.attributes};"Parent"in g&&delete g.Parent,p.refSeq=m;const y=_-p.min;p.min=_,p.max=_+o;const v=w(p,y),b=new ht({changedIds:[p._id],typeName:"AddFeatureChange",assembly:f,addedFeature:{_id:p._id,refSeq:p.refSeq,min:p.min,max:p.max,type:p.type,children:v.children,attributes:g,strand:p.strand},copyFeature:!0,allIds:h});e.submit(b).then((()=>{r.apolloSetSelectedFeature(p._id)})),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Target assembly"}),i.jsx(s.Select,{labelId:"label",value:f,onChange:function(e){h(e.target.value)},children:d.filter((e=>e.name!==o)).map((e=>i.jsx(s.MenuItem,{value:e.name,children:n.readConfObject(e,"displayName")},e.name)))}),i.jsx(s.DialogContentText,{children:"Target reference sequence"}),i.jsx(s.Select,{labelId:"label",value:m,onChange:function(e){y(e.target.value)},children:p.map((e=>i.jsx(s.MenuItem,{value:e._id,children:e.name},e._id)))}),i.jsx(s.DialogContentText,{children:"Start position in target reference sequence"}),i.jsx(s.TextField,{margin:"dense",type:"number",fullWidth:!0,variant:"outlined",value:_,onChange:e=>{v(Number(e.target.value))}})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!f||!m||!_,variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function Vs({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),{ontologyManager:h}=r.apolloDataStore,{featureTypeOntology:p}=h;function g(e){if(!e.parent?.children||1===e.parent.children.size)return;const t=[];for(const n of e.parent.children.values())p?.isTypeOf(n.type,"CDS")||t.push(n);t.sort(((e,t)=>e.min-t.min));const n=[];for(const t of e.parent.children.values())p?.isTypeOf(t.type,"CDS")||n.push(t);if(n.sort(((e,t)=>t.max-e.max)),e.min===t[0].min){let n;for(const r of t)if(r._id!==e._id&&r.min>=e.min){n=r.min;break}if(n&&n!=e.parent.min)return{typeName:"LocationStartChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.min,newLocation:n}}if(e.max===n[0].max){let t;for(const r of n)if(r._id!=e._id&&r.max<=e.max){t=r.max;break}if(t&&t!=e.parent.max)return{typeName:"LocationEndChange",changedId:e.parent._id,featureId:e.parent._id,oldLocation:e.parent.max,newLocation:t}}}return i.jsxs(Bs,{open:!0,title:"Delete feature",handleClose:t,maxWidth:!1,"data-testid":"delete-feature",children:[i.jsxs("form",{onSubmit:r=>{!async function(r){r.preventDefault(),f(""),n?._id===c._id&&o();const i=[],s=new pt({changedIds:[c._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(c),parentFeatureId:c.parent?._id}]});if(p&&(p.isTypeOf(c.type,"transcript")||p.isTypeOf(c.type,"pseudogenic_transcript"))){const e=g(c);e&&i.push(e)}if(p&&p.isTypeOf(c.type,"exon")){const e=function(e){if(!p)return;if(!p.isTypeOf(e.type,"exon"))return;if(!e.parent?.cdsLocations||0===e.parent.cdsLocations.length||0===e.parent.cdsLocations[0].length)return;if(!e.parent.children)throw new Error("Unable to find parent of CDS");if(1!=e.parent.cdsLocations.length)throw new Error("Unable to handle a transcript with multiple CDSs");const t=(e.parent.cdsLocations.at(0)??[]).sort((({min:e},{min:t})=>e-t));let n;for(const r of e.parent.children.values())if(r.type===t[0].type){n=r;break}if(!n)throw new Error("Unable to find CDS");const r=t[0].min,o=t[t.length-1].max;if(!(e.min>r&&e.max<o||e.max<r||e.min>o)){if(e.min<=r&&e.max>=o)return new pt({changedIds:[n._id],typeName:"DeleteFeatureChange",assembly:a,changes:[{deletedFeature:l.getSnapshot(n),parentFeatureId:n.parent?._id}]});if(e.min<=r&&e.max>r){let r;for(const n of t)if(n.min>e.max){r=n.min;break}if(!r)throw new Error("Error setting new CDS start");return{typeName:"LocationStartChange",changedId:n._id,featureId:n._id,oldLocation:n.min,newLocation:r}}if(e.min<o&&e.max>=o){let r;for(const n of t.reverse())if(n.max<e.min){r=n.max;break}if(!r)throw new Error("Error setting new CDS end");return{typeName:"LocationEndChange",changedId:n._id,featureId:n._id,oldLocation:n.max,newLocation:r}}throw new Error("Unexpected relationship between exon and CDS")}}(c);e&&("DeleteFeatureChange"===e.typeName?(s.changedIds.push(...e.changedIds),s.changes.push(...e.changes)):i.push(e));const t=g(c);if(t){i.push(t);const e=c.parent?.parent;if(e?.children)if("LocationStartChange"===t.typeName){let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.min<n&&(n=r.min);n!=e.min&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.min,newLocation:n})}else{let n=t.newLocation;for(const[,r]of e.children)r._id!=t.featureId&&r.max>n&&(n=r.max);n!=e.max&&i.push({typeName:t.typeName,changedId:e._id,featureId:e._id,oldLocation:e.max,newLocation:n})}}}const u=function(e,t){if(0===e.length)return;const n=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:t}),r=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:t});for(const t of e)"LocationStartChange"===t.typeName&&(n.changedIds.push(t.changedId),n.changes.push({featureId:t.featureId,oldStart:t.oldLocation,newStart:t.newLocation})),"LocationEndChange"===t.typeName&&(r.changedIds.push(t.changedId),r.changes.push({featureId:t.featureId,oldEnd:t.oldLocation,newEnd:t.newLocation}));if(n.changedIds.length>0&&0===r.changedIds.length)return n;if(r.changedIds.length>0&&0===n.changedIds.length)return r;throw new Error("Unexpected list of changes")}(i,a);await e.submit(s),u&&await e.submit(u),t(),r.preventDefault()}(r)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to delete the selected feature?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}function Ws(e,t){if(e.apolloDragging)return;e.setSelectedFeature(t);const{session:n}=e,{apolloDataStore:r}=n,{featureTypeOntology:o}=r.ontologyManager;if(!o)throw new Error("featureTypeOntology is undefined");let i=!1;for(const[,e]of t.children??[])if(o.isTypeOf(e.type,"CDS")||o.isTypeOf(e.type,"exon")){i=!0;break}(o.isTypeOf(t.type,"transcript")||o.isTypeOf(t.type,"pseudogenic_transcript"))&&i?e.showFeatureDetailsWidget(t,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(t)}function Js(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")}function Ks(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")}function Ys(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"exon")}function Xs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"CDS")}function Zs(e,t){const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");const r=e.children;if(!r?.size)return!1;if(!Js(e,t))return!1;for(const[,e]of r)if(Ks(e,t)){const{children:n}=e;return!!n?.size&&[...n.values()].some((e=>Ys(e,t)))}return!1}function Qs(e,t){if(!e.parent)return{upstream:void 0,downstream:void 0};const n=e.parent;if(!n.children)throw new Error(`Error getting children of ${n._id}`);const{featureTypeOntology:r}=t.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");let o=[];for(const[,e]of n.children)r.isTypeOf(e.type,"exon")&&o.push(e);const i={upstream:void 0,downstream:void 0};o=o.sort(((e,t)=>e.min<t.min?-1:1));for(const t of o)if(t.min>e.max){i.downstream=t;break}o=o.sort(((e,t)=>e.min>t.min?-1:1));for(const t of o)if(t.max<e.min){i.upstream=t;break}if(-1===n.strand){const e=i.downstream;i.downstream=i.upstream,i.upstream=e}return i}function el(e,t,n){let r=Ta;return-1===e&&(r=Ra),t&&(r=r===Ra?Ta:Ra),n&&(r=r===Ra?Ta:Ra),r}function tl(e,t,n,r){const o=r.bpToPx({refName:t,coord:e.min,regionNumber:n}),i=r.bpToPx({refName:t,coord:e.max,regionNumber:n});if(void 0===o||void 0===i)return;const{offsetPx:a}=r;return[o.offsetPx-a,i.offsetPx-a]}function nl(e,t,n){const[r,o]=n;if(!(Math.abs(o-r)<8))return Math.abs(r-t)<4?{feature:e,edge:"min"}:Math.abs(o-t)<4?{feature:e,edge:"max"}:void 0}function rl(e,t){return Boolean(t&&e._id===t._id)}function ol(e){let t;t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id;const n=`(${(e.min+1).toLocaleString("en")}..${e.max.toLocaleString("en")})`;if(t&&t.length+n.length>65){const e=60-n.length;t=e>0?t.slice(0,e):"",t=`${t}[...]`}return`${t} ${n}`}function il(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,l=[],c=n?n.role:"admin",u=!(c&&["admin","user"].includes(c)),[d]=i,f=e.getAssemblyId(d.assemblyName),h=e.getAssemblyId(d.assemblyName);return l.push({label:ol(t),type:"subHeader"},{label:"Add child feature",disabled:u,onClick:()=>{s.queueDialog((e=>[Us,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:f,internetAccount:n}]))}},{label:"Copy features and annotations",disabled:u,onClick:()=>{s.queueDialog((e=>[Gs,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}},{label:"Delete feature",disabled:u,onClick:()=>{s.queueDialog((n=>[Vs,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:h,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Color feature",disabled:u,onClick:()=>{s.queueDialog((e=>[zs,{session:s,handleClose:()=>{e()},changeManager:r,sourceFeature:t,sourceAssemblyId:h}]))}}),o.isSessionModelWithWidgets(s)&&l.push({label:"Open feature details",onClick:()=>{const e=s.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:t,assembly:h,refName:d.refName});s.showWidget(e)}}),l}function al(e,t,n){const r=(e.max-e.min)*t,o=Math.max(e.min-r,1),i=Math.min(e.max+r,n);return{refName:e.refSeq,start:o,end:i}}function sl(e,t,n){const r=[{featureId:e._id,oldLocation:e[n],newLocation:t}],{parent:o}=e;return o&&("min"===n&&o[n]>t||"max"===n&&o[n]<t)&&r.push(...sl(o,t,n)),r}function ll(e,t,n,r,o){const i=e._id,a=[{featureId:i,oldLocation:e[n],newLocation:t}],{parent:s,children:l}=e;if(l)for(const[,e]of l)e._id!==o&&("min"===n&&e[n]<t||"max"===n&&e[n]>t)&&a.push(...ll(e,t,n,r));if(s&&r){const e=[];if(s.children)for(const[,t]of s.children)t._id!==i&&e.push(t);if(0===e.length)a.push(...ll(s,t,n,r,i));else{const o=s[n],l=Math[n](...e.map((e=>e[n])),t);l!==o&&a.push(...ll(s,l,n,r,i))}}return a}function cl(e,t,n,r=!1){const o=e[n];if(t===o)throw new Error(`New and existing locations are the same: "${t}"`);return"min"===n?t>o?ll(e,t,n,r):sl(e,t,n):t<o?ll(e,t,n,r):sl(e,t,n)}function ul(e){return"feature"in e}async function dl(e,t){let n;try{n=await e.text()}catch{n=""}return`${t?`${t} — `:""}${e.status} ${e.statusText}${n?` (${n})`:""}`}var fl;!function(e){e.GFF3="text/x-gff3",e.FASTA="text/x-fasta",e.BGZIP_FASTA="application/x-bgzip-fasta",e.FAI="text/x-fai",e.GZI="application/x-gzi",e.EXTERNAL="text/x-external"}(fl||(fl={}));const hl=ma()((e=>({accordion:{border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{borderBottom:0}},accordionSummary:{flexDirection:"row-reverse"},accordionDetails:{padding:e.spacing(2),borderTop:"1px solid rgba(0, 0, 0, .125)"},radioIcon:{color:e.palette.tertiary.contrastText},dialog:{minWidth:550,maxWidth:800}})));function pl(e,t,n,r,o,i,a,s,l){return!(!e||!(t&&r||n===fl.GFF3&&r||r&&o&&i||a&&s&&l))}function gl({changeManager:e,handleClose:t,session:r}){const{classes:o}=hl(),{internetAccounts:a}=l.getRoot(r),{notify:c}=r,d=a.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(""),[p,g]=u.useState(""),[m,y]=u.useState(!1),[_,v]=u.useState(fl.BGZIP_FASTA),[b,x]=u.useState(!0),[w,S]=u.useState(!1),[C,A]=u.useState(!1),[k,N]=u.useState(!0),[T,R]=u.useState(null),[E,I]=u.useState(null),[j,D]=u.useState(null),[O,F]=u.useState(""),[M,L]=u.useState(""),[P,B]=u.useState(""),[q,U]=u.useState(!1),[$,z]=u.useState(!1),[H,G]=u.useState(!1);async function V(e,t){const{jobsManager:n}=r,o=new AbortController,[{baseURL:i,getFetcher:a}]=d,s=new URL("files",i);s.searchParams.set("type",t);const l=s.href,c=new FormData;let u=e.name;const h=t===fl.BGZIP_FASTA||t===fl.FASTA&&(!w||$)||t===fl.GFF3&&H;h&&!e.name.toLocaleLowerCase().endsWith(".gz")?u=`${u}.gz`:!h&&e.name.toLocaleLowerCase().endsWith(".gz")&&(u=`${u}.txt`),c.append("file",e,u),c.append("type",t);const p=a({locationType:"UriLocation",uri:l}),m={name:`UploadAssemblyFile for ${f}`,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{o.abort(new DOMException(`Canceling adding of assembly "${f}"`,"AbortError")),n.abortJob(m.name)}};n.runJob(m),n.update(m.name,`Uploading ${e.name}, this may take awhile`);const{signal:y}=o,_=await p(l,{method:"POST",body:c,signal:y});if(!_.ok){const e=await dl(_,"Error when inserting new assembly (while uploading file)");return n.abortJob(m.name,e),g(e),""}const v=(await _.json())._id;return n.done(m),v}let W=!1;try{const e=new URL(O);"http:"!==e.protocol&&"https:"!==e.protocol||(W=!0)}catch{}let J=!1;try{const e=new URL(M);"http:"!==e.protocol&&"https:"!==e.protocol||(J=!0)}catch{}let K=!1;try{const e=new URL(P);"http:"!==e.protocol&&"https:"!==e.protocol||(K=!0)}catch{}const[Y,X]=u.useState("panelFastaInput"),Z=e=>(t,n)=>{n&&X(e)};return i.jsxs(Bs,{open:!0,handleClose:t,"data-testid":"add-assembly-dialog",title:"Add new assembly",maxWidth:!1,children:[i.jsxs("form",{onSubmit:async function(n){let r;if(n.preventDefault(),g(""),A(!0),U(!0),c(`Assembly "${f}" is being added`,"info"),t(),n.preventDefault(),_===fl.EXTERNAL)r=new yt({typeName:"AddAssemblyFromExternalChange",assembly:(new at).toHexString(),assemblyName:f,externalLocation:{fa:O,fai:M,gzi:P}});else{if(!T)throw new Error("Missing fasta file");if(_===fl.GFF3&&b){const e=await V(T,fl.GFF3);r=new mt({typeName:"AddAssemblyAndFeaturesFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e},parseOptions:{strict:k}})}else if(_===fl.GFF3){const e=await V(T,fl.GFF3);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else if(w){const e=await V(T,fl.FASTA);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e}})}else{if(!E||!j)throw new Error("Missing fasta index files");const e=await V(T,fl.BGZIP_FASTA),t=await V(E,fl.FAI),n=await V(j,fl.GZI);r=new _t({typeName:"AddAssemblyFromFileChange",assembly:(new at).toHexString(),assemblyName:f,fileIds:{fa:e,fai:t,gzi:n}})}}const[{internetAccountId:o}]=d;await e.submit(r,{internetAccountId:o,updateJobsManager:!0}),A(!1),U(!1)},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{className:o.dialog,children:[q?i.jsx(s.LinearProgress,{}):null,i.jsx(s.TextField,{margin:"dense",id:"name",label:"Assembly name",type:"TextField",fullWidth:!0,variant:"outlined",onChange:e=>{A(!1),h(e.target.value),function(e){const{assemblies:t}=r;t.find((t=>n.readConfObject(t,"displayName")===e))?(y(!1),g(`Assembly ${e} already exists.`)):(y(!0),g(""))}(e.target.value)},disabled:C&&!p}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelFastaInput"===Y,onChange:Z("panelFastaInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelFastaInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelFastaInputd-content",id:"panelFastaInputd-header",children:i.jsx(s.Typography,{component:"span",children:"FASTA input"})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.FormGroup,{children:[i.jsx(s.FormControlLabel,{"data-testid":"files-on-url-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{v(_===fl.EXTERNAL?fl.BGZIP_FASTA:fl.EXTERNAL),_===fl.EXTERNAL&&S(!1)},checked:_===fl.EXTERNAL,disabled:w&&_!==fl.GFF3}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Use external URLs",i.jsx(s.Tooltip,{title:"Use external URLs to provide FASTA and index files. Does not copy the files to the Apollo collaboration server, so ensure the URLs are stable.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"sequence-is-editable-checkbox",control:i.jsx(s.Checkbox,{onChange:()=>{S(!w)}}),checked:w,disabled:_===fl.EXTERNAL,label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Store sequence in database",i.jsx(s.Tooltip,{title:"Enables users to edit the genomic sequence, but comes with performance impacts. Use with care.",placement:"top-start",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{"data-testid":"fasta-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:!w||$,onChange:()=>{z(!w||!$)},disabled:!w}),label:"FASTA is gzip compressed"}),i.jsx(s.Table,_===fl.BGZIP_FASTA||_===fl.GFF3?{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:'Unless "Store sequence in database" enabled, FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent). Compression is optional for sequences stored in the database.',children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fasta-input-file",type:"file",onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),t.name.endsWith(".gz")&&z(!0))},disabled:C&&!p})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"fai-input-file",type:"file",onChange:e=>{I(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx("input",{"data-testid":"gzi-input-file",type:"file",onChange:e=>{D(e.target.files?.item(0)??null)},disabled:C&&!p||w})})]})]})}:{size:"small",sx:{mt:2},children:i.jsxs(s.TableBody,{children:[i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:[i.jsx("span",{children:"FASTA"}),i.jsx(s.Tooltip,{title:"Remote FASTA input must be compressed with bgzip and indexed with samtools faidx (or equivalent)",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fasta-input-url",variant:"outlined",value:O,error:!W,onChange:e=>{const{value:t}=e.target;F(t),L(t?`${t}.fai`:""),B(t?`${t}.gzi`:"")},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA index (.fai)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"fai-input-url",variant:"outlined",value:M,error:!J,onChange:e=>{L(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]}),i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:"FASTA binary index (.gzi)"}),i.jsx(s.TableCell,{style:{borderBottomWidth:0},children:i.jsx(s.TextField,{"data-testid":"gzi-input-url",variant:"outlined",value:P,error:!K,onChange:e=>{B(e.target.value)},disabled:C&&!p,slotProps:{input:{startAdornment:i.jsx(s.InputAdornment,{position:"start",children:i.jsx(_a,{})})}}})})]})]})})]})})]}),i.jsxs(s.Accordion,{disableGutters:!0,elevation:0,square:!0,className:o.accordion,expanded:"panelGffInput"===Y,onChange:Z("panelGffInput"),children:[i.jsx(s.AccordionSummary,{className:o.accordionSummary,expandIcon:"panelGffInput"===Y?i.jsx(va,{className:o.radioIcon,sx:{fontSize:"1.2rem",ml:5}}):i.jsx(ba,{className:o.radioIcon,sx:{fontSize:"1.2rem",mr:5}}),"aria-controls":"panelGffInputd-content",children:i.jsxs(s.Typography,{component:"span",children:["GFF3 input",i.jsx(s.Tooltip,{title:"GFF3 must includes FASTA sequences. File can be gzip compressed.",children:i.jsx(ya,{className:o.radioIcon,sx:{fontSize:18}})})]})}),i.jsx(s.AccordionDetails,{className:o.accordionDetails,children:i.jsxs(s.Box,{style:{marginTop:20},children:[i.jsx("input",{"data-testid":"gff3-input-file",type:"file",disabled:C&&!p,onChange:e=>{const t=e.target.files?.item(0);t&&(R(t),v(fl.GFF3),t.name.endsWith(".gz")&&G(!0))}}),i.jsxs(s.FormGroup,{style:{display:"grid"},children:[i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:b,onChange:()=>{x(!b)},disabled:C&&!p}),label:"Load features from GFF3 file"}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:!b||C&&!p,control:i.jsx(s.Checkbox,{checked:k,onChange:e=>{N(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),i.jsx(s.FormControlLabel,{"data-testid":"gff3-is-gzip-checkbox",control:i.jsx(s.Checkbox,{checked:H,onChange:()=>{G(!H)},disabled:C&&!p}),label:"GFF3 is gzip compressed"})]})]})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!pl(m,w,_,T,E,j,W,J,K)||C,variant:"contained",type:"submit","data-testid":"submit-button",children:C?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),p?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:p})}):null]})}const ml=[{field:"name",headerName:"Assembly Name",width:150,editable:!1},{field:"aliases",headerName:"Aliases",width:300,editable:!0}];function yl({changeManager:e,handleClose:t,session:n}){const{apolloDataStore:r}=n,{collaborationServerDriver:o}=r,a=o.getAssemblies().map((e=>({id:e.name,name:e.displayName,aliases:e.aliases.join(", ")}))),[l,c]=u.useState("");return i.jsxs(Bs,{open:!0,title:"Add assembly aliases",handleClose:t,maxWidth:"sm","data-testid":"add-assembly-alias",fullWidth:!0,children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.Box,{sx:{height:400,width:"100%"},children:i.jsx(m.DataGrid,{rows:a,columns:ml,initialState:{pagination:{paginationModel:{pageSize:5}}},pageSizeOptions:[5],processRowUpdate:(n,r)=>{const o=new gt({typeName:"AddAssemblyAliasesChange",assembly:n.id,aliases:n.aliases.split(",")});return e.submit(o).catch((()=>{c("Error submitting change")})),t(),n},disableRowSelectionOnClick:!0})})}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}class _l{clientStore;constructor(e){this.clientStore=e}}async function vl(e,t){return qa(`Apollo-${e}`,1,{upgrade(e){const n="changes";e.objectStoreNames.contains(n)||e.createObjectStore(n,{autoIncrement:!0});for(const n of t){const t=`features-${n}`;if(!e.objectStoreNames.contains(t)){const n=e.createObjectStore(t);n.createIndex("min","min",{unique:!1}),n.createIndex("max","max",{unique:!1})}const r=`checkresults-${n}`;if(!e.objectStoreNames.contains(r)){const t=e.createObjectStore(r,{keyPath:"_id"});t.createIndex("min","start",{unique:!1}),t.createIndex("max","end",{unique:!1}),t.createIndex("featureId","featureId",{unique:!1})}}}})}class bl extends _l{async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:o}=e,i=(await this.getRegions(t)).map((e=>e.refName)),a=`features-${r}`,s=`checkresults-${r}`,l=[],c=[],u=(await vl(t,i)).transaction([a,s]);for await(const e of u.objectStore(a).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.max>o&&l.push(e.value);for await(const e of u.objectStore(s).index("min").iterate(IDBKeyRange.upperBound(n,!0)))e.value.end>o&&c.push(e.value);return[l,c]}async getSequence(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e.assemblyName);if(!r)throw new Error(`Assembly not found: "${e.assemblyName}"`);const{configuration:i}=r,{adapter:a}=i.sequence,{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.type);if(!l)throw new Error(`No adapter found for "${a.type}"`);const c=new(await l.getAdapterClass())(a,void 0,s),u=await c.getSequence(e);if(!u)throw new Error(`Sequence not found: ${JSON.stringify(e)}`);return{seq:u,refSeq:e.refName}}async getRegions(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{regions:i}=r;if(!i)throw new Error(`Assembly not found: "${e}"`);return i}getAssemblies(e){return[]}async getRefNameAliases(e){const t=o.getSession(this.clientStore),{assemblyManager:n}=t,r=await n.waitForAssembly(e);if(!r)throw new Error(`Assembly not found: "${e}"`);const{configuration:i}=r,{refNameAliases:a}=i;if(!a)return[];const{pluginManager:s}=o.getEnv(this.clientStore),l=s.getAdapterType(a.adapter.type);if(!l)throw new Error(`No adapter found for "${a.adapter.type}"`);return new(await l.getAdapterClass())(a.adapter,void 0,s).getRefNameAliases({})}async submitChange(e,t){if(!st(e))return new Wt;const{assembly:n,changedIds:r}=e,o=(await this.getRegions(n)).map((e=>e.refName)),i=await vl(n,o),a=new Set,s=[],c=new Set;if(function(e){return"DeleteFeatureChange"===e.typeName}(e))for(const t of e.changes)if(t.parentFeatureId){const e=this.clientStore.getFeature(t.parentFeatureId);e&&(a.add(e.topLevelFeature),c.add(e.topLevelFeature.refSeq))}else{const{refSeq:e,_id:n}=t.deletedFeature;s.push({refSeq:e,featureId:n}),c.add(e)}else for(const e of r){const t=this.clientStore.getFeature(e);t&&(a.add(t.topLevelFeature),c.add(t.refSeq))}const u=[...c].flatMap((e=>[`features-${e}`,`checkresults-${e}`]));u.push("changes");const d=i.transaction(u,"readwrite");for(const{refSeq:e,featureId:t}of s)d.objectStore(`features-${e}`).delete(t);for(const e of a){const t=l.getSnapshot(e);d.objectStore(`features-${e.refSeq}`).put(t,e._id)}for(const{featureId:e,refSeq:t}of s){const n=d.objectStore(`checkresults-${t}`);for await(const t of n.index("featureId").iterate(e))this.clientStore.deleteCheckResult(t.value._id),t.delete()}for(const e of a){const t=d.objectStore(`checkresults-${e.refSeq}`);for await(const n of t.index("featureId").iterate(e._id))this.clientStore.deleteCheckResult(n.value._id),n.delete()}if(d.objectStore("changes").put({...e.toJSON(),createdAt:new Date}),await d.done,a.size>0){const e=[...ne.getChecks().values()],t=[];for(const r of a){const o=l.getSnapshot(r),i=async(e,t)=>(await this.getSequence({assemblyName:n,refName:r.refSeq,start:e,end:t})).seq;for(const n of e){const e=await n.checkFeature(o,i);for(const n of e)t.push({refSeq:r.refSeq,result:n,topLevelFeatureId:r._id})}}if(t.length>0){const e=o.map((e=>`checkresults-${e}`)),n=i.transaction(e,"readwrite");for(const{refSeq:e,result:r,topLevelFeatureId:o}of t)n.objectStore(`checkresults-${e}`).put({...r,featureId:o});await n.done;for(const{result:e}of t)this.clientStore.addCheckResult(e)}}return new Wt}async searchFeatures(e,t){return[]}async getCheckResults(e){const t=(await this.getRegions(e)).map((e=>e.refName)),n=await vl(e,t),r=[],o=t.map((e=>`checkresults-${e}`)),i=n.transaction(o);for(const e of o)for await(const t of i.objectStore(e).iterate())r.push(t.value);return r}async getChanges(e,t={}){const n=(await this.getRegions(e)).map((e=>e.refName)),r=await vl(e,n);let o=[];for await(const e of r.transaction("changes").store.iterate())o.push({sequence:e.key,...e.value});const{filters:i}=t;if(i?.user){const e=new RegExp(i.user,"i");o=o.filter((t=>void 0!==t.user&&e.test(t.user)))}if(i?.typeName&&(o=o.filter((e=>e.typeName===i.typeName))),i?.startTime){const e=new Date(i.startTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()>=e))}if(i?.endTime){const e=new Date(i.endTime).getTime();o=o.filter((t=>new Date(t.createdAt).getTime()<=e))}const a=o.length,s=t.sortField??"sequence",l="asc"===(t.sortOrder??"desc")?1:-1;if(o.sort(((e,t)=>{const n=e[s],r=t[s];return n===r?0:void 0===n?1:void 0===r?-1:n<r?-l:l})),void 0!==t.page&&void 0!==t.pageSize){const e=t.page*t.pageSize;o=o.slice(e,e+t.pageSize)}return{changes:o,totalCount:a}}}const xl={async AddFeatureChange(e,t){const{assembly:n,changes:r}=t;for(const t of r){const{addedFeature:r,parentFeatureId:o}=t;if(o){let t=e.getFeature(o);if(!t&&(await e.loadFeatures([{assemblyName:n,refName:r.refSeq,start:r.min,end:r.max}]),t=e.getFeature(o),!t))throw new Error(`Could not find parent feature "${o}"`);t.attributes.get("_id")||t.setAttribute("_id",[t._id]),t.addChild(r)}else e.addFeature(n,r)}},async DeleteFeatureChange(e,t){for(const n of t.changes){const{deletedFeature:t,parentFeatureId:r}=n;if(r){const n=e.getFeature(r);if(!n)throw new Error(`Could not find parent feature "${r}"`);n.deleteChild(t._id)}else e.getFeature(t._id)&&e.deleteFeature(t._id)}},async FeatureAttributeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setAttributes(new Map(Object.entries(t.changes[n].newAttributes)))}},async LocationEndChange(e,t){for(const n of t.changes){const{featureId:t,newEnd:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMax(r)}},async LocationStartChange(e,t){for(const n of t.changes){const{featureId:t,newStart:r}=n,o=e.getFeature(t);if(!o)throw new Error(`Could not find feature with identifier "${t}"`);o.setMin(r)}},async MergeExonsChange(e,t){for(const n of t.changes){const{firstExon:t,secondExon:r}=n,o=e.getFeature(t._id);if(!o)throw new Error(`Could not find feature with identifier "${t._id}"`);o.setMin(Math.min(t.min,r.min)),o.setMax(Math.max(t.max,r.max));const i=o.attributes.get("merged_with")?.slice()??[],a=Lt(Mt(r.attributes));i.includes(a)||i.push(a),o.setAttribute("merged_with",i),o.parent?.deleteChild(r._id)}},async SplitExonChange(e,t){for(const[n]of t.changedIds.entries()){const{exonToBeSplit:r,parentFeatureId:o,upstreamCut:i,downstreamCut:a,leftExonId:s,rightExonId:l}=t.changes[n];if(!o)throw new Error("TODO: Split exon without parent");const[c,u]=t.makeSplitExons(r,i,a,s,l),d=e.getFeature(o);if(!d)throw new Error(`Could not find parent feature "${o}"`);d.addChild(c),d.addChild(u),e.getFeature(r._id)&&e.deleteFeature(r._id)}},async MergeTranscriptsChange(e,t){for(const[n,r]of t.changedIds.entries()){const{firstTranscript:o,secondTranscript:i}=t.changes[n],a=e.getFeature(o._id);if(!a)throw new Error(`Could not find feature with identifier "${r}"`);t.mergeTranscriptsOnClient(a,i),a.parent?.deleteChild(i._id)}},async UndoMergeExonsChange(e,t){for(const n of t.changes){const{exonsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async UndoSplitExonChange(e,t){for(const n of t.changes){const{exonToRestore:t,parentFeatureId:r,idsToDelete:o}=n;if(!r)throw new Error("Parent ID is missing");const i=e.getFeature(r);if(!i)throw new Error(`Could not find parent feature "${r}"`);i.attributes.get("_id")||i.setAttribute("_id",[i._id]),i.addChild(t),o.map((e=>{i.deleteChild(e)}))}},async UndoMergeTranscriptsChange(e,t){for(const n of t.changes){const{transcriptsToRestore:t,parentFeatureId:r}=n;if(!r)throw new Error("Parent ID is missing");const o=e.getFeature(r);if(!o)throw new Error(`Could not find parent feature "${r}"`);o.attributes.get("_id")||o.setAttribute("_id",[o._id]);for(const e of t)o.addChild(e)}},async StrandChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setStrand(t.changes[n].newStrand)}},async TypeChange(e,t){for(const[n,r]of t.changedIds.entries()){const o=e.getFeature(r);if(!o)throw new Error(`Could not find feature with identifier "${r}"`);o.setType(t.changes[n].newType)}}};class wl{dataStore;constructor(e){this.dataStore=e}recentChanges=[];undoneChanges=[];async submit(e,t={}){const{addToRecents:n=!0,submitToBackend:r=!0,updateJobsManager:i=!1}=t,a=o.getSession(this.dataStore),s=new AbortController,{jobsManager:l,isLocked:c,changeInProgress:u,setChangeInProgress:d}=o.getSession(this.dataStore);if(c)return a.notify("Cannot submit changes in locked mode"),void d(!1);if(u)return void a.notify("Could not submit change, there is another change still in progress");d(!0);const f={name:e.typeName,statusMessage:"Pre-validating",progressPct:0,cancelCallback:()=>{s.abort(new DOMException(`Cancelling change "${e.typeName}"`,"AbortError"))}};i&&l.runJob(f);const h=await Kt.frontendPreValidate(e);if(!h.ok){const e=`Pre-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,e),a.notify(e,"error"),void d(!1)}const p=e.typeName,g=function(e){return e in xl}(p)?xl[p]:void 0;if(g)try{await g(this.dataStore,e)}catch(e){return i&&l.abortJob(f.name,String(e)),console.error(e),a.notify(`Error encountered in client: ${String(e)}. Data may be out of sync, please refresh the page`,"error"),void d(!1)}if((await Kt.frontendPostValidate(e)).ok||await this.undo(e),r){i&&l.update(f.name,"Submitting to driver");const{collaborationServerDriver:r,getBackendDriver:o}=this.dataStore,s=te(e)?o(e.assembly)??r:r;let c;try{c=await s.submitChange(e,t)}catch(t){return i&&l.abortJob(f.name,String(t)),console.error(t),a.notify(String(t),"error"),d(!1),void await this.undo(e,!1)}if(!c.ok){const t=`Post-validation failed: "${h.resultsMessages}"`;return i&&l.abortJob(f.name,t),a.notify(t,"error"),d(!1),void await this.undo(e,!1)}e.notification&&a.notify(e.notification,"success"),n&&(this.recentChanges.push(e),this.undoneChanges=[])}i&&l.done(f),d(!1)}async undo(e,t=!0){const n=e.getInverse();return this.submit(n,{submitToBackend:t,addToRecents:!1})}async redo(e,t=!0){return this.submit(e,{submitToBackend:t,addToRecents:!1})}async undoLastChange(){const e=o.getSession(this.dataStore),t=this.recentChanges.pop();if(t)return this.undoneChanges.push(t),this.undo(t);e.notify("No changes to undo!","info")}async redoLastChange(){const e=o.getSession(this.dataStore),t=this.undoneChanges.pop();if(t)return this.recentChanges.push(t),this.redo(t);e.notify("No changes to redo!","info")}}class Sl extends _l{inFlight=new Map;refSeqMaps=new Map;async fetch(e,t,n){return e.getFetcher({locationType:"UriLocation",uri:t.toString()})(t,n)}async searchFeatures(e,t){const n=this.clientStore.getInternetAccount(t[0]),{baseURL:r}=n,o=new URL("features/searchFeatures",r),i=new URLSearchParams({assemblies:t.join(","),term:e});o.search=i.toString();const a=o.toString(),s=await this.fetch(n,a);if(!s.ok){const e=await dl(s,"searchFeatures failed");throw new Error(e)}return s.json()}async getFeatures(e){const{assemblyName:t,end:n,refName:r,start:i}=e,{assemblyManager:a}=o.getSession(this.clientStore);if(!a.get(t))throw new Error(`Could not find assembly with name "${t}"`);const s=(await this.getRefSeqMapping(t)).get(r);if(!s)throw new Error(`Could not find refSeq "${r}"`);const l=s.id,c=this.clientStore.getInternetAccount(t),{baseURL:u}=c,d=new URL("features/getFeatures",u),f=new URLSearchParams({refSeq:l,start:String(i),end:String(n)});d.search=f.toString();const h=d.toString(),p=await this.fetch(c,h);if(!p.ok){const e=await dl(p,"getFeatures failed");throw new Error(e)}return this.checkSocket(t,r,c),p.json()}checkSocket(e,t,n){const{socket:r}=n,o=`${e}-${t}`;r.hasListeners(o)||r.on(o,(async e=>{const t=n.retrieveToken();if(!t)return;const r=sn(t),o=new wl(this.clientStore);if(n.setLastChangeSequenceNumber(Number(e.changeSequence)),e.userSessionId===r)return;const i=ee.fromJSON(e.changeInfo);st(i)&&this.haveDataForChange(i)&&await o.submit(i,{submitToBackend:!1})}))}haveDataForChange(e){const{assembly:t,changedIds:n}=e;if(!this.clientStore.assemblies.get(t))return!1;for(const e of n)if(this.clientStore.getFeature(e))return!0;return!1}async getSequence(e){const t=`${e.refName}:${e.start}-${e.end}`,n=this.inFlight.get(t),{assemblyName:r,end:i,refName:a,start:s}=e,{assemblyManager:l}=o.getSession(this.clientStore);if(!l.get(r))throw new Error(`Could not find assembly with name "${r}"`);const c=(await this.getRefSeqMapping(r)).get(a);if(!c)throw new Error(`Could not find refSeq "${a}"`);const u=c.id;if(n)return{seq:await n,refSeq:u};let d=this.clientStore.assemblies.get(r);d||(d=this.clientStore.addAssembly(r));let f=d.refSeqs.get(u);f||(f=d.addRefSeq(u,a));const h=f.getSequence(s,i);if(h.length===i-s)return{seq:h,refSeq:u};const p=this.clientStore.getInternetAccount(r),{baseURL:g}=p,m=new URL("sequence",g),y=new URLSearchParams({refSeq:u,start:String(s),end:String(i)});m.search=y.toString();const _=m.toString(),v=this.getSeqFromServer(p,_,f,s,i);this.inFlight.set(t,v);const b=await v;return this.checkSocket(r,a,p),this.inFlight.delete(t),{seq:b,refSeq:u}}async getSeqFromServer(e,t,n,r,o){const i=await this.fetch(e,t);if(!i.ok){let e;try{e=await i.text()}catch{e=""}throw new Error(`getSequence failed: ${i.status} (${i.statusText})${e?` (${e})`:""}`)}const a=await i.text();return n.addSequence({sequence:a,start:r,stop:o}),a}async getRefSeqMapping(e){const t=this.refSeqMaps.get(e);if(t)return t;const{assemblyManager:n}=o.getSession(this.clientStore);if(!n.get(e))throw new Error(`Could not find assembly with name "${e}"`);const r=this.clientStore.getInternetAccount(e),{baseURL:i}=r,a=new URL("refSeqs",i),s=new URLSearchParams({assembly:e});a.search=s.toString();const l=a.toString(),c=await this.fetch(r,l);if(!c.ok){let e;try{e=await c.text()}catch{e=""}throw new Error(`getRefNameAliases failed: ${c.status} (${c.statusText})${e?` (${e})`:""}`)}const u=await c.json(),d=new Map(u.map((e=>[e.name,{refName:e.name,id:e._id,aliases:e.aliases}])));return this.refSeqMaps.set(e,d),d}async getRefNameAliases(e){return[...(await this.getRefSeqMapping(e)).values()].map((e=>({refName:e.refName,aliases:[...new Set([e.id,...e.aliases])],uniqueId:`alias-${e.id}`})))}async getRefSeqId(e,t){const n=await this.getRefSeqMapping(e);if(!n)return;const r=n.get(t);return r?.id}async getRegions(e){const{assemblyManager:t}=o.getSession(this.clientStore);if(!t.get(e))throw new Error(`Could not find assembly with name "${e}"`);const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,i=new URL("refSeqs",r),a=new URLSearchParams({assembly:e});i.search=a.toString();const s=i.toString(),l=await this.fetch(n,s);if(!l.ok){let e;try{e=await l.text()}catch{e=""}throw new Error(`getRegions failed: ${l.status} (${l.statusText})${e?` (${e})`:""}`)}return(await l.json()).map((e=>({refName:e.name,start:0,end:e.length})))}getAssemblies(e){const{assemblyManager:t}=o.getSession(this.clientStore);return t.assemblies.filter((t=>{const r=n.getConf(t,["sequence","metadata"]);return!(!(r&&r.apollo&&r.internetAccountConfigId)||e&&r.internetAccountConfigId!==e)}))}async getChanges(e,t={}){const n=this.clientStore.getInternetAccount(e),{baseURL:r}=n,o=new URL("changes",r),i={assembly:e};void 0!==t.page&&(i.page=String(t.page)),void 0!==t.pageSize&&(i.pageSize=String(t.pageSize)),t.sortField&&(i.sortField=t.sortField),t.sortOrder&&(i.sortOrder=t.sortOrder),t.filters?.user&&(i.user=t.filters.user),t.filters?.typeName&&(i.typeName=t.filters.typeName),t.filters?.startTime&&(i.startTime=t.filters.startTime),t.filters?.endTime&&(i.endTime=t.filters.endTime),o.search=new URLSearchParams(i).toString();const a=await this.fetch(n,o.toString());if(!a.ok){const e=await dl(a,"getChanges failed");throw new Error(e)}return a.json()}async getCheckResults(e){const t=this.clientStore.getInternetAccount(e),{baseURL:n}=t,r=new URL("checks",n);r.search=new URLSearchParams({assembly:e}).toString();const o=await this.fetch(t,r.toString());if(!o.ok){const e=await dl(o,"getCheckResults failed");throw new Error(e)}return o.json()}async submitChange(e,t={}){const{internetAccountId:n}=t,r=this.clientStore.getInternetAccount("assembly"in e?e.assembly:void 0,n),{baseURL:o}=r,i=new URL("changes",o).href,a=await this.fetch(r,i,{method:"POST",body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"}});if(!a.ok){const e=await dl(a,"submitChange failed");throw new Error(e)}const s=new Wt;return a.ok||(s.ok=!1),s}}var Cl;function Al(e,t,n,r){const o={_id:(new at).toHexString(),refSeq:e,type:"CDS",min:n,max:r,strand:t},i={_id:(new at).toHexString(),refSeq:e,type:"exon",min:n,max:r,strand:t},a={};return a[o._id]=o,a[i._id]=i,{_id:(new at).toHexString(),refSeq:e,type:"mRNA",min:n,max:r,strand:t,children:a}}function kl({changeManager:e,handleClose:t,region:n,session:r}){const[o,a]=u.useState(String(n.end)),[l,c]=u.useState(String(n.start+1)),[d,f]=u.useState(Cl.GENE_AND_SUBFEATURES),[h,p]=u.useState(""),[g,m]=u.useState(),[y,_]=u.useState(""),v=Number(o)<=Number(l);let b=Boolean(v)||!(l&&o&&d);return(d===Cl.CUSTOM&&!h||!g&&d===Cl.GENE_AND_SUBFEATURES||!g&&d===Cl.TRANSCRIPT_AND_SUBFEATURES)&&(b=!0),i.jsxs(Bs,{open:!0,title:"Add new feature",handleClose:t,maxWidth:!1,"data-testid":"add-feature-dialog",children:[i.jsxs("form",{onSubmit:async function(i){i.preventDefault(),_("");const a=r.apolloDataStore.getBackendDriver(n.assemblyName);if(!a)return void _("No backend driver found");let s=n.refName;if(a instanceof Sl){const e=await a.getRefSeqId(n.assemblyName,n.refName);if(!e)return void _(`Could not find refSeq for "${n.refName}"`);s=e}if(d===Cl.GENE_AND_SUBFEATURES){const i=Al(s,g,Number(l)-1,Number(o)),a={};a[i._id]=i;const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:"gene",strand:g,children:a}});return e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),void t()}if(d===Cl.TRANSCRIPT_AND_SUBFEATURES){const i=Al(s,g,Number(l)-1,Number(o)),a=new ht({changedIds:[i._id],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:i});return e.submit(a).then((()=>{r.apolloSetSelectedFeature(i._id)})),void t()}if(!h)return void _("No type selected");const c=(new at).toHexString(),u=new ht({changedIds:[c],typeName:"AddFeatureChange",assembly:n.assemblyName,addedFeature:{_id:c,refSeq:s,min:Number(l)-1,max:Number(o),type:h,strand:g}});e.submit(u).then((()=>{r.apolloSetSelectedFeature(c)})),t()},"data-testid":"submit-form",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.TextField,{margin:"dense",id:"start",label:"Start",type:"number",fullWidth:!0,variant:"outlined",value:Number(l),onChange:e=>{c(e.target.value)}}),i.jsx(s.TextField,{margin:"dense",id:"end",label:"End",type:"number",fullWidth:!0,variant:"outlined",value:o,onChange:e=>{a(e.target.value)},error:v,helperText:v?'"End" must be greater than "Start"':null}),i.jsxs(s.FormControl,{children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Strand"}),i.jsxs(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Strand",value:g?.toString(),onChange:function(e){switch(_(""),Number(e.target.value)){case 1:m(1);break;case-1:m(-1);break;default:m(void 0)}},children:[i.jsx(s.MenuItem,{value:void 0}),i.jsx(s.MenuItem,{value:1,children:"+"}),i.jsx(s.MenuItem,{value:-1,children:"-"})]})]}),i.jsx(s.FormControl,{style:{marginTop:20},children:i.jsxs(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:Cl.GENE_AND_SUBFEATURES,name:"radio-buttons-group",value:d,onChange:e=>{_("");const{value:t}=e.target;Object.keys(Cl).includes(t)&&f(Cl[t])},children:[i.jsx(s.FormControlLabel,{value:Cl.GENE_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add gene and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a gene with a single mRNA, exon, and CDS",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Cl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:i.jsxs(s.Box,{display:"flex",alignItems:"center",children:["Add transcript and sub-features",i.jsx(s.Tooltip,{title:"This is a shortcut to create a single mRNA with exon and CDS, but without a parent gene",children:i.jsx(s.IconButton,{size:"small",children:i.jsx(ya,{sx:{fontSize:18}})})})]})}),i.jsx(s.FormControlLabel,{value:Cl.CUSTOM,checked:d!==Cl.GENE_AND_SUBFEATURES&&d!==Cl.TRANSCRIPT_AND_SUBFEATURES,control:i.jsx(s.Radio,{}),label:"Add feature with a sequence ontology type"})]})}),d===Cl.CUSTOM?i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:170},value:h,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{var n;t&&(n=t,_(""),p(n))}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:b,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),y?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:y})}):null]})}function Nl({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),[o,a]=u.useState(""),[c,d]=u.useState(!1),[f,h]=u.useState(!1),p=r.filter((e=>"ApolloInternetAccount"===e.type));if(0===p.length)throw new Error("No Apollo internet account found");const[g,m]=u.useState(p[0]),{collaborationServerDriver:y}=n.apolloDataStore,_=y.getAssemblies(),[v,b]=u.useState(_.at(0));return i.jsxs(Bs,{open:!0,title:"Delete Assembly",handleClose:t,maxWidth:!1,"data-testid":"delete-assembly",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),h(!0),a(""),!v)return void a("Must select assembly!");const r=new xt({typeName:"DeleteAssemblyChange",assembly:v.name});await e.submit(r,{internetAccountId:g.internetAccountId}),t(),n.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[p.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:g.internetAccountId,onChange:function(e){h(!1);const t=p.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);m(t)},disabled:f&&!o,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:v?.name??"",onChange:function(e){const t=_.find((t=>t.name===e.target.value));b(t)},disabled:0===_.length,children:_.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx(s.DialogContentText,{children:i.jsx("strong",{style:{color:"red"},children:"NOTE: All assembly data will be deleted and this operation cannot be undone!"})}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:c,onChange:()=>{d(!c)}}),label:"I understand that all assembly data will be deleted"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!v||!c,variant:"contained",type:"submit",children:"Delete"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}!function(e){e.GENE_AND_SUBFEATURES="GENE_AND_SUBFEATURES",e.TRANSCRIPT_AND_SUBFEATURES="TRANSCRIPT_AND_SUBFEATURES",e.CUSTOM="CUSTOM"}(Cl||(Cl={}));var Tl,Rl,El,Il,jl={},Dl={},Ol={},Fl={};function Ml(){if(Tl)return Fl;function e(e){return decodeURIComponent(e)}function t(e,t){return String(t).replaceAll(e,(function(e){return encodeURIComponent(e).toUpperCase()}))}function n(e){return t(/[\n;\r\t=%&,\u0000-\u001f\u007f]/g,e)}function r(e){return t(/[\n\r\t%\u0000-\u001f\u007f]/g,e)}function o(t){if(null==t||!t.length||"."===t)return{};var n={};return t.replace(/\r\n|[\r\n]$/,"").split(";").forEach((function(t){var r,o,i=t.split("=",2);if(null!==(r=i[1])&&void 0!==r&&r.length){i[0]=i[0].trim();var a=n[i[0].trim()];a||(n[i[0]]=a=[]),(o=a).push.apply(o,W(i[1].split(",").map((function(e){return e.trim()})).map(e)))}})),n}function i(e){var t=[];return Object.entries(e).forEach((function(e){var r=G(e,2),o=r[0],i=r[1].map(n).join(",");t.push("".concat(n(o),"=").concat(i))})),t.length?t.join(";"):"."}function a(e,t){var n=null==e.attributes?".":i(e.attributes),o=[null===e.seq_id?".":r(e.seq_id),null===e.source?".":r(e.source),null===e.type?".":r(e.type),null===e.start?".":r(e.start),null===e.end?".":r(e.end),null===e.score?".":r(e.score),null===e.strand?".":r(e.strand),null===e.phase?".":r(e.phase),n],a="".concat(o.join("\t"),"\n");return t[a]?"":(t[a]=!0,a)}function s(e,t){if(Array.isArray(e))return e.map((function(e){return s(e,t)})).join("");var n,r=[a(e,t)];return void 0!==(n=e).child_features&&void 0!==n.derived_features&&r.push.apply(r,W(e.child_features.map((function(e){return s(e,t)}))).concat(W(e.derived_features.map((function(e){return s(e,t)}))))),r.join("")}function l(e){return s(e,{})}function c(e){var t="##".concat(e.directive);return e.value&&(t+=" ".concat(e.value)),t+"\n"}function u(e){return"# ".concat(e.comment,"\n")}function d(e){for(var t=">".concat(e.id).concat(e.description?" ".concat(e.description):"","\n"),n=Math.ceil(e.sequence.length/80),r=new Array(n),o=0;o<n;o+=1){var i=80*o;r[o]=e.sequence.slice(i,i+80)}return"".concat(t).concat(r.join("\n"),"\n")}function f(e){return"attributes"in e?l(e):"directive"in e?c(e):"sequence"in e?d(e):"comment"in e?u(e):"# (invalid item found during format)\n"}return Tl=1,Object.defineProperty(Fl,"__esModule",{value:!0}),Fl.unescape=e,Fl.escape=n,Fl.escapeColumn=r,Fl.parseAttributes=o,Fl.parseFeature=function(t){var n=t.trim().split("\t").map((function(e){return"."===e||""===e?null:e}));return{seq_id:n[0]&&e(n[0]),source:n[1]&&e(n[1]),type:n[2]&&e(n[2]),start:null===n[3]?null:parseInt(n[3],10),end:null===n[4]?null:parseInt(n[4],10),score:null===n[5]?null:parseFloat(n[5]),strand:n[6],phase:n[7],attributes:null===n[8]?null:o(n[8])}},Fl.parseDirective=function(e){var t=/^\s*##\s*(\S+)\s*(.*)/.exec(e);if(!t)return null;var n=G(t,2)[1],r=G(t,3)[2],o={directive:n};if(r.length&&(r=r.replace(/\r\n|[\r\n]$/,""),o.value=r),"sequence-region"===n){var i,a,s=r.split(/\s+/,3);return B(B({},o),{},{seq_id:s[0],start:null===(i=s[1])||void 0===i?void 0:i.replaceAll(/\D/g,""),end:null===(a=s[2])||void 0===a?void 0:a.replaceAll(/\D/g,"")})}if("genome-build"===n){var l=G(r.split(/\s+/,2),2),c=l[0],u=l[1];return B(B({},o),{},{source:c,buildName:u})}return o},Fl.formatAttributes=i,Fl.formatFeature=l,Fl.formatDirective=c,Fl.formatComment=u,Fl.formatSequence=d,Fl.formatItem=function(e){return Array.isArray(e)?e.map(f):f(e)},Fl}function Ll(){if(El)return Dl;El=1,Object.defineProperty(Dl,"__esModule",{value:!0}),Dl.GFFFormattingTransformer=Dl.GFFTransformer=void 0,Dl.parseStringSync=function(t,r){if(!t)return[];var o=n(null!=r?r:{}),i=[],a=i.push.bind(i),s={errorCallback:o.errorCallback};o.parseFeatures&&(s.featureCallback=a),o.parseDirectives&&(s.directiveCallback=a),o.parseComments&&(s.commentCallback=a),o.parseSequences&&(s.sequenceCallback=a);var l=new e.GFF3Parser({disableDerivesFromReferences:o.disableDerivesFromReferences||!1,bufferSize:Infinity});return t.split(/\r\n|[\r\n]/).forEach((function(e){return l.addLine.bind(l)(e,s)})),l.finish(s),i},Dl.formatSync=function(e){var n=[],r=[];e.forEach((function(e){"sequence"in e?r.push(e):n.push(e)}));var o=n.map((function(e){return Array.isArray(e)?(0,t.formatItem)(e).join(""):(0,t.formatItem)(e)})).join("");return r.length&&(o+="##FASTA\n",o+=r.map(t.formatSequence).join("")),o};var e=function(){if(Rl)return Ol;Rl=1,Object.defineProperty(Ol,"__esModule",{value:!0}),Ol.GFF3Parser=Ol.FASTAParser=void 0;var e=Ml(),t=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};R(this,e),D(this,"seqCallback",void 0),D(this,"currentSequence",void 0),this.seqCallback=t,this.currentSequence=void 0}),[{key:"addLine",value:function(e){var t=/^>\s*(\S+)\s*(.*)/.exec(e);t?(this.flush(),this.currentSequence={id:t[1],sequence:""},t[2]&&(this.currentSequence.description=t[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replaceAll(/\s/g,""))}},{key:"flush",value:function(){this.currentSequence&&this.seqCallback(this.currentSequence)}},{key:"finish",value:function(){this.flush()}}])}();Ol.FASTAParser=t;var n=function(){return I((function e(t){R(this,e),D(this,"endCallback",void 0),D(this,"disableDerivesFromReferences",void 0),D(this,"bufferSize",void 0),D(this,"fastaParser",void 0),D(this,"eof",!1),D(this,"lineNumber",0),D(this,"underConstructionTopLevel",[]),D(this,"underConstructionById",{}),D(this,"completedReferences",{}),D(this,"underConstructionOrphans",new Map),this.endCallback=t.endCallback||function(){},this.disableDerivesFromReferences=t.disableDerivesFromReferences||!1,this.bufferSize=void 0===t.bufferSize?Infinity:t.bufferSize}),[{key:"addLine",value:function(n,r){if(this.fastaParser)this.fastaParser.addLine(n);else if(!this.eof)if(this.lineNumber+=1,/^\s*[^#\s>]/.test(n))this.bufferLine(n,r);else{var o=/^\s*(#+)(.*)/.exec(n);if(o){var i=G(o,2)[1],a=G(o,3)[2];if(3===i.length)this.emitAllUnderConstructionFeatures(r);else if(2===i.length){var s=(0,e.parseDirective)(n);s&&("FASTA"===s.directive?(this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback)):this.emitItem(s,r))}else a=a.replace(/\s*/,""),this.emitItem({comment:a},r)}else if(/^\s*$/.test(n));else if(/^\s*>/.test(n))this.emitAllUnderConstructionFeatures(r),this.eof=!0,this.fastaParser=new t(r.sequenceCallback),this.fastaParser.addLine(n);else{var l=n.replaceAll(/\r\n|[\r\n]$/g,"");this.parseError("GFF3 parse error. Cannot parse '".concat(l,"'."),r)}}}},{key:"finish",value:function(e){this.emitAllUnderConstructionFeatures(e),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}},{key:"emitItem",value:function(e,t){Array.isArray(e)&&t.featureCallback?t.featureCallback(e):"directive"in e&&t.directiveCallback?t.directiveCallback(e):"comment"in e&&t.commentCallback&&t.commentCallback(e)}},{key:"enforceBufferSizeLimit",value:function(){for(var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1?arguments[1]:void 0,r=function(t){var n;t&&Array.isArray(t)&&null!==(n=t[0].attributes)&&void 0!==n&&null!==(n=n.ID)&&void 0!==n&&n[0]&&(t[0].attributes.ID.forEach((function(t){delete e.underConstructionById[t],delete e.completedReferences[t]})),t.forEach((function(e){e.child_features&&e.child_features.forEach((function(e){return r(e)})),e.derived_features&&e.derived_features.forEach((function(e){return r(e)}))})))};this.underConstructionTopLevel.length+t>this.bufferSize;){var o=this.underConstructionTopLevel.shift();o&&(this.emitItem(o,n),r(o))}}},{key:"emitAllUnderConstructionFeatures",value:function(e){var t=this;this.underConstructionTopLevel.forEach((function(n){return t.emitItem.bind(t)(n,e)})),this.underConstructionTopLevel=[],this.underConstructionById={},this.completedReferences={},this.underConstructionOrphans.size&&this.parseError("some features reference other features that do not exist in the file (or in the same '###' scope). ".concat(Array.from(this.underConstructionOrphans.keys()).join(",")),e)}},{key:"bufferLine",value:function(t,n){var r,o,i,a=this,s=B(B({},(0,e.parseFeature)(t)),{},{child_features:[],derived_features:[]}),l=(null===(r=s.attributes)||void 0===r?void 0:r.ID)||[],c=(null===(o=s.attributes)||void 0===o?void 0:o.Parent)||[],u=this.disableDerivesFromReferences?[]:(null===(i=s.attributes)||void 0===i?void 0:i.Derives_from)||[];if(l.length||c.length||u.length){var d=void 0;l.forEach((function(e){var t=a.underConstructionById[e];t?(t[t.length-1].type!==s.type&&a.parseError('multi-line feature "'.concat(e,'" has inconsistent types: "').concat(s.type,'", "').concat(t[t.length-1].type,'"'),n),t.push(s),d=t):(d=[s],a.enforceBufferSizeLimit(1,n),c.length||u.length||a.underConstructionTopLevel.push(d),a.underConstructionById[e]=d,a.resolveReferencesTo(d,e))})),this.resolveReferencesFrom(d||[s],{Parent:c,Derives_from:u},l)}else this.emitItem([s],n)}},{key:"resolveReferencesTo",value:function(e,t){var n=this.underConstructionOrphans.get(t);n&&(e.forEach((function(e){var t;(t=e.child_features).push.apply(t,W(n.Parent))})),e.forEach((function(e){var t;(t=e.derived_features).push.apply(t,W(n.Derives_from))})),this.underConstructionOrphans.delete(t))}},{key:"parseError",value:function(e,t){var n;this.eof=!0,null===(n=t.errorCallback)||void 0===n||n.call(t,"".concat(this.lineNumber,": ").concat(e))}},{key:"postSet",value:function(e,t,n){var r=e[t];r||(e[t]=r={});var o=r[n]||!1;return r[n]=!0,o}},{key:"resolveReferencesFrom",value:function(e,t,n){var r=this;t.Parent.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Parent,".concat(t))})).length||o.forEach((function(t){t.child_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Parent.push(e)}})),t.Derives_from.forEach((function(t){var o=r.underConstructionById[t];if(o)n.filter((function(e){return r.postSet(r.completedReferences,e,"Derives_from,".concat(t))})).length||o.forEach((function(t){t.derived_features.push(e)}));else{var i=r.underConstructionOrphans.get(t);i||r.underConstructionOrphans.set(t,i={Parent:[],Derives_from:[]}),i.Derives_from.push(e)}}))}}])}();return Ol.GFF3Parser=n,Ol}(),t=Ml();function n(e){return B({parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:Infinity,disableDerivesFromReferences:!1,errorCallback:function(e){throw new Error(e)}},e)}Dl.GFFTransformer=function(){return I((function t(r){R(this,t),D(this,"decoder",void 0),D(this,"parser",void 0),D(this,"lastString",""),D(this,"parseFeatures",void 0),D(this,"parseDirectives",void 0),D(this,"parseComments",void 0),D(this,"parseSequences",void 0),this.decoder=new TextDecoder;var o=n(null!=r?r:{});this.parser=new e.GFF3Parser({bufferSize:o.bufferSize,disableDerivesFromReferences:o.disableDerivesFromReferences}),this.parseFeatures=o.parseFeatures,this.parseDirectives=o.parseDirectives,this.parseComments=o.parseComments,this.parseSequences=o.parseSequences,this.errorCallback=null==r?void 0:r.errorCallback}),[{key:"makeCallbacks",value:function(e){var t={errorCallback:this.emitErrorMessage.bind(this,e)};return this.parseFeatures&&(t.featureCallback=function(t){e.enqueue(t)}),this.parseDirectives&&(t.directiveCallback=function(t){e.enqueue(t)}),this.parseComments&&(t.commentCallback=function(t){e.enqueue(t)}),this.parseSequences&&(t.sequenceCallback=function(t){e.enqueue(t)}),t}},{key:"emitErrorMessage",value:function(e,t){this.errorCallback?this.errorCallback(t):e.error(t)}},{key:"transform",value:function(e,t){var n="".concat(this.lastString).concat(this.decoder.decode(e,{stream:!0})).split(/\r\n|[\r\n]/g);this.lastString=n.pop()||"";var r,o=j(n);try{for(o.s();!(r=o.n()).done;)this.parser.addLine(r.value,this.makeCallbacks(t))}catch(e){o.e(e)}finally{o.f()}}},{key:"flush",value:function(e){var t=this.makeCallbacks(e);this.lastString="".concat(this.lastString).concat(this.decoder.decode()),this.lastString&&(this.parser.addLine(this.lastString,t),this.lastString=""),this.parser.finish(t)}}])}();var r=function(){return I((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R(this,e),D(this,"linesSinceLastSyncMark",0),D(this,"haveWeEmittedData",!1),D(this,"fastaMode",!1),D(this,"minLinesBetweenSyncMarks",void 0),D(this,"insertVersionDirective",void 0),this.minLinesBetweenSyncMarks=t.minSyncLines||100,this.insertVersionDirective=!1!==t.insertVersionDirective}),[{key:"transform",value:function(e,n){!this.haveWeEmittedData&&this.insertVersionDirective&&(!("directive"in e)||"directive"in e&&"gff-version"!==e.directive)&&n.enqueue("##gff-version 3\n"),"sequence"in e&&!this.fastaMode&&(n.enqueue("##FASTA\n"),this.fastaMode=!0);var r=Array.isArray(e)?e.map((function(e){return(0,t.formatItem)(e)})).join(""):(0,t.formatItem)(e);if(n.enqueue(r),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)n.enqueue("###\n"),this.linesSinceLastSyncMark=0;else{for(var o=0,i=0;i<r.length;i+=1)"\n"===r[i]&&(o+=1);this.linesSinceLastSyncMark+=o}this.haveWeEmittedData=!0}}])}();return Dl.GFFFormattingTransformer=r,Dl}var Pl,Bl=(Il||(Il=1,function(e){var t,n=jl&&jl.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=jl&&jl.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=jl&&jl.__importStar||(t=function(e){return t=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},t(e)},function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var i=t(e),a=0;a<i.length;a++)"default"!==i[a]&&n(o,e,i[a]);return r(o,e),o}),i=jl&&jl.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.util=e.defaultExport=void 0;var a=o(Ll());i(Ll(),e);var s=o(Ml());e.defaultExport=B(B({},a),{},{util:s}),e.default=e.defaultExport,e.util=o(Ml())}(jl)),jl),ql={exports:{}},Ul=(Pl||(Pl=1,function(e,t){!function(){function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){a(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==("undefined"==typeof window?"undefined":K(window))&&window.window===window?window:"object"==("undefined"==typeof self?"undefined":K(self))&&self.self===self?self:"object"==K(re)&&re.global===re?re:void 0,i=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=o.saveAs||("object"!=("undefined"==typeof window?"undefined":K(window))||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(e,i,a){var s=o.URL||o.webkitURL,l=document.createElement("a");l.download=i=i||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):n(l.href)?t(e,i,a):r(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=K(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(n(e))t(e,o,i);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){r(a)}))}}:function(e,n,r,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var s="application/octet-stream"===e.type,l=/constructor/i.test(o.HTMLElement)||o.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&l||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=e:location=e,a=null},u.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,f=d.createObjectURL(e);a?a.location=f:location.href=f,a=null,setTimeout((function(){d.revokeObjectURL(f)}),4e4)}});o.saveAs=a.saveAs=a,e.exports=a}()}(ql)),ql.exports);function $l(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 24 24",...e,children:i.jsx("path",{d:"M23,12L19,8V11H10V13H19V16M1,18V6C1,4.89 1.9,4 3,4H15A2,2 0 0,1 17,6V9H15V6H3V18H15V15H17V18A2,2 0 0,1 15,20H3A2,2 0 0,1 1,18Z"})})}function zl({handleClose:e,session:t,assembly:r}){const[o,a]=u.useState(!1),[l,c]=u.useState(""),{getInternetAccount:d}=t.apolloDataStore,{assemblyManager:f}=t,h=f.get(r);if(!h)return void c(`Assembly "${r}" not found`);const{internetAccountConfigId:p}=n.getConf(h,["sequence","metadata"]);return i.jsxs(Bs,{open:!0,title:"Export annotations",handleClose:e,maxWidth:!1,"data-testid":"download-gff3",children:[i.jsxs("form",{onSubmit:async function(t){t.preventDefault(),c(""),await(p?async function(e){const t=d(r,e),n=new URL("export/getID",t.baseURL),i=new URLSearchParams({assembly:r});n.search=i.toString();const a=n.toString(),s=t.getFetcher({locationType:"UriLocation",uri:a}),l=await s(a,{method:"GET"});if(!l.ok){const e=await dl(l,"Error when exporting ID");return void c(e)}const{exportID:u}=await l.json(),f=new URL("export",t.baseURL),h=new URLSearchParams({exportID:u,includeFASTA:o?"true":"false"});f.search=h.toString();const p=f.toString();window.open(p,"_blank")}(p):async function(e){const t=function(e){const t=new ReadableStream({async start(t){for await(const n of async function*(e){const t=await vl(e,[]);for(const e of t.objectStoreNames){const n=t.transaction(e);for await(const e of n.store.iterate())yield e.value}t.close()}(e)){const e=En(n);t.enqueue(e)}t.close()}});return t.pipeThrough(new TransformStream(new Bl.GFFFormattingTransformer))}(e),n=`${e}.gff3`;try{const e=await globalThis.showSaveFilePicker({suggestedName:n}),r=await e.createWritable();await t.pipeTo(r)}catch{const e=await new Response(t).blob();Ul.saveAs(e,n)}}(r)),e()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.DialogContentText,{children:["Exporting annotations for ",r]}),i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{"data-testid":"include-fasta-checkbox",control:i.jsx(s.Checkbox,{checked:o,onChange:()=>{a(!o)},disabled:!p}),label:"Include fasta sequence in GFF output"})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Download"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),l?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:l})}):null]})}function Hl({changeManager:e,handleClose:t,session:r}){const{apolloDataStore:o}=r,[a,l]=u.useState(),[c,d]=u.useState(),[f,h]=u.useState(""),[p,g]=u.useState(!1),[m,y]=u.useState(),[_,v]=u.useState(!1),[b,x]=u.useState(!0),[w,S]=u.useState(!1),{collaborationServerDriver:C,getInternetAccount:A}=o,k=C.getAssemblies();return u.useEffect((()=>{c&&(async()=>{const{internetAccountConfigId:e}=n.getConf(c,["sequence","metadata"]),t=A(c.name,e);if(!t)throw new Error("No Apollo internet account found");const{baseURL:r}=t,o=new URL("features/count",r),i=new URLSearchParams({assemblyId:c.name});o.search=i.toString();const a=t.getFetcher({locationType:"UriLocation",uri:o.toString()});S(!0);const s=await a(o.toString(),{method:"GET"});if(!s.ok)throw new Error(await dl(s));{const e=await s.json();y(e.count)}S(!1)})().catch((e=>{console.error(e),h(e.message??e)}))}),[A,r,c]),i.jsxs(Bs,{open:!0,title:"Import Features from GFF3 file",handleClose:t,maxWidth:!1,"data-testid":"import-features-dialog",children:[w?i.jsx(s.LinearProgress,{}):null,i.jsxs("form",{onSubmit:async function(o){o.preventDefault(),h(""),S(!0),g(!0);let i="";if(!a)return void h("must select a file");if(!c)return void h("Must select assembly to download");const{internetAccountConfigId:s}=n.getConf(c,["sequence","metadata"]),l=A(c.name,s),{baseURL:u}=l,d=new URL("files",u);d.searchParams.set("type","text/x-gff3");const f=d.href,p=new FormData;p.append("file",a),p.append("fileName",a.name),p.append("type","text/x-gff3");const m=l.getFetcher({locationType:"UriLocation",uri:f});t();const{jobsManager:y}=r,v=new AbortController,x={name:`Importing features for ${c.displayName}`,statusMessage:"Uploading file, this may take awhile",progressPct:0,cancelCallback:()=>{v.abort(new DOMException(`Canceling importing of features to ${c.displayName}`,"AbortError")),y.abortJob(x.name)}};if(y.runJob(x),m){const{signal:e}=v,t=await m(f,{method:"POST",body:p,signal:e});if(!t.ok){const e=await dl(t,"Error when inserting new features (while uploading file)");return y.abortJob(x.name,e),void h(e)}i=(await t.json())._id}const w=new vt({typeName:"AddFeaturesFromFileChange",assembly:c.name,fileId:i,parseOptions:{strict:b},deleteExistingFeatures:_});y.done(x),await e.submit(w,{updateJobsManager:!0})},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{labelId:"label",value:c?.name??"",onChange:function(e){const t=k.find((t=>t.name===e.target.value));d(t),g(!1)},disabled:p&&!f,children:k.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName??e.name},e.name)))}),i.jsx(s.DialogContentText,{children:"Upload GFF3 to load features"}),i.jsx("input",{type:"file",onChange:function(e){g(!1),e.target.files&&l(e.target.files[0])},disabled:p&&!f}),i.jsx(s.FormControlLabel,{label:"Strict parsing",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:b,onChange:function(e){x(e.target.checked)}})}),i.jsx(s.FormHelperText,{children:"Don't import any features if any lines in the GFF3 are unable to be processed"}),m&&m>0?i.jsxs(i.Fragment,{children:[i.jsx(s.FormControlLabel,{label:"Delete existing features",disabled:p&&!f,control:i.jsx(s.Checkbox,{checked:_,onChange:function(e){v(e.target.checked)},slotProps:{input:{"aria-label":"controlled"}},color:"warning"})}),i.jsxs(s.FormHelperText,{children:["This assembly has ",m," features that will be deleted"]})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!(c&&a&&void 0!==m)||p,variant:"contained",type:"submit",children:p?"Submitting...":"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]})]}),f?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:f})}):null]})}function Gl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),a=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===a.length)throw new Error("No Apollo internet account found");const[c,d]=u.useState(a[0]);return i.jsxs(Bs,{open:!0,title:"Log out",handleClose:e,maxWidth:!1,"data-testid":"log-out",children:[i.jsxs("form",{onSubmit:function(e){e.preventDefault(),o(""),c.removeToken(),globalThis.location.reload()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[a.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:c.internetAccountId,onChange:function(e){const t=a.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);d(t)},children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Are you sure you want to log out?"})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{disabled:!c,variant:"contained",type:"submit",children:"Log Out"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Vl({handleClose:e,session:t}){const{internetAccounts:n}=l.getRoot(t),[r,o]=u.useState(""),[a,c]=u.useState(!1),d=n.filter((e=>"ApolloInternetAccount"===e.type));if(0===d.length)throw new Error("No Apollo internet account found");const[f,h]=u.useState(d[0]),[p,g]=u.useState([]),[m,y]=u.useState([]),{collaborationServerDriver:_}=t.apolloDataStore,v=_.getAssemblies(),[b,x]=u.useState(v.at(0));function w(e,t){const n=[...m],r=e.target.value;if(t)n.includes(r)||(n.push(r),y(n));else{const e=n.indexOf(r,0);-1!==e&&n.splice(e,1),y(n)}}return u.useEffect((()=>{(async function(){const{baseURL:e,getFetcher:t}=f,n=new URL("checks/types",e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving checks from server");return void o(e)}const a=await i.json();g(a)})().catch((e=>{o(String(e))}))}),[f]),u.useEffect((()=>{(async function(){if(!b)return;const{baseURL:e,getFetcher:t}=f,n=new URL(`assemblies/${b.name}`,e).href,r=t({locationType:"UriLocation",uri:n}),i=await r(n,{method:"GET"});if(!i.ok){const e=await dl(i,"Error when retrieving assembly from server");return void o(e)}const a=await i.json();y(a.checks)})().catch((e=>{o(String(e))}))}),[b,f]),i.jsxs(Bs,{open:!0,title:"Manage Checks",handleClose:e,"data-testid":"manage-checks",children:[i.jsxs("form",{onSubmit:async function(n){if(n.preventDefault(),!b)return void o("Must select assembly!");const{notify:r}=t,{baseURL:i,getFetcher:a}=f,s=new URL("assemblies/checks",i).href,l=a({locationType:"UriLocation",uri:s}),c=await l(s,{method:"POST",body:JSON.stringify({_id:b.name,checks:m,name:""}),headers:{"Content-Type":"application/json"}});if(c.ok)r("Assembly checks updated successfully","success"),e();else{const e=await dl(c,"Error when updating assembly checks");o(e)}},children:[i.jsxs(s.DialogContent,{children:[d.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:f.internetAccountId,onChange:function(e){c(!1);const t=d.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);h(t)},disabled:a&&!r,children:n.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx(s.DialogContentText,{children:"Select assembly"}),i.jsx(s.Select,{style:{width:300},labelId:"label",value:b?.name??"",onChange:function(e){const t=v.find((t=>t.name===e.target.value));x(t)},disabled:0===v.length,children:v.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))}),i.jsx("br",{}),i.jsx("br",{}),i.jsx(s.TableContainer,{component:s.Paper,children:i.jsxs(s.Table,{children:[i.jsx(s.TableHead,{children:i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:"Check name"}),i.jsx(s.TableCell,{children:"Use check"})]})}),i.jsx(s.TableBody,{children:p.map((e=>i.jsxs(s.TableRow,{children:[i.jsx(s.TableCell,{children:e.name}),i.jsx(s.TableCell,{children:i.jsx(s.Checkbox,{value:e._id,checked:m.includes(e._id),onChange:w})})]},e._id)))})]})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Cancel"})]})]}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function Wl(e){return"ApolloInternetAccount"===e.type}function Jl({changeManager:e,handleClose:t,session:n}){const{internetAccounts:r}=l.getRoot(n),o=r.filter((e=>Wl(e))).filter((e=>e.role?.includes("admin")));if(0===o.length)throw new Error("No Apollo internet account found");const[a,c]=u.useState(""),[d,f]=u.useState(o[0]),[h,p]=u.useState([]);function g(e){return e===d.getUserId()}u.useEffect((()=>{(async function(){const{baseURL:e}=d,t=new URL("users",e).href,n=d.getFetcher({locationType:"UriLocation",uri:t}),r=await n(t,{method:"GET"});if(!r.ok){const e=await dl(r,"Error when getting user data from db");return void c(e)}const o=await r.json();p(o.map((e=>void 0===e.role?{...e,role:""}:e)))})().catch((e=>{c(String(e))}))}),[d]);const y=[{field:"username",headerName:"User",width:140},{field:"email",headerName:"Email",width:160},{field:"role",headerName:"Role",width:140,type:"singleSelect",valueOptions:["readOnly","user","admin","none"],getOptionLabel(e){switch(e){case"readOnly":return"Read-only";case"user":return"User";case"admin":return"Admin";case"none":return"None";default:return"unknown"}},editable:!0},{field:"actions",type:"actions",getActions:t=>[i.jsx(m.GridActionsCellItem,{icon:i.jsx(co,{}),onClick:async()=>{globalThis.confirm("Delete this user?")&&await async function(t){const n=new wt({typeName:"DeleteUserChange",userId:t});await e.submit(n,{internetAccountId:d.internetAccountId}),p((e=>e.filter((e=>e._id!==t))))}(t.id)},disabled:g(t.id),label:"Delete"},`delete-${t.id}`)]}];return i.jsxs(Bs,{open:!0,fullScreen:!0,title:"Manage users",handleClose:t,"data-testid":"manage-users",children:[i.jsxs(s.DialogContent,{children:[o.length>1?i.jsxs(i.Fragment,{children:[i.jsx(s.DialogContentText,{children:"Select account"}),i.jsx(s.Select,{value:d.internetAccountId,onChange:function(e){const t=o.find((t=>t.internetAccountId===e.target.value));if(!t)throw new Error(`Could not find internetAccount with ID "${e.target.value}"`);f(t)},disabled:!a,children:r.map((e=>i.jsx(s.MenuItem,{value:e.internetAccountId,children:e.name},e.id)))})]}):null,i.jsx("div",{style:{height:"100%",width:"100%"},children:i.jsx(m.DataGrid,{pagination:!0,rows:h,columns:y,getRowId:e=>e._id,slots:{toolbar:m.GridToolbar},getRowHeight:()=>"auto",isCellEditable:e=>!g(e.id),processRowUpdate:async function(t){const n=new Ht({typeName:"UserChange",role:t.role,userId:t._id});return await e.submit(n,{internetAccountId:d.internetAccountId}),t},onProcessRowUpdateError:e=>{c(String(e))}})})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})}),a?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:a})}):null]})}function Kl(e,t){const n=t[e];let r;if("three_prime"===e)r=`3'end (coords: ${n.min+1}-${n.max})`;else{if("five_prime"!==e)throw new Error(`Unexpected direction: "${e}"`);r=`5'end (coords: ${n.min+1}-${n.max})`}return r}function Yl({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),[f,h]=u.useState(),p=function(e){const t={},n=e.parent;if(!n)throw new Error("Unable to find parent of reference exon");let r=[];if(n.children)for(const[,e]of n.children)"exon"===e.type&&r.push(e);r=r.sort(((e,t)=>e.min===t.min?e.max-t.max:e.min-t.min)),n.strand&&-1===n.strand&&(r=r.reverse());let o=0;for(const n of r){if(n._id===e._id){r.length>o+1&&(t.three_prime=r[o+1]),o>0&&(t.five_prime=r[o-1]);break}o++}return t}(a);return i.jsxs(Bs,{open:!0,title:"Merge exons",handleClose:t,maxWidth:!1,"data-testid":"merge-exons",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d("");const{parent:s}=a;if(!f||!s)return;n?._id===a._id&&r();const c=new jt({changedIds:[a._id],typeName:"MergeExonsChange",assembly:o,firstExon:l.getSnapshot(a),secondExon:l.getSnapshot(f),parentFeatureId:s._id});e.submit(c),t(),i.preventDefault()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(p).length?"There are no neighbouring exons to merge with":"Merge with exon on:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:f,onChange:e=>{d("");const{value:t}=e.target;h(p[t])},children:Object.keys(p).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:Kl(e,p)})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(p).length||void 0===f,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function Xl(e){let t;return t=e.attributes.get("gff_name")?e.attributes.get("gff_name")?.join(","):e.attributes.get("gff_id")?e.attributes.get("gff_id")?.join(","):e._id,`${t} [${e.min+1}-${e.max}]`}function Zl({changeManager:e,handleClose:t,selectedFeature:n,session:r,setSelectedFeature:o,sourceAssemblyId:a,sourceFeature:c}){const[d,f]=u.useState(""),h=function(e,t){const n=e.parent;if(!n)throw new Error("Unable to find parent of reference transcript");const{featureTypeOntology:r}=t.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");const o={};if(n.children)for(const[,t]of n.children)r.isTypeOf(t.type,"transcript")&&t._id!==e._id&&(o[t._id]=t);return o}(c,r),p=Object.keys(h).at(0),[g,m]=u.useState(p);return i.jsxs(Bs,{open:!0,title:"Merge transcripts",handleClose:t,maxWidth:!1,"data-testid":"merge-transcripts",children:[i.jsxs("form",{onSubmit:function(r){if(r.preventDefault(),f(""),!g)return;const i=h[g];if(n?._id===c._id&&o(),!c.parent)throw new Error("Cannot find parent");const s=new Pt({changedIds:[c._id],typeName:"MergeTranscriptsChange",assembly:a,firstTranscript:l.getSnapshot(c),secondTranscript:l.getSnapshot(i),parentFeatureId:c.parent._id});e.submit(s),t()},children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[0===Object.keys(h).length?"There are no transcripts to merge with":"Merge with transcript:",i.jsx(s.FormControl,{style:{marginTop:5},children:i.jsx(s.RadioGroup,{"aria-labelledby":"demo-radio-buttons-group-label",name:"radio-buttons-group",value:g,onChange:e=>{f("");const{value:t}=e.target;m(t)},children:Object.keys(h).map((e=>i.jsx(s.FormControlLabel,{value:e,control:i.jsx(s.Radio,{}),label:i.jsx(s.Box,{display:"flex",alignItems:"center",children:Xl(h[e])})},e)))})})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===Object.keys(h).length||void 0===g,children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}const Ql=ma()((e=>({changeTextarea:{fontFamily:"monospace",width:600,resize:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius}})));function ec(e){const t={};for(const n of e.items)if(void 0!==n.value&&""!==n.value&&null!==n.value)switch(n.field){case"user":t.user=String(n.value);break;case"typeName":t.typeName=String(n.value);break;case"createdAt":{const e=new Date(n.value).toISOString();"after"===n.operator||"onOrAfter"===n.operator?t.startTime=e:"before"!==n.operator&&"onOrBefore"!==n.operator||(t.endTime=e);break}}return t}function tc({handleClose:e,session:t,assembly:n}){const{classes:r}=Ql(),[o,a]=u.useState(),[l,c]=u.useState([]),[d,f]=u.useState(0),[h,p]=u.useState(!1),[g,y]=u.useState({page:0,pageSize:15}),[_,v]=u.useState([{field:"sequence",sort:"desc"}]),[b,x]=u.useState({items:[]}),{apolloDataStore:w}=t,{assemblyManager:S}=t,C=S.get(n),A=C?.displayName??n,k=[{field:"sequence"},{field:"typeName",headerName:"Change type",width:200,type:"singleSelect",valueOptions:[...Q.changes.keys()]},{field:"changeData",headerName:"Change JSON",width:600,sortable:!1,filterable:!1,renderCell:({value:e})=>i.jsx("textarea",{className:r.changeTextarea,value:JSON.stringify(e),readOnly:!0})},{field:"user",headerName:"User",width:140},{field:"createdAt",headerName:"Time",width:160,type:"dateTime",valueGetter:e=>e&&new Date(e)}];return u.useEffect((()=>{(async function(){const e=w.getBackendDriver(n);if(!e)return void a(`No driver found for assembly "${n}"`);p(!0);const[t]=_,r=t?.field,o=t?.sort,i="asc"===o||"desc"===o?o:void 0,{changes:s,totalCount:l}=await e.getChanges(n,{page:g.page,pageSize:g.pageSize,sortField:r,sortOrder:i,filters:ec(b)}),u=s.map((e=>{const{sequence:t,typeName:n,changes:r,user:o,createdAt:i,...a}=e;return{sequence:t,typeName:n,changeData:r??{typeName:n,...a},user:o,createdAt:i}}));c(u),f(l)})().catch((e=>{a(String(e))})).finally((()=>{p(!1)}))}),[w,n,g,_,b]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View change log",handleClose:e,"data-testid":"view-changelog",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Changes for ",A]}),i.jsx(m.DataGrid,{pagination:!0,paginationMode:"server",sortingMode:"server",filterMode:"server",rowCount:d,paginationModel:g,onPaginationModelChange:y,sortModel:_,onSortModelChange:v,filterModel:b,onFilterModelChange:x,loading:h,rows:l,columns:k,getRowId:e=>e.sequence,showToolbar:!0,pageSizeOptions:[5,15,25,50,100],initialState:{columns:{columnVisibilityModel:{sequence:!1}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}const nc=[{field:"refName",headerName:"Ref Name"},{field:"aliases",headerName:"Aliases",editable:!0,flex:1}],rc=e=>/^[\da-f]{24}$/i.test(e),oc=p.observer((function({changeManager:e,handleClose:t,session:n}){const r=u.useRef(null),[o,a]=u.useState(""),[l,c]=u.useState(!1),[d,f]=u.useState(),[h,p]=u.useState([]),[g,y]=u.useState(new Map),{apolloDataStore:_}=n,{collaborationServerDriver:v}=_,b=v.getAssemblies();u.useEffect((()=>{b.length>0&&(f(b[0]),v.getRefNameAliases(b[0].name).then((e=>{x(e)})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})))}),[]);const x=e=>{const t=new Map;for(const n of e){const e=n.refName;rc(e)||t.set(e,n.aliases)}y(t)},w=()=>[...g].map(((e,t)=>({id:t,refName:e[0],aliases:e[1].filter((t=>t!==e[0])).join(", ")})));return i.jsxs(Bs,{open:!0,title:"Add reference sequence aliases",handleClose:t,maxWidth:"sm","data-testid":"add-refseq-alias",fullWidth:!0,children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:[i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{children:i.jsxs(s.FormControl,{disabled:l&&!o,fullWidth:!0,children:[i.jsx(s.InputLabel,{id:"demo-simple-select-label",children:"Assembly"}),i.jsx(s.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Assembly",value:d?.name??"",onChange:e=>{const t=b.find((t=>t.name===e.target.value));f(t),t?.name&&(v.getRefNameAliases(t.name).then((e=>{x(e),a("")})).catch((()=>{y(new Map),a("Error fetching refName aliases for assembly")})),c(!1),r.current&&(r.current.value=""))},style:{minWidth:150},children:b.map((e=>i.jsx(s.MenuItem,{value:e.name,children:e.displayName},e.name)))})]})}),i.jsxs(s.Grid,{children:[i.jsx(s.InputLabel,{children:"Load RefName alias"}),i.jsx("input",{type:"file",onChange:e=>{(async e=>{if(!e.target.files)return;const t=e.target.files[0],n=(await t.text()).split("\n"),r=new Map(g);a("");for(const e of n){const t=e.split("\t");for(const e of t)r.has(e)&&r.set(e,[...r.get(e)??[],...t])}y(r)})(e).catch((()=>{a("Error reading file")}))},ref:r,disabled:l&&!o||!d})]})]}),d&&g.size>0?i.jsxs("div",{style:{height:200,width:"100%",marginTop:20},children:[i.jsx(s.InputLabel,{children:"Refname aliases found for selected assembly."}),i.jsx(m.DataGrid,{rows:w(),columns:nc,initialState:{pagination:{paginationModel:{page:0,pageSize:5}}},pageSizeOptions:[5,10],onRowSelectionModelChange:e=>{const{ids:t}=e;if(t.size>0){c(!0);const e=[...t.values()].flatMap((e=>w().filter((t=>String(t.id)===String(e)))));p(e)}else c(!1),p([])},processRowUpdate:(e,t)=>{const n=new Map(g);return n.set(e.refName,e.aliases.split(",")),y(n),e},checkboxSelection:!0,disableRowSelectionExcludeModel:!0})]}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!l,onClick:()=>{const n=[];for(const e of h){const{refName:t}=e,r=e.aliases.split(",").map((e=>e.trim())).filter((e=>e.length>0));n.push({refName:t,aliases:r})}if(a(""),!d)return void a("No assembly selected");const r=new bt({typeName:"AddRefSeqAliasesChange",assembly:d.name,refSeqAliases:n});e.submit(r).catch((()=>{a("Error submitting change")})),t()},children:"Submit"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Close"})]}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})}));function ic({handleClose:e,session:t,assembly:n}){const[r,o]=u.useState(),[a,l]=u.useState([]),{apolloDataStore:c}=t;return u.useEffect((()=>{(async function(){const e=c.getBackendDriver(n);if(!e)return void o(`No driver found for assembly "${n}"`);const t=await e.getCheckResults(n);l(t)})().catch((e=>{o(String(e))}))}),[c,n]),i.jsxs(Bs,{open:!0,fullScreen:!0,title:"View check results",handleClose:e,"data-testid":"view-check-results",children:[i.jsxs(s.DialogContent,{children:[i.jsxs(s.DialogContentText,{children:["Check results for ",n]}),i.jsx(m.DataGrid,{pagination:!0,rows:a,columns:[{field:"_id",headerName:"id",width:50},{field:"name",headerName:"Check name",width:200},{field:"refSeq",headerName:"Reference sequence ID",width:200},{field:"ids",headerName:"Feature IDs",width:200},{field:"message",headerName:"Message",flex:1}],getRowId:e=>e._id,showToolbar:!0,initialState:{sorting:{sortModel:[{field:"name",sort:"asc"}]},columns:{columnVisibilityModel:{name:!0}}}})]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:e,children:"Close"})}),r?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:r})}):null]})}function ac(e){return e.max-e.min<2?{isSplittable:!1,comment:"This exon is too short to be split"}:{isSplittable:!0,comment:""}}function sc(e){const t=ac(e);return t.isSplittable?"Are you sure you want to split the selected exon?":t.comment}function lc({changeManager:e,handleClose:t,selectedFeature:n,setSelectedFeature:r,sourceAssemblyId:o,sourceFeature:a}){const[c,d]=u.useState(""),f=l.getSnapshot(a);return i.jsxs(Bs,{open:!0,title:"Split exon",handleClose:t,maxWidth:!1,"data-testid":"split-exon",children:[i.jsxs("form",{onSubmit:function(i){i.preventDefault(),d(""),n?._id===a._id&&r();const s=f.min+(f.max-f.min)/2,l=Math.floor(s),c=Math.ceil(s);if(!a.parent?._id)throw new Error("Splitting an exon without parent is not possible yet");const u=new qt({changedIds:[a._id],typeName:"SplitExonChange",assembly:o,exonToBeSplit:f,parentFeatureId:a.parent._id,upstreamCut:l,downstreamCut:c,leftExonId:(new at).toHexString(),rightExonId:(new at).toHexString()});e.submit(u),t(),i.preventDefault()},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:sc(f)})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:!ac(f).isSplittable,children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:t,children:"Cancel"})]})]}),c?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:c})}):null]})}function cc({changeManager:e,handleClose:t,session:r,sourceAssemblyId:o,sourceFeature:a,setSelectedFeature:c}){const[d,f]=u.useState(""),{notify:h}=r;return i.jsxs(Bs,{open:!0,title:"Duplicate transcript",handleClose:t,maxWidth:!1,"data-testid":"duplicate-transcript",children:[i.jsxs("form",{onSubmit:i=>{!async function(i){i.preventDefault(),f("");try{const i=a.parent;if(!i)return void f("No parent gene found for this transcript");const s=l.getSnapshot(a),u=(new at).toHexString(),d={...s,_id:u};if(d.children){const e={};for(const[,t]of Object.entries(d.children)){const n=(new at).toHexString();e[n]={...t,_id:n}}d.children=e}const p=n.readConfObject(r.getPluginConfiguration(),"skippedAttributesOnCopy");Aa(d,new Set(p??[]));const g=new ht({parentFeatureId:i._id,changedIds:[i._id],typeName:"AddFeatureChange",assembly:o,addedFeature:d});await e.submit(g).then((()=>{c(void 0),r.apolloSetSelectedFeature(u),h("Successfully duplicated transcript","success")})),t()}catch(e){f(e instanceof Error?e.message:"Failed to duplicate transcript")}}(i)},children:[i.jsx(s.DialogContent,{style:{display:"flex",flexDirection:"column"},children:i.jsx(s.DialogContentText,{children:"Are you sure you want to create a duplicate of this transcript?"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",children:"Yes"}),i.jsx(s.Button,{variant:"outlined",type:"button",onClick:t,children:"Cancel"})]})]}),d?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:d})}):null]})}var uc=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle");function dc(e){const{color:t}=e;return i.jsx(s.SvgIcon,{viewBox:"0 0 18 18",style:{fontSize:18,marginRight:4},...e,children:"disabled"===t?i.jsx("path",{d:"M9.001,10.71 l0,-3.348 l8.424,0 c0.126,0.567,0.225,1.098,0.225,1.845 c0,5.139,-3.447,8.793,-8.64,8.793 c-4.968,0,-9,-4.032,-9,-9 c0,-4.968,4.032,-9,9,-9 c2.43,0,4.464,0.891,6.021,2.349 l-2.556,2.484 c-0.648,-0.612,-1.782,-1.332,-3.465,-1.332 c-2.979,0,-5.409,2.475,-5.409,5.508 c0,3.033,2.43,5.508,5.409,5.508 c3.447,0,4.716,-2.385,4.95,-3.798 l-4.959,0 l0,-0.009 z"}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M17.64,9.20454545 c0,-0.638,-0.057,-1.252,-0.164,-1.841 l-8.476,0 l0,3.481 l4.844,0 c-0.209,1.125,-0.843,2.079,-1.796,2.717 l0,2.258 l2.908,0 c1.702,-1.567,2.684,-3.874,2.684,-6.615 l0,0 z",fill:"#4285F4"}),i.jsx("path",{d:"M9,18 c2.43,0,4.467,-0.806,5.956,-2.18 l-2.908,-2.259 c-0.806,0.54,-1.837,0.859,-3.048,0.859 c-2.344,0,-4.328,-1.583,-5.036,-3.71 l-3.007,0 l0,2.332 c1.481,2.941,4.525,4.958,8.043,4.958 l0,0 z",fill:"#34A853"}),i.jsx("path",{d:"M3.96409091,10.71 c-0.18,-0.54,-0.282,-1.117,-0.282,-1.71 c0,-0.593,0.102,-1.17,0.282,-1.71 l0,-2.332 l-3.007,0 c-0.609,1.215,-0.957,2.59,-0.957,4.042 c0,1.452,0.348,2.827,0.957,4.042 l3.007,-2.332 l0,0 z",fill:"#FBBC05"}),i.jsx("path",{d:"M9,3.57954545 c1.321,0,2.508,0.454,3.44,1.346 l2.582,-2.581 c-1.559,-1.453,-3.596,-2.345,-6.022,-2.345 c-3.518,0,-6.562,2.017,-8.043,4.959 l3.007,2.331 c0.708,-2.127,2.692,-3.71,5.036,-3.71 l0,0 z",fill:"#EA4335"})]})})}function fc(e){const{color:t}=e;return i.jsxs(s.SvgIcon,{viewBox:"0 0 21 21",style:{fontSize:21},...e,children:[i.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#F25022"}),i.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"disabled"===t?"#7B7B7B":"#00A4EF"}),i.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"disabled"===t?"#939393":"#7FBA00"}),i.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"disabled"===t?"#B9B9B9":"#FFB900"})]})}const hc=ma()((e=>({loginButton:{marginBottom:e.spacing(1),width:"220px",height:"40px",fontSize:"16px",textTransform:"none",justifyContent:"left",padding:"3px 12px"}})));function pc(e){const{classes:t}=hc(),{disabled:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(dc,{color:n?"disabled":void 0}),...e,children:"Sign in with Google"})}function gc(e){const{classes:t}=hc(),{disabled:n}=e;return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(fc,{color:n?"disabled":void 0}),...e,children:"Sign in with Microsoft"})}function mc(e){const{classes:t}=hc();return i.jsx(s.Button,{className:t.loginButton,variant:"outlined",startIcon:i.jsx(uc,{fontSize:"small"}),...e,children:"Continue as Guest"})}const yc=ma()((e=>({divider:{marginTop:e.spacing(4),marginBottom:e.spacing(5)}}))),_c=({baseURL:e,handleClose:t,name:n})=>{const{classes:r}=yc(),[o,a]=u.useState(""),[l,c]=u.useState([]);function d(e){t("google"===e?"google":"microsoft"===e?"microsoft":"guest")}u.useEffect((()=>{const t=new AbortController,{signal:n}=t;return async function(){const t=new URL("auth/types",e).href,r=await fetch(t,{method:"GET",signal:n});if(!r.ok){const e=await dl(r,"Error when retrieving auth types from server");return void a(e)}const o=await r.json();c(o)}().catch((e=>{ts(e)||a(String(e))})),()=>{t.abort(new DOMException("Error retrieving valid authentication types","AbortError"))}}),[e]);const f=l.includes("google"),h=l.includes("microsoft"),p=l.includes("guest");return i.jsxs(Bs,{open:!0,title:`Log in to ${n}`,handleClose:t,maxWidth:!1,"data-testid":"login-apollo",children:[i.jsxs(s.DialogContent,{style:{display:"flex",flexDirection:"column",paddingTop:8},children:[f?i.jsx(pc,{disabled:!f,onClick:()=>{d("google")}}):null,h?i.jsx(gc,{disabled:!h,onClick:()=>{d("microsoft")}}):null,p?i.jsxs(i.Fragment,{children:[i.jsx(s.Divider,{className:r.divider}),i.jsx(mc,{onClick:()=>{d("guest")}})]}):null]}),i.jsx(s.DialogActions,{children:i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})}),o?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:o})}):null]})},vc="undefined"==typeof sessionStorage,bc=e=>r.InternetAccount.named("ApolloInternetAccount").props({type:l.types.literal("ApolloInternetAccount"),configuration:n.ConfigurationReference(e)}).views((e=>({get baseURL(){return n.getConf(e,"baseURL")},getUserId(){const t=e.retrieveToken();if(t)return ln(t).id}}))).volatile((()=>({role:void 0,controller:new AbortController,tokenPromise:void 0}))).actions((e=>({setRole(){const t=e.retrieveToken();if(!t)return void(e.role=void 0);const n=ln(t),{role:r,exp:o}=n;if(o<Date.now()/1e3)return e.role=void 0,void e.removeToken();e.role!==r&&(e.role=r)}}))).actions((e=>{const t=e.getFetcher;return{getFetcher(n){const r=t(n);return async(t,n)=>{const o=await r(t,n);return 403===o.status?(e.removeToken(),e.setRole(),r(t,n)):o}}}})).actions((e=>({removeToken(){sessionStorage.removeItem(e.tokenKey),e.tokenPromise=void 0}}))).actions((e=>({async getToken(t){if(e.tokenPromise)return e.tokenPromise;let n=t?.internetAccountPreAuthorization?.authInfo?.token;if(n)return e.tokenPromise=Promise.resolve(n),e.tokenPromise;if(vc)throw new Error("Did not get internet account pre-authorization info in worker");return n=e.retrieveToken(),n?(e.tokenPromise=Promise.resolve(n),e.tokenPromise):(e.tokenPromise=new Promise(((t,n)=>{e.getTokenFromUser((n=>{e.storeToken(n),t(n)}),(t=>{e.removeToken(),n(t)}))})),e.tokenPromise)}}))).actions((e=>{let t;return{addMessageChannel(e,n){t=t=>{this.finishOAuthWindow(t,e,n)},window.addEventListener("message",t)},deleteMessageChannel(){window.removeEventListener("message",t)},finishOAuthWindow(t,n,r){if(t.data.name!==`JBrowseAuthWindow-${e.internetAccountId}`)return;const o=t.data.redirectUri.replace("#","?"),i=new URL(o),a=new URLSearchParams(i.search).get("access_token");this.deleteMessageChannel(),a?(e.storeToken(a),e.setRole(),n(a)):r(new Error("Error with token endpoint"))},async openAuthWindow(t,n,r){const i=o.isElectron?"http://localhost/auth":globalThis.location.origin+globalThis.location.pathname,a=new URL("auth/login",e.baseURL),s=new URLSearchParams({type:t,redirect_uri:i});a.search=s.toString();const l=`JBrowseAuthWindow-${e.internetAccountId}`;if(o.isElectron){const{ipcRenderer:t}=globalThis.require("electron"),o=await t.invoke("openAuthWindow",{internetAccountId:e.internetAccountId,data:{redirect_uri:i},url:a.toString()}),s=new MessageEvent("message",{data:{name:l,redirectUri:o}});this.finishOAuthWindow(s,n,r)}else this.addMessageChannel(n,r),window.open(a,l,"width=500,height=600")}}})).actions((e=>({async getTokenFromUser(t,n){const{baseURL:r}=e,o=await new Promise(((t,n)=>{const{session:r}=l.getRoot(e),{baseURL:o,name:i}=e;r.queueDialog((e=>[_c,{name:i,handleClose:r=>{r?r instanceof Error?n(r):t(r):n(new Error("user cancelled entry")),e()},baseURL:o}]))}));if("guest"!==o)return void e.openAuthWindow(o,t,n);const i=new URL("auth/login",r),a=new URLSearchParams({type:o});i.search=a.toString();const s=i.toString(),c=await fetch(s,{signal:e.controller.signal});if(!c.ok){const e=await dl(c,"Error when logging in");return void n(new Error(e))}const{token:u}=await c.json();t(u)}}))).volatile((()=>({lastChangeSequenceNumber:void 0}))).actions((e=>({setLastChangeSequenceNumber(t){e.lastChangeSequenceNumber=t}}))).actions((e=>({updateLastChangeSequenceNumber:l.flow((function*(){const{baseURL:t}=e,n=new URL("changes",t),r=new URLSearchParams({limit:"1"});n.search=r.toString();const o=n.toString(),i=e.getFetcher({locationType:"UriLocation",uri:o});let a;try{a=yield i(o,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!a.ok){const e=yield dl(a,"Error when fetching server LastChangeSequence");throw new Error(e)}const{changes:s}=yield a.json();e.setLastChangeSequenceNumber(s.length>0?s[0].sequence:0)})),getMissingChanges:l.flow((function*(){const{session:t}=l.getRoot(e),{changeManager:n}=t.apolloDataStore;if(!e.lastChangeSequenceNumber)throw new Error("No LastChangeSequence stored in session. Please, refresh you browser to get last updates from server");const{baseURL:r,lastChangeSequenceNumber:o}=e,i=new URL("changes",r),a=new URLSearchParams({since:String(o),sort:"1"});i.search=a.toString();const s=i.toString(),c=e.getFetcher({locationType:"UriLocation",uri:s});let u;try{u=yield c(s,{method:"GET",signal:e.controller.signal})}catch(t){return void(e.controller.signal.aborted||console.error(t))}if(!u.ok)return void console.error(`Error when fetching the last updates to recover socket connection — ${u.status}`);const{changes:d}=yield u.json();for(const e of d){const t=ee.fromJSON(e);n.submit(t,{submitToBackend:!1})}}))}))).volatile((e=>{const{origin:t,pathname:n}=new URL("socket.io/",e.baseURL);return{socket:so(t,{path:n})}})).actions((e=>({addSocketListeners(){const{session:t}=l.getRoot(e),{notify:n}=t,r=e.retrieveToken();if(!r)throw new Error("No Token found");const o=sn(ln(r)),{socket:i}=e,{addCheckResult:a,changeManager:s,deleteCheckResult:c}=t.apolloDataStore;i.on("connect",(()=>{e.getMissingChanges()})),i.on("connect_error",(e=>{console.error(e),n("Could not connect to the Apollo server.","error")})),i.on("COMMON",(e=>{if("checkResult"in e)return void(e.deleted?c(e.checkResult._id.toString()):a(e.checkResult));if(sessionStorage.setItem("LastChangeSequence",String(e.changeSequence)),e.userSessionId===o)return;const t=ee.fromJSON(e.changeInfo);s.submit(t,{submitToBackend:!1})})),i.on("USER_LOCATION",(e=>{const{channel:n,locations:r,userName:i,userSessionId:a}=e;"USER_LOCATION"===n&&a!==o&&t.addOrUpdateCollaborator({name:i,id:a,locations:r})})),i.on("REQUEST_INFORMATION",(e=>{const{channel:n,userSessionId:o}=e;"REQUEST_INFORMATION"===n&&o!==r&&t.broadcastLocations()}))}}))).actions((e=>({postUserLocation:(t=>{let n;return t=>{clearTimeout(n),n=setTimeout((()=>{!async function(t){if(!l.isAlive(e)||"none"===e.role)return;const{baseURL:n,controller:r}=e,o=new URL("users/userLocation",n).href,i=new URLSearchParams(JSON.stringify(t)),a=e.getFetcher({locationType:"UriLocation",uri:o});try{if(!(await a(o,{method:"POST",body:i,signal:r.signal})).ok)throw new Error("ignore")}catch{console.error("Broadcasting user location failed")}}(t)}),300)}})()}))).volatile((()=>({roleNotificationSent:!1}))).actions((e=>{function t(){e.postUserLocation([])}function n(){if("hidden"===document.visibilityState&&e.postUserLocation([]),"visible"===document.visibilityState){const{session:t}=l.getRoot(e);t.broadcastLocations()}}return{initialize:l.flow((function*(r){if("none"===r){if(!e.roleNotificationSent){const{session:t}=l.getRoot(e);t.notify("You have registered as an Apollo user but have not been given access. Ask your administrator to enable access for your account.","warning"),e.roleNotificationSent=!0}return}if("admin"===r){const t=l.getRoot(e);o.isAbstractMenuManager(t)&&function(e){e.appendToMenu("Apollo",{label:"Admin",type:"subMenu",icon:lo,subMenu:[{label:"Add Assembly",icon:Ln,onClick:e=>{e.queueDialog((t=>[gl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Delete Assembly",icon:co,onClick:e=>{e.queueDialog((t=>[Nl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Import Features",icon:uo,onClick:e=>{e.queueDialog((t=>[Hl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add reference sequence aliases",onClick:e=>{e.queueDialog((t=>[oc,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Add Assembly aliases",onClick:e=>{e.queueDialog((t=>[yl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Users",icon:fo,onClick:e=>{e.queueDialog((t=>[Jl,{session:e,handleClose:()=>{t()},changeManager:e.apolloDataStore.changeManager}]))}},{label:"Manage Checks",icon:ho,onClick:e=>{e.queueDialog((t=>[Vl,{session:e,handleClose:()=>{t()}}]))}}]})}(t)}yield e.updateLastChangeSequenceNumber(),e.addSocketListeners();const{baseURL:i}=e,a=new URL("users/locations",i).href,s=e.getFetcher({locationType:"UriLocation",uri:a});yield s(a,{method:"GET",signal:e.controller.signal}),window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",n)})),removeBeforeUnloadListener(){window.removeEventListener("beforeunload",t)},removeVisibilityChangeListener(){document.removeEventListener("visibilitychange",n)}}})).actions((e=>({afterAttach(){e.setRole(),c.autorun((async t=>{if(vc)return;const{session:n}=l.getRoot(e);if(n&&e.role)try{await e.initialize(e.role),t.dispose()}catch{}}),{name:"ApolloInternetAccount"})},beforeDestroy(){e.removeBeforeUnloadListener(),e.removeVisibilityChangeListener(),e.controller.abort(new DOMException("Cleaning up Apollo connection","AbortError")),e.socket.close()}})));var xc=function(){return crypto.getRandomValues(new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21)).reduce((function(e,t){return e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")}),"")};const wc="undefined"==typeof sessionStorage;class Sc extends _.BaseAdapter{refNameAliasesP;async getRefNameAliases(){if(this.refNameAliasesP)return this.refNameAliasesP;const e=n.readConfObject(this.config,"assemblyId");if(!wc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");return await n.getRefNameAliases(e)}const t=new Promise(((t,n)=>{const r=setTimeout((()=>{n(new Error("timeout"))}),2e4),o=xc(),i=e=>{const n=e.data;(function(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo&&"refNameAliases"in e})(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.refNameAliases))};addEventListener("message",i),rpcServer.emit("apollo",{apollo:!0,method:"getRefNameAliases",assembly:e,messageId:o})}));return this.refNameAliasesP=t,t}freeResources(){}}var Cc=n.ConfigurationSchema("ApolloRefNameAliasAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0});function Ac(e){return"uniqueId"in e&&"object"!==K(e.data)}var kc=function(){function e(t){var n=this;R(this,e),D(this,"data",void 0),D(this,"subfeatures",void 0),D(this,"parentHandle",void 0),D(this,"uniqueId",void 0),Ac(t)?this.data=t:(this.data=t.data,this.parentHandle=t.parent);var r,o=Ac(t)?t.uniqueId:t.id;if(null==o)throw new Error("SimpleFeature requires a unique `id` or `data.uniqueId` attribute");if(this.uniqueId=String(o),!(this.data.aliases||this.data.end-this.data.start>=0))throw new Error("invalid feature data, end less than start. end: ".concat(this.data.end," start: ").concat(this.data.start));this.data.subfeatures&&(this.subfeatures=null===(r=this.data.subfeatures)||void 0===r?void 0:r.map((function(t,r){return"function"!=typeof t.get?new e({id:t.uniqueId||"".concat(o,"-").concat(r),data:B({strand:n.data.strand},t),parent:n}):t})))}return I(e,[{key:"get",value:function(e){return"subfeatures"===e?this.subfeatures:"parent"===e?this.parent():this.data[e]}},{key:"set",value:function(e,t){this.data[e]=t}},{key:"tags",value:function(){return Object.keys(this.data)}},{key:"id",value:function(){return this.uniqueId}},{key:"parent",value:function(){return this.parentHandle}},{key:"children",value:function(){return this.get("subfeatures")}},{key:"toJSON",value:function(){var e=B(B({},this.data),{},{uniqueId:this.id()}),t=this.parent();t&&(e.parentId=t.id());var n=this.children();return n&&(e.subfeatures=n.map((function(e){return e.toJSON()}))),e}}],[{key:"fromJSON",value:function(t){return new e(B({},t))}}])}();function Nc(e){return"object"==typeof e&&null!==e&&"apollo"in e&&!0===e.apollo}const Tc="undefined"==typeof sessionStorage;class Rc extends _.BaseSequenceAdapter{regions;async getRefNames(){return(await this.getRegions()).map((e=>e.refName))}async getRegions(){if(this.regions)return this.regions;const e=n.readConfObject(this.config,"assemblyId");if(!Tc){const t=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!t)throw new Error("No Apollo data store found");const n=t.getBackendDriver(e);if(!n)throw new Error("No backend driver found");const r=await n.getRegions(e);return this.regions=r,r}const t=await new Promise(((t,n)=>{const r=setTimeout((()=>{n("timeout")}),2e4),o=xc(),i=e=>{const{data:n}=e;Nc(n)&&n.messageId===o&&(clearTimeout(r),removeEventListener("message",i),t(n.regions))};addEventListener("message",i),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getRegions",assembly:e,messageId:o})}));return this.regions=t,t}getFeatures(e){const{end:t,refName:r,start:o}=e,i=n.readConfObject(this.config,"assemblyId"),a={...e,assemblyName:i};return v.ObservableCreate((async e=>{if(!Tc){const n=this.pluginManager?.rootModel?.session?.apolloDataStore;if(!n)return void e.error("No Apollo data store found");const s=n.getBackendDriver(i);if(!s)return void e.error("No backend driver found");const l=(await s.getRegions(a.assemblyName)).find((e=>e.refName===a.refName));if(!l)return void e.error("Cannot get region");a.end>l.end&&(a.end=l.end);const{seq:c}=await s.getSequence(a);return e.next(new kc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:c}})),void e.complete()}const n=await new Promise(((e,t)=>{const n=setTimeout((()=>{t("timeout")}),2e4),r=xc(),o=t=>{const{data:i}=t;Nc(i)&&i.messageId===r&&(clearTimeout(n),removeEventListener("message",o),e(i.sequence))};addEventListener("message",o),globalThis.rpcServer.emit("apollo",{apollo:!0,method:"getSequence",region:a,messageId:r})}));e.next(new kc({id:`${r} ${o}-${t}`,data:{refName:r,start:o,end:t,seq:n}})),e.complete()}))}freeResources(){}}var Ec=n.ConfigurationSchema("ApolloSequenceAdapter",{assemblyId:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),Ic=function(){return I((function e(t){R(this,e),D(this,"label",void 0),D(this,"renderingComponent",void 0),D(this,"displayString",void 0),D(this,"matchedAttribute",void 0),D(this,"matchedObject",void 0),D(this,"textSearchAdapter",void 0),D(this,"relevance",void 0),D(this,"trackId",void 0),D(this,"score",void 0),D(this,"locString",void 0),D(this,"results",void 0),this.label=t.label,this.locString=t.locString,this.renderingComponent=t.renderingComponent,this.displayString=t.displayString,this.matchedAttribute=t.matchedAttribute,this.matchedObject=t.matchedObject,this.textSearchAdapter=t.textSearchAdapter,this.relevance=t.relevance,this.trackId=t.trackId,this.score=t.score||1,this.results=t.results||[]}),[{key:"getLabel",value:function(){return this.label}},{key:"getDisplayString",value:function(){return this.displayString||this.label}},{key:"getRenderingComponent",value:function(){return this.renderingComponent}},{key:"getTrackId",value:function(){return this.trackId}},{key:"getScore",value:function(){return this.score}},{key:"updateScore",value:function(e){return this.score=e,this.score}},{key:"getId",value:function(){return"".concat(this.getLabel(),"-").concat(this.getLocation(),"-").concat(this.getTrackId())}},{key:"hasLocation",value:function(){return!!this.locString}},{key:"getLocation",value:function(){return this.locString}},{key:"getComboResults",value:function(){return this.results}}])}();function jc(e,t){const{children:n,indexedIds:r,allIds:o,...i}=t;if(JSON.stringify(i).includes(e))return t;if(n)for(const t of Object.values(n)){const n=jc(e,t);if(n)return n}}class Dc extends _.BaseAdapter{get baseURL(){return n.readConfObject(this.config,"baseURL").uri}get trackId(){return n.readConfObject(this.config,"trackId")}get assemblyNames(){return n.readConfObject(this.config,"assemblyNames")}mapBaseResult(e,t,n){return e.map((e=>{const r=jc(n,e)??e,o=t.getCanonicalRefName(e.refSeq);return new Ic({label:n,trackId:this.trackId,locString:`${o}:${r.min+1}..${r.max}`,matchedObject:r})}))}async searchIndex(e){const t=e.queryString,n=[],r=this.pluginManager?.rootModel?.session;if(!r)return n;const{apolloDataStore:o}=r,{assemblyManager:i}=r;for(const r of this.assemblyNames){const a=o.getBackendDriver(r),s=i.get(r);if(!a||!s)continue;const l=await a.searchFeatures(e.queryString,[r]);n.push(...this.mapBaseResult(l,s,t))}return n}freeResources(){}}var Oc=n.ConfigurationSchema("ApolloTextSearchAdapter",{assemblyNames:{type:"stringArray",defaultValue:[],description:"List of assemblies covered by text search adapter"},trackId:{type:"string",defaultValue:""},baseURL:{type:"fileLocation",defaultValue:{uri:"",locationType:"UriLocation"}}},{explicitlyTyped:!0,explicitIdentifier:"textSearchAdapterId"}),Fc=a.createSvgIcon(i.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),Mc=a.createSvgIcon(i.jsx("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit"),Lc=a.createSvgIcon(i.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreHoriz");const Pc=ma()((e=>({attributeKey:{fontWeight:"bold",marginRight:e.spacing(2)}})));function Bc({attributeKey:e}){const{classes:t}=Pc(),n=/^[A-Z]/.test(e);let r,o=e;return e in Dn?(o=Dn[e],r=`On GFF3 export, this will be assigned to the GFF3's reserved "${o}" attribute`):function(e){return e in On}(e)?(o=On[e],r=`On GFF3 export, this will be placed in the GFF3's "${o}" column`):n&&(r="On GFF3 export, this attribute will be changed to start with a lower-case letter because attributes starting with an upper-case letter are reserved in GFF3"),i.jsxs("div",{style:{display:"flex"},children:[i.jsx(s.Typography,{className:t.attributeKey,children:o}),r?i.jsx(s.Tooltip,{title:r,children:i.jsx(s.Chip,{icon:i.jsx(ya,{}),label:"GFF3",size:"small",variant:"outlined"})}):null]})}const qc="Custom",Uc={[qc]:"custom"};for(const[e,t]of Object.entries(jn))Uc[`GFF ${t}`]=e;for(const[e,t]of Object.entries({score:"gff_score",source:"gff_source"}))Uc[`GFF ${t}`]=e;const $c=p.observer((function({setKey:e,session:t}){const{pluginManager:n}=o.getEnv(t),r=n.evaluateExtensionPoint("Apollo-ReservedAttributeKeys",Uc),a=Object.keys(r).at(0)??qc,[l,c]=u.useState(a),[d,f]=u.useState(),h=l===qc;return i.jsxs("form",{onSubmit:function(t){t.preventDefault(),e(h?d:r[l])},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:8},children:[i.jsxs(s.FormControl,{variant:"outlined",children:[i.jsx(s.InputLabel,{id:"attribute-key-select-label",children:"Key"}),i.jsx(s.Select,{labelId:"attribute-key-select-label",value:l,label:"Key",onChange:e=>{c(e.target.value)},children:Object.keys(r).map((e=>i.jsx(s.MenuItem,{value:e,children:e},e)))})]}),h?i.jsx(s.TextField,{label:"Attribute key",variant:"outlined",id:"attributeKey",onChange:e=>{f(e.target.value)}}):null]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",type:"submit",disabled:h&&!d,children:"Add"}),i.jsx(s.Button,{variant:"outlined",onClick:function(){e()},children:"Cancel"})]})]})}));var zc=a.createSvgIcon(i.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");const Hc=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);return u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]),i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{r!==String(t)&&e(r)},inputRef:e=>{d(e)}})})),Gc=p.observer((function({attributeValues:e,setAttribute:t,isNew:n=!1}){const[r,o]=u.useState(e&&e.length>0?e:[""]);return i.jsxs(i.Fragment,{children:[r.map(((e,t)=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx(Hc,{value:e,onChangeCommitted:e=>{!function(e,t){o((n=>{const r=[...n];return r[e]=t,r}))}(t,e)},variant:"outlined",fullWidth:!0}),i.jsx(s.IconButton,{"aria-label":"delete",size:"medium",edge:"end",onClick:()=>{!function(e){o((t=>{const n=[...t];return n.splice(e,1),n}))}(t)},children:i.jsx(co,{fontSize:"inherit"})})]},`${t}-${e}`))),i.jsx(s.IconButton,{"aria-label":"add",size:"medium",color:"secondary",edge:"start",onClick:function(){o((e=>{const t=[...e];return t.push(""),t}))},children:i.jsx(zc,{fontSize:"inherit"})}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{color:"primary",variant:"contained",onClick:()=>{t(r.filter(Boolean))},children:n?"Add":"Update"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:()=>{t()},children:"Cancel"})]})]})}));function Vc({values:e}){return i.jsx(i.Fragment,{children:e?.map(((e,t)=>i.jsx(s.Typography,{variant:"body2",color:"textSecondary",children:e},`${t}.${e}`)))})}const Wc=ma()((e=>({list:{"li:nth-of-type(odd)":{backgroundColor:e.palette.action.focus},"li:nth-of-type(even)":{backgroundColor:e.palette.action.hover}}}))),Jc=p.observer((function({assembly:e,editable:t,feature:n,session:r}){const{pluginManager:a}=o.getEnv(r),{classes:d}=Wc(),[f,h]=u.useState(null),[p,g]=u.useState(null),[m,y]=u.useState(null),[_,v]=u.useState(!1),[b,x]=u.useState(),w=Boolean(f),{changeManager:S}=r.apolloDataStore,{notify:C}=r;function A(){h(null),g(null)}const{_id:k,attributes:N}=n,T=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Gc,{key:b});return i.jsxs(i.Fragment,{children:[i.jsxs(s.List,{className:d.list,children:[c.entries(N).map((([o,c])=>{const u=a.evaluateExtensionPoint("Apollo-AttributeEditorComponent",Gc,{key:o}),d=a.evaluateExtensionPoint("Apollo-AttributeViewerComponent",Vc,{key:o});return i.jsx(s.ListItem,{secondaryAction:t&&!m?i.jsx(s.IconButton,{edge:"end",onClick:e=>{!function(e,t){h(e.currentTarget),g(t)}(e,o)},children:i.jsx(Lc,{})}):null,children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Bc,{attributeKey:o}),secondary:m===o?i.jsx(u,{session:r,attributeValues:c,setAttribute:t=>{y(null),t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(!(t in o))return void C(`"${t}" not found in feature attributes`,"error");if(o[t].toString()===r.toString())return;o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(o,t)}}):i.jsx(d,{values:c})})},o)})),b?i.jsx(s.ListItem,{children:i.jsx(s.ListItemText,{disableTypography:!0,primary:i.jsx(Bc,{attributeKey:b}),secondary:i.jsx(T,{session:r,attributeValues:[],setAttribute:t=>{t&&function(t,r){const o={...l.getSnapshot(N)},i=structuredClone(o);if(t in o)return void C(`Feature already has attribute "${t}"`,"error");o[t]=r;const a=new St({changedIds:[n._id],typeName:"FeatureAttributeChange",assembly:e,featureId:n._id,oldAttributes:i,newAttributes:o});S.submit(a)}(b,t),x(void 0)},isNew:!0})})}):null]}),t?i.jsx(s.Button,{color:"primary",variant:"contained",disabled:_||Boolean(b),onClick:()=>{v(!0)},children:"Add new"}):null,_?i.jsx(s.Paper,{variant:"outlined",style:{marginTop:8},children:i.jsx($c,{session:r,setKey:e=>{x(e),v(!1)}})}):null,i.jsxs(s.Menu,{anchorEl:f,open:w,onClose:A,children:[i.jsxs(s.MenuItem,{onClick:function(){p&&function(t){const n=l.getSnapshot(N),{[t]:r,...o}=n,i=new St({changedIds:[k],typeName:"FeatureAttributeChange",assembly:e,featureId:k,oldAttributes:n,newAttributes:o});S.submit(i)}(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(co,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Delete"})]}),i.jsxs(s.MenuItem,{onClick:function(){p&&y(p),A()},children:[i.jsx(s.ListItemIcon,{children:i.jsx(Mc,{fontSize:"small"})}),i.jsx(s.Typography,{variant:"inherit",children:"Edit"})]})]})]})})),Kc=p.observer((function({onChangeCommitted:e,value:t,...n}){const[r,o]=u.useState(String(t)),[a,l]=u.useState(!1),[c,d]=u.useState(null);u.useEffect((()=>{o(String(t))}),[t]),u.useEffect((()=>{a&&(c?.blur(),l(!1))}),[a,c]);const f=Number.isNaN(Number(r));return i.jsx(s.TextField,{...n,type:"text",onChange:function(e){o(e.target.value)},value:r,onKeyDown:e=>{"Enter"===e.key?c?.blur():"Escape"===e.key&&(o(String(t)),l(!0))},onBlur:()=>{const n=Number(r);r!==String(t)&&(Number.isNaN(n)?o(String(t)):e(n)||o(String(t)))},inputRef:e=>{d(e)},error:f,helperText:f?"Not a valid number":void 0})})),Yc=p.observer((function({assembly:e,feature:t,session:n}){const[r,o]=u.useState(""),[a,l]=u.useState(""),{_id:c,assemblyId:d,max:f,min:h,strand:p,type:g}=t,m=e=>{n.notify(e.message,"error")},{changeManager:y}=n.apolloDataStore;function _(t){const{value:n}=t.target,r=n?Number(n):void 0,o=new $t({typeName:"StrandChange",changedIds:[c],featureId:c,oldStrand:p,newStrand:r,assembly:e});return y.submit(o)}return i.jsxs("div",{"data-testid":"basic_information",children:[i.jsx(Kc,{margin:"dense",id:"start",label:"Start",fullWidth:!0,variant:"outlined",value:h+1,onChangeCommitted:function(t){t--;const n=new Et({typeName:"LocationStartChange",changedIds:[c],featureId:c,oldStart:h,newStart:t,assembly:e});return y.submit(n),!0}}),i.jsx(Kc,{margin:"dense",id:"end",label:"End",fullWidth:!0,variant:"outlined",value:f,onChangeCommitted:function(t){const n=new Tt({typeName:"LocationEndChange",changedIds:[c],featureId:c,oldEnd:f,newEnd:t,assembly:e});return y.submit(n),!0}}),i.jsx(qs,{session:n,ontologyName:"Sequence Ontology",value:g,filterTerms:Cs,fetchValidTerms:async function(e,t,n){const r=await Ms(e,t);if(r)return r;l(`Type "${e?.type}" does not have any children in the ontology`)}.bind(null,t),renderInput:e=>i.jsx(s.TextField,{...e,label:"Type",variant:"outlined",fullWidth:!0,error:Boolean(a),helperText:a}),onChange:(e,t)=>{t&&function(e){o("");const t=new zt({typeName:"TypeChange",changedIds:[c],featureId:c,oldType:g,newType:e,assembly:d});return y.submit(t)}(t).catch(m)}}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"1",checked:1===p,onChange:_}),"Positive Strand (+)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"-1",checked:-1===p,onChange:_}),"Negative Strand (-)"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",value:"",checked:void 0===p,onChange:_}),"No Strand Information"]}),r?i.jsx(s.Typography,{color:"error",children:r}):null]})})),Xc=p.observer((function(e){const{feature:t,model:n}=e,{children:r,parent:o}=t,a=[];if(r)for(const[,e]of r)a.push(e);return o??a.length>0?i.jsxs("div",{style:{marginTop:10},children:[o&&i.jsxs("div",{children:[i.jsx(s.Typography,{variant:"h6",children:"Parent:"}),i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(o)},children:[o.type,Sa(o)," (",o.min,"..",o.max,")"]})]}),a.length>0&&i.jsxs("div",{children:[i.jsxs(s.Typography,{variant:"h6",children:[1===a.length?"Child":"Children",":"]}),a.map((e=>i.jsx("div",{style:{marginBottom:5},children:i.jsxs(s.Button,{variant:"contained",onClick:()=>{n.setFeature(e)},children:[e.type,Sa(e)," (",e.min,"..",e.max,")"]})},e._id)))]})]}):null})),Zc=ma()({sequence:{width:"100%",resize:"vertical"}}),Qc=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),{classes:a}=Zc();if(!t||!o)return null;const s=o.getByRefName(n);if(!s)return null;const{max:l,min:c}=t;let u=s.getSequence(c,l);return u?u=function(e,t,n,r,o){return`>${t}:${n+1}–${r}\n${e}`}(u,n,c,l):r.apolloDataStore.loadRefSeq([{assemblyName:e,refName:n,start:c,end:l}]),i.jsx("div",{children:i.jsx("textarea",{readOnly:!0,rows:20,className:a.sequence,value:u})})})),eu=ma()((e=>({root:{padding:e.spacing(2)}}))),tu=p.observer((function(e){const{model:t}=e,{assembly:n,feature:r,refName:a}=t,l=o.getSession(t),c=l.apolloDataStore.assemblies.get(n),{classes:d}=eu(),[f,h]=u.useState(["attributes"]);if(u.useEffect((()=>{h(["attributes"])}),[r]),!r||!c)return null;const p=c.getByRefName(a);if(!p)return null;const{max:g,min:m}=r;function y(e,t){h(e?[...f,t]:f.filter((e=>e!==t)))}return p.getSequence(m,g)||l.apolloDataStore.loadRefSeq([{assemblyName:n,refName:a,start:m,end:g}]),i.jsxs("div",{className:d.root,children:[i.jsx(Yc,{feature:r,session:l,assembly:c._id}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("attributes"),onChange:(e,t)=>{y(t,"attributes")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",children:"Attributes"})}),i.jsx(s.AccordionDetails,{children:i.jsx(Jc,{feature:r,session:l,assembly:c._id,editable:!0})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("sequence"),onChange:(e,t)=>{y(t,"sequence")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",children:"Sequence"})}),i.jsx(s.AccordionDetails,{children:f.includes("sequence")&&i.jsx(Qc,{feature:r,session:l,assembly:c._id,refName:a})})]}),i.jsxs(s.Accordion,{style:{marginTop:10},expanded:f.includes("related_features"),onChange:(e,t)=>{y(t,"related_features")},children:[i.jsx(s.AccordionSummary,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsx(s.Typography,{component:"span",children:"Related features"})}),i.jsx(s.AccordionDetails,{children:i.jsx(Xc,{model:t,feature:r})})]})]})}));var nu=l.types.late((function(){return ru})),ru=l.types.model("AnnotationFeatureModel",{_id:l.types.identifier,refSeq:l.types.string,type:l.types.string,min:l.types.number,max:l.types.number,strand:l.types.maybe(l.types.union(l.types.literal(1),l.types.literal(-1))),children:l.types.maybe(l.types.map(nu)),attributes:l.types.map(l.types.array(l.types.string))}).views((function(e){return{get length(){return e.max-e.min},get featureId(){return e.attributes.get("id")},get minWithChildren(){var t=e.min,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.min(t,i[1].min)}}catch(e){o.e(e)}finally{o.f()}return t},get maxWithChildren(){var t=e.max,n=e.children;if(!n)return t;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);t=Math.max(t,i[1].max)}}catch(e){o.e(e)}finally{o.f()}return t},hasDescendant:function(t){var n=e.children;if(!n)return!1;var r,o=j(n);try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);if(i[0]===t)return!0;if(i[1].hasDescendant(t))return!0}}catch(e){o.e(e)}finally{o.f()}return!1},get transcriptExonParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent, cannot calculate exon locations");var n=e.children;if(!n)throw new Error("No exons in transcript");var r,i=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"exon")})).sort((function(e,t){return e.min-t.min})),a=e.min,s=[],l=j(i);try{for(l.s();!(r=l.n()).done;){var c=r.value;c.min>a&&s.push({min:a,max:c.min,type:"intron"}),s.push({min:c.min,max:c.max,type:"exon"}),a=c.max}}catch(e){l.e(e)}finally{l.f()}return a<e.max&&s.push({min:a,max:e.max,type:"intron"}),-1===e.strand&&s.reverse(),s},get transcriptParts(){var t=o.getSession(e).apolloDataStore.ontologyManager.featureTypeOntology;if(!t.isTypeOf(e.type,"transcript")&&!t.isTypeOf(e.type,"pseudogenic_transcript"))throw new Error('Only features of type "transcript" or equivalent can calculate CDS locations');var n=e.children;if(!n)throw new Error("no CDS or exons in transcript");var r=W(n.values()).filter((function(e){return t.isTypeOf(e.type,"CDS")})),i=[];if(0===r.length)return i.push(this.transcriptExonParts),i;var a,s=j(r);try{var l=function(){var r,s=a.value,l=s.max,c=s.min,u=[],d=!1,f=[],h=j(n);try{for(h.s();!(r=h.n()).done;){var p=G(r.value,2)[1];t.isTypeOf(p.type,"exon")&&f.push({min:p.min,max:p.max})}}catch(e){h.e(e)}finally{h.f()}f.sort((function(e,t){return e.min-t.min}));for(var g=0,m=f;g<m.length;g++){var y=m[g],_=u.at(-1);_&&u.push({min:_.max,max:y.min,type:"intron"});var v,b=G(o.intersection2(c,l,y.min,y.max),2),x=b[0],w=b[1];v=d?1===e.strand?"threePrimeUTR":"fivePrimeUTR":1===e.strand?"fivePrimeUTR":"threePrimeUTR",void 0!==x&&void 0!==w?(d=!0,x===y.min&&w===y.max?u.push({min:x,max:w,phase:0,type:"CDS"}):x===y.min?u.push({min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:v}):w===y.max?u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"}):u.push({min:y.min,max:x,type:v},{min:x,max:w,phase:0,type:"CDS"},{min:w,max:y.max,type:"fivePrimeUTR"===v?"threePrimeUTR":"fivePrimeUTR"})):u.push({min:y.min,max:y.max,type:v})}u.sort((function(e,t){return e.min-t.min})),-1===e.strand&&u.reverse();var S=0,C=u.map((function(e){if("CDS"!==e.type)return e;var t=S;return S=(3-(e.max-e.min-t+3)%3)%3,B(B({},e),{},{phase:t})}));i.push(C)};for(s.s();!(a=s.n()).done;)l()}catch(e){s.e(e)}finally{s.f()}return i}}})).views((function(e){return{get cdsLocations(){return e.transcriptParts.map((function(e){return e.filter((function(e){return"CDS"===e.type}))}))}}})).actions((function(e){return{setAttributes:function(t){e.attributes.clear();var n,r=j(t.entries());try{for(r.s();!(n=r.n()).done;){var o=G(n.value,2);e.attributes.set(o[0],o[1])}}catch(e){r.e(e)}finally{r.f()}},setAttribute:function(t,n){e.attributes.merge(D({},t,n))},setType:function(t){e.type=t},setRefSeq:function(t){e.refSeq=t},setMin:function(t){if(t>e.max)throw new Error('Min "'.concat(t+1,'" is greater than max "').concat(e.max,'"'));e.min!==t&&(e.min=t)},setMax:function(t){if(t<e.min)throw new Error('Max "'.concat(t,'" is less than Min "').concat(e.min,'"'));e.max!==t&&(e.max=t)},setStrand:function(t){e.strand=t},addChild:function(t){if(e.children&&e.children.size>0){var n=l.getSnapshot(e.children);e.children.clear();var r,o=j(Object.entries(B(B({},n),{},D({},t._id,t))).sort((function(e,t){var n=G(e,2)[1],r=G(t,2);return n.min-r[1].min})));try{for(o.s();!(r=o.n()).done;){var i=G(r.value,2);e.children.put(i[1])}}catch(e){o.e(e)}finally{o.f()}}else{var a;e.children=l.cast({}),null===(a=e.children)||void 0===a||a.put(t)}},deleteChild:function(t){var n;null===(n=e.children)||void 0===n||n.delete(t)}}})).actions((function(e){return{update:function(t){var n=t.children,r=t.max,o=t.min,i=t.strand;e.setRefSeq(t.refSeq),e.setMin(o),e.setMax(r),e.setStrand(i),n&&(e.children=l.cast(n))}}})).views((function(e){return{get parent(){var t;try{t=l.getParentOfType(e,ru)}catch(e){}return t},get topLevelFeature(){var t,n=e;do{try{n=t=l.getParentOfType(n,ru)}catch(e){t=void 0}}while(t);return n},get assemblyId(){for(var t=e;l.hasParent(t);)if("refSeqs"in(t=l.getParent(t))&&"_id"in t)return t._id;throw new Error("AnnotationFeatureModel: could not find parent ApolloAssembly")}}})),ou=l.types.model({start:l.types.number,stop:l.types.number,sequence:l.types.string}),iu=l.types.model("ApolloRefSeq",{_id:l.types.identifier,name:l.types.string,description:"",features:l.types.map(ru),sequence:l.types.array(ou)}).actions((function(e){return{addFeature:function(t){e.features.put(t)},deleteFeature:function(t){return e.features.delete(t)},setDescription:function(t){e.description=t},addSequence:function(t){var n;if(t.sequence.length!==t.stop-t.start)throw new Error("sequence does not match declared length: ".concat(JSON.stringify(t)));if(0!==e.sequence.length){var r=e.sequence.map((function(e){return{start:e.start,stop:e.stop,sequence:e.sequence}}));r.push({start:t.start,stop:t.stop,sequence:t.sequence}),r.sort((function(e,t){return e.start===t.start?e.stop-t.stop:e.start-t.start}));var o,i=r.reduce((function(e,t){var n=e.at(-1);if(void 0===n)return[t];if(n.stop>=t.start){if(t.stop>n.stop){var r=n.stop-t.start;n.stop=t.stop,n.sequence+=t.sequence.slice(r)}}else e.push(t);return e}),[]),a=j(i);try{for(a.s();!(o=a.n()).done;){var s=o.value;if(s.sequence.length!==s.stop-s.start)throw new Error("Consolidated sequence does not match declared length")}}catch(e){a.e(e)}finally{a.f()}e.sequence.length===i.length&&e.sequence.every((function(e,t){var n;return e.start===(null===(n=i[t])||void 0===n?void 0:n.start)&&e.stop===i[t].stop}))||(e.sequence.clear(),(n=e.sequence).push.apply(n,W(i)))}else e.sequence.push(t)}}})).views((function(e){return{getSequence:function(t,n){var r,i=j(e.sequence);try{for(i.s();!(r=i.n()).done;){var a=r.value,s=a.sequence,l=a.start;if(o.isContainedWithin(t,n,l,a.stop))return s.slice(t-l,n-l)}}catch(e){i.e(e)}finally{i.f()}return""},getFeatures:function(t,n){var r,i=[],a=j(e.features);try{for(a.s();!(r=a.n()).done;){var s=G(r.value,2)[1];o.doesIntersect2(s.min,s.max,t,n)&&i.push(s)}}catch(e){a.e(e)}finally{a.f()}return i}}})),au=l.types.model("ApolloAssembly",{_id:l.types.identifier,refSeqs:l.types.map(iu),comments:l.types.array(l.types.string),backendDriverType:l.types.optional(l.types.enumeration("backendDriverType",["CollaborationServerDriver","LocalDriver"]),"CollaborationServerDriver")}).views((function(e){return{getByRefName:function(t){return W(e.refSeqs.values()).find((function(e){return e.name===t}))}}})).actions((function(e){return{addRefSeq:function(t,n,r){return e.refSeqs.put({_id:t,name:n,description:r})},addComment:function(t){return e.comments.push(t)}}})),su=l.types.model("CheckResult",{_id:l.types.identifier,name:l.types.string,cause:l.types.string,ids:l.types.array(l.types.safeReference(ru)),refSeq:l.types.string,start:l.types.number,end:l.types.number,ignored:!1,message:l.types.string});const lu=l.types.model("ApolloFeatureDetailsWidget",{id:d.ElementId,type:l.types.literal("ApolloFeatureDetailsWidget"),feature:l.types.maybe(l.types.reference(ru,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}}))),cu=l.types.model("ApolloTranscriptDetails",{id:d.ElementId,type:l.types.literal("ApolloTranscriptDetails"),feature:l.types.maybe(l.types.reference(ru,{onInvalidated(e){e.parent.setTryReload(e.invalidId),e.removeRef()}})),assembly:l.types.string,refName:l.types.string}).volatile((()=>({tryReload:void 0}))).actions((e=>({setFeature(t){e.feature=t},setTryReload(t){e.tryReload=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((t=>{if(!e.tryReload)return;const n=o.getSession(e),{apolloDataStore:r}=n;if(!r)return;const i=r.getFeature(e.tryReload);i&&(e.setFeature(i),e.setTryReload(),t.dispose())})))}})));var uu=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,du=li((function(e){return uu.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),fu=function(e){return"theme"!==e},hu=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?du:fu},pu=function(e,t,n){var r;if(t){var o=t.shouldForwardProp;r=e.__emotion_forwardProp&&o?function(t){return e.__emotion_forwardProp(t)&&o(t)}:o}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},gu="You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",mu=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return wi(t,n,r),Hi((function(){return Si(t,n,r)})),null},yu=function e(t,n){if("production"!==ae.env.NODE_ENV&&void 0===t)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var r,o,i=t.__emotion_real===t,a=i&&t.__emotion_base||t;void 0!==n&&(r=n.label,o=n.target);var s=pu(t,n,i),l=s||hu(a),c=!l("as");return function(){var u=arguments,d=i&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==r&&d.push("label:"+r+";"),null==u[0]||void 0===u[0].raw)d.push.apply(d,u);else{"production"!==ae.env.NODE_ENV&&void 0===u[0][0]&&console.error(gu),d.push(u[0][0]);for(var f=u.length,h=1;h<f;h++)"production"!==ae.env.NODE_ENV&&void 0===u[0][h]&&console.error(gu),d.push(u[h],u[0][h])}var p=Wi((function(e,t,n){var r=c&&e.as||a,i="",u=[],f=e;if(null==e.theme){for(var h in f={},e)f[h]=e[h];f.theme=w.useContext(Ji)}"string"==typeof e.className?i=xi(t.registered,u,e.className):null!=e.className&&(i=e.className+" ");var p=zi(d.concat(u),t.registered,f);i+=t.key+"-"+p.name,void 0!==o&&(i+=" "+o);var g=c&&void 0===s?hu(r):l,m={};for(var y in e)c&&"as"===y||g(y)&&(m[y]=e[y]);return m.className=i,m.ref=n,w.createElement(w.Fragment,null,w.createElement(mu,{cache:t,serialized:p,isStringTag:"string"==typeof r}),w.createElement(r,m))}));return p.displayName=void 0!==r?r:"Styled("+("string"==typeof a?a:a.displayName||a.name||"Component")+")",p.defaultProps=t.defaultProps,p.__emotion_real=p,p.__emotion_base=a,p.__emotion_styles=d,p.__emotion_forwardProp=s,Object.defineProperty(p,"toString",{value:function(){return void 0===o&&"production"!==ae.env.NODE_ENV?"NO_COMPONENT_SELECTOR":"."+o}}),p.withComponent=function(t,r){return e(t,bi({},n,r,{shouldForwardProp:pu(p,r,!0)})).apply(void 0,d)},p}}.bind();async function _u(e){if(isSecureContext){const t=new Blob([e.outerText],{type:"text/plain"}),n=new Blob([e.outerHTML],{type:"text/html"}),r=new ClipboardItem({[t.type]:t,[n.type]:n});return navigator.clipboard.write([r])}const t=t=>{t.clipboardData?.setData("text/plain",e.outerText),t.clipboardData?.setData("text/html",e.outerHTML),t.preventDefault()};document.addEventListener("copy",t),document.execCommand("copy"),document.removeEventListener("copy",t)}function vu(e){let t=0;for(const n of e)t+=n.sequence.length;return t}function bu(e,t,n){const r=[],{cdsLocations:i,strand:a,transcriptParts:s}=t;switch(e){case"genomic":case"cDNA":{const[t]=s;for(const i of t){if("cDNA"===e&&"intron"===i.type)continue;let t=n(i.min,i.max);-1===a&&(t=o.revcom(t));const s="fivePrimeUTR"===i.type||"threePrimeUTR"===i.type?"UTR":i.type,l=r.at(-1);l&&l.type===s?(l.sequence+=t,l.locs.push({min:i.min,max:i.max})):r.push({type:s,sequence:t,locs:[{min:i.min,max:i.max}]})}return r}case"CDS":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}return r.push({type:"CDS",sequence:e,locs:s}),r}case"protein":{let e="";const[t]=i,s=[];for(const r of t){let t=n(r.min,r.max);-1===a&&(t=o.revcom(t)),e+=t,s.push({min:r.min,max:r.max})}let l="";for(let t=0;t<e.length;t+=3){const n=e.slice(t,t+3).toUpperCase();l+=o.defaultCodonTable[n]||"&"}return r.push({type:"protein",sequence:l,locs:s}),r}}}function xu(e){switch(e){case"upOrDownstream":return"rgb(255,255,255)";case"exon":case"UTR":return"rgb(194,106,119)";case"CDS":return"rgb(93,168,153)";case"intron":return"rgb(187,187,187)";case"protein":return"rgb(148,203,236)"}}function wu(e){const t=[],n=e.flatMap((e=>e.locs));let[r]=n;for(let e=1;e<n.length;e++)r.min===n[e].max||r.max===n[e].min?r={min:Math.min(r.min,n[e].min),max:Math.max(r.max,n[e].max)}:(t.push(r),r=n[e]);return t.push(r),t}["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){yu[e]=yu(e)}));const Su=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const o=r.apolloDataStore.assemblies.get(e),a=o?.getByRefName(n),{featureTypeOntology:l}=r.apolloDataStore.ontologyManager,c="genomic",d=["genomic","cDNA"],[f,h]=u.useState(d),[p,g]=u.useState(c),[m,y]=u.useState((()=>a?bu(c,t,((e,t)=>a.getSequence(e,t))):[])),[_,v]=u.useState((()=>wu(m))),b=s.useTheme(),x=u.useRef(null);if(u.useEffect((()=>{const{cdsLocations:e}=t,[n]=e;h(n.length>0?[...d,"CDS","protein"]:d)}),[t]),!o||!a)return null;const w=o.getByRefName(n);if(!w)return null;if(!l)throw new Error("featureTypeOntology is undefined");return l.isTypeOf(t.type,"transcript")?i.jsxs(i.Fragment,{children:[i.jsx(s.Select,{defaultValue:"genomic",value:p,onChange:function(e){const n=e.target.value;g(n);const r=a?bu(n,t,((e,t)=>a.getSequence(e,t))):[],o=wu(r);y(r),v(o)},size:"small","data-testid":"sequenceOptionSelector",children:f.map((e=>i.jsx(s.MenuItem,{value:e,"data-testid":`sequenceOption-${e}`,children:e},e)))}),i.jsx(s.Button,{variant:"contained",onClick:()=>{const e=x.current;e&&_u(e)},style:{marginLeft:10},size:"medium",children:"Copy sequence"}),i.jsxs(s.Paper,{style:{fontFamily:"monospace",padding:b.spacing(),overflowX:"auto"},ref:x,children:[">",w.name,":",_.map((e=>1===t.strand?`${e.min+1}-${e.max}`:`${e.max}-${e.min+1}`)).join(";"),"(strand=",1===t.strand?"+":"-",";length=",vu(m),")",i.jsx("br",{}),function(e,t){const n=[];let r=0;for(const[t,o]of e.entries()){const e=r%60,a=r>0&&0===e?"\n":"";r+=o.sequence.length;const s=a+o.sequence.slice(0,60-e),l=[s,...Ot(o.sequence.slice(s.length),60)],c=i.jsx("span",{style:{background:xu(o.type),color:b.palette.getContrastText(xu(o.type)),whiteSpace:"pre-line"},children:l.join("\n")},`${o.type}-${t}`);n.push(c)}return n}(m)]})]}):null}));var Cu=a.createSvgIcon(i.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),Au=a.createSvgIcon(i.jsx("path",{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2m6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5M19 3l-6 6 2 2 7-7V3z"}),"ContentCut"),ku=a.createSvgIcon(i.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove");const Nu=yu(Kc)((()=>({"&.MuiFormControl-root":{marginTop:0,marginBottom:0,width:"100%"},"& .MuiInputBase-input":{fontSize:12,height:20,padding:1,paddingLeft:10}}))),Tu=yu("div")({display:"flex",justifyContent:"center",alignItems:"center",textAlign:"left",width:"100%",overflowWrap:"break-word",wordWrap:"break-word",wordBreak:"break-all","& span":{fontSize:12}}),Ru=yu(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}}))),Eu=e=>{const{strand:t}=e;return i.jsx("div",{children:1===t?i.jsx(Ln,{}):-1===t?i.jsx(ku,{}):i.jsx(s.Typography,{component:"span",children:"N/A"})})},Iu=p.observer((function({assembly:e,feature:t,refName:n,session:r}){const{notify:a}=r,l=r.apolloDataStore.assemblies.get(e),c=l?.getByRefName(n),{changeManager:d}=r.apolloDataStore,f=u.useRef(null),{changeInProgress:h}=r;if(!c)return null;const{apolloDataStore:p}=r,{featureTypeOntology:g}=p.ontologyManager;if(!g.isTypeOf(t.type,"transcript")&&!g.isTypeOf(t.type,"pseudogenic_transcript"))throw new Error("Feature is not a transcript or equivalent");const{cdsLocations:m,transcriptExonParts:y,strand:_}=t,[v]=m,[b,x]=((e,t)=>{const{transcriptExonParts:n}=e,r=n.filter((e=>t.isTypeOf(e.type,"exon"))).sort((({min:e},{min:t})=>e-t)),o=r[0]?.min,i=r[r.length-1]?.max;return[o,i]})(t,g);let w=b,S=x;const C=v.length>0;if(C){const e=v.toSorted((({min:e},{min:t})=>e-t));w=e[0].min,S=e[e.length-1].max}const A=(t,n,r,o,i)=>{if(!r.children)throw new Error("Transcript should have child features");if(t===n)return!0;const s=R(r,g,t,o);if(!s)return a("No matching CDS feature found","error"),!1;if(o&&n>=s.max)return a("Start location should be less than CDS end location","error"),!1;if(!o&&n<=s.min)return a("End location should be greater than CDS start location","error"),!1;if(!D(r,g,n,o))return a("There should be an overlapping exon for the new CDS location","error"),!1;const l=o?new Et({typeName:"LocationStartChange",changedIds:[s._id],featureId:s._id,oldStart:s.min,newStart:n,assembly:e}):new Tt({typeName:"LocationEndChange",changedIds:[s._id],featureId:s._id,oldEnd:s.max,newEnd:n,assembly:e});return d.submit(l).then((()=>{i&&i()})).catch((()=>{a("Error updating feature CDS position","error")})),!0};function k(t,n,r,o){if(!r.children)throw new Error("Transcript should have child features");const{matchingExon:i,prevExon:s,nextExon:l}=O(r,g,t,o);if(!i)return a("No matching exon found","error"),!1;if(o&&n>=i.max)return a("Start location should be less than end location","error"),!1;if(!o&&n<=i.min)return a("End location should be greater than start location","error"),!1;if(s&&s.max+2>n)return a("Error while changing start location","error"),!1;if(l&&l.min-2<n)return a("Error while changing end location","error"),!1;const c=I(r,i.min,i.max,g);if(!c)return a("No matching exon feature found","error"),!1;const u=E(r,g);if(o&&n!==i.min){const t=new Et({typeName:"LocationStartChange",changedIds:[],changes:[],assembly:e});if(s)T(c,t,n);else{const e=r.min,i=r.parent;if(n<e)i&&n<i.min&&T(i,t,n),T(r,t,n),T(c,t,n);else if(n>e&&(T(c,t,n),T(r,t,n),i)){const[e]=j(i,r,n,g,o);i.min!=e&&T(i,t,e)}}u&&u.min>=i.min&&u.min<=i.max&&n>u.min&&T(u,t,n),d.submit(t).catch((()=>{a("Error updating feature exon start position","error")}))}if(!o&&n!==i.max){const t=new Tt({typeName:"LocationEndChange",changedIds:[],changes:[],assembly:e});if(l)N(c,t,n);else{const e=r.max,i=r.parent;if(n>e)i&&n>i.max&&N(i,t,n),N(r,t,n),N(c,t,n);else if(n<e&&(N(c,t,n),N(r,t,n),i)){const[,e]=j(i,r,n,g,o);i.max!=e&&N(i,t,e)}}u&&u.max>=i.min&&u.max<=i.max&&n<u.max&&N(u,t,n),d.submit(t).catch((()=>{a("Error updating feature exon end position","error")}))}return!0}const N=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldEnd:e.max,newEnd:n})},T=(e,t,n)=>{t.changedIds.push(e._id),t.changes.push({featureId:e._id,oldStart:e.min,newStart:n})},R=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(t.isTypeOf(i.type,"CDS")){if(r&&n===i.min){o=i;break}if(!r&&n===i.max){o=i;break}}return o},E=(e,t)=>{let n;for(const[,r]of e.children??[])if(t.isTypeOf(r.type,"CDS")){n=r;break}return n},I=(e,t,n,r)=>{let o;for(const[,i]of e.children??[])if(r.isTypeOf(i.type,"exon")&&t===i.min&&n===i.max){o=i;break}return o},j=(e,t,n,r,o)=>{const i=[],a=[];for(const[,s]of e.children?.entries()??[])r.isTypeOf(s.type,"transcript")&&(s._id===t._id?o?(i.push(n),a.push(s.max)):(a.push(n),i.push(s.min)):(i.push(s.min),a.push(s.max)));return[Math.min(...i),Math.max(...a)]},D=(e,t,n,r)=>{const{transcriptExonParts:o}=e;let i;for(const[,e]of o.entries())if(t.isTypeOf(e.type,"exon")){if(!r&&n>=e.min&&n<=e.max){i=e;break}if(r&&n>=e.min&&n<=e.max){i=e;break}}return i},O=(e,t,n,r)=>{const{transcriptExonParts:o,strand:i}=e;let a,s,l,c;for(const[e,i]of o.entries())if(t.isTypeOf(i.type,"exon")){if(r&&i.min===n){a=i,s=e;break}if(!r&&i.max===n){a=i,s=e;break}}if(a&&void 0!==s){if(1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(-1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){l=n;break}}if(1===i&&s<o.length-1)for(let e=s+1;e<o.length;e++){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}if(-1===i&&s>0)for(let e=s-1;e>=0;e--){const n=o[e];if(t.isTypeOf(n.type,"exon")){c=n;break}}}return{matchingExon:a,prevExon:l,nextExon:c}},F=(e,t)=>{let n="";if(t>0){const r=y[t-1];1===_?"intron"===r.type&&(n=c.getSequence(e.min-2,e.min)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.max,e.max+2)))}return n=n.toUpperCase(),[{spliceSite:n,color:"AG"===n?"green":"red"}]},M=(e,t)=>{let n="";if(t<y.length-1){const r=y[t+1];1===_?"intron"===r.type&&(n=c.getSequence(e.max,e.max+2)):"intron"===r.type&&(n=o.revcom(c.getSequence(e.min-2,e.min)))}return n=n.toUpperCase(),[{spliceSite:n,color:"GT"===n?"green":"red"}]},L=()=>{let e="";const[n]=m,r=n.toSorted((({min:e},{min:t})=>e-t));for(const t of r)e+=c.getSequence(t.min,t.max);-1===_&&(e=o.revcom(e));const a=[];for(let n=0;n<e.length;n+=3){const r=e.slice(n,n+3).toUpperCase(),l=o.defaultCodonTable[r]||"&";"ATG"===r?a.push(i.jsx(s.Typography,{component:"span",style:{backgroundColor:h?"lightgray":"yellow",cursor:"pointer",border:"1px solid black"},onClick:()=>{if(h)return;const e=P(n);e!==w&&1===_&&A(w,e,t,!0),e!==S&&-1===_&&A(S,e,t,!1)},children:l},n)):["TAA","TAG","TGA"].includes(r)?a.push(i.jsx(s.Typography,{style:{backgroundColor:"red",color:"white"},component:"span",children:l},n)):a.push(i.jsx(s.Typography,{component:"span",children:l},n))}return a},P=e=>{const[t]=m;let n=0;const r=t.toSorted((({min:e},{min:t})=>e-t));if(1===_)for(const t of r){const r=t.max-t.min;if(n+r>e)return t.min+(e-n);n+=r}else if(-1===_)for(let t=r.length-1;t>=0;t--){const o=r[t],i=o.max-o.min;if(n+i>e)return o.max-(e-n);n+=i}return 1===_?w:S};return i.jsxs("div",{children:[C&&i.jsx("div",{children:i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1}),i.jsx(s.Grid,1===_?{size:4,children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:w+1,onChangeCommitted:e=>A(w,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:h})}:{size:4,children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:S,onChangeCommitted:e=>A(S,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:h})}),i.jsx(s.Grid,{size:2,children:i.jsx(s.Typography,{component:"span",children:"CDS"})}),i.jsx(s.Grid,1===_?{size:4,children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:S,onChangeCommitted:e=>A(S,e,t,!1),style:{border:"1px solid black",borderRadius:5},disabled:h})}:{size:4,children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:w+1,onChangeCommitted:e=>A(w,e-1,t,!0),style:{border:"1px solid black",borderRadius:5},disabled:h})}),i.jsx(s.Grid,{size:1})]})}),i.jsxs("div",{style:{marginTop:5,marginBottom:10},children:[i.jsx("div",{style:{textAlign:"center"},children:i.jsx(s.Typography,{children:"Exons"})}),y.map(((e,n)=>i.jsx("div",{children:"exon"===e.type&&i.jsxs(s.Grid,{container:!0,justifyContent:"center",alignItems:"center",style:{textAlign:"center"},children:[i.jsx(s.Grid,{size:1,children:0!==n&&F(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))}),i.jsx(s.Grid,1===_?{size:4,style:{padding:0},children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>k(e.min,n-1,t,!0),disabled:h})}:{size:4,style:{padding:0},children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>k(e.max,n,t,!1),disabled:h})}),i.jsx(s.Grid,{size:2,children:i.jsx(Eu,{strand:t.strand})}),i.jsx(s.Grid,1===_?{size:4,style:{padding:0},children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:e.max,onChangeCommitted:n=>k(e.max,n,t,!1),disabled:h})}:{size:4,style:{padding:0},children:i.jsx(Nu,{margin:"dense",variant:"outlined",value:e.min+1,onChangeCommitted:n=>k(e.min,n-1,t,!0),disabled:h})}),i.jsx(s.Grid,{size:1,children:n!==y.length-1&&M(e,n).map(((e,t)=>i.jsx(s.Typography,{component:"span",color:e.color,children:e.spliceSite},t)))})]})},n)))]}),C&&i.jsx("div",{children:i.jsxs(s.Accordion,{children:[i.jsx(Ru,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Translation"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Tu,{children:i.jsx(s.Typography,{component:"span",ref:f,style:{maxHeight:120,overflowY:"scroll"},children:L()})}),i.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"row",alignItems:"center",gap:10},children:[i.jsx(s.Tooltip,{title:"Copy",children:i.jsx("button",{onClick:()=>{const e=f.current;e&&_u(e)},style:{border:"none",background:"none",padding:0},disabled:h,children:i.jsx(Cu,{style:{fontSize:15}})})}),i.jsx(s.Tooltip,{title:"Trim",children:i.jsx("button",{onClick:()=>{const e=L(),n=e.map((e=>e.props.children)).join("");if(n.startsWith("M")&&n.endsWith("*"))return;const r=[];for(const t of e)r.push({codonGenomicPos:t.key,sequenceLetter:t.props.children});if(0===r.length)return;const o=n.indexOf("M"),i=n.indexOf("*"),s=r[o].codonGenomicPos,l=r[i].codonGenomicPos;if(!s||!l)return;const c=P(s);let u=P(l);if(1===_){if(c>u)return void a("Start codon genomic location should be less than stop codon genomic location","error");let e;u+=3,c!==w&&(e=new Promise((e=>{A(w,c,t,!0,(()=>{e(!0)}))}))),u!==S&&(e?e.then((()=>{A(S,u,t,!1)})):A(S,u,t,!1))}if(-1===_){if(c<u)return void a("Start codon genomic location should be less than stop codon genomic location","error");let e;u-=3,c!==S&&(e=new Promise((e=>{A(S,c,t,!1,(()=>{e(!0)}))}))),u!==w&&(e?e.then((()=>{A(w,u,t,!0)})):A(w,u,t,!0))}a("Translation sequence trimmed to start and stop codons","success")},style:{border:"none",background:"none",padding:0},disabled:h,children:i.jsx(Au,{style:{fontSize:15}})})})]})]})]})})]})})),ju=yu(s.TableCell)((()=>({fontWeight:"bold"}))),Du=p.observer((function(e){const{feature:t}=e,n=xa(t),r=wa(t);return i.jsx(s.Table,{size:"small",sx:{fontSize:"0.75rem","& .MuiTableCell-root":{padding:"4px"}},children:i.jsxs(s.TableBody,{children:[""!==n&&i.jsxs(s.TableRow,{children:[i.jsx(ju,{children:"Name"}),i.jsx(s.TableCell,{children:xa(t)})]}),""!==r&&i.jsxs(s.TableRow,{children:[i.jsx(ju,{children:"ID"}),i.jsx(s.TableCell,{children:wa(t)})]}),i.jsxs(s.TableRow,{children:[i.jsx(ju,{children:"Type"}),i.jsx(s.TableCell,{children:t.type})]}),i.jsxs(s.TableRow,{children:[i.jsx(ju,{children:"Location"}),i.jsxs(s.TableCell,{children:[e.refName,":",t.min,"..",t.max]})]}),i.jsxs(s.TableRow,{children:[i.jsx(ju,{children:"Strand"}),i.jsx(s.TableCell,{children:(o=t.strand,1===o?"Forward":-1===o?"Reverse":"")})]})]})});var o})),Ou=ma()((e=>({root:{padding:e.spacing(2)}}))),Fu=yu(s.AccordionSummary)((()=>({minHeight:30,maxHeight:30,"&.Mui-expanded":{minHeight:30,maxHeight:30}})));function Mu(e){return null}const Lu=p.observer((function(e){const{classes:t}=Ou(),n=["summary","location"],[r,a]=u.useState(n),{model:c}=e,{assembly:d,feature:f,refName:h}=c;u.useEffect((()=>{a(n)}),[f]);const p=o.getSession(c),{pluginManager:g}=o.getEnv(p),m=o.getSession(c),y=m.apolloDataStore.assemblies.get(d),{internetAccounts:_}=l.getRoot(p),v=_.find((e=>"ApolloInternetAccount"===e.type)),b=["admin","user"].includes((v?v.role:"admin")??"");if(!f||!y)return null;const x=y.getByRefName(h);if(!x)return null;const{max:w,min:S}=f;function C(e,t){a(e?[...r,t]:r.filter((e=>e!==t)))}x.getSequence(S,w)||m.apolloDataStore.loadRefSeq([{assemblyName:d,refName:h,start:S,end:w}]);const A=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSummary",Mu,{feature:f,session:p}),k=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSummary",Mu,{feature:f,session:p}),N=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideLocation",Mu,{feature:f,session:p}),T=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterLocation",Mu,{feature:f,session:p}),R=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideAttributes",Mu,{feature:f,session:p}),E=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterAttributes",Mu,{feature:f,session:p}),I=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-InsideSequence",Mu,{feature:f,session:p}),j=g.evaluateExtensionPoint("Apollo-TranscriptDetailsCustomComponent-AfterSequence",Mu,{feature:f,session:p});return i.jsxs("div",{className:t.root,children:[i.jsxs(s.Accordion,{expanded:r.includes("summary"),onChange:(e,t)=>{C(t,"summary")},children:[i.jsx(Fu,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel1-content",id:"panel1-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Summary"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Du,{feature:f,refName:h}),i.jsx(A,{session:p,feature:f})]})]}),i.jsx(k,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("location"),onChange:(e,t)=>{C(t,"location")},children:[i.jsx(Fu,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel2-content",id:"panel2-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Location"})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Iu,{feature:f,refName:h,session:m,assembly:y._id||""}),i.jsx(N,{session:p,feature:f})]})]}),i.jsx(T,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("attrs"),onChange:(e,t)=>{C(t,"attrs")},children:[i.jsx(Fu,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel3-content",id:"panel3-header",children:i.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[i.jsxs(s.Typography,{component:"span",fontWeight:"bold",children:["Attributes"," "]}),i.jsx(s.Tooltip,{title:"Separate multiple values for the attribute with commas",children:i.jsx(ya,{style:{color:"white",fontSize:15,marginLeft:10}})})]})}),i.jsxs(s.AccordionDetails,{children:[i.jsx(Jc,{feature:f,session:m,assembly:y._id||"",editable:b}),i.jsx(R,{session:p,feature:f})]})]}),i.jsx(E,{session:p,feature:f}),i.jsxs(s.Accordion,{style:{marginTop:5},expanded:r.includes("sequence"),onChange:(e,t)=>{C(t,"sequence")},children:[i.jsx(Fu,{expandIcon:i.jsx(Fc,{style:{color:"white"}}),"aria-controls":"panel4-content",id:"panel4-header",children:i.jsx(s.Typography,{component:"span",fontWeight:"bold",children:"Sequence"})}),i.jsxs(s.AccordionDetails,{children:[r.includes("sequence")&&i.jsx(Su,{feature:f,session:m,assembly:y._id||"",refName:h}),i.jsx(I,{session:p,feature:f})]})]}),i.jsx(j,{feature:f,session:p})]})})),Pu=n.ConfigurationSchema("LinearApolloDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),Bu=ma()({highlighted:{background:"orange"}}),qu=({highlight:e,text:t})=>{const{classes:n}=Bu();if(!e)return i.jsx(i.Fragment,{children:t});const r=t.split(e);if(1===r.length)return i.jsx(i.Fragment,{children:t});const o=[];for(let t=0;t<r.length-1;t++)o.push(r[t],i.jsx("span",{className:n.highlighted,children:e}));return i.jsxs(i.Fragment,{children:[o,r.at(-1)]})},Uu=p.observer((function({feature:e,filterText:t}){const n=[...e.attributes.entries()].map((([e,t])=>{if(e.startsWith("gff_")){const n=e.slice(4);return[n.charAt(0).toUpperCase()+n.slice(1),l.getSnapshot(t)]}return"_id"===e?["ID",l.getSnapshot(t)]:[e,l.getSnapshot(t)]})).filter((([e])=>e)).map((([e,t])=>`${e}=${Array.isArray(t)?t.join(", "):t}`)).join(", ");return i.jsx(qu,{text:n,highlight:t})})),$u=ma()((e=>({inputWrapper:{position:"relative"},hiddenWidthSpan:{padding:e.spacing(.5),color:"transparent"},numberTextInput:{border:"none",background:"inherit",font:"inherit",position:"absolute",width:"100%",left:0}}))),zu=p.observer((function({initialValue:e,notifyError:t,onChangeCommitted:n}){const[r,o]=u.useState(e),[a,s]=u.useState(!1),[l,c]=u.useState(null),{classes:d}=$u();return u.useEffect((()=>{e!==r&&o(e)}),[e]),u.useEffect((()=>{a&&(l?.blur(),s(!1))}),[a,l]),i.jsxs("span",{className:d.inputWrapper,children:[i.jsx("span",{className:d.hiddenWidthSpan,"aria-hidden":!0,children:r}),i.jsx("input",{type:"text",value:r,className:d.numberTextInput,onChange:function(e){const t=Number(e.target.value);Number.isNaN(t)||o(t)},onKeyDown:t=>{"Enter"===t.key?l?.blur():"Escape"===t.key&&(o(e),s(!0))},onBlur:()=>{r!==e&&n(r).catch(t)},ref:e=>{c(e)}})]})})),Hu=ma()((e=>({typeContent:{display:"inline-block",width:"174px",height:"100%",cursor:"text"},feature:{td:{position:"relative",verticalAlign:"top",paddingLeft:"0.5em"}},arrow:{display:"inline-block",width:"1.6em",textAlign:"center",cursor:"pointer"},arrowExpanded:{transform:"rotate(90deg)"},hoveredFeature:{backgroundColor:e.palette.action.hover},typeInputElement:{border:"none",background:"none"},typeErrorMessage:{color:"red"}})));function Gu(e,t){const{changeManager:n,getAssemblyId:r,regions:i,selectedFeature:a,session:s,setSelectedFeature:c,filteredTranscripts:u,updateFilteredTranscripts:d}=e;return function(e,t,n,r,i,a,s,c,u){const d=function(e){const{internetAccounts:t}=l.getParent(e);return t.find((e=>"ApolloInternetAccount"===e.type))}(a),f=d?d.role:"admin",h=!(f&&["admin","user"].includes(f)),p=[];if(e){const l=e.attributes.get("gff_id")?.toString(),f=n(t.assemblyName),g=n(t.assemblyName);p.push({label:"Edit feature details",onClick:()=>{const n=a.addWidget("ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget",{feature:e,assembly:g,refName:t.refName});a.showWidget(n)}},{label:"Add child feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Us,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:f,internetAccount:d}]))}},{label:"Copy features and annotations",disabled:h,onClick:()=>{a.queueDialog((t=>[Gs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g}]))}},{label:"Delete feature",disabled:h,onClick:()=>{a.queueDialog((t=>[Vs,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge transcripts",disabled:h,onClick:()=>{a.queueDialog((t=>[Zl,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Merge exons",disabled:h,onClick:()=>{a.queueDialog((t=>[Yl,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Split exon",disabled:h,onClick:()=>{a.queueDialog((t=>[lc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}});const{featureTypeOntology:m}=a.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");(m.isTypeOf(e.type,"transcript")||m.isTypeOf(e.type,"pseudogenic_transcript"))&&o.isSessionModelWithWidgets(a)&&p.push({label:"Edit transcript details",onClick:()=>{const n=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:e,assembly:g,changeManager:s,refName:t.refName});a.showWidget(n)}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((t=>[cc,{session:a,handleClose:()=>{t()},changeManager:s,sourceFeature:e,sourceAssemblyId:g,selectedFeature:r,setSelectedFeature:i}]))}},{label:"Visible",type:"checkbox",checked:!l||!c.includes(l),onClick:()=>{if(l){const e=c.includes(l)?c.filter((e=>e!==l)):[...c,l];u(e)}}})}return p}(t,i[0],r,a,c,s,n,u,d)}const Vu=p.observer((function e({depth:t,feature:n,isHovered:r,isSelected:o,model:a,selectedFeatureClass:s,setContextMenu:l}){const{classes:c}=Hu(),{changeManager:u,hoveredFeature:d,selectedFeature:f,session:h,tabularEditor:p}=a,{featureCollapsed:g,filterText:m}=p,{_id:y,children:_,max:v,min:b,strand:x,type:w}=n,S=!g.get(y),C=e=>{h.notify(e.message,"error")};return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{onMouseEnter:e=>{a.setHoveredFeature({feature:n,bp:b})},className:c.feature+(o?` ${s}`:r?` ${c.hoveredFeature}`:""),onClick:e=>{e.stopPropagation(),a.setSelectedFeature(n)},onDoubleClick:()=>{a.setSelectedFeature(n),function(e,t){e.lgv.navTo(al(t,.1,e.lgv.totalBp))}(a,n)},onContextMenu:e=>(e.preventDefault(),l({position:{left:e.clientX+2,top:e.clientY-6},items:Gu(a,n)}),!1),children:[i.jsxs("td",{style:{whiteSpace:"nowrap",borderLeft:2*t+"em solid transparent"},children:[_?.size?i.jsx("div",{onClick:e=>{e.stopPropagation(),p.setFeatureCollapsed(y,S)},className:c.arrow+(S?` ${c.arrowExpanded}`:""),children:"❯"}):null,i.jsx("div",{className:c.typeContent,children:i.jsx(qs,{session:h,ontologyName:"Sequence Ontology",style:{width:170},value:w,filterTerms:Cs,fetchValidTerms:Wu.bind(null,n),renderInput:e=>i.jsxs("div",{ref:e.InputProps.ref,children:[i.jsx("input",{type:"text",...e.inputProps,className:c.typeInputElement,style:{width:170}}),e.error?i.jsx("div",{className:c.typeErrorMessage,children:e.errorMessage??"unknown error"}):null]}),onChange:(e,t)=>{t&&function(e,t,n,r){const o=t._id,i=new zt({typeName:"TypeChange",changedIds:[o],featureId:o,oldType:String(n),newType:String(r),assembly:t.assemblyId});return e.submit(i)}(u,n,e,t).catch(C)}})})]}),i.jsx("td",{children:i.jsx(zu,{initialValue:b+1,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Et({typeName:"LocationStartChange",changedIds:[o],featureId:o,oldStart:n,newStart:r,assembly:t.assemblyId});return e.submit(i)}(u,n,b,e-1)})}),i.jsx("td",{children:i.jsx(zu,{initialValue:v,notifyError:C,onChangeCommitted:e=>function(e,t,n,r){const o=t._id,i=new Tt({typeName:"LocationEndChange",changedIds:[o],featureId:o,oldEnd:n,newEnd:r,assembly:t.assemblyId});return e.submit(i)}(u,n,v,e)})}),i.jsx("td",{children:1===x?"+":-1===x?"-":void 0}),i.jsx("td",{children:i.jsx(Uu,{filterText:m,feature:n})})]}),S&&_?[..._.entries()].filter((e=>{if(!m)return!0;const[,t]=e;return JSON.stringify(t).includes(m)})).map((([n,r])=>i.jsx(e,{isHovered:d?.feature._id===r._id,isSelected:f?._id===r._id,selectedFeatureClass:s,depth:(t||0)+1,feature:r,model:a,setContextMenu:l},n))):null]})}));async function Wu(e,t,n){const{parent:r}=e;if(r){const e=(await t.getTermsWithLabelOrSynonym(r.type,{includeSubclasses:!1})).filter(Cs);if(e.length>0)return await t.getClassesThat("part_of",e)}}const Ju=ma()((e=>({scrollableTable:{width:"100%",height:"100%",th:{position:"sticky",top:0,zIndex:2,textAlign:"left",background:e.palette.background.paper,paddingTop:"3.2em"},td:{whiteSpace:"normal"}},selectedFeature:{backgroundColor:e.palette.action.selected}}))),Ku=p.observer((function({model:e}){const{hoveredFeature:t,seenFeatures:n,selectedFeature:r,tabularEditor:o}=e,a=s.useTheme(),{classes:l}=Ju(),c=u.useRef(null),[d,f]=u.useState(null),{filterText:p}=o;return u.useEffect((()=>{const e=c.current;if(e&&r){const t=e.querySelector(`.${l.selectedFeature}`);if(t){const n=e.scrollTop,r=t.offsetTop-25;r>n&&r<n+e.offsetHeight||e.scroll({top:r-40,behavior:"smooth"})}}}),[r,n,l.selectedFeature]),i.jsxs("div",{ref:c,style:{width:"100%",overflowY:"auto",height:"100%"},children:[i.jsxs("table",{className:l.scrollableTable,children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"Strand"}),i.jsx("th",{children:"Attributes"})]})}),i.jsx("tbody",{children:[...n.entries()].filter((e=>{if(!p)return!0;const[,t]=e;return JSON.stringify(t).includes(p)})).sort(((e,t)=>e[1].min-t[1].min)).map((([n,o])=>i.jsx(Vu,{isSelected:r?._id===n,isHovered:t?.feature._id===n,selectedFeatureClass:l.selectedFeature,feature:o,model:e,depth:0,setContextMenu:f},n)))})]}),i.jsx(h.Menu,{open:Boolean(d),onMenuItemClick:(e,t)=>{t(),f(null)},onClose:()=>{f(null)},slotProps:{transition:{onExit:()=>{f(null)}}},style:{zIndex:a.zIndex.tooltip},menuItems:d?.items??[],anchorReference:"anchorPosition",anchorPosition:d?.position})]})}));var Yu=a.createSvgIcon(i.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),Xu=a.createSvgIcon(i.jsx("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");const Zu=ma()({toolbar:{width:"100%",display:"flex",paddingRight:"2em",flexDirection:"row",justifyContent:"space-between",position:"absolute",zIndex:4},filterText:{}}),Qu=p.observer((function({model:e}){const t=e.tabularEditor,{classes:n}=Zu();return i.jsxs("div",{className:n.toolbar,children:[i.jsx(s.Tooltip,{title:"Collapse all",children:i.jsx(s.IconButton,{"aria-label":"collapse",sx:{marginTop:0},onClick:t.collapseAllFeatures,children:i.jsx(Xu,{})})}),i.jsx(s.TextField,{className:n.filterText,label:"Filter features",value:t.filterText,sx:{marginTop:0},variant:"outlined",onChange:e=>{t.setFilterText(e.target.value)},slotProps:{input:{endAdornment:i.jsx(s.InputAdornment,{position:"end",children:i.jsx(s.IconButton,{onClick:()=>{t.clearFilterText()},children:i.jsx(Yu,{})})})}}})]})}));function ed(e){e.stopPropagation()}const td=p.observer((function({model:e}){return e.tabularEditor.isShown?i.jsxs("div",{onMouseDown:ed,onClick:ed,style:{width:"100%",height:"100%",position:"relative"},children:[i.jsx(Qu,{model:e}),i.jsx(Ku,{model:e})]}):null})),nd=l.types.model("TabularEditor",{isShown:!0,featureCollapsed:l.types.map(l.types.boolean),filterText:""}).actions((e=>({setFeatureCollapsed(t,n){e.featureCollapsed.set(t,n)},setFilterText(t){e.filterText=t},clearFilterText(){e.filterText=""},collapseAllFeatures(){const t=l.getParent(e);for(const[n]of t.seenFeatures.entries())e.featureCollapsed.set(n,!0)},togglePane(){e.isShown=!e.isShown},hidePane(){e.isShown=!1},showPane(){e.isShown=!0}})));function rd(e,t,n){const{lgv:r}=e,{bpPerPx:o,offsetPx:i}=r;return n.offsetPx-i+(n.reversed?n.end-t.max:t.min-n.start)/o}function od(e,t,n,r){const{apolloRowHeight:o,lgv:i}=e,{bpPerPx:a}=i;return[n*o,Math.round(rd(e,t,r)),Math.round((t.max-t.min)/a),o]}function id(e,t,n,r,o,i,a,l){const c=function(e,t,n){const{theme:r}=e;switch(n){case"select":return r.palette.action.disabled;case"hover":return r.palette.action.focus;case"highlight":{const{attributes:e}=t,n=e.get("apollo_color");return n?.[0]}}}(e,a,l);c&&(t.fillStyle=s.alpha(c,.3),t.fillRect(n,r,o,i))}function ad(e,t,n,r,o,i){e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t+.5,n+.5,r-1,o-1)}function sd(e,t,n){const{refName:r,regionNumber:o,x:i}=e,{lgv:a}=n,{offsetPx:s}=a,l=a.bpToPx({refName:r,coord:t.min,regionNumber:o}),c=a.bpToPx({refName:r,coord:t.max,regionNumber:o});if(void 0!==l&&void 0!==c){const e=l.offsetPx-s,t=c.offsetPx-s;if(Math.abs(t-e)<8)return;if(Math.abs(e-i)<4)return"min";if(Math.abs(t-i)<4)return"max"}}function ld(e,t,n,r,o,i){const[a,s,l,c]=od(e,n,r,o);id(e,t,s,a,l,c,n,i)}const cd={draw:function(e,t,n,r,o,i){const{selectedFeature:a,theme:s}=e,[l,c,u,d]=od(e,n,r,i);u>2&&(t.fillStyle=s.palette.background.default,t.fillRect(c,l,u,d)),ad(t,c,l,u,d,s.palette.text.primary),rl(n,a)&&ld(e,t,n,r,i,"select")},drawDragPreview:function(e,t,n,r,o){const{apolloDragging:i,theme:a}=e;if(!i)return;const{current:l,start:c}=i,u=Math.min(l.bp,c.bp),d=Math.max(l.bp,c.bp),[f,h,p,g]=od(e,{min:u,max:d},r,o);t.fillStyle=s.alpha(a.palette.info.main,.2),t.fillRect(h,f,p,g),t.setLineDash([6]),ad(t,h,f,p,g,a.palette.info.main)},drawOverlay:ld,getContextMenuItems:function(e){const{hoveredFeature:t}=e;return t?il(e,t.feature):[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function ud(e,t,n,r,i,a){const{apolloRowHeight:s,canvasPatterns:l,theme:c}=e,[u,d,f]=od(e,n,i,a),h=Math.round(s/2);if(f>2){const e=o.getFrame(n.min,n.max,r??1,n.phase),i=c.palette.framesCDS.at(e)?.main;t.fillStyle=i??"black",t.fillRect(d,u,f,s);const p=l.forward,g=l.backward;if(p&&g&&r){const{reversed:e}=a,n=e?-1:1,[o,i]=r*n==1?[p,g]:[g,p];t.fillStyle=o,t.fillRect(d,u,f,h),t.fillStyle=i,t.fillRect(d,u+h,f,h)}}ad(t,d,u,f,s,c.palette.text.primary)}function dd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=od(e,n,r,o);id(e,t,l,s,c,1*a,n,i)}const{drawDragPreview:fd}=cd,hd={draw:function(e,t,n,r,o,i){const a=n.parent;if(!a)return void cd.draw(e,t,n,r,0,i);const{cdsLocations:s}=a,l=s.find((e=>{const t=e.at(1===n.strand?0:-1)?.min,r=e.at(1===n.strand?-1:0)?.max;return n.min===t&&n.max===r}));if(!l)return;for(const o of l)ud(e,t,o,n.strand,r,i);const{selectedFeature:c}=e;rl(n,c)&&dd(e,t,n,r,i,"select")},drawDragPreview:fd,drawOverlay:dd,getContextMenuItems:function(){return[]},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function pd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[,s,l]=od(e,n,r,o),c=Math.round(.6*a),u=Math.round(c/2);id(e,t,s,Math.round(u/2)+r*a,l,c,n,i)}const{drawDragPreview:gd}=cd,md={draw:function(e,t,n,r,o,i){const{apolloRowHeight:a,canvasPatterns:s,selectedFeature:l,theme:c}=e,[,u,d]=od(e,n,r,i),f=Math.round(.6*a),h=Math.round(f/2),p=Math.round(h/2)+r*a;if(d>2){t.fillStyle="rgb(211,211,211)",t.fillRect(u,p,d,f);const e=s.forward,r=s.backward,{strand:o}=n;if(e&&r&&o){const{reversed:n}=i,a=n?-1:1,[s,l]=o*a==1?[e,r]:[r,e];t.fillStyle=s,t.fillRect(u,p,d,h),t.fillStyle=l,t.fillRect(u,p+h,d,h)}}ad(t,u,p,d,f,c.palette.text.primary),rl(n,l)&&pd(e,t,n,r,i,"select")},drawDragPreview:gd,drawOverlay:pd,getContextMenuItems:function(e,t){const{apolloInternetAccount:n,changeManager:r,regions:i,selectedFeature:a,session:s}=e,[l]=i,c=e.getAssemblyId(l.assemblyName),u="admin"===(n?n.role:"admin"),d=[],f=Qs(t,e),h=o.getContainingView(e);if(f.upstream){const n=f.upstream;d.push({label:"Go to upstream exon",icon:el(t.strand,!0,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}if(f.downstream){const n=f.downstream;d.push({label:"Go to downstream exon",icon:el(t.strand,!1,h.displayedRegions.at(0)?.reversed),onClick:()=>{h.navTo(al(n,.1,h.totalBp)),Ws(e,n)}})}return d.push({label:"Merge exons",disabled:!u,onClick:()=>{s.queueDialog((n=>[Yl,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:!u,onClick:()=>{s.queueDialog((n=>[lc,{session:s,handleClose:()=>{n()},changeManager:r,sourceFeature:t,sourceAssemblyId:c,selectedFeature:a,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),d},getLayout:function(e,t){return{byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max}},isDraggable:!0};function yd(e,t){return vd(e,t).byRow.length}function _d(e,t,n,r,o,i,a){if(a>0)return;const{apolloRowHeight:s}=e,[l,c,u]=od(e,n,r,o);id(e,t,c,l,u,yd(e,n)*s,n,i)}function vd(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:bd}=cd,xd={draw:function(e,t,r,o,i,a){if(i>0)return;const{apolloRowHeight:l,theme:c,selectedFeature:u,session:d}=e,[f,h,p]=od(e,r,o,a),g=yd(e,r)*l;if(p>2){let e=n.readConfObject(d.getPluginConfiguration(),"geneBackgroundColor",{featureType:r.type});e=s.alpha(c.palette.background.paper,.6),t.fillStyle=e,t.fillRect(h,f,p,g)}ad(t,h,f,p,g,c.palette.text.primary),rl(r,u)&&_d(e,t,r,o,a,"select",i)},drawDragPreview:bd,drawOverlay:_d,getContextMenuItems:function(){return[]},getLayout:vd,isDraggable:!1};function wd(e,t){return Cd(e,t).byRow.length}function Sd(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=od(e,n,r,o);id(e,t,l,s,c,wd(e,n)*a,n,i)}function Cd(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;const{getGlyph:o}=e;for(const[,i]of r){const r=o(i).getLayout(e,i),a=n.byRow.length;for(const[e,o]of r.byRow.entries())n.byRow.push([{feature:t,rowInFeature:a+e},...o]);for(const e of r.byFeature.entries()){const[t,r]=e;n.byFeature.set(t,r+a)}}return n}const{drawDragPreview:Ad}=cd,kd={draw:function(e,t,n,r,o,i){if(o>0)return;const{apolloRowHeight:a,selectedFeature:l,theme:c}=e,[u,d,f]=od(e,n,r,i),h=wd(e,n)*a;f>2&&(t.fillStyle=s.alpha(c.palette.background.paper,.6),t.fillRect(d,u,f,h)),ad(t,d,u,f,h,c.palette.text.primary),cd.draw(e,t,n,r,0,i),rl(n,l)&&Sd(e,t,n,r,i,"select")},drawDragPreview:Ad,drawOverlay:Sd,getContextMenuItems:function(){return[]},getLayout:Cd,isDraggable:!0};function*Nd(e,t,n=1){if(e!==t)if(e<t)for(let r=e;r<t;r+=n)yield r;else for(let r=e;r>t;r-=n)yield r}function Td(e,t,n,r,o,i){const{apolloRowHeight:a}=e,[s,l,c]=od(e,n,r,o),u=a*function(e,t){return Rd(e,t).byRow.length}(e,n);id(e,t,l,s,c,u,n,i)}function Rd(e,t){const n={byFeature:new Map([[t._id,0]]),byRow:[[{feature:t,rowInFeature:0}]],min:t.min,max:t.max},{children:r}=t;if(!r)return n;n.byRow=[];const o=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>Ys(e,r)))}(e,t),i=function(e,t){const{children:n}=t;if(!n)return[];const{session:r}=e;return[...n.values()].filter((e=>!Ys(e,r)))}(e,t);if(n.byFeature.set(t._id,0),0===i.length){const e=[];e.push({feature:t,rowInFeature:0});for(const t of o)e.push({feature:t,rowInFeature:0}),n.byFeature.set(t._id,0);return n.byRow.push(e),n}const{getGlyph:a,session:s}=e;let l=0;for(const[r,c]of i.entries()){const i=[];if(i.push({feature:t,rowInFeature:r+l}),Xs(c,s)){for(const e of o)i.push({feature:e,rowInFeature:l}),n.byFeature.set(e._id,l);i.push({feature:c,rowInFeature:l}),n.byFeature.set(c._id,l)}else{const t=a(c).getLayout(e,c).byRow.length;for(let e=0;e<t;e++)i.push({feature:c,rowInFeature:e}),n.byFeature.set(c._id,e);l+=t-1}n.byRow.push(i)}return n}const{drawDragPreview:Ed}=cd,Id={draw:function(e,t,n,r,o,i){!function(e,t,n,r,o){const{apolloRowHeight:i,lgv:a,theme:s}=e,{bpPerPx:l}=a,{reversed:c}=o,u=Math.round(rd(e,n,o)),d=Math.round(n.length/l),f=Math.round(i/2)+r*i;t.strokeStyle=s.palette.text.primary;const{strand:h=1}=n;t.beginPath();const p=h*(c?-1:1);let g=u-(-1===p?5:0),m=u+d+(-1===p?0:5);g=Math.max(g,0),m=Math.min(m,globalThis.innerWidth),t.moveTo(g,f),t.lineTo(m,f);const y=g+(-1===p?0:3),_=m-(-1===p?3:0),v=-1===p?3:-3,b=-1===p?Nd(y,_,20):Nd(_,y,20);for(const e of b)t.moveTo(e+v,f+v),t.lineTo(e,f),t.lineTo(e+v,f-v);t.stroke()}(e,t,n,r,i);const{selectedFeature:a}=e;rl(n,a)&&Td(e,t,n,r,i,"select")},drawDragPreview:Ed,drawOverlay:Td,getContextMenuItems:function(e,t){const{changeManager:n,regions:r,selectedFeature:i,session:a}=e,[s]=r,l=e.getAssemblyId(s.assemblyName),c=[];return o.isSessionModelWithWidgets(a)&&c.splice(1,0,{label:"Open transcript editor",onClick:()=>{const e=a.addWidget("ApolloTranscriptDetails","apolloTranscriptDetails",{feature:t,assembly:l,changeManager:n,refName:s.refName});a.showWidget(e)}}),c.push({label:"Merge transcript",onClick:()=>{a.queueDialog((r=>[Zl,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Duplicate feature",onClick:()=>{a.queueDialog((r=>[cc,{session:a,handleClose:()=>{r()},changeManager:n,sourceFeature:t,sourceAssemblyId:l,selectedFeature:i,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}}),c},getLayout:Rd,isDraggable:!1};var jd=a.createSvgIcon(i.jsx("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M10 17H5v-2h5zm0-4H5v-2h5zm0-4H5V7h5zm4.82 6L12 12.16l1.41-1.41 1.41 1.42L17.99 9l1.42 1.42z"}),"FactCheck"),Dd=a.createSvgIcon(i.jsx("path",{d:"m19.07 4.93-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07"}),"TrackChanges");const Od=p.observer((function({featureTypes:e,handleClose:t,onUpdate:n,session:r}){const[o,a]=u.useState(""),[l,c]=u.useState(e);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-features-dialog",title:"Filter features by type",handleClose:t,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the feature types you want to display in the apollo track"}),i.jsxs(s.Grid,{container:!0,spacing:2,children:[i.jsx(s.Grid,{size:8,children:i.jsx(qs,{session:r,ontologyName:"Sequence Ontology",style:{width:"100%"},value:o,filterTerms:Cs,renderInput:e=>i.jsx(s.TextField,{...e,label:"Feature type",variant:"outlined",fullWidth:!0}),onChange:(e,t)=>{t&&(e=>{a(e)})(t)}})}),i.jsx(s.Grid,{size:4,children:i.jsx(s.Button,{variant:"contained",onClick:()=>{if(o){if(l.includes(o))return;n([...l,o]),c([...l,o])}},disabled:!o,style:{marginTop:9},size:"medium",children:"Add"})})]}),l.length>0&&i.jsxs("div",{children:[i.jsx("hr",{}),i.jsxs("div",{style:{width:300},children:[i.jsx(s.DialogContentText,{children:"Selected feature types:"}),i.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:l.map((e=>i.jsx(s.Chip,{label:e,onDelete:()=>{(e=>{const t=l.filter((t=>t!==e));n(t),c(t)})(e)}},e)))})]})]})]})})})),Fd=p.observer((function({model:e,handleClose:t}){const[n,r]=u.useState(`${e.zoomThresholdSetting}`);return i.jsx(h.Dialog,{open:!0,onClose:t,title:"Edit zoom threshold setting",children:i.jsxs(s.DialogContent,{children:[i.jsx(s.Typography,{children:"The zoom level in base pairs (bp) per pixel at which features are rendered in this Annotations track. Increasing the value will allow features to render when zooming out, but might impact performance."}),i.jsx(s.TextField,{label:"Threshold value (bpPerPx)",value:n,onChange:e=>{r(e.target.value)}}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",onClick:()=>{e.setZoomThresholdSetting({zoomThreshold:+n}),t()},children:"Submit"}),i.jsx(s.Button,{variant:"contained",color:"secondary",onClick:()=>{t()},children:"Cancel"})]})]})})})),Md=ma()((e=>({canvasContainer:{position:"relative",left:0},canvas:{position:"absolute",left:0},center:{display:"flex",justifyContent:"center"},ellipses:{textOverflow:"ellipsis",overflow:"hidden"},avatar:{position:"static",height:"100%",width:"100%",overflow:"visible",color:e.palette.warning.light,backgroundColor:e.palette.warning.contrastText},box:{position:"absolute",overflow:"visible"},badge:{display:"inline-block"},loading:{position:"absolute",right:e.spacing(3),zIndex:10,pointerEvents:"none",textAlign:"right"},locked:{position:"absolute",right:e.spacing(3),top:e.spacing(6),zIndex:1,pointerEvents:"none",textAlign:"right"}})));function Ld(e,t,n){const r=new Map;for(const t of e)(r.get(t.message)??r.set(t.message,[]).get(t.message)).push(t);const o=[];for(const[e,n]of r.entries()){if(0===n.length)continue;n.sort(((e,t)=>e.start-t.start));let r=[n[0]],i=n[0].start,a=n[0].start+t;const s=()=>{const t=r.map((e=>e.start)).sort(((e,t)=>e-t)),n=Math.floor(t.length/2),s=r[0].ids;o.push({_id:r[0]._id,message:e,start:t.length%2?t[n]:(t[n-1]+t[n])/2,count:r.length,members:[...r],range:{min:i,max:a},featureIds:s})};for(let e=1;e<n.length;e++){const o=n[e],l=o.start,c=l+t;l<=a?(r.push(o),l<i&&(i=l),c>a&&(a=c)):(s(),r=[o],i=l,a=c)}s()}return o.sort(((e,t)=>e.message.localeCompare(t.message)||e.start-t.start)),o}function Pd(e,t,n){return"M"===e?t.palette.startCodon:"*"===e?n?t.palette.text.primary:t.palette.stopCodon:void 0}function Bd(e,t){const n=e.toUpperCase();return"A"===n||"C"===n||"G"===n||"T"===n?t.palette.bases[n].main.toString():"lightgray"}function qd(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloDisplay").props({type:l.types.literal("LinearApolloDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string),loadingState:!1}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?400:e.graphical?100:200},get loading(){return e.loadingState},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setLoading(t){e.loadingState=t},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showCheckResults:a}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Check Results",type:"checkbox",checked:a,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[Fd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const n=e.session;e.session.queueDialog((r=>[Od,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}},{label:"Export annotations",icon:$l,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const o=e.session;o.queueDialog((e=>[zl,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Change Log",icon:Dd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const o=e.session;o.queueDialog((e=>[tc,{session:o,handleClose:()=>{e()},assembly:r}]))}},{label:"View Check Results",icon:jd,onClick:()=>{const[t]=e.regions,{assemblyName:n}=t,r=e.getAssemblyId(n);if(!r)return;const o=e.session;o.queueDialog((e=>[ic,{session:o,handleClose:()=>{e()},assembly:r}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.setLoading(!0),e.session.apolloDataStore.loadFeatures(e.regions).then((()=>{setTimeout((()=>{e.setLoading(!1)}),1e3)})))}),{name:"LinearApolloDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloDisplayLayouts").props({cleanupBoundary:2e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({getAnnotationFeatureById:t=>e.seenFeatures.get(t),getGlyph:t=>Js(t,e.session)?xd:Ks(t,e.session)?Id:Ys(t,e.session)?md:Xs(t,e.session)?hd:t.children?.size?kd:cd}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({getCanonicalRefName(t,n){const{assemblyManager:r}=e.session,o=r.get(t);if(!o)throw new Error("no assembly in layout");const i=o.getCanonicalRefName(n);if(!i)throw new Error("no canonical refName in layout");return i}}))).views((e=>({isFeatureDisplayed(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return e.lgv.displayedRegions.some((r=>{const{end:i,refName:a,start:s}=r;return!(e.filteredFeatureTypes.length>0&&!e.filteredFeatureTypes.includes(t.type)||n!==a||!o.doesIntersect2(s,i,t.min,t.max))}))}}))).views((e=>({get layouts(){const t=new Map;for(const[n,r]of e.seenFeatures.entries()){if(!l.isAlive(r)){e.deleteSeenFeature(n);continue}if(!e.isFeatureDisplayed(r))continue;const i=e.getGlyph(r).getLayout(e,r),a=e.getCanonicalRefName(r.assemblyId,r.refSeq);let s=t.get(r.assemblyId);s||(s=new Map,t.set(r.assemblyId,s));const c=s.get(a);if(!c){s.set(a,i);continue}let u=0;e:for(;;){let e=c.byRow.at(u);if(!e){c.byRow.push(...i.byRow);for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}const t=u+i.byRow.length-1;let n=u;for(;e&&u<=t;){for(const t of e.values())if(o.doesIntersect2(i.min,i.max,t.feature.min,t.feature.max)){u+=1;continue e}n+=1,e=c.byRow.at(n)}for(let e=0;e<i.byRow.length;e++){const t=c.byRow.at(u+e);t?t.push(...i.byRow[e]):c.byRow.push(i.byRow[e])}for(const e of i.byFeature.entries()){const[t,n]=e;c.byFeature.set(t,n+u)}c.min=Math.min(c.min,i.min),c.max=Math.max(c.max,i.max);break e}}return t},getRowForFeature(t){const n=e.getCanonicalRefName(t.assemblyId,t.refSeq);return this.layouts.get(t.assemblyId)?.get(n)?.byFeature.get(t._id)},getFeaturesAtPosition(e,t,n,r){const o=this.layouts.get(e);if(!o)return[];const i=o.get(t);if(!i)return[];const a=i.byRow.at(n);return a?a.filter((({feature:e})=>r>=e.min&&r<=e.max)).map((e=>e.feature)):[]}}))).views((e=>({highestRow(t){const n=e.layouts.get(t);return n?Math.max(0,...[...n.values()].map((e=>e.byRow.length))):0}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered()){for(const[t,n]of e.seenFeatures.entries()){let r=!1;for(const t of e.regions)if(o.doesIntersect2(t.start-e.cleanupBoundary,t.end+e.cleanupBoundary,n.min,n.max)){r=!0;break}r||e.deleteSeenFeature(t)}for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}}),{name:"LinearApolloDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({featuresHeight:t=>(e.highestRow(t)+1)*e.apolloRowHeight,get canvasPatterns(){const t={forward:null,backward:null},n=document.createElement("canvas"),r=n?.getContext("2d");if(!r)return t;const o=10;n.width=n.height=o;const{theme:i}=e,a="light"===i.palette.mode?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",s="light"===i.palette.mode?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",l=["forward","backward"];for(const e of l){const i="forward"===e?r.createLinearGradient(0,o,o,0):r.createLinearGradient(0,0,o,o);i.addColorStop(0,a),i.addColorStop(.25,a),i.addColorStop(.25,s),i.addColorStop(.5,s),i.addColorStop(.5,a),i.addColorStop(.75,a),i.addColorStop(.75,s),i.addColorStop(1,s),r.fillStyle=i,r.clearRect(0,0,o,o),r.fillRect(0,0,o,o),t[e]=r.createPattern(n,"repeat")}return t}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight(e.lgv.assemblyNames[0]));for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{canvas:t,layouts:n,lgv:r}=e;if(!r.initialized||e.regionCannotBeRendered()||!t)return;const{dynamicBlocks:i,offsetPx:a}=r,s=t.getContext("2d");if(!s)return;const l=n.get(r.assemblyNames[0]);if(l){s.clearRect(0,0,t.width,t.height);for(const n of i.contentBlocks){const r=n.offsetPx-a;s.save(),s.beginPath(),s.rect(r,0,n.widthPx,t.height),s.clip();const i=l.get(n.refName);if(!i)return;const{byRow:c}=i;for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).draw(e,s,r,t,a,n)}for(const[t,r]of c.entries())for(const i of r){const{feature:r,rowInFeature:a}=i;o.doesIntersect2(n.start,n.end,r.min,r.max)&&e.getGlyph(r).drawOverlay(e,s,r,t,n,"highlight",a)}s.restore()}}}),{name:"LinearApolloDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition:t=>function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,assemblyName:d,refName:f}=t.pxToBp(s);return{x:s,y:l,assemblyName:d,refName:f,bp:c,regionNumber:u}}(t,e.lgv),getFeaturesAtMousePosition(t){const{bp:n,assemblyName:r,refName:o,y:i}=t,a=Math.floor(i/e.apolloRowHeight),s=e.layouts.get(r)?.get(o);return s?e.getFeaturesAtPosition(r,o,a,n):[]}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(e){}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);if(1===r.length)return il(e,r[0]);const o=[];for(const t of r){const n=e.getGlyph(t);o.push({label:t.type,subMenu:[...il(e,t),...n.getContextMenuItems(e,t)]})}return o}}))).actions((e=>{function t(t){"Escape"===t.key&&e.setDragging()}return{startDrag(n,r,o,i=!1){globalThis.addEventListener("keydown",t,!0),e.apolloDragging={start:n,current:n,feature:r,edge:o,shrinkParent:i}},endDrag(){if(globalThis.removeEventListener("keydown",t,!0),!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:n,edge:r,feature:o,start:i,shrinkParent:a}=e.apolloDragging;if(Math.abs(n.x-i.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:s}=e.lgv,l=e.getAssemblyId(s[i.regionNumber].assemblyName),c=cl(o,n.bp,r,a),u="max"===r?new Tt({typeName:"LocationEndChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:l}):new Et({typeName:"LocationStartChange",changedIds:c.map((e=>e.featureId)),changes:c.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:l});e.changeManager.submit(u),e.setDragging(),e.setCursor()}}})).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);for(const o of r.toReversed())if(e.getGlyph(o).isDraggable){const r=sd(n,o,e);if(r)return t.stopPropagation(),void e.startDrag(n,o,r,!0)}},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);const r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?e.setHoveredFeature({feature:o,bp:n.bp}):e.setHoveredFeature();for(const t of r.toReversed())if(e.getGlyph(t).isDraggable&&sd(n,t,e))return void e.setCursor("col-resize");e.setCursor()},onMouseLeave(t){e.setDragging(),e.setHoveredFeature()},onMouseUp(t){if(e.apolloDragging)return void e.endDrag();const n=e.getMousePosition(t),r=e.getFeaturesAtMousePosition(n);let o=r.at(-1);if(o&&Xs(o,e.session)){const t=r.at(-2);t&&!Ys(t,e.session)&&(o=t)}o?(Ws(e,o),e.setSelectedFeature(o)):e.setSelectedFeature()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,overlayCanvas:n}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;const{dynamicBlocks:r,offsetPx:i}=t,a=n.getContext("2d");if(!a)return;a.clearRect(0,0,n.width,n.height);const{apolloDragging:s,hoveredFeature:l}=e;if(!l)return;const{feature:c}=l,u=e.getGlyph(c),d=e.getRowForFeature(c);if(void 0!==d)for(const t of r.contentBlocks){const r=t.offsetPx-i;if(a.save(),a.beginPath(),a.rect(r,0,t.widthPx,n.height),a.clip(),t.assemblyName===c.assemblyId&&o.doesIntersect2(t.start,t.end,c.min,c.max)&&u.drawOverlay(e,a,c,d,t,"hover"),s){const{current:n,start:r,feature:i}=s,l=Math.min(n.bp,r.bp),c=Math.max(n.bp,r.bp);if(o.doesIntersect2(t.start,t.end,l,c)){const n=e.getGlyph(i),r=e.getRowForFeature(i);void 0!==r&&n.drawDragPreview(e,a,i,r,t)}}a.restore()}}),{name:"LinearApolloDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(nd,{})}).named("LinearApolloDisplay")}const Ud=n.ConfigurationSchema("LinearApolloReferenceSequenceDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0});function $d(e,t,n){const r=t<=1?[2,1,0,7,6,5]:[2,1,0,5,4,3];n&&r.reverse(),r.unshift(0);const o=r.at(e);if(void 0===o)throw new Error("could not find row");return o}function zd(e,t,n,r){return r.offsetPx-n+(r.reversed?r.end-e.max:e.min-r.start)/t}function Hd(e,t,n,r,o,i,a=!1){e.fillStyle=a?i.palette.action.disabled:i.palette.action.focus,e.fillRect(t,n,r,o),e.strokeStyle=a?i.palette.text.secondary:i.palette.text.primary,e.strokeStyle=i.palette.text.primary,e.strokeRect(t,n,r,o)}function Gd(e,t,n,r,o,i,a,s=!1){const l=function(e,t,n){if(!(t>1||void 0===e))return n?1===e?4:3:1===e?3:4}(t.strand,n,i.reversed);void 0!==l&&Hd(e,zd(t,n,r,i),l*o,t.length/n,o,a,s)}function Vd(e,t,n,r,i,a,s,l=!1){const c=t.parent;if(!c)return;const u=c.cdsLocations.find((e=>{const n=e.at(1===t.strand?0:-1)?.min,r=e.at(1===t.strand?-1:0)?.max;return t.min===n&&t.max===r}));if(u)for(const c of u){const u=$d(o.getFrame(c.min,c.max,t.strand??1,c.phase),n,a.reversed);Hd(e,zd(c,n,r,a),u*i,(c.max-c.min)/n,i,s,l)}}function Wd(e,t,n,r,o){const i=Math.min(r,10);e.fillStyle="#000",e.font=`${i}px`;const a=e.measureText(o).width,s=Math.round(t+(r-a)/2);e.fillText(o,s,n+10)}function Jd(e,t,n,r,o,i,a,s){const l=t<=1?[3,2,1,0,0,-1,-2,-3]:[3,2,1,-1,-2,-3];s&&l.reverse();for(const[t,s]of l.entries()){const l=n.palette.framesCDS.at(s)?.main;if(!l)continue;const c=t*a;e.fillStyle=r?n.palette.background.default:l,e.fillRect(o,c,i,a),r&&ad(e,o,c,i,a,n.palette.grey[200])}}function Kd(e,t,n,r,i,a,s){if(1/i<1)return;const l=Math.round(r+n/i),c=Math.round(r+(n+1)/i)-l,u=[-1,1];for(const n of u){const r=(1===n?3:4)*a,u=1===n?t:o.revcom(t);e.fillStyle=Bd(u,s),e.fillRect(l,r,c,a),1/i>=12&&(ad(e,l,r,c,a,s.palette.text.disabled),Wd(e,l,r,c,u))}}function Yd(e,t,n,r,i,a,s,l,c,u,d){const f=(s<=1?[0,2,1,0,7,6,5]:[0,2,1,0,5,4,3]).map((e=>e*c)),h=[-1,1];for(const p of h){const h=o.getFrame(l,l+3,p,0),g=f.at(h);if(void 0===g)continue;const m=Math.round(n+r/s),y=Math.round(n+(r+3)/s)-m,_=1===p?t:o.revcom(t),v=o.defaultCodonTable[_],b=Pd(v,i,a);b&&(d&&"*"==v||u&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c)),1/s>=4&&(ad(e,m,g,y,c,i.palette.text.disabled),Wd(e,m,g,y,v))}}function Xd(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloReferenceSequenceDisplay").props({type:l.types.literal("LinearApolloReferenceSequenceDisplay"),configuration:n.ConfigurationReference(t),showStartCodons:!1,showStopCodons:!0,highContrast:!1,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),sequenceRowHeight:15}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).views((e=>({get lgv(){return o.getContainingView(e)}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>3)return"Zoom in to see sequence"}}))).views((e=>({get expandedRegions(){return e.lgv.dynamicBlocks.contentBlocks.map((e=>{const{assemblyName:t,end:n,refName:r,start:o}=e,{parentRegion:i}=e;return{assemblyName:t,refName:r,start:Math.round(Math.max(o-5,i.start)),end:Math.round(Math.min(n+5,i.end))}}))},get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature},get height(){const{sequenceRowHeight:t}=e;return e.lgv.bpPerPx<=1?8*t:6*t}}))).volatile((()=>({scrollTop:0}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleHighContrast(){e.highContrast=!e.highContrast}}))).views((e=>{const{trackMenuItems:t}=e;return{trackMenuItems(){const{showStartCodons:n,showStopCodons:r,highContrast:o}=e;return[...t(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show start codons",type:"checkbox",checked:n,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:r,onClick:()=>{e.toggleShowStopCodons()}},{label:"Use high contrast colors",type:"checkbox",checked:o,onClick:()=>{e.toggleHighContrast()}}]}]}}})).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&e.lgv.bpPerPx<=3&&e.session.apolloDataStore.loadRefSeq(e.expandedRegions)}),{name:"LinearApolloReferenceSequenceDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloReferenceSequenceDisplayRendering").volatile((()=>({seqTrackCanvas:null,seqTrackOverlayCanvas:null,theme:s.createTheme()}))).actions((e=>({setSeqTrackCanvas(t){e.seqTrackCanvas=t},setSeqTrackOverlayCanvas(t){e.seqTrackOverlayCanvas=t},setTheme(t){e.theme=t},afterAttach(){l.addDisposer(e,c.autorun((()=>{const{lgv:t,seqTrackCanvas:n,theme:r,highContrast:i,showStartCodons:a,showStopCodons:s,sequenceRowHeight:l,session:c}=e;if(!t.initialized||e.regionCannotBeRendered()||!n)return;if(3/t.bpPerPx<1)return;const{bpPerPx:u,offsetPx:d,dynamicBlocks:f}=t;!function(e,t,n,r,i,a,s,l,c,u){const d=e.getContext("2d");if(!d)return;d.clearRect(0,0,e.width,e.height);const{apolloDataStore:f}=u;for(const e of i.contentBlocks){const i=e.offsetPx-r;Jd(d,n,t,a,i,e.widthPx,c,e.reversed);const u=f.assemblies.get(e.assemblyName),h=u?.getByRefName(e.refName),p=Math.floor(e.start),g=Math.ceil(e.end);let m=h?.getSequence(p,g);if(!m)return;m=m.toUpperCase(),e.reversed&&(m=o.revcom(m));const y=i-(e.reversed?g-e.end:e.start-p)/n;for(let r=0;r<m.length;r++){const o=e.reversed?g-r:p+r,i=m.slice(r,r+3);Kd(d,m[r],r,y,n,c,t),3===i.length&&Yd(d,i,y,r,t,a,n,o,c,s,l)}}}(n,r,u,d,f,i,a,s,l,c)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequence"})),l.addDisposer(e,c.autorun((()=>{const{seqTrackOverlayCanvas:t}=e;if(!e.lgv.initialized||e.regionCannotBeRendered()||!t)return;const n=t.getContext("2d");if(!n)return;n.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.height);const{hoveredFeature:r,selectedFeature:o,lgv:i,sequenceRowHeight:a,session:s,theme:l}=e;if(!r&&!o)return;const{bpPerPx:c,dynamicBlocks:u,offsetPx:d}=i;!function(e,t,n,r,o,i,a,s,l,c){const{featureTypeOntology:u}=a.apolloDataStore.ontologyManager;if(!u)throw new Error("featureTypeOntology is undefined");for(const a of c.contentBlocks){t.save(),t.beginPath(),t.rect(a.offsetPx-l,0,a.widthPx,e.height),t.clip();for(const e of[r,n?.feature].filter((e=>void 0!==e)))u.isTypeOf(e.type,"CDS")?Vd(t,e,s,l,o,a,i,e._id===r?._id):Gd(t,e,s,l,o,a,i,e._id===r?._id);t.restore()}}(t,n,r,o,a,l,s,c,d,u)}),{name:"LinearApolloReferenceSequenceDisplayRenderSequenceHighlight"}))}})))}(0,t).named("LinearApolloReferenceSequenceDisplay")}const Zd=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{height:r,regionCannotBeRendered:a,setSeqTrackCanvas:l,setSeqTrackOverlayCanvas:c,setTheme:d}=n,{classes:f}=Md();u.useEffect((()=>{d(t)}),[t,d]);const h=o.getContainingView(n),p=a();return p?i.jsx(s.Alert,{severity:"warning",classes:{message:f.ellipses},slotProps:{root:{className:f.center}},children:i.jsx(s.Tooltip,{title:p,children:i.jsx("div",{children:p})})}):i.jsx(i.Fragment,{children:3/h.bpPerPx>=1?i.jsxs("div",{className:f.canvasContainer,style:{width:h.dynamicBlocks.totalWidthPx,height:r},children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),l(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),c(e)},width:h.dynamicBlocks.totalWidthPx,height:r,className:f.canvas,"data-testid":"seqTrackOverlayCanvas"})]}):null})})),Qd=n.ConfigurationSchema("LinearApolloSixFrameDisplay",{},{explicitIdentifier:"displayId",explicitlyTyped:!0}),ef=p.observer((function({sourceFeature:e,filteredTranscripts:t,handleClose:n,onUpdate:r}){const o=[];if(e.children)for(const[,t]of e.children){const e=t.attributes.get("gff_id")?.toString();e&&o.push(e)}const[a,l]=u.useState(t);return i.jsx(Bs,{open:!0,maxWidth:!1,"data-testid":"filter-transcripts-dialog",title:"Filter transcripts by ID",handleClose:n,children:i.jsxs(s.DialogContent,{children:[i.jsx(s.DialogContentText,{children:"Select the alternate transcripts you want to display in the apollo track"}),i.jsx(s.Grid,{container:!0,spacing:2,children:i.jsx(s.Grid,{size:8,children:i.jsx(s.FormGroup,{children:o.map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:!a.includes(e),onChange:()=>{(e=>{const t=a.includes(e)?a.filter((t=>t!==e)):[...a,e];r(t),l(t)})(e)},slotProps:{input:{"aria-label":"controlled"}}}),label:e})))})})})]})})}));let tf=null,nf=null,rf=null,of=null;const af=globalThis.document.createElement("canvas");if(af?.getContext)for(const e of["forward","backward"])for(const t of["light","dark"]){const n=document.createElement("canvas"),r=10;n.width=n.height=r;const o=n.getContext("2d");if(o){const i="light"===t?"rgba(0,0,0,0)":"rgba(0,0,0,0.75)",a="light"===t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.50)",s="forward"===e?o.createLinearGradient(0,r,r,0):o.createLinearGradient(0,0,r,r);s.addColorStop(0,i),s.addColorStop(.25,i),s.addColorStop(.25,a),s.addColorStop(.5,a),s.addColorStop(.5,i),s.addColorStop(.75,i),s.addColorStop(.75,a),s.addColorStop(1,a),o.fillStyle=s,o.fillRect(0,0,10,10),"forward"===e?"light"===t?tf=o.createPattern(n,"repeat"):rf=o.createPattern(n,"repeat"):"light"===t?nf=o.createPattern(n,"repeat"):of=o.createPattern(n,"repeat")}}function sf(e,t){for(const n of e)if(Ss(n,t))return!0;return!1}function lf(e,t,n){const{filteredTranscripts:r,session:i}=n,{apolloDataStore:a}=i,{featureTypeOntology:s}=a.ontologyManager;if(!s)throw new Error("featureTypeOntology is undefined");const l=s.isTypeOf(t.type,"transcript"),c=t.attributes.get("gff_id")?.toString();if(c&&r.includes(c))return;const{bp:u,refName:d,regionNumber:f,x:h}=e,{lgv:p}=n;if(l){const e=t;if(!e.children)return;const n=[],r=[];for(const t of e.children.values()){const e=s.isTypeOf(t.type,"exon"),o=s.isTypeOf(t.type,"CDS");e?n.push(t):o&&r.push(t)}const i=n.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(i){const e=tl(i,d,f,p);if(e){const t=nl(i,h,e);if(t)return t}}for(const t of e.cdsLocations)for(const e of t){const t=tl(e,d,f,p);if(t){const e=r.find((e=>{const[t,n]=o.intersection2(u,u+1,e.min,e.max);return void 0!==t&&void 0!==n}));if(e){const n=nl(e,h,t);if(n)return n}}}}}const cf={draw:function(e,t,n,r,i){const{apolloRowHeight:a,lgv:l,session:c,theme:u,highestRow:d,filteredTranscripts:f,selectedFeature:h,showFeatureLabels:p}=r,{bpPerPx:g,displayedRegions:m,offsetPx:y}=l,_=m[i],{refName:v,reversed:b}=_,x=a,w=x,S=x,C=x,A=p?2:1,k=u.palette.text.primary,{attributes:N,children:T,min:R,strand:E}=t;if(!T)return;const{apolloDataStore:I}=c,{featureTypeOntology:j}=I.ontologyManager;if(!j)throw new Error("featureTypeOntology is undefined");const D=[],O=(l.bpToPx({refName:v,coord:R,regionNumber:i})?.offsetPx??0)-y,F=t.length/g,M=b?O-F:O,L=(1==E?3:4)*A*x;e.fillStyle=u.palette.text.primary,e.fillRect(M,L,F,C),e.fillStyle=rl(t,h)?s.alpha("rgb(0,0,0)",.7):s.alpha(u.palette.background.paper,.7),e.fillRect(M+1,L+1,F-2,C-2);const P=rl(t,h),B={x:M,y:L,h:C,text:N.get("gff_id")?.toString(),color:k,isSelected:P};P?D.unshift(B):D.push(B);const q="dark"===u.palette.mode?rf:tf,U="dark"===u.palette.mode?of:nf,$=b?-1:1;let z=null,H=null;E&&([z,H]=E*$==1?[q,U]:[U,q]),z&&H&&(e.fillStyle=z,e.fillRect(M+1,L+1,F-2,(C-2)/2),e.fillStyle=H,e.fillRect(M+1,L+(C-2)/2,F-2,(C-2)/2));const G=new Set;for(const[,t]of T){if(!j.isTypeOf(t.type,"transcript")&&!j.isTypeOf(t.type,"pseudogenic_transcript"))continue;const{children:n,cdsLocations:r}=t;if(!n)continue;const a=t.attributes.get("gff_id")?.toString();if(a&&f.includes(a))continue;for(const[,t]of n){if(!j.isTypeOf(t.type,"exon"))continue;const n=(l.bpToPx({refName:v,coord:t.min,regionNumber:i})?.offsetPx??0)-y,r=t.length/g,o=b?n-r:n,a=L+(C-w)/2,c=rl(t,h);if(e.fillStyle=u.palette.text.primary,e.fillRect(o,a,r,w),r>2){e.clearRect(o+1,a+1,r-2,w-2),e.fillStyle=c?"rgb(0,0,0)":s.alpha("#f5f500",.6),e.fillRect(o+1,a+1,r-2,w-2),z&&H&&(e.fillStyle=z,e.fillRect(o+1,a+1,r-2,(w-2)/2),e.fillStyle=H,e.fillRect(o+1,a+1+(w-2)/2,r-2,(w-2)/2));const n={x:o,y:a,h:w,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(n):D.push(n)}}const c=rl(t,h?.parent);let m=0,_=0;for(const n of r){let r=0,a=0,s=1;for(const f of n.toSorted(((e,t)=>e.max-t.max)))if(h&&c&&j.isTypeOf(h.type,"CDS")||!sf(G,f)){const n=(f.max-f.min)/g,w=(l.bpToPx({refName:v,coord:f.min,regionNumber:i})?.offsetPx??0)-y;m=b?w-n:w,e.fillStyle=u.palette.text.primary;const C=o.getFrame(f.min,f.max,t.strand??1,f.phase),k=(p?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(C);if(void 0===k)continue;if(_=k*x,e.fillRect(m,_,n,S),s>1){const t=[(m-a)/2+a,Math.max(C<0?x*A*d+1:1,Math.min(r,_)-x/2)];e.strokeStyle="rgb(0, 128, 128)",e.beginPath(),e.moveTo(a,r),e.lineTo(...t),e.stroke(),e.moveTo(...t),e.lineTo(m,_+x/2),e.stroke()}if(a=m+n,r=_+x/2,s+=1,n>2){e.clearRect(m+1,_+1,n-2,S-2);const t=u.palette.framesCDS.at(C)?.main,r=t??"rgb(171,71,188)";e.fillStyle=r,e.fillStyle=h&&c&&j.isTypeOf(h.type,"CDS")?"rgb(0,0,0)":r,e.fillRect(m+1,_+1,n-2,S-2),z&&H&&(e.fillStyle=z,e.fillRect(m+1,_+1,n-2,(S-2)/2),e.fillStyle=H,e.fillRect(m+1,_+(S-2)/2,n-2,(S-2)/2))}G.add(f)}}const N={x:m,y:_,h:S,text:t.attributes.get("gff_id")?.toString(),color:k,isSelected:c};c?D.unshift(N):D.push(N)}p&&function(e,t,n="10px sans-serif"){for(let r=t.length-1;r>=0;--r){const i=t[r];e.fillStyle=i.color;const a=i.x+1,s=i.y+i.h,l=o.measureText(i.text,10);i.isSelected&&(e.font="bold ".concat(n)),i.text&&(e.clearRect(a-5,s,l+10,i.h),e.fillText(i.text,a,s+11,l),e.font=n)}}(e,D)},drawDragPreview:function(e,t){const{apolloDragging:n,apolloRowHeight:r,lgv:o,theme:i}=e,{bpPerPx:a,displayedRegions:l,offsetPx:c}=o;if(!n)return;const{current:u,edge:d,feature:f,start:h}=n,p=Math.floor(h.y/r),g=l[h.regionNumber],m=(g.reversed?g.end-f[d]:f[d]-g.start)/a-c,y=Math.min(u.x,m),_=p*r,v=Math.abs(u.x-m),b=1*r;t.strokeStyle=i.palette.info.main,t.setLineDash([6]),t.strokeRect(y,_,v,b),t.fillStyle=s.alpha(i.palette.info.main,.2),t.fillRect(y,_,v,b)},drawOverlay:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,highestRow:s,session:l,showFeatureLabels:c}=e;if(!n)return;const{feature:u}=n,{apolloDataStore:d}=l,{featureTypeOntology:f}=d.ontologyManager;if(!f)throw new Error("featureTypeOntology is undefined");if(!f.isTypeOf(u.type,"transcript"))return;const h=u.attributes.get("gff_id")?.toString();if(h&&i.includes(h))return;const p=e.getFeatureLayoutPosition(u);if(!p)return;const{bpPerPx:g,displayedRegions:m,offsetPx:y}=a,{layoutIndex:_}=p,v=m[_],{refName:b,reversed:x}=v,w=r,S=w,C=c?2:1,{cdsLocations:A,strand:k}=u;for(const e of A){let n=0,r=0,i=1;for(const l of e.toSorted(((e,t)=>e.max-t.max))){const e=(l.max-l.min)/g,u=(a.bpToPx({refName:b,coord:l.min,regionNumber:_})?.offsetPx??0)-y,d=x?u-e:u,f=o.getFrame(l.min,l.max,k??1,l.phase),h=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(f);if(void 0===h)continue;const p=h*w;if(i>1){const e=[(d-r)/2+r,Math.max(f<0?w*C*s+1:1,Math.min(n,p)-w/2)];t.strokeStyle="rgb(0, 0, 0)",t.lineWidth=2,t.beginPath(),t.moveTo(r,n),t.lineTo(...e),t.stroke(),t.moveTo(...e),t.lineTo(d,p+w/2),t.stroke()}r=d+e,n=p+w/2,i+=1,e>2&&(t.fillStyle="rgba(255,0,0,0.6)",t.fillRect(d,p,e,S))}}},drawTooltip:function(e,t){const{hoveredFeature:n,apolloRowHeight:r,filteredTranscripts:i,lgv:a,session:l,showFeatureLabels:c,theme:u}=e;if(!n)return;const{feature:d,bp:f}=n,{featureTypeOntology:h}=l.apolloDataStore.ontologyManager;if(!h)throw new Error("featureTypeOntology is undefined");if(!h.isTypeOf(d.type,"transcript"))return;const{attributes:p,strand:g,type:m}=d,y=e.getFeatureLayoutPosition(d);if(!y)return;const _=p.get("gff_id")?.toString();if(_&&i.includes(_))return;const{layoutIndex:v}=y,{bpPerPx:b,displayedRegions:x,offsetPx:w}=a,S=x[v],{refName:C,reversed:A}=S,k=r;let N,T="Loc: ";for(const e of d.cdsLocations)for(const t of e)if(f>=t.min&&f<=t.max){N=t;break}if(!N)return;const{max:R,min:E,phase:I}=N;T+=`${E+1}–${R}`;let j=(a.bpToPx({refName:C,coord:A?R:E,regionNumber:v})?.offsetPx??0)-w;const D=o.getFrame(E,R,g??1,I),O=(c?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).at(D);if(void 0===O)return;const F=O*k,M=(R-E)/b,L=`Type: ${N.type}`,P=p.get("gff_name")?.find((e=>""!==e)),B=[t.measureText(L).width,t.measureText(T).width];P&&B.push(t.measureText(`Parent Type: ${m}`).width,t.measureText(`Parent Name: ${P}`).width);const q=Math.max(...B);j=j+M+5,t.fillStyle=s.alpha(u.palette.text.primary,.7),t.fillRect(j,F,q+4,4===B.length?55:35),t.beginPath(),t.moveTo(j,F),t.lineTo(j-5,F+5),t.lineTo(j,F+10),t.fill(),t.fillStyle=u.palette.background.default;let U=F+12;t.fillText(L,j+2,U),P&&(U+=12,t.fillText(`Parent Type: ${m}`,j+2,U),U+=12,t.fillText(`Parent Name: ${P}`,j+2,U)),U+=12,t.fillText(T,j+2,U)},getContextMenuItems:function(e,t){const{apolloInternetAccount:n,hoveredFeature:r,changeManager:i,filteredTranscripts:a,regions:s,selectedFeature:c,session:u}=e,[d]=s,f=e.getAssemblyId(d.assemblyName),h=[],p=n?n.role:"admin",g=!(p&&["admin","user"].includes(p));if(!r)return h;const{featureTypeOntology:m}=u.apolloDataStore.ontologyManager;if(!m)throw new Error("featureTypeOntology is undefined");if(ul(t)){const{bp:n,feature:r}=t;let s=Ca(r,n);Xs(r,u)&&(s=Ca(r,n,!0));for(const t of s){const n=t.attributes.get("gff_id")?.toString();if(n&&a.includes(n))continue;const r=il(e,t);if(Ys(t,u)){const n=Qs(t,e),a=o.getContainingView(e);if(n.upstream){const o=n.upstream;r.push({label:"Go to upstream exon",icon:el(t.strand,!0,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}if(n.downstream){const o=n.downstream;r.push({label:"Go to downstream exon",icon:el(t.strand,!1,a.displayedRegions.at(0)?.reversed),onClick:()=>{a.navTo(al(o,.1,a.totalBp)),Ws(e,o)}})}r.push({label:"Merge exons",disabled:g,onClick:()=>{u.queueDialog((n=>[Yl,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}},{label:"Split exon",disabled:g,onClick:()=>{u.queueDialog((n=>[lc,{session:u,handleClose:()=>{n()},changeManager:i,sourceFeature:t,sourceAssemblyId:f,selectedFeature:c,setSelectedFeature:t=>{e.setSelectedFeature(t)}}]))}})}m.isTypeOf(t.type,"gene")&&r.push({label:"Filter alternate transcripts",onClick:()=>{u.queueDialog((n=>[ef,{handleClose:()=>{n()},sourceFeature:t,filteredTranscripts:l.getSnapshot(a),onUpdate:t=>{e.updateFilteredTranscripts(t)}}]))}}),h.push({label:t.type,subMenu:r})}}return h},getContextMenuItemsForFeature:il,onMouseDown:function(e,t,n){const{feature:r}=t,o=lf(t,r,e);o&&(n.stopPropagation(),e.startDrag(t,o.feature,o.edge,!0))},onMouseLeave:function(){},onMouseMove:function(e,t){if(ul(t)){const{feature:n,bp:r}=t;if(e.setHoveredFeature({feature:n,bp:r}),lf(t,n,e))return void e.setCursor("col-resize")}e.setCursor()},onMouseUp:function(e,t){if(!e.apolloDragging&&ul(t)){const{feature:n}=t,{session:r}=e,{apolloDataStore:o}=r,{featureTypeOntology:i}=o.ontologyManager;if(e.setSelectedFeature(n),!i)throw new Error("featureTypeOntology is undefined");let a=!1;for(const[,e]of n.children??[])if(i.isTypeOf(e.type,"CDS")||i.isTypeOf(e.type,"exon")){a=!0;break}(i.isTypeOf(n.type,"transcript")||i.isTypeOf(n.type,"pseudogenic_transcript"))&&a?e.showFeatureDetailsWidget(n,["ApolloTranscriptDetails","apolloTranscriptDetails"]):e.showFeatureDetailsWidget(n)}}};function uf(e,t,n,r,i,a,s,l,c,u,d,f){const h=(u?[0,4,2,0,14,12,10]:[0,2,1,0,7,6,5]).map((e=>e*c)),p=[-1,1];for(const u of p){const p=o.getFrame(l,l+3,u,0),g=h.at(p);if(void 0===g)continue;const m=Math.round(n+r/s),y=0===Math.round(3/s)?1:Math.round(3/s),_=1===u?t:o.revcom(t),v=o.defaultCodonTable[_],b=Pd(v,i,a);b&&(f&&"*"==v||d&&"*"!=v)&&(e.fillStyle=b,e.fillRect(m,g,y,c))}}function df(e,t){return function(e,t){return function(e,t){const i=function(e,t){return function(e,t){const i=function(e,t){return r.BaseDisplay.named("BaseLinearApolloSixFrameDisplay").props({type:l.types.literal("LinearApolloSixFrameDisplay"),configuration:n.ConfigurationReference(t),graphical:!0,table:!1,showFeatureLabels:!0,showStartCodons:!1,showStopCodons:!0,showCheckResults:!0,zoomThreshold:200,heightPreConfig:l.types.maybe(l.types.refinement("displayHeight",l.types.number,(e=>e>=20))),filteredFeatureTypes:l.types.array(l.types.string)}).views((e=>{const{configuration:t,renderProps:n}=e;return{renderProps:()=>({...n(),...b.getParentRenderProps(e),config:t.renderer})}})).volatile((()=>({scrollTop:0}))).views((e=>({get lgv(){return o.getContainingView(e)},get height(){return e.heightPreConfig?e.heightPreConfig:e.graphical&&e.table?500:e.graphical?e.showFeatureLabels?400:200:300},get zoomThresholdSetting(){return e.zoomThreshold??n.getConf(e,"zoomThreshold")}}))).views((e=>({get rendererTypeName(){return e.configuration.renderer.type},get session(){return o.getSession(e)},get regions(){return e.lgv.dynamicBlocks.contentBlocks.map((({assemblyName:e,end:t,refName:n,start:r})=>({assemblyName:e,refName:n,start:Math.round(r),end:Math.round(t)})))},regionCannotBeRendered(){if(e.lgv&&e.lgv.bpPerPx>=e.zoomThreshold)return"Zoom in to see annotations"}}))).views((e=>({get apolloInternetAccount(){const[t]=e.regions,{internetAccounts:r}=l.getRoot(e),{assemblyName:o}=t,{assemblyManager:i}=e.session,a=i.get(o);if(!a)throw new Error(`No assembly found with name ${o}`);const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return r.find((e=>n.getConf(e,"internetAccountId")===s))},get changeManager(){return e.session.apolloDataStore.changeManager},getAssemblyId(t){const{assemblyManager:n}=e.session,r=n.get(t);if(!r)throw new Error(`Could not find assembly named ${t}`);return r.name},get selectedFeature(){return e.session.apolloSelectedFeature},get hoveredFeature(){return e.session.apolloHoveredFeature}}))).actions((e=>({setScrollTop(t){e.scrollTop=t},setHeight:t=>(e.heightPreConfig=Math.max(t,20),e.height),resizeHeight(t){const n=e.height;return this.setHeight(e.height+t)-n},showGraphicalOnly(){e.graphical=!0,e.table=!1},showTableOnly(){e.graphical=!1,e.table=!0},showGraphicalAndTable(){e.graphical=!0,e.table=!0},toggleShowFeatureLabels(){e.showFeatureLabels=!e.showFeatureLabels},toggleShowStartCodons(){e.showStartCodons=!e.showStartCodons},toggleShowStopCodons(){e.showStopCodons=!e.showStopCodons},toggleShowCheckResults(){e.showCheckResults=!e.showCheckResults},updateFilteredFeatureTypes(t){e.filteredFeatureTypes=l.cast(t)},setZoomThresholdSetting({zoomThreshold:t}){e.zoomThreshold=t}}))).views((e=>{const{filteredFeatureTypes:t,trackMenuItems:n}=e;return{trackMenuItems(){const{graphical:r,table:i,showFeatureLabels:a,showStartCodons:s,showStopCodons:c,showCheckResults:u}=e;return[...n(),{type:"subMenu",label:"Appearance",subMenu:[{label:"Show graphical display",type:"radio",checked:r&&!i,onClick:()=>{e.showGraphicalOnly()}},{label:"Show table display",type:"radio",checked:i&&!r,onClick:()=>{e.showTableOnly()}},{label:"Show both graphical and table display",type:"radio",checked:i&&r,onClick:()=>{e.showGraphicalAndTable()}},{label:"Feature Labels",type:"checkbox",checked:a,onClick:()=>{e.toggleShowFeatureLabels()}},{label:"Show start codons",type:"checkbox",checked:s,onClick:()=>{e.toggleShowStartCodons()}},{label:"Show stop codons",type:"checkbox",checked:c,onClick:()=>{e.toggleShowStopCodons()}},{label:"Check Results",type:"checkbox",checked:u,onClick:()=>{e.toggleShowCheckResults()}},{label:"Change zoom threshold",onClick:()=>{o.getSession(e).queueDialog((t=>[Fd,{model:e,handleClose:t}]))}}]},{label:"Filter features by type",onClick:()=>{const n=e.session;e.session.queueDialog((r=>[Od,{session:n,handleClose:()=>{r()},featureTypes:l.getSnapshot(t),onUpdate:t=>{e.updateFilteredFeatureTypes(t)}}]))}}]}}})).actions((e=>({setSelectedFeature(t){e.session.apolloSetSelectedFeature(t)},setHoveredFeature(t){e.session.apolloSetHoveredFeature(t)},showFeatureDetailsWidget(t,n){const[r]=e.regions,{assemblyName:o,refName:i}=r,a=e.getAssemblyId(o);if(!a)return;const{session:s}=e,{changeManager:l}=s.apolloDataStore,[c,u]=n??["ApolloFeatureDetailsWidget","apolloFeatureDetailsWidget"],d=s.addWidget(c,u,{feature:t,assembly:a,refName:i,changeManager:l});s.showWidget(d)},afterAttach(){l.addDisposer(e,c.autorun((()=>{e.lgv.initialized&&!e.regionCannotBeRendered()&&(e.session.apolloDataStore.loadFeatures(e.regions),e.lgv.bpPerPx<=e.zoomThreshold&&e.session.apolloDataStore.loadRefSeq(e.regions))}),{name:"LinearApolloSixFrameDisplayLoadFeatures",delay:1e3}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayLayouts").props({featuresMinMaxLimit:5e5}).volatile((()=>({seenFeatures:c.observable.map()}))).views((e=>({get featuresMinMax(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map((n=>{const r=t.get(n.assemblyName);let i,a;const{end:s,refName:l,start:c}=n;for(const[,t]of e.seenFeatures)l!==r?.getCanonicalRefName(t.refSeq)||!o.doesIntersect2(c,s,t.min,t.max)||t.length>e.featuresMinMaxLimit||(void 0===i&&({min:i}=t),void 0===a&&({max:a}=t),t.minWithChildren<i&&({min:i}=t),t.maxWithChildren>a&&({max:a}=t));if(void 0!==i&&void 0!==a)return[i,a]}))},getGlyph:e=>cf,featureLabelSpacer:t=>e.showFeatureLabels?2*t-1:t}))).actions((e=>({addSeenFeature(t){e.seenFeatures.set(t._id,t)},deleteSeenFeature(t){e.seenFeatures.delete(t)}}))).views((e=>({get geneTrackRowNums(){return[4,5].map((t=>e.featureLabelSpacer(t)))}}))).views((e=>({get featureLayouts(){const{assemblyManager:t}=e.session;return e.lgv.displayedRegions.map(((n,r)=>{const i=t.get(n.assemblyName),a=new Map;if(!e.featuresMinMax[r])return a;const{end:s,refName:c,start:u}=n;for(const[t,n]of e.seenFeatures.entries()){if(!l.isAlive(n)){e.deleteSeenFeature(t);continue}if(c!==i?.getCanonicalRefName(n.refSeq)||!o.doesIntersect2(u,s,n.min,n.max))continue;const{featureTypeOntology:r}=e.session.apolloDataStore.ontologyManager;if(!r)throw new Error("featureTypeOntology is undefined");if(Zs(n,e.session)){const t=1==n.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1];a.get(t)||a.set(t,[]);const i=a.get(t);i?.push({rowNum:t,feature:n});const{children:s}=n;if(!s)continue;for(const[,t]of s)if(r.isTypeOf(t.type,"transcript")){const{cdsLocations:n,strand:i,children:s}=t;if(s)for(const[,t]of s){if(!r.isTypeOf(t.type,"exon"))continue;const n=1==t.strand?e.geneTrackRowNums[0]:e.geneTrackRowNums[1],o=a.get(n);o?.push({rowNum:n,feature:t})}for(const r of n)for(const n of r){const r=o.getFrame(n.min,n.max,i??1,n.phase),s=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(r);if(void 0===s)continue;a.get(s)||a.set(s,[]);const l=a.get(s);l?.push({rowNum:s,feature:t})}}}}return a}))},getFeatureLayoutPosition(e){const{featureLayouts:t}=this;for(const[n,r]of t.entries())for(const[,t]of r)for(const{feature:r}of t)if(e._id===r._id)return{layoutIndex:n,layoutRow:0,featureRow:0}}}))).views((e=>({get highestRow(){return 5}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(e.lgv.initialized&&!e.regionCannotBeRendered())for(const t of e.regions){const n=e.session.apolloDataStore.assemblies.get(t.assemblyName),r=n?.getByRefName(t.refName),i=r?.features;if(i)for(const[,n]of i)o.doesIntersect2(t.start,t.end,n.min,n.max)&&!e.seenFeatures.has(n._id)&&e.addSeenFeature(n)}}),{name:"LinearApolloSixFrameDisplaySetSeenFeatures",delay:1e3}))}})))}(0,t).named("LinearApolloSixFrameDisplayRendering").props({apolloRowHeight:20,detailsMinHeight:200,detailsHeight:200,lastRowTooltipBufferHeight:120,isShown:!0,filteredTranscripts:l.types.array(l.types.string)}).volatile((()=>({canvas:null,overlayCanvas:null,collaboratorCanvas:null,theme:s.createTheme()}))).views((e=>({get featuresHeight(){return(e.highestRow+1)*e.apolloRowHeight*(e.showFeatureLabels?2:1)+e.lastRowTooltipBufferHeight}}))).actions((e=>({toggleShown(){e.isShown=!e.isShown},setDetailsHeight(t){e.detailsHeight=e.isShown?Math.max(Math.min(t,e.height-100),Math.min(e.height,e.detailsMinHeight)):t},setCanvas(t){e.canvas=t},setOverlayCanvas(t){e.overlayCanvas=t},setCollaboratorCanvas(t){e.collaboratorCanvas=t},setTheme(t){e.theme=t}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.collaboratorCanvas?.getContext("2d");if(t){t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);for(const n of e.session.collaborators){const{locations:r}=n;if(0===r.length)continue;let o=0;for(const i of e.lgv.displayedRegions){for(const a of r){if(a.refSeq!==i.refName)continue;const{end:r,refSeq:s,start:l}=a,c=e.lgv.bpToPx({refName:s,coord:l,regionNumber:o});if(!c)continue;const u=c.offsetPx-e.lgv.offsetPx,d=(r-l)/e.lgv.bpPerPx;t.fillStyle="rgba(0,255,0,.2)",t.fillRect(u,1,d,100),t.fillStyle="black",t.fillText(n.name,u+1,11,d-2)}o++}}}}),{name:"LinearApolloSixFrameDisplayRenderCollaborators"})),l.addDisposer(e,c.autorun((()=>{const{apolloRowHeight:t,canvas:n,featureLayouts:r,featuresHeight:i,lgv:a,session:s,theme:l,showFeatureLabels:c,showStartCodons:u,showStopCodons:d}=e;if(!a.initialized||e.regionCannotBeRendered())return;const{bpPerPx:f,offsetPx:h,displayedRegions:p,dynamicBlocks:g}=a,m=n?.getContext("2d");if(m){m.clearRect(0,0,g.totalWidthPx,i);for(const[t,n]of r.entries()){const r=p[t];for(const[i,a]of n.entries())for(const{feature:n}of a){if(!Zs(n,e.session))continue;if(!o.doesIntersect2(r.start,r.end,n.min,n.max))continue;const{topLevelFeature:a}=n,s=e.getGlyph(a);void 0!==s&&s.draw(m,a,i,e,t)}}if(u||d){const{apolloDataStore:e}=s;for(const n of g.contentBlocks){const r=e.assemblies.get(n.assemblyName),o=r?.getByRefName(n.refName),i=Math.floor(n.start),a=Math.ceil(n.end);let s=o?.getSequence(i,a);if(!s)break;s=s.toUpperCase();const p=Math.round(n.offsetPx-h-(n.start-i)/f);for(let e=0;e<s.length;e++){const n=i+e;uf(m,s.slice(e,e+3),p,e,l,!0,f,n,t,c,u,d)}}}}}),{name:"LinearApolloSixFrameDisplayRenderFeatures"}))}})))}(0,t);return i.named("LinearApolloSixFrameDisplayMouseEvents").volatile((()=>({apolloDragging:null,cursor:void 0}))).views((e=>({getMousePosition(t){const n=function(e,t){const n=e.currentTarget,{clientX:r,clientY:o}=e,{left:i,top:a}=n.getBoundingClientRect(),s=r-i,l=o-a,{coord:c,index:u,refName:d}=t.pxToBp(s);return{x:s,y:l,refName:d,bp:c,regionNumber:u}}(t,e.lgv),{bp:r,regionNumber:i,y:a}=n,s=Math.floor(a/e.apolloRowHeight)+1,l=e.featureLayouts[i].get(s);if(!l)return n;const{featureTypeOntology:c}=e.session.apolloDataStore.ontologyManager;if(!c)throw new Error("featureTypeOntology is undefined");let u;if(e.geneTrackRowNums.includes(s)?(u=l.find((e=>"exon"==e.feature.type&&r>=e.feature.min&&r<=e.feature.max)),u||(u=l.find((e=>r>=e.feature.min&&r<=e.feature.max)))):u=l.find((t=>{const{feature:n}=t,i=n.attributes.get("gff_id")?.toString();if(!c.isTypeOf(n.type,"transcript"))return!1;for(const t of n.cdsLocations)for(const a of t){const t=o.getFrame(a.min,a.max,n.strand??1,a.phase),l=(e.showFeatureLabels?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(t);if(s===l&&r>=a.min&&r<=a.max)return void 0===i||!e.filteredTranscripts.includes(i)}return!1})),!u)return n;const{feature:d}=u;return{...n,feature:d}}}))).actions((e=>({continueDrag(t,n){if(!e.apolloDragging)throw new Error("continueDrag() called with no current drag in progress");n.stopPropagation(),e.apolloDragging={...e.apolloDragging,current:t}},setDragging(t){e.apolloDragging=t??null}}))).actions((e=>({setCursor(t){e.cursor!==t&&(e.cursor=t)},updateFilteredTranscripts(t){e.filteredTranscripts=l.cast(t)}}))).actions((()=>({onClick(){}})))}(0,t).views((e=>({contextMenuItems(t){const{hoveredFeature:n}=e;if(!n)return[];const r=e.getMousePosition(t),{topLevelFeature:o}=n.feature,i=e.getGlyph(o);return ul(r)?i.getContextMenuItems(e,r):[]}}))).actions((e=>({startDrag(t,n,r,o=!1){e.apolloDragging={start:t,current:t,feature:n,edge:r,shrinkParent:o}},endDrag(){if(!e.apolloDragging)throw new Error("endDrag() called with no current drag in progress");const{current:t,edge:n,feature:r,start:o,shrinkParent:i}=e.apolloDragging;if(Math.abs(t.x-o.x)<=4)return e.setDragging(),void e.setCursor();const{displayedRegions:a}=e.lgv,s=e.getAssemblyId(a[o.regionNumber].assemblyName),l=cl(r,t.bp,n,i),c="max"===n?new Tt({typeName:"LocationEndChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldEnd:e.oldLocation,newEnd:e.newLocation}))),assembly:s}):new Et({typeName:"LocationStartChange",changedIds:l.map((e=>e.featureId)),changes:l.map((e=>({featureId:e.featureId,oldStart:e.oldLocation,newStart:e.newLocation}))),assembly:s});e.changeManager.submit(c),e.setDragging(),e.setCursor()}}))).actions((e=>({onMouseDown(t){const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseDown(e,n,t)},onMouseMove(t){const n=e.getMousePosition(t);if(e.apolloDragging)return e.setCursor("col-resize"),void e.continueDrag(n,t);ul(n)?e.getGlyph(n.feature).onMouseMove(e,n,t):(e.setHoveredFeature(),e.setCursor())},onMouseLeave(t){e.setDragging(),e.setHoveredFeature();const n=e.getMousePosition(t);ul(n)&&e.getGlyph(n.feature).onMouseLeave(e,n,t)},onMouseUp(t){const n=e.getMousePosition(t);ul(n)?e.getGlyph(n.feature).onMouseUp(e,n,t):e.setSelectedFeature(),e.apolloDragging&&e.endDrag()}}))).actions((e=>({afterAttach(){l.addDisposer(e,c.autorun((()=>{if(!e.lgv.initialized||e.regionCannotBeRendered())return;const t=e.overlayCanvas?.getContext("2d");if(!t)return;t.clearRect(0,0,e.lgv.dynamicBlocks.totalWidthPx,e.featuresHeight);const{apolloDragging:n,hoveredFeature:r}=e;if(!r)return;const o=e.getGlyph(r.feature);o.drawOverlay(e,t),o.drawTooltip(e,t),n&&e.getGlyph(n.feature.topLevelFeature).drawDragPreview(e,t)}),{name:"LinearApolloSixFrameDisplayRenderMouseoverAndDrag"}))}})))}(0,t).props({tabularEditor:l.types.optional(nd,{})}).named("LinearApolloSixFrameDisplay")}const ff=n.ConfigurationSchema("ApolloPlugin",{ontologies:l.types.array(Fs),featureTypeOntologyName:{description:"Name of the feature type ontology",type:"string",defaultValue:"Sequence Ontology"},hasRole:{description:"Flag used internally by jbrowse-plugin-apollo",type:"boolean",defaultValue:!1},skippedAttributesOnCopy:{description:"Feature attribute keys to skip when copying features",type:"stringArray",defaultValue:[]},geneBackgroundColor:{description:"Color for feature background",type:"string",defaultValue:"jexl:geneBackgroundColor(featureType)",contextVariable:["featureType"]}},{actions:e=>({addOntology(t){e.ontologies.push(t)}})}),hf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogene")||n.isTypeOf(e.type,"pseudogenic_transcript")},pf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"gene")||n.isTypeOf(e.type,"pseudogene")},gf=(e,t)=>{const{featureTypeOntology:n}=t.apolloDataStore.ontologyManager;if(!n)throw new Error("featureTypeOntology is undefined");return n.isTypeOf(e.type,"transcript")||n.isTypeOf(e.type,"pseudogenic_transcript")};function mf(e){const{attributes:t}=e,n=["gene_name","gene_id","gene_stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}const yf=e=>{const t=function(e){const{attributes:t}=e,n=["name","gff_name","transcript_name","gene_name"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e),n=function(e){const{attributes:t}=e,n=["id","gff_id","transcript_id","gene_id","gene_stable_id","stable_id"];for(const e of n){const n=t?.[e];if(n?.[0])return n[0]}return""}(e);return t?`${e.type} - ${t}`:n?`${e.type} - ${n}`:e.type};function _f({annotationFeature:e,assembly:t,handleClose:r,refSeqId:o,session:a,region:c}){const d=a,f=n.readConfObject(d.getPluginConfiguration(),"skippedAttributesOnCopy"),h=new Set(f??[]),{featureTypeOntology:p}=d.apolloDataStore.ontologyManager,g=u.useMemo((()=>Object.keys(e.children??{})),[e]),[m,y]=u.useState(!0),[_,v]=u.useState(g),[b,x]=u.useState(""),[w,S]=u.useState([]),[C,A]=u.useState(!1),[k,N]=u.useState(),T=d.apolloDataStore.assemblies.get(t.name),R=T?.refSeqs.get(o),E=R?.getFeatures(c.start,c.end),I=()=>{const e=[];for(const t of E??[])if(!(t.min>c.end||t.max<c.start)&&p?.isTypeOf(t.type,"gene")){const n=l.getSnapshot(t);e.push(n)}return e};u.useEffect((()=>{x("");const e=I();S(e),N(e[0])}),[_,m,c]);const j=async e=>{if(k)for(const n of Object.keys(e)){const r={...e[n]};if(Aa(r,h),r.strand=k.strand,r.children)for(const e of Object.keys(r.children))r.children[e].strand=k.strand;const o=new ht({parentFeatureId:k._id,changedIds:[k._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:r});await F(o,n)}},D=async n=>{const r={};for(const[e,t]of Object.entries(n)){const n={...t};Aa(n,h),r[e]=n}const i=(new at).toHexString(),a=Math.min(...Object.values(r).map((e=>e.min))),s=Math.max(...Object.values(r).map((e=>e.max))),l=new ht({changedIds:[i],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{_id:i,refSeq:o,min:a,max:s,strand:e.strand,type:"gene",children:r,attributes:{name:[mf(e)],gene_name:[mf(e)]}}});await F(l,i)},O=async(e,n)=>{if(!k)return;const r=[];e!==k.min&&r.push(new Et({typeName:"LocationStartChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldStart:k.min,newStart:e})),n!==k.max&&r.push(new Tt({typeName:"LocationEndChange",changedIds:[k._id],featureId:k._id,assembly:t.name,oldEnd:k.max,newEnd:n}));for(const e of r)await F(e)},F=async(e,t)=>{await d.apolloDataStore.changeManager.submit(e).then((()=>{d.apolloSetSelectedFeature(t)}))};return i.jsxs(Bs,{open:!0,title:"Create Apollo Annotation",handleClose:r,fullWidth:!0,maxWidth:"sm",children:[i.jsx(s.DialogTitle,{fontSize:15,children:"Select the feature to be copied to apollo track"}),i.jsxs(s.DialogContent,{children:[i.jsxs(s.Box,{sx:{ml:3},children:[hf(e,d)&&i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:m,onChange:e=>{const t=e.target.checked;y(t),v(t?g:[])}}),label:`${yf(e)} (${e.min+1}..${e.max})`}),e.children&&i.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",ml:3},children:Object.values(e.children).filter((e=>gf(e,d))).map((e=>i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{size:"small",checked:_.includes(e._id),onChange:t=>{((e,t)=>{v((n=>e.target.checked?[...n,t._id]:n.filter((e=>e!==t._id))))})(t,e)}}),label:`${yf(e)} (${e.min+1}..${e.max})`},e._id)))})]}),w.length>0&&(!m&&_.length>0||m&&gf(e,d))&&i.jsxs("div",{style:{border:"1px solid #ccc",marginTop:20,padding:10,borderRadius:5},children:[i.jsxs(s.Box,{sx:{ml:3},children:[i.jsx(s.Typography,{variant:"caption",fontSize:12,children:"Select the destination feature to copy the selected features"}),i.jsx(s.Box,{sx:{mt:1},children:i.jsx(s.Select,{labelId:"label",style:{width:"100%"},value:k?._id??"",onChange:e=>{const t=w.find((t=>t._id===e.target.value));N(t)},disabled:C,children:w.map((e=>i.jsx(s.MenuItem,{value:e._id,children:`${yf(e)} (${e.min+1}..${e.max})`},e._id)))})})]}),i.jsx(s.Box,{sx:{ml:3},children:i.jsx(s.FormGroup,{children:i.jsx(s.FormControlLabel,{control:i.jsx(s.Checkbox,{checked:C,onChange:e=>{A(e.target.checked)}}),label:"Create new gene"})})})]})]}),i.jsxs(s.DialogActions,{children:[i.jsx(s.Button,{variant:"contained",type:"submit",disabled:0===_.length||!m&&_.length>0&&!k,onClick:async()=>{if(m){if(pf(e,d)&&(await(async()=>{const n={...e};let r;if(Aa(n,h),n.children&&_.length!==Object.values(n.children).length){const o={};for(const e of _)o[e]=n.children[e];r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:{...n,children:o}})}else r=new ht({changedIds:[e._id],typeName:"AddFeatureChange",assembly:t.name,addedFeature:n});await F(r,e._id)})(),a.notify("Successfully copied selected gene and transcript(s)","success")),gf(e,d))if(k&&!C){const t={};if(t[e._id]=e,k.max<e.max||k.min>e.min){const n=Math.min(k.min,e.min),r=Math.max(k.max,e.max);await O(n,r),await j(t)}else await j(t);a.notify("Successfully copied selected transcripts to destination gene","success")}else{const t={};t[e._id]=e,await D(t),a.notify("Successfully created a new gene with selected transcripts","success")}}else{if(!e.children)return;if(k&&!C){const t={};for(const n of _)t[n]=e.children[n];const n=Math.min(...Object.values(t).map((e=>e.min))),r=Math.max(...Object.values(t).map((e=>e.max)));if(k.min>n||k.max<r){const e=Math.min(k.min,n),o=Math.max(k.max,r);await O(e,o),await j(t)}else await j(t);a.notify("Successfully copied transcript to destination gene","success")}else{const t={};for(const n of _)t[n]=e.children[n];await D(t),a.notify("Successfully created a new gene with selected transcript","success")}}r()},children:"Create"}),i.jsx(s.Button,{variant:"outlined",type:"submit",onClick:r,children:"Cancel"})]}),b?i.jsx(s.DialogContent,{children:i.jsx(s.DialogContentText,{color:"error",children:b})}):null]})}function vf(e){return i.jsx(s.SvgIcon,{viewBox:"0 0 856 855",style:{fontSize:18,marginRight:4},...e,children:i.jsxs("g",{children:[i.jsx("path",{style:{opacity:.68,fill:"#AEAEAE"},d:"M276.7,656.9l85-148h102.9c23.1,0,16.1-16,11.1-25l-134-238.5l85-148l185,315.6c0,0-15-26.3,0,0\n\t\t\tc53,92.9-24,243.9-132,243.9c-6,0-4,0-6.4,0H276.7z"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"49.7,756.9 219.1,756.9 513.7,246.9 425.7,99.9 \t\t"}),i.jsx("polygon",{style:{opacity:.85,fill:"#717171"},points:"630,756.9 806.4,756.9 513.7,246.9 425.1,400.2 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"175.7,657.3 195.6,657.3 277.9,508.9 254.1,508.9 170.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"369.7,657.3 389.6,657.3 471.9,508.9 448.1,508.9 364.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"321.7,657.3 341.6,657.3 423.9,508.9 400.1,508.9 316.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"224.7,657.3 244.6,657.3 326.9,508.9 303.1,508.9 219.6,657.3 \t\t"}),i.jsx("polygon",{style:{fill:"#C6C6C6"},points:"273.7,657.3 293.6,657.3 375.9,508.9 352.1,508.9 268.6,657.3 \t\t"})]})})}function bf(e){if("LinearPileupDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=this.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a},getAnnotationFeature(e,t){const n=e.get("start"),r=e.get("end"),o=e.get("strand"),i=e.get("name"),a=function(e){const t=/(\d+)([MIDNSHPX=])/g,n=[];let r;for(;null!==(r=t.exec(e));)n.push([r[2],Number.parseInt(r[1],10)]);return n}(e.get("CIGAR"));let s,l=n;const c=[];for(const[e,t]of a)switch(e){case"M":case"=":case"X":void 0===s&&(s=l),l+=t;break;case"N":void 0!==s&&(c.push({start:s,end:l}),s=void 0),l+=t;break;case"D":l+=t;break;case"I":case"S":case"H":case"P":break;default:throw new Error(`Unknown CIGAR operation: ${e}`)}void 0!==s&&c.push({start:s,end:l});const u={_id:at().toHexString(),refSeq:t,min:n,max:r,type:"mRNA",strand:o};if(i&&(u.attributes={},u.attributes.gff_name=[i]),0===c.length)return u;u.children={};for(const e of c){const n={_id:at().toHexString(),refSeq:t,min:e.start,max:e.end,type:"exon",strand:o};u.children[n._id]=n}return u}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;return a?[...t(),{label:"Create Apollo annotation",icon:vf,onClick:async()=>{const t=n.apolloDataStore.getBackendDriver(i.assemblyName);let o=i.refName;if(t instanceof Sl){const e=await t.getRefSeqId(i.assemblyName,i.refName);if(!e)throw new Error(`Could not find refSeq for "${i.refName}"`);o=e}n.queueDialog((t=>[_f,{session:n,handleClose:()=>{t()},annotationFeature:e.getAnnotationFeature(a,o),assembly:r,refSeqId:o,region:i}]))}}]:t()}}}));return e.stateModel=n,e}function xf(e,t){const n=e.get("subfeatures");return[{start:e.get("start")+1,end:e.get("end"),seq_id:t,source:e.get("source")??null,type:e.get("type")??null,score:e.get("score")??null,strand:e.get("strand")?1===e.get("strand")?"+":"-":null,phase:null!==e.get("phase")||void 0!==e.get("phase")?e.get("phase"):null,attributes:Af(e),derived_features:[],child_features:n?n.map((e=>xf(e,t))):[]}]}function wf(e,t){return Fn(xf(e,t))}const Sf=new Set(["start","end","type","strand","refName","subfeatures","derived_features","phase","source","score","parent","__jbrowsefmt","length","position","uniqueId","exonFrames","parentId","thickStart","thickEnd","_lineHash"]),Cf={id:"gff_id",name:"gff_name",alias:"gff_alias",target:"gff_target",gap:"gff_gap",derives_from:"gff_derives_from",note:"gff_note",dbxref:"gff_dbxref",ontology_term:"gff_ontology_term",is_circular:"gff_is_circular"};function Af(e){const t={};for(const[n,r]of Object.entries(e.toJSON()))Sf.has(n)||(t[Cf[n]??n]=Array.isArray(r)?r.map(String):[String(r)]);return t}function kf(e){if("LinearBasicDisplay"!==e.name)return e;const{stateModel:t}=e,n=t.views((e=>({getFirstRegion:()=>o.getContainingView(e).dynamicBlocks.contentBlocks[0],getAssembly(){const t=e.getFirstRegion(),n=o.getSession(e),{assemblyManager:r}=n,{assemblyName:i}=t,a=r.get(i);if(!a)throw new Error(`Could not find assembly named ${i}`);return a}}))).views((e=>{const t=e.contextMenuItems;return{contextMenuItems(){const n=o.getSession(e),r=e.getAssembly(),i=e.getFirstRegion(),a=e.contextMenuFeature;if(!a)return t();const s=function(e){let t=e,n=e.get("parent");for(;n;)t=n,n=n.get("parent");return t}(a);return[...t(),{label:"Create Apollo annotation",icon:vf,onClick:async()=>{const e=n.apolloDataStore.getBackendDriver(i.assemblyName);let t=i.refName;if(e instanceof Sl){const n=await e.getRefSeqId(i.assemblyName,i.refName);if(!n)throw new Error(`Could not find refSeq for "${i.refName}"`);t=n}const o=wf(s,t);n.queueDialog((e=>[_f,{session:n,handleClose:()=>{e()},annotationFeature:o,assembly:r,refSeqId:t,region:i}]))}}]}}}));return e.stateModel=n,e}var Nf=a.createSvgIcon(i.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess"),Tf=a.createSvgIcon(i.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"}),"Lock"),Rf=a.createSvgIcon(i.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"Error");const Ef=p.observer((function({display:e}){const{classes:t}=Md(),{apolloDragging:n,apolloRowHeight:r,lgv:a,session:l,showCheckResults:c}=e,{assemblyManager:u}=l;return c?a.dynamicBlocks.contentBlocks.map((c=>{const d=a.bpPerPx*r,f=u.get(c.assemblyName);return f?Ld([...l.apolloDataStore.checkResults.values()].filter((e=>f.isValidRefName(e.refSeq)&&f.getCanonicalRefName(e.refSeq)===c.refName&&o.doesIntersect2(c.start,c.end,e.start,e.end))),d).map((o=>{const a=Math.round(rd(e,o.range,c)),[l]=o.featureIds;if(!l)return null;const u=e.getRowForFeature(l)??0;return i.jsx(s.Tooltip,{title:o.message,children:i.jsx(s.Box,{className:t.box,style:{top:u*r,left:a,height:r,width:r,pointerEvents:n?"none":"auto"},children:i.jsx(s.Badge,{className:t.badge,badgeContent:o.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:o.count<=1,children:i.jsx(s.Avatar,{className:t.avatar,children:i.jsx(Rf,{"data-testid":`ErrorIcon-${o.start}`})})})})},o._id)})):null})):null})),If=p.observer((function(e){const{mouseCooordinate:t,session:n,dragging:r}=e,{apolloHoveredFeature:o}=n;if(!t||!o||r)return;const[a,s]=t,{feature:l}=o,{attributes:c,min:u,max:d}=l,f=`Loc: ${u+1}..${d}`,p=`Type: ${l.type}`,g=c.get("gff_name")?.find((e=>""!==e));return i.jsxs(h.BaseTooltip,{clientPoint:{x:a,y:s},placement:"top-start",children:[p,i.jsx("br",{}),g?i.jsxs(i.Fragment,{children:[g,i.jsx("br",{})]}):null,f]})})),jf=p.observer((function(e){const{model:t}=e,{apolloDragging:n,cursor:r,featuresHeight:a,isShown:s,onMouseDown:l,onMouseLeave:c,onMouseMove:d,onMouseUp:f,session:h,setOverlayCanvas:p}=t,{classes:g}=Md(),m=o.getContainingView(t),[y,_]=u.useState();if(!s)return null;const v=a(m.assemblyNames[0]);return i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:m.dynamicBlocks.totalWidthPx,height:v,onMouseMove:(...e)=>{const[t]=e;_([t.clientX,t.clientY]),d(...e)},onMouseLeave:(...e)=>{_(void 0),c(...e)},onMouseDown:l,onMouseUp:f,className:g.canvas,style:{cursor:r??"default"},"data-testid":"overlayCanvas"}),i.jsx(If,{mouseCooordinate:y,session:h,dragging:Boolean(n)})]})})),Df=p.observer((function(e){const t=s.useTheme(),{model:n}=e,{loading:r,contextMenuItems:a,featuresHeight:l,isShown:c,regionCannotBeRendered:d,session:f,setCanvas:p,setCollaboratorCanvas:g,setTheme:m}=n,{classes:y}=Md(),_=o.getContainingView(n);u.useEffect((()=>{m(t)}),[t,m]);const[v,b]=u.useState(),[x,w]=u.useState([]),S=d();if(!c)return null;const C=l(_.assemblyNames[0]);return i.jsxs("div",{className:y.canvasContainer,style:{width:_.dynamicBlocks.totalWidthPx,height:C},onContextMenu:e=>{e.preventDefault(),x.length>0?w([]):(b([e.clientX,e.clientY]),w(a(e)))},children:[f.isLocked?i.jsx("div",{className:y.locked,"data-testid":"lock-icon",children:i.jsx(Tf,{})}):null,r?i.jsx("div",{className:y.loading,children:i.jsx(s.CircularProgress,{size:"18px"})}):null,S?i.jsx(s.Alert,{severity:"warning",classes:{message:y.ellipses},slotProps:{root:{className:y.center}},children:i.jsx(s.Tooltip,{title:S,children:i.jsx("div",{children:S})})}):i.jsxs(i.Fragment,{children:[i.jsx("canvas",{ref:async e=>{await Promise.resolve(),g(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),p(e)},width:_.dynamicBlocks.totalWidthPx,height:C,className:y.canvas,"data-testid":"canvas"}),i.jsx(jf,{model:n}),i.jsx(Ef,{display:n}),i.jsx(h.Menu,{open:x.length>0,onMenuItemClick:(e,t)=>{t(),w([])},onClose:()=>{w([])},slotProps:{transition:{onExit:()=>{w([])}}},anchorReference:"anchorPosition",anchorPosition:v?{top:v[1],left:v[0]}:void 0,menuItems:x})]})]})})),Of=p.observer((function({model:e,hrStyle:t={margin:0,top:0,color:"black"},idx:n=0}){const{apolloRowHeight:r,highestRow:o,showFeatureLabels:a}=e,s=a?2:1;return i.jsx("div",{style:{position:"absolute",left:0,top:r*s*(o+1)/2+n*s*r,width:"100%"},children:i.jsx("hr",{style:t})})})),Ff=p.observer((function(e,t){const n=s.useTheme(),{model:r}=e,{apolloRowHeight:a,contextMenuItems:l,cursor:c,featuresHeight:d,geneTrackRowNums:f,isShown:p,onMouseDown:g,onMouseLeave:m,onMouseMove:y,onMouseUp:_,regionCannotBeRendered:v,session:b,setCanvas:x,setCollaboratorCanvas:w,setOverlayCanvas:S,setTheme:C,showCheckResults:A,showFeatureLabels:k}=r,{classes:N}=Md(),T=o.getContainingView(r);u.useEffect((()=>{C(n)}),[n,C]);const[R,E]=u.useState(),[I,j]=u.useState([]),D=v();if(!p)return null;const{assemblyManager:O}=b;return i.jsx(i.Fragment,{children:i.jsxs("div",{className:N.canvasContainer,style:{width:T.dynamicBlocks.totalWidthPx,height:d},onContextMenu:e=>{e.preventDefault(),I.length>0?j([]):(E([e.clientX,e.clientY]),j(l(e)))},children:[b.isLocked?i.jsx("div",{className:N.locked,"data-testid":"lock-icon",children:i.jsx(Tf,{})}):null,D?i.jsx(s.Alert,{severity:"warning",classes:{message:N.ellipses},slotProps:{root:{className:N.center}},children:i.jsx(s.Tooltip,{title:D,children:i.jsx("div",{children:D})})}):i.jsxs(i.Fragment,{children:[i.jsx(Of,{model:r,idx:0}),i.jsx(Of,{model:r,hrStyle:{margin:0,top:0,color:"grey",opacity:.4},idx:1}),i.jsx(Of,{model:r,idx:2}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),w(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"collaboratorCanvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),x(e)},width:T.dynamicBlocks.totalWidthPx,height:d,className:N.canvas,"data-testid":"canvas"}),i.jsx("canvas",{ref:async e=>{await Promise.resolve(),S(e)},width:T.dynamicBlocks.totalWidthPx,height:d,onMouseMove:y,onMouseLeave:m,onMouseDown:g,onMouseUp:_,className:N.canvas,style:{cursor:c??"default"},"data-testid":"overlayCanvas"}),T.displayedRegions.flatMap(((e,n)=>{const r=T.bpPerPx*a,l=O.get(e.assemblyName);return A?Ld([...b.apolloDataStore.checkResults.values()].filter((t=>l?.isValidRefName(t.refSeq)&&l.getCanonicalRefName(t.refSeq)===e.refName&&o.doesIntersect2(e.start,e.end,t.start,t.end))),r).map((r=>{const l=(T.bpToPx({refName:e.refName,coord:r.start,regionNumber:n})?.offsetPx??0)-T.offsetPx,[c]=r.featureIds;if(!c||!c.parent||!Zs(c.parent,b))return null;let u;for(const e of c.cdsLocations)for(const t of e){const e=o.getFrame(t.min,t.max,c.strand??1,t.phase),n=(k?[0,5,3,1,15,13,11]:[0,2,1,0,8,7,6]).at(e);if(void 0!==n&&r.start>=t.min&&r.start<=t.max){u=n-1;break}}return void 0===u&&(u=(1==c.strand?f[0]:f[1])-1),i.jsx(s.Tooltip,{title:r.message,children:i.jsx(s.Box,{className:N.box,style:{top:u*a,left:l,height:a,width:a,pointerEvents:t?"none":"auto"},children:i.jsx(s.Badge,{className:N.badge,badgeContent:r.count,color:"primary",overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},invisible:r.count<=1,children:i.jsx(s.Avatar,{className:N.avatar,children:i.jsx(Rf,{"data-testid":`ErrorIcon-${r.start}`})})})})},r._id)})):null})),i.jsx(h.Menu,{open:I.length>0,onMenuItemClick:(e,t)=>{t(),j([])},onClose:()=>{j([])},slotProps:{transition:{onExit:()=>{j([])}}},anchorReference:"anchorPosition",anchorPosition:R?{top:R[1],left:R[0]}:void 0,style:{zIndex:n.zIndex.tooltip},menuItems:I})]})]})})})),Mf=ma()((e=>({shading:{background:s.alpha(e.palette.primary.main,.2),overflowX:"hidden"},details:{background:e.palette.background.paper},accordionControl:{height:12,width:"100%","&:hover":{background:e.palette.action.hover},display:"flex",alignItems:"center",justifyContent:"center"},accordionRoot:{background:e.palette.divider},resizeHandle:{width:"100%",height:4,position:"absolute",cursor:"row-resize",zIndex:100},expandIcon:{},title:{userSelect:"none"},alertContainer:{display:"flex",alignItems:"center",justifyContent:"center"}})));function Lf(e,t){const{apolloRowHeight:n,selectedFeature:r}=e;if(t.current&&r){let o;if("getFeatureLayoutPosition"in e){const t=e.getFeatureLayoutPosition(r);t&&(o=t.layoutRow+t.featureRow)}else o=e.getRowForFeature(r);void 0!==o&&t.current.scroll({top:o*n,behavior:"smooth"})}}const Pf=({onResize:e})=>{const{classes:t}=Mf(),n=u.useCallback((t=>{t.stopPropagation(),t.preventDefault(),e(t.movementY)}),[e]);return i.jsx("div",{onMouseDown:e=>{e.stopPropagation();const t=new AbortController,{signal:r}=t;function o(){t.abort(new DOMException("Canceling drag event listener","AbortError"))}globalThis.addEventListener("mousemove",n,{signal:r}),globalThis.addEventListener("mouseup",o,{signal:r}),globalThis.addEventListener("mouseleave",o,{signal:r})},onClick:e=>{e.stopPropagation(),e.preventDefault()},className:t.resizeHandle})},Bf=p.observer((function({onClick:e,onResize:t,open:n,title:r}){const{classes:o}=Mf();return i.jsxs("div",{className:o.accordionRoot,children:[n&&t?i.jsx(Pf,{onResize:t}):null,i.jsxs("div",{className:o.accordionControl,onClick:e,children:[i.jsx(n?Nf:Fc,{className:o.expandIcon}),r?i.jsx(s.Typography,{className:o.title,variant:"caption",component:"span",children:r}):null]})]})})),qf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=Mf(),{graphical:d,height:f,isShown:h,selectedFeature:p,table:g,tabularEditor:m,toggleShown:y}=e,_=u.useRef(null);u.useEffect((()=>{Lf(e,_)}),[e,p]);const v=t=>{e.setDetailsHeight(e.detailsHeight-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(d&&g){const n=m.isShown?e.detailsHeight:0,r=h?f-e.detailsHeight-24:0;return i.jsxs("div",{style:{height:f},children:[i.jsx(Bf,{open:h,title:"Graphical",onClick:y}),i.jsx("div",{className:c.shading,ref:_,style:{height:r},children:i.jsx(Df,{model:e,...t})}),i.jsx(Bf,{title:"Table",open:m.isShown,onClick:m.togglePane,onResize:v}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(td,{model:e})})]})}return i.jsx("div",d?{className:c.shading,ref:_,style:{height:f},children:i.jsx(Df,{model:e,...t})}:{className:c.details,style:{height:f},children:i.jsx(td,{model:e})})})),Uf=p.observer((function({model:e,...t}){const n=o.getSession(e),{ontologyManager:r}=n.apolloDataStore,{featureTypeOntology:a}=r,l=a?.dataStore,{classes:c}=Mf(),{detailsHeight:d,graphical:f,height:h,isShown:p,selectedFeature:g,table:m,tabularEditor:y,toggleShown:_}=e,v=u.useRef(null);u.useEffect((()=>{Lf(e,v)}),[e,g]);const b=t=>{e.setDetailsHeight(d-t)};if(!l)return i.jsx("div",{className:c.alertContainer,children:i.jsx(s.Alert,{severity:"error",children:"Could not load feature type ontology."})});if(f&&m){const n=y.isShown?d:0,r=p?h-d-24:0;return i.jsxs("div",{style:{height:h},children:[i.jsx(Bf,{open:p,title:"Graphical",onClick:_}),i.jsx("div",{className:c.shading,ref:v,style:{height:r},children:i.jsx(Ff,{model:e,...t})}),i.jsx(Bf,{title:"Table",open:y.isShown,onClick:y.togglePane,onResize:b}),i.jsx("div",{className:c.details,style:{height:n},children:i.jsx(td,{model:e})})]})}return i.jsx("div",f?{className:c.shading,ref:v,style:{height:h},children:i.jsx(Ff,{model:e,...t})}:{className:c.details,style:{height:h},children:i.jsx(td,{model:e})})}));var $f=a.createSvgIcon(i.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"}),"Logout"),zf=a.createSvgIcon(i.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"}),"Redo"),Hf=a.createSvgIcon(i.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo"),Gf=a.createSvgIcon(i.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save");const Vf=l.types.model("JobsManager",{}).views((e=>({get jobStatusWidget(){const{widgets:t}=o.getSession(e);let n=t.get("JobsList");return n||(n=o.getSession(e).addWidget("JobsListWidget","JobsList")),n}}))).actions((e=>({update(t,n,r){e.jobStatusWidget.updateJobStatusMessage(t,n),r&&e.jobStatusWidget.updateJobProgressPct(t,r)},abortJob(t,n){const r=o.getSession(e);if(o.isSessionModelWithWidgets(r)){r.showWidget(e.jobStatusWidget),e.jobStatusWidget.updateJobStatusMessage(t,n??"Aborted unexpectedly");const o=e.jobStatusWidget.jobs.findIndex((e=>e.name===t));e.jobStatusWidget.addAbortedJob({...e.jobStatusWidget.jobs[o]}),e.jobStatusWidget.removeJob(t),r.notify("Job aborted","info")}},runJob(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.addJob(t))},done(t){const n=o.getSession(e);o.isSessionModelWithWidgets(n)&&(n.showWidget(e.jobStatusWidget),e.jobStatusWidget.removeJob(t.name),e.jobStatusWidget.addFinishedJob({name:t.name,statusMessage:"All operations successful",progressPct:100,cancelCallback:t.cancelCallback}))}})));function Wf(e,t){const r=e.evaluateExtensionPoint("Apollo-extendAnnotationFeature",ru),i=function(e){return l.types.model("ClientDataStore",{typeName:l.types.optional(l.types.literal("Client"),"Client"),assemblies:l.types.map(au),checkResults:l.types.map(su),ontologyManager:l.types.optional(Os,{})}).views((t=>({get internetAccounts(){return l.getRoot(t).internetAccounts},get pluginConfiguration(){return l.getRoot(t).jbrowse.configuration.ApolloPlugin},getFeature:n=>l.resolveIdentifier(e,t.assemblies,n)}))).actions((e=>({addAssembly(t,n){const r={_id:t,refSeqs:{}};return n&&(r.backendDriverType=n),e.assemblies.put(r)}}))).actions((e=>({addFeature(t,n){const r=o.getSession(e),{assemblyManager:i}=r;let a=e.assemblies.get(t);if(!a){if(!i.get(t))throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);a=e.addAssembly(t)}let s=a.refSeqs.get(n.refSeq);if(!s){const e=i.get(t);if(!e)throw new Error(`Could not find assembly "${t}" to add feature "${n._id}"`);const r=e.getCanonicalRefName(n.refSeq);if(!r)throw new Error(`Could not find refSeq "${n.refSeq}" to add feature "${n._id}"`);s=a.addRefSeq(n.refSeq,r)}s.features.put(n)},deleteFeature(t){const n=e.getFeature(t);if(!n)throw new Error(`Could not find feature "${t}" to delete`);const{_id:r,parent:o}=n;o?o.deleteChild(t):l.getParentOfType(n,iu).deleteFeature(r)},deleteAssembly(t){e.assemblies.delete(t)},addCheckResult(t){e.checkResults.put(t)},addCheckResults(t){for(const n of t)e.checkResults.has(n._id)||e.checkResults.put(n)},deleteCheckResult(t){e.checkResults.delete(t)},clearCheckResults(){e.checkResults.clear()}}))).volatile((e=>({changeManager:new wl(e),collaborationServerDriver:new Sl(e),localDriver:new bl(e)}))).actions((e=>({afterCreate(){l.addDisposer(e,c.autorun((()=>{const{ontologyManager:t,pluginConfiguration:r}=e,i=r.ontologies;for(const r of i||[]){const[i,a,s,l]=[n.readConfObject(r,"name"),n.readConfObject(r,"version"),n.readConfObject(r,"source"),n.readConfObject(r,"textIndexFields")];if(!t.findOntology(i)){const n=o.getSession(e),{jobsManager:r}=n,c=new AbortController,u=`Loading ontology "${i}"`,d={name:u,statusMessage:`Loading ontology "${i}", version "${a}", this may take a while`,progressPct:0,cancelCallback:()=>{c.abort(new DOMException(`Canceling loading of ontology "${i}"`,"AbortError")),r.abortJob(d.name)}};t.addOntology(i,a,s,{textIndexing:{indexFields:l},update:(e,t)=>{0!==t?100!==t?r.update(u,e,t):r.done(d):r.runJob(d)}})}}})))}}))).views((e=>({getBackendDriver(t){const r=o.getSession(e),{assemblyManager:i}=r,a=i.get(t);if(!a)return;const{internetAccountConfigId:s}=n.getConf(a,["sequence","metadata"]);return s?e.collaborationServerDriver:e.localDriver},getInternetAccount(t,r){if(!(t??r))throw new Error("Must provide either assemblyName or internetAccountId");let i=r;if(t&&!i){const{assemblyManager:r}=o.getSession(e),a=r.get(t);if(!a)throw new Error(`No assembly found with name ${t}`);({internetAccountConfigId:i}=n.getConf(a,["sequence","metadata"]))}const{internetAccounts:a}=e,s=a.find((e=>e.internetAccountId===i));if(!s)throw new Error(`No InternetAccount found with config id ${r}`);return s}}))).actions((e=>({loadFeatures:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const[r,o]=yield t.getFeatures(n);if(0===r.length)continue;const{assemblyName:i,refName:a}=n;let s=e.assemblies.get(i);s||(s=e.assemblies.put({_id:i,refSeqs:{}}));const[l]=r;let c=s.refSeqs.get(l.refSeq);c||(c=s.refSeqs.put({_id:l.refSeq,name:a,features:{}}));for(const e of r)c.features.has(e._id)||c.features.put(e);e.addCheckResults(o)}})),loadRefSeq:l.flow((function*(t){for(const n of t){const t=e.getBackendDriver(n.assemblyName);if(!t)return;const{refSeq:r,seq:o}=yield t.getSequence(n),{assemblyName:i,end:a,refName:s,start:l}=n;let c=e.assemblies.get(i);c||(c=e.assemblies.put({_id:i,refSeqs:{}}));let u=c.refSeqs.get(r);u||(u=c.refSeqs.put({_id:r,name:s,sequence:[]})),u.addSequence({start:l,stop:a,sequence:o})}}))})))}(r),a=t.props({apolloDataStore:l.types.optional(i,{typeName:"Client"}),apolloSelectedFeature:l.types.safeReference(r),jobsManager:l.types.optional(Vf,{}),isLocked:l.types.optional(l.types.boolean,!1),changeInProgress:l.types.optional(l.types.boolean,!1)}).volatile((()=>({apolloHoveredFeature:void 0,abortController:new AbortController}))).extend((()=>{const e=c.observable.array([]);return{views:{get collaborators(){return e}},actions:{addOrUpdateCollaborator(t){const n=e.find((e=>e.id===t.id));n?n.locations=t.locations:e.push(t)}}}})).actions((e=>({apolloSetSelectedFeature(t){e.apolloSelectedFeature=t},apolloSetHoveredFeature(t){e.apolloHoveredFeature=t},addApolloLocalTrackConfig(t){const n=`apollo_track_${t.name}`;e.tracks.some((e=>e.trackId===n))||l.getRoot(e).jbrowse.addTrackConf({type:"ApolloTrack",trackId:n,name:`Annotations (${t.displayName})`,assemblyNames:[t.name],category:["Apollo"]})},toggleLocked(){e.isLocked=!e.isLocked},setChangeInProgress(t){e.changeInProgress=t},getPluginConfiguration(){const{jbrowse:t}=l.getRoot(e);return t.configuration.ApolloPlugin},broadcastLocations(){const{internetAccounts:t}=l.getRoot(e),n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);s&&"CollaborationServerDriver"===s.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Wl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Wl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}}))).actions((e=>({apolloSetEventualSelectedFeature:c.flow((function*(t){yield c.when((()=>Boolean(e.apolloDataStore.getFeature(t)))),e.apolloSetSelectedFeature(t)}))}))).volatile((e=>({previousSnapshot:l.getSnapshot(e)}))).actions((e=>({afterCreate(){l.applySnapshot(e,{name:e.name,id:e.id});const{internetAccounts:t,jbrowse:r,reloadPluginManagerCallback:o}=l.getRoot(e);l.addDisposer(e,c.autorun((()=>{const n=[];for(const t of e.views){if("LinearGenomeView"!==t.type)return;const r=t;if(r.initialized){const{dynamicBlocks:t}=r;for(const r of t.contentBlocks){const{assemblyName:t,end:o,refName:i,start:a}=r,s=e.apolloDataStore.assemblies.get(t);s&&"CollaborationServerDriver"===s.backendDriverType&&n.push({assemblyName:t,refName:i,start:a,end:o})}}}if(0===n.length){for(const e of t)Wl(e)&&e.postUserLocation([]);return}const r=[];for(const e of t)if(Wl(e)){for(const e of n)r.push({assemblyId:e.assemblyName,refSeq:e.refName,start:e.start,end:e.end});e.postUserLocation(r)}}),{name:"ApolloSessionBroadcastLocations"})),l.addDisposer(e,c.autorun((async i=>{const a=r.configuration.ApolloPlugin,s=n.readConfObject(a,"hasRole"),c=n.readConfObject(a,"featureTypeOntologyName"),u=t.some((e=>Wl(e))),d=e.assemblyManager.assemblies.filter((e=>!n.getConf(e,["sequence","metadata"]).apollo));if(!u||s){const{assemblies:t}=e.assemblyManager;if(0===t.length)return;const{pluginConfiguration:r}=e.apolloDataStore;r.ontologies.find((e=>n.readConfObject(e,"name")===c))||r.addOntology({name:"Sequence Ontology",version:"01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa",source:{uri:"https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/01c33c6d9b6c8dca12e7d3e37b49ee113093c2fa/Ontology_Files/so.json",locationType:"UriLocation"}});for(const t of d)e.addApolloLocalTrackConfig(t);return l.applySnapshot(e,e.previousSnapshot),void i.dispose()}const{signal:f}=e.abortController;for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const{baseURL:t}=n,r=new URL("jbrowse/config.json",t).href,a=n.getFetcher({locationType:"UriLocation",uri:r});let s,l;try{s=await a(r,{signal:f})}catch(t){e.abortController.signal.aborted||console.error(t);continue}if(s.ok){try{l=await s.json()}catch(e){console.error(e);continue}l.configuration.ApolloPlugin.hasRole&&(o(l,e.previousSnapshot),i.dispose())}else{const e=await dl(s,"Failed to fetch assemblies");console.error(e)}}}),{name:"ApolloSessionLoadConfig"}))},beforeDestroy(){e.abortController.abort(new DOMException("Clean up Apollo session","AbortError"))}}))).views((e=>{const t=e.getTrackActions;return{getTrackActions(r){if("ApolloTrack"===r.type||"ReferenceSequenceTrack"===r.type)return t?.(r);const o=n.readConfObject(r,"trackId");return o.endsWith("-sessionTrack")?[...t?.(r)??[],{label:"Save track to Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a={...l.getSnapshot(r),trackId:o.slice(0,o.length-13)};for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:i?.tracks&&[...i.tracks,a]}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track added","success")}e.deleteTrackConf(r),n.addTrackConf(a)},icon:Gf}]:[...t?.(r)??[],{label:"Remove track from Apollo",onClick:async()=>{const{internetAccounts:t,jbrowse:n}=l.getRoot(e);let i;i=kt(l.getSnapshot(n)),0===Object.keys(i).length&&(i=void 0);const a=i?.tracks?.filter((e=>e.trackId!==o));for(const n of t){if("ApolloInternetAccount"!==n.type)continue;const t=new Nt({typeName:"ImportJBrowseConfigChange",oldJBrowseConfig:i,newJBrowseConfig:{...i,tracks:a}}),{internetAccountId:r}=n;await e.apolloDataStore.changeManager.submit(t,{internetAccountId:r});const{notify:o}=e;o("Track removed","success")}e.deleteTrackConf(r),n.deleteTrackConf(r)},icon:Gf}]}}}));return l.types.snapshotProcessor(a,{postProcessor(e,t){if(e.apolloSelectedFeature=void 0,e.apolloDataStore={typeName:"Client",checkResults:{}},!t)return e;const{apolloDataStore:n}=t,{checkResults:r}=n;for(const[,e]of r){const[t]=e.ids}return e}})}const Jf="WorkerGlobalScope"in globalThis;for(const[e,t]of Object.entries(Gt))Q.registerChange(e,t);const Kf=new Sn;ne.registerCheck(Kf.name,Kf);const Yf=new Rn;ne.registerCheck(Yf.name,Yf),Kt.registerValidation(new Xt),Kt.registerValidation(new Zt),e.default=class extends t{name="ApolloPlugin";version="1.0.0";configurationSchema=ff;install(e){!function(e){e.addAdapterType((()=>new y({name:"ApolloSequenceAdapter",configSchema:Ec,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Rc})))}(e),function(e){e.addAdapterType((()=>new y({name:"ApolloRefNameAliasAdapter",configSchema:Cc,adapterMetadata:{category:void 0,hiddenFromGUI:!0,description:void 0},AdapterClass:Sc})))}(e),function(e){e.addTextSearchAdapterType((()=>new r.TextSearchAdapterType({name:"ApolloTextSearchAdapter",displayName:"Apollo text search adapter",configSchema:Oc,AdapterClass:Dc,description:"Apollo Text Search adapter"})))}(e),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloFeatureDetailsWidget",{});return new r.WidgetType({name:"ApolloFeatureDetailsWidget",heading:"Apollo feature details",configSchema:e,stateModel:lu,ReactComponent:tu})})),e.addWidgetType((()=>{const e=n.ConfigurationSchema("ApolloTranscriptDetails",{});return new r.WidgetType({name:"ApolloTranscriptDetails",heading:"Apollo transcript details",configSchema:e,stateModel:cu,ReactComponent:Lu})})),e.addTrackType((()=>{const t=n.ConfigurationSchema("ApolloTrack",{adapter:""},{baseConfiguration:r.createBaseTrackConfig(e),explicitIdentifier:"trackId"});return new r.TrackType({name:"ApolloTrack",configSchema:t,stateModel:r.createBaseTrackModel(e,"ApolloTrack",t)})})),e.addInternetAccountType((()=>new r.InternetAccountType({name:"ApolloInternetAccount",configSchema:Pn,stateModel:bc(Pn)}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloDisplay",configSchema:Pu,stateModel:qd(0,Pu),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:qf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloSixFrameDisplay",configSchema:Qd,stateModel:df(0,Qd),trackType:"ApolloTrack",viewType:"LinearGenomeView",ReactComponent:Uf}))),e.addDisplayType((()=>new r.DisplayType({name:"LinearApolloReferenceSequenceDisplay",configSchema:Ud,stateModel:Xd(0,Ud),displayName:"Apollo reference sequence display",trackType:"ReferenceSequenceTrack",viewType:"LinearGenomeView",ReactComponent:Zd}))),e.addToExtensionPoint("Core-extendSession",Wf.bind(this,e)),e.addToExtensionPoint("Core-extendPluggableElement",(e=>{if("LinearGenomeView"===e.name){const{stateModel:t}=e,n=t.views((e=>{const t=e.rubberBandMenuItems;return{rubberBandMenuItems:()=>[...t(),{label:"Add new feature",icon:Ln,onClick:()=>{const t=o.getSession(e),{leftOffset:n,rightOffset:r}=e,i=e.getSelectedRegions(n,r);t.queueDialog((e=>[kl,{session:t,handleClose:()=>{e()},region:i[0],changeManager:t.apolloDataStore.changeManager}]))}}]}}));e.stateModel=n}return e})),e.addToExtensionPoint("Core-extendPluggableElement",bf),e.addToExtensionPoint("Core-extendPluggableElement",kf),e.addToExtensionPoint("Core-preProcessTrackConfig",(e=>{if("ReferenceSequenceTrack"!==e.type)return e;const t=e.displays??[],n=t.findIndex((e=>"LinearApolloReferenceSequenceDisplay"===e.type));if(0===n)return e;if(-1===n)return{...e,displays:[{type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`},...t]};const r=t.toSpliced(n,1);return r.unshift({type:"LinearApolloReferenceSequenceDisplay",displayId:`${e.trackId}-LinearApolloReferenceSequenceDisplay`}),{...e,displays:r}})),e.addToExtensionPoint("LinearGenomeView-searchResultSelected",((e,t)=>{const{session:n,result:r}=t,o=r.getTrackId(),i=r.matchedObject;return o?.startsWith("apollo_track_")&&i&&n.apolloSetEventualSelectedFeature(i._id),e})),Jf||e.addToExtensionPoint("Core-extendWorker",(t=>"on"in t&&t.on?(t.on("apollo",(async n=>{if("object"!=typeof(r=n)||null===r||!("apollo"in r)||!0!==r.apollo)return;var r;const{apollo:o,messageId:i,method:a}=n;switch(a){case"getSequence":{const{region:r}=n,{assemblyName:a}=r,s=e.rootModel?.session?.apolloDataStore;if(!s)break;const l=s.getBackendDriver(a);if(!l)break;const{seq:c}=await l.getSequence(r);t.workers[0].postMessage({apollo:o,messageId:i,sequence:c});break}case"getRegions":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRegions(r);t.workers[0].postMessage({apollo:o,messageId:i,regions:l});break}case"getRefNameAliases":{const{assembly:r}=n,a=e.rootModel?.session?.apolloDataStore;if(!a)break;const s=a.getBackendDriver(r);if(!s)break;const l=await s.getRefNameAliases(r);t.workers[0].postMessage({apollo:o,messageId:i,refNameAliases:l});break}}})),t):t))}configure(e){o.isAbstractMenuManager(e.rootModel)&&(e.jexl.addFunction("geneBackgroundColor",(e=>"pseudogene"===e?s.alpha("rgb(148, 203, 236)",.6):"ncRNA_gene"===e?s.alpha("rgb(194, 106, 119)",.6):void 0)),function(e){e.insertInMenu("Apollo",{label:"Redo",icon:zf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.redoLastChange()}},0),e.insertInMenu("Apollo",{label:"Undo",icon:Hf,onClick(e){const{apolloDataStore:t}=e;t.changeManager.undoLastChange()}},0),e.appendToMenu("Apollo",{label:"Lock/Unlock session",onClick:e=>{e.toggleLocked()}});const{internetAccounts:t}=e;t.some((e=>Wl(e)))&&e.appendToMenu("Apollo",{label:"Log out",icon:$f,onClick:e=>{e.queueDialog((t=>[Gl,{session:e,handleClose:()=>{t()}}]))}})}(e.rootModel))}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=jbrowse-plugin-apollo.umd.production.min.js.map
|