@deephaven/embed-chart 0.37.1-auth-plugins.2 → 0.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/App-97a93d70.js +2 -0
- package/build/assets/App-97a93d70.js.map +1 -0
- package/build/assets/index-7bce681d.js +2 -0
- package/build/assets/{index-235fb33d.js.map → index-7bce681d.js.map} +1 -1
- package/build/assets/index-b88ed4a8.js +2 -0
- package/build/assets/index-b88ed4a8.js.map +1 -0
- package/build/assets/useConnection-e7328bfb.js +2 -0
- package/build/assets/useConnection-e7328bfb.js.map +1 -0
- package/build/index.html +2 -2
- package/package.json +14 -14
- package/build/assets/App-0441bef8.js +0 -2
- package/build/assets/App-0441bef8.js.map +0 -1
- package/build/assets/index-235fb33d.js +0 -2
- package/build/assets/index-5cea01c9.js +0 -2
- package/build/assets/index-5cea01c9.js.map +0 -1
- package/build/assets/useConnection-f8d5b429.js +0 -2
- package/build/assets/useConnection-f8d5b429.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{M as L,A as l,C as u,G as E,R as k,N as O,O as N,P as M,Q as T,S as I}from"./vendor-73e67738.js";import{L as h,e as m}from"./index-7bce681d.js";import{T as _,a as q,b as H,C as B,c as F}from"./useConnection-e7328bfb.js";import{d as ke,e as Oe,u as Ne}from"./useConnection-e7328bfb.js";import"./helpers-042e6b4d.js";const x=h.module("MessageUtils"),V="io.deephaven.message.LoginOptions.request";function Y(e,n=L(),i){return{message:e,id:n,payload:i}}async function G(e,n=3e4){if(window.opener==null)throw new Error("window.opener is null, unable to send request.");return new Promise((i,s)=>{let a;const t=L(),o=c=>{const{data:r}=c;if(x.debug("Received message",r),(r==null?void 0:r.id)!==t){x.debug("Ignore message, id doesn't match",r);return}window.clearTimeout(a),window.removeEventListener("message",o),i(r.payload)};window.addEventListener("message",o),a=window.setTimeout(()=>{window.removeEventListener("message",o),s(new _("Request timed out"))},n),window.opener.postMessage(Y(e,t),"*")})}const $=l.createContext(!1);function J({fontClassNames:e=["fira-sans-regular","fira-sans-bold","fira-mono"],children:n}){const[i,s]=l.useState(!1);return l.useEffect(function(){document.fonts.ready.then(()=>{s(!0)})},[]),u.jsxs(u.Fragment,{children:[u.jsx($.Provider,{value:i,children:n}),u.jsx("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:e.map(a=>u.jsx("p",{className:a,children:"preload"},a))})]})}function W(e){if(e==null)return!1;const n=e;return n.Component!==void 0&&typeof n.isAvailable=="function"}const D="io.deephaven.auth.AnonymousAuthenticationHandler",f=h.module("AuthPluginAnonymous");function Q({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState(),t=q();return l.useEffect(()=>{let o=!1;async function c(){try{if(f.info("Logging in..."),await e.login({type:t.CoreClient.LOGIN_TYPE_ANONYMOUS}),o){f.info("Previous login result canceled");return}f.info("Logged in successfully."),n()}catch(r){if(o){f.info("Previous login failure canceled");return}f.error("Unable to login:",r),a(r),i(r)}}return c(),()=>{o=!0}},[e,t,i,n]),u.jsx(m,{"data-testid":"auth-anonymous-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const z={Component:Q,isAvailable:e=>e.includes(D)},K=z,C=h.module("AuthPluginParent");function X(){return new URLSearchParams(window.location.search).get("authProvider")??""}function Z({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState();return l.useEffect(()=>{async function t(){try{C.info("Logging in by delegating to parent window...");const o=await G(V);await e.login(o),C.info("Logged in successfully."),n()}catch(o){C.error("Unable to login:",o),a(o),i(o)}}t()},[e,i,n]),u.jsx(m,{"data-testid":"auth-parent-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const ee={Component:Z,isAvailable:()=>window.opener!=null&&X()==="parent"},ne=ee,p=h.module("AuthPluginPsk"),j="io.deephaven.authentication.psk.PskAuthenticationHandler";function te(){return new URLSearchParams(window.location.search).get("psk")??""}function oe({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState(),[t]=l.useState(()=>te());return l.useEffect(()=>{let o=!1;async function c(){try{if(!t)throw new Error("No Pre-shared key token found. Add `psk=<token>` parameter to your URL");if(p.info("Logging in with found token..."),await e.login({type:j,token:t}),o){p.info("Previous login result canceled");return}p.info("Logged in successfully."),n()}catch(r){if(o){p.info("Previous login failure canceled");return}p.error("Unable to login:",r),a(r),i(r)}}return c(),()=>{o=!0}},[e,i,n,t]),u.jsx(m,{"data-testid":"auth-psk-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const se={Component:oe,isAvailable:e=>e.includes(j)},ie=se,R={react:E,"react-dom":k,redux:O,"react-redux":N},re=M.createRequires(()=>R),ae=M.createRemoteComponent({requires:re}),ue=ae,le=T.createRequires(R),ce=I({requires:le}),de=ce,d=h.module("@deephaven/app-utils.PluginUtils");function je(e,n){const i=new URL(`${n}.js`,e),s=E.forwardRef((a,t)=>u.jsx(ue,{url:i.href,render:({err:o,Component:c})=>{if(o!=null&&o!==""){const r=`Error loading plugin ${n} from ${i} due to ${o}`;return d.error(r),u.jsx("div",{className:"error-message",children:`${r}`})}return u.jsx(c,{ref:t,...a})}}));return s.pluginName=n,s.displayName="Plugin",s}async function ge(e){return await de(e)}async function fe(e){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);try{return await n.json()}catch{throw new Error("Could not be parsed as JSON")}}async function pe(e){d.debug("Loading plugins...");try{const n=await fe(`${e}/manifest.json`);if(!Array.isArray(n.plugins))throw new Error("Plugin manifest JSON does not contain plugins array");d.debug("Plugin manifest loaded:",n);const i=[];for(let t=0;t<n.plugins.length;t+=1){const{name:o,main:c}=n.plugins[t],r=`${e}/${o}/${c}`;i.push(ge(r))}const s=await Promise.allSettled(i),a=new Map;for(let t=0;t<s.length;t+=1){const o=s[t],{name:c}=n.plugins[t];o.status==="fulfilled"?a.set(c,o.value):d.error(`Unable to load plugin ${c}`,o.reason)}return d.info("Plugins loaded:",a),a}catch(n){return d.error("Unable to load plugins:",n),new Map}}function he(e){var n;return((n=e.get("AuthHandlers"))==null?void 0:n.split(","))??[]}function me(e,n,i){const s=he(n),a=[...e.entries()].filter(([,r])=>W(r.AuthPlugin)).map(([r,g])=>[r,g.AuthPlugin]);a.push(...i??[]);const t=a.filter(([r,g])=>g.isAvailable(s));if(t.length===0)throw new Error(`No login plugins found, please register a login plugin for auth handlers: ${s}`);t.length>1&&d.warn("More than one login plugin available, will use the first one: ",t.map(([r])=>r).join(", "));const[o,c]=t[0];return d.info("Using LoginPlugin",o),c.Component}const v=l.createContext(null);function Pe({pluginsUrl:e,children:n}){const[i,s]=l.useState(null);return l.useEffect(function(){let t=!1;async function o(){const c=await pe(e);t||s(c)}return o(),()=>{t=!0}},[e]),u.jsx(v.Provider,{value:i,children:n})}const we=new Map([["@deephaven/auth-plugins.AuthPluginPsk",ie],["@deephaven/auth-plugins.AuthPluginParent",ne],["@deephaven/auth-plugins.AuthPluginAnonymous",K]]);function Ae({children:e}){const n=H(),i=l.useContext(v),[s,a]=l.useState(),[t,o]=l.useState(!1),[c,r]=l.useState();l.useEffect(function(){let w=!1;async function S(){try{const A=await n.getAuthConfigValues();w||a(new Map(A))}catch(A){w||r(A)}}return S(),()=>{w=!0}},[n]);const g=l.useMemo(()=>{if(!(i==null||s==null))try{return me(i,s,we)}catch(P){r(P)}},[s,i]),b=l.useCallback(()=>{o(!0)},[]),U=l.useCallback(P=>{o(!1),r(P)},[]),y=g==null||s==null;return y||c!=null?u.jsx(m,{isLoading:y,errorMessage:c!=null?`${c}`:void 0}):t?u.jsx(u.Fragment,{children:e}):u.jsx(g,{authConfigValues:s,client:n,onSuccess:b,onFailure:U})}function Ce(e){return new URL(e,`${window.location}`)}function ve(){return new URLSearchParams(window.location.search).get("envoyPrefix")}function ye(){const e=ve();return e!=null?{headers:{"envoy-prefix":e}}:{headers:{}}}function xe({children:e}){return l.useContext($)?u.jsx(u.Fragment,{children:e}):u.jsx(m,{"data-testid":"fonts-loaded-loading"})}function Re({apiUrl:e,fontClassNames:n,pluginsUrl:i,children:s}){const a=Ce(e).origin,t=ye();return u.jsx(J,{fontClassNames:n,children:u.jsx(B,{serverUrl:a,options:t,children:u.jsx(Pe,{pluginsUrl:i,children:u.jsx(Ae,{children:u.jsx(F,{children:u.jsx(xe,{children:s})})})})})})}function be(){const e=l.useContext(v);if(e==null)throw new Error("No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?");return e}export{Re as AppBootstrap,Ae as AuthBootstrap,B as ClientBootstrap,ke as ClientContext,F as ConnectionBootstrap,Oe as ConnectionContext,J as FontBootstrap,xe as FontsLoaded,$ as FontsLoadedContext,Pe as PluginsBootstrap,v as PluginsContext,ue as RemoteComponent,he as getAuthHandlers,me as getAuthPluginComponent,Ce as getBaseUrl,ye as getConnectOptions,ve as getEnvoyPrefix,je as loadComponentPlugin,fe as loadJson,ge as loadModulePlugin,pe as loadModulePlugins,H as useClient,Ne as useConnection,be as usePlugins};
|
|
2
|
+
//# sourceMappingURL=index-b88ed4a8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-b88ed4a8.js","sources":["../../../jsapi-utils/src/MessageUtils.ts","../../../app-utils/src/components/FontBootstrap.tsx","../../../auth-plugins/src/AuthPlugin.ts","../../../auth-plugins/src/AuthHandlerTypes.ts","../../../auth-plugins/src/AuthPluginAnonymous.tsx","../../../auth-plugins/src/AuthPluginParent.tsx","../../../auth-plugins/src/AuthPluginPsk.tsx","../../../app-utils/src/plugins/remote-component.config.ts","../../../app-utils/src/plugins/RemoteComponent.ts","../../../app-utils/src/plugins/loadRemoteModule.ts","../../../app-utils/src/plugins/PluginUtils.tsx","../../../app-utils/src/components/PluginsBootstrap.tsx","../../../app-utils/src/components/AuthBootstrap.tsx","../../../app-utils/src/utils/ConnectUtils.ts","../../../app-utils/src/components/FontsLoaded.tsx","../../../app-utils/src/components/AppBootstrap.tsx","../../../app-utils/src/components/usePlugins.ts"],"sourcesContent":["import shortid from 'shortid';\nimport Log from '@deephaven/log';\nimport { TimeoutError } from '@deephaven/utils';\n\nconst log = Log.module('MessageUtils');\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\nexport interface Message<T> {\n message: string;\n payload?: T;\n id: string;\n}\n\nexport interface Response<T> {\n id: string;\n payload: T;\n}\n\n/**\n * Make message object with optional payload\n * @param message Message string\n * @param id Unique message id\n * @param payload Payload to send\n * @returns Message\n */\nexport function makeMessage<T>(\n message: string,\n id = shortid(),\n payload?: T\n): Message<T> {\n return { message, id, payload };\n}\n\n/**\n * Make response object for given message id\n * @param messageId Id of the request message to respond to\n * @param payload Payload to respond with\n * @returns Response\n */\nexport function makeResponse<T>(messageId: string, payload: T): Response<T> {\n return { id: messageId, payload };\n}\n\n/**\n * Request data from the parent window and wait for response\n * @param request Request message to send to the parent window\n * @param timeout Timeout in ms\n * @returns Payload of the given type, or undefined\n */\nexport async function requestParentResponse<T>(\n request: string,\n timeout = 30000\n): Promise<T> {\n if (window.opener == null) {\n throw new Error('window.opener is null, unable to send request.');\n }\n return new Promise((resolve, reject) => {\n let timeoutId: number;\n const id = shortid();\n const listener = (event: MessageEvent<Response<T>>) => {\n const { data } = event;\n log.debug('Received message', data);\n if (data?.id !== id) {\n log.debug(\"Ignore message, id doesn't match\", data);\n return;\n }\n window.clearTimeout(timeoutId);\n window.removeEventListener('message', listener);\n resolve(data.payload);\n };\n window.addEventListener('message', listener);\n timeoutId = window.setTimeout(() => {\n window.removeEventListener('message', listener);\n reject(new TimeoutError('Request timed out'));\n }, timeout);\n window.opener.postMessage(makeMessage(request, id), '*');\n });\n}\n","import React, { createContext, useEffect, useState } from 'react';\nimport 'fira';\n\nexport const FontsLoadedContext = createContext<boolean>(false);\n\nexport type FontBootstrapProps = {\n /**\n * Class names of the font elements to pre load\n */\n fontClassNames?: string[];\n\n /**\n * The children to render wrapped with the FontsLoadedContext.\n * Note that it renders the children even if the fonts aren't loaded yet.\n */\n children: React.ReactNode;\n};\n\n/**\n * FontBootstrap component. Handles preloading fonts.\n */\nexport function FontBootstrap({\n fontClassNames = ['fira-sans-regular', 'fira-sans-bold', 'fira-mono'],\n children,\n}: FontBootstrapProps) {\n const [isLoaded, setIsLoaded] = useState(false);\n useEffect(function initFonts() {\n document.fonts.ready.then(() => {\n setIsLoaded(true);\n });\n }, []);\n\n return (\n <>\n <FontsLoadedContext.Provider value={isLoaded}>\n {children}\n </FontsLoadedContext.Provider>\n {/*\n Need to preload any monaco and Deephaven grid fonts.\n We hide text with all the fonts we need on the root app.jsx page\n Load the Fira Mono font so that Monaco calculates word wrapping properly.\n This element doesn't need to be visible, just load the font and stay hidden.\n https://github.com/microsoft/vscode/issues/88689\n Can be replaced with a rel=\"preload\" when firefox adds support\n https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content\n */}\n <div\n id=\"preload-fonts\"\n style={{ visibility: 'hidden', position: 'absolute', top: -10000 }}\n >\n {/* trigger loading of fonts needed by monaco and iris grid */}\n {fontClassNames.map(className => (\n <p key={className} className={className}>\n preload\n </p>\n ))}\n </div>\n </>\n );\n}\n\nexport default FontBootstrap;\n","import React from 'react';\nimport { CoreClient } from '@deephaven/jsapi-types';\n\n/**\n * Map from auth config keys to their values\n * E.g. Map { AuthHandlers → \"io.deephaven.auth.AnonymousAuthenticationHandler\" }\n */\nexport type AuthConfigMap = Map<string, string>;\n\n/**\n * Props for the auth plugin component to render\n */\nexport type AuthPluginProps = {\n /** Map from config keys to their values */\n authConfigValues: AuthConfigMap;\n\n /** Client to check auth configuration on */\n client: CoreClient;\n\n /** Called when authentication is sucessful */\n onSuccess(): void;\n\n /** Called when authentication fails */\n onFailure(error: unknown): void;\n};\n\nexport type AuthPluginComponent = React.FunctionComponent<AuthPluginProps>;\n\n/**\n * Whether the auth plugin is available given the current configuration\n */\nexport type AuthPluginIsAvailableFunction = (authHandlers: string[]) => boolean;\n\nexport type AuthPlugin = {\n Component: AuthPluginComponent;\n isAvailable: AuthPluginIsAvailableFunction;\n};\n\nexport function isAuthPlugin(plugin?: unknown): plugin is AuthPlugin {\n if (plugin == null) return false;\n const authPlugin = plugin as AuthPlugin;\n return (\n authPlugin.Component !== undefined &&\n typeof authPlugin.isAvailable === 'function'\n );\n}\n","export const AUTH_HANDLER_TYPE_ANONYMOUS =\n 'io.deephaven.auth.AnonymousAuthenticationHandler';\n\nexport const AUTH_HANDLER_TYPE_PSK =\n 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n","import React, { useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AUTH_HANDLER_TYPE_ANONYMOUS } from './AuthHandlerTypes';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginAnonymous');\n\n/**\n * AuthPlugin that tries to login anonymously. Fails if anonymous login fails\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const dh = useApi();\n\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n log.info('Logging in...');\n await client.login({ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, dh, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-anonymous-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginAnonymous: AuthPlugin = {\n Component,\n isAvailable: authHandlers =>\n authHandlers.includes(AUTH_HANDLER_TYPE_ANONYMOUS),\n};\n\nexport default AuthPluginAnonymous;\n","import React, { useEffect, useState } from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport {\n LOGIN_OPTIONS_REQUEST,\n requestParentResponse,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginParent');\n\nfunction getWindowAuthProvider(): string {\n return new URLSearchParams(window.location.search).get('authProvider') ?? '';\n}\n\n/**\n * AuthPlugin that tries to delegate to the parent window for authentication. Fails if there is no parent window.\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n useEffect(() => {\n async function login() {\n try {\n log.info('Logging in by delegating to parent window...');\n const loginOptions = await requestParentResponse<LoginOptions>(\n LOGIN_OPTIONS_REQUEST\n );\n\n await client.login(loginOptions);\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n }, [client, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-parent-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginParent: AuthPlugin = {\n Component,\n isAvailable: () =>\n window.opener != null && getWindowAuthProvider() === 'parent',\n};\n\nexport default AuthPluginParent;\n","import React, { useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginPsk');\n\nconst AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n\nfunction getWindowToken(): string {\n return new URLSearchParams(window.location.search).get('psk') ?? '';\n}\n\n/**\n * AuthPlugin that tries to login using a pre-shared key.\n * Add the `psk=<token>` parameter to your URL string to set the token.\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const [token] = useState(() => getWindowToken());\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n if (!token) {\n throw new Error(\n 'No Pre-shared key token found. Add `psk=<token>` parameter to your URL'\n );\n }\n log.info('Logging in with found token...');\n await client.login({ type: AUTH_TYPE, token });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, onFailure, onSuccess, token]);\n return (\n <LoadingOverlay\n data-testid=\"auth-psk-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginPsk: AuthPlugin = {\n Component,\n isAvailable: authHandlers => authHandlers.includes(AUTH_TYPE),\n};\n\nexport default AuthPluginPsk;\n","/* eslint-disable global-require */\n/**\n * remote-component.config.js\n *\n * Dependencies for Remote Components\n */\nimport react from 'react';\nimport * as redux from 'redux';\nimport * as reactRedux from 'react-redux';\nimport ReactDOM from 'react-dom';\n\n// eslint-disable-next-line import/prefer-default-export\nexport const resolve = {\n react,\n 'react-dom': ReactDOM,\n redux,\n 'react-redux': reactRedux,\n};\n","import {\n createRemoteComponent,\n createRequires,\n} from '@paciolan/remote-component';\nimport { resolve } from './remote-component.config';\n\nconst requires = createRequires(() => resolve);\n\nexport const RemoteComponent = createRemoteComponent({ requires });\nexport default RemoteComponent;\n","import createLoadRemoteModule, {\n createRequires,\n} from '@paciolan/remote-module-loader';\nimport { resolve } from './remote-component.config';\n\nconst requires = createRequires(resolve);\n\nexport const loadRemoteModule: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (url: string): Promise<any>;\n} = createLoadRemoteModule({\n requires,\n});\n\nexport default loadRemoteModule;\n","import React, { ForwardRefExoticComponent } from 'react';\nimport {\n AuthPlugin,\n AuthPluginComponent,\n isAuthPlugin,\n} from '@deephaven/auth-plugins';\nimport Log from '@deephaven/log';\nimport RemoteComponent from './RemoteComponent';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\n\n// A PluginModule. This interface should have new fields added to it from different levels of plugins.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PluginModule {}\n\nexport type PluginModuleMap = Map<string, PluginModule>;\n\n/**\n * Load a component plugin from the server.\n * @param baseURL Base URL of the plugin server\n * @param pluginName Name of the component plugin to load\n * @returns A lazily loaded JSX.Element from the plugin\n */\nexport function loadComponentPlugin(\n baseURL: URL,\n pluginName: string\n): ForwardRefExoticComponent<React.RefAttributes<unknown>> {\n const pluginUrl = new URL(`${pluginName}.js`, baseURL);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Plugin: any = React.forwardRef((props, ref) => (\n <RemoteComponent\n url={pluginUrl.href}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n render={({ err, Component }: { err: unknown; Component: any }) => {\n if (err != null && err !== '') {\n const errorMessage = `Error loading plugin ${pluginName} from ${pluginUrl} due to ${err}`;\n log.error(errorMessage);\n return <div className=\"error-message\">{`${errorMessage}`}</div>;\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <Component ref={ref} {...props} />;\n }}\n />\n ));\n Plugin.pluginName = pluginName;\n Plugin.displayName = 'Plugin';\n return Plugin;\n}\n\n/**\n * Imports a commonjs plugin module from the provided URL\n * @param pluginUrl The URL of the plugin to load\n * @returns The loaded module\n */\nexport async function loadModulePlugin(pluginUrl: string): Promise<unknown> {\n const myModule = await loadRemoteModule(pluginUrl);\n return myModule;\n}\n\n/**\n * Loads a JSON file and returns the JSON object\n * @param jsonUrl The URL of the JSON file to load\n * @returns The JSON object of the manifest file\n */\nexport async function loadJson(\n jsonUrl: string\n): Promise<{ plugins: { name: string; main: string }[] }> {\n const res = await fetch(jsonUrl);\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n try {\n return await res.json();\n } catch {\n throw new Error('Could not be parsed as JSON');\n }\n}\n\n/**\n * Load all plugin modules available.\n * @param modulePluginsUrl The base URL of the module plugins to load\n * @returns A map from the name of the plugin to the plugin module that was loaded\n */\nexport async function loadModulePlugins(\n modulePluginsUrl: string\n): Promise<PluginModuleMap> {\n log.debug('Loading plugins...');\n try {\n const manifest = await loadJson(`${modulePluginsUrl}/manifest.json`);\n\n if (!Array.isArray(manifest.plugins)) {\n throw new Error('Plugin manifest JSON does not contain plugins array');\n }\n\n log.debug('Plugin manifest loaded:', manifest);\n const pluginPromises: Promise<unknown>[] = [];\n for (let i = 0; i < manifest.plugins.length; i += 1) {\n const { name, main } = manifest.plugins[i];\n const pluginMainUrl = `${modulePluginsUrl}/${name}/${main}`;\n pluginPromises.push(loadModulePlugin(pluginMainUrl));\n }\n const pluginModules = await Promise.allSettled(pluginPromises);\n\n const pluginMap: PluginModuleMap = new Map();\n for (let i = 0; i < pluginModules.length; i += 1) {\n const module = pluginModules[i];\n const { name } = manifest.plugins[i];\n if (module.status === 'fulfilled') {\n pluginMap.set(name, module.value as PluginModule);\n } else {\n log.error(`Unable to load plugin ${name}`, module.reason);\n }\n }\n log.info('Plugins loaded:', pluginMap);\n\n return pluginMap;\n } catch (e) {\n log.error('Unable to load plugins:', e);\n return new Map();\n }\n}\n\nexport function getAuthHandlers(\n authConfigValues: Map<string, string>\n): string[] {\n return authConfigValues.get('AuthHandlers')?.split(',') ?? [];\n}\n\n/**\n * Get the auth plugin component from the plugin map and current configuration\n * Throws if no auth plugin is available\n *\n * @param pluginMap Map of plugins loaded from the server\n * @param authConfigValues Auth config values from the server\n * @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins\n * @returns The auth plugin component to render\n */\nexport function getAuthPluginComponent(\n pluginMap: PluginModuleMap,\n authConfigValues: Map<string, string>,\n corePlugins?: Map<string, AuthPlugin>\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // Filter out all the plugins that are auth plugins, and then map them to [pluginName, AuthPlugin] pairs\n // Uses some pretty disgusting casting, because TypeScript wants to treat it as an (string | AuthPlugin)[] array instead\n const authPlugins = ([\n ...pluginMap.entries(),\n ].filter(([, plugin]: [string, { AuthPlugin?: AuthPlugin }]) =>\n isAuthPlugin(plugin.AuthPlugin)\n ) as [string, { AuthPlugin: AuthPlugin }][]).map(([name, plugin]) => [\n name,\n plugin.AuthPlugin,\n ]) as [string, AuthPlugin][];\n\n // Add all the core plugins in priority\n authPlugins.push(...(corePlugins ?? []));\n\n // Filter the available auth plugins\n\n const availableAuthPlugins = authPlugins.filter(([name, authPlugin]) =>\n authPlugin.isAvailable(authHandlers)\n );\n\n if (availableAuthPlugins.length === 0) {\n throw new Error(\n `No login plugins found, please register a login plugin for auth handlers: ${authHandlers}`\n );\n } else if (availableAuthPlugins.length > 1) {\n log.warn(\n 'More than one login plugin available, will use the first one: ',\n availableAuthPlugins.map(([name]) => name).join(', ')\n );\n }\n\n const [loginPluginName, NewLoginPlugin] = availableAuthPlugins[0];\n log.info('Using LoginPlugin', loginPluginName);\n\n return NewLoginPlugin.Component;\n}\n","import React, { createContext, useEffect, useState } from 'react';\nimport { PluginModuleMap, loadModulePlugins } from '../plugins';\n\nexport const PluginsContext = createContext<PluginModuleMap | null>(null);\n\nexport type PluginsBootstrapProps = {\n /**\n * Base URL of the plugins to load.\n */\n pluginsUrl: string;\n\n /**\n * The children to render wrapped with the PluginsContext.\n * Note that it renders the children even if the plugins aren't loaded yet.\n */\n children: React.ReactNode;\n};\n\n/**\n * PluginsBootstrap component. Handles loading the plugins.\n */\nexport function PluginsBootstrap({\n pluginsUrl,\n children,\n}: PluginsBootstrapProps) {\n const [plugins, setPlugins] = useState<PluginModuleMap | null>(null);\n useEffect(\n function initPlugins() {\n let isCancelled = false;\n async function loadPlugins() {\n const pluginModules = await loadModulePlugins(pluginsUrl);\n if (!isCancelled) {\n setPlugins(pluginModules);\n }\n }\n loadPlugins();\n return () => {\n isCancelled = true;\n };\n },\n [pluginsUrl]\n );\n\n return (\n <PluginsContext.Provider value={plugins}>\n {children}\n </PluginsContext.Provider>\n );\n}\n\nexport default PluginsBootstrap;\n","import React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n AuthConfigMap,\n AuthPluginAnonymous,\n AuthPluginParent,\n AuthPluginPsk,\n} from '@deephaven/auth-plugins';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\nimport useClient from './useClient';\n\nexport type AuthBootstrapProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\n/** Core auth plugins that are always loaded */\nconst CORE_AUTH_PLUGINS = new Map([\n ['@deephaven/auth-plugins.AuthPluginPsk', AuthPluginPsk],\n ['@deephaven/auth-plugins.AuthPluginParent', AuthPluginParent],\n ['@deephaven/auth-plugins.AuthPluginAnonymous', AuthPluginAnonymous],\n]);\n\n/**\n * AuthBootstrap component. Handles displaying the auth plugin and authenticating.\n */\nexport function AuthBootstrap({ children }: AuthBootstrapProps) {\n const client = useClient();\n // `useContext` instead of `usePlugins` so that we don't have to wait for the plugins to load\n // We want to load the auth config values in parallel with the plugins\n const plugins = useContext(PluginsContext);\n const [authConfig, setAuthConfig] = useState<AuthConfigMap>();\n const [isLoggedIn, setIsLoggedIn] = useState(false);\n const [error, setError] = useState<unknown>();\n\n useEffect(\n function initAuthConfigValues() {\n let isCancelled = false;\n async function loadAuthConfigValues() {\n try {\n const newAuthConfigValues = await client.getAuthConfigValues();\n if (!isCancelled) {\n setAuthConfig(new Map(newAuthConfigValues));\n }\n } catch (e) {\n if (!isCancelled) {\n setError(e);\n }\n }\n }\n loadAuthConfigValues();\n return () => {\n isCancelled = true;\n };\n },\n [client]\n );\n\n const AuthComponent = useMemo(() => {\n if (plugins == null || authConfig == null) {\n return undefined;\n }\n\n try {\n return getAuthPluginComponent(plugins, authConfig, CORE_AUTH_PLUGINS);\n } catch (e) {\n setError(e);\n }\n }, [authConfig, plugins]);\n\n const handleLoginSuccess = useCallback(() => {\n setIsLoggedIn(true);\n }, []);\n\n const handleLoginFailure = useCallback((e: unknown) => {\n setIsLoggedIn(false);\n setError(e);\n }, []);\n\n const isLoading = AuthComponent == null || authConfig == null;\n\n if (isLoading || error != null) {\n return (\n <LoadingOverlay\n isLoading={isLoading}\n errorMessage={error != null ? `${error}` : undefined}\n />\n );\n }\n if (!isLoggedIn) {\n return (\n <AuthComponent\n authConfigValues={authConfig}\n client={client}\n onSuccess={handleLoginSuccess}\n onFailure={handleLoginFailure}\n />\n );\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default AuthBootstrap;\n","import { ConnectOptions } from '@deephaven/jsapi-types';\n\n/**\n * Get the base URL of the API\n * @param apiUrl API URL\n * @returns URL for the base of the API\n */\nexport function getBaseUrl(apiUrl: string): URL {\n return new URL(apiUrl, `${window.location}`);\n}\n\n/**\n * Get the Envoy prefix header value\n * @returns Envoy prefix header value\n */\nexport function getEnvoyPrefix(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get('envoyPrefix');\n}\n\nexport function getConnectOptions(): ConnectOptions {\n const envoyPrefix = getEnvoyPrefix();\n return envoyPrefix != null\n ? { headers: { 'envoy-prefix': envoyPrefix } }\n : { headers: {} };\n}\n","import React, { useContext } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { FontsLoadedContext } from './FontBootstrap';\n\nexport type FontsLoadedProps = {\n /** Children to show when the fonts have completed loading */\n children: React.ReactNode;\n};\n\nexport function FontsLoaded({ children }: FontsLoadedProps) {\n const isFontsLoaded = useContext(FontsLoadedContext);\n\n if (!isFontsLoaded) {\n return <LoadingOverlay data-testid=\"fonts-loaded-loading\" />;\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default FontsLoaded;\n","import React from 'react';\nimport '@deephaven/components/scss/BaseStyleSheet.scss';\nimport FontBootstrap from './FontBootstrap';\nimport ClientBootstrap from './ClientBootstrap';\nimport PluginsBootstrap from './PluginsBootstrap';\nimport AuthBootstrap from './AuthBootstrap';\nimport ConnectionBootstrap from './ConnectionBootstrap';\nimport { getBaseUrl, getConnectOptions } from '../utils';\nimport FontsLoaded from './FontsLoaded';\n\nexport type AppBootstrapProps = {\n /** URL of the API to load. */\n apiUrl: string;\n\n /** URL of the plugins to load. */\n pluginsUrl: string;\n\n /** Font class names to load. */\n fontClassNames?: string[];\n\n /**\n * The children to render wrapped when everything is loaded and authenticated.\n */\n children: React.ReactNode;\n};\n\n/**\n * AppBootstrap component. Handles loading the fonts, client, and authentication.\n * Will display the children when everything is loaded and authenticated.\n */\nexport function AppBootstrap({\n apiUrl,\n fontClassNames,\n pluginsUrl,\n children,\n}: AppBootstrapProps) {\n const serverUrl = getBaseUrl(apiUrl).origin;\n const clientOptions = getConnectOptions();\n return (\n <FontBootstrap fontClassNames={fontClassNames}>\n <ClientBootstrap serverUrl={serverUrl} options={clientOptions}>\n <PluginsBootstrap pluginsUrl={pluginsUrl}>\n <AuthBootstrap>\n <ConnectionBootstrap>\n <FontsLoaded>{children}</FontsLoaded>\n </ConnectionBootstrap>\n </AuthBootstrap>\n </PluginsBootstrap>\n </ClientBootstrap>\n </FontBootstrap>\n );\n}\n\nexport default AppBootstrap;\n","import { useContext } from 'react';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport function usePlugins() {\n const plugins = useContext(PluginsContext);\n if (plugins == null) {\n throw new Error(\n 'No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?'\n );\n }\n return plugins;\n}\n\nexport default usePlugins;\n"],"names":["log","Log","LOGIN_OPTIONS_REQUEST","makeMessage","message","id","shortid","payload","requestParentResponse","request","timeout","resolve","reject","timeoutId","listener","event","data","TimeoutError","FontsLoadedContext","createContext","FontBootstrap","fontClassNames","children","isLoaded","setIsLoaded","useState","useEffect","jsxs","Fragment","jsx","className","isAuthPlugin","plugin","authPlugin","AUTH_HANDLER_TYPE_ANONYMOUS","Component","client","onSuccess","onFailure","error","setError","dh","useApi","isCanceled","login","e","LoadingOverlay","AuthPluginAnonymous","authHandlers","AuthPluginAnonymous$1","getWindowAuthProvider","loginOptions","AuthPluginParent","AuthPluginParent$1","AUTH_TYPE","getWindowToken","token","AuthPluginPsk","AuthPluginPsk$1","react","ReactDOM","redux","reactRedux","requires","createRequires","RemoteComponent","createRemoteComponent","RemoteComponent$1","loadRemoteModule","createLoadRemoteModule","loadRemoteModule$1","loadComponentPlugin","baseURL","pluginName","pluginUrl","Plugin","React","props","ref","err","errorMessage","loadModulePlugin","loadJson","jsonUrl","res","loadModulePlugins","modulePluginsUrl","manifest","pluginPromises","i","name","main","pluginMainUrl","pluginModules","pluginMap","module","getAuthHandlers","authConfigValues","_a","getAuthPluginComponent","corePlugins","authPlugins","availableAuthPlugins","loginPluginName","NewLoginPlugin","PluginsContext","PluginsBootstrap","pluginsUrl","plugins","setPlugins","isCancelled","loadPlugins","CORE_AUTH_PLUGINS","AuthBootstrap","useClient","useContext","authConfig","setAuthConfig","isLoggedIn","setIsLoggedIn","loadAuthConfigValues","newAuthConfigValues","AuthComponent","useMemo","handleLoginSuccess","useCallback","handleLoginFailure","isLoading","getBaseUrl","apiUrl","getEnvoyPrefix","getConnectOptions","envoyPrefix","FontsLoaded","AppBootstrap","serverUrl","clientOptions","ClientBootstrap","ConnectionBootstrap","usePlugins"],"mappings":"kUAIA,MAAMA,EAAMC,EAAI,OAAO,cAAc,EAExBC,EACX,4CAuBK,SAASC,EACdC,EACAC,EAAKC,EAAA,EACLC,EACY,CACL,MAAA,CAAE,QAAAH,EAAS,GAAAC,EAAI,QAAAE,EACxB,CAkBsB,eAAAC,EACpBC,EACAC,EAAU,IACE,CACR,GAAA,OAAO,QAAU,KACb,MAAA,IAAI,MAAM,gDAA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AAWV,CAAc,EACzC,GAAIG,GAAW,KACb,MAAM,IAAI,MACR,sGAAA,EAGG,OAAAA,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=Object.defineProperty;var m=(n,t,o)=>t in n?E(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var p=(n,t,o)=>(m(n,typeof t!="symbol"?t+"":t,o),o);import{A as e,C as l}from"./vendor-73e67738.js";import{A as h,L as A,e as S}from"./index-7bce681d.js";class g extends Error{constructor(){super(...arguments);p(this,"isTimeout",!0)}}const j=g,x=()=>{const n=e.useContext(h);if(n==null)throw new Error("No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?");return n},w=e.createContext(null);function L({serverUrl:n,options:t,children:o}){const i=x(),[s,r]=e.useState();return e.useEffect(function(){const u=new i.CoreClient(n,t);return r(u),()=>{u.disconnect()}},[i,t,n]),s==null?null:l.jsx(w.Provider,{value:s,children:o})}function B(){const n=e.useContext(w);if(n==null)throw new Error("No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?");return n}const N=A.module("@deephaven/jsapi-components.ConnectionBootstrap"),v=e.createContext(null);function y({children:n}){const t=x(),o=B(),[i,s]=e.useState(),[r,C]=e.useState();return e.useEffect(function(){let c=!1;async function d(){try{const a=await o.getAsIdeConnection();if(c)return;C(a)}catch(a){if(c)return;s(a)}}return d(),()=>{c=!0}},[t,o]),e.useEffect(function(){if(r==null)return;function c(a){const{detail:f}=a;N.info("Shutdown",`${JSON.stringify(f)}`),s(`Server shutdown: ${f??"Unknown reason"}`)}return r.addEventListener(t.IdeConnection.EVENT_SHUTDOWN,c)},[t,r]),r==null||i!=null?l.jsx(S,{"data-testid":"connection-bootstrap-loading",isLoading:r==null,errorMessage:`${i}`}):l.jsx(v.Provider,{value:r,children:n})}function I(){const n=e.useContext(v);if(n==null)throw new Error("No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?");return n}export{L as C,j as T,x as a,B as b,y as c,w as d,v as e,I as u};
|
|
2
|
+
//# sourceMappingURL=useConnection-e7328bfb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnection-e7328bfb.js","sources":["../../../utils/src/TimeoutError.ts","../../../jsapi-bootstrap/src/useApi.ts","../../../app-utils/src/components/ClientBootstrap.tsx","../../../app-utils/src/components/useClient.ts","../../../app-utils/src/components/ConnectionBootstrap.tsx","../../../app-utils/src/components/useConnection.ts"],"sourcesContent":["class TimeoutError extends Error {\n isTimeout = true;\n}\n\nexport default TimeoutError;\n","import { useContext } from 'react';\nimport { ApiContext } from './ApiBootstrap';\n\nexport const useApi = () => {\n const dh = useContext(ApiContext);\n if (dh == null) {\n throw new Error(\n 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?'\n );\n }\n return dh;\n};\n\nexport default useApi;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { ConnectOptions, CoreClient } from '@deephaven/jsapi-types';\n\nexport const ClientContext = createContext<CoreClient | null>(null);\n\nexport type ClientBootstrapProps = {\n /** URL of the server to connect to */\n serverUrl: string;\n\n /** Connection options to pass to CoreClient when connecting */\n options?: ConnectOptions;\n\n /**\n * The children to render wrapped with the ClientContext.\n * Will not render children until the client is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ClientBootstrap component. Handles creating the client.\n */\nexport function ClientBootstrap({\n serverUrl,\n options,\n children,\n}: ClientBootstrapProps) {\n const api = useApi();\n const [client, setClient] = useState<CoreClient>();\n useEffect(\n function initClient() {\n const newClient = new api.CoreClient(serverUrl, options);\n setClient(newClient);\n return () => {\n newClient.disconnect();\n };\n },\n [api, options, serverUrl]\n );\n\n if (client == null) {\n return null;\n }\n return (\n <ClientContext.Provider value={client}>{children}</ClientContext.Provider>\n );\n}\n\nexport default ClientBootstrap;\n","import { useContext } from 'react';\nimport { ClientContext } from './ClientBootstrap';\n\nexport function useClient() {\n const client = useContext(ClientContext);\n if (client == null) {\n throw new Error(\n 'No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?'\n );\n }\n return client;\n}\n\nexport default useClient;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { IdeConnection } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport useClient from './useClient';\n\nconst log = Log.module('@deephaven/jsapi-components.ConnectionBootstrap');\n\nexport const ConnectionContext = createContext<IdeConnection | null>(null);\n\nexport type ConnectionBootstrapProps = {\n /**\n * The children to render wrapped with the ConnectionContext.\n * Will not render children until the connection is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ConnectionBootstrap component. Handles initializing the connection.\n */\nexport function ConnectionBootstrap({ children }: ConnectionBootstrapProps) {\n const api = useApi();\n const client = useClient();\n const [error, setError] = useState<unknown>();\n const [connection, setConnection] = useState<IdeConnection>();\n useEffect(\n function initConnection() {\n let isCancelled = false;\n async function loadConnection() {\n try {\n const newConnection = await client.getAsIdeConnection();\n if (isCancelled) {\n return;\n }\n setConnection(newConnection);\n } catch (e) {\n if (isCancelled) {\n return;\n }\n setError(e);\n }\n }\n loadConnection();\n return () => {\n isCancelled = true;\n };\n },\n [api, client]\n );\n\n useEffect(\n function listenForShutdown() {\n if (connection == null) return;\n\n function handleShutdown(event: CustomEvent) {\n const { detail } = event;\n log.info('Shutdown', `${JSON.stringify(detail)}`);\n setError(`Server shutdown: ${detail ?? 'Unknown reason'}`);\n }\n\n const removerFn = connection.addEventListener(\n api.IdeConnection.EVENT_SHUTDOWN,\n handleShutdown\n );\n return removerFn;\n },\n [api, connection]\n );\n\n if (connection == null || error != null) {\n return (\n <LoadingOverlay\n data-testid=\"connection-bootstrap-loading\"\n isLoading={connection == null}\n errorMessage={`${error}`}\n />\n );\n }\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}\n\nexport default ConnectionBootstrap;\n","import { useContext } from 'react';\nimport { ConnectionContext } from './ConnectionBootstrap';\n\nexport function useConnection() {\n const connection = useContext(ConnectionContext);\n if (connection == null) {\n throw new Error(\n 'No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?'\n );\n }\n return connection;\n}\n\nexport default useConnection;\n"],"names":["TimeoutError","__publicField","TimeoutError$1","useApi","dh","useContext","ApiContext","ClientContext","createContext","ClientBootstrap","serverUrl","options","children","api","client","setClient","useState","useEffect","newClient","useClient","log","Log","ConnectionContext","ConnectionBootstrap","error","setError","connection","setConnection","isCancelled","loadConnection","newConnection","e","handleShutdown","event","detail","jsx","LoadingOverlay","useConnection"],"mappings":"8QAAA,MAAMA,UAAqB,KAAM,CAAjC,kCACEC,EAAA,iBAAY,IACd,CAEA,MAAAC,EAAeF,ECDFG,EAAS,IAAM,CACpB,MAAAC,EAAKC,aAAWC,CAAU,EAChC,GAAIF,GAAM,KACR,MAAM,IAAI,MACR,sFAAA,EAGG,OAAAA,CACT,ECPaG,EAAgBC,gBAAiC,IAAI,EAmB3D,SAASC,EAAgB,CAC9B,UAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAAyB,CACvB,MAAMC,EAAMV,IACN,CAACW,EAAQC,CAAS,EAAIC,EAAqB,SAAA,EAYjD,OAXAC,EAAA,UACE,UAAsB,CACpB,MAAMC,EAAY,IAAIL,EAAI,WAAWH,EAAWC,CAAO,EACvD,OAAAI,EAAUG,CAAS,EACZ,IAAM,CACXA,EAAU,WAAW,CAAA,CAEzB,EACA,CAACL,EAAKF,EAASD,CAAS,CAAA,EAGtBI,GAAU,KACL,WAGNP,EAAc,SAAd,CAAuB,MAAOO,EAAS,SAAAF,CAAS,CAAA,CAErD,CC5CO,SAASO,GAAY,CACpB,MAAAL,EAAST,aAAWE,CAAa,EACvC,GAAIO,GAAU,KACZ,MAAM,IAAI,MACR,kGAAA,EAGG,OAAAA,CACT,CCJA,MAAMM,EAAMC,EAAI,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<head>
|
|
4
|
-
<meta name="ui-version" content="v0.37.
|
|
4
|
+
<meta name="ui-version" content="v0.37.2" />
|
|
5
5
|
<meta charset="utf-8" />
|
|
6
6
|
<meta
|
|
7
7
|
name="viewport"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<link rel="icon" href="./favicon-cc-app.svg" />
|
|
18
18
|
<title>Deephaven Embedded Chart</title>
|
|
19
|
-
<script type="module" crossorigin src="./assets/index-
|
|
19
|
+
<script type="module" crossorigin src="./assets/index-7bce681d.js"></script>
|
|
20
20
|
<link rel="modulepreload" crossorigin href="./assets/helpers-042e6b4d.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="./assets/vendor-73e67738.js">
|
|
22
22
|
<link rel="stylesheet" href="./assets/vendor-458ea229.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/embed-chart",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2",
|
|
4
4
|
"description": "Deephaven Embedded Chart",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"build"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@deephaven/app-utils": "^0.37.
|
|
20
|
-
"@deephaven/chart": "^0.37.
|
|
21
|
-
"@deephaven/components": "^0.37.
|
|
22
|
-
"@deephaven/jsapi-bootstrap": "^0.37.
|
|
23
|
-
"@deephaven/jsapi-shim": "^0.37.
|
|
24
|
-
"@deephaven/jsapi-utils": "^0.37.
|
|
25
|
-
"@deephaven/log": "^0.37.
|
|
19
|
+
"@deephaven/app-utils": "^0.37.2",
|
|
20
|
+
"@deephaven/chart": "^0.37.2",
|
|
21
|
+
"@deephaven/components": "^0.37.2",
|
|
22
|
+
"@deephaven/jsapi-bootstrap": "^0.37.2",
|
|
23
|
+
"@deephaven/jsapi-shim": "^0.37.2",
|
|
24
|
+
"@deephaven/jsapi-utils": "^0.37.2",
|
|
25
|
+
"@deephaven/log": "^0.37.2",
|
|
26
26
|
"fira": "mozilla/fira#4.202",
|
|
27
27
|
"react": "^17.0.2",
|
|
28
28
|
"react-dom": "^17.0.2"
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"preview": "vite preview"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@deephaven/eslint-config": "^0.37.
|
|
38
|
-
"@deephaven/mocks": "^0.37.
|
|
39
|
-
"@deephaven/prettier-config": "^0.37.
|
|
40
|
-
"@deephaven/stylelint-config": "^0.37.
|
|
41
|
-
"@deephaven/tsconfig": "^0.37.
|
|
37
|
+
"@deephaven/eslint-config": "^0.37.2",
|
|
38
|
+
"@deephaven/mocks": "^0.37.2",
|
|
39
|
+
"@deephaven/prettier-config": "^0.37.2",
|
|
40
|
+
"@deephaven/stylelint-config": "^0.37.2",
|
|
41
|
+
"@deephaven/tsconfig": "^0.37.2",
|
|
42
42
|
"@vitejs/plugin-react-swc": "^3.2.0",
|
|
43
43
|
"vite": "^4.1.4"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "fa22e4b507d6b3a52ea05ca6b1256c0cb1432c18"
|
|
49
49
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var We=Object.defineProperty;var qe=(T,s,e)=>s in T?We(T,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):T[s]=e;var u=(T,s,e)=>(qe(T,typeof s!="symbol"?s+"":s,e),e);import{G as X,C as D,E as Se,F as Le,A as _,H as je,I as ze,J as he,K as Xe,L as pe}from"./vendor-73e67738.js";import{v as Ze,L as Z,a as Ge,d as Ye,b as Ke,c as _e,e as Qe}from"./index-235fb33d.js";import{C as ke,T as Be,u as Je}from"./useConnection-f8d5b429.js";import{P as Ae,b as et,h as tt,p as st,o as nt,s as rt,t as it,c as Ie}from"./plotly-b2b7fdc4.js";import"./helpers-042e6b4d.js";const ee=class{static disableAllActions(){ee.actionsDisabled=!0}static enableAllActions(){ee.actionsDisabled=!1}static isContextActionEvent(s){return Array.isArray(s.contextActions)}static compareActions(s,e){return s.group!==e.group?(s.group??0)>(e.group??0)?1:-1:s.order!==e.order?(s.order??0)>(e.order??0)?1:-1:s.title!==e.title?(s.title??"")>(e.title??"")?1:-1:s!==e?s>e?1:-1:0}static sortActions(s){if(s==null||!Array.isArray(s))return[];const e=s.slice();return e.sort(ee.compareActions),e}static isMacPlatform(){const{platform:s}=window.navigator;return s.startsWith("Mac")}static getModifierKey(){return ee.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(s){const e=ee.getModifierKey();return s[e]}static getMenuItems(s,e=!0){let t=[],n=s;Array.isArray(n)||(n=[n]);for(let r=0;r<n.length;r+=1){const i=n[r];let a;typeof i=="function"?a=i():a=i,a!=null&&(a instanceof Promise?e&&t.push(a):Array.isArray(a)?t=t.concat(a):t.push(a))}return t=t.filter(r=>r.title!==void 0||r.then!=null||r.menuElement),t}static getNextMenuItem(s,e,t){let n=s;n<0&&e<0&&(n=t.length);for(let r=1;r<t.length+1;r+=1){const i=(n+e*r+t.length)%t.length,a=t[i];if(!(a instanceof Promise)&&a.disabled!==!0)return i}return s}};let Ee=ee;u(Ee,"actionsDisabled",!1);const J=Ee,Ce=X.forwardRef((T,s)=>{var A;function e(E){const{menuItem:M,onMenuItemClick:F}=T;F(M,E)}function t(E){const{menuItem:M,onMenuItemMouseMove:F}=T;F(M,E)}function n(E){const{menuItem:M,onMenuItemContextMenu:F}=T;F(M,E)}function r(E,M,F){if(typeof E.type=="string")return E;const{closeMenu:C,menuItem:P,isKeyboardSelected:R,isMouseSelected:$,"data-testid":L}=T,le={menuItem:P,closeMenu:C,isKeyboardSelected:R,isMouseSelected:$,iconElement:M,displayShortcut:F,"data-testid":L};return X.cloneElement(E,{forwardedProps:le})}const{children:i,menuItem:a,isKeyboardSelected:l=!1,isMouseSelected:o=!1,"data-testid":d}=T,h=(A=a.shortcut)==null?void 0:A.getDisplayText();let f=null;if(a.icon){const E=a.icon;if(X.isValidElement(E))f=E;else{let M;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(M={color:a.iconColor}),f=D.jsx(Le,{icon:E,style:M})}}let S=null;const y=Boolean(i);a.actions&&(S=D.jsx(Le,{icon:Ze}));let b=null;if(a.menuElement)b=D.jsx("div",{className:"custom-menu-item",onMouseMove:t,children:r(a.menuElement,f,h)});else{const E=a.disabled,M=a.iconOutline;b=D.jsx("button",{type:"button",className:Se("btn-context-menu",{disabled:E},{active:(y||o)&&(E===void 0||!E)},{"keyboard-active":l&&(E===void 0||!E)}),onClick:e,onMouseMove:t,onContextMenu:n,title:a.description??"",children:D.jsxs("div",{className:"btn-context-menu-wrapper",children:[D.jsx("span",{className:Se("icon",{outline:M}),children:f}),D.jsx("span",{className:"title",children:a.title}),h!==void 0&&D.jsx("span",{className:"shortcut",children:h}),S&&D.jsx("span",{className:Se("submenu-indicator",{disabled:E}),children:S})]})})}return D.jsxs("div",{className:"context-menu-item",ref:s,"data-testid":d,children:[i,b]})});Ce.displayName="ContextMenuItem";Ce.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const at=Ce;class xe{static makeCancelable(s,e){let t=!1,n,r;const i=new Promise((a,l)=>{r=l,Promise.resolve(s).then(o=>{t?e&&e(o):(n=o,a(o))}).catch(o=>l(o))});return i.cancel=()=>{t=!0,r(new ke),n!=null&&e&&e(n)},i}static isCanceled(s){return s instanceof ke}static isTimedOut(s){return s instanceof Be}static withTimeout(s,e){return new Promise((t,n)=>{setTimeout(()=>{try{t(e())}catch(r){n(r)}},s)})}}function me(T){if(T==null)throw new Error("Value is null or undefined")}class ot{static join(s,e="and"){if(s==null||s.length===0)return"";if(s.length===1)return s[0];if(s.length===2)return`${s[0]} ${e} ${s[1]}`;const t=s.slice(0,s.length-1).join(", "),n=s[s.length-1];return`${t}, ${e} ${n}`}static toLower(s,e=!0){if(s==null){if(e)return"";throw new Error("Null string passed in to TextUtils.toLower")}return s.toLowerCase()}static sort(s,e,t=!0){return s<e?t?-1:1:s>e?t?1:-1:0}}const lt=ot,Re=Z.module("ContextMenu"),Ne=class extends _.PureComponent{constructor(e){super(e);u(this,"container");u(this,"oldFocus");u(this,"activeSubMenuRef");u(this,"subMenuTimer");u(this,"rAF");u(this,"initialPosition");this.handleBlur=this.handleBlur.bind(this),this.handleCloseSubMenu=this.handleCloseSubMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemContextMenu=this.handleMenuItemContextMenu.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.container=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{var t;(t=this.container.current)==null||t.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,t){var i,a;const{actions:n}=this.props,{activeSubMenu:r}=this.state;r!==t.activeSubMenu&&(r==null?(i=this.container.current)==null||i.focus():this.setActiveSubMenuPosition()),e.actions!==n&&(this.initMenu(),(this.container.current==null||!this.container.current.contains(document.activeElement))&&((a=this.container.current)==null||a.focus())),this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);const{options:e}=this.props;let t=e.initialKeyboardIndex;t===void 0&&(t=-1);const{actions:n}=this.props,r=J.getMenuItems(n),i=[];for(let a=r.length-1;a>=0;a-=1){const l=r[a];l instanceof Promise?this.initMenuPromise(l):i.push(l)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:J.sortActions(i)})}initMenuPromise(e){const t=xe.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(r=>{const i=r.pendingItems.indexOf(t);if(i>=0){const a=r.pendingItems.slice();return a.splice(i,1),{menuItems:J.sortActions(r.menuItems.concat(n)),pendingItems:a}}return null})},n=>{xe.isCanceled(n)||(this.setState(r=>{const i=r.pendingItems.indexOf(t);if(i>=0){const a=r.pendingItems.slice();return a.splice(i,1),{pendingItems:a}}return null}),Re.error(n))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current===null)return;const e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}verifyPosition(){var S,y;const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:r,top:i,left:a}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:l,left:o}=this.initialPosition;const{width:d,height:h}=((S=this.container.current)==null?void 0:S.getBoundingClientRect())??{width:0,height:0},f=(((y=this.container.current)==null?void 0:y.scrollHeight)??0)>window.innerHeight;h===0||d===0||(l+h>window.innerHeight&&(l-h-r>0?l-=h-r:l=window.innerHeight-h),o+d>window.innerWidth&&(o=o-d-n),(a!==o||i!==l)&&(this.setState({hasOverflow:f}),t(l,o)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){Re.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let t=e.relatedTarget,n=!1;for(;t&&!n;)n=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;n||this.closeMenu(!0)}}isEscapeKey(e){const{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let r=n,i=!1;if(e.key==="Enter"||e.key===" "){n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}if(e.key==="ArrowRight"?n>=0&&n<=t.length?i=!0:r=0:this.isEscapeKey(e.key)?r=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?r=J.getNextMenuItem(r,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(r=J.getNextMenuItem(r,1,t)),i){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==r&&(r!==null?this.setKeyboardIndex(r):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,r=t[e].actions?e:null;n!==r&&this.setState({activeSubMenu:r,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();const{menuItems:n}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(n.indexOf(e)):e.action!=null&&(e.action(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n),n>=0&&n<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:t,left:n}=this.props,{activeSubMenu:r,hasOverflow:i,keyboardIndex:a,menuItems:l,mouseIndex:o,pendingItems:d,subMenuTop:h,subMenuLeft:f,subMenuParentWidth:S,subMenuParentHeight:y}=this.state;for(let F=0;F<l.length;F+=1){const C=l[F];F>0&&C.group!==l[F-1].group&&e.push(D.jsx("hr",{},`${F}.separator`));const P=D.jsx(at,{ref:r===F?this.activeSubMenuRef:null,isKeyboardSelected:a===F,isMouseSelected:o===F,menuItem:C,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},F);e.push(P)}let b=null;d.length>0&&(b=D.jsx("div",{className:"loading",children:D.jsx(Ge,{})}));const{menuStyle:A,"data-testid":E}=this.props,M=r!==null&&h!==null&&f!==null;return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:Se({"has-overflow":i},"context-menu-container"),style:{top:t,left:n,...A},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Ne.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":E,children:[e,b]}),M&&r!==null&&h!==null&&f!==null&&D.jsx(Ne,{actions:l[r].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:f,updatePosition:(F,C)=>{this.setState({subMenuTop:F,subMenuLeft:C})},subMenuParentWidth:S,subMenuParentHeight:y},`sub-${r}`)]})}};let Fe=Ne;u(Fe,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const ct=Fe;class ut extends _.Component{constructor(e){super(e);u(this,"container");u(this,"openMenu");this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var e;(e=this.container.current)!=null&&e.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var e;(e=this.container.current)!=null&&e.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(!J.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=J.getMenuItems(e.contextActions),n=this.container.current.getBoundingClientRect(),r=e.clientY-n.top,i=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const a=document.elementFromPoint(i,r),l=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});a==null||a.dispatchEvent(l)});return}return}e.preventDefault(),this.setState({actions:t,top:r,left:i})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:r,left:i}=this.state;return n&&(e=D.jsx(ct,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:r,left:i,updatePosition:(a,l)=>{this.setState({top:a,left:l})},"data-testid":t})),D.jsx("div",{className:Se("context-menu-root",{active:n}),ref:this.container,children:e})}}const dt=ut;class be{static isValid(s){return!0}static isSameFormat(s,e){throw new Error("isSameFormat not implemented")}static makeFormat(s,e,t){return{label:s,formatString:e,type:t}}format(s,e){return""}}u(be,"TYPE_GLOBAL","type-global"),u(be,"TYPE_CONTEXT_PRESET","type-context-preset"),u(be,"TYPE_CONTEXT_CUSTOM","type-context-custom");const x=be;class ht extends x{format(s){switch(s){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const pt=ht;class mt extends x{format(s){return String.fromCharCode(s)}}const gt=mt,{dh:ft}=globalThis,c=ft,$e=Z.module("DateTimeColumnFormatter"),K=class extends x{constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:r=K.DEFAULT_DATETIME_FORMAT_STRING}={}){super();u(this,"dhTimeZone");u(this,"defaultDateTimeFormatString");u(this,"showTimeZone");u(this,"showTSeparator");u(this,"formatStringMap");const i=e||K.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=c.i18n.TimeZone.getTimeZone(i)}catch{$e.error("Unsupported time zone id",i),this.dhTimeZone=c.i18n.TimeZone.getTimeZone(K.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=r,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=K.makeFormatStringMap(t,n)}static isValid(e){try{return c.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=x.TYPE_CONTEXT_PRESET){return{label:e,formatString:t,type:n}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static makeGlobalFormatStringMap(e,t){const n=t?"'T'":" ",r=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${r}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${r}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${r}`]])}static getGlobalFormats(e,t){return[...K.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",r=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${r}`],["MM-dd-yyyy",`MM-dd-yyyy${r}`],["HH:mm:ss",`HH:mm:ss${r}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${r}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${r}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${r}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${r}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${r}`]])}static getFormats(e,t){return[...K.makeFormatStringMap(e,t).keys()]}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,r=this.getEffectiveFormatString(n);try{return c.i18n.DateTimeFormat.format(r,e,this.dhTimeZone)}catch{$e.error("Invalid format arguments")}return""}};let fe=K;u(fe,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS"),u(fe,"DEFAULT_TIME_ZONE_ID","America/New_York");const Tt=Z.module("DecimalColumnFormatter"),k=class extends x{constructor({defaultFormatString:e=k.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return c.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=x.TYPE_CONTEXT_PRESET,r){return{label:e,type:n,formatString:t,multiplier:r}}static makePresetFormat(e,t="",n){return k.makeFormat(e,t,x.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return k.makeFormat("Custom Format",e,x.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,r=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return c.i18n.NumberFormat.format(n,r)}catch{Tt.error("Invalid format arguments")}return""}};let V=k;u(V,"DEFAULT_FORMAT_STRING","###,##0.0000"),u(V,"FORMAT_PERCENT",k.makePresetFormat("Percent","##0.00%")),u(V,"FORMAT_BASIS_POINTS",k.makePresetFormat("Basis Points","###,##0 bp",1e4)),u(V,"FORMAT_MILLIONS",k.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(V,"FORMAT_SCIENTIFIC_NOTATION",k.makePresetFormat("Scientific Notation","0.0000E0")),u(V,"FORMAT_ROUND",k.makePresetFormat("Round","###,##0")),u(V,"FORMAT_ROUND_TWO_DECIMALS",k.makePresetFormat("0.00","###,##0.00")),u(V,"FORMAT_ROUND_FOUR_DECIMALS",k.makePresetFormat("0.0000","###,##0.0000"));class St extends x{format(s){return`${s}`}}const yt=St,Et=Z.module("IntegerColumnFormatter"),te=class extends x{constructor({defaultFormatString:e=te.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return c.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=x.TYPE_CONTEXT_PRESET,r){return{label:e,type:n,formatString:t,multiplier:r}}static makePresetFormat(e,t="",n){return te.makeFormat(e,t,x.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return te.makeFormat("Custom Format",e,x.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,r=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return c.i18n.NumberFormat.format(n,r)}catch{Et.error("Invalid format arguments")}return""}};let ae=te;u(ae,"DEFAULT_FORMAT_STRING","###,##0"),u(ae,"FORMAT_MILLIONS",te.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(ae,"FORMAT_SCIENTIFIC_NOTATION",te.makePresetFormat("Scientific Notation","0.0000E0"));class Ft extends x{format(s){return s}}const O=class{static makeDateWrapper(s,e,t=0,n=1,r=0,i=0,a=0,l=0){if(!s)throw new Error("No timezone provided");const o=`${e}`.padStart(4,"0"),d=`${t+1}`.padStart(2,"0"),h=`${n}`.padStart(2,"0"),f=`${r}`.padStart(2,"0"),S=`${i}`.padStart(2,"0"),y=`${a}`.padStart(2,"0"),b=`${l}`.padStart(9,"0"),A=`${o}-${d}-${h} ${f}:${S}:${y}.${b}`;return c.i18n.DateTimeFormat.parse(O.FULL_DATE_FORMAT,A,c.i18n.TimeZone.getTimeZone(s))}static getNextNanos(s){const e=parseInt(s,10),t="0".repeat(9-s.length),n=`${e+1}${t}`;return parseInt(n,10)}static getNextDate(s,e,t){let{year:n,month:r,date:i,hours:a,minutes:l,seconds:o,nanos:d}=e;if(s.nanos!=null){if(s.nanos.length===9)return null;d=O.getNextNanos(s.nanos),d>999999999&&(o+=1,d=0)}else s.seconds!=null?o+=1:s.minutes!=null?l+=1:s.hours!=null?a+=1:s.date!=null?i+=1:s.month!=null?r+=1:n+=1;const h=new Date(n,r,i,a,l,o);return O.makeDateWrapper(t,h.getFullYear(),h.getMonth(),h.getDate(),h.getHours(),h.getMinutes(),h.getSeconds(),d)}static parseMonth(s){const e=parseInt(s,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const t=s.trim().toLowerCase();if(t.length>=3){for(let n=0;n<O.months.length;n+=1)if(O.months[n].startsWith(t))return n}return NaN}static parseDateValues(s,e,t,n,r,i,a){const l=parseInt(s,10),o=e!=null?this.parseMonth(e):0,d=t!=null?parseInt(t,10):1,h=n!=null?parseInt(n,10):0,f=r!=null?parseInt(r,10):0,S=i!=null?parseInt(i,10):0,y=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(o)||Number.isNaN(d)||Number.isNaN(h)||Number.isNaN(f)||Number.isNaN(S)||Number.isNaN(y)?null:{year:l,month:o,date:d,hours:h,minutes:f,seconds:S,nanos:y}}static parseDateTimeString(s){const t=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(s);if(t==null)throw new Error(`Unexpected date string: ${s}`);const[,n,,r,,i,,a,,l,,o,,d,h]=t;if(h!=null&&h.length>0)throw new Error(`Unexpected characters after date string '${s}': ${h}`);return{year:n,month:r,date:i,hours:a,minutes:l,seconds:o,nanos:d}}static parseDateRange(s,e){const t=s.trim().toLowerCase();if(t.length===0)throw new Error("Cannot parse date range from empty string");if(t==="null")return[null,null];if(t==="today"){const l=new Date(Date.now()),o=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[o,d]}if(t==="yesterday"){const l=new Date(Date.now()),o=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[o,d]}if(t==="now"){const l=new Date(Date.now());return[c.DateWrapper.ofJsDate(l),null]}const n=O.parseDateTimeString(t);if(n.year==null&&n.month==null&&n.date==null)throw new Error(`Unable to extract year, month, or day ${t}`);const r=O.parseDateValues(n.year,n.month,n.date,n.hours,n.minutes,n.seconds,n.nanos);if(r==null)throw new Error(`Unable to extract date values from ${n}`);const i=O.makeDateWrapper(e,r.year,r.month,r.date,r.hours,r.minutes,r.seconds,r.nanos),a=O.getNextDate(n,r,e);return[i,a]}static getJsDate(s){return typeof s=="number"?new Date(s):s.asDate()}};let se=O;u(se,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS"),u(se,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);class ye{}u(ye,"not","not"),u(ye,"and","and"),u(ye,"or","or");class g{}u(g,"eq","eq"),u(g,"eqIgnoreCase","eqIgnoreCase"),u(g,"notEq","notEq"),u(g,"notEqIgnoreCase","notEqIgnoreCase"),u(g,"greaterThan","greaterThan"),u(g,"greaterThanOrEqualTo","greaterThanOrEqualTo"),u(g,"lessThan","lessThan"),u(g,"lessThanOrEqualTo","lessThanOrEqualTo"),u(g,"in","in"),u(g,"inIgnoreCase","inIgnoreCase"),u(g,"notIn","notIn"),u(g,"notInIgnoreCase","notInIgnoreCase"),u(g,"isTrue","isTrue"),u(g,"isFalse","isFalse"),u(g,"isNull","isNull"),u(g,"invoke","invoke"),u(g,"contains","contains"),u(g,"notContains","notContains"),u(g,"startsWith","startsWith"),u(g,"endsWith","endsWith"),u(g,"containsAny","containsAny");const q=Z.module("TableUtils"),m=class{static getSortIndex(s,e){var t;for(let n=0;n<s.length;n+=1)if(((t=s[n].column)==null?void 0:t.name)===e)return n;return null}static getSortForColumn(s,e){const t=m.getSortIndex(s,e);return t!=null?s[t]:null}static getFilterText(s){return s?s.toString():null}static getFilterTypes(s){return m.isBooleanType(s)?[g.isTrue,g.isFalse,g.isNull]:m.isCharType(s)||m.isNumberType(s)||m.isDateType(s)?[g.eq,g.notEq,g.greaterThan,g.greaterThanOrEqualTo,g.lessThan,g.lessThanOrEqualTo]:m.isTextType(s)?[g.eq,g.eqIgnoreCase,g.notEq,g.notEqIgnoreCase,g.contains,g.notContains,g.startsWith,g.endsWith]:[]}static getNextSort(s,e,t){if(t<0||t>=s.length)return null;const n=m.getSortForColumn(e,s[t].name);return n===null?s[t].sort().asc():n.direction===m.sortDirection.ascending?n.desc():null}static makeColumnSort(s,e,t,n){if(e<0||e>=s.length||t===m.sortDirection.none)return null;let r=s[e].sort();switch(t){case m.sortDirection.ascending:r=r.asc();break;case m.sortDirection.descending:r=r.desc();break}return n&&(r=r.abs()),r}static toggleSortForColumn(s,e,t,n=!1){if(t<0||t>=e.length)return[];const r=m.getNextSort(e,s,t);return m.setSortForColumn(s,e[t].name,r,n)}static sortColumn(s,e,t,n,r,i){if(t<0||t>=e.length)return[];const a=m.makeColumnSort(e,t,n,r);return m.setSortForColumn(s,e[t].name,a,i)}static setSortForColumn(s,e,t,n=!1){const r=m.getSortIndex(s,e);let i=[];return n&&(i=i.concat(s.filter(({direction:a})=>a!==m.sortDirection.reverse)),r!==null&&i.splice(r,1)),t!==null&&i.push(t),i}static getNormalizedType(s){switch(s){case"boolean":case"java.lang.Boolean":case m.dataType.BOOLEAN:return m.dataType.BOOLEAN;case"char":case"java.lang.Character":case m.dataType.CHAR:return m.dataType.CHAR;case"java.lang.String":case m.dataType.STRING:return m.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case m.dataType.DATETIME:return m.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case m.dataType.DECIMAL:return m.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case m.dataType.INT:return m.dataType.INT;default:return m.dataType.UNKNOWN}}static isLongType(s){switch(s){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(s){switch(s){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(s){return m.isIntegerType(s)||m.isDecimalType(s)}static isIntegerType(s){switch(s){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(s){switch(s){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(s){switch(s){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(s){switch(s){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(s){switch(s){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(s){switch(s){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(s){switch(s){case"java.lang.String":return!0;default:return!1}}static isTextType(s){return this.isStringType(s)||this.isCharType(s)}static getBaseType(s){return s.split("[]")[0]}static isCompatibleType(s,e){return m.getNormalizedType(s)===m.getNormalizedType(e)}static makeQuickFilter(s,e,t){const n=e.split("||");let r=null;for(let i=0;i<n.length;i+=1){const l=n[i].split("&&");let o=null;for(let d=0;d<l.length;d+=1){const h=l[d].trim();if(h.length>0){const f=m.makeQuickFilterFromComponent(s,h,t);if(f)o?o=o.and(f):o=f;else throw new Error(`Unable to parse quick filter from text ${e}`)}}r&&o?r=r.or(o):r=o}return r}static makeQuickFilterFromComponent(s,e,t){const{type:n}=s;return m.isNumberType(n)?this.makeQuickNumberFilter(s,e):m.isBooleanType(n)?this.makeQuickBooleanFilter(s,e):t!=null&&m.isDateType(n)?this.makeQuickDateFilter(s,e,t):m.isCharType(n)?this.makeQuickCharFilter(s,e):this.makeQuickTextFilter(s,e)}static makeQuickNumberFilter(s,e){const t=s.filter();let n=null;const i=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let a=null,l=null,o=null,d=null,h=null;if(i!==null&&i.length>3&&([,a,l,o,d,h]=i),h!=null&&h.trim().length>0)return null;if(a==null&&(a="="),d!=null){if(!(a==="="||a==="!"||a==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":n=t.isNull();break;case"nan":n=c.FilterCondition.invoke("isNaN",t);break;case"infinity":case"inf":case"∞":l!=null?n=c.FilterCondition.invoke("isInf",t).and(t.lessThan(c.FilterValue.ofNumber(0))):n=c.FilterCondition.invoke("isInf",t).and(t.greaterThan(c.FilterValue.ofNumber(0)));break}return n!==null&&(a==="!"||a==="!=")&&(n=n.not()),n}if(o==null)return null;if(o=m.removeCommas(o),m.isLongType(s.type))try{o=c.FilterValue.ofNumber(c.LongWrapper.ofString(`${l!=null?"-":""}${o}`))}catch(f){return q.warn("Unable to create long filter",f),null}else{if(o=parseFloat(o),o==null||Number.isNaN(o))return null;o=c.FilterValue.ofNumber(l!=null?0-o:o)}return n=s.filter(),m.makeRangeFilterWithOperation(n,a,o)}static makeQuickTextFilter(s,e){const t=`${e}`.trim(),r=/^(!~|!=|~|=|!)?(.*)/.exec(t);let i=null,a=null;if(r!==null&&r.length>2&&([,i,a]=r,a!=null&&(a=a.trim())),a==null||a.length===0)return null;i==null&&(i="=");const l=s.filter();if(a.toLowerCase()==="null")switch(i){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let o=null,d=null;switch(a.startsWith("*")?(o="*",a=a.substring(1)):a.endsWith("*")&&!a.endsWith("\\*")&&(d="*",a=a.substring(0,a.length-1)),a=a.replace("\\",""),i){case"~":return l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)).not());case"!=":return o==="*"?l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`)).not()):l.notEqIgnoreCase(c.FilterValue.ofString(a.toLowerCase()));case"=":return o==="*"?l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`))):l.eqIgnoreCase(c.FilterValue.ofString(a.toLowerCase()))}return null}static makeQuickBooleanFilter(s,e){const n=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(n===null)return null;const[,r,i]=n,a=r==="!"||r==="!=",l=i.trim().toLowerCase();let o=s.filter();try{const d=m.makeBooleanValue(l);return d!=null&&d?o=o.isTrue():d===null?o=o.isNull():o=o.isFalse(),a?o.not():o}catch{return null}}static makeQuickDateFilter(s,e,t){const n=e.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(n);if(i==null||i.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let a=null,l=null;[,a,l]=i;let o=g.eq;switch(a){case"<":o=g.lessThan;break;case"<=":case"=<":o=g.lessThanOrEqualTo;break;case">":o=g.greaterThan;break;case">=":case"=>":o=g.greaterThanOrEqualTo;break;case"!=":case"!":o=g.notEq;break;case"=":case"==":default:o=g.eq;break}return m.makeQuickDateFilterWithOperation(s,l,o,t)}static makeQuickDateFilterWithOperation(s,e,t,n){const[r,i]=se.parseDateRange(e,n),a=r!=null?c.FilterValue.ofNumber(r):null,l=i!=null?c.FilterValue.ofNumber(i):null,o=s.filter();if(a==null)return t===g.notEq?o.isNull().not():o.isNull();switch(t){case g.eq:{if(l!=null){const d=o.greaterThanOrEqualTo(a),h=o.lessThan(l);return d.and(h)}return o.eq(a)}case g.lessThan:return o.lessThan(a);case g.lessThanOrEqualTo:return l!=null?o.lessThan(l):o.lessThanOrEqualTo(a);case g.greaterThan:return l!=null?o.greaterThanOrEqualTo(l):o.greaterThan(a);case g.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(a);case g.notEq:{if(l!=null){const d=o.lessThan(a),h=o.greaterThanOrEqualTo(l);return d.or(h)}return o.notEq(a)}default:throw new Error(`Invalid operator: ${t}`)}}static quoteValue(s){return s.length>=2&&(s.charAt(0)==='"'&&s.charAt(s.length-1)==='"'||s.charAt(0)==="'"&&s.charAt(s.length-1)==="'")?s:`"${s}"`}static isRangeOperation(s){switch(s){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(s,e){const t=`${e}`.trim(),r=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(t);let i=null,a=null,l=null;if(r!==null&&r.length>3&&([,i,a,l]=r),l!=null&&l.trim().length>0||a==null||a.length===0)return null;i==null&&(i="=");const o=s.filter();if(a.toLowerCase()==="null")switch(i){case"=":return o.isNull();case"!=":case"!":return o.isNull().not();default:return null}const d=c.FilterValue.ofString(m.isRangeOperation(i)?m.quoteValue(a):a);return m.makeRangeFilterWithOperation(o,i,d)}static makeRangeFilterWithOperation(s,e,t){switch(e){case"=":return s.eq(t);case"<":return s.lessThan(t);case"<=":case"=<":return s.lessThanOrEqualTo(t);case">":return s.greaterThan(t);case">=":case"=>":return s.greaterThanOrEqualTo(t);case"!=":case"!":return s.notEq(t);default:return null}}static makeCancelableTablePromise(s){return xe.makeCancelable(s,e=>{e.close()})}static makeCancelableTableEventPromise(s,e,t=0,n=null){let r,i,a=!0;const l=new Promise((o,d)=>{i=setTimeout(()=>{r(),a=!1,d(new Be(`Event "${e}" timed out.`))},t),r=s.addEventListener(e,h=>{if(n!=null&&!n(h)){q.debug2("Event triggered, but matcher returned false.");return}q.debug2("Event triggered, resolving."),r(),clearTimeout(i),a=!1,o(h)})});return l.cancel=()=>{if(a){q.debug2("Pending promise cleanup."),r(),clearTimeout(i),a=!1;return}q.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(s,e,t){const{filterItems:n,filterOperators:r,invertSelection:i,selectedValues:a}=e;let l=null;for(let d=0;d<n.length;d+=1){const h=n[d],{selectedType:f,value:S}=h;if(f!=null&&f.length>0&&S!=null&&S.length>0)try{const y=m.makeAdvancedValueFilter(s,f,S,t);if(y!=null){if(d===0)l=y;else if(l!==null&&d-1<r.length){const b=r[d-1];if(b===ye.and)l=l.and(y);else if(b===ye.or)l=l.or(y);else{q.error("Unexpected filter operator",b,y),l=null;break}}}else q.debug2("Empty filter ignored for",f,S)}catch(y){q.error("Unable to create filter",y),l=null;break}}const o=m.makeSelectValueFilter(s,a,i);return o!=null&&(l!=null?l=l.and(o):l=o),l}static removeCommas(s){return s.replace(/[\s|,]/g,"")}static makeFilterValue(s,e){const t=m.getBaseType(s);return m.isTextType(t)?c.FilterValue.ofString(e):m.isLongType(t)?c.FilterValue.ofNumber(c.LongWrapper.ofString(m.removeCommas(e))):c.FilterValue.ofNumber(m.removeCommas(e))}static makeFilterRawValue(s,e){return m.isTextType(s)?c.FilterValue.ofString(e):m.isBooleanType(s)?c.FilterValue.ofBoolean(e):c.FilterValue.ofNumber(e)}static makeValue(s,e,t){if(e==="null")return null;if(m.isTextType(s))return e;if(m.isLongType(s))return c.LongWrapper.ofString(m.removeCommas(e));if(m.isBooleanType(s))return m.makeBooleanValue(e,!0);if(m.isDateType(s)){const[n]=se.parseDateRange(e,t);return n}return m.isNumberType(s)?m.makeNumberValue(e):(q.error("Unexpected column type",s),null)}static makeBooleanValue(s,e=!1){if(s===""&&e)return null;switch(s==null?void 0:s.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${s}'`)}}static makeNumberValue(s){if(s==="null"||s==="")return null;const e=s.toLowerCase().trim();if(e==="∞"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-∞"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const t=m.removeCommas(e);if(m.NUMBER_REGEX.test(t))return parseFloat(t);throw new Error(`Invalid number '${s}'`)}static getFilterOperatorString(s){switch(s){case g.eq:return"=";case g.notEq:return"!=";case g.greaterThan:return">";case g.greaterThanOrEqualTo:return">=";case g.lessThan:return"<";case g.lessThanOrEqualTo:return"<=";case g.contains:return"~";case g.notContains:return"!~";default:throw new Error(`Unexpected filter type ${s}`)}}static makeAdvancedValueFilter(s,e,t,n){if(m.isDateType(s.type))return m.makeQuickDateFilterWithOperation(s,t,e,n);if(m.isNumberType(s.type)||m.isCharType(s.type))return m.makeQuickFilter(s,`${m.getFilterOperatorString(e)}${t}`);const r=m.makeFilterValue(s.type,t),i=s.filter();switch(e){case g.eq:return i.eq(r);case g.eqIgnoreCase:return i.eqIgnoreCase(r);case g.notEq:return i.notEq(r);case g.notEqIgnoreCase:return i.notEqIgnoreCase(r);case g.greaterThan:return i.greaterThan(r);case g.greaterThanOrEqualTo:return i.greaterThanOrEqualTo(r);case g.lessThan:return i.lessThan(r);case g.lessThanOrEqualTo:return i.lessThanOrEqualTo(r);case g.isTrue:return i.isTrue();case g.isFalse:return i.isFalse();case g.isNull:return i.isNull();case g.contains:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)));case g.notContains:return i.isNull().or(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)).not());case g.startsWith:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${t}\\E.*`)));case g.endsWith:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E$`)));case g.in:case g.inIgnoreCase:case g.notIn:case g.notInIgnoreCase:case g.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(s,e,t){if(e.length===0){if(t)return null;let i=null;m.isTextType(s.type)?i=c.FilterValue.ofString("a"):m.isBooleanType(s.type)?i=c.FilterValue.ofBoolean(!0):m.isDateType(s.type)?i=c.FilterValue.ofNumber(c.DateWrapper.ofJsDate(new Date)):i=c.FilterValue.ofNumber(0);const a=s.filter().eq(i),l=s.filter().notEq(i);return a.and(l)}const n=[];let r=!1;for(let i=0;i<e.length;i+=1){const a=e[i];a==null?r=!0:m.isTextType(s.type)?n.push(c.FilterValue.ofString(typeof a=="number"?String.fromCharCode(a):a)):m.isBooleanType(s.type)?n.push(c.FilterValue.ofBoolean(Boolean(a))):n.push(c.FilterValue.ofNumber(a))}return r?n.length>0?t?s.filter().isNull().not().and(s.filter().notIn(n)):s.filter().isNull().or(s.filter().in(n)):t?s.filter().isNull().not():s.filter().isNull():t?s.filter().notIn(n):s.filter().in(n)}static isTreeTable(s){return s!=null&&s.expand!==void 0&&s.collapse!==void 0}static sortColumns(s,e=!0){return[...s].sort((t,n)=>{const r=t.name.toUpperCase(),i=n.name.toUpperCase();return lt.sort(r,i,e)})}};let W=m;u(W,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"}),u(W,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null}),u(W,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"})),u(W,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/);const U=W;class Pe{constructor(s=[],e,t,n,r=!1){u(this,"defaultColumnFormatter");u(this,"typeFormatterMap");u(this,"columnFormatMap");u(this,"truncateNumbersWithPound");this.defaultColumnFormatter=new yt,this.typeFormatterMap=new Map([[U.dataType.BOOLEAN,new pt],[U.dataType.CHAR,new gt],[U.dataType.DATETIME,new fe(e)],[U.dataType.DECIMAL,new V(t)],[U.dataType.INT,new ae(n)],[U.dataType.STRING,new Ft]]),this.columnFormatMap=Pe.makeColumnFormatMap(s),this.truncateNumbersWithPound=r}static makeColumnFormatMap(s){return s==null?new Map:s.reduce((e,t)=>{const n=U.getNormalizedType(t.columnType);if(n===null)return e;e.has(n)||e.set(n,new Map);const r=e.get(n);return r==null||r.set(t.columnName,t.format),e},new Map)}static makeColumnFormattingRule(s,e,t){return{columnType:s,columnName:e,format:t}}getColumnFormatMapForType(s,e=!1){const t=U.getNormalizedType(s);if(t!==null)return e&&!this.columnFormatMap.has(t)&&this.columnFormatMap.set(t,new Map),this.columnFormatMap.get(t)}getColumnFormat(s,e){const t=this.getColumnFormatMapForType(s);return(t==null?void 0:t.get(e))??null}getColumnTypeFormatter(s){const e=U.getNormalizedType(s);let t=this.defaultColumnFormatter;return e&&(t=this.typeFormatterMap.get(e)??t),t}getFormattedString(s,e,t="",n){if(s==null)return"";const r=this.getColumnTypeFormatter(e),i=n||this.getColumnFormat(e,t);return r.format(s,i??void 0)}get timeZone(){var e;const s=this.typeFormatterMap.get(U.dataType.DATETIME);return(e=s==null?void 0:s.dhTimeZone)==null?void 0:e.id}}function bt(T){if(T&&T.formatter){const{formatter:s}=T;return s}}function Dt(T){return{timeZone:T==null?void 0:T.timeZone,defaultDateTimeFormatString:T==null?void 0:T.defaultDateTimeFormat,showTimeZone:T==null?void 0:T.showTimeZone,showTSeparator:T==null?void 0:T.showTSeparator}}function Mt(T,s,e){const t=T.getColumnFormat(e,s);return t!=null&&(t.type===x.TYPE_CONTEXT_PRESET||t.type===x.TYPE_CONTEXT_CUSTOM)}const we={getColumnFormats:bt,getDateTimeFormatterOptions:Dt,isCustomColumnFormatDefined:Mt};Ae.register([et,tt,st,nt,rt,it]);const At=typeof Ie=="function"?Ie(Ae):Ie.default(Ae),j=class{constructor(){u(this,"listeners");u(this,"formatter");u(this,"rect");u(this,"isDownsamplingDisabled");u(this,"title");this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(j.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(j.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(j.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(j.EVENT_LOADFINISHED))}};let H=j;u(H,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(H,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(H,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(H,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(H,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(H,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(H,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(H,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const z=H,Nt="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",It="#403e41",wt="#5b5a5c",xt="#c0bfbf",Ct="#4878ea",Pt="rgba(91, 90, 92, 0.7)",w={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Nt,gridcolor:It,linecolor:wt,zerolinecolor:xt,activecolor:Ct,rangebgcolor:Pt,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},B=Object.freeze({paper_bgcolor:w["paper-bgcolor"],plot_bgcolor:w["plot-bgcolor"],title_color:w["title-color"],colorway:w.colorway,gridcolor:w.gridcolor,linecolor:w.linecolor,zerolinecolor:w.zerolinecolor,activecolor:w.activecolor,rangebgcolor:w.rangebgcolor,area_color:w["area-color"],trend_color:w["trend-color"],line_color:w["line-color"],error_band_line_color:w["error-band-line-color"],error_band_fill_color:w["error-band-fill-color"],ohlc_increasing:w["ohlc-increasing"],ohlc_decreasing:w["ohlc-decreasing"]}),ge=Z.module("ChartUtils"),G=Object.freeze(c.calendar.DayOfWeek.values()),Ve="io.deephaven.time.DateTime",vt=36e5,Ot=1e6;function Lt(T){return T.asDate!==void 0}function kt(T){return T.asNumber!==void 0}function He(T){return T.dhTimeZone!==void 0}function Rt(T){return T!=null&&T.range!=null&&(T.autorange===!1||T.autorange===void 0)}const p=class{static getPlotlyChartType(s,e){switch(s){case c.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case c.plot.SeriesPlotStyle.LINE:return"scatter";case c.plot.SeriesPlotStyle.BAR:case c.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case c.plot.SeriesPlotStyle.PIE:return"pie";case c.plot.SeriesPlotStyle.TREEMAP:return"treemap";case c.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case c.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(s,e,t){const n=new Set;switch(s){case c.plot.SeriesPlotStyle.SCATTER:(e??!1)&&n.add(p.MODE_LINES),(t??!0)&&n.add(p.MODE_MARKERS);break;case c.plot.SeriesPlotStyle.LINE:(e??!0)&&n.add(p.MODE_LINES),(t??!1)&&n.add(p.MODE_MARKERS);break}return n.size>0?[...n].join("+"):void 0}static getPlotlyProperty(s,e){switch(s){case c.plot.SeriesPlotStyle.PIE:switch(e){case c.plot.SourceType.X:return"labels";case c.plot.SourceType.Y:return"values"}break;case c.plot.SeriesPlotStyle.OHLC:switch(e){case c.plot.SourceType.TIME:return"x"}break;case c.plot.SeriesPlotStyle.TREEMAP:switch(e){case c.plot.SourceType.X:return"ids";case c.plot.SourceType.Y:return"values";case c.plot.SourceType.LABEL:return"labels";case c.plot.SourceType.PARENT:return"parents";case c.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case c.plot.SourceType.X:return"x";case c.plot.SourceType.Y:return"y";case c.plot.SourceType.Z:return"z";case c.plot.SourceType.X_LOW:return"xLow";case c.plot.SourceType.X_HIGH:return"xHigh";case c.plot.SourceType.Y_LOW:return"yLow";case c.plot.SourceType.Y_HIGH:return"yHigh";case c.plot.SourceType.TIME:return"time";case c.plot.SourceType.OPEN:return"open";case c.plot.SourceType.HIGH:return"high";case c.plot.SourceType.LOW:return"low";case c.plot.SourceType.CLOSE:return"close";case c.plot.SourceType.SHAPE:return"shape";case c.plot.SourceType.SIZE:return"size";case c.plot.SourceType.LABEL:return"label";case c.plot.SourceType.COLOR:return"color";case c.plot.SourceType.PARENT:return"parent";case c.plot.SourceType.HOVER_TEXT:return"hovertext";case c.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(s){var t,n;const{sources:e}=s;return e.length===2&&((n=(t=e[0])==null?void 0:t.axis)==null?void 0:n.type)===c.plot.AxisType.Y?p.ORIENTATION.HORIZONTAL:p.ORIENTATION.VERTICAL}static getPlotlyErrorBars(s,e,t){const n=t.map((i,a)=>i-s[a]),r=e.map((i,a)=>s[a]-i);return{type:"data",symmetric:!1,array:n,arrayminus:r}}static getPlotlyDateFormat(s,e,t){const n=t==null?void 0:t.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let r;const i=s==null?void 0:s.getColumnTypeFormatter(e);return i!=null&&He(i)&&i.dhTimeZone!=null&&i.showTimeZone&&(r=c.i18n.DateTimeFormat.format(" z",new Date,i.dhTimeZone)),{tickformat:n,ticksuffix:r,automargin:!0}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const r=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);me(r);const[,i,a,l,,o,d,h,f,S]=r,y=l.replace(",","").length,A=a.indexOf(",")>=0||l.indexOf(",")>=0?",":"",E=h!=null&&h!==""?"e":"f",M=f!==""?f:E,F=o.length+d.length,P=`0${y}${A}.${F}${M}`,R=p.convertNumberPrefix(i),$=p.convertNumberPrefix(S);return{tickformat:P,tickprefix:R,ticksuffix:$,automargin:!0}}static getPlotlyAxisFormat(s,e=null){const{axis:t,columnType:n}=s,{formatPattern:r}=t;let i=null;return W.isDateType(n)?(i=p.getPlotlyDateFormat(e,n,r),i=p.addTickSpacing(i,t,!0)):W.isNumberType(n)&&(i=p.getPlotlyNumberFormat(e,n,r),i=p.addTickSpacing(i,t,!1)),t.formatType===c.plot.AxisFormatType.CATEGORY&&(i?i.type="category":i={type:"category",tickformat:void 0,ticksuffix:void 0}),i}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:n}=e;if(n>0){const r=s||{};let i=n;return t&&(i=n/Ot),e.log&&(i=Math.log(i)),r.tickmode="linear",r.dtick=i,r}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const n=s.series[t];for(let r=0;r<n.sources.length;r+=1){const i=n.sources[r];if(i.axis===e)return i}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,n,r=p.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:r,showlegend:n??void 0}}static makeSeriesDataFromSeries(s,e,t,n=null,r=B){const{name:i,isLinesVisible:a,isShapesVisible:l,plotStyle:o,lineColor:d,shapeColor:h,sources:f,shape:S,shapeSize:y}=s,b=f.some(C=>{var P;return(P=C.axis)==null?void 0:P.businessCalendar}),A=p.getChartType(o,b),E=p.getPlotlyChartMode(o,a??void 0,l??void 0),M=p.getPlotlySeriesOrientation(s),F=p.makeSeriesData(A,E,i,n,M);return p.addSourcesToSeriesData(F,o,f,e),p.addStylingToSeriesData(F,o,r,d,h,S,y,t),F}static addSourcesToSeriesData(s,e,t,n){const r=s;for(let i=0;i<t.length;i+=1){const a=t[i],{axis:l,type:o}=a,d=p.getPlotlyProperty(e,o);je(r,d,[]);const h=l!=null?p.getAxisPropertyName(l.type):null;if(h!=null){const f=n.get(l.type);if(f){const S=f.indexOf(l),y=S>0?`${S+1}`:"";r[`${h}axis`]=`${h}${y}`}}}}static addStylingToSeriesData(s,e,t=B,n=null,r=null,i=null,a=null,l=null){const o=s;if(o.marker={line:{}},o.line={width:1},e===c.plot.SeriesPlotStyle.AREA?o.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?o.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?o.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(o.width=[],o.marker.line!==void 0&&Object.assign(o.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(o.increasing={line:{color:t.ohlc_increasing}},o.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(o.textinfo="label+percent",o.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(o.hoverinfo="text",o.textinfo="label+text",o.tiling={packing:"squarify",pad:0},o.textposition="middle center",o.outsidetextfont={color:t.title_color}),n!=null&&(e===c.plot.SeriesPlotStyle.BAR?o.marker.color=n:o.line.color=n),r!=null&&(o.marker.color=r),i!=null&&i.length>0)try{o.marker.symbol=p.getMarkerSymbol(i)}catch(d){ge.warn("Unable to handle shape",i,":",d)}a!=null&&(o.marker.size=a*p.DEFAULT_MARKER_SIZE),l!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(o.visible=l)}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAxisFormats(s,e){const t=new Map,n={tickformat:null,ticksuffix:null},r=p.getAllAxes(s),i=p.groupArray(r,"type"),{charts:a}=s;for(let l=0;l<a.length;l+=1){const o=a[l];for(let d=0;d<o.series.length;d+=1){const h=o.series[d],{sources:f}=h,S=f.filter(y=>y.axis);for(let y=0;y<S.length;y+=1){const b=S[y],{axis:A}=b,{type:E}=A,M=i.get(E);me(M);const F=M.indexOf(A),C=p.getAxisPropertyName(E);if(C!=null){const P=p.getAxisLayoutProperty(C,F);if(t.has(P))ge.debug(`${P} already added.`);else{ge.debug(`Adding ${P} to axisFormats.`);const R=p.getPlotlyAxisFormat(b,e);if(R===null)t.set(P,n);else{t.set(P,R);const{businessCalendar:$}=A;if($!=null){const L=[],{businessPeriods:le,businessDays:ne,holidays:re,timeZone:ce}=$,ue=e==null?void 0:e.getColumnTypeFormatter(Ve);let ie;He(ue)&&(ie=ue.dhTimeZone);const de=ie?(ce.standardOffset-ie.standardOffset)/60:0;re.length>0&&L.push(...p.createRangeBreakValuesFromHolidays(re,ce,ie)),le.forEach(Q=>L.push({pattern:"hour",bounds:[p.periodToDecimal(Q.close)+de,p.periodToDecimal(Q.open)+de]})),ne.length<G.length&&p.createBoundsFromDays(ne).forEach(Q=>L.push({pattern:"day of week",bounds:Q})),R.rangebreaks=L}if(t.size===o.axes.length)return t}}}}}}return t}static getChartType(s,e){switch(s){case c.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return p.getPlotlyChartType(s,e)}}static getAxisPropertyName(s){switch(s){case c.plot.AxisType.X:return"x";case c.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(s){switch(s){case c.plot.AxisPosition.BOTTOM:return"bottom";case c.plot.AxisPosition.TOP:return"top";case c.plot.AxisPosition.LEFT:return"left";case c.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let n=0;n<t.length;n+=1){const r=t[n];for(let i=0;i<r.series.length;i+=1)if(e===r.series[i])return r}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(n=>n.indexOf("axis")>=0);for(let n=0;n<t.length;n+=1){const r=t[n],i=s[r];Rt(i)&&(e[r]=[...i.range])}return e}static updateFigureAxes(s,e,t,n=0,r=0,i=B){const a=s,l=p.getAllAxes(e);for(let o=0;o<e.charts.length;o+=1){const d=e.charts[o],h=t==null?void 0:t(d),f=p.getChartBounds(e,d,n,r);p.updateLayoutAxes(a,d.axes,l,n,r,f,h,i)}p.removeStaleAxes(a,l)}static getChartBounds(s,e,t,n){const{cols:r,rows:i}=s,{column:a,colspan:l,row:o,rowspan:d}=e,h=a+l,f=o+d,S=1/r,y=1/i,b=p.AXIS_SIZE_PX/t,A=p.AXIS_SIZE_PX/n,E={bottom:(i-f)*y+(f<i?A/2:0),top:(i-o)*y-(o>0?A/2:0),left:a*S+(a>0?b/2:0),right:h*S-(h<r?b/2:0)};return(p.groupArray(e.axes,"position").get(c.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(p.LEGEND_WIDTH_PX/t,p.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*p.DEFAULT_AXIS_SIZE),E}static updateLayoutAxes(s,e,t,n=0,r=0,i={left:0,top:0,right:1,bottom:1},a,l=B){const o=n>0?Math.max(p.MIN_AXIS_SIZE,Math.min(p.AXIS_SIZE_PX/r,p.MAX_AXIS_SIZE)):p.DEFAULT_AXIS_SIZE,d=r>0?Math.max(p.MIN_AXIS_SIZE,Math.min(p.AXIS_SIZE_PX/n,p.MAX_AXIS_SIZE)):p.DEFAULT_AXIS_SIZE,h=s,f=p.groupArray(e,"position"),S=p.groupArray(e,"type"),y=[...S.keys()],b=p.groupArray(t,"type");for(let A=0;A<y.length;A+=1){const E=y[A],M=p.getAxisPropertyName(E);if(M!=null){const F=S.get(E),C=b.get(E),R=E===c.plot.AxisType.Y?r:n;me(F),me(C);for(let $=0;$<F.length;$+=1){const L=F[$],le=C.indexOf(L),ne=p.getAxisLayoutProperty(M,le);h[ne]==null&&(h[ne]=p.makeLayoutAxis(E,l));const re=h[ne];if(re!=null){p.updateLayoutAxis(re,L,$,f,o,d,i);const{range:ce,autorange:ue}=re;if(a!=null&&ce!==void 0&&(ue===void 0||ue===!1)){const ie=a(L),[de,Q]=ie(ce);ge.debug("Setting downsample range",R,de,Q),L.range(R,de,Q)}else L.range(R)}}}}}static removeStaleAxes(s,e){const t=s,n=p.groupArray(e,"type"),r=[...n.keys()];for(let i=0;i<r.length;i+=1){const a=r[i],l=n.get(a);me(l);let o=l.length;const d=p.getAxisPropertyName(a);if(d!=null){let h=p.getAxisLayoutProperty(d,o);for(;t[h]!=null;)delete t[h],o+=1,h=p.getAxisLayoutProperty(d,o)}}}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static updateLayoutAxis(s,e,t,n,r,i,a){const o=e.type===c.plot.AxisType.Y?i:r,d=s,h=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=h:d.title={text:h},e.log&&(d.type="log"),d.side=p.getAxisSide(e.position),t>0){d.overlaying=p.getAxisPropertyName(e.type)??void 0;const f=n.get(e.position)??[],S=f.indexOf(e);S>0&&(d.anchor="free",e.position===c.plot.AxisPosition.RIGHT?d.position=a.right+(S-f.length+1)*o:e.position===c.plot.AxisPosition.TOP?d.position=a.top+(S-f.length+1)*o:e.position===c.plot.AxisPosition.BOTTOM?d.position=a.bottom+(f.length-S+1)*o:e.position===c.plot.AxisPosition.LEFT&&(d.position=a.left+(f.length-S+1)*o))}else if(e.type===c.plot.AxisType.X){const f=n.get(c.plot.AxisPosition.LEFT)||[],S=n.get(c.plot.AxisPosition.RIGHT)||[],y=Math.max(a.left,a.left+(f.length-1)*i),b=Math.min(a.right-(S.length-1)*i,a.right);d.domain=[y,b]}else if(e.type===c.plot.AxisType.Y){const f=n.get(c.plot.AxisPosition.BOTTOM)||[],S=n.get(c.plot.AxisPosition.TOP)||[],y=Math.max(a.bottom,a.bottom+(f.length-1)*r),b=Math.min(a.top-(S.length-1)*r,a.top);d.domain=[y,b]}}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(s){const e=s.map(i=>G.indexOf(i)),t=G.filter(i=>!s.includes(i)).map(i=>G.indexOf(i)),n=new Set;t.forEach(i=>{for(let a=i+1;a<i+G.length;a+=1){const l=a%G.length;if(e.includes(l)){n.add(l);break}}});const r=[];return n.forEach(i=>{for(let a=i-1;a>i-G.length;a-=1){const l=a<0?a+G.length:a;if(e.includes(l)){const o=(l+1)%7;r.push([o,i]);break}}}),r}static createRangeBreakValuesFromHolidays(s,e,t){const n=[],r=[];return s.forEach(i=>{i.businessPeriods.length>0?r.push(...p.createPartialHoliday(i,e,t)):n.push(p.createFullHoliday(i,e,t))}),[{values:n},...r]}static createFullHoliday(s,e,t){return p.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}static createPartialHoliday(s,e,t){const n=s.date.toString(),r=["00:00"];s.businessPeriods.forEach(a=>{r.push(a.open),r.push(a.close)}),r.push("24:00");const i=[];for(let a=0;a<r.length;a+=2){const l=r[a],o=r[a+1];if(l!==o){const d=[p.adjustDateForTimeZone(`${n} ${l}:00.000000`,e,t)],h=vt*(p.periodToDecimal(o)-p.periodToDecimal(l));i.push({values:d,dvalue:h})}}return i}static adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?p.unwrapValue(p.wrapValue(s,Ve,e),t):s}static groupArray(s,e){return s.reduce((t,n)=>{const r=n[e],i=t.get(r)??[];return i.push(n),t.set(r,i),t},new Map)}static unwrapValue(s,e){if(s!=null){if(Lt(s))return c.i18n.DateTimeFormat.format(p.DATE_FORMAT,s,e);if(kt(s))return s.asNumber()}return s}static wrapValue(s,e,t=null){if(W.isDateType(e)&&typeof s=="string"){const n=s,r=p.DATE_FORMAT.substr(0,s.length),i=c.i18n.DateTimeFormat.parse(r,n);if(!t)return i;const a=`${r} Z`,l=c.i18n.DateTimeFormat.format("Z",i,t),o=c.i18n.DateTimeFormat.parse(a,`${n} ${l}`),d=c.i18n.DateTimeFormat.format("Z",o,t);return c.i18n.DateTimeFormat.parse(a,`${n} ${d}`)}return s}static makeLayoutAxis(s,e=B){const t={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===c.plot.AxisType.X?Object.assign(t,{showgrid:!0}):s===c.plot.AxisType.Y&&Object.assign(t,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),t}static getColorwayFromTheme(s=B){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):ge.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static makeDefaultLayout(s=B){const e={...s,autosize:!0,colorway:p.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...p.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...p.DEFAULT_MARGIN},xaxis:p.makeLayoutAxis(c.plot.AxisType.X,s),yaxis:p.makeLayoutAxis(c.plot.AxisType.Y,s)};return e.datarevision=0,e}static hydrateSettings(s){return{...s,type:s.type!=null?c.plot.SeriesPlotStyle[s.type]:void 0}}static titleFromSettings(s){const{series:e,xAxis:t,title:n=`${(e??[]).join(", ")} by ${t}`}=s;return n}static makeFigureSettings(s,e){const{series:t,xAxis:n,type:r}=s,i=p.titleFromSettings(s),a={formatType:`${c.plot.AxisFormatType.NUMBER}`,type:`${c.plot.AxisType.X}`,position:`${c.plot.AxisPosition.BOTTOM}`},l={formatType:`${c.plot.AxisFormatType.NUMBER}`,type:`${c.plot.AxisType.Y}`,position:`${c.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${c.plot.ChartType.XY}`,axes:[a,l],series:(t??[]).map(o=>({plotStyle:`${r}`,name:o,dataSources:[{type:`${c.plot.SourceType.X}`,columnName:n??"",axis:a,table:e},{type:`${c.plot.SourceType.Y}`,columnName:o,axis:l,table:e}]}))}],title:i}}};let I=p;u(I,"DEFAULT_AXIS_SIZE",.15),u(I,"MIN_AXIS_SIZE",.025),u(I,"MAX_AXIS_SIZE",.2),u(I,"AXIS_SIZE_PX",75),u(I,"LEGEND_WIDTH_PX",50),u(I,"MAX_LEGEND_SIZE",.25),u(I,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(I,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(I,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(I,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(I,"SUBTITLE_LINE_HEIGHT",25),u(I,"DEFAULT_MARKER_SIZE",6),u(I,"MODE_MARKERS","markers"),u(I,"MODE_LINES","lines");const N=I;const Y=Z.module("Chart"),oe=class extends _.Component{constructor(e){super(e);u(this,"currentSeries");u(this,"plot");u(this,"plotWrapper");u(this,"columnFormats");u(this,"dateTimeFormatterOptions");u(this,"decimalFormatOptions");u(this,"integerFormatOptions");u(this,"rect");u(this,"ranges");u(this,"isSubscribed");u(this,"isLoadedFired");u(this,"getCachedConfig",ze((e,t,n,r)=>{const i=[],a=Boolean(e);if(a&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:oe.convertIcon(Ye),attr:"fill-warning"}),t||n||r||a){const l=oe.downsampleButtonTitle(n,r),o=oe.downsampleButtonAttr(n,r),d=n?Ke:_e;i.push({name:l,icon:oe.convertIcon(d),click:this.handleDownsampleClick,attr:o})}return{displaylogo:!1,displayModeBar:n||a?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}));this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=X.createRef(),this.plotWrapper=X.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,n]=e.icon,r=`${n}`;return{width:t,path:r,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){Y.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:n}=e;switch(Y.debug2("Received data update",t,n),t){case z.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:a,revision:l}=i;return typeof a.datarevision=="number"&&(a.datarevision+=1),{data:n,layout:a,revision:l+1}});const{onUpdate:r}=this.props;r({isLoading:!this.isLoadedFired});break}case z.EVENT_LOADFINISHED:{const{onUpdate:r}=this.props;this.isLoadedFired=!0,r({isLoading:!1});break}case z.EVENT_DISCONNECT:{const{onDisconnect:r}=this.props;r();break}case z.EVENT_RECONNECT:{const{onReconnect:r}=this.props;r();break}case z.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case z.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case z.EVENT_DOWNSAMPLENEEDED:case z.EVENT_DOWNSAMPLEFAILED:{const r=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:r});const{onError:i}=this.props;i(new Error(r));break}default:Y.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=N.getLayoutRanges(t);!he(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(Y.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(Y.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:r}=this.props;if(n!=null){const i=n.reduce((a,{name:l,visible:o})=>l!=null&&o==="legendonly"?[...a,l]:a,[]);r({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){Y.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:r,model:i}=this.props;i.setDimensions(t),r&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=we.getColumnFormats(e),n=we.getDateTimeFormatterOptions(e),{decimalFormatOptions:r={},integerFormatOptions:i={}}=e;(!he(this.columnFormats,t)||!he(this.dateTimeFormatterOptions,n)||!he(this.decimalFormatOptions,r)||!he(this.integerFormatOptions,i))&&(this.columnFormats=we.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=r,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Pe(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&Ae.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{Y.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:r,isDownsamplingDisabled:i,layout:a,revision:l}=this.state,o=this.getCachedConfig(t,n,r,i),d=e!=null;return D.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:d&&D.jsx(At,{ref:this.plot,data:e,layout:a,revision:l,config:o,onAfterPlot:this.handleAfterPlot,onError:Y.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let De=oe;u(De,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:se.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const $t=De,v=Z.module("FigureChartModel"),Oe=class extends z{constructor(e,t={},n=B){super();u(this,"figure");u(this,"settings");u(this,"theme");u(this,"data");u(this,"layout");u(this,"seriesDataMap");u(this,"pendingSeries");u(this,"oneClicks");u(this,"filterColumnMap");u(this,"lastFilter");u(this,"isConnected");u(this,"seriesToProcess");u(this,"addPendingSeries",Xe(()=>{const e=N.getAllAxes(this.figure),{pendingSeries:t}=this;for(let n=0;n<t.length;n+=1){const r=t[n],i=this.figure.charts.find(a=>a.series.includes(r));this.addSeries(r,e,(i==null?void 0:i.showLegend)??null),r.subscribe()}this.pendingSeries=[]},Oe.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",pe((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}}));u(this,"getValueTranslator",pe((e,t)=>{const n=this.getTimeZone(e,t);return r=>N.unwrapValue(r,n)}));u(this,"getValueParser",pe((e,t)=>{const n=this.getTimeZone(e,t);return r=>N.wrapValue(r,e,n)}));u(this,"getRangeParser",pe((e,t)=>n=>{let[r,i]=n;const a=this.getValueParser(e,t);return r=a(r),i=a(i),[r,i]}));u(this,"getAxisRangeParser",pe((e,t)=>n=>{const r=N.getSourceForAxis(e,n);return r?this.getRangeParser(r.columnType,t):i=>i}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const r={data:{},layout:N.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:r},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=N.getAllAxes(this.figure),n=[];for(let a=0;a<e.length;a+=1){const l=e[a];for(let o=0;o<l.series.length;o+=1){const d=l.series[o];n.push(d.name),this.addSeries(d,t,l.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(a=>n.indexOf(a)<0);for(let a=0;a<i.length;a+=1){const l=i[a];this.seriesDataMap.delete(l)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const r=N.groupArray(t,"type"),i=N.makeSeriesDataFromSeries(e,r,N.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===c.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===c.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=N.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===c.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:l}=a;for(let o=0;o<l.length;o+=1)this.filterColumnMap.set(l[o].name,l[o]);this.oneClicks.push(a)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){v.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?c.plot.DownsampleOptions.DISABLE:c.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(c.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(c.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(c.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(c.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(c.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(c.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(c.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(c.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(c.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(c.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){v.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){v.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){v.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){v.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;v.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const a=n[i];v.debug2("handleFigureUpdated updating series",a.name);const{sources:l}=a;for(let o=0;o<l.length;o+=1){const d=l[o],{columnType:h,type:f}=d,S=this.getValueTranslator(h,this.formatter),y=t.getArray(a,f,S);this.setDataArrayForSeries(a,f,y)}this.seriesToProcess.delete(a.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(a)}const{data:r}=this;this.fireUpdate(r)}handleRequestFailed(e){v.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){v.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){v.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;v.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var r;super.setTitle(e);const t=((r=(e??"").match(/<br>/g))==null?void 0:r.length)??0,n=N.DEFAULT_MARGIN.t+t*N.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=N.DEFAULT_TITLE_PADDING.t+t*N.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();N.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;N.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{v.debug(`Assigning ${n}`,this.layout[n],t);const r=this.layout[n];r!=null?Object.assign(r,t):v.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:r,plotStyle:i}=e,a=this.seriesDataMap.get(r),l=N.getPlotlyProperty(i,t);a&&je(a,l,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,r=this.seriesDataMap.get(t);if(r!=null){if(n===c.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:a}=r;if(i&&a&&i.length===a.length){const l=[];for(let o=0;o<i.length;o+=1)l.push(a[o]-i[o]);r.width=l}}else if(n===c.plot.SeriesPlotStyle.LINE){const{x:i,xLow:a,xHigh:l,y:o,yLow:d,yHigh:h}=r;a&&l&&a!==i&&(r.error_x=N.getPlotlyErrorBars(i,a,l)),d&&h&&d!==o&&(r.error_y=N.getPlotlyErrorBars(o,d,h))}else if(n===c.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:a}=r;i!==void 0&&a===void 0&&(r.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){v.warn("Trying to set a filter, but no one click!");return}v.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:r}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(a=>{const l=e.get(a);this.lastFilter.get(a)!==l&&r.find(o=>o.name===a)!=null&&n.setValueForColumn(a,l)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let Me=Oe;u(Me,"ADD_SERIES_DEBOUNCE",50);const Ue=Me;class ve{static async makeModelFromSettings(s,e,t=B){const n=await ve.makeFigureFromSettings(s,e);return new Ue(n,s,t)}static async makeFigureFromSettings(s,e){const t=await e.copy();return t.applyCustomColumns(e.customColumns),t.applyFilter(e.filter),t.applySort(e.sort),c.plot.Figure.create(N.makeFigureSettings(s,t))}static async makeModel(s,e,t=B){return new Ue(e,s,t)}}const Vt=ve;const Te=Z.module("EmbedChart.App");async function Ht(T,s){Te.info(`Fetching figure ${s}...`);const e={name:s,type:c.VariableType.FIGURE};return T.getObject(e)}function Xt(){const[T,s]=_.useState(),[e,t]=_.useState(),[n,r]=_.useState(!0),i=_.useMemo(()=>new URLSearchParams(window.location.search),[]),a=Je();_.useEffect(function(){async function d(){try{const h=i.get("name");if(h==null)throw new Error("No name param provided");Te.debug("Loading figure",h,"...");const f=await Ht(a,h);Te.debug("Creating model...");const S=await Vt.makeModel(void 0,f);s(S),Te.debug("Figure successfully loaded!")}catch(h){Te.error("Unable to load figure",h),t(`${h}`)}r(!1)}d()},[a,i]);const l=T!=null;return D.jsxs("div",{className:"App",children:[l&&D.jsx($t,{model:T}),!l&&D.jsx(Qe,{isLoaded:l,isLoading:n,errorMessage:e??null}),D.jsx(dt,{})]})}export{Xt as default};
|
|
2
|
-
//# sourceMappingURL=App-0441bef8.js.map
|