From 43485759f94b34dc2ed6f31d80e7e4ae537aa3bb Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 2 Apr 2020 13:57:03 -0700 Subject: [PATCH 01/41] Disable loading scripts from unpkg for widgets --- src/client/common/application/commands.ts | 1 + src/client/common/types.ts | 1 + src/client/common/utils/localize.ts | 4 ++ .../datascience/commands/commandRegistry.ts | 34 ++++++++++++-- src/client/datascience/constants.ts | 4 +- .../interactiveWindowTypes.ts | 7 ++- .../interactive-common/linkProvider.ts | 13 ++++-- .../interactive-common/synchronization.ts | 2 + .../ipywidgets/ipywidgetHandler.ts | 17 ++++++- src/client/datascience/webViewHost.ts | 3 +- src/client/telemetry/index.ts | 4 ++ .../history-react/interactiveCell.tsx | 4 +- .../history-react/redux/reducers/index.ts | 1 + .../interactive-common/cellOutput.tsx | 23 +++++++++- .../redux/reducers/commonEffects.ts | 15 ++++++- .../redux/reducers/types.ts | 7 +++ src/datascience-ui/ipywidgets/container.tsx | 45 ++++++++++++++++--- src/datascience-ui/ipywidgets/manager.ts | 9 ++-- src/datascience-ui/ipywidgets/types.ts | 7 ++- .../native-editor/nativeCell.tsx | 3 ++ .../native-editor/nativeEditor.tsx | 4 +- .../native-editor/redux/reducers/index.ts | 1 + src/ipywidgets/src/embed.ts | 5 ++- src/ipywidgets/src/manager.ts | 26 ++++++++--- .../commands/commandRegistry.unit.test.ts | 6 +++ 25 files changed, 214 insertions(+), 32 deletions(-) diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index 8da4a3d858b4..9aa84e46b09c 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -162,4 +162,5 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu [DSCommands.SaveAsNotebookNonCustomEditor]: [Uri, Uri]; [DSCommands.OpenNotebookNonCustomEditor]: [Uri]; [DSCommands.GatherQuality]: [string]; + [DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never]; } diff --git a/src/client/common/types.ts b/src/client/common/types.ts index b7d91a2cbc35..ff6b90c7938a 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -392,6 +392,7 @@ export interface IDataScienceSettings { variableQueries: IVariableQuery[]; disableJupyterAutoStart?: boolean; jupyterCommandLineArguments: string[]; + loadWidgetScriptsFromThirdPartySource?: boolean; } export const IConfigurationService = Symbol('IConfigurationService'); diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index 60843c35a29e..b7c2113e6e92 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -829,6 +829,10 @@ export namespace DataScience { 'DataScience.loadClassFailedWithNoInternet', 'Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.' ); + export const loadThirdPartyWidgetScriptsPostEnabled = localize( + 'DataScience.loadThirdPartyWidgetScriptsPostEnabled', + "Once you have updated the setting 'loadWidgetScriptsFromThirdPartySource' you will need to restart the Kernel." + ); } export namespace DebugConfigStrings { diff --git a/src/client/datascience/commands/commandRegistry.ts b/src/client/datascience/commands/commandRegistry.ts index a18a49b4e2b7..44792f68552c 100644 --- a/src/client/datascience/commands/commandRegistry.ts +++ b/src/client/datascience/commands/commandRegistry.ts @@ -4,11 +4,12 @@ 'use strict'; import { inject, injectable, multiInject, named, optional } from 'inversify'; -import { CodeLens, env, Range, Uri } from 'vscode'; +import { CodeLens, ConfigurationTarget, env, Range, Uri } from 'vscode'; import { ICommandNameArgumentTypeMapping } from '../../common/application/commands'; -import { ICommandManager, IDebugService, IDocumentManager } from '../../common/application/types'; -import { IDisposable, IOutputChannel } from '../../common/types'; +import { IApplicationShell, ICommandManager, IDebugService, IDocumentManager } from '../../common/application/types'; +import { IConfigurationService, IDisposable, IOutputChannel } from '../../common/types'; import { DataScience } from '../../common/utils/localize'; +import { noop } from '../../common/utils/misc'; import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; import { Commands, JUPYTER_OUTPUT_CHANNEL, Telemetry } from '../constants'; import { @@ -37,6 +38,8 @@ export class CommandRegistry implements IDisposable { private readonly commandLineCommand: JupyterCommandLineSelectorCommand, @inject(INotebookEditorProvider) private notebookEditorProvider: INotebookEditorProvider, @inject(IDebugService) private debugService: IDebugService, + @inject(IConfigurationService) private configService: IConfigurationService, + @inject(IApplicationShell) private appShell: IApplicationShell, @inject(IOutputChannel) @named(JUPYTER_OUTPUT_CHANNEL) private jupyterOutput: IOutputChannel ) { this.disposables.push(this.serverSelectedCommand); @@ -69,6 +72,10 @@ export class CommandRegistry implements IDisposable { this.registerCommand(Commands.CreateNewNotebook, this.createNewNotebook); this.registerCommand(Commands.ViewJupyterOutput, this.viewJupyterOutput); this.registerCommand(Commands.GatherQuality, this.reportGatherQuality); + this.registerCommand( + Commands.EnableLoadingWidgetsFrom3rdPartySource, + this.enableLoadingWidgetScriptsFromThirdParty + ); if (this.commandListeners) { this.commandListeners.forEach((listener: IDataScienceCommandListener) => { listener.register(this.commandManager); @@ -98,6 +105,27 @@ export class CommandRegistry implements IDisposable { return undefined; } + private enableLoadingWidgetScriptsFromThirdParty(): void { + if (this.configService.getSettings(undefined).datascience.loadWidgetScriptsFromThirdPartySource){ + return; + } + // Update the setting and once updated, notify user to restart kernel. + this.configService + .updateSetting( + 'dataScience.loadWidgetScriptsFromThirdPartySource', + true, + undefined, + ConfigurationTarget.Global + ) + .then(() => { + // Let user know they'll need to restart the kernel. + this.appShell + .showInformationMessage(DataScience.loadThirdPartyWidgetScriptsPostEnabled()) + .then(noop, noop); + }) + .catch(noop); + } + private async runAllCells(file: string): Promise { let codeWatcher = this.getCodeWatcher(file); if (!codeWatcher) { diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 03561aa7bf6b..b3373ab973f7 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -82,6 +82,7 @@ export namespace Commands { export const SaveAsNotebookNonCustomEditor = 'python.datascience.notebookeditor.saveAs'; export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open'; export const GatherQuality = 'python.datascience.gatherquality'; + export const EnableLoadingWidgetsFrom3rdPartySource = 'python.datascience.loadWidgetScriptsFromThirdPartySource'; } export namespace CodeLensCommands { @@ -288,7 +289,8 @@ export enum Telemetry { GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED', GatherQualityReport = 'DS_INTERNAL.GATHER_QUALITY_REPORT', ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING', - IPyWidgetLoadFailure = 'DS_INTERNAL.IPYWIDGET_LOAD_FAILURE' + IPyWidgetLoadFailure = 'DS_INTERNAL.IPYWIDGET_LOAD_FAILURE', + IPyWidgetLoadDisabled = 'DS_INTERNAL.IPYWIDGET_LOAD_DISABLED' } export enum NativeKeyboardCommandTelemetry { diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index f4f0c71cbf49..7632a873f153 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -9,7 +9,8 @@ import type { KernelMessage } from '@jupyterlab/services'; import { CommonActionType, IAddCellAction, - ILoadIPyWidgetClassFailureAction + ILoadIPyWidgetClassFailureAction, + LoadIPyWidgetClassDisabledAction } from '../../../datascience-ui/interactive-common/redux/reducers/types'; import { PythonInterpreter } from '../../interpreter/contracts'; import { LiveKernelModel } from '../jupyter/kernels/types'; @@ -107,7 +108,8 @@ export enum InteractiveWindowMessages { ReceivedUpdateModel = 'received_update_model', OpenSettings = 'open_settings', UpdateDisplayData = 'update_display_data', - IPyWidgetLoadFailure = 'ipywidget_load_failure' + IPyWidgetLoadFailure = 'ipywidget_load_failure', + IPyWidgetLoadDisabled = 'ipywidget_load_disabled' } export enum IPyWidgetMessages { @@ -563,4 +565,5 @@ export class IInteractiveWindowMapping { public [SharedMessages.LocInit]: string; public [InteractiveWindowMessages.UpdateDisplayData]: KernelMessage.IUpdateDisplayDataMsg; public [InteractiveWindowMessages.IPyWidgetLoadFailure]: ILoadIPyWidgetClassFailureAction; + public [InteractiveWindowMessages.IPyWidgetLoadDisabled]: LoadIPyWidgetClassDisabledAction; } diff --git a/src/client/datascience/interactive-common/linkProvider.ts b/src/client/datascience/interactive-common/linkProvider.ts index a662af22eb1f..809378b6d3e7 100644 --- a/src/client/datascience/interactive-common/linkProvider.ts +++ b/src/client/datascience/interactive-common/linkProvider.ts @@ -17,7 +17,10 @@ const LineQueryRegex = /line=(\d+)/; // The following list of commands represent those that can be executed // in a markdown cell using the syntax: https://command:[my.vscode.command]. -const linkCommandWhitelist = ['python.datascience.gatherquality']; +const linkCommandWhitelist = [ + 'python.datascience.gatherquality', + 'python.datascience.loadWidgetScriptsFromThirdPartySource' +]; // tslint:disable: no-any @injectable() @@ -49,8 +52,12 @@ export class LinkProvider implements IInteractiveWindowListener { this.openFile(href); } else if (href.startsWith('https://command:')) { const temp: string = href.split(':')[2]; - const command = temp.split('/?')[0]; - const params: string[] = temp.split('/?')[1].split(','); + const params: string[] = + temp.includes('/?') && temp.includes(',') ? temp.split('/?')[1].split(',') : []; + let command = temp.split('/?')[0]; + if (command.endsWith('/')) { + command = command.substring(0, command.length - 1); + } if (linkCommandWhitelist.includes(command)) { commands.executeCommand(command, params); } diff --git a/src/client/datascience/interactive-common/synchronization.ts b/src/client/datascience/interactive-common/synchronization.ts index 53d09f24c925..a188941c338d 100644 --- a/src/client/datascience/interactive-common/synchronization.ts +++ b/src/client/datascience/interactive-common/synchronization.ts @@ -86,6 +86,7 @@ const messageWithMessageTypes: MessageMapping & Messa [CommonActionType.REFRESH_VARIABLES]: MessageType.other, [CommonActionType.FOCUS_INPUT]: MessageType.other, [CommonActionType.LOAD_IPYWIDGET_CLASS_FAILURE]: MessageType.other, + [CommonActionType.LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE]: MessageType.other, // Types from InteractiveWindowMessages [InteractiveWindowMessages.Activate]: MessageType.other, @@ -112,6 +113,7 @@ const messageWithMessageTypes: MessageMapping & Messa [InteractiveWindowMessages.GotoCodeCell]: MessageType.syncWithLiveShare, [InteractiveWindowMessages.Interrupt]: MessageType.other, [InteractiveWindowMessages.IPyWidgetLoadFailure]: MessageType.other, + [InteractiveWindowMessages.IPyWidgetLoadDisabled]: MessageType.other, [InteractiveWindowMessages.LoadAllCells]: MessageType.other, [InteractiveWindowMessages.LoadAllCellsComplete]: MessageType.other, [InteractiveWindowMessages.LoadOnigasmAssemblyRequest]: MessageType.other, diff --git a/src/client/datascience/ipywidgets/ipywidgetHandler.ts b/src/client/datascience/ipywidgets/ipywidgetHandler.ts index 1537ec71cb11..9dd4d0df6060 100644 --- a/src/client/datascience/ipywidgets/ipywidgetHandler.ts +++ b/src/client/datascience/ipywidgets/ipywidgetHandler.ts @@ -5,7 +5,10 @@ import { inject, injectable } from 'inversify'; import { Event, EventEmitter, Uri } from 'vscode'; -import { ILoadIPyWidgetClassFailureAction } from '../../../datascience-ui/interactive-common/redux/reducers/types'; +import { + ILoadIPyWidgetClassFailureAction, + LoadIPyWidgetClassDisabledAction +} from '../../../datascience-ui/interactive-common/redux/reducers/types'; import { traceError } from '../../common/logger'; import { IDisposableRegistry } from '../../common/types'; import { sendTelemetryEvent } from '../../telemetry'; @@ -60,6 +63,8 @@ export class IPyWidgetHandler implements IInteractiveWindowListener { this.saveIdentity(payload).catch((ex) => traceError('Failed to initialize ipywidgetHandler', ex)); } else if (message === InteractiveWindowMessages.IPyWidgetLoadFailure) { this.sendLoadFailureTelemetry(payload); + } else if (message === InteractiveWindowMessages.IPyWidgetLoadDisabled) { + this.sendLoadDisabledTelemetry(payload); } // tslint:disable-next-line: no-any this.getIPyWidgetMessageDispatcher()?.receiveMessage({ message: message as any, payload }); // NOSONAR @@ -76,6 +81,16 @@ export class IPyWidgetHandler implements IInteractiveWindowListener { // do nothing on failure } } + private sendLoadDisabledTelemetry(payload: LoadIPyWidgetClassDisabledAction) { + try { + sendTelemetryEvent(Telemetry.IPyWidgetLoadDisabled, 0, { + moduleHash: this.hashFn(payload.moduleName), + moduleVersion: payload.moduleVersion + }); + } catch { + // do nothing on failure + } + } private getIPyWidgetMessageDispatcher() { if (!this.notebookIdentity) { return; diff --git a/src/client/datascience/webViewHost.ts b/src/client/datascience/webViewHost.ts index 3139475f58da..0991c5623ee1 100644 --- a/src/client/datascience/webViewHost.ts +++ b/src/client/datascience/webViewHost.ts @@ -366,7 +366,8 @@ export abstract class WebViewHost implements IDisposable { event.affectsConfiguration('editor.scrollbar.horizontalScrollbarSize') || event.affectsConfiguration('files.autoSave') || event.affectsConfiguration('files.autoSaveDelay') || - event.affectsConfiguration('python.dataScience.enableGather') + event.affectsConfiguration('python.dataScience.enableGather') || + event.affectsConfiguration('python.dataScience.loadWidgetScriptsFromThirdPartySource') ) { // See if the theme changed const newSettings = await this.generateDataScienceExtraSettings(); diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 5586018182d8..295f4e834ff1 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1921,4 +1921,8 @@ export interface IEventNamePropertyMapping { * Telemetry event sent when an ipywidget module fails to load. Module name is hashed. */ [Telemetry.IPyWidgetLoadFailure]: { isOnline: boolean; moduleHash: string; moduleVersion: string }; + /** + * Telemetry event sent when an loading of 3rd party ipywidget JS scripts from 3rd party source has been disabled. + */ + [Telemetry.IPyWidgetLoadDisabled]: { moduleHash: string; moduleVersion: string }; } diff --git a/src/datascience-ui/history-react/interactiveCell.tsx b/src/datascience-ui/history-react/interactiveCell.tsx index 75fd1065c6f9..684963bd28c5 100644 --- a/src/datascience-ui/history-react/interactiveCell.tsx +++ b/src/datascience-ui/history-react/interactiveCell.tsx @@ -130,7 +130,8 @@ export class InteractiveCell extends React.Component { const cellOuterClass = this.props.cellVM.editable ? 'cell-outer-editable' : 'cell-outer'; const cellWrapperClass = this.props.cellVM.editable ? 'cell-wrapper' : 'cell-wrapper cell-wrapper-noneditable'; const themeMatplotlibPlots = this.props.settings.themeMatplotlibPlots ? true : false; - + const loadWidgetScriptsFromThirdPartySource = + this.props.settings.loadWidgetScriptsFromThirdPartySource === true; // Only render if we are allowed to. if (shouldRender) { return ( @@ -154,6 +155,7 @@ export class InteractiveCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} + loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} /> diff --git a/src/datascience-ui/history-react/redux/reducers/index.ts b/src/datascience-ui/history-react/redux/reducers/index.ts index 0022113cee14..89a1988c2064 100644 --- a/src/datascience-ui/history-react/redux/reducers/index.ts +++ b/src/datascience-ui/history-react/redux/reducers/index.ts @@ -40,6 +40,7 @@ export const reducerMap: Partial = { [CommonActionType.UNMOUNT]: Creation.unmount, [CommonActionType.FOCUS_INPUT]: CommonEffects.focusInput, [CommonActionType.LOAD_IPYWIDGET_CLASS_FAILURE]: CommonEffects.handleLoadIPyWidgetClassFailure, + [CommonActionType.LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE]: CommonEffects.handleLoadIPyWidgetClassDisabled, // Messages from the webview (some are ignored) [InteractiveWindowMessages.Undo]: Execution.undo, diff --git a/src/datascience-ui/interactive-common/cellOutput.tsx b/src/datascience-ui/interactive-common/cellOutput.tsx index 62cb6a5c38b2..a5a56aa818f3 100644 --- a/src/datascience-ui/interactive-common/cellOutput.tsx +++ b/src/datascience-ui/interactive-common/cellOutput.tsx @@ -31,6 +31,7 @@ interface ICellOutputProps { cellVM: ICellViewModel; baseTheme: string; maxTextSize?: number; + loadWidgetScriptsFromThirdPartySource: boolean; hideOutput?: boolean; themeMatplotlibPlots?: boolean; expandImage(imageHtml: string): void; @@ -180,6 +181,9 @@ export class CellOutput extends React.Component { if (nextProps.maxTextSize !== this.props.maxTextSize) { return true; } + if (nextProps.loadWidgetScriptsFromThirdPartySource !== this.props.loadWidgetScriptsFromThirdPartySource) { + return true; + } if (nextProps.themeMatplotlibPlots !== this.props.themeMatplotlibPlots) { return true; } @@ -543,9 +547,24 @@ export class CellOutput extends React.Component { transformedList.forEach((transformed, index) => { const mimetype = transformed.output.mimeType; - if (isIPyWidgetOutput(transformed.output.mimeBundle)) { - return; + if (this.props.loadWidgetScriptsFromThirdPartySource) { + return; + } + // If loading of widget source is not allowed, display a message. + const errorMessage = getLocString( + 'DataScience.loadThirdPartyWidgetScriptsDisabled', + "Loading of 3rd party widgets is disabled by default. Please enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource, alternatively click here to enable this. Once enabled you will need to restart the Kernel" + ); + + // tslint:disable: react-no-dangerous-html + buffer.push( +
+ +
+ +
+ ); } else if (mimetype && isMimeTypeSupported(mimetype)) { // If that worked, use the transform // Get the matching React.Component for that mimetype diff --git a/src/datascience-ui/interactive-common/redux/reducers/commonEffects.ts b/src/datascience-ui/interactive-common/redux/reducers/commonEffects.ts index d34e012b9a35..bac9f6bbd8fd 100644 --- a/src/datascience-ui/interactive-common/redux/reducers/commonEffects.ts +++ b/src/datascience-ui/interactive-common/redux/reducers/commonEffects.ts @@ -13,7 +13,13 @@ import { Helpers } from '../../../interactive-common/redux/reducers/helpers'; import { getLocString, storeLocStrings } from '../../../react-common/locReactSide'; import { postActionToExtension } from '../helpers'; import { Transfer } from './transfer'; -import { CommonActionType, CommonReducerArg, ILoadIPyWidgetClassFailureAction, IOpenSettingsAction } from './types'; +import { + CommonActionType, + CommonReducerArg, + ILoadIPyWidgetClassFailureAction, + IOpenSettingsAction, + LoadIPyWidgetClassDisabledAction +} from './types'; export namespace CommonEffects { export function notebookDirty(arg: CommonReducerArg): IMainState { @@ -255,4 +261,11 @@ export namespace CommonEffects { return arg.prevState; } } + export function handleLoadIPyWidgetClassDisabled( + arg: CommonReducerArg + ): IMainState { + // Make sure to tell the extension so it can log telemetry. + postActionToExtension(arg, InteractiveWindowMessages.IPyWidgetLoadDisabled, arg.payload.data); + return arg.prevState; + } } diff --git a/src/datascience-ui/interactive-common/redux/reducers/types.ts b/src/datascience-ui/interactive-common/redux/reducers/types.ts index 428eab2e5810..d2850726cd40 100644 --- a/src/datascience-ui/interactive-common/redux/reducers/types.ts +++ b/src/datascience-ui/interactive-common/redux/reducers/types.ts @@ -56,6 +56,7 @@ export enum CommonActionType { INSERT_BELOW = 'action.insert_below', INTERRUPT_KERNEL = 'action.interrupt_kernel_action', LOAD_IPYWIDGET_CLASS_FAILURE = 'action.load_ipywidget_class_failure', + LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE = 'action.load_ipywidget_class_disabled_failure', LOADED_ALL_CELLS = 'action.loaded_all_cells', LINK_CLICK = 'action.link_click', MOVE_CELL_DOWN = 'action.move_cell_down', @@ -131,6 +132,7 @@ export type CommonActionTypeMapping = { [CommonActionType.OPEN_SETTINGS]: IOpenSettingsAction; [CommonActionType.FOCUS_INPUT]: never | undefined; [CommonActionType.LOAD_IPYWIDGET_CLASS_FAILURE]: ILoadIPyWidgetClassFailureAction; + [CommonActionType.LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE]: LoadIPyWidgetClassDisabledAction; }; export interface IShowDataViewerAction extends IShowDataViewer {} @@ -215,5 +217,10 @@ export interface ILoadIPyWidgetClassFailureAction { // tslint:disable-next-line: no-any error: any; } +export type LoadIPyWidgetClassDisabledAction = { + className: string; + moduleName: string; + moduleVersion: string; +}; export type CommonAction = ActionWithPayload; diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index ebd5524c44ae..1db51dfcc952 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -10,10 +10,13 @@ import { IStore } from '../interactive-common/redux/store'; import { PostOffice } from '../react-common/postOffice'; import { WidgetManager } from './manager'; +import { SharedMessages } from '../../client/datascience/messages'; +import { IDataScienceExtraSettings } from '../../client/datascience/types'; import { CommonAction, CommonActionType, - ILoadIPyWidgetClassFailureAction + ILoadIPyWidgetClassFailureAction, + LoadIPyWidgetClassDisabledAction } from '../interactive-common/redux/reducers/types'; type Props = { @@ -24,15 +27,31 @@ type Props = { export class WidgetManagerComponent extends React.Component { private readonly widgetManager: WidgetManager; - + private readonly loaderSettings = { + loadWidgetScriptsFromThirdPartySource: false, + errorHandler: this.handleLoadError.bind(this) + }; constructor(props: Props) { super(props); + this.loaderSettings.loadWidgetScriptsFromThirdPartySource = + props.store.getState().main.settings?.loadWidgetScriptsFromThirdPartySource === true; this.widgetManager = new WidgetManager( document.getElementById(this.props.widgetContainerId)!, this.props.postOffice, - this.handleLoadError.bind(this) + this.loaderSettings ); + + props.postOffice.addHandler({ + handleMessage: (type: string, payload?: any) => { + if (type === SharedMessages.UpdateSettings) { + const settings = JSON.parse(payload) as IDataScienceExtraSettings; + this.loaderSettings.loadWidgetScriptsFromThirdPartySource = + settings.loadWidgetScriptsFromThirdPartySource === true; + } + return true; + } + }); } public render() { return null; @@ -54,10 +73,26 @@ export class WidgetManagerComponent extends React.Component { payload: { messageDirection: 'incoming', data: { className, moduleName, moduleVersion, isOnline, error } } }; } + private createLoadDisabledErrorAction( + className: string, + moduleName: string, + moduleVersion: string + ): CommonAction { + return { + type: CommonActionType.LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE, + payload: { messageDirection: 'incoming', data: { className, moduleName, moduleVersion } } + }; + } // tslint:disable-next-line: no-any private async handleLoadError(className: string, moduleName: string, moduleVersion: string, error: any) { - const isOnline = await isonline.default({ timeout: 1000 }); - this.props.store.dispatch(this.createLoadErrorAction(className, moduleName, moduleVersion, isOnline, error)); + if (this.loaderSettings.loadWidgetScriptsFromThirdPartySource) { + const isOnline = await isonline.default({ timeout: 1000 }); + this.props.store.dispatch( + this.createLoadErrorAction(className, moduleName, moduleVersion, isOnline, error) + ); + } else { + this.props.store.dispatch(this.createLoadDisabledErrorAction(className, moduleName, moduleVersion)); + } } } diff --git a/src/datascience-ui/ipywidgets/manager.ts b/src/datascience-ui/ipywidgets/manager.ts index d0cc4fc6a5d6..d85f9db15199 100644 --- a/src/datascience-ui/ipywidgets/manager.ts +++ b/src/datascience-ui/ipywidgets/manager.ts @@ -55,8 +55,11 @@ export class WidgetManager implements IIPyWidgetManager { constructor( private readonly widgetContainer: HTMLElement, private readonly postOffice: PostOffice, - // tslint:disable-next-line: no-any - private loadErrorHandler: (className: string, moduleName: string, moduleVersion: string, error: any) => void + private readonly scriptLoader: { + loadWidgetScriptsFromThirdPartySource: boolean; + // tslint:disable-next-line: no-any + errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; + } ) { // Create an observable with list of messages to be processed by the kernel in ipywidgets. // Use an observable so that messages are buffered until it is ready to process them. @@ -197,7 +200,7 @@ export class WidgetManager implements IIPyWidgetManager { // When ever there is a display data message, ensure we build the model. this.proxyKernel.iopubMessage.connect(this.handleDisplayDataMessage.bind(this)); - this.manager = new JupyterLabWidgetManager(this.proxyKernel, this.widgetContainer, this.loadErrorHandler); + this.manager = new JupyterLabWidgetManager(this.proxyKernel, this.widgetContainer, this.scriptLoader); WidgetManager._instance.next(this); } catch (ex) { // tslint:disable-next-line: no-console diff --git a/src/datascience-ui/ipywidgets/types.ts b/src/datascience-ui/ipywidgets/types.ts index a3b4e138643a..6575759d9dfd 100644 --- a/src/datascience-ui/ipywidgets/types.ts +++ b/src/datascience-ui/ipywidgets/types.ts @@ -18,8 +18,11 @@ export type CommTargetCallback = (comm: Kernel.IComm, msg: KernelMessage.ICommOp export type IJupyterLabWidgetManagerCtor = new ( kernel: Kernel.IKernelConnection, el: HTMLElement, - // tslint:disable-next-line: no-any - loadErrorHandler: (className: string, moduleName: string, moduleVersion: string, error: any) => void + scriptLoader: { + loadWidgetScriptsFromThirdPartySource: boolean; + // tslint:disable-next-line: no-any + errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; + } ) => IJupyterLabWidgetManager; export interface IJupyterLabWidgetManager { diff --git a/src/datascience-ui/native-editor/nativeCell.tsx b/src/datascience-ui/native-editor/nativeCell.tsx index dbe82203d555..aa8c315c5938 100644 --- a/src/datascience-ui/native-editor/nativeCell.tsx +++ b/src/datascience-ui/native-editor/nativeCell.tsx @@ -51,6 +51,7 @@ interface INativeCellBaseProps { themeMatplotlibPlots: boolean | undefined; focusPending: number; busy: boolean; + loadWidgetScriptsFromThirdPartySource: boolean; } type INativeCellProps = INativeCellBaseProps & typeof actionCreators; @@ -676,6 +677,7 @@ export class NativeCell extends React.Component { private renderOutput = (): JSX.Element | null => { const themeMatplotlibPlots = this.props.themeMatplotlibPlots ? true : false; const toolbar = this.props.cellVM.cell.data.cell_type === 'markdown' ? this.renderMiddleToolbar() : null; + const loadWidgetScriptsFromThirdPartySource = this.props.loadWidgetScriptsFromThirdPartySource === true; if (this.shouldRenderOutput()) { return (
@@ -686,6 +688,7 @@ export class NativeCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} + loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} />
); diff --git a/src/datascience-ui/native-editor/nativeEditor.tsx b/src/datascience-ui/native-editor/nativeEditor.tsx index d9b62ba01a6a..f1350d0db492 100644 --- a/src/datascience-ui/native-editor/nativeEditor.tsx +++ b/src/datascience-ui/native-editor/nativeEditor.tsx @@ -247,7 +247,8 @@ ${buildSettingsCss(this.props.settings)}`} if (!this.props.settings || !this.props.editorOptions) { return null; } - + const loadWidgetScriptsFromThirdPartySource = + this.props.settings.loadWidgetScriptsFromThirdPartySource === true; const addNewCell = () => { setTimeout(() => this.props.insertBelow(cellVM.cell.id), 1); this.props.sendCommand(NativeCommandType.AddToEnd, 'mouse'); @@ -284,6 +285,7 @@ ${buildSettingsCss(this.props.settings)}`} // Focus pending does not apply to native editor. focusPending={0} busy={this.props.busy} + loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} /> {lastLine} diff --git a/src/datascience-ui/native-editor/redux/reducers/index.ts b/src/datascience-ui/native-editor/redux/reducers/index.ts index a1f2f1da2f50..7632d7082770 100644 --- a/src/datascience-ui/native-editor/redux/reducers/index.ts +++ b/src/datascience-ui/native-editor/redux/reducers/index.ts @@ -59,6 +59,7 @@ export const reducerMap: Partial = { [CommonActionType.LOADED_ALL_CELLS]: Transfer.loadedAllCells, [CommonActionType.UNMOUNT]: Creation.unmount, [CommonActionType.LOAD_IPYWIDGET_CLASS_FAILURE]: CommonEffects.handleLoadIPyWidgetClassFailure, + [CommonActionType.LOAD_IPYWIDGET_CLASS_DISABLED_FAILURE]: CommonEffects.handleLoadIPyWidgetClassDisabled, // Messages from the webview (some are ignored) [InteractiveWindowMessages.StartCell]: Creation.startCell, diff --git a/src/ipywidgets/src/embed.ts b/src/ipywidgets/src/embed.ts index d76a82aa9f5b..08f1d6393dee 100644 --- a/src/ipywidgets/src/embed.ts +++ b/src/ipywidgets/src/embed.ts @@ -99,7 +99,10 @@ export function requireLoader(moduleName: string, moduleVersion: string): Promis */ export function renderWidgets(element = document.documentElement): void { const managerFactory = (): any => { - return new wm.WidgetManager(undefined, element, () => 'Error loading widget.'); + return new wm.WidgetManager(undefined, element, { + loadWidgetScriptsFromThirdPartySource: false, + errorHandler: () => 'Error loading widget.' + }); }; libembed.renderWidgets(managerFactory, element).catch((x) => { window.console.error(x); diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index e5b4a8a2af81..9f1a4ff05436 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -23,7 +23,10 @@ export class WidgetManager extends jupyterlab.WidgetManager { constructor( kernel: Kernel.IKernelConnection, el: HTMLElement, - private loadErrorHandler: (className: string, moduleName: string, moduleVersion: string, error: any) => void + private readonly scriptLoader: { + loadWidgetScriptsFromThirdPartySource: boolean; + errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; + } ) { super( new DocumentContext(kernel), @@ -90,16 +93,29 @@ export class WidgetManager extends jupyterlab.WidgetManager { // Call the base class to try and load. If that fails, look locally window.console.log(`WidgetManager: Loading class ${className}:${moduleName}:${moduleVersion}`); // tslint:disable-next-line: no-unnecessary-local-variable - const result = await super.loadClass(className, moduleName, moduleVersion).catch(async (x) => { + const result = await super.loadClass(className, moduleName, moduleVersion).catch(async (originalException) => { try { + if (!this.scriptLoader.loadWidgetScriptsFromThirdPartySource) { + throw new Error('Loading from 3rd party source is disabled'); + } const m = await requireLoader(moduleName, moduleVersion); if (m && m[className]) { return m[className]; } - throw x; + throw originalException; } catch (ex) { - this.loadErrorHandler(className, moduleName, moduleVersion, x); - throw x; + this.scriptLoader.errorHandler(className, moduleName, moduleVersion, originalException); + if (this.scriptLoader.loadWidgetScriptsFromThirdPartySource) { + throw originalException; + } else { + // Don't throw exceptions if disabled, else everything stops working. + window.console.error(ex); + // Returning an unresolved promise will prevent Jupyter ipywidgets from doing anything. + // tslint:disable-next-line: promise-must-complete + return new Promise(() => { + // Noop. + }); + } } }); diff --git a/src/test/datascience/commands/commandRegistry.unit.test.ts b/src/test/datascience/commands/commandRegistry.unit.test.ts index ad42d2e87cd2..90d30dffc989 100644 --- a/src/test/datascience/commands/commandRegistry.unit.test.ts +++ b/src/test/datascience/commands/commandRegistry.unit.test.ts @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { anything, instance, mock, verify } from 'ts-mockito'; +import { ApplicationShell } from '../../../client/common/application/applicationShell'; import { CommandManager } from '../../../client/common/application/commandManager'; import { DebugService } from '../../../client/common/application/debugService'; import { DocumentManager } from '../../../client/common/application/documentManager'; import { ICommandManager } from '../../../client/common/application/types'; +import { ConfigurationService } from '../../../client/common/configuration/service'; import { JupyterCommandLineSelectorCommand } from '../../../client/datascience/commands/commandLineSelector'; import { CommandRegistry } from '../../../client/datascience/commands/commandRegistry'; import { KernelSwitcherCommand } from '../../../client/datascience/commands/kernelSwitcher'; @@ -31,6 +33,8 @@ suite('Data Science - Commands', () => { const debugService = mock(DebugService); const documentManager = mock(DocumentManager); commandManager = mock(CommandManager); + const configService = mock(ConfigurationService); + const appShell = mock(ApplicationShell); commandRegistry = new CommandRegistry( documentManager, @@ -42,6 +46,8 @@ suite('Data Science - Commands', () => { instance(commandLineCommand), instance(notebookEditorProvider), instance(debugService), + instance(configService), + instance(appShell), new MockOutputChannel('Jupyter') ); }); From cca2194211184c0decfc551ed803bdaafac2e6ff Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 2 Apr 2020 14:17:47 -0700 Subject: [PATCH 02/41] Oops --- package.json | 6 ++++++ package.nls.json | 4 +++- src/client/datascience/commands/commandRegistry.ts | 2 +- src/datascience-ui/ipywidgets/container.tsx | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fa6e0743af90..5d1d6f469ce8 100644 --- a/package.json +++ b/package.json @@ -1604,6 +1604,12 @@ "description": "Allows a user to import a jupyter notebook into a python file anytime one is opened.", "scope": "resource" }, + "python.dataScience.loadWidgetScriptsFromThirdPartySource": { + "type": "boolean", + "default": false, + "description": "Enables loading of scripts files for Widgets (ipywidgest, bqplot, beakerx, ipyleaflet, etc) from a third party source such as https://unpkg.com.", + "scope": "machine" + }, "python.dataScience.gatherRules": { "type": "array", "default": [ diff --git a/package.nls.json b/package.nls.json index 4e7dc281819c..125d5913d166 100644 --- a/package.nls.json +++ b/package.nls.json @@ -457,5 +457,7 @@ "DataScience.jupyterSelectURIQuickPickTitleRemoteOnly": "Pick an already running jupyter server", "DataScience.jupyterSelectURIRemoteDetail": "Specify the URI of an existing server", "DataScience.gatherQuality": "Did gather work as desired?", - "DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets." + "DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.", + "DataScience.loadThirdPartyWidgetScriptsDisabled": "Loading of Widgets is disabled by default. Please enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource', alternatively click here to enable this. Once enabled you will need to restart the Kernel", + "DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'loadWidgetScriptsFromThirdPartySource'." } diff --git a/src/client/datascience/commands/commandRegistry.ts b/src/client/datascience/commands/commandRegistry.ts index 44792f68552c..b4a0f225d9e4 100644 --- a/src/client/datascience/commands/commandRegistry.ts +++ b/src/client/datascience/commands/commandRegistry.ts @@ -106,7 +106,7 @@ export class CommandRegistry implements IDisposable { } private enableLoadingWidgetScriptsFromThirdParty(): void { - if (this.configService.getSettings(undefined).datascience.loadWidgetScriptsFromThirdPartySource){ + if (this.configService.getSettings(undefined).datascience.loadWidgetScriptsFromThirdPartySource) { return; } // Update the setting and once updated, notify user to restart kernel. diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 1db51dfcc952..2e6d73c161ec 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -43,6 +43,7 @@ export class WidgetManagerComponent extends React.Component { ); props.postOffice.addHandler({ + // tslint:disable-next-line: no-any handleMessage: (type: string, payload?: any) => { if (type === SharedMessages.UpdateSettings) { const settings = JSON.parse(payload) as IDataScienceExtraSettings; From f9cf82f21ae506525b36ace3f891d525e16c00c3 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 2 Apr 2020 14:46:56 -0700 Subject: [PATCH 03/41] Updated --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d1d6f469ce8..b5f611cbb8e7 100644 --- a/package.json +++ b/package.json @@ -1607,7 +1607,7 @@ "python.dataScience.loadWidgetScriptsFromThirdPartySource": { "type": "boolean", "default": false, - "description": "Enables loading of scripts files for Widgets (ipywidgest, bqplot, beakerx, ipyleaflet, etc) from a third party source such as https://unpkg.com.", + "description": "Enables loading of scripts files for Widgets (ipywidgest, bqplot, beakerx, ipyleaflet, etc) from https://unpkg.com.", "scope": "machine" }, "python.dataScience.gatherRules": { From dc69573f2230a43a5cf0fa608552231c598f81ee Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 2 Apr 2020 15:53:09 -0700 Subject: [PATCH 04/41] review fixes --- package.nls.json | 2 +- src/datascience-ui/interactive-common/cellOutput.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.nls.json b/package.nls.json index 125d5913d166..31ca2cc4402c 100644 --- a/package.nls.json +++ b/package.nls.json @@ -458,6 +458,6 @@ "DataScience.jupyterSelectURIRemoteDetail": "Specify the URI of an existing server", "DataScience.gatherQuality": "Did gather work as desired?", "DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.", - "DataScience.loadThirdPartyWidgetScriptsDisabled": "Loading of Widgets is disabled by default. Please enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource', alternatively click here to enable this. Once enabled you will need to restart the Kernel", + "DataScience.loadThirdPartyWidgetScriptsDisabled": "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel", "DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'loadWidgetScriptsFromThirdPartySource'." } diff --git a/src/datascience-ui/interactive-common/cellOutput.tsx b/src/datascience-ui/interactive-common/cellOutput.tsx index a5a56aa818f3..ef156473ded7 100644 --- a/src/datascience-ui/interactive-common/cellOutput.tsx +++ b/src/datascience-ui/interactive-common/cellOutput.tsx @@ -554,7 +554,7 @@ export class CellOutput extends React.Component { // If loading of widget source is not allowed, display a message. const errorMessage = getLocString( 'DataScience.loadThirdPartyWidgetScriptsDisabled', - "Loading of 3rd party widgets is disabled by default. Please enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource, alternatively click here to enable this. Once enabled you will need to restart the Kernel" + "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel" ); // tslint:disable: react-no-dangerous-html From 21e3191e1f97fddf7d0da067389ad95a3cc7e1e5 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Fri, 3 Apr 2020 12:20:36 -0700 Subject: [PATCH 05/41] Backup --- .vscode/launch.json | 2 +- src/client/common/application/types.ts | 12 + .../common/application/webPanels/webPanel.ts | 8 +- src/client/datascience/constants.ts | 4 + .../interactiveWindowTypes.ts | 18 ++ .../interactive-common/synchronization.ts | 9 +- .../ipywidgets/baseMessageDispatcher.ts | 85 ++++++ .../ipywidgets/ipyWidgetMessageDispatcher.ts | 2 +- .../ipyWidgetMessageDispatcherFactory.ts | 12 +- .../ipywidgets/ipyWidgetScriptSource.ts | 243 ++++++++++++++++++ .../ipyWidgetScriptSourceProviderFactory.ts | 119 +++++++++ .../ipywidgets/ipywidgetHandler.ts | 4 +- .../localWidgetScriptSourceProvider.ts | 102 ++++++++ .../remoteWidgetScriptSourceProvider.ts | 21 ++ src/client/datascience/ipywidgets/types.ts | 25 ++ .../datascience/jupyter/jupyterNotebook.ts | 4 + .../jupyter/liveshare/guestJupyterNotebook.ts | 5 + src/client/datascience/serviceRegistry.ts | 2 + src/client/datascience/types.ts | 21 +- src/client/datascience/webViewHost.ts | 8 +- src/client/telemetry/index.ts | 24 ++ .../interactive-common/cellOutput.tsx | 34 +-- src/datascience-ui/ipywidgets/container.tsx | 108 +++++++- src/datascience-ui/ipywidgets/manager.ts | 5 +- src/ipywidgets/src/embed.ts | 5 +- src/ipywidgets/src/manager.ts | 34 ++- src/ipywidgets/src/widgetLoader.ts | 15 +- src/test/datascience/mockJupyterNotebook.ts | 5 +- .../datascience/uiTests/webBrowserPanel.ts | 3 + 29 files changed, 888 insertions(+), 51 deletions(-) create mode 100644 src/client/datascience/ipywidgets/baseMessageDispatcher.ts create mode 100644 src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts create mode 100644 src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts create mode 100644 src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts create mode 100644 src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index d471dd658003..26f7e11c4256 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,7 +16,7 @@ "outFiles": [ "${workspaceFolder}/out/**/*" ], - "preLaunchTask": "Compile", + // "preLaunchTask": "Compile", "skipFiles": [ "/**" ] diff --git a/src/client/common/application/types.ts b/src/client/common/application/types.ts index e0516cf7b383..7f6899c201c3 100644 --- a/src/client/common/application/types.ts +++ b/src/client/common/application/types.ts @@ -987,6 +987,18 @@ export type WebPanelMessage = { // Wraps the VS Code webview panel export const IWebPanel = Symbol('IWebPanel'); export interface IWebPanel { + /** + * Convert a uri for the local file system to one that can be used inside webviews. + * + * Webviews cannot directly load resources from the workspace or local file system using `file:` uris. The + * `asWebviewUri` function takes a local `file:` uri and converts it into a uri that can be used inside of + * a webview to load the same resource: + * + * ```ts + * webview.html = `` + * ``` + */ + asWebviewUri(localResource: Uri): Uri; setTitle(val: string): void; /** * Makes the webpanel show up. diff --git a/src/client/common/application/webPanels/webPanel.ts b/src/client/common/application/webPanels/webPanel.ts index 9b36befee4a1..40719293572f 100644 --- a/src/client/common/application/webPanels/webPanel.ts +++ b/src/client/common/application/webPanels/webPanel.ts @@ -71,6 +71,12 @@ export class WebPanel implements IWebPanel { this.panel.dispose(); } } + public asWebviewUri(localResource: Uri) { + if (!this.panel) { + throw new Error('WebView not initialized, too early to get a Uri'); + } + return this.panel?.webview.asWebviewUri(localResource); + } public isVisible(): boolean { return this.panel ? this.panel.visible : false; @@ -161,7 +167,7 @@ export class WebPanel implements IWebPanel { VS Code Python React UI - + diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index b3373ab973f7..a3fa8535a986 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -244,6 +244,10 @@ export enum Telemetry { HashedCellOutputMimeType = 'DS_INTERNAL.HASHED_OUTPUT_MIME_TYPE', HashedCellOutputMimeTypePerf = 'DS_INTERNAL.HASHED_OUTPUT_MIME_TYPE_PERF', HashedNotebookCellOutputMimeTypePerf = 'DS_INTERNAL.HASHED_NOTEBOOK_OUTPUT_MIME_TYPE_PERF', + HashedIPyWidgetNameDiscovered = 'HashedIPyWidgetNameDiscovered', + HashedIPyWidgetNameUsed = 'HashedIPyWidgetNameUsed', + DiscoverIPyWidgetNamesPerf = 'DiscoverIPyWidgetNamesPerf', + JupyterInstalledButNotKernelSpecModule = 'DS_INTERNAL.JUPYTER_INTALLED_BUT_NO_KERNELSPEC_MODULE', PtvsdPromptToInstall = 'DATASCIENCE.PTVSD_PROMPT_TO_INSTALL', PtvsdSuccessfullyInstalled = 'DATASCIENCE.PTVSD_SUCCESSFULLY_INSTALLED', diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index 7632a873f153..d429b4534b19 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -13,6 +13,7 @@ import { LoadIPyWidgetClassDisabledAction } from '../../../datascience-ui/interactive-common/redux/reducers/types'; import { PythonInterpreter } from '../../interpreter/contracts'; +import { WidgetScriptSource } from '../ipywidgets/types'; import { LiveKernelModel } from '../jupyter/kernels/types'; import { CssMessages, IGetCssRequest, IGetCssResponse, IGetMonacoThemeRequest, SharedMessages } from '../messages'; import { IGetMonacoThemeResponse } from '../monacoMessages'; @@ -115,6 +116,18 @@ export enum InteractiveWindowMessages { export enum IPyWidgetMessages { IPyWidgets_Ready = 'IPyWidgets_Ready', IPyWidgets_onRestartKernel = 'IPyWidgets_onRestartKernel', + IPyWidgets_onKernelChanged = 'IPyWidgets_onKernelChanged', + IPyWidgets_updateRequireConfig = 'IPyWidgets_updateRequireConfig', + /** + * UI sends a request to extension to determine whether we have the source for any of the widgets. + */ + IPyWidgets_WidgetScriptSourceRequest = 'IPyWidgets_WidgetScriptSourceRequest', + /** + * Extension sends response to the request with yes/no. + */ + IPyWidgets_WidgetScriptSourceResponse = 'IPyWidgets_WidgetScriptSourceResponse', + IPyWidgets_AllWidgetScriptSourcesRequest = 'IPyWidgets_AllWidgetScriptSourcesRequest', + IPyWidgets_AllWidgetScriptSourcesResponse = 'IPyWidgets_AllWidgetScriptSourcesResponse', IPyWidgets_msg = 'IPyWidgets_msg', IPyWidgets_binary_msg = 'IPyWidgets_binary_msg', IPyWidgets_kernelOptions = 'IPyWidgets_kernelOptions', @@ -468,8 +481,13 @@ export type NotebookModelChange = // Map all messages to specific payloads export class IInteractiveWindowMapping { public [IPyWidgetMessages.IPyWidgets_kernelOptions]: KernelSocketOptions; + public [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesRequest]: undefined | never; + public [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse]: WidgetScriptSource[]; + public [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest]: string; + public [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse]: WidgetScriptSource; public [IPyWidgetMessages.IPyWidgets_Ready]: never | undefined; public [IPyWidgetMessages.IPyWidgets_onRestartKernel]: never | undefined; + public [IPyWidgetMessages.IPyWidgets_onKernelChanged]: never | undefined; public [IPyWidgetMessages.IPyWidgets_registerCommTarget]: string; // tslint:disable-next-line: no-any public [IPyWidgetMessages.IPyWidgets_binary_msg]: any; diff --git a/src/client/datascience/interactive-common/synchronization.ts b/src/client/datascience/interactive-common/synchronization.ts index a188941c338d..50eba700310c 100644 --- a/src/client/datascience/interactive-common/synchronization.ts +++ b/src/client/datascience/interactive-common/synchronization.ts @@ -182,9 +182,14 @@ const messageWithMessageTypes: MessageMapping & Messa [SharedMessages.Started]: MessageType.other, [SharedMessages.UpdateSettings]: MessageType.other, // IpyWidgets - [IPyWidgetMessages.IPyWidgets_kernelOptions]: MessageType.noIdea, + [IPyWidgetMessages.IPyWidgets_kernelOptions]: MessageType.syncAcrossSameNotebooks, [IPyWidgetMessages.IPyWidgets_Ready]: MessageType.noIdea, - [IPyWidgetMessages.IPyWidgets_onRestartKernel]: MessageType.noIdea, + [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesRequest]: MessageType.noIdea, + [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse]: MessageType.syncAcrossSameNotebooks, + [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest]: MessageType.noIdea, + [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse]: MessageType.syncAcrossSameNotebooks, + [IPyWidgetMessages.IPyWidgets_onKernelChanged]: MessageType.syncAcrossSameNotebooks, + [IPyWidgetMessages.IPyWidgets_onRestartKernel]: MessageType.syncAcrossSameNotebooks, [IPyWidgetMessages.IPyWidgets_msg]: MessageType.noIdea, [IPyWidgetMessages.IPyWidgets_binary_msg]: MessageType.noIdea, [IPyWidgetMessages.IPyWidgets_registerCommTarget]: MessageType.noIdea diff --git a/src/client/datascience/ipywidgets/baseMessageDispatcher.ts b/src/client/datascience/ipywidgets/baseMessageDispatcher.ts new file mode 100644 index 000000000000..4a8f557d47ba --- /dev/null +++ b/src/client/datascience/ipywidgets/baseMessageDispatcher.ts @@ -0,0 +1,85 @@ +// // Copyright (c) Microsoft Corporation. All rights reserved. +// // Licensed under the MIT License. + +// 'use strict'; + +// import * as util from 'util'; +// import { Event, EventEmitter, Uri } from 'vscode'; +// import { traceError, traceInfo } from '../../common/logger'; +// import { IDisposable } from '../../common/types'; +// import { noop } from '../../common/utils/misc'; +// import { deserializeDataViews, serializeDataViews } from '../../common/utils/serializers'; +// import { +// IInteractiveWindowMapping, +// InteractiveWindowMessages, +// IPyWidgetMessages +// } from '../interactive-common/interactiveWindowTypes'; +// import { INotebook, INotebookProvider, KernelSocketInformation } from '../types'; +// import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; + +// // tslint:disable: no-any +// /** +// * This class maps between messages from the react code and talking to a real kernel. +// */ +// export abstract class BaseNotebookMessageListener implements IIPyWidgetMessageDispatcher { +// public get postMessage(): Event { +// return this._postMessageEmitter.event; +// } +// protected notebook?: INotebook; + +// protected readonly disposables: IDisposable[] = []; +// protected disposed = false; +// private _postMessageEmitter = new EventEmitter(); +// constructor(protected readonly notebookProvider: INotebookProvider, public readonly notebookIdentity: Uri) { +// notebookProvider.onNotebookCreated( +// (e) => { +// if (e.identity.toString() === notebookIdentity.toString()) { +// this.initialize().ignoreErrors(); +// } +// }, +// this, +// this.disposables +// ); +// } +// public dispose() { +// this.disposed = true; +// while (this.disposables.length) { +// const disposable = this.disposables.shift(); +// disposable?.dispose(); // NOSONAR +// } +// } + +// public receiveMessage(message: IPyWidgetMessage | { message: InteractiveWindowMessages.RestartKernel }): void { +// traceInfo(`IPyWidgetMessage: ${util.inspect(message)}`); +// switch (message.message) { +// case IPyWidgetMessages.IPyWidgets_Ready: +// this.initialize().ignoreErrors(); +// break; +// default: +// break; +// } +// } +// public async initialize() { +// // If we have any pending targets, register them now +// await this.getNotebook(); +// } +// protected abstract async onNotebookInitialized(): Promise; +// protected raisePostMessage( +// message: IPyWidgetMessages, +// payload: M[T] +// ) { +// this._postMessageEmitter.fire({ message, payload }); +// } +// private async getNotebook(): Promise { +// if (this.notebookIdentity && !this.notebook) { +// this.notebook = await this.notebookProvider.getOrCreateNotebook({ +// identity: this.notebookIdentity, +// getOnly: true +// }); +// if (this.notebook) { +// await this.onNotebookInitialized(); +// } +// } +// return this.notebook; +// } +// } diff --git a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts index f7d42e149c8e..468972e5d672 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts @@ -21,7 +21,7 @@ import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; /** * This class maps between messages from the react code and talking to a real kernel. */ -export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { + export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { public get postMessage(): Event { return this._postMessageEmitter.event; } diff --git a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcherFactory.ts b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcherFactory.ts index 4193b4362b5c..551bf1d18dca 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcherFactory.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcherFactory.ts @@ -75,7 +75,7 @@ class IPyWidgetMessageDispatcherWithOldMessages implements IIPyWidgetMessageDisp */ @injectable() export class IPyWidgetMessageDispatcherFactory implements IDisposable { - private readonly ipywidgetMulticasters = new Map(); + private readonly messageDispatchers = new Map(); private readonly messages: IPyWidgetMessage[] = []; private disposed = false; private disposables: IDisposable[] = []; @@ -98,17 +98,17 @@ export class IPyWidgetMessageDispatcherFactory implements IDisposable { } } public create(identity: Uri): IIPyWidgetMessageDispatcher { - let baseDispatcher = this.ipywidgetMulticasters.get(identity.fsPath); + let baseDispatcher = this.messageDispatchers.get(identity.fsPath); if (!baseDispatcher) { baseDispatcher = new IPyWidgetMessageDispatcher(this.notebookProvider, identity); - this.ipywidgetMulticasters.set(identity.fsPath, baseDispatcher); + this.messageDispatchers.set(identity.fsPath, baseDispatcher); // Capture all messages so we can re-play messages that others missed. this.disposables.push(baseDispatcher.postMessage(this.onMessage, this)); } // If we have messages upto this point, then capture those messages, - // & pass to the multicaster so it can re-broadcast those old messages. + // & pass to the dispatcher so it can re-broadcast those old messages. // If there are no old messages, even then return a new instance of the class. // This way, the reference to that will be controlled by calling code. const dispatcher = new IPyWidgetMessageDispatcherWithOldMessages( @@ -124,9 +124,9 @@ export class IPyWidgetMessageDispatcherFactory implements IDisposable { } notebook.onDisposed( () => { - const item = this.ipywidgetMulticasters.get(notebook.identity.fsPath); + const item = this.messageDispatchers.get(notebook.identity.fsPath); item?.dispose(); // NOSONAR - this.ipywidgetMulticasters.delete(notebook.identity.fsPath); + this.messageDispatchers.delete(notebook.identity.fsPath); }, this, this.disposables diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts new file mode 100644 index 000000000000..49b79dc7aa70 --- /dev/null +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; +import type * as jupyterlabService from '@jupyterlab/services'; +import { sha256 } from 'hash.js'; +import { inject, injectable } from 'inversify'; +import { IDisposable } from 'monaco-editor'; +import { Event, EventEmitter, Uri } from 'vscode'; +import { traceError } from '../../common/logger'; +import { IFileSystem } from '../../common/platform/types'; +import { IDisposableRegistry } from '../../common/types'; +import { IInterpreterService, PythonInterpreter } from '../../interpreter/contracts'; +import { sendTelemetryEvent } from '../../telemetry'; +import { Telemetry } from '../constants'; +import { + INotebookIdentity, + InteractiveWindowMessages, + IPyWidgetMessages +} from '../interactive-common/interactiveWindowTypes'; +import { + IInteractiveBase, + IInteractiveWindowListener, + IInteractiveWindowProvider, + INotebook, + INotebookEditorProvider, + INotebookProvider, + KernelSocketInformation +} from '../types'; +import { LocalWidgetScriptSourceProvider } from './localWidgetScriptSourceProvider'; +import { RemoteWidgetScriptSourceProvider } from './remoteWidgetScriptSourceProvider'; +import { IWidgetScriptSourceProvider } from './types'; + +@injectable() +export class IPyWidgetScriptSource implements IInteractiveWindowListener { + // tslint:disable-next-line: no-any + public get postMessage(): Event<{ message: string; payload: any }> { + return this.postEmitter.event; + } + private notebookIdentity?: Uri; + private postEmitter = new EventEmitter<{ + message: string; + // tslint:disable-next-line: no-any + payload: any; + }>(); + private notebook?: INotebook; + private jupyterLab?: typeof jupyterlabService; + private interactiveBase?: IInteractiveBase; + private scriptProvider?: IWidgetScriptSourceProvider; + private disposables: IDisposable[] = []; + private interpreterForWhichWidgetSourcesWereFetched?: PythonInterpreter; + private kernelSocketInfo?: KernelSocketInformation; + private subscribedToKernelSocket: boolean = false; + private pendingModuleRequests = new Set(); + constructor( + @inject(IDisposableRegistry) disposables: IDisposableRegistry, + @inject(INotebookProvider) private readonly notebookProvider: INotebookProvider, + @inject(IFileSystem) private readonly fs: IFileSystem, + @inject(INotebookEditorProvider) private readonly notebookEditorProvider: INotebookEditorProvider, + @inject(IInteractiveWindowProvider) private readonly interactiveWindowProvider: IInteractiveWindowProvider, + @inject(IInterpreterService) private readonly interpreterService: IInterpreterService + ) { + disposables.push(this); + this.notebookProvider.onNotebookCreated( + (e) => { + if (e.identity.toString() === this.notebookIdentity?.toString()) { + this.initialize().catch(traceError.bind('Failed to initialize')); + } + }, + this, + this.disposables + ); + } + + public dispose() { + while (this.disposables.length) { + this.disposables.shift()?.dispose(); // NOSONAR + } + } + + // tslint:disable-next-line: no-any + public onMessage(message: string, payload?: any): void { + if (message === InteractiveWindowMessages.NotebookIdentity) { + this.saveIdentity(payload).catch((ex) => + traceError(`Failed to initialize ${(this as Object).constructor.name}`, ex) + ); + } else if (message === IPyWidgetMessages.IPyWidgets_Ready) { + this.sendListOfWidgetSources().catch(traceError.bind('Failed to send widget sources upon ready')); + } else if (message === IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesRequest) { + this.sendListOfWidgetSources().catch(traceError.bind('Failed to send widget sources upon ready')); + } else if (message === IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest) { + if (payload) { + sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { + hashedName: sha256().update(payload).digest('hex') + }); + } + this.sendWidgetSource(payload).catch(traceError.bind('Failed to send widget sources upon ready')); + } + } + + private async sendListOfWidgetSources(ignoreCache?: boolean) { + if (!this.notebook || !this.scriptProvider) { + return; + } + const sources = await this.scriptProvider.getWidgetScriptSources(ignoreCache); + this.postEmitter.fire({ + message: IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse, + payload: sources + }); + } + private async sendWidgetSource(moduleName: string) { + if (!this.notebook || !this.scriptProvider) { + this.pendingModuleRequests.add(moduleName); + return; + } + const source = await this.scriptProvider.getWidgetScriptSource(moduleName); + this.postEmitter.fire({ + message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, + payload: source + }); + } + private async saveIdentity(args: INotebookIdentity) { + this.notebookIdentity = Uri.parse(args.resource); + await this.initialize(); + } + + private async initialize() { + if (!this.jupyterLab) { + // Lazy load jupyter lab for faster extension loading. + // tslint:disable-next-line:no-require-imports + this.jupyterLab = require('@jupyterlab/services') as typeof jupyterlabService; // NOSONAR + } + + if (!this.notebookIdentity || this.notebook) { + return; + } + this.notebook = await this.notebookProvider.getOrCreateNotebook({ + identity: this.notebookIdentity, + disableUI: true, + getOnly: true + }); + if (!this.notebook) { + return; + } + this.interactiveBase = this.notebookEditorProvider.editors.find( + (editor) => editor.notebook?.identity.toString() === this.notebookIdentity?.toString() + ); + if (!this.interactiveBase) { + this.interactiveBase = this.interactiveWindowProvider.getActive(); + } + if (!this.interactiveBase) { + return; + } + if (this.notebook.connection.localLaunch) { + this.scriptProvider = new LocalWidgetScriptSourceProvider( + this.notebook, + this.interactiveBase, + this.fs, + this.interpreterService + ); + } else { + this.scriptProvider = new RemoteWidgetScriptSourceProvider(this.notebook.connection); + } + this.subscribeToKernelSocket(); + await this.initializeNotebook(); + } + private async initializeNotebook() { + if (!this.notebook) { + return; + } + this.notebook.onDisposed(() => this.dispose()); + // When changing a kernel, we might have a new interpreter. + this.notebook.onKernelChanged( + () => { + // If underlying interpreter has changed, then refresh list of widget sources. + // After all, different kernels have different widgets. + if ( + this.notebook?.getMatchingInterpreter() && + this.notebook?.getMatchingInterpreter() === this.interpreterForWhichWidgetSourcesWereFetched + ) { + return; + } + // Let UI know that kernel has changed. + this.postEmitter.fire({ message: IPyWidgetMessages.IPyWidgets_onKernelChanged, payload: undefined }); + this.sendListOfWidgetSources(true).catch(traceError.bind('Failed to refresh widget sources')); + }, + this, + this.disposables + ); + // Kernel restarts are required when user installs new packages, possible a new widget/package was installed. + this.notebook.onKernelRestarted( + () => this.sendListOfWidgetSources(true).catch(traceError.bind('Failed to refresh widget sources')), + this, + this.disposables + ); + this.handlePendingRequests(); + this.sendListOfWidgetSources().catch(traceError.bind('Failed to send initial list of Widget Sources')); + } + private subscribeToKernelSocket() { + if (this.subscribedToKernelSocket || !this.notebook) { + return; + } + this.subscribedToKernelSocket = true; + // Listen to changes to kernel socket (e.g. restarts or changes to kernel). + this.notebook.kernelSocket.subscribe((info) => { + // Remove old handlers. + this.kernelSocketInfo?.socket?.removeListener('message', this.onKernelSocketMessage.bind(this)); // NOSONAR + + if (!info || !info.socket) { + // No kernel socket information, hence nothing much we can do. + this.kernelSocketInfo = undefined; + return; + } + + this.kernelSocketInfo = info; + this.kernelSocketInfo.socket?.addListener('message', this.onKernelSocketMessage.bind(this)); // NOSONAR + }); + } + /** + * If we get a comm open message, then we know a widget will be displayed. + * In this case get hold of the name and send it up (pre-fetch it before UI makes a request for it). + */ + // tslint:disable-next-line: no-any + private onKernelSocketMessage(message: any) { + if (this.jupyterLab?.KernelMessage.isCommOpenMsg(message) && message.content.target_module) { + this.sendWidgetSource(message.content.target_module).catch( + traceError.bind('Failed to pre-load Widget Script') + ); + } + } + private handlePendingRequests() { + const pendingModuleNames = Array.from(this.pendingModuleRequests.values()); + while (pendingModuleNames.length) { + const moduleName = pendingModuleNames.shift(); + if (moduleName) { + this.pendingModuleRequests.delete(moduleName); + this.sendWidgetSource(moduleName).catch( + traceError.bind(`Failed to send WidgetScript for ${moduleName}`) + ); + } + } + } +} diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts new file mode 100644 index 000000000000..5a4b6408cb6c --- /dev/null +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts @@ -0,0 +1,119 @@ +// // Copyright (c) Microsoft Corporation. All rights reserved. +// // Licensed under the MIT License. + +// 'use strict'; + +// import { inject, injectable } from 'inversify'; +// import { Event, EventEmitter, Uri } from 'vscode'; +// import { IFileSystem } from '../../common/platform/types'; +// import { IDisposable, IDisposableRegistry } from '../../common/types'; +// import { IInterpreterService } from '../../interpreter/contracts'; +// import { IInteractiveWindowProvider, INotebook, INotebookEditorProvider, INotebookProvider } from '../types'; +// import { IPyWidgetMessageDispatcher } from './ipyWidgetMessageDispatcher'; +// import { IPyWidgetScriptSource } from './ipyWidgetScriptSource'; +// import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; + +// // /** +// // * This just wraps the iPyWidgetMessageDispatcher class. +// // * When raising events for arrived messages, this class will first raise events for +// // * all messages that arrived before this class was contructed. +// // */ +// // class IPyWidgetScriptSourceProviderFactory implements IIPyWidgetMessageDispatcher { +// // public get postMessage(): Event { +// // return this._postMessageEmitter.event; +// // } +// // private _postMessageEmitter = new EventEmitter(); +// // private readonly disposables: IDisposable[] = []; +// // constructor( +// // private readonly baseMulticaster: IPyWidgetMessageDispatcher, +// // private oldMessages: ReadonlyArray +// // ) { +// // baseMulticaster.postMessage(this.raisePostMessage, this, this.disposables); +// // } + +// // public dispose() { +// // while (this.disposables.length) { +// // const disposable = this.disposables.shift(); +// // disposable?.dispose(); // NOSONAR +// // } +// // } +// // public async initialize() { +// // return this.baseMulticaster.initialize(); +// // } + +// // public receiveMessage(message: IPyWidgetMessage) { +// // this.baseMulticaster.receiveMessage(message); +// // } +// // private raisePostMessage(message: IPyWidgetMessage) { +// // // Send all of the old messages the notebook may not have received. +// // // Also send them in the same order. +// // this.oldMessages.forEach((oldMessage) => { +// // this._postMessageEmitter.fire(oldMessage); +// // }); +// // this.oldMessages = []; +// // this._postMessageEmitter.fire(message); +// // } +// // } + +// /** +// * Creates the dispatcher responsible for handling loading ipywidget widget scripts. +// */ +// @injectable() +// export class IPyWidgetScriptSourceProviderFactory implements IDisposable { +// private readonly scriptSourceProviders = new Map(); +// private disposed = false; +// private disposables: IDisposable[] = []; +// constructor( +// @inject(INotebookProvider) private notebookProvider: INotebookProvider, +// @inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry, +// @inject(IFileSystem) private readonly fs: IFileSystem, +// @inject(INotebookEditorProvider) private readonly notebookEditorProvider: INotebookEditorProvider, +// @inject(IInteractiveWindowProvider) private readonly interactiveWindowProvider: IInteractiveWindowProvider, +// @inject(IInterpreterService) private readonly interpreterService: IInterpreterService +// ) { +// disposableRegistry.push(this); +// notebookProvider.onNotebookCreated((e) => this.trackDisposingOfNotebook(e.notebook), this, this.disposables); + +// notebookProvider.activeNotebooks.forEach((nbPromise) => +// nbPromise.then((notebook) => this.trackDisposingOfNotebook(notebook)).ignoreErrors() +// ); +// } + +// public dispose() { +// this.disposed = true; +// while (this.disposables.length) { +// this.disposables.shift()?.dispose(); // NOSONAR +// } +// } +// public create(identity: Uri): IPyWidgetScriptSource { +// let scriptSource = this.scriptSourceProviders.get(identity.fsPath); +// if (!scriptSource) { +// scriptSource = new IPyWidgetScriptSource( +// this.disposableRegistry, +// this.notebookProvider, +// this.trackDisposingOfNotebook, +// this.notebookEditorProvider, +// this.interactiveWindowProvider, +// this.interpreterService, +// identity +// ); +// this.scriptSourceProviders.set(identity.fsPath, scriptSource); +// this.disposables.push(scriptSource); +// } +// return scriptSource; +// } +// private trackDisposingOfNotebook(notebook: INotebook) { +// if (this.disposed) { +// return; +// } +// notebook.onDisposed( +// () => { +// const item = this.scriptSourceProviders.get(notebook.identity.fsPath); +// item?.dispose(); // NOSONAR +// this.scriptSourceProviders.delete(notebook.identity.fsPath); +// }, +// this, +// this.disposables +// ); +// } +// } diff --git a/src/client/datascience/ipywidgets/ipywidgetHandler.ts b/src/client/datascience/ipywidgets/ipywidgetHandler.ts index 9dd4d0df6060..d565d6008c30 100644 --- a/src/client/datascience/ipywidgets/ipywidgetHandler.ts +++ b/src/client/datascience/ipywidgets/ipywidgetHandler.ts @@ -42,7 +42,7 @@ export class IPyWidgetHandler implements IInteractiveWindowListener { constructor( @inject(INotebookProvider) notebookProvider: INotebookProvider, @inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry, - @inject(IPyWidgetMessageDispatcherFactory) private readonly factory: IPyWidgetMessageDispatcherFactory + @inject(IPyWidgetMessageDispatcherFactory) private readonly widgetMessageDispatcherFactory: IPyWidgetMessageDispatcherFactory ) { disposables.push( notebookProvider.onNotebookCreated(async (e) => { @@ -95,7 +95,7 @@ export class IPyWidgetHandler implements IInteractiveWindowListener { if (!this.notebookIdentity) { return; } - this.ipyWidgetMessageDispatcher = this.factory.create(this.notebookIdentity); + this.ipyWidgetMessageDispatcher = this.widgetMessageDispatcherFactory.create(this.notebookIdentity); return this.ipyWidgetMessageDispatcher; } diff --git a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts new file mode 100644 index 000000000000..6b5b6634850b --- /dev/null +++ b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { sha256 } from 'hash.js'; +import * as path from 'path'; +import { Uri } from 'vscode'; +import { traceError } from '../../common/logger'; +import { IFileSystem } from '../../common/platform/types'; +import { IInterpreterService, PythonInterpreter } from '../../interpreter/contracts'; +import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; +import { Telemetry } from '../constants'; +import { ILocalResourceUriConverter, INotebook } from '../types'; +import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; + +/** + * Widget scripts are found in /share/jupyter/nbextensions. + * Here's an example: + * /share/jupyter/nbextensions/k3d/index.js + * /share/jupyter/nbextensions/nglview/index.js + * /share/jupyter/nbextensions/bqplot/index.js + */ +export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { + private cachedWidgetScripts?: Promise; + constructor( + private readonly notebook: INotebook, + private readonly localResourceUriConverter: ILocalResourceUriConverter, + private readonly fs: IFileSystem, + private readonly interpreterService: IInterpreterService + ) {} + public async getWidgetScriptSource(moduleName: string): Promise { + const sources = await this.getWidgetScriptSources(); + const found = sources.find((item) => item.moduleName.toLowerCase() === moduleName.toLowerCase()); + return found || { moduleName }; + } + public async getWidgetScriptSources(ignoreCache?: boolean): Promise> { + if (!ignoreCache && this.cachedWidgetScripts) { + return this.cachedWidgetScripts; + } + return (this.cachedWidgetScripts = this.getWidgetScriptSourcesWithoutCache()); + } + @captureTelemetry(Telemetry.DiscoverIPyWidgetNamesPerf) + private async getWidgetScriptSourcesWithoutCache(): Promise { + const sysPrefix = await this.getSysPrefixOfKernel(); + if (!sysPrefix) { + return []; + } + + const nbextensionsPath = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + // Search only one level deep, hence `*/index.js`. + const files = await this.fs.search(`*${path.sep}index.js`, nbextensionsPath); + return files + .map((file) => { + // Should be of the form `/index.js` + const parts = file.split(path.sep); + if (parts.length !== 2) { + traceError('Incorrect file found when searching for nnbextension entrypoints'); + return; + } + const moduleName = parts[0]; + + sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { + hashedName: sha256().update(moduleName).digest('hex') + }); + + // Drop the `.js`. + const fileUri = Uri.file(path.join(nbextensionsPath, moduleName, 'index')); + const scriptUri = this.localResourceUriConverter.asWebviewUri(fileUri).toString(); + return { moduleName, scriptUri }; + }) + .filter((item) => !!item) + .map((item) => item!); + } + private async getSysPrefixOfKernel() { + const interpreter = this.getInterpreter(); + if (interpreter?.sysPrefix) { + return interpreter?.sysPrefix; + } + if (!interpreter?.path) { + return; + } + const interpreterInfo = await this.interpreterService.getInterpreterDetails(interpreter.path); + return interpreterInfo?.sysPrefix; + } + private getInterpreter(): Partial | undefined { + let interpreter: undefined | Partial = this.notebook.getMatchingInterpreter(); + const kernel = this.notebook.getKernelSpec(); + interpreter = kernel?.metadata?.interpreter?.path ? kernel?.metadata?.interpreter : interpreter; + + // If we still do not have the interpreter, then check if we have the path to the kernel. + if (!interpreter && kernel?.path) { + interpreter = { path: kernel.path }; + } + + if (!interpreter || !interpreter.path) { + return; + } + const pythonPath = interpreter.path; + return { ...interpreter, path: pythonPath }; + } +} diff --git a/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts new file mode 100644 index 000000000000..0eebaae5741e --- /dev/null +++ b/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { IConnection } from '../types'; +import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; + +/** + * When using a remote jupyter connection the widget scripts are accessible over + * `/nbextensions/moduleName/index` + */ +export class RemoteWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { + constructor(private readonly connection: IConnection) {} + public async getWidgetScriptSource(moduleName: string): Promise { + return { moduleName, scriptUri: `${this.connection.baseUrl}/nbextensions/${moduleName}/index` }; + } + public async getWidgetScriptSources(_ignoreCache?: boolean): Promise> { + return []; + } +} diff --git a/src/client/datascience/ipywidgets/types.ts b/src/client/datascience/ipywidgets/types.ts index 2388ca21da73..6779cbc25024 100644 --- a/src/client/datascience/ipywidgets/types.ts +++ b/src/client/datascience/ipywidgets/types.ts @@ -23,3 +23,28 @@ export interface IIPyWidgetMessageDispatcher extends IDisposable { receiveMessage(message: IPyWidgetMessage): void; initialize(): Promise; } + +/** + * Name value pair of widget name/module along with the Uri to the script. + */ +export type WidgetScriptSource = { + moduleName: string; + /** + * Resource Uri (not using Uri type as this needs to be sent from extension to UI). + */ + scriptUri?: string; +}; + +/** + * Used to get an entry for widget (or all of them). + */ +export interface IWidgetScriptSourceProvider { + /** + * Return the script path for the requested module. + */ + getWidgetScriptSource(moduleName: string): Promise; + /** + * Returns a list of all widgets with their sources. Can be empty. + */ + getWidgetScriptSources(ignoreCache?: boolean): Promise>; +} diff --git a/src/client/datascience/jupyter/jupyterNotebook.ts b/src/client/datascience/jupyter/jupyterNotebook.ts index 976e159a07d2..b2dd844bbc48 100644 --- a/src/client/datascience/jupyter/jupyterNotebook.ts +++ b/src/client/datascience/jupyter/jupyterNotebook.ts @@ -27,6 +27,7 @@ import { CodeSnippits, Identifiers, Telemetry } from '../constants'; import { CellState, ICell, + IConnection, IJupyterKernelSpec, IJupyterSession, INotebook, @@ -174,6 +175,9 @@ export class JupyterNotebookBase implements INotebook { public get kernelSocket(): Observable { return this.session.kernelSocket; } + public get connection(): Readonly { + return this.launchInfo.connectionInfo; + } constructor( _liveShare: ILiveShareApi, // This is so the liveshare mixin works diff --git a/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts b/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts index 0da3357f1220..0da7dbf55a08 100644 --- a/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts +++ b/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts @@ -19,6 +19,7 @@ import { PythonInterpreter } from '../../../interpreter/contracts'; import { LiveShare, LiveShareCommands } from '../../constants'; import { ICell, + IConnection, IJupyterKernelSpec, INotebook, INotebookCompletion, @@ -43,6 +44,10 @@ export class GuestJupyterNotebook return this._jupyterLab; } + public get connection(): IConnection { + throw new Error('Not Implemented'); + } + public get identity(): Uri { return this._identity; } diff --git a/src/client/datascience/serviceRegistry.ts b/src/client/datascience/serviceRegistry.ts index a7285abab47a..e0abd26669e9 100644 --- a/src/client/datascience/serviceRegistry.ts +++ b/src/client/datascience/serviceRegistry.ts @@ -45,6 +45,7 @@ import { InteractiveWindowCommandListener } from './interactive-window/interacti import { InteractiveWindowProvider } from './interactive-window/interactiveWindowProvider'; import { IPyWidgetHandler } from './ipywidgets/ipywidgetHandler'; import { IPyWidgetMessageDispatcherFactory } from './ipywidgets/ipyWidgetMessageDispatcherFactory'; +import { IPyWidgetScriptSource } from './ipywidgets/ipyWidgetScriptSource'; import { JupyterCommandLineSelector } from './jupyter/commandLineSelector'; import { JupyterCommandFactory } from './jupyter/interpreter/jupyterCommand'; import { JupyterCommandFinder } from './jupyter/interpreter/jupyterCommandFinder'; @@ -140,6 +141,7 @@ export function registerTypes(serviceManager: IServiceManager) { serviceManager.add(IInteractiveWindowListener, LinkProvider); serviceManager.add(IInteractiveWindowListener, ShowPlotListener); serviceManager.add(IInteractiveWindowListener, IPyWidgetHandler); + serviceManager.add(IInteractiveWindowListener, IPyWidgetScriptSource); serviceManager.add(IJupyterCommandFactory, JupyterCommandFactory); serviceManager.add(INotebookEditor, useCustomEditorApi ? NativeEditor : NativeEditorOldWebView); serviceManager.add(INotebookExporter, JupyterExporter); diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts index 5ee7c835db1c..789197da03aa 100644 --- a/src/client/datascience/types.ts +++ b/src/client/datascience/types.ts @@ -109,6 +109,7 @@ export interface INotebookServer extends IAsyncDisposable { export interface INotebook extends IAsyncDisposable { readonly resource: Resource; + readonly connection: Readonly; kernelSocket: Observable; readonly identity: Uri; readonly server: INotebookServer; @@ -366,7 +367,25 @@ export interface IDataScienceErrorHandler { handleError(err: Error): Promise; } -export interface IInteractiveBase extends Disposable { +/** + * Given a local resource this will convert the Uri into a form such that it can be used in a WebView. + */ +export interface ILocalResourceUriConverter { + /** + * Convert a uri for the local file system to one that can be used inside webviews. + * + * Webviews cannot directly load resources from the workspace or local file system using `file:` uris. The + * `asWebviewUri` function takes a local `file:` uri and converts it into a uri that can be used inside of + * a webview to load the same resource: + * + * ```ts + * webview.html = `` + * ``` + */ + asWebviewUri(localResource: Uri): Uri; +} + +export interface IInteractiveBase extends Disposable, ILocalResourceUriConverter { onExecutedCode: Event; notebook?: INotebook; show(): Promise; diff --git a/src/client/datascience/webViewHost.ts b/src/client/datascience/webViewHost.ts index 0991c5623ee1..5b15bd9e3816 100644 --- a/src/client/datascience/webViewHost.ts +++ b/src/client/datascience/webViewHost.ts @@ -4,7 +4,7 @@ import '../common/extensions'; import { injectable, unmanaged } from 'inversify'; -import { ConfigurationChangeEvent, ViewColumn, WebviewPanel, WorkspaceConfiguration } from 'vscode'; +import { ConfigurationChangeEvent, Uri, ViewColumn, WebviewPanel, WorkspaceConfiguration } from 'vscode'; import { IWebPanel, IWebPanelMessageListener, IWebPanelProvider, IWorkspaceService } from '../common/application/types'; import { isTestExecution } from '../common/constants'; @@ -82,6 +82,12 @@ export abstract class WebViewHost implements IDisposable { this.webPanel.updateCwd(cwd); } } + public asWebviewUri(localResource: Uri) { + if (!this.webPanel) { + throw new Error('asWebViewUri called too early'); + } + return this.webPanel?.asWebviewUri(localResource); + } public dispose() { if (!this.isDisposed) { diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 295f4e834ff1..22fea7565cef 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -750,6 +750,30 @@ export interface IEventNamePropertyMapping { hasJupyter: boolean; hasVnd: boolean; }; + /** + * Telemetry event sent with name of a Widget used in a notebook. + * This is used by the user. + */ + [Telemetry.HashedIPyWidgetNameUsed]: { + /** + * Hash of the widget + */ + hashedName: string; + }; + /** + * Telemetry event sent with named of a Widget found in user environment. + * This is what we found on the system. + */ + [Telemetry.HashedIPyWidgetNameDiscovered]: { + /** + * Hash of the widget + */ + hashedName: string; + }; + /** + * Total time taken to discover all IPyWidgets on disc. + */ + [Telemetry.DiscoverIPyWidgetNamesPerf]: never | undefined; [EventName.HASHED_PACKAGE_PERF]: never | undefined; /** * Telemetry event sent with details of selection in prompt diff --git a/src/datascience-ui/interactive-common/cellOutput.tsx b/src/datascience-ui/interactive-common/cellOutput.tsx index ef156473ded7..39f1e23d6930 100644 --- a/src/datascience-ui/interactive-common/cellOutput.tsx +++ b/src/datascience-ui/interactive-common/cellOutput.tsx @@ -548,23 +548,23 @@ export class CellOutput extends React.Component { transformedList.forEach((transformed, index) => { const mimetype = transformed.output.mimeType; if (isIPyWidgetOutput(transformed.output.mimeBundle)) { - if (this.props.loadWidgetScriptsFromThirdPartySource) { - return; - } - // If loading of widget source is not allowed, display a message. - const errorMessage = getLocString( - 'DataScience.loadThirdPartyWidgetScriptsDisabled', - "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel" - ); - - // tslint:disable: react-no-dangerous-html - buffer.push( -
- -
- -
- ); + // if (this.props.loadWidgetScriptsFromThirdPartySource) { + return; + // } + // // If loading of widget source is not allowed, display a message. + // const errorMessage = getLocString( + // 'DataScience.loadThirdPartyWidgetScriptsDisabled', + // "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel" + // ); + + // // tslint:disable: react-no-dangerous-html + // buffer.push( + //
+ // + //
+ // + //
+ // ); } else if (mimetype && isMimeTypeSupported(mimetype)) { // If that worked, use the transform // Get the matching React.Component for that mimetype diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 2e6d73c161ec..6d9844402b93 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -6,10 +6,12 @@ import * as isonline from 'is-online'; import * as React from 'react'; import { Store } from 'redux'; -import { IStore } from '../interactive-common/redux/store'; -import { PostOffice } from '../react-common/postOffice'; -import { WidgetManager } from './manager'; - +import { createDeferred, Deferred } from '../../client/common/utils/async'; +import { + IInteractiveWindowMapping, + IPyWidgetMessages +} from '../../client/datascience/interactive-common/interactiveWindowTypes'; +import { WidgetScriptSource } from '../../client/datascience/ipywidgets/types'; import { SharedMessages } from '../../client/datascience/messages'; import { IDataScienceExtraSettings } from '../../client/datascience/types'; import { @@ -18,6 +20,9 @@ import { ILoadIPyWidgetClassFailureAction, LoadIPyWidgetClassDisabledAction } from '../interactive-common/redux/reducers/types'; +import { IStore } from '../interactive-common/redux/store'; +import { PostOffice } from '../react-common/postOffice'; +import { WidgetManager } from './manager'; type Props = { postOffice: PostOffice; @@ -25,11 +30,25 @@ type Props = { store: Store & { dispatch: unknown }; }; +type NonPartial = { + [P in keyof T]-?: T[P]; +}; + export class WidgetManagerComponent extends React.Component { private readonly widgetManager: WidgetManager; + private readonly widgetSourceRequests = new Map>(); private readonly loaderSettings = { + // Whether to allow loading widgets from 3rd party (cdn). loadWidgetScriptsFromThirdPartySource: false, - errorHandler: this.handleLoadError.bind(this) + // Total time to wait for a script to load. This includes ipywidgets making a request from extension for a Uri of a widget, + // then extension replying back with the Uri (max time of 5 seconds). + timeoutWaitingForScriptToLoad: 5_000, + // List of widgets that must always be loaded using requirejs instead of using a CDN or the like. + widgetsToLoadFromRequirejs: new Set(), + // Callback when loading a widget fails. + errorHandler: this.handleLoadError.bind(this), + // Callback when requesting a module be registered with requirejs (if possible). + loadWidgetScript: this.loadWidgetScript.bind(this) }; constructor(props: Props) { super(props); @@ -49,6 +68,17 @@ export class WidgetManagerComponent extends React.Component { const settings = JSON.parse(payload) as IDataScienceExtraSettings; this.loaderSettings.loadWidgetScriptsFromThirdPartySource = settings.loadWidgetScriptsFromThirdPartySource === true; + } else if (type === IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse) { + this.registerScriptSourcesInRequirejs(payload as WidgetScriptSource[]); + } else if (type === IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse) { + this.registerScriptSourceInRequirejs(payload as WidgetScriptSource); + } else if (type === IPyWidgetMessages.IPyWidgets_onKernelChanged) { + // If user changed the kernel, then some widgets might exist now and some might now. + this.widgetSourceRequests.clear(); + // Request again. + this.props.postOffice.sendMessage( + IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesRequest + ); } return true; } @@ -60,7 +90,58 @@ export class WidgetManagerComponent extends React.Component { public componentWillUnmount() { this.widgetManager.dispose(); } + /** + * Given a list of the widgets along with the sources, we will need to register them with requirejs. + * IPyWidgets uses requirejs to dynamically load modules. + * (https://requirejs.org/docs/api.html) + * All we're doing here is given a widget (module) name, we register the path where the widget (module) can be loaded from. + * E.g. + * requirejs.config({ paths:{ + * 'widget_xyz': '' + * }}); + */ + private registerScriptSourcesInRequirejs(sources: WidgetScriptSource[]) { + if (!Array.isArray(sources) || sources.length === 0) { + return; + } + // tslint:disable-next-line: no-any + const requirejs = (window as any).requirejs as { config: Function }; + if (!requirejs) { + return window.console.error('Requirejs not found'); + } + const config: { paths: Record } = { + paths: {} + }; + sources + .map((source) => { + // We have fetched the script sources for all of these modules. + // In some cases we might not have the source, meaning we don't have it or couldn't find it. + let deferred = this.widgetSourceRequests.get(source.moduleName); + if (!deferred) { + deferred = createDeferred(); + this.widgetSourceRequests.set(source.moduleName, deferred); + } + deferred.resolve(); + return source; + }) + .filter((source) => source.scriptUri) + .map((source) => source as NonPartial) + .forEach((source) => { + this.loaderSettings.widgetsToLoadFromRequirejs.add(source.moduleName); + // Register the script source into requirejs so it gets loaded via requirejs. + config.paths[source.moduleName] = source.scriptUri; + }); + requirejs.config(config); + } + private registerScriptSourceInRequirejs(source?: WidgetScriptSource) { + if (!source) { + return; + } + // tslint:disable-next-line: no-console + console.log(`Source for IPyWidget ${source.moduleName} ${source.scriptUri ? 'Not found' : source.scriptUri}`); + this.registerScriptSourcesInRequirejs([source]); + } private createLoadErrorAction( className: string, moduleName: string, @@ -96,4 +177,21 @@ export class WidgetManagerComponent extends React.Component { this.props.store.dispatch(this.createLoadDisabledErrorAction(className, moduleName, moduleVersion)); } } + + private loadWidgetScript(moduleName: string, cb: () => void) { + // tslint:disable-next-line: no-console + console.log(`Load IPyWidget ${moduleName}`); + let deferred = this.widgetSourceRequests.get(moduleName); + if (!deferred) { + deferred = createDeferred(); + this.widgetSourceRequests.set(moduleName, deferred); + this.props.postOffice.sendMessage( + IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest, + moduleName + ); + } + + // tslint:disable-next-line: no-console + deferred.promise.finally(cb).catch((ex) => console.log('Failed to load Widget Script from Extension', ex)); + } } diff --git a/src/datascience-ui/ipywidgets/manager.ts b/src/datascience-ui/ipywidgets/manager.ts index d85f9db15199..12d896b61e98 100644 --- a/src/datascience-ui/ipywidgets/manager.ts +++ b/src/datascience-ui/ipywidgets/manager.ts @@ -56,9 +56,12 @@ export class WidgetManager implements IIPyWidgetManager { private readonly widgetContainer: HTMLElement, private readonly postOffice: PostOffice, private readonly scriptLoader: { - loadWidgetScriptsFromThirdPartySource: boolean; + readonly loadWidgetScriptsFromThirdPartySource: boolean; + readonly widgetsToLoadFromRequirejs: Readonly>; + readonly timeoutWaitingForScriptToLoad: number; // tslint:disable-next-line: no-any errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; + loadWidgetScript(moduleName: string, done: () => void): void; } ) { // Create an observable with list of messages to be processed by the kernel in ipywidgets. diff --git a/src/ipywidgets/src/embed.ts b/src/ipywidgets/src/embed.ts index 08f1d6393dee..84f189e60178 100644 --- a/src/ipywidgets/src/embed.ts +++ b/src/ipywidgets/src/embed.ts @@ -101,7 +101,10 @@ export function renderWidgets(element = document.documentElement): void { const managerFactory = (): any => { return new wm.WidgetManager(undefined, element, { loadWidgetScriptsFromThirdPartySource: false, - errorHandler: () => 'Error loading widget.' + widgetsToLoadFromRequirejs: new Set(), + errorHandler: () => 'Error loading widget.', + timeoutWaitingForScriptToLoad: 1_000, + loadWidgetScript: (_moduleName: string, _done: () => void) => undefined }); }; libembed.renderWidgets(managerFactory, element).catch((x) => { diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index 9f1a4ff05436..065ef564ef0c 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -16,6 +16,9 @@ export const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json'; // tslint:disable: no-any // Source borrowed from https://github.com/jupyter-widgets/ipywidgets/blob/master/examples/web3/src/manager.ts +// These widgets can always be loaded from requirejs (as it is bundled). +const widgetsToLoadFromRequire = ['@jupyter-widgets/controls', '@jupyter-widgets/base', '@jupyter-widgets/output']; + export class WidgetManager extends jupyterlab.WidgetManager { public kernel: Kernel.IKernelConnection; public el: HTMLElement; @@ -24,8 +27,11 @@ export class WidgetManager extends jupyterlab.WidgetManager { kernel: Kernel.IKernelConnection, el: HTMLElement, private readonly scriptLoader: { - loadWidgetScriptsFromThirdPartySource: boolean; + readonly loadWidgetScriptsFromThirdPartySource: boolean; + readonly widgetsToLoadFromRequirejs: Readonly>; + readonly timeoutWaitingForScriptToLoad: number; errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; + loadWidgetScript(moduleName: string, done: () => void): void; } ) { super( @@ -95,10 +101,32 @@ export class WidgetManager extends jupyterlab.WidgetManager { // tslint:disable-next-line: no-unnecessary-local-variable const result = await super.loadClass(className, moduleName, moduleVersion).catch(async (originalException) => { try { - if (!this.scriptLoader.loadWidgetScriptsFromThirdPartySource) { + const loadModuleFromRequirejs = + widgetsToLoadFromRequire.includes(moduleName) || + this.scriptLoader.widgetsToLoadFromRequirejs.has(moduleName); + + if (!this.scriptLoader.loadWidgetScriptsFromThirdPartySource && !loadModuleFromRequirejs) { throw new Error('Loading from 3rd party source is disabled'); } - const m = await requireLoader(moduleName, moduleVersion); + + if (!loadModuleFromRequirejs) { + // If not loading from requirejs, then check if we can. + // But do not wait for too long. + const didTimeOut = await Promise.race([ + new Promise((resolve) => + setTimeout(() => resolve('timedout'), this.scriptLoader.timeoutWaitingForScriptToLoad) + ), + new Promise((resolve) => this.scriptLoader.loadWidgetScript(moduleName, resolve)) + ]); + if (didTimeOut === 'timedout') { + // tslint:disable-next-line: no-console + console.error(`Timeout waiting to load Widget module source ${moduleName}`); + } + } + + // If loading module from requirejs (e.g. already bundled), then do not use the cdn. + const useCdn = !loadModuleFromRequirejs && this.scriptLoader.loadWidgetScriptsFromThirdPartySource; + const m = await requireLoader(moduleName, moduleVersion, useCdn); if (m && m[className]) { return m[className]; } diff --git a/src/ipywidgets/src/widgetLoader.ts b/src/ipywidgets/src/widgetLoader.ts index d3c6ed1a50e8..c1a1e3310b84 100644 --- a/src/ipywidgets/src/widgetLoader.ts +++ b/src/ipywidgets/src/widgetLoader.ts @@ -42,14 +42,8 @@ async function requirePromise(pkg: string | string[]): Promise { } }); } -const widgetsToLoadFromRequire = [ - 'azureml_widgets', - '@jupyter-widgets/controls', - '@jupyter-widgets/base', - '@jupyter-widgets/output' -]; -export function requireLoader(moduleName: string, moduleVersion: string) { - if (!widgetsToLoadFromRequire.includes(moduleName)) { +export function requireLoader(moduleName: string, moduleVersion: string, useCdn: boolean) { + if (useCdn) { // tslint:disable-next-line: no-any const requirejs = (window as any).requirejs; if (requirejs === undefined) { @@ -58,6 +52,11 @@ export function requireLoader(moduleName: string, moduleVersion: string) { const conf: { paths: { [key: string]: string } } = { paths: {} }; conf.paths[moduleName] = moduleNameToCDNUrl(moduleName, moduleVersion); requirejs.config(conf); + // tslint:disable-next-line: no-console + console.log(`Using CDN to load Widget Module ${moduleName}, version ${moduleVersion}`); + } else { + // tslint:disable-next-line: no-console + console.log(`Not using CDN to load Widget Module ${moduleName}`); } return requirePromise([`${moduleName}`]); } diff --git a/src/test/datascience/mockJupyterNotebook.ts b/src/test/datascience/mockJupyterNotebook.ts index 319805cfdd3d..75057536b218 100644 --- a/src/test/datascience/mockJupyterNotebook.ts +++ b/src/test/datascience/mockJupyterNotebook.ts @@ -11,6 +11,7 @@ import { LiveKernelModel } from '../../client/datascience/jupyter/kernels/types' import { ICell, ICellHashProvider, + IConnection, IGatherProvider, IJupyterKernelSpec, INotebook, @@ -28,7 +29,9 @@ export class MockJupyterNotebook implements INotebook { public get server(): INotebookServer { return this.owner; } - + public get connection(): IConnection { + throw new Error('Not implemented'); + } public get identity(): Uri { return Uri.parse(Identifiers.InteractiveWindowIdentity); } diff --git a/src/test/datascience/uiTests/webBrowserPanel.ts b/src/test/datascience/uiTests/webBrowserPanel.ts index 3e681e09b70d..e9d04cca44ef 100644 --- a/src/test/datascience/uiTests/webBrowserPanel.ts +++ b/src/test/datascience/uiTests/webBrowserPanel.ts @@ -155,6 +155,9 @@ export class WebBrowserPanel implements IWebPanel, IDisposable { console.error('Failed to start Web Browser Panel', ex) ); } + public asWebviewUri(localResource: Uri): Uri { + return localResource; + } public setTitle(newTitle: string): void { if (this.panel) { this.panel.title = newTitle; From 1ac445810ca7e940c535b73ebb247561d1d696eb Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 6 Apr 2020 16:31:45 -0700 Subject: [PATCH 06/41] Ooops --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 26f7e11c4256..d471dd658003 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,7 +16,7 @@ "outFiles": [ "${workspaceFolder}/out/**/*" ], - // "preLaunchTask": "Compile", + "preLaunchTask": "Compile", "skipFiles": [ "/**" ] From 91f9d2d9266f6df7e219560fc94cedda608de6f5 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 6 Apr 2020 18:14:02 -0700 Subject: [PATCH 07/41] Misc --- .../ipywidgets/ipyWidgetScriptSource.ts | 44 ++++++++++++++++--- .../history-react/interactiveCell.tsx | 3 -- .../interactive-common/cellOutput.tsx | 22 +--------- src/datascience-ui/ipywidgets/container.tsx | 11 +++-- .../native-editor/nativeCell.tsx | 2 - src/ipywidgets/src/manager.ts | 5 --- 6 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index 49b79dc7aa70..14084e708601 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -3,10 +3,12 @@ 'use strict'; import type * as jupyterlabService from '@jupyterlab/services'; +import type * as serlialize from '@jupyterlab/services/lib/kernel/serialize'; import { sha256 } from 'hash.js'; import { inject, injectable } from 'inversify'; import { IDisposable } from 'monaco-editor'; import { Event, EventEmitter, Uri } from 'vscode'; +import type { Data as WebSocketData } from 'ws'; import { traceError } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; import { IDisposableRegistry } from '../../common/types'; @@ -52,6 +54,14 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { private kernelSocketInfo?: KernelSocketInformation; private subscribedToKernelSocket: boolean = false; private pendingModuleRequests = new Set(); + private jupyterSerialize?: typeof serlialize; + private get deserialize(): typeof serlialize.deserialize { + if (!this.jupyterSerialize) { + // tslint:disable-next-line: no-require-imports + this.jupyterSerialize = require('@jupyterlab/services/lib/kernel/serialize') as typeof serlialize; + } + return this.jupyterSerialize.deserialize; + } constructor( @inject(IDisposableRegistry) disposables: IDisposableRegistry, @inject(INotebookProvider) private readonly notebookProvider: INotebookProvider, @@ -109,6 +119,10 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { }); } private async sendWidgetSource(moduleName: string) { + // Standard widgets area already available, hence no need to look for them. + if (moduleName.startsWith('@jupyter')) { + return; + } if (!this.notebook || !this.scriptProvider) { this.pendingModuleRequests.add(moduleName); return; @@ -161,13 +175,13 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { } else { this.scriptProvider = new RemoteWidgetScriptSourceProvider(this.notebook.connection); } - this.subscribeToKernelSocket(); await this.initializeNotebook(); } private async initializeNotebook() { if (!this.notebook) { return; } + this.subscribeToKernelSocket(); this.notebook.onDisposed(() => this.dispose()); // When changing a kernel, we might have a new interpreter. this.notebook.onKernelChanged( @@ -220,12 +234,28 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { * If we get a comm open message, then we know a widget will be displayed. * In this case get hold of the name and send it up (pre-fetch it before UI makes a request for it). */ - // tslint:disable-next-line: no-any - private onKernelSocketMessage(message: any) { - if (this.jupyterLab?.KernelMessage.isCommOpenMsg(message) && message.content.target_module) { - this.sendWidgetSource(message.content.target_module).catch( - traceError.bind('Failed to pre-load Widget Script') - ); + private onKernelSocketMessage(message: WebSocketData) { + // tslint:disable-next-line: no-any + const msg = this.deserialize(message as any); + if (this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && msg.content.target_module) { + this.sendWidgetSource(msg.content.target_module).catch(traceError.bind('Failed to pre-load Widget Script')); + } else if ( + this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && + msg.content.data && + msg.content.data.state && + // tslint:disable-next-line: no-any + ((msg.content.data.state as any)._view_module || (msg.content.data.state as any)._model_module) + ) { + // tslint:disable-next-line: no-any + const viewModule: string = (msg.content.data.state as any)._view_module; + // tslint:disable-next-line: no-any + const modelModule = (msg.content.data.state as any)._model_module; + if (viewModule) { + this.sendWidgetSource(viewModule).catch(traceError.bind('Failed to pre-load Widget Script')); + } + if (modelModule) { + this.sendWidgetSource(viewModule).catch(traceError.bind('Failed to pre-load Widget Script')); + } } } private handlePendingRequests() { diff --git a/src/datascience-ui/history-react/interactiveCell.tsx b/src/datascience-ui/history-react/interactiveCell.tsx index 684963bd28c5..77929ca0b66b 100644 --- a/src/datascience-ui/history-react/interactiveCell.tsx +++ b/src/datascience-ui/history-react/interactiveCell.tsx @@ -130,8 +130,6 @@ export class InteractiveCell extends React.Component { const cellOuterClass = this.props.cellVM.editable ? 'cell-outer-editable' : 'cell-outer'; const cellWrapperClass = this.props.cellVM.editable ? 'cell-wrapper' : 'cell-wrapper cell-wrapper-noneditable'; const themeMatplotlibPlots = this.props.settings.themeMatplotlibPlots ? true : false; - const loadWidgetScriptsFromThirdPartySource = - this.props.settings.loadWidgetScriptsFromThirdPartySource === true; // Only render if we are allowed to. if (shouldRender) { return ( @@ -155,7 +153,6 @@ export class InteractiveCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} - loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} />
diff --git a/src/datascience-ui/interactive-common/cellOutput.tsx b/src/datascience-ui/interactive-common/cellOutput.tsx index ef156473ded7..15d06b9789e9 100644 --- a/src/datascience-ui/interactive-common/cellOutput.tsx +++ b/src/datascience-ui/interactive-common/cellOutput.tsx @@ -31,7 +31,6 @@ interface ICellOutputProps { cellVM: ICellViewModel; baseTheme: string; maxTextSize?: number; - loadWidgetScriptsFromThirdPartySource: boolean; hideOutput?: boolean; themeMatplotlibPlots?: boolean; expandImage(imageHtml: string): void; @@ -181,9 +180,6 @@ export class CellOutput extends React.Component { if (nextProps.maxTextSize !== this.props.maxTextSize) { return true; } - if (nextProps.loadWidgetScriptsFromThirdPartySource !== this.props.loadWidgetScriptsFromThirdPartySource) { - return true; - } if (nextProps.themeMatplotlibPlots !== this.props.themeMatplotlibPlots) { return true; } @@ -548,23 +544,7 @@ export class CellOutput extends React.Component { transformedList.forEach((transformed, index) => { const mimetype = transformed.output.mimeType; if (isIPyWidgetOutput(transformed.output.mimeBundle)) { - if (this.props.loadWidgetScriptsFromThirdPartySource) { - return; - } - // If loading of widget source is not allowed, display a message. - const errorMessage = getLocString( - 'DataScience.loadThirdPartyWidgetScriptsDisabled', - "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel" - ); - - // tslint:disable: react-no-dangerous-html - buffer.push( -
- -
- -
- ); + return; } else if (mimetype && isMimeTypeSupported(mimetype)) { // If that worked, use the transform // Get the matching React.Component for that mimetype diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 6d9844402b93..80c253e4204c 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -40,8 +40,9 @@ export class WidgetManagerComponent extends React.Component { private readonly loaderSettings = { // Whether to allow loading widgets from 3rd party (cdn). loadWidgetScriptsFromThirdPartySource: false, - // Total time to wait for a script to load. This includes ipywidgets making a request from extension for a Uri of a widget, - // then extension replying back with the Uri (max time of 5 seconds). + // Total time to wait for a script to load. This includes ipywidgets making a request to extension for a Uri of a widget, + // then extension replying back with the Uri (max 5 seconds round trip time). + // If expires, then Widget downloader will attempt to download with what ever information it has (potentially failing). timeoutWaitingForScriptToLoad: 5_000, // List of widgets that must always be loaded using requirejs instead of using a CDN or the like. widgetsToLoadFromRequirejs: new Set(), @@ -72,7 +73,11 @@ export class WidgetManagerComponent extends React.Component { this.registerScriptSourcesInRequirejs(payload as WidgetScriptSource[]); } else if (type === IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse) { this.registerScriptSourceInRequirejs(payload as WidgetScriptSource); - } else if (type === IPyWidgetMessages.IPyWidgets_onKernelChanged) { + } else if ( + type === IPyWidgetMessages.IPyWidgets_kernelOptions || + type === IPyWidgetMessages.IPyWidgets_onKernelChanged + ) { + // This happens when we have restarted a kernel. // If user changed the kernel, then some widgets might exist now and some might now. this.widgetSourceRequests.clear(); // Request again. diff --git a/src/datascience-ui/native-editor/nativeCell.tsx b/src/datascience-ui/native-editor/nativeCell.tsx index aa8c315c5938..4c268c883265 100644 --- a/src/datascience-ui/native-editor/nativeCell.tsx +++ b/src/datascience-ui/native-editor/nativeCell.tsx @@ -677,7 +677,6 @@ export class NativeCell extends React.Component { private renderOutput = (): JSX.Element | null => { const themeMatplotlibPlots = this.props.themeMatplotlibPlots ? true : false; const toolbar = this.props.cellVM.cell.data.cell_type === 'markdown' ? this.renderMiddleToolbar() : null; - const loadWidgetScriptsFromThirdPartySource = this.props.loadWidgetScriptsFromThirdPartySource === true; if (this.shouldRenderOutput()) { return (
@@ -688,7 +687,6 @@ export class NativeCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} - loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} />
); diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index c49acb10cc1b..065ef564ef0c 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -27,16 +27,11 @@ export class WidgetManager extends jupyterlab.WidgetManager { kernel: Kernel.IKernelConnection, el: HTMLElement, private readonly scriptLoader: { -<<<<<<< HEAD readonly loadWidgetScriptsFromThirdPartySource: boolean; readonly widgetsToLoadFromRequirejs: Readonly>; readonly timeoutWaitingForScriptToLoad: number; errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; loadWidgetScript(moduleName: string, done: () => void): void; -======= - loadWidgetScriptsFromThirdPartySource: boolean; - errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; ->>>>>>> master } ) { super( From 1dbf99da47b95f14cf5c2788ef30b176e408caf5 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 14:33:15 -0700 Subject: [PATCH 08/41] Oops --- src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts index 468972e5d672..f7d42e149c8e 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetMessageDispatcher.ts @@ -21,7 +21,7 @@ import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; /** * This class maps between messages from the react code and talking to a real kernel. */ - export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { +export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { public get postMessage(): Event { return this._postMessageEmitter.event; } From 78564d64021d818a8905e237454d663b5bb4d5b9 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 14:51:04 -0700 Subject: [PATCH 09/41] Fixes --- .../ipywidgets/ipyWidgetScriptSource.ts | 6 +++--- .../history-react/interactiveCell.tsx | 3 +++ src/datascience-ui/ipywidgets/container.tsx | 13 ++++++++++--- src/datascience-ui/ipywidgets/manager.ts | 3 +-- src/datascience-ui/native-editor/nativeCell.tsx | 2 ++ src/ipywidgets/src/embed.ts | 3 +-- src/ipywidgets/src/manager.ts | 15 ++------------- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index 14084e708601..7fd66fa3ff19 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -218,7 +218,7 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { // Listen to changes to kernel socket (e.g. restarts or changes to kernel). this.notebook.kernelSocket.subscribe((info) => { // Remove old handlers. - this.kernelSocketInfo?.socket?.removeListener('message', this.onKernelSocketMessage.bind(this)); // NOSONAR + this.kernelSocketInfo?.socket?.removeReceiveHook(this.onKernelSocketMessage.bind(this)); // NOSONAR if (!info || !info.socket) { // No kernel socket information, hence nothing much we can do. @@ -227,14 +227,14 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { } this.kernelSocketInfo = info; - this.kernelSocketInfo.socket?.addListener('message', this.onKernelSocketMessage.bind(this)); // NOSONAR + this.kernelSocketInfo.socket?.addReceiveHook(this.onKernelSocketMessage.bind(this)); // NOSONAR }); } /** * If we get a comm open message, then we know a widget will be displayed. * In this case get hold of the name and send it up (pre-fetch it before UI makes a request for it). */ - private onKernelSocketMessage(message: WebSocketData) { + private async onKernelSocketMessage(message: WebSocketData): Promise { // tslint:disable-next-line: no-any const msg = this.deserialize(message as any); if (this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && msg.content.target_module) { diff --git a/src/datascience-ui/history-react/interactiveCell.tsx b/src/datascience-ui/history-react/interactiveCell.tsx index 77929ca0b66b..684963bd28c5 100644 --- a/src/datascience-ui/history-react/interactiveCell.tsx +++ b/src/datascience-ui/history-react/interactiveCell.tsx @@ -130,6 +130,8 @@ export class InteractiveCell extends React.Component { const cellOuterClass = this.props.cellVM.editable ? 'cell-outer-editable' : 'cell-outer'; const cellWrapperClass = this.props.cellVM.editable ? 'cell-wrapper' : 'cell-wrapper cell-wrapper-noneditable'; const themeMatplotlibPlots = this.props.settings.themeMatplotlibPlots ? true : false; + const loadWidgetScriptsFromThirdPartySource = + this.props.settings.loadWidgetScriptsFromThirdPartySource === true; // Only render if we are allowed to. if (shouldRender) { return ( @@ -153,6 +155,7 @@ export class InteractiveCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} + loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} />
diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 80c253e4204c..eb1c22038d1f 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -183,7 +183,7 @@ export class WidgetManagerComponent extends React.Component { } } - private loadWidgetScript(moduleName: string, cb: () => void) { + private loadWidgetScript(moduleName: string): Promise { // tslint:disable-next-line: no-console console.log(`Load IPyWidget ${moduleName}`); let deferred = this.widgetSourceRequests.get(moduleName); @@ -194,9 +194,16 @@ export class WidgetManagerComponent extends React.Component { IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest, moduleName ); + + // If we timeout, then resolve this promise. + // We don't want the calling code to unnecessary wait for too long. + setTimeout(() => deferred?.resolve(), this.loaderSettings.timeoutWaitingForScriptToLoad); } - // tslint:disable-next-line: no-console - deferred.promise.finally(cb).catch((ex) => console.log('Failed to load Widget Script from Extension', ex)); + return ( + deferred.promise + // tslint:disable-next-line: no-console + .catch((ex) => console.log('Failed to load Widget Script from Extension', ex)) + ); } } diff --git a/src/datascience-ui/ipywidgets/manager.ts b/src/datascience-ui/ipywidgets/manager.ts index fed85420c8a8..aa55060bd1be 100644 --- a/src/datascience-ui/ipywidgets/manager.ts +++ b/src/datascience-ui/ipywidgets/manager.ts @@ -49,10 +49,9 @@ export class WidgetManager implements IIPyWidgetManager, IMessageHandler { private readonly scriptLoader: { readonly loadWidgetScriptsFromThirdPartySource: boolean; readonly widgetsToLoadFromRequirejs: Readonly>; - readonly timeoutWaitingForScriptToLoad: number; // tslint:disable-next-line: no-any errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; - loadWidgetScript(moduleName: string, done: () => void): void; + loadWidgetScript(moduleName: string): void; } ) { // tslint:disable-next-line: no-any diff --git a/src/datascience-ui/native-editor/nativeCell.tsx b/src/datascience-ui/native-editor/nativeCell.tsx index 4c268c883265..aa8c315c5938 100644 --- a/src/datascience-ui/native-editor/nativeCell.tsx +++ b/src/datascience-ui/native-editor/nativeCell.tsx @@ -677,6 +677,7 @@ export class NativeCell extends React.Component { private renderOutput = (): JSX.Element | null => { const themeMatplotlibPlots = this.props.themeMatplotlibPlots ? true : false; const toolbar = this.props.cellVM.cell.data.cell_type === 'markdown' ? this.renderMiddleToolbar() : null; + const loadWidgetScriptsFromThirdPartySource = this.props.loadWidgetScriptsFromThirdPartySource === true; if (this.shouldRenderOutput()) { return (
@@ -687,6 +688,7 @@ export class NativeCell extends React.Component { expandImage={this.props.showPlot} maxTextSize={this.props.maxTextSize} themeMatplotlibPlots={themeMatplotlibPlots} + loadWidgetScriptsFromThirdPartySource={loadWidgetScriptsFromThirdPartySource} />
); diff --git a/src/ipywidgets/src/embed.ts b/src/ipywidgets/src/embed.ts index 84f189e60178..1fe5fe69fa3e 100644 --- a/src/ipywidgets/src/embed.ts +++ b/src/ipywidgets/src/embed.ts @@ -103,8 +103,7 @@ export function renderWidgets(element = document.documentElement): void { loadWidgetScriptsFromThirdPartySource: false, widgetsToLoadFromRequirejs: new Set(), errorHandler: () => 'Error loading widget.', - timeoutWaitingForScriptToLoad: 1_000, - loadWidgetScript: (_moduleName: string, _done: () => void) => undefined + loadWidgetScript: (_moduleName: string) => Promise.resolve() }); }; libembed.renderWidgets(managerFactory, element).catch((x) => { diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index 065ef564ef0c..4880cdb2d843 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -29,9 +29,8 @@ export class WidgetManager extends jupyterlab.WidgetManager { private readonly scriptLoader: { readonly loadWidgetScriptsFromThirdPartySource: boolean; readonly widgetsToLoadFromRequirejs: Readonly>; - readonly timeoutWaitingForScriptToLoad: number; errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; - loadWidgetScript(moduleName: string, done: () => void): void; + loadWidgetScript(moduleName: string): Promise; } ) { super( @@ -111,17 +110,7 @@ export class WidgetManager extends jupyterlab.WidgetManager { if (!loadModuleFromRequirejs) { // If not loading from requirejs, then check if we can. - // But do not wait for too long. - const didTimeOut = await Promise.race([ - new Promise((resolve) => - setTimeout(() => resolve('timedout'), this.scriptLoader.timeoutWaitingForScriptToLoad) - ), - new Promise((resolve) => this.scriptLoader.loadWidgetScript(moduleName, resolve)) - ]); - if (didTimeOut === 'timedout') { - // tslint:disable-next-line: no-console - console.error(`Timeout waiting to load Widget module source ${moduleName}`); - } + await this.scriptLoader.loadWidgetScript(moduleName); } // If loading module from requirejs (e.g. already bundled), then do not use the cdn. From 544e740cf45fbb02720d436f4d6d4ca110c899b6 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 17:07:55 -0700 Subject: [PATCH 10/41] misc --- src/client/common/net/httpClient.ts | 4 +- src/client/common/types.ts | 25 +++ src/client/datascience/constants.ts | 3 +- .../interactiveWindowTypes.ts | 2 +- .../cdnWidgetScriptSourceProvider.ts | 108 +++++++++++++ .../ipywidgets/ipyWidgetScriptSource.ts | 148 +++++++++++++++--- .../localWidgetScriptSourceProvider.ts | 4 +- src/client/datascience/ipywidgets/types.ts | 6 +- src/client/telemetry/index.ts | 10 ++ src/datascience-ui/ipywidgets/container.tsx | 25 +-- src/datascience-ui/ipywidgets/manager.ts | 4 +- .../react-common/settingsReactSide.ts | 7 +- src/ipywidgets/src/embed.ts | 2 +- src/ipywidgets/src/manager.ts | 12 +- .../configSettings.unit.test.ts | 7 +- src/test/datascience/color.test.ts | 7 +- .../datascience/dataScienceIocContainer.ts | 7 +- .../codewatcher.unit.test.ts | 7 +- src/test/datascience/execution.unit.test.ts | 7 +- src/test/datascience/helpers.ts | 7 +- ...eractiveWindowCommandListener.unit.test.ts | 7 +- .../jupyter/serverCache.unit.test.ts | 7 +- .../datascience/jupyterVariables.unit.test.ts | 15 +- 23 files changed, 368 insertions(+), 63 deletions(-) create mode 100644 src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts diff --git a/src/client/common/net/httpClient.ts b/src/client/common/net/httpClient.ts index 14cfb7fa20a9..559e075fc3ea 100644 --- a/src/client/common/net/httpClient.ts +++ b/src/client/common/net/httpClient.ts @@ -26,7 +26,7 @@ export class HttpClient implements IHttpClient { } public async getJSON(uri: string, strict: boolean = true): Promise { - const body = await this.getBody(uri); + const body = await this.getContents(uri); return this.parseBodyToJSON(body, strict); } @@ -44,7 +44,7 @@ export class HttpClient implements IHttpClient { } } - public async getBody(uri: string): Promise { + public async getContents(uri: string): Promise { // tslint:disable-next-line:no-require-imports const request = require('request') as typeof requestTypes; return new Promise((resolve, reject) => { diff --git a/src/client/common/types.ts b/src/client/common/types.ts index ff6b90c7938a..af38c0d1a4c8 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -393,8 +393,29 @@ export interface IDataScienceSettings { disableJupyterAutoStart?: boolean; jupyterCommandLineArguments: string[]; loadWidgetScriptsFromThirdPartySource?: boolean; + ipyWidgets: WidgetSettings; } +export type WidgetCDNs = 'unpkg.com' | 'jsdelivr.com'; +export type LocalKernelScriptSource = WidgetCDNs | 'localPythonEnvironment'; +export type RemoteKernelScriptSource = WidgetCDNs | 'remoteJupyterServer'; +export type WidgetSettings = { + /** + * Whether ipywidget support is enabled or not. + */ + enabled: boolean; + /** + * Order of sources to fetch the widget scripts (when running a local kernel). + * In this case we might be able to get the widget scripts from the local python environment. + */ + localKernelScriptSources: LocalKernelScriptSource[]; + /** + * Order of sources to fetch the widget scripts (when running a remote kernel). + * In this case we cannot get widget script from local environment, but might be able to get it from the remote jupyter server. + */ + remoteKernelScriptSources: RemoteKernelScriptSource[]; +}; + export const IConfigurationService = Symbol('IConfigurationService'); export interface IConfigurationService { getSettings(resource?: Uri): IPythonSettings; @@ -465,6 +486,10 @@ export interface IHttpClient { * @param strict Set `false` to allow trailing comma and comments in the JSON, defaults to `true` */ getJSON(uri: string, strict?: boolean): Promise; + /** + * Returns the contents of a remote resource. + */ + getContents(uri: string): Promise; } export const IExtensionContext = Symbol('ExtensionContext'); diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index a3fa8535a986..0a80f701ee5e 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -294,7 +294,8 @@ export enum Telemetry { GatherQualityReport = 'DS_INTERNAL.GATHER_QUALITY_REPORT', ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING', IPyWidgetLoadFailure = 'DS_INTERNAL.IPYWIDGET_LOAD_FAILURE', - IPyWidgetLoadDisabled = 'DS_INTERNAL.IPYWIDGET_LOAD_DISABLED' + IPyWidgetLoadDisabled = 'DS_INTERNAL.IPYWIDGET_LOAD_DISABLED', + IPyWidgetTestAvailabilityOnCDN = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_CDN' } export enum NativeKeyboardCommandTelemetry { diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index 2a6b9ba65afd..0eedb5552c23 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -489,7 +489,7 @@ export class IInteractiveWindowMapping { public [IPyWidgetMessages.IPyWidgets_kernelOptions]: KernelSocketOptions; public [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesRequest]: undefined | never; public [IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse]: WidgetScriptSource[]; - public [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest]: string; + public [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest]: { moduleName: string; moduleVersion: string }; public [IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse]: WidgetScriptSource; public [IPyWidgetMessages.IPyWidgets_Ready]: never | undefined; public [IPyWidgetMessages.IPyWidgets_onRestartKernel]: never | undefined; diff --git a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts new file mode 100644 index 000000000000..579be91c4564 --- /dev/null +++ b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { + IConfigurationService, + IHttpClient, + LocalKernelScriptSource, + RemoteKernelScriptSource +} from '../../common/types'; +import { StopWatch } from '../../common/utils/stopWatch'; +import { sendTelemetryEvent } from '../../telemetry'; +import { Telemetry } from '../constants'; +import { INotebook } from '../types'; +import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; + +// Source borrowed from https://github.com/jupyter-widgets/ipywidgets/blob/54941b7a4b54036d089652d91b39f937bde6b6cd/packages/html-manager/src/libembed-amd.ts#L33 +const unpgkUrl = 'https://unpkg.com/'; +const jsdelivrUrl = 'https://cdn.jsdelivr.net/npm/'; +function moduleNameToCDNUrl(cdn: string, moduleName: string, moduleVersion: string) { + let packageName = moduleName; + let fileName = 'index'; // default filename + // if a '/' is present, like 'foo/bar', packageName is changed to 'foo', and path to 'bar' + // We first find the first '/' + let index = moduleName.indexOf('/'); + if (index !== -1 && moduleName[0] === '@') { + // if we have a namespace, it's a different story + // @foo/bar/baz should translate to @foo/bar and baz + // so we find the 2nd '/' + index = moduleName.indexOf('/', index + 1); + } + if (index !== -1) { + fileName = moduleName.substr(index + 1); + packageName = moduleName.substr(0, index); + } + return `${cdn}${packageName}@${moduleVersion}/dist/${fileName}`; +} + +function getCDNPrefix(cdn?: LocalKernelScriptSource | RemoteKernelScriptSource): string | undefined { + switch (cdn) { + case 'unpkg.com': + return unpgkUrl; + case 'jsdelivr.com': + return jsdelivrUrl; + default: + break; + } +} +/** + * Widget scripts are found in CDN. + * Given an widget module name & version, this will attempt to find the Url on a CDN. + * We'll need to stick to the order of preference prescribed by the user. + */ +export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { + private get cdnProviders(): readonly (LocalKernelScriptSource | RemoteKernelScriptSource)[] { + const settings = this.configurationSettings.getSettings(undefined); + if (this.notebook.connection.localLaunch) { + return settings.datascience.ipyWidgets.localKernelScriptSources; + } else { + return settings.datascience.ipyWidgets.remoteKernelScriptSources; + } + } + private static validUrls = new Map(); + constructor( + private readonly notebook: INotebook, + private readonly configurationSettings: IConfigurationService, + private readonly httpClient: IHttpClient + ) {} + public async getWidgetScriptSource(moduleName: string, moduleVersion: string): Promise { + const cdns = [...this.cdnProviders]; + + while (cdns.length) { + const cdn = getCDNPrefix(cdns.shift()); + if (!cdn) { + continue; + } + const scriptUri = moduleNameToCDNUrl(unpgkUrl, moduleName, moduleVersion); + const exists = await this.getUrlForWidget(cdn, moduleName, scriptUri); + if (exists) { + return { moduleName, scriptUri, source: 'cdn' }; + } + } + return { moduleName }; + } + public async getWidgetScriptSources(_ignoreCache?: boolean): Promise> { + return []; + } + private async getUrlForWidget(cdn: string, moduleName: string, url: string): Promise { + if (CDNWidgetScriptSourceProvider.validUrls.has(url)) { + return CDNWidgetScriptSourceProvider.validUrls.get(url)!; + } + + const stopWatch = new StopWatch(); + const exists = await this.httpClient + .getContents(url) + .catch(() => false) + .then(() => true); + sendTelemetryEvent(Telemetry.IPyWidgetTestAvailabilityOnCDN, stopWatch.elapsedTime, { cdn, exists }); + + // If exists, then can't contain PII, as its a public module. + if (exists) { + sendTelemetryEvent(Telemetry.HashedIPyWidgetNameUsed, stopWatch.elapsedTime, { hashedName: moduleName }); + } + CDNWidgetScriptSourceProvider.validUrls.set(url, exists); + return exists; + } +} diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index 7fd66fa3ff19..f810021ef95e 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -11,7 +11,7 @@ import { Event, EventEmitter, Uri } from 'vscode'; import type { Data as WebSocketData } from 'ws'; import { traceError } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; -import { IDisposableRegistry } from '../../common/types'; +import { IConfigurationService, IDisposableRegistry, IHttpClient } from '../../common/types'; import { IInterpreterService, PythonInterpreter } from '../../interpreter/contracts'; import { sendTelemetryEvent } from '../../telemetry'; import { Telemetry } from '../constants'; @@ -29,6 +29,7 @@ import { INotebookProvider, KernelSocketInformation } from '../types'; +import { CDNWidgetScriptSourceProvider } from './cdnWidgetScriptSourceProvider'; import { LocalWidgetScriptSourceProvider } from './localWidgetScriptSourceProvider'; import { RemoteWidgetScriptSourceProvider } from './remoteWidgetScriptSourceProvider'; import { IWidgetScriptSourceProvider } from './types'; @@ -48,12 +49,15 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { private notebook?: INotebook; private jupyterLab?: typeof jupyterlabService; private interactiveBase?: IInteractiveBase; - private scriptProvider?: IWidgetScriptSourceProvider; + private scriptProviders?: IWidgetScriptSourceProvider[]; private disposables: IDisposable[] = []; private interpreterForWhichWidgetSourcesWereFetched?: PythonInterpreter; private kernelSocketInfo?: KernelSocketInformation; private subscribedToKernelSocket: boolean = false; - private pendingModuleRequests = new Set(); + /** + * Key value pair of widget modules along with the version that needs to be loaded. + */ + private pendingModuleRequests = new Map(); private jupyterSerialize?: typeof serlialize; private get deserialize(): typeof serlialize.deserialize { if (!this.jupyterSerialize) { @@ -68,7 +72,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { @inject(IFileSystem) private readonly fs: IFileSystem, @inject(INotebookEditorProvider) private readonly notebookEditorProvider: INotebookEditorProvider, @inject(IInteractiveWindowProvider) private readonly interactiveWindowProvider: IInteractiveWindowProvider, - @inject(IInterpreterService) private readonly interpreterService: IInterpreterService + @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, + @inject(IConfigurationService) private readonly configurationSettings: IConfigurationService, + @inject(IHttpClient) private readonly httpClient: IHttpClient ) { disposables.push(this); this.notebookProvider.onNotebookCreated( @@ -100,37 +106,76 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { this.sendListOfWidgetSources().catch(traceError.bind('Failed to send widget sources upon ready')); } else if (message === IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest) { if (payload) { + const { moduleName, moduleVersion } = payload as { moduleName: string; moduleVersion: string }; sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { - hashedName: sha256().update(payload).digest('hex') + hashedName: sha256().update(moduleName).digest('hex') }); + this.sendWidgetSource(moduleName, moduleVersion).catch( + traceError.bind('Failed to send widget sources upon ready') + ); } - this.sendWidgetSource(payload).catch(traceError.bind('Failed to send widget sources upon ready')); } } private async sendListOfWidgetSources(ignoreCache?: boolean) { - if (!this.notebook || !this.scriptProvider) { + if (!this.notebook || !this.scriptProviders) { return; } - const sources = await this.scriptProvider.getWidgetScriptSources(ignoreCache); + + // Get script sources in order, if one works, then get out. + const scriptSourceProviders = [...this.scriptProviders]; + while (scriptSourceProviders.length) { + const scriptProvider = scriptSourceProviders.shift(); + if (!scriptProvider) { + continue; + } + const sources = await scriptProvider.getWidgetScriptSources(ignoreCache); + if (sources.length > 0) { + this.postEmitter.fire({ + message: IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse, + payload: sources + }); + return; + } + } + + // Tried all providers, nothing worked, hence send an empty response. this.postEmitter.fire({ message: IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse, - payload: sources + payload: [] }); } - private async sendWidgetSource(moduleName: string) { + private async sendWidgetSource(moduleName: string, moduleVersion: string) { // Standard widgets area already available, hence no need to look for them. if (moduleName.startsWith('@jupyter')) { return; } - if (!this.notebook || !this.scriptProvider) { - this.pendingModuleRequests.add(moduleName); + if (!this.notebook || !this.scriptProviders) { + this.pendingModuleRequests.set(moduleName, moduleVersion); return; } - const source = await this.scriptProvider.getWidgetScriptSource(moduleName); + + // Get script sources in order, if one works, then get out. + const scriptSourceProviders = [...this.scriptProviders]; + while (scriptSourceProviders.length) { + const scriptProvider = scriptSourceProviders.shift(); + if (!scriptProvider) { + continue; + } + const source = await scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); + if (source.scriptUri) { + this.postEmitter.fire({ + message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, + payload: source + }); + return; + } + } + + // Tried all providers, nothing worked, hence send an empty response. this.postEmitter.fire({ message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, - payload: source + payload: { moduleName } }); } private async saveIdentity(args: INotebookIdentity) { @@ -165,18 +210,68 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { if (!this.interactiveBase) { return; } + + // Check whether to use CDNs. if (this.notebook.connection.localLaunch) { - this.scriptProvider = new LocalWidgetScriptSourceProvider( + this.scriptProviders = [ + new LocalWidgetScriptSourceProvider( + this.notebook, + this.interactiveBase, + this.fs, + this.interpreterService + ) + ]; + } else { + this.scriptProviders = [new RemoteWidgetScriptSourceProvider(this.notebook.connection)]; + } + + // If we're allowed to use CDN providers, then use them, and use in order of preference. + if (this.canUseCDN()) { + const preferCDNFirst = this.preferCDNFirst(); + const cdnProvider = new CDNWidgetScriptSourceProvider( this.notebook, - this.interactiveBase, - this.fs, - this.interpreterService + this.configurationSettings, + this.httpClient ); - } else { - this.scriptProvider = new RemoteWidgetScriptSourceProvider(this.notebook.connection); + + if (preferCDNFirst) { + this.scriptProviders.splice(0, 0, cdnProvider); + } else { + this.scriptProviders.push(cdnProvider); + } } await this.initializeNotebook(); } + private canUseCDN(): boolean { + if (!this.notebook) { + return false; + } + const settings = this.configurationSettings.getSettings(undefined); + const scriptSources = this.notebook.connection.localLaunch + ? settings.datascience.ipyWidgets.localKernelScriptSources + : settings.datascience.ipyWidgets.remoteKernelScriptSources; + + if (scriptSources.length === 0) { + return false; + } + + return scriptSources.indexOf('jsdelivr.com') >= 0 || scriptSources.indexOf('unpkg.com') >= 0; + } + private preferCDNFirst(): boolean { + if (!this.notebook) { + return false; + } + const settings = this.configurationSettings.getSettings(undefined); + const scriptSources = this.notebook.connection.localLaunch + ? settings.datascience.ipyWidgets.localKernelScriptSources + : settings.datascience.ipyWidgets.remoteKernelScriptSources; + + if (scriptSources.length === 0) { + return false; + } + const item = scriptSources[0]; + return item === 'jsdelivr.com' || item === 'unpkg.com'; + } private async initializeNotebook() { if (!this.notebook) { return; @@ -238,7 +333,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { // tslint:disable-next-line: no-any const msg = this.deserialize(message as any); if (this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && msg.content.target_module) { - this.sendWidgetSource(msg.content.target_module).catch(traceError.bind('Failed to pre-load Widget Script')); + this.sendWidgetSource(msg.content.target_module, '').catch( + traceError.bind('Failed to pre-load Widget Script') + ); } else if ( this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && msg.content.data && @@ -251,20 +348,21 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { // tslint:disable-next-line: no-any const modelModule = (msg.content.data.state as any)._model_module; if (viewModule) { - this.sendWidgetSource(viewModule).catch(traceError.bind('Failed to pre-load Widget Script')); + this.sendWidgetSource(viewModule, '').catch(traceError.bind('Failed to pre-load Widget Script')); } if (modelModule) { - this.sendWidgetSource(viewModule).catch(traceError.bind('Failed to pre-load Widget Script')); + this.sendWidgetSource(viewModule, '').catch(traceError.bind('Failed to pre-load Widget Script')); } } } private handlePendingRequests() { - const pendingModuleNames = Array.from(this.pendingModuleRequests.values()); + const pendingModuleNames = Array.from(this.pendingModuleRequests.keys()); while (pendingModuleNames.length) { const moduleName = pendingModuleNames.shift(); if (moduleName) { + const moduleVersion = this.pendingModuleRequests.get(moduleName)!; this.pendingModuleRequests.delete(moduleName); - this.sendWidgetSource(moduleName).catch( + this.sendWidgetSource(moduleName, moduleVersion).catch( traceError.bind(`Failed to send WidgetScript for ${moduleName}`) ); } diff --git a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts index 6b5b6634850b..81dcb12c55ff 100644 --- a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts @@ -67,7 +67,9 @@ export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvi // Drop the `.js`. const fileUri = Uri.file(path.join(nbextensionsPath, moduleName, 'index')); const scriptUri = this.localResourceUriConverter.asWebviewUri(fileUri).toString(); - return { moduleName, scriptUri }; + // tslint:disable-next-line: no-unnecessary-local-variable + const widgetScriptSource: WidgetScriptSource = { moduleName, scriptUri, source: 'local' }; + return widgetScriptSource; }) .filter((item) => !!item) .map((item) => item!); diff --git a/src/client/datascience/ipywidgets/types.ts b/src/client/datascience/ipywidgets/types.ts index 6779cbc25024..97fa3c802408 100644 --- a/src/client/datascience/ipywidgets/types.ts +++ b/src/client/datascience/ipywidgets/types.ts @@ -29,6 +29,10 @@ export interface IIPyWidgetMessageDispatcher extends IDisposable { */ export type WidgetScriptSource = { moduleName: string; + /** + * Where is the script being source from. + */ + source?: 'cdn' | 'local' | 'remote'; /** * Resource Uri (not using Uri type as this needs to be sent from extension to UI). */ @@ -42,7 +46,7 @@ export interface IWidgetScriptSourceProvider { /** * Return the script path for the requested module. */ - getWidgetScriptSource(moduleName: string): Promise; + getWidgetScriptSource(moduleName: string, moduleVersion: string): Promise; /** * Returns a list of all widgets with their sources. Can be empty. */ diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 5573dedb8e11..ad86a28d5408 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1958,4 +1958,14 @@ export interface IEventNamePropertyMapping { * Telemetry event sent when an loading of 3rd party ipywidget JS scripts from 3rd party source has been disabled. */ [Telemetry.IPyWidgetLoadDisabled]: { moduleHash: string; moduleVersion: string }; + /** + * Telemetry send when we check whether a 3rd party widget exists on a CDN or not. + * We capture the time and whether the widget was found or not. + */ + [Telemetry.IPyWidgetTestAvailabilityOnCDN]: { + // The CDN we were testing. + cdn: string; + // Whether we managed to find the widget on the CDN or not. + exists: boolean; + }; } diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index eb1c22038d1f..2aaf9cf38d14 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -45,7 +45,7 @@ export class WidgetManagerComponent extends React.Component { // If expires, then Widget downloader will attempt to download with what ever information it has (potentially failing). timeoutWaitingForScriptToLoad: 5_000, // List of widgets that must always be loaded using requirejs instead of using a CDN or the like. - widgetsToLoadFromRequirejs: new Set(), + widgetsRegisteredInRequireJs: new Set(), // Callback when loading a widget fails. errorHandler: this.handleLoadError.bind(this), // Callback when requesting a module be registered with requirejs (if possible). @@ -132,7 +132,7 @@ export class WidgetManagerComponent extends React.Component { .filter((source) => source.scriptUri) .map((source) => source as NonPartial) .forEach((source) => { - this.loaderSettings.widgetsToLoadFromRequirejs.add(source.moduleName); + this.loaderSettings.widgetsRegisteredInRequireJs.add(source.moduleName); // Register the script source into requirejs so it gets loaded via requirejs. config.paths[source.moduleName] = source.scriptUri; }); @@ -183,22 +183,29 @@ export class WidgetManagerComponent extends React.Component { } } - private loadWidgetScript(moduleName: string): Promise { + /** + * Method called by ipywidgets to get the source for a widget. + * When we get a source for the widget, we register it in requriejs. + * We need to check if it is avaialble on CDN, if not then fallback to local FS. + * Or check local FS then fall back to CDN (depending on the order defined by the user). + */ + private loadWidgetScript(moduleName: string, moduleVersion: string): Promise { // tslint:disable-next-line: no-console - console.log(`Load IPyWidget ${moduleName}`); + console.log(`Fetch IPyWidget source for ${moduleName}`); let deferred = this.widgetSourceRequests.get(moduleName); if (!deferred) { deferred = createDeferred(); this.widgetSourceRequests.set(moduleName, deferred); - this.props.postOffice.sendMessage( - IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest, - moduleName - ); - // If we timeout, then resolve this promise. // We don't want the calling code to unnecessary wait for too long. setTimeout(() => deferred?.resolve(), this.loaderSettings.timeoutWaitingForScriptToLoad); } + // Whether we have the scripts or not, send message to extension. + // Useful telemetry and also we know it was explicity requestd by ipywidgest. + this.props.postOffice.sendMessage( + IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest, + { moduleName, moduleVersion } + ); return ( deferred.promise diff --git a/src/datascience-ui/ipywidgets/manager.ts b/src/datascience-ui/ipywidgets/manager.ts index aa55060bd1be..57a3750498c4 100644 --- a/src/datascience-ui/ipywidgets/manager.ts +++ b/src/datascience-ui/ipywidgets/manager.ts @@ -48,10 +48,10 @@ export class WidgetManager implements IIPyWidgetManager, IMessageHandler { private readonly postOffice: PostOffice, private readonly scriptLoader: { readonly loadWidgetScriptsFromThirdPartySource: boolean; - readonly widgetsToLoadFromRequirejs: Readonly>; + readonly widgetsRegisteredInRequireJs: Readonly>; // tslint:disable-next-line: no-any errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; - loadWidgetScript(moduleName: string): void; + loadWidgetScript(moduleName: string, moduleVersion: string): void; } ) { // tslint:disable-next-line: no-any diff --git a/src/datascience-ui/react-common/settingsReactSide.ts b/src/datascience-ui/react-common/settingsReactSide.ts index 2aaaa5661bae..dff25de7c17c 100644 --- a/src/datascience-ui/react-common/settingsReactSide.ts +++ b/src/datascience-ui/react-common/settingsReactSide.ts @@ -66,7 +66,12 @@ export function getDefaultSettings() { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; return result; diff --git a/src/ipywidgets/src/embed.ts b/src/ipywidgets/src/embed.ts index 1fe5fe69fa3e..3027340274e7 100644 --- a/src/ipywidgets/src/embed.ts +++ b/src/ipywidgets/src/embed.ts @@ -101,7 +101,7 @@ export function renderWidgets(element = document.documentElement): void { const managerFactory = (): any => { return new wm.WidgetManager(undefined, element, { loadWidgetScriptsFromThirdPartySource: false, - widgetsToLoadFromRequirejs: new Set(), + widgetsRegisteredInRequireJs: new Set(), errorHandler: () => 'Error loading widget.', loadWidgetScript: (_moduleName: string) => Promise.resolve() }); diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index 4880cdb2d843..5186691a3891 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -17,7 +17,7 @@ export const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json'; // Source borrowed from https://github.com/jupyter-widgets/ipywidgets/blob/master/examples/web3/src/manager.ts // These widgets can always be loaded from requirejs (as it is bundled). -const widgetsToLoadFromRequire = ['@jupyter-widgets/controls', '@jupyter-widgets/base', '@jupyter-widgets/output']; +const widgetsRegisteredInRequireJs = ['@jupyter-widgets/controls', '@jupyter-widgets/base', '@jupyter-widgets/output']; export class WidgetManager extends jupyterlab.WidgetManager { public kernel: Kernel.IKernelConnection; @@ -28,9 +28,9 @@ export class WidgetManager extends jupyterlab.WidgetManager { el: HTMLElement, private readonly scriptLoader: { readonly loadWidgetScriptsFromThirdPartySource: boolean; - readonly widgetsToLoadFromRequirejs: Readonly>; + readonly widgetsRegisteredInRequireJs: Readonly>; errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; - loadWidgetScript(moduleName: string): Promise; + loadWidgetScript(moduleName: string, moduleVersion: string): Promise; } ) { super( @@ -101,8 +101,8 @@ export class WidgetManager extends jupyterlab.WidgetManager { const result = await super.loadClass(className, moduleName, moduleVersion).catch(async (originalException) => { try { const loadModuleFromRequirejs = - widgetsToLoadFromRequire.includes(moduleName) || - this.scriptLoader.widgetsToLoadFromRequirejs.has(moduleName); + widgetsRegisteredInRequireJs.includes(moduleName) || + this.scriptLoader.widgetsRegisteredInRequireJs.has(moduleName); if (!this.scriptLoader.loadWidgetScriptsFromThirdPartySource && !loadModuleFromRequirejs) { throw new Error('Loading from 3rd party source is disabled'); @@ -110,7 +110,7 @@ export class WidgetManager extends jupyterlab.WidgetManager { if (!loadModuleFromRequirejs) { // If not loading from requirejs, then check if we can. - await this.scriptLoader.loadWidgetScript(moduleName); + await this.scriptLoader.loadWidgetScript(moduleName, moduleVersion); } // If loading module from requirejs (e.g. already bundled), then do not use the cdn. diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index 4906cb96d13d..eea0959f495f 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -299,7 +299,12 @@ suite('Python Settings', async () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; expected.pythonPath = 'python3'; // tslint:disable-next-line:no-any diff --git a/src/test/datascience/color.test.ts b/src/test/datascience/color.test.ts index 74603f558f19..ee6e5e6b406e 100644 --- a/src/test/datascience/color.test.ts +++ b/src/test/datascience/color.test.ts @@ -74,7 +74,12 @@ suite('Theme colors', () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; configService = TypeMoq.Mock.ofType(); configService.setup((x) => x.getSettings(TypeMoq.It.isAny())).returns(() => settings); diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index 5e0a83ae4ec6..4ee7be581bba 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -1363,7 +1363,12 @@ export class DataScienceIocContainer extends UnitTestIocContainer { variableQueries: [], jupyterCommandLineArguments: [], disableJupyterAutoStart: true, - loadWidgetScriptsFromThirdPartySource: true + loadWidgetScriptsFromThirdPartySource: true, + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; pythonSettings.jediEnabled = false; pythonSettings.downloadLanguageServer = false; diff --git a/src/test/datascience/editor-integration/codewatcher.unit.test.ts b/src/test/datascience/editor-integration/codewatcher.unit.test.ts index e0738de79c2b..8e3d97e35252 100644 --- a/src/test/datascience/editor-integration/codewatcher.unit.test.ts +++ b/src/test/datascience/editor-integration/codewatcher.unit.test.ts @@ -94,7 +94,12 @@ suite('DataScience Code Watcher Unit Tests', () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; debugService.setup((d) => d.activeDebugSession).returns(() => undefined); diff --git a/src/test/datascience/execution.unit.test.ts b/src/test/datascience/execution.unit.test.ts index 1f941679d28b..1931f402b896 100644 --- a/src/test/datascience/execution.unit.test.ts +++ b/src/test/datascience/execution.unit.test.ts @@ -892,7 +892,12 @@ suite('Jupyter Execution', async () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; // Service container also needs to generate jupyter servers. However we can't use a mock as that messes up returning diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index d914a45ad15b..3a3215f8c1dc 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -32,6 +32,11 @@ export function defaultDataScienceSettings(): IDataScienceSettings { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; } diff --git a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts index 97f8fedef1d5..bc8dbb713044 100644 --- a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts +++ b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts @@ -141,7 +141,12 @@ suite('Interactive window command listener', async () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; when(knownSearchPaths.getSearchPaths()).thenReturn(['/foo/bar']); diff --git a/src/test/datascience/jupyter/serverCache.unit.test.ts b/src/test/datascience/jupyter/serverCache.unit.test.ts index cd98f0cb6a49..5cacb519023d 100644 --- a/src/test/datascience/jupyter/serverCache.unit.test.ts +++ b/src/test/datascience/jupyter/serverCache.unit.test.ts @@ -50,7 +50,12 @@ suite('Data Science - ServerCache', () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; when(configService.getSettings(anything())).thenReturn(pythonSettings); serverCache = new ServerCache(instance(configService), instance(workspaceService), instance(fileSystem)); diff --git a/src/test/datascience/jupyterVariables.unit.test.ts b/src/test/datascience/jupyterVariables.unit.test.ts index 51a0abba7e9b..09b0cd04ce11 100644 --- a/src/test/datascience/jupyterVariables.unit.test.ts +++ b/src/test/datascience/jupyterVariables.unit.test.ts @@ -97,7 +97,12 @@ suite('JupyterVariables', () => { runStartupCommands: '', debugJustMyCode: true, variableQueries: [], - jupyterCommandLineArguments: [] + jupyterCommandLineArguments: [], + ipyWidgets: { + enabled: true, + localKernelScriptSources: [], + remoteKernelScriptSources: [] + } }; // Create our fake notebook @@ -235,9 +240,9 @@ suite('JupyterVariables', () => { Promise.resolve({ 'text/plain': `\u001b[1;31mType:\u001b[0m complex \u001b[1;31mString form:\u001b[0m (1+1j) -\u001b[1;31mDocstring:\u001b[0m +\u001b[1;31mDocstring:\u001b[0m Create a complex number from a real part and an optional imaginary part. - + This is equivalent to (real + imag*1j) where imag defaults to 0. "` }) @@ -286,9 +291,9 @@ This is equivalent to (real + imag*1j) where imag defaults to 0. Promise.resolve({ 'text/plain': `\u001b[1;31mType:\u001b[0m complex \u001b[1;31mString form:\u001b[0m (1+1j) -\u001b[1;31mDocstring:\u001b[0m +\u001b[1;31mDocstring:\u001b[0m Create a complex number from a real part and an optional imaginary part. - + This is equivalent to (real + imag*1j) where imag defaults to 0. "` }) From 19751e9db21a8ad4a05d06b76387ac39b5be1215 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 17:08:09 -0700 Subject: [PATCH 11/41] misc --- package.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/package.json b/package.json index fe4eb7ea8124..a1d02b4912b6 100644 --- a/package.json +++ b/package.json @@ -1604,6 +1604,32 @@ "description": "Allows a user to import a jupyter notebook into a python file anytime one is opened.", "scope": "resource" }, + "python.dataScience.ipyWidgets.localKernelScriptSources": { + "type": "array", + "default": [], + "items": { + "enum": [ + "unpkg.com", + "jsdelivr.com", + "localPythonEnvironment" + ] + }, + "description": "For local Kernels, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", + "scope": "machine" + }, + "python.dataScience.ipyWidgets.remoteKernelScriptSources": { + "type": "array", + "default": [], + "items": { + "enum": [ + "unpkg.com", + "jsdelivr.com", + "remoteJupyterServer" + ] + }, + "description": "For remote Kernels, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", + "scope": "machine" + }, "python.dataScience.loadWidgetScriptsFromThirdPartySource": { "type": "boolean", "default": false, From 1df1e10a96cc0f3d3c5de3db4306cff7ea0eea06 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 17:10:50 -0700 Subject: [PATCH 12/41] Remove --- src/client/common/types.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/client/common/types.ts b/src/client/common/types.ts index af38c0d1a4c8..876013c94e1d 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -400,10 +400,6 @@ export type WidgetCDNs = 'unpkg.com' | 'jsdelivr.com'; export type LocalKernelScriptSource = WidgetCDNs | 'localPythonEnvironment'; export type RemoteKernelScriptSource = WidgetCDNs | 'remoteJupyterServer'; export type WidgetSettings = { - /** - * Whether ipywidget support is enabled or not. - */ - enabled: boolean; /** * Order of sources to fetch the widget scripts (when running a local kernel). * In this case we might be able to get the widget scripts from the local python environment. From 11499bb6b090c2eb47e51f42f7bbc433ee46cb6d Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 7 Apr 2020 17:14:15 -0700 Subject: [PATCH 13/41] Fixes --- .../datascience/ipywidgets/ipyWidgetScriptSource.ts | 9 +++++++++ src/datascience-ui/react-common/settingsReactSide.ts | 1 - .../common/configSettings/configSettings.unit.test.ts | 1 - src/test/datascience/color.test.ts | 1 - src/test/datascience/dataScienceIocContainer.ts | 1 - .../editor-integration/codewatcher.unit.test.ts | 1 - src/test/datascience/execution.unit.test.ts | 1 - src/test/datascience/helpers.ts | 1 - .../interactiveWindowCommandListener.unit.test.ts | 1 - src/test/datascience/jupyter/serverCache.unit.test.ts | 1 - src/test/datascience/jupyterVariables.unit.test.ts | 1 - 11 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index f810021ef95e..350fba52e491 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -117,6 +117,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { } } + /** + * Send a list of all widgets and sources to the UI. + */ private async sendListOfWidgetSources(ignoreCache?: boolean) { if (!this.notebook || !this.scriptProviders) { return; @@ -145,6 +148,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { payload: [] }); } + /** + * Send the widget script source for a specific widget module & version. + */ private async sendWidgetSource(moduleName: string, moduleVersion: string) { // Standard widgets area already available, hence no need to look for them. if (moduleName.startsWith('@jupyter')) { @@ -257,6 +263,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { return scriptSources.indexOf('jsdelivr.com') >= 0 || scriptSources.indexOf('unpkg.com') >= 0; } + /** + * Whether we should load widgets first from CDN then from else where. + */ private preferCDNFirst(): boolean { if (!this.notebook) { return false; diff --git a/src/datascience-ui/react-common/settingsReactSide.ts b/src/datascience-ui/react-common/settingsReactSide.ts index dff25de7c17c..861d8243f6eb 100644 --- a/src/datascience-ui/react-common/settingsReactSide.ts +++ b/src/datascience-ui/react-common/settingsReactSide.ts @@ -68,7 +68,6 @@ export function getDefaultSettings() { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index eea0959f495f..e4d9843516cf 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -301,7 +301,6 @@ suite('Python Settings', async () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/color.test.ts b/src/test/datascience/color.test.ts index ee6e5e6b406e..86b54303f276 100644 --- a/src/test/datascience/color.test.ts +++ b/src/test/datascience/color.test.ts @@ -76,7 +76,6 @@ suite('Theme colors', () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index 4ee7be581bba..d1c9dafe54f5 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -1365,7 +1365,6 @@ export class DataScienceIocContainer extends UnitTestIocContainer { disableJupyterAutoStart: true, loadWidgetScriptsFromThirdPartySource: true, ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/editor-integration/codewatcher.unit.test.ts b/src/test/datascience/editor-integration/codewatcher.unit.test.ts index 8e3d97e35252..1b3009d630d9 100644 --- a/src/test/datascience/editor-integration/codewatcher.unit.test.ts +++ b/src/test/datascience/editor-integration/codewatcher.unit.test.ts @@ -96,7 +96,6 @@ suite('DataScience Code Watcher Unit Tests', () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/execution.unit.test.ts b/src/test/datascience/execution.unit.test.ts index 1931f402b896..70ee48ed5c58 100644 --- a/src/test/datascience/execution.unit.test.ts +++ b/src/test/datascience/execution.unit.test.ts @@ -894,7 +894,6 @@ suite('Jupyter Execution', async () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index 3a3215f8c1dc..e44c81838814 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -34,7 +34,6 @@ export function defaultDataScienceSettings(): IDataScienceSettings { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts index bc8dbb713044..f9e70a47fc45 100644 --- a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts +++ b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts @@ -143,7 +143,6 @@ suite('Interactive window command listener', async () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/jupyter/serverCache.unit.test.ts b/src/test/datascience/jupyter/serverCache.unit.test.ts index 5cacb519023d..f5d6525dba16 100644 --- a/src/test/datascience/jupyter/serverCache.unit.test.ts +++ b/src/test/datascience/jupyter/serverCache.unit.test.ts @@ -52,7 +52,6 @@ suite('Data Science - ServerCache', () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/jupyterVariables.unit.test.ts b/src/test/datascience/jupyterVariables.unit.test.ts index 09b0cd04ce11..8d99214a9e5c 100644 --- a/src/test/datascience/jupyterVariables.unit.test.ts +++ b/src/test/datascience/jupyterVariables.unit.test.ts @@ -99,7 +99,6 @@ suite('JupyterVariables', () => { variableQueries: [], jupyterCommandLineArguments: [], ipyWidgets: { - enabled: true, localKernelScriptSources: [], remoteKernelScriptSources: [] } From 953b5c4703ea4615fe6e3dca056bea3a6677e200 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 8 Apr 2020 16:37:45 -0700 Subject: [PATCH 14/41] Changes --- package.json | 8 +- package.nls.json | 3 +- src/client/common/types.ts | 2 +- src/client/common/utils/localize.ts | 5 + src/client/datascience/constants.ts | 4 +- .../cdnWidgetScriptSourceProvider.ts | 21 +- .../ipywidgets/ipyWidgetScriptSource.ts | 170 +++----- .../ipyWidgetScriptSourceProvider.ts | 235 +++++++++++ .../localWidgetScriptSourceProvider.ts | 14 +- .../remoteWidgetScriptSourceProvider.ts | 3 + src/client/datascience/ipywidgets/types.ts | 7 +- src/client/telemetry/index.ts | 13 +- src/datascience-ui/ipywidgets/container.tsx | 4 +- .../react-common/settingsReactSide.ts | 2 +- .../configSettings.unit.test.ts | 2 +- src/test/datascience/color.test.ts | 2 +- .../datascience/dataScienceIocContainer.ts | 2 +- .../codewatcher.unit.test.ts | 2 +- src/test/datascience/execution.unit.test.ts | 2 +- src/test/datascience/helpers.ts | 2 +- ...eractiveWindowCommandListener.unit.test.ts | 2 +- ...cdnWidgetScriptSourceProvider.unit.test.ts | 210 ++++++++++ .../ipyWidgetScriptSource.unit.test.ts | 380 ++++++++++++++++++ ...calWidgetScriptSourceProvider.unit.test.ts | 249 ++++++++++++ .../jupyter/serverCache.unit.test.ts | 2 +- .../datascience/jupyterVariables.unit.test.ts | 2 +- 26 files changed, 1195 insertions(+), 153 deletions(-) create mode 100644 src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts create mode 100644 src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts create mode 100644 src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts create mode 100644 src/test/datascience/ipywidgets/localWidgetScriptSourceProvider.unit.test.ts diff --git a/package.json b/package.json index 0480674c02e8..c82037c95725 100644 --- a/package.json +++ b/package.json @@ -1606,26 +1606,26 @@ "description": "Allows a user to import a jupyter notebook into a python file anytime one is opened.", "scope": "resource" }, - "python.dataScience.ipyWidgets.localKernelScriptSources": { + "python.dataScience.widgets.localKernelScriptSources": { "type": "array", "default": [], "items": { "enum": [ - "unpkg.com", "jsdelivr.com", + "unpkg.com", "localPythonEnvironment" ] }, "description": "For local Kernels, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", "scope": "machine" }, - "python.dataScience.ipyWidgets.remoteKernelScriptSources": { + "python.dataScience.widgets.remoteKernelScriptSources": { "type": "array", "default": [], "items": { "enum": [ - "unpkg.com", "jsdelivr.com", + "unpkg.com", "remoteJupyterServer" ] }, diff --git a/package.nls.json b/package.nls.json index 0a899e1991b1..3c10718b43a0 100644 --- a/package.nls.json +++ b/package.nls.json @@ -459,5 +459,6 @@ "DataScience.gatherQuality": "Did gather work as desired?", "DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.", "DataScience.loadThirdPartyWidgetScriptsDisabled": "Loading of Widgets is disabled by default. Click here to enable the setting 'python.dataScience.loadWidgetScriptsFromThirdPartySource'. Once enabled you will need to restart the Kernel", - "DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'loadWidgetScriptsFromThirdPartySource'." + "DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'loadWidgetScriptsFromThirdPartySource'.", + "DataScience.useCDNForWidgets": "Widgets require us to download supporting files from a 3rd party website. Click [here](https://aka.ms/widgets) for more information." } diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 876013c94e1d..b153e49cdbfa 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -393,7 +393,7 @@ export interface IDataScienceSettings { disableJupyterAutoStart?: boolean; jupyterCommandLineArguments: string[]; loadWidgetScriptsFromThirdPartySource?: boolean; - ipyWidgets: WidgetSettings; + widgets: WidgetSettings; } export type WidgetCDNs = 'unpkg.com' | 'jsdelivr.com'; diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index b7c2113e6e92..3f575412f327 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -61,6 +61,7 @@ export namespace Diagnostics { export namespace Common { export const canceled = localize('Common.canceled', 'Canceled'); export const cancel = localize('Common.cancel', 'Cancel'); + export const ok = localize('Common.ok', 'Ok'); export const gotIt = localize('Common.gotIt', 'Got it!'); export const install = localize('Common.install', 'Install'); export const loadingExtension = localize('Common.loadingPythonExtension', 'Python extension loading...'); @@ -833,6 +834,10 @@ export namespace DataScience { 'DataScience.loadThirdPartyWidgetScriptsPostEnabled', "Once you have updated the setting 'loadWidgetScriptsFromThirdPartySource' you will need to restart the Kernel." ); + export const useCDNForWidgets = localize( + 'DataScience.useCDNForWidgets', + 'Widgets require us to download supporting files from a 3rd party website. Click [here](https://aka.ms/widgets) for more information.' + ); } export namespace DebugConfigStrings { diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 0a80f701ee5e..dd331140cf5a 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -295,7 +295,9 @@ export enum Telemetry { ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING', IPyWidgetLoadFailure = 'DS_INTERNAL.IPYWIDGET_LOAD_FAILURE', IPyWidgetLoadDisabled = 'DS_INTERNAL.IPYWIDGET_LOAD_DISABLED', - IPyWidgetTestAvailabilityOnCDN = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_CDN' + IPyWidgetTestAvailabilityOnCDN = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_CDN', + IPyWidgetPromptToUseCDN = 'DS_INTERNAL.IPYWIDGET_PROMPT_TO_USE_CDN', + IPyWidgetPromptToUseCDNSelection = 'DS_INTERNAL.IPYWIDGET_PROMPT_TO_USE_CDN_SELECTION' } export enum NativeKeyboardCommandTelemetry { diff --git a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts index 579be91c4564..ad95eac6ec4d 100644 --- a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts @@ -56,26 +56,29 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide private get cdnProviders(): readonly (LocalKernelScriptSource | RemoteKernelScriptSource)[] { const settings = this.configurationSettings.getSettings(undefined); if (this.notebook.connection.localLaunch) { - return settings.datascience.ipyWidgets.localKernelScriptSources; + return settings.datascience.widgets.localKernelScriptSources; } else { - return settings.datascience.ipyWidgets.remoteKernelScriptSources; + return settings.datascience.widgets.remoteKernelScriptSources; } } - private static validUrls = new Map(); + public static validUrls = new Map(); constructor( private readonly notebook: INotebook, private readonly configurationSettings: IConfigurationService, private readonly httpClient: IHttpClient ) {} + public dispose() { + // Noop. + } public async getWidgetScriptSource(moduleName: string, moduleVersion: string): Promise { const cdns = [...this.cdnProviders]; - while (cdns.length) { - const cdn = getCDNPrefix(cdns.shift()); - if (!cdn) { + const cdn = cdns.shift(); + const cdnBaseUrl = getCDNPrefix(cdn); + if (!cdnBaseUrl || !cdn) { continue; } - const scriptUri = moduleNameToCDNUrl(unpgkUrl, moduleName, moduleVersion); + const scriptUri = moduleNameToCDNUrl(cdnBaseUrl, moduleName, moduleVersion); const exists = await this.getUrlForWidget(cdn, moduleName, scriptUri); if (exists) { return { moduleName, scriptUri, source: 'cdn' }; @@ -94,8 +97,8 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide const stopWatch = new StopWatch(); const exists = await this.httpClient .getContents(url) - .catch(() => false) - .then(() => true); + .then(() => true) + .catch(() => false); sendTelemetryEvent(Telemetry.IPyWidgetTestAvailabilityOnCDN, stopWatch.elapsedTime, { cdn, exists }); // If exists, then can't contain PII, as its a public module. diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index 350fba52e491..e1314ab47d88 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -9,6 +9,7 @@ import { inject, injectable } from 'inversify'; import { IDisposable } from 'monaco-editor'; import { Event, EventEmitter, Uri } from 'vscode'; import type { Data as WebSocketData } from 'ws'; +import { IApplicationShell, IWorkspaceService } from '../../common/application/types'; import { traceError } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; import { IConfigurationService, IDisposableRegistry, IHttpClient } from '../../common/types'; @@ -29,10 +30,7 @@ import { INotebookProvider, KernelSocketInformation } from '../types'; -import { CDNWidgetScriptSourceProvider } from './cdnWidgetScriptSourceProvider'; -import { LocalWidgetScriptSourceProvider } from './localWidgetScriptSourceProvider'; -import { RemoteWidgetScriptSourceProvider } from './remoteWidgetScriptSourceProvider'; -import { IWidgetScriptSourceProvider } from './types'; +import { IPyWidgetScriptSourceProvider } from './ipyWidgetScriptSourceProvider'; @injectable() export class IPyWidgetScriptSource implements IInteractiveWindowListener { @@ -49,7 +47,7 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { private notebook?: INotebook; private jupyterLab?: typeof jupyterlabService; private interactiveBase?: IInteractiveBase; - private scriptProviders?: IWidgetScriptSourceProvider[]; + private scriptProvider?: IPyWidgetScriptSourceProvider; private disposables: IDisposable[] = []; private interpreterForWhichWidgetSourcesWereFetched?: PythonInterpreter; private kernelSocketInfo?: KernelSocketInformation; @@ -74,7 +72,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { @inject(IInteractiveWindowProvider) private readonly interactiveWindowProvider: IInteractiveWindowProvider, @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, @inject(IConfigurationService) private readonly configurationSettings: IConfigurationService, - @inject(IHttpClient) private readonly httpClient: IHttpClient + @inject(IHttpClient) private readonly httpClient: IHttpClient, + @inject(IApplicationShell) private readonly appShell: IApplicationShell, + @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService ) { disposables.push(this); this.notebookProvider.onNotebookCreated( @@ -121,31 +121,14 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { * Send a list of all widgets and sources to the UI. */ private async sendListOfWidgetSources(ignoreCache?: boolean) { - if (!this.notebook || !this.scriptProviders) { + if (!this.notebook || !this.scriptProvider) { return; } - // Get script sources in order, if one works, then get out. - const scriptSourceProviders = [...this.scriptProviders]; - while (scriptSourceProviders.length) { - const scriptProvider = scriptSourceProviders.shift(); - if (!scriptProvider) { - continue; - } - const sources = await scriptProvider.getWidgetScriptSources(ignoreCache); - if (sources.length > 0) { - this.postEmitter.fire({ - message: IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse, - payload: sources - }); - return; - } - } - - // Tried all providers, nothing worked, hence send an empty response. + const sources = await this.scriptProvider.getWidgetScriptSources(ignoreCache); this.postEmitter.fire({ message: IPyWidgetMessages.IPyWidgets_AllWidgetScriptSourcesResponse, - payload: [] + payload: sources }); } /** @@ -156,32 +139,15 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { if (moduleName.startsWith('@jupyter')) { return; } - if (!this.notebook || !this.scriptProviders) { + if (!this.notebook || !this.scriptProvider) { this.pendingModuleRequests.set(moduleName, moduleVersion); return; } - // Get script sources in order, if one works, then get out. - const scriptSourceProviders = [...this.scriptProviders]; - while (scriptSourceProviders.length) { - const scriptProvider = scriptSourceProviders.shift(); - if (!scriptProvider) { - continue; - } - const source = await scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); - if (source.scriptUri) { - this.postEmitter.fire({ - message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, - payload: source - }); - return; - } - } - - // Tried all providers, nothing worked, hence send an empty response. + const source = await this.scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); this.postEmitter.fire({ message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, - payload: { moduleName } + payload: source }); } private async saveIdentity(args: INotebookIdentity) { @@ -196,91 +162,47 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { this.jupyterLab = require('@jupyterlab/services') as typeof jupyterlabService; // NOSONAR } - if (!this.notebookIdentity || this.notebook) { + if (!this.notebookIdentity) { return; } - this.notebook = await this.notebookProvider.getOrCreateNotebook({ - identity: this.notebookIdentity, - disableUI: true, - getOnly: true - }); + if (!this.notebook) { + this.notebook = await this.notebookProvider.getOrCreateNotebook({ + identity: this.notebookIdentity, + disableUI: true, + getOnly: true + }); + } if (!this.notebook) { return; } - this.interactiveBase = this.notebookEditorProvider.editors.find( - (editor) => editor.notebook?.identity.toString() === this.notebookIdentity?.toString() - ); if (!this.interactiveBase) { - this.interactiveBase = this.interactiveWindowProvider.getActive(); + this.interactiveBase = this.notebookEditorProvider.editors.find( + (editor) => + editor.notebook?.identity.toString() === this.notebookIdentity?.toString() || + editor.file.toString() === this.notebookIdentity?.toString() + ); + if (!this.interactiveBase) { + this.interactiveBase = this.interactiveWindowProvider.getActive(); + } } if (!this.interactiveBase) { return; } - - // Check whether to use CDNs. - if (this.notebook.connection.localLaunch) { - this.scriptProviders = [ - new LocalWidgetScriptSourceProvider( - this.notebook, - this.interactiveBase, - this.fs, - this.interpreterService - ) - ]; - } else { - this.scriptProviders = [new RemoteWidgetScriptSourceProvider(this.notebook.connection)]; - } - - // If we're allowed to use CDN providers, then use them, and use in order of preference. - if (this.canUseCDN()) { - const preferCDNFirst = this.preferCDNFirst(); - const cdnProvider = new CDNWidgetScriptSourceProvider( - this.notebook, - this.configurationSettings, - this.httpClient - ); - - if (preferCDNFirst) { - this.scriptProviders.splice(0, 0, cdnProvider); - } else { - this.scriptProviders.push(cdnProvider); - } + if (this.scriptProvider) { + return; } + this.scriptProvider = new IPyWidgetScriptSourceProvider( + this.notebook, + this.interactiveBase, + this.fs, + this.interpreterService, + this.appShell, + this.configurationSettings, + this.workspaceService, + this.httpClient + ); await this.initializeNotebook(); } - private canUseCDN(): boolean { - if (!this.notebook) { - return false; - } - const settings = this.configurationSettings.getSettings(undefined); - const scriptSources = this.notebook.connection.localLaunch - ? settings.datascience.ipyWidgets.localKernelScriptSources - : settings.datascience.ipyWidgets.remoteKernelScriptSources; - - if (scriptSources.length === 0) { - return false; - } - - return scriptSources.indexOf('jsdelivr.com') >= 0 || scriptSources.indexOf('unpkg.com') >= 0; - } - /** - * Whether we should load widgets first from CDN then from else where. - */ - private preferCDNFirst(): boolean { - if (!this.notebook) { - return false; - } - const settings = this.configurationSettings.getSettings(undefined); - const scriptSources = this.notebook.connection.localLaunch - ? settings.datascience.ipyWidgets.localKernelScriptSources - : settings.datascience.ipyWidgets.remoteKernelScriptSources; - - if (scriptSources.length === 0) { - return false; - } - const item = scriptSources[0]; - return item === 'jsdelivr.com' || item === 'unpkg.com'; - } private async initializeNotebook() { if (!this.notebook) { return; @@ -355,12 +277,20 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { // tslint:disable-next-line: no-any const viewModule: string = (msg.content.data.state as any)._view_module; // tslint:disable-next-line: no-any + const viewModuleVersion: string = (msg.content.data.state as any)._view_module_version; + // tslint:disable-next-line: no-any const modelModule = (msg.content.data.state as any)._model_module; + // tslint:disable-next-line: no-any + const modelModuleVersion = (msg.content.data.state as any)._model_module_version; if (viewModule) { - this.sendWidgetSource(viewModule, '').catch(traceError.bind('Failed to pre-load Widget Script')); + this.sendWidgetSource(viewModule, modelModuleVersion || '').catch( + traceError.bind('Failed to pre-load Widget Script') + ); } if (modelModule) { - this.sendWidgetSource(viewModule, '').catch(traceError.bind('Failed to pre-load Widget Script')); + this.sendWidgetSource(viewModule, viewModuleVersion || '').catch( + traceError.bind('Failed to pre-load Widget Script') + ); } } } diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts new file mode 100644 index 000000000000..a5dbac64adf1 --- /dev/null +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { ConfigurationChangeEvent, ConfigurationTarget } from 'vscode'; +import { IApplicationShell, IWorkspaceService } from '../../common/application/types'; +import { IFileSystem } from '../../common/platform/types'; +import { + IConfigurationService, + IHttpClient, + LocalKernelScriptSource, + RemoteKernelScriptSource +} from '../../common/types'; +import { createDeferred, Deferred } from '../../common/utils/async'; +import { Common, DataScience } from '../../common/utils/localize'; +import { IInterpreterService } from '../../interpreter/contracts'; +import { sendTelemetryEvent } from '../../telemetry'; +import { Telemetry } from '../constants'; +import { ILocalResourceUriConverter, INotebook } from '../types'; +import { CDNWidgetScriptSourceProvider } from './cdnWidgetScriptSourceProvider'; +import { LocalWidgetScriptSourceProvider } from './localWidgetScriptSourceProvider'; +import { RemoteWidgetScriptSourceProvider } from './remoteWidgetScriptSourceProvider'; +import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; + +/** + * This class decides where to get widget scripts from. + * Whether its cdn or local or other, and also controls the order/priority. + * If user changes the order, this will react to those configuration setting changes. + * If user has not configured antying, user will be presented with a prompt. + */ +export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { + private scriptProviders?: IWidgetScriptSourceProvider[]; + private configurationPromise?: Deferred; + private get configuredScriptSources(): readonly (LocalKernelScriptSource | RemoteKernelScriptSource)[] { + const settings = this.configurationSettings.getSettings(undefined); + if (this.notebook.connection.localLaunch) { + return settings.datascience.widgets.localKernelScriptSources; + } else { + return settings.datascience.widgets.remoteKernelScriptSources; + } + } + constructor( + private readonly notebook: INotebook, + private readonly localResourceUriConverter: ILocalResourceUriConverter, + private readonly fs: IFileSystem, + private readonly interpreterService: IInterpreterService, + private readonly appShell: IApplicationShell, + private readonly configurationSettings: IConfigurationService, + private readonly workspaceService: IWorkspaceService, + private readonly httpClient: IHttpClient + ) {} + public initialize() { + this.workspaceService.onDidChangeConfiguration(this.onSettingsChagned.bind(this)); + } + public dispose() { + this.disposeScriptProviders(); + } + /** + * We know widgets are being used, at this point prompt user if required. + */ + public async getWidgetScriptSource( + moduleName: string, + moduleVersion: string + ): Promise> { + await this.configureWidgets(); + if (!this.scriptProviders) { + this.rebuildProviders(); + } + + // Get script sources in order, if one works, then get out. + const scriptSourceProviders = (this.scriptProviders || []).slice(); + while (scriptSourceProviders.length) { + const scriptProvider = scriptSourceProviders.shift(); + if (!scriptProvider) { + continue; + } + const source = await scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); + if (source.scriptUri) { + return source; + } + } + + // Tried all providers, nothing worked, hence send an empty response. + return { moduleName }; + } + public async getWidgetScriptSources(ignoreCache?: boolean | undefined): Promise { + // At this point we dont need to configure the settings. + // We don't know if widgest are being used. + if (!this.scriptProviders) { + this.rebuildProviders(); + } + + // Get script sources in order, if one works, then get out. + const scriptSourceProviders = (this.scriptProviders || []).slice(); + while (scriptSourceProviders.length) { + const scriptProvider = scriptSourceProviders.shift(); + if (!scriptProvider) { + continue; + } + const sources = await scriptProvider.getWidgetScriptSources(ignoreCache); + if (sources.length > 0) { + return sources; + } + } + return []; + } + private onSettingsChagned(e: ConfigurationChangeEvent) { + const isLocalConnection = this.notebook.connection.localLaunch; + if (e.affectsConfiguration('python.datascience.widgets.localKernelScriptSources') && isLocalConnection) { + this.rebuildProviders(); + } + if (e.affectsConfiguration('python.datascience.widgets.remoteKernelScriptSources') && !isLocalConnection) { + this.rebuildProviders(); + } + } + private disposeScriptProviders() { + while (this.scriptProviders && this.scriptProviders.length) { + const item = this.scriptProviders.shift(); + if (item) { + item.dispose(); + } + } + } + private rebuildProviders() { + this.disposeScriptProviders(); + // If we haven't configured anything, then nothing to do here. + if (this.configuredScriptSources.length === 0) { + return; + } + if (this.notebook.connection.localLaunch) { + this.scriptProviders = [ + new LocalWidgetScriptSourceProvider( + this.notebook, + this.localResourceUriConverter, + this.fs, + this.interpreterService + ) + ]; + } else { + this.scriptProviders = [new RemoteWidgetScriptSourceProvider(this.notebook.connection)]; + } + + // If we're allowed to use CDN providers, then use them, and use in order of preference. + if (this.canUseCDN()) { + const cdnProvider = new CDNWidgetScriptSourceProvider( + this.notebook, + this.configurationSettings, + this.httpClient + ); + + if (this.preferCDNFirst()) { + this.scriptProviders.splice(0, 0, cdnProvider); + } else { + this.scriptProviders.push(cdnProvider); + } + } + } + private canUseCDN(): boolean { + if (!this.notebook) { + return false; + } + const settings = this.configurationSettings.getSettings(undefined); + const scriptSources = this.notebook.connection.localLaunch + ? settings.datascience.widgets.localKernelScriptSources + : settings.datascience.widgets.remoteKernelScriptSources; + + if (scriptSources.length === 0) { + return false; + } + + return scriptSources.indexOf('jsdelivr.com') >= 0 || scriptSources.indexOf('unpkg.com') >= 0; + } + /** + * Whether we should load widgets first from CDN then from else where. + */ + private preferCDNFirst(): boolean { + if (!this.notebook) { + return false; + } + const settings = this.configurationSettings.getSettings(undefined); + const scriptSources = this.notebook.connection.localLaunch + ? settings.datascience.widgets.localKernelScriptSources + : settings.datascience.widgets.remoteKernelScriptSources; + + if (scriptSources.length === 0) { + return false; + } + const item = scriptSources[0]; + return item === 'jsdelivr.com' || item === 'unpkg.com'; + } + + private async configureWidgets(): Promise { + if (this.configuredScriptSources.length !== 0) { + return; + } + if (this.configurationPromise) { + return this.configurationPromise.promise; + } + this.configurationPromise = createDeferred(); + sendTelemetryEvent(Telemetry.IPyWidgetPromptToUseCDN); + const selection = await this.appShell.showInformationMessage( + DataScience.useCDNForWidgets(), + Common.ok(), + Common.cancel() + ); + if (selection === Common.ok()) { + sendTelemetryEvent(Telemetry.IPyWidgetPromptToUseCDNSelection, undefined, { selection: 'ok' }); + // always search local interpreter or attempt to fetch scripts from remote jupyter server as backups. + await this.updateScriptSources(true, ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']); + await this.updateScriptSources(false, ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']); + } else { + const selected = selection === Common.cancel() ? 'cancel' : 'dismissed'; + sendTelemetryEvent(Telemetry.IPyWidgetPromptToUseCDNSelection, undefined, { selection: selected }); + // At a minimum search local interpreter or attempt to fetch scripts from remote jupyter server. + await this.updateScriptSources(true, ['localPythonEnvironment']); + await this.updateScriptSources(false, ['remoteJupyterServer']); + } + this.configurationPromise.resolve(); + } + private async updateScriptSources( + updateLocalKernelSettings: boolean, + scriptSources: LocalKernelScriptSource[] | RemoteKernelScriptSource[] + ) { + const targetSetting = updateLocalKernelSettings + ? 'datascience.widgets.localKernelScriptSources' + : 'datascience.widgets.remoteKernelScriptSources'; + await this.configurationSettings.updateSetting( + targetSetting, + scriptSources, + undefined, + ConfigurationTarget.Global + ); + } +} diff --git a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts index 81dcb12c55ff..5f3b412651c2 100644 --- a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts @@ -29,11 +29,14 @@ export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvi private readonly fs: IFileSystem, private readonly interpreterService: IInterpreterService ) {} - public async getWidgetScriptSource(moduleName: string): Promise { + public async getWidgetScriptSource(moduleName: string): Promise> { const sources = await this.getWidgetScriptSources(); const found = sources.find((item) => item.moduleName.toLowerCase() === moduleName.toLowerCase()); return found || { moduleName }; } + public dispose() { + // Noop. + } public async getWidgetScriptSources(ignoreCache?: boolean): Promise> { if (!ignoreCache && this.cachedWidgetScripts) { return this.cachedWidgetScripts; @@ -82,8 +85,13 @@ export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvi if (!interpreter?.path) { return; } - const interpreterInfo = await this.interpreterService.getInterpreterDetails(interpreter.path); - return interpreterInfo?.sysPrefix; + const interpreterInfo = await this.interpreterService + .getInterpreterDetails(interpreter.path) + .catch(traceError.bind(`Failed to get interpreter details for Kernel/Interpreter ${interpreter.path}`)); + + if (interpreterInfo) { + return interpreterInfo?.sysPrefix; + } } private getInterpreter(): Partial | undefined { let interpreter: undefined | Partial = this.notebook.getMatchingInterpreter(); diff --git a/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts index 0eebaae5741e..e5fd8e312d45 100644 --- a/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/remoteWidgetScriptSourceProvider.ts @@ -12,6 +12,9 @@ import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; */ export class RemoteWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { constructor(private readonly connection: IConnection) {} + public dispose() { + // Noop. + } public async getWidgetScriptSource(moduleName: string): Promise { return { moduleName, scriptUri: `${this.connection.baseUrl}/nbextensions/${moduleName}/index` }; } diff --git a/src/client/datascience/ipywidgets/types.ts b/src/client/datascience/ipywidgets/types.ts index 97fa3c802408..08f9c3ae3e4e 100644 --- a/src/client/datascience/ipywidgets/types.ts +++ b/src/client/datascience/ipywidgets/types.ts @@ -42,13 +42,16 @@ export type WidgetScriptSource = { /** * Used to get an entry for widget (or all of them). */ -export interface IWidgetScriptSourceProvider { +export interface IWidgetScriptSourceProvider extends IDisposable { /** * Return the script path for the requested module. + * This is called when ipywidgets needs a source for a particular widget. */ - getWidgetScriptSource(moduleName: string, moduleVersion: string): Promise; + getWidgetScriptSource(moduleName: string, moduleVersion: string): Promise>; /** * Returns a list of all widgets with their sources. Can be empty. + * This is only called as a way for extension to pre-fetch all known widgest to improve performance. + * But this doesn't mean ipywidgest is being used or user has any widgets. */ getWidgetScriptSources(ignoreCache?: boolean): Promise>; } diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index ad86a28d5408..8e0d89d75779 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1959,7 +1959,7 @@ export interface IEventNamePropertyMapping { */ [Telemetry.IPyWidgetLoadDisabled]: { moduleHash: string; moduleVersion: string }; /** - * Telemetry send when we check whether a 3rd party widget exists on a CDN or not. + * Telemetry sent when we check whether a 3rd party widget exists on a CDN or not. * We capture the time and whether the widget was found or not. */ [Telemetry.IPyWidgetTestAvailabilityOnCDN]: { @@ -1968,4 +1968,15 @@ export interface IEventNamePropertyMapping { // Whether we managed to find the widget on the CDN or not. exists: boolean; }; + /** + * Telemetry sent when we prompt user to use a CDN for IPyWidget scripts. + * This is always sent when we display a prompt. + */ + [Telemetry.IPyWidgetPromptToUseCDN]: never | undefined; + /** + * Telemetry sent when user does somethign with the prompt displsyed to user about using CDN for IPyWidget scripts. + */ + [Telemetry.IPyWidgetPromptToUseCDNSelection]: { + selection: 'ok' | 'cancel' | 'dismissed'; + }; } diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 2aaf9cf38d14..1ed2fc2782f1 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -43,7 +43,9 @@ export class WidgetManagerComponent extends React.Component { // Total time to wait for a script to load. This includes ipywidgets making a request to extension for a Uri of a widget, // then extension replying back with the Uri (max 5 seconds round trip time). // If expires, then Widget downloader will attempt to download with what ever information it has (potentially failing). - timeoutWaitingForScriptToLoad: 5_000, + // Note, we might have a message displayed at the user end (asking for consent to use CDN). + // Hence use 60 seconds. + timeoutWaitingForScriptToLoad: 60_000, // List of widgets that must always be loaded using requirejs instead of using a CDN or the like. widgetsRegisteredInRequireJs: new Set(), // Callback when loading a widget fails. diff --git a/src/datascience-ui/react-common/settingsReactSide.ts b/src/datascience-ui/react-common/settingsReactSide.ts index 861d8243f6eb..72c86ad2cc83 100644 --- a/src/datascience-ui/react-common/settingsReactSide.ts +++ b/src/datascience-ui/react-common/settingsReactSide.ts @@ -67,7 +67,7 @@ export function getDefaultSettings() { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index e4d9843516cf..240544df8a01 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -300,7 +300,7 @@ suite('Python Settings', async () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/color.test.ts b/src/test/datascience/color.test.ts index 86b54303f276..0c6143cfa16d 100644 --- a/src/test/datascience/color.test.ts +++ b/src/test/datascience/color.test.ts @@ -75,7 +75,7 @@ suite('Theme colors', () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index d1c9dafe54f5..f688941d4e86 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -1364,7 +1364,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer { jupyterCommandLineArguments: [], disableJupyterAutoStart: true, loadWidgetScriptsFromThirdPartySource: true, - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/editor-integration/codewatcher.unit.test.ts b/src/test/datascience/editor-integration/codewatcher.unit.test.ts index 1b3009d630d9..79e7a0889952 100644 --- a/src/test/datascience/editor-integration/codewatcher.unit.test.ts +++ b/src/test/datascience/editor-integration/codewatcher.unit.test.ts @@ -95,7 +95,7 @@ suite('DataScience Code Watcher Unit Tests', () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/execution.unit.test.ts b/src/test/datascience/execution.unit.test.ts index 70ee48ed5c58..62e3681b523f 100644 --- a/src/test/datascience/execution.unit.test.ts +++ b/src/test/datascience/execution.unit.test.ts @@ -893,7 +893,7 @@ suite('Jupyter Execution', async () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index e44c81838814..a571dbe70094 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -33,7 +33,7 @@ export function defaultDataScienceSettings(): IDataScienceSettings { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts index f9e70a47fc45..1043eaff07dc 100644 --- a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts +++ b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts @@ -142,7 +142,7 @@ suite('Interactive window command listener', async () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts b/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts new file mode 100644 index 000000000000..71b61654426b --- /dev/null +++ b/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { assert } from 'chai'; +import { anything, instance, mock, verify, when } from 'ts-mockito'; +import { EventEmitter } from 'vscode'; +import { ConfigurationService } from '../../../client/common/configuration/service'; +import { HttpClient } from '../../../client/common/net/httpClient'; +import { IConfigurationService, IHttpClient, WidgetCDNs, WidgetSettings } from '../../../client/common/types'; +import { noop } from '../../../client/common/utils/misc'; +import { CDNWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/cdnWidgetScriptSourceProvider'; +import { IWidgetScriptSourceProvider, WidgetScriptSource } from '../../../client/datascience/ipywidgets/types'; +import { JupyterNotebookBase } from '../../../client/datascience/jupyter/jupyterNotebook'; +import { IConnection, INotebook } from '../../../client/datascience/types'; + +const unpgkUrl = 'https://unpkg.com/'; +const jsdelivrUrl = 'https://cdn.jsdelivr.net/npm/'; + +// tslint:disable: max-func-body-length no-any +suite('Data Science - ipywidget - CDN', () => { + let scriptSourceProvider: IWidgetScriptSourceProvider; + let notebook: INotebook; + let configService: IConfigurationService; + let httpClient: IHttpClient; + let widgetSettings: WidgetSettings; + setup(() => { + notebook = mock(JupyterNotebookBase); + configService = mock(ConfigurationService); + httpClient = mock(HttpClient); + widgetSettings = { localKernelScriptSources: [], remoteKernelScriptSources: [] }; + const settings = { datascience: { widgets: widgetSettings } }; + when(configService.getSettings(anything())).thenReturn(settings as any); + CDNWidgetScriptSourceProvider.validUrls = new Map(); + scriptSourceProvider = new CDNWidgetScriptSourceProvider( + instance(notebook), + instance(configService), + instance(httpClient) + ); + }); + + [true, false].forEach((localLaunch) => { + suite(localLaunch ? 'Local Jupyter Server' : 'Remote Jupyter Server', () => { + setup(() => { + const connection: IConnection = { + baseUrl: '', + localProcExitCode: undefined, + disconnected: new EventEmitter().event, + dispose: noop, + hostName: '', + localLaunch, + token: '' + }; + when(notebook.connection).thenReturn(connection); + }); + test('Return empty list when requesting sources for all known widgets', async () => { + const values = await scriptSourceProvider.getWidgetScriptSources(); + assert.deepEqual(values, []); + }); + test('Return empty list when requesting sources for all known widgets (even with cache ignored)', async () => { + const values = await scriptSourceProvider.getWidgetScriptSources(true); + assert.deepEqual(values, []); + }); + test('Script source will be empty if CDN is not a configured source of widget scripts in settings', async () => { + const value = await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + assert.deepEqual(value, { moduleName: 'HelloWorld' }); + // Should not make any http calls. + verify(httpClient.getContents(anything())).never(); + }); + function updateCDNSettings(...values: WidgetCDNs[]) { + if (localLaunch) { + widgetSettings.localKernelScriptSources = values; + } else { + widgetSettings.remoteKernelScriptSources = values; + } + } + (['unpkg.com', 'jsdelivr.com'] as WidgetCDNs[]).forEach((cdn) => { + suite(cdn, () => { + const moduleName = 'HelloWorld'; + const moduleVersion = '1'; + let expectedSource = ''; + setup(() => { + const baseUrl = cdn === 'unpkg.com' ? unpgkUrl : jsdelivrUrl; + expectedSource = `${baseUrl}${moduleName}@${moduleVersion}/dist/index`; + CDNWidgetScriptSourceProvider.validUrls = new Map(); + }); + test('Get widget source from CDN', async () => { + updateCDNSettings(cdn); + when(httpClient.getContents(anything())).thenResolve(); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { + moduleName: 'HelloWorld', + scriptUri: expectedSource, + source: 'cdn' + }); + verify(httpClient.getContents(anything())).once(); + }); + test('Ensure widgtet script is downloaded once and cached', async () => { + updateCDNSettings(cdn); + when(httpClient.getContents(anything())).thenResolve(); + const expectedValue: WidgetScriptSource = { + moduleName: 'HelloWorld', + scriptUri: expectedSource, + source: 'cdn' + }; + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + assert.deepEqual(value, expectedValue); + const value1 = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + assert.deepEqual(value1, expectedValue); + const value2 = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + assert.deepEqual(value2, expectedValue); + + // Only one http request + verify(httpClient.getContents(anything())).once(); + }); + test('No script source if package does not exist on CDN', async () => { + updateCDNSettings(cdn); + when(httpClient.getContents(anything())).thenReject(new Error('Not found')); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { moduleName: 'HelloWorld' }); + verify(httpClient.getContents(anything())).once(); + }); + test('No script source if package does not exist on both CDNs', async () => { + updateCDNSettings('jsdelivr.com', 'unpkg.com'); + when(httpClient.getContents(anything())).thenReject(new Error('Not found')); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { moduleName: 'HelloWorld' }); + }); + test('Give preference to jsdelivr over unpkg', async () => { + updateCDNSettings('jsdelivr.com', 'unpkg.com'); + when(httpClient.getContents(anything())).thenResolve(); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { + moduleName: 'HelloWorld', + scriptUri: `${jsdelivrUrl}${moduleName}@${moduleVersion}/dist/index`, + source: 'cdn' + }); + verify(httpClient.getContents(anything())).once(); + }); + test('Give preference to unpkg over jsdelivr', async () => { + updateCDNSettings('unpkg.com', 'jsdelivr.com'); + when(httpClient.getContents(anything())).thenResolve(); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { + moduleName: 'HelloWorld', + scriptUri: `${unpgkUrl}${moduleName}@${moduleVersion}/dist/index`, + source: 'cdn' + }); + verify(httpClient.getContents(anything())).once(); + }); + test('Get Script from unpk if jsdelivr fails', async () => { + updateCDNSettings('jsdelivr.com', 'unpkg.com'); + when(httpClient.getContents(anything())).thenCall(async (url: string) => { + if (url.startsWith(jsdelivrUrl)) { + throw new Error('Kaboom'); + } + }); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { + moduleName: 'HelloWorld', + scriptUri: `${unpgkUrl}${moduleName}@${moduleVersion}/dist/index`, + source: 'cdn' + }); + verify(httpClient.getContents(anything())).twice(); + }); + test('Get Script from jsdelivr if unpkg fails', async () => { + updateCDNSettings('unpkg.com', 'jsdelivr.com'); + when(httpClient.getContents(anything())).thenCall(async (url: string) => { + if (url.startsWith(unpgkUrl)) { + throw new Error('Kaboom'); + } + }); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { + moduleName: 'HelloWorld', + scriptUri: `${jsdelivrUrl}${moduleName}@${moduleVersion}/dist/index`, + source: 'cdn' + }); + verify(httpClient.getContents(anything())).twice(); + }); + test('No script source if downloading from both CDNs fail', async () => { + updateCDNSettings('unpkg.com', 'jsdelivr.com'); + when(httpClient.getContents(anything())).thenCall(async () => + Promise.reject(new Error('Kaboom')) + ); + + const value = await scriptSourceProvider.getWidgetScriptSource(moduleName, moduleVersion); + + assert.deepEqual(value, { moduleName: 'HelloWorld' }); + verify(httpClient.getContents(anything())).twice(); + }); + }); + }); + }); + }); +}); diff --git a/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts b/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts new file mode 100644 index 000000000000..6f343b4deda8 --- /dev/null +++ b/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts @@ -0,0 +1,380 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { assert } from 'chai'; +import * as sinon from 'sinon'; +import { anything, deepEqual, instance, mock, verify, when } from 'ts-mockito'; +import { ConfigurationChangeEvent, ConfigurationTarget, EventEmitter } from 'vscode'; +import { ApplicationShell } from '../../../client/common/application/applicationShell'; +import { IApplicationShell, IWorkspaceService } from '../../../client/common/application/types'; +import { WorkspaceService } from '../../../client/common/application/workspace'; +import { ConfigurationService } from '../../../client/common/configuration/service'; +import { HttpClient } from '../../../client/common/net/httpClient'; +import { FileSystem } from '../../../client/common/platform/fileSystem'; +import { IConfigurationService, WidgetSettings } from '../../../client/common/types'; +import { Common, DataScience } from '../../../client/common/utils/localize'; +import { noop } from '../../../client/common/utils/misc'; +import { CDNWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/cdnWidgetScriptSourceProvider'; +import { IPyWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/ipyWidgetScriptSourceProvider'; +import { LocalWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/localWidgetScriptSourceProvider'; +import { RemoteWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/remoteWidgetScriptSourceProvider'; +import { JupyterNotebookBase } from '../../../client/datascience/jupyter/jupyterNotebook'; +import { IConnection, ILocalResourceUriConverter, INotebook } from '../../../client/datascience/types'; +import { InterpreterService } from '../../../client/interpreter/interpreterService'; + +// tslint:disable: no-any no-invalid-this + +suite('Data Science - ipywidget - Widget Script Source Provider', () => { + let scriptSourceProvider: IPyWidgetScriptSourceProvider; + let notebook: INotebook; + let configService: IConfigurationService; + let widgetSettings: WidgetSettings; + let appShell: IApplicationShell; + let workspaceService: IWorkspaceService; + let onDidChangeWorkspaceSettings: EventEmitter; + setup(() => { + notebook = mock(JupyterNotebookBase); + configService = mock(ConfigurationService); + appShell = mock(ApplicationShell); + workspaceService = mock(WorkspaceService); + onDidChangeWorkspaceSettings = new EventEmitter(); + when(workspaceService.onDidChangeConfiguration).thenReturn(onDidChangeWorkspaceSettings.event); + const httpClient = mock(HttpClient); + const resourceConverter = mock(); + const fs = mock(FileSystem); + const interpreterService = mock(InterpreterService); + + widgetSettings = { localKernelScriptSources: [], remoteKernelScriptSources: [] }; + const settings = { datascience: { widgets: widgetSettings } }; + when(configService.getSettings(anything())).thenReturn(settings as any); + CDNWidgetScriptSourceProvider.validUrls = new Map(); + scriptSourceProvider = new IPyWidgetScriptSourceProvider( + instance(notebook), + instance(resourceConverter), + instance(fs), + instance(interpreterService), + instance(appShell), + instance(configService), + instance(workspaceService), + instance(httpClient) + ); + }); + teardown(() => sinon.restore()); + + [true, false].forEach((localLaunch) => { + suite(localLaunch ? 'Local Jupyter Server' : 'Remote Jupyter Server', () => { + setup(() => { + const connection: IConnection = { + baseUrl: '', + localProcExitCode: undefined, + disconnected: new EventEmitter().event, + dispose: noop, + hostName: '', + localLaunch, + token: '' + }; + when(notebook.connection).thenReturn(connection); + }); + test('Return empty list when requesting sources for all known widgets (and nothing is configured)', async () => { + const values = await scriptSourceProvider.getWidgetScriptSources(); + assert.deepEqual(values, []); + }); + test('Prompt to use CDN', async () => { + when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve(); + + await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + verify( + appShell.showInformationMessage(DataScience.useCDNForWidgets(), Common.ok(), Common.cancel()) + ).once(); + }); + function verifyNoCDNUpdatedInSettings() { + // Confirm message was displayed. + verify( + appShell.showInformationMessage(DataScience.useCDNForWidgets(), Common.ok(), Common.cancel()) + ).once(); + + // Confirm settings were updated. + verify( + configService.updateSetting( + 'datascience.widgets.localKernelScriptSources', + deepEqual(['localPythonEnvironment']), + undefined, + ConfigurationTarget.Global + ) + ).once(); + verify( + configService.updateSetting( + 'datascience.widgets.remoteKernelScriptSources', + deepEqual(['remoteJupyterServer']), + undefined, + ConfigurationTarget.Global + ) + ).once(); + } + test('Update settings to not use CDN if prompt is dismissed', async () => { + when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve(); + + await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + verifyNoCDNUpdatedInSettings(); + }); + test('Update settings to not use CDN if Cancel is clicked in prompt', async () => { + when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve( + Common.cancel() as any + ); + + await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + verifyNoCDNUpdatedInSettings(); + }); + test('Update settings to use CDN based on prompt', async () => { + when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve( + Common.ok() as any + ); + + await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + // Confirm message was displayed. + verify( + appShell.showInformationMessage(DataScience.useCDNForWidgets(), Common.ok(), Common.cancel()) + ).once(); + + // Confirm settings were updated. + verify( + configService.updateSetting( + 'datascience.widgets.localKernelScriptSources', + deepEqual(['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']), + undefined, + ConfigurationTarget.Global + ) + ).once(); + verify( + configService.updateSetting( + 'datascience.widgets.remoteKernelScriptSources', + deepEqual(['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']), + undefined, + ConfigurationTarget.Global + ) + ).once(); + }); + test('Attempt to get widget sources from all providers', async () => { + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + } + const localOrRemoteSource = localLaunch + ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources') + : sinon.stub(RemoteWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + + localOrRemoteSource.resolves([]); + cdnSource.resolves([]); + + scriptSourceProvider.initialize(); + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, []); + assert.isTrue(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + }); + test('Attempt to get widget source from all providers', async () => { + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + } + const localOrRemoteSource = localLaunch + ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') + : sinon.stub(RemoteWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + + localOrRemoteSource.resolves({ moduleName: 'HelloWorld' }); + cdnSource.resolves({ moduleName: 'HelloWorld' }); + + scriptSourceProvider.initialize(); + const value = await scriptSourceProvider.getWidgetScriptSource('HelloWorld', '1'); + + assert.deepEqual(value, { moduleName: 'HelloWorld' }); + assert.isTrue(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + }); + test('Widget sources should respect changes to configuration settings', async () => { + // 1. Search CDN then local/remote juptyer. + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + } + const localOrRemoteSource = localLaunch + ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources') + : sinon.stub(RemoteWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + cdnSource.resolves([{ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }]); + + scriptSourceProvider.initialize(); + let values = await scriptSourceProvider.getWidgetScriptSources(); + + // 1. Confirm CDN was given preference. + assert.deepEqual(values, [{ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }]); + assert.isFalse(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + + // 2. Update settings to use local python environment or remote jupyter in case of remote connection. + localOrRemoteSource.reset(); + cdnSource.reset(); + localOrRemoteSource.resolves([{ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }]); + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + } else { + widgetSettings.remoteKernelScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; + } + onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); + + values = await scriptSourceProvider.getWidgetScriptSources(); + + // Confirm Local source is given preference or remote was given preference. + // Ie. we shoudln't have got the module from a CDN. + assert.deepEqual(values, [{ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }]); + assert.isTrue(localOrRemoteSource.calledOnce); + assert.isFalse(cdnSource.calledOnce); + + // 3. Now removing local and remote jupyter, meaning we always want to get from CDN. + localOrRemoteSource.reset(); + cdnSource.reset(); + cdnSource.resolves([{ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }]); + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com']; + } + onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); + + values = await scriptSourceProvider.getWidgetScriptSources(); + + // 2. Confirm we got the module from CDN and not from local/remote. + assert.deepEqual(values, [{ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }]); + assert.isFalse(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + }); + test('Widget source should respect changes to configuration settings', async () => { + // 1. Search CDN then local/remote juptyer. + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + } + const localOrRemoteSource = localLaunch + ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') + : sinon.stub(RemoteWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + cdnSource.resolves({ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }); + + scriptSourceProvider.initialize(); + let value = await scriptSourceProvider.getWidgetScriptSource('', ''); + + // 1. Confirm CDN was given preference. + assert.deepEqual(value, { moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }); + assert.isFalse(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + + // 2. Update settings to use local python environment or remote jupyter in case of remote connection. + localOrRemoteSource.reset(); + cdnSource.reset(); + localOrRemoteSource.resolves({ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }); + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + } else { + widgetSettings.remoteKernelScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; + } + onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); + + value = await scriptSourceProvider.getWidgetScriptSource('', ''); + + // Confirm Local source is given preference or remote was given preference. + // Ie. we shoudln't have got the module from a CDN. + assert.deepEqual(value, { moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }); + assert.isTrue(localOrRemoteSource.calledOnce); + assert.isFalse(cdnSource.calledOnce); + + // 3. Now removing local and remote jupyter, meaning we always want to get from CDN. + localOrRemoteSource.reset(); + cdnSource.reset(); + cdnSource.resolves({ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }); + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com']; + } + onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); + + value = await scriptSourceProvider.getWidgetScriptSource('', ''); + + // 2. Confirm we got the module from CDN and not from local/remote. + assert.deepEqual(value, { moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }); + assert.isFalse(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + }); + test('Widget source should support fall back search', async () => { + // 1. Search CDN and if that fails then get from local/remote. + if (localLaunch) { + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + } else { + widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + } + const localOrRemoteSource = localLaunch + ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') + : sinon.stub(RemoteWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource'); + localOrRemoteSource.resolves({ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }); + cdnSource.resolves({ moduleName: 'moduleCDN' }); + + scriptSourceProvider.initialize(); + const value = await scriptSourceProvider.getWidgetScriptSource('', ''); + + // 1. Confirm CDN was first searched, then local/remote + assert.deepEqual(value, { moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }); + assert.isTrue(localOrRemoteSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + // Confirm we first searched CDN before going to local/remote. + cdnSource.calledBefore(localOrRemoteSource); + }); + test('Widget sources from CDN should be given prefernce', async function () { + if (!localLaunch) { + return this.skip(); + } + widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + const localSource = sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + + localSource.resolves([]); + cdnSource.resolves([{ moduleName: 'module1', scriptUri: '1', source: 'cdn' }]); + + scriptSourceProvider.initialize(); + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, [{ moduleName: 'module1', scriptUri: '1', source: 'cdn' }]); + assert.isFalse(localSource.calledOnce); + assert.isTrue(cdnSource.calledOnce); + }); + test('Widget sources from Local should be given prefernce', async function () { + if (!localLaunch) { + return this.skip(); + } + widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + const localSource = sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); + + localSource.resolves([{ moduleName: 'module1', scriptUri: '1', source: 'cdn' }]); + cdnSource.resolves([]); + + scriptSourceProvider.initialize(); + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, [{ moduleName: 'module1', scriptUri: '1', source: 'cdn' }]); + assert.isTrue(localSource.calledOnce); + assert.isFalse(cdnSource.calledOnce); + }); + }); + }); +}); diff --git a/src/test/datascience/ipywidgets/localWidgetScriptSourceProvider.unit.test.ts b/src/test/datascience/ipywidgets/localWidgetScriptSourceProvider.unit.test.ts new file mode 100644 index 000000000000..71d401cda53b --- /dev/null +++ b/src/test/datascience/ipywidgets/localWidgetScriptSourceProvider.unit.test.ts @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { assert } from 'chai'; +import * as path from 'path'; +import { anything, instance, mock, verify, when } from 'ts-mockito'; +import { Uri } from 'vscode'; +import { FileSystem } from '../../../client/common/platform/fileSystem'; +import { IFileSystem } from '../../../client/common/platform/types'; +import { LocalWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/localWidgetScriptSourceProvider'; +import { IWidgetScriptSourceProvider } from '../../../client/datascience/ipywidgets/types'; +import { JupyterNotebookBase } from '../../../client/datascience/jupyter/jupyterNotebook'; +import { ILocalResourceUriConverter, INotebook } from '../../../client/datascience/types'; +import { IInterpreterService } from '../../../client/interpreter/contracts'; +import { InterpreterService } from '../../../client/interpreter/interpreterService'; + +// tslint:disable: max-func-body-length no-any +suite('Data Science - ipywidget - Local Widget Script Source', () => { + let scriptSourceProvider: IWidgetScriptSourceProvider; + let notebook: INotebook; + let resourceConverter: ILocalResourceUriConverter; + let fs: IFileSystem; + let interpreterService: IInterpreterService; + const filesToLookSerachFor = `*${path.sep}index.js`; + function asVSCodeUri(uri: Uri) { + return `vscodeUri://${uri.fsPath}`; + } + setup(() => { + notebook = mock(JupyterNotebookBase); + resourceConverter = mock(); + fs = mock(FileSystem); + interpreterService = mock(InterpreterService); + when(resourceConverter.asWebviewUri(anything())).thenCall(asVSCodeUri); + scriptSourceProvider = new LocalWidgetScriptSourceProvider( + instance(notebook), + instance(resourceConverter), + instance(fs), + instance(interpreterService) + ); + }); + test('Empty list when there is no kernel associated with notebook', async () => { + when(notebook.getKernelSpec()).thenReturn(); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, []); + }); + test('Empty list when there are no widgets', async () => { + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix: 'sysPrefix', path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, []); + + // Ensure we searched the directories. + verify(fs.search(anything(), anything())).once(); + }); + test('Look for widgets in sysPath of interpreter defined in kernel metadata', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, []); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); + test('Look for widgets in sysPath of kernel', async () => { + const sysPrefix = 'sysPrefix Of Kernel'; + const kernelPath = 'kernel Path.exe'; + when(interpreterService.getInterpreterDetails(kernelPath)).thenResolve({ sysPrefix } as any); + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + + when(notebook.getKernelSpec()).thenReturn({ path: kernelPath } as any); + when(fs.search(anything(), anything())).thenResolve([]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + + assert.deepEqual(values, []); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); + test('Ensure we cache the list of all widgets', async () => { + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix: 'sysPrefix', path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + assert.deepEqual(values, []); + const values1 = await scriptSourceProvider.getWidgetScriptSources(); + assert.deepEqual(values1, []); + const values2 = await scriptSourceProvider.getWidgetScriptSources(); + assert.deepEqual(values2, []); + + // Ensure we search directories once. + verify(fs.search(anything(), anything())).once(); + }); + test('Return widget sources', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([ + 'widget1/index.js', + 'widget2/index.js', + 'widget3/index.js' + ]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + + // Ensure the script paths are properly converted to be used within notebooks. + assert.deepEqual(values, [ + { + moduleName: 'widget1', + source: 'local', + scriptUri: asVSCodeUri(Uri.file(path.join(searchDirectory, 'widget1', 'index'))) + }, + { + moduleName: 'widget2', + source: 'local', + scriptUri: asVSCodeUri(Uri.file(path.join(searchDirectory, 'widget2', 'index'))) + }, + { + moduleName: 'widget3', + source: 'local', + scriptUri: asVSCodeUri(Uri.file(path.join(searchDirectory, 'widget3', 'index'))) + } + ] as any); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + // We must use resource convert to conver paths. + verify(resourceConverter.asWebviewUri(anything())).called(); + }); + test('Ensure we search directory only once (cache results)', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([ + 'widget1/index.js', + 'widget2/index.js', + 'widget3/index.js' + ]); + + const values = await scriptSourceProvider.getWidgetScriptSources(); + assert.equal(values.length, 3); + const values1 = await scriptSourceProvider.getWidgetScriptSources(); + assert.equal(values1.length, 3); + const values2 = await scriptSourceProvider.getWidgetScriptSources(); + assert.equal(values2.length, 3); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); + test('Get source for a specific widget & search in the right place', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([ + 'widget1/index.js', + 'widget2/index.js', + 'widget3/index.js' + ]); + + const value = await scriptSourceProvider.getWidgetScriptSource('widget1', '1'); + + // Ensure the script paths are properly converted to be used within notebooks. + assert.deepEqual(value, { + moduleName: 'widget1', + source: 'local', + scriptUri: asVSCodeUri(Uri.file(path.join(searchDirectory, 'widget1', 'index'))) + }); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); + test('Get source for a specific widget & ensure we search directory once (ensur we cache)', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([ + 'widget1/index.js', + 'widget2/index.js', + 'widget3/index.js' + ]); + + const value = await scriptSourceProvider.getWidgetScriptSource('widget2', '1'); + assert.deepEqual(value, { + moduleName: 'widget2', + source: 'local', + scriptUri: asVSCodeUri(Uri.file(path.join(searchDirectory, 'widget2', 'index'))) + }); + const value1 = await scriptSourceProvider.getWidgetScriptSource('widget2', '1'); + assert.isOk(value1); + const value2 = await scriptSourceProvider.getWidgetScriptSource('widget2', '1'); + assert.deepEqual(value2, value1); + // We should ignore version numbers (when getting widget sources from local fs). + const value3 = await scriptSourceProvider.getWidgetScriptSource('widget2', '1234'); + assert.deepEqual(value3, value1); + + // Ensure we look for the right things in the right place. + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); + test('Return empty source for widgets that cannot be found', async () => { + const sysPrefix = 'sysPrefix Of Python in Metadata'; + const searchDirectory = path.join(sysPrefix, 'share', 'jupyter', 'nbextensions'); + when(notebook.getKernelSpec()).thenReturn({ + metadata: { interpreter: { sysPrefix, path: 'pythonPath' } } + } as any); + when(fs.search(anything(), anything())).thenResolve([ + 'widget1/index.js', + 'widget2/index.js', + 'widget3/index.js' + ]); + + const value = await scriptSourceProvider.getWidgetScriptSource('widgetNotFound', '1'); + assert.deepEqual(value, { + moduleName: 'widgetNotFound' + }); + const value1 = await scriptSourceProvider.getWidgetScriptSource('widgetNotFound', '1'); + assert.isOk(value1); + const value2 = await scriptSourceProvider.getWidgetScriptSource('widgetNotFound', '1'); + assert.deepEqual(value2, value1); + // We should ignore version numbers (when getting widget sources from local fs). + const value3 = await scriptSourceProvider.getWidgetScriptSource('widgetNotFound', '1234'); + assert.deepEqual(value3, value1); + + // Ensure we look for the right things in the right place. + // Also ensure we call once (& cache for subsequent searches). + verify(fs.search(filesToLookSerachFor, searchDirectory)).once(); + }); +}); diff --git a/src/test/datascience/jupyter/serverCache.unit.test.ts b/src/test/datascience/jupyter/serverCache.unit.test.ts index f5d6525dba16..35f83e7b7eaa 100644 --- a/src/test/datascience/jupyter/serverCache.unit.test.ts +++ b/src/test/datascience/jupyter/serverCache.unit.test.ts @@ -51,7 +51,7 @@ suite('Data Science - ServerCache', () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } diff --git a/src/test/datascience/jupyterVariables.unit.test.ts b/src/test/datascience/jupyterVariables.unit.test.ts index 8d99214a9e5c..f597faf86233 100644 --- a/src/test/datascience/jupyterVariables.unit.test.ts +++ b/src/test/datascience/jupyterVariables.unit.test.ts @@ -98,7 +98,7 @@ suite('JupyterVariables', () => { debugJustMyCode: true, variableQueries: [], jupyterCommandLineArguments: [], - ipyWidgets: { + widgets: { localKernelScriptSources: [], remoteKernelScriptSources: [] } From 0f9a4133fe02e40851a33c1b8f340305896a02ac Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 8 Apr 2020 17:14:35 -0700 Subject: [PATCH 15/41] Fix casing --- package.json | 8 +- src/client/common/types.ts | 4 +- .../cdnWidgetScriptSourceProvider.ts | 4 +- .../ipyWidgetScriptSourceProvider.ts | 20 ++--- .../react-common/settingsReactSide.ts | 4 +- .../configSettings.unit.test.ts | 4 +- src/test/datascience/color.test.ts | 4 +- .../datascience/dataScienceIocContainer.ts | 4 +- .../codewatcher.unit.test.ts | 4 +- src/test/datascience/execution.unit.test.ts | 4 +- src/test/datascience/helpers.ts | 4 +- ...eractiveWindowCommandListener.unit.test.ts | 4 +- ...cdnWidgetScriptSourceProvider.unit.test.ts | 6 +- .../ipyWidgetScriptSource.unit.test.ts | 78 +++++++++++++------ .../jupyter/serverCache.unit.test.ts | 4 +- .../datascience/jupyterVariables.unit.test.ts | 4 +- 16 files changed, 94 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index c82037c95725..517446005832 100644 --- a/package.json +++ b/package.json @@ -1606,7 +1606,7 @@ "description": "Allows a user to import a jupyter notebook into a python file anytime one is opened.", "scope": "resource" }, - "python.dataScience.widgets.localKernelScriptSources": { + "python.dataScience.widgets.localConnectionScriptSources": { "type": "array", "default": [], "items": { @@ -1616,10 +1616,10 @@ "localPythonEnvironment" ] }, - "description": "For local Kernels, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", + "description": "For local connections, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", "scope": "machine" }, - "python.dataScience.widgets.remoteKernelScriptSources": { + "python.dataScience.widgets.remoteConnectionScriptSources": { "type": "array", "default": [], "items": { @@ -1629,7 +1629,7 @@ "remoteJupyterServer" ] }, - "description": "For remote Kernels, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", + "description": "For remote connections, this defines the location and order of the sources where scripts files for Widgets are downloaded from (e.g. ipywidgest, bqplot, beakerx, ipyleaflet, etc)", "scope": "machine" }, "python.dataScience.loadWidgetScriptsFromThirdPartySource": { diff --git a/src/client/common/types.ts b/src/client/common/types.ts index b153e49cdbfa..934489ecb477 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -404,12 +404,12 @@ export type WidgetSettings = { * Order of sources to fetch the widget scripts (when running a local kernel). * In this case we might be able to get the widget scripts from the local python environment. */ - localKernelScriptSources: LocalKernelScriptSource[]; + localConnectionScriptSources: LocalKernelScriptSource[]; /** * Order of sources to fetch the widget scripts (when running a remote kernel). * In this case we cannot get widget script from local environment, but might be able to get it from the remote jupyter server. */ - remoteKernelScriptSources: RemoteKernelScriptSource[]; + remoteConnectionScriptSources: RemoteKernelScriptSource[]; }; export const IConfigurationService = Symbol('IConfigurationService'); diff --git a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts index ad95eac6ec4d..7076dc73fb7c 100644 --- a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts @@ -56,9 +56,9 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide private get cdnProviders(): readonly (LocalKernelScriptSource | RemoteKernelScriptSource)[] { const settings = this.configurationSettings.getSettings(undefined); if (this.notebook.connection.localLaunch) { - return settings.datascience.widgets.localKernelScriptSources; + return settings.datascience.widgets.localConnectionScriptSources; } else { - return settings.datascience.widgets.remoteKernelScriptSources; + return settings.datascience.widgets.remoteConnectionScriptSources; } } public static validUrls = new Map(); diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts index a5dbac64adf1..93db1e2dee62 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts @@ -35,9 +35,9 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide private get configuredScriptSources(): readonly (LocalKernelScriptSource | RemoteKernelScriptSource)[] { const settings = this.configurationSettings.getSettings(undefined); if (this.notebook.connection.localLaunch) { - return settings.datascience.widgets.localKernelScriptSources; + return settings.datascience.widgets.localConnectionScriptSources; } else { - return settings.datascience.widgets.remoteKernelScriptSources; + return settings.datascience.widgets.remoteConnectionScriptSources; } } constructor( @@ -107,10 +107,10 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide } private onSettingsChagned(e: ConfigurationChangeEvent) { const isLocalConnection = this.notebook.connection.localLaunch; - if (e.affectsConfiguration('python.datascience.widgets.localKernelScriptSources') && isLocalConnection) { + if (e.affectsConfiguration('python.datasSience.widgets.localConnectionScriptSources') && isLocalConnection) { this.rebuildProviders(); } - if (e.affectsConfiguration('python.datascience.widgets.remoteKernelScriptSources') && !isLocalConnection) { + if (e.affectsConfiguration('python.datasSience.widgets.remoteConnectionScriptSources') && !isLocalConnection) { this.rebuildProviders(); } } @@ -162,8 +162,8 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide } const settings = this.configurationSettings.getSettings(undefined); const scriptSources = this.notebook.connection.localLaunch - ? settings.datascience.widgets.localKernelScriptSources - : settings.datascience.widgets.remoteKernelScriptSources; + ? settings.datascience.widgets.localConnectionScriptSources + : settings.datascience.widgets.remoteConnectionScriptSources; if (scriptSources.length === 0) { return false; @@ -180,8 +180,8 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide } const settings = this.configurationSettings.getSettings(undefined); const scriptSources = this.notebook.connection.localLaunch - ? settings.datascience.widgets.localKernelScriptSources - : settings.datascience.widgets.remoteKernelScriptSources; + ? settings.datascience.widgets.localConnectionScriptSources + : settings.datascience.widgets.remoteConnectionScriptSources; if (scriptSources.length === 0) { return false; @@ -223,8 +223,8 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide scriptSources: LocalKernelScriptSource[] | RemoteKernelScriptSource[] ) { const targetSetting = updateLocalKernelSettings - ? 'datascience.widgets.localKernelScriptSources' - : 'datascience.widgets.remoteKernelScriptSources'; + ? 'dataScience.widgets.localConnectionScriptSources' + : 'dataScience.widgets.remoteConnectionScriptSources'; await this.configurationSettings.updateSetting( targetSetting, scriptSources, diff --git a/src/datascience-ui/react-common/settingsReactSide.ts b/src/datascience-ui/react-common/settingsReactSide.ts index 72c86ad2cc83..acefa7c1b25d 100644 --- a/src/datascience-ui/react-common/settingsReactSide.ts +++ b/src/datascience-ui/react-common/settingsReactSide.ts @@ -68,8 +68,8 @@ export function getDefaultSettings() { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; diff --git a/src/test/common/configSettings/configSettings.unit.test.ts b/src/test/common/configSettings/configSettings.unit.test.ts index 240544df8a01..cdf04f16b863 100644 --- a/src/test/common/configSettings/configSettings.unit.test.ts +++ b/src/test/common/configSettings/configSettings.unit.test.ts @@ -301,8 +301,8 @@ suite('Python Settings', async () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; expected.pythonPath = 'python3'; diff --git a/src/test/datascience/color.test.ts b/src/test/datascience/color.test.ts index 0c6143cfa16d..ec4ddcce9ada 100644 --- a/src/test/datascience/color.test.ts +++ b/src/test/datascience/color.test.ts @@ -76,8 +76,8 @@ suite('Theme colors', () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; configService = TypeMoq.Mock.ofType(); diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index f688941d4e86..ad9bba33861a 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -1365,8 +1365,8 @@ export class DataScienceIocContainer extends UnitTestIocContainer { disableJupyterAutoStart: true, loadWidgetScriptsFromThirdPartySource: true, widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; pythonSettings.jediEnabled = false; diff --git a/src/test/datascience/editor-integration/codewatcher.unit.test.ts b/src/test/datascience/editor-integration/codewatcher.unit.test.ts index 79e7a0889952..adfb210f9aca 100644 --- a/src/test/datascience/editor-integration/codewatcher.unit.test.ts +++ b/src/test/datascience/editor-integration/codewatcher.unit.test.ts @@ -96,8 +96,8 @@ suite('DataScience Code Watcher Unit Tests', () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; debugService.setup((d) => d.activeDebugSession).returns(() => undefined); diff --git a/src/test/datascience/execution.unit.test.ts b/src/test/datascience/execution.unit.test.ts index 62e3681b523f..83ac1ceb6de3 100644 --- a/src/test/datascience/execution.unit.test.ts +++ b/src/test/datascience/execution.unit.test.ts @@ -894,8 +894,8 @@ suite('Jupyter Execution', async () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index a571dbe70094..de0a51313d28 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -34,8 +34,8 @@ export function defaultDataScienceSettings(): IDataScienceSettings { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; } diff --git a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts index 1043eaff07dc..1aff18b927b7 100644 --- a/src/test/datascience/interactiveWindowCommandListener.unit.test.ts +++ b/src/test/datascience/interactiveWindowCommandListener.unit.test.ts @@ -143,8 +143,8 @@ suite('Interactive window command listener', async () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; diff --git a/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts b/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts index 71b61654426b..e9652b3267bb 100644 --- a/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts +++ b/src/test/datascience/ipywidgets/cdnWidgetScriptSourceProvider.unit.test.ts @@ -26,7 +26,7 @@ suite('Data Science - ipywidget - CDN', () => { notebook = mock(JupyterNotebookBase); configService = mock(ConfigurationService); httpClient = mock(HttpClient); - widgetSettings = { localKernelScriptSources: [], remoteKernelScriptSources: [] }; + widgetSettings = { localConnectionScriptSources: [], remoteConnectionScriptSources: [] }; const settings = { datascience: { widgets: widgetSettings } }; when(configService.getSettings(anything())).thenReturn(settings as any); CDNWidgetScriptSourceProvider.validUrls = new Map(); @@ -68,9 +68,9 @@ suite('Data Science - ipywidget - CDN', () => { }); function updateCDNSettings(...values: WidgetCDNs[]) { if (localLaunch) { - widgetSettings.localKernelScriptSources = values; + widgetSettings.localConnectionScriptSources = values; } else { - widgetSettings.remoteKernelScriptSources = values; + widgetSettings.remoteConnectionScriptSources = values; } } (['unpkg.com', 'jsdelivr.com'] as WidgetCDNs[]).forEach((cdn) => { diff --git a/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts b/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts index 6f343b4deda8..5f761a392bfc 100644 --- a/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts +++ b/src/test/datascience/ipywidgets/ipyWidgetScriptSource.unit.test.ts @@ -43,7 +43,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { const fs = mock(FileSystem); const interpreterService = mock(InterpreterService); - widgetSettings = { localKernelScriptSources: [], remoteKernelScriptSources: [] }; + widgetSettings = { localConnectionScriptSources: [], remoteConnectionScriptSources: [] }; const settings = { datascience: { widgets: widgetSettings } }; when(configService.getSettings(anything())).thenReturn(settings as any); CDNWidgetScriptSourceProvider.validUrls = new Map(); @@ -96,7 +96,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { // Confirm settings were updated. verify( configService.updateSetting( - 'datascience.widgets.localKernelScriptSources', + 'dataScience.widgets.localConnectionScriptSources', deepEqual(['localPythonEnvironment']), undefined, ConfigurationTarget.Global @@ -104,7 +104,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { ).once(); verify( configService.updateSetting( - 'datascience.widgets.remoteKernelScriptSources', + 'dataScience.widgets.remoteConnectionScriptSources', deepEqual(['remoteJupyterServer']), undefined, ConfigurationTarget.Global @@ -142,7 +142,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { // Confirm settings were updated. verify( configService.updateSetting( - 'datascience.widgets.localKernelScriptSources', + 'dataScience.widgets.localConnectionScriptSources', deepEqual(['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']), undefined, ConfigurationTarget.Global @@ -150,7 +150,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { ).once(); verify( configService.updateSetting( - 'datascience.widgets.remoteKernelScriptSources', + 'dataScience.widgets.remoteConnectionScriptSources', deepEqual(['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']), undefined, ConfigurationTarget.Global @@ -159,9 +159,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { }); test('Attempt to get widget sources from all providers', async () => { if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = [ + 'jsdelivr.com', + 'unpkg.com', + 'localPythonEnvironment' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; } const localOrRemoteSource = localLaunch ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources') @@ -180,9 +184,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { }); test('Attempt to get widget source from all providers', async () => { if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = [ + 'jsdelivr.com', + 'unpkg.com', + 'localPythonEnvironment' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; } const localOrRemoteSource = localLaunch ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') @@ -202,9 +210,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { test('Widget sources should respect changes to configuration settings', async () => { // 1. Search CDN then local/remote juptyer. if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = [ + 'jsdelivr.com', + 'unpkg.com', + 'localPythonEnvironment' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; } const localOrRemoteSource = localLaunch ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources') @@ -225,9 +237,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { cdnSource.reset(); localOrRemoteSource.resolves([{ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }]); if (localLaunch) { - widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + widgetSettings.localConnectionScriptSources = [ + 'localPythonEnvironment', + 'jsdelivr.com', + 'unpkg.com' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; + widgetSettings.remoteConnectionScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; } onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); @@ -244,9 +260,9 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { cdnSource.reset(); cdnSource.resolves([{ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }]); if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com']; + widgetSettings.localConnectionScriptSources = ['jsdelivr.com']; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com']; } onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); @@ -260,9 +276,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { test('Widget source should respect changes to configuration settings', async () => { // 1. Search CDN then local/remote juptyer. if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = [ + 'jsdelivr.com', + 'unpkg.com', + 'localPythonEnvironment' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; } const localOrRemoteSource = localLaunch ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') @@ -283,9 +303,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { cdnSource.reset(); localOrRemoteSource.resolves({ moduleName: 'moduleLocal', scriptUri: '1', source: 'local' }); if (localLaunch) { - widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + widgetSettings.localConnectionScriptSources = [ + 'localPythonEnvironment', + 'jsdelivr.com', + 'unpkg.com' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; + widgetSettings.remoteConnectionScriptSources = ['remoteJupyterServer', 'jsdelivr.com', 'unpkg.com']; } onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); @@ -302,9 +326,9 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { cdnSource.reset(); cdnSource.resolves({ moduleName: 'moduleCDN', scriptUri: '1', source: 'cdn' }); if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com']; + widgetSettings.localConnectionScriptSources = ['jsdelivr.com']; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com']; } onDidChangeWorkspaceSettings.fire({ affectsConfiguration: () => true }); @@ -318,9 +342,13 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { test('Widget source should support fall back search', async () => { // 1. Search CDN and if that fails then get from local/remote. if (localLaunch) { - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = [ + 'jsdelivr.com', + 'unpkg.com', + 'localPythonEnvironment' + ]; } else { - widgetSettings.remoteKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; + widgetSettings.remoteConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'remoteJupyterServer']; } const localOrRemoteSource = localLaunch ? sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSource') @@ -343,7 +371,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { if (!localLaunch) { return this.skip(); } - widgetSettings.localKernelScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; + widgetSettings.localConnectionScriptSources = ['jsdelivr.com', 'unpkg.com', 'localPythonEnvironment']; const localSource = sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); @@ -361,7 +389,7 @@ suite('Data Science - ipywidget - Widget Script Source Provider', () => { if (!localLaunch) { return this.skip(); } - widgetSettings.localKernelScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; + widgetSettings.localConnectionScriptSources = ['localPythonEnvironment', 'jsdelivr.com', 'unpkg.com']; const localSource = sinon.stub(LocalWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); const cdnSource = sinon.stub(CDNWidgetScriptSourceProvider.prototype, 'getWidgetScriptSources'); diff --git a/src/test/datascience/jupyter/serverCache.unit.test.ts b/src/test/datascience/jupyter/serverCache.unit.test.ts index 35f83e7b7eaa..88930e182b57 100644 --- a/src/test/datascience/jupyter/serverCache.unit.test.ts +++ b/src/test/datascience/jupyter/serverCache.unit.test.ts @@ -52,8 +52,8 @@ suite('Data Science - ServerCache', () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; when(configService.getSettings(anything())).thenReturn(pythonSettings); diff --git a/src/test/datascience/jupyterVariables.unit.test.ts b/src/test/datascience/jupyterVariables.unit.test.ts index f597faf86233..aa47fa9785ed 100644 --- a/src/test/datascience/jupyterVariables.unit.test.ts +++ b/src/test/datascience/jupyterVariables.unit.test.ts @@ -99,8 +99,8 @@ suite('JupyterVariables', () => { variableQueries: [], jupyterCommandLineArguments: [], widgets: { - localKernelScriptSources: [], - remoteKernelScriptSources: [] + localConnectionScriptSources: [], + remoteConnectionScriptSources: [] } }; From 2342dfcf16d769ebab0967cd040a4474b0f15ab0 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 8 Apr 2020 17:44:14 -0700 Subject: [PATCH 16/41] Misc changes --- src/datascience-ui/ipywidgets/container.tsx | 55 ++++++++++++++++++--- src/ipywidgets/src/manager.ts | 22 ++------- src/ipywidgets/src/widgetLoader.ts | 44 +---------------- 3 files changed, 52 insertions(+), 69 deletions(-) diff --git a/src/datascience-ui/ipywidgets/container.tsx b/src/datascience-ui/ipywidgets/container.tsx index 1ed2fc2782f1..13dbcd32249a 100644 --- a/src/datascience-ui/ipywidgets/container.tsx +++ b/src/datascience-ui/ipywidgets/container.tsx @@ -37,6 +37,8 @@ type NonPartial = { export class WidgetManagerComponent extends React.Component { private readonly widgetManager: WidgetManager; private readonly widgetSourceRequests = new Map>(); + private readonly widgetSourcesAlreadyRegistered = new Map(); + private timedoutWaitingForWidgetsToGetLoaded?: boolean; private readonly loaderSettings = { // Whether to allow loading widgets from 3rd party (cdn). loadWidgetScriptsFromThirdPartySource: false, @@ -119,8 +121,31 @@ export class WidgetManagerComponent extends React.Component { const config: { paths: Record } = { paths: {} }; + + const promisesToResolve: Deferred[] = []; sources + .filter((source) => { + // Ignore scripts that have already been registered once before. + if ( + this.widgetSourcesAlreadyRegistered.has(source.moduleName) && + this.widgetSourcesAlreadyRegistered.get(source.moduleName) === source.scriptUri + ) { + return true; + } + this.widgetSourcesAlreadyRegistered.set(source.moduleName, source.scriptUri); + return false; + }) .map((source) => { + if (source.scriptUri) { + // tslint:disable-next-line: no-console + console.log( + `Source for IPyWidget ${source.moduleName} found in ${source.source} @ ${source.scriptUri}.` + ); + } else { + // tslint:disable-next-line: no-console + console.error(`Source for IPyWidget ${source.moduleName} not found.`); + } + // We have fetched the script sources for all of these modules. // In some cases we might not have the source, meaning we don't have it or couldn't find it. let deferred = this.widgetSourceRequests.get(source.moduleName); @@ -128,7 +153,7 @@ export class WidgetManagerComponent extends React.Component { deferred = createDeferred(); this.widgetSourceRequests.set(source.moduleName, deferred); } - deferred.resolve(); + promisesToResolve.push(deferred); return source; }) .filter((source) => source.scriptUri) @@ -140,13 +165,13 @@ export class WidgetManagerComponent extends React.Component { }); requirejs.config(config); + // Now resolve promises (anything that was waiting for modules to get registered can carry on). + promisesToResolve.forEach((item) => item.resolve()); } private registerScriptSourceInRequirejs(source?: WidgetScriptSource) { if (!source) { return; } - // tslint:disable-next-line: no-console - console.log(`Source for IPyWidget ${source.moduleName} ${source.scriptUri ? 'Not found' : source.scriptUri}`); this.registerScriptSourcesInRequirejs([source]); } private createLoadErrorAction( @@ -198,9 +223,24 @@ export class WidgetManagerComponent extends React.Component { if (!deferred) { deferred = createDeferred(); this.widgetSourceRequests.set(moduleName, deferred); + // If we timeout, then resolve this promise. // We don't want the calling code to unnecessary wait for too long. - setTimeout(() => deferred?.resolve(), this.loaderSettings.timeoutWaitingForScriptToLoad); + // Else UI will not get rendered due to blocking ipywidets (at the end of the day ipywidgets gets loaded via kernel) + // And kernel blocks the UI from getting processed. + // Also, if we timeout once, then for subsequent attempts, wait for just 1 second. + // Possible user has ignored some UI prompt and things are now in a state of limbo. + // This way thigns will fall over sooner due to missing widget sources. + const timeoutTime = this.timedoutWaitingForWidgetsToGetLoaded + ? 1_000 + : this.loaderSettings.timeoutWaitingForScriptToLoad; + + setTimeout(() => { + // tslint:disable-next-line: no-console + console.error(`Timeout waiting to get widget source for ${moduleName}, ${moduleVersion}`); + deferred?.resolve(); + this.timedoutWaitingForWidgetsToGetLoaded = true; + }, timeoutTime); } // Whether we have the scripts or not, send message to extension. // Useful telemetry and also we know it was explicity requestd by ipywidgest. @@ -209,10 +249,9 @@ export class WidgetManagerComponent extends React.Component { { moduleName, moduleVersion } ); - return ( - deferred.promise - // tslint:disable-next-line: no-console - .catch((ex) => console.log('Failed to load Widget Script from Extension', ex)) + return deferred.promise.catch((ex) => + // tslint:disable-next-line: no-console + console.error(`Failed to load Widget Script from Extension for for ${moduleName}, ${moduleVersion}`, ex) ); } } diff --git a/src/ipywidgets/src/manager.ts b/src/ipywidgets/src/manager.ts index 5186691a3891..7b585f2e4207 100644 --- a/src/ipywidgets/src/manager.ts +++ b/src/ipywidgets/src/manager.ts @@ -27,7 +27,6 @@ export class WidgetManager extends jupyterlab.WidgetManager { kernel: Kernel.IKernelConnection, el: HTMLElement, private readonly scriptLoader: { - readonly loadWidgetScriptsFromThirdPartySource: boolean; readonly widgetsRegisteredInRequireJs: Readonly>; errorHandler(className: string, moduleName: string, moduleVersion: string, error: any): void; loadWidgetScript(moduleName: string, moduleVersion: string): Promise; @@ -104,35 +103,22 @@ export class WidgetManager extends jupyterlab.WidgetManager { widgetsRegisteredInRequireJs.includes(moduleName) || this.scriptLoader.widgetsRegisteredInRequireJs.has(moduleName); - if (!this.scriptLoader.loadWidgetScriptsFromThirdPartySource && !loadModuleFromRequirejs) { - throw new Error('Loading from 3rd party source is disabled'); - } - if (!loadModuleFromRequirejs) { // If not loading from requirejs, then check if we can. + // Notify the script loader that we need to load the widget module. + // If possible the loader will locate and register that in requirejs for things to start working. await this.scriptLoader.loadWidgetScript(moduleName, moduleVersion); } // If loading module from requirejs (e.g. already bundled), then do not use the cdn. - const useCdn = !loadModuleFromRequirejs && this.scriptLoader.loadWidgetScriptsFromThirdPartySource; - const m = await requireLoader(moduleName, moduleVersion, useCdn); + const m = await requireLoader(moduleName); if (m && m[className]) { return m[className]; } throw originalException; } catch (ex) { this.scriptLoader.errorHandler(className, moduleName, moduleVersion, originalException); - if (this.scriptLoader.loadWidgetScriptsFromThirdPartySource) { - throw originalException; - } else { - // Don't throw exceptions if disabled, else everything stops working. - window.console.error(ex); - // Returning an unresolved promise will prevent Jupyter ipywidgets from doing anything. - // tslint:disable-next-line: promise-must-complete - return new Promise(() => { - // Noop. - }); - } + throw originalException; } }); diff --git a/src/ipywidgets/src/widgetLoader.ts b/src/ipywidgets/src/widgetLoader.ts index c1a1e3310b84..112e7c5b40cf 100644 --- a/src/ipywidgets/src/widgetLoader.ts +++ b/src/ipywidgets/src/widgetLoader.ts @@ -3,33 +3,6 @@ 'use strict'; -// This is the magic that allows us to load 3rd party widgets. -// If a widget isn't found locally, lets try to get the required files from `unpkg.com`. -// For some reason this isn't the default behavior of the html manager. - -// Source borrowed from https://github.com/jupyter-widgets/ipywidgets/blob/master/examples/web3/src/manager.ts - -const cdn = 'https://unpkg.com/'; - -function moduleNameToCDNUrl(moduleName: string, moduleVersion: string) { - let packageName = moduleName; - let fileName = 'index'; // default filename - // if a '/' is present, like 'foo/bar', packageName is changed to 'foo', and path to 'bar' - // We first find the first '/' - let index = moduleName.indexOf('/'); - if (index !== -1 && moduleName[0] === '@') { - // if we have a namespace, it's a different story - // @foo/bar/baz should translate to @foo/bar and baz - // so we find the 2nd '/' - index = moduleName.indexOf('/', index + 1); - } - if (index !== -1) { - fileName = moduleName.substr(index + 1); - packageName = moduleName.substr(0, index); - } - return `${cdn}${packageName}@${moduleVersion}/dist/${fileName}`; -} - // tslint:disable-next-line: no-any async function requirePromise(pkg: string | string[]): Promise { return new Promise((resolve, reject) => { @@ -42,21 +15,6 @@ async function requirePromise(pkg: string | string[]): Promise { } }); } -export function requireLoader(moduleName: string, moduleVersion: string, useCdn: boolean) { - if (useCdn) { - // tslint:disable-next-line: no-any - const requirejs = (window as any).requirejs; - if (requirejs === undefined) { - throw new Error('Requirejs is needed, please ensure it is loaded on the page.'); - } - const conf: { paths: { [key: string]: string } } = { paths: {} }; - conf.paths[moduleName] = moduleNameToCDNUrl(moduleName, moduleVersion); - requirejs.config(conf); - // tslint:disable-next-line: no-console - console.log(`Using CDN to load Widget Module ${moduleName}, version ${moduleVersion}`); - } else { - // tslint:disable-next-line: no-console - console.log(`Not using CDN to load Widget Module ${moduleName}`); - } +export function requireLoader(moduleName: string) { return requirePromise([`${moduleName}`]); } From 4afd7bf9bf9702872b8e28264e44f750243918fd Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 9 Apr 2020 09:50:46 -0700 Subject: [PATCH 17/41] Fixes --- src/client/datascience/constants.ts | 11 +- .../ipywidgets/baseMessageDispatcher.ts | 85 ------------- .../cdnWidgetScriptSourceProvider.ts | 10 +- .../ipywidgets/ipyWidgetScriptSource.ts | 26 ++-- .../ipyWidgetScriptSourceProvider.ts | 20 ++- .../ipyWidgetScriptSourceProviderFactory.ts | 119 ------------------ .../localWidgetScriptSourceProvider.ts | 9 +- src/client/telemetry/index.ts | 64 ++++++---- 8 files changed, 82 insertions(+), 262 deletions(-) delete mode 100644 src/client/datascience/ipywidgets/baseMessageDispatcher.ts delete mode 100644 src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index dd331140cf5a..edd2b7668ec2 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -244,10 +244,6 @@ export enum Telemetry { HashedCellOutputMimeType = 'DS_INTERNAL.HASHED_OUTPUT_MIME_TYPE', HashedCellOutputMimeTypePerf = 'DS_INTERNAL.HASHED_OUTPUT_MIME_TYPE_PERF', HashedNotebookCellOutputMimeTypePerf = 'DS_INTERNAL.HASHED_NOTEBOOK_OUTPUT_MIME_TYPE_PERF', - HashedIPyWidgetNameDiscovered = 'HashedIPyWidgetNameDiscovered', - HashedIPyWidgetNameUsed = 'HashedIPyWidgetNameUsed', - DiscoverIPyWidgetNamesPerf = 'DiscoverIPyWidgetNamesPerf', - JupyterInstalledButNotKernelSpecModule = 'DS_INTERNAL.JUPYTER_INTALLED_BUT_NO_KERNELSPEC_MODULE', PtvsdPromptToInstall = 'DATASCIENCE.PTVSD_PROMPT_TO_INSTALL', PtvsdSuccessfullyInstalled = 'DATASCIENCE.PTVSD_SUCCESSFULLY_INSTALLED', @@ -295,7 +291,12 @@ export enum Telemetry { ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING', IPyWidgetLoadFailure = 'DS_INTERNAL.IPYWIDGET_LOAD_FAILURE', IPyWidgetLoadDisabled = 'DS_INTERNAL.IPYWIDGET_LOAD_DISABLED', - IPyWidgetTestAvailabilityOnCDN = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_CDN', + HashedIPyWidgetNameUsed = 'DS_INTERNAL.IPYWIDGET_USED_BY_USER', + HashedIPyWidgetNameDiscovered = 'DS_INTERNAL.IPYWIDGET_DISCOVERED', + HashedIPyWidgetScriptDiscoveryError = 'DS_INTERNAL.IPYWIDGET_DISCOVERY_ERRORED', + DiscoverIPyWidgetNamesLocalPerf = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_LOCAL', + // DiscoverIPyWidgetNamesRemotePerf = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_REMOTE', + DiscoverIPyWidgetNamesCDNPerf = 'DS_INTERNAL.IPYWIDGET_TEST_AVAILABILITY_ON_CDN', IPyWidgetPromptToUseCDN = 'DS_INTERNAL.IPYWIDGET_PROMPT_TO_USE_CDN', IPyWidgetPromptToUseCDNSelection = 'DS_INTERNAL.IPYWIDGET_PROMPT_TO_USE_CDN_SELECTION' } diff --git a/src/client/datascience/ipywidgets/baseMessageDispatcher.ts b/src/client/datascience/ipywidgets/baseMessageDispatcher.ts deleted file mode 100644 index 4a8f557d47ba..000000000000 --- a/src/client/datascience/ipywidgets/baseMessageDispatcher.ts +++ /dev/null @@ -1,85 +0,0 @@ -// // Copyright (c) Microsoft Corporation. All rights reserved. -// // Licensed under the MIT License. - -// 'use strict'; - -// import * as util from 'util'; -// import { Event, EventEmitter, Uri } from 'vscode'; -// import { traceError, traceInfo } from '../../common/logger'; -// import { IDisposable } from '../../common/types'; -// import { noop } from '../../common/utils/misc'; -// import { deserializeDataViews, serializeDataViews } from '../../common/utils/serializers'; -// import { -// IInteractiveWindowMapping, -// InteractiveWindowMessages, -// IPyWidgetMessages -// } from '../interactive-common/interactiveWindowTypes'; -// import { INotebook, INotebookProvider, KernelSocketInformation } from '../types'; -// import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; - -// // tslint:disable: no-any -// /** -// * This class maps between messages from the react code and talking to a real kernel. -// */ -// export abstract class BaseNotebookMessageListener implements IIPyWidgetMessageDispatcher { -// public get postMessage(): Event { -// return this._postMessageEmitter.event; -// } -// protected notebook?: INotebook; - -// protected readonly disposables: IDisposable[] = []; -// protected disposed = false; -// private _postMessageEmitter = new EventEmitter(); -// constructor(protected readonly notebookProvider: INotebookProvider, public readonly notebookIdentity: Uri) { -// notebookProvider.onNotebookCreated( -// (e) => { -// if (e.identity.toString() === notebookIdentity.toString()) { -// this.initialize().ignoreErrors(); -// } -// }, -// this, -// this.disposables -// ); -// } -// public dispose() { -// this.disposed = true; -// while (this.disposables.length) { -// const disposable = this.disposables.shift(); -// disposable?.dispose(); // NOSONAR -// } -// } - -// public receiveMessage(message: IPyWidgetMessage | { message: InteractiveWindowMessages.RestartKernel }): void { -// traceInfo(`IPyWidgetMessage: ${util.inspect(message)}`); -// switch (message.message) { -// case IPyWidgetMessages.IPyWidgets_Ready: -// this.initialize().ignoreErrors(); -// break; -// default: -// break; -// } -// } -// public async initialize() { -// // If we have any pending targets, register them now -// await this.getNotebook(); -// } -// protected abstract async onNotebookInitialized(): Promise; -// protected raisePostMessage( -// message: IPyWidgetMessages, -// payload: M[T] -// ) { -// this._postMessageEmitter.fire({ message, payload }); -// } -// private async getNotebook(): Promise { -// if (this.notebookIdentity && !this.notebook) { -// this.notebook = await this.notebookProvider.getOrCreateNotebook({ -// identity: this.notebookIdentity, -// getOnly: true -// }); -// if (this.notebook) { -// await this.onNotebookInitialized(); -// } -// } -// return this.notebook; -// } -// } diff --git a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts index 7076dc73fb7c..1713ee5a23b5 100644 --- a/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/cdnWidgetScriptSourceProvider.ts @@ -79,7 +79,7 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide continue; } const scriptUri = moduleNameToCDNUrl(cdnBaseUrl, moduleName, moduleVersion); - const exists = await this.getUrlForWidget(cdn, moduleName, scriptUri); + const exists = await this.getUrlForWidget(cdn, scriptUri); if (exists) { return { moduleName, scriptUri, source: 'cdn' }; } @@ -89,7 +89,7 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide public async getWidgetScriptSources(_ignoreCache?: boolean): Promise> { return []; } - private async getUrlForWidget(cdn: string, moduleName: string, url: string): Promise { + private async getUrlForWidget(cdn: string, url: string): Promise { if (CDNWidgetScriptSourceProvider.validUrls.has(url)) { return CDNWidgetScriptSourceProvider.validUrls.get(url)!; } @@ -99,12 +99,8 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide .getContents(url) .then(() => true) .catch(() => false); - sendTelemetryEvent(Telemetry.IPyWidgetTestAvailabilityOnCDN, stopWatch.elapsedTime, { cdn, exists }); + sendTelemetryEvent(Telemetry.DiscoverIPyWidgetNamesCDNPerf, stopWatch.elapsedTime, { cdn, exists }); - // If exists, then can't contain PII, as its a public module. - if (exists) { - sendTelemetryEvent(Telemetry.HashedIPyWidgetNameUsed, stopWatch.elapsedTime, { hashedName: moduleName }); - } CDNWidgetScriptSourceProvider.validUrls.set(url, exists); return exists; } diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts index e1314ab47d88..ed408268d776 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts @@ -4,7 +4,6 @@ 'use strict'; import type * as jupyterlabService from '@jupyterlab/services'; import type * as serlialize from '@jupyterlab/services/lib/kernel/serialize'; -import { sha256 } from 'hash.js'; import { inject, injectable } from 'inversify'; import { IDisposable } from 'monaco-editor'; import { Event, EventEmitter, Uri } from 'vscode'; @@ -31,6 +30,7 @@ import { KernelSocketInformation } from '../types'; import { IPyWidgetScriptSourceProvider } from './ipyWidgetScriptSourceProvider'; +import { WidgetScriptSource } from './types'; @injectable() export class IPyWidgetScriptSource implements IInteractiveWindowListener { @@ -107,9 +107,6 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { } else if (message === IPyWidgetMessages.IPyWidgets_WidgetScriptSourceRequest) { if (payload) { const { moduleName, moduleVersion } = payload as { moduleName: string; moduleVersion: string }; - sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { - hashedName: sha256().update(moduleName).digest('hex') - }); this.sendWidgetSource(moduleName, moduleVersion).catch( traceError.bind('Failed to send widget sources upon ready') ); @@ -119,6 +116,8 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { /** * Send a list of all widgets and sources to the UI. + * Used to pre-emptively register widgets with requirejs, even if they are not used. + * (this is merely a perf optimization). */ private async sendListOfWidgetSources(ignoreCache?: boolean) { if (!this.notebook || !this.scriptProvider) { @@ -133,6 +132,7 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { } /** * Send the widget script source for a specific widget module & version. + * This is a request made when a widget is certainly used in a notebook. */ private async sendWidgetSource(moduleName: string, moduleVersion: string) { // Standard widgets area already available, hence no need to look for them. @@ -144,11 +144,19 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener { return; } - const source = await this.scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); - this.postEmitter.fire({ - message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, - payload: source - }); + let widgetSource: WidgetScriptSource = { moduleName }; + try { + widgetSource = await this.scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); + } catch (ex) { + traceError('Failed to get widget source due to an error', ex); + sendTelemetryEvent(Telemetry.HashedIPyWidgetScriptDiscoveryError); + } finally { + // Send to UI (even if there's an error) continues instead of hanging while waiting for a response. + this.postEmitter.fire({ + message: IPyWidgetMessages.IPyWidgets_WidgetScriptSourceResponse, + payload: widgetSource + }); + } } private async saveIdentity(args: INotebookIdentity) { this.notebookIdentity = Uri.parse(args.resource); diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts index 93db1e2dee62..1ccc63ea7006 100644 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProvider.ts @@ -3,6 +3,7 @@ 'use strict'; +import { sha256 } from 'hash.js'; import { ConfigurationChangeEvent, ConfigurationTarget } from 'vscode'; import { IApplicationShell, IWorkspaceService } from '../../common/application/types'; import { IFileSystem } from '../../common/platform/types'; @@ -70,19 +71,25 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide // Get script sources in order, if one works, then get out. const scriptSourceProviders = (this.scriptProviders || []).slice(); + let found: WidgetScriptSource = { moduleName }; while (scriptSourceProviders.length) { const scriptProvider = scriptSourceProviders.shift(); if (!scriptProvider) { continue; } const source = await scriptProvider.getWidgetScriptSource(moduleName, moduleVersion); + // If we found the script source, then use that. if (source.scriptUri) { - return source; + found = source; + break; } } - // Tried all providers, nothing worked, hence send an empty response. - return { moduleName }; + sendTelemetryEvent(Telemetry.HashedIPyWidgetNameUsed, undefined, { + hashedName: sha256().update(found.moduleName).digest('hex'), + source: found.source + }); + return found; } public async getWidgetScriptSources(ignoreCache?: boolean | undefined): Promise { // At this point we dont need to configure the settings. @@ -100,6 +107,13 @@ export class IPyWidgetScriptSourceProvider implements IWidgetScriptSourceProvide } const sources = await scriptProvider.getWidgetScriptSources(ignoreCache); if (sources.length > 0) { + sources.forEach((item) => + sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { + hashedName: sha256().update(item.moduleName).digest('hex'), + source: item.source + }) + ); + return sources; } } diff --git a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts b/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts deleted file mode 100644 index 5a4b6408cb6c..000000000000 --- a/src/client/datascience/ipywidgets/ipyWidgetScriptSourceProviderFactory.ts +++ /dev/null @@ -1,119 +0,0 @@ -// // Copyright (c) Microsoft Corporation. All rights reserved. -// // Licensed under the MIT License. - -// 'use strict'; - -// import { inject, injectable } from 'inversify'; -// import { Event, EventEmitter, Uri } from 'vscode'; -// import { IFileSystem } from '../../common/platform/types'; -// import { IDisposable, IDisposableRegistry } from '../../common/types'; -// import { IInterpreterService } from '../../interpreter/contracts'; -// import { IInteractiveWindowProvider, INotebook, INotebookEditorProvider, INotebookProvider } from '../types'; -// import { IPyWidgetMessageDispatcher } from './ipyWidgetMessageDispatcher'; -// import { IPyWidgetScriptSource } from './ipyWidgetScriptSource'; -// import { IIPyWidgetMessageDispatcher, IPyWidgetMessage } from './types'; - -// // /** -// // * This just wraps the iPyWidgetMessageDispatcher class. -// // * When raising events for arrived messages, this class will first raise events for -// // * all messages that arrived before this class was contructed. -// // */ -// // class IPyWidgetScriptSourceProviderFactory implements IIPyWidgetMessageDispatcher { -// // public get postMessage(): Event { -// // return this._postMessageEmitter.event; -// // } -// // private _postMessageEmitter = new EventEmitter(); -// // private readonly disposables: IDisposable[] = []; -// // constructor( -// // private readonly baseMulticaster: IPyWidgetMessageDispatcher, -// // private oldMessages: ReadonlyArray -// // ) { -// // baseMulticaster.postMessage(this.raisePostMessage, this, this.disposables); -// // } - -// // public dispose() { -// // while (this.disposables.length) { -// // const disposable = this.disposables.shift(); -// // disposable?.dispose(); // NOSONAR -// // } -// // } -// // public async initialize() { -// // return this.baseMulticaster.initialize(); -// // } - -// // public receiveMessage(message: IPyWidgetMessage) { -// // this.baseMulticaster.receiveMessage(message); -// // } -// // private raisePostMessage(message: IPyWidgetMessage) { -// // // Send all of the old messages the notebook may not have received. -// // // Also send them in the same order. -// // this.oldMessages.forEach((oldMessage) => { -// // this._postMessageEmitter.fire(oldMessage); -// // }); -// // this.oldMessages = []; -// // this._postMessageEmitter.fire(message); -// // } -// // } - -// /** -// * Creates the dispatcher responsible for handling loading ipywidget widget scripts. -// */ -// @injectable() -// export class IPyWidgetScriptSourceProviderFactory implements IDisposable { -// private readonly scriptSourceProviders = new Map(); -// private disposed = false; -// private disposables: IDisposable[] = []; -// constructor( -// @inject(INotebookProvider) private notebookProvider: INotebookProvider, -// @inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry, -// @inject(IFileSystem) private readonly fs: IFileSystem, -// @inject(INotebookEditorProvider) private readonly notebookEditorProvider: INotebookEditorProvider, -// @inject(IInteractiveWindowProvider) private readonly interactiveWindowProvider: IInteractiveWindowProvider, -// @inject(IInterpreterService) private readonly interpreterService: IInterpreterService -// ) { -// disposableRegistry.push(this); -// notebookProvider.onNotebookCreated((e) => this.trackDisposingOfNotebook(e.notebook), this, this.disposables); - -// notebookProvider.activeNotebooks.forEach((nbPromise) => -// nbPromise.then((notebook) => this.trackDisposingOfNotebook(notebook)).ignoreErrors() -// ); -// } - -// public dispose() { -// this.disposed = true; -// while (this.disposables.length) { -// this.disposables.shift()?.dispose(); // NOSONAR -// } -// } -// public create(identity: Uri): IPyWidgetScriptSource { -// let scriptSource = this.scriptSourceProviders.get(identity.fsPath); -// if (!scriptSource) { -// scriptSource = new IPyWidgetScriptSource( -// this.disposableRegistry, -// this.notebookProvider, -// this.trackDisposingOfNotebook, -// this.notebookEditorProvider, -// this.interactiveWindowProvider, -// this.interpreterService, -// identity -// ); -// this.scriptSourceProviders.set(identity.fsPath, scriptSource); -// this.disposables.push(scriptSource); -// } -// return scriptSource; -// } -// private trackDisposingOfNotebook(notebook: INotebook) { -// if (this.disposed) { -// return; -// } -// notebook.onDisposed( -// () => { -// const item = this.scriptSourceProviders.get(notebook.identity.fsPath); -// item?.dispose(); // NOSONAR -// this.scriptSourceProviders.delete(notebook.identity.fsPath); -// }, -// this, -// this.disposables -// ); -// } -// } diff --git a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts index 5f3b412651c2..5e9ed47d42c6 100644 --- a/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts +++ b/src/client/datascience/ipywidgets/localWidgetScriptSourceProvider.ts @@ -3,13 +3,12 @@ 'use strict'; -import { sha256 } from 'hash.js'; import * as path from 'path'; import { Uri } from 'vscode'; import { traceError } from '../../common/logger'; import { IFileSystem } from '../../common/platform/types'; import { IInterpreterService, PythonInterpreter } from '../../interpreter/contracts'; -import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; +import { captureTelemetry } from '../../telemetry'; import { Telemetry } from '../constants'; import { ILocalResourceUriConverter, INotebook } from '../types'; import { IWidgetScriptSourceProvider, WidgetScriptSource } from './types'; @@ -43,7 +42,7 @@ export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvi } return (this.cachedWidgetScripts = this.getWidgetScriptSourcesWithoutCache()); } - @captureTelemetry(Telemetry.DiscoverIPyWidgetNamesPerf) + @captureTelemetry(Telemetry.DiscoverIPyWidgetNamesLocalPerf) private async getWidgetScriptSourcesWithoutCache(): Promise { const sysPrefix = await this.getSysPrefixOfKernel(); if (!sysPrefix) { @@ -63,10 +62,6 @@ export class LocalWidgetScriptSourceProvider implements IWidgetScriptSourceProvi } const moduleName = parts[0]; - sendTelemetryEvent(Telemetry.HashedIPyWidgetNameDiscovered, undefined, { - hashedName: sha256().update(moduleName).digest('hex') - }); - // Drop the `.js`. const fileUri = Uri.file(path.join(nbextensionsPath, moduleName, 'index')); const scriptUri = this.localResourceUriConverter.asWebviewUri(fileUri).toString(); diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 8e0d89d75779..b03049d579db 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -759,30 +759,6 @@ export interface IEventNamePropertyMapping { hasJupyter: boolean; hasVnd: boolean; }; - /** - * Telemetry event sent with name of a Widget used in a notebook. - * This is used by the user. - */ - [Telemetry.HashedIPyWidgetNameUsed]: { - /** - * Hash of the widget - */ - hashedName: string; - }; - /** - * Telemetry event sent with named of a Widget found in user environment. - * This is what we found on the system. - */ - [Telemetry.HashedIPyWidgetNameDiscovered]: { - /** - * Hash of the widget - */ - hashedName: string; - }; - /** - * Total time taken to discover all IPyWidgets on disc. - */ - [Telemetry.DiscoverIPyWidgetNamesPerf]: never | undefined; [EventName.HASHED_PACKAGE_PERF]: never | undefined; /** * Telemetry event sent with details of selection in prompt @@ -1950,6 +1926,41 @@ export interface IEventNamePropertyMapping { * Telemetry event sent when the ZMQ native binaries do not work. */ [Telemetry.ZMQNotSupported]: undefined | never; + /** + * Telemetry event sent with name of a Widget that is used. + */ + [Telemetry.HashedIPyWidgetNameUsed]: { + /** + * Hash of the widget + */ + hashedName: string; + /** + * Where did we find the hashed name (CDN or user environment or remote jupyter). + */ + source?: 'cdn' | 'local' | 'remote'; + }; + /** + * Telemetry event sent with name of a Widget found. + */ + [Telemetry.HashedIPyWidgetNameDiscovered]: { + /** + * Hash of the widget + */ + hashedName: string; + /** + * Where did we find the hashed name (CDN or user environment or remote jupyter). + */ + source?: 'cdn' | 'local' | 'remote'; + }; + /** + * Total time taken to discover all IPyWidgets on disc. + * This is how long it takes to discover a single widget on disc (from python environment). + */ + [Telemetry.DiscoverIPyWidgetNamesLocalPerf]: never | undefined; + /** + * Something went wrong in looking for a widget. + */ + [Telemetry.HashedIPyWidgetScriptDiscoveryError]: never | undefined; /** * Telemetry event sent when an ipywidget module fails to load. Module name is hashed. */ @@ -1959,10 +1970,9 @@ export interface IEventNamePropertyMapping { */ [Telemetry.IPyWidgetLoadDisabled]: { moduleHash: string; moduleVersion: string }; /** - * Telemetry sent when we check whether a 3rd party widget exists on a CDN or not. - * We capture the time and whether the widget was found or not. + * Total time taken to discover a widget script on CDN. */ - [Telemetry.IPyWidgetTestAvailabilityOnCDN]: { + [Telemetry.DiscoverIPyWidgetNamesCDNPerf]: { // The CDN we were testing. cdn: string; // Whether we managed to find the widget on the CDN or not. From ddd1d9d5f66261d6422026cb719557062d170fee Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 9 Apr 2020 10:02:29 -0700 Subject: [PATCH 18/41] Oops --- src/test/datascience/dataScienceIocContainer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index 606729fdc9bf..fc59cd4c72f2 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -1284,7 +1284,8 @@ export class DataScienceIocContainer extends UnitTestIocContainer { show: noop as any, postMessage: noop as any, close: noop, - updateCwd: noop as any + updateCwd: noop as any, + asWebviewUri: (uri) => uri }); } } From f785d9415fcfb18e67abddec616d03958508b724 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 9 Apr 2020 10:22:23 -0700 Subject: [PATCH 19/41] Remove azure ML --- .../webpack.datascience-ui.config.builder.js | 8 - .../interactive-ipynb/nativeEditor.ts | 1 - .../interactive-window/interactiveWindow.ts | 1 - src/ipywidgets/scripts/copyfiles.js | 6 - src/ipywidgets/src/azureml/README.md | 3 - src/ipywidgets/src/azureml/index.js | 192 ------------------ src/ipywidgets/src/azureml/registration.js | 19 -- 7 files changed, 230 deletions(-) delete mode 100644 src/ipywidgets/src/azureml/README.md delete mode 100644 src/ipywidgets/src/azureml/index.js delete mode 100644 src/ipywidgets/src/azureml/registration.js diff --git a/build/webpack/webpack.datascience-ui.config.builder.js b/build/webpack/webpack.datascience-ui.config.builder.js index 6e88bb947d03..05587db4e14c 100644 --- a/build/webpack/webpack.datascience-ui.config.builder.js +++ b/build/webpack/webpack.datascience-ui.config.builder.js @@ -105,14 +105,6 @@ function buildConfiguration(isNotebook) { { from: path.join(constants.ExtensionRootDir, 'node_modules/font-awesome/**/*'), to: path.join(constants.ExtensionRootDir, 'out', 'datascience-ui', 'common', 'node_modules') - }, - { - from: path.join(constants.ExtensionRootDir, 'out/ipywidgets/azureml/azuremlindex.js'), - to: path.join(constants.ExtensionRootDir, 'out', 'datascience-ui', bundleFolder) - }, - { - from: path.join(constants.ExtensionRootDir, 'out/ipywidgets/azureml/azuremlregistration.js'), - to: path.join(constants.ExtensionRootDir, 'out', 'datascience-ui', bundleFolder) } ] ); diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index abad3f7fd372..9d6f8fcadac2 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -202,7 +202,6 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { nativeEditorDir, [ path.join(nativeEditorDir, 'require.js'), - path.join(nativeEditorDir, 'azuremlregistration.js'), path.join(nativeEditorDir, 'ipywidgets.js'), path.join(nativeEditorDir, 'monaco.bundle.js'), path.join(nativeEditorDir, 'commons.initial.bundle.js'), diff --git a/src/client/datascience/interactive-window/interactiveWindow.ts b/src/client/datascience/interactive-window/interactiveWindow.ts index 88b84db91e2b..4286ad90a0ed 100644 --- a/src/client/datascience/interactive-window/interactiveWindow.ts +++ b/src/client/datascience/interactive-window/interactiveWindow.ts @@ -133,7 +133,6 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi historyReactDir, [ path.join(historyReactDir, 'require.js'), - path.join(historyReactDir, 'azuremlregistration.js'), path.join(historyReactDir, 'ipywidgets.js'), path.join(historyReactDir, 'monaco.bundle.js'), path.join(historyReactDir, 'commons.initial.bundle.js'), diff --git a/src/ipywidgets/scripts/copyfiles.js b/src/ipywidgets/scripts/copyfiles.js index 8ca6ba9729a4..19bf24824656 100644 --- a/src/ipywidgets/scripts/copyfiles.js +++ b/src/ipywidgets/scripts/copyfiles.js @@ -6,14 +6,8 @@ const path = require('path'); const fs = require('fs'); const outputDir = path.join(__dirname, '..', '..', '..', 'out/ipywidgets'); -const azureMLDir = path.join(outputDir, 'azureml'); if (!fs.existsSync(outputDir)) { fs.mkdirSync(outputDir); } -if (!fs.existsSync(azureMLDir)) { - fs.mkdirSync(azureMLDir); -} fs.copyFileSync(path.join(__dirname, '../src/widgets.css'), path.join(outputDir, 'widgets.css')); -fs.copyFileSync(path.join(__dirname, '../src/azureml/index.js'), path.join(azureMLDir, 'azuremlindex.js')); -fs.copyFileSync(path.join(__dirname, '../src/azureml/registration.js'), path.join(azureMLDir, 'azuremlregistration.js')); diff --git a/src/ipywidgets/src/azureml/README.md b/src/ipywidgets/src/azureml/README.md deleted file mode 100644 index 996b248b13e8..000000000000 --- a/src/ipywidgets/src/azureml/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This directory contains a copy of the azureml widget extension for jupyter's JS files as of 3/26/2020 - -Longer term we're trying to get the AML team to put this source on http://unpkg instead so we can load it dynamically diff --git a/src/ipywidgets/src/azureml/index.js b/src/ipywidgets/src/azureml/index.js deleted file mode 100644 index 0d0972f1bf62..000000000000 --- a/src/ipywidgets/src/azureml/index.js +++ /dev/null @@ -1,192 +0,0 @@ -define(["@jupyter-widgets/base"],(function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=259)}([function(t,e,r){(function(t,n){var i; -/** - * @license - * Lodash - * Copyright OpenJS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */(function(){var a,o=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",c="__lodash_hash_undefined__",u=500,h="__lodash_placeholder__",f=1,p=2,d=4,g=1,m=2,v=1,y=2,x=4,b=8,_=16,w=32,A=64,C=128,M=256,k=512,I=30,T="...",L=800,S=16,E=1,D=2,P=1/0,O=9007199254740991,z=17976931348623157e292,R=NaN,F=4294967295,N=F-1,j=F>>>1,B=[["ary",C],["bind",v],["bindKey",y],["curry",b],["curryRight",_],["flip",k],["partial",w],["partialRight",A],["rearg",M]],Y="[object Arguments]",V="[object Array]",U="[object AsyncFunction]",H="[object Boolean]",G="[object Date]",q="[object DOMException]",W="[object Error]",Z="[object Function]",X="[object GeneratorFunction]",J="[object Map]",K="[object Number]",Q="[object Null]",$="[object Object]",tt="[object Proxy]",et="[object RegExp]",rt="[object Set]",nt="[object String]",it="[object Symbol]",at="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",lt="[object ArrayBuffer]",ct="[object DataView]",ut="[object Float32Array]",ht="[object Float64Array]",ft="[object Int8Array]",pt="[object Int16Array]",dt="[object Int32Array]",gt="[object Uint8Array]",mt="[object Uint8ClampedArray]",vt="[object Uint16Array]",yt="[object Uint32Array]",xt=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,_t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,wt=/&(?:amp|lt|gt|quot|#39);/g,At=/[&<>"']/g,Ct=RegExp(wt.source),Mt=RegExp(At.source),kt=/<%-([\s\S]+?)%>/g,It=/<%([\s\S]+?)%>/g,Tt=/<%=([\s\S]+?)%>/g,Lt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,St=/^\w*$/,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Dt=/[\\^$.*+?()[\]{}|]/g,Pt=RegExp(Dt.source),Ot=/^\s+|\s+$/g,zt=/^\s+/,Rt=/\s+$/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Nt=/\{\n\/\* \[wrapped with (.+)\] \*/,jt=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Yt=/\\(\\)?/g,Vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ut=/\w*$/,Ht=/^[-+]0x[0-9a-f]+$/i,Gt=/^0b[01]+$/i,qt=/^\[object .+?Constructor\]$/,Wt=/^0o[0-7]+$/i,Zt=/^(?:0|[1-9]\d*)$/,Xt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Jt=/($^)/,Kt=/['\n\r\u2028\u2029\\]/g,Qt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",$t="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",te="[\\ud800-\\udfff]",ee="["+$t+"]",re="["+Qt+"]",ne="\\d+",ie="[\\u2700-\\u27bf]",ae="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+$t+ne+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",le="[^\\ud800-\\udfff]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",he="[A-Z\\xc0-\\xd6\\xd8-\\xde]",fe="(?:"+ae+"|"+oe+")",pe="(?:"+he+"|"+oe+")",de="(?:"+re+"|"+se+")"+"?",ge="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[le,ce,ue].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),me="(?:"+[ie,ce,ue].join("|")+")"+ge,ve="(?:"+[le+re+"?",re,ce,ue,te].join("|")+")",ye=RegExp("['’]","g"),xe=RegExp(re,"g"),be=RegExp(se+"(?="+se+")|"+ve+ge,"g"),_e=RegExp([he+"?"+ae+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[ee,he,"$"].join("|")+")",pe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[ee,he+fe,"$"].join("|")+")",he+"?"+fe+"+(?:['’](?:d|ll|m|re|s|t|ve))?",he+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ne,me].join("|"),"g"),we=RegExp("[\\u200d\\ud800-\\udfff"+Qt+"\\ufe0e\\ufe0f]"),Ae=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ce=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Me=-1,ke={};ke[ut]=ke[ht]=ke[ft]=ke[pt]=ke[dt]=ke[gt]=ke[mt]=ke[vt]=ke[yt]=!0,ke[Y]=ke[V]=ke[lt]=ke[H]=ke[ct]=ke[G]=ke[W]=ke[Z]=ke[J]=ke[K]=ke[$]=ke[et]=ke[rt]=ke[nt]=ke[ot]=!1;var Ie={};Ie[Y]=Ie[V]=Ie[lt]=Ie[ct]=Ie[H]=Ie[G]=Ie[ut]=Ie[ht]=Ie[ft]=Ie[pt]=Ie[dt]=Ie[J]=Ie[K]=Ie[$]=Ie[et]=Ie[rt]=Ie[nt]=Ie[it]=Ie[gt]=Ie[mt]=Ie[vt]=Ie[yt]=!0,Ie[W]=Ie[Z]=Ie[ot]=!1;var Te={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Le=parseFloat,Se=parseInt,Ee="object"==typeof t&&t&&t.Object===Object&&t,De="object"==typeof self&&self&&self.Object===Object&&self,Pe=Ee||De||Function("return this")(),Oe=e&&!e.nodeType&&e,ze=Oe&&"object"==typeof n&&n&&!n.nodeType&&n,Re=ze&&ze.exports===Oe,Fe=Re&&Ee.process,Ne=function(){try{var t=ze&&ze.require&&ze.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),je=Ne&&Ne.isArrayBuffer,Be=Ne&&Ne.isDate,Ye=Ne&&Ne.isMap,Ve=Ne&&Ne.isRegExp,Ue=Ne&&Ne.isSet,He=Ne&&Ne.isTypedArray;function Ge(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function qe(t,e,r,n){for(var i=-1,a=null==t?0:t.length;++i-1}function Qe(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function br(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=fr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),wr=fr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Ar(t){return"\\"+Te[t]}function Cr(t){return we.test(t)}function Mr(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function kr(t,e){return function(r){return t(e(r))}}function Ir(t,e){for(var r=-1,n=t.length,i=0,a=[];++r",""":'"',"'":"'"});var Pr=function t(e){var r,n=(e=null==e?Pe:Pr.defaults(Pe.Object(),e,Pr.pick(Pe,Ce))).Array,i=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,ae=n.prototype,oe=$t.prototype,se=ee.prototype,le=e["__core-js_shared__"],ce=oe.toString,ue=se.hasOwnProperty,he=0,fe=(r=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",pe=se.toString,de=ce.call(ee),ge=Pe._,me=re("^"+ce.call(ue).replace(Dt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ve=Re?e.Buffer:a,be=e.Symbol,we=e.Uint8Array,Te=ve?ve.allocUnsafe:a,Ee=kr(ee.getPrototypeOf,ee),De=ee.create,Oe=se.propertyIsEnumerable,ze=ae.splice,Fe=be?be.isConcatSpreadable:a,Ne=be?be.iterator:a,ir=be?be.toStringTag:a,fr=function(){try{var t=Na(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Or=e.clearTimeout!==Pe.clearTimeout&&e.clearTimeout,zr=i&&i.now!==Pe.Date.now&&i.now,Rr=e.setTimeout!==Pe.setTimeout&&e.setTimeout,Fr=te.ceil,Nr=te.floor,jr=ee.getOwnPropertySymbols,Br=ve?ve.isBuffer:a,Yr=e.isFinite,Vr=ae.join,Ur=kr(ee.keys,ee),Hr=te.max,Gr=te.min,qr=i.now,Wr=e.parseInt,Zr=te.random,Xr=ae.reverse,Jr=Na(e,"DataView"),Kr=Na(e,"Map"),Qr=Na(e,"Promise"),$r=Na(e,"Set"),tn=Na(e,"WeakMap"),en=Na(ee,"create"),rn=tn&&new tn,nn={},an=uo(Jr),on=uo(Kr),sn=uo(Qr),ln=uo($r),cn=uo(tn),un=be?be.prototype:a,hn=un?un.valueOf:a,fn=un?un.toString:a;function pn(t){if(Ts(t)&&!vs(t)&&!(t instanceof vn)){if(t instanceof mn)return t;if(ue.call(t,"__wrapped__"))return ho(t)}return new mn(t)}var dn=function(){function t(){}return function(e){if(!Is(e))return{};if(De)return De(e);t.prototype=e;var r=new t;return t.prototype=a,r}}();function gn(){}function mn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=a}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function yn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function zn(t,e,r,n,i,o){var s,l=e&f,c=e&p,u=e&d;if(r&&(s=i?r(t,n,i,o):r(t)),s!==a)return s;if(!Is(t))return t;var h=vs(t);if(h){if(s=function(t){var e=t.length,r=new t.constructor(e);e&&"string"==typeof t[0]&&ue.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!l)return ra(t,s)}else{var g=Ya(t),m=g==Z||g==X;if(_s(t))return Ji(t,l);if(g==$||g==Y||m&&!i){if(s=c||m?{}:Ua(t),!l)return c?function(t,e){return na(t,Ba(t),e)}(t,function(t,e){return t&&na(e,al(e),t)}(s,t)):function(t,e){return na(t,ja(t),e)}(t,En(s,t))}else{if(!Ie[g])return i?t:{};s=function(t,e,r){var n=t.constructor;switch(e){case lt:return Ki(t);case H:case G:return new n(+t);case ct:return function(t,e){var r=e?Ki(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ut:case ht:case ft:case pt:case dt:case gt:case mt:case vt:case yt:return Qi(t,r);case J:return new n;case K:case nt:return new n(t);case et:return function(t){var e=new t.constructor(t.source,Ut.exec(t));return e.lastIndex=t.lastIndex,e}(t);case rt:return new n;case it:return i=t,hn?ee(hn.call(i)):{}}var i}(t,g,l)}}o||(o=new wn);var v=o.get(t);if(v)return v;o.set(t,s),Ps(t)?t.forEach((function(n){s.add(zn(n,e,r,n,t,o))})):Ls(t)&&t.forEach((function(n,i){s.set(i,zn(n,e,r,i,t,o))}));var y=h?a:(u?c?Ea:Sa:c?al:il)(t);return We(y||t,(function(n,i){y&&(n=t[i=n]),Tn(s,i,zn(n,e,r,i,t,o))})),s}function Rn(t,e,r){var n=r.length;if(null==t)return!n;for(t=ee(t);n--;){var i=r[n],o=e[i],s=t[i];if(s===a&&!(i in t)||!o(s))return!1}return!0}function Fn(t,e,r){if("function"!=typeof t)throw new ie(l);return no((function(){t.apply(a,r)}),e)}function Nn(t,e,r,n){var i=-1,a=Ke,s=!0,l=t.length,c=[],u=e.length;if(!l)return c;r&&(e=$e(e,mr(r))),n?(a=Qe,s=!1):e.length>=o&&(a=yr,s=!1,e=new _n(e));t:for(;++i-1},xn.prototype.set=function(t,e){var r=this.__data__,n=Ln(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},bn.prototype.clear=function(){this.size=0,this.__data__={hash:new yn,map:new(Kr||xn),string:new yn}},bn.prototype.delete=function(t){var e=Ra(this,t).delete(t);return this.size-=e?1:0,e},bn.prototype.get=function(t){return Ra(this,t).get(t)},bn.prototype.has=function(t){return Ra(this,t).has(t)},bn.prototype.set=function(t,e){var r=Ra(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},_n.prototype.add=_n.prototype.push=function(t){return this.__data__.set(t,c),this},_n.prototype.has=function(t){return this.__data__.has(t)},wn.prototype.clear=function(){this.__data__=new xn,this.size=0},wn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},wn.prototype.get=function(t){return this.__data__.get(t)},wn.prototype.has=function(t){return this.__data__.has(t)},wn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof xn){var n=r.__data__;if(!Kr||n.length0&&r(s)?e>1?Hn(s,e-1,r,n,i):tr(i,s):n||(i[i.length]=s)}return i}var Gn=sa(),qn=sa(!0);function Wn(t,e){return t&&Gn(t,e,il)}function Zn(t,e){return t&&qn(t,e,il)}function Xn(t,e){return Je(e,(function(e){return Cs(t[e])}))}function Jn(t,e){for(var r=0,n=(e=qi(e,t)).length;null!=t&&re}function ti(t,e){return null!=t&&ue.call(t,e)}function ei(t,e){return null!=t&&e in ee(t)}function ri(t,e,r){for(var i=r?Qe:Ke,o=t[0].length,s=t.length,l=s,c=n(s),u=1/0,h=[];l--;){var f=t[l];l&&e&&(f=$e(f,mr(e))),u=Gr(f.length,u),c[l]=!r&&(e||o>=120&&f.length>=120)?new _n(l&&f):a}f=t[0];var p=-1,d=c[0];t:for(;++p=s)return l;var c=r[n];return l*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)}))}function yi(t,e,r){for(var n=-1,i=e.length,a={};++n-1;)s!==t&&ze.call(s,l,1),ze.call(t,l,1);return t}function bi(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==a){var a=i;Ga(i)?ze.call(t,i,1):Ni(t,i)}}return t}function _i(t,e){return t+Nr(Zr()*(e-t+1))}function wi(t,e){var r="";if(!t||e<1||e>O)return r;do{e%2&&(r+=t),(e=Nr(e/2))&&(t+=t)}while(e);return r}function Ai(t,e){return io($a(t,e,Sl),t+"")}function Ci(t){return Cn(pl(t))}function Mi(t,e){var r=pl(t);return so(r,On(e,0,r.length))}function ki(t,e,r,n){if(!Is(t))return t;for(var i=-1,o=(e=qi(e,t)).length,s=o-1,l=t;null!=l&&++ia?0:a+e),(r=r>a?a:r)<0&&(r+=a),a=e>r?0:r-e>>>0,e>>>=0;for(var o=n(a);++i>>1,o=t[a];null!==o&&!zs(o)&&(r?o<=e:o=o){var u=e?null:wa(t);if(u)return Tr(u);s=!1,i=yr,c=new _n}else c=e?[]:l;t:for(;++n=n?t:Si(t,e,r)}var Xi=Or||function(t){return Pe.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=Te?Te(r):new t.constructor(r);return t.copy(n),n}function Ki(t){var e=new t.constructor(t.byteLength);return new we(e).set(new we(t)),e}function Qi(t,e){var r=e?Ki(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function $i(t,e){if(t!==e){var r=t!==a,n=null===t,i=t==t,o=zs(t),s=e!==a,l=null===e,c=e==e,u=zs(e);if(!l&&!u&&!o&&t>e||o&&s&&c&&!l&&!u||n&&s&&c||!r&&c||!i)return 1;if(!n&&!o&&!u&&t1?r[i-1]:a,s=i>2?r[2]:a;for(o=t.length>3&&"function"==typeof o?(i--,o):a,s&&qa(r[0],r[1],s)&&(o=i<3?a:o,i=1),e=ee(e);++n-1?i[o?e[s]:s]:a}}function fa(t){return La((function(e){var r=e.length,n=r,i=mn.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ie(l);if(i&&!s&&"wrapper"==Pa(o))var s=new mn([],!0)}for(n=s?n:r;++n1&&b.reverse(),f&&ul))return!1;var u=o.get(t);if(u&&o.get(e))return u==e;var h=-1,f=!0,p=r&m?new _n:a;for(o.set(t,e),o.set(e,t);++h-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Ft,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return We(B,(function(r){var n="_."+r[0];e&r[1]&&!Ke(t,n)&&t.push(n)})),t.sort()}(function(t){var e=t.match(Nt);return e?e[1].split(jt):[]}(n),r)))}function oo(t){var e=0,r=0;return function(){var n=qr(),i=S-(n-r);if(r=n,i>0){if(++e>=L)return arguments[0]}else e=0;return t.apply(a,arguments)}}function so(t,e){var r=-1,n=t.length,i=n-1;for(e=e===a?n:e;++r1?t[e-1]:a;return r="function"==typeof r?(t.pop(),r):a,Do(t,r)}));function jo(t){var e=pn(t);return e.__chain__=!0,e}function Bo(t,e){return e(t)}var Yo=La((function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return Pn(e,t)};return!(e>1||this.__actions__.length)&&n instanceof vn&&Ga(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:Bo,args:[i],thisArg:a}),new mn(n,this.__chain__).thru((function(t){return e&&!t.length&&t.push(a),t}))):this.thru(i)}));var Vo=ia((function(t,e,r){ue.call(t,r)?++t[r]:Dn(t,r,1)}));var Uo=ha(mo),Ho=ha(vo);function Go(t,e){return(vs(t)?We:jn)(t,za(e,3))}function qo(t,e){return(vs(t)?Ze:Bn)(t,za(e,3))}var Wo=ia((function(t,e,r){ue.call(t,r)?t[r].push(e):Dn(t,r,[e])}));var Zo=Ai((function(t,e,r){var i=-1,a="function"==typeof e,o=xs(t)?n(t.length):[];return jn(t,(function(t){o[++i]=a?Ge(e,t,r):ni(t,e,r)})),o})),Xo=ia((function(t,e,r){Dn(t,r,e)}));function Jo(t,e){return(vs(t)?$e:fi)(t,za(e,3))}var Ko=ia((function(t,e,r){t[r?0:1].push(e)}),(function(){return[[],[]]}));var Qo=Ai((function(t,e){if(null==t)return[];var r=e.length;return r>1&&qa(t,e[0],e[1])?e=[]:r>2&&qa(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Hn(e,1),[])})),$o=zr||function(){return Pe.Date.now()};function ts(t,e,r){return e=r?a:e,e=t&&null==e?t.length:e,Ca(t,C,a,a,a,a,e)}function es(t,e){var r;if("function"!=typeof e)throw new ie(l);return t=Ys(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=a),r}}var rs=Ai((function(t,e,r){var n=v;if(r.length){var i=Ir(r,Oa(rs));n|=w}return Ca(t,n,e,r,i)})),ns=Ai((function(t,e,r){var n=v|y;if(r.length){var i=Ir(r,Oa(ns));n|=w}return Ca(e,n,t,r,i)}));function is(t,e,r){var n,i,o,s,c,u,h=0,f=!1,p=!1,d=!0;if("function"!=typeof t)throw new ie(l);function g(e){var r=n,o=i;return n=i=a,h=e,s=t.apply(o,r)}function m(t){var r=t-u;return u===a||r>=e||r<0||p&&t-h>=o}function v(){var t=$o();if(m(t))return y(t);c=no(v,function(t){var r=e-(t-u);return p?Gr(r,o-(t-h)):r}(t))}function y(t){return c=a,d&&n?g(t):(n=i=a,s)}function x(){var t=$o(),r=m(t);if(n=arguments,i=this,u=t,r){if(c===a)return function(t){return h=t,c=no(v,e),f?g(t):s}(u);if(p)return Xi(c),c=no(v,e),g(u)}return c===a&&(c=no(v,e)),s}return e=Us(e)||0,Is(r)&&(f=!!r.leading,o=(p="maxWait"in r)?Hr(Us(r.maxWait)||0,e):o,d="trailing"in r?!!r.trailing:d),x.cancel=function(){c!==a&&Xi(c),h=0,n=u=i=c=a},x.flush=function(){return c===a?s:y($o())},x}var as=Ai((function(t,e){return Fn(t,1,e)})),os=Ai((function(t,e,r){return Fn(t,Us(e)||0,r)}));function ss(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(l);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=t.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(ss.Cache||bn),r}function ls(t){if("function"!=typeof t)throw new ie(l);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ss.Cache=bn;var cs=Wi((function(t,e){var r=(e=1==e.length&&vs(e[0])?$e(e[0],mr(za())):$e(Hn(e,1),mr(za()))).length;return Ai((function(n){for(var i=-1,a=Gr(n.length,r);++i=e})),ms=ii(function(){return arguments}())?ii:function(t){return Ts(t)&&ue.call(t,"callee")&&!Oe.call(t,"callee")},vs=n.isArray,ys=je?mr(je):function(t){return Ts(t)&&Qn(t)==lt};function xs(t){return null!=t&&ks(t.length)&&!Cs(t)}function bs(t){return Ts(t)&&xs(t)}var _s=Br||Ul,ws=Be?mr(Be):function(t){return Ts(t)&&Qn(t)==G};function As(t){if(!Ts(t))return!1;var e=Qn(t);return e==W||e==q||"string"==typeof t.message&&"string"==typeof t.name&&!Es(t)}function Cs(t){if(!Is(t))return!1;var e=Qn(t);return e==Z||e==X||e==U||e==tt}function Ms(t){return"number"==typeof t&&t==Ys(t)}function ks(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=O}function Is(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ts(t){return null!=t&&"object"==typeof t}var Ls=Ye?mr(Ye):function(t){return Ts(t)&&Ya(t)==J};function Ss(t){return"number"==typeof t||Ts(t)&&Qn(t)==K}function Es(t){if(!Ts(t)||Qn(t)!=$)return!1;var e=Ee(t);if(null===e)return!0;var r=ue.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==de}var Ds=Ve?mr(Ve):function(t){return Ts(t)&&Qn(t)==et};var Ps=Ue?mr(Ue):function(t){return Ts(t)&&Ya(t)==rt};function Os(t){return"string"==typeof t||!vs(t)&&Ts(t)&&Qn(t)==nt}function zs(t){return"symbol"==typeof t||Ts(t)&&Qn(t)==it}var Rs=He?mr(He):function(t){return Ts(t)&&ks(t.length)&&!!ke[Qn(t)]};var Fs=xa(hi),Ns=xa((function(t,e){return t<=e}));function js(t){if(!t)return[];if(xs(t))return Os(t)?Er(t):ra(t);if(Ne&&t[Ne])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Ne]());var e=Ya(t);return(e==J?Mr:e==rt?Tr:pl)(t)}function Bs(t){return t?(t=Us(t))===P||t===-P?(t<0?-1:1)*z:t==t?t:0:0===t?t:0}function Ys(t){var e=Bs(t),r=e%1;return e==e?r?e-r:e:0}function Vs(t){return t?On(Ys(t),0,F):0}function Us(t){if("number"==typeof t)return t;if(zs(t))return R;if(Is(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Is(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Ot,"");var r=Gt.test(t);return r||Wt.test(t)?Se(t.slice(2),r?2:8):Ht.test(t)?R:+t}function Hs(t){return na(t,al(t))}function Gs(t){return null==t?"":Ri(t)}var qs=aa((function(t,e){if(Ja(e)||xs(e))na(e,il(e),t);else for(var r in e)ue.call(e,r)&&Tn(t,r,e[r])})),Ws=aa((function(t,e){na(e,al(e),t)})),Zs=aa((function(t,e,r,n){na(e,al(e),t,n)})),Xs=aa((function(t,e,r,n){na(e,il(e),t,n)})),Js=La(Pn);var Ks=Ai((function(t,e){t=ee(t);var r=-1,n=e.length,i=n>2?e[2]:a;for(i&&qa(e[0],e[1],i)&&(n=1);++r1),e})),na(t,Ea(t),r),n&&(r=zn(r,f|p|d,Ia));for(var i=e.length;i--;)Ni(r,e[i]);return r}));var cl=La((function(t,e){return null==t?{}:function(t,e){return yi(t,e,(function(e,r){return tl(t,r)}))}(t,e)}));function ul(t,e){if(null==t)return{};var r=$e(Ea(t),(function(t){return[t]}));return e=za(e),yi(t,r,(function(t,r){return e(t,r[0])}))}var hl=Aa(il),fl=Aa(al);function pl(t){return null==t?[]:vr(t,il(t))}var dl=ca((function(t,e,r){return e=e.toLowerCase(),t+(r?gl(e):e)}));function gl(t){return Al(Gs(t).toLowerCase())}function ml(t){return(t=Gs(t))&&t.replace(Xt,_r).replace(xe,"")}var vl=ca((function(t,e,r){return t+(r?"-":"")+e.toLowerCase()})),yl=ca((function(t,e,r){return t+(r?" ":"")+e.toLowerCase()})),xl=la("toLowerCase");var bl=ca((function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}));var _l=ca((function(t,e,r){return t+(r?" ":"")+Al(e)}));var wl=ca((function(t,e,r){return t+(r?" ":"")+e.toUpperCase()})),Al=la("toUpperCase");function Cl(t,e,r){return t=Gs(t),(e=r?a:e)===a?function(t){return Ae.test(t)}(t)?function(t){return t.match(_e)||[]}(t):function(t){return t.match(Bt)||[]}(t):t.match(e)||[]}var Ml=Ai((function(t,e){try{return Ge(t,a,e)}catch(t){return As(t)?t:new Qt(t)}})),kl=La((function(t,e){return We(e,(function(e){e=co(e),Dn(t,e,rs(t[e],t))})),t}));function Il(t){return function(){return t}}var Tl=fa(),Ll=fa(!0);function Sl(t){return t}function El(t){return li("function"==typeof t?t:zn(t,f))}var Dl=Ai((function(t,e){return function(r){return ni(r,t,e)}})),Pl=Ai((function(t,e){return function(r){return ni(t,r,e)}}));function Ol(t,e,r){var n=il(e),i=Xn(e,n);null!=r||Is(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Xn(e,il(e)));var a=!(Is(r)&&"chain"in r&&!r.chain),o=Cs(t);return We(i,(function(r){var n=e[r];t[r]=n,o&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__),i=r.__actions__=ra(this.__actions__);return i.push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,tr([this.value()],arguments))})})),t}function zl(){}var Rl=ma($e),Fl=ma(Xe),Nl=ma(nr);function jl(t){return Wa(t)?hr(co(t)):function(t){return function(e){return Jn(e,t)}}(t)}var Bl=ya(),Yl=ya(!0);function Vl(){return[]}function Ul(){return!1}var Hl=ga((function(t,e){return t+e}),0),Gl=_a("ceil"),ql=ga((function(t,e){return t/e}),1),Wl=_a("floor");var Zl,Xl=ga((function(t,e){return t*e}),1),Jl=_a("round"),Kl=ga((function(t,e){return t-e}),0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(l);return t=Ys(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ts,pn.assign=qs,pn.assignIn=Ws,pn.assignInWith=Zs,pn.assignWith=Xs,pn.at=Js,pn.before=es,pn.bind=rs,pn.bindAll=kl,pn.bindKey=ns,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return vs(t)?t:[t]},pn.chain=jo,pn.chunk=function(t,e,r){e=(r?qa(t,e,r):e===a)?1:Hr(Ys(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,l=n(Fr(i/e));oi?0:i+r),(n=n===a||n>i?i:Ys(n))<0&&(n+=i),n=r>n?0:Vs(n);r>>0)?(t=Gs(t))&&("string"==typeof e||null!=e&&!Ds(e))&&!(e=Ri(e))&&Cr(t)?Zi(Er(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(l);return e=null==e?0:Hr(Ys(e),0),Ai((function(r){var n=r[e],i=Zi(r,0,e);return n&&tr(i,n),Ge(t,this,i)}))},pn.tail=function(t){var e=null==t?0:t.length;return e?Si(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Si(t,0,(e=r||e===a?1:Ys(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?Si(t,(e=n-(e=r||e===a?1:Ys(e)))<0?0:e,n):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Bi(t,za(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Bi(t,za(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(l);return Is(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),is(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Bo,pn.toArray=js,pn.toPairs=hl,pn.toPairsIn=fl,pn.toPath=function(t){return vs(t)?$e(t,co):zs(t)?[t]:ra(lo(Gs(t)))},pn.toPlainObject=Hs,pn.transform=function(t,e,r){var n=vs(t),i=n||_s(t)||Rs(t);if(e=za(e,4),null==r){var a=t&&t.constructor;r=i?n?new a:[]:Is(t)&&Cs(a)?dn(Ee(t)):{}}return(i?We:Wn)(t,(function(t,n,i){return e(r,t,n,i)})),r},pn.unary=function(t){return ts(t,1)},pn.union=To,pn.unionBy=Lo,pn.unionWith=So,pn.uniq=function(t){return t&&t.length?Fi(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Fi(t,za(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:a,t&&t.length?Fi(t,a,e):[]},pn.unset=function(t,e){return null==t||Ni(t,e)},pn.unzip=Eo,pn.unzipWith=Do,pn.update=function(t,e,r){return null==t?t:ji(t,e,Gi(r))},pn.updateWith=function(t,e,r,n){return n="function"==typeof n?n:a,null==t?t:ji(t,e,Gi(r),n)},pn.values=pl,pn.valuesIn=function(t){return null==t?[]:vr(t,al(t))},pn.without=Po,pn.words=Cl,pn.wrap=function(t,e){return us(Gi(e),t)},pn.xor=Oo,pn.xorBy=zo,pn.xorWith=Ro,pn.zip=Fo,pn.zipObject=function(t,e){return Ui(t||[],e||[],Tn)},pn.zipObjectDeep=function(t,e){return Ui(t||[],e||[],ki)},pn.zipWith=No,pn.entries=hl,pn.entriesIn=fl,pn.extend=Ws,pn.extendWith=Zs,Ol(pn,pn),pn.add=Hl,pn.attempt=Ml,pn.camelCase=dl,pn.capitalize=gl,pn.ceil=Gl,pn.clamp=function(t,e,r){return r===a&&(r=e,e=a),r!==a&&(r=(r=Us(r))==r?r:0),e!==a&&(e=(e=Us(e))==e?e:0),On(Us(t),e,r)},pn.clone=function(t){return zn(t,d)},pn.cloneDeep=function(t){return zn(t,f|d)},pn.cloneDeepWith=function(t,e){return zn(t,f|d,e="function"==typeof e?e:a)},pn.cloneWith=function(t,e){return zn(t,d,e="function"==typeof e?e:a)},pn.conformsTo=function(t,e){return null==e||Rn(t,e,il(e))},pn.deburr=ml,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=ql,pn.endsWith=function(t,e,r){t=Gs(t),e=Ri(e);var n=t.length,i=r=r===a?n:On(Ys(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},pn.eq=ps,pn.escape=function(t){return(t=Gs(t))&&Mt.test(t)?t.replace(At,wr):t},pn.escapeRegExp=function(t){return(t=Gs(t))&&Pt.test(t)?t.replace(Dt,"\\$&"):t},pn.every=function(t,e,r){var n=vs(t)?Xe:Yn;return r&&qa(t,e,r)&&(e=a),n(t,za(e,3))},pn.find=Uo,pn.findIndex=mo,pn.findKey=function(t,e){return ar(t,za(e,3),Wn)},pn.findLast=Ho,pn.findLastIndex=vo,pn.findLastKey=function(t,e){return ar(t,za(e,3),Zn)},pn.floor=Wl,pn.forEach=Go,pn.forEachRight=qo,pn.forIn=function(t,e){return null==t?t:Gn(t,za(e,3),al)},pn.forInRight=function(t,e){return null==t?t:qn(t,za(e,3),al)},pn.forOwn=function(t,e){return t&&Wn(t,za(e,3))},pn.forOwnRight=function(t,e){return t&&Zn(t,za(e,3))},pn.get=$s,pn.gt=ds,pn.gte=gs,pn.has=function(t,e){return null!=t&&Va(t,e,ti)},pn.hasIn=tl,pn.head=xo,pn.identity=Sl,pn.includes=function(t,e,r,n){t=xs(t)?t:pl(t),r=r&&!n?Ys(r):0;var i=t.length;return r<0&&(r=Hr(i+r,0)),Os(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:Ys(r);return i<0&&(i=Hr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Bs(e),r===a?(r=e,e=0):r=Bs(r),function(t,e,r){return t>=Gr(e,r)&&t=-O&&t<=O},pn.isSet=Ps,pn.isString=Os,pn.isSymbol=zs,pn.isTypedArray=Rs,pn.isUndefined=function(t){return t===a},pn.isWeakMap=function(t){return Ts(t)&&Ya(t)==ot},pn.isWeakSet=function(t){return Ts(t)&&Qn(t)==st},pn.join=function(t,e){return null==t?"":Vr.call(t,e)},pn.kebabCase=vl,pn.last=Ao,pn.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==a&&(i=(i=Ys(r))<0?Hr(n+i,0):Gr(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):or(t,cr,i,!0)},pn.lowerCase=yl,pn.lowerFirst=xl,pn.lt=Fs,pn.lte=Ns,pn.max=function(t){return t&&t.length?Vn(t,Sl,$n):a},pn.maxBy=function(t,e){return t&&t.length?Vn(t,za(e,2),$n):a},pn.mean=function(t){return ur(t,Sl)},pn.meanBy=function(t,e){return ur(t,za(e,2))},pn.min=function(t){return t&&t.length?Vn(t,Sl,hi):a},pn.minBy=function(t,e){return t&&t.length?Vn(t,za(e,2),hi):a},pn.stubArray=Vl,pn.stubFalse=Ul,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Xl,pn.nth=function(t,e){return t&&t.length?mi(t,Ys(e)):a},pn.noConflict=function(){return Pe._===this&&(Pe._=ge),this},pn.noop=zl,pn.now=$o,pn.pad=function(t,e,r){t=Gs(t);var n=(e=Ys(e))?Sr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return va(Nr(i),r)+t+va(Fr(i),r)},pn.padEnd=function(t,e,r){t=Gs(t);var n=(e=Ys(e))?Sr(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Zr();return Gr(t+i*(e-t+Le("1e-"+((i+"").length-1))),e)}return _i(t,e)},pn.reduce=function(t,e,r){var n=vs(t)?er:pr,i=arguments.length<3;return n(t,za(e,4),r,i,jn)},pn.reduceRight=function(t,e,r){var n=vs(t)?rr:pr,i=arguments.length<3;return n(t,za(e,4),r,i,Bn)},pn.repeat=function(t,e,r){return e=(r?qa(t,e,r):e===a)?1:Ys(e),wi(Gs(t),e)},pn.replace=function(){var t=arguments,e=Gs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var n=-1,i=(e=qi(e,t)).length;for(i||(i=1,t=a);++nO)return[];var r=F,n=Gr(t,F);e=za(e),t-=F;for(var i=gr(n,e);++r=o)return t;var l=r-Sr(n);if(l<1)return n;var c=s?Zi(s,0,l).join(""):t.slice(0,l);if(i===a)return c+n;if(s&&(l+=c.length-l),Ds(i)){if(t.slice(l).search(i)){var u,h=c;for(i.global||(i=re(i.source,Gs(Ut.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var f=u.index;c=c.slice(0,f===a?l:f)}}else if(t.indexOf(Ri(i),l)!=l){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},pn.unescape=function(t){return(t=Gs(t))&&Ct.test(t)?t.replace(wt,Dr):t},pn.uniqueId=function(t){var e=++he;return Gs(t)+e},pn.upperCase=wl,pn.upperFirst=Al,pn.each=Go,pn.eachRight=qo,pn.first=xo,Ol(pn,(Zl={},Wn(pn,(function(t,e){ue.call(pn.prototype,e)||(Zl[e]=t)})),Zl),{chain:!1}),pn.VERSION="4.17.15",We(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){pn[t].placeholder=pn})),We(["drop","take"],(function(t,e){vn.prototype[t]=function(r){r=r===a?1:Hr(Ys(r),0);var n=this.__filtered__&&!e?new vn(this):this.clone();return n.__filtered__?n.__takeCount__=Gr(r,n.__takeCount__):n.__views__.push({size:Gr(r,F),type:t+(n.__dir__<0?"Right":"")}),n},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),We(["filter","map","takeWhile"],(function(t,e){var r=e+1,n=r==E||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:za(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}})),We(["head","last"],(function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}})),We(["initial","tail"],(function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}})),vn.prototype.compact=function(){return this.filter(Sl)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=Ai((function(t,e){return"function"==typeof t?new vn(this):this.map((function(r){return ni(r,t,e)}))})),vn.prototype.reject=function(t){return this.filter(ls(za(t)))},vn.prototype.slice=function(t,e){t=Ys(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==a&&(r=(e=Ys(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(F)},Wn(vn.prototype,(function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=pn[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(pn.prototype[e]=function(){var e=this.__wrapped__,s=n?[1]:arguments,l=e instanceof vn,c=s[0],u=l||vs(e),h=function(t){var e=i.apply(pn,tr([t],s));return n&&f?e[0]:e};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,g=l&&!p;if(!o&&u){e=g?e:new vn(this);var m=t.apply(e,s);return m.__actions__.push({func:Bo,args:[h],thisArg:a}),new mn(m,f)}return d&&g?t.apply(this,s):(m=this.thru(h),d?n?m.value()[0]:m.value():m)})})),We(["pop","push","shift","sort","splice","unshift"],(function(t){var e=ae[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(vs(i)?i:[],t)}return this[r]((function(r){return e.apply(vs(r)?r:[],t)}))}})),Wn(vn.prototype,(function(t,e){var r=pn[e];if(r){var n=r.name+"";ue.call(nn,n)||(nn[n]=[]),nn[n].push({name:e,func:r})}})),nn[pa(a,y).name]=[{name:"wrapper",func:a}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=ra(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ra(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ra(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=vs(t),n=e<0,i=r?t.length:0,a=function(t,e,r){var n=-1,i=r.length;for(;++n=this.__values__.length;return{done:t,value:t?a:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof gn;){var n=ho(r);n.__index__=0,n.__values__=a,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Bo,args:[Io],thisArg:a}),new mn(e,this.__chain__)}return this.thru(Io)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return Yi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Ne&&(pn.prototype[Ne]=function(){return this}),pn}();Pe._=Pr,(i=function(){return Pr}.call(e,r,e,n))===a||(n.exports=i)}).call(this)}).call(this,r(16),r(32)(t))},function(t,e,r){(function(t){t.exports=function(){"use strict";var e,n;function i(){return e.apply(null,arguments)}function a(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function o(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function s(t){return void 0===t}function l(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function c(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function u(t,e){var r,n=[];for(r=0;r>>0,n=0;n0)for(r=0;r=0?r?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var B=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Y=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,V={},U={};function H(t,e,r,n){var i=n;"string"==typeof n&&(i=function(){return this[n]()}),t&&(U[t]=i),e&&(U[e[0]]=function(){return j(i.apply(this,arguments),e[1],e[2])}),r&&(U[r]=function(){return this.localeData().ordinal(i.apply(this,arguments),t)})}function G(t,e){return t.isValid()?(e=q(e,t.localeData()),V[e]=V[e]||function(t){var e,r,n,i=t.match(B);for(e=0,r=i.length;e=0&&Y.test(t);)t=t.replace(Y,n),Y.lastIndex=0,r-=1;return t}var W=/\d/,Z=/\d\d/,X=/\d{3}/,J=/\d{4}/,K=/[+-]?\d{6}/,Q=/\d\d?/,$=/\d\d\d\d?/,tt=/\d\d\d\d\d\d?/,et=/\d{1,3}/,rt=/\d{1,4}/,nt=/[+-]?\d{1,6}/,it=/\d+/,at=/[+-]?\d+/,ot=/Z|[+-]\d\d:?\d\d/gi,st=/Z|[+-]\d\d(?::?\d\d)?/gi,lt=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,ct={};function ut(t,e,r){ct[t]=S(e)?e:function(t,n){return t&&r?r:e}}function ht(t,e){return h(ct,t)?ct[t](e._strict,e._locale):new RegExp(ft(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,(function(t,e,r,n,i){return e||r||n||i}))))}function ft(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}var pt={};function dt(t,e){var r,n=e;for("string"==typeof t&&(t=[t]),l(e)&&(n=function(t,r){r[e]=A(t)}),r=0;r68?1900:2e3)};var Tt,Lt=St("FullYear",!0);function St(t,e){return function(r){return null!=r?(Dt(this,t,r),i.updateOffset(this,e),this):Et(this,t)}}function Et(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function Dt(t,e,r){t.isValid()&&!isNaN(r)&&("FullYear"===e&&It(t.year())&&1===t.month()&&29===t.date()?t._d["set"+(t._isUTC?"UTC":"")+e](r,t.month(),Pt(r,t.month())):t._d["set"+(t._isUTC?"UTC":"")+e](r))}function Pt(t,e){if(isNaN(t)||isNaN(e))return NaN;var r,n=(e%(r=12)+r)%r;return t+=(e-n)/12,1===n?It(t)?29:28:31-n%7%2}Tt=Array.prototype.indexOf?Array.prototype.indexOf:function(t){var e;for(e=0;e=0&&isFinite(s.getFullYear())&&s.setFullYear(t),s}function Ht(t){var e=new Date(Date.UTC.apply(null,arguments));return t<100&&t>=0&&isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t),e}function Gt(t,e,r){var n=7+e-r;return-(7+Ht(t,0,n).getUTCDay()-e)%7+n-1}function qt(t,e,r,n,i){var a,o,s=1+7*(e-1)+(7+r-n)%7+Gt(t,n,i);return s<=0?o=kt(a=t-1)+s:s>kt(t)?(a=t+1,o=s-kt(t)):(a=t,o=s),{year:a,dayOfYear:o}}function Wt(t,e,r){var n,i,a=Gt(t.year(),e,r),o=Math.floor((t.dayOfYear()-a-1)/7)+1;return o<1?n=o+Zt(i=t.year()-1,e,r):o>Zt(t.year(),e,r)?(n=o-Zt(t.year(),e,r),i=t.year()+1):(i=t.year(),n=o),{week:n,year:i}}function Zt(t,e,r){var n=Gt(t,e,r),i=Gt(t+1,e,r);return(kt(t)-n+i)/7}H("w",["ww",2],"wo","week"),H("W",["WW",2],"Wo","isoWeek"),O("week","w"),O("isoWeek","W"),N("week",5),N("isoWeek",5),ut("w",Q),ut("ww",Q,Z),ut("W",Q),ut("WW",Q,Z),gt(["w","ww","W","WW"],(function(t,e,r,n){e[n.substr(0,1)]=A(t)})),H("d",0,"do","day"),H("dd",0,0,(function(t){return this.localeData().weekdaysMin(this,t)})),H("ddd",0,0,(function(t){return this.localeData().weekdaysShort(this,t)})),H("dddd",0,0,(function(t){return this.localeData().weekdays(this,t)})),H("e",0,0,"weekday"),H("E",0,0,"isoWeekday"),O("day","d"),O("weekday","e"),O("isoWeekday","E"),N("day",11),N("weekday",11),N("isoWeekday",11),ut("d",Q),ut("e",Q),ut("E",Q),ut("dd",(function(t,e){return e.weekdaysMinRegex(t)})),ut("ddd",(function(t,e){return e.weekdaysShortRegex(t)})),ut("dddd",(function(t,e){return e.weekdaysRegex(t)})),gt(["dd","ddd","dddd"],(function(t,e,r,n){var i=r._locale.weekdaysParse(t,n,r._strict);null!=i?e.d=i:d(r).invalidWeekday=t})),gt(["d","e","E"],(function(t,e,r,n){e[n]=A(t)}));var Xt="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Jt="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Kt="Su_Mo_Tu_We_Th_Fr_Sa".split("_");function Qt(t,e,r){var n,i,a,o=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)a=p([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(a,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(a,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(a,"").toLocaleLowerCase();return r?"dddd"===e?-1!==(i=Tt.call(this._weekdaysParse,o))?i:null:"ddd"===e?-1!==(i=Tt.call(this._shortWeekdaysParse,o))?i:null:-1!==(i=Tt.call(this._minWeekdaysParse,o))?i:null:"dddd"===e?-1!==(i=Tt.call(this._weekdaysParse,o))?i:-1!==(i=Tt.call(this._shortWeekdaysParse,o))?i:-1!==(i=Tt.call(this._minWeekdaysParse,o))?i:null:"ddd"===e?-1!==(i=Tt.call(this._shortWeekdaysParse,o))?i:-1!==(i=Tt.call(this._weekdaysParse,o))?i:-1!==(i=Tt.call(this._minWeekdaysParse,o))?i:null:-1!==(i=Tt.call(this._minWeekdaysParse,o))?i:-1!==(i=Tt.call(this._weekdaysParse,o))?i:-1!==(i=Tt.call(this._shortWeekdaysParse,o))?i:null}var $t=lt,te=lt,ee=lt;function re(){function t(t,e){return e.length-t.length}var e,r,n,i,a,o=[],s=[],l=[],c=[];for(e=0;e<7;e++)r=p([2e3,1]).day(e),n=this.weekdaysMin(r,""),i=this.weekdaysShort(r,""),a=this.weekdays(r,""),o.push(n),s.push(i),l.push(a),c.push(n),c.push(i),c.push(a);for(o.sort(t),s.sort(t),l.sort(t),c.sort(t),e=0;e<7;e++)s[e]=ft(s[e]),l[e]=ft(l[e]),c[e]=ft(c[e]);this._weekdaysRegex=new RegExp("^("+c.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+o.join("|")+")","i")}function ne(){return this.hours()%12||12}function ie(t,e){H(t,0,0,(function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)}))}function ae(t,e){return e._meridiemParse}H("H",["HH",2],0,"hour"),H("h",["hh",2],0,ne),H("k",["kk",2],0,(function(){return this.hours()||24})),H("hmm",0,0,(function(){return""+ne.apply(this)+j(this.minutes(),2)})),H("hmmss",0,0,(function(){return""+ne.apply(this)+j(this.minutes(),2)+j(this.seconds(),2)})),H("Hmm",0,0,(function(){return""+this.hours()+j(this.minutes(),2)})),H("Hmmss",0,0,(function(){return""+this.hours()+j(this.minutes(),2)+j(this.seconds(),2)})),ie("a",!0),ie("A",!1),O("hour","h"),N("hour",13),ut("a",ae),ut("A",ae),ut("H",Q),ut("h",Q),ut("k",Q),ut("HH",Q,Z),ut("hh",Q,Z),ut("kk",Q,Z),ut("hmm",$),ut("hmmss",tt),ut("Hmm",$),ut("Hmmss",tt),dt(["H","HH"],bt),dt(["k","kk"],(function(t,e,r){var n=A(t);e[bt]=24===n?0:n})),dt(["a","A"],(function(t,e,r){r._isPm=r._locale.isPM(t),r._meridiem=t})),dt(["h","hh"],(function(t,e,r){e[bt]=A(t),d(r).bigHour=!0})),dt("hmm",(function(t,e,r){var n=t.length-2;e[bt]=A(t.substr(0,n)),e[_t]=A(t.substr(n)),d(r).bigHour=!0})),dt("hmmss",(function(t,e,r){var n=t.length-4,i=t.length-2;e[bt]=A(t.substr(0,n)),e[_t]=A(t.substr(n,2)),e[wt]=A(t.substr(i)),d(r).bigHour=!0})),dt("Hmm",(function(t,e,r){var n=t.length-2;e[bt]=A(t.substr(0,n)),e[_t]=A(t.substr(n))})),dt("Hmmss",(function(t,e,r){var n=t.length-4,i=t.length-2;e[bt]=A(t.substr(0,n)),e[_t]=A(t.substr(n,2)),e[wt]=A(t.substr(i))}));var oe,se=St("Hours",!0),le={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:zt,monthsShort:Rt,week:{dow:0,doy:6},weekdays:Xt,weekdaysMin:Kt,weekdaysShort:Jt,meridiemParse:/[ap]\.?m?\.?/i},ce={},ue={};function he(t){return t?t.toLowerCase().replace("_","-"):t}function fe(e){var n=null;if(!ce[e]&&void 0!==t&&t&&t.exports)try{n=oe._abbr,r(445)("./"+e),pe(n)}catch(t){}return ce[e]}function pe(t,e){var r;return t&&((r=s(e)?ge(t):de(t,e))?oe=r:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+t+" not found. Did you forget to load it?")),oe._abbr}function de(t,e){if(null!==e){var r,n=le;if(e.abbr=t,null!=ce[t])L("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=ce[t]._config;else if(null!=e.parentLocale)if(null!=ce[e.parentLocale])n=ce[e.parentLocale]._config;else{if(null==(r=fe(e.parentLocale)))return ue[e.parentLocale]||(ue[e.parentLocale]=[]),ue[e.parentLocale].push({name:t,config:e}),null;n=r._config}return ce[t]=new D(E(n,e)),ue[t]&&ue[t].forEach((function(t){de(t.name,t.config)})),pe(t),ce[t]}return delete ce[t],null}function ge(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return oe;if(!a(t)){if(e=fe(t))return e;t=[t]}return function(t){for(var e,r,n,i,a=0;a0;){if(n=fe(i.slice(0,e).join("-")))return n;if(r&&r.length>=e&&C(i,r,!0)>=e-1)break;e--}a++}return oe}(t)}function me(t){var e,r=t._a;return r&&-2===d(t).overflow&&(e=r[yt]<0||r[yt]>11?yt:r[xt]<1||r[xt]>Pt(r[vt],r[yt])?xt:r[bt]<0||r[bt]>24||24===r[bt]&&(0!==r[_t]||0!==r[wt]||0!==r[At])?bt:r[_t]<0||r[_t]>59?_t:r[wt]<0||r[wt]>59?wt:r[At]<0||r[At]>999?At:-1,d(t)._overflowDayOfYear&&(ext)&&(e=xt),d(t)._overflowWeeks&&-1===e&&(e=Ct),d(t)._overflowWeekday&&-1===e&&(e=Mt),d(t).overflow=e),t}function ve(t,e,r){return null!=t?t:null!=e?e:r}function ye(t){var e,r,n,a,o,s=[];if(!t._d){for(n=function(t){var e=new Date(i.now());return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}(t),t._w&&null==t._a[xt]&&null==t._a[yt]&&function(t){var e,r,n,i,a,o,s,l;if(null!=(e=t._w).GG||null!=e.W||null!=e.E)a=1,o=4,r=ve(e.GG,t._a[vt],Wt(Pe(),1,4).year),n=ve(e.W,1),((i=ve(e.E,1))<1||i>7)&&(l=!0);else{a=t._locale._week.dow,o=t._locale._week.doy;var c=Wt(Pe(),a,o);r=ve(e.gg,t._a[vt],c.year),n=ve(e.w,c.week),null!=e.d?((i=e.d)<0||i>6)&&(l=!0):null!=e.e?(i=e.e+a,(e.e<0||e.e>6)&&(l=!0)):i=a}n<1||n>Zt(r,a,o)?d(t)._overflowWeeks=!0:null!=l?d(t)._overflowWeekday=!0:(s=qt(r,n,i,a,o),t._a[vt]=s.year,t._dayOfYear=s.dayOfYear)}(t),null!=t._dayOfYear&&(o=ve(t._a[vt],n[vt]),(t._dayOfYear>kt(o)||0===t._dayOfYear)&&(d(t)._overflowDayOfYear=!0),r=Ht(o,0,t._dayOfYear),t._a[yt]=r.getUTCMonth(),t._a[xt]=r.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=s[e]=n[e];for(;e<7;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[bt]&&0===t._a[_t]&&0===t._a[wt]&&0===t._a[At]&&(t._nextDay=!0,t._a[bt]=0),t._d=(t._useUTC?Ht:Ut).apply(null,s),a=t._useUTC?t._d.getUTCDay():t._d.getDay(),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[bt]=24),t._w&&void 0!==t._w.d&&t._w.d!==a&&(d(t).weekdayMismatch=!0)}}var xe=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,be=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_e=/Z|[+-]\d\d(?::?\d\d)?/,we=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Ae=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ce=/^\/?Date\((\-?\d+)/i;function Me(t){var e,r,n,i,a,o,s=t._i,l=xe.exec(s)||be.exec(s);if(l){for(d(t).iso=!0,e=0,r=we.length;e0&&d(t).unusedInput.push(o),s=s.slice(s.indexOf(r)+r.length),c+=r.length),U[a]?(r?d(t).empty=!1:d(t).unusedTokens.push(a),mt(a,r,t)):t._strict&&!r&&d(t).unusedTokens.push(a);d(t).charsLeftOver=l-c,s.length>0&&d(t).unusedInput.push(s),t._a[bt]<=12&&!0===d(t).bigHour&&t._a[bt]>0&&(d(t).bigHour=void 0),d(t).parsedDateParts=t._a.slice(0),d(t).meridiem=t._meridiem,t._a[bt]=function(t,e,r){var n;return null==r?e:null!=t.meridiemHour?t.meridiemHour(e,r):null!=t.isPM?((n=t.isPM(r))&&e<12&&(e+=12),n||12!==e||(e=0),e):e}(t._locale,t._a[bt],t._meridiem),ye(t),me(t)}else Le(t);else Me(t)}function Ee(t){var e=t._i,r=t._f;return t._locale=t._locale||ge(t._l),null===e||void 0===r&&""===e?m({nullInput:!0}):("string"==typeof e&&(t._i=e=t._locale.preparse(e)),_(e)?new b(me(e)):(c(e)?t._d=e:a(r)?function(t){var e,r,n,i,a;if(0===t._f.length)return d(t).invalidFormat=!0,void(t._d=new Date(NaN));for(i=0;ithis?this:t:m()}));function Re(t,e){var r,n;if(1===e.length&&a(e[0])&&(e=e[0]),!e.length)return Pe();for(r=e[0],n=1;n(a=Zt(t,n,i))&&(e=a),lr.call(this,t,e,r,n,i))}function lr(t,e,r,n,i){var a=qt(t,e,r,n,i),o=Ht(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}H(0,["gg",2],0,(function(){return this.weekYear()%100})),H(0,["GG",2],0,(function(){return this.isoWeekYear()%100})),or("gggg","weekYear"),or("ggggg","weekYear"),or("GGGG","isoWeekYear"),or("GGGGG","isoWeekYear"),O("weekYear","gg"),O("isoWeekYear","GG"),N("weekYear",1),N("isoWeekYear",1),ut("G",at),ut("g",at),ut("GG",Q,Z),ut("gg",Q,Z),ut("GGGG",rt,J),ut("gggg",rt,J),ut("GGGGG",nt,K),ut("ggggg",nt,K),gt(["gggg","ggggg","GGGG","GGGGG"],(function(t,e,r,n){e[n.substr(0,2)]=A(t)})),gt(["gg","GG"],(function(t,e,r,n){e[n]=i.parseTwoDigitYear(t)})),H("Q",0,"Qo","quarter"),O("quarter","Q"),N("quarter",7),ut("Q",W),dt("Q",(function(t,e){e[yt]=3*(A(t)-1)})),H("D",["DD",2],"Do","date"),O("date","D"),N("date",9),ut("D",Q),ut("DD",Q,Z),ut("Do",(function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient})),dt(["D","DD"],xt),dt("Do",(function(t,e){e[xt]=A(t.match(Q)[0])}));var cr=St("Date",!0);H("DDD",["DDDD",3],"DDDo","dayOfYear"),O("dayOfYear","DDD"),N("dayOfYear",4),ut("DDD",et),ut("DDDD",X),dt(["DDD","DDDD"],(function(t,e,r){r._dayOfYear=A(t)})),H("m",["mm",2],0,"minute"),O("minute","m"),N("minute",14),ut("m",Q),ut("mm",Q,Z),dt(["m","mm"],_t);var ur=St("Minutes",!1);H("s",["ss",2],0,"second"),O("second","s"),N("second",15),ut("s",Q),ut("ss",Q,Z),dt(["s","ss"],wt);var hr,fr=St("Seconds",!1);for(H("S",0,0,(function(){return~~(this.millisecond()/100)})),H(0,["SS",2],0,(function(){return~~(this.millisecond()/10)})),H(0,["SSS",3],0,"millisecond"),H(0,["SSSS",4],0,(function(){return 10*this.millisecond()})),H(0,["SSSSS",5],0,(function(){return 100*this.millisecond()})),H(0,["SSSSSS",6],0,(function(){return 1e3*this.millisecond()})),H(0,["SSSSSSS",7],0,(function(){return 1e4*this.millisecond()})),H(0,["SSSSSSSS",8],0,(function(){return 1e5*this.millisecond()})),H(0,["SSSSSSSSS",9],0,(function(){return 1e6*this.millisecond()})),O("millisecond","ms"),N("millisecond",16),ut("S",et,W),ut("SS",et,Z),ut("SSS",et,X),hr="SSSS";hr.length<=9;hr+="S")ut(hr,it);function pr(t,e){e[At]=A(1e3*("0."+t))}for(hr="S";hr.length<=9;hr+="S")dt(hr,pr);var dr=St("Milliseconds",!1);H("z",0,0,"zoneAbbr"),H("zz",0,0,"zoneName");var gr=b.prototype;function mr(t){return t}gr.add=tr,gr.calendar=function(t,e){var r=t||Pe(),n=He(r,this).startOf("day"),a=i.calendarFormat(this,n)||"sameElse",o=e&&(S(e[a])?e[a].call(this,r):e[a]);return this.format(o||this.localeData().calendar(a,this,Pe(r)))},gr.clone=function(){return new b(this)},gr.diff=function(t,e,r){var n,i,a;if(!this.isValid())return NaN;if(!(n=He(t,this)).isValid())return NaN;switch(i=6e4*(n.utcOffset()-this.utcOffset()),e=z(e)){case"year":a=rr(this,n)/12;break;case"month":a=rr(this,n);break;case"quarter":a=rr(this,n)/3;break;case"second":a=(this-n)/1e3;break;case"minute":a=(this-n)/6e4;break;case"hour":a=(this-n)/36e5;break;case"day":a=(this-n-i)/864e5;break;case"week":a=(this-n-i)/6048e5;break;default:a=this-n}return r?a:w(a)},gr.endOf=function(t){return void 0===(t=z(t))||"millisecond"===t?this:("date"===t&&(t="day"),this.startOf(t).add(1,"isoWeek"===t?"week":t).subtract(1,"ms"))},gr.format=function(t){t||(t=this.isUtc()?i.defaultFormatUtc:i.defaultFormat);var e=G(this,t);return this.localeData().postformat(e)},gr.from=function(t,e){return this.isValid()&&(_(t)&&t.isValid()||Pe(t).isValid())?Xe({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},gr.fromNow=function(t){return this.from(Pe(),t)},gr.to=function(t,e){return this.isValid()&&(_(t)&&t.isValid()||Pe(t).isValid())?Xe({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},gr.toNow=function(t){return this.to(Pe(),t)},gr.get=function(t){return S(this[t=z(t)])?this[t]():this},gr.invalidAt=function(){return d(this).overflow},gr.isAfter=function(t,e){var r=_(t)?t:Pe(t);return!(!this.isValid()||!r.isValid())&&("millisecond"===(e=z(s(e)?"millisecond":e))?this.valueOf()>r.valueOf():r.valueOf()9999?G(r,e?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):S(Date.prototype.toISOString)?e?this.toDate().toISOString():new Date(this.valueOf()+60*this.utcOffset()*1e3).toISOString().replace("Z",G(r,"Z")):G(r,e?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")},gr.inspect=function(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t="moment",e="";this.isLocal()||(t=0===this.utcOffset()?"moment.utc":"moment.parseZone",e="Z");var r="["+t+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i=e+'[")]';return this.format(r+n+"-MM-DD[T]HH:mm:ss.SSS"+i)},gr.toJSON=function(){return this.isValid()?this.toISOString():null},gr.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},gr.unix=function(){return Math.floor(this.valueOf()/1e3)},gr.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},gr.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},gr.year=Lt,gr.isLeapYear=function(){return It(this.year())},gr.weekYear=function(t){return sr.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},gr.isoWeekYear=function(t){return sr.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)},gr.quarter=gr.quarters=function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},gr.month=jt,gr.daysInMonth=function(){return Pt(this.year(),this.month())},gr.week=gr.weeks=function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},gr.isoWeek=gr.isoWeeks=function(t){var e=Wt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},gr.weeksInYear=function(){var t=this.localeData()._week;return Zt(this.year(),t.dow,t.doy)},gr.isoWeeksInYear=function(){return Zt(this.year(),1,4)},gr.date=cr,gr.day=gr.days=function(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=function(t,e){return"string"!=typeof t?t:isNaN(t)?"number"==typeof(t=e.weekdaysParse(t))?t:null:parseInt(t,10)}(t,this.localeData()),this.add(t-e,"d")):e},gr.weekday=function(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},gr.isoWeekday=function(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=function(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7},gr.dayOfYear=function(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},gr.hour=gr.hours=se,gr.minute=gr.minutes=ur,gr.second=gr.seconds=fr,gr.millisecond=gr.milliseconds=dr,gr.utcOffset=function(t,e,r){var n,a=this._offset||0;if(!this.isValid())return null!=t?this:NaN;if(null!=t){if("string"==typeof t){if(null===(t=Ue(st,t)))return this}else Math.abs(t)<16&&!r&&(t*=60);return!this._isUTC&&e&&(n=Ge(this)),this._offset=t,this._isUTC=!0,null!=n&&this.add(n,"m"),a!==t&&(!e||this._changeInProgress?$e(this,Xe(t-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,i.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?a:Ge(this)},gr.utc=function(t){return this.utcOffset(0,t)},gr.local=function(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(Ge(this),"m")),this},gr.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var t=Ue(ot,this._i);null!=t?this.utcOffset(t):this.utcOffset(0,!0)}return this},gr.hasAlignedHourOffset=function(t){return!!this.isValid()&&(t=t?Pe(t).utcOffset():0,(this.utcOffset()-t)%60==0)},gr.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},gr.isLocal=function(){return!!this.isValid()&&!this._isUTC},gr.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},gr.isUtc=qe,gr.isUTC=qe,gr.zoneAbbr=function(){return this._isUTC?"UTC":""},gr.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},gr.dates=k("dates accessor is deprecated. Use date instead.",cr),gr.months=k("months accessor is deprecated. Use month instead",jt),gr.years=k("years accessor is deprecated. Use year instead",Lt),gr.zone=k("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",(function(t,e){return null!=t?("string"!=typeof t&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()})),gr.isDSTShifted=k("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",(function(){if(!s(this._isDSTShifted))return this._isDSTShifted;var t={};if(y(t,this),(t=Ee(t))._a){var e=t._isUTC?p(t._a):Pe(t._a);this._isDSTShifted=this.isValid()&&C(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}));var vr=D.prototype;function yr(t,e,r,n){var i=ge(),a=p().set(n,e);return i[r](a,t)}function xr(t,e,r){if(l(t)&&(e=t,t=void 0),t=t||"",null!=e)return yr(t,e,r,"month");var n,i=[];for(n=0;n<12;n++)i[n]=yr(t,n,r,"month");return i}function br(t,e,r,n){"boolean"==typeof t?(l(e)&&(r=e,e=void 0),e=e||""):(r=e=t,t=!1,l(e)&&(r=e,e=void 0),e=e||"");var i,a=ge(),o=t?a._week.dow:0;if(null!=r)return yr(e,(r+o)%7,n,"day");var s=[];for(i=0;i<7;i++)s[i]=yr(e,(i+o)%7,n,"day");return s}vr.calendar=function(t,e,r){var n=this._calendar[t]||this._calendar.sameElse;return S(n)?n.call(e,r):n},vr.longDateFormat=function(t){var e=this._longDateFormat[t],r=this._longDateFormat[t.toUpperCase()];return e||!r?e:(this._longDateFormat[t]=r.replace(/MMMM|MM|DD|dddd/g,(function(t){return t.slice(1)})),this._longDateFormat[t])},vr.invalidDate=function(){return this._invalidDate},vr.ordinal=function(t){return this._ordinal.replace("%d",t)},vr.preparse=mr,vr.postformat=mr,vr.relativeTime=function(t,e,r,n){var i=this._relativeTime[r];return S(i)?i(t,e,r,n):i.replace(/%d/i,t)},vr.pastFuture=function(t,e){var r=this._relativeTime[t>0?"future":"past"];return S(r)?r(e):r.replace(/%s/i,e)},vr.set=function(t){var e,r;for(r in t)S(e=t[r])?this[r]=e:this["_"+r]=e;this._config=t,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)},vr.months=function(t,e){return t?a(this._months)?this._months[t.month()]:this._months[(this._months.isFormat||Ot).test(e)?"format":"standalone"][t.month()]:a(this._months)?this._months:this._months.standalone},vr.monthsShort=function(t,e){return t?a(this._monthsShort)?this._monthsShort[t.month()]:this._monthsShort[Ot.test(e)?"format":"standalone"][t.month()]:a(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},vr.monthsParse=function(t,e,r){var n,i,a;if(this._monthsParseExact)return Ft.call(this,t,e,r);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=p([2e3,n]),r&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),r||this._monthsParse[n]||(a="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(a.replace(".",""),"i")),r&&"MMMM"===e&&this._longMonthsParse[n].test(t))return n;if(r&&"MMM"===e&&this._shortMonthsParse[n].test(t))return n;if(!r&&this._monthsParse[n].test(t))return n}},vr.monthsRegex=function(t){return this._monthsParseExact?(h(this,"_monthsRegex")||Vt.call(this),t?this._monthsStrictRegex:this._monthsRegex):(h(this,"_monthsRegex")||(this._monthsRegex=Yt),this._monthsStrictRegex&&t?this._monthsStrictRegex:this._monthsRegex)},vr.monthsShortRegex=function(t){return this._monthsParseExact?(h(this,"_monthsRegex")||Vt.call(this),t?this._monthsShortStrictRegex:this._monthsShortRegex):(h(this,"_monthsShortRegex")||(this._monthsShortRegex=Bt),this._monthsShortStrictRegex&&t?this._monthsShortStrictRegex:this._monthsShortRegex)},vr.week=function(t){return Wt(t,this._week.dow,this._week.doy).week},vr.firstDayOfYear=function(){return this._week.doy},vr.firstDayOfWeek=function(){return this._week.dow},vr.weekdays=function(t,e){return t?a(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]:a(this._weekdays)?this._weekdays:this._weekdays.standalone},vr.weekdaysMin=function(t){return t?this._weekdaysMin[t.day()]:this._weekdaysMin},vr.weekdaysShort=function(t){return t?this._weekdaysShort[t.day()]:this._weekdaysShort},vr.weekdaysParse=function(t,e,r){var n,i,a;if(this._weekdaysParseExact)return Qt.call(this,t,e,r);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=p([2e3,1]).day(n),r&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(a="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(a.replace(".",""),"i")),r&&"dddd"===e&&this._fullWeekdaysParse[n].test(t))return n;if(r&&"ddd"===e&&this._shortWeekdaysParse[n].test(t))return n;if(r&&"dd"===e&&this._minWeekdaysParse[n].test(t))return n;if(!r&&this._weekdaysParse[n].test(t))return n}},vr.weekdaysRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||re.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(h(this,"_weekdaysRegex")||(this._weekdaysRegex=$t),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)},vr.weekdaysShortRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||re.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(h(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=te),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},vr.weekdaysMinRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||re.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(h(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=ee),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},vr.isPM=function(t){return"p"===(t+"").toLowerCase().charAt(0)},vr.meridiem=function(t,e,r){return t>11?r?"pm":"PM":r?"am":"AM"},pe("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10;return t+(1===A(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th")}}),i.lang=k("moment.lang is deprecated. Use moment.locale instead.",pe),i.langData=k("moment.langData is deprecated. Use moment.localeData instead.",ge);var _r=Math.abs;function wr(t,e,r,n){var i=Xe(e,r);return t._milliseconds+=n*i._milliseconds,t._days+=n*i._days,t._months+=n*i._months,t._bubble()}function Ar(t){return t<0?Math.floor(t):Math.ceil(t)}function Cr(t){return 4800*t/146097}function Mr(t){return 146097*t/4800}function kr(t){return function(){return this.as(t)}}var Ir=kr("ms"),Tr=kr("s"),Lr=kr("m"),Sr=kr("h"),Er=kr("d"),Dr=kr("w"),Pr=kr("M"),Or=kr("y");function zr(t){return function(){return this.isValid()?this._data[t]:NaN}}var Rr=zr("milliseconds"),Fr=zr("seconds"),Nr=zr("minutes"),jr=zr("hours"),Br=zr("days"),Yr=zr("months"),Vr=zr("years"),Ur=Math.round,Hr={ss:44,s:45,m:45,h:22,d:26,M:11};function Gr(t,e,r,n,i){return i.relativeTime(e||1,!!r,t,n)}var qr=Math.abs;function Wr(t){return(t>0)-(t<0)||+t}function Zr(){if(!this.isValid())return this.localeData().invalidDate();var t,e,r=qr(this._milliseconds)/1e3,n=qr(this._days),i=qr(this._months);t=w(r/60),e=w(t/60),r%=60,t%=60;var a=w(i/12),o=i%=12,s=n,l=e,c=t,u=r?r.toFixed(3).replace(/\.?0+$/,""):"",h=this.asSeconds();if(!h)return"P0D";var f=h<0?"-":"",p=Wr(this._months)!==Wr(h)?"-":"",d=Wr(this._days)!==Wr(h)?"-":"",g=Wr(this._milliseconds)!==Wr(h)?"-":"";return f+"P"+(a?p+a+"Y":"")+(o?p+o+"M":"")+(s?d+s+"D":"")+(l||c||u?"T":"")+(l?g+l+"H":"")+(c?g+c+"M":"")+(u?g+u+"S":"")}var Xr=Ne.prototype;return Xr.isValid=function(){return this._isValid},Xr.abs=function(){var t=this._data;return this._milliseconds=_r(this._milliseconds),this._days=_r(this._days),this._months=_r(this._months),t.milliseconds=_r(t.milliseconds),t.seconds=_r(t.seconds),t.minutes=_r(t.minutes),t.hours=_r(t.hours),t.months=_r(t.months),t.years=_r(t.years),this},Xr.add=function(t,e){return wr(this,t,e,1)},Xr.subtract=function(t,e){return wr(this,t,e,-1)},Xr.as=function(t){if(!this.isValid())return NaN;var e,r,n=this._milliseconds;if("month"===(t=z(t))||"year"===t)return e=this._days+n/864e5,r=this._months+Cr(e),"month"===t?r:r/12;switch(e=this._days+Math.round(Mr(this._months)),t){case"week":return e/7+n/6048e5;case"day":return e+n/864e5;case"hour":return 24*e+n/36e5;case"minute":return 1440*e+n/6e4;case"second":return 86400*e+n/1e3;case"millisecond":return Math.floor(864e5*e)+n;default:throw new Error("Unknown unit "+t)}},Xr.asMilliseconds=Ir,Xr.asSeconds=Tr,Xr.asMinutes=Lr,Xr.asHours=Sr,Xr.asDays=Er,Xr.asWeeks=Dr,Xr.asMonths=Pr,Xr.asYears=Or,Xr.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*A(this._months/12):NaN},Xr._bubble=function(){var t,e,r,n,i,a=this._milliseconds,o=this._days,s=this._months,l=this._data;return a>=0&&o>=0&&s>=0||a<=0&&o<=0&&s<=0||(a+=864e5*Ar(Mr(s)+o),o=0,s=0),l.milliseconds=a%1e3,t=w(a/1e3),l.seconds=t%60,e=w(t/60),l.minutes=e%60,r=w(e/60),l.hours=r%24,o+=w(r/24),i=w(Cr(o)),s+=i,o-=Ar(Mr(i)),n=w(s/12),s%=12,l.days=o,l.months=s,l.years=n,this},Xr.clone=function(){return Xe(this)},Xr.get=function(t){return t=z(t),this.isValid()?this[t+"s"]():NaN},Xr.milliseconds=Rr,Xr.seconds=Fr,Xr.minutes=Nr,Xr.hours=jr,Xr.days=Br,Xr.weeks=function(){return w(this.days()/7)},Xr.months=Yr,Xr.years=Vr,Xr.humanize=function(t){if(!this.isValid())return this.localeData().invalidDate();var e=this.localeData(),r=function(t,e,r){var n=Xe(t).abs(),i=Ur(n.as("s")),a=Ur(n.as("m")),o=Ur(n.as("h")),s=Ur(n.as("d")),l=Ur(n.as("M")),c=Ur(n.as("y")),u=i<=Hr.ss&&["s",i]||i0,u[4]=r,Gr.apply(null,u)}(this,!t,e);return t&&(r=e.pastFuture(+this,r)),e.postformat(r)},Xr.toISOString=Zr,Xr.toString=Zr,Xr.toJSON=Zr,Xr.locale=nr,Xr.localeData=ar,Xr.toIsoString=k("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Zr),Xr.lang=ir,H("X",0,0,"unix"),H("x",0,0,"valueOf"),ut("x",at),ut("X",/[+-]?\d+(\.\d{1,3})?/),dt("X",(function(t,e,r){r._d=new Date(1e3*parseFloat(t,10))})),dt("x",(function(t,e,r){r._d=new Date(A(t))})),i.version="2.22.2",e=Pe,i.fn=gr,i.min=function(){return Re("isBefore",[].slice.call(arguments,0))},i.max=function(){return Re("isAfter",[].slice.call(arguments,0))},i.now=function(){return Date.now?Date.now():+new Date},i.utc=p,i.unix=function(t){return Pe(1e3*t)},i.months=function(t,e){return xr(t,e,"months")},i.isDate=c,i.locale=pe,i.invalid=m,i.duration=Xe,i.isMoment=_,i.weekdays=function(t,e,r){return br(t,e,r,"weekdays")},i.parseZone=function(){return Pe.apply(null,arguments).parseZone()},i.localeData=ge,i.isDuration=je,i.monthsShort=function(t,e){return xr(t,e,"monthsShort")},i.weekdaysMin=function(t,e,r){return br(t,e,r,"weekdaysMin")},i.defineLocale=de,i.updateLocale=function(t,e){if(null!=e){var r,n,i=le;null!=(n=fe(t))&&(i=n._config),e=E(i,e),(r=new D(e)).parentLocale=ce[t],ce[t]=r,pe(t)}else null!=ce[t]&&(null!=ce[t].parentLocale?ce[t]=ce[t].parentLocale:null!=ce[t]&&delete ce[t]);return ce[t]},i.locales=function(){return I(ce)},i.weekdaysShort=function(t,e,r){return br(t,e,r,"weekdaysShort")},i.normalizeUnits=z,i.relativeTimeRounding=function(t){return void 0===t?Ur:"function"==typeof t&&(Ur=t,!0)},i.relativeTimeThreshold=function(t,e){return void 0!==Hr[t]&&(void 0===e?Hr[t]:(Hr[t]=e,"s"===t&&(Hr.ss=e-1),!0))},i.calendarFormat=function(t,e){var r=t.diff(e,"days",!0);return r<-6?"sameElse":r<-1?"lastWeek":r<0?"lastDay":r<1?"sameDay":r<2?"nextDay":r<7?"nextWeek":"sameElse"},i.prototype=gr,i.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"YYYY-[W]WW",MONTH:"YYYY-MM"},i}()}).call(this,r(32)(t))},function(t,e,r){(function(e){t.exports=e.jQuery=r(260)}).call(this,r(16))},function(t,e,r){"use strict";t.exports=r(448)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=a(r(450)),i=a(r(454));function a(t){return t&&t.__esModule?t:{default:t}}var o=(0,n.default)(i.default);e.default=o},function(t,e,r){var n;try{n={cloneDeep:r(382),constant:r(64),defaults:r(383),each:r(94),filter:r(97),find:r(384),flatten:r(124),forEach:r(95),forIn:r(389),has:r(108),isUndefined:r(109),last:r(390),map:r(110),mapValues:r(391),max:r(392),merge:r(394),min:r(400),minBy:r(401),now:r(402),pick:r(403),range:r(408),reduce:r(112),sortBy:r(411),uniqueId:r(416),values:r(117),zipObject:r(417)}}catch(t){}n||(n=window._),t.exports=n},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){(function(e,r){var n;t.exports=function t(e,r,i){function a(s,l){if(!r[s]){if(!e[s]){if(!l&&"function"==typeof n&&n)return n(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};e[s][0].call(u.exports,(function(t){return a(e[s][1][t]||t)}),u,u.exports,t,e,r,i)}return r[s].exports}for(var o="function"==typeof n&&n,s=0;s:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;padding-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;padding-left:0px;padding-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var a in i){var o=a.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,i[a])}},{"../src/lib":717}],2:[function(t,e,r){"use strict";e.exports=t("../src/transforms/aggregate")},{"../src/transforms/aggregate":1297}],3:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":864}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/barpolar")},{"../src/traces/barpolar":877}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":887}],6:[function(t,e,r){"use strict";e.exports=t("../src/components/calendars")},{"../src/components/calendars":590}],7:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":896}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/carpet")},{"../src/traces/carpet":915}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":929}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/choroplethmapbox")},{"../src/traces/choroplethmapbox":936}],11:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":942}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":957}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourcarpet")},{"../src/traces/contourcarpet":968}],14:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":695}],15:[function(t,e,r){"use strict";e.exports=t("../src/traces/densitymapbox")},{"../src/traces/densitymapbox":976}],16:[function(t,e,r){"use strict";e.exports=t("../src/transforms/filter")},{"../src/transforms/filter":1298}],17:[function(t,e,r){"use strict";e.exports=t("../src/traces/funnel")},{"../src/traces/funnel":986}],18:[function(t,e,r){"use strict";e.exports=t("../src/traces/funnelarea")},{"../src/traces/funnelarea":995}],19:[function(t,e,r){"use strict";e.exports=t("../src/transforms/groupby")},{"../src/transforms/groupby":1299}],20:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":1008}],21:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":1017}],22:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":1029}],23:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":1035}],24:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":1039}],25:[function(t,e,r){"use strict";e.exports=t("../src/traces/image")},{"../src/traces/image":1046}],26:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./contour"),t("./scatterternary"),t("./violin"),t("./funnel"),t("./waterfall"),t("./image"),t("./pie"),t("./sunburst"),t("./treemap"),t("./funnelarea"),t("./scatter3d"),t("./surface"),t("./isosurface"),t("./volume"),t("./mesh3d"),t("./cone"),t("./streamtube"),t("./scattergeo"),t("./choropleth"),t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./parcoords"),t("./parcats"),t("./scattermapbox"),t("./choroplethmapbox"),t("./densitymapbox"),t("./sankey"),t("./indicator"),t("./table"),t("./carpet"),t("./scattercarpet"),t("./contourcarpet"),t("./ohlc"),t("./candlestick"),t("./scatterpolar"),t("./scatterpolargl"),t("./barpolar")]),n.register([t("./aggregate"),t("./filter"),t("./groupby"),t("./sort")]),n.register([t("./calendars")]),e.exports=n},{"./aggregate":2,"./bar":3,"./barpolar":4,"./box":5,"./calendars":6,"./candlestick":7,"./carpet":8,"./choropleth":9,"./choroplethmapbox":10,"./cone":11,"./contour":12,"./contourcarpet":13,"./core":14,"./densitymapbox":15,"./filter":16,"./funnel":17,"./funnelarea":18,"./groupby":19,"./heatmap":20,"./heatmapgl":21,"./histogram":22,"./histogram2d":23,"./histogram2dcontour":24,"./image":25,"./indicator":27,"./isosurface":28,"./mesh3d":29,"./ohlc":30,"./parcats":31,"./parcoords":32,"./pie":33,"./pointcloud":34,"./sankey":35,"./scatter3d":36,"./scattercarpet":37,"./scattergeo":38,"./scattergl":39,"./scattermapbox":40,"./scatterpolar":41,"./scatterpolargl":42,"./scatterternary":43,"./sort":44,"./splom":45,"./streamtube":46,"./sunburst":47,"./surface":48,"./table":49,"./treemap":50,"./violin":51,"./volume":52,"./waterfall":53}],27:[function(t,e,r){"use strict";e.exports=t("../src/traces/indicator")},{"../src/traces/indicator":1054}],28:[function(t,e,r){"use strict";e.exports=t("../src/traces/isosurface")},{"../src/traces/isosurface":1060}],29:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":1065}],30:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":1070}],31:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcats")},{"../src/traces/parcats":1079}],32:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":1089}],33:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":1100}],34:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":1109}],35:[function(t,e,r){"use strict";e.exports=t("../src/traces/sankey")},{"../src/traces/sankey":1115}],36:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":1152}],37:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattercarpet")},{"../src/traces/scattercarpet":1159}],38:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":1167}],39:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":1180}],40:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":1190}],41:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolar")},{"../src/traces/scatterpolar":1198}],42:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolargl")},{"../src/traces/scatterpolargl":1205}],43:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":1213}],44:[function(t,e,r){"use strict";e.exports=t("../src/transforms/sort")},{"../src/transforms/sort":1301}],45:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":1222}],46:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":1230}],47:[function(t,e,r){"use strict";e.exports=t("../src/traces/sunburst")},{"../src/traces/sunburst":1238}],48:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":1247}],49:[function(t,e,r){"use strict";e.exports=t("../src/traces/table")},{"../src/traces/table":1255}],50:[function(t,e,r){"use strict";e.exports=t("../src/traces/treemap")},{"../src/traces/treemap":1264}],51:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":1276}],52:[function(t,e,r){"use strict";e.exports=t("../src/traces/volume")},{"../src/traces/volume":1284}],53:[function(t,e,r){"use strict";e.exports=t("../src/traces/waterfall")},{"../src/traces/waterfall":1292}],54:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=n(),h=i(),f=a();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),new o({turntable:u,orbit:h,matrix:f},c)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map((function(e){return t[e]})),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach((function(t){for(var e=t[0],r=[],n=0;n1||i>1)}function T(t,e,r){return t.sort(S),t.forEach((function(n,i){var a,o,s=0;if(G(n,r)&&I(n))n.circularPathData.verticalBuffer=s+n.width/2;else{for(var l=0;lo.source.column)){var c=t[l].circularPathData.verticalBuffer+t[l].width/2+e;s=c>s?c:s}n.circularPathData.verticalBuffer=s+n.width/2}})),t}function L(t,r,i,a){var o=e.min(t.links,(function(t){return t.source.y0}));t.links.forEach((function(t){t.circular&&(t.circularPathData={})})),T(t.links.filter((function(t){return"top"==t.circularLinkType})),r,a),T(t.links.filter((function(t){return"bottom"==t.circularLinkType})),r,a),t.links.forEach((function(e){if(e.circular){if(e.circularPathData.arcRadius=e.width+w,e.circularPathData.leftNodeBuffer=5,e.circularPathData.rightNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,G(e,a)&&I(e))e.circularPathData.leftSmallArcRadius=w+e.width/2,e.circularPathData.leftLargeArcRadius=w+e.width/2,e.circularPathData.rightSmallArcRadius=w+e.width/2,e.circularPathData.rightLargeArcRadius=w+e.width/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+_+e.circularPathData.verticalBuffer,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-_-e.circularPathData.verticalBuffer,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius);else{var s=e.source.column,l=e.circularLinkType,c=t.links.filter((function(t){return t.source.column==s&&t.circularLinkType==l}));"bottom"==e.circularLinkType?c.sort(D):c.sort(E);var u=0;c.forEach((function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=w+e.width/2+u,e.circularPathData.leftLargeArcRadius=w+e.width/2+n*r+u),u+=t.width})),s=e.target.column,c=t.links.filter((function(t){return t.target.column==s&&t.circularLinkType==l})),"bottom"==e.circularLinkType?c.sort(O):c.sort(P),u=0,c.forEach((function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=w+e.width/2+u,e.circularPathData.rightLargeArcRadius=w+e.width/2+n*r+u),u+=t.width})),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i,e.source.y1,e.target.y1)+_+e.circularPathData.verticalBuffer,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius):(e.circularPathData.verticalFullExtent=o-_-e.circularPathData.verticalBuffer,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius)}e.circularPathData.leftInnerExtent=e.circularPathData.sourceX+e.circularPathData.leftNodeBuffer,e.circularPathData.rightInnerExtent=e.circularPathData.targetX-e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.sourceX+e.circularPathData.leftLargeArcRadius+e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.targetX-e.circularPathData.rightLargeArcRadius-e.circularPathData.rightNodeBuffer}if(e.circular)e.path=function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.leftSmallArcRadius)+" L"+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" L"+t.circularPathData.rightFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.rightSmallArcRadius)+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(e);else{var h=n.linkHorizontal().source((function(t){return[t.source.x0+(t.source.x1-t.source.x0),t.y0]})).target((function(t){return[t.target.x0,t.y1]}));e.path=h(e)}}))}function S(t,e){return z(t)==z(e)?"bottom"==t.circularLinkType?D(t,e):E(t,e):z(e)-z(t)}function E(t,e){return t.y0-e.y0}function D(t,e){return e.y0-t.y0}function P(t,e){return t.y1-e.y1}function O(t,e){return e.y1-t.y1}function z(t){return t.target.column-t.source.column}function R(t){return t.target.x0-t.source.x1}function F(t,e){var r=M(t),n=R(e)/Math.tan(r);return"up"==H(t)?t.y1+n:t.y1-n}function N(t,e){var r=M(t),n=R(e)/Math.tan(r);return"up"==H(t)?t.y1-n:t.y1+n}function j(t,e,r,n){t.links.forEach((function(i){if(!i.circular&&i.target.column-i.source.column>1){var a=i.source.column+1,o=i.target.column-1,s=1,l=o-a+1;for(s=1;a<=o;a++,s++)t.nodes.forEach((function(o){if(o.column==a){var c,u=s/(l+1),h=Math.pow(1-u,3),f=3*u*Math.pow(1-u,2),p=3*Math.pow(u,2)*(1-u),d=Math.pow(u,3),g=h*i.y0+f*i.y0+p*i.y1+d*i.y1,m=g-i.width/2,v=g+i.width/2;m>o.y0&&ma.y0&&i.y0a.y0&&i.y1a.y1)&&B(t,c,e,r)}))):v>o.y0&&vo.y1&&B(t,c,e,r)}))):mo.y1&&(c=v-o.y0+10,o=B(o,c,e,r),t.nodes.forEach((function(t){b(t,n)!=b(o,n)&&t.column==o.column&&t.y0o.y1&&B(t,c,e,r)})))}}))}}))}function B(t,e,r,n){return t.y0+e>=r&&t.y1+e<=n&&(t.y0=t.y0+e,t.y1=t.y1+e,t.targetLinks.forEach((function(t){t.y1=t.y1+e})),t.sourceLinks.forEach((function(t){t.y0=t.y0+e}))),t}function Y(t,e,r,n){t.nodes.forEach((function(i){n&&i.y+(i.y1-i.y0)>e&&(i.y=i.y-(i.y+(i.y1-i.y0)-e));var a=t.links.filter((function(t){return b(t.source,r)==b(i,r)})),o=a.length;o>1&&a.sort((function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!U(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var r=N(e,t);return t.y1-r}if(e.target.column>t.target.column)return N(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0}));var s=i.y0;a.forEach((function(t){t.y0=s+t.width/2,s+=t.width})),a.forEach((function(t,e){if("bottom"==t.circularLinkType){for(var r=e+1,n=0;r1&&n.sort((function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!U(t,e))return t.y0-e.y0;if(e.source.column0?"up":"down"}function G(t,e){return b(t.source,e)==b(t.target,e)}t.sankeyCircular=function(){var t,n,a=0,b=0,M=1,I=1,T=24,S=m,E=o,D=v,P=y,O=32,z=2,R=null;function F(){var o={nodes:D.apply(null,arguments),links:P.apply(null,arguments)};!function(t){t.nodes.forEach((function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]}));var e=r.map(t.nodes,S);t.links.forEach((function(t,r){t.index=r;var n=t.source,i=t.target;"object"!==(void 0===n?"undefined":l(n))&&(n=t.source=x(e,n)),"object"!==(void 0===i?"undefined":l(i))&&(i=t.target=x(e,i)),n.sourceLinks.push(t),i.targetLinks.push(t)}))}(o),function(t,e,r){var n=0;if(null===r){for(var a=[],o=0;o0?r+_+w:r,bottom:n=n>0?n+_+w:n,left:a=a>0?a+_+w:a,right:i=i>0?i+_+w:i}}(i),u=function(t,r){var n=e.max(t.nodes,(function(t){return t.column})),i=M-a,o=I-b,s=i+r.right+r.left,l=o+r.top+r.bottom,c=i/s,u=o/l;return a=a*c+r.left,M=0==r.right?M:M*c,b=b*u+r.top,I*=u,t.nodes.forEach((function(t){t.x0=a+t.column*((M-a-T)/n),t.x1=t.x0+T})),u}(i,c);s*=u,i.links.forEach((function(t){t.width=t.value*s})),l.forEach((function(t){var e=t.length;t.forEach((function(t,n){t.depth==l.length-1&&1==e?(t.y0=I/2-t.value*s,t.y1=t.y0+t.value*s):0==t.depth&&1==e?(t.y0=I/2-t.value*s,t.y1=t.y0+t.value*s):t.partOfCycle?0==k(t,r)?(t.y0=I/2+n,t.y1=t.y0+t.value*s):"top"==t.circularLinkType?(t.y0=b+n,t.y1=t.y0+t.value*s):(t.y0=I-t.value*s-n,t.y1=t.y0+t.value*s):0==c.top||0==c.bottom?(t.y0=(I-b)/e*n,t.y1=t.y0+t.value*s):(t.y0=(I-b)/2-e/2+n,t.y1=t.y0+t.value*s)}))}))})(s),v();for(var c=1,u=o;u>0;--u)m(c*=.99,s),v();function m(t,r){var n=l.length;l.forEach((function(i){var a=i.length,o=i[0].depth;i.forEach((function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&k(i,r)>0);else if(0==o&&1==a)s=i.y1-i.y0,i.y0=I/2-s/2,i.y1=I/2+s/2;else if(o==n-1&&1==a)s=i.y1-i.y0,i.y0=I/2-s/2,i.y1=I/2+s/2;else{var l=e.mean(i.sourceLinks,g),c=e.mean(i.targetLinks,d),u=((l&&c?(l+c)/2:l||c)-p(i))*t;i.y0+=u,i.y1+=u}}))}))}function v(){l.forEach((function(e){var r,n,i,a=b,o=e.length;for(e.sort(h),i=0;i0&&(r.y0+=n,r.y1+=n),a=r.y1+t;if((n=a-t-I)>0)for(a=r.y0-=n,r.y1-=n,i=o-2;i>=0;--i)(n=(r=e[i]).y1+t-a)>0&&(r.y0-=n,r.y1-=n),a=r.y0}))}}(o,O,S),N(o);for(var s=0;s<4;s++)Y(o,I,S),V(o,0,S),j(o,b,I,S),Y(o,I,S),V(o,0,S);return function(t,r,n){var i=t.nodes,a=t.links,o=!1,s=!1;if(a.forEach((function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(s=!0)})),0==o||0==s){var l=e.min(i,(function(t){return t.y0})),c=e.max(i,(function(t){return t.y1})),u=(n-r)/(c-l);i.forEach((function(t){var e=(t.y1-t.y0)*u;t.y0=(t.y0-l)*u,t.y1=t.y0+e})),a.forEach((function(t){t.y0=(t.y0-l)*u,t.y1=(t.y1-l)*u,t.width=t.width*u}))}}(o,b,I),L(o,z,I,S),o}function N(t){t.nodes.forEach((function(t){t.sourceLinks.sort(u),t.targetLinks.sort(c)})),t.nodes.forEach((function(t){var e=t.y0,r=e,n=t.y1,i=n;t.sourceLinks.forEach((function(t){t.circular?(t.y0=n-t.width/2,n-=t.width):(t.y0=e+t.width/2,e+=t.width)})),t.targetLinks.forEach((function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=r+t.width/2,r+=t.width)}))}))}return F.nodeId=function(t){return arguments.length?(S="function"==typeof t?t:s(t),F):S},F.nodeAlign=function(t){return arguments.length?(E="function"==typeof t?t:s(t),F):E},F.nodeWidth=function(t){return arguments.length?(T=+t,F):T},F.nodePadding=function(e){return arguments.length?(t=+e,F):t},F.nodes=function(t){return arguments.length?(D="function"==typeof t?t:s(t),F):D},F.links=function(t){return arguments.length?(P="function"==typeof t?t:s(t),F):P},F.size=function(t){return arguments.length?(a=b=0,M=+t[0],I=+t[1],F):[M-a,I-b]},F.extent=function(t){return arguments.length?(a=+t[0][0],M=+t[1][0],b=+t[0][1],I=+t[1][1],F):[[a,b],[M,I]]},F.iterations=function(t){return arguments.length?(O=+t,F):O},F.circularLinkGap=function(t){return arguments.length?(z=+t,F):z},F.nodePaddingRatio=function(t){return arguments.length?(n=+t,F):n},F.sortNodes=function(t){return arguments.length?(R=t,F):R},F.update=function(t){return C(t,S),N(t),t.links.forEach((function(t){t.circular&&(t.circularLinkType=t.y0+t.y1a&&(b=a);var o=e.min(i,(function(t){return(y-n-(t.length-1)*b)/e.sum(t,u)}));i.forEach((function(t){t.forEach((function(t,e){t.y1=(t.y0=e)+t.value*o}))})),t.links.forEach((function(t){t.width=t.value*o}))})(),d();for(var a=1,o=M;o>0;--o)l(a*=.99),d(),s(a),d();function s(t){i.forEach((function(r){r.forEach((function(r){if(r.targetLinks.length){var n=(e.sum(r.targetLinks,f)/e.sum(r.targetLinks,u)-h(r))*t;r.y0+=n,r.y1+=n}}))}))}function l(t){i.slice().reverse().forEach((function(r){r.forEach((function(r){if(r.sourceLinks.length){var n=(e.sum(r.sourceLinks,p)/e.sum(r.sourceLinks,u)-h(r))*t;r.y0+=n,r.y1+=n}}))}))}function d(){i.forEach((function(t){var e,r,i,a=n,o=t.length;for(t.sort(c),i=0;i0&&(e.y0+=r,e.y1+=r),a=e.y1+b;if((r=a-b-y)>0)for(a=e.y0-=r,e.y1-=r,i=o-2;i>=0;--i)(r=(e=t[i]).y1+b-a)>0&&(e.y0-=r,e.y1-=r),a=e.y0}))}}(a),T(a),a}function T(t){t.nodes.forEach((function(t){t.sourceLinks.sort(l),t.targetLinks.sort(s)})),t.nodes.forEach((function(t){var e=t.y0,r=e;t.sourceLinks.forEach((function(t){t.y0=e+t.width/2,e+=t.width})),t.targetLinks.forEach((function(t){t.y1=r+t.width/2,r+=t.width}))}))}return I.update=function(t){return T(t),t},I.nodeId=function(t){return arguments.length?(_="function"==typeof t?t:o(t),I):_},I.nodeAlign=function(t){return arguments.length?(w="function"==typeof t?t:o(t),I):w},I.nodeWidth=function(t){return arguments.length?(x=+t,I):x},I.nodePadding=function(t){return arguments.length?(b=+t,I):b},I.nodes=function(t){return arguments.length?(A="function"==typeof t?t:o(t),I):A},I.links=function(t){return arguments.length?(C="function"==typeof t?t:o(t),I):C},I.size=function(e){return arguments.length?(t=n=0,i=+e[0],y=+e[1],I):[i-t,y-n]},I.extent=function(e){return arguments.length?(t=+e[0][0],i=+e[1][0],n=+e[0][1],y=+e[1][1],I):[[t,n],[i,y]]},I.iterations=function(t){return arguments.length?(M=+t,I):M},I},t.sankeyCenter=function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?e.min(t.sourceLinks,i)-1:0},t.sankeyLeft=function(t){return t.depth},t.sankeyRight=function(t,e){return e-1-t.height},t.sankeyJustify=a,t.sankeyLinkHorizontal=function(){return n.linkHorizontal().source(y).target(x)},Object.defineProperty(t,"__esModule",{value:!0})}))},{"d3-array":154,"d3-collection":155,"d3-shape":163}],57:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("@turf/meta"),i=6378137;function a(t){var e=0;if(t&&t.length>0){e+=Math.abs(o(t[0]));for(var r=1;r2){for(l=0;lt[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(t*r)/r},r.radiansToLength=h,r.lengthToRadians=f,r.lengthToDegrees=function(t,e){return p(f(t,e))},r.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},r.radiansToDegrees=p,r.degreesToRadians=function(t){return t%360*Math.PI/180},r.convertLength=function(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return h(f(t,e),r)},r.convertArea=function(t,e,n){if(void 0===e&&(e="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=r.areaFactors[e];if(!i)throw new Error("invalid original units");var a=r.areaFactors[n];if(!a)throw new Error("invalid final units");return t/i*a},r.isNumber=d,r.isObject=function(t){return!!t&&t.constructor===Object},r.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!d(t))throw new Error("bbox must only contain numbers")}))},r.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")},r.radians2degrees=function(){throw new Error("method has been renamed to `radiansToDegrees`")},r.degrees2radians=function(){throw new Error("method has been renamed to `degreesToRadians`")},r.distanceToDegrees=function(){throw new Error("method has been renamed to `lengthToDegrees`")},r.distanceToRadians=function(){throw new Error("method has been renamed to `lengthToRadians`")},r.radiansToDistance=function(){throw new Error("method has been renamed to `radiansToLength`")},r.bearingToAngle=function(){throw new Error("method has been renamed to `bearingToAzimuth`")},r.convertDistance=function(){throw new Error("method has been renamed to `convertLength`")}},{}],61:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("@turf/helpers");function i(t,e,r){if(null!==t)for(var n,a,o,s,l,c,u,h,f=0,p=0,d=t.type,g="FeatureCollection"===d,m="Feature"===d,v=g?t.features.length:1,y=0;yc||p>u||d>h)return l=i,c=r,u=p,h=d,void(o=0);var g=n.lineString([l,i],t.properties);if(!1===e(g,r,a,d,o))return!1;o++,l=i}))&&void 0}}}))}function u(t,e){if(!t)throw new Error("geojson is required");l(t,(function(t,r,i){if(null!==t.geometry){var a=t.geometry.type,o=t.geometry.coordinates;switch(a){case"LineString":if(!1===e(t,r,i,0,0))return!1;break;case"Polygon":for(var s=0;si&&(i=t[o]),t[o] - * @license MIT - */function i(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,a=Math.min(r,n);i=0;c--)if(u[c]!==h[c])return!1;for(c=u.length-1;c>=0;c--)if(s=u[c],!x(t[s],e[s],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function b(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function w(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!t&&i&&!r;if((!t&&o.isError(i)&&a&&_(i,r)||s)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}f.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return g(m(t.actual),128)+" "+t.operator+" "+g(m(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=d(e),a=n.indexOf("\n"+i);if(a>=0){var o=n.indexOf("\n",a+1);n=n.substring(o+1)}this.stack=n}}},o.inherits(f.AssertionError,Error),f.fail=v,f.ok=y,f.equal=function(t,e,r){t!=e&&v(t,e,r,"==",f.equal)},f.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",f.notEqual)},f.deepEqual=function(t,e,r){x(t,e,!1)||v(t,e,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,r){x(t,e,!0)||v(t,e,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,r){x(t,e,!1)&&v(t,e,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,r,n){x(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",f.strictEqual)},f.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",f.notStrictEqual)},f.throws=function(t,e,r){w(!0,t,e,r)},f.doesNotThrow=function(t,e,r){w(!1,t,e,r)},f.ifError=function(t){if(t)throw t},f.strict=n((function t(e,r){e||v(e,!0,r,"==",t)}),f,{equal:f.strictEqual,deepEqual:f.deepStrictEqual,notEqual:f.notStrictEqual,notDeepEqual:f.notDeepStrictEqual}),f.strict.strict=f.strict;var A=Object.keys||function(t){var e=[];for(var r in t)s.call(t,r)&&e.push(r);return e}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":456,"util/":73}],71:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],72:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],73:[function(t,r,n){(function(e,r){var i=/%[sdj%]/g;n.format=function(t){if(!v(t)){for(var e=[],r=0;r=a)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),l=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(e)?r.showHidden=e:e&&n._extend(r,e),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,t,r.depth)}function l(t,e){var r=s.styles[e];return r?"["+s.colors[r][0]+"m"+t+"["+s.colors[r][1]+"m":t}function c(t,e){return t}function u(t,e,r){if(t.customInspect&&e&&A(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return v(i)||(i=u(t,i,r)),i}var a=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return m(e)?t.stylize(""+e,"number"):d(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}(t,e);if(a)return a;var o=Object.keys(e),s=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return h(e);if(0===o.length){if(A(e)){var l=e.name?": "+e.name:"";return t.stylize("[Function"+l+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return h(e)}var c,b="",C=!1,M=["{","}"];return p(e)&&(C=!0,M=["[","]"]),A(e)&&(b=" [Function"+(e.name?": "+e.name:"")+"]"),x(e)&&(b=" "+RegExp.prototype.toString.call(e)),_(e)&&(b=" "+Date.prototype.toUTCString.call(e)),w(e)&&(b=" "+h(e)),0!==o.length||C&&0!=e.length?r<0?x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=C?function(t,e,r,n,i){for(var a=[],o=0,s=e.length;o60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,b,M)):M[0]+b+M[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,r,n,i,a){var o,s,l;if((l=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),T(n,i)||(o="["+i+"]"),s||(t.seen.indexOf(l.value)<0?(s=g(r)?u(t,l.value,null):u(t,l.value,r-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+s.split("\n").map((function(t){return" "+t})).join("\n")):s=t.stylize("[Circular]","special")),y(o)){if(a&&i.match(/^\d+$/))return s;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function m(t){return"number"==typeof t}function v(t){return"string"==typeof t}function y(t){return void 0===t}function x(t){return b(t)&&"[object RegExp]"===C(t)}function b(t){return"object"==typeof t&&null!==t}function _(t){return b(t)&&"[object Date]"===C(t)}function w(t){return b(t)&&("[object Error]"===C(t)||t instanceof Error)}function A(t){return"function"==typeof t}function C(t){return Object.prototype.toString.call(t)}function M(t){return t<10?"0"+t.toString(10):t.toString(10)}n.debuglog=function(t){if(y(a)&&(a=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var r=e.pid;o[t]=function(){var e=n.format.apply(n,arguments);console.error("%s %d: %s",t,r,e)}}else o[t]=function(){};return o[t]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=g,n.isNullOrUndefined=function(t){return null==t},n.isNumber=m,n.isString=v,n.isSymbol=function(t){return"symbol"==typeof t},n.isUndefined=y,n.isRegExp=x,n.isObject=b,n.isDate=_,n.isError=w,n.isFunction=A,n.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},n.isBuffer=t("./support/isBuffer");var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(){var t=new Date,e=[M(t.getHours()),M(t.getMinutes()),M(t.getSeconds())].join(":");return[t.getDate(),k[t.getMonth()],e].join(" ")}function T(t,e){return Object.prototype.hasOwnProperty.call(t,e)}n.log=function(){console.log("%s - %s",I(),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":72,_process:484,inherits:71}],74:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],75:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=e.length,a=new Array(r+1),o=0;o0?o-4:o;for(r=0;r>16&255,l[u++]=e>>8&255,l[u++]=255&e;return 2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,l[u++]=255&e),1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,l[u++]=e>>8&255,l[u++]=255&e),l},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,a=[],o=0,s=r-i;os?s:o+16383));return 1===i?(e=t[r-1],a.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],a.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var i,a,o=[],s=e;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],77:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":87}],78:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],79:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":87}],80:[function(t,e,r){"use strict";var n=t("./is-rat"),i=t("./lib/is-bn"),a=t("./lib/num-to-bn"),o=t("./lib/str-to-bn"),s=t("./lib/rationalize"),l=t("./div");e.exports=function t(e,r){if(n(e))return r?l(e,t(r)):[e[0].clone(),e[1].clone()];var c,u,h=0;if(i(e))c=e.clone();else if("string"==typeof e)c=o(e);else{if(0===e)return[a(0),a(1)];if(e===Math.floor(e))c=a(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),h-=256;c=a(e)}}if(n(r))c.mul(r[1]),u=r[0].clone();else if(i(r))u=r.clone();else if("string"==typeof r)u=o(r);else if(r)if(r===Math.floor(r))u=a(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),h+=256;u=a(r)}else u=a(1);return h>0?c=c.ushln(h):h<0&&(u=u.ushln(-h)),s(c,u)}},{"./div":79,"./is-rat":81,"./lib/is-bn":85,"./lib/num-to-bn":86,"./lib/rationalize":87,"./lib/str-to-bn":88}],81:[function(t,e,r){"use strict";var n=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&n(t[0])&&n(t[1])}},{"./lib/is-bn":85}],82:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return t.cmp(new n(0))}},{"bn.js":96}],83:[function(t,e,r){"use strict";var n=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var a=0;a20?52:r+32}},{"bit-twiddle":94,"double-bits":169}],85:[function(t,e,r){"use strict";t("bn.js"),e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":96}],86:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("double-bits");e.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":96,"double-bits":169}],87:[function(t,e,r){"use strict";var n=t("./num-to-bn"),i=t("./bn-sign");e.exports=function(t,e){var r=i(t),a=i(e);if(0===r)return[n(0),n(1)];if(0===a)return[n(0),n(0)];a<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}},{"./bn-sign":82,"./num-to-bn":86}],88:[function(t,e,r){"use strict";var n=t("bn.js");e.exports=function(t){return new n(t)}},{"bn.js":96}],89:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":87}],90:[function(t,e,r){"use strict";var n=t("./lib/bn-sign");e.exports=function(t){return n(t[0])*n(t[1])}},{"./lib/bn-sign":82}],91:[function(t,e,r){"use strict";var n=t("./lib/rationalize");e.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":87}],92:[function(t,e,r){"use strict";var n=t("./lib/bn-to-num"),i=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var a=e.abs().divmod(r.abs()),o=a.div,s=n(o),l=a.mod,c=e.negative!==r.negative?-1:1;if(0===l.cmpn(0))return c*s;if(s){var u=i(s)+4,h=n(l.ushln(u).divRound(r));return c*(s+h*Math.pow(2,-u))}var f=r.bitLength()-l.bitLength()+53;return h=n(l.ushln(f).divRound(r)),f<1023?c*h*Math.pow(2,-f):(h*=Math.pow(2,-1023),c*h*Math.pow(2,1023-f))}},{"./lib/bn-to-num":83,"./lib/ctz":84}],93:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],94:[function(t,e,r){"use strict";function n(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(t>0)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],95:[function(t,e,r){"use strict";var n=t("clamp");e.exports=function(t,e){e||(e={});var r,o,s,l,c,u,h,f,p,d,g,m=null==e.cutoff?.25:e.cutoff,v=null==e.radius?8:e.radius,y=e.channel||0;if(ArrayBuffer.isView(t)||Array.isArray(t)){if(!e.width||!e.height)throw Error("For raw data width and height should be provided by options");r=e.width,o=e.height,l=t,u=e.stride?e.stride:Math.floor(t.length/r/o)}else window.HTMLCanvasElement&&t instanceof window.HTMLCanvasElement?(h=(f=t).getContext("2d"),r=f.width,o=f.height,p=h.getImageData(0,0,r,o),l=p.data,u=4):window.CanvasRenderingContext2D&&t instanceof window.CanvasRenderingContext2D?(f=t.canvas,h=t,r=f.width,o=f.height,p=h.getImageData(0,0,r,o),l=p.data,u=4):window.ImageData&&t instanceof window.ImageData&&(p=t,r=t.width,o=t.height,l=p.data,u=4);if(s=Math.max(r,o),window.Uint8ClampedArray&&l instanceof window.Uint8ClampedArray||window.Uint8Array&&l instanceof window.Uint8Array)for(c=l,l=Array(r*o),d=0,g=c.length;d=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function l(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(t){return t instanceof a||null!==t&&"object"==typeof t&&t.constructor.wordSize===a.wordSize&&Array.isArray(t.words)},a.max=function(t,e){return t.cmp(e)>0?t:e},a.min=function(t,e){return t.cmp(e)<0?t:e},a.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},a.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,o=a%n,s=Math.min(a,a-o)+r,c=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],a=0|e.words[0],o=i*a,s=67108863&o,l=o/67108864|0;r.words[0]=s;for(var c=1;c>>26,h=67108863&l,f=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=f;p++){var d=c-p|0;u+=(o=(i=0|t.words[d])*(a=0|e.words[p])+h)/67108864|0,h=67108863&o}r.words[c]=0|h,l=0|u}return 0!==l?r.words[c]=0|l:r.length--,r.strip()}a.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,a=0,o=0;o>>24-i&16777215)||o!==this.length-1?c[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var f=u[t],p=h[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var g=d.modn(p).toString(t);r=(d=d.idivn(p)).isZero()?g+r:c[f-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(t,e){return n(void 0!==o),this.toArrayLike(o,t,e)},a.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},a.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,l="le"===e,c=new t(a),u=this.clone();if(l){for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},a.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},a.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},a.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},a.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},a.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},a.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},a.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},a.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(t){return this.clone().inotn(t)},a.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},a.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,p=0|o[1],d=8191&p,g=p>>>13,m=0|o[2],v=8191&m,y=m>>>13,x=0|o[3],b=8191&x,_=x>>>13,w=0|o[4],A=8191&w,C=w>>>13,M=0|o[5],k=8191&M,I=M>>>13,T=0|o[6],L=8191&T,S=T>>>13,E=0|o[7],D=8191&E,P=E>>>13,O=0|o[8],z=8191&O,R=O>>>13,F=0|o[9],N=8191&F,j=F>>>13,B=0|s[0],Y=8191&B,V=B>>>13,U=0|s[1],H=8191&U,G=U>>>13,q=0|s[2],W=8191&q,Z=q>>>13,X=0|s[3],J=8191&X,K=X>>>13,Q=0|s[4],$=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],at=8191&it,ot=it>>>13,st=0|s[7],lt=8191&st,ct=st>>>13,ut=0|s[8],ht=8191&ut,ft=ut>>>13,pt=0|s[9],dt=8191&pt,gt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(c+(n=Math.imul(h,Y))|0)+((8191&(i=(i=Math.imul(h,V))+Math.imul(f,Y)|0))<<13)|0;c=((a=Math.imul(f,V))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(d,Y),i=(i=Math.imul(d,V))+Math.imul(g,Y)|0,a=Math.imul(g,V);var vt=(c+(n=n+Math.imul(h,H)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(f,H)|0))<<13)|0;c=((a=a+Math.imul(f,G)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,Y),i=(i=Math.imul(v,V))+Math.imul(y,Y)|0,a=Math.imul(y,V),n=n+Math.imul(d,H)|0,i=(i=i+Math.imul(d,G)|0)+Math.imul(g,H)|0,a=a+Math.imul(g,G)|0;var yt=(c+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(f,W)|0))<<13)|0;c=((a=a+Math.imul(f,Z)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(b,Y),i=(i=Math.imul(b,V))+Math.imul(_,Y)|0,a=Math.imul(_,V),n=n+Math.imul(v,H)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(y,H)|0,a=a+Math.imul(y,G)|0,n=n+Math.imul(d,W)|0,i=(i=i+Math.imul(d,Z)|0)+Math.imul(g,W)|0,a=a+Math.imul(g,Z)|0;var xt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(f,J)|0))<<13)|0;c=((a=a+Math.imul(f,K)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(A,Y),i=(i=Math.imul(A,V))+Math.imul(C,Y)|0,a=Math.imul(C,V),n=n+Math.imul(b,H)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(_,H)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(v,W)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(y,W)|0,a=a+Math.imul(y,Z)|0,n=n+Math.imul(d,J)|0,i=(i=i+Math.imul(d,K)|0)+Math.imul(g,J)|0,a=a+Math.imul(g,K)|0;var bt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(f,$)|0))<<13)|0;c=((a=a+Math.imul(f,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(k,Y),i=(i=Math.imul(k,V))+Math.imul(I,Y)|0,a=Math.imul(I,V),n=n+Math.imul(A,H)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(C,H)|0,a=a+Math.imul(C,G)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,Z)|0)+Math.imul(_,W)|0,a=a+Math.imul(_,Z)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,K)|0)+Math.imul(y,J)|0,a=a+Math.imul(y,K)|0,n=n+Math.imul(d,$)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(g,$)|0,a=a+Math.imul(g,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((a=a+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,V))+Math.imul(S,Y)|0,a=Math.imul(S,V),n=n+Math.imul(k,H)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,G)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,Z)|0)+Math.imul(C,W)|0,a=a+Math.imul(C,Z)|0,n=n+Math.imul(b,J)|0,i=(i=i+Math.imul(b,K)|0)+Math.imul(_,J)|0,a=a+Math.imul(_,K)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(y,$)|0,a=a+Math.imul(y,tt)|0,n=n+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,nt)|0)+Math.imul(g,rt)|0,a=a+Math.imul(g,nt)|0;var wt=(c+(n=n+Math.imul(h,at)|0)|0)+((8191&(i=(i=i+Math.imul(h,ot)|0)+Math.imul(f,at)|0))<<13)|0;c=((a=a+Math.imul(f,ot)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,V))+Math.imul(P,Y)|0,a=Math.imul(P,V),n=n+Math.imul(L,H)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,G)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,K)|0)+Math.imul(C,J)|0,a=a+Math.imul(C,K)|0,n=n+Math.imul(b,$)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(_,$)|0,a=a+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(y,rt)|0,a=a+Math.imul(y,nt)|0,n=n+Math.imul(d,at)|0,i=(i=i+Math.imul(d,ot)|0)+Math.imul(g,at)|0,a=a+Math.imul(g,ot)|0;var At=(c+(n=n+Math.imul(h,lt)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(f,lt)|0))<<13)|0;c=((a=a+Math.imul(f,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,Y),i=(i=Math.imul(z,V))+Math.imul(R,Y)|0,a=Math.imul(R,V),n=n+Math.imul(D,H)|0,i=(i=i+Math.imul(D,G)|0)+Math.imul(P,H)|0,a=a+Math.imul(P,G)|0,n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,K)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,K)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(C,$)|0,a=a+Math.imul(C,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(_,rt)|0,a=a+Math.imul(_,nt)|0,n=n+Math.imul(v,at)|0,i=(i=i+Math.imul(v,ot)|0)+Math.imul(y,at)|0,a=a+Math.imul(y,ot)|0,n=n+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(g,lt)|0,a=a+Math.imul(g,ct)|0;var Ct=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,ft)|0)+Math.imul(f,ht)|0))<<13)|0;c=((a=a+Math.imul(f,ft)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,Y),i=(i=Math.imul(N,V))+Math.imul(j,Y)|0,a=Math.imul(j,V),n=n+Math.imul(z,H)|0,i=(i=i+Math.imul(z,G)|0)+Math.imul(R,H)|0,a=a+Math.imul(R,G)|0,n=n+Math.imul(D,W)|0,i=(i=i+Math.imul(D,Z)|0)+Math.imul(P,W)|0,a=a+Math.imul(P,Z)|0,n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,K)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,K)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(C,rt)|0,a=a+Math.imul(C,nt)|0,n=n+Math.imul(b,at)|0,i=(i=i+Math.imul(b,ot)|0)+Math.imul(_,at)|0,a=a+Math.imul(_,ot)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,a=a+Math.imul(y,ct)|0,n=n+Math.imul(d,ht)|0,i=(i=i+Math.imul(d,ft)|0)+Math.imul(g,ht)|0,a=a+Math.imul(g,ft)|0;var Mt=(c+(n=n+Math.imul(h,dt)|0)|0)+((8191&(i=(i=i+Math.imul(h,gt)|0)+Math.imul(f,dt)|0))<<13)|0;c=((a=a+Math.imul(f,gt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,H),i=(i=Math.imul(N,G))+Math.imul(j,H)|0,a=Math.imul(j,G),n=n+Math.imul(z,W)|0,i=(i=i+Math.imul(z,Z)|0)+Math.imul(R,W)|0,a=a+Math.imul(R,Z)|0,n=n+Math.imul(D,J)|0,i=(i=i+Math.imul(D,K)|0)+Math.imul(P,J)|0,a=a+Math.imul(P,K)|0,n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,nt)|0,n=n+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(C,at)|0,a=a+Math.imul(C,ot)|0,n=n+Math.imul(b,lt)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(_,lt)|0,a=a+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(y,ht)|0,a=a+Math.imul(y,ft)|0;var kt=(c+(n=n+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,gt)|0)+Math.imul(g,dt)|0))<<13)|0;c=((a=a+Math.imul(g,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,W),i=(i=Math.imul(N,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),n=n+Math.imul(z,J)|0,i=(i=i+Math.imul(z,K)|0)+Math.imul(R,J)|0,a=a+Math.imul(R,K)|0,n=n+Math.imul(D,$)|0,i=(i=i+Math.imul(D,tt)|0)+Math.imul(P,$)|0,a=a+Math.imul(P,tt)|0,n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,nt)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(C,lt)|0,a=a+Math.imul(C,ct)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ft)|0)+Math.imul(_,ht)|0,a=a+Math.imul(_,ft)|0;var It=(c+(n=n+Math.imul(v,dt)|0)|0)+((8191&(i=(i=i+Math.imul(v,gt)|0)+Math.imul(y,dt)|0))<<13)|0;c=((a=a+Math.imul(y,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,K))+Math.imul(j,J)|0,a=Math.imul(j,K),n=n+Math.imul(z,$)|0,i=(i=i+Math.imul(z,tt)|0)+Math.imul(R,$)|0,a=a+Math.imul(R,tt)|0,n=n+Math.imul(D,rt)|0,i=(i=i+Math.imul(D,nt)|0)+Math.imul(P,rt)|0,a=a+Math.imul(P,nt)|0,n=n+Math.imul(L,at)|0,i=(i=i+Math.imul(L,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(I,lt)|0,a=a+Math.imul(I,ct)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(C,ht)|0,a=a+Math.imul(C,ft)|0;var Tt=(c+(n=n+Math.imul(b,dt)|0)|0)+((8191&(i=(i=i+Math.imul(b,gt)|0)+Math.imul(_,dt)|0))<<13)|0;c=((a=a+Math.imul(_,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(j,$)|0,a=Math.imul(j,tt),n=n+Math.imul(z,rt)|0,i=(i=i+Math.imul(z,nt)|0)+Math.imul(R,rt)|0,a=a+Math.imul(R,nt)|0,n=n+Math.imul(D,at)|0,i=(i=i+Math.imul(D,ot)|0)+Math.imul(P,at)|0,a=a+Math.imul(P,ot)|0,n=n+Math.imul(L,lt)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(S,lt)|0,a=a+Math.imul(S,ct)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ft)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ft)|0;var Lt=(c+(n=n+Math.imul(A,dt)|0)|0)+((8191&(i=(i=i+Math.imul(A,gt)|0)+Math.imul(C,dt)|0))<<13)|0;c=((a=a+Math.imul(C,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(j,rt)|0,a=Math.imul(j,nt),n=n+Math.imul(z,at)|0,i=(i=i+Math.imul(z,ot)|0)+Math.imul(R,at)|0,a=a+Math.imul(R,ot)|0,n=n+Math.imul(D,lt)|0,i=(i=i+Math.imul(D,ct)|0)+Math.imul(P,lt)|0,a=a+Math.imul(P,ct)|0,n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,ft)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ft)|0;var St=(c+(n=n+Math.imul(k,dt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(I,dt)|0))<<13)|0;c=((a=a+Math.imul(I,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,at),i=(i=Math.imul(N,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),n=n+Math.imul(z,lt)|0,i=(i=i+Math.imul(z,ct)|0)+Math.imul(R,lt)|0,a=a+Math.imul(R,ct)|0,n=n+Math.imul(D,ht)|0,i=(i=i+Math.imul(D,ft)|0)+Math.imul(P,ht)|0,a=a+Math.imul(P,ft)|0;var Et=(c+(n=n+Math.imul(L,dt)|0)|0)+((8191&(i=(i=i+Math.imul(L,gt)|0)+Math.imul(S,dt)|0))<<13)|0;c=((a=a+Math.imul(S,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(N,lt),i=(i=Math.imul(N,ct))+Math.imul(j,lt)|0,a=Math.imul(j,ct),n=n+Math.imul(z,ht)|0,i=(i=i+Math.imul(z,ft)|0)+Math.imul(R,ht)|0,a=a+Math.imul(R,ft)|0;var Dt=(c+(n=n+Math.imul(D,dt)|0)|0)+((8191&(i=(i=i+Math.imul(D,gt)|0)+Math.imul(P,dt)|0))<<13)|0;c=((a=a+Math.imul(P,gt)|0)+(i>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,ft))+Math.imul(j,ht)|0,a=Math.imul(j,ft);var Pt=(c+(n=n+Math.imul(z,dt)|0)|0)+((8191&(i=(i=i+Math.imul(z,gt)|0)+Math.imul(R,dt)|0))<<13)|0;c=((a=a+Math.imul(R,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Ot=(c+(n=Math.imul(N,dt))|0)+((8191&(i=(i=Math.imul(N,gt))+Math.imul(j,dt)|0))<<13)|0;return c=((a=Math.imul(j,gt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,l[0]=mt,l[1]=vt,l[2]=yt,l[3]=xt,l[4]=bt,l[5]=_t,l[6]=wt,l[7]=At,l[8]=Ct,l[9]=Mt,l[10]=kt,l[11]=It,l[12]=Tt,l[13]=Lt,l[14]=St,l[15]=Et,l[16]=Dt,l[17]=Pt,l[18]=Ot,0!==c&&(l[19]=c,r.length++),r};function d(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=f),a.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?f(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,t,e):d(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=a.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,a){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=a>>>26,this.words[r]=67108863&a}return 0!==e&&(this.words[r]=e,this.length++),this},a.prototype.muln=function(t){return this.clone().imuln(t)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new a(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,c=0;c=0&&(0!==u||c>=i);c--){var h=0|this.words[c];this.words[c]=u<<26-a|h>>>a,u=h&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},a.prototype.shln=function(t){return this.clone().ishln(t)},a.prototype.ushln=function(t){return this.clone().iushln(t)},a.prototype.shrn=function(t){return this.clone().ishrn(t)},a.prototype.ushrn=function(t){return this.clone().iushrn(t)},a.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},a.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(l/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!=(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,l=n.length-i.length;if("mod"!==e){(s=new a(null)).length=l+1,s.words=new Array(s.length);for(var c=0;c=0;h--){var f=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(f=Math.min(f/o|0,67108863),n._ishlnsubmul(i,f,h);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=f)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new a(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new a(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new a(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,s},a.prototype.div=function(t){return this.divmod(t,"div",!1).div},a.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},a.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},a.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},a.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},a.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},a.prototype.divn=function(t){return this.clone().idivn(t)},a.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new a(1),o=new a(0),s=new a(0),l=new a(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),h=e.clone();!e.isZero();){for(var f=0,p=1;0==(e.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var d=0,g=1;0==(r.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(u),l.isub(h)),s.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),o.isub(l)):(r.isub(e),s.isub(i),l.isub(o))}return{a:s,b:l,gcd:r.iushln(c)}},a.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new a(1),s=new a(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,u=1;0==(e.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(e.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(l),o.iushrn(1);for(var h=0,f=1;0==(r.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(r.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(s)):(r.isub(e),s.isub(o))}return(i=0===e.cmpn(1)?o:s).cmpn(0)<0&&i.iadd(t),i},a.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},a.prototype.invm=function(t){return this.egcd(t).a.umod(t)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(t){return this.words[0]&t},a.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},a.prototype.gtn=function(t){return 1===this.cmpn(t)},a.prototype.gt=function(t){return 1===this.cmp(t)},a.prototype.gten=function(t){return this.cmpn(t)>=0},a.prototype.gte=function(t){return this.cmp(t)>=0},a.prototype.ltn=function(t){return-1===this.cmpn(t)},a.prototype.lt=function(t){return-1===this.cmp(t)},a.prototype.lten=function(t){return this.cmpn(t)<=0},a.prototype.lte=function(t){return this.cmp(t)<=0},a.prototype.eqn=function(t){return 0===this.cmpn(t)},a.prototype.eq=function(t){return 0===this.cmp(t)},a.red=function(t){return new w(t)},a.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(t){return this.red=t,this},a.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},a.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},a.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},a.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},a.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},a.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},a.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},a.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new a(e,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function x(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=a._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new a(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(y,v),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=a}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},a._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new x;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return m[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new a(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var s=new a(1).toRed(this),l=s.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,c).cmp(l);)u.redIAdd(l);for(var h=this.pow(u,i),f=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),d=o;0!==p.cmp(s);){for(var g=p,m=0;0!==g.cmp(s);m++)g=g.redSqr();n(m=0;n--){for(var c=e.words[n],u=l-1;u>=0;u--){var h=c>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==o?(o<<=1,o|=h,(4==++s||0===n&&0===u)&&(i=this.mul(i,r[o]),s=0,o=0)):s=0}l=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},a.mont=function(t){return new A(t)},i(A,w),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new a(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:105}],97:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i=t.length,a=0;for(e=0;e>>1;if(!(u<=0)){var h,f=i.mallocDouble(2*u*s),p=i.mallocInt32(s);if((s=l(t,u,f,p))>0){if(1===u&&n)a.init(s),h=a.sweepComplete(u,r,0,s,f,p,0,s,f,p);else{var d=i.mallocDouble(2*u*c),g=i.mallocInt32(c);(c=l(e,u,d,g))>0&&(a.init(s+c),h=1===u?a.sweepBipartite(u,r,0,s,f,p,0,c,d,g):o(u,r,n,s,f,p,c,d,g),i.free(d),i.free(g))}i.free(f),i.free(p)}return h}}}function u(t,e){n.push([t,e])}},{"./lib/intersect":100,"./lib/sweep":104,"typedarray-pool":544}],99:[function(t,e,r){"use strict";var n="d",i="ax",a="vv",o="fp",s="es",l="rs",c="re",u="rb",h="ri",f="rp",p="bs",d="be",g="bb",m="bi",v="bp",y="rv",x="Q",b=[n,i,a,l,c,u,h,p,d,g,m];function _(t){var e="bruteForce"+(t?"Full":"Partial"),r=[],_=b.slice();t||_.splice(3,0,o);var w=["function "+e+"("+_.join()+"){"];function A(e,o){var _=function(t,e,r){var o="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),_=["function ",o,"(",b.join(),"){","var ",s,"=2*",n,";"],w="for(var i="+l+","+f+"="+s+"*"+l+";i<"+c+";++i,"+f+"+="+s+"){var x0="+u+"["+i+"+"+f+"],x1="+u+"["+i+"+"+f+"+"+n+"],xi="+h+"[i];",A="for(var j="+p+","+v+"="+s+"*"+p+";j<"+d+";++j,"+v+"+="+s+"){var y0="+g+"["+i+"+"+v+"],"+(r?"y1="+g+"["+i+"+"+v+"+"+n+"],":"")+"yi="+m+"[j];";return t?_.push(w,x,":",A):_.push(A,x,":",w),r?_.push("if(y1"+d+"-"+p+"){"),t?(A(!0,!1),w.push("}else{"),A(!1,!1)):(w.push("if("+o+"){"),A(!0,!0),w.push("}else{"),A(!0,!1),w.push("}}else{if("+o+"){"),A(!1,!0),w.push("}else{"),A(!1,!1),w.push("}")),w.push("}}return "+e);var C=r.join("")+w.join("");return new Function(C)()}r.partial=_(!1),r.full=_(!0)},{}],100:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,u,I,T,L,S){!function(t,e){var r=8*i.log2(e+1)*(t+1)|0,a=i.nextPow2(b*r);w.length0;){var O=(D-=1)*b,z=w[O],R=w[O+1],F=w[O+2],N=w[O+3],j=w[O+4],B=w[O+5],Y=D*_,V=A[Y],U=A[Y+1],H=1&B,G=!!(16&B),q=u,W=I,Z=L,X=S;if(H&&(q=L,W=S,Z=u,X=I),!(2&B&&(F=m(t,z,R,F,q,W,U),R>=F)||4&B&&(R=v(t,z,R,F,q,W,V))>=F)){var J=F-R,K=j-N;if(G){if(t*J*(J+K)=p0)&&!(p1>=hi)",["p0","p1"]),g=u("lo===p0",["p0"]),m=u("lo>>1,f=2*t,p=h,d=s[f*h+e];c=x?(p=y,d=x):v>=_?(p=m,d=v):(p=b,d=_):x>=_?(p=y,d=x):_>=v?(p=m,d=v):(p=b,d=_);for(var w=f*(u-1),A=f*p,C=0;Cr&&i[h+e]>c;--u,h-=o){for(var f=h,p=h+o,d=0;d=0&&i.push("lo=e[k+n]"),t.indexOf("hi")>=0&&i.push("hi=e[k+o]"),r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],103:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,h){var f=(r-e+1)/6|0,p=e+f,d=r-f,g=e+r>>1,m=g-f,v=g+f,y=p,x=m,b=g,_=v,w=d,A=e+1,C=r-1,M=0;c(y,x,h)&&(M=y,y=x,x=M),c(_,w,h)&&(M=_,_=w,w=M),c(y,b,h)&&(M=y,y=b,b=M),c(x,b,h)&&(M=x,x=b,b=M),c(y,_,h)&&(M=y,y=_,_=M),c(b,_,h)&&(M=b,b=_,_=M),c(x,w,h)&&(M=x,x=w,w=M),c(x,b,h)&&(M=x,x=b,b=M),c(_,w,h)&&(M=_,_=w,w=M);for(var k=h[2*x],I=h[2*x+1],T=h[2*_],L=h[2*_+1],S=2*y,E=2*b,D=2*w,P=2*p,O=2*g,z=2*d,R=0;R<2;++R){var F=h[S+R],N=h[E+R],j=h[D+R];h[P+R]=F,h[O+R]=N,h[z+R]=j}o(m,e,h),o(v,r,h);for(var B=A;B<=C;++B)if(u(B,k,I,h))B!==A&&a(B,A,h),++A;else if(!u(B,T,L,h))for(;;){if(u(C,T,L,h)){u(C,k,I,h)?(s(B,A,C,h),++A,--C):(a(B,C,h),--C);break}if(--Ct;){var c=r[l-2],u=r[l-1];if(cr[e+1])}function u(t,e,r,n){var i=n[t*=2];return i>>1;a(p,I);var T=0,L=0;for(A=0;A=o)d(c,u,L--,S=S-o|0);else if(S>=0)d(s,l,T--,S);else if(S<=-o){S=-S-o|0;for(var E=0;E>>1;a(p,T);var L=0,S=0,E=0;for(C=0;C>1==p[2*C+3]>>1&&(P=2,C+=1),D<0){for(var O=-(D>>1)-1,z=0;z>1)-1,0===P?d(s,l,L--,O):1===P?d(c,u,S--,O):2===P&&d(h,f,E--,O)}},scanBipartite:function(t,e,r,n,i,c,u,h,f,m,v,y){var x=0,b=2*t,_=e,w=e+t,A=1,C=1;n?C=o:A=o;for(var M=i;M>>1;a(p,L);var S=0;for(M=0;M=o?(D=!n,k-=o):(D=!!n,k-=1),D)g(s,l,S++,k);else{var P=y[k],O=b*k,z=v[O+e+1],R=v[O+e+1+t];t:for(var F=0;F>>1;a(p,A);var C=0;for(x=0;x=o)s[C++]=b-o;else{var k=d[b-=1],I=m*b,T=f[I+e+1],L=f[I+e+1+t];t:for(var S=0;S=0;--S)if(s[S]===b){for(O=S+1;O0&&s.length>a){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else s=o[e]=r,++t._eventsCount;return t}function v(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var l=new Error('Unhandled "error" event. ('+e+")");throw l.context=e,l}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:h(r,c,this);break;case 2:f(r,c,this,arguments[1]);break;case 3:p(r,c,this,arguments[1],arguments[2]);break;case 4:d(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),a=1;a=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,a=o;break}if(a<0)return this;0===a?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return x(this,t,!0)},o.prototype.rawListeners=function(t){return x(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):b.call(t,e)},o.prototype.listenerCount=b,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],107:[function(t,e,r){(function(e){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -"use strict";var n=t("base64-js"),i=t("ieee754"),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=e,r.SlowBuffer=function(t){return+t!=t&&(t=0),e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,e.prototype),r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return l(t,e,r)}function l(t,r,n){if("string"==typeof t)return function(t,r){if("string"==typeof r&&""!==r||(r="utf8"),!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|p(t,r),i=s(n),a=i.write(t,r);return a!==n&&(i=i.slice(0,a)),i}(t,r);if(ArrayBuffer.isView(t))return h(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(B(t,ArrayBuffer)||t&&B(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function p(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var a=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(t).length;default:if(a)return i?-1:F(t).length;r=(""+r).toLowerCase(),a=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return L(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return C(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,r,n,i,a){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Y(n=+n)&&(n=a?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(a)return-1;n=t.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:v(t,r,n,i,a);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):v(t,[r],n,i,a);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){var a,o=1,s=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var u=-1;for(a=r;as&&(r=s-l),a=r;a>=0;a--){for(var h=!0,f=0;fi&&(n=i):n=i;var a=e.length;n>a/2&&(n=a/2);for(var o=0;o>8,i=r%256,a.push(i),a.push(n);return a}(e,t.length-r),t,r,n)}function C(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function M(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&c)<<6|63&a)>127&&(u=l);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(l=(15&c)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&c)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);for(var r="",n=0;ne&&(t+=" ... "),""},a&&(e.prototype[a]=e.prototype.inspect),e.prototype.compare=function(t,r,n,i,a){if(B(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===a&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(this===t)return 0;for(var o=(a>>>=0)-(i>>>=0),s=(n>>>=0)-(r>>>=0),l=Math.min(o,s),c=this.slice(i,a),u=t.slice(r,n),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return _(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;ii)&&(r=i);for(var a="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function D(t,r,n,i,a,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>a||rt.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,a){return e=+e,r>>>=0,a||P(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function z(t,e,r,n,a){return e=+e,r>>>=0,a||P(t,0,r,8),i.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||E(t,e,this.length);for(var n=this[t],i=1,a=0;++a>>=0,e>>>=0,r||E(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||E(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||E(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||E(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||E(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||E(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||E(t,e,this.length);for(var n=this[t],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||E(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},e.prototype.readInt8=function(t,e){return t>>>=0,e||E(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||E(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||E(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||E(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||E(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||E(t,4,this.length),i.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||E(t,4,this.length),i.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||E(t,8,this.length),i.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||E(t,8,this.length),i.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||D(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,n||D(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return a},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var a=t.charCodeAt(0);("utf8"===i&&a<128||"latin1"===i)&&(t=a)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=r;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function N(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function B(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":76,buffer:107,ieee754:414}],108:[function(t,e,r){"use strict";var n=t("./lib/monotone"),i=t("./lib/triangulation"),a=t("./lib/delaunay"),o=t("./lib/filter");function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function l(t,e){return t[0]-e[0]||t[1]-e[1]}function c(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var u=!!c(r,"delaunay",!0),h=!!c(r,"interior",!0),f=!!c(r,"exterior",!0),p=!!c(r,"infinity",!1);if(!h&&!f||0===t.length)return[];var d=n(t,e);if(u||h!==f||p){for(var g=i(t.length,function(t){return t.map(s).sort(l)}(e)),m=0;m0;){for(var p=r.pop(),d=(s=r.pop(),u=-1,h=-1,l=o[s],1);d=0||(e.flip(s,p),i(t,e,r,u,s,h),i(t,e,r,s,h,u),i(t,e,r,h,p,u),i(t,e,r,p,u,h))}}},{"binary-search-bounds":113,"robust-in-sphere":507}],110:[function(t,e,r){"use strict";var n,i=t("binary-search-bounds");function a(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function o(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var n=function(t,e){for(var r=t.cells(),n=r.length,i=0;i0||l.length>0;){for(;s.length>0;){var p=s.pop();if(c[p]!==-i){c[p]=i,u[p];for(var d=0;d<3;++d){var g=f[3*p+d];g>=0&&0===c[g]&&(h[3*p+d]?l.push(g):(s.push(g),c[g]=i))}}}var m=l;l=s,s=m,l.length=0,i=-i}var v=function(t,e,r){for(var n=0,i=0;i1&&i(r[f[p-2]],r[f[p-1]],a)>0;)t.push([f[p-1],f[p-2],o]),p-=1;f.length=p,f.push(o);var d=u.upperIds;for(p=d.length;p>1&&i(r[d[p-2]],r[d[p-1]],a)<0;)t.push([d[p-2],d[p-1],o]),p-=1;d.length=p,d.push(o)}}function p(t,e){var r;return(r=t.a[0]v[0]&&i.push(new c(v,m,s,h),new c(m,v,o,h))}i.sort(u);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),x=[new l([y,1],[y,0],-1,[],[],[],[])],b=[],_=(h=0,i.length);h<_;++h){var w=i[h],A=w.type;A===a?f(b,x,t,w.a,w.idx):A===s?d(x,0,w):g(x,0,w)}return b}},{"binary-search-bounds":113,"robust-orientation":509}],112:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function i(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),n=0;n=0}}(),a.removeTriangle=function(t,e,r){var n=this.stars;o(n[t],e,r),o(n[e],r,t),o(n[r],t,e)},a.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},a.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],114:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1,r=1;rr?r:t:te?e:t}},{}],118:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n;if(r){n=e;for(var i=new Array(e.length),a=0;ae[2]?1:0)}function v(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--a){var x=e[u=(I=n[a])[0]],b=x[0],_=x[1],w=t[b],A=t[_];if((w[0]-A[0]||w[1]-A[1])<0){var C=b;b=_,_=C}x[0]=b;var M,k=x[1]=I[1];for(i&&(M=x[2]);a>0&&n[a-1][0]===u;){var I,T=(I=n[--a])[1];i?e.push([k,T,M]):e.push([k,T]),k=T}i?e.push([k,_,M]):e.push([k,_])}return f}(t,e,f,m,r));return v(e,y,r),!!y||f.length>0||m.length>0}},{"./lib/rat-seg-intersect":119,"big-rat":80,"big-rat/cmp":78,"big-rat/to-float":92,"box-intersect":98,nextafter:453,"rat-vec":488,"robust-segment-intersect":512,"union-find":545}],119:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var a=s(e,t),h=s(n,r),f=u(a,h);if(0===o(f))return null;var p=s(t,r),d=u(h,p),g=i(d,f),m=c(a,g);return l(t,m)};var n=t("big-rat/mul"),i=t("big-rat/div"),a=t("big-rat/sub"),o=t("big-rat/sign"),s=t("rat-vec/sub"),l=t("rat-vec/add"),c=t("rat-vec/muls");function u(t,e){return a(n(t[0],e[1]),n(t[1],e[0]))}},{"big-rat/div":79,"big-rat/mul":89,"big-rat/sign":90,"big-rat/sub":91,"rat-vec/add":487,"rat-vec/muls":489,"rat-vec/sub":490}],120:[function(t,e,r){"use strict";var n=t("clamp");function i(t,e){null==e&&(e=!0);var r=t[0],i=t[1],a=t[2],o=t[3];return null==o&&(o=e?1:255),e&&(r*=255,i*=255,a*=255,o*=255),16777216*(r=255&n(r,0,255))+((i=255&n(i,0,255))<<16)+((a=255&n(a,0,255))<<8)+(o=255&n(o,0,255))}e.exports=i,e.exports.to=i,e.exports.from=function(t,e){var r=(t=+t)>>>24,n=(16711680&t)>>>16,i=(65280&t)>>>8,a=255&t;return!1===e?[r,n,i,a]:[r/255,n/255,i/255,a/255]}},{clamp:117}],121:[function(t,e,r){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],122:[function(t,e,r){"use strict";var n=t("color-rgba"),i=t("clamp"),a=t("dtype");e.exports=function(t,e){"float"!==e&&e||(e="array"),"uint"===e&&(e="uint8"),"uint_clamped"===e&&(e="uint8_clamped");var r=new(a(e))(4),o="uint8"!==e&&"uint8_clamped"!==e;return t.length&&"string"!=typeof t||((t=n(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:255,o&&(r[0]/=255,r[1]/=255,r[2]/=255,r[3]/=255),r):(o?(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=null!=t[3]?t[3]:1):(r[0]=i(Math.floor(255*t[0]),0,255),r[1]=i(Math.floor(255*t[1]),0,255),r[2]=i(Math.floor(255*t[2]),0,255),r[3]=null==t[3]?255:i(Math.floor(255*t[3]),0,255)),r)}},{clamp:117,"color-rgba":124,dtype:171}],123:[function(t,r,n){(function(e){"use strict";var n=t("color-name"),i=t("is-plain-obj"),a=t("defined");r.exports=function(t){var r,s,l=[],c=1;if("string"==typeof t)if(n[t])l=n[t].slice(),s="rgb";else if("transparent"===t)c=0,s="rgb",l=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var u=(p=t.slice(1)).length;c=1,u<=4?(l=[parseInt(p[0]+p[0],16),parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16)],4===u&&(c=parseInt(p[3]+p[3],16)/255)):(l=[parseInt(p[0]+p[1],16),parseInt(p[2]+p[3],16),parseInt(p[4]+p[5],16)],8===u&&(c=parseInt(p[6]+p[7],16)/255)),l[0]||(l[0]=0),l[1]||(l[1]=0),l[2]||(l[2]=0),s="rgb"}else if(r=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var h=r[1],f="rgb"===h,p=h.replace(/a$/,"");s=p,u="cmyk"===p?4:"gray"===p?1:3,l=r[2].trim().split(/\s*,\s*/).map((function(t,e){if(/%$/.test(t))return e===u?parseFloat(t)/100:"rgb"===p?255*parseFloat(t)/100:parseFloat(t);if("h"===p[e]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==o[t])return o[t]}return parseFloat(t)})),h===p&&l.push(1),c=f?1:void 0===l[u]?1:l[u],l=l.slice(0,u)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(l=t.match(/([0-9]+)/g).map((function(t){return parseFloat(t)})),s=t.match(/([a-z])/gi).join("").toLowerCase());else if(isNaN(t))if(i(t)){var d=a(t.r,t.red,t.R,null);null!==d?(s="rgb",l=[d,a(t.g,t.green,t.G),a(t.b,t.blue,t.B)]):(s="hsl",l=[a(t.h,t.hue,t.H),a(t.s,t.saturation,t.S),a(t.l,t.lightness,t.L,t.b,t.brightness)]),c=a(t.a,t.alpha,t.opacity,1),null!=t.opacity&&(c/=100)}else(Array.isArray(t)||e.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(t))&&(l=[t[0],t[1],t[2]],s="rgb",c=4===t.length?t[3]:1);else s="rgb",l=[t>>>16,(65280&t)>>>8,255&t];return{space:s,values:l,alpha:c}};var o={red:0,orange:60,yellow:120,green:180,blue:240,purple:300}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"color-name":121,defined:166,"is-plain-obj":424}],124:[function(t,e,r){"use strict";var n=t("color-parse"),i=t("color-space/hsl"),a=t("clamp");e.exports=function(t){var e,r=n(t);return r.space?((e=Array(3))[0]=a(r.values[0],0,255),e[1]=a(r.values[1],0,255),e[2]=a(r.values[2],0,255),"h"===r.space[0]&&(e=i.rgb(e)),e.push(a(r.alpha,0,1)),e):[]}},{clamp:117,"color-parse":123,"color-space/hsl":125}],125:[function(t,e,r){"use strict";var n=t("./rgb");e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,r,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0===s)return[a=255*l,a,a];e=2*l-(r=l<.5?l*(1+s):l+s-l*s),i=[0,0,0];for(var c=0;c<3;c++)(n=o+1/3*-(c-1))<0?n++:n>1&&n--,a=6*n<1?e+6*(r-e)*n:2*n<1?r:3*n<2?e+(r-e)*(2/3-n)*6:e,i[c]=255*a;return i}},n.hsl=function(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o;return s===o?e=0:n===s?e=(i-a)/l:i===s?e=2+(a-n)/l:a===s&&(e=4+(n-i)/l),(e=Math.min(60*e,360))<0&&(e+=360),r=(o+s)/2,[e,100*(s===o?0:r<=.5?l/(s+o):l/(2-s-o)),100*r]}},{"./rgb":126}],126:[function(t,e,r){"use strict";e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},{}],127:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:1,rgb:[255,255,255,1]}],viridis:[{index:0,rgb:[68,1,84]},{index:.13,rgb:[71,44,122]},{index:.25,rgb:[59,81,139]},{index:.38,rgb:[44,113,142]},{index:.5,rgb:[33,144,141]},{index:.63,rgb:[39,173,129]},{index:.75,rgb:[92,200,99]},{index:.88,rgb:[170,220,50]},{index:1,rgb:[253,231,37]}],inferno:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[31,12,72]},{index:.25,rgb:[85,15,109]},{index:.38,rgb:[136,34,106]},{index:.5,rgb:[186,54,85]},{index:.63,rgb:[227,89,51]},{index:.75,rgb:[249,140,10]},{index:.88,rgb:[249,201,50]},{index:1,rgb:[252,255,164]}],magma:[{index:0,rgb:[0,0,4]},{index:.13,rgb:[28,16,68]},{index:.25,rgb:[79,18,123]},{index:.38,rgb:[129,37,129]},{index:.5,rgb:[181,54,122]},{index:.63,rgb:[229,80,100]},{index:.75,rgb:[251,135,97]},{index:.88,rgb:[254,194,135]},{index:1,rgb:[252,253,191]}],plasma:[{index:0,rgb:[13,8,135]},{index:.13,rgb:[75,3,161]},{index:.25,rgb:[125,3,168]},{index:.38,rgb:[168,34,150]},{index:.5,rgb:[203,70,121]},{index:.63,rgb:[229,107,93]},{index:.75,rgb:[248,148,65]},{index:.88,rgb:[253,195,40]},{index:1,rgb:[240,249,33]}],warm:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[172,0,187]},{index:.25,rgb:[219,0,170]},{index:.38,rgb:[255,0,130]},{index:.5,rgb:[255,63,74]},{index:.63,rgb:[255,123,0]},{index:.75,rgb:[234,176,0]},{index:.88,rgb:[190,228,0]},{index:1,rgb:[147,255,0]}],cool:[{index:0,rgb:[125,0,179]},{index:.13,rgb:[116,0,218]},{index:.25,rgb:[98,74,237]},{index:.38,rgb:[68,146,231]},{index:.5,rgb:[0,204,197]},{index:.63,rgb:[0,247,146]},{index:.75,rgb:[0,255,88]},{index:.88,rgb:[40,255,8]},{index:1,rgb:[147,255,0]}],"rainbow-soft":[{index:0,rgb:[125,0,179]},{index:.1,rgb:[199,0,180]},{index:.2,rgb:[255,0,121]},{index:.3,rgb:[255,108,0]},{index:.4,rgb:[222,194,0]},{index:.5,rgb:[150,255,0]},{index:.6,rgb:[0,255,55]},{index:.7,rgb:[0,246,150]},{index:.8,rgb:[50,167,222]},{index:.9,rgb:[103,51,235]},{index:1,rgb:[124,0,186]}],bathymetry:[{index:0,rgb:[40,26,44]},{index:.13,rgb:[59,49,90]},{index:.25,rgb:[64,76,139]},{index:.38,rgb:[63,110,151]},{index:.5,rgb:[72,142,158]},{index:.63,rgb:[85,174,163]},{index:.75,rgb:[120,206,163]},{index:.88,rgb:[187,230,172]},{index:1,rgb:[253,254,204]}],cdom:[{index:0,rgb:[47,15,62]},{index:.13,rgb:[87,23,86]},{index:.25,rgb:[130,28,99]},{index:.38,rgb:[171,41,96]},{index:.5,rgb:[206,67,86]},{index:.63,rgb:[230,106,84]},{index:.75,rgb:[242,149,103]},{index:.88,rgb:[249,193,135]},{index:1,rgb:[254,237,176]}],chlorophyll:[{index:0,rgb:[18,36,20]},{index:.13,rgb:[25,63,41]},{index:.25,rgb:[24,91,59]},{index:.38,rgb:[13,119,72]},{index:.5,rgb:[18,148,80]},{index:.63,rgb:[80,173,89]},{index:.75,rgb:[132,196,122]},{index:.88,rgb:[175,221,162]},{index:1,rgb:[215,249,208]}],density:[{index:0,rgb:[54,14,36]},{index:.13,rgb:[89,23,80]},{index:.25,rgb:[110,45,132]},{index:.38,rgb:[120,77,178]},{index:.5,rgb:[120,113,213]},{index:.63,rgb:[115,151,228]},{index:.75,rgb:[134,185,227]},{index:.88,rgb:[177,214,227]},{index:1,rgb:[230,241,241]}],"freesurface-blue":[{index:0,rgb:[30,4,110]},{index:.13,rgb:[47,14,176]},{index:.25,rgb:[41,45,236]},{index:.38,rgb:[25,99,212]},{index:.5,rgb:[68,131,200]},{index:.63,rgb:[114,156,197]},{index:.75,rgb:[157,181,203]},{index:.88,rgb:[200,208,216]},{index:1,rgb:[241,237,236]}],"freesurface-red":[{index:0,rgb:[60,9,18]},{index:.13,rgb:[100,17,27]},{index:.25,rgb:[142,20,29]},{index:.38,rgb:[177,43,27]},{index:.5,rgb:[192,87,63]},{index:.63,rgb:[205,125,105]},{index:.75,rgb:[216,162,148]},{index:.88,rgb:[227,199,193]},{index:1,rgb:[241,237,236]}],oxygen:[{index:0,rgb:[64,5,5]},{index:.13,rgb:[106,6,15]},{index:.25,rgb:[144,26,7]},{index:.38,rgb:[168,64,3]},{index:.5,rgb:[188,100,4]},{index:.63,rgb:[206,136,11]},{index:.75,rgb:[220,174,25]},{index:.88,rgb:[231,215,44]},{index:1,rgb:[248,254,105]}],par:[{index:0,rgb:[51,20,24]},{index:.13,rgb:[90,32,35]},{index:.25,rgb:[129,44,34]},{index:.38,rgb:[159,68,25]},{index:.5,rgb:[182,99,19]},{index:.63,rgb:[199,134,22]},{index:.75,rgb:[212,171,35]},{index:.88,rgb:[221,210,54]},{index:1,rgb:[225,253,75]}],phase:[{index:0,rgb:[145,105,18]},{index:.13,rgb:[184,71,38]},{index:.25,rgb:[186,58,115]},{index:.38,rgb:[160,71,185]},{index:.5,rgb:[110,97,218]},{index:.63,rgb:[50,123,164]},{index:.75,rgb:[31,131,110]},{index:.88,rgb:[77,129,34]},{index:1,rgb:[145,105,18]}],salinity:[{index:0,rgb:[42,24,108]},{index:.13,rgb:[33,50,162]},{index:.25,rgb:[15,90,145]},{index:.38,rgb:[40,118,137]},{index:.5,rgb:[59,146,135]},{index:.63,rgb:[79,175,126]},{index:.75,rgb:[120,203,104]},{index:.88,rgb:[193,221,100]},{index:1,rgb:[253,239,154]}],temperature:[{index:0,rgb:[4,35,51]},{index:.13,rgb:[23,51,122]},{index:.25,rgb:[85,59,157]},{index:.38,rgb:[129,79,143]},{index:.5,rgb:[175,95,130]},{index:.63,rgb:[222,112,101]},{index:.75,rgb:[249,146,66]},{index:.88,rgb:[249,196,65]},{index:1,rgb:[232,250,91]}],turbidity:[{index:0,rgb:[34,31,27]},{index:.13,rgb:[65,50,41]},{index:.25,rgb:[98,69,52]},{index:.38,rgb:[131,89,57]},{index:.5,rgb:[161,112,59]},{index:.63,rgb:[185,140,66]},{index:.75,rgb:[202,174,88]},{index:.88,rgb:[216,209,126]},{index:1,rgb:[233,246,171]}],"velocity-blue":[{index:0,rgb:[17,32,64]},{index:.13,rgb:[35,52,116]},{index:.25,rgb:[29,81,156]},{index:.38,rgb:[31,113,162]},{index:.5,rgb:[50,144,169]},{index:.63,rgb:[87,173,176]},{index:.75,rgb:[149,196,189]},{index:.88,rgb:[203,221,211]},{index:1,rgb:[254,251,230]}],"velocity-green":[{index:0,rgb:[23,35,19]},{index:.13,rgb:[24,64,38]},{index:.25,rgb:[11,95,45]},{index:.38,rgb:[39,123,35]},{index:.5,rgb:[95,146,12]},{index:.63,rgb:[152,165,18]},{index:.75,rgb:[201,186,69]},{index:.88,rgb:[233,216,137]},{index:1,rgb:[255,253,205]}],cubehelix:[{index:0,rgb:[0,0,0]},{index:.07,rgb:[22,5,59]},{index:.13,rgb:[60,4,105]},{index:.2,rgb:[109,1,135]},{index:.27,rgb:[161,0,147]},{index:.33,rgb:[210,2,142]},{index:.4,rgb:[251,11,123]},{index:.47,rgb:[255,29,97]},{index:.53,rgb:[255,54,69]},{index:.6,rgb:[255,85,46]},{index:.67,rgb:[255,120,34]},{index:.73,rgb:[255,157,37]},{index:.8,rgb:[241,191,57]},{index:.87,rgb:[224,220,93]},{index:.93,rgb:[218,241,142]},{index:1,rgb:[227,253,198]}]}},{}],128:[function(t,e,r){"use strict";var n=t("./colorScale"),i=t("lerp");function a(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}function o(t){for(var e,r="#",n=0;n<3;++n)r+=("00"+(e=(e=t[n]).toString(16))).substr(e.length);return r}function s(t){return"rgba("+t.join(",")+")"}e.exports=function(t){var e,r,l,c,u,h,f,p,d,g;if(t||(t={}),p=(t.nshades||72)-1,f=t.format||"hex",(h=t.colormap)||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!n[h])throw Error(h+" not a supported colorscale");u=n[h]}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);u=h.slice()}if(u.length>p+1)throw new Error(h+" map requires nshades to be at least size "+u.length);d=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:t.alpha.slice():"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=u.map((function(t){return Math.round(t.index*p)})),d[0]=Math.min(Math.max(d[0],0),1),d[1]=Math.min(Math.max(d[1],0),1);var m=u.map((function(t,e){var r=u[e].index,n=u[e].rgb.slice();return 4===n.length&&n[3]>=0&&n[3]<=1?n:(n[3]=d[0]+(d[1]-d[0])*r,n)})),v=[];for(g=0;g0?-1:l(t,e,a)?-1:1:0===s?c>0?1:l(t,e,r)?1:-1:i(c-s)}var f=n(t,e,r);return f>0?o>0&&n(t,e,a)>0?1:-1:f<0?o>0||n(t,e,a)>0?1:-1:n(t,e,a)>0?1:l(t,e,r)?1:-1};var n=t("robust-orientation"),i=t("signum"),a=t("two-sum"),o=t("robust-product"),s=t("robust-sum");function l(t,e,r){var n=a(t[0],-e[0]),i=a(t[1],-e[1]),l=a(r[0],-e[0]),c=a(r[1],-e[1]),u=s(o(n,l),o(i,c));return u[u.length-1]>=0}},{"robust-orientation":509,"robust-product":510,"robust-sum":514,signum:515,"two-sum":543}],130:[function(t,e,r){e.exports=function(t,e){var r=t.length,a=t.length-e.length;if(a)return a;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||n(t[0],t[1])-n(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=n(t[0],t[1]),c=n(e[0],e[1]);return n(l,t[2])-n(c,e[2])||n(l+t[2],o)-n(c+e[2],s);case 4:var u=t[0],h=t[1],f=t[2],p=t[3],d=e[0],g=e[1],m=e[2],v=e[3];return u+h+f+p-(d+g+m+v)||n(u,h,f,p)-n(d,g,m,v,d)||n(u+h,u+f,u+p,h+f,h+p,f+p)-n(d+g,d+m,d+v,g+m,g+v,m+v)||n(u+h+f,u+h+p,u+f+p,h+f+p)-n(d+g+m,d+g+v,d+m+v,g+m+v);default:for(var y=t.slice().sort(i),x=e.slice().sort(i),b=0;bt[r][0]&&(r=n);return er?[[r],[e]]:[[e]]}},{}],134:[function(t,e,r){"use strict";e.exports=function(t){var e=n(t),r=e.length;if(r<=2)return[];for(var i=new Array(r),a=e[r-1],o=0;o=e[l]&&(s+=1);a[o]=s}}return t}(n(a,!0),r)}};var n=t("incremental-convex-hull"),i=t("affine-hull")},{"affine-hull":65,"incremental-convex-hull":415}],136:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",CPV:"verde",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COG:"^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|ç)ao",CYP:"cyprus",CSK:"czechoslovakia",CZE:"^(?=.*rep).*czech|czechia|bohemia",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"(^ireland)|(^republic.*ireland)",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"fed.*micronesia|micronesia.*fed",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",KOR:"^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",MDA:"moldov|b(a|e)ssarabia",REU:"r(e|é)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|é)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|ã)o.?tom(e|é)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"south.africa|s\\\\..?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",TJK:"tajik",THA:"thailand|\\bsiam",MKD:"macedonia|fyrom",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",TZA:"tanzania",USA:"united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],137:[function(t,e,r){e.exports=["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]},{}],138:[function(t,e,r){e.exports=["normal","condensed","semi-condensed","extra-condensed","ultra-condensed","expanded","semi-expanded","extra-expanded","ultra-expanded"]},{}],139:[function(t,e,r){e.exports=["normal","italic","oblique"]},{}],140:[function(t,e,r){e.exports=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"]},{}],141:[function(t,e,r){"use strict";e.exports={parse:t("./parse"),stringify:t("./stringify")}},{"./parse":143,"./stringify":144}],142:[function(t,e,r){"use strict";var n=t("css-font-size-keywords");e.exports={isSize:function(t){return/^[\d\.]/.test(t)||-1!==t.indexOf("/")||-1!==n.indexOf(t)}}},{"css-font-size-keywords":137}],143:[function(t,e,r){"use strict";var n=t("unquote"),i=t("css-global-keywords"),a=t("css-system-font-keywords"),o=t("css-font-weight-keywords"),s=t("css-font-style-keywords"),l=t("css-font-stretch-keywords"),c=t("string-split-by"),u=t("./lib/util").isSize;e.exports=f;var h=f.cache={};function f(t){if("string"!=typeof t)throw new Error("Font argument must be a string.");if(h[t])return h[t];if(""===t)throw new Error("Cannot parse an empty string.");if(-1!==a.indexOf(t))return h[t]={system:t};for(var e,r={style:"normal",variant:"normal",weight:"normal",stretch:"normal",lineHeight:"normal",size:"1rem",family:["serif"]},f=c(t,/\s+/);e=f.shift();){if(-1!==i.indexOf(e))return["style","variant","weight","stretch"].forEach((function(t){r[t]=e})),h[t]=r;if(-1===s.indexOf(e))if("normal"!==e&&"small-caps"!==e)if(-1===l.indexOf(e)){if(-1===o.indexOf(e)){if(u(e)){var d=c(e,"/");if(r.size=d[0],null!=d[1]?r.lineHeight=p(d[1]):"/"===f[0]&&(f.shift(),r.lineHeight=p(f.shift())),!f.length)throw new Error("Missing required font-family.");return r.family=c(f.join(" "),/\s*,\s*/).map(n),h[t]=r}throw new Error("Unknown or unsupported font token: "+e)}r.weight=e}else r.stretch=e;else r.variant=e;else r.style=e}throw new Error("Missing required font-size.")}function p(t){var e=parseFloat(t);return e.toString()===t?e:t}},{"./lib/util":142,"css-font-stretch-keywords":138,"css-font-style-keywords":139,"css-font-weight-keywords":140,"css-global-keywords":145,"css-system-font-keywords":146,"string-split-by":528,unquote:547}],144:[function(t,e,r){"use strict";var n=t("pick-by-alias"),i=t("./lib/util").isSize,a=g(t("css-global-keywords")),o=g(t("css-system-font-keywords")),s=g(t("css-font-weight-keywords")),l=g(t("css-font-style-keywords")),c=g(t("css-font-stretch-keywords")),u={normal:1,"small-caps":1},h={serif:1,"sans-serif":1,monospace:1,cursive:1,fantasy:1,"system-ui":1},f="1rem",p="serif";function d(t,e){if(t&&!e[t]&&!a[t])throw Error("Unknown keyword `"+t+"`");return t}function g(t){for(var e={},r=0;r=0;--p)a[p]=c*t[p]+u*e[p]+h*r[p]+f*n[p];return a}return c*t+u*e+h*r+f*n},e.exports.derivative=function(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}},{}],148:[function(t,e,r){"use strict";var n=t("./lib/thunk.js");function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}e.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var a=0;a0)throw new Error("cwise: pre() block may not reference array args");if(a0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(a),e.shimArgs.push("scalar"+a);else if("index"===o){if(e.indexArgs.push(a),a0)throw new Error("cwise: pre() block may not reference array index");if(a0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(a),ar.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},{"./lib/thunk.js":150}],149:[function(t,e,r){"use strict";var n=t("uniq");function i(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,h=0;for(n=0;n0&&l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",h,"]-=s",h].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function a(t,e,r){for(var n=t.body,i=[],a=[],o=0;o0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}e.exports=function(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,s=new Array(t.arrayArgs.length),l=new Array(t.arrayArgs.length),c=0;c0&&x.push("shape=SS.slice(0)"),t.indexArgs.length>0){var b=new Array(r);for(c=0;c0&&y.push("var "+x.join(",")),c=0;c3&&y.push(a(t.pre,t,l));var C=a(t.body,t,l),M=function(t){for(var e=0,r=t[0].length;e0,c=[],u=0;u0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(u=0;u3&&y.push(a(t.post,t,l)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+y.join("\n")+"\n----------");var k=[t.funcName||"unnamed","_cwise_loop_",s[0].join("s"),"m",M,o(l)].join("");return new Function(["function ",k,"(",v.join(","),"){",y.join("\n"),"} return ",k].join(""))()}},{uniq:546}],150:[function(t,e,r){"use strict";var n=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+h+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+h+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),u=0;ue?1:t>=e?0:NaN}function r(t){var r;return 1===t.length&&(r=t,t=function(t,n){return e(r(t),n)}),{left:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}var n=r(e),i=n.right,a=n.left;function o(t,e){return[t,e]}function s(t){return null===t?NaN:+t}function l(t,e){var r,n,i=t.length,a=0,o=-1,l=0,c=0;if(null==e)for(;++o1)return c/(a-1)}function c(t,e){var r=l(t,e);return r?Math.sqrt(r):r}function u(t,e){var r,n,i,a=t.length,o=-1;if(null==e){for(;++o=r)for(n=i=r;++or&&(n=r),i=r)for(n=i=r;++or&&(n=r),i=0?(a>=v?10:a>=y?5:a>=x?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=v?10:a>=y?5:a>=x?2:1)}function _(t,e,r){var n=Math.abs(e-t)/Math.max(0,r),i=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),a=n/i;return a>=v?i*=10:a>=y?i*=5:a>=x&&(i*=2),e=1)return+r(t[n-1],n-1,t);var n,i=(n-1)*e,a=Math.floor(i),o=+r(t[a],a,t);return o+(+r(t[a+1],a+1,t)-o)*(i-a)}}function C(t,e){var r,n,i=t.length,a=-1;if(null==e){for(;++a=r)for(n=r;++ar&&(n=r)}else for(;++a=r)for(n=r;++ar&&(n=r);return n}function M(t){if(!(i=t.length))return[];for(var e=-1,r=C(t,k),n=new Array(r);++et?1:e>=t?0:NaN},t.deviation=c,t.extent=u,t.histogram=function(){var t=g,e=u,r=w;function n(n){var a,o,s=n.length,l=new Array(s);for(a=0;ah;)f.pop(),--p;var d,g=new Array(p+1);for(a=0;a<=p;++a)(d=g[a]=[]).x0=a>0?f[a-1]:u,d.x1=a=r)for(n=r;++an&&(n=r)}else for(;++a=r)for(n=r;++an&&(n=r);return n},t.mean=function(t,e){var r,n=t.length,i=n,a=-1,o=0;if(null==e)for(;++a=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r},t.min=C,t.pairs=function(t,e){null==e&&(e=o);for(var r=0,n=t.length-1,i=t[0],a=new Array(n<0?0:n);r0)return[t];if((n=e0)for(t=Math.ceil(t/o),e=Math.floor(e/o),a=new Array(i=Math.ceil(e-t+1));++s=l.length)return null!=t&&n.sort(t),null!=e?e(n):n;for(var s,c,h,f=-1,p=n.length,d=l[i++],g=r(),m=a();++fl.length)return r;var i,a=c[n-1];return null!=e&&n>=l.length?i=r.entries():(i=[],r.each((function(e,r){i.push({key:r,values:t(e,n)})}))),null!=a?i.sort((function(t,e){return a(t.key,e.key)})):i}(u(t,0,a,o),0)},key:function(t){return l.push(t),s},sortKeys:function(t){return c[l.length-1]=t,s},sortValues:function(e){return t=e,s},rollup:function(t){return e=t,s}}},t.set=c,t.map=r,t.keys=function(t){var e=[];for(var r in t)e.push(r);return e},t.values=function(t){var e=[];for(var r in t)e.push(t[r]);return e},t.entries=function(t){var e=[];for(var r in t)e.push({key:r,value:t[r]});return e},Object.defineProperty(t,"__esModule",{value:!0})}))},{}],156:[function(t,e,r){!function(t,n){n("object"==typeof r&&void 0!==e?r:(t=t||self).d3=t.d3||{})}(this,(function(t){"use strict";function e(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function r(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function n(){}var i="\\s*([+-]?\\d+)\\s*",a="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",o="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",s=/^#([0-9a-f]{3,8})$/,l=new RegExp("^rgb\\("+[i,i,i]+"\\)$"),c=new RegExp("^rgb\\("+[o,o,o]+"\\)$"),u=new RegExp("^rgba\\("+[i,i,i,a]+"\\)$"),h=new RegExp("^rgba\\("+[o,o,o,a]+"\\)$"),f=new RegExp("^hsl\\("+[a,o,o]+"\\)$"),p=new RegExp("^hsla\\("+[a,o,o,a]+"\\)$"),d={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function g(){return this.rgb().formatHex()}function m(){return this.rgb().formatRgb()}function v(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=s.exec(t))?(r=e[1].length,e=parseInt(e[1],16),6===r?y(e):3===r?new w(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===r?new w(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===r?new w(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=l.exec(t))?new w(e[1],e[2],e[3],1):(e=c.exec(t))?new w(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=u.exec(t))?x(e[1],e[2],e[3],e[4]):(e=h.exec(t))?x(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=f.exec(t))?k(e[1],e[2]/100,e[3]/100,1):(e=p.exec(t))?k(e[1],e[2]/100,e[3]/100,e[4]):d.hasOwnProperty(t)?y(d[t]):"transparent"===t?new w(NaN,NaN,NaN,0):null}function y(t){return new w(t>>16&255,t>>8&255,255&t,1)}function x(t,e,r,n){return n<=0&&(t=e=r=NaN),new w(t,e,r,n)}function b(t){return t instanceof n||(t=v(t)),t?new w((t=t.rgb()).r,t.g,t.b,t.opacity):new w}function _(t,e,r,n){return 1===arguments.length?b(t):new w(t,e,r,null==n?1:n)}function w(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function A(){return"#"+M(this.r)+M(this.g)+M(this.b)}function C(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function M(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function k(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new L(t,e,r,n)}function I(t){if(t instanceof L)return new L(t.h,t.s,t.l,t.opacity);if(t instanceof n||(t=v(t)),!t)return new L;if(t instanceof L)return t;var e=(t=t.rgb()).r/255,r=t.g/255,i=t.b/255,a=Math.min(e,r,i),o=Math.max(e,r,i),s=NaN,l=o-a,c=(o+a)/2;return l?(s=e===o?(r-i)/l+6*(r0&&c<1?0:s,new L(s,l,c,t.opacity)}function T(t,e,r,n){return 1===arguments.length?I(t):new L(t,e,r,null==n?1:n)}function L(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function S(t,e,r){return 255*(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)}e(n,v,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:g,formatHex:g,formatHsl:function(){return I(this).formatHsl()},formatRgb:m,toString:m}),e(w,_,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new w(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new w(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:A,formatHex:A,formatRgb:C,toString:C})),e(L,T,r(n,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new L(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new L(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new w(S(t>=240?t-240:t+120,i,n),S(t,i,n),S(t<120?t+240:t-120,i,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var E=Math.PI/180,D=180/Math.PI,P=.96422,O=1,z=.82521,R=4/29,F=6/29,N=3*F*F,j=F*F*F;function B(t){if(t instanceof V)return new V(t.l,t.a,t.b,t.opacity);if(t instanceof X)return J(t);t instanceof w||(t=b(t));var e,r,n=q(t.r),i=q(t.g),a=q(t.b),o=U((.2225045*n+.7168786*i+.0606169*a)/O);return n===i&&i===a?e=r=o:(e=U((.4360747*n+.3850649*i+.1430804*a)/P),r=U((.0139322*n+.0971045*i+.7141733*a)/z)),new V(116*o-16,500*(e-o),200*(o-r),t.opacity)}function Y(t,e,r,n){return 1===arguments.length?B(t):new V(t,e,r,null==n?1:n)}function V(t,e,r,n){this.l=+t,this.a=+e,this.b=+r,this.opacity=+n}function U(t){return t>j?Math.pow(t,1/3):t/N+R}function H(t){return t>F?t*t*t:N*(t-R)}function G(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function q(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function W(t){if(t instanceof X)return new X(t.h,t.c,t.l,t.opacity);if(t instanceof V||(t=B(t)),0===t.a&&0===t.b)return new X(NaN,0=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}}))}function a(t,e){for(var r,n=0,i=t.length;n0)for(var r,n,i=new Array(r),a=0;af+c||np+c||au.index){var h=f-s.x-s.vx,m=p-s.y-s.vy,v=h*h+m*m;vt.r&&(t.r=t[e].r)}function f(){if(r){var e,i,a=r.length;for(n=new Array(a),e=0;e=c)){(t.data!==r||t.next)&&(0===h&&(d+=(h=o())*h),0===f&&(d+=(f=o())*f),d1?(null==r?u.remove(t):u.set(t,y(r)),e):u.get(t)},find:function(e,r,n){var i,a,o,s,l,c=0,u=t.length;for(null==n?n=1/0:n*=n,c=0;c1?(f.on(t,r),e):f.on(t)}}},t.forceX=function(t){var e,r,n,i=a(.1);function o(t){for(var i,a=0,o=e.length;a=0;)e+=r[n].value;else e=1;t.value=e}function a(t,e){var r,n,i,a,s,u=new c(t),h=+t.value&&(u.value=t.value),f=[u];for(null==e&&(e=o);r=f.pop();)if(h&&(r.value=+r.data.value),(i=e(r.data))&&(s=i.length))for(r.children=new Array(s),a=s-1;a>=0;--a)f.push(n=r.children[a]=new c(i[a])),n.parent=r,n.depth=r.depth+1;return u.eachBefore(l)}function o(t){return t.children}function s(t){t.data=t.data.data}function l(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function c(t){this.data=t,this.depth=this.height=0,this.parent=null}c.prototype=a.prototype={constructor:c,count:function(){return this.eachAfter(i)},each:function(t){var e,r,n,i,a=this,o=[a];do{for(e=o.reverse(),o=[];a=e.pop();)if(t(a),r=a.children)for(n=0,i=r.length;n=0;--r)i.push(e[r]);return this},sum:function(t){return this.eachAfter((function(e){for(var r=+t(e.data)||0,n=e.children,i=n&&n.length;--i>=0;)r+=n[i].value;e.value=r}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,r=function(t,e){if(t===e)return t;var r=t.ancestors(),n=e.ancestors(),i=null;for(t=r.pop(),e=n.pop();t===e;)i=t,t=r.pop(),e=n.pop();return i}(e,t),n=[e];e!==r;)e=e.parent,n.push(e);for(var i=n.length;t!==r;)n.splice(i,0,t),t=t.parent;return n},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(r){r!==t&&e.push({source:r.parent,target:r})})),e},copy:function(){return a(this).eachBefore(s)}};var u=Array.prototype.slice;function h(t){for(var e,r,n=0,i=(t=function(t){for(var e,r,n=t.length;n;)r=Math.random()*n--|0,e=t[n],t[n]=t[r],t[r]=e;return t}(u.call(t))).length,a=[];n0&&r*r>n*n+i*i}function g(t,e){for(var r=0;r(o*=o)?(n=(c+o-i)/(2*c),a=Math.sqrt(Math.max(0,o/c-n*n)),r.x=t.x-n*s-a*l,r.y=t.y-n*l+a*s):(n=(c+i-o)/(2*c),a=Math.sqrt(Math.max(0,i/c-n*n)),r.x=e.x+n*s-a*l,r.y=e.y+n*l+a*s)):(r.x=e.x+r.r,r.y=e.y)}function b(t,e){var r=t.r+e.r-1e-6,n=e.x-t.x,i=e.y-t.y;return r>0&&r*r>n*n+i*i}function _(t){var e=t._,r=t.next._,n=e.r+r.r,i=(e.x*r.r+r.x*e.r)/n,a=(e.y*r.r+r.y*e.r)/n;return i*i+a*a}function w(t){this._=t,this.next=null,this.previous=null}function A(t){if(!(i=t.length))return 0;var e,r,n,i,a,o,s,l,c,u,f;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(r=t[1],e.x=-r.r,r.x=e.r,r.y=0,!(i>2))return e.r+r.r;x(r,e,n=t[2]),e=new w(e),r=new w(r),n=new w(n),e.next=n.previous=r,r.next=e.previous=n,n.next=r.previous=e;t:for(s=3;sf&&(f=s),m=u*u*g,(p=Math.max(f/m,m/h))>d){u-=s;break}d=p}v.push(o={value:u,dice:l1?e:1)},r}(q),X=function t(e){function r(t,r,n,i,a){if((o=t._squarify)&&o.ratio===e)for(var o,s,l,c,u,h=-1,f=o.length,p=t.value;++h1?e:1)},r}(q);t.cluster=function(){var t=e,i=1,a=1,o=!1;function s(e){var s,l=0;e.eachAfter((function(e){var i=e.children;i?(e.x=function(t){return t.reduce(r,0)/t.length}(i),e.y=function(t){return 1+t.reduce(n,0)}(i)):(e.x=s?l+=t(e,s):0,e.y=0,s=e)}));var c=function(t){for(var e;e=t.children;)t=e[0];return t}(e),u=function(t){for(var e;e=t.children;)t=e[e.length-1];return t}(e),h=c.x-t(c,u)/2,f=u.x+t(u,c)/2;return e.eachAfter(o?function(t){t.x=(t.x-e.x)*i,t.y=(e.y-t.y)*a}:function(t){t.x=(t.x-h)/(f-h)*i,t.y=(1-(e.y?t.y/e.y:1))*a})}return s.separation=function(e){return arguments.length?(t=e,s):t},s.size=function(t){return arguments.length?(o=!1,i=+t[0],a=+t[1],s):o?null:[i,a]},s.nodeSize=function(t){return arguments.length?(o=!0,i=+t[0],a=+t[1],s):o?[i,a]:null},s},t.hierarchy=a,t.pack=function(){var t=null,e=1,r=1,n=k;function i(i){return i.x=e/2,i.y=r/2,t?i.eachBefore(L(t)).eachAfter(S(n,.5)).eachBefore(E(1)):i.eachBefore(L(T)).eachAfter(S(k,1)).eachAfter(S(n,i.r/Math.min(e,r))).eachBefore(E(Math.min(e,r)/(2*i.r))),i}return i.radius=function(e){return arguments.length?(t=C(e),i):t},i.size=function(t){return arguments.length?(e=+t[0],r=+t[1],i):[e,r]},i.padding=function(t){return arguments.length?(n="function"==typeof t?t:I(+t),i):n},i},t.packEnclose=h,t.packSiblings=function(t){return A(t),t},t.partition=function(){var t=1,e=1,r=0,n=!1;function i(i){var a=i.height+1;return i.x0=i.y0=r,i.x1=t,i.y1=e/a,i.eachBefore(function(t,e){return function(n){n.children&&P(n,n.x0,t*(n.depth+1)/e,n.x1,t*(n.depth+2)/e);var i=n.x0,a=n.y0,o=n.x1-r,s=n.y1-r;o0)throw new Error("cycle");return a}return r.id=function(e){return arguments.length?(t=M(e),r):t},r.parentId=function(t){return arguments.length?(e=M(t),r):e},r},t.tree=function(){var t=j,e=1,r=1,n=null;function i(i){var l=function(t){for(var e,r,n,i,a,o=new H(t,0),s=[o];e=s.pop();)if(n=e._.children)for(e.children=new Array(a=n.length),i=a-1;i>=0;--i)s.push(r=e.children[i]=new H(n[i],i)),r.parent=e;return(o.parent=new H(null,0)).children=[o],o}(i);if(l.eachAfter(a),l.parent.m=-l.z,l.eachBefore(o),n)i.eachBefore(s);else{var c=i,u=i,h=i;i.eachBefore((function(t){t.xu.x&&(u=t),t.depth>h.depth&&(h=t)}));var f=c===u?1:t(c,u)/2,p=f-c.x,d=e/(u.x+f+p),g=r/(h.depth||1);i.eachBefore((function(t){t.x=(t.x+p)*d,t.y=t.depth*g}))}return i}function a(e){var r=e.children,n=e.parent.children,i=e.i?n[e.i-1]:null;if(r){!function(t){for(var e,r=0,n=0,i=t.children,a=i.length;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(e);var a=(r[0].z+r[r.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-a):e.z=a}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,r,n){if(r){for(var i,a=e,o=e,s=r,l=a.parent.children[0],c=a.m,u=o.m,h=s.m,f=l.m;s=Y(s),a=B(a),s&&a;)l=B(l),(o=Y(o)).a=e,(i=s.z+h-a.z-c+t(s._,a._))>0&&(V(U(s,e,n),e,i),c+=i,u+=i),h+=s.m,c+=a.m,f+=l.m,u+=o.m;s&&!Y(o)&&(o.t=s,o.m+=h-u),a&&!B(l)&&(l.t=a,l.m+=c-f,n=e)}return n}(e,i,e.parent.A||n[0])}function o(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=e,t.y=t.depth*r}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(n=!1,e=+t[0],r=+t[1],i):n?null:[e,r]},i.nodeSize=function(t){return arguments.length?(n=!0,e=+t[0],r=+t[1],i):n?[e,r]:null},i},t.treemap=function(){var t=Z,e=!1,r=1,n=1,i=[0],a=k,o=k,s=k,l=k,c=k;function u(t){return t.x0=t.y0=0,t.x1=r,t.y1=n,t.eachBefore(h),i=[0],e&&t.eachBefore(D),t}function h(e){var r=i[e.depth],n=e.x0+r,u=e.y0+r,h=e.x1-r,f=e.y1-r;h=r-1){var u=s[e];return u.x0=i,u.y0=a,u.x1=o,void(u.y1=l)}for(var h=c[e],f=n/2+h,p=e+1,d=r-1;p>>1;c[g]l-a){var y=(i*v+o*m)/n;t(e,p,m,i,a,y,l),t(p,r,v,y,a,o,l)}else{var x=(a*v+l*m)/n;t(e,p,m,i,a,o,x),t(p,r,v,i,x,o,l)}}(0,l,t.value,e,r,n,i)},t.treemapDice=P,t.treemapResquarify=X,t.treemapSlice=G,t.treemapSliceDice=function(t,e,r,n,i){(1&t.depth?G:P)(t,e,r,n,i)},t.treemapSquarify=Z,Object.defineProperty(t,"__esModule",{value:!0})}))},{}],160:[function(t,e,r){!function(n,i){"object"==typeof r&&void 0!==e?i(r,t("d3-color")):i((n=n||self).d3=n.d3||{},n.d3)}(this,(function(t,e){"use strict";function r(t,e,r,n,i){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*r+(1+3*t+3*a-3*o)*n+o*i)/6}function n(t){var e=t.length-1;return function(n){var i=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),a=t[i],o=t[i+1],s=i>0?t[i-1]:2*a-o,l=i180||r<-180?r-360*Math.round(r/360):r):a(isNaN(t)?e:t)}function l(t){return 1==(t=+t)?c:function(e,r){return r-e?function(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}(e,r,t):a(isNaN(e)?r:e)}}function c(t,e){var r=e-t;return r?o(t,r):a(isNaN(t)?e:t)}var u=function t(r){var n=l(r);function i(t,r){var i=n((t=e.rgb(t)).r,(r=e.rgb(r)).r),a=n(t.g,r.g),o=n(t.b,r.b),s=c(t.opacity,r.opacity);return function(e){return t.r=i(e),t.g=a(e),t.b=o(e),t.opacity=s(e),t+""}}return i.gamma=t,i}(1);function h(t){return function(r){var n,i,a=r.length,o=new Array(a),s=new Array(a),l=new Array(a);for(n=0;na&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:y(r,n)})),a=_.lastIndex;return a180?e+=360:e-t>180&&(t+=360),a.push({i:r.push(i(r)+"rotate(",null,n)-2,x:y(t,e)})):e&&r.push(i(r)+"rotate("+e+n)}(a.rotate,o.rotate,s,l),function(t,e,r,a){t!==e?a.push({i:r.push(i(r)+"skewX(",null,n)-2,x:y(t,e)}):e&&r.push(i(r)+"skewX("+e+n)}(a.skewX,o.skewX,s,l),function(t,e,r,n,a,o){if(t!==r||e!==n){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:y(t,r)},{i:s-2,x:y(e,n)})}else 1===r&&1===n||a.push(i(a)+"scale("+r+","+n+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,r=-1,n=l.length;++r1e-6)if(Math.abs(h*l-c*u)>1e-6&&a){var p=n-o,d=i-s,g=l*l+c*c,m=p*p+d*d,v=Math.sqrt(g),y=Math.sqrt(f),x=a*Math.tan((e-Math.acos((g+f-m)/(2*v*y)))/2),b=x/y,_=x/v;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*u)+","+(r+b*h)),this._+="A"+a+","+a+",0,0,"+ +(h*p>u*d)+","+(this._x1=t+_*l)+","+(this._y1=r+_*c)}else this._+="L"+(this._x1=t)+","+(this._y1=r)},arc:function(t,i,a,o,s,l){t=+t,i=+i;var c=(a=+a)*Math.cos(o),u=a*Math.sin(o),h=t+c,f=i+u,p=1^l,d=l?o-s:s-o;if(a<0)throw new Error("negative radius: "+a);null===this._x1?this._+="M"+h+","+f:(Math.abs(this._x1-h)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+h+","+f),a&&(d<0&&(d=d%r+r),d>n?this._+="A"+a+","+a+",0,1,"+p+","+(t-c)+","+(i-u)+"A"+a+","+a+",0,1,"+p+","+(this._x1=h)+","+(this._y1=f):d>1e-6&&(this._+="A"+a+","+a+",0,"+ +(d>=e)+","+p+","+(this._x1=t+a*Math.cos(s))+","+(this._y1=i+a*Math.sin(s))))},rect:function(t,e,r,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +r+"v"+ +n+"h"+-r+"Z"},toString:function(){return this._}},t.path=a,Object.defineProperty(t,"__esModule",{value:!0})}))},{}],162:[function(t,e,r){!function(t,n){n("object"==typeof r&&void 0!==e?r:t.d3=t.d3||{})}(this,(function(t){"use strict";function e(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var i,a,o,s,l,c,u,h,f,p=t._root,d={data:n},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!p)return t._root=d,t;for(;p.length;)if((c=e>=(a=(g+v)/2))?g=a:v=a,(u=r>=(o=(m+y)/2))?m=o:y=o,i=p,!(p=p[h=u<<1|c]))return i[h]=d,t;if(s=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===s&&r===l)return d.next=p,i?i[h]=d:t._root=d,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(a=(g+v)/2))?g=a:v=a,(u=r>=(o=(m+y)/2))?m=o:y=o}while((h=u<<1|c)==(f=(l>=o)<<1|s>=a));return i[f]=p,i[h]=d,t}var r=function(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i};function n(t){return t[0]}function i(t){return t[1]}function a(t,e,r){var a=new o(null==e?n:e,null==r?i:r,NaN,NaN,NaN,NaN);return null==t?a:a.addAll(t)}function o(t,e,r,n,i,a){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=a,this._root=void 0}function s(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var l=a.prototype=o.prototype;l.copy=function(){var t,e,r=new o(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=s(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var i=0;i<4;++i)(e=n.source[i])&&(e.length?t.push({source:e,target:n.target[i]=new Array(4)}):n.target[i]=s(e));return r},l.add=function(t){var r=+this._x.call(null,t),n=+this._y.call(null,t);return e(this.cover(r,n),r,n,t)},l.addAll=function(t){var r,n,i,a,o=t.length,s=new Array(o),l=new Array(o),c=1/0,u=1/0,h=-1/0,f=-1/0;for(n=0;nh&&(h=i),af&&(f=a));for(ht||t>i||n>e||e>a))return this;var o,s,l=i-r,c=this._root;switch(s=(e<(n+a)/2)<<1|t<(r+i)/2){case 0:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),t>(i=r+l)||e>a);break;case 1:do{(o=new Array(4))[s]=c,c=o}while(a=n+(l*=2),(r=i-l)>t||e>a);break;case 2:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),t>(i=r+l)||n>e);break;case 3:do{(o=new Array(4))[s]=c,c=o}while(n=a-(l*=2),(r=i-l)>t||n>e)}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=n,this._x1=i,this._y1=a,this},l.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},l.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},l.find=function(t,e,n){var i,a,o,s,l,c,u,h=this._x0,f=this._y0,p=this._x1,d=this._y1,g=[],m=this._root;for(m&&g.push(new r(m,h,f,p,d)),null==n?n=1/0:(h=t-n,f=e-n,p=t+n,d=e+n,n*=n);c=g.pop();)if(!(!(m=c.node)||(a=c.x0)>p||(o=c.y0)>d||(s=c.x1)=y)<<1|t>=v)&&(c=g[g.length-1],g[g.length-1]=g[g.length-1-u],g[g.length-1-u]=c)}else{var x=t-+this._x.call(null,m.data),b=e-+this._y.call(null,m.data),_=x*x+b*b;if(_=(s=(d+m)/2))?d=s:m=s,(u=o>=(l=(g+v)/2))?g=l:v=l,e=p,!(p=p[h=u<<1|c]))return this;if(!p.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(r=e,f=h)}for(;p.data!==t;)if(n=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,n?(i?n.next=i:delete n.next,this):e?(i?e[h]=i:delete e[h],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(r?r[f]=p:this._root=p),this):(this._root=i,this)},l.removeAll=function(t){for(var e=0,r=t.length;e=1?f:t<=-1?-f:Math.asin(t)}function g(t){return t.innerRadius}function m(t){return t.outerRadius}function v(t){return t.startAngle}function y(t){return t.endAngle}function x(t){return t&&t.padAngle}function b(t,e,r,n,i,a,s){var l=t-r,u=e-n,h=(s?a:-a)/c(l*l+u*u),f=h*u,p=-h*l,d=t+f,g=e+p,m=r+f,v=n+p,y=(d+m)/2,x=(g+v)/2,b=m-d,_=v-g,w=b*b+_*_,A=i-a,C=d*v-m*g,M=(_<0?-1:1)*c(o(0,A*A*w-C*C)),k=(C*_-b*M)/w,I=(-C*b-_*M)/w,T=(C*_+b*M)/w,L=(-C*b+_*M)/w,S=k-y,E=I-x,D=T-y,P=L-x;return S*S+E*E>D*D+P*P&&(k=T,I=L),{cx:k,cy:I,x01:-f,y01:-p,x11:k*(i/A-1),y11:I*(i/A-1)}}function _(t){this._context=t}function w(t){return new _(t)}function A(t){return t[0]}function C(t){return t[1]}function M(){var t=A,n=C,i=r(!0),a=null,o=w,s=null;function l(r){var l,c,u,h=r.length,f=!1;for(null==a&&(s=o(u=e.path())),l=0;l<=h;++l)!(l=h;--f)c.point(v[f],y[f]);c.lineEnd(),c.areaEnd()}m&&(v[u]=+t(p,u,r),y[u]=+i(p,u,r),c.point(n?+n(p,u,r):v[u],a?+a(p,u,r):y[u]))}if(d)return c=null,d+""||null}function h(){return M().defined(o).curve(l).context(s)}return u.x=function(e){return arguments.length?(t="function"==typeof e?e:r(+e),n=null,u):t},u.x0=function(e){return arguments.length?(t="function"==typeof e?e:r(+e),u):t},u.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:r(+t),u):n},u.y=function(t){return arguments.length?(i="function"==typeof t?t:r(+t),a=null,u):i},u.y0=function(t){return arguments.length?(i="function"==typeof t?t:r(+t),u):i},u.y1=function(t){return arguments.length?(a=null==t?null:"function"==typeof t?t:r(+t),u):a},u.lineX0=u.lineY0=function(){return h().x(t).y(i)},u.lineY1=function(){return h().x(t).y(a)},u.lineX1=function(){return h().x(n).y(i)},u.defined=function(t){return arguments.length?(o="function"==typeof t?t:r(!!t),u):o},u.curve=function(t){return arguments.length?(l=t,null!=s&&(c=l(s)),u):l},u.context=function(t){return arguments.length?(null==t?s=c=null:c=l(s=t),u):s},u}function I(t,e){return et?1:e>=t?0:NaN}function T(t){return t}_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}};var L=E(w);function S(t){this._curve=t}function E(t){function e(e){return new S(t(e))}return e._curve=t,e}function D(t){var e=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?e(E(t)):e()._curve},t}function P(){return D(M().curve(L))}function O(){var t=k().curve(L),e=t.curve,r=t.lineX0,n=t.lineX1,i=t.lineY0,a=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return D(r())},delete t.lineX0,t.lineEndAngle=function(){return D(n())},delete t.lineX1,t.lineInnerRadius=function(){return D(i())},delete t.lineY0,t.lineOuterRadius=function(){return D(a())},delete t.lineY1,t.curve=function(t){return arguments.length?e(E(t)):e()._curve},t}function z(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}S.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,e){this._curve.point(e*Math.sin(t),e*-Math.cos(t))}};var R=Array.prototype.slice;function F(t){return t.source}function N(t){return t.target}function j(t){var n=F,i=N,a=A,o=C,s=null;function l(){var r,l=R.call(arguments),c=n.apply(this,l),u=i.apply(this,l);if(s||(s=r=e.path()),t(s,+a.apply(this,(l[0]=c,l)),+o.apply(this,l),+a.apply(this,(l[0]=u,l)),+o.apply(this,l)),r)return s=null,r+""||null}return l.source=function(t){return arguments.length?(n=t,l):n},l.target=function(t){return arguments.length?(i=t,l):i},l.x=function(t){return arguments.length?(a="function"==typeof t?t:r(+t),l):a},l.y=function(t){return arguments.length?(o="function"==typeof t?t:r(+t),l):o},l.context=function(t){return arguments.length?(s=null==t?null:t,l):s},l}function B(t,e,r,n,i){t.moveTo(e,r),t.bezierCurveTo(e=(e+n)/2,r,e,i,n,i)}function Y(t,e,r,n,i){t.moveTo(e,r),t.bezierCurveTo(e,r=(r+i)/2,n,r,n,i)}function V(t,e,r,n,i){var a=z(e,r),o=z(e,r=(r+i)/2),s=z(n,r),l=z(n,i);t.moveTo(a[0],a[1]),t.bezierCurveTo(o[0],o[1],s[0],s[1],l[0],l[1])}var U={draw:function(t,e){var r=Math.sqrt(e/h);t.moveTo(r,0),t.arc(0,0,r,0,p)}},H={draw:function(t,e){var r=Math.sqrt(e/5)/2;t.moveTo(-3*r,-r),t.lineTo(-r,-r),t.lineTo(-r,-3*r),t.lineTo(r,-3*r),t.lineTo(r,-r),t.lineTo(3*r,-r),t.lineTo(3*r,r),t.lineTo(r,r),t.lineTo(r,3*r),t.lineTo(-r,3*r),t.lineTo(-r,r),t.lineTo(-3*r,r),t.closePath()}},G=Math.sqrt(1/3),q=2*G,W={draw:function(t,e){var r=Math.sqrt(e/q),n=r*G;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},Z=Math.sin(h/10)/Math.sin(7*h/10),X=Math.sin(p/10)*Z,J=-Math.cos(p/10)*Z,K={draw:function(t,e){var r=Math.sqrt(.8908130915292852*e),n=X*r,i=J*r;t.moveTo(0,-r),t.lineTo(n,i);for(var a=1;a<5;++a){var o=p*a/5,s=Math.cos(o),l=Math.sin(o);t.lineTo(l*r,-s*r),t.lineTo(s*n-l*i,l*n+s*i)}t.closePath()}},Q={draw:function(t,e){var r=Math.sqrt(e),n=-r/2;t.rect(n,n,r,r)}},$=Math.sqrt(3),tt={draw:function(t,e){var r=-Math.sqrt(e/(3*$));t.moveTo(0,2*r),t.lineTo(-$*r,-r),t.lineTo($*r,-r),t.closePath()}},et=-.5,rt=Math.sqrt(3)/2,nt=1/Math.sqrt(12),it=3*(nt/2+1),at={draw:function(t,e){var r=Math.sqrt(e/it),n=r/2,i=r*nt,a=n,o=r*nt+r,s=-a,l=o;t.moveTo(n,i),t.lineTo(a,o),t.lineTo(s,l),t.lineTo(et*n-rt*i,rt*n+et*i),t.lineTo(et*a-rt*o,rt*a+et*o),t.lineTo(et*s-rt*l,rt*s+et*l),t.lineTo(et*n+rt*i,et*i-rt*n),t.lineTo(et*a+rt*o,et*o-rt*a),t.lineTo(et*s+rt*l,et*l-rt*s),t.closePath()}},ot=[U,H,W,Q,K,tt,at];function st(){}function lt(t,e,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+r)/6)}function ct(t){this._context=t}function ut(t){this._context=t}function ht(t){this._context=t}function ft(t,e){this._basis=new ct(t),this._beta=e}ct.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:lt(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:lt(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},ut.prototype={areaStart:st,areaEnd:st,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:lt(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},ht.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:lt(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},ft.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,e=this._y,r=t.length-1;if(r>0)for(var n,i=t[0],a=e[0],o=t[r]-i,s=e[r]-a,l=-1;++l<=r;)n=l/r,this._basis.point(this._beta*t[l]+(1-this._beta)*(i+n*o),this._beta*e[l]+(1-this._beta)*(a+n*s));this._x=this._y=null,this._basis.lineEnd()},point:function(t,e){this._x.push(+t),this._y.push(+e)}};var pt=function t(e){function r(t){return 1===e?new ct(t):new ft(t,e)}return r.beta=function(e){return t(+e)},r}(.85);function dt(t,e,r){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-r),t._x2,t._y2)}function gt(t,e){this._context=t,this._k=(1-e)/6}gt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:dt(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:dt(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var mt=function t(e){function r(t){return new gt(t,e)}return r.tension=function(e){return t(+e)},r}(0);function vt(t,e){this._context=t,this._k=(1-e)/6}vt.prototype={areaStart:st,areaEnd:st,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:dt(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var yt=function t(e){function r(t){return new vt(t,e)}return r.tension=function(e){return t(+e)},r}(0);function xt(t,e){this._context=t,this._k=(1-e)/6}xt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:dt(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var bt=function t(e){function r(t){return new xt(t,e)}return r.tension=function(e){return t(+e)},r}(0);function _t(t,e,r){var n=t._x1,i=t._y1,a=t._x2,o=t._y2;if(t._l01_a>u){var s=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,l=3*t._l01_a*(t._l01_a+t._l12_a);n=(n*s-t._x0*t._l12_2a+t._x2*t._l01_2a)/l,i=(i*s-t._y0*t._l12_2a+t._y2*t._l01_2a)/l}if(t._l23_a>u){var c=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,h=3*t._l23_a*(t._l23_a+t._l12_a);a=(a*c+t._x1*t._l23_2a-e*t._l12_2a)/h,o=(o*c+t._y1*t._l23_2a-r*t._l12_2a)/h}t._context.bezierCurveTo(n,i,a,o,t._x2,t._y2)}function wt(t,e){this._context=t,this._alpha=e}wt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var r=this._x2-t,n=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(r*r+n*n,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:_t(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var At=function t(e){function r(t){return e?new wt(t,e):new gt(t,0)}return r.alpha=function(e){return t(+e)},r}(.5);function Ct(t,e){this._context=t,this._alpha=e}Ct.prototype={areaStart:st,areaEnd:st,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){if(t=+t,e=+e,this._point){var r=this._x2-t,n=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(r*r+n*n,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:_t(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var Mt=function t(e){function r(t){return e?new Ct(t,e):new vt(t,0)}return r.alpha=function(e){return t(+e)},r}(.5);function kt(t,e){this._context=t,this._alpha=e}kt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var r=this._x2-t,n=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(r*r+n*n,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:_t(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var It=function t(e){function r(t){return e?new kt(t,e):new xt(t,0)}return r.alpha=function(e){return t(+e)},r}(.5);function Tt(t){this._context=t}function Lt(t){return t<0?-1:1}function St(t,e,r){var n=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(n||i<0&&-0),o=(r-t._y1)/(i||n<0&&-0),s=(a*i+o*n)/(n+i);return(Lt(a)+Lt(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function Et(t,e){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-e)/2:e}function Dt(t,e,r){var n=t._x0,i=t._y0,a=t._x1,o=t._y1,s=(a-n)/3;t._context.bezierCurveTo(n+s,i+s*e,a-s,o-s*r,a,o)}function Pt(t){this._context=t}function Ot(t){this._context=new zt(t)}function zt(t){this._context=t}function Rt(t){this._context=t}function Ft(t){var e,r,n=t.length-1,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e1)for(var r,n,i,a=1,o=t[e[0]],s=o.length;a=0;)r[e]=e;return r}function Yt(t,e){return t[e]}function Vt(t){var e=t.map(Ut);return Bt(t).sort((function(t,r){return e[t]-e[r]}))}function Ut(t){for(var e,r=-1,n=0,i=t.length,a=-1/0;++ra&&(a=e,n=r);return n}function Ht(t){var e=t.map(Gt);return Bt(t).sort((function(t,r){return e[t]-e[r]}))}function Gt(t){for(var e,r=0,n=-1,i=t.length;++n=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,e)}}this._x=t,this._y=e}},t.arc=function(){var t=g,o=m,_=r(0),w=null,A=v,C=y,M=x,k=null;function I(){var r,g,m=+t.apply(this,arguments),v=+o.apply(this,arguments),y=A.apply(this,arguments)-f,x=C.apply(this,arguments)-f,I=n(x-y),T=x>y;if(k||(k=r=e.path()),vu)if(I>p-u)k.moveTo(v*a(y),v*l(y)),k.arc(0,0,v,y,x,!T),m>u&&(k.moveTo(m*a(x),m*l(x)),k.arc(0,0,m,x,y,T));else{var L,S,E=y,D=x,P=y,O=x,z=I,R=I,F=M.apply(this,arguments)/2,N=F>u&&(w?+w.apply(this,arguments):c(m*m+v*v)),j=s(n(v-m)/2,+_.apply(this,arguments)),B=j,Y=j;if(N>u){var V=d(N/m*l(F)),U=d(N/v*l(F));(z-=2*V)>u?(P+=V*=T?1:-1,O-=V):(z=0,P=O=(y+x)/2),(R-=2*U)>u?(E+=U*=T?1:-1,D-=U):(R=0,E=D=(y+x)/2)}var H=v*a(E),G=v*l(E),q=m*a(O),W=m*l(O);if(j>u){var Z,X=v*a(D),J=v*l(D),K=m*a(P),Q=m*l(P);if(I1?0:t<-1?h:Math.acos(t)}(($*et+tt*rt)/(c($*$+tt*tt)*c(et*et+rt*rt)))/2),it=c(Z[0]*Z[0]+Z[1]*Z[1]);B=s(j,(m-it)/(nt-1)),Y=s(j,(v-it)/(nt+1))}}R>u?Y>u?(L=b(K,Q,H,G,v,Y,T),S=b(X,J,q,W,v,Y,T),k.moveTo(L.cx+L.x01,L.cy+L.y01),Yu&&z>u?B>u?(L=b(q,W,X,J,m,-B,T),S=b(H,G,K,Q,m,-B,T),k.lineTo(L.cx+L.x01,L.cy+L.y01),B0&&(d+=h);for(null!=e?g.sort((function(t,r){return e(m[t],m[r])})):null!=n&&g.sort((function(t,e){return n(r[t],r[e])})),s=0,c=d?(y-f*b)/d:0;s0?h*c:0)+b,m[l]={data:r[l],index:s,value:h,startAngle:v,endAngle:u,padAngle:x};return m}return s.value=function(e){return arguments.length?(t="function"==typeof e?e:r(+e),s):t},s.sortValues=function(t){return arguments.length?(e=t,n=null,s):e},s.sort=function(t){return arguments.length?(n=t,e=null,s):n},s.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:r(+t),s):i},s.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:r(+t),s):a},s.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:r(+t),s):o},s},t.areaRadial=O,t.radialArea=O,t.lineRadial=P,t.radialLine=P,t.pointRadial=z,t.linkHorizontal=function(){return j(B)},t.linkVertical=function(){return j(Y)},t.linkRadial=function(){var t=j(V);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.symbol=function(){var t=r(U),n=r(64),i=null;function a(){var r;if(i||(i=r=e.path()),t.apply(this,arguments).draw(i,+n.apply(this,arguments)),r)return i=null,r+""||null}return a.type=function(e){return arguments.length?(t="function"==typeof e?e:r(e),a):t},a.size=function(t){return arguments.length?(n="function"==typeof t?t:r(+t),a):n},a.context=function(t){return arguments.length?(i=null==t?null:t,a):i},a},t.symbols=ot,t.symbolCircle=U,t.symbolCross=H,t.symbolDiamond=W,t.symbolSquare=Q,t.symbolStar=K,t.symbolTriangle=tt,t.symbolWye=at,t.curveBasisClosed=function(t){return new ut(t)},t.curveBasisOpen=function(t){return new ht(t)},t.curveBasis=function(t){return new ct(t)},t.curveBundle=pt,t.curveCardinalClosed=yt,t.curveCardinalOpen=bt,t.curveCardinal=mt,t.curveCatmullRomClosed=Mt,t.curveCatmullRomOpen=It,t.curveCatmullRom=At,t.curveLinearClosed=function(t){return new Tt(t)},t.curveLinear=w,t.curveMonotoneX=function(t){return new Pt(t)},t.curveMonotoneY=function(t){return new Ot(t)},t.curveNatural=function(t){return new Rt(t)},t.curveStep=function(t){return new Nt(t,.5)},t.curveStepAfter=function(t){return new Nt(t,1)},t.curveStepBefore=function(t){return new Nt(t,0)},t.stack=function(){var t=r([]),e=Bt,n=jt,i=Yt;function a(r){var a,o,s=t.apply(this,arguments),l=r.length,c=s.length,u=new Array(c);for(a=0;a0){for(var r,n,i,a=0,o=t[0].length;a1)for(var r,n,i,a,o,s,l=0,c=t[e[0]].length;l=0?(n[0]=a,n[1]=a+=i):i<0?(n[1]=o,n[0]=o+=i):n[0]=a},t.stackOffsetNone=jt,t.stackOffsetSilhouette=function(t,e){if((r=t.length)>0){for(var r,n=0,i=t[e[0]],a=i.length;n0&&(n=(r=t[e[0]]).length)>0){for(var r,n,i,a=0,o=1;o=0&&r._call.call(null,t),r=r._next;--n}function v(){l=(s=u.now())+c,n=i=0;try{m()}finally{n=0,function(){for(var t,n,i=e,a=1/0;i;)i._call?(a>i._time&&(a=i._time),t=i,i=i._next):(n=i._next,i._next=null,i=t?t._next=n:e=n);r=t,x(a)}(),l=0}}function y(){var t=u.now(),e=t-s;e>o&&(c-=e,s=t)}function x(t){n||(i&&(i=clearTimeout(i)),t-l>24?(t<1/0&&(i=setTimeout(v,t-u.now()-c)),a&&(a=clearInterval(a))):(a||(s=u.now(),a=setInterval(y,o)),n=1,h(v)))}d.prototype=g.prototype={constructor:d,restart:function(t,n,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?f():+i)+(null==n?0:+n),this._next||r===this||(r?r._next=this:e=this,r=this),this._call=t,this._time=i,x()},stop:function(){this._call&&(this._call=null,this._time=1/0,x())}},t.now=f,t.timer=g,t.timerFlush=m,t.timeout=function(t,e,r){var n=new d;return e=null==e?0:+e,n.restart((function(r){n.stop(),t(r+e)}),e,r),n},t.interval=function(t,e,r){var n=new d,i=e;return null==e?(n.restart(t,e,r),n):(e=+e,r=null==r?f():+r,n.restart((function a(o){o+=i,n.restart(a,i+=e,r),t(o)}),e,r),n)},Object.defineProperty(t,"__esModule",{value:!0})}))},{}],165:[function(t,e,r){!function(){var t={version:"3.5.17"},r=[].slice,n=function(t){return r.call(t)},i=this.document;function a(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(i)try{n(i.documentElement.childNodes)[0].nodeType}catch(t){n=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),i)try{i.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var s=this.Element.prototype,l=s.setAttribute,c=s.setAttributeNS,u=this.CSSStyleDeclaration.prototype,h=u.setProperty;s.setAttribute=function(t,e){l.call(this,t,e+"")},s.setAttributeNS=function(t,e,r){c.call(this,t,e,r+"")},u.setProperty=function(t,e,r){h.call(this,t,e+"",r)}}function f(t,e){return te?1:t>=e?0:NaN}function p(t){return null===t?NaN:+t}function d(t){return!isNaN(t)}function g(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}t.ascending=f,t.descending=function(t,e){return et?1:e>=t?0:NaN},t.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},t.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},t.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return o/(l-1)},t.deviation=function(){var e=t.variance.apply(this,arguments);return e?Math.sqrt(e):e};var m=g(f);function v(t){return t.length}t.bisectLeft=m.left,t.bisect=t.bisectRight=m.right,t.bisector=function(t){return g(1===t.length?function(e,r){return f(t(e),r)}:t)},t.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},t.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},t.pairs=function(t){for(var e=0,r=t.length-1,n=t[0],i=new Array(r<0?0:r);e=0;)for(e=(n=t[i]).length;--e>=0;)r[--o]=n[e];return r};var y=Math.abs;function x(t){for(var e=1;t*e%1;)e*=10;return e}function b(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function _(){this._=Object.create(null)}t.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r==1/0)throw new Error("infinite range");var n,i=[],a=x(y(r)),o=-1;if(t*=a,e*=a,(r*=a)<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=i.length)return r?r.call(n,a):e?a.sort(e):a;for(var l,c,u,h,f=-1,p=a.length,d=i[s++],g=new _;++f=i.length)return e;var n=[],o=a[r++];return e.forEach((function(e,i){n.push({key:e,values:t(i,r)})})),o?n.sort((function(t,e){return o(t.key,e.key)})):n}(o(t.map,e,0),0)},n.key=function(t){return i.push(t),n},n.sortKeys=function(t){return a[i.length-1]=t,n},n.sortValues=function(t){return e=t,n},n.rollup=function(t){return r=t,n},n},t.set=function(t){var e=new E;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},t.event=null,t.requote=function(t){return t.replace(V,"\\$&")};var V=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]};function H(t){return U(t,Z),t}var G=function(t,e){return e.querySelector(t)},q=function(t,e){return e.querySelectorAll(t)},W=function(t,e){var r=t.matches||t[O(t,"matchesSelector")];return(W=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(G=function(t,e){return Sizzle(t,e)[0]||null},q=Sizzle,W=Sizzle.matchesSelector),t.selection=function(){return t.select(i.documentElement)};var Z=t.selection.prototype=[];function X(t){return"function"==typeof t?t:function(){return G(t,this)}}function J(t){return"function"==typeof t?t:function(){return q(t,this)}}Z.select=function(t){var e,r,n,i,a=[];t=X(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Q.hasOwnProperty(r)?{space:Q[r],local:t}:t}},Z.attr=function(e,r){if(arguments.length<2){if("string"==typeof e){var n=this.node();return(e=t.ns.qualify(e)).local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(r in e)this.each($(r,e[r]));return this}return this.each($(e,r))},Z.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=rt(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},Z.sort=function(t){t=ht.apply(this,arguments);for(var e=-1,r=this.length;++e=e&&(e=i+1);!(o=s[e])&&++e0&&(e=e.slice(0,o));var l=vt.get(e);function c(){var t=this[a];t&&(this.removeEventListener(e,t,t.$),delete this[a])}return l&&(e=l,s=xt),o?r?function(){var t=s(r,n(arguments));c.call(this),this.addEventListener(e,this[a]=t,t.$=i),t._=r}:c:r?R:function(){var r,n=new RegExp("^__on([^.]+)"+t.requote(e)+"$");for(var i in this)if(r=i.match(n)){var a=this[i];this.removeEventListener(r[1],a,a.$),delete this[i]}}}t.selection.enter=pt,t.selection.enter.prototype=dt,dt.append=Z.append,dt.empty=Z.empty,dt.node=Z.node,dt.call=Z.call,dt.size=Z.size,dt.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++s0?1:t<0?-1:0}function zt(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function Rt(t){return t>1?0:t<-1?Tt:Math.acos(t)}function Ft(t){return t>1?Et:t<-1?-Et:Math.asin(t)}function Nt(t){return((t=Math.exp(t))+1/t)/2}function jt(t){return(t=Math.sin(t/2))*t}var Bt=Math.SQRT2;t.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,h=l-a,f=u*u+h*h;if(f0&&(e=e.transition().duration(g)),e.call(w.event)}function I(){c&&c.domain(l.range().map((function(t){return(t-f.x)/f.k})).map(l.invert)),h&&h.domain(u.range().map((function(t){return(t-f.y)/f.k})).map(u.invert))}function T(t){m++||t({type:"zoomstart"})}function L(t){I(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function S(t){--m||(t({type:"zoomend"}),r=null)}function E(){var e=this,r=_.of(e,arguments),n=0,i=t.select(o(e)).on(y,(function(){n=1,M(t.mouse(e),a),L(r)})).on(x,(function(){i.on(y,null).on(x,null),s(n),S(r)})),a=A(t.mouse(e)),s=wt(e);ws.call(e),T(r)}function D(){var e,r=this,n=_.of(r,arguments),i={},a=0,o=".zoom-"+t.event.changedTouches[0].identifier,l="touchmove"+o,c="touchend"+o,u=[],h=t.select(r),p=wt(r);function d(){var n=t.touches(r);return e=f.k,n.forEach((function(t){t.identifier in i&&(i[t.identifier]=A(t))})),n}function g(){var e=t.event.target;t.select(e).on(l,m).on(c,y),u.push(e);for(var n=t.event.changedTouches,o=0,h=n.length;o1){v=p[0];var x=p[1],b=v[0]-x[0],_=v[1]-x[1];a=b*b+_*_}}function m(){var o,l,c,u,h=t.touches(r);ws.call(r);for(var f=0,p=h.length;f360?t-=360:t<0&&(t+=360),t<60?n+(i-n)*t/60:t<180?i:t<240?n+(i-n)*(240-t)/60:n}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+e):r+e-r*e),new le(a(t+120),a(t),a(t-120))}function Zt(e,r,n){return this instanceof Zt?(this.h=+e,this.c=+r,void(this.l=+n)):arguments.length<2?e instanceof Zt?new Zt(e.h,e.c,e.l):ie(e instanceof Kt?e.l:(e=ge((e=t.rgb(e)).r,e.g,e.b)).l,e.a,e.b):new Zt(e,r,n)}qt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Gt(this.h,this.s,this.l/t)},qt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Gt(this.h,this.s,t*this.l)},qt.rgb=function(){return Wt(this.h,this.s,this.l)},t.hcl=Zt;var Xt=Zt.prototype=new Ht;function Jt(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new Kt(r,Math.cos(t*=Dt)*e,Math.sin(t)*e)}function Kt(t,e,r){return this instanceof Kt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof Kt?new Kt(t.l,t.a,t.b):t instanceof Zt?Jt(t.h,t.c,t.l):ge((t=le(t)).r,t.g,t.b):new Kt(t,e,r)}Xt.brighter=function(t){return new Zt(this.h,this.c,Math.min(100,this.l+Qt*(arguments.length?t:1)))},Xt.darker=function(t){return new Zt(this.h,this.c,Math.max(0,this.l-Qt*(arguments.length?t:1)))},Xt.rgb=function(){return Jt(this.h,this.c,this.l).rgb()},t.lab=Kt;var Qt=18,$t=.95047,te=1,ee=1.08883,re=Kt.prototype=new Ht;function ne(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return new le(se(3.2404542*(i=ae(i)*$t)-1.5371385*(n=ae(n)*te)-.4985314*(a=ae(a)*ee)),se(-.969266*i+1.8760108*n+.041556*a),se(.0556434*i-.2040259*n+1.0572252*a))}function ie(t,e,r){return t>0?new Zt(Math.atan2(r,e)*Pt,Math.sqrt(e*e+r*r),t):new Zt(NaN,NaN,t)}function ae(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function oe(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function se(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function le(t,e,r){return this instanceof le?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof le?new le(t.r,t.g,t.b):pe(""+t,le,Wt):new le(t,e,r)}function ce(t){return new le(t>>16,t>>8&255,255&t)}function ue(t){return ce(t)+""}re.brighter=function(t){return new Kt(Math.min(100,this.l+Qt*(arguments.length?t:1)),this.a,this.b)},re.darker=function(t){return new Kt(Math.max(0,this.l-Qt*(arguments.length?t:1)),this.a,this.b)},re.rgb=function(){return ne(this.l,this.a,this.b)},t.rgb=le;var he=le.prototype=new Ht;function fe(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function pe(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(ve(i[0]),ve(i[1]),ve(i[2]))}return(a=ye.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o|=o>>4,s=240&a,s|=s>>4,l=15&a,l|=l<<4):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function de(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new Gt(n,i,l)}function ge(t,e,r){var n=oe((.4124564*(t=me(t))+.3575761*(e=me(e))+.1804375*(r=me(r)))/$t),i=oe((.2126729*t+.7151522*e+.072175*r)/te);return Kt(116*i-16,500*(n-i),200*(i-oe((.0193339*t+.119192*e+.9503041*r)/ee)))}function me(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ve(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}he.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&e=200&&e<300||304===e){try{t=i.call(o,c)}catch(t){return void s.error.call(o,t)}s.load.call(o,t)}else s.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(e)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=h:c.onreadystatechange=function(){c.readyState>3&&h()},c.onprogress=function(e){var r=t.event;t.event=e;try{s.progress.call(o,c)}finally{t.event=r}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",o):r},o.responseType=function(t){return arguments.length?(u=t,o):u},o.response=function(t){return i=t,o},["get","post"].forEach((function(t){o[t]=function(){return o.send.apply(o,[t].concat(n(arguments)))}})),o.send=function(t,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),c.open(t,e,!0),null==r||"accept"in l||(l.accept=r+",*/*"),c.setRequestHeader)for(var a in l)c.setRequestHeader(a,l[a]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=u&&(c.responseType=u),null!=i&&o.on("error",i).on("load",(function(t){i(null,t)})),s.beforesend.call(o,c),c.send(null==n?null:n),o},o.abort=function(){return c.abort(),o},t.rebind(o,s,"on"),null==a?o:o.get(function(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}(a))}ye.forEach((function(t,e){ye.set(t,ce(e))})),t.functor=xe,t.xhr=be(D),t.dsv=function(t,e){var r=new RegExp('["'+t+"\n]"),n=t.charCodeAt(0);function i(t,r,n){arguments.length<3&&(n=r,r=null);var i=_e(t,e,null==r?a:o(r),n);return i.row=function(t){return arguments.length?i.response(null==(r=t)?a:o(t)):r},i}function a(t){return i.parse(t.responseText)}function o(t){return function(e){return i.parse(e.responseText,t)}}function s(e){return e.map(l).join(t)}function l(t){return r.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,e){var r;return i.parseRows(t,(function(t,n){if(r)return r(t,n-1);var i=new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+"]"})).join(",")+"}");r=e?function(t,r){return e(i(t),r)}:i}))},i.parseRows=function(t,e){var r,i,a={},o={},s=[],l=t.length,c=0,u=0;function h(){if(c>=l)return o;if(i)return i=!1,a;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++24?(isFinite(e)&&(clearTimeout(Me),Me=setTimeout(Te,e)),Ce=0):(Ce=1,ke(Te))}function Le(){for(var t=Date.now(),e=we;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Se(){for(var t,e=we,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}));function Pe(e){var r=e.decimal,n=e.thousands,i=e.grouping,a=e.currency,o=i&&n?function(t,e){for(var r=t.length,a=[],o=0,s=i[0],l=0;r>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(r-=s,r+s)),!((l+=s+1)>e));)s=i[o=(o+1)%i.length];return a.reverse().join(n)}:D;return function(e){var n=Oe.exec(e),i=n[1]||" ",s=n[2]||">",l=n[3]||"-",c=n[4]||"",u=n[5],h=+n[6],f=n[7],p=n[8],d=n[9],g=1,m="",v="",y=!1,x=!0;switch(p&&(p=+p.substring(1)),(u||"0"===i&&"="===s)&&(u=i="0",s="="),d){case"n":f=!0,d="g";break;case"%":g=100,v="%",d="f";break;case"p":g=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===c&&(m="0"+d.toLowerCase());case"c":x=!1;case"d":y=!0,p=0;break;case"s":g=-1,d="r"}"$"===c&&(m=a[0],v=a[1]),"r"!=d||p||(d="g"),null!=p&&("g"==d?p=Math.max(1,Math.min(21,p)):"e"!=d&&"f"!=d||(p=Math.max(0,Math.min(20,p)))),d=ze.get(d)||Re;var b=u&&f;return function(e){var n=v;if(y&&e%1)return"";var a=e<0||0===e&&1/e<0?(e=-e,"-"):"-"===l?"":l;if(g<0){var c=t.formatPrefix(e,p);e=c.scale(e),n=c.symbol+v}else e*=g;var _,w,A=(e=d(e,p)).lastIndexOf(".");if(A<0){var C=x?e.lastIndexOf("e"):-1;C<0?(_=e,w=""):(_=e.substring(0,C),w=e.substring(C))}else _=e.substring(0,A),w=r+e.substring(A+1);!u&&f&&(_=o(_,1/0));var M=m.length+_.length+w.length+(b?0:a.length),k=M"===s?k+a+e:"^"===s?k.substring(0,M>>=1)+a+e+k.substring(M):a+(b?e:k+e))+n}}}t.formatPrefix=function(e,r){var n=0;return(e=+e)&&(e<0&&(e*=-1),r&&(e=t.round(e,Ee(e,r))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),De[8+n/3]};var Oe=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ze=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(e,r){return(e=t.round(e,Ee(e,r))).toFixed(Math.max(0,Math.min(20,Ee(e*(1+1e-15),r))))}});function Re(t){return t+""}var Fe=t.time={},Ne=Date;function je(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}je.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Be.setUTCDate.apply(this._,arguments)},setDay:function(){Be.setUTCDay.apply(this._,arguments)},setFullYear:function(){Be.setUTCFullYear.apply(this._,arguments)},setHours:function(){Be.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Be.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Be.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Be.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Be.setUTCSeconds.apply(this._,arguments)},setTime:function(){Be.setTime.apply(this._,arguments)}};var Be=Date.prototype;function Ye(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o=c)return-1;if(37===(i=e.charCodeAt(s++))){if(o=e.charAt(s++),!(a=w[o in He?e.charAt(s++):o])||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}u.utc=function(t){var e=u(t);function r(t){try{var r=new(Ne=je);return r._=t,e(r)}finally{Ne=Date}}return r.parse=function(t){try{Ne=je;var r=e.parse(t);return r&&r._}finally{Ne=Date}},r.toString=e.toString,r},u.multi=u.utc.multi=hr;var f=t.map(),p=Ze(o),d=Xe(o),g=Ze(s),m=Xe(s),v=Ze(l),y=Xe(l),x=Ze(c),b=Xe(c);a.forEach((function(t,e){f.set(t.toLowerCase(),e)}));var _={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:u(r),d:function(t,e){return We(t.getDate(),e,2)},e:function(t,e){return We(t.getDate(),e,2)},H:function(t,e){return We(t.getHours(),e,2)},I:function(t,e){return We(t.getHours()%12||12,e,2)},j:function(t,e){return We(1+Fe.dayOfYear(t),e,3)},L:function(t,e){return We(t.getMilliseconds(),e,3)},m:function(t,e){return We(t.getMonth()+1,e,2)},M:function(t,e){return We(t.getMinutes(),e,2)},p:function(t){return a[+(t.getHours()>=12)]},S:function(t,e){return We(t.getSeconds(),e,2)},U:function(t,e){return We(Fe.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return We(Fe.mondayOfYear(t),e,2)},x:u(n),X:u(i),y:function(t,e){return We(t.getFullYear()%100,e,2)},Y:function(t,e){return We(t.getFullYear()%1e4,e,4)},Z:cr,"%":function(){return"%"}},w={a:function(t,e,r){g.lastIndex=0;var n=g.exec(e.slice(r));return n?(t.w=m.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){p.lastIndex=0;var n=p.exec(e.slice(r));return n?(t.w=d.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){v.lastIndex=0;var n=v.exec(e.slice(r));return n?(t.m=y.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,e,r){return h(t,_.c.toString(),e,r)},d:nr,e:nr,H:ar,I:ar,j:ir,L:lr,m:rr,M:or,p:function(t,e,r){var n=f.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)},S:sr,U:Ke,w:Je,W:Qe,x:function(t,e,r){return h(t,_.x.toString(),e,r)},X:function(t,e,r){return h(t,_.X.toString(),e,r)},y:tr,Y:$e,Z:er,"%":ur};return u}Fe.year=Ye((function(t){return(t=Fe.day(t)).setMonth(0,1),t}),(function(t,e){t.setFullYear(t.getFullYear()+e)}),(function(t){return t.getFullYear()})),Fe.years=Fe.year.range,Fe.years.utc=Fe.year.utc.range,Fe.day=Ye((function(t){var e=new Ne(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e}),(function(t,e){t.setDate(t.getDate()+e)}),(function(t){return t.getDate()-1})),Fe.days=Fe.day.range,Fe.days.utc=Fe.day.utc.range,Fe.dayOfYear=function(t){var e=Fe.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(t,e){e=7-e;var r=Fe[t]=Ye((function(t){return(t=Fe.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t}),(function(t,e){t.setDate(t.getDate()+7*Math.floor(e))}),(function(t){var r=Fe.year(t).getDay();return Math.floor((Fe.dayOfYear(t)+(r+e)%7)/7)-(r!==e)}));Fe[t+"s"]=r.range,Fe[t+"s"].utc=r.utc.range,Fe[t+"OfYear"]=function(t){var r=Fe.year(t).getDay();return Math.floor((Fe.dayOfYear(t)+(r+e)%7)/7)}})),Fe.week=Fe.sunday,Fe.weeks=Fe.sunday.range,Fe.weeks.utc=Fe.sunday.utc.range,Fe.weekOfYear=Fe.sundayOfYear;var He={"-":"",_:" ",0:"0"},Ge=/^\s*\d+/,qe=/^%/;function We(t,e,r){var n=t<0?"-":"",i=(n?-t:t)+"",a=i.length;return n+(a68?1900:2e3),r+i[0].length):-1}function er(t,e,r){return/^[+-]\d{4}$/.test(e=e.slice(r,r+5))?(t.Z=-e,r+5):-1}function rr(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function nr(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ir(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ar(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function or(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function sr(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function lr(t,e,r){Ge.lastIndex=0;var n=Ge.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function cr(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=y(e)/60|0,i=y(e)%60;return r+We(n,"0",2)+We(i,"0",2)}function ur(t,e,r){qe.lastIndex=0;var n=qe.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function hr(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*a,l=Math.cos(e),c=Math.sin(e),u=i*c,h=n*l+u*Math.cos(s),f=u*o*Math.sin(s);Pr.add(Math.atan2(f,h)),r=t,n=l,i=c}Or.point=function(o,s){Or.point=a,r=(t=o)*Dt,n=Math.cos(s=(e=s)*Dt/2+Tt/4),i=Math.sin(s)},Or.lineEnd=function(){a(t,e)}}function Rr(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function Fr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Nr(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function jr(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Br(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Yr(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Vr(t){return[Math.atan2(t[1],t[0]),Ft(t[2])]}function Ur(t,e){return y(t[0]-e[0])kt?i=90:c<-kt&&(r=-90),h[0]=e,h[1]=n}};function p(t,a){u.push(h=[e=t,n=t]),ai&&(i=a)}function d(t,o){var s=Rr([t*Dt,o*Dt]);if(l){var c=Nr(l,s),u=Nr([c[1],-c[0],0],c);Yr(u),u=Vr(u);var h=t-a,f=h>0?1:-1,d=u[0]*Pt*f,g=y(h)>180;if(g^(f*ai&&(i=m);else if(g^(f*a<(d=(d+360)%360-180)&&di&&(i=o);g?t_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t):n>=e?(tn&&(n=t)):t>a?_(e,t)>_(e,n)&&(n=t):_(t,n)>_(e,n)&&(e=t)}else p(t,o);l=s,a=t}function g(){f.point=d}function m(){h[0]=e,h[1]=n,f.point=p,l=null}function v(t,e){if(l){var r=t-a;c+=y(r)>180?r+(r>0?360:-360):r}else o=t,s=e;Or.point(t,e),d(t,e)}function x(){Or.lineStart()}function b(){v(o,s),Or.lineEnd(),y(c)>kt&&(e=-(n=180)),h[0]=e,h[1]=n,l=null}function _(t,e){return(e-=t)<0?e+360:e}function w(t,e){return t[0]-e[0]}function A(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t_(g[0],g[1])&&(g[1]=p[1]),_(p[0],g[1])>_(g[0],g[1])&&(g[0]=p[0])):s.push(g=p);for(var l,c,p,d=-1/0,g=(o=0,s[c=s.length-1]);o<=c;g=p,++o)p=s[o],(l=_(g[1],p[0]))>d&&(d=l,e=p[0],n=g[1])}return u=h=null,e===1/0||r===1/0?[[NaN,NaN],[NaN,NaN]]:[[e,r],[n,i]]}}(),t.geo.centroid=function(e){wr=Ar=Cr=Mr=kr=Ir=Tr=Lr=Sr=Er=Dr=0,t.geo.stream(e,Hr);var r=Sr,n=Er,i=Dr,a=r*r+n*n+i*i;return a=0;--s)i.point((h=u[s])[0],h[1]);else n(p.x,p.p.x,-1,i);p=p.p}u=(p=p.o).z,d=!d}while(!p.v);i.lineEnd()}}}function $r(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n=0?1:-1,A=w*_,C=A>Tt,M=d*x;if(Pr.add(Math.atan2(M*w*Math.sin(A),g*b+M*Math.cos(A))),a+=C?_+w*Lt:_,C^f>=r^v>=r){var k=Nr(Rr(h),Rr(t));Yr(k);var I=Nr(i,k);Yr(I);var T=(C^_>=0?-1:1)*Ft(I[2]);(n>T||n===T&&(k[0]||k[1]))&&(o+=C^_>=0?1:-1)}if(!m++)break;f=v,d=x,g=b,h=t}}return(a<-kt||a0){for(x||(o.polygonStart(),x=!0),o.lineStart();++a1&&2&e&&r.push(r.pop().concat(r.shift())),s.push(r.filter(rn))}return u}}function rn(t){return t.length>1}function nn(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:R,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function an(t,e){return((t=t.x)[0]<0?t[1]-Et-kt:Et-t[1])-((e=e.x)[0]<0?e[1]-Et-kt:Et-e[1])}var on=en(Kr,(function(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Tt:-Tt,l=y(a-r);y(l-Tt)0?Et:-Et),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Tt&&(y(r-i)kt?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}(r,n,a,o),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),e=0),t.point(r=a,n=o),i=s},lineEnd:function(){t.lineEnd(),r=n=NaN},clean:function(){return 2-e}}}),(function(t,e,r,n){var i;if(null==t)i=r*Et,n.point(-Tt,i),n.point(0,i),n.point(Tt,i),n.point(Tt,0),n.point(Tt,-i),n.point(0,-i),n.point(-Tt,-i),n.point(-Tt,0),n.point(-Tt,i);else if(y(t[0]-e[0])>kt){var a=t[0]0,n=y(e)>kt;return en(i,(function(t){var e,s,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,f){var p,d=[h,f],g=i(h,f),m=r?g?0:o(h,f):g?o(h+(h<0?Tt:-Tt),f):0;if(!e&&(c=l=g)&&t.lineStart(),g!==l&&(p=a(e,d),(Ur(e,p)||Ur(d,p))&&(d[0]+=kt,d[1]+=kt,g=i(d[0],d[1]))),g!==l)u=0,g?(t.lineStart(),p=a(d,e),t.point(p[0],p[1])):(p=a(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(n&&e&&r^g){var v;m&s||!(v=a(d,e,!0))||(u=0,r?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!g||e&&Ur(e,d)||t.point(d[0],d[1]),e=d,l=g,s=m},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}}),Hn(t,6*Dt),r?[0,-t]:[-Tt,t-Tt]);function i(t,r){return Math.cos(t)*Math.cos(r)>e}function a(t,r,n){var i=[1,0,0],a=Nr(Rr(t),Rr(r)),o=Fr(a,a),s=a[0],l=o-s*s;if(!l)return!n&&t;var c=e*o/l,u=-e*s/l,h=Nr(i,a),f=Br(i,c);jr(f,Br(a,u));var p=h,d=Fr(f,p),g=Fr(p,p),m=d*d-g*(Fr(f,f)-1);if(!(m<0)){var v=Math.sqrt(m),x=Br(p,(-d-v)/g);if(jr(x,f),x=Vr(x),!n)return x;var b,_=t[0],w=r[0],A=t[1],C=r[1];w<_&&(b=_,_=w,w=b);var M=w-_,k=y(M-Tt)0^x[1]<(y(x[0]-_)Tt^(_<=x[0]&&x[0]<=w)){var I=Br(p,(-d+v)/g);return jr(I,f),[x,Vr(I)]}}}function o(e,n){var i=r?t:Tt-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}}function ln(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=0,h=1,f=s.x-l,p=s.y-c;if(a=t-l,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>h)return;a>u&&(u=a)}if(a=r-l,f||!(a<0)){if(a/=f,f<0){if(a>h)return;a>u&&(u=a)}else if(f>0){if(a0)){if(a/=p,p<0){if(a0){if(a>h)return;a>u&&(u=a)}if(a=n-c,p||!(a<0)){if(a/=p,p<0){if(a>h)return;a>u&&(u=a)}else if(p>0){if(a0&&(i.a={x:l+u*f,y:c+u*p}),h<1&&(i.b={x:l+h*f,y:c+h*p}),i}}}}}}var cn=1e9;function un(e,r,n,i){return function(l){var c,u,h,f,p,d,g,m,v,y,x,b=l,_=nn(),w=ln(e,r,n,i),A={point:k,lineStart:function(){A.point=I,u&&u.push(h=[]),y=!0,v=!1,g=m=NaN},lineEnd:function(){c&&(I(f,p),d&&v&&_.rejoin(),c.push(_.buffer())),A.point=k,v&&l.lineEnd()},polygonStart:function(){l=_,c=[],u=[],x=!0},polygonEnd:function(){l=b,c=t.merge(c);var r=function(t){for(var e=0,r=u.length,n=t[1],i=0;in&&zt(c,a,t)>0&&++e:a[1]<=n&&zt(c,a,t)<0&&--e,c=a;return 0!==e}([e,i]),n=x&&r,a=c.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),C(null,null,1,l),l.lineEnd()),a&&Qr(c,o,r,C,l),l.polygonEnd()),c=u=h=null}};function C(t,o,l,c){var u=0,h=0;if(null==t||(u=a(t,l))!==(h=a(o,l))||s(t,o)<0^l>0)do{c.point(0===u||3===u?e:n,u>1?i:r)}while((u=(u+l+4)%4)!==h);else c.point(o[0],o[1])}function M(t,a){return e<=t&&t<=n&&r<=a&&a<=i}function k(t,e){M(t,e)&&l.point(t,e)}function I(t,e){var r=M(t=Math.max(-cn,Math.min(cn,t)),e=Math.max(-cn,Math.min(cn,e)));if(u&&h.push([t,e]),y)f=t,p=e,d=r,y=!1,r&&(l.lineStart(),l.point(t,e));else if(r&&v)l.point(t,e);else{var n={a:{x:g,y:m},b:{x:t,y:e}};w(n)?(v||(l.lineStart(),l.point(n.a.x,n.a.y)),l.point(n.b.x,n.b.y),r||l.lineEnd(),x=!1):r&&(l.lineStart(),l.point(t,e),x=!1)}g=t,m=e,v=r}return A};function a(t,i){return y(t[0]-e)0?0:3:y(t[0]-n)0?2:1:y(t[1]-r)0?1:0:i>0?3:2}function o(t,e){return s(t.x,e.x)}function s(t,e){var r=a(t,1),n=a(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}}function hn(t){var e=0,r=Tt/3,n=Rn(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Tt/180,r=t[1]*Tt/180):[e/Tt*180,r/Tt*180]},i}function fn(t,e){var r=Math.sin(t),n=(r+Math.sin(e))/2,i=1+r*(2*n-r),a=Math.sqrt(i)/n;function o(t,e){var r=Math.sqrt(i-2*n*Math.sin(e))/n;return[r*Math.sin(t*=n),a-r*Math.cos(t)]}return o.invert=function(t,e){var r=a-e;return[Math.atan2(t,r)/n,Ft((i-(t*t+r*r)*n*n)/(2*n))]},o}t.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),(i=a(t)).valid=!0,i},extent:function(s){return arguments.length?(a=un(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return hn(fn)}).raw=fn,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var e,r,n,i,a=t.geo.albers(),o=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};function c(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}return c.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},c.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},c.precision=function(t){return arguments.length?(a.precision(t),o.precision(t),s.precision(t),c):a.precision()},c.scale=function(t){return arguments.length?(a.scale(t),o.scale(.35*t),s.scale(t),c.translate(a.translate())):a.scale()},c.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),u=+t[0],h=+t[1];return r=a.translate(t).clipExtent([[u-.455*e,h-.238*e],[u+.455*e,h+.238*e]]).stream(l).point,n=o.translate([u-.307*e,h+.201*e]).clipExtent([[u-.425*e+kt,h+.12*e+kt],[u-.214*e-kt,h+.234*e-kt]]).stream(l).point,i=s.translate([u-.205*e,h+.212*e]).clipExtent([[u-.214*e+kt,h+.166*e+kt],[u-.115*e-kt,h+.234*e-kt]]).stream(l).point,c},c.scale(1070)};var pn,dn,gn,mn,vn,yn,xn={point:R,lineStart:R,lineEnd:R,polygonStart:function(){dn=0,xn.lineStart=bn},polygonEnd:function(){xn.lineStart=xn.lineEnd=xn.point=R,pn+=y(dn/2)}};function bn(){var t,e,r,n;function i(t,e){dn+=n*t-r*e,r=t,n=e}xn.point=function(a,o){xn.point=i,t=r=a,e=n=o},xn.lineEnd=function(){i(t,e)}}var _n={point:function(t,e){tvn&&(vn=t),eyn&&(yn=e)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function wn(){var t=An(4.5),e=[],r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(e){return t=An(e),r},result:function(){if(e.length){var t=e.join("");return e=[],t}}};function n(r,n){e.push("M",r,",",n,t)}function i(t,n){e.push("M",t,",",n),r.point=a}function a(t,r){e.push("L",t,",",r)}function o(){r.point=n}function s(){e.push("Z")}return r}function An(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var Cn,Mn={point:kn,lineStart:In,lineEnd:Tn,polygonStart:function(){Mn.lineStart=Ln},polygonEnd:function(){Mn.point=kn,Mn.lineStart=In,Mn.lineEnd=Tn}};function kn(t,e){Cr+=t,Mr+=e,++kr}function In(){var t,e;function r(r,n){var i=r-t,a=n-e,o=Math.sqrt(i*i+a*a);Ir+=o*(t+r)/2,Tr+=o*(e+n)/2,Lr+=o,kn(t=r,e=n)}Mn.point=function(n,i){Mn.point=r,kn(t=n,e=i)}}function Tn(){Mn.point=kn}function Ln(){var t,e,r,n;function i(t,e){var i=t-r,a=e-n,o=Math.sqrt(i*i+a*a);Ir+=o*(r+t)/2,Tr+=o*(n+e)/2,Lr+=o,Sr+=(o=n*t-r*e)*(r+t),Er+=o*(n+e),Dr+=3*o,kn(r=t,n=e)}Mn.point=function(a,o){Mn.point=i,kn(t=r=a,e=n=o)},Mn.lineEnd=function(){i(t,e)}}function Sn(t){var e=4.5,r={point:n,lineStart:function(){r.point=i},lineEnd:o,polygonStart:function(){r.lineEnd=s},polygonEnd:function(){r.lineEnd=o,r.point=n},pointRadius:function(t){return e=t,r},result:R};function n(r,n){t.moveTo(r+e,n),t.arc(r,n,e,0,Lt)}function i(e,n){t.moveTo(e,n),r.point=a}function a(e,r){t.lineTo(e,r)}function o(){r.point=n}function s(){t.closePath()}return r}function En(t){var e=.5,r=Math.cos(30*Dt),n=16;function i(t){return(n?o:a)(t)}function a(e){return On(e,(function(r,n){r=t(r,n),e.point(r[0],r[1])}))}function o(e){var r,i,a,o,l,c,u,h,f,p,d,g,m={point:v,lineStart:y,lineEnd:b,polygonStart:function(){e.polygonStart(),m.lineStart=_},polygonEnd:function(){e.polygonEnd(),m.lineStart=y}};function v(r,n){r=t(r,n),e.point(r[0],r[1])}function y(){h=NaN,m.point=x,e.lineStart()}function x(r,i){var a=Rr([r,i]),o=t(r,i);s(h,f,u,p,d,g,h=o[0],f=o[1],u=r,p=a[0],d=a[1],g=a[2],n,e),e.point(h,f)}function b(){m.point=v,e.lineEnd()}function _(){y(),m.point=w,m.lineEnd=A}function w(t,e){x(r=t,e),i=h,a=f,o=p,l=d,c=g,m.point=x}function A(){s(h,f,u,p,d,g,i,a,r,o,l,c,n,e),m.lineEnd=b,b()}return m}function s(n,i,a,o,l,c,u,h,f,p,d,g,m,v){var x=u-n,b=h-i,_=x*x+b*b;if(_>4*e&&m--){var w=o+p,A=l+d,C=c+g,M=Math.sqrt(w*w+A*A+C*C),k=Math.asin(C/=M),I=y(y(C)-1)e||y((x*E+b*D)/_-.5)>.3||o*p+l*d+c*g0&&16,i):Math.sqrt(e)},i}function Dn(t){var e=En((function(e,r){return t([e*Pt,r*Pt])}));return function(t){return Fn(e(t))}}function Pn(t){this.stream=t}function On(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function zn(t){return Rn((function(){return t}))()}function Rn(e){var r,n,i,a,o,s,l=En((function(t,e){return[(t=r(t,e))[0]*c+a,o-t[1]*c]})),c=150,u=480,h=250,f=0,p=0,d=0,g=0,m=0,v=on,y=D,x=null,b=null;function _(t){return[(t=i(t[0]*Dt,t[1]*Dt))[0]*c+a,o-t[1]*c]}function w(t){return(t=i.invert((t[0]-a)/c,(o-t[1])/c))&&[t[0]*Pt,t[1]*Pt]}function A(){i=Jr(n=Bn(d,g,m),r);var t=r(f,p);return a=u-t[0]*c,o=h+t[1]*c,C()}function C(){return s&&(s.valid=!1,s=null),_}return _.stream=function(t){return s&&(s.valid=!1),(s=Fn(v(n,l(y(t))))).valid=!0,s},_.clipAngle=function(t){return arguments.length?(v=null==t?(x=t,on):sn((x=+t)*Dt),C()):x},_.clipExtent=function(t){return arguments.length?(b=t,y=t?un(t[0][0],t[0][1],t[1][0],t[1][1]):D,C()):b},_.scale=function(t){return arguments.length?(c=+t,A()):c},_.translate=function(t){return arguments.length?(u=+t[0],h=+t[1],A()):[u,h]},_.center=function(t){return arguments.length?(f=t[0]%360*Dt,p=t[1]%360*Dt,A()):[f*Pt,p*Pt]},_.rotate=function(t){return arguments.length?(d=t[0]%360*Dt,g=t[1]%360*Dt,m=t.length>2?t[2]%360*Dt:0,A()):[d*Pt,g*Pt,m*Pt]},t.rebind(_,l,"precision"),function(){return r=e.apply(this,arguments),_.invert=r.invert&&w,A()}}function Fn(t){return On(t,(function(e,r){t.point(e*Dt,r*Dt)}))}function Nn(t,e){return[t,e]}function jn(t,e){return[t>Tt?t-Lt:t<-Tt?t+Lt:t,e]}function Bn(t,e,r){return t?e||r?Jr(Vn(t),Un(e,r)):Vn(t):e||r?Un(e,r):jn}function Yn(t){return function(e,r){return[(e+=t)>Tt?e-Lt:e<-Tt?e+Lt:e,r]}}function Vn(t){var e=Yn(t);return e.invert=Yn(-t),e}function Un(t,e){var r=Math.cos(t),n=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function o(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*r+s*n;return[Math.atan2(l*i-u*a,s*r-c*n),Ft(u*i+l*a)]}return o.invert=function(t,e){var o=Math.cos(e),s=Math.cos(t)*o,l=Math.sin(t)*o,c=Math.sin(e),u=c*i-l*a;return[Math.atan2(l*i+c*a,s*r+u*n),Ft(u*r-s*n)]},o}function Hn(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=Gn(r,i),a=Gn(r,a),(o>0?ia)&&(i+=o*Lt)):(i=t+o*Lt,a=t-.5*l);for(var c,u=i;o>0?u>a:u2?t[2]*Dt:0),e.invert=function(e){return(e=t.invert(e[0]*Dt,e[1]*Dt))[0]*=Pt,e[1]*=Pt,e},e},jn.invert=Nn,t.geo.circle=function(){var t,e,r=[0,0],n=6;function i(){var t="function"==typeof r?r.apply(this,arguments):r,n=Bn(-t[0]*Dt,-t[1]*Dt,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Pt,t[1]*=Pt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(r=t,i):r},i.angle=function(r){return arguments.length?(e=Hn((t=+r)*Dt,n*Dt),i):t},i.precision=function(r){return arguments.length?(e=Hn(t*Dt,(n=+r)*Dt),i):n},i.angle(90)},t.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Dt,i=t[1]*Dt,a=e[1]*Dt,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),h=Math.cos(a);return Math.atan2(Math.sqrt((r=h*o)*r+(r=c*u-l*h*s)*r),l*u+c*h*s)},t.geo.graticule=function(){var e,r,n,i,a,o,s,l,c,u,h,f,p=10,d=p,g=90,m=360,v=2.5;function x(){return{type:"MultiLineString",coordinates:b()}}function b(){return t.range(Math.ceil(i/g)*g,n,g).map(h).concat(t.range(Math.ceil(l/m)*m,s,m).map(f)).concat(t.range(Math.ceil(r/p)*p,e,p).filter((function(t){return y(t%g)>kt})).map(c)).concat(t.range(Math.ceil(o/d)*d,a,d).filter((function(t){return y(t%m)>kt})).map(u))}return x.lines=function(){return b().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(f(s).slice(1),h(n).reverse().slice(1),f(l).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],n=+t[1][0],l=+t[0][1],s=+t[1][1],i>n&&(t=i,i=n,n=t),l>s&&(t=l,l=s,s=t),x.precision(v)):[[i,l],[n,s]]},x.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),x.precision(v)):[[r,o],[e,a]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(g=+t[0],m=+t[1],x):[g,m]},x.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],x):[p,d]},x.precision=function(t){return arguments.length?(v=+t,c=qn(o,a,90),u=Wn(r,e,v),h=qn(l,s,90),f=Wn(i,n,v),x):v},x.majorExtent([[-180,-90+kt],[180,90-kt]]).minorExtent([[-180,-80-kt],[180,80+kt]])},t.geo.greatArc=function(){var e,r,n=Zn,i=Xn;function a(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}return a.distance=function(){return t.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},a.source=function(t){return arguments.length?(n=t,e="function"==typeof t?null:t,a):n},a.target=function(t){return arguments.length?(i=t,r="function"==typeof t?null:t,a):i},a.precision=function(){return arguments.length?a:0},a},t.geo.interpolate=function(t,e){return r=t[0]*Dt,n=t[1]*Dt,i=e[0]*Dt,a=e[1]*Dt,o=Math.cos(n),s=Math.sin(n),l=Math.cos(a),c=Math.sin(a),u=o*Math.cos(r),h=o*Math.sin(r),f=l*Math.cos(i),p=l*Math.sin(i),d=2*Math.asin(Math.sqrt(jt(a-n)+o*l*jt(i-r))),g=1/Math.sin(d),(m=d?function(t){var e=Math.sin(t*=d)*g,r=Math.sin(d-t)*g,n=r*u+e*f,i=r*h+e*p,a=r*s+e*c;return[Math.atan2(i,n)*Pt,Math.atan2(a,Math.sqrt(n*n+i*i))*Pt]}:function(){return[r*Pt,n*Pt]}).distance=d,m;var r,n,i,a,o,s,l,c,u,h,f,p,d,g,m},t.geo.length=function(e){return Cn=0,t.geo.stream(e,Jn),Cn};var Jn={sphere:R,point:R,lineStart:function(){var t,e,r;function n(n,i){var a=Math.sin(i*=Dt),o=Math.cos(i),s=y((n*=Dt)-t),l=Math.cos(s);Cn+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=r*a-e*o*l)*s),e*a+r*o*l),t=n,e=a,r=o}Jn.point=function(i,a){t=i*Dt,e=Math.sin(a*=Dt),r=Math.cos(a),Jn.point=n},Jn.lineEnd=function(){Jn.point=Jn.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Kn(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}var Qn=Kn((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(t.geo.azimuthalEqualArea=function(){return zn(Qn)}).raw=Qn;var $n=Kn((function(t){var e=Math.acos(t);return e&&e/Math.sin(e)}),D);function ti(t,e){var r=Math.cos(t),n=function(t){return Math.tan(Tt/4+t/2)},i=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(n(e)/n(t)),a=r*Math.pow(n(t),i)/i;if(!i)return ni;function o(t,e){a>0?e<-Et+kt&&(e=-Et+kt):e>Et-kt&&(e=Et-kt);var r=a/Math.pow(n(e),i);return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}return o.invert=function(t,e){var r=a-e,n=Ot(i)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/i,2*Math.atan(Math.pow(a/n,1/i))-Et]},o}function ei(t,e){var r=Math.cos(t),n=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),i=r/n+t;if(y(n)1&&zt(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function hi(t,e){return t[0]-e[0]||t[1]-e[1]}(t.geo.stereographic=function(){return zn(oi)}).raw=oi,si.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Et]},(t.geo.transverseMercator=function(){var t=ii(si),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):[(t=r())[0],t[1],t[2]-90]},r([0,0,90])}).raw=si,t.geom={},t.geom.hull=function(t){var e=li,r=ci;if(arguments.length)return n(t);function n(t){if(t.length<3)return[];var n,i=xe(e),a=xe(r),o=t.length,s=[],l=[];for(n=0;n=0;--n)p.push(t[s[c[n]][2]]);for(n=+h;nkt)s=s.L;else{if(!((i=a-Li(s,o))>kt)){n>-kt?(e=s.P,r=s):i>-kt?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Ci(t);if(yi.insert(e,l),e||r){if(e===r)return Oi(e),r=Ci(e.site),yi.insert(l,r),l.edge=r.edge=Fi(e.site,l.site),Pi(e),void Pi(r);if(r){Oi(e),Oi(r);var c=e.site,u=c.x,h=c.y,f=t.x-u,p=t.y-h,d=r.site,g=d.x-u,m=d.y-h,v=2*(f*m-p*g),y=f*f+p*p,x=g*g+m*m,b={x:(m*y-p*x)/v+u,y:(f*x-g*y)/v+h};Ni(r.edge,c,d,b),l.edge=Fi(c,t,null,b),r.edge=Fi(t,d,null,b),Pi(e),Pi(r)}else l.edge=Fi(e.site,l.site)}}function Ti(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-1/0;var s=(r=o.site).x,l=r.y,c=l-e;if(!c)return s;var u=s-n,h=1/a-1/c,f=u/c;return h?(-f+Math.sqrt(f*f-2*h*(u*u/(-2*c)-l+c/2+i-a/2)))/h+n:(n+s)/2}function Li(t,e){var r=t.N;if(r)return Ti(r,e);var n=t.site;return n.y===e?n.x:1/0}function Si(t){this.site=t,this.edges=[]}function Ei(t,e){return e.angle-t.angle}function Di(){Yi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Pi(t){var e=t.P,r=t.N;if(e&&r){var n=e.site,i=t.site,a=r.site;if(n!==a){var o=i.x,s=i.y,l=n.x-o,c=n.y-s,u=a.x-o,h=2*(l*(m=a.y-s)-c*u);if(!(h>=-It)){var f=l*l+c*c,p=u*u+m*m,d=(m*f-c*p)/h,g=(l*p-u*f)/h,m=g+s,v=wi.pop()||new Di;v.arc=t,v.site=i,v.x=d+o,v.y=m+Math.sqrt(d*d+g*g),v.cy=m,t.circle=v;for(var y=null,x=bi._;x;)if(v.y=s)return;if(f>d){if(a){if(a.y>=c)return}else a={x:m,y:l};r={x:m,y:c}}else{if(a){if(a.y1)if(f>d){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xkt||y(i-r)>kt)&&(s.splice(o,0,new ji((v=a.site,x=u,b=y(n-h)kt?{x:h,y:y(e-h)kt?{x:y(r-d)kt?{x:f,y:y(e-f)kt?{x:y(r-p)=r&&c.x<=i&&c.y>=n&&c.y<=o?[[r,o],[i,o],[i,n],[r,n]]:[]).point=t[s]})),e}function s(t){return t.map((function(t,e){return{x:Math.round(n(t,e)/kt)*kt,y:Math.round(i(t,e)/kt)*kt,i:e}}))}return o.links=function(t){return Gi(s(t)).edges.filter((function(t){return t.l&&t.r})).map((function(e){return{source:t[e.l.i],target:t[e.r.i]}}))},o.triangles=function(t){var e=[];return Gi(s(t)).cells.forEach((function(r,n){for(var i,a,o,s,l=r.site,c=r.edges.sort(Ei),u=-1,h=c.length,f=c[h-1].edge,p=f.l===l?f.r:f.l;++ua||h>o||f=_)<<1|e>=b,A=w+4;wa&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:ta(r,n)})),a=na.lastIndex;return ag&&(g=l.x),l.y>m&&(m=l.y),c.push(l.x),u.push(l.y);else for(h=0;hg&&(g=b),_>m&&(m=_),c.push(b),u.push(_)}var w=g-p,A=m-d;function C(t,e,r,n,i,a,o,s){if(!isNaN(r)&&!isNaN(n))if(t.leaf){var l=t.x,c=t.y;if(null!=l)if(y(l-r)+y(c-n)<.01)M(t,e,r,n,i,a,o,s);else{var u=t.point;t.x=t.y=t.point=null,M(t,u,l,c,i,a,o,s),M(t,e,r,n,i,a,o,s)}else t.x=r,t.y=n,t.point=e}else M(t,e,r,n,i,a,o,s)}function M(t,e,r,n,i,a,o,s){var l=.5*(i+o),c=.5*(a+s),u=r>=l,h=n>=c,f=h<<1|u;t.leaf=!1,u?i=l:o=l,h?a=c:s=c,C(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),e,r,n,i,a,o,s)}w>A?m=d+w:g=p+A;var k={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){C(k,t,+v(t,++h),+x(t,h),p,d,g,m)},visit:function(t){Ji(t,k,p,d,g,m)},find:function(t){return Ki(k,t[0],t[1],p,d,g,m)}};if(h=-1,null==e){for(;++h=0&&!(n=t.interpolators[i](e,r)););return n}function aa(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1?1:t(e)}}function ua(t){return function(e){return 1-t(1-e)}}function ha(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}}function fa(t){return t*t}function pa(t){return t*t*t}function da(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function ga(t){return 1-Math.cos(t*Et)}function ma(t){return Math.pow(2,10*(t-1))}function va(t){return 1-Math.sqrt(1-t*t)}function ya(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function xa(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function ba(t){var e,r,n,i=[t.a,t.b],a=[t.c,t.d],o=wa(i),s=_a(i,a),l=wa(((e=a)[0]+=(n=-s)*(r=i)[0],e[1]+=n*r[1],e))||0;i[0]*a[1]=0?t.slice(0,e):t,i=e>=0?t.slice(e+1):"in";return n=sa.get(n)||oa,ca((i=la.get(i)||D)(n.apply(null,r.call(arguments,1))))},t.interpolateHcl=function(e,r){e=t.hcl(e),r=t.hcl(r);var n=e.h,i=e.c,a=e.l,o=r.h-n,s=r.c-i,l=r.l-a;return isNaN(s)&&(s=0,i=isNaN(i)?r.c:i),isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return Jt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateHsl=function(e,r){e=t.hsl(e),r=t.hsl(r);var n=e.h,i=e.s,a=e.l,o=r.h-n,s=r.s-i,l=r.l-a;return isNaN(s)&&(s=0,i=isNaN(i)?r.s:i),isNaN(o)?(o=0,n=isNaN(n)?r.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return Wt(n+o*t,i+s*t,a+l*t)+""}},t.interpolateLab=function(e,r){e=t.lab(e),r=t.lab(r);var n=e.l,i=e.a,a=e.b,o=r.l-n,s=r.a-i,l=r.b-a;return function(t){return ne(n+o*t,i+s*t,a+l*t)+""}},t.interpolateRound=xa,t.transform=function(e){var r=i.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){r.setAttribute("transform",t);var e=r.transform.baseVal.consolidate()}return new ba(e?e.matrix:Aa)})(e)},ba.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var Aa={a:1,b:0,c:0,d:1,e:0,f:0};function Ca(t){return t.length?t.pop()+",":""}function Ma(e,r){var n=[],i=[];return e=t.transform(e),r=t.transform(r),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push("translate(",null,",",null,")");n.push({i:i-4,x:ta(t[0],e[0])},{i:i-2,x:ta(t[1],e[1])})}else(e[0]||e[1])&&r.push("translate("+e+")")}(e.translate,r.translate,n,i),function(t,e,r,n){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Ca(r)+"rotate(",null,")")-2,x:ta(t,e)})):e&&r.push(Ca(r)+"rotate("+e+")")}(e.rotate,r.rotate,n,i),function(t,e,r,n){t!==e?n.push({i:r.push(Ca(r)+"skewX(",null,")")-2,x:ta(t,e)}):e&&r.push(Ca(r)+"skewX("+e+")")}(e.skew,r.skew,n,i),function(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Ca(r)+"scale(",null,",",null,")");n.push({i:i-4,x:ta(t[0],e[0])},{i:i-2,x:ta(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Ca(r)+"scale("+e+")")}(e.scale,r.scale,n,i),e=r=null,function(t){for(var e,r=-1,a=i.length;++r0?n=t:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:n=0})):t>0&&(l.start({type:"start",alpha:n=t}),e=Ie(s.tick)),s):n},s.start=function(){var t,e,r,n=v.length,l=y.length,u=c[0],d=c[1];for(t=0;t=0;)r.push(i[n])}function ja(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++o=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;r&&(a.value=0),a.children=c}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return ja(i,(function(e){var n,i;t&&(n=e.children)&&n.sort(t),r&&(i=e.parent)&&(i.value+=e.value)})),s}return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Na(t,(function(t){t.children&&(t.value=0)})),ja(t,(function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)}))),t},n},t.layout.partition=function(){var e=t.layout.hierarchy(),r=[1,1];function n(t,n){var i=e.call(this,t,n);return function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cs&&(s=n),o.push(n)}for(r=0;ri&&(n=r,i=e);return n}function $a(t){return t.reduce(to,0)}function to(t,e){return t+e[1]}function eo(t,e){return ro(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function ro(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function no(e){return[t.min(e),t.max(e)]}function io(t,e){return t.value-e.value}function ao(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function oo(t,e){t._pack_next=e,e._pack_prev=t}function so(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function lo(t){if((e=t.children)&&(l=e.length)){var e,r,n,i,a,o,s,l,c=1/0,u=-1/0,h=1/0,f=-1/0;if(e.forEach(co),(r=e[0]).x=-r.r,r.y=0,x(r),l>1&&((n=e[1]).x=n.r,n.y=0,x(n),l>2))for(ho(r,n,i=e[2]),x(i),ao(r,i),r._pack_prev=i,ao(i,n),n=r._pack_next,a=3;a0)for(o=-1;++o=h[0]&&l<=h[1]&&((s=c[t.bisect(f,l,1,d)-1]).y+=g,s.push(a[o]));return c}return a.value=function(t){return arguments.length?(r=t,a):r},a.range=function(t){return arguments.length?(n=xe(t),a):n},a.bins=function(t){return arguments.length?(i="number"==typeof t?function(e){return ro(e,t)}:xe(t),a):i},a.frequency=function(t){return arguments.length?(e=!!t,a):e},a},t.layout.pack=function(){var e,r=t.layout.hierarchy().sort(io),n=0,i=[1,1];function a(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,ja(s,(function(t){t.r=+u(t.value)})),ja(s,lo),n){var h=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;ja(s,(function(t){t.r+=h})),ja(s,lo),ja(s,(function(t){t.r-=h}))}return function t(e,r,n,i){var a=e.children;if(e.x=r+=i*e.x,e.y=n+=i*e.y,e.r*=i,a)for(var o=-1,s=a.length;++op.x&&(p=t),t.depth>d.depth&&(d=t)}));var g=r(f,p)/2-f.x,m=n[0]/(p.x+r(p,f)/2+g),v=n[1]/(d.depth||1);Na(u,(function(t){t.x=(t.x+g)*m,t.y=t.depth*v}))}return c}function o(t){var e=t.children,n=t.parent.children,i=t.i?n[t.i-1]:null;if(e.length){!function(t){for(var e,r=0,n=0,i=t.children,a=i.length;--a>=0;)(e=i[a]).z+=r,e.m+=r,r+=e.s+(n+=e.c)}(t);var a=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+r(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+r(t._,i._));t.parent.A=function(t,e,n){if(e){for(var i,a=t,o=t,s=e,l=a.parent.children[0],c=a.m,u=o.m,h=s.m,f=l.m;s=go(s),a=po(a),s&&a;)l=po(l),(o=go(o)).a=t,(i=s.z+h-a.z-c+r(s._,a._))>0&&(mo(vo(s,t,n),t,i),c+=i,u+=i),h+=s.m,c+=a.m,f+=l.m,u+=o.m;s&&!go(o)&&(o.t=s,o.m+=h-u),a&&!po(l)&&(l.t=a,l.m+=c-f,n=t)}return n}(t,i,t.parent.A||n[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function l(t){t.x*=n[0],t.y=t.depth*n[1]}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t)?l:null,a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null==(n=t)?null:l,a):i?n:null},Fa(a,e)},t.layout.cluster=function(){var e=t.layout.hierarchy().sort(null).value(null),r=fo,n=[1,1],i=!1;function a(a,o){var s,l=e.call(this,a,o),c=l[0],u=0;ja(c,(function(e){var n=e.children;n&&n.length?(e.x=function(t){return t.reduce((function(t,e){return t+e.x}),0)/t.length}(n),e.y=function(e){return 1+t.max(e,(function(t){return t.y}))}(n)):(e.x=s?u+=r(e,s):0,e.y=0,s=e)}));var h=function t(e){var r=e.children;return r&&r.length?t(r[0]):e}(c),f=function t(e){var r,n=e.children;return n&&(r=n.length)?t(n[r-1]):e}(c),p=h.x-r(h,f)/2,d=f.x+r(f,h)/2;return ja(c,i?function(t){t.x=(t.x-c.x)*n[0],t.y=(c.y-t.y)*n[1]}:function(t){t.x=(t.x-p)/(d-p)*n[0],t.y=(1-(c.y?t.y/c.y:1))*n[1]}),l}return a.separation=function(t){return arguments.length?(r=t,a):r},a.size=function(t){return arguments.length?(i=null==(n=t),a):i?null:n},a.nodeSize=function(t){return arguments.length?(i=null!=(n=t),a):i?n:null},Fa(a,e)},t.layout.treemap=function(){var e,r=t.layout.hierarchy(),n=Math.round,i=[1,1],a=null,o=yo,s=!1,l="squarify",c=.5*(1+Math.sqrt(5));function u(t,e){for(var r,n,i=-1,a=t.length;++i0;)s.push(r=c[i-1]),s.area+=r.area,"squarify"!==l||(n=p(s,g))<=f?(c.pop(),f=n):(s.area-=s.pop().area,d(s,g,a,!1),g=Math.min(a.dx,a.dy),s.length=s.area=0,f=1/0);s.length&&(d(s,g,a,!0),s.length=s.area=0),e.forEach(h)}}function f(t){var e=t.children;if(e&&e.length){var r,n=o(t),i=e.slice(),a=[];for(u(i,n.dx*n.dy/t.value),a.area=0;r=i.pop();)a.push(r),a.area+=r.area,null!=r.z&&(d(a,r.z?n.dx:n.dy,n,!i.length),a.length=a.area=0);e.forEach(f)}}function p(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return e*=e,(n*=n)?Math.max(e*i*c/n,n/(e*a*c)):1/0}function d(t,e,r,i){var a,o=-1,s=t.length,l=r.x,c=r.y,u=e?n(t.area/e):0;if(e==r.dx){for((i||u>r.dy)&&(u=r.dy);++or.dx)&&(u=r.dx);++o1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var e=t.random.normal.apply(t,arguments);return function(){return Math.exp(e())}},bates:function(e){var r=t.random.irwinHall(e);return function(){return r()/e}},irwinHall:function(t){return function(){for(var e=0,r=0;r2?ko:wo,s=i?Ia:ka;return a=t(e,r,s,n),o=t(r,e,s,ia),l}function l(t){return a(t)}return l.invert=function(t){return o(t)},l.domain=function(t){return arguments.length?(e=t.map(Number),s()):e},l.range=function(t){return arguments.length?(r=t,s()):r},l.rangeRound=function(t){return l.range(t).interpolate(xa)},l.clamp=function(t){return arguments.length?(i=t,s()):i},l.interpolate=function(t){return arguments.length?(n=t,s()):n},l.ticks=function(t){return So(e,t)},l.tickFormat=function(t,r){return Eo(e,t,r)},l.nice=function(t){return To(e,t),s()},l.copy=function(){return t(e,r,n,i)},s()}([0,1],[0,1],ia,!1)};var Do={s:1,g:1,p:1,r:1,e:1};function Po(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function e(r,n,i,a){function o(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(n)}function s(t){return i?Math.pow(n,t):-Math.pow(n,-t)}function l(t){return r(o(t))}return l.invert=function(t){return s(r.invert(t))},l.domain=function(t){return arguments.length?(i=t[0]>=0,r.domain((a=t.map(Number)).map(o)),l):a},l.base=function(t){return arguments.length?(n=+t,r.domain(a.map(o)),l):n},l.nice=function(){var t=Ao(a.map(o),i?Math:zo);return r.domain(t),a=t.map(s),l},l.ticks=function(){var t=bo(a),e=[],r=t[0],l=t[1],c=Math.floor(o(r)),u=Math.ceil(o(l)),h=n%1?2:n;if(isFinite(u-c)){if(i){for(;c0;f--)e.push(s(c)*f);for(c=0;e[c]l;u--);e=e.slice(c,u)}return e},l.tickFormat=function(e,r){if(!arguments.length)return Oo;arguments.length<2?r=Oo:"function"!=typeof r&&(r=t.format(r));var i=Math.max(1,n*e/l.ticks().length);return function(t){var e=t/s(Math.round(o(t)));return e*n0?i[t-1]:r[0],th?0:1;if(c=St)return l(c,p)+(s?l(s,1-p):"")+"Z";var d,g,m,v,y,x,b,_,w,A,C,M,k=0,I=0,T=[];if((v=(+o.apply(this,arguments)||0)/2)&&(m=n===Vo?Math.sqrt(s*s+c*c):+n.apply(this,arguments),p||(I*=-1),c&&(I=Ft(m/c*Math.sin(v))),s&&(k=Ft(m/s*Math.sin(v)))),c){y=c*Math.cos(u+I),x=c*Math.sin(u+I),b=c*Math.cos(h-I),_=c*Math.sin(h-I);var L=Math.abs(h-u-2*I)<=Tt?0:1;if(I&&Zo(y,x,b,_)===p^L){var S=(u+h)/2;y=c*Math.cos(S),x=c*Math.sin(S),b=_=null}}else y=x=0;if(s){w=s*Math.cos(h-k),A=s*Math.sin(h-k),C=s*Math.cos(u+k),M=s*Math.sin(u+k);var E=Math.abs(u-h+2*k)<=Tt?0:1;if(k&&Zo(w,A,C,M)===1-p^E){var D=(u+h)/2;w=s*Math.cos(D),A=s*Math.sin(D),C=M=null}}else w=A=0;if(f>kt&&(d=Math.min(Math.abs(c-s)/2,+r.apply(this,arguments)))>.001){g=s0?0:1}function Xo(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,h=t[1]+c,f=e[0]+l,p=e[1]+c,d=(u+f)/2,g=(h+p)/2,m=f-u,v=p-h,y=m*m+v*v,x=r-n,b=u*p-f*h,_=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*v-m*_)/y,A=(-b*m-v*_)/y,C=(b*v+m*_)/y,M=(-b*m+v*_)/y,k=w-d,I=A-g,T=C-d,L=M-g;return k*k+I*I>T*T+L*L&&(w=C,A=M),[[w-l,A-c],[w*r/x,A*r/x]]}function Jo(t){var e=li,r=ci,n=Kr,i=Qo,a=i.key,o=.7;function s(a){var s,l=[],c=[],u=-1,h=a.length,f=xe(e),p=xe(r);function d(){l.push("M",i(t(c),o))}for(;++u1&&i.push("H",n[0]),i.join("")},"step-before":ts,"step-after":es,basis:is,"basis-open":function(t){if(t.length<4)return Qo(t);for(var e,r=[],n=-1,i=t.length,a=[0],o=[0];++n<3;)e=t[n],a.push(e[0]),o.push(e[1]);for(r.push(as(ls,a)+","+as(ls,o)),--n;++n9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}(t))}});function Qo(t){return t.length>1?t.join("L"):t+"Z"}function $o(t){return t.join("L")+"Z"}function ts(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;cTt)+",1 "+e}function l(t,e,r,n){return"Q 0,0 "+n}return a.radius=function(t){return arguments.length?(r=xe(t),a):r},a.source=function(e){return arguments.length?(t=xe(e),a):t},a.target=function(t){return arguments.length?(e=xe(t),a):e},a.startAngle=function(t){return arguments.length?(n=xe(t),a):n},a.endAngle=function(t){return arguments.length?(i=xe(t),a):i},a},t.svg.diagonal=function(){var t=Zn,e=Xn,r=ds;function n(n,i){var a=t.call(this,n,i),o=e.call(this,n,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return"M"+(l=l.map(r))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return n.source=function(e){return arguments.length?(t=xe(e),n):t},n.target=function(t){return arguments.length?(e=xe(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},t.svg.diagonal.radial=function(){var e=t.svg.diagonal(),r=ds,n=e.projection;return e.projection=function(t){return arguments.length?n(gs(r=t)):r},e},t.svg.symbol=function(){var t=vs,e=ms;function r(r,n){return(xs.get(t.call(this,r,n))||ys)(e.call(this,r,n))}return r.type=function(e){return arguments.length?(t=xe(e),r):t},r.size=function(t){return arguments.length?(e=xe(t),r):e},r};var xs=t.map({circle:ys,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*_s)),r=e*_s;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/bs),r=e*bs/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/bs),r=e*bs/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});t.svg.symbolTypes=xs.keys();var bs=Math.sqrt(3),_s=Math.tan(30*Dt);Z.transition=function(t){for(var e,r,n=Ms||++Ts,i=Es(t),a=[],o=ks||{time:Date.now(),ease:da,delay:0,duration:250},s=-1,l=this.length;++s0;)c[--f].call(t,o);if(a>=1)return h.event&&h.event.end.call(t,t.__data__,e),--u.count?delete u[n]:delete t[r],1}h||(a=i.time,o=Ie((function(t){var e=h.delay;if(o.t=e+a,e<=t)return f(t-e);o.c=f}),0,a),h=u[n]={tween:new _,time:a,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++u.count)}Is.call=Z.call,Is.empty=Z.empty,Is.node=Z.node,Is.size=Z.size,t.transition=function(e,r){return e&&e.transition?Ms?e.transition(r):e:t.selection().transition(e)},t.transition.prototype=Is,Is.select=function(t){var e,r,n,i=this.id,a=this.namespace,o=[];t=X(t);for(var s=-1,l=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function g(t){t.select(".extent").attr("y",l[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function m(){var h,m,v=this,y=t.select(t.event.target),x=n.of(v,arguments),b=t.select(v),_=y.datum(),w=!/^(n|s)$/.test(_)&&i,A=!/^(e|w)$/.test(_)&&a,C=y.classed("extent"),M=wt(v),k=t.mouse(v),I=t.select(o(v)).on("keydown.brush",(function(){32==t.event.keyCode&&(C||(h=null,k[0]-=s[1],k[1]-=l[1],C=2),j())})).on("keyup.brush",(function(){32==t.event.keyCode&&2==C&&(k[0]+=s[1],k[1]+=l[1],C=0,j())}));if(t.event.changedTouches?I.on("touchmove.brush",S).on("touchend.brush",D):I.on("mousemove.brush",S).on("mouseup.brush",D),b.interrupt().selectAll("*").interrupt(),C)k[0]=s[0]-k[0],k[1]=l[0]-k[1];else if(_){var T=+/w$/.test(_),L=+/^n/.test(_);m=[s[1-T]-k[0],l[1-L]-k[1]],k[0]=s[T],k[1]=l[L]}else t.event.altKey&&(h=k.slice());function S(){var e=t.mouse(v),r=!1;m&&(e[0]+=m[0],e[1]+=m[1]),C||(t.event.altKey?(h||(h=[(s[0]+s[1])/2,(l[0]+l[1])/2]),k[0]=s[+(e[0]1?{floor:function(e){for(;s(e=t.floor(e));)e=Hs(e-1);return e},ceil:function(e){for(;s(e=t.ceil(e));)e=Hs(+e+1);return e}}:t))},i.ticks=function(t,e){var r=bo(i.domain()),n=null==t?a(r,10):"number"==typeof t?a(r,t):!t.range&&[{range:t},e];return n&&(t=n[0],e=n[1]),t.range(r[0],Hs(+r[1]+1),e<1?1:e)},i.tickFormat=function(){return n},i.copy=function(){return Us(e.copy(),r,n)},Io(i,e)}function Hs(t){return new Date(t)}js.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Vs:Ys,Vs.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},Vs.toString=Ys.toString,Fe.second=Ye((function(t){return new Ne(1e3*Math.floor(t/1e3))}),(function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))}),(function(t){return t.getSeconds()})),Fe.seconds=Fe.second.range,Fe.seconds.utc=Fe.second.utc.range,Fe.minute=Ye((function(t){return new Ne(6e4*Math.floor(t/6e4))}),(function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))}),(function(t){return t.getMinutes()})),Fe.minutes=Fe.minute.range,Fe.minutes.utc=Fe.minute.utc.range,Fe.hour=Ye((function(t){var e=t.getTimezoneOffset()/60;return new Ne(36e5*(Math.floor(t/36e5-e)+e))}),(function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))}),(function(t){return t.getHours()})),Fe.hours=Fe.hour.range,Fe.hours.utc=Fe.hour.utc.range,Fe.month=Ye((function(t){return(t=Fe.day(t)).setDate(1),t}),(function(t,e){t.setMonth(t.getMonth()+e)}),(function(t){return t.getMonth()})),Fe.months=Fe.month.range,Fe.months.utc=Fe.month.utc.range;var Gs=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],qs=[[Fe.second,1],[Fe.second,5],[Fe.second,15],[Fe.second,30],[Fe.minute,1],[Fe.minute,5],[Fe.minute,15],[Fe.minute,30],[Fe.hour,1],[Fe.hour,3],[Fe.hour,6],[Fe.hour,12],[Fe.day,1],[Fe.day,2],[Fe.week,1],[Fe.month,1],[Fe.month,3],[Fe.year,1]],Ws=js.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Kr]]),Zs={range:function(e,r,n){return t.range(Math.ceil(e/n)*n,+r,n).map(Hs)},floor:D,ceil:D};qs.year=Fe.year,Fe.scale=function(){return Us(t.scale.linear(),qs,Ws)};var Xs=qs.map((function(t){return[t[0].utc,t[1]]})),Js=Bs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Kr]]);function Ks(t){return JSON.parse(t.responseText)}function Qs(t){var e=i.createRange();return e.selectNode(i.body),e.createContextualFragment(t.responseText)}Xs.year=Fe.year.utc,Fe.scale.utc=function(){return Us(t.scale.linear(),Xs,Js)},t.text=be((function(t){return t.responseText})),t.json=function(t,e){return _e(t,"application/json",Ks,e)},t.html=function(t,e){return _e(t,"text/html",Qs,e)},t.xml=be((function(t){return t.responseXML})),"object"==typeof e&&e.exports?e.exports=t:this.d3=t}()},{}],166:[function(t,e,r){e.exports=function(){for(var t=0;t=2)return!1;t[r]=n}return!0})):_.filter((function(t){for(var e=0;e<=s;++e){var r=v[t[e]];if(r<0)return!1;t[e]=r}return!0})),1&s)for(u=0;u<_.length;++u)f=(b=_[u])[0],b[0]=b[1],b[1]=f;return _}},{"incremental-convex-hull":415,uniq:546}],168:[function(t,e,r){"use strict";e.exports=a;var n=(a.canvas=document.createElement("canvas")).getContext("2d"),i=o([32,126]);function a(t,e){Array.isArray(t)&&(t=t.join(", "));var r,a={},s=16,l=.05;e&&(2===e.length&&"number"==typeof e[0]?r=o(e):Array.isArray(e)?r=e:(e.o?r=o(e.o):e.pairs&&(r=e.pairs),e.fontSize&&(s=e.fontSize),null!=e.threshold&&(l=e.threshold))),r||(r=i),n.font=s+"px "+t;for(var c=0;cs*l){var p=(f-h)/s;a[u]=1e3*p}}return a}function o(t){for(var e=[],r=t[0];r<=t[1];r++)for(var n=String.fromCharCode(r),i=t[0];i>>31},e.exports.exponent=function(t){return(e.exports.hi(t)<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){return!(2146435072&e.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:107}],170:[function(t,e,r){var n=t("abs-svg-path"),i=t("normalize-svg-path"),a={M:"moveTo",C:"bezierCurveTo"};e.exports=function(t,e){t.beginPath(),i(n(e)).forEach((function(e){var r=e[0],n=e.slice(1);t[a[r]].apply(t,n)})),t.closePath()}},{"abs-svg-path":63,"normalize-svg-path":454}],171:[function(t,e,r){e.exports=function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}},{}],172:[function(t,e,r){"use strict";e.exports=function(t,e){switch(void 0===e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n80*r){n=l=t[0],s=c=t[1];for(var b=r;bl&&(l=u),p>c&&(c=p);d=0!==(d=Math.max(l-n,c-s))?1/d:0}return o(y,x,r,n,s,d),x}function i(t,e,r,n,i){var a,o;if(i===T(t,e,r,n)>0)for(a=e;a=e;a-=n)o=M(a,t[a],t[a+1],o);return o&&x(o,o.next)&&(k(o),o=o.next),o}function a(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!x(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(k(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function o(t,e,r,n,i,h,f){if(t){!f&&h&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=d(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,h);for(var p,g,m=t;t.prev!==t.next;)if(p=t.prev,g=t.next,h?l(t,n,i,h):s(t))e.push(p.i/r),e.push(t.i/r),e.push(g.i/r),k(t),t=g.next,m=g.next;else if((t=g)===m){f?1===f?o(t=c(a(t),e,r),e,r,n,i,h,2):2===f&&u(t,e,r,n,i,h):o(a(t),e,r,n,i,h,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(y(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(m(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&y(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function l(t,e,r,n){var i=t.prev,a=t,o=t.next;if(y(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=d(s,l,e,r,n),f=d(c,u,e,r,n),p=t.prevZ,g=t.nextZ;p&&p.z>=h&&g&&g.z<=f;){if(p!==t.prev&&p!==t.next&&m(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,g!==t.prev&&g!==t.next&&m(i.x,i.y,a.x,a.y,o.x,o.y,g.x,g.y)&&y(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&m(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;g&&g.z<=f;){if(g!==t.prev&&g!==t.next&&m(i.x,i.y,a.x,a.y,o.x,o.y,g.x,g.y)&&y(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function c(t,e,r){var n=t;do{var i=n.prev,o=n.next.next;!x(i,o)&&b(i,n,n.next,o)&&A(i,o)&&A(o,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(o.i/r),k(n),k(n.next),n=t=o),n=n.next}while(n!==t);return a(n)}function u(t,e,r,n,i,s){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&v(l,c)){var u=C(l,c);return l=a(l,l.next),u=a(u,u.next),o(l,e,r,n,i,s),void o(u,e,r,n,i,s)}c=c.next}l=l.next}while(l!==t)}function h(t,e){return t.x-e.x}function f(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&m(ar.x||n.x===r.x&&p(r,n)))&&(r=n,f=l)),n=n.next}while(n!==c);return r}(t,e)){var r=C(e,t);a(r,r.next)}}function p(t,e){return y(t.prev,t,e.prev)<0&&y(e.next,t,t.next)<0}function d(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function g(t){var e=t,r=t;do{(e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&b(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(A(t,e)&&A(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(y(t.prev,t,e.prev)||y(t,e.prev,e))||x(t,e)&&y(t.prev,t,t.next)>0&&y(e.prev,e,e.next)>0)}function y(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function x(t,e){return t.x===e.x&&t.y===e.y}function b(t,e,r,n){var i=w(y(t,e,r)),a=w(y(t,e,n)),o=w(y(r,n,t)),s=w(y(r,n,e));return i!==a&&o!==s||!(0!==i||!_(t,r,e))||!(0!==a||!_(t,n,e))||!(0!==o||!_(r,t,n))||!(0!==s||!_(r,e,n))}function _(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function w(t){return t>0?1:t<0?-1:0}function A(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function C(t,e){var r=new I(t.i,t.x,t.y),n=new I(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function M(t,e,r,n){var i=new I(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function k(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function I(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,r,n){for(var i=0,a=e,o=r-n;a0&&(n+=t[i-1].length,r.holes.push(n))}return r}},{}],174:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var i=0;i=e}))}(e);for(var r,i=n(t).components.filter((function(t){return t.length>1})),a=1/0,o=0;o=55296&&y<=56319&&(w+=t[++r]),w=A?f.call(A,C,w,g):w,e?(p.value=w,d(m,g,p)):m[g]=w,++g;v=g}if(void 0===v)for(v=o(t.length),e&&(m=new e(v)),r=0;r0?1:-1}},{}],186:[function(t,e,r){"use strict";var n=t("../math/sign"),i=Math.abs,a=Math.floor;e.exports=function(t){return isNaN(t)?0:0!==(t=Number(t))&&isFinite(t)?n(t)*a(i(t)):t}},{"../math/sign":183}],187:[function(t,e,r){"use strict";var n=t("./to-integer"),i=Math.max;e.exports=function(t){return i(0,n(t))}},{"./to-integer":186}],188:[function(t,e,r){"use strict";var n=t("./valid-callable"),i=t("./valid-value"),a=Function.prototype.bind,o=Function.prototype.call,s=Object.keys,l=Object.prototype.propertyIsEnumerable;e.exports=function(t,e){return function(r,c){var u,h=arguments[2],f=arguments[3];return r=Object(i(r)),n(c),u=s(r),f&&u.sort("function"==typeof f?a.call(f,r):void 0),"function"!=typeof t&&(t=u[t]),o.call(t,u,(function(t,n){return l.call(r,t)?o.call(c,h,r[t],t,r,n):e}))}}},{"./valid-callable":206,"./valid-value":208}],189:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":190,"./shim":191}],190:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],191:[function(t,e,r){"use strict";var n=t("../keys"),i=t("../valid-value"),a=Math.max;e.exports=function(t,e){var r,o,s,l=a(arguments.length,2);for(t=Object(i(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},o=1;o-1}},{}],212:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return"string"==typeof t||t&&"object"==typeof t&&(t instanceof String||n.call(t)===i)||!1}},{}],213:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],214:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("es5-ext/string/#/contains"),o=t("d"),s=t("es6-symbol"),l=t("./"),c=Object.defineProperty;n=e.exports=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");l.call(this,t),e=e?a.call(e,"key+value")?"key+value":a.call(e,"key")?"key":"value":"value",c(this,"__kind__",o("",e))},i&&i(n,l),delete n.prototype.constructor,n.prototype=Object.create(l.prototype,{_resolve:o((function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t}))}),c(n.prototype,s.toStringTag,o("c","Array Iterator"))},{"./":217,d:153,"es5-ext/object/set-prototype-of":203,"es5-ext/string/#/contains":209,"es6-symbol":222}],215:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/valid-callable"),a=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,l=Function.prototype.call,c=Array.prototype.some;e.exports=function(t,e){var r,u,h,f,p,d,g,m,v=arguments[2];if(s(t)||n(t)?r="array":a(t)?r="string":t=o(t),i(e),h=function(){f=!0},"array"!==r)if("string"!==r)for(u=t.next();!u.done;){if(l.call(e,v,u.value,h),f)return;u=t.next()}else for(d=t.length,p=0;p=55296&&m<=56319&&(g+=t[++p]),l.call(e,v,g,h),!f);++p);else c.call(t,(function(t){return l.call(e,v,t,h),f}))}},{"./get":216,"es5-ext/function/is-arguments":180,"es5-ext/object/valid-callable":206,"es5-ext/string/is-string":212}],216:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/string/is-string"),a=t("./array"),o=t("./string"),s=t("./valid-iterable"),l=t("es6-symbol").iterator;e.exports=function(t){return"function"==typeof s(t)[l]?t[l]():n(t)?new a(t):i(t)?new o(t):new a(t)}},{"./array":214,"./string":219,"./valid-iterable":220,"es5-ext/function/is-arguments":180,"es5-ext/string/is-string":212,"es6-symbol":222}],217:[function(t,e,r){"use strict";var n,i=t("es5-ext/array/#/clear"),a=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),l=t("d"),c=t("d/auto-bind"),u=t("es6-symbol"),h=Object.defineProperty,f=Object.defineProperties;e.exports=n=function(t,e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");f(this,{__list__:l("w",s(t)),__context__:l("w",e),__nextIndex__:l("w",0)}),e&&(o(e.on),e.on("_add",this._onAdd),e.on("_delete",this._onDelete),e.on("_clear",this._onClear))},delete n.prototype.constructor,f(n.prototype,a({_next:l((function(){var t;if(this.__list__)return this.__redo__&&void 0!==(t=this.__redo__.shift())?t:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach((function(e,r){e>=t&&(this.__redo__[r]=++e)}),this),this.__redo__.push(t)):h(this,"__redo__",l("c",[t])))})),_onDelete:l((function(t){var e;t>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(e=this.__redo__.indexOf(t))&&this.__redo__.splice(e,1),this.__redo__.forEach((function(e,r){e>t&&(this.__redo__[r]=--e)}),this)))})),_onClear:l((function(){this.__redo__&&i.call(this.__redo__),this.__nextIndex__=0}))}))),h(n.prototype,u.iterator,l((function(){return this})))},{d:153,"d/auto-bind":152,"es5-ext/array/#/clear":176,"es5-ext/object/assign":189,"es5-ext/object/valid-callable":206,"es5-ext/object/valid-value":208,"es6-symbol":222}],218:[function(t,e,r){"use strict";var n=t("es5-ext/function/is-arguments"),i=t("es5-ext/object/is-value"),a=t("es5-ext/string/is-string"),o=t("es6-symbol").iterator,s=Array.isArray;e.exports=function(t){return!(!i(t)||!s(t)&&!a(t)&&!n(t)&&"function"!=typeof t[o])}},{"es5-ext/function/is-arguments":180,"es5-ext/object/is-value":197,"es5-ext/string/is-string":212,"es6-symbol":222}],219:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/set-prototype-of"),a=t("d"),o=t("es6-symbol"),s=t("./"),l=Object.defineProperty;n=e.exports=function(t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");t=String(t),s.call(this,t),l(this,"__length__",a("",t.length))},i&&i(n,s),delete n.prototype.constructor,n.prototype=Object.create(s.prototype,{_next:a((function(){if(this.__list__)return this.__nextIndex__=55296&&e<=56319?r+this.__list__[this.__nextIndex__++]:r}))}),l(n.prototype,o.toStringTag,a("c","String Iterator"))},{"./":217,d:153,"es5-ext/object/set-prototype-of":203,"es6-symbol":222}],220:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":218}],221:[function(t,r,n){(function(e,i){ -/*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version 3.3.1 - */ -!function(t,e){"object"==typeof n&&void 0!==r?r.exports=e():t.ES6Promise=e()}(this,(function(){"use strict";function r(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=0,o=void 0,s=void 0,l=function(t,e){g[a]=t,g[a+1]=e,2===(a+=2)&&(s?s(m):_())},c="undefined"!=typeof window?window:void 0,u=c||{},h=u.MutationObserver||u.WebKitMutationObserver,f="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(m,1)}}var g=new Array(1e3);function m(){for(var t=0;t=r-1){f=l.length-1;var d=t-e[r-1];for(p=0;p=r-1)for(var u=s.length-1,h=(e[r-1],0);h=0;--r)if(t[--e])return!1;return!0},s.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(t0;--h)n.push(a(l[h-1],c[h-1],arguments[h])),i.push(0)}},s.push=function(t){var e=this.lastT(),r=this.dimension;if(!(t1e-6?1/s:0;this._time.push(t);for(var f=r;f>0;--f){var p=a(c[f-1],u[f-1],arguments[f]);n.push(p),i.push((p-n[o++])*h)}}},s.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(a(o[l-1],s[l-1],arguments[l])),n.push(0)}},s.move=function(t){var e=this.lastT(),r=this.dimension;if(!(t<=e||arguments.length!==r+1)){var n=this._state,i=this._velocity,o=n.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,h=u>1e-6?1/u:0;this._time.push(t);for(var f=r;f>0;--f){var p=arguments[f];n.push(a(l[f-1],c[f-1],n[o++]+p)),i.push(p*h)}}},s.idle=function(t){var e=this.lastT();if(!(t=0;--h)n.push(a(l[h],c[h],n[o]+u*i[o])),i.push(0),o+=1}}},{"binary-search-bounds":93,"cubic-hermite":147}],230:[function(t,e,r){var n=t("dtype");e.exports=function(t,e,r){if(!t)throw new TypeError("must specify data as first parameter");if(r=0|+(r||0),Array.isArray(t)&&t[0]&&"number"==typeof t[0][0]){var i,a,o,s,l=t[0].length,c=t.length*l;e&&"string"!=typeof e||(e=new(n(e||"float32"))(c+r));var u=e.length-r;if(c!==u)throw new Error("source length "+c+" ("+l+"x"+t.length+") does not match destination length "+u);for(i=0,o=r;ie[0]-o[0]/2&&(f=o[0]/2,p+=o[1]);return r}},{"css-font/stringify":144}],232:[function(t,e,r){"use strict";function n(t,e){e||(e={}),("string"==typeof t||Array.isArray(t))&&(e.family=t);var r=Array.isArray(e.family)?e.family.join(", "):e.family;if(!r)throw Error("`family` must be defined");var s=e.size||e.fontSize||e.em||48,l=e.weight||e.fontWeight||"",c=(t=[e.style||e.fontStyle||"",l,s].join(" ")+"px "+r,e.origin||"top");if(n.cache[r]&&s<=n.cache[r].em)return i(n.cache[r],c);var u=e.canvas||n.canvas,h=u.getContext("2d"),f={upper:void 0!==e.upper?e.upper:"H",lower:void 0!==e.lower?e.lower:"x",descent:void 0!==e.descent?e.descent:"p",ascent:void 0!==e.ascent?e.ascent:"h",tittle:void 0!==e.tittle?e.tittle:"i",overshoot:void 0!==e.overshoot?e.overshoot:"O"},p=Math.ceil(1.5*s);u.height=p,u.width=.5*p,h.font=t;var d={top:0};h.clearRect(0,0,p,p),h.textBaseline="top",h.fillStyle="black",h.fillText("H",0,0);var g=a(h.getImageData(0,0,p,p));h.clearRect(0,0,p,p),h.textBaseline="bottom",h.fillText("H",0,p);var m=a(h.getImageData(0,0,p,p));d.lineHeight=d.bottom=p-m+g,h.clearRect(0,0,p,p),h.textBaseline="alphabetic",h.fillText("H",0,p);var v=p-a(h.getImageData(0,0,p,p))-1+g;d.baseline=d.alphabetic=v,h.clearRect(0,0,p,p),h.textBaseline="middle",h.fillText("H",0,.5*p);var y=a(h.getImageData(0,0,p,p));d.median=d.middle=p-y-1+g-.5*p,h.clearRect(0,0,p,p),h.textBaseline="hanging",h.fillText("H",0,.5*p);var x=a(h.getImageData(0,0,p,p));d.hanging=p-x-1+g-.5*p,h.clearRect(0,0,p,p),h.textBaseline="ideographic",h.fillText("H",0,p);var b=a(h.getImageData(0,0,p,p));if(d.ideographic=p-b-1+g,f.upper&&(h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.upper,0,0),d.upper=a(h.getImageData(0,0,p,p)),d.capHeight=d.baseline-d.upper),f.lower&&(h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.lower,0,0),d.lower=a(h.getImageData(0,0,p,p)),d.xHeight=d.baseline-d.lower),f.tittle&&(h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.tittle,0,0),d.tittle=a(h.getImageData(0,0,p,p))),f.ascent&&(h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.ascent,0,0),d.ascent=a(h.getImageData(0,0,p,p))),f.descent&&(h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.descent,0,0),d.descent=o(h.getImageData(0,0,p,p))),f.overshoot){h.clearRect(0,0,p,p),h.textBaseline="top",h.fillText(f.overshoot,0,0);var _=o(h.getImageData(0,0,p,p));d.overshoot=_-v}for(var w in d)d[w]/=s;return d.em=s,n.cache[r]=d,i(d,c)}function i(t,e){var r={};for(var n in"string"==typeof e&&(e=t[e]),t)"em"!==n&&(r[n]=t[n]-e);return r}function a(t){for(var e=t.height,r=t.data,n=3;n0;n-=4)if(0!==r[n])return Math.floor(.25*(n-3)/e)}e.exports=n,n.canvas=document.createElement("canvas"),n.cache={}},{}],233:[function(t,e,r){"use strict";e.exports=function(t){return new c(t||v,null)};var n=0,i=1;function a(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function o(t){return new a(t._color,t.key,t.value,t.left,t.right,t._count)}function s(t,e){return new a(t,e.key,e.value,e.left,e.right,e._count)}function l(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function c(t,e){this._compare=t,this.root=e}var u=c.prototype;function h(t,e){var r;return e.left&&(r=h(t,e.left))?r:(r=t(e.key,e.value))||(e.right?h(t,e.right):void 0)}function f(t,e,r,n){if(e(t,n.key)<=0){var i;if(n.left&&(i=f(t,e,r,n.left)))return i;if(i=r(n.key,n.value))return i}if(n.right)return f(t,e,r,n.right)}function p(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(o<=0){if(i.left&&(a=p(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}if(s>0&&i.right)return p(t,e,r,n,i.right)}function d(t,e){this.tree=t,this._stack=e}Object.defineProperty(u,"keys",{get:function(){var t=[];return this.forEach((function(e,r){t.push(e)})),t}}),Object.defineProperty(u,"values",{get:function(){var t=[];return this.forEach((function(e,r){t.push(r)})),t}}),Object.defineProperty(u,"length",{get:function(){return this.root?this.root._count:0}}),u.insert=function(t,e){for(var r=this._compare,o=this.root,u=[],h=[];o;){var f=r(t,o.key);u.push(o),h.push(f),o=f<=0?o.left:o.right}u.push(new a(n,t,e,null,null,1));for(var p=u.length-2;p>=0;--p)o=u[p],h[p]<=0?u[p]=new a(o._color,o.key,o.value,u[p+1],o.right,o._count+1):u[p]=new a(o._color,o.key,o.value,o.left,u[p+1],o._count+1);for(p=u.length-1;p>1;--p){var d=u[p-1];if(o=u[p],d._color===i||o._color===i)break;var g=u[p-2];if(g.left===d)if(d.left===o){if(!(m=g.right)||m._color!==n){g._color=n,g.left=d.right,d._color=i,d.right=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3&&((v=u[p-3]).left===g?v.left=d:v.right=d);break}d._color=i,g.right=s(i,m),g._color=n,p-=1}else{if(!(m=g.right)||m._color!==n){d.right=o.left,g._color=n,g.left=o.right,o._color=i,o.left=d,o.right=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3&&((v=u[p-3]).left===g?v.left=o:v.right=o);break}d._color=i,g.right=s(i,m),g._color=n,p-=1}else if(d.right===o){if(!(m=g.left)||m._color!==n){g._color=n,g.right=d.left,d._color=i,d.left=g,u[p-2]=d,u[p-1]=o,l(g),l(d),p>=3&&((v=u[p-3]).right===g?v.right=d:v.left=d);break}d._color=i,g.left=s(i,m),g._color=n,p-=1}else{var m;if(!(m=g.left)||m._color!==n){var v;d.left=o.right,g._color=n,g.right=o.left,o._color=i,o.right=d,o.left=g,u[p-2]=o,u[p-1]=d,l(g),l(d),l(o),p>=3&&((v=u[p-3]).right===g?v.right=o:v.left=o);break}d._color=i,g.left=s(i,m),g._color=n,p-=1}}return u[0]._color=i,new c(r,u[0])},u.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return h(t,this.root);case 2:return f(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return p(e,r,this._compare,t,this.root)}},Object.defineProperty(u,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new d(this,t)}}),Object.defineProperty(u,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new d(this,t)}}),u.at=function(t){if(t<0)return new d(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new d(this,[])},u.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new d(this,n)},u.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new d(this,n)},u.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new d(this,n)},u.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new d(this,n)},u.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new d(this,n);r=i<=0?r.left:r.right}return new d(this,[])},u.remove=function(t){var e=this.find(t);return e?e.remove():this},u.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var g=d.prototype;function m(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function v(t,e){return te?1:0}Object.defineProperty(g,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(g,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),g.clone=function(){return new d(this.tree,this._stack.slice())},g.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new a(r._color,r.key,r.value,r.left,r.right,r._count);for(var u=t.length-2;u>=0;--u)(r=t[u]).left===t[u+1]?e[u]=new a(r._color,r.key,r.value,e[u+1],r.right,r._count):e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count);if((r=e[e.length-1]).left&&r.right){var h=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var f=e[h-1];for(e.push(new a(r._color,f.key,f.value,r.left,r.right,r._count)),e[h-1].key=r.key,e[h-1].value=r.value,u=e.length-2;u>=h;--u)r=e[u],e[u]=new a(r._color,r.key,r.value,r.left,e[u+1],r._count);e[h-1].left=e[h]}if((r=e[e.length-1])._color===n){var p=e[e.length-2];for(p.left===r?p.left=null:p.right===r&&(p.right=null),e.pop(),u=0;u=0;--u){if(e=t[u],0===u)return void(e._color=i);if((r=t[u-1]).left===e){if((a=r.right).right&&a.right._color===n)return c=(a=r.right=o(a)).right=o(a.right),r.right=a.left,a.left=r,a.right=c,a._color=r._color,e._color=i,r._color=i,c._color=i,l(r),l(a),u>1&&((h=t[u-2]).left===r?h.left=a:h.right=a),void(t[u-1]=a);if(a.left&&a.left._color===n)return c=(a=r.right=o(a)).left=o(a.left),r.right=c.left,a.left=c.right,c.left=r,c.right=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((h=t[u-2]).left===r?h.left=c:h.right=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.right=s(n,a));r.right=s(n,a);continue}a=o(a),r.right=a.left,a.left=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((h=t[u-2]).left===r?h.left=a:h.right=a),t[u-1]=a,t[u]=r,u+11&&((h=t[u-2]).right===r?h.right=a:h.left=a),void(t[u-1]=a);if(a.right&&a.right._color===n)return c=(a=r.left=o(a)).right=o(a.right),r.left=c.right,a.right=c.left,c.right=r,c.left=a,c._color=r._color,r._color=i,a._color=i,e._color=i,l(r),l(a),l(c),u>1&&((h=t[u-2]).right===r?h.right=c:h.left=c),void(t[u-1]=c);if(a._color===i){if(r._color===n)return r._color=i,void(r.left=s(n,a));r.left=s(n,a);continue}var h;a=o(a),r.left=a.right,a.right=r,a._color=r._color,r._color=n,l(r),l(a),u>1&&((h=t[u-2]).right===r?h.right=a:h.left=a),t[u-1]=a,t[u]=r,u+10)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(g,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(g,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),g.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(g,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),g.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),n=e[e.length-1];r[r.length-1]=new a(n._color,n.key,t,n.left,n.right,n._count);for(var i=e.length-2;i>=0;--i)(n=e[i]).left===e[i+1]?r[i]=new a(n._color,n.key,n.value,r[i+1],n.right,n._count):r[i]=new a(n._color,n.key,n.value,n.left,r[i+1],n._count);return new c(this.tree._compare,r[0])},g.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(g,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],234:[function(t,e,r){var n=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],i=607/128,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function o(t){if(t<0)return Number("0/0");for(var e=a[0],r=a.length-1;r>0;--r)e+=a[r]/(t+r);var n=t+i+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(o(e));e-=1;for(var r=n[0],i=1;i<9;i++)r+=n[i]/(e+i);var a=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*r},e.exports.log=o},{}],235:[function(t,e,r){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must specify type string");if(e=e||{},"undefined"==typeof document&&!e.canvas)return null;var r=e.canvas||document.createElement("canvas");"number"==typeof e.width&&(r.width=e.width),"number"==typeof e.height&&(r.height=e.height);var n,i=e;try{var a=[t];0===t.indexOf("webgl")&&a.push("experimental-"+t);for(var o=0;o0?(p[u]=-1,d[u]=0):(p[u]=0,d[u]=1)}}var g=[0,0,0],m={model:l,view:l,projection:l,_ortho:!1};h.isOpaque=function(){return!0},h.isTransparent=function(){return!1},h.drawTransparent=function(t){};var v=[0,0,0],y=[0,0,0],x=[0,0,0];h.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||l,n=t.view||l,i=t.projection||l,a=this.bounds,s=t._ortho||!1,u=o(r,n,i,a,s),h=u.cubeEdges,f=u.axis,b=n[12],_=n[13],w=n[14],A=n[15],C=(s?2:1)*this.pixelRatio*(i[3]*b+i[7]*_+i[11]*w+i[15]*A)/e.drawingBufferHeight,M=0;M<3;++M)this.lastCubeProps.cubeEdges[M]=h[M],this.lastCubeProps.axis[M]=f[M];var k=p;for(M=0;M<3;++M)d(p[M],M,this.bounds,h,f);e=this.gl;var I,T,L,S=g;for(M=0;M<3;++M)this.backgroundEnable[M]?S[M]=f[M]:S[M]=0;for(this._background.draw(r,n,i,a,S,this.backgroundColor),this._lines.bind(r,n,i,this),M=0;M<3;++M){var E=[0,0,0];f[M]>0?E[M]=a[1][M]:E[M]=a[0][M];for(var D=0;D<2;++D){var P=(M+1+D)%3,O=(M+1+(1^D))%3;this.gridEnable[P]&&this._lines.drawGrid(P,O,this.bounds,E,this.gridColor[P],this.gridWidth[P]*this.pixelRatio)}for(D=0;D<2;++D)P=(M+1+D)%3,O=(M+1+(1^D))%3,this.zeroEnable[O]&&Math.min(a[0][O],a[1][O])<=0&&Math.max(a[0][O],a[1][O])>=0&&this._lines.drawZero(P,O,this.bounds,E,this.zeroLineColor[O],this.zeroLineWidth[O]*this.pixelRatio)}for(M=0;M<3;++M){this.lineEnable[M]&&this._lines.drawAxisLine(M,this.bounds,k[M].primalOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio),this.lineMirror[M]&&this._lines.drawAxisLine(M,this.bounds,k[M].mirrorOffset,this.lineColor[M],this.lineWidth[M]*this.pixelRatio);var z=c(v,k[M].primalMinor),R=c(y,k[M].mirrorMinor),F=this.lineTickLength;for(D=0;D<3;++D){var N=C/r[5*D];z[D]*=F[D]*N,R[D]*=F[D]*N}this.lineTickEnable[M]&&this._lines.drawAxisTicks(M,k[M].primalOffset,z,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio),this.lineTickMirror[M]&&this._lines.drawAxisTicks(M,k[M].mirrorOffset,R,this.lineTickColor[M],this.lineTickWidth[M]*this.pixelRatio)}function j(t){(L=[0,0,0])[t]=1}function B(t,e,r){var n=(t+1)%3,i=(t+2)%3,a=e[n],o=e[i],s=r[n],l=r[i];a>0&&l>0?j(n):a>0&&l<0?j(n):a<0&&l>0?j(n):a<0&&l<0?j(n):o>0&&s>0?j(i):o>0&&s<0?j(i):o<0&&s>0?j(i):o<0&&s<0&&j(i)}for(this._lines.unbind(),this._text.bind(r,n,i,this.pixelRatio),M=0;M<3;++M){var Y=k[M].primalMinor,V=k[M].mirrorMinor,U=c(x,k[M].primalOffset);for(D=0;D<3;++D)this.lineTickEnable[M]&&(U[D]+=C*Y[D]*Math.max(this.lineTickLength[D],0)/r[5*D]);var H=[0,0,0];if(H[M]=1,this.tickEnable[M]){for(-3600===this.tickAngle[M]?(this.tickAngle[M]=0,this.tickAlign[M]="auto"):this.tickAlign[M]=-1,T=1,"auto"===(I=[this.tickAlign[M],.5,T])[0]?I[0]=0:I[0]=parseInt(""+I[0]),L=[0,0,0],B(M,Y,V),D=0;D<3;++D)U[D]+=C*Y[D]*this.tickPad[D]/r[5*D];this._text.drawTicks(M,this.tickSize[M],this.tickAngle[M],U,this.tickColor[M],H,L,I)}if(this.labelEnable[M]){for(T=0,L=[0,0,0],this.labels[M].length>4&&(j(M),T=1),"auto"===(I=[this.labelAlign[M],.5,T])[0]?I[0]=0:I[0]=parseInt(""+I[0]),D=0;D<3;++D)U[D]+=C*Y[D]*this.labelPad[D]/r[5*D];U[M]+=.5*(a[0][M]+a[1][M]),this._text.drawLabel(M,this.labelSize[M],this.labelAngle[M],U,this.labelColor[M],[0,0,0],L,I)}}this._text.unbind()},h.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":237,"./lib/cube.js":238,"./lib/lines.js":239,"./lib/text.js":241,"./lib/ticks.js":242}],237:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var c=(l+1)%3,u=(l+2)%3,h=[0,0,0],f=[0,0,0],p=-1;p<=1;p+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),h[l]=p,f[l]=p;for(var d=-1;d<=1;d+=2){h[c]=d;for(var g=-1;g<=1;g+=2)h[u]=g,e.push(h[0],h[1],h[2],f[0],f[1],f[2]),s+=1}var m=c;c=u,u=m}var v=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),x=i(t,[{buffer:v,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:v,type:t.FLOAT,size:3,offset:12,stride:24}],y),b=a(t);return b.attributes.position.location=0,b.attributes.normal.location=1,new o(t,v,x,b)};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}var s=o.prototype;s.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;s<3;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),l.disable(l.POLYGON_OFFSET_FILL)}},s.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":240,"gl-buffer":244,"gl-vao":329}],238:[function(t,e,r){"use strict";e.exports=function(t,e,r,a,p){i(s,e,t),i(s,r,s);for(var y=0,x=0;x<2;++x){u[2]=a[x][2];for(var b=0;b<2;++b){u[1]=a[b][1];for(var _=0;_<2;++_)u[0]=a[_][0],f(l[y],u,s),y+=1}}var w=-1;for(x=0;x<8;++x){for(var A=l[x][3],C=0;C<3;++C)c[x][C]=l[x][C]/A;p&&(c[x][2]*=-1),A<0&&(w<0?w=x:c[x][2]T&&(w|=1<T&&(w|=1<c[x][1]&&(R=x));var F=-1;for(x=0;x<3;++x)(j=R^1<c[N][0]&&(N=j))}var B=g;B[0]=B[1]=B[2]=0,B[n.log2(F^R)]=R&F,B[n.log2(R^N)]=R&N;var Y=7^N;Y===w||Y===z?(Y=7^F,B[n.log2(N^Y)]=Y&N):B[n.log2(F^Y)]=Y&F;var V=m,U=w;for(M=0;M<3;++M)V[M]=U&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]),l=n(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);r.text=function(t){return i(t,s,l,null,[{name:"position",type:"vec3"}])};var c=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]),u=n(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);r.bg=function(t){return i(t,c,u,null,[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}])}},{"gl-shader":304,glslify:411}],241:[function(t,e,r){(function(r){"use strict";e.exports=function(t,e,r,a,s,l){var u=n(t),h=i(t,[{buffer:u,size:3}]),f=o(t);f.attributes.position.location=0;var p=new c(t,f,u,h);return p.update(e,r,a,s,l),p};var n=t("gl-buffer"),i=t("gl-vao"),a=t("vectorize-text"),o=t("./shaders").text,s=window||r.global||{},l=s.__TEXT_CACHE||{};function c(t,e,r,n){this.gl=t,this.shader=e,this.buffer=r,this.vao=n,this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}s.__TEXT_CACHE={};var u=c.prototype,h=[0,0];u.bind=function(t,e,r,n){this.vao.bind(),this.shader.bind();var i=this.shader.uniforms;i.model=t,i.view=e,i.projection=r,i.pixelScale=n,h[0]=this.gl.drawingBufferWidth,h[1]=this.gl.drawingBufferHeight,this.shader.uniforms.resolution=h},u.unbind=function(){this.vao.unbind()},u.update=function(t,e,r,n,i){var o=[];function s(t,e,r,n,i,s){var c=l[r];c||(c=l[r]={});var u=c[e];u||(u=c[e]=function(t,e){try{return a(t,e)}catch(e){return console.warn('error vectorizing text:"'+t+'" error:',e),{cells:[],positions:[]}}}(e,{triangles:!0,font:r,textAlign:"center",textBaseline:"middle",lineSpacing:i,styletags:s}));for(var h=(n||12)/12,f=u.positions,p=u.cells,d=0,g=p.length;d=0;--v){var y=f[m[v]];o.push(h*y[0],-h*y[1],t)}}for(var c=[0,0,0],u=[0,0,0],h=[0,0,0],f=[0,0,0],p={breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},d=0;d<3;++d){h[d]=o.length/3|0,s(.5*(t[0][d]+t[1][d]),e[d],r[d],12,1.25,p),f[d]=(o.length/3|0)-h[d],c[d]=o.length/3|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;o<0?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c|=0);var u=""+l;if(o<0&&(u="-"+u),i){for(var h=""+c;h.length=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r},r.equal=function(t,e){for(var r=0;r<3;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;nr)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function u(t,e){for(var r=n.malloc(t.length,e),i=t.length,a=0;a=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=c(this.gl,this.type,this.length,this.usage,t.data,e):this.length=c(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=n.malloc(t.size,r),l=a(s,t.shape);i.assign(l,t),this.length=c(this.gl,this.type,this.length,this.usage,e<0?s:s.subarray(0,t.size),e),n.free(s)}}else if(Array.isArray(t)){var h;h=this.type===this.gl.ELEMENT_ARRAY_BUFFER?u(t,"uint16"):u(t,"float32"),this.length=c(this.gl,this.type,this.length,this.usage,e<0?h:h.subarray(0,t.length),e),n.free(h)}else if("object"==typeof t&&"number"==typeof t.length)this.length=c(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");(t|=0)<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=function(t,e,r,n){if(r=r||t.ARRAY_BUFFER,n=n||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(n!==t.DYNAMIC_DRAW&&n!==t.STATIC_DRAW&&n!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var i=t.createBuffer(),a=new s(t,r,i,0,n);return a.update(e),a}},{ndarray:452,"ndarray-ops":446,"typedarray-pool":544}],245:[function(t,e,r){"use strict";var n=t("gl-vec3");e.exports=function(t,e){var r=t.positions,i=t.vectors,a={positions:[],vertexIntensity:[],vertexIntensityBounds:t.vertexIntensityBounds,vectors:[],cells:[],coneOffset:t.coneOffset,colormap:t.colormap};if(0===t.positions.length)return e&&(e[0]=[0,0,0],e[1]=[0,0,0]),a;for(var o=0,s=1/0,l=-1/0,c=1/0,u=-1/0,h=1/0,f=-1/0,p=null,d=null,g=[],m=1/0,v=!1,y=0;yo&&(o=n.length(b)),y){var _=2*n.distance(p,x)/(n.length(d)+n.length(b));_?(m=Math.min(m,_),v=!1):v=!0}v||(p=x,d=b),g.push(b)}var w=[s,c,h],A=[l,u,f];e&&(e[0]=w,e[1]=A),0===o&&(o=1);var C=1/o;isFinite(m)||(m=1),a.vectorScale=m;var M=t.coneSize||.5;t.absoluteConeSize&&(M=t.absoluteConeSize*C),a.coneScale=M,y=0;for(var k=0;y=1},p.isTransparent=function(){return this.opacity<1},p.pickSlots=1,p.setPickBase=function(t){this.pickId=t},p.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),void 0!==t.tubeScale&&(this.tubeScale=t.tubeScale),void 0!==t.vectorScale&&(this.vectorScale=t.vectorScale),void 0!==t.coneScale&&(this.coneScale=t.coneScale),void 0!==t.coneOffset&&(this.coneOffset=t.coneOffset),t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(function(t){for(var e=u({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;n<256;++n){for(var i=e[n],a=0;a<3;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return c(r,[256,256,4],[4,0,1])}(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions,i=t.vectors;if(n&&r&&i){var a=[],o=[],s=[],l=[],h=[];this.cells=r,this.positions=n,this.vectors=i;var f=t.meshColor||[1,1,1,1],p=t.vertexIntensity,d=1/0,g=-1/0;if(p)if(t.vertexIntensityBounds)d=+t.vertexIntensityBounds[0],g=+t.vertexIntensityBounds[1];else for(var m=0;m0){var g=this.triShader;g.bind(),g.uniforms=c,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}},p.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||h,n=t.view||h,i=t.projection||h,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,tubeScale:this.tubeScale,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255},l=this.pickShader;l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind())},p.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions[r[1]].slice(0,3),i={position:n,dataCoordinate:n,index:Math.floor(r[1]/48)};return"cone"===this.traceType?i.index=Math.floor(r[1]/48):"streamtube"===this.traceType&&(i.intensity=this.intensity[r[1]],i.velocity=this.vectors[r[1]].slice(0,3),i.divergence=this.vectors[r[1]][3],i.index=e),i},p.dispose=function(){this.texture.dispose(),this.triShader.dispose(),this.pickShader.dispose(),this.triangleVAO.dispose(),this.trianglePositions.dispose(),this.triangleVectors.dispose(),this.triangleColors.dispose(),this.triangleUVs.dispose(),this.triangleIds.dispose()},e.exports=function(t,e,r){var s=r.shaders;1===arguments.length&&(t=(e=t).gl);var l=function(t,e){var r=n(t,e.meshShader.vertex,e.meshShader.fragment,null,e.meshShader.attributes);return r.attributes.position.location=0,r.attributes.color.location=2,r.attributes.uv.location=3,r.attributes.vector.location=4,r}(t,s),u=function(t,e){var r=n(t,e.pickShader.vertex,e.pickShader.fragment,null,e.pickShader.attributes);return r.attributes.position.location=0,r.attributes.id.location=1,r.attributes.vector.location=4,r}(t,s),h=o(t,c(new Uint8Array([255,255,255,255]),[1,1,4]));h.generateMipmap(),h.minFilter=t.LINEAR_MIPMAP_LINEAR,h.magFilter=t.LINEAR;var p=i(t),d=i(t),g=i(t),m=i(t),v=i(t),y=new f(t,h,l,u,p,d,v,g,m,a(t,[{buffer:p,type:t.FLOAT,size:4},{buffer:v,type:t.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:g,type:t.FLOAT,size:4},{buffer:m,type:t.FLOAT,size:2},{buffer:d,type:t.FLOAT,size:4}]),r.traceType||"cone");return y.update(e),y}},{colormap:128,"gl-buffer":244,"gl-mat4/invert":268,"gl-mat4/multiply":270,"gl-shader":304,"gl-texture2d":324,"gl-vao":329,ndarray:452}],247:[function(t,e,r){var n=t("glslify"),i=n(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float rawIndex, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n float index = rawIndex - floor(rawIndex /\n (segmentCount * 6.0)) *\n (segmentCount * 6.0);\n\n float segment = floor(0.001 + index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex > 2.99 && segmentIndex < 3.01) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n float nextAngle = (\n (segmentIndex > 0.99 && segmentIndex < 1.01) ||\n (segmentIndex > 4.99 && segmentIndex < 5.01)\n ) ? 1.0 : 0.0;\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex < 3.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\n\nuniform float vectorScale, coneScale, coneOffset;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 eyePosition, lightPosition;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * conePosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n\n f_color = color;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_uv = uv;\n}\n"]),a=n(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float rawIndex, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n float index = rawIndex - floor(rawIndex /\n (segmentCount * 6.0)) *\n (segmentCount * 6.0);\n\n float segment = floor(0.001 + index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex > 2.99 && segmentIndex < 3.01) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n float nextAngle = (\n (segmentIndex > 0.99 && segmentIndex < 1.01) ||\n (segmentIndex > 4.99 && segmentIndex < 5.01)\n ) ? 1.0 : 0.0;\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex < 3.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float vectorScale, coneScale, coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector.xyz), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec3"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec3"}]}},{glslify:411}],248:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34e3:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],249:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":248}],250:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=n(e),o=i(e,[{buffer:r,type:e.FLOAT,size:3,offset:0,stride:40},{buffer:r,type:e.FLOAT,size:4,offset:12,stride:40},{buffer:r,type:e.FLOAT,size:3,offset:28,stride:40}]),l=a(e);l.attributes.position.location=0,l.attributes.color.location=1,l.attributes.offset.location=2;var c=new s(e,r,o,l);return c.update(t),c};var n=t("gl-buffer"),i=t("gl-vao"),a=t("./shaders/index"),o=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function s(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1,this.hasAlpha=!1}var l=s.prototype;function c(t,e){for(var r=0;r<3;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}l.isOpaque=function(){return!this.hasAlpha},l.isTransparent=function(){return this.hasAlpha},l.drawTransparent=l.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||o,i=r.projection=t.projection||o;r.model=t.model||o,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],s=n[13],l=n[14],c=n[15],u=(t._ortho?2:1)*this.pixelRatio*(i[3]*a+i[7]*s+i[11]*l+i[15]*c)/e.drawingBufferHeight;this.vao.bind();for(var h=0;h<3;++h)e.lineWidth(this.lineWidth[h]*this.pixelRatio),r.capSize=this.capSize[h]*u,this.lineCount[h]&&e.drawArrays(e.LINES,this.lineOffset[h],this.lineCount[h]);this.vao.unbind()};var u=function(){for(var t=new Array(3),e=0;e<3;++e){for(var r=[],n=1;n<=2;++n)for(var i=-1;i<=1;i+=2){var a=[0,0,0];a[(n+e)%3]=i,r.push(a)}t[e]=r}return t}();function h(t,e,r,n){for(var i=u[n],a=0;a0&&((p=u.slice())[s]+=d[1][s],i.push(u[0],u[1],u[2],g[0],g[1],g[2],g[3],0,0,0,p[0],p[1],p[2],g[0],g[1],g[2],g[3],0,0,0),c(this.bounds,p),o+=2+h(i,p,g,s)))}this.lineCount[s]=o-this.lineOffset[s]}this.buffer.update(i)}},l.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":251,"gl-buffer":244,"gl-vao":329}],251:[function(t,e,r){"use strict";var n=t("glslify"),i=t("gl-shader"),a=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (\n outOfRange(clipBounds[0], clipBounds[1], fragPosition) ||\n fragColor.a * opacity == 0.\n ) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"offset",type:"vec3"}])}},{"gl-shader":304,glslify:411}],252:[function(t,e,r){"use strict";var n=t("gl-texture2d");e.exports=function(t,e,r,n){i||(i=t.FRAMEBUFFER_UNSUPPORTED,a=t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT,o=t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS,s=t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);var c=t.getExtension("WEBGL_draw_buffers");if(!l&&c&&function(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);l=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;au||r<0||r>u)throw new Error("gl-fbo: Parameters are too large for FBO");var h=1;if("color"in(n=n||{})){if((h=Math.max(0|n.color,0))<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(h>1){if(!c)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(h>t.getParameter(c.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+h+" draw buffers")}}var f=t.UNSIGNED_BYTE,p=t.getExtension("OES_texture_float");if(n.float&&h>0){if(!p)throw new Error("gl-fbo: Context does not support floating point textures");f=t.FLOAT}else n.preferFloat&&h>0&&p&&(f=t.FLOAT);var g=!0;"depth"in n&&(g=!!n.depth);var m=!1;return"stencil"in n&&(m=!!n.stencil),new d(t,e,r,f,h,g,m,c)};var i,a,o,s,l=null;function c(t){return[t.getParameter(t.FRAMEBUFFER_BINDING),t.getParameter(t.RENDERBUFFER_BINDING),t.getParameter(t.TEXTURE_BINDING_2D)]}function u(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function h(t){switch(t){case i:throw new Error("gl-fbo: Framebuffer unsupported");case a:throw new Error("gl-fbo: Framebuffer incomplete attachment");case o:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case s:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function f(t,e,r,i,a,o){if(!i)return null;var s=n(t,e,r,a,i);return s.magFilter=t.NEAREST,s.minFilter=t.NEAREST,s.mipSamples=1,s.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,o,t.TEXTURE_2D,s.handle,0),s}function p(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function d(t,e,r,n,i,a,o,s){this.gl=t,this._shape=[0|e,0|r],this._destroyed=!1,this._ext=s,this.color=new Array(i);for(var d=0;d1&&s.drawBuffersWEBGL(l[o]);var y=r.getExtension("WEBGL_depth_texture");y?d?t.depth=f(r,i,a,y.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g&&(t.depth=f(r,i,a,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):g&&d?t._depth_rb=p(r,i,a,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):g?t._depth_rb=p(r,i,a,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=p(r,i,a,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var x=r.checkFramebufferStatus(r.FRAMEBUFFER);if(x!==r.FRAMEBUFFER_COMPLETE){for(t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null),v=0;vi||r<0||r>i)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var a=c(n),o=0;o>8*p&255;this.pickOffset=r,i.bind();var d=i.uniforms;d.viewTransform=t,d.pickOffset=e,d.shape=this.shape;var g=i.attributes;return this.positionBuffer.bind(),g.position.pointer(),this.weightBuffer.bind(),g.weight.pointer(s.UNSIGNED_BYTE,!1),this.idBuffer.bind(),g.pickId.pointer(s.UNSIGNED_BYTE,!1),s.drawArrays(s.TRIANGLES,0,o),r+this.shape[0]*this.shape[1]}}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(r=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},h.update=function(t){var e=(t=t||{}).shape||[0,0],r=t.x||i(e[0]),o=t.y||i(e[1]),s=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=o;var l=t.colorLevels||[0],c=t.colorValues||[0,0,0,1],u=l.length,h=this.bounds,p=h[0]=r[0],d=h[1]=o[0],g=1/((h[2]=r[r.length-1])-p),m=1/((h[3]=o[o.length-1])-d),v=e[0],y=e[1];this.shape=[v,y];var x=(v-1)*(y-1)*(f.length>>>1);this.numVertices=x;for(var b=a.mallocUint8(4*x),_=a.mallocFloat32(2*x),w=a.mallocUint8(2*x),A=a.mallocUint32(x),C=0,M=0;M max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (\n outOfRange(clipBounds[0], clipBounds[1], worldPosition) ||\n fragColor.a * opacity == 0.\n ) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]),s=n(["precision highp float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1540259130(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, encode_float_1540259130(pixelArcLength).xyz);\n}"]),l=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return i(t,a,o,null,l)},r.createPickShader=function(t){return i(t,a,s,null,l)}},{"gl-shader":304,glslify:411}],258:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl||t.scene&&t.scene.gl,r=u(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var o=h(e);o.attributes.position.location=0,o.attributes.nextPosition.location=1,o.attributes.arcLength.location=2,o.attributes.lineWidth.location=3,o.attributes.color.location=4;for(var s=n(e),c=i(e,[{buffer:s,size:3,offset:0,stride:48},{buffer:s,size:3,offset:12,stride:48},{buffer:s,size:1,offset:24,stride:48},{buffer:s,size:1,offset:28,stride:48},{buffer:s,size:4,offset:32,stride:48}]),f=l(new Array(1024),[256,1,4]),p=0;p<1024;++p)f.data[p]=255;var d=a(e,f);d.wrap=e.REPEAT;var g=new m(e,r,o,s,c,d);return g.update(t),g};var n=t("gl-buffer"),i=t("gl-vao"),a=t("gl-texture2d"),o=t("glsl-read-float"),s=t("binary-search-bounds"),l=t("ndarray"),c=t("./lib/shaders"),u=c.createShader,h=c.createPickShader,f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function p(t,e){for(var r=0,n=0;n<3;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function d(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;r<3;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function g(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function m(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.hasAlpha=!1,this.dirty=!0,this.pixelRatio=1}var v=m.prototype;v.isTransparent=function(){return this.hasAlpha},v.isOpaque=function(){return!this.hasAlpha},v.pickSlots=1,v.setPickBase=function(t){this.pickId=t},v.drawTransparent=v.draw=function(t){if(this.vertexCount){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||f,view:t.view||f,projection:t.projection||f,clipBounds:d(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},v.drawPick=function(t){if(this.vertexCount){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||f,view:t.view||f,projection:t.projection||f,pickId:this.pickId,clipBounds:d(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount),n.unbind()}},v.update=function(t){var e,r;this.dirty=!0;var n=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),this.hasAlpha=!1,"opacity"in t&&(this.opacity=+t.opacity,this.opacity<1&&(this.hasAlpha=!0));var i=[],a=[],o=[],c=0,u=0,h=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],f=t.position||t.positions;if(f){var d=t.color||t.colors||[0,0,0,1],g=t.lineWidth||1,m=!1;t:for(e=1;e0){for(var w=0;w<24;++w)i.push(i[i.length-12]);u+=2,m=!0}continue t}h[0][r]=Math.min(h[0][r],b[r],_[r]),h[1][r]=Math.max(h[1][r],b[r],_[r])}Array.isArray(d[0])?(v=d.length>e-1?d[e-1]:d.length>0?d[d.length-1]:[0,0,0,1],y=d.length>e?d[e]:d.length>0?d[d.length-1]:[0,0,0,1]):v=y=d,3===v.length&&(v=[v[0],v[1],v[2],1]),3===y.length&&(y=[y[0],y[1],y[2],1]),!this.hasAlpha&&v[3]<1&&(this.hasAlpha=!0),x=Array.isArray(g)?g.length>e-1?g[e-1]:g.length>0?g[g.length-1]:[0,0,0,1]:g;var A=c;if(c+=p(b,_),m){for(r=0;r<2;++r)i.push(b[0],b[1],b[2],_[0],_[1],_[2],A,x,v[0],v[1],v[2],v[3]);u+=2,m=!1}i.push(b[0],b[1],b[2],_[0],_[1],_[2],A,x,v[0],v[1],v[2],v[3],b[0],b[1],b[2],_[0],_[1],_[2],A,-x,v[0],v[1],v[2],v[3],_[0],_[1],_[2],b[0],b[1],b[2],c,-x,y[0],y[1],y[2],y[3],_[0],_[1],_[2],b[0],b[1],b[2],c,x,y[0],y[1],y[2],y[3]),u+=4}}if(this.buffer.update(i),a.push(c),o.push(f[f.length-1].slice()),this.bounds=h,this.vertexCount=u,this.points=o,this.arcLength=a,"dashes"in t){var C=t.dashes.slice();for(C.unshift(0),e=1;e1.0001)return null;v+=m[h]}return Math.abs(v-1)>.001?null:[f,s(t,m),m]}},{barycentric:75,"polytope-closest-point/lib/closest_point_2d.js":483}],282:[function(t,e,r){var n=t("glslify"),i=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection\n , inverseModel;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n gl_Position = project(position);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * vec4(position , 1.0);\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n f_color = color;\n f_data = position;\n f_uv = uv;\n}\n"]),a=n(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\n//#pragma glslify: beckmann = require(glsl-specular-beckmann) // used in gl-surface3d\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (f_color.a == 0.0 ||\n outOfRange(clipBounds[0], clipBounds[1], f_data)\n ) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n //float specular = max(0.0, beckmann(L, V, N, roughness)); // used in gl-surface3d\n\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = vec4(f_color.rgb, 1.0) * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * f_color.a;\n}\n"]),o=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]),s=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),l=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0.0, 0.0 ,0.0 ,0.0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]),c=n(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5, 0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]),u=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]),h=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]),f=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]),p=n(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]),d=n(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor, 1.0);\n}\n"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:l,fragment:c,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:u,fragment:h,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:h,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:p,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{glslify:411}],283:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("normals"),l=t("gl-mat4/multiply"),c=t("gl-mat4/invert"),u=t("ndarray"),h=t("colormap"),f=t("simplicial-complex-contour"),p=t("typedarray-pool"),d=t("./lib/shaders"),g=t("./lib/closest-point"),m=d.meshShader,v=d.wireShader,y=d.pointShader,x=d.pickShader,b=d.pointPickShader,_=d.contourShader,w=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function A(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g,m,v,y,x,b,_,A,C,M,k,I){this.gl=t,this.pixelRatio=1,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=f,this.triangleUVs=h,this.triangleIds=c,this.triangleVAO=p,this.triangleCount=0,this.lineWidth=1,this.edgePositions=d,this.edgeColors=m,this.edgeUVs=v,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=x,this.pointColors=_,this.pointUVs=A,this.pointSizes=C,this.pointIds=b,this.pointVAO=M,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=k,this.contourVAO=I,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickVertex=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this.hasAlpha=!1,this.opacityscale=!1,this._model=w,this._view=w,this._projection=w,this._resolution=[1,1]}var C=A.prototype;function M(t,e){if(!e)return 1;if(!e.length)return 1;for(var r=0;rt&&r>0){var n=(e[r][0]-t)/(e[r][0]-e[r-1][0]);return e[r][1]*(1-n)+n*e[r-1][1]}}return 1}function k(t){var e=n(t,y.vertex,y.fragment);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function I(t){var e=n(t,x.vertex,x.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e}function T(t){var e=n(t,b.vertex,b.fragment);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function L(t){var e=n(t,_.vertex,_.fragment);return e.attributes.position.location=0,e}C.isOpaque=function(){return!this.hasAlpha},C.isTransparent=function(){return this.hasAlpha},C.pickSlots=1,C.setPickBase=function(t){this.pickId=t},C.highlight=function(t){if(t&&this.contourEnable){for(var e=f(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=p.mallocFloat32(6*a),s=0,l=0;l0&&((h=this.triShader).bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&this.lineWidth>0&&((h=this.lineShader).bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth*this.pixelRatio),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0&&((h=this.pointShader).bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()),this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0&&((h=this.contourShader).bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind())},C.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||w,n=t.view||w,i=t.projection||w,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;o<3;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s,l={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255};(s=this.pickShader).bind(),s.uniforms=l,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth*this.pixelRatio),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0&&((s=this.pointPickShader).bind(),s.uniforms=l,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind())},C.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ai[C]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=m[t],r.uniforms.angle=v[t],a.drawArrays(a.TRIANGLES,i[C],i[M]-i[C]))),y[t]&&A&&(u[1^t]-=k*p*x[t],r.uniforms.dataAxis=h,r.uniforms.screenOffset=u,r.uniforms.color=b[t],r.uniforms.angle=_[t],a.drawArrays(a.TRIANGLES,w,A)),u[1^t]=k*s[2+(1^t)]-1,d[t+2]&&(u[1^t]+=k*p*g[t+2],Ci[C]&&(r.uniforms.dataAxis=c,r.uniforms.screenOffset=u,r.uniforms.color=m[t+2],r.uniforms.angle=v[t+2],a.drawArrays(a.TRIANGLES,i[C],i[M]-i[C]))),y[t+2]&&A&&(u[1^t]+=k*p*x[t+2],r.uniforms.dataAxis=h,r.uniforms.screenOffset=u,r.uniforms.color=b[t+2],r.uniforms.angle=_[t+2],a.drawArrays(a.TRIANGLES,w,A))}),g.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,c=r.pixelRatio;if(this.titleCount){for(var u=0;u<2;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),g.bind=(f=[0,0],p=[0,0],d=[0,0],function(){var t=this.plot,e=this.shader,r=t._tickBounds,n=t.dataBox,i=t.screenBox,a=t.viewBox;e.bind();for(var o=0;o<2;++o){var s=r[o],l=r[o+2]-s,c=.5*(n[o+2]+n[o]),u=n[o+2]-n[o],h=a[o],g=a[o+2]-h,m=i[o],v=i[o+2]-m;p[o]=2*l/u*g/v,f[o]=2*(s-c)/u*g/v}d[1]=2*t.pixelRatio/(i[3]-i[1]),d[0]=d[1]*(i[3]-i[1])/(i[2]-i[0]),e.uniforms.dataScale=p,e.uniforms.dataShift=f,e.uniforms.textScale=d,this.vbo.bind(),e.attributes.textCoordinate.pointer()}),g.update=function(t){var e,r,n,i,o,s=[],l=t.ticks,c=t.bounds;for(o=0;o<2;++o){var u=[Math.floor(s.length/3)],h=[-1/0],f=l[o];for(e=0;e=0){var g=e[d]-n[d]*(e[d+2]-e[d])/(n[d+2]-n[d]);0===d?o.drawLine(g,e[1],g,e[3],p[d],f[d]):o.drawLine(e[0],g,e[2],g,p[d],f[d])}}for(d=0;d=0;--t)this.objects[t].dispose();for(this.objects.length=0,t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},c.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},c.removeObject=function(t){for(var e=this.objects,r=0;rMath.abs(e))c.rotate(a,0,0,-t*r*Math.PI*d.rotateSpeed/window.innerWidth);else if(!d._ortho){var o=-d.zoomSpeed*i*e/window.innerHeight*(a-c.lastT())/20;c.pan(a,0,0,h*(Math.exp(o)-1))}}}),!0)},d.enableMouseListeners(),d};var n=t("right-now"),i=t("3d-view"),a=t("mouse-change"),o=t("mouse-wheel"),s=t("mouse-event-offset"),l=t("has-passive-events")},{"3d-view":54,"has-passive-events":413,"mouse-change":437,"mouse-event-offset":438,"mouse-wheel":440,"right-now":503}],292:[function(t,e,r){var n=t("glslify"),i=t("gl-shader"),a=n(["precision mediump float;\n#define GLSLIFY 1\nattribute vec2 position;\nvarying vec2 uv;\nvoid main() {\n uv = position;\n gl_Position = vec4(position, 0, 1);\n}"]),o=n(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D accumBuffer;\nvarying vec2 uv;\n\nvoid main() {\n vec4 accum = texture2D(accumBuffer, 0.5 * (uv + 1.0));\n gl_FragColor = min(vec4(1,1,1,1), accum);\n}"]);e.exports=function(t){return i(t,a,o,null,[{name:"position",type:"vec2"}])}},{"gl-shader":304,glslify:411}],293:[function(t,e,r){"use strict";var n=t("./camera.js"),i=t("gl-axes3d"),a=t("gl-axes3d/properties"),o=t("gl-spikes3d"),s=t("gl-select-static"),l=t("gl-fbo"),c=t("a-big-triangle"),u=t("mouse-change"),h=t("gl-mat4/perspective"),f=t("gl-mat4/ortho"),p=t("./lib/shader"),d=t("is-mobile")({tablet:!0});function g(){this.mouse=[-1,-1],this.screen=null,this.distance=1/0,this.index=null,this.dataCoordinate=null,this.dataPosition=null,this.object=null,this.data=null}function m(t){var e=Math.round(Math.log(Math.abs(t))/Math.log(10));if(e<0){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}return e>0?(r=Math.round(Math.pow(10,e)),Math.ceil(t/r)*r):Math.ceil(t)}function v(t){return"boolean"!=typeof t||t}e.exports={createScene:function(t){(t=t||{}).camera=t.camera||{};var e=t.canvas;e||(e=document.createElement("canvas"),t.container?t.container.appendChild(e):document.body.appendChild(e));var r=t.gl;if(r||(t.glOptions&&(d=!!t.glOptions.preserveDrawingBuffer),r=function(t,e){var r=null;try{(r=t.getContext("webgl",e))||(r=t.getContext("experimental-webgl",e))}catch(t){return null}return r}(e,t.glOptions||{premultipliedAlpha:!0,antialias:!0,preserveDrawingBuffer:d})),!r)throw new Error("webgl not supported");var y=t.bounds||[[-10,-10,-10],[10,10,10]],x=new g,b=l(r,r.drawingBufferWidth,r.drawingBufferHeight,{preferFloat:!d}),_=p(r),w=t.cameraObject&&!0===t.cameraObject._ortho||t.camera.projection&&"orthographic"===t.camera.projection.type||!1,A={eye:t.camera.eye||[2,0,0],center:t.camera.center||[0,0,0],up:t.camera.up||[0,1,0],zoomMin:t.camera.zoomMax||.1,zoomMax:t.camera.zoomMin||100,mode:t.camera.mode||"turntable",_ortho:w},C=t.axes||{},M=i(r,C);M.enable=!C.disable;var k=t.spikes||{},I=o(r,k),T=[],L=[],S=[],E=[],D=!0,P=!0,O=new Array(16),z=new Array(16),R={view:null,projection:O,model:z,_ortho:!1},F=(P=!0,[r.drawingBufferWidth,r.drawingBufferHeight]),N=t.cameraObject||n(e,A),j={gl:r,contextLost:!1,pixelRatio:t.pixelRatio||1,canvas:e,selection:x,camera:N,axes:M,axesPixels:null,spikes:I,bounds:y,objects:T,shape:F,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:v(t.autoResize),autoBounds:v(t.autoBounds),autoScale:!!t.autoScale,autoCenter:v(t.autoCenter),clipToBounds:v(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:R,oncontextloss:null,mouseListener:null,_stopped:!1,getAspectratio:function(){return{x:this.aspect[0],y:this.aspect[1],z:this.aspect[2]}},setAspectratio:function(t){this.aspect[0]=t.x,this.aspect[1]=t.y,this.aspect[2]=t.z},setBounds:function(t,e){this.bounds[0][t]=e.min,this.bounds[1][t]=e.max},setClearColor:function(t){this.clearColor=t},clearRGBA:function(){this.gl.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}},B=[r.drawingBufferWidth/j.pixelRatio|0,r.drawingBufferHeight/j.pixelRatio|0];function Y(){if(!j._stopped&&j.autoResize){var t=e.parentNode,r=1,n=1;t&&t!==document.body?(r=t.clientWidth,n=t.clientHeight):(r=window.innerWidth,n=window.innerHeight);var i=0|Math.ceil(r*j.pixelRatio),a=0|Math.ceil(n*j.pixelRatio);if(i!==e.width||a!==e.height){e.width=i,e.height=a;var o=e.style;o.position=o.position||"absolute",o.left="0px",o.top="0px",o.width=r+"px",o.height=n+"px",D=!0}}}function V(){for(var t=T.length,e=E.length,n=0;n0&&0===S[e-1];)S.pop(),E.pop().dispose()}function U(){if(j.contextLost)return!0;r.isContextLost()&&(j.contextLost=!0,j.mouseListener.enabled=!1,j.selection.object=null,j.oncontextloss&&j.oncontextloss())}j.autoResize&&Y(),window.addEventListener("resize",Y),j.update=function(t){j._stopped||(t=t||{},D=!0,P=!0)},j.add=function(t){j._stopped||(t.axes=M,T.push(t),L.push(-1),D=!0,P=!0,V())},j.remove=function(t){if(!j._stopped){var e=T.indexOf(t);e<0||(T.splice(e,1),L.pop(),D=!0,P=!0,V())}},j.dispose=function(){if(!j._stopped&&(j._stopped=!0,window.removeEventListener("resize",Y),e.removeEventListener("webglcontextlost",U),j.mouseListener.enabled=!1,!j.contextLost)){M.dispose(),I.dispose();for(var t=0;tx.distance)continue;for(var c=0;c 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]),r.pickVertex=n(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]),r.pickFragment=n(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"])},{glslify:411}],295:[function(t,e,r){"use strict";var n=t("gl-shader"),i=t("gl-buffer"),a=t("typedarray-pool"),o=t("./lib/shader");function s(t,e,r,n,i){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.shader=n,this.pickShader=i,this.sizeMin=.5,this.sizeMinCap=2,this.sizeMax=20,this.areaRatio=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.blend=!1,this.pickOffset=0,this.points=null}e.exports=function(t,e){var r=t.gl,a=i(r),l=i(r),c=n(r,o.pointVertex,o.pointFragment),u=n(r,o.pickVertex,o.pickFragment),h=new s(t,a,l,c,u);return h.update(e),t.addObject(h),h};var l,c,u=s.prototype;u.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.plot.removeObject(this)},u.update=function(t){var e;function r(e,r){return e in t?t[e]:r}t=t||{},this.sizeMin=r("sizeMin",.5),this.sizeMax=r("sizeMax",20),this.color=r("color",[1,0,0,1]).slice(),this.areaRatio=r("areaRatio",1),this.borderColor=r("borderColor",[0,0,0,1]).slice(),this.blend=r("blend",!1);var n=t.positions.length>>>1,i=t.positions instanceof Float32Array,o=t.idToIndex instanceof Int32Array&&t.idToIndex.length>=n,s=t.positions,l=i?s:a.mallocFloat32(s.length),c=o?t.idToIndex:a.mallocInt32(n);if(i||l.set(s),!o)for(l.set(s),e=0;e>>1;for(r=0;r=e[0]&&a<=e[2]&&o>=e[1]&&o<=e[3]&&n++}return n}(this.points,i),u=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(s,.33333)));l[0]=2/a,l[4]=2/o,l[6]=-2*i[0]/a-1,l[7]=-2*i[1]/o-1,this.offsetBuffer.bind(),r.bind(),r.attributes.position.pointer(),r.uniforms.matrix=l,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointCloud=u<5,r.uniforms.pointSize=u,r.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio))),e&&(c[0]=255&t,c[1]=t>>8&255,c[2]=t>>16&255,c[3]=t>>24&255,this.pickBuffer.bind(),r.attributes.pickId.pointer(n.UNSIGNED_BYTE),r.uniforms.pickOffset=c,this.pickOffset=t);var h=n.getParameter(n.BLEND),f=n.getParameter(n.DITHER);return h&&!this.blend&&n.disable(n.BLEND),f&&n.disable(n.DITHER),n.drawArrays(n.POINTS,0,this.pointCount),h&&!this.blend&&n.enable(n.BLEND),f&&n.enable(n.DITHER),t+this.pointCount}),u.draw=u.unifiedDraw,u.drawPick=u.unifiedDraw,u.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":294,"gl-buffer":244,"gl-shader":304,"typedarray-pool":544}],296:[function(t,e,r){e.exports=function(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],h=e[2],f=e[3],p=r[0],d=r[1],g=r[2],m=r[3];return(a=c*p+u*d+h*g+f*m)<0&&(a=-a,p=-p,d=-d,g=-g,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*p,t[1]=s*u+l*d,t[2]=s*h+l*g,t[3]=s*f+l*m,t}},{}],297:[function(t,e,r){"use strict";e.exports=function(t){return t||0===t?t.toString():""}},{}],298:[function(t,e,r){"use strict";var n=t("vectorize-text");e.exports=function(t,e,r){var a=i[e];if(a||(a=i[e]={}),t in a)return a[t];var o={textAlign:"center",textBaseline:"middle",lineHeight:1,font:e,lineSpacing:1.25,styletags:{breaklines:!0,bolds:!0,italics:!0,subscripts:!0,superscripts:!0},triangles:!0},s=n(t,o);o.triangles=!1;var l,c,u=n(t,o);if(r&&1!==r){for(l=0;l max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),o=i(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]),s=i(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]),l=i(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (\n outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate) ||\n interpColor.a * opacity == 0.\n ) discard;\n gl_FragColor = interpColor * opacity;\n}\n"]),c=i(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]),u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],h={vertex:a,fragment:l,attributes:u},f={vertex:o,fragment:l,attributes:u},p={vertex:s,fragment:l,attributes:u},d={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},m={vertex:s,fragment:c,attributes:u};function v(t,e){var r=n(t,e),i=r.attributes;return i.position.location=0,i.color.location=1,i.glyph.location=2,i.id.location=3,r}r.createPerspective=function(t){return v(t,h)},r.createOrtho=function(t){return v(t,f)},r.createProject=function(t){return v(t,p)},r.createPickPerspective=function(t){return v(t,d)},r.createPickOrtho=function(t){return v(t,g)},r.createPickProject=function(t){return v(t,m)}},{"gl-shader":304,glslify:411}],300:[function(t,e,r){"use strict";var n=t("is-string-blank"),i=t("gl-buffer"),a=t("gl-vao"),o=t("typedarray-pool"),s=t("gl-mat4/multiply"),l=t("./lib/shaders"),c=t("./lib/glyphs"),u=t("./lib/get-simple-string"),h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function f(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function p(t,e,r,n){return f(n,n),f(n,n),f(n,n)}function d(t,e){this.index=t,this.dataCoordinate=this.position=e}function g(t){return!0===t?1:t>1?1:t}function m(t,e,r,n,i,a,o,s,l,c,u,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=a,this.glyphBuffer=o,this.idBuffer=s,this.vao=l,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.hasAlpha=!1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.projectHasAlpha=!1,this.pickId=0,this.pickPerspectiveShader=c,this.pickOrthoShader=u,this.pickProjectShader=h,this.points=[],this._selectResult=new d(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.dirty=!0}e.exports=function(t){var e=t.gl,r=l.createPerspective(e),n=l.createOrtho(e),o=l.createProject(e),s=l.createPickPerspective(e),c=l.createPickOrtho(e),u=l.createPickProject(e),h=i(e),f=i(e),p=i(e),d=i(e),g=a(e,[{buffer:h,size:3,type:e.FLOAT},{buffer:f,size:4,type:e.FLOAT},{buffer:p,size:2,type:e.FLOAT},{buffer:d,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new m(e,r,n,o,h,f,p,d,g,s,c,u);return v.update(t),v};var v=m.prototype;v.pickSlots=1,v.setPickBase=function(t){this.pickId=t},v.isTransparent=function(){if(this.hasAlpha)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&this.projectHasAlpha)return!0;return!1},v.isOpaque=function(){if(!this.hasAlpha)return!0;for(var t=0;t<3;++t)if(this.axesProject[t]&&!this.projectHasAlpha)return!0;return!1};var y=[0,0],x=[0,0,0],b=[0,0,0],_=[0,0,0,1],w=[0,0,0,1],A=h.slice(),C=[0,0,0],M=[[0,0,0],[0,0,0]];function k(t){return t[0]=t[1]=t[2]=0,t}function I(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function T(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function L(t,e,r,n){var i,a=e.axesProject,o=e.gl,l=t.uniforms,c=r.model||h,u=r.view||h,f=r.projection||h,d=e.axesBounds,g=function(t){for(var e=M,r=0;r<2;++r)for(var n=0;n<3;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}(e.clipBounds);i=e.axes&&e.axes.lastCubeProps?e.axes.lastCubeProps.axis:[1,1,1],y[0]=2/o.drawingBufferWidth,y[1]=2/o.drawingBufferHeight,t.bind(),l.view=u,l.projection=f,l.screenSize=y,l.highlightId=e.highlightId,l.highlightScale=e.highlightScale,l.clipBounds=g,l.pickGroup=e.pickId/255,l.pixelRatio=n;for(var m=0;m<3;++m)if(a[m]){l.scale=e.projectScale[m],l.opacity=e.projectOpacity[m];for(var v=A,L=0;L<16;++L)v[L]=0;for(L=0;L<4;++L)v[5*L]=1;v[5*m]=0,i[m]<0?v[12+m]=d[0][m]:v[12+m]=d[1][m],s(v,c,v),l.model=v;var S=(m+1)%3,E=(m+2)%3,D=k(x),P=k(b);D[S]=1,P[E]=1;var O=p(0,0,0,I(_,D)),z=p(0,0,0,I(w,P));if(Math.abs(O[1])>Math.abs(z[1])){var R=O;O=z,z=R,R=D,D=P,P=R;var F=S;S=E,E=F}O[0]<0&&(D[S]=-1),z[1]>0&&(P[E]=-1);var N=0,j=0;for(L=0;L<4;++L)N+=Math.pow(c[4*S+L],2),j+=Math.pow(c[4*E+L],2);D[S]/=Math.sqrt(N),P[E]/=Math.sqrt(j),l.axes[0]=D,l.axes[1]=P,l.fragClipBounds[0]=T(C,g[0],m,-1e8),l.fragClipBounds[1]=T(C,g[1],m,1e8),e.vao.bind(),e.vao.draw(o.TRIANGLES,e.vertexCount),e.lineWidth>0&&(o.lineWidth(e.lineWidth*n),e.vao.draw(o.LINES,e.lineVertexCount,e.vertexCount)),e.vao.unbind()}}var S=[[-1e8,-1e8,-1e8],[1e8,1e8,1e8]];function E(t,e,r,n,i,a,o){var s=r.gl;if((a===r.projectHasAlpha||o)&&L(e,r,n,i),a===r.hasAlpha||o){t.bind();var l=t.uniforms;l.model=n.model||h,l.view=n.view||h,l.projection=n.projection||h,y[0]=2/s.drawingBufferWidth,y[1]=2/s.drawingBufferHeight,l.screenSize=y,l.highlightId=r.highlightId,l.highlightScale=r.highlightScale,l.fragClipBounds=S,l.clipBounds=r.axes.bounds,l.opacity=r.opacity,l.pickGroup=r.pickId/255,l.pixelRatio=i,r.vao.bind(),r.vao.draw(s.TRIANGLES,r.vertexCount),r.lineWidth>0&&(s.lineWidth(r.lineWidth*i),r.vao.draw(s.LINES,r.lineVertexCount,r.vertexCount)),r.vao.unbind()}}function D(t,e,r,i){var a;a=Array.isArray(t)?e=this.pointCount||e<0)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;i<3;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},v.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},v.update=function(t){if("perspective"in(t=t||{})&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if(this.projectHasAlpha=!1,"projectOpacity"in t){Array.isArray(t.projectOpacity)?this.projectOpacity=t.projectOpacity.slice():(r=+t.projectOpacity,this.projectOpacity=[r,r,r]);for(var n=0;n<3;++n)this.projectOpacity[n]=g(this.projectOpacity[n]),this.projectOpacity[n]<1&&(this.projectHasAlpha=!0)}this.hasAlpha=!1,"opacity"in t&&(this.opacity=g(t.opacity),this.opacity<1&&(this.hasAlpha=!0)),this.dirty=!0;var i,a,s=t.position,l=t.font||"normal",c=t.alignment||[0,0];if(2===c.length)i=c[0],a=c[1];else for(i=[],a=[],n=0;n0){var P=0,O=x,z=[0,0,0,1],R=[0,0,0,1],F=Array.isArray(p)&&Array.isArray(p[0]),N=Array.isArray(v)&&Array.isArray(v[0]);t:for(n=0;n<_;++n){for(y+=1,w=s[n],A=0;A<3;++A){if(isNaN(w[A])||!isFinite(w[A]))continue t;h[A]=Math.max(h[A],w[A]),u[A]=Math.min(u[A],w[A])}C=(j=D(f,n,l,this.pixelRatio)).mesh,M=j.lines,k=j.bounds;var j,B=j.visible;if(B)if(Array.isArray(p)){if(3===(Y=F?n0?1-k[0][0]:q<0?1+k[1][0]:1,W*=W>0?1-k[0][1]:W<0?1+k[1][1]:1],X=C.cells||[],J=C.positions||[];for(A=0;A0){var v=r*u;o.drawBox(h-v,f-v,p+v,f+v,a),o.drawBox(h-v,d-v,p+v,d+v,a),o.drawBox(h-v,f-v,h+v,d+v,a),o.drawBox(p-v,f-v,p+v,d+v,a)}}}},s.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},s.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":301,"gl-buffer":244,"gl-shader":304}],303:[function(t,e,r){"use strict";e.exports=function(t,e){var r=e[0],a=e[1],o=n(t,r,a,{}),s=i.mallocUint8(r*a*4);return new c(t,o,s)};var n=t("gl-fbo"),i=t("typedarray-pool"),a=t("ndarray"),o=t("bit-twiddle").nextPow2,s=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_16_arg0_<255||_inline_16_arg1_<255||_inline_16_arg2_<255||_inline_16_arg3_<255){var _inline_16_l=_inline_16_arg4_-_inline_16_arg6_[0],_inline_16_a=_inline_16_arg5_-_inline_16_arg6_[1],_inline_16_f=_inline_16_l*_inline_16_l+_inline_16_a*_inline_16_a;_inline_16_fthis.buffer.length){i.free(this.buffer);for(var n=this.buffer=i.mallocUint8(o(r*e*4)),a=0;ar)for(t=r;te)for(t=e;t=0){for(var A=0|w.type.charAt(w.type.length-1),C=new Array(A),M=0;M=0;)k+=1;_[y]=k}var I=new Array(r.length);function T(){f.program=o.program(p,f._vref,f._fref,b,_);for(var t=0;t=0){if((d=f.charCodeAt(f.length-1)-48)<2||d>4)throw new n("","Invalid data type for attribute "+h+": "+f);o(t,e,p[0],i,d,a,h)}else{if(!(f.indexOf("mat")>=0))throw new n("","Unknown data type for attribute "+h+": "+f);var d;if((d=f.charCodeAt(f.length-1)-48)<2||d>4)throw new n("","Invalid data type for attribute "+h+": "+f);s(t,e,p,i,d,a,h)}}}return a};var n=t("./GLError");function i(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}var a=i.prototype;function o(t,e,r,n,a,o,s){for(var l=["gl","v"],c=[],u=0;u4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+a+"fv(locations["+e+"],false,obj"+t+")"}throw new i("","Unknown uniform data type for "+name+": "+r)}if((a=r.charCodeAt(r.length-1)-48)<2||a>4)throw new i("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+a+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+a+"fv(locations["+e+"],obj"+t+")";default:throw new i("","Unrecognized data type for vector "+name+": "+r)}}}function c(e){for(var n=["return function updateProperty(obj){"],i=function t(e,r){if("object"!=typeof r)return[[e,r]];var n=[];for(var i in r){var a=r[i],o=e;parseInt(i)+""===i?o+="["+i+"]":o+="."+i,"object"==typeof a?n.push.apply(n,t(o,a)):n.push([o,a])}return n}("",e),a=0;a4)throw new i("","Invalid data type");return"b"===t.charAt(0)?o(r,!1):o(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r;if((r=t.charCodeAt(t.length-1)-48)<2||r>4)throw new i("","Invalid uniform dimension type for matrix "+name+": "+t);return o(r*r,0)}throw new i("","Unknown uniform data type for "+name+": "+t)}}(r[u].type);var p}function h(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){s[0]in a||(a[s[0]]=[]),a=a[s[0]];for(var l=1;l1)for(var l=0;l 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\n\nuniform float vectorScale, tubeScale;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 eyePosition, lightPosition;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * tubePosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n // vec4 m_position = model * vec4(tubePosition, 1.0);\n vec4 t_position = view * tubePosition;\n gl_Position = projection * t_position;\n\n f_color = color;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_uv = uv;\n}\n"]),a=n(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]),o=n(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]),s=n(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);r.meshShader={vertex:i,fragment:a,attributes:[{name:"position",type:"vec4"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"vector",type:"vec4"}]},r.pickShader={vertex:o,fragment:s,attributes:[{name:"position",type:"vec4"},{name:"id",type:"vec4"},{name:"vector",type:"vec4"}]}},{glslify:411}],315:[function(t,e,r){"use strict";var n=t("gl-vec3"),i=t("gl-vec4"),a=["xyz","xzy","yxz","yzx","zxy","zyx"],o=function(t,e,r,a){for(var o=0,s=0;s0)for(A=0;A<8;A++){var C=(A+1)%8;c.push(f[A],p[A],p[C],p[C],f[C],f[A]),h.push(y,v,v,v,y,y),d.push(g,m,m,m,g,g);var M=c.length;u.push([M-6,M-5,M-4],[M-3,M-2,M-1])}var k=f;f=p,p=k;var I=y;y=v,v=I;var T=g;g=m,m=T}return{positions:c,cells:u,vectors:h,vertexIntensity:d}}(t,r,a,o)})),h=[],f=[],p=[],d=[];for(s=0;se)return r-1}return r},l=function(t,e,r){return tr?r:t},c=function(t){var e=1/0;t.sort((function(t,e){return t-e}));for(var r=t.length,n=1;nh-1||y>f-1||x>p-1)return n.create();var b,_,w,A,C,M,k=a[0][d],I=a[0][v],T=a[1][g],L=a[1][y],S=a[2][m],E=(o-k)/(I-k),D=(c-T)/(L-T),P=(u-S)/(a[2][x]-S);switch(isFinite(E)||(E=.5),isFinite(D)||(D=.5),isFinite(P)||(P=.5),r.reversedX&&(d=h-1-d,v=h-1-v),r.reversedY&&(g=f-1-g,y=f-1-y),r.reversedZ&&(m=p-1-m,x=p-1-x),r.filled){case 5:C=m,M=x,w=g*p,A=y*p,b=d*p*f,_=v*p*f;break;case 4:C=m,M=x,b=d*p,_=v*p,w=g*p*h,A=y*p*h;break;case 3:w=g,A=y,C=m*f,M=x*f,b=d*f*p,_=v*f*p;break;case 2:w=g,A=y,b=d*f,_=v*f,C=m*f*h,M=x*f*h;break;case 1:b=d,_=v,C=m*h,M=x*h,w=g*h*p,A=y*h*p;break;default:b=d,_=v,w=g*h,A=y*h,C=m*h*f,M=x*h*f}var O=i[b+w+C],z=i[b+w+M],R=i[b+A+C],F=i[b+A+M],N=i[_+w+C],j=i[_+w+M],B=i[_+A+C],Y=i[_+A+M],V=n.create(),U=n.create(),H=n.create(),G=n.create();n.lerp(V,O,N,E),n.lerp(U,z,j,E),n.lerp(H,R,B,E),n.lerp(G,F,Y,E);var q=n.create(),W=n.create();n.lerp(q,V,H,D),n.lerp(W,U,G,D);var Z=n.create();return n.lerp(Z,q,W,P),Z}(e,t,p)},g=t.getDivergence||function(t,e){var r=n.create(),i=1e-4;n.add(r,t,[i,0,0]);var a=d(r);n.subtract(a,a,e),n.scale(a,a,1e4),n.add(r,t,[0,i,0]);var o=d(r);n.subtract(o,o,e),n.scale(o,o,1e4),n.add(r,t,[0,0,i]);var s=d(r);return n.subtract(s,s,e),n.scale(s,s,1e4),n.add(r,a,o),n.add(r,r,s),r},m=[],v=e[0][0],y=e[0][1],x=e[0][2],b=e[1][0],_=e[1][1],w=e[1][2],A=function(t){var e=t[0],r=t[1],n=t[2];return!(eb||r_||nw)},C=10*n.distance(e[0],e[1])/i,M=C*C,k=1,I=0,T=r.length;T>1&&(k=function(t){for(var e=[],r=[],n=[],i={},a={},o={},s=t.length,l=0;lI&&(I=F),z.push(F),m.push({points:E,velocities:D,divergences:z});for(var N=0;N<100*i&&E.lengthM&&n.scale(j,j,C/Math.sqrt(B)),n.add(j,j,S),P=d(j),n.squaredDistance(O,j)-M>-1e-4*M&&(E.push(j),O=j,D.push(P),R=g(j,P),F=n.length(R),isFinite(F)&&F>I&&(I=F),z.push(F)),S=j}}var Y=o(m,t.colormap,I,k);return h?Y.tubeScale=h:(0===I&&(I=1),Y.tubeScale=.5*u*k/I),Y};var u=t("./lib/shaders"),h=t("gl-cone3d").createMesh;e.exports.createTubeMesh=function(t,e){return h(t,e,{shaders:u,traceType:"streamtube"})}},{"./lib/shaders":314,"gl-cone3d":245,"gl-vec3":348,"gl-vec4":384}],316:[function(t,e,r){var n=t("gl-shader"),i=t("glslify"),a=i(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform vec3 objectOffset;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 localCoordinate = vec3(uv.zw, f.x);\n worldCoordinate = objectOffset + localCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n vec4 clipPosition = projection * view * worldPosition;\n gl_Position = clipPosition;\n kill = f.y;\n value = f.z;\n planeCoordinate = uv.xy;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * worldPosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n lightDirection = lightPosition - cameraCoordinate.xyz;\n eyeDirection = eyePosition - cameraCoordinate.xyz;\n surfaceNormal = normalize((vec4(normal,0) * inverseModel).xyz);\n}\n"]),o=i(["precision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat beckmannSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]),s=i(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]),l=i(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);r.createShader=function(t){var e=n(t,a,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,a,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,s,o,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,s,l,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":304,glslify:411}],317:[function(t,e,r){arguments[4][113][0].apply(r,arguments)},{dup:113}],318:[function(t,e,r){"use strict";e.exports=function(t){var e=t.gl,r=y(e),n=b(e),s=x(e),l=_(e),c=i(e),u=a(e,[{buffer:c,size:4,stride:w,offset:0},{buffer:c,size:3,stride:w,offset:16},{buffer:c,size:3,stride:w,offset:28}]),h=i(e),f=a(e,[{buffer:h,size:4,stride:20,offset:0},{buffer:h,size:1,stride:20,offset:16}]),p=i(e),d=a(e,[{buffer:p,size:2,type:e.FLOAT}]),g=o(e,1,I,e.RGBA,e.UNSIGNED_BYTE);g.minFilter=e.LINEAR,g.magFilter=e.LINEAR;var m=new T(e,[0,0],[[0,0,0],[0,0,0]],r,n,c,u,g,s,l,h,f,p,d,[0,0,0]),v={levels:[[],[],[]]};for(var A in t)v[A]=t[A];return v.colormap=v.colormap||"jet",m.update(v),m};var n=t("bit-twiddle"),i=t("gl-buffer"),a=t("gl-vao"),o=t("gl-texture2d"),s=t("typedarray-pool"),l=t("colormap"),c=t("ndarray-ops"),u=t("ndarray-pack"),h=t("ndarray"),f=t("surface-nets"),p=t("gl-mat4/multiply"),d=t("gl-mat4/invert"),g=t("binary-search-bounds"),m=t("ndarray-gradient"),v=t("./lib/shaders"),y=v.createShader,x=v.createContourShader,b=v.createPickShader,_=v.createPickContourShader,w=40,A=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],C=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],M=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];function k(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}!function(){for(var t=0;t<3;++t){var e=M[t],r=(t+2)%3;e[(t+1)%3+0]=1,e[r+3]=1,e[t+6]=1}}();var I=256;function T(t,e,r,n,i,a,o,l,c,u,f,p,d,g,m){this.gl=t,this.shape=e,this.bounds=r,this.objectOffset=m,this.intensityBounds=[],this._shader=n,this._pickShader=i,this._coordinateBuffer=a,this._vao=o,this._colorMap=l,this._contourShader=c,this._contourPickShader=u,this._contourBuffer=f,this._contourVAO=p,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new k([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=d,this._dynamicVAO=g,this._dynamicOffsets=[0,0,0],this._dynamicCounts=[0,0,0],this.contourWidth=[1,1,1],this.contourLevels=[[1],[1],[1]],this.contourTint=[0,0,0],this.contourColor=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],this.dynamicLevel=[NaN,NaN,NaN],this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.dynamicTint=[1,1,1],this.dynamicWidth=[1,1,1],this.axesBounds=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[h(s.mallocFloat(1024),[0,0]),h(s.mallocFloat(1024),[0,0]),h(s.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-1/0,-1/0,-1/0],[1/0,1/0,1/0]],this.snapToData=!1,this.pixelRatio=1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.vertexColor=0,this.dirty=!0}var L=T.prototype;L.isTransparent=function(){return this.opacity<1},L.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;t<3;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},L.pickSlots=1,L.setPickBase=function(t){this.pickId=t};var S=[0,0,0],E={showSurface:!1,showContour:!1,projections:[A.slice(),A.slice(),A.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function D(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||S,o=e.showSurface,s=e.showContour;for(r=0;r<3;++r)for(o=o||e.surfaceProject[r],n=0;n<3;++n)s=s||e.contourProject[r][n];for(r=0;r<3;++r){var l=E.projections[r];for(n=0;n<16;++n)l[n]=0;for(n=0;n<4;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],p(l,t.model,l);var c=E.clipBounds[r];for(i=0;i<2;++i)for(n=0;n<3;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return E.showSurface=o,E.showContour=s,E}var P={model:A,view:A,projection:A,inverseModel:A.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,objectOffset:[0,0,0],kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0},O=A.slice(),z=[1,0,0,0,1,0,0,0,1];function R(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=P;n.model=t.model||A,n.view=t.view||A,n.projection=t.projection||A,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.objectOffset=this.objectOffset,n.contourColor=this.contourColor[0],n.inverseModel=d(n.inverseModel,n.model);for(var i=0;i<2;++i)for(var a=n.clipBounds[i],o=0;o<3;++o)a[o]=Math.min(Math.max(this.clipBounds[i][o],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=z,n.vertexColor=this.vertexColor;var s=O;for(p(s,n.view,n.model),p(s,n.projection,s),d(s,s),i=0;i<3;++i)n.eyePosition[i]=s[12+i]/s[15];var l=s[15];for(i=0;i<3;++i)l+=this.lightPosition[i]*s[4*i+3];for(i=0;i<3;++i){var c=s[12+i];for(o=0;o<3;++o)c+=s[4*o+i]*this.lightPosition[o];n.lightPosition[i]=c/l}var u=D(n,this);if(u.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;i<3;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=u.projections[i],this._shader.uniforms.clipBounds=u.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(u.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var f=this._contourVAO;for(f.bind(),i=0;i<3;++i)for(h.uniforms.permutation=M[i],r.lineWidth(this.contourWidth[i]*this.pixelRatio),o=0;o>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;u<2;++u)for(var h=u?a:1-a,f=0;f<2;++f)for(var p=i+u,d=s+f,m=h*(f?l:1-l),v=0;v<3;++v)c[v]+=this._field[v].get(p,d)*m;for(var y=this._pickResult.level,x=0;x<3;++x)if(y[x]=g.le(this.contourLevels[x],c[x]),y[x]<0)this.contourLevels[x].length>0&&(y[x]=0);else if(y[x]Math.abs(_-c[x])&&(y[x]+=1)}for(r.index[0]=a<.5?i:i+1,r.index[1]=l<.5?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],v=0;v<3;++v)r.dataCoordinate[v]=this._field[v].get(r.index[0],r.index[1]);return r},L.padField=function(t,e){var r=e.shape.slice(),n=t.shape.slice();c.assign(t.lo(1,1).hi(r[0],r[1]),e),c.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),c.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),c.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),c.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))},L.update=function(t){t=t||{},this.objectOffset=t.objectOffset||this.objectOffset,this.dirty=!0,"contourWidth"in t&&(this.contourWidth=N(t.contourWidth,Number)),"showContour"in t&&(this.showContour=N(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=N(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=B(t.contourColor)),"contourProject"in t&&(this.contourProject=N(t.contourProject,(function(t){return N(t,Boolean)}))),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=B(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=N(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=N(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds),"vertexColor"in t&&(this.vertexColor=t.vertexColor?1:0);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var i=(e.shape[0]+2)*(e.shape[1]+2);i>this._field[2].data.length&&(s.freeFloat(this._field[2].data),this._field[2].data=s.mallocFloat(n.nextPow2(i))),this._field[2]=h(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),this.padField(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;o<2;++o)this._field[2].size>this._field[o].data.length&&(s.freeFloat(this._field[o].data),this._field[o].data=s.mallocFloat(this._field[2].size)),this._field[o]=h(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var p=t.coords;if(!Array.isArray(p)||3!==p.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;o<2;++o){var d=p[o];for(b=0;b<2;++b)if(d.shape[b]!==a[b])throw new Error("gl-surface: coords have incorrect shape");this.padField(this._field[o],d)}}else if(t.ticks){var g=t.ticks;if(!Array.isArray(g)||2!==g.length)throw new Error("gl-surface: invalid ticks");for(o=0;o<2;++o){var v=g[o];if((Array.isArray(v)||v.length)&&(v=h(v)),v.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var y=h(v.data,a);y.stride[o]=v.stride[0],y.stride[1^o]=0,this.padField(this._field[o],y)}}else{for(o=0;o<2;++o){var x=[0,0];x[o]=1,this._field[o]=h(this._field[o].data,[a[0]+2,a[1]+2],x,0)}this._field[0].set(0,0,0);for(var b=0;b0){for(var At=0;At<5;++At)rt.pop();G-=1}continue t}rt.push(st[0],st[1],ut[0],ut[1],st[2]),G+=1}}ot.push(G)}this._contourOffsets[nt]=at,this._contourCounts[nt]=ot}var Ct=s.mallocFloat(rt.length);for(o=0;o halfCharStep + halfCharWidth ||\n\t\t\t\t\tfloor(uv.x) < halfCharStep - halfCharWidth) return;\n\n\t\t\t\tuv += charId * charStep;\n\t\t\t\tuv = uv / atlasSize;\n\n\t\t\t\tvec4 color = fontColor;\n\t\t\t\tvec4 mask = texture2D(atlas, uv);\n\n\t\t\t\tfloat maskY = lightness(mask);\n\t\t\t\t// float colorY = lightness(color);\n\t\t\t\tcolor.a *= maskY;\n\t\t\t\tcolor.a *= opacity;\n\n\t\t\t\t// color.a += .1;\n\n\t\t\t\t// antialiasing, see yiq color space y-channel formula\n\t\t\t\t// color.rgb += (1. - color.rgb) * (1. - mask.rgb);\n\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"});return{regl:t,draw:e,atlas:{}}},A.prototype.update=function(t){var e=this;if("string"==typeof t)t={text:t};else if(!t)return;null!=(t=i(t,{position:"position positions coord coords coordinates",font:"font fontFace fontface typeface cssFont css-font family fontFamily",fontSize:"fontSize fontsize size font-size",text:"text texts chars characters value values symbols",align:"align alignment textAlign textbaseline",baseline:"baseline textBaseline textbaseline",direction:"dir direction textDirection",color:"color colour fill fill-color fillColor textColor textcolor",kerning:"kerning kern",range:"range dataBox",viewport:"vp viewport viewBox viewbox viewPort",opacity:"opacity alpha transparency visible visibility opaque",offset:"offset positionOffset padding shift indent indentation"},!0)).opacity&&(Array.isArray(t.opacity)?this.opacity=t.opacity.map((function(t){return parseFloat(t)})):this.opacity=parseFloat(t.opacity)),null!=t.viewport&&(this.viewport=h(t.viewport),A.normalViewport&&(this.viewport.y=this.canvas.height-this.viewport.y-this.viewport.height),this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null==this.viewport&&(this.viewport={x:0,y:0,width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight},this.viewportArray=[this.viewport.x,this.viewport.y,this.viewport.width,this.viewport.height]),null!=t.kerning&&(this.kerning=t.kerning),null!=t.offset&&("number"==typeof t.offset&&(t.offset=[t.offset,0]),this.positionOffset=y(t.offset)),t.direction&&(this.direction=t.direction),t.range&&(this.range=t.range,this.scale=[1/(t.range[2]-t.range[0]),1/(t.range[3]-t.range[1])],this.translate=[-t.range[0],-t.range[1]]),t.scale&&(this.scale=t.scale),t.translate&&(this.translate=t.translate),this.scale||(this.scale=[1/this.viewport.width,1/this.viewport.height]),this.translate||(this.translate=[0,0]),this.font.length||t.font||(t.font=A.baseFontSize+"px sans-serif");var r,a=!1,o=!1;if(t.font&&(Array.isArray(t.font)?t.font:[t.font]).forEach((function(t,r){if("string"==typeof t)try{t=n.parse(t)}catch(e){t=n.parse(A.baseFontSize+"px "+t)}else t=n.parse(n.stringify(t));var i=n.stringify({size:A.baseFontSize,family:t.family,stretch:_?t.stretch:void 0,variant:t.variant,weight:t.weight,style:t.style}),s=p(t.size),l=Math.round(s[0]*d(s[1]));if(l!==e.fontSize[r]&&(o=!0,e.fontSize[r]=l),!(e.font[r]&&i==e.font[r].baseString||(a=!0,e.font[r]=A.fonts[i],e.font[r]))){var c=t.family.join(", "),u=[t.style];t.style!=t.variant&&u.push(t.variant),t.variant!=t.weight&&u.push(t.weight),_&&t.weight!=t.stretch&&u.push(t.stretch),e.font[r]={baseString:i,family:c,weight:t.weight,stretch:t.stretch,style:t.style,variant:t.variant,width:{},kerning:{},metrics:v(c,{origin:"top",fontSize:A.baseFontSize,fontStyle:u.join(" ")})},A.fonts[i]=e.font[r]}})),(a||o)&&this.font.forEach((function(r,i){var a=n.stringify({size:e.fontSize[i],family:r.family,stretch:_?r.stretch:void 0,variant:r.variant,weight:r.weight,style:r.style});if(e.fontAtlas[i]=e.shader.atlas[a],!e.fontAtlas[i]){var o=r.metrics;e.shader.atlas[a]=e.fontAtlas[i]={fontString:a,step:2*Math.ceil(e.fontSize[i]*o.bottom*.5),em:e.fontSize[i],cols:0,rows:0,height:0,width:0,chars:[],ids:{},texture:e.regl.texture()}}null==t.text&&(t.text=e.text)})),"string"==typeof t.text&&t.position&&t.position.length>2){for(var s=Array(.5*t.position.length),f=0;f2){for(var w=!t.position[0].length,C=u.mallocFloat(2*this.count),M=0,k=0;M1?e.align[r]:e.align[0]:e.align;if("number"==typeof n)return n;switch(n){case"right":case"end":return-t;case"center":case"centre":case"middle":return.5*-t}return 0}))),null==this.baseline&&null==t.baseline&&(t.baseline=0),null!=t.baseline&&(this.baseline=t.baseline,Array.isArray(this.baseline)||(this.baseline=[this.baseline]),this.baselineOffset=this.baseline.map((function(t,r){var n=(e.font[r]||e.font[0]).metrics,i=0;return i+=.5*n.bottom,i+="number"==typeof t?t-n.baseline:-n[t],A.normalViewport||(i*=-1),i}))),null!=t.color)if(t.color||(t.color="transparent"),"string"!=typeof t.color&&isNaN(t.color)){var H;if("number"==typeof t.color[0]&&t.color.length>this.counts.length){var G=t.color.length;H=u.mallocUint8(G);for(var q=(t.color.subarray||t.color.slice).bind(t.color),W=0;W4||this.baselineOffset.length>1||this.align&&this.align.length>1||this.fontAtlas.length>1||this.positionOffset.length>2){var J=Math.max(.5*this.position.length||0,.25*this.color.length||0,this.baselineOffset.length||0,this.alignOffset.length||0,this.font.length||0,this.opacity.length||0,.5*this.positionOffset.length||0);this.batch=Array(J);for(var K=0;K1?this.counts[K]:this.counts[0],offset:this.textOffsets.length>1?this.textOffsets[K]:this.textOffsets[0],color:this.color?this.color.length<=4?this.color:this.color.subarray(4*K,4*K+4):[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[K]:this.opacity,baseline:null!=this.baselineOffset[K]?this.baselineOffset[K]:this.baselineOffset[0],align:this.align?null!=this.alignOffset[K]?this.alignOffset[K]:this.alignOffset[0]:0,atlas:this.fontAtlas[K]||this.fontAtlas[0],positionOffset:this.positionOffset.length>2?this.positionOffset.subarray(2*K,2*K+2):this.positionOffset}}else this.count?this.batch=[{count:this.count,offset:0,color:this.color||[0,0,0,255],opacity:Array.isArray(this.opacity)?this.opacity[0]:this.opacity,baseline:this.baselineOffset[0],align:this.alignOffset?this.alignOffset[0]:0,atlas:this.fontAtlas[0],positionOffset:this.positionOffset}]:this.batch=[]},A.prototype.destroy=function(){},A.prototype.kerning=!0,A.prototype.position={constant:new Float32Array(2)},A.prototype.translate=null,A.prototype.scale=null,A.prototype.font=null,A.prototype.text="",A.prototype.positionOffset=[0,0],A.prototype.opacity=1,A.prototype.color=new Uint8Array([0,0,0,255]),A.prototype.alignOffset=[0,0],A.normalViewport=!1,A.maxAtlasSize=1024,A.atlasCanvas=document.createElement("canvas"),A.atlasContext=A.atlasCanvas.getContext("2d",{alpha:!1}),A.baseFontSize=64,A.fonts={},e.exports=A},{"bit-twiddle":94,"color-normalize":122,"css-font":141,"detect-kerning":168,"es6-weak-map":320,"flatten-vertex-data":230,"font-atlas":231,"font-measure":232,"gl-util/context":325,"is-plain-obj":424,"object-assign":456,"parse-rect":461,"parse-unit":463,"pick-by-alias":467,regl:501,"to-px":538,"typedarray-pool":544}],320:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?WeakMap:t("./polyfill")},{"./is-implemented":321,"./polyfill":323}],321:[function(t,e,r){"use strict";e.exports=function(){var t,e;if("function"!=typeof WeakMap)return!1;try{t=new WeakMap([[e={},"one"],[{},"two"],[{},"three"]])}catch(t){return!1}return"[object WeakMap]"===String(t)&&"function"==typeof t.set&&t.set({},1)===t&&"function"==typeof t.delete&&"function"==typeof t.has&&"one"===t.get(e)}},{}],322:[function(t,e,r){"use strict";e.exports="function"==typeof WeakMap&&"[object WeakMap]"===Object.prototype.toString.call(new WeakMap)},{}],323:[function(t,e,r){"use strict";var n,i=t("es5-ext/object/is-value"),a=t("es5-ext/object/set-prototype-of"),o=t("es5-ext/object/valid-object"),s=t("es5-ext/object/valid-value"),l=t("es5-ext/string/random-uniq"),c=t("d"),u=t("es6-iterator/get"),h=t("es6-iterator/for-of"),f=t("es6-symbol").toStringTag,p=t("./is-native-implemented"),d=Array.isArray,g=Object.defineProperty,m=Object.prototype.hasOwnProperty,v=Object.getPrototypeOf;e.exports=n=function(){var t,e=arguments[0];if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");return t=p&&a&&WeakMap!==n?a(new WeakMap,v(this)):this,i(e)&&(d(e)||(e=u(e))),g(t,"__weakMapData__",c("c","$weakMap$"+l())),e?(h(e,(function(e){s(e),t.set(e[0],e[1])})),t):t},p&&(a&&a(n,WeakMap),n.prototype=Object.create(WeakMap.prototype,{constructor:c(n)})),Object.defineProperties(n.prototype,{delete:c((function(t){return!!m.call(o(t),this.__weakMapData__)&&(delete t[this.__weakMapData__],!0)})),get:c((function(t){if(m.call(o(t),this.__weakMapData__))return t[this.__weakMapData__]})),has:c((function(t){return m.call(o(t),this.__weakMapData__)})),set:c((function(t,e){return g(o(t),this.__weakMapData__,c("c",e)),this})),toString:c((function(){return"[object WeakMap]"}))}),g(n.prototype,f,c("c","WeakMap"))},{"./is-native-implemented":322,d:153,"es5-ext/object/is-value":197,"es5-ext/object/set-prototype-of":203,"es5-ext/object/valid-object":207,"es5-ext/object/valid-value":208,"es5-ext/string/random-uniq":213,"es6-iterator/for-of":215,"es6-iterator/get":216,"es6-symbol":222}],324:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("ndarray-ops"),a=t("typedarray-pool");e.exports=function(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(o||function(t){o=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],s=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],l=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}(t),"number"==typeof arguments[1])return m(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return m(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1],r=c(e)?e:e.raw;if(r)return function(t,e,r,n,i,a){var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,i,i,a,e),new f(t,o,r,n,i,a)}(t,r,0|e.width,0|e.height,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return function(t,e){var r=e.dtype,o=e.shape.slice(),s=t.getParameter(t.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>s||o[1]<0||o[1]>s)throw new Error("gl-texture2d: Invalid texture size");var l=d(o,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,l=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,l=!1,r="uint8");var h,p,m=0;if(2===o.length)m=t.LUMINANCE,o=[o[0],o[1],1],e=n(e.data,o,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])m=t.ALPHA;else if(2===o[2])m=t.LUMINANCE_ALPHA;else if(3===o[2])m=t.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");m=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,l=!1);var v=e.size;if(l)h=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var y=[o[2],o[2]*o[0],1];p=a.malloc(v,r);var x=n(p,o,y,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?i.assign(x,e):u(x,e),h=p.subarray(0,v)}var b=g(t);return t.texImage2D(t.TEXTURE_2D,0,m,o[0],o[1],0,m,c,h),l||a.free(p),new f(t,b,o[0],o[1],m,c)}(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")};var o=null,s=null,l=null;function c(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageData&&t instanceof ImageData}var u=function(t,e){i.muls(t,e,255)};function h(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(e<0||e>i||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function f(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}var p=f.prototype;function d(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function g(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function m(t,e,r,n,i){var a=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>a||r<0||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=g(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new f(t,o,e,r,n,i)}Object.defineProperties(p,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&o.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),s.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),l.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(l.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return h(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return h(this,t|=0,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t|=0,h(this,this._shape[0],t),t}}}),p.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},p.dispose=function(){this.gl.deleteTexture(this.handle)},p.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},p.setPixels=function(t,e,r,o){var s=this.gl;this.bind(),Array.isArray(e)?(o=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),o=o||0;var l=c(t)?t:t.raw;if(l)this._mipLevels.indexOf(o)<0?(s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,this.type,l),this._mipLevels.push(o)):s.texSubImage2D(s.TEXTURE_2D,o,e,r,this.format,this.type,l);else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>o||r+t.shape[0]>this._shape[0]>>>o||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");!function(t,e,r,o,s,l,c,h){var f=h.dtype,p=h.shape.slice();if(p.length<2||p.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var g=0,m=0,v=d(p,h.stride.slice());if("float32"===f?g=t.FLOAT:"float64"===f?(g=t.FLOAT,v=!1,f="float32"):"uint8"===f?g=t.UNSIGNED_BYTE:(g=t.UNSIGNED_BYTE,v=!1,f="uint8"),2===p.length)m=t.LUMINANCE,p=[p[0],p[1],1],h=n(h.data,p,[h.stride[0],h.stride[1],1],h.offset);else{if(3!==p.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===p[2])m=t.ALPHA;else if(2===p[2])m=t.LUMINANCE_ALPHA;else if(3===p[2])m=t.RGB;else{if(4!==p[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");m=t.RGBA}p[2]}if(m!==t.LUMINANCE&&m!==t.ALPHA||s!==t.LUMINANCE&&s!==t.ALPHA||(m=s),m!==s)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=h.size,x=c.indexOf(o)<0;if(x&&c.push(o),g===l&&v)0===h.offset&&h.data.length===y?x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,h.data):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,h.data):x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,h.data.subarray(h.offset,h.offset+y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,h.data.subarray(h.offset,h.offset+y));else{var b;b=l===t.FLOAT?a.mallocFloat32(y):a.mallocUint8(y);var _=n(b,p,[p[2],p[2]*p[0],1]);g===t.FLOAT&&l===t.UNSIGNED_BYTE?u(_,h):i.assign(_,h),x?t.texImage2D(t.TEXTURE_2D,o,s,p[0],p[1],0,s,l,b.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,o,e,r,p[0],p[1],s,l,b.subarray(0,y)),l===t.FLOAT?a.freeFloat32(b):a.freeUint8(b)}}(s,e,r,o,this.format,this.type,this._mipLevels,t)}}},{ndarray:452,"ndarray-ops":446,"typedarray-pool":544}],325:[function(t,r,n){(function(e){"use strict";var n=t("pick-by-alias");function i(t){if(t.container)if(t.container==document.body)document.body.style.width||(t.canvas.width=t.width||t.pixelRatio*e.innerWidth),document.body.style.height||(t.canvas.height=t.height||t.pixelRatio*e.innerHeight);else{var r=t.container.getBoundingClientRect();t.canvas.width=t.width||r.right-r.left,t.canvas.height=t.height||r.bottom-r.top}}function a(t){return"function"==typeof t.getContext&&"width"in t&&"height"in t}function o(){var t=document.createElement("canvas");return t.style.position="absolute",t.style.top=0,t.style.left=0,t}r.exports=function(t){var r;if(t?"string"==typeof t&&(t={container:t}):t={},(t=a(t)?{container:t}:"string"==typeof(r=t).nodeName&&"function"==typeof r.appendChild&&"function"==typeof r.getBoundingClientRect?{container:t}:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(t)?{gl:t}:n(t,{container:"container target element el canvas holder parent parentNode wrapper use ref root node",gl:"gl context webgl glContext",attrs:"attributes attrs contextAttributes",pixelRatio:"pixelRatio pxRatio px ratio pxratio pixelratio",width:"w width",height:"h height"},!0)).pixelRatio||(t.pixelRatio=e.pixelRatio||1),t.gl)return t.gl;if(t.canvas&&(t.container=t.canvas.parentNode),t.container){if("string"==typeof t.container){var s=document.querySelector(t.container);if(!s)throw Error("Element "+t.container+" is not found");t.container=s}a(t.container)?(t.canvas=t.container,t.container=t.canvas.parentNode):t.canvas||(t.canvas=o(),t.container.appendChild(t.canvas),i(t))}else if(!t.canvas){if("undefined"==typeof document)throw Error("Not DOM environment. Use headless-gl.");t.container=document.body||document.documentElement,t.canvas=o(),t.container.appendChild(t.canvas),i(t)}if(!t.gl)try{t.gl=t.canvas.getContext("webgl",t.attrs)}catch(r){try{t.gl=t.canvas.getContext("experimental-webgl",t.attrs)}catch(r){t.gl=t.canvas.getContext("webgl-experimental",t.attrs)}}return t.gl}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"pick-by-alias":467}],326:[function(t,e,r){"use strict";e.exports=function(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;i1?0:Math.acos(s)};var n=t("./fromValues"),i=t("./normalize"),a=t("./dot")},{"./dot":341,"./fromValues":347,"./normalize":358}],332:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},{}],333:[function(t,e,r){e.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},{}],334:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},{}],335:[function(t,e,r){e.exports=function(){var t=new Float32Array(3);return t[0]=0,t[1]=0,t[2]=0,t}},{}],336:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}},{}],337:[function(t,e,r){e.exports=t("./distance")},{"./distance":338}],338:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},{}],339:[function(t,e,r){e.exports=t("./divide")},{"./divide":340}],340:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}},{}],341:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},{}],342:[function(t,e,r){e.exports=1e-6},{}],343:[function(t,e,r){e.exports=function(t,e){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1],l=e[2];return Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-l)<=n*Math.max(1,Math.abs(a),Math.abs(l))};var n=t("./epsilon")},{"./epsilon":342}],344:[function(t,e,r){e.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},{}],345:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},{}],346:[function(t,e,r){e.exports=function(t,e,r,i,a,o){var s,l;for(e||(e=3),r||(r=0),l=i?Math.min(i*e+r,t.length):t.length,s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}},{}],359:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},{}],360:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[1],a=r[2],o=e[1]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=e[0],t[1]=i+o*c-s*l,t[2]=a+o*l+s*c,t}},{}],361:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[2],o=e[0]-i,s=e[2]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+s*l+o*c,t[1]=e[1],t[2]=a+s*c-o*l,t}},{}],362:[function(t,e,r){e.exports=function(t,e,r,n){var i=r[0],a=r[1],o=e[0]-i,s=e[1]-a,l=Math.sin(n),c=Math.cos(n);return t[0]=i+o*c-s*l,t[1]=a+o*l+s*c,t[2]=e[2],t}},{}],363:[function(t,e,r){e.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},{}],364:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}},{}],365:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}},{}],366:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},{}],367:[function(t,e,r){e.exports=t("./squaredDistance")},{"./squaredDistance":369}],368:[function(t,e,r){e.exports=t("./squaredLength")},{"./squaredLength":370}],369:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},{}],370:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},{}],371:[function(t,e,r){e.exports=t("./subtract")},{"./subtract":372}],372:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}},{}],373:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t}},{}],374:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t}},{}],375:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,h=c*i+l*n-o*a,f=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+h*-l-f*-s,t[1]=h*c+p*-s+f*-o-u*-l,t[2]=f*c+p*-l+u*-s-h*-o,t}},{}],376:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}},{}],377:[function(t,e,r){e.exports=function(t){var e=new Float32Array(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}},{}],378:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}},{}],379:[function(t,e,r){e.exports=function(){var t=new Float32Array(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}},{}],380:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)}},{}],381:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}},{}],382:[function(t,e,r){e.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}},{}],383:[function(t,e,r){e.exports=function(t,e,r,n){var i=new Float32Array(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}},{}],384:[function(t,e,r){e.exports={create:t("./create"),clone:t("./clone"),fromValues:t("./fromValues"),copy:t("./copy"),set:t("./set"),add:t("./add"),subtract:t("./subtract"),multiply:t("./multiply"),divide:t("./divide"),min:t("./min"),max:t("./max"),scale:t("./scale"),scaleAndAdd:t("./scaleAndAdd"),distance:t("./distance"),squaredDistance:t("./squaredDistance"),length:t("./length"),squaredLength:t("./squaredLength"),negate:t("./negate"),inverse:t("./inverse"),normalize:t("./normalize"),dot:t("./dot"),lerp:t("./lerp"),random:t("./random"),transformMat4:t("./transformMat4"),transformQuat:t("./transformQuat")}},{"./add":376,"./clone":377,"./copy":378,"./create":379,"./distance":380,"./divide":381,"./dot":382,"./fromValues":383,"./inverse":385,"./length":386,"./lerp":387,"./max":388,"./min":389,"./multiply":390,"./negate":391,"./normalize":392,"./random":393,"./scale":394,"./scaleAndAdd":395,"./set":396,"./squaredDistance":397,"./squaredLength":398,"./subtract":399,"./transformMat4":400,"./transformQuat":401}],385:[function(t,e,r){e.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}},{}],386:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}},{}],387:[function(t,e,r){e.exports=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t}},{}],388:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}},{}],389:[function(t,e,r){e.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}},{}],390:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}},{}],391:[function(t,e,r){e.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}},{}],392:[function(t,e,r){e.exports=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=a*o),t}},{}],393:[function(t,e,r){var n=t("./normalize"),i=t("./scale");e.exports=function(t,e){return e=e||1,t[0]=Math.random(),t[1]=Math.random(),t[2]=Math.random(),t[3]=Math.random(),n(t,t),i(t,t,e),t}},{"./normalize":392,"./scale":394}],394:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}},{}],395:[function(t,e,r){e.exports=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}},{}],396:[function(t,e,r){e.exports=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}},{}],397:[function(t,e,r){e.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}},{}],398:[function(t,e,r){e.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}},{}],399:[function(t,e,r){e.exports=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}},{}],400:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}},{}],401:[function(t,e,r){e.exports=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2],c=r[3],u=c*n+s*a-l*i,h=c*i+l*n-o*a,f=c*a+o*i-s*n,p=-o*n-s*i-l*a;return t[0]=u*c+p*-o+h*-l-f*-s,t[1]=h*c+p*-s+f*-o-u*-l,t[2]=f*c+p*-l+u*-s-h*-o,t[3]=e[3],t}},{}],402:[function(t,e,r){e.exports=function(t,e,r,a){return n[0]=a,n[1]=r,n[2]=e,n[3]=t,i[0]};var n=new Uint8Array(4),i=new Float32Array(n.buffer)},{}],403:[function(t,e,r){var n=t("glsl-tokenizer"),i=t("atob-lite");e.exports=function(t){for(var e=Array.isArray(t)?t:n(t),r=0;r0)continue;r=t.slice(0,1).join("")}return F(r),E+=r.length,(I=I.slice(r.length)).length}}function H(){return/[^a-fA-F0-9]/.test(e)?(F(I.join("")),k=l,C):(I.push(e),r=e,C+1)}function G(){return"."===e?(I.push(e),k=g,r=e,C+1):/[eE]/.test(e)?(I.push(e),k=g,r=e,C+1):"x"===e&&1===I.length&&"0"===I[0]?(k=_,I.push(e),r=e,C+1):/[^\d]/.test(e)?(F(I.join("")),k=l,C):(I.push(e),r=e,C+1)}function q(){return"f"===e&&(I.push(e),r=e,C+=1),/[eE]/.test(e)?(I.push(e),r=e,C+1):"-"===e&&/[eE]/.test(r)?(I.push(e),r=e,C+1):/[^\d]/.test(e)?(F(I.join("")),k=l,C):(I.push(e),r=e,C+1)}function W(){if(/[^\d\w_]/.test(e)){var t=I.join("");return k=R.indexOf(t)>-1?y:z.indexOf(t)>-1?v:m,F(I.join("")),k=l,C}return I.push(e),r=e,C+1}};var n=t("./lib/literals"),i=t("./lib/operators"),a=t("./lib/builtins"),o=t("./lib/literals-300es"),s=t("./lib/builtins-300es"),l=999,c=9999,u=0,h=1,f=2,p=3,d=4,g=5,m=6,v=7,y=8,x=9,b=10,_=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":406,"./lib/builtins-300es":405,"./lib/literals":408,"./lib/literals-300es":407,"./lib/operators":409}],405:[function(t,e,r){var n=t("./builtins");n=n.slice().filter((function(t){return!/^(gl\_|texture)/.test(t)})),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":406}],406:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],407:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":408}],408:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],409:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],410:[function(t,e,r){var n=t("./index");e.exports=function(t,e){var r=n(e),i=[];return i=(i=i.concat(r(t))).concat(r(null))}},{"./index":404}],411:[function(t,e,r){e.exports=function(t){"string"==typeof t&&(t=[t]);for(var e=[].slice.call(arguments,1),r=[],n=0;n>1,u=-7,h=r?i-1:0,f=r?-1:1,p=t[e+h];for(h+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+h],h+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+h],h+=f,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g}},{}],415:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(r<=i)throw new Error("Must input at least d+1 points");var o=t.slice(0,i+1),s=n.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;u<=i;++u)l[u]=u;s<0&&(l[0]=1,l[1]=0);var h=new a(l,new Array(i+1),!1),f=h.adjacent,p=new Array(i+2);for(u=0;u<=i;++u){for(var d=l.slice(),g=0;g<=i;++g)g===u&&(d[g]=-1);var m=d[0];d[0]=d[1],d[1]=m;var v=new a(d,new Array(i+1),!0);f[u]=v,p[u]=v}for(p[i+1]=h,u=0;u<=i;++u){d=f[u].vertices;var y=f[u].adjacent;for(g=0;g<=i;++g){var x=d[g];if(x<0)y[g]=h;else for(var b=0;b<=i;++b)f[b].vertices.indexOf(x)<0&&(y[g]=f[b])}}var _=new c(i,o,p),w=!!e;for(u=i+1;u0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var i=new Function("test",e.join("")),a=n[t+1];return a||(a=n),i(a)}(t)),this.orient=a}var u=c.prototype;u.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){(t=o.pop()).vertices;for(var s=t.adjacent,l=0;l<=r;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,h=0;h<=r;++h){var f=u[h];i[h]=f<0?e:a[f]}var p=this.orient();if(p>0)return c;c.lastVisited=-n,0===p&&o.push(c)}}}return null},u.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;u<=n;++u)a[u]=i[l[u]];for(s.lastVisited=r,u=0;u<=n;++u){var h=c[u];if(!(h.lastVisited>=r)){var f=a[u];a[u]=t;var p=this.orient();if(a[u]=f,p<0){s=h;continue t}h.boundary?h.lastVisited=-r:h.lastVisited=r}}return}return s},u.addPeaks=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,h=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var f=[];h.length>0;){var p=(e=h.pop()).vertices,d=e.adjacent,g=p.indexOf(r);if(!(g<0))for(var m=0;m<=n;++m)if(m!==g){var v=d[m];if(v.boundary&&!(v.lastVisited>=r)){var y=v.vertices;if(v.lastVisited!==-r){for(var x=0,b=0;b<=n;++b)y[b]<0?(x=b,l[b]=t):l[b]=i[y[b]];if(this.orient()>0){y[x]=r,v.boundary=!1,c.push(v),h.push(v),v.lastVisited=r;continue}v.lastVisited=-r}var _=v.adjacent,w=p.slice(),A=d.slice(),C=new a(w,A,!0);u.push(C);var M=_.indexOf(e);if(!(M<0))for(_[M]=C,A[g]=v,w[m]=-1,A[m]=e,d[m]=C,C.flip(),b=0;b<=n;++b){var k=w[b];if(!(k<0||k===r)){for(var I=new Array(n-1),T=0,L=0;L<=n;++L){var S=w[L];S<0||L===b||(I[T++]=S)}f.push(new o(I,C,b))}}}}}for(f.sort(s),m=0;m+1=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var h=o[0];o[0]=o[1],o[1]=h}e.push(o)}}return e}},{"robust-orientation":509,"simplicial-complex":519}],416:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=0,a=1;function o(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}e.exports=function(t){return t&&0!==t.length?new x(y(t)):new x(null)};var s=o.prototype;function l(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function c(t,e){var r=y(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function u(t,e){var r=t.intervals([]);r.push(e),c(t,r)}function h(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?i:(r.splice(n,1),c(t,r),a)}function f(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function d(t,e){for(var r=0;r>1],i=[],a=[],s=[];for(r=0;r3*(e+1)?u(this,t):this.left.insert(t):this.left=y([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?u(this,t):this.right.insert(t):this.right=y([t]);else{var r=n.ge(this.leftPoints,t,m),i=n.ge(this.rightPoints,t,v);this.leftPoints.splice(r,0,t),this.rightPoints.splice(i,0,t)}},s.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?h(this,t):2===(c=this.left.remove(t))?(this.left=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?h(this,t):2===(c=this.right.remove(t))?(this.right=null,this.count-=1,a):(c===a&&(this.count-=1),c):i;if(1===this.count)return this.leftPoints[0]===t?2:i;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var r=this,o=this.left;o.right;)r=o,o=o.right;if(r===this)o.right=this.right;else{var s=this.left,c=this.right;r.count-=o.count,r.right=o.left,o.left=s,o.right=c}l(this,o),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?l(this,this.left):l(this,this.right);return a}for(s=n.ge(this.leftPoints,t,m);sthis.mid?this.right&&(r=this.right.queryPoint(t,e))?r:p(this.rightPoints,t,e):d(this.leftPoints,e);var r},s.queryInterval=function(t,e,r){var n;return tthis.mid&&this.right&&(n=this.right.queryInterval(t,e,r))?n:ethis.mid?p(this.rightPoints,t,r):d(this.leftPoints,r)};var b=x.prototype;b.insert=function(t){this.root?this.root.insert(t):this.root=new o(t[0],null,null,[t],[t])},b.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),e!==i}return!1},b.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},b.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(b,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(b,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":93}],417:[function(t,e,r){"use strict";e.exports=function(t,e){e=e||new Array(t.length);for(var r=0;r - * @license MIT - */ -e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],421:[function(t,e,r){"use strict";e.exports="undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion))},{}],422:[function(t,e,r){"use strict";e.exports=a,e.exports.isMobile=a,e.exports.default=a;var n=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,i=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function a(t){t||(t={});var e=t.ua;return e||"undefined"==typeof navigator||(e=navigator.userAgent),e&&e.headers&&"string"==typeof e.headers["user-agent"]&&(e=e.headers["user-agent"]),"string"==typeof e&&(t.tablet?i.test(e):n.test(e))}},{}],423:[function(t,e,r){"use strict";e.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}},{}],424:[function(t,e,r){"use strict";var n=Object.prototype.toString;e.exports=function(t){var e;return"[object Object]"===n.call(t)&&(null===(e=Object.getPrototypeOf(t))||e===Object.getPrototypeOf({}))}},{}],425:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=0;n13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}},{}],426:[function(t,e,r){"use strict";e.exports=function(t){return"string"==typeof t&&(t=t.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(t)&&/[\dz]$/i.test(t)&&t.length>4))}},{}],427:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],428:[function(t,e,r){!function(t,n){"object"==typeof r&&void 0!==e?e.exports=n():(t=t||self).mapboxgl=n()}(this,(function(){"use strict";var t,e,r;function n(n,i){if(t)if(e){var a="var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk);",o={};t(o),(r=i(o)).workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"}))}else e=i;else t=i}return n(0,(function(t){function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r=n;function n(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=r,this.p2y=n}n.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},n.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},n.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},n.prototype.solveCurveX=function(t,e){var r,n,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)(n=1))return n;for(;ra?r=i:n=i,i=.5*(n-r)+r}return i},n.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var i=a;function a(t,e){this.x=t,this.y=e}function o(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0;r0;)e[r]=arguments[r+1];for(var n=0,i=e;n>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function g(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function m(t,e){t.forEach((function(t){e[t]&&(e[t]=e[t].bind(e))}))}function v(t,e){return-1!==t.indexOf(e,t.length-e.length)}function y(t,e,r){var n={};for(var i in t)n[i]=e.call(r||this,t[i],i,t);return n}function x(t,e,r){var n={};for(var i in t)e.call(r||this,t[i],i,t)&&(n[i]=t[i]);return n}function b(t){return Array.isArray(t)?t.map(b):"object"==typeof t&&t?y(t,b):t}var _={};function w(t){_[t]||("undefined"!=typeof console&&console.warn(t),_[t]=!0)}function A(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function C(t){for(var e=0,r=0,n=t.length,i=n-1,a=void 0,o=void 0;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(t,r,n,i){var a=n||i;return e[r]=!a||a.toLowerCase(),""})),e["max-age"]){var r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}function k(t){try{var e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}var I,T,L,S,E=self.performance&&self.performance.now?self.performance.now.bind(self.performance):Date.now.bind(Date),D=self.requestAnimationFrame||self.mozRequestAnimationFrame||self.webkitRequestAnimationFrame||self.msRequestAnimationFrame,P=self.cancelAnimationFrame||self.mozCancelAnimationFrame||self.webkitCancelAnimationFrame||self.msCancelAnimationFrame,O={now:E,frame:function(t){var e=D(t);return{cancel:function(){return P(e)}}},getImageData:function(t){var e=self.document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(0,0,t.width,t.height)},resolveURL:function(t){return I||(I=self.document.createElement("a")),I.href=t,I.href},hardwareConcurrency:self.navigator.hardwareConcurrency||4,get devicePixelRatio(){return self.devicePixelRatio},get prefersReducedMotion(){return!!self.matchMedia&&(null==T&&(T=self.matchMedia("(prefers-reduced-motion: reduce)")),T.matches)}},z={API_URL:"https://api.mapbox.com",get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},FEEDBACK_URL:"https://apps.mapbox.com/feedback",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},R={supported:!1,testSupport:function(t){!F&&S&&(N?j(t):L=t)}},F=!1,N=!1;function j(t){var e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,S),t.isContextLost())return;R.supported=!0}catch(t){}t.deleteTexture(e),F=!0}self.document&&((S=self.document.createElement("img")).onload=function(){L&&j(L),L=null,N=!0},S.onerror=function(){F=!0,L=null},S.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var B="01",Y=function(t,e){this._transformRequestFn=t,this._customAccessToken=e,this._createSkuToken()};function V(t){return 0===t.indexOf("mapbox:")}Y.prototype._createSkuToken=function(){var t=function(){for(var t="",e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",B,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt},Y.prototype._isSkuTokenExpired=function(){return Date.now()>this._skuTokenExpiresAt},Y.prototype.transformRequest=function(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}},Y.prototype.normalizeStyleURL=function(t,e){if(!V(t))return t;var r=q(t);return r.path="/styles/v1"+r.path,this._makeAPIURL(r,this._customAccessToken||e)},Y.prototype.normalizeGlyphsURL=function(t,e){if(!V(t))return t;var r=q(t);return r.path="/fonts/v1"+r.path,this._makeAPIURL(r,this._customAccessToken||e)},Y.prototype.normalizeSourceURL=function(t,e){if(!V(t))return t;var r=q(t);return r.path="/v4/"+r.authority+".json",r.params.push("secure"),this._makeAPIURL(r,this._customAccessToken||e)},Y.prototype.normalizeSpriteURL=function(t,e,r,n){var i=q(t);return V(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+r,this._makeAPIURL(i,this._customAccessToken||n)):(i.path+=""+e+r,W(i))},Y.prototype.normalizeTileURL=function(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),!e||!V(e))return t;var n=q(t),i=O.devicePixelRatio>=2||512===r?"@2x":"",a=R.supported?".webp":"$1";return n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,""+i+a),n.path=n.path.replace(/^.+\/v4\//,"/"),n.path="/v4"+n.path,z.REQUIRE_ACCESS_TOKEN&&(z.ACCESS_TOKEN||this._customAccessToken)&&this._skuToken&&n.params.push("sku="+this._skuToken),this._makeAPIURL(n,this._customAccessToken)},Y.prototype.canonicalizeTileURL=function(t){var e=q(t);if(!e.path.match(/(^\/v4\/)/)||!e.path.match(/\.[\w]+$/))return t;var r="mapbox://tiles/";r+=e.path.replace("/v4/","");var n=e.params.filter((function(t){return!t.match(/^access_token=/)}));return n.length&&(r+="?"+n.join("&")),r},Y.prototype.canonicalizeTileset=function(t,e){if(!V(e))return t.tiles||[];for(var r=[],n=0,i=t.tiles;n=1&&self.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){w("Unable to write to LocalStorage")}},X.prototype.processRequests=function(t){},X.prototype.postEvent=function(t,e,r,n){var i=this;if(z.EVENTS_URL){var a=q(z.EVENTS_URL);a.params.push("access_token="+(n||z.ACCESS_TOKEN||""));var o={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:"1.3.2",skuId:B,userId:this.anonId},s=e?h(o,e):o,l={url:W(a),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=vt(l,(function(t){i.pendingRequest=null,r(t),i.saveEventData(),i.processRequests(n)}))}},X.prototype.queueRequest=function(t,e){this.queue.push(t),this.processRequests(e)};var J,K=function(t){function e(){t.call(this,"map.load"),this.success={},this.skuToken=""}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.postMapLoadEvent=function(t,e,r,n){this.skuToken=r,(z.EVENTS_URL&&n||z.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return V(t)||H(t)})))&&this.queueRequest({id:e,timestamp:Date.now()},n)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){var r=this.queue.shift(),n=r.id,i=r.timestamp;n&&this.success[n]||(this.anonId||this.fetchEventData(),g(this.anonId)||(this.anonId=d()),this.postEvent(i,{skuToken:this.skuToken},(function(t){t||n&&(e.success[n]=!0)}),t))}},e}(X),Q=new(function(t){function e(e){t.call(this,"appUserTurnstile"),this._customAccessToken=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.postTurnstileEvent=function(t,e){z.EVENTS_URL&&z.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return V(t)||H(t)}))&&this.queueRequest(Date.now(),e)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var r=Z(z.ACCESS_TOKEN),n=r?r.u:z.ACCESS_TOKEN,i=n!==this.eventData.tokenU;g(this.anonId)||(this.anonId=d(),i=!0);var a=this.queue.shift();if(this.eventData.lastSuccess){var o=new Date(this.eventData.lastSuccess),s=new Date(a),l=(a-this.eventData.lastSuccess)/864e5;i=i||l>=1||l<-1||o.getDate()!==s.getDate()}else i=!0;if(!i)return this.processRequests();this.postEvent(a,{"enabled.telemetry":!1},(function(t){t||(e.eventData.lastSuccess=a,e.eventData.tokenU=n)}),t)}},e}(X)),$=Q.postTurnstileEvent.bind(Q),tt=new K,et=tt.postMapLoadEvent.bind(tt),rt="mapbox-tiles",nt=500,it=50,at=42e4;function ot(t){var e=t.indexOf("?");return e<0?t:t.slice(0,e)}var st=1/0,lt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(lt);var ct=function(t){function e(e,r,n){401===r&&H(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),t.call(this,e),this.status=r,this.url=n,this.name=this.constructor.name,this.message=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.name+": "+this.message+" ("+this.status+"): "+this.url},e}(Error);function ut(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}var ht=ut()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===self.location.protocol?self.parent:self).location.href};function ft(t,e){var r,n=new self.AbortController,i=new self.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ht(),signal:n.signal}),a=!1,o=!1,s=(r=i.url).indexOf("sku=")>0&&H(r);"json"===t.type&&i.headers.set("Accept","application/json");var l=function(r,n,a){if(!o){if(r&&"SecurityError"!==r.message&&w(r),n&&a)return c(n);var l=Date.now();self.fetch(i).then((function(r){if(r.ok){var n=s?r.clone():null;return c(r,n,l)}return e(new ct(r.statusText,r.status,t.url))})).catch((function(t){20!==t.code&&e(new Error(t.message))}))}},c=function(r,n,s){("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((function(t){o||(n&&s&&function(t,e,r){if(self.caches){var n={status:e.status,statusText:e.statusText,headers:new self.Headers};e.headers.forEach((function(t,e){return n.headers.set(e,t)}));var i=M(e.headers.get("Cache-Control")||"");i["no-store"]||(i["max-age"]&&n.headers.set("Expires",new Date(r+1e3*i["max-age"]).toUTCString()),new Date(n.headers.get("Expires")).getTime()-rDate.now()&&!r["no-cache"]}(n);t.delete(r),i&&t.put(r,n.clone()),e(null,n,i)})).catch(e)})).catch(e)}(i,l):l(null,null),{cancel:function(){o=!0,a||n.abort()}}}var pt,dt,gt=function(t,e){if(r=t.url,!(/^file:/.test(r)||/^file:/.test(ht())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&self.Request.prototype.hasOwnProperty("signal"))return ft(t,e);if(ut()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e)}var r;return function(t,e){var r=new self.XMLHttpRequest;for(var n in r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer"),t.headers)r.setRequestHeader(n,t.headers[n]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=function(){e(new Error(r.statusText))},r.onload=function(){if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){var n=r.response;if("json"===t.type)try{n=JSON.parse(r.response)}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else e(new ct(r.statusText,r.status,t.url))},r.send(t.body),{cancel:function(){return r.abort()}}}(t,e)},mt=function(t,e){return gt(h(t,{type:"arrayBuffer"}),e)},vt=function(t,e){return gt(h(t,{method:"POST"}),e)};pt=[],dt=0;var yt=function(t,e){if(dt>=z.MAX_PARALLEL_IMAGE_REQUESTS){var r={requestParameters:t,callback:e,cancelled:!1,cancel:function(){this.cancelled=!0}};return pt.push(r),r}dt++;var n=!1,i=function(){if(!n)for(n=!0,dt--;pt.length&&dt0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},At.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var Ct={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"string",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"},{"!":"text-variable-anchor"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:22,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},"interpolate-hcl":{group:"Ramps, scales, curves"},"interpolate-lab":{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},format:{group:"Types"},"number-format":{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"feature-state":{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Zoom"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Feature data"},accumulated:{group:"Feature data"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"string",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"string",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"string",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"string",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}}},Mt=function(t,e,r,n){this.message=(t?t+": ":"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)};function kt(t){var e=t.key,r=t.value;return r?[new Mt(e,r,"constants have been deprecated as of v8")]:[]}function It(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var Ht=[Pt,Ot,zt,Rt,Ft,Yt,Nt,Vt(jt)];function Gt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Gt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var r=0,n=Ht;r255?255:t}function i(t){return t<0?0:t>1?1:t}function a(t){return"%"===t[t.length-1]?n(parseFloat(t)/100*255):n(parseInt(t))}function o(t){return"%"===t[t.length-1]?i(parseFloat(t)/100):i(parseFloat(t))}function s(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{e.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in r)return r[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=i.indexOf("("),c=i.indexOf(")");if(-1!==l&&c+1===i.length){var u=i.substr(0,l),h=i.substr(l+1,c-(l+1)).split(","),f=1;switch(u){case"rgba":if(4!==h.length)return null;f=o(h.pop());case"rgb":return 3!==h.length?null:[a(h[0]),a(h[1]),a(h[2]),f];case"hsla":if(4!==h.length)return null;f=o(h.pop());case"hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,d=o(h[1]),g=o(h[2]),m=g<=.5?g*(d+1):g+d-g*d,v=2*g-m;return[n(255*s(v,m,p+1/3)),n(255*s(v,m,p)),n(255*s(v,m,p-1/3)),f];default:return null}}return null}}catch(t){}})).parseCSSColor,Wt=function(t,e,r,n){void 0===n&&(n=1),this.r=t,this.g=e,this.b=r,this.a=n};Wt.parse=function(t){if(t){if(t instanceof Wt)return t;if("string"==typeof t){var e=qt(t);if(e)return new Wt(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},Wt.prototype.toString=function(){var t=this.toArray(),e=t[0],r=t[1],n=t[2],i=t[3];return"rgba("+Math.round(e)+","+Math.round(r)+","+Math.round(n)+","+i+")"},Wt.prototype.toArray=function(){var t=this.r,e=this.g,r=this.b,n=this.a;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]},Wt.black=new Wt(0,0,0,1),Wt.white=new Wt(1,1,1,1),Wt.transparent=new Wt(0,0,0,0),Wt.red=new Wt(1,0,0,1);var Zt=function(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};Zt.prototype.compare=function(t,e){return this.collator.compare(t,e)},Zt.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var Xt=function(t,e,r,n){this.text=t,this.scale=e,this.fontStack=r,this.textColor=n},Jt=function(t){this.sections=t};function Kt(t,e,r,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:"Invalid rgba value ["+[t,e,r,n].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function Qt(t){if(null===t)return Pt;if("string"==typeof t)return zt;if("boolean"==typeof t)return Rt;if("number"==typeof t)return Ot;if(t instanceof Wt)return Ft;if(t instanceof Zt)return Bt;if(t instanceof Jt)return Yt;if(Array.isArray(t)){for(var e,r=t.length,n=0,i=t;n2){var s=t[1];if("string"!=typeof s||!(s in re)||"object"===s)return e.error('The item type argument of "array" must be one of string, number, boolean',1);a=re[s],n++}else a=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],n++}r=Vt(a,o)}else r=re[i];for(var l=[];n1)&&e.push(n)}}return e.concat(this.args.map((function(t){return t.serialize()})))};var ie=function(t){this.type=Yt,this.sections=t};ie.parse=function(t,e){if(t.length<3)return e.error("Expected at least two arguments.");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");for(var r=[],n=1;n4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":Kt(e[0],e[1],e[2],e[3])))return new Wt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ee(r||"Could not parse color from value '"+("string"==typeof e?e:String(JSON.stringify(e)))+"'")}if("number"===this.type.kind){for(var o=null,s=0,l=this.args;s=0)return!1;var r=!0;return t.eachChild((function(t){r&&!pe(t,e)&&(r=!1)})),r}ue.parse=function(t,e){if(2!==t.length)return e.error("Expected one argument.");var r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");var n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Rt);if(!n)return null;var i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Rt);if(!i)return null;var a=null;return r.locale&&!(a=e.parse(r.locale,1,zt))?null:new ue(n,i,a)},ue.prototype.evaluate=function(t){return new Zt(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)},ue.prototype.eachChild=function(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)},ue.prototype.possibleOutputs=function(){return[void 0]},ue.prototype.serialize=function(){var t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]};var de=function(t,e){this.type=e.type,this.name=t,this.boundExpression=e};de.parse=function(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");var r=t[1];return e.scope.has(r)?new de(r,e.scope.get(r)):e.error('Unknown variable "'+r+'". Make sure "'+r+'" has been bound in an enclosing "let" expression before using it.',1)},de.prototype.evaluate=function(t){return this.boundExpression.evaluate(t)},de.prototype.eachChild=function(){},de.prototype.possibleOutputs=function(){return[void 0]},de.prototype.serialize=function(){return["var",this.name]};var ge=function(t,e,r,n,i){void 0===e&&(e=[]),void 0===n&&(n=new Dt),void 0===i&&(i=[]),this.registry=t,this.path=e,this.key=e.map((function(t){return"["+t+"]"})).join(""),this.scope=n,this.errors=i,this.expectedType=r};function me(t,e){for(var r,n,i=t.length-1,a=0,o=i,s=0;a<=o;)if(r=t[s=Math.floor((a+o)/2)],n=t[s+1],r<=e){if(s===i||ee))throw new ee("Input is not a number.");o=s-1}return 0}ge.prototype.parse=function(t,e,r,n,i){return void 0===i&&(i={}),e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)},ge.prototype._parse=function(t,e){function r(t,e,r){return"assert"===r?new ne(e,[t]):"coerce"===r?new oe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var n=t[0];if("string"!=typeof n)return this.error("Expression name must be a string, but found "+typeof n+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var i=this.registry[n];if(i){var a=i.parse(t,this);if(!a)return null;if(this.expectedType){var o=this.expectedType,s=a.type;if("string"!==o.kind&&"number"!==o.kind&&"boolean"!==o.kind&&"object"!==o.kind&&"array"!==o.kind||"value"!==s.kind)if("color"!==o.kind&&"formatted"!==o.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(o,s))return null}else a=r(a,o,e.typeAnnotation||"coerce");else a=r(a,o,e.typeAnnotation||"assert")}if(!(a instanceof te)&&function t(e){if(e instanceof de)return t(e.boundExpression);if(e instanceof ce&&"error"===e.name)return!1;if(e instanceof ue)return!1;var r=e instanceof oe||e instanceof ne,n=!0;return e.eachChild((function(e){n=r?n&&t(e):n&&e instanceof te})),!!n&&he(e)&&pe(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}(a)){var l=new le;try{a=new te(a.type,a.evaluate(l))}catch(t){return this.error(t.message),null}}return a}return this.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error("Expected an array, but found "+typeof t+" instead.")},ge.prototype.concat=function(t,e,r){var n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new ge(this.registry,n,e||null,i,this.errors)},ge.prototype.error=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];var n=""+this.key+e.map((function(t){return"["+t+"]"})).join("");this.errors.push(new Et(n,t))},ge.prototype.checkSubtype=function(t,e){var r=Gt(t,e);return r&&this.error(r),r};var ve=function(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var n=0,i=r;n=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);var u=e.parse(s,c,i);if(!u)return null;i=i||u.type,n.push([o,u])}return new ve(i,r,n)},ve.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[me(e,n)].evaluate(t)},ve.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var xe=Object.freeze({number:ye,color:function(t,e,r){return new Wt(ye(t.r,e.r,r),ye(t.g,e.g,r),ye(t.b,e.b,r),ye(t.a,e.a,r))},array:function(t,e,r){return t.map((function(t,n){return ye(t,e[n],r)}))}}),be=.95047,_e=1,we=1.08883,Ae=4/29,Ce=6/29,Me=3*Ce*Ce,ke=Ce*Ce*Ce,Ie=Math.PI/180,Te=180/Math.PI;function Le(t){return t>ke?Math.pow(t,1/3):t/Me+Ae}function Se(t){return t>Ce?t*t*t:Me*(t-Ae)}function Ee(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function De(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Pe(t){var e=De(t.r),r=De(t.g),n=De(t.b),i=Le((.4124564*e+.3575761*r+.1804375*n)/be),a=Le((.2126729*e+.7151522*r+.072175*n)/_e);return{l:116*a-16,a:500*(i-a),b:200*(a-Le((.0193339*e+.119192*r+.9503041*n)/we)),alpha:t.a}}function Oe(t){var e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=_e*Se(e),r=be*Se(r),n=we*Se(n),new Wt(Ee(3.2404542*r-1.5371385*e-.4985314*n),Ee(-.969266*r+1.8760108*e+.041556*n),Ee(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function ze(t,e,r){var n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}var Re={forward:Pe,reverse:Oe,interpolate:function(t,e,r){return{l:ye(t.l,e.l,r),a:ye(t.a,e.a,r),b:ye(t.b,e.b,r),alpha:ye(t.alpha,e.alpha,r)}}},Fe={forward:function(t){var e=Pe(t),r=e.l,n=e.a,i=e.b,a=Math.atan2(i,n)*Te;return{h:a<0?a+360:a,c:Math.sqrt(n*n+i*i),l:r,alpha:t.a}},reverse:function(t){var e=t.h*Ie,r=t.c;return Oe({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:ze(t.h,e.h,r),c:ye(t.c,e.c,r),l:ye(t.l,e.l,r),alpha:ye(t.alpha,e.alpha,r)}}},Ne=Object.freeze({lab:Re,hcl:Fe}),je=function(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(var a=0,o=i;a1})))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:s}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(i=e.parse(i,2,Ot)))return null;var l=[],c=null;"interpolate-hcl"===r||"interpolate-lab"===r?c=Ft:e.expectedType&&"value"!==e.expectedType.kind&&(c=e.expectedType);for(var u=0;u=h)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',p);var g=e.parse(f,d,c);if(!g)return null;c=c||g.type,l.push([h,g])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new je(c,r,n,i,l):e.error("Type "+Ut(c)+" is not interpolatable.")},je.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);var a=me(e,n),o=e[a],s=e[a+1],l=je.interpolationFactor(this.interpolation,n,o,s),c=r[a].evaluate(t),u=r[a+1].evaluate(t);return"interpolate"===this.operator?xe[this.type.kind.toLowerCase()](c,u,l):"interpolate-hcl"===this.operator?Fe.reverse(Fe.interpolate(Fe.forward(c),Fe.forward(u),l)):Re.reverse(Re.interpolate(Re.forward(c),Re.forward(u),l))},je.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e=r.length)throw new ee("Array index out of bounds: "+e+" > "+(r.length-1)+".");if(e!==Math.floor(e))throw new ee("Array index must be an integer, but found "+e+" instead.");return r[e]},Ue.prototype.eachChild=function(t){t(this.index),t(this.input)},Ue.prototype.possibleOutputs=function(){return[void 0]},Ue.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var He=function(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a};He.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(var i={},a=[],o=2;oNumber.MAX_SAFE_INTEGER)return c.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof f&&Math.floor(f)!==f)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,Qt(f)))return null}else r=Qt(f);if(void 0!==i[String(f)])return c.error("Branch labels must be unique.");i[String(f)]=a.length}var p=e.parse(l,o,n);if(!p)return null;n=n||p.type,a.push(p)}var d=e.parse(t[1],1,jt);if(!d)return null;var g=e.parse(t[t.length-1],t.length-1,n);return g?"value"!==d.type.kind&&e.concat(1).checkSubtype(r,d.type)?null:new He(r,n,d,i,a,g):null},He.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(Qt(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},He.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},He.prototype.possibleOutputs=function(){var t;return(t=[]).concat.apply(t,this.outputs.map((function(t){return t.possibleOutputs()}))).concat(this.otherwise.possibleOutputs())},He.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],r=[],n={},i=0,a=Object.keys(this.cases).sort();i",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),$e=Ze("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),tr=Ze(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0})),er=function(t,e,r,n,i){this.type=zt,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i};er.parse=function(t,e){if(3!==t.length)return e.error("Expected two arguments.");var r=e.parse(t[1],1,Ot);if(!r)return null;var n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");var i=null;if(n.locale&&!(i=e.parse(n.locale,1,zt)))return null;var a=null;if(n.currency&&!(a=e.parse(n.currency,1,zt)))return null;var o=null;if(n["min-fraction-digits"]&&!(o=e.parse(n["min-fraction-digits"],1,Ot)))return null;var s=null;return n["max-fraction-digits"]&&!(s=e.parse(n["max-fraction-digits"],1,Ot))?null:new er(r,i,a,o,s)},er.prototype.evaluate=function(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))},er.prototype.eachChild=function(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)},er.prototype.possibleOutputs=function(){return[void 0]},er.prototype.serialize=function(){var t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]};var rr=function(t){this.type=Ot,this.input=t};rr.parse=function(t,e){if(2!==t.length)return e.error("Expected 1 argument, but found "+(t.length-1)+" instead.");var r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error("Expected argument of type string or array, but found "+Ut(r.type)+" instead."):new rr(r):null},rr.prototype.evaluate=function(t){var e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ee("Expected value to be of type string or array, but found "+Ut(Qt(e))+" instead.")},rr.prototype.eachChild=function(t){t(this.input)},rr.prototype.possibleOutputs=function(){return[void 0]},rr.prototype.serialize=function(){var t=["length"];return this.eachChild((function(e){t.push(e.serialize())})),t};var nr={"==":Xe,"!=":Je,">":Qe,"<":Ke,">=":tr,"<=":$e,array:ne,at:Ue,boolean:ne,case:Ge,coalesce:Ye,collator:ue,format:ie,interpolate:je,"interpolate-hcl":je,"interpolate-lab":je,length:rr,let:Ve,literal:te,match:He,number:ne,"number-format":er,object:ne,step:ve,string:ne,"to-boolean":oe,"to-color":oe,"to-number":oe,"to-string":oe,var:de};function ir(t,e){var r=e[0],n=e[1],i=e[2],a=e[3];r=r.evaluate(t),n=n.evaluate(t),i=i.evaluate(t);var o=a?a.evaluate(t):1,s=Kt(r,n,i,o);if(s)throw new ee(s);return new Wt(r/255*o,n/255*o,i/255*o,o)}function ar(t,e){return t in e}function or(t,e){var r=e[t];return void 0===r?null:r}function sr(t){return{type:t}}function lr(t){return{result:"success",value:t}}function cr(t){return{result:"error",value:t}}function ur(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function hr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function fr(t){return!!t.expression&&t.expression.interpolated}function pr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function dr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function gr(t){return t}function mr(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function vr(t,e,r,n,i){return mr(typeof r===i?n[r]:void 0,t.default,e.default)}function yr(t,e,r){if("number"!==pr(r))return mr(t.default,e.default);var n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];var i=me(t.stops.map((function(t){return t[0]})),r);return t.stops[i][1]}function xr(t,e,r){var n=void 0!==t.base?t.base:1;if("number"!==pr(r))return mr(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];var a=me(t.stops.map((function(t){return t[0]})),r),o=function(t,e,r,n){var i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),s=t.stops[a][1],l=t.stops[a+1][1],c=xe[e.type]||gr;if(t.colorSpace&&"rgb"!==t.colorSpace){var u=Ne[t.colorSpace];c=function(t,e){return u.reverse(u.interpolate(u.forward(t),u.forward(e),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=s.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==r&&void 0!==n)return c(r,n,o)}}:c(s,l,o)}function br(t,e,r){return"color"===e.type?r=Wt.parse(r):"formatted"===e.type?r=Jt.fromString(r.toString()):pr(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),mr(r,t.default,e.default)}ce.register(nr,{error:[{kind:"error"},[zt],function(t,e){var r=e[0];throw new ee(r.evaluate(t))}],typeof:[zt,[jt],function(t,e){return Ut(Qt(e[0].evaluate(t)))}],"to-rgba":[Vt(Ot,4),[Ft],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Ft,[Ot,Ot,Ot],ir],rgba:[Ft,[Ot,Ot,Ot,Ot],ir],has:{type:Rt,overloads:[[[zt],function(t,e){return ar(e[0].evaluate(t),t.properties())}],[[zt,Nt],function(t,e){var r=e[0],n=e[1];return ar(r.evaluate(t),n.evaluate(t))}]]},get:{type:jt,overloads:[[[zt],function(t,e){return or(e[0].evaluate(t),t.properties())}],[[zt,Nt],function(t,e){var r=e[0],n=e[1];return or(r.evaluate(t),n.evaluate(t))}]]},"feature-state":[jt,[zt],function(t,e){return or(e[0].evaluate(t),t.featureState||{})}],properties:[Nt,[],function(t){return t.properties()}],"geometry-type":[zt,[],function(t){return t.geometryType()}],id:[jt,[],function(t){return t.id()}],zoom:[Ot,[],function(t){return t.globals.zoom}],"heatmap-density":[Ot,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[Ot,[],function(t){return t.globals.lineProgress||0}],accumulated:[jt,[],function(t){return void 0===t.globals.accumulated?null:t.globals.accumulated}],"+":[Ot,sr(Ot),function(t,e){for(var r=0,n=0,i=e;n":[Rt,[zt,jt],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>a}],"filter-id->":[Rt,[jt],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>i}],"filter-<=":[Rt,[zt,jt],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[Rt,[jt],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n<=i}],"filter->=":[Rt,[zt,jt],function(t,e){var r=e[0],n=e[1],i=t.properties()[r.value],a=n.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[Rt,[jt],function(t,e){var r=e[0],n=t.id(),i=r.value;return typeof n==typeof i&&n>=i}],"filter-has":[Rt,[jt],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[Rt,[],function(t){return null!==t.id()}],"filter-type-in":[Rt,[Vt(zt)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[Rt,[Vt(jt)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[Rt,[zt,Vt(jt)],function(t,e){var r=e[0];return e[1].value.indexOf(t.properties()[r.value])>=0}],"filter-in-large":[Rt,[zt,Vt(jt)],function(t,e){var r=e[0],n=e[1];return function(t,e,r,n){for(;r<=n;){var i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[r.value],n.value,0,n.value.length-1)}],all:{type:Rt,overloads:[[[Rt,Rt],function(t,e){var r=e[0],n=e[1];return r.evaluate(t)&&n.evaluate(t)}],[sr(Rt),function(t,e){for(var r=0,n=e;r0&&"string"==typeof t[0]&&t[0]in nr}function Ar(t,e){var r=new ge(nr,[],e?function(t){var e={color:Ft,string:zt,number:Ot,enum:zt,boolean:Rt,formatted:Yt};return"array"===t.type?Vt(e[t.value]||jt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?lr(new _r(n,e)):cr(r.errors)}_r.prototype.evaluateWithoutErrorHandling=function(t,e,r,n){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)},_r.prototype.evaluate=function(t,e,r,n){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.formattedSection=n||null;try{var i=this.expression.evaluate(this._evaluator);if(null==i)return this._defaultValue;if(this._enumValues&&!(i in this._enumValues))throw new ee("Expected value to be one of "+Object.keys(this._enumValues).map((function(t){return JSON.stringify(t)})).join(", ")+", but found "+JSON.stringify(i)+" instead.");return i}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var Cr=function(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!fe(e.expression)};Cr.prototype.evaluateWithoutErrorHandling=function(t,e,r,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n)},Cr.prototype.evaluate=function(t,e,r,n){return this._styleExpression.evaluate(t,e,r,n)};var Mr=function(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!fe(e.expression),this.interpolationType=n};function kr(t,e){if("error"===(t=Ar(t,e)).result)return t;var r=t.value.expression,n=he(r);if(!n&&!ur(e))return cr([new Et("","data expressions not supported")]);var i=pe(r,["zoom"]);if(!i&&!hr(e))return cr([new Et("","zoom expressions not supported")]);var a=function t(e){var r=null;if(e instanceof Ve)r=t(e.result);else if(e instanceof Ye)for(var n=0,i=e.args;nn.maximum?[new Mt(e,r,r+" is greater than the maximum value "+n.maximum)]:[]}function Er(t){var e,r,n,i=t.valueSpec,a=Lt(t.value.type),o={},s="categorical"!==a&&void 0===t.value.property,l=!s,c="array"===pr(t.value.stops)&&"array"===pr(t.value.stops[0])&&"object"===pr(t.value.stops[0][0]),u=Tr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===a)return[new Mt(t.key,t.value,'identity function may not have a "stops" property')];var e=[],r=t.value;return e=e.concat(Lr({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===pr(r)&&0===r.length&&e.push(new Mt(t.key,r,"array must have at least one stop")),e},default:function(t){return Qr({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===a&&s&&u.push(new Mt(t.key,t.value,'missing required property "property"')),"identity"===a||t.value.stops||u.push(new Mt(t.key,t.value,'missing required property "stops"')),"exponential"===a&&t.valueSpec.expression&&!fr(t.valueSpec)&&u.push(new Mt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!ur(t.valueSpec)?u.push(new Mt(t.key,t.value,"property functions not supported")):s&&!hr(t.valueSpec)&&u.push(new Mt(t.key,t.value,"zoom functions not supported"))),"categorical"!==a&&!c||void 0!==t.value.property||u.push(new Mt(t.key,t.value,'"property" property is required')),u;function h(t){var e=[],a=t.value,s=t.key;if("array"!==pr(a))return[new Mt(s,a,"array expected, "+pr(a)+" found")];if(2!==a.length)return[new Mt(s,a,"array length 2 expected, length "+a.length+" found")];if(c){if("object"!==pr(a[0]))return[new Mt(s,a,"object expected, "+pr(a[0])+" found")];if(void 0===a[0].zoom)return[new Mt(s,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new Mt(s,a,"object stop key must have value")];if(n&&n>Lt(a[0].zoom))return[new Mt(s,a[0].zoom,"stop zoom values must appear in ascending order")];Lt(a[0].zoom)!==n&&(n=Lt(a[0].zoom),r=void 0,o={}),e=e.concat(Tr({key:s+"[0]",value:a[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Sr,value:f}}))}else e=e.concat(f({key:s+"[0]",value:a[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},a));return wr(St(a[1]))?e.concat([new Mt(s+"[1]",a[1],"expressions are not allowed in function stops.")]):e.concat(Qr({key:s+"[1]",value:a[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function f(t,n){var s=pr(t.value),l=Lt(t.value),c=null!==t.value?t.value:n;if(e){if(s!==e)return[new Mt(t.key,c,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new Mt(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==a){var u="number expected, "+s+" found";return ur(i)&&void 0===a&&(u+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Mt(t.key,c,u)]}return"categorical"!==a||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==a&&"number"===s&&void 0!==r&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(var e=0,r=t.slice(1);ee?1:0}function Nr(t){if(!t)return!0;var e,r=t[0];return t.length<=1?"any"!==r:"=="===r?jr(t[1],t[2],"=="):"!="===r?Vr(jr(t[1],t[2],"==")):"<"===r||">"===r||"<="===r||">="===r?jr(t[1],t[2],r):"any"===r?(e=t.slice(1),["any"].concat(e.map(Nr))):"all"===r?["all"].concat(t.slice(1).map(Nr)):"none"===r?["all"].concat(t.slice(1).map(Nr).map(Vr)):"in"===r?Br(t[1],t.slice(2)):"!in"===r?Vr(Br(t[1],t.slice(2))):"has"===r?Yr(t[1]):"!has"!==r||Vr(Yr(t[1]))}function jr(t,e,r){switch(t){case"$type":return["filter-type-"+r,e];case"$id":return["filter-id-"+r,e];default:return["filter-"+r,t,e]}}function Br(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((function(t){return typeof t!=typeof e[0]}))?["filter-in-large",t,["literal",e.sort(Fr)]]:["filter-in-small",t,["literal",e]]}}function Yr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Vr(t){return["!",t]}function Ur(t){return Or(St(t.value))?Dr(It({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var r=e.value,n=e.key;if("array"!==pr(r))return[new Mt(n,r,"array expected, "+pr(r)+" found")];var i,a=e.styleSpec,o=[];if(r.length<1)return[new Mt(n,r,"filter array must have at least 1 element")];switch(o=o.concat(Pr({key:n+"[0]",value:r[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),Lt(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===Lt(r[1])&&o.push(new Mt(n,r,'"$type" cannot be use with operator "'+r[0]+'"'));case"==":case"!=":3!==r.length&&o.push(new Mt(n,r,'filter array for operator "'+r[0]+'" must have 3 elements'));case"in":case"!in":r.length>=2&&"string"!==(i=pr(r[1]))&&o.push(new Mt(n+"[1]",r[1],"string expected, "+i+" found"));for(var s=2;s=u[p+0]&&n>=u[p+1])?(o[f]=!0,a.push(c[f])):o[f]=!1}}},hn.prototype._forEachCell=function(t,e,r,n,i,a,o,s){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(r),h=this._convertToCellCoord(n),f=l;f<=u;f++)for(var p=c;p<=h;p++){var d=this.d*p+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(p),this._convertFromCellCoord(f+1),this._convertFromCellCoord(p+1)))&&i.call(this,t,e,r,n,d,a,o,s))return}},hn.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},hn.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},hn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=un+this.cells.length+1+1,r=0,n=0;n=0)){var h=t[u];c[u]=pn[l].shallow.indexOf(u)>=0?h:mn(h,e)}t instanceof Error&&(c.message=t.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==l&&(c.$name=l),c}throw new Error("can't serialize object of type "+typeof t)}function vn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof fn)return t;if(Array.isArray(t))return t.map(vn);if("object"==typeof t){var e=t.$name||"Object",r=pn[e].klass;if(!r)throw new Error("can't deserialize unregistered class "+e);if(r.deserialize)return r.deserialize(t);for(var n=Object.create(r.prototype),i=0,a=Object.keys(t);i=0?s:vn(s)}}return n}throw new Error("can't deserialize object of type "+typeof t)}var yn=function(){this.first=!0};yn.prototype.update=function(t,e){var r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function bn(t){for(var e=0,r=t;e=65097&&t<=65103)||xn["CJK Compatibility Ideographs"](t)||xn["CJK Compatibility"](t)||xn["CJK Radicals Supplement"](t)||xn["CJK Strokes"](t)||!(!xn["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||xn["CJK Unified Ideographs Extension A"](t)||xn["CJK Unified Ideographs"](t)||xn["Enclosed CJK Letters and Months"](t)||xn["Hangul Compatibility Jamo"](t)||xn["Hangul Jamo Extended-A"](t)||xn["Hangul Jamo Extended-B"](t)||xn["Hangul Jamo"](t)||xn["Hangul Syllables"](t)||xn.Hiragana(t)||xn["Ideographic Description Characters"](t)||xn.Kanbun(t)||xn["Kangxi Radicals"](t)||xn["Katakana Phonetic Extensions"](t)||xn.Katakana(t)&&12540!==t||!(!xn["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!xn["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||xn["Unified Canadian Aboriginal Syllabics"](t)||xn["Unified Canadian Aboriginal Syllabics Extended"](t)||xn["Vertical Forms"](t)||xn["Yijing Hexagram Symbols"](t)||xn["Yi Syllables"](t)||xn["Yi Radicals"](t))))}function An(t){return!(wn(t)||function(t){return!!(xn["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||xn["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||xn["Letterlike Symbols"](t)||xn["Number Forms"](t)||xn["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||xn["Control Pictures"](t)&&9251!==t||xn["Optical Character Recognition"](t)||xn["Enclosed Alphanumerics"](t)||xn["Geometric Shapes"](t)||xn["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||xn["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||xn["CJK Symbols and Punctuation"](t)||xn.Katakana(t)||xn["Private Use Area"](t)||xn["CJK Compatibility Forms"](t)||xn["Small Form Variants"](t)||xn["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Cn(t,e){return!(!e&&(t>=1424&&t<=2303||xn["Arabic Presentation Forms-A"](t)||xn["Arabic Presentation Forms-B"](t))||t>=2304&&t<=3583||t>=3840&&t<=4255||xn.Khmer(t))}var Mn,kn=!1,In=null,Tn=!1,Ln=new At,Sn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return Tn||null!=Sn.applyArabicShaping}},En=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new yn,this.transition={})};En.prototype.isSupportedScript=function(t){return function(t,e){for(var r=0,n=t;rthis.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}};var Dn=function(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(dr(t))return new Ir(t,e);if(wr(t)){var r=kr(t,e);if("error"===r.result)throw new Error(r.value.map((function(t){return t.key+": "+t.message})).join(", "));return r.value}var n=t;return"string"==typeof t&&"color"===e.type&&(n=Wt.parse(t)),{kind:"constant",evaluate:function(){return n}}}(void 0===e?t.specification.default:e,t.specification)};Dn.prototype.isDataDriven=function(){return"source"===this.expression.kind||"composite"===this.expression.kind},Dn.prototype.possiblyEvaluate=function(t){return this.property.possiblyEvaluate(this,t)};var Pn=function(t){this.property=t,this.value=new Dn(t,void 0)};Pn.prototype.transitioned=function(t,e){return new zn(this.property,this.value,e,h({},t.transition,this.transition),t.now)},Pn.prototype.untransitioned=function(){return new zn(this.property,this.value,null,{},0)};var On=function(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)};On.prototype.getValue=function(t){return b(this._values[t].value.value)},On.prototype.setValue=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Pn(this._values[t].property)),this._values[t].value=new Dn(this._values[t].property,null===e?void 0:b(e))},On.prototype.getTransition=function(t){return b(this._values[t].transition)},On.prototype.setTransition=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Pn(this._values[t].property)),this._values[t].transition=b(e)||void 0},On.prototype.serialize=function(){for(var t={},e=0,r=Object.keys(this._values);ethis.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(e=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(i))}return r};var Rn=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};Rn.prototype.possiblyEvaluate=function(t){for(var e=new jn(this._properties),r=0,n=Object.keys(this._values);rn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}},e.prototype.interpolate=function(t){return t},e}(Yn),Un=function(t){this.specification=t};Un.prototype.possiblyEvaluate=function(t,e){if(void 0!==t.value){if("constant"===t.expression.kind){var r=t.expression.evaluate(e);return this._calculate(r,r,r,e)}return this._calculate(t.expression.evaluate(new En(Math.floor(e.zoom-1),e)),t.expression.evaluate(new En(Math.floor(e.zoom),e)),t.expression.evaluate(new En(Math.floor(e.zoom+1),e)),e)}},Un.prototype._calculate=function(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}},Un.prototype.interpolate=function(t){return t};var Hn=function(t){this.specification=t};Hn.prototype.possiblyEvaluate=function(t,e){return!!t.expression.evaluate(e)},Hn.prototype.interpolate=function(){return!1};var Gn=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],t){var r=t[e];r.specification.overridable&&this.overridableProperties.push(e);var n=this.defaultPropertyValues[e]=new Dn(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Pn(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}};dn("DataDrivenProperty",Yn),dn("DataConstantProperty",Bn),dn("CrossFadedDataDrivenProperty",Vn),dn("CrossFadedProperty",Un),dn("ColorRampProperty",Hn);var qn=function(t){function e(e,r){if(t.call(this),this.id=e.id,this.type=e.type,this._featureFilter=function(){return!0},"custom"!==e.type&&(e=e,this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Fn(r.layout)),r.paint)){for(var n in this._transitionablePaint=new On(r.paint),e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned()}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCrossfadeParameters=function(){return this._crossfadeParameters},e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,r){if(void 0===r&&(r={}),null!=e){var n="layers."+this.id+".layout."+t;if(this._validate(sn,n,t,e,r))return}"visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,r){if(void 0===r&&(r={}),null!=e){var n="layers."+this.id+".paint."+t;if(this._validate(on,n,t,e,r))return!1}if(v(t,"-transition"))return this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0),!1;var i=this._transitionablePaint._values[t],a="cross-faded-data-driven"===i.property.specification["property-type"],o=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);var l=this._transitionablePaint._values[t].value;return l.isDataDriven()||o||a||this._handleOverridablePaintPropertyUpdate(t,s,l)},e.prototype._handleSpecialPaintPropertyUpdate=function(t){},e.prototype._handleOverridablePaintPropertyUpdate=function(t,e,r){return!1},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t)),this.paint=this._transitioningPaint.possiblyEvaluate(t)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),x(t,(function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)}))},e.prototype._validate=function(t,e,r,n,i){return void 0===i&&(i={}),(!i||!1!==i.validate)&&ln(this,t.call(nn,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:Ct,style:{glyphs:!0,sprite:!0}}))},e.prototype.is3D=function(){return!1},e.prototype.isTileClipped=function(){return!1},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e.prototype.isStateDependent=function(){for(var t in this.paint._values){var e=this.paint.get(t);if(e instanceof Nn&&ur(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1},e}(At),Wn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Zn=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Xn=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Jn(t,e){void 0===e&&(e=1);var r=0,n=0;return{members:t.map((function(t){var i,a=(i=t.type,Wn[i].BYTES_PER_ELEMENT),o=r=Kn(r,Math.max(e,a)),s=t.components||1;return n=Math.max(n,a),r+=a*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Kn(r,Math.max(n,e)),alignment:e}}function Kn(t,e){return Math.ceil(t/e)*e}Xn.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Xn.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Xn.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Xn.prototype.clear=function(){this.length=0},Xn.prototype.resize=function(t){this.reserve(t),this.length=t},Xn.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Xn.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Qn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;return this.resize(r+1),this.emplace(r,t,e)},e.prototype.emplace=function(t,e,r){var n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t},e}(Xn);Qn.prototype.bytesPerElement=4,dn("StructArrayLayout2i4",Qn);var $n=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)},e.prototype.emplace=function(t,e,r,n,i){var a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,t},e}(Xn);$n.prototype.bytesPerElement=8,dn("StructArrayLayout4i8",$n);var ti=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)},e.prototype.emplace=function(t,e,r,n,i,a,o){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,t},e}(Xn);ti.prototype.bytesPerElement=12,dn("StructArrayLayout2i4i12",ti);var ei=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)},e.prototype.emplace=function(t,e,r,n,i,a,o){var s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=a,this.uint8[l+7]=o,t},e}(Xn);ei.prototype.bytesPerElement=8,dn("StructArrayLayout2i4ub8",ei);var ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;return this.resize(l+1),this.emplace(l,t,e,r,n,i,a,o,s)},e.prototype.emplace=function(t,e,r,n,i,a,o,s,l){var c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=r,this.uint16[c+2]=n,this.uint16[c+3]=i,this.uint16[c+4]=a,this.uint16[c+5]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,t},e}(Xn);ri.prototype.bytesPerElement=16,dn("StructArrayLayout8ui16",ri);var ni=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s){var l=this.length;return this.resize(l+1),this.emplace(l,t,e,r,n,i,a,o,s)},e.prototype.emplace=function(t,e,r,n,i,a,o,s,l){var c=8*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.uint16[c+4]=a,this.uint16[c+5]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,t},e}(Xn);ni.prototype.bytesPerElement=16,dn("StructArrayLayout4i4ui16",ni);var ii=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)},e.prototype.emplace=function(t,e,r,n){var i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t},e}(Xn);ii.prototype.bytesPerElement=12,dn("StructArrayLayout3f12",ii);var ai=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){var r=1*t;return this.uint32[r+0]=e,t},e}(Xn);ai.prototype.bytesPerElement=4,dn("StructArrayLayout1ul4",ai);var oi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u){var h=this.length;return this.resize(h+1),this.emplace(h,t,e,r,n,i,a,o,s,l,c,u)},e.prototype.emplace=function(t,e,r,n,i,a,o,s,l,c,u,h){var f=12*t,p=6*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=a,this.int16[f+5]=o,this.uint32[p+3]=s,this.uint16[f+8]=l,this.uint16[f+9]=c,this.int16[f+10]=u,this.int16[f+11]=h,t},e}(Xn);oi.prototype.bytesPerElement=24,dn("StructArrayLayout6i1ul2ui2i24",oi);var si=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a)},e.prototype.emplace=function(t,e,r,n,i,a,o){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,t},e}(Xn);si.prototype.bytesPerElement=12,dn("StructArrayLayout2i2i2i12",si);var li=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)},e.prototype.emplace=function(t,e,r,n,i){var a=12*t,o=3*t;return this.uint8[a+0]=e,this.uint8[a+1]=r,this.float32[o+1]=n,this.float32[o+2]=i,t},e}(Xn);li.prototype.bytesPerElement=12,dn("StructArrayLayout2ub2f12",li);var ci=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g){var m=this.length;return this.resize(m+1),this.emplace(m,t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g)},e.prototype.emplace=function(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g,m){var v=22*t,y=11*t,x=44*t;return this.int16[v+0]=e,this.int16[v+1]=r,this.uint16[v+2]=n,this.uint16[v+3]=i,this.uint32[y+2]=a,this.uint32[y+3]=o,this.uint32[y+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=c,this.uint16[v+12]=u,this.float32[y+7]=h,this.float32[y+8]=f,this.uint8[x+36]=p,this.uint8[x+37]=d,this.uint8[x+38]=g,this.uint32[y+10]=m,t},e}(Xn);ci.prototype.bytesPerElement=44,dn("StructArrayLayout2i2ui3ul3ui2f3ub1ul44",ci);var ui=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g,m,v,y,x){var b=this.length;return this.resize(b+1),this.emplace(b,t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g,m,v,y,x)},e.prototype.emplace=function(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g,m,v,y,x,b){var _=24*t,w=12*t;return this.int16[_+0]=e,this.int16[_+1]=r,this.int16[_+2]=n,this.int16[_+3]=i,this.int16[_+4]=a,this.int16[_+5]=o,this.uint16[_+6]=s,this.uint16[_+7]=l,this.uint16[_+8]=c,this.uint16[_+9]=u,this.uint16[_+10]=h,this.uint16[_+11]=f,this.uint16[_+12]=p,this.uint16[_+13]=d,this.uint16[_+14]=g,this.uint16[_+15]=m,this.uint16[_+16]=v,this.uint32[w+9]=y,this.float32[w+10]=x,this.float32[w+11]=b,t},e}(Xn);ui.prototype.bytesPerElement=48,dn("StructArrayLayout6i11ui1ul2f48",ui);var hi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){var r=1*t;return this.float32[r+0]=e,t},e}(Xn);hi.prototype.bytesPerElement=4,dn("StructArrayLayout1f4",hi);var fi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)},e.prototype.emplace=function(t,e,r,n){var i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t},e}(Xn);fi.prototype.bytesPerElement=6,dn("StructArrayLayout3i6",fi);var pi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)},e.prototype.emplace=function(t,e,r,n){var i=2*t,a=4*t;return this.uint32[i+0]=e,this.uint16[a+2]=r,this.uint16[a+3]=n,t},e}(Xn);pi.prototype.bytesPerElement=8,dn("StructArrayLayout1ul2ui8",pi);var di=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r){var n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)},e.prototype.emplace=function(t,e,r,n){var i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t},e}(Xn);di.prototype.bytesPerElement=6,dn("StructArrayLayout3ui6",di);var gi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;return this.resize(r+1),this.emplace(r,t,e)},e.prototype.emplace=function(t,e,r){var n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t},e}(Xn);gi.prototype.bytesPerElement=4,dn("StructArrayLayout2ui4",gi);var mi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){var r=1*t;return this.uint16[r+0]=e,t},e}(Xn);mi.prototype.bytesPerElement=2,dn("StructArrayLayout1ui2",mi);var vi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var r=this.length;return this.resize(r+1),this.emplace(r,t,e)},e.prototype.emplace=function(t,e,r){var n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t},e}(Xn);vi.prototype.bytesPerElement=8,dn("StructArrayLayout2f8",vi);var yi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,r,n){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)},e.prototype.emplace=function(t,e,r,n,i){var a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,t},e}(Xn);yi.prototype.bytesPerElement=16,dn("StructArrayLayout4f16",yi);var xi=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},radius:{configurable:!0},signedDistanceFromAnchor:{configurable:!0},anchorPoint:{configurable:!0}};return r.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorPointX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorPointY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.x1.get=function(){return this._structArray.int16[this._pos2+2]},r.x1.set=function(t){this._structArray.int16[this._pos2+2]=t},r.y1.get=function(){return this._structArray.int16[this._pos2+3]},r.y1.set=function(t){this._structArray.int16[this._pos2+3]=t},r.x2.get=function(){return this._structArray.int16[this._pos2+4]},r.x2.set=function(t){this._structArray.int16[this._pos2+4]=t},r.y2.get=function(){return this._structArray.int16[this._pos2+5]},r.y2.set=function(t){this._structArray.int16[this._pos2+5]=t},r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},r.radius.get=function(){return this._structArray.int16[this._pos2+10]},r.radius.set=function(t){this._structArray.int16[this._pos2+10]=t},r.signedDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+11]},r.signedDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+11]=t},r.anchorPoint.get=function(){return new i(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,r),e}(Zn);xi.prototype.size=24;var bi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new xi(this,t)},e}(oi);dn("CollisionBoxArray",bi);var _i=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},placedOrientation:{configurable:!0},hidden:{configurable:!0},crossTileID:{configurable:!0}};return r.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.glyphStartIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},r.numGlyphs.set=function(t){this._structArray.uint16[this._pos2+3]=t},r.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},r.vertexStartIndex.set=function(t){this._structArray.uint32[this._pos4+2]=t},r.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},r.lineStartIndex.set=function(t){this._structArray.uint32[this._pos4+3]=t},r.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},r.lineLength.set=function(t){this._structArray.uint32[this._pos4+4]=t},r.segment.get=function(){return this._structArray.uint16[this._pos2+10]},r.segment.set=function(t){this._structArray.uint16[this._pos2+10]=t},r.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},r.lowerSize.set=function(t){this._structArray.uint16[this._pos2+11]=t},r.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},r.upperSize.set=function(t){this._structArray.uint16[this._pos2+12]=t},r.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},r.lineOffsetX.set=function(t){this._structArray.float32[this._pos4+7]=t},r.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},r.lineOffsetY.set=function(t){this._structArray.float32[this._pos4+8]=t},r.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},r.writingMode.set=function(t){this._structArray.uint8[this._pos1+36]=t},r.placedOrientation.get=function(){return this._structArray.uint8[this._pos1+37]},r.placedOrientation.set=function(t){this._structArray.uint8[this._pos1+37]=t},r.hidden.get=function(){return this._structArray.uint8[this._pos1+38]},r.hidden.set=function(t){this._structArray.uint8[this._pos1+38]=t},r.crossTileID.get=function(){return this._structArray.uint32[this._pos4+10]},r.crossTileID.set=function(t){this._structArray.uint32[this._pos4+10]=t},Object.defineProperties(e.prototype,r),e}(Zn);_i.prototype.size=44;var wi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new _i(this,t)},e}(ci);dn("PlacedSymbolArray",wi);var Ai=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={anchorX:{configurable:!0},anchorY:{configurable:!0},rightJustifiedTextSymbolIndex:{configurable:!0},centerJustifiedTextSymbolIndex:{configurable:!0},leftJustifiedTextSymbolIndex:{configurable:!0},verticalPlacedTextSymbolIndex:{configurable:!0},key:{configurable:!0},textBoxStartIndex:{configurable:!0},textBoxEndIndex:{configurable:!0},verticalTextBoxStartIndex:{configurable:!0},verticalTextBoxEndIndex:{configurable:!0},iconBoxStartIndex:{configurable:!0},iconBoxEndIndex:{configurable:!0},featureIndex:{configurable:!0},numHorizontalGlyphVertices:{configurable:!0},numVerticalGlyphVertices:{configurable:!0},numIconVertices:{configurable:!0},crossTileID:{configurable:!0},textBoxScale:{configurable:!0},radialTextOffset:{configurable:!0}};return r.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},r.anchorX.set=function(t){this._structArray.int16[this._pos2+0]=t},r.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},r.anchorY.set=function(t){this._structArray.int16[this._pos2+1]=t},r.rightJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+2]},r.rightJustifiedTextSymbolIndex.set=function(t){this._structArray.int16[this._pos2+2]=t},r.centerJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+3]},r.centerJustifiedTextSymbolIndex.set=function(t){this._structArray.int16[this._pos2+3]=t},r.leftJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+4]},r.leftJustifiedTextSymbolIndex.set=function(t){this._structArray.int16[this._pos2+4]=t},r.verticalPlacedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+5]},r.verticalPlacedTextSymbolIndex.set=function(t){this._structArray.int16[this._pos2+5]=t},r.key.get=function(){return this._structArray.uint16[this._pos2+6]},r.key.set=function(t){this._structArray.uint16[this._pos2+6]=t},r.textBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+7]},r.textBoxStartIndex.set=function(t){this._structArray.uint16[this._pos2+7]=t},r.textBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+8]},r.textBoxEndIndex.set=function(t){this._structArray.uint16[this._pos2+8]=t},r.verticalTextBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+9]},r.verticalTextBoxStartIndex.set=function(t){this._structArray.uint16[this._pos2+9]=t},r.verticalTextBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+10]},r.verticalTextBoxEndIndex.set=function(t){this._structArray.uint16[this._pos2+10]=t},r.iconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+11]},r.iconBoxStartIndex.set=function(t){this._structArray.uint16[this._pos2+11]=t},r.iconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+12]},r.iconBoxEndIndex.set=function(t){this._structArray.uint16[this._pos2+12]=t},r.featureIndex.get=function(){return this._structArray.uint16[this._pos2+13]},r.featureIndex.set=function(t){this._structArray.uint16[this._pos2+13]=t},r.numHorizontalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+14]},r.numHorizontalGlyphVertices.set=function(t){this._structArray.uint16[this._pos2+14]=t},r.numVerticalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+15]},r.numVerticalGlyphVertices.set=function(t){this._structArray.uint16[this._pos2+15]=t},r.numIconVertices.get=function(){return this._structArray.uint16[this._pos2+16]},r.numIconVertices.set=function(t){this._structArray.uint16[this._pos2+16]=t},r.crossTileID.get=function(){return this._structArray.uint32[this._pos4+9]},r.crossTileID.set=function(t){this._structArray.uint32[this._pos4+9]=t},r.textBoxScale.get=function(){return this._structArray.float32[this._pos4+10]},r.textBoxScale.set=function(t){this._structArray.float32[this._pos4+10]=t},r.radialTextOffset.get=function(){return this._structArray.float32[this._pos4+11]},r.radialTextOffset.set=function(t){this._structArray.float32[this._pos4+11]=t},Object.defineProperties(e.prototype,r),e}(Zn);Ai.prototype.size=48;var Ci=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new Ai(this,t)},e}(ui);dn("SymbolInstanceArray",Ci);var Mi=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={offsetX:{configurable:!0}};return r.offsetX.get=function(){return this._structArray.float32[this._pos4+0]},r.offsetX.set=function(t){this._structArray.float32[this._pos4+0]=t},Object.defineProperties(e.prototype,r),e}(Zn);Mi.prototype.size=4;var ki=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e.prototype.get=function(t){return new Mi(this,t)},e}(hi);dn("GlyphOffsetArray",ki);var Ii=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={x:{configurable:!0},y:{configurable:!0},tileUnitDistanceFromAnchor:{configurable:!0}};return r.x.get=function(){return this._structArray.int16[this._pos2+0]},r.x.set=function(t){this._structArray.int16[this._pos2+0]=t},r.y.get=function(){return this._structArray.int16[this._pos2+1]},r.y.set=function(t){this._structArray.int16[this._pos2+1]=t},r.tileUnitDistanceFromAnchor.get=function(){return this._structArray.int16[this._pos2+2]},r.tileUnitDistanceFromAnchor.set=function(t){this._structArray.int16[this._pos2+2]=t},Object.defineProperties(e.prototype,r),e}(Zn);Ii.prototype.size=6;var Ti=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e.prototype.get=function(t){return new Ii(this,t)},e}(fi);dn("SymbolLineVertexArray",Ti);var Li=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return r.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},r.featureIndex.set=function(t){this._structArray.uint32[this._pos4+0]=t},r.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},r.sourceLayerIndex.set=function(t){this._structArray.uint16[this._pos2+2]=t},r.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},r.bucketIndex.set=function(t){this._structArray.uint16[this._pos2+3]=t},Object.defineProperties(e.prototype,r),e}(Zn);Li.prototype.size=8;var Si=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return new Li(this,t)},e}(pi);dn("FeatureIndexArray",Si);var Ei=Jn([{name:"a_pos",components:2,type:"Int16"}],4).members,Di=function(t){void 0===t&&(t=[]),this.segments=t};function Pi(t,e){return 256*(t=c(Math.floor(t),0,255))+c(Math.floor(e),0,255)}Di.prototype.prepareSegment=function(t,e,r,n){var i=this.segments[this.segments.length-1];return t>Di.MAX_VERTEX_ARRAY_LENGTH&&w("Max vertices per segment is "+Di.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!i||i.vertexLength+t>Di.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i},Di.prototype.get=function(){return this.segments},Di.prototype.destroy=function(){for(var t=0,e=this.segments;t>1;this.ids[n]>=t?r=n:e=n+1}for(var i=[];this.ids[e]===t;){var a=this.positions[3*e],o=this.positions[3*e+1],s=this.positions[3*e+2];i.push({index:a,start:o,end:s}),e++}return i},Oi.serialize=function(t,e){var r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return function t(e,r,n,i){if(!(n>=i)){for(var a=e[n+i>>1],o=n-1,s=i+1;;){do{o++}while(e[o]a);if(o>=s)break;zi(e,o,s),zi(r,3*o,3*s),zi(r,3*o+1,3*s+1),zi(r,3*o+2,3*s+2)}t(e,r,n,s),t(e,r,s+1,i)}}(r,n,0,r.length-1),e.push(r.buffer,n.buffer),{ids:r,positions:n}},Oi.deserialize=function(t){var e=new Oi;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e},dn("FeaturePositionMap",Oi);var Ri=function(t,e){this.gl=t.gl,this.location=e},Fi=function(t){function e(e,r){t.call(this,e,r),this.current=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))},e}(Ri),Ni=function(t){function e(e,r){t.call(this,e,r),this.current=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))},e}(Ri),ji=function(t){function e(e,r){t.call(this,e,r),this.current=[0,0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))},e}(Ri),Bi=function(t){function e(e,r){t.call(this,e,r),this.current=[0,0,0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))},e}(Ri),Yi=function(t){function e(e,r){t.call(this,e,r),this.current=[0,0,0,0]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))},e}(Ri),Vi=function(t){function e(e,r){t.call(this,e,r),this.current=Wt.transparent}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))},e}(Ri),Ui=new Float32Array(16),Hi=function(t){function e(e,r){t.call(this,e,r),this.current=Ui}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.set=function(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(var e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}},e}(Ri);function Gi(t){return[Pi(255*t.r,255*t.g),Pi(255*t.b,255*t.a)]}var qi=function(t,e,r){this.value=t,this.names=e,this.uniformNames=this.names.map((function(t){return"u_"+t})),this.type=r,this.maxValue=-1/0};qi.prototype.defines=function(){return this.names.map((function(t){return"#define HAS_UNIFORM_u_"+t}))},qi.prototype.setConstantPatternPositions=function(){},qi.prototype.populatePaintArray=function(){},qi.prototype.updatePaintArray=function(){},qi.prototype.upload=function(){},qi.prototype.destroy=function(){},qi.prototype.setUniforms=function(t,e,r,n){e.set(n.constantOr(this.value))},qi.prototype.getBinding=function(t,e){return"color"===this.type?new Vi(t,e):new Ni(t,e)},qi.serialize=function(t){var e=t.value,r=t.names,n=t.type;return{value:mn(e),names:r,type:n}},qi.deserialize=function(t){var e=t.value,r=t.names,n=t.type;return new qi(vn(e),r,n)};var Wi=function(t,e,r){this.value=t,this.names=e,this.uniformNames=this.names.map((function(t){return"u_"+t})),this.type=r,this.maxValue=-1/0,this.patternPositions={patternTo:null,patternFrom:null}};Wi.prototype.defines=function(){return this.names.map((function(t){return"#define HAS_UNIFORM_u_"+t}))},Wi.prototype.populatePaintArray=function(){},Wi.prototype.updatePaintArray=function(){},Wi.prototype.upload=function(){},Wi.prototype.destroy=function(){},Wi.prototype.setConstantPatternPositions=function(t,e){this.patternPositions.patternTo=t.tlbr,this.patternPositions.patternFrom=e.tlbr},Wi.prototype.setUniforms=function(t,e,r,n,i){var a=this.patternPositions;"u_pattern_to"===i&&a.patternTo&&e.set(a.patternTo),"u_pattern_from"===i&&a.patternFrom&&e.set(a.patternFrom)},Wi.prototype.getBinding=function(t,e){return new Yi(t,e)};var Zi=function(t,e,r,n){this.expression=t,this.names=e,this.type=r,this.uniformNames=this.names.map((function(t){return"a_"+t})),this.maxValue=-1/0,this.paintVertexAttributes=e.map((function(t){return{name:"a_"+t,type:"Float32",components:"color"===r?2:1,offset:0}})),this.paintVertexArray=new n};Zi.prototype.defines=function(){return[]},Zi.prototype.setConstantPatternPositions=function(){},Zi.prototype.populatePaintArray=function(t,e,r,n){var i=this.paintVertexArray,a=i.length;i.reserve(t);var o=this.expression.evaluate(new En(0),e,{},n);if("color"===this.type)for(var s=Gi(o),l=a;lra.max||o.yra.max)&&(w("Geometry exceeds allowed extent, reduce your vector tile buffer size"),o.x=c(o.x,ra.min,ra.max),o.y=c(o.y,ra.min,ra.max))}return r}function ia(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}var aa=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Qn,this.indexArray=new di,this.segments=new Di,this.programConfigurations=new Qi(Ei,t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function oa(t,e){for(var r=0;r1){if(ua(t,e))return!0;for(var n=0;n1?t.distSqr(r):t.distSqr(r.sub(e)._mult(i)._add(e))}function da(t,e){for(var r,n,i,a=!1,o=0;oe.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);return a}function ga(t,e){for(var r=!1,n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function ma(t,e,r){var n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;var a=A(t,e,r[0]);return a!==A(t,e,r[1])||a!==A(t,e,r[2])||a!==A(t,e,r[3])}function va(t,e,r){var n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).binders[t].maxValue}function ya(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function xa(t,e,r,n,a){if(!e[0]&&!e[1])return t;var o=i.convert(e)._mult(a);"viewport"===r&&o._rotate(-n);for(var s=[],l=0;l=ea||c<0||c>=ea)){var u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),h=u.vertexLength;ia(this.layoutVertexArray,l,c,-1,-1),ia(this.layoutVertexArray,l,c,1,-1),ia(this.layoutVertexArray,l,c,1,1),ia(this.layoutVertexArray,l,c,-1,1),this.indexArray.emplaceBack(h,h+1,h+2),this.indexArray.emplaceBack(h,h+3,h+2),u.vertexLength+=4,u.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{})},dn("CircleBucket",aa,{omit:["layers"]});var ba,_a=new Gn({"circle-sort-key":new Yn(Ct.layout_circle["circle-sort-key"])}),wa={paint:new Gn({"circle-radius":new Yn(Ct.paint_circle["circle-radius"]),"circle-color":new Yn(Ct.paint_circle["circle-color"]),"circle-blur":new Yn(Ct.paint_circle["circle-blur"]),"circle-opacity":new Yn(Ct.paint_circle["circle-opacity"]),"circle-translate":new Bn(Ct.paint_circle["circle-translate"]),"circle-translate-anchor":new Bn(Ct.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Bn(Ct.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Bn(Ct.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Yn(Ct.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Yn(Ct.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Yn(Ct.paint_circle["circle-stroke-opacity"])}),layout:_a},Aa="undefined"!=typeof Float32Array?Float32Array:Array;function Ca(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}Math.hypot||(Math.hypot=function(){for(var t=arguments,e=0,r=arguments.length;r--;)e+=t[r]*t[r];return Math.sqrt(e)}),ba=new Aa(3),Aa!=Float32Array&&(ba[0]=0,ba[1]=0,ba[2]=0),function(){var t=new Aa(4);Aa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var Ma=function(t){function e(e){t.call(this,e,wa)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createBucket=function(t){return new aa(t)},e.prototype.queryRadius=function(t){var e=t;return va("circle-radius",this,e)+va("circle-stroke-width",this,e)+ya(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,i,a,o,s){for(var l=xa(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,o),c=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),u="map"===this.paint.get("circle-pitch-alignment"),h=u?l:function(t,e){return t.map((function(t){return ka(t,e)}))}(l,s),f=u?c*o:c,p=0,d=n;pt.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,l=0;l80*r){n=a=t[0],i=o=t[1];for(var d=r;da&&(a=s),l>o&&(o=l);c=0!==(c=Math.max(a-n,o-i))?1/c:0}return Ha(f,p,r,n,i,c),p}function Va(t,e,r,n,i){var a,o;if(i===fo(t,e,r,n)>0)for(a=e;a=e;a-=n)o=co(a,t[a],t[a+1],o);return o&&no(o,o.next)&&(uo(o),o=o.next),o}function Ua(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!no(n,n.next)&&0!==ro(n.prev,n,n.next))n=n.next;else{if(uo(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function Ha(t,e,r,n,i,a,o){if(t){!o&&a&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=Qa(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,a,o,s,l,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,c*=2}while(o>1)}(i)}(t,n,i,a);for(var s,l,c=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?qa(t,n,i,a):Ga(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),uo(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?Ha(t=Wa(Ua(t),e,r),e,r,n,i,a,2):2===o&&Za(t,e,r,n,i,a):Ha(Ua(t),e,r,n,i,a,1);break}}}function Ga(t){var e=t.prev,r=t,n=t.next;if(ro(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(to(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&ro(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function qa(t,e,r,n){var i=t.prev,a=t,o=t.next;if(ro(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Qa(s,l,e,r,n),f=Qa(c,u,e,r,n),p=t.prevZ,d=t.nextZ;p&&p.z>=h&&d&&d.z<=f;){if(p!==t.prev&&p!==t.next&&to(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ro(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&to(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&ro(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&to(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&ro(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=f;){if(d!==t.prev&&d!==t.next&&to(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&ro(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Wa(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!no(i,a)&&io(i,n,n.next,a)&&so(i,a)&&so(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),uo(n),uo(n.next),n=t=a),n=n.next}while(n!==t);return Ua(n)}function Za(t,e,r,n,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&eo(o,s)){var l=lo(o,s);return o=Ua(o,o.next),l=Ua(l,l.next),Ha(o,e,r,n,i,a),void Ha(l,e,r,n,i,a)}s=s.next}o=o.next}while(o!==t)}function Xa(t,e){return t.x-e.x}function Ja(t,e){if(e=function(t,e){var r,n=e,i=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=u&&i!==n.x&&to(ar.x||n.x===r.x&&Ka(r,n)))&&(r=n,f=l)),n=n.next}while(n!==c);return r}(t,e)){var r=lo(e,t);Ua(r,r.next)}}function Ka(t,e){return ro(t.prev,t,e.prev)<0&&ro(e.next,t,t.next)<0}function Qa(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function $a(t){var e=t,r=t;do{(e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function eo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&io(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(so(t,e)&&so(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(ro(t.prev,t,e.prev)||ro(t,e.prev,e))||no(t,e)&&ro(t.prev,t,t.next)>0&&ro(e.prev,e,e.next)>0)}function ro(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function no(t,e){return t.x===e.x&&t.y===e.y}function io(t,e,r,n){var i=oo(ro(t,e,r)),a=oo(ro(t,e,n)),o=oo(ro(r,n,t)),s=oo(ro(r,n,e));return i!==a&&o!==s||!(0!==i||!ao(t,r,e))||!(0!==a||!ao(t,n,e))||!(0!==o||!ao(r,t,n))||!(0!==s||!ao(r,e,n))}function ao(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function oo(t){return t>0?1:t<0?-1:0}function so(t,e){return ro(t.prev,t,t.next)<0?ro(t,e,t.next)>=0&&ro(t,t.prev,e)>=0:ro(t,e,t.prev)<0||ro(t,t.next,e)<0}function lo(t,e){var r=new ho(t.i,t.x,t.y),n=new ho(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function co(t,e,r,n){var i=new ho(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function uo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ho(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function fo(t,e,r,n){for(var i=0,a=e,o=r-n;an;){if(i-n>600){var o=i-n+1,s=r-n+1,l=Math.log(o),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);t(e,r,Math.max(n,Math.floor(r-s*c/o+u)),Math.min(i,Math.floor(r+(o-s)*c/o+u)),a)}var h=e[r],f=n,p=i;for(go(e,n,r),a(e[i],h)>0&&go(e,n,i);f0;)p--}0===a(e[n],h)?go(e,n,p):go(e,++p,i),p<=r&&(n=p+1),r<=p&&(i=p-1)}}(t,e,r||0,n||t.length-1,i||mo)}function go(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function mo(t,e){return te?1:0}function vo(t,e){var r=t.length;if(r<=1)return[t];for(var n,i,a=[],o=0;o1)for(var l=0;l0&&(n+=t[i-1].length,r.holes.push(n))}return r},ja.default=Ba;var _o=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Qn,this.indexArray=new di,this.indexArray2=new gi,this.programConfigurations=new Qi(Na,t.layers,t.zoom),this.segments=new Di,this.segments2=new Di,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};_o.prototype.populate=function(t,e){this.hasPattern=xo("fill",this.layers,e);for(var r=this.layers[0].layout.get("fill-sort-key"),n=[],i=0,a=t;i>3}if(a--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&l.push(e),e=[]),e.push(new i(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&l.push(e),l},Io.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())s&&(s=i),(a+=t.readSVarint())c&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,c]},Io.prototype.toGeoJSON=function(t,e,r){var n,i,a=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=Io.types[this.type];function u(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}function Po(t,e,r){if(3===t){var n=new So(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}Eo.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ko(this._pbf,e,this.extent,this._keys,this._values)};var Oo={VectorTile:function(t,e){this.layers=t.readFields(Po,{},e)},VectorTileFeature:ko,VectorTileLayer:So},zo=Oo.VectorTileFeature.types,Ro=Math.pow(2,13);function Fo(t,e,r,n,i,a,o,s){t.emplaceBack(e,r,2*Math.floor(n*Ro)+o,i*Ro*2,a*Ro*2,Math.round(s))}var No=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ti,this.indexArray=new di,this.programConfigurations=new Qi(Mo,t.layers,t.zoom),this.segments=new Di,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function jo(t,e){return t.x===e.x&&(t.x<0||t.x>ea)||t.y===e.y&&(t.y<0||t.y>ea)}function Bo(t){return t.every((function(t){return t.x<0}))||t.every((function(t){return t.x>ea}))||t.every((function(t){return t.y<0}))||t.every((function(t){return t.y>ea}))}No.prototype.populate=function(t,e){this.features=[],this.hasPattern=xo("fill-extrusion",this.layers,e);for(var r=0,n=t;r=1){var v=p[g-1];if(!jo(m,v)){u.vertexLength+4>Di.MAX_VERTEX_ARRAY_LENGTH&&(u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var y=m.sub(v)._perp()._unit(),x=v.dist(m);d+x>32768&&(d=0),Fo(this.layoutVertexArray,m.x,m.y,y.x,y.y,0,0,d),Fo(this.layoutVertexArray,m.x,m.y,y.x,y.y,0,1,d),d+=x,Fo(this.layoutVertexArray,v.x,v.y,y.x,y.y,0,0,d),Fo(this.layoutVertexArray,v.x,v.y,y.x,y.y,0,1,d);var b=u.vertexLength;this.indexArray.emplaceBack(b,b+2,b+1),this.indexArray.emplaceBack(b+1,b+2,b+3),u.vertexLength+=4,u.primitiveLength+=2}}}}if(u.vertexLength+s>Di.MAX_VERTEX_ARRAY_LENGTH&&(u=this.segments.prepareSegment(s,this.layoutVertexArray,this.indexArray)),"Polygon"===zo[t.type]){for(var _=[],w=[],A=u.vertexLength,C=0,M=o;C=2&&t[u-1].equals(t[u-2]);)u--;for(var h=0;h0;if(M&&x>h){var I=f.dist(g);if(I>2*p){var T=f.sub(f.sub(g)._mult(p/I)._round());this.updateDistance(g,T),this.addCurrentVertex(T,v,0,0,d),g=T}}var L=g&&m,S=L?r:c?"butt":n;if(L&&"round"===S&&(Ai&&(S="bevel"),"bevel"===S&&(A>2&&(S="flipbevel"),A100)b=y.mult(-1);else{var E=A*v.add(y).mag()/v.sub(y).mag();b._perp()._mult(E*(k?-1:1))}this.addCurrentVertex(f,b,0,0,d),this.addCurrentVertex(f,b.mult(-1),0,0,d)}else if("bevel"===S||"fakeround"===S){var D=-Math.sqrt(A*A-1),P=k?D:0,O=k?0:D;if(g&&this.addCurrentVertex(f,v,P,O,d),"fakeround"===S)for(var z=Math.round(180*C/Math.PI/20),R=1;R2*p){var V=f.add(m.sub(f)._mult(p/Y)._round());this.updateDistance(f,V),this.addCurrentVertex(V,y,0,0,d),f=V}}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,s)}},Xo.prototype.addCurrentVertex=function(t,e,r,n,i,a){void 0===a&&(a=!1);var o=e.x+e.y*r,s=e.y-e.x*r,l=-e.x+e.y*n,c=-e.y-e.x*n;this.addHalfVertex(t,o,s,a,!1,r,i),this.addHalfVertex(t,l,c,a,!0,-n,i),this.distance>Zo/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,r,n,i,a))},Xo.prototype.addHalfVertex=function(t,e,r,n,i,a,o){var s=t.x,l=t.y,c=.5*this.scaledDistance;this.layoutVertexArray.emplaceBack((s<<1)+(n?1:0),(l<<1)+(i?1:0),Math.round(63*e)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&c)<<2,c>>6);var u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),i?this.e2=u:this.e1=u},Xo.prototype.updateDistance=function(t,e){this.distance+=t.dist(e),this.scaledDistance=this.totalDistance>0?(this.clipStart+(this.clipEnd-this.clipStart)*this.distance/this.totalDistance)*(Zo-1):this.distance},dn("LineBucket",Xo,{omit:["layers","patternFeatures"]});var Jo=new Gn({"line-cap":new Bn(Ct.layout_line["line-cap"]),"line-join":new Yn(Ct.layout_line["line-join"]),"line-miter-limit":new Bn(Ct.layout_line["line-miter-limit"]),"line-round-limit":new Bn(Ct.layout_line["line-round-limit"]),"line-sort-key":new Yn(Ct.layout_line["line-sort-key"])}),Ko={paint:new Gn({"line-opacity":new Yn(Ct.paint_line["line-opacity"]),"line-color":new Yn(Ct.paint_line["line-color"]),"line-translate":new Bn(Ct.paint_line["line-translate"]),"line-translate-anchor":new Bn(Ct.paint_line["line-translate-anchor"]),"line-width":new Yn(Ct.paint_line["line-width"]),"line-gap-width":new Yn(Ct.paint_line["line-gap-width"]),"line-offset":new Yn(Ct.paint_line["line-offset"]),"line-blur":new Yn(Ct.paint_line["line-blur"]),"line-dasharray":new Un(Ct.paint_line["line-dasharray"]),"line-pattern":new Vn(Ct.paint_line["line-pattern"]),"line-gradient":new Hn(Ct.paint_line["line-gradient"])}),layout:Jo},Qo=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.possiblyEvaluate=function(e,r){return r=new En(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),t.prototype.possiblyEvaluate.call(this,e,r)},e.prototype.evaluate=function(e,r,n,i){return r=h({},r,{zoom:Math.floor(r.zoom)}),t.prototype.evaluate.call(this,e,r,n,i)},e}(Yn))(Ko.paint.properties["line-width"].specification);Qo.useIntegerZoom=!0;var $o=function(t){function e(e){t.call(this,e,Ko)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._handleSpecialPaintPropertyUpdate=function(t){"line-gradient"===t&&this._updateGradient()},e.prototype._updateGradient=function(){var t=this._transitionablePaint._values["line-gradient"].value.expression;this.gradient=Oa(t,"lineProgress"),this.gradientTexture=null},e.prototype.recalculate=function(e){t.prototype.recalculate.call(this,e),this.paint._values["line-floorwidth"]=Qo.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new Xo(t)},e.prototype.queryRadius=function(t){var e=t,r=ts(va("line-width",this,e),va("line-gap-width",this,e)),n=va("line-offset",this,e);return r/2+Math.abs(n)+ya(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,r,n,a,o,s){var l=xa(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,s),c=s/2*ts(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){for(var r=[],n=new i(0,0),a=0;a=3)for(var a=0;a0?e+2*t:t}var es=Jn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"}]),rs=Jn([{name:"a_projected_pos",components:3,type:"Float32"}],4),ns=(Jn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Jn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}])),is=(Jn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},{type:"Int16",name:"radius"},{type:"Int16",name:"signedDistanceFromAnchor"}]),Jn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),as=Jn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function os(t,e,r){return t.sections.forEach((function(t){t.text=function(t,e,r){var n=e.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Sn.applyArabicShaping&&(t=Sn.applyArabicShaping(t)),t}(t.text,e,r)})),t}Jn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"}]),Jn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"radialTextOffset"}]),Jn([{type:"Float32",name:"offsetX"}]),Jn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var ss={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},ls=24,cs={horizontal:1,vertical:2,horizontalOnly:3},us=function(){this.text="",this.sectionIndex=[],this.sections=[]};function hs(t,e,r,n,i,a,o,s,l,c,u){var h,f=us.fromFeature(t,r);c===cs.vertical&&f.verticalizePunctuation();var p=Sn.processBidirectionalText,d=Sn.processStyledBidirectionalText;if(p&&1===f.sections.length){h=[];for(var g=0,m=p(f.toString(),vs(f,s,n,e));g=0&&n>=t&&fs[this.text.charCodeAt(n)];n--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)},us.prototype.substring=function(t,e){var r=new us;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r},us.prototype.toString=function(){return this.text},us.prototype.getMaxScale=function(){var t=this;return this.sectionIndex.reduce((function(e,r){return Math.max(e,t.sections[r].scale)}),0)};var fs={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},ps={};function ds(t,e,r,n){var i=Math.pow(t-e,2);return n?t=0,l=0,c=0;c0)&&("constant"!==i.value.kind||i.value.value.length>0),l="constant"!==o.value.kind||o.value.value&&o.value.value.length>0,c=n.get("symbol-sort-key");if(this.features=[],s||l){for(var u=e.iconDependencies,h=e.glyphDependencies,f=new En(this.zoom),p=0,d=t;p=0;for(var k=0,I=x.sections;k=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0;this.addCollisionDebugVertices(a,o,s,l,c?this.collisionCircle:this.collisionBox,i.anchorPoint,r,c)}},Ds.prototype.generateCollisionDebugBuffers=function(){for(var t=0;t0},Ds.prototype.hasIconData=function(){return this.icon.segments.get().length>0},Ds.prototype.hasCollisionBoxData=function(){return this.collisionBox.segments.get().length>0},Ds.prototype.hasCollisionCircleData=function(){return this.collisionCircle.segments.get().length>0},Ds.prototype.addIndicesForPlacedTextSymbol=function(t){for(var e=this.text.placedSymbolArray.get(t),r=e.vertexStartIndex+4*e.numGlyphs,n=e.vertexStartIndex;n1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(var r=0,n=this.symbolInstanceIndexes;r=0&&n.indexOf(t)===r&&e.addIndicesForPlacedTextSymbol(t)})),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedTextSymbol(a.verticalPlacedTextSymbolIndex);var o=this.icon.placedSymbolArray.get(i);if(o.numGlyphs){var s=o.vertexStartIndex;this.icon.indexArray.emplaceBack(s,s+1,s+2),this.icon.indexArray.emplaceBack(s+1,s+2,s+3)}}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}},dn("SymbolBucket",Ds,{omit:["layers","collisionBoxArray","features","compareText"]}),Ds.MAX_GLYPHS=65535,Ds.addDynamicAttributes=Ls;var Ps=new Gn({"symbol-placement":new Bn(Ct.layout_symbol["symbol-placement"]),"symbol-spacing":new Bn(Ct.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Bn(Ct.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Yn(Ct.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Bn(Ct.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Bn(Ct.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Bn(Ct.layout_symbol["icon-ignore-placement"]),"icon-optional":new Bn(Ct.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Bn(Ct.layout_symbol["icon-rotation-alignment"]),"icon-size":new Yn(Ct.layout_symbol["icon-size"]),"icon-text-fit":new Bn(Ct.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Bn(Ct.layout_symbol["icon-text-fit-padding"]),"icon-image":new Yn(Ct.layout_symbol["icon-image"]),"icon-rotate":new Yn(Ct.layout_symbol["icon-rotate"]),"icon-padding":new Bn(Ct.layout_symbol["icon-padding"]),"icon-keep-upright":new Bn(Ct.layout_symbol["icon-keep-upright"]),"icon-offset":new Yn(Ct.layout_symbol["icon-offset"]),"icon-anchor":new Yn(Ct.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Bn(Ct.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Bn(Ct.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Bn(Ct.layout_symbol["text-rotation-alignment"]),"text-field":new Yn(Ct.layout_symbol["text-field"]),"text-font":new Yn(Ct.layout_symbol["text-font"]),"text-size":new Yn(Ct.layout_symbol["text-size"]),"text-max-width":new Yn(Ct.layout_symbol["text-max-width"]),"text-line-height":new Bn(Ct.layout_symbol["text-line-height"]),"text-letter-spacing":new Yn(Ct.layout_symbol["text-letter-spacing"]),"text-justify":new Yn(Ct.layout_symbol["text-justify"]),"text-radial-offset":new Yn(Ct.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Bn(Ct.layout_symbol["text-variable-anchor"]),"text-anchor":new Yn(Ct.layout_symbol["text-anchor"]),"text-max-angle":new Bn(Ct.layout_symbol["text-max-angle"]),"text-writing-mode":new Bn(Ct.layout_symbol["text-writing-mode"]),"text-rotate":new Yn(Ct.layout_symbol["text-rotate"]),"text-padding":new Bn(Ct.layout_symbol["text-padding"]),"text-keep-upright":new Bn(Ct.layout_symbol["text-keep-upright"]),"text-transform":new Yn(Ct.layout_symbol["text-transform"]),"text-offset":new Yn(Ct.layout_symbol["text-offset"]),"text-allow-overlap":new Bn(Ct.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Bn(Ct.layout_symbol["text-ignore-placement"]),"text-optional":new Bn(Ct.layout_symbol["text-optional"])}),Os={paint:new Gn({"icon-opacity":new Yn(Ct.paint_symbol["icon-opacity"]),"icon-color":new Yn(Ct.paint_symbol["icon-color"]),"icon-halo-color":new Yn(Ct.paint_symbol["icon-halo-color"]),"icon-halo-width":new Yn(Ct.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Yn(Ct.paint_symbol["icon-halo-blur"]),"icon-translate":new Bn(Ct.paint_symbol["icon-translate"]),"icon-translate-anchor":new Bn(Ct.paint_symbol["icon-translate-anchor"]),"text-opacity":new Yn(Ct.paint_symbol["text-opacity"]),"text-color":new Yn(Ct.paint_symbol["text-color"],{runtimeType:Ft,getOverride:function(t){return t.textColor},hasOverride:function(t){return!!t.textColor}}),"text-halo-color":new Yn(Ct.paint_symbol["text-halo-color"]),"text-halo-width":new Yn(Ct.paint_symbol["text-halo-width"]),"text-halo-blur":new Yn(Ct.paint_symbol["text-halo-blur"]),"text-translate":new Bn(Ct.paint_symbol["text-translate"]),"text-translate-anchor":new Bn(Ct.paint_symbol["text-translate-anchor"])}),layout:Ps},zs=function(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Pt,this.defaultValue=t};zs.prototype.evaluate=function(t){if(t.formattedSection){var e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default},zs.prototype.eachChild=function(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)},zs.prototype.possibleOutputs=function(){return[void 0]},zs.prototype.serialize=function(){return null},dn("FormatSectionOverride",zs,{omit:["defaultValue"]});var Rs=function(t){function e(e){t.call(this,e,Os)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.recalculate=function(e){if(t.prototype.recalculate.call(this,e),"auto"===this.layout.get("icon-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["icon-rotation-alignment"]="map":this.layout._values["icon-rotation-alignment"]="viewport"),"auto"===this.layout.get("text-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="map":this.layout._values["text-rotation-alignment"]="viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){var r=this.layout.get("text-writing-mode");if(r){for(var n=[],i=0,a=r;i=0;f--){var p=o[f];if(!(h.w>p.w||h.h>p.h)){if(h.x=p.x,h.y=p.y,l=Math.max(l,h.y+h.h),s=Math.max(s,h.x+h.w),h.w===p.w&&h.h===p.h){var d=o.pop();f>1,u=-7,h=r?i-1:0,f=r?-1:1,p=t[e+h];for(h+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=256*a+t[e+h],h+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+h],h+=f,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),a-=c}return(p?-1:1)*o*Math.pow(2,a-n)},$s=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=u?(s=0,o=u):o+h>=1?(s=(e*l-1)*Math.pow(2,i),o+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,c-=8);t[r+p-d]|=128*g},tl=el;function el(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function rl(t){return t.type===el.Bytes?t.readVarint()+t.pos:t.pos+1}function nl(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function il(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function al(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function ml(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}el.Varint=0,el.Fixed64=1,el.Bytes=2,el.Fixed32=5,el.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=dl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=ml(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=dl(this.buf,this.pos)+4294967296*dl(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=dl(this.buf,this.pos)+4294967296*ml(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=Qs(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Qs(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return nl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return nl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return nl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return nl(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return nl(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return nl(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(a=t[i+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===u?(a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),i+=u}return n}(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==el.Bytes)return t.push(this.readVarint(e));var r=rl(this);for(t=t||[];this.pos127;);else if(e===el.Bytes)this.pos=this.readVarint()+this.pos;else if(e===el.Fixed32)this.pos+=4;else{if(e!==el.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&il(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),$s(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),$s(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&il(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,el.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,al,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,ol,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,cl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,sl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,ll,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ul,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,hl,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,fl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,pl,e)},writeBytesField:function(t,e){this.writeTag(t,el.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,el.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,el.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,el.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,el.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,el.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,el.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,el.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,el.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,el.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var vl=3;function yl(t,e,r){1===t&&r.readMessage(xl,e)}function xl(t,e,r){if(3===t){var n=r.readMessage(bl,{}),i=n.id,a=n.bitmap,o=n.width,s=n.height,l=n.left,c=n.top,u=n.advance;e.push({id:i,bitmap:new Ea({width:o+2*vl,height:s+2*vl},a),metrics:{width:o,height:s,left:l,top:c,advance:u}})}}function bl(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint())}var _l=vl,wl=function(t){var e=this;this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=function(){e._triggered=!1,e._callback()})};wl.prototype.trigger=function(){var t=this;this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((function(){t._triggered=!1,t._callback()}),0))};var Al=function(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},m(["receive","process"],this),this.invoker=new wl(this.process),this.target.addEventListener("message",this.receive,!1)};function Cl(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}Al.prototype.send=function(t,e,r,n){var i=this,a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[a]=r);var o=[];return this.target.postMessage({id:a,type:t,hasCallback:!!r,targetMapId:n,sourceMapId:this.mapId,data:mn(e,o)},o),{cancel:function(){r&&delete i.callbacks[a],i.target.postMessage({id:a,type:"",targetMapId:n,sourceMapId:i.mapId})}}},Al.prototype.receive=function(t){var e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[r];var n=this.cancelCallbacks[r];delete this.cancelCallbacks[r],n&&n()}else this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()},Al.prototype.process=function(){var t=this;if(this.taskQueue.length){var e=this.taskQueue.shift(),r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),r)if(""===r.type){var n=this.callbacks[e];delete this.callbacks[e],n&&(r.error?n(vn(r.error)):n(null,vn(r.data)))}else{var i=!1,a=r.hasCallback?function(r,n){i=!0,delete t.cancelCallbacks[e];var a=[];t.target.postMessage({id:e,type:"",sourceMapId:t.mapId,error:r?mn(r):null,data:mn(n,a)},a)}:function(t){i=!0},o=null,s=vn(r.data);if(this.parent[r.type])o=this.parent[r.type](r.sourceMapId,s,a);else if(this.parent.getWorkerSource){var l=r.type.split(".");o=this.parent.getWorkerSource(r.sourceMapId,l[0],s.source)[l[1]](s,a)}else a(new Error("Could not find function "+r.type));!i&&o&&o.cancel&&(this.cancelCallbacks[e]=o.cancel)}}},Al.prototype.remove=function(){this.target.removeEventListener("message",this.receive,!1)};var Ml=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};Ml.prototype.setNorthEast=function(t){return this._ne=t instanceof kl?new kl(t.lng,t.lat):kl.convert(t),this},Ml.prototype.setSouthWest=function(t){return this._sw=t instanceof kl?new kl(t.lng,t.lat):kl.convert(t),this},Ml.prototype.extend=function(t){var e,r,n=this._sw,i=this._ne;if(t instanceof kl)e=t,r=t;else{if(!(t instanceof Ml))return Array.isArray(t)?t.every(Array.isArray)?this.extend(Ml.convert(t)):this.extend(kl.convert(t)):this;if(e=t._sw,r=t._ne,!e||!r)return this}return n||i?(n.lng=Math.min(e.lng,n.lng),n.lat=Math.min(e.lat,n.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new kl(e.lng,e.lat),this._ne=new kl(r.lng,r.lat)),this},Ml.prototype.getCenter=function(){return new kl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},Ml.prototype.getSouthWest=function(){return this._sw},Ml.prototype.getNorthEast=function(){return this._ne},Ml.prototype.getNorthWest=function(){return new kl(this.getWest(),this.getNorth())},Ml.prototype.getSouthEast=function(){return new kl(this.getEast(),this.getSouth())},Ml.prototype.getWest=function(){return this._sw.lng},Ml.prototype.getSouth=function(){return this._sw.lat},Ml.prototype.getEast=function(){return this._ne.lng},Ml.prototype.getNorth=function(){return this._ne.lat},Ml.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},Ml.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},Ml.prototype.isEmpty=function(){return!(this._sw&&this._ne)},Ml.convert=function(t){return!t||t instanceof Ml?t:new Ml(t)};var kl=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};kl.prototype.wrap=function(){return new kl(u(this.lng,-180,180),this.lat)},kl.prototype.toArray=function(){return[this.lng,this.lat]},kl.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},kl.prototype.toBounds=function(t){void 0===t&&(t=0);var e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new Ml(new kl(this.lng-r,this.lat-e),new kl(this.lng+r,this.lat+e))},kl.convert=function(t){if(t instanceof kl)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new kl(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new kl(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")};var Il=2*Math.PI*6378137;function Tl(t){return Il*Math.cos(t*Math.PI/180)}function Ll(t){return(180+t)/360}function Sl(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function El(t,e){return t/Tl(e)}function Dl(t){var e=180-360*t;return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}var Pl=function(t,e,r){void 0===r&&(r=0),this.x=+t,this.y=+e,this.z=+r};Pl.fromLngLat=function(t,e){void 0===e&&(e=0);var r=kl.convert(t);return new Pl(Ll(r.lng),Sl(r.lat),El(e,r.lat))},Pl.prototype.toLngLat=function(){return new kl(360*this.x-180,Dl(this.y))},Pl.prototype.toAltitude=function(){return this.z*Tl(Dl(this.y))},Pl.prototype.meterInMercatorCoordinateUnits=function(){return 1/Il*(t=Dl(this.y),1/Math.cos(t*Math.PI/180));var t};var Ol=function(t,e,r){this.z=t,this.x=e,this.y=r,this.key=Fl(0,t,e,r)};Ol.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Ol.prototype.url=function(t,e){var r,n,i,a,o,s=(r=this.x,n=this.y,i=this.z,a=Cl(256*r,256*(n=Math.pow(2,i)-n-1),i),o=Cl(256*(r+1),256*(n+1),i),a[0]+","+a[1]+","+o[0]+","+o[1]),l=function(t,e,r){for(var n,i="",a=t;a>0;a--)i+=(e&(n=1<this.canonical.z?new Rl(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Rl(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},Rl.prototype.isChildOf=function(t){if(t.wrap!==this.wrap)return!1;var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},Rl.prototype.children=function(t){if(this.overscaledZ>=t)return[new Rl(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new Rl(e,this.wrap,e,r,n),new Rl(e,this.wrap,e,r+1,n),new Rl(e,this.wrap,e,r,n+1),new Rl(e,this.wrap,e,r+1,n+1)]},Rl.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)},Nl.prototype._unpackMapbox=function(t,e,r){return(256*t*256+256*e+r)/10-1e4},Nl.prototype._unpackTerrarium=function(t,e,r){return 256*t+e+r/256-32768},Nl.prototype.getPixels=function(){return new Da({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))},Nl.prototype.backfillBorder=function(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");var n=e*this.dim,i=e*this.dim+this.dim,a=r*this.dim,o=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1}switch(r){case-1:a=o-1;break;case 1:o=a+1}for(var s=-e*this.dim,l=-r*this.dim,c=a;c=0)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][r]=null);else if(void 0!==e&&e>=0)if(this.stateChanges[t]&&this.stateChanges[t][n])for(r in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][r]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}},Ul.prototype.getState=function(t,e){var r=String(e),n=this.state[t]||{},i=this.stateChanges[t]||{},a=h({},n[r],i[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){var o=this.deletedStates[t][e];if(null===o)return{};for(var s in o)delete a[s]}return a},Ul.prototype.initializeTileState=function(t,e){t.setFeatureState(this.state,e)},Ul.prototype.coalesceChanges=function(t,e){var r={};for(var n in this.stateChanges){this.state[n]=this.state[n]||{};var i={};for(var a in this.stateChanges[n])this.state[n][a]||(this.state[n][a]={}),h(this.state[n][a],this.stateChanges[n][a]),i[a]=this.state[n][a];r[n]=i}for(var o in this.deletedStates){this.state[o]=this.state[o]||{};var s={};if(null===this.deletedStates[o])for(var l in this.state[o])s[l]={},this.state[o][l]={};else for(var c in this.deletedStates[o]){if(null===this.deletedStates[o][c])this.state[o][c]={};else for(var u=0,f=Object.keys(this.deletedStates[o][c]);u=0&&u[3]>=0&&s.insert(o,u[0],u[1],u[2],u[3])}},Hl.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new Oo.VectorTile(new tl(this.rawTileData)).layers,this.sourceLayerCoder=new Bl(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},Hl.prototype.query=function(t,e,r){var n=this;this.loadVTLayers();for(var a=t.params||{},o=ea/t.tileSize/t.scale,s=Rr(a.filter),l=t.queryGeometry,c=t.queryPadding*o,u=Gl(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),f=Gl(t.cameraQueryGeometry),p=0,d=this.grid3D.query(f.minX-c,f.minY-c,f.maxX+c,f.maxY+c,(function(e,r,n,a){return function(t,e,r,n,a){for(var o=0,s=t;o=l.x&&a>=l.y)return!0}var c=[new i(e,r),new i(e,a),new i(n,a),new i(n,r)];if(t.length>2)for(var u=0,h=c;u=0)return!0;return!1}(a,l)){var c=this.sourceLayerCoder.decode(r),u=this.vtLayers[c].feature(n);if(i(new En(this.tileID.overscaledZ),u))for(var h=0;h-r/2;){if(--o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;for(var l=[],c=0;sn;)c-=l.shift().angleDelta;if(c>i)return!1;o++,s+=h.dist(f)}return!0}function Xl(t){for(var e=0,r=0;rc){var d=(c-l)/p,g=ye(h.x,f.x,d),m=ye(h.y,f.y,d),v=new bs(g,m,f.angleTo(h),u);return v._round(),!o||Zl(t,v,s,o,e)?v:void 0}l+=p}}function $l(t,e,r,n,i,a,o,s,l){var c=Jl(n,a,o),u=Kl(n,i),h=u*o,f=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&_=0&&w=0&&p+u<=h){var A=new bs(_,w,x,g);A._round(),i&&!Zl(e,A,o,i,a)||d.push(A)}}f+=y}return l||d.length||s||(d=t(e,f/2,n,i,a,o,s,!0,c)),d}(t,f?e/2*s%e:(u/2+2*a)*o*s%e,e,c,r,h,f,!1,l)}Wl.prototype.registerFadeDuration=function(t){var e=t+this.timeAdded;e>l.z,u=new i(l.x*c,l.y*c),h=new i(u.x+c,u.y+c),f=this.segments.prepareSegment(4,r,n);r.emplaceBack(u.x,u.y,u.x,u.y),r.emplaceBack(h.x,u.y,h.x,u.y),r.emplaceBack(u.x,h.y,u.x,h.y),r.emplaceBack(h.x,h.y,h.x,h.y);var p=f.vertexLength;n.emplaceBack(p,p+1,p+2),n.emplaceBack(p+1,p+2,p+3),f.vertexLength+=4,f.primitiveLength+=2}this.maskedBoundsBuffer=e.createVertexBuffer(r,jl.members),this.maskedIndexBuffer=e.createIndexBuffer(n)}},Wl.prototype.hasData=function(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state},Wl.prototype.patternsLoaded=function(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length},Wl.prototype.setExpiryData=function(t){var e=this.expirationTime;if(t.cacheControl){var r=M(t.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){var n=Date.now(),i=!1;if(this.expirationTime>n)i=!1;else if(e)if(this.expirationTime0&&(v=Math.max(10*l,v),this._addLineCollisionCircles(t,e,r,r.segment,y,v,n,a,o,h))}else{if(f){var x=new i(g,p),b=new i(m,p),_=new i(g,d),w=new i(m,d),A=f*Math.PI/180;x._rotate(A),b._rotate(A),_._rotate(A),w._rotate(A),g=Math.min(x.x,b.x,_.x,w.x),m=Math.max(x.x,b.x,_.x,w.x),p=Math.min(x.y,b.y,_.y,w.y),d=Math.max(x.y,b.y,_.y,w.y)}t.emplaceBack(r.x,r.y,g,p,m,d,n,a,o,0,0)}this.boxEndIndex=t.length};tc.prototype._addLineCollisionCircles=function(t,e,r,n,i,a,o,s,l,c){var u=a/2,h=Math.floor(i/u)||1,f=1+.4*Math.log(c)/Math.LN2,p=Math.floor(h*f/2),d=-a/2,g=r,m=n+1,v=d,y=-i/2,x=y-i/4;do{if(--m<0){if(v>y)return;m=0;break}v-=e[m].dist(g),g=e[m]}while(v>x);for(var b=e[m].dist(e[m+1]),_=-p;_i&&(A+=w-i),!(A=e.length)return;b=e[m].dist(e[m+1])}var C=A-v,M=e[m],k=e[m+1].sub(M)._unit()._mult(C)._add(M)._round(),I=Math.abs(A-d)0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)};function rc(t,e){return te?1:0}function nc(t,e,r){void 0===e&&(e=1),void 0===r&&(r=!1);for(var n=1/0,a=1/0,o=-1/0,s=-1/0,l=t[0],c=0;co)&&(o=u.x),(!c||u.y>s)&&(s=u.y)}var h=o-n,f=s-a,p=Math.min(h,f),d=p/2,g=new ec([],ic);if(0===p)return new i(n,a);for(var m=n;my.d||!y.d)&&(y=b,r&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,x)),b.max-y.d<=e||(d=b.h/2,g.push(new ac(b.p.x-d,b.p.y-d,d,t)),g.push(new ac(b.p.x+d,b.p.y-d,d,t)),g.push(new ac(b.p.x-d,b.p.y+d,d,t)),g.push(new ac(b.p.x+d,b.p.y+d,d,t)),x+=4)}return r&&(console.log("num probes: "+x),console.log("best distance: "+y.d)),y.p}function ic(t,e){return e.max-t.max}function ac(t,e,r,n){this.p=new i(t,e),this.h=r,this.d=function(t,e){for(var r=!1,n=1/0,i=0;it.y!=u.y>t.y&&t.x<(u.x-c.x)*(t.y-c.y)/(u.y-c.y)+c.x&&(r=!r),n=Math.min(n,pa(t,c,u))}return(r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}ec.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},ec.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},ec.prototype.peek=function(){return this.data[0]},ec.prototype._up=function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i}e[t]=n},ec.prototype._down=function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t=0)break;e[t]=o,t=a}e[t]=i};var oc=e((function(t){t.exports=function(t,e){var r,n,i,a,o,s,l,c;for(r=3&t.length,n=t.length-r,i=e,o=3432918353,s=461845907,c=0;c>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}})),sc=e((function(t){t.exports=function(t,e){for(var r,n=t.length,i=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++a;switch(n){case 3:i^=(255&t.charCodeAt(a+2))<<16;case 2:i^=(255&t.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}})),lc=oc,cc=oc,uc=sc;lc.murmur3=cc,lc.murmur2=uc;var hc=7;function fc(t,e){var r=0,n=0,i=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":n=i-hc;break;case"bottom-right":case"bottom-left":n=-i+hc;break;case"bottom":n=-e+hc;break;case"top":n=e-hc}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e}return[r,n]}function pc(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}var dc=65535;function gc(t,e,r,n,a,o,s,l,c,u,h,f,p){var d=function(t,e,r,n,a,o,s,l){for(var c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=e.positionedGlyphs,h=[],f=0;fdc&&w(t.layerIds[0]+': Value for "text-size" is >= 256. Reduce your "text-size".'):"composite"===g.kind&&((m=[_s*p.compositeTextSizes[0].evaluate(o,{}),_s*p.compositeTextSizes[1].evaluate(o,{})])[0]>dc||m[1]>dc)&&w(t.layerIds[0]+': Value for "text-size" is >= 256. Reduce your "text-size".'),t.addSymbols(t.text,d,m,s,a,o,c,e,l.lineStartIndex,l.lineLength);for(var v=0,y=u;v=0;o--)if(n.dist(a[o])it&&(t.getActor().send("enforceCacheSizeLimit",nt),st=0)},t.clamp=c,t.clearTileCache=function(t){var e=self.caches.delete(rt);t&&e.catch(t).then((function(){return t()}))},t.clone=function(t){var e=new Aa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=b,t.config=z,t.create=function(){var t=new Aa(16);return Aa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=function(){var t=new Aa(9);return Aa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},t.create$2=function(){var t=new Aa(4);return Aa!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},t.createCommonjsModule=e,t.createExpression=Ar,t.createLayout=Jn,t.createStyleLayer=function(t){return"custom"===t.type?new Ys(t):new Vs[t.type](t)},t.deepEqual=o,t.ease=l,t.emitValidationErrors=ln,t.endsWith=v,t.enforceCacheSizeLimit=function(t){self.caches&&self.caches.open(rt).then((function(e){e.keys().then((function(r){for(var n=0;n=ea||c.y<0||c.y>=ea||function(t,e,r,n,a,o,s,l,c,u,h,f,p,d,g,m,v,y,x,b,_){var A,C,M,k=t.addToLineVertexArray(e,r),I=0,T=0,L=0,S={},E=lc(""),D=(o.layout.get("text-radial-offset").evaluate(x,{})||0)*ls;if(t.allowVerticalPlacement&&n.vertical){var P=o.layout.get("text-rotate").evaluate(x,{})+90,O=n.vertical;M=new tc(s,r,e,l,c,u,O,h,f,p,t.overscaling,P)}for(var z in n.horizontal){var R=n.horizontal[z];if(!A){E=lc(R.text);var F=o.layout.get("text-rotate").evaluate(x,{});A=new tc(s,r,e,l,c,u,R,h,f,p,t.overscaling,F)}var N=1===R.lineCount;if(T+=gc(t,e,R,o,p,x,d,k,n.vertical?cs.horizontal:cs.horizontalOnly,N?Object.keys(n.horizontal):[z],S,b,_),N)break}n.vertical&&(L+=gc(t,e,n.vertical,o,p,x,d,k,cs.vertical,["vertical"],S,b,_));var j=A?A.boxStartIndex:t.collisionBoxArray.length,B=A?A.boxEndIndex:t.collisionBoxArray.length,Y=M?M.boxStartIndex:t.collisionBoxArray.length,V=M?M.boxEndIndex:t.collisionBoxArray.length;if(a){var U=function(t,e,r,n,a,o){var s,l,c,u,h=e.image,f=r.layout,p=e.top-1/h.pixelRatio,d=e.left-1/h.pixelRatio,g=e.bottom+1/h.pixelRatio,m=e.right+1/h.pixelRatio;if("none"!==f.get("icon-text-fit")&&a){var v=m-d,y=g-p,x=f.get("text-size").evaluate(o,{})/24,b=a.left*x,_=a.right*x,w=a.top*x,A=_-b,C=a.bottom*x-w,M=f.get("icon-text-fit-padding")[0],k=f.get("icon-text-fit-padding")[1],I=f.get("icon-text-fit-padding")[2],T=f.get("icon-text-fit-padding")[3],L="width"===f.get("icon-text-fit")?.5*(C-y):0,S="height"===f.get("icon-text-fit")?.5*(A-v):0,E="width"===f.get("icon-text-fit")||"both"===f.get("icon-text-fit")?A:v,D="height"===f.get("icon-text-fit")||"both"===f.get("icon-text-fit")?C:y;s=new i(b+S-T,w+L-M),l=new i(b+S+k+E,w+L-M),c=new i(b+S+k+E,w+L+I+D),u=new i(b+S-T,w+L+I+D)}else s=new i(d,p),l=new i(m,p),c=new i(m,g),u=new i(d,g);var P=r.layout.get("icon-rotate").evaluate(o,{})*Math.PI/180;if(P){var O=Math.sin(P),z=Math.cos(P),R=[z,-O,O,z];s._matMult(R),l._matMult(R),u._matMult(R),c._matMult(R)}return[{tl:s,tr:l,bl:u,br:c,tex:h.paddedRect,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0}]}(0,a,o,0,mc(n.horizontal),x),H=o.layout.get("icon-rotate").evaluate(x,{});C=new tc(s,r,e,l,c,u,a,g,m,!1,t.overscaling,H),I=4*U.length;var G=t.iconSizeData,q=null;"source"===G.kind?(q=[_s*o.layout.get("icon-size").evaluate(x,{})])[0]>dc&&w(t.layerIds[0]+': Value for "icon-size" is >= 256. Reduce your "icon-size".'):"composite"===G.kind&&((q=[_s*_.compositeIconSizes[0].evaluate(x,{}),_s*_.compositeIconSizes[1].evaluate(x,{})])[0]>dc||q[1]>dc)&&w(t.layerIds[0]+': Value for "icon-size" is >= 256. Reduce your "icon-size".'),t.addSymbols(t.icon,U,q,y,v,x,!1,e,k.lineStartIndex,k.lineLength)}var W=C?C.boxStartIndex:t.collisionBoxArray.length,Z=C?C.boxEndIndex:t.collisionBoxArray.length;t.glyphOffsetArray.length>=Ds.MAX_GLYPHS&&w("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),t.symbolInstances.emplaceBack(e.x,e.y,S.right>=0?S.right:-1,S.center>=0?S.center:-1,S.left>=0?S.left:-1,S.vertical||-1,E,j,B,Y,V,W,Z,l,T,L,I,0,h,D)}(t,c,l,r,n,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,g,x,A,s,v,b,C,f,e,a,o)};if("line"===M)for(var T=0,L=function(t,e,r,n,a){for(var o=[],s=0;s=n&&f.x>=n||(h.x>=n?h=new i(n,h.y+(f.y-h.y)*((n-h.x)/(f.x-h.x)))._round():f.x>=n&&(f=new i(n,h.y+(f.y-h.y)*((n-h.x)/(f.x-h.x)))._round()),h.y>=a&&f.y>=a||(h.y>=a?h=new i(h.x+(f.x-h.x)*((a-h.y)/(f.y-h.y)),a)._round():f.y>=a&&(f=new i(h.x+(f.x-h.x)*((a-h.y)/(f.y-h.y)),a)._round()),c&&h.equals(c[c.length-1])||(c=[h],o.push(c)),c.push(f)))))}return o}(e.geometry,0,0,ea,ea);T1){var F=Ql(R,_,r.vertical||p,n,24,m);F&&I(R,F)}}else if("Polygon"===e.type)for(var N=0,j=vo(e.geometry,0);N=k.maxzoom||"none"!==k.visibility&&(o(M,this.zoom),(d[k.id]=k.createBucket({index:c.bucketLayerIDs.length,layers:M,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source})).populate(b,g),c.bucketLayerIDs.push(M.map((function(t){return t.id}))))}}}var I=t.mapObject(g.glyphDependencies,(function(t){return Object.keys(t).map(Number)}));Object.keys(I).length?n.send("getGlyphs",{uid:this.uid,stacks:I},(function(t,e){u||(u=t,h=e,S.call(s))})):h={};var T=Object.keys(g.iconDependencies);T.length?n.send("getImages",{icons:T},(function(t,e){u||(u=t,f=e,S.call(s))})):f={};var L=Object.keys(g.patternDependencies);function S(){if(u)return a(u);if(h&&f&&p){var e=new i(h),r=new t.ImageAtlas(f,p);for(var n in d){var s=d[n];s instanceof t.SymbolBucket?(o(s.layers,this.zoom),t.performSymbolLayout(s,h,e.positions,f,r.iconPositions,this.showCollisionBoxes)):s.hasPattern&&(s instanceof t.LineBucket||s instanceof t.FillBucket||s instanceof t.FillExtrusionBucket)&&(o(s.layers,this.zoom),s.addFeatures(g,r.patternPositions))}this.status="done",a(null,{buckets:t.values(d).filter((function(t){return!t.isEmpty()})),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:r,glyphMap:this.returnDependencies?h:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}L.length?n.send("getImages",{icons:L},(function(t,e){u||(u=t,p=e,S.call(s))})):p={},S.call(this)};var s="undefined"!=typeof performance,l={getEntriesByName:function(t){return!!(s&&performance&&performance.getEntriesByName)&&performance.getEntriesByName(t)},mark:function(t){return!!(s&&performance&&performance.mark)&&performance.mark(t)},measure:function(t,e,r){return!!(s&&performance&&performance.measure)&&performance.measure(t,e,r)},clearMarks:function(t){return!!(s&&performance&&performance.clearMarks)&&performance.clearMarks(t)},clearMeasures:function(t){return!!(s&&performance&&performance.clearMeasures)&&performance.clearMeasures(t)}},c=function(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},l.mark(this._marks.start)};function u(e,r){var n=t.getArrayBuffer(e.request,(function(e,n,i,a){e?r(e):n&&r(null,{vectorTile:new t.vectorTile.VectorTile(new t.pbf(n)),rawData:n,cacheControl:i,expires:a})}));return function(){n.cancel(),r()}}c.prototype.finish=function(){l.mark(this._marks.end);var t=l.getEntriesByName(this._marks.measure);return 0===t.length&&(l.measure(this._marks.measure,this._marks.start,this._marks.end),t=l.getEntriesByName(this._marks.measure),l.clearMarks(this._marks.start),l.clearMarks(this._marks.end),l.clearMeasures(this._marks.measure)),t},l.Performance=c;var h=function(t,e,r){this.actor=t,this.layerIndex=e,this.loadVectorData=r||u,this.loading={},this.loaded={}};h.prototype.loadTile=function(e,r){var n=this,i=e.uid;this.loading||(this.loading={});var o=!!(e&&e.request&&e.request.collectResourceTiming)&&new l.Performance(e.request),s=this.loading[i]=new a(e);s.abort=this.loadVectorData(e,(function(e,a){if(delete n.loading[i],e||!a)return s.status="done",n.loaded[i]=s,r(e);var l=a.rawData,c={};a.expires&&(c.expires=a.expires),a.cacheControl&&(c.cacheControl=a.cacheControl);var u={};if(o){var h=o.finish();h&&(u.resourceTiming=JSON.parse(JSON.stringify(h)))}s.vectorTile=a.vectorTile,s.parse(a.vectorTile,n.layerIndex,n.actor,(function(e,n){if(e||!n)return r(e);r(null,t.extend({rawTileData:l.slice(0)},n,c,u))})),n.loaded=n.loaded||{},n.loaded[i]=s}))},h.prototype.reloadTile=function(t,e){var r=this.loaded,n=t.uid,i=this;if(r&&r[n]){var a=r[n];a.showCollisionBoxes=t.showCollisionBoxes;var o=function(t,r){var n=a.reloadCallback;n&&(delete a.reloadCallback,a.parse(a.vectorTile,i.layerIndex,i.actor,n)),e(t,r)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.actor,o):o())}},h.prototype.abortTile=function(t,e){var r=this.loading,n=t.uid;r&&r[n]&&r[n].abort&&(r[n].abort(),delete r[n]),e()},h.prototype.removeTile=function(t,e){var r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()};var f=function(){this.loaded={}};f.prototype.loadTile=function(e,r){var n=e.uid,i=e.encoding,a=e.rawImageData,o=new t.DEMData(n,a,i);this.loaded=this.loaded||{},this.loaded[n]=o,r(null,o)},f.prototype.removeTile=function(t){var e=this.loaded,r=t.uid;e&&e[r]&&delete e[r]};var p={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function d(t){var e=0;if(t&&t.length>0){e+=Math.abs(g(t[0]));for(var r=1;r2){for(o=0;o=0}(t)===e?t:t.reverse()}var _=t.vectorTile.VectorTileFeature.prototype.toGeoJSON,w=function(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};w.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],r=0,n=this._feature.geometry;r>31}function F(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,a=0,o=r.length,s=0;s>1;!function t(e,r,n,i,a,o){for(;a>i;){if(a-i>600){var s=a-i+1,l=n-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);t(e,r,n,Math.max(i,Math.floor(n-l*u/s+h)),Math.min(a,Math.floor(n+(s-l)*u/s+h)),o)}var f=r[2*n+o],p=i,d=a;for(j(e,r,i,n),r[2*a+o]>f&&j(e,r,i,a);pf;)d--}r[2*i+o]===f?j(e,r,i,d):j(e,r,++d,a),d<=n&&(i=d+1),n<=d&&(a=d-1)}}(e,r,s,i,a,o%2),t(e,r,n,i,s-1,o+1),t(e,r,n,s+1,a,o+1)}}(o,s,n,0,o.length-1,0)};H.prototype.range=function(t,e,r,n){return function(t,e,r,n,i,a,o){for(var s,l,c=[0,t.length-1,0],u=[];c.length;){var h=c.pop(),f=c.pop(),p=c.pop();if(f-p<=o)for(var d=p;d<=f;d++)s=e[2*d],l=e[2*d+1],s>=r&&s<=i&&l>=n&&l<=a&&u.push(t[d]);else{var g=Math.floor((p+f)/2);s=e[2*g],l=e[2*g+1],s>=r&&s<=i&&l>=n&&l<=a&&u.push(t[g]);var m=(h+1)%2;(0===h?r<=s:n<=l)&&(c.push(p),c.push(g-1),c.push(m)),(0===h?i>=s:a>=l)&&(c.push(g+1),c.push(f),c.push(m))}}return u}(this.ids,this.coords,t,e,r,n,this.nodeSize)},H.prototype.within=function(t,e,r){return function(t,e,r,n,i,a){for(var o=[0,t.length-1,0],s=[],l=i*i;o.length;){var c=o.pop(),u=o.pop(),h=o.pop();if(u-h<=a)for(var f=h;f<=u;f++)Y(e[2*f],e[2*f+1],r,n)<=l&&s.push(t[f]);else{var p=Math.floor((h+u)/2),d=e[2*p],g=e[2*p+1];Y(d,g,r,n)<=l&&s.push(t[p]);var m=(c+1)%2;(0===c?r-i<=d:n-i<=g)&&(o.push(h),o.push(p-1),o.push(m)),(0===c?r+i>=d:n+i>=g)&&(o.push(p+1),o.push(u),o.push(m))}}return s}(this.ids,this.coords,t,e,r,this.nodeSize)};var G={minZoom:0,maxZoom:16,radius:40,extent:512,nodeSize:64,log:!1,reduce:null,map:function(t){return t}},q=function(t){this.options=$(Object.create(G),t),this.trees=new Array(this.options.maxZoom+1)};function W(t,e,r,n,i){return{x:t,y:e,zoom:1/0,id:r,parentId:-1,numPoints:n,properties:i}}function Z(t,e){var r=t.geometry.coordinates,n=r[0],i=r[1];return{x:K(n),y:Q(i),zoom:1/0,index:e,parentId:-1}}function X(t){return{type:"Feature",id:t.id,properties:J(t),geometry:{type:"Point",coordinates:[(n=t.x,360*(n-.5)),(e=t.y,r=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(r))/Math.PI-90)]}};var e,r,n}function J(t){var e=t.numPoints,r=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return $($({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:r})}function K(t){return t/360+.5}function Q(t){var e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function $(t,e){for(var r in e)t[r]=e[r];return t}function tt(t){return t.x}function et(t){return t.y}function rt(t,e,r,n,i,a){var o=i-r,s=a-n;if(0!==o||0!==s){var l=((t-r)*o+(e-n)*s)/(o*o+s*s);l>1?(r=i,n=a):l>0&&(r+=o*l,n+=s*l)}return(o=t-r)*o+(s=e-n)*s}function nt(t,e,r,n){var i={id:void 0===t?null:t,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)it(t,e);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n0&&(o+=n?(i*c-l*a)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(c-a,2))),i=l,a=c}var u=e.length-3;e[2]=1,function t(e,r,n,i){for(var a,o=i,s=n-r>>1,l=n-r,c=e[r],u=e[r+1],h=e[n],f=e[n+1],p=r+3;po)a=p,o=d;else if(d===o){var g=Math.abs(p-s);gi&&(a-r>3&&t(e,r,a,i),e[a+2]=o,n-a>3&&t(e,a,n,i))}(e,0,u,r),e[u+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function lt(t,e,r,n){for(var i=0;i1?1:r}function ht(t,e,r,n,i,a,o,s){if(n/=e,a>=(r/=e)&&o=n)return null;for(var l=[],c=0;c=r&&d=n)){var g=[];if("Point"===f||"MultiPoint"===f)ft(h,g,r,n,i);else if("LineString"===f)pt(h,g,r,n,i,!1,s.lineMetrics);else if("MultiLineString"===f)gt(h,g,r,n,i,!1);else if("Polygon"===f)gt(h,g,r,n,i,!0);else if("MultiPolygon"===f)for(var m=0;m=r&&o<=n&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function pt(t,e,r,n,i,a,o){for(var s,l,c=dt(t),u=0===i?vt:yt,h=t.start,f=0;fr&&(l=u(c,p,d,m,v,r),o&&(c.start=h+s*l)):y>n?x=r&&(l=u(c,p,d,m,v,r),b=!0),x>n&&y<=n&&(l=u(c,p,d,m,v,n),b=!0),!a&&b&&(o&&(c.end=h+s*l),e.push(c),c=dt(t)),o&&(h+=s)}var _=t.length-3;p=t[_],d=t[_+1],g=t[_+2],(y=0===i?p:d)>=r&&y<=n&&mt(c,p,d,g),_=c.length-3,a&&_>=3&&(c[_]!==c[0]||c[_+1]!==c[1])&&mt(c,c[0],c[1],c[2]),c.length&&e.push(c)}function dt(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function gt(t,e,r,n,i,a){for(var o=0;oo.maxX&&(o.maxX=u),h>o.maxY&&(o.maxY=h)}return o}function Ct(t,e,r,n){var i=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(i?o:n))r.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(r.numSimplified++,s.push(e[l]),s.push(e[l+1])),r.numPoints++;i&&function(t,e){for(var r=0,n=0,i=t.length,a=i-2;n0===e)for(n=0,i=t.length;n24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var n=0;n=n;c--){var u=+Date.now();s=this._cluster(s,c),this.trees[c]=new H(s,tt,et,a,Float32Array),r&&console.log("z%d: %d clusters in %dms",c,s.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this},q.prototype.getClusters=function(t,e){var r=((t[0]+180)%360+360)%360-180,n=Math.max(-90,Math.min(90,t[1])),i=180===t[2]?180:((t[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,i=180;else if(r>i){var o=this.getClusters([r,n,180,a],e),s=this.getClusters([-180,n,i,a],e);return o.concat(s)}for(var l=this.trees[this._limitZoom(e)],c=[],u=0,h=l.range(K(r),Q(a),K(i),Q(n));u>5,r=t%32,n="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(n);var a=i.points[e];if(!a)throw new Error(n);for(var o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),s=[],l=0,c=i.within(a.x,a.y,o);l1?this._map(c,!0):null,m=(l<<5)+(e+1),v=0,y=h;v1&&console.time("creation"),f=this.tiles[h]=At(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(f.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var g,m,v,y,x,b,_=.5*l.buffer/l.extent,w=.5-_,A=.5+_,C=1+_;g=m=v=y=null,x=ht(t,u,r-_,r+A,0,f.minX,f.maxX,l),b=ht(t,u,r+w,r+C,0,f.minX,f.maxX,l),t=null,x&&(g=ht(x,u,n-_,n+A,1,f.minY,f.maxY,l),m=ht(x,u,n+w,n+C,1,f.minY,f.maxY,l),x=null),b&&(v=ht(b,u,n-_,n+A,1,f.minY,f.maxY,l),y=ht(b,u,n+w,n+C,1,f.minY,f.maxY,l),b=null),c>1&&console.timeEnd("clipping"),s.push(g||[],e+1,2*r,2*n),s.push(m||[],e+1,2*r,2*n+1),s.push(v||[],e+1,2*r+1,2*n),s.push(y||[],e+1,2*r+1,2*n+1)}}},kt.prototype.getTile=function(t,e,r){var n=this.options,i=n.extent,a=n.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var l,c=t,u=e,h=r;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[It(c,u,h)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",c,u,h),a>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?_t(this.tiles[s],i):null):null};var Lt=function(e){function r(t,r,n){e.call(this,t,r,Tt),n&&(this.loadGeoJSON=n)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},r.prototype._loadData=function(){var e=this;if(this._pendingCallback&&this._pendingLoadDataParams){var r=this._pendingCallback,n=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams;var i=!!(n&&n.request&&n.request.collectResourceTiming)&&new l.Performance(n.request);this.loadGeoJSON(n,(function(a,o){if(a||!o)return r(a);if("object"!=typeof o)return r(new Error("Input data given to '"+n.source+"' is not a valid GeoJSON object."));!function t(e,r){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.map(y(t,r)),e;case"GeometryCollection":return e.geometries=e.geometries.map(y(t,r)),e;case"Feature":return e.geometry=t(e.geometry,r),e;case"Polygon":case"MultiPolygon":return function(t,e){return"Polygon"===t.type?t.coordinates=x(t.coordinates,e):"MultiPolygon"===t.type&&(t.coordinates=t.coordinates.map(y(x,e))),t}(e,r);default:return e}}(o,!0);try{e._geoJSONIndex=n.cluster?new q(function(e){var r=e.superclusterOptions,n=e.clusterProperties;if(!n||!r)return r;for(var i={},a={},o={accumulated:null,zoom:0},s={properties:null},l=Object.keys(n),c=0,u=l;c=0?0:e.button},r.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var f=function(e){function r(){e.call(this),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.isLoaded=function(){return this.loaded},r.prototype.setLoaded=function(t){if(this.loaded!==t&&(this.loaded=t,t)){for(var e=0,r=this.requestors;e=0?1.2:1))}function v(t,e,r,n,i,a,o){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else{var l=a.requests[s];l||(l=a.requests[s]=[],x.loadGlyphRange(r,s,n.url,n.requestManager,(function(t,e){if(e)for(var r in e)n._doesCharSupportLocalGlyph(+r)||(a.glyphs[+r]=e[+r]);for(var i=0,o=l;ithis.height)return t.warnOnce("LineAtlas out of space"),null;for(var a=0,o=0;o=n&&e.x=i&&e.y0&&(l[new t.OverscaledTileID(e.overscaledZ,a,r.z,i,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&(n.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",n))}}))},r.prototype.onAdd=function(t){this.map=t,this.load()},r.prototype.setData=function(e){var r=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData((function(e){if(e)r.fire(new t.ErrorEvent(e));else{var n={dataType:"source",sourceDataType:"content"};r._collectResourceTiming&&r._resourceTiming&&r._resourceTiming.length>0&&(n.resourceTiming=r._resourceTiming,r._resourceTiming=[]),r.fire(new t.Event("data",n))}})),this},r.prototype.getClusterExpansionZoom=function(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this},r.prototype.getClusterChildren=function(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this},r.prototype.getClusterLeaves=function(t,e,r,n){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:r},n),this},r.prototype._updateWorkerData=function(e){var r=this;this._loaded=!1;var n=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(n.request=this.map._requestManager.transformRequest(t.browser.resolveURL(i),t.ResourceType.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(i),this.actor.send(this.type+".loadData",n,(function(t,i){r._removed||i&&i.abandoned||(r._loaded=!0,i&&i.resourceTiming&&i.resourceTiming[r.id]&&(r._resourceTiming=i.resourceTiming[r.id].slice(0)),r.actor.send(r.type+".coalesce",{source:n.source},null),e(t))}))},r.prototype.loaded=function(){return this._loaded},r.prototype.loadTile=function(e,r){var n=this,i=e.actor?"reloadTile":"loadTile";e.actor=this.actor;var a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.browser.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes};e.request=this.actor.send(i,a,(function(t,a){return delete e.request,e.unloadVectorData(),e.aborted?r(null):t?r(t):(e.loadVectorData(a,n.map.painter,"reloadTile"===i),r(null))}))},r.prototype.abortTile=function(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0},r.prototype.unloadTile=function(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})},r.prototype.onRemove=function(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})},r.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},r.prototype.hasTransition=function(){return!1},r}(t.Evented),E=function(e){function r(t,r,n,i){e.call(this),this.id=t,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=r}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.load=function(e,r){var n=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),(function(i,a){n._loaded=!0,i?n.fire(new t.ErrorEvent(i)):a&&(n.image=a,e&&(n.coordinates=e),r&&r(),n._finishLoading())}))},r.prototype.loaded=function(){return this._loaded},r.prototype.updateImage=function(t){var e=this;return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(function(){e.texture=null})),this):this},r.prototype._finishLoading=function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))},r.prototype.onAdd=function(t){this.map=t,this.load()},r.prototype.setCoordinates=function(e){var r=this;this.coordinates=e;var n=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){for(var r=1/0,n=1/0,i=-1/0,a=-1/0,o=0,s=e;or.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError("Playback for this video can be set only between the "+r.start(0)+" and "+r.end(0)+"-second mark."))):this.video.currentTime=e}},r.prototype.getVideo=function(){return this.video},r.prototype.onAdd=function(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))},r.prototype.prepare=function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var e=this.map.painter.context,r=e.gl;for(var n in this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,t.rasterBoundsAttributes.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this.tiles){var i=this.tiles[n];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}}},r.prototype.serialize=function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}},r.prototype.hasTransition=function(){return this.video&&!this.video.paused},r}(E),P=function(e){function r(r,n,i,a){e.call(this,r,n,i,a),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some((function(t){return!Array.isArray(t)||2!==t.length||t.some((function(t){return"number"!=typeof t}))}))||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+r,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+r,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new t.ErrorEvent(new t.ValidationError("sources."+r,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+r,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+r,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.load=function(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},r.prototype.getCanvas=function(){return this.canvas},r.prototype.onAdd=function(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()},r.prototype.onRemove=function(){this.pause()},r.prototype.prepare=function(){var e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),!this._hasInvalidDimensions()&&0!==Object.keys(this.tiles).length){var r=this.map.painter.context,n=r.gl;for(var i in this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,t.rasterBoundsAttributes.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(r,this.canvas,n.RGBA,{premultiply:!0}),this.tiles){var a=this.tiles[i];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}},r.prototype.serialize=function(){return{type:"canvas",coordinates:this.coordinates}},r.prototype.hasTransition=function(){return this._playing},r.prototype._hasInvalidDimensions=function(){for(var t=0,e=[this.canvas.width,this.canvas.height];tthis.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this},j.prototype.has=function(t){return t.wrapped().key in this.data},j.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},j.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},j.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},j.prototype.remove=function(t,e){if(!this.has(t))return this;var r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this},j.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this};var B=function(t,e,r){this.context=t;var n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};B.prototype.bind=function(){this.context.bindElementBuffer.set(this.buffer)},B.prototype.updateData=function(t){var e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)},B.prototype.destroy=function(){var t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)};var Y={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},V=function(t,e,r,n){this.length=e.length,this.attributes=r,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;var i=t.gl;this.buffer=i.createBuffer(),t.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer};V.prototype.bind=function(){this.context.bindVertexBuffer.set(this.buffer)},V.prototype.updateData=function(t){var e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)},V.prototype.enableAttributes=function(t,e){for(var r=0;r1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}},r.prototype.getTile=function(t){return this.getTileByID(t.key)},r.prototype.getTileByID=function(t){return this._tiles[t]},r.prototype.getZoom=function(t){return t.zoom+t.scaleZoom(t.tileSize/this._source.tileSize)},r.prototype._retainLoadedChildren=function(t,e,r,n){for(var i in this._tiles){var a=this._tiles[i];if(!(n[i]||!a.hasData()||a.tileID.overscaledZ<=e||a.tileID.overscaledZ>r)){for(var o=a.tileID;a&&a.tileID.overscaledZ>e+1;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[s.key])&&a.hasData()&&(o=s)}for(var l=o;l.overscaledZ>e;)if(t[(l=l.scaledTo(l.overscaledZ-1)).key]){n[o.key]=o;break}}}},r.prototype.findLoadedParent=function(t,e){for(var r=t.overscaledZ-1;r>=e;r--){var n=t.scaledTo(r);if(!n)return;var i=String(n.key),a=this._tiles[i];if(a&&a.hasData())return a;if(this._cache.has(n))return this._cache.get(n)}},r.prototype.updateCacheSize=function(t){var e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=Math.floor(5*e),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n)},r.prototype.handleWrapJump=function(t){var e=(t-(void 0===this._prevLng?t:this._prevLng))/360,r=Math.round(e);if(this._prevLng=t,r){var n={};for(var i in this._tiles){var a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+r),n[a.tileID.key]=a}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var s in this._tiles){var l=this._tiles[s];this._setTileReloadTimer(s,l)}}},r.prototype.update=function(e){var n=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)})):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter((function(t){return n._source.hasTile(t)})))):i=[];var a=(this._source.roundZoom?Math.round:Math.floor)(this.getZoom(e)),o=Math.max(a-r.maxOverzooming,this._source.minzoom),s=Math.max(a+r.maxUnderzooming,this._source.minzoom),l=this._updateRetainedTiles(i,a);if(Dt(this._source.type)){for(var c={},u={},h=0,f=Object.keys(l);hthis._source.maxzoom){var m=d.children(this._source.maxzoom)[0],v=this.getTile(m);if(v&&v.hasData()){n[m.key]=m;continue}}else{var y=d.children(this._source.maxzoom);if(n[y[0].key]&&n[y[1].key]&&n[y[2].key]&&n[y[3].key])continue}for(var x=g.wasRequested(),b=d.overscaledZ-1;b>=a;--b){var _=d.scaledTo(b);if(i[_.key])break;if(i[_.key]=!0,!(g=this.getTile(_))&&x&&(g=this._addTile(_)),g&&(n[_.key]=_,x=g.wasRequested(),g.hasData()))break}}}return n},r.prototype._addTile=function(e){var r=this._tiles[e.key];if(r)return r;(r=this._cache.getAndRemove(e))&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));var n=Boolean(r);return n||(r=new t.Tile(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))),r?(r.uses++,this._tiles[e.key]=r,n||this._source.fire(new t.Event("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null},r.prototype._setTileReloadTimer=function(t,e){var r=this;t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);var n=e.getExpiryTimeout();n&&(this._timers[t]=setTimeout((function(){r._reloadTile(t,"expired"),delete r._timers[t]}),n))},r.prototype._removeTile=function(t){var e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},r.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},r.prototype.tilesIn=function(e,r,n){var i=this,a=[],o=this.transform;if(!o)return a;for(var s=n?o.getCameraQueryGeometry(e):e,l=e.map((function(t){return o.pointCoordinate(t)})),c=s.map((function(t){return o.pointCoordinate(t)})),u=this.getIds(),h=1/0,f=1/0,p=-1/0,d=-1/0,g=0,m=c;g=0&&v[1].y+m>=0){var y=l.map((function(t){return s.getTilePoint(t)})),x=c.map((function(t){return s.getTilePoint(t)}));a.push({tile:n,tileID:s,queryGeometry:y,cameraQueryGeometry:x,scale:g})}}},x=0;x=t.browser.now())return!0}return!1},r.prototype.setFeatureState=function(t,e,r){t=t||"_geojsonTileLayer",this._state.updateState(t,e,r)},r.prototype.removeFeatureState=function(t,e,r){t=t||"_geojsonTileLayer",this._state.removeFeatureState(t,e,r)},r.prototype.getFeatureState=function(t,e){return t=t||"_geojsonTileLayer",this._state.getState(t,e)},r}(t.Evented);function Et(t,e){return t%32-e%32||e-t}function Dt(t){return"raster"===t||"image"===t||"video"===t}function Pt(){return new t.window.Worker($n.workerUrl)}St.maxOverzooming=10,St.maxUnderzooming=3;var Ot=function(){this.active={}};Ot.prototype.acquire=function(t){if(!this.workers)for(this.workers=[];this.workers.length=-e[0]&&r<=e[0]&&n>=-e[1]&&n<=e[1]}function Qt(e,r,n,i,a,o,s,l){var c=i?e.textSizeData:e.iconSizeData,u=t.evaluateSizeForZoom(c,n.transform.zoom),h=[256/n.width*2+1,256/n.height*2+1],f=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;f.clear();for(var p=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,g=n.transform.width/n.transform.height,m=!1,v=0;vMath.abs(n.x-r.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?r.yn.x)?{needsFlipping:!0}:null}function ee(e,r,n,i,a,o,s,l,c,u,h,f,p,d){var g,m=r/24,v=e.lineOffsetX*m,y=e.lineOffsetY*m;if(e.numGlyphs>1){var x=e.glyphStartIndex+e.numGlyphs,b=e.lineStartIndex,_=e.lineStartIndex+e.lineLength,w=$t(m,l,v,y,n,h,f,e,c,o,p,!1);if(!w)return{notEnoughRoom:!0};var A=Jt(w.first.point,s).point,C=Jt(w.last.point,s).point;if(i&&!n){var M=te(e.writingMode,A,C,d);if(M)return M}g=[w.first];for(var k=e.glyphStartIndex+1;k0?S.point:re(f,L,I,1,a),D=te(e.writingMode,I,E,d);if(D)return D}var P=ne(m*l.getoffsetX(e.glyphStartIndex),v,y,n,h,f,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,o,p,!1);if(!P)return{notEnoughRoom:!0};g=[P]}for(var O=0,z=g;O0?1:-1,m=0;i&&(g*=-1,m=Math.PI),g<0&&(m+=Math.PI);for(var v=g>0?l+s:l+s+1,y=v,x=a,b=a,_=0,w=0,A=Math.abs(d);_+w<=A;){if((v+=g)=c)return null;if(b=x,void 0===(x=f[v])){var C=new t.Point(u.getx(v),u.gety(v)),M=Jt(C,h);if(M.signedDistanceFromCamera>0)x=f[v]=M.point;else{var k=v-g;x=re(0===_?o:new t.Point(u.getx(k),u.gety(k)),C,b,A-_+1,h)}}_+=w,w=b.dist(x)}var I=(A-_)/w,T=x.sub(b),L=T.mult(I)._add(b);return L._add(T._unit()._perp()._mult(n*g)),{point:L,angle:m+Math.atan2(x.y-b.y,x.x-b.x),tileDistance:p?{prevTileDistance:v-g===y?0:u.gettileUnitDistanceFromAnchor(v-g),lastSegmentViewportDistance:A-_}:null}}Wt.prototype.keysLength=function(){return this.boxKeys.length+this.circleKeys.length},Wt.prototype.insert=function(t,e,r,n,i){this._forEachCell(e,r,n,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i)},Wt.prototype.insertCircle=function(t,e,r,n){this._forEachCell(e-n,r-n,e+n,r+n,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(r),this.circles.push(n)},Wt.prototype._insertBoxCell=function(t,e,r,n,i,a){this.boxCells[i].push(a)},Wt.prototype._insertCircleCell=function(t,e,r,n,i,a){this.circleCells[i].push(a)},Wt.prototype._query=function(t,e,r,n,i,a){if(r<0||t>this.width||n<0||e>this.height)return!i&&[];var o=[];if(t<=0&&e<=0&&this.width<=r&&this.height<=n){if(i)return!0;for(var s=0;s0:o},Wt.prototype._queryCircle=function(t,e,r,n,i){var a=t-r,o=t+r,s=e-r,l=e+r;if(o<0||a>this.width||l<0||s>this.height)return!n&&[];var c=[],u={hitTest:n,circle:{x:t,y:e,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(a,s,o,l,this._queryCellCircle,c,u,i),n?c.length>0:c},Wt.prototype.query=function(t,e,r,n,i){return this._query(t,e,r,n,!1,i)},Wt.prototype.hitTest=function(t,e,r,n,i){return this._query(t,e,r,n,!0,i)},Wt.prototype.hitTestCircle=function(t,e,r,n){return this._queryCircle(t,e,r,!0,n)},Wt.prototype._queryCell=function(t,e,r,n,i,a,o,s){var l=o.seenUids,c=this.boxCells[i];if(null!==c)for(var u=this.bboxes,h=0,f=c;h=u[d+0]&&n>=u[d+1]&&(!s||s(this.boxKeys[p]))){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:u[d],y1:u[d+1],x2:u[d+2],y2:u[d+3]})}}}var g=this.circleCells[i];if(null!==g)for(var m=this.circles,v=0,y=g;vo*o+s*s},Wt.prototype._circleAndRectCollide=function(t,e,r,n,i,a,o){var s=(a-n)/2,l=Math.abs(t-(n+s));if(l>s+r)return!1;var c=(o-i)/2,u=Math.abs(e-(i+c));if(u>c+r)return!1;if(l<=s||u<=c)return!0;var h=l-s,f=u-c;return h*h+f*f<=r*r};var ie=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ae(t,e){for(var r=0;rI)le(e,T,!1);else{var P=this.projectPoint(c,L,S),O=E*C;if(d.length>0){var z=P.x-d[d.length-4],R=P.y-d[d.length-3];if(O*O*2>z*z+R*R&&T+8-k&&F=this.screenRightBoundary||n<100||e>this.screenBottomBoundary},se.prototype.isInsideGrid=function(t,e,r,n){return r>=0&&t=0&&e0)return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(m=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={radialOffset:a,width:n,height:i,anchor:e,textBoxScale:o,prevAnchor:m},this.markUsedJustification(d,e,p,g),d.allowVerticalPlacement&&(this.markUsedOrientation(d,g,p),this.placedOrientations[p.crossTileID]=g),y},me.prototype.placeLayerBucket=function(e,r,n,i,a,o,s,l,c,u){var h=this,f=e.layers[0].layout,p=t.evaluateSizeForZoom(e.textSizeData,this.transform.zoom),d=f.get("text-optional"),g=f.get("icon-optional"),m=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),y=m&&(v||!e.hasIconData()||g),x=v&&(m||!e.hasTextData()||d),b=this.collisionGroups.get(e.sourceID),_="map"===f.get("text-rotation-alignment"),w="map"===f.get("text-pitch-alignment"),A="viewport-y"===f.get("symbol-z-order");!e.collisionArrays&&u&&e.deserializeCollisionBoxes(u);var C=function(i,u){if(!c[i.crossTileID])if(l)h.placements[i.crossTileID]=new fe(!1,!1,!1);else{var v,A=!1,C=!1,M=!0,k={box:null,offscreen:null},I={box:null,offscreen:null},T=null,L=null,S=0,E=0,D=0;u.textFeatureIndex&&(S=u.textFeatureIndex),u.verticalTextFeatureIndex&&(E=u.verticalTextFeatureIndex);var P=u.textBox;if(P){var O=function(r){var n=t.WritingMode.horizontal;if(e.allowVerticalPlacement&&!r&&h.prevPlacement){var a=h.prevPlacement.placedOrientations[i.crossTileID];a&&(h.placedOrientations[i.crossTileID]=a,n=a,h.markUsedOrientation(e,n,i))}return n},z=function(r,n){if(e.allowVerticalPlacement&&i.numVerticalGlyphVertices>0&&u.verticalTextBox)for(var a=0,o=e.writingModes;a0&&(R=R.filter((function(t){return t!==F.anchor}))).unshift(F.anchor)}var N=function(t,n){for(var a=t.x2-t.x1,s=t.y2-t.y1,l=i.textBoxScale,c={box:[],offscreen:!1},u=m?2*R.length:R.length,f=0;f=R.length;if((c=h.attemptAnchorPlacement(p,t,a,s,i.radialTextOffset,l,_,w,o,r,b,d,i,e,n))&&c.box&&c.box.length){A=!0;break}}return c};z((function(){return N(P,t.WritingMode.horizontal)}),(function(){var r=u.verticalTextBox,n=k&&k.box&&k.box.length;return e.allowVerticalPlacement&&!n&&i.numVerticalGlyphVertices>0&&r?N(r,t.WritingMode.vertical):{box:null,offscreen:null}})),k&&(A=k.box,M=k.offscreen);var j=O(k&&k.box);if(!A&&h.prevPlacement){var B=h.prevPlacement.variableOffsets[i.crossTileID];B&&(h.variableOffsets[i.crossTileID]=B,h.markUsedJustification(e,B.anchor,i,j))}}else{var Y=function(t,n){var a=h.collisionIndex.placeCollisionBox(t,f.get("text-allow-overlap"),o,r,b.predicate);return a&&a.box&&a.box.length&&(h.markUsedOrientation(e,n,i),h.placedOrientations[i.crossTileID]=n),a};z((function(){return Y(P,t.WritingMode.horizontal)}),(function(){var r=u.verticalTextBox;return e.allowVerticalPlacement&&i.numVerticalGlyphVertices>0&&r?Y(r,t.WritingMode.vertical):{box:null,offscreen:null}})),O(k&&k.box&&k.box.length)}}A=(v=k)&&v.box&&v.box.length>0,M=v&&v.offscreen;var V=u.textCircles;if(V){var U=e.text.placedSymbolArray.get(i.centerJustifiedTextSymbolIndex),H=t.evaluateSizeForFeature(e.textSizeData,p,U);T=h.collisionIndex.placeCollisionCircles(V,f.get("text-allow-overlap"),a,o,U,e.lineVertexArray,e.glyphOffsetArray,H,r,n,s,w,b.predicate),A=f.get("text-allow-overlap")||T.circles.length>0,M=M&&T.offscreen}u.iconFeatureIndex&&(D=u.iconFeatureIndex),u.iconBox&&(C=(L=h.collisionIndex.placeCollisionBox(u.iconBox,f.get("icon-allow-overlap"),o,r,b.predicate)).box.length>0,M=M&&L.offscreen);var G=d||0===i.numHorizontalGlyphVertices&&0===i.numVerticalGlyphVertices,q=g||0===i.numIconVertices;G||q?q?G||(C=C&&A):A=C&&A:C=A=C&&A,A&&v&&v.box&&(I&&I.box&&E?h.collisionIndex.insertCollisionBox(v.box,f.get("text-ignore-placement"),e.bucketInstanceId,E,b.ID):h.collisionIndex.insertCollisionBox(v.box,f.get("text-ignore-placement"),e.bucketInstanceId,S,b.ID)),C&&L&&h.collisionIndex.insertCollisionBox(L.box,f.get("icon-ignore-placement"),e.bucketInstanceId,D,b.ID),A&&T&&h.collisionIndex.insertCollisionCircles(T.circles,f.get("text-ignore-placement"),e.bucketInstanceId,S,b.ID),h.placements[i.crossTileID]=new fe(A||y,C||x,M||e.justReloaded),c[i.crossTileID]=!0}};if(A)for(var M=e.getSortedSymbolIndexes(this.transform.angle),k=M.length-1;k>=0;--k){var I=M[k];C(e.symbolInstances.get(I),e.collisionArrays[I])}else for(var T=0;T=0&&(e.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:n.crossTileID)}},me.prototype.markUsedOrientation=function(e,r,n){for(var i=r===t.WritingMode.horizontal||r===t.WritingMode.horizontalOnly?r:0,a=r===t.WritingMode.vertical?r:0,o=0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];o0||g>0,b=p.numIconVertices>0;if(x){for(var _=Me(y.text),w=(d+g)/4,A=0;A=0&&(e.text.placedSymbolArray.get(t).hidden=C||I)})),p.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(p.verticalPlacedTextSymbolIndex).hidden=C||k);var T=this.variableOffsets[p.crossTileID];T&&this.markUsedJustification(e,T.anchor,p,M);var L=this.placedOrientations[p.crossTileID];L&&(this.markUsedJustification(e,"left",p,L),this.markUsedOrientation(e,L,p))}if(b){for(var S=Me(y.icon),E=0;Et},me.prototype.setStale=function(){this.stale=!0};var ye=Math.pow(2,25),xe=Math.pow(2,24),be=Math.pow(2,17),_e=Math.pow(2,16),we=Math.pow(2,9),Ae=Math.pow(2,8),Ce=Math.pow(2,1);function Me(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,r=Math.floor(127*t.opacity);return r*ye+e*xe+r*be+e*_e+r*we+e*Ae+r*Ce+e}var ke=function(){this._currentTileIndex=0,this._seenCrossTileIDs={}};ke.prototype.continuePlacement=function(t,e,r,n,i){for(;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=r[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(this._inProgressLayer||(this._inProgressLayer=new ke),this._inProgressLayer.continuePlacement(n[s.source],this.placement,this._showCollisionBoxes,s,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0},Ie.prototype.commit=function(t){return this.placement.commit(t),this.placement};var Te=512/t.EXTENT/2,Le=function(t,e,r){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=r;for(var n=0;nt.overscaledZ)for(var s in o){var l=o[s];l.tileID.isChildOf(t)&&l.findMatches(e.symbolInstances,t,i)}else{var c=o[t.scaledTo(Number(a)).key];c&&c.findMatches(e.symbolInstances,t,i)}}for(var u=0;u1?"@2x":"",l=t.getJSON(r.transformRequest(r.normalizeSpriteURL(e,s,".json"),t.ResourceType.SpriteJSON),(function(t,e){l=null,o||(o=t,i=e,u())})),c=t.getImage(r.transformRequest(r.normalizeSpriteURL(e,s,".png"),t.ResourceType.SpriteImage),(function(t,e){c=null,o||(o=t,a=e,u())}));function u(){if(o)n(o);else if(i&&a){var e=t.browser.getImageData(a),r={};for(var s in i){var l=i[s],c=l.width,u=l.height,h=l.x,f=l.y,p=l.sdf,d=l.pixelRatio,g=new t.RGBAImage({width:c,height:u});t.RGBAImage.copy(e,g,{x:h,y:f},{x:0,y:0},{width:c,height:u}),r[s]={data:g,pixelRatio:d,sdf:p}}n(null,r)}}return{cancel:function(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e.sprite,this.map._requestManager,(function(e,r){if(n._spriteRequest=null,e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n.fire(new t.Event("data",{dataType:"style"}))})):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);var a=Nt(this.stylesheet.layers);this._order=a.map((function(t){return t.id})),this._layers={};for(var o=0,s=a;o0)throw new Error("Unimplemented: "+i.map((function(t){return t.command})).join(", ")+".");return n.forEach((function(t){"setTransition"!==t.command&&r[t.command].apply(r,t.args)})),this.stylesheet=e,!0},r.prototype.addImage=function(e,r){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,r),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.updateImage=function(t,e){this.imageManager.updateImage(t,e)},r.prototype.getImage=function(t){return this.imageManager.getImage(t)},r.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this.fire(new t.Event("data",{dataType:"style"}))},r.prototype.listImages=function(){return this._checkLoaded(),this.imageManager.listImages()},r.prototype.addSource=function(e,r,n){var i=this;if(void 0===n&&(n={}),this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!r.type)throw new Error("The type property must be defined, but the only the following properties were given: "+Object.keys(r).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,r,null,n))){this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);var a=this.sourceCaches[e]=new St(e,r,this.dispatcher);a.style=this,a.setEventedParent(this,(function(){return{isSourceLoaded:i.loaded(),source:a.serialize(),sourceId:e}})),a.onAdd(this.map),this._changed=!0}},r.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var r in this._layers)if(this._layers[r].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+r+'" is using it.')));var n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.clearTiles(),n.onRemove&&n.onRemove(this.map),this._changed=!0},r.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},r.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},r.prototype.addLayer=function(e,r,n){void 0===n&&(n={}),this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else{var a;if("custom"===e.type){if(Pe(this,t.validateCustomStyleLayer(e)))return;a=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone$1(e),e=t.extend(e,{source:i})),this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},n))return;a=t.createStyleLayer(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}var o=r?this._order.indexOf(r):this._order.length;if(r&&-1===o)this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.')));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&"custom"!==a.type){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}},r.prototype.moveLayer=function(e,r){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==r){var n=this._order.indexOf(e);this._order.splice(n,1);var i=r?this._order.indexOf(r):this._order.length;r&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+r+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},r.prototype.removeLayer=function(e){this._checkLoaded();var r=this._layers[e];if(r){r.setEventedParent(null);var n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=r,delete this._layers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],r.onRemove&&r.onRemove(this.map)}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},r.prototype.getLayer=function(t){return this._layers[t]},r.prototype.setLayerZoomRange=function(e,r,n){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===r&&i.maxzoom===n||(null!=r&&(i.minzoom=r),null!=n&&(i.maxzoom=n),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},r.prototype.setFilter=function(e,r,n){void 0===n&&(n={}),this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.deepEqual(i.filter,r))return null==r?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(t.validateStyle.filter,"layers."+i.id+".filter",r,null,n)||(i.filter=t.clone$1(r),this._updateLayer(i)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},r.prototype.getFilter=function(e){return t.clone$1(this.getLayer(e).filter)},r.prototype.setLayoutProperty=function(e,r,n,i){void 0===i&&(i={}),this._checkLoaded();var a=this.getLayer(e);a?t.deepEqual(a.getLayoutProperty(r),n)||(a.setLayoutProperty(r,n,i),this._updateLayer(a)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getLayoutProperty=function(e,r){var n=this.getLayer(e);if(n)return n.getLayoutProperty(r);this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style.")))},r.prototype.setPaintProperty=function(e,r,n,i){void 0===i&&(i={}),this._checkLoaded();var a=this.getLayer(e);a?t.deepEqual(a.getPaintProperty(r),n)||(a.setPaintProperty(r,n,i)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},r.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},r.prototype.setFeatureState=function(e,r){this._checkLoaded();var n=e.source,i=e.sourceLayer,a=this.sourceCaches[n],o=parseInt(e.id,10);if(void 0!==a){var s=a.getSource().type;"geojson"===s&&i?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||i?isNaN(o)||o<0?this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided and non-negative."))):a.setFeatureState(i,o,r):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+n+"' does not exist in the map's style.")))},r.prototype.removeFeatureState=function(e,r){this._checkLoaded();var n=e.source,i=this.sourceCaches[n];if(void 0!==i){var a=i.getSource().type,o="vector"===a?e.sourceLayer:void 0,s=parseInt(e.id,10);"vector"!==a||o?void 0!==e.id&&isNaN(s)||s<0?this.fire(new t.ErrorEvent(new Error("The feature id parameter must be non-negative."))):r&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is requred to remove its specific state property."))):i.removeFeatureState(o,s,r):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+n+"' does not exist in the map's style.")))},r.prototype.getFeatureState=function(e){this._checkLoaded();var r=e.source,n=e.sourceLayer,i=this.sourceCaches[r],a=parseInt(e.id,10);if(void 0!==i)if("vector"!==i.getSource().type||n){if(!(isNaN(a)||a<0))return i.getFeatureState(n,a);this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided and non-negative.")))}else this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},r.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},r.prototype.serialize=function(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,(function(t){return t.serialize()})),layers:this._serializeLayers(this._order)},(function(t){return void 0!==t}))},r.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},r.prototype._flattenAndSortRenderedFeatures=function(t){for(var e=this,r=function(t){return"fill-extrusion"===e._layers[t].type},n={},i=[],a=this._order.length-1;a>=0;a--){var o=this._order[a];if(r(o)){n[o]=a;for(var s=0,l=t;s=0;d--){var g=this._order[d];if(r(g))for(var m=i.length-1;m>=0;m--){var v=i[m].feature;if(n[v.layer.id] 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,0.0,1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),qe=cr("uniform float u_overscale_factor;varying float v_placed;varying float v_notUsed;varying float v_radius;varying vec2 v_extrude;varying vec2 v_extrude_scale;void main() {float alpha=0.5;vec4 color=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {color=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {color*=.2;}float extrude_scale_length=length(v_extrude_scale);float extrude_length=length(v_extrude)*extrude_scale_length;float stroke_width=15.0*extrude_scale_length/u_overscale_factor;float radius=v_radius*extrude_scale_length;float distance_to_edge=abs(extrude_length-radius);float opacity_t=smoothstep(-stroke_width,0.0,-distance_to_edge);gl_FragColor=opacity_t*color;}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;varying float v_radius;varying vec2 v_extrude;varying vec2 v_extrude_scale;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,0.0,1.0);highp float padding_factor=1.2;gl_Position.xy+=a_extrude*u_extrude_scale*padding_factor*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;v_radius=abs(a_extrude.y);v_extrude=a_extrude*padding_factor;v_extrude_scale=u_extrude_scale*u_camera_to_center_distance*collision_perspective_ratio;}"),We=cr("uniform highp vec4 u_color;void main() {gl_FragColor=u_color;}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),Ze=cr("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),Xe=cr("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),Je=cr("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec4 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float pixelRatio=u_scale.x;float tileRatio=u_scale.y;float fromScale=u_scale.z;float toScale=u_scale.w;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=vec2((pattern_br_a.x-pattern_tl_a.x)/pixelRatio,(pattern_br_a.y-pattern_tl_a.y)/pixelRatio);vec2 display_size_b=vec2((pattern_br_b.x-pattern_tl_b.x)/pixelRatio,(pattern_br_b.y-pattern_tl_b.y)/pixelRatio);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),Ke=cr("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec4 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float pixelRatio=u_scale.x;float tileZoomRatio=u_scale.y;float fromScale=u_scale.z;float toScale=u_scale.w;vec2 display_size_a=vec2((pattern_br_a.x-pattern_tl_a.x)/pixelRatio,(pattern_br_a.y-pattern_tl_a.y)/pixelRatio);vec2 display_size_b=vec2((pattern_br_b.x-pattern_tl_b.x)/pixelRatio,(pattern_br_b.y-pattern_tl_b.y)/pixelRatio);gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),Qe=cr("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),$e=cr("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec4 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float pixelRatio=u_scale.x;float tileRatio=u_scale.y;float fromScale=u_scale.z;float toScale=u_scale.w;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=vec2((pattern_br_a.x-pattern_tl_a.x)/pixelRatio,(pattern_br_a.y-pattern_tl_a.y)/pixelRatio);vec2 display_size_b=vec2((pattern_br_b.x-pattern_tl_b.x)/pixelRatio,(pattern_br_b.y-pattern_tl_b.y)/pixelRatio);base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),tr=cr("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform float u_maxzoom;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;return (data.r+data.g*256.0+data.b*256.0*256.0)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggeration=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/ pow(2.0,(u_zoom-u_maxzoom)*exaggeration+19.2562-u_zoom);gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),er=cr("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),rr=cr("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),nr=cr("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp float v_lineprogress;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,vec2(v_lineprogress,0.5));gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define MAX_LINE_DISTANCE 32767.0\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_lineprogress;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_lineprogress=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0/MAX_LINE_DISTANCE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),ir=cr("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec4 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float pixelRatio=u_scale.x;float tileZoomRatio=u_scale.y;float fromScale=u_scale.z;float toScale=u_scale.w;vec2 display_size_a=vec2((pattern_br_a.x-pattern_tl_a.x)/pixelRatio,(pattern_br_a.y-pattern_tl_a.y)/pixelRatio);vec2 display_size_b=vec2((pattern_br_b.x-pattern_tl_b.x)/pixelRatio,(pattern_br_b.y-pattern_tl_b.y)/pixelRatio);vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x,1.0);float x_b=mod(v_linesofar/pattern_size_b.x,1.0);float y_a=0.5+(v_normal.y*clamp(v_width2.s,0.0,(pattern_size_a.y+2.0)/2.0)/pattern_size_a.y);float y_b=0.5+(v_normal.y*clamp(v_width2.s,0.0,(pattern_size_b.y+2.0)/2.0)/pattern_size_b.y);vec2 pos_a=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,vec2(x_a,y_a));vec2 pos_b=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,vec2(x_b,y_b));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_linesofar=a_linesofar;v_width2=vec2(outset,inset);}"),ar=cr("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),or=cr("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),sr=cr("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size[0],a_size[1],u_size_t)/256.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size[0]/256.0;} else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {size=u_size;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),0.0,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));}"),lr=cr("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size[0],a_size[1],u_size_t)/256.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size[0]/256.0;} else if (!u_is_size_zoom_constant && u_is_size_feature_constant) {size=u_size;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),0.0,1.0);float gamma_scale=gl_Position.w;vec2 tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));v_data0=vec2(tex.x,tex.y);v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}");function cr(t,e){var r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n={};return{fragmentSource:t=t.replace(r,(function(t,e,r,i,a){return n[a]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"})),vertexSource:e=e.replace(r,(function(t,e,r,i,a){var o="float"===i?"vec2":"vec4",s=a.match(/color/)?"color":o;return n[a]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float u_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\nvarying "+r+" "+i+" "+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"vec4"===s?"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = a_"+a+";\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+a+" = unpack_mix_"+s+"(a_"+a+", u_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+a+"\nuniform lowp float u_"+a+"_t;\nattribute "+r+" "+o+" a_"+a+";\n#else\nuniform "+r+" "+i+" u_"+a+";\n#endif\n":"vec4"===s?"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = a_"+a+";\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+a+"\n "+r+" "+i+" "+a+" = unpack_mix_"+s+"(a_"+a+", u_"+a+"_t);\n#else\n "+r+" "+i+" "+a+" = u_"+a+";\n#endif\n"}))}}var ur=Object.freeze({prelude:Ne,background:je,backgroundPattern:Be,circle:Ye,clippingMask:Ve,heatmap:Ue,heatmapTexture:He,collisionBox:Ge,collisionCircle:qe,debug:We,fill:Ze,fillOutline:Xe,fillOutlinePattern:Je,fillPattern:Ke,fillExtrusion:Qe,fillExtrusionPattern:$e,hillshadePrepare:tr,hillshade:er,line:rr,lineGradient:nr,linePattern:ir,lineSDF:ar,raster:or,symbolIcon:sr,symbolSDF:lr}),hr=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};hr.prototype.bind=function(t,e,r,n,i,a,o,s){this.context=t;for(var l=this.boundPaintVertexBuffers.length!==n.length,c=0;!l&&c>16,l>>16],u_pixel_coord_lower:[65535&s,65535&l]}}fr.prototype.draw=function(t,e,r,n,i,a,o,s,l,c,u,h,f,p,d,g){var m,v=t.gl;for(var y in t.program.set(this.program),t.setDepthMode(r),t.setStencilMode(n),t.setColorMode(i),t.setCullFace(a),this.fixedUniforms)this.fixedUniforms[y].set(o[y]);p&&p.setUniforms(t,this.binderUniforms,h,{zoom:f});for(var x=(m={},m[v.LINES]=2,m[v.TRIANGLES]=3,m[v.LINE_STRIP]=1,m)[e],b=0,_=u.get();b<_.length;b+=1){var w=_[b],A=w.vaos||(w.vaos={});(A[s]||(A[s]=new hr)).bind(t,this,l,p?p.getPaintVertexBuffers():[],c,w.vertexOffset,d,g),v.drawElements(e,w.primitiveLength*x,v.UNSIGNED_SHORT,w.primitiveOffset*x*2)}};var dr=function(e,r,n,i){var a=r.style.light,o=a.properties.get("position"),s=[o.x,o.y,o.z],l=t.create$1();"viewport"===a.properties.get("anchor")&&t.fromRotation(l,-r.transform.angle),t.transformMat3(s,s,l);var c=a.properties.get("color");return{u_matrix:e,u_lightpos:s,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+n,u_opacity:i}},gr=function(e,r,n,i,a,o,s){return t.extend(dr(e,r,n,i),pr(o,r,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8})},mr=function(t){return{u_matrix:t}},vr=function(e,r,n,i){return t.extend(mr(e),pr(n,r,i))},yr=function(t,e){return{u_matrix:t,u_world:e}},xr=function(e,r,n,i,a){return t.extend(vr(e,r,n,i),{u_world:a})},br=function(e,r,n,i){var a,o,s=e.transform;if("map"===i.paint.get("circle-pitch-alignment")){var l=ce(n,1,s.zoom);a=!0,o=[l,l]}else a=!1,o=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_matrix:e.translatePosMatrix(r.posMatrix,n,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),u_pitch_with_map:+a,u_device_pixel_ratio:t.browser.devicePixelRatio,u_extrude_scale:o}},_r=function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,r.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,r.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,r.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,r.u_overscale_factor)}},wr=function(t,e,r){var n=ce(r,1,e.zoom),i=Math.pow(2,e.zoom-r.tileID.overscaledZ),a=r.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:n,u_extrude_scale:[e.pixelsToGLUnits[0]/(n*i),e.pixelsToGLUnits[1]/(n*i)],u_overscale_factor:a}},Ar=function(t,e){return{u_matrix:t,u_color:e}},Cr=function(t){return{u_matrix:t}},Mr=function(t,e,r,n){return{u_matrix:t,u_extrude_scale:ce(e,1,r),u_intensity:n}},kr=function(t,e,r){var n=r.paint.get("hillshade-shadow-color"),i=r.paint.get("hillshade-highlight-color"),a=r.paint.get("hillshade-accent-color"),o=r.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===r.paint.get("hillshade-illumination-anchor")&&(o-=t.transform.angle);var s=!t.options.moving;return{u_matrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),s),u_image:0,u_latrange:Tr(0,e.tileID),u_light:[r.paint.get("hillshade-exaggeration"),o],u_shadow:n,u_highlight:i,u_accent:a}},Ir=function(e,r){var n=e.dem.stride,i=t.create();return t.ortho(i,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(i,i,[0,-t.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[n,n],u_zoom:e.tileID.overscaledZ,u_maxzoom:r}};function Tr(e,r){var n=Math.pow(2,r.canonical.z),i=r.canonical.y;return[new t.MercatorCoordinate(0,i/n).toLngLat().lat,new t.MercatorCoordinate(0,(i+1)/n).toLngLat().lat]}var Lr=function(e,r,n){var i=e.transform;return{u_matrix:Or(e,r,n),u_ratio:1/ce(r,1,i.zoom),u_device_pixel_ratio:t.browser.devicePixelRatio,u_units_to_pixels:[1/i.pixelsToGLUnits[0],1/i.pixelsToGLUnits[1]]}},Sr=function(e,r,n){return t.extend(Lr(e,r,n),{u_image:0})},Er=function(e,r,n,i){var a=e.transform,o=Pr(r,a);return{u_matrix:Or(e,r,n),u_texsize:r.imageAtlasTexture.size,u_ratio:1/ce(r,1,a.zoom),u_device_pixel_ratio:t.browser.devicePixelRatio,u_image:0,u_scale:[t.browser.devicePixelRatio,o,i.fromScale,i.toScale],u_fade:i.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Dr=function(e,r,n,i,a){var o=e.transform,s=e.lineAtlas,l=Pr(r,o),c="round"===n.layout.get("line-cap"),u=s.getDash(i.from,c),h=s.getDash(i.to,c),f=u.width*a.fromScale,p=h.width*a.toScale;return t.extend(Lr(e,r,n),{u_patternscale_a:[l/f,-u.height/2],u_patternscale_b:[l/p,-h.height/2],u_sdfgamma:s.width/(256*Math.min(f,p)*t.browser.devicePixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:h.y,u_mix:a.t})};function Pr(t,e){return 1/ce(t,1,e.tileZoom)}function Or(t,e,r){return t.translatePosMatrix(e.tileID.posMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}var zr=function(t,e,r,n,i){return{u_matrix:t,u_tl_parent:e,u_scale_parent:r,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(o=i.paint.get("raster-saturation"),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Rr(i.paint.get("raster-hue-rotate"))};var a,o};function Rr(t){t*=Math.PI/180;var e=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*e-r+1)/3,(Math.sqrt(3)*e-r+1)/3]}var Fr=function(t,e,r,n,i,a,o,s,l,c){var u=i.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:u.cameraToCenterDistance,u_pitch:u.pitch/360*2*Math.PI,u_rotate_symbol:+r,u_aspect_ratio:u.width/u.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+n,u_texsize:c,u_texture:0}},Nr=function(e,r,n,i,a,o,s,l,c,u,h){var f=a.transform;return t.extend(Fr(e,r,n,i,a,o,s,l,c,u),{u_gamma_scale:i?Math.cos(f._pitch)*f.cameraToCenterDistance:1,u_device_pixel_ratio:t.browser.devicePixelRatio,u_is_halo:+h})},jr=function(t,e,r){return{u_matrix:t,u_opacity:e,u_color:r}},Br=function(e,r,n,i,a,o){return t.extend(function(t,e,r,n){var i=r.imageManager.getPattern(t.from),a=r.imageManager.getPattern(t.to),o=r.imageManager.getPixelSize(),s=o.width,l=o.height,c=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(n.tileID.canonical.x+n.tileID.wrap*c),f=u*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[s,l],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/ce(n,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,f>>16],u_pixel_coord_lower:[65535&h,65535&f]}}(i,o,n,a),{u_matrix:e,u_opacity:r})},Yr={fillExtrusion:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_lightpos:new t.Uniform3f(e,r.u_lightpos),u_lightintensity:new t.Uniform1f(e,r.u_lightintensity),u_lightcolor:new t.Uniform3f(e,r.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,r.u_vertical_gradient),u_opacity:new t.Uniform1f(e,r.u_opacity)}},fillExtrusionPattern:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_lightpos:new t.Uniform3f(e,r.u_lightpos),u_lightintensity:new t.Uniform1f(e,r.u_lightintensity),u_lightcolor:new t.Uniform3f(e,r.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,r.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,r.u_height_factor),u_image:new t.Uniform1i(e,r.u_image),u_texsize:new t.Uniform2f(e,r.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,r.u_pixel_coord_lower),u_scale:new t.Uniform4f(e,r.u_scale),u_fade:new t.Uniform1f(e,r.u_fade),u_opacity:new t.Uniform1f(e,r.u_opacity)}},fill:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix)}},fillPattern:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_image:new t.Uniform1i(e,r.u_image),u_texsize:new t.Uniform2f(e,r.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,r.u_pixel_coord_lower),u_scale:new t.Uniform4f(e,r.u_scale),u_fade:new t.Uniform1f(e,r.u_fade)}},fillOutline:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_world:new t.Uniform2f(e,r.u_world)}},fillOutlinePattern:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_world:new t.Uniform2f(e,r.u_world),u_image:new t.Uniform1i(e,r.u_image),u_texsize:new t.Uniform2f(e,r.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,r.u_pixel_coord_lower),u_scale:new t.Uniform4f(e,r.u_scale),u_fade:new t.Uniform1f(e,r.u_fade)}},circle:function(e,r){return{u_camera_to_center_distance:new t.Uniform1f(e,r.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,r.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,r.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,r.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,r.u_matrix)}},collisionBox:_r,collisionCircle:_r,debug:function(e,r){return{u_color:new t.UniformColor(e,r.u_color),u_matrix:new t.UniformMatrix4f(e,r.u_matrix)}},clippingMask:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix)}},heatmap:function(e,r){return{u_extrude_scale:new t.Uniform1f(e,r.u_extrude_scale),u_intensity:new t.Uniform1f(e,r.u_intensity),u_matrix:new t.UniformMatrix4f(e,r.u_matrix)}},heatmapTexture:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_world:new t.Uniform2f(e,r.u_world),u_image:new t.Uniform1i(e,r.u_image),u_color_ramp:new t.Uniform1i(e,r.u_color_ramp),u_opacity:new t.Uniform1f(e,r.u_opacity)}},hillshade:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_image:new t.Uniform1i(e,r.u_image),u_latrange:new t.Uniform2f(e,r.u_latrange),u_light:new t.Uniform2f(e,r.u_light),u_shadow:new t.UniformColor(e,r.u_shadow),u_highlight:new t.UniformColor(e,r.u_highlight),u_accent:new t.UniformColor(e,r.u_accent)}},hillshadePrepare:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_image:new t.Uniform1i(e,r.u_image),u_dimension:new t.Uniform2f(e,r.u_dimension),u_zoom:new t.Uniform1f(e,r.u_zoom),u_maxzoom:new t.Uniform1f(e,r.u_maxzoom)}},line:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_ratio:new t.Uniform1f(e,r.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,r.u_units_to_pixels)}},lineGradient:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_ratio:new t.Uniform1f(e,r.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,r.u_units_to_pixels),u_image:new t.Uniform1i(e,r.u_image)}},linePattern:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_texsize:new t.Uniform2f(e,r.u_texsize),u_ratio:new t.Uniform1f(e,r.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_image:new t.Uniform1i(e,r.u_image),u_units_to_pixels:new t.Uniform2f(e,r.u_units_to_pixels),u_scale:new t.Uniform4f(e,r.u_scale),u_fade:new t.Uniform1f(e,r.u_fade)}},lineSDF:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_ratio:new t.Uniform1f(e,r.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,r.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,r.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,r.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,r.u_sdfgamma),u_image:new t.Uniform1i(e,r.u_image),u_tex_y_a:new t.Uniform1f(e,r.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,r.u_tex_y_b),u_mix:new t.Uniform1f(e,r.u_mix)}},raster:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_tl_parent:new t.Uniform2f(e,r.u_tl_parent),u_scale_parent:new t.Uniform1f(e,r.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,r.u_buffer_scale),u_fade_t:new t.Uniform1f(e,r.u_fade_t),u_opacity:new t.Uniform1f(e,r.u_opacity),u_image0:new t.Uniform1i(e,r.u_image0),u_image1:new t.Uniform1i(e,r.u_image1),u_brightness_low:new t.Uniform1f(e,r.u_brightness_low),u_brightness_high:new t.Uniform1f(e,r.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,r.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,r.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,r.u_spin_weights)}},symbolIcon:function(e,r){return{u_is_size_zoom_constant:new t.Uniform1i(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,r.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,r.u_size_t),u_size:new t.Uniform1f(e,r.u_size),u_camera_to_center_distance:new t.Uniform1f(e,r.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,r.u_pitch),u_rotate_symbol:new t.Uniform1i(e,r.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,r.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,r.u_fade_change),u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,r.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,r.u_coord_matrix),u_is_text:new t.Uniform1f(e,r.u_is_text),u_pitch_with_map:new t.Uniform1i(e,r.u_pitch_with_map),u_texsize:new t.Uniform2f(e,r.u_texsize),u_texture:new t.Uniform1i(e,r.u_texture)}},symbolSDF:function(e,r){return{u_is_size_zoom_constant:new t.Uniform1i(e,r.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,r.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,r.u_size_t),u_size:new t.Uniform1f(e,r.u_size),u_camera_to_center_distance:new t.Uniform1f(e,r.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,r.u_pitch),u_rotate_symbol:new t.Uniform1i(e,r.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,r.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,r.u_fade_change),u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,r.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,r.u_coord_matrix),u_is_text:new t.Uniform1f(e,r.u_is_text),u_pitch_with_map:new t.Uniform1i(e,r.u_pitch_with_map),u_texsize:new t.Uniform2f(e,r.u_texsize),u_texture:new t.Uniform1i(e,r.u_texture),u_gamma_scale:new t.Uniform1f(e,r.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,r.u_device_pixel_ratio),u_is_halo:new t.Uniform1f(e,r.u_is_halo)}},background:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_opacity:new t.Uniform1f(e,r.u_opacity),u_color:new t.UniformColor(e,r.u_color)}},backgroundPattern:function(e,r){return{u_matrix:new t.UniformMatrix4f(e,r.u_matrix),u_opacity:new t.Uniform1f(e,r.u_opacity),u_image:new t.Uniform1i(e,r.u_image),u_pattern_tl_a:new t.Uniform2f(e,r.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,r.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,r.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,r.u_pattern_br_b),u_texsize:new t.Uniform2f(e,r.u_texsize),u_mix:new t.Uniform1f(e,r.u_mix),u_pattern_size_a:new t.Uniform2f(e,r.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,r.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,r.u_scale_a),u_scale_b:new t.Uniform1f(e,r.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,r.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,r.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,r.u_tile_units_to_pixels)}}};function Vr(e,r){for(var n=e.sort((function(t,e){return t.tileID.isLessThan(e.tileID)?-1:e.tileID.isLessThan(t.tileID)?1:0})),i=0;i0){var s=t.browser.now(),l=(s-e.timeAdded)/o,c=r?(s-r.timeAdded)/o:-1,u=n.getSource(),h=a.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),f=!r||Math.abs(r.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),p=f&&e.refreshedUponExpiration?1:t.clamp(f?l:1-c,0,1);return e.refreshedUponExpiration&&l>=1&&(e.refreshedUponExpiration=!1),r?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}function rn(e,r,n){var i=e.context,a=i.gl,o=n.posMatrix,s=e.useProgram("debug"),l=Mt.disabled,c=kt.disabled,u=e.colorModeForRenderPass(),h="$debug";s.draw(i,a.LINE_STRIP,l,c,u,Tt.disabled,Ar(o,t.Color.red),h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);for(var f=r.getTileByID(n.key).latestRawTileData,p=f&&f.byteLength||0,d=Math.floor(p/1024),g=r.getTile(n).tileSize,m=512/Math.min(g,512),v=function(t,e,r,n){n=n||1;var i,a,o,s,l,c,u,h,f=[];for(i=0,a=t.length;i":[24,[4,18,20,9,4,0]],"?":[18,[3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,-1,-1,9,2,8,1,9,0,10,1,9,2]],"@":[27,[18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,-1,-1,12,16,10,14,9,11,9,8,10,6,11,5,-1,-1,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,-1,-1,19,16,18,8,18,6,19,5]],A:[18,[9,21,1,0,-1,-1,9,21,17,0,-1,-1,4,7,14,7]],B:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,-1,-1,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0]],C:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5]],D:[21,[4,21,4,0,-1,-1,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0]],E:[19,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11,-1,-1,4,0,17,0]],F:[18,[4,21,4,0,-1,-1,4,21,17,21,-1,-1,4,11,12,11]],G:[21,[18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,-1,-1,13,8,18,8]],H:[22,[4,21,4,0,-1,-1,18,21,18,0,-1,-1,4,11,18,11]],I:[8,[4,21,4,0]],J:[16,[12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7]],K:[21,[4,21,4,0,-1,-1,18,21,4,7,-1,-1,9,12,18,0]],L:[17,[4,21,4,0,-1,-1,4,0,16,0]],M:[24,[4,21,4,0,-1,-1,4,21,12,0,-1,-1,20,21,12,0,-1,-1,20,21,20,0]],N:[22,[4,21,4,0,-1,-1,4,21,18,0,-1,-1,18,21,18,0]],O:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21]],P:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10]],Q:[22,[9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,-1,-1,12,4,18,-2]],R:[21,[4,21,4,0,-1,-1,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,-1,-1,11,11,18,0]],S:[20,[17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3]],T:[16,[8,21,8,0,-1,-1,1,21,15,21]],U:[22,[4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21]],V:[18,[1,21,9,0,-1,-1,17,21,9,0]],W:[24,[2,21,7,0,-1,-1,12,21,7,0,-1,-1,12,21,17,0,-1,-1,22,21,17,0]],X:[20,[3,21,17,0,-1,-1,17,21,3,0]],Y:[18,[1,21,9,11,9,0,-1,-1,17,21,9,11]],Z:[20,[17,21,3,0,-1,-1,3,21,17,21,-1,-1,3,0,17,0]],"[":[14,[4,25,4,-7,-1,-1,5,25,5,-7,-1,-1,4,25,11,25,-1,-1,4,-7,11,-7]],"\\":[14,[0,21,14,-3]],"]":[14,[9,25,9,-7,-1,-1,10,25,10,-7,-1,-1,3,25,10,25,-1,-1,3,-7,10,-7]],"^":[16,[6,15,8,18,10,15,-1,-1,3,12,8,17,13,12,-1,-1,8,17,8,0]],_:[16,[0,-2,16,-2]],"`":[10,[6,21,5,20,4,18,4,16,5,15,6,16,5,17]],a:[19,[15,14,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],b:[19,[4,21,4,0,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],c:[18,[15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],d:[19,[15,21,15,0,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],e:[18,[3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],f:[12,[10,21,8,21,6,20,5,17,5,0,-1,-1,2,14,9,14]],g:[19,[15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],h:[19,[4,21,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],i:[8,[3,21,4,20,5,21,4,22,3,21,-1,-1,4,14,4,0]],j:[10,[5,21,6,20,7,21,6,22,5,21,-1,-1,6,14,6,-3,5,-6,3,-7,1,-7]],k:[17,[4,21,4,0,-1,-1,14,14,4,4,-1,-1,8,8,15,0]],l:[8,[4,21,4,0]],m:[30,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0,-1,-1,15,10,18,13,20,14,23,14,25,13,26,10,26,0]],n:[19,[4,14,4,0,-1,-1,4,10,7,13,9,14,12,14,14,13,15,10,15,0]],o:[19,[8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14]],p:[19,[4,14,4,-7,-1,-1,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3]],q:[19,[15,14,15,-7,-1,-1,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3]],r:[13,[4,14,4,0,-1,-1,4,8,5,11,7,13,9,14,12,14]],s:[17,[14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3]],t:[12,[5,21,5,4,6,1,8,0,10,0,-1,-1,2,14,9,14]],u:[19,[4,14,4,4,5,1,7,0,10,0,12,1,15,4,-1,-1,15,14,15,0]],v:[16,[2,14,8,0,-1,-1,14,14,8,0]],w:[22,[3,14,7,0,-1,-1,11,14,7,0,-1,-1,11,14,15,0,-1,-1,19,14,15,0]],x:[17,[3,14,14,0,-1,-1,14,14,3,0]],y:[16,[2,14,8,0,-1,-1,14,14,8,0,6,-4,4,-6,2,-7,1,-7]],z:[17,[14,14,3,0,-1,-1,3,14,14,14,-1,-1,3,0,14,0]],"{":[14,[9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,-1,-1,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,-1,-1,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7]],"|":[8,[4,25,4,-7]],"}":[14,[5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,-1,-1,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,-1,-1,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7]],"~":[24,[3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,-1,-1,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]]},an={symbol:function(t,e,r,n,i){if("translucent"===t.renderPass){var a=kt.disabled,o=t.colorModeForRenderPass();0!==r.paint.get("icon-opacity").constantOr(1)&&Xr(t,e,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,o,i),0!==r.paint.get("text-opacity").constantOr(1)&&Xr(t,e,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,o,i),e.map.showCollisionBoxes&&function(t,e,r,n){Hr(t,e,r,n,!1),Hr(t,e,r,n,!0)}(t,e,r,n)}},circle:function(e,r,n,i){if("translucent"===e.renderPass){var a=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),s=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1);if(0!==a.constantOr(1)||0!==o.constantOr(1)&&0!==s.constantOr(1)){for(var c=e.context,u=c.gl,h=e.depthModeForSublayer(0,Mt.ReadOnly),f=kt.disabled,p=e.colorModeForRenderPass(),d=[],g=0;ge.y){var r=t;t=e,e=r}return{x0:t.x,y0:t.y,x1:e.x,y1:e.y,dx:e.x-t.x,dy:e.y-t.y}}function ln(t,e,r,n,i){var a=Math.max(r,Math.floor(e.y0)),o=Math.min(n,Math.ceil(e.y1));if(t.x0===e.x0&&t.y0===e.y0?t.x0+e.dy/t.dy*t.dx0,h=e.dx<0,f=a;fl.dy&&(o=s,s=l,l=o),s.dy>c.dy&&(o=s,s=c,c=o),l.dy>c.dy&&(o=l,l=c,c=o),s.dy&&ln(c,s,n,i,a),l.dy&&ln(c,l,n,i,a)}on.prototype.resize=function(e,r){var n=this.context.gl;if(this.width=e*t.browser.devicePixelRatio,this.height=r*t.browser.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var i=0,a=this.style._order;i256&&this.clearStencil(),r.setColorMode(It.disabled),r.setDepthMode(Mt.disabled);var i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(var a=0,o=e;a256&&this.clearStencil();var t=this.nextStencilID++,e=this.context.gl;return new kt({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)},on.prototype.stencilModeForClipping=function(t){var e=this.context.gl;return new kt({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)},on.prototype.colorModeForRenderPass=function(){var e=this.context.gl;return this._showOverdrawInspector?new It([e.CONSTANT_COLOR,e.ONE],new t.Color(1/8,1/8,1/8,0),[!0,!0,!0,!0]):"opaque"===this.renderPass?It.unblended:It.alphaBlended},on.prototype.depthModeForSublayer=function(t,e,r){if(!this.opaquePassEnabledForLayer())return Mt.disabled;var n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Mt(r||this.context.gl.LEQUAL,e,[n,n])},on.prototype.opaquePassEnabledForLayer=function(){return this.currentLayer=0;this.currentLayer--){var k=this.style._layers[n[this.currentLayer]],I=i[k.source],T=s[k.source];this._renderTileClippingMasks(k,T),this.renderLayer(this,I,k,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer0?e.pop():null},on.prototype.isPatternMissing=function(t){if(!t)return!1;var e=this.imageManager.getPattern(t.from),r=this.imageManager.getPattern(t.to);return!e||!r},on.prototype.useProgram=function(t,e){void 0===e&&(e=this.emptyProgramConfiguration),this.cache=this.cache||{};var r=""+t+(e.cacheKey||"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[r]||(this.cache[r]=new fr(this.context,ur[t],e,Yr[t],this._showOverdrawInspector)),this.cache[r]},on.prototype.setCustomLayerDefaults=function(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()},on.prototype.setBaseState=function(){var t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)};var un=function(e,r,n){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=r||22,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._posMatrixCache={},this._alignedPosMatrixCache={}},hn={minZoom:{configurable:!0},maxZoom:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerPoint:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},unmodified:{configurable:!0},point:{configurable:!0}};un.prototype.clone=function(){var t=new un(this._minZoom,this._maxZoom,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._calcMatrices(),t},hn.minZoom.get=function(){return this._minZoom},hn.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},hn.maxZoom.get=function(){return this._maxZoom},hn.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},hn.renderWorldCopies.get=function(){return this._renderWorldCopies},hn.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},hn.worldSize.get=function(){return this.tileSize*this.scale},hn.centerPoint.get=function(){return this.size._div(2)},hn.size.get=function(){return new t.Point(this.width,this.height)},hn.bearing.get=function(){return-this.angle/Math.PI*180},hn.bearing.set=function(e){var r=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=t.create$2(),t.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},hn.pitch.get=function(){return this._pitch/Math.PI*180},hn.pitch.set=function(e){var r=t.clamp(e,0,60)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())},hn.fov.get=function(){return this._fov/Math.PI*180},hn.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},hn.zoom.get=function(){return this._zoom},hn.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},hn.center.get=function(){return this._center},hn.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},un.prototype.coveringZoomLevel=function(t){return(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize))},un.prototype.getVisibleUnwrappedCoordinates=function(e){var r=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var n=this.pointCoordinate(new t.Point(0,0)),i=this.pointCoordinate(new t.Point(this.width,0)),a=this.pointCoordinate(new t.Point(this.width,this.height)),o=this.pointCoordinate(new t.Point(0,this.height)),s=Math.floor(Math.min(n.x,i.x,a.x,o.x)),l=Math.floor(Math.max(n.x,i.x,a.x,o.x)),c=s-1;c<=l+1;c++)0!==c&&r.push(new t.UnwrappedTileID(c,e));return r},un.prototype.coveringTiles=function(e){var r=this.coveringZoomLevel(e),n=r;if(void 0!==e.minzoom&&re.maxzoom&&(r=e.maxzoom);var i=t.MercatorCoordinate.fromLngLat(this.center),a=Math.pow(2,r),o=new t.Point(a*i.x-.5,a*i.y-.5);return function(e,r,n,i){void 0===i&&(i=!0);var a=1<=0&&l<=a)for(c=r;co&&(i=o-m)}if(this.lngRange){var v=p.x,y=c.x/2;v-yl&&(n=l-y)}void 0===n&&void 0===i||(this.center=this.unproject(new t.Point(void 0!==n?n:p.x,void 0!==i?i:p.y))),this._unmodified=u,this._constraining=!1}},un.prototype._calcMatrices=function(){if(this.height){this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var e=this._fov/2,r=Math.PI/2+this._pitch,n=Math.sin(e)*this.cameraToCenterDistance/Math.sin(Math.PI-r-e),i=this.point,a=i.x,o=i.y,s=1.01*(Math.cos(Math.PI/2-this._pitch)*n+this.cameraToCenterDistance),l=this.height/50,c=new Float64Array(16);t.perspective(c,this._fov,this.width/this.height,l,s),t.scale(c,c,[1,-1,1]),t.translate(c,c,[0,0,-this.cameraToCenterDistance]),t.rotateX(c,c,this._pitch),t.rotateZ(c,c,this.angle),t.translate(c,c,[-a,-o,0]),this.mercatorMatrix=t.scale([],c,[this.worldSize,this.worldSize,this.worldSize]),t.scale(c,c,[1,1,t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,1]),this.projMatrix=c;var u=this.width%2/2,h=this.height%2/2,f=Math.cos(this.angle),p=Math.sin(this.angle),d=a-Math.round(a)+f*u+p*h,g=o-Math.round(o)+f*h+p*u,m=new Float64Array(c);if(t.translate(m,m,[d>.5?d-1:d,g>.5?g-1:g,0]),this.alignedProjMatrix=m,c=t.create(),t.scale(c,c,[this.width/2,-this.height/2,1]),t.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=t.create(),t.scale(c,c,[1,-1,1]),t.translate(c,c,[-1,-1,0]),t.scale(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),!(c=t.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}},un.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.Point(0,0)),r=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(r,r,this.pixelMatrix)[3]/this.cameraToCenterDistance},un.prototype.getCameraPoint=function(){var e=this._pitch,r=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,r))},un.prototype.getCameraQueryGeometry=function(e){var r=this.getCameraPoint();if(1===e.length)return[e[0],r];for(var n=r.x,i=r.y,a=r.x,o=r.y,s=0,l=e;s=3&&(this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:+(e[3]||0),pitch:+(e[4]||0)}),!0)},fn.prototype._updateHashUnthrottled=function(){var e=this.getHashString();try{t.window.history.replaceState(t.window.history.state,"",e)}catch(t){}};var pn=function(e){function n(n,i,a,o){void 0===o&&(o={});var s=r.mousePos(i.getCanvasContainer(),a),l=i.unproject(s);e.call(this,n,t.extend({point:s,lngLat:l,originalEvent:a},o)),this._defaultPrevented=!1,this.target=i}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},i.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,i),n}(t.Event),dn=function(e){function n(n,i,a){var o=r.touchPos(i.getCanvasContainer(),a),s=o.map((function(t){return i.unproject(t)})),l=o.reduce((function(t,e,r,n){return t.add(e.div(n.length))}),new t.Point(0,0)),c=i.unproject(l);e.call(this,n,{points:o,point:l,lngLats:s,lngLat:c,originalEvent:a}),this._defaultPrevented=!1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={defaultPrevented:{configurable:!0}};return n.prototype.preventDefault=function(){this._defaultPrevented=!0},i.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(n.prototype,i),n}(t.Event),gn=function(t){function e(e,r,n){t.call(this,e,{originalEvent:n}),this._defaultPrevented=!1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={defaultPrevented:{configurable:!0}};return e.prototype.preventDefault=function(){this._defaultPrevented=!0},r.defaultPrevented.get=function(){return this._defaultPrevented},Object.defineProperties(e.prototype,r),e}(t.Event),mn=function(e){this._map=e,this._el=e.getCanvasContainer(),this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=1/450,t.bindAll(["_onWheel","_onTimeout","_onScrollFrame","_onScrollFinished"],this)};mn.prototype.setZoomRate=function(t){this._defaultZoomRate=t},mn.prototype.setWheelZoomRate=function(t){this._wheelZoomRate=t},mn.prototype.isEnabled=function(){return!!this._enabled},mn.prototype.isActive=function(){return!!this._active},mn.prototype.isZooming=function(){return!!this._zooming},mn.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},mn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},mn.prototype.onWheel=function(e){if(this.isEnabled()){var r=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=t.browser.now(),i=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==r&&r%4.000244140625==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),e.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=e,this._delta-=r,this.isActive()||this._start(e)),e.preventDefault()}},mn.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this.isActive()||this._start(t)},mn.prototype._start=function(e){if(this._delta){this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0,this._map.fire(new t.Event("movestart",{originalEvent:e})),this._map.fire(new t.Event("zoomstart",{originalEvent:e}))),this._finishTimeout&&clearTimeout(this._finishTimeout);var n=r.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(n)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame))}},mn.prototype._onScrollFrame=function(){var e=this;if(this._frameId=null,this.isActive()){var r=this._map.transform;if(0!==this._delta){var n="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==i&&(i=1/i);var a="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):r.scale;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(a*i))),"wheel"===this._type&&(this._startZoom=r.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var o="number"==typeof this._targetZoom?this._targetZoom:r.zoom,s=this._startZoom,l=this._easing,c=!1;if("wheel"===this._type&&s&&l){var u=Math.min((t.browser.now()-this._lastWheelEventTime)/200,1),h=l(u);r.zoom=t.number(s,o,h),u<1?this._frameId||(this._frameId=this._map._requestRenderFrame(this._onScrollFrame)):c=!0}else r.zoom=o,c=!0;r.setLocationAtPoint(this._around,this._aroundPoint),this._map.fire(new t.Event("move",{originalEvent:this._lastWheelEvent})),this._map.fire(new t.Event("zoom",{originalEvent:this._lastWheelEvent})),c&&(this._active=!1,this._finishTimeout=setTimeout((function(){e._zooming=!1,e._map.fire(new t.Event("zoomend",{originalEvent:e._lastWheelEvent})),e._map.fire(new t.Event("moveend",{originalEvent:e._lastWheelEvent})),delete e._targetZoom}),200))}},mn.prototype._smoothOutEasing=function(e){var r=t.ease;if(this._prevEase){var n=this._prevEase,i=(t.browser.now()-n.start)/n.duration,a=n.easing(i+.01)-n.easing(i),o=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=t.bezier(o,s,.25,1)}return this._prevEase={start:t.browser.now(),duration:e,easing:r},r};var vn=function(e,r){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=r.clickTolerance||1,t.bindAll(["_onMouseMove","_onMouseUp","_onKeyDown"],this)};vn.prototype.isEnabled=function(){return!!this._enabled},vn.prototype.isActive=function(){return!!this._active},vn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},vn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},vn.prototype.onMouseDown=function(e){this.isEnabled()&&e.shiftKey&&0===e.button&&(t.window.document.addEventListener("mousemove",this._onMouseMove,!1),t.window.document.addEventListener("keydown",this._onKeyDown,!1),t.window.document.addEventListener("mouseup",this._onMouseUp,!1),r.disableDrag(),this._startPos=this._lastPos=r.mousePos(this._el,e),this._active=!0)},vn.prototype._onMouseMove=function(t){var e=r.mousePos(this._el,t);if(!(this._lastPos.equals(e)||!this._box&&e.dist(this._startPos)180&&(p=180);var d=p/180;c+=h*p*(d/2),Math.abs(r._normalizeBearing(c,0))0&&r-e[0][0]>160;)e.shift()};var bn=t.bezier(0,0,.3,1),_n=function(e,r){this._map=e,this._el=e.getCanvasContainer(),this._state="disabled",this._clickTolerance=r.clickTolerance||1,t.bindAll(["_onMove","_onMouseUp","_onTouchEnd","_onBlur","_onDragFrame"],this)};_n.prototype.isEnabled=function(){return"disabled"!==this._state},_n.prototype.isActive=function(){return"active"===this._state},_n.prototype.enable=function(){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-drag-pan"),this._state="enabled")},_n.prototype.disable=function(){if(this.isEnabled())switch(this._el.classList.remove("mapboxgl-touch-drag-pan"),this._state){case"active":this._state="disabled",this._unbind(),this._deactivate(),this._fireEvent("dragend"),this._fireEvent("moveend");break;case"pending":this._state="disabled",this._unbind();break;default:this._state="disabled"}},_n.prototype.onMouseDown=function(e){"enabled"===this._state&&(e.ctrlKey||0!==r.mouseButton(e)||(r.addEventListener(t.window.document,"mousemove",this._onMove,{capture:!0}),r.addEventListener(t.window.document,"mouseup",this._onMouseUp),this._start(e)))},_n.prototype.onTouchStart=function(e){"enabled"===this._state&&(e.touches.length>1||(r.addEventListener(t.window.document,"touchmove",this._onMove,{capture:!0,passive:!1}),r.addEventListener(t.window.document,"touchend",this._onTouchEnd),this._start(e)))},_n.prototype._start=function(e){t.window.addEventListener("blur",this._onBlur),this._state="pending",this._startPos=this._mouseDownPos=this._prevPos=this._lastPos=r.mousePos(this._el,e),this._inertia=[[t.browser.now(),this._startPos]]},_n.prototype._onMove=function(e){e.preventDefault();var n=r.mousePos(this._el,e);this._lastPos.equals(n)||"pending"===this._state&&n.dist(this._mouseDownPos)1400&&(s=1400,o._unit()._mult(s));var l=s/750,c=o.mult(-l/2);this._map.panBy(c,{duration:1e3*l,easing:bn,noMoveStart:!0},{originalEvent:t})}}},_n.prototype._fireEvent=function(e,r){return this._map.fire(new t.Event(e,r?{originalEvent:r}:{}))},_n.prototype._drainInertiaBuffer=function(){for(var e=this._inertia,r=t.browser.now();e.length>0&&r-e[0][0]>160;)e.shift()};var wn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onKeyDown"],this)};function An(t){return t*(2-t)}wn.prototype.isEnabled=function(){return!!this._enabled},wn.prototype.enable=function(){this.isEnabled()||(this._el.addEventListener("keydown",this._onKeyDown,!1),this._enabled=!0)},wn.prototype.disable=function(){this.isEnabled()&&(this._el.removeEventListener("keydown",this._onKeyDown),this._enabled=!1)},wn.prototype._onKeyDown=function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var e=0,r=0,n=0,i=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),i=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),i=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(a=1,t.preventDefault());break;default:return}var o=this._map,s=o.getZoom(),l={duration:300,delayEndEvents:500,easing:An,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+15*r,pitch:o.getPitch()+10*n,offset:[100*-i,100*-a],center:o.getCenter()};o.easeTo(l,{originalEvent:t})}};var Cn=function(e){this._map=e,t.bindAll(["_onDblClick","_onZoomEnd"],this)};Cn.prototype.isEnabled=function(){return!!this._enabled},Cn.prototype.isActive=function(){return!!this._active},Cn.prototype.enable=function(){this.isEnabled()||(this._enabled=!0)},Cn.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},Cn.prototype.onTouchStart=function(t){var e=this;if(this.isEnabled()&&!(t.points.length>1))if(this._tapped){var r=t.points[0],n=this._tappedPoint;if(n&&n.dist(r)<=30){t.originalEvent.preventDefault();var i=function(){e._tapped&&e._zoom(t),e._map.off("touchcancel",a),e._resetTapped()},a=function(){e._map.off("touchend",i),e._resetTapped()};this._map.once("touchend",i),this._map.once("touchcancel",a)}else this._resetTapped()}else this._tappedPoint=t.points[0],this._tapped=setTimeout((function(){e._tapped=null,e._tappedPoint=null}),300)},Cn.prototype._resetTapped=function(){clearTimeout(this._tapped),this._tapped=null,this._tappedPoint=null},Cn.prototype.onDblClick=function(t){this.isEnabled()&&(t.originalEvent.preventDefault(),this._zoom(t))},Cn.prototype._zoom=function(t){this._active=!0,this._map.on("zoomend",this._onZoomEnd),this._map.zoomTo(this._map.getZoom()+(t.originalEvent.shiftKey?-1:1),{around:t.lngLat},t)},Cn.prototype._onZoomEnd=function(){this._active=!1,this._map.off("zoomend",this._onZoomEnd)};var Mn=t.bezier(0,0,.15,1),kn=function(e){this._map=e,this._el=e.getCanvasContainer(),t.bindAll(["_onMove","_onEnd","_onTouchFrame"],this)};kn.prototype.isEnabled=function(){return!!this._enabled},kn.prototype.enable=function(t){this.isEnabled()||(this._el.classList.add("mapboxgl-touch-zoom-rotate"),this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)},kn.prototype.disable=function(){this.isEnabled()&&(this._el.classList.remove("mapboxgl-touch-zoom-rotate"),this._enabled=!1)},kn.prototype.disableRotation=function(){this._rotationDisabled=!0},kn.prototype.enableRotation=function(){this._rotationDisabled=!1},kn.prototype.onStart=function(e){if(this.isEnabled()&&2===e.touches.length){var n=r.mousePos(this._el,e.touches[0]),i=r.mousePos(this._el,e.touches[1]),a=n.add(i).div(2);this._startVec=n.sub(i),this._startAround=this._map.transform.pointLocation(a),this._gestureIntent=void 0,this._inertia=[],r.addEventListener(t.window.document,"touchmove",this._onMove,{passive:!1}),r.addEventListener(t.window.document,"touchend",this._onEnd)}},kn.prototype._getTouchEventData=function(t){var e=r.mousePos(this._el,t.touches[0]),n=r.mousePos(this._el,t.touches[1]),i=e.sub(n);return{vec:i,center:e.add(n).div(2),scale:i.mag()/this._startVec.mag(),bearing:this._rotationDisabled?0:180*i.angleWith(this._startVec)/Math.PI}},kn.prototype._onMove=function(e){if(2===e.touches.length){var r=this._getTouchEventData(e),n=r.vec,i=r.scale,a=r.bearing;if(!this._gestureIntent){var o=this._rotationDisabled&&1!==i||Math.abs(1-i)>.15;Math.abs(a)>10?this._gestureIntent="rotate":o&&(this._gestureIntent="zoom"),this._gestureIntent&&(this._map.fire(new t.Event(this._gestureIntent+"start",{originalEvent:e})),this._map.fire(new t.Event("movestart",{originalEvent:e})),this._startVec=n)}this._lastTouchEvent=e,this._frameId||(this._frameId=this._map._requestRenderFrame(this._onTouchFrame)),e.preventDefault()}},kn.prototype._onTouchFrame=function(){this._frameId=null;var e=this._gestureIntent;if(e){var r=this._map.transform;this._startScale||(this._startScale=r.scale,this._startBearing=r.bearing);var n=this._getTouchEventData(this._lastTouchEvent),i=n.center,a=n.bearing,o=n.scale,s=r.pointLocation(i),l=r.locationPoint(s);"rotate"===e&&(r.bearing=this._startBearing+a),r.zoom=r.scaleZoom(this._startScale*o),r.setLocationAtPoint(this._startAround,l),this._map.fire(new t.Event(e,{originalEvent:this._lastTouchEvent})),this._map.fire(new t.Event("move",{originalEvent:this._lastTouchEvent})),this._drainInertiaBuffer(),this._inertia.push([t.browser.now(),o,i])}},kn.prototype._onEnd=function(e){r.removeEventListener(t.window.document,"touchmove",this._onMove,{passive:!1}),r.removeEventListener(t.window.document,"touchend",this._onEnd);var n=this._gestureIntent,i=this._startScale;if(this._frameId&&(this._map._cancelRenderFrame(this._frameId),this._frameId=null),delete this._gestureIntent,delete this._startScale,delete this._startBearing,delete this._lastTouchEvent,n){this._map.fire(new t.Event(n+"end",{originalEvent:e})),this._drainInertiaBuffer();var a=this._inertia,o=this._map;if(a.length<2)o.snapToNorth({},{originalEvent:e});else{var s=a[a.length-1],l=a[0],c=o.transform.scaleZoom(i*s[1]),u=o.transform.scaleZoom(i*l[1]),h=c-u,f=(s[0]-l[0])/1e3,p=s[2];if(0!==f&&c!==u){var d=.15*h/f;Math.abs(d)>2.5&&(d=d>0?2.5:-2.5);var g=1e3*Math.abs(d/(12*.15)),m=c+d*g/2e3;m<0&&(m=0),o.easeTo({zoom:m,duration:g,easing:Mn,around:this._aroundCenter?o.getCenter():o.unproject(p),noMoveStart:!0},{originalEvent:e})}else o.snapToNorth({},{originalEvent:e})}}},kn.prototype._drainInertiaBuffer=function(){for(var e=this._inertia,r=t.browser.now();e.length>2&&r-e[0][0]>160;)e.shift()};var In={scrollZoom:mn,boxZoom:vn,dragRotate:xn,dragPan:_n,keyboard:wn,doubleClickZoom:Cn,touchZoomRotate:kn},Tn=function(e){function r(r,n){e.call(this),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=n.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}return e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r,r.prototype.getCenter=function(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)},r.prototype.setCenter=function(t,e){return this.jumpTo({center:t},e)},r.prototype.panBy=function(e,r,n){return e=t.Point.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},r),n)},r.prototype.panTo=function(e,r,n){return this.easeTo(t.extend({center:e},r),n)},r.prototype.getZoom=function(){return this.transform.zoom},r.prototype.setZoom=function(t,e){return this.jumpTo({zoom:t},e),this},r.prototype.zoomTo=function(e,r,n){return this.easeTo(t.extend({zoom:e},r),n)},r.prototype.zoomIn=function(t,e){return this.zoomTo(this.getZoom()+1,t,e),this},r.prototype.zoomOut=function(t,e){return this.zoomTo(this.getZoom()-1,t,e),this},r.prototype.getBearing=function(){return this.transform.bearing},r.prototype.setBearing=function(t,e){return this.jumpTo({bearing:t},e),this},r.prototype.rotateTo=function(e,r,n){return this.easeTo(t.extend({bearing:e},r),n)},r.prototype.resetNorth=function(e,r){return this.rotateTo(0,t.extend({duration:1e3},e),r),this},r.prototype.resetNorthPitch=function(e,r){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),r),this},r.prototype.snapToNorth=function(t,e){return Math.abs(this.getBearing())e?1:0})),["bottom","left","right","top"])){var o=this.transform,s=o.project(t.LngLat.convert(e)),l=o.project(t.LngLat.convert(r)),c=s.rotate(-n*Math.PI/180),u=l.rotate(-n*Math.PI/180),h=new t.Point(Math.max(c.x,u.x),Math.max(c.y,u.y)),f=new t.Point(Math.min(c.x,u.x),Math.min(c.y,u.y)),p=h.sub(f),d=(o.width-i.padding.left-i.padding.right)/p.x,g=(o.height-i.padding.top-i.padding.bottom)/p.y;if(!(g<0||d<0)){var m=Math.min(o.scaleZoom(o.scale*Math.min(d,g)),i.maxZoom),v=t.Point.convert(i.offset),y=(i.padding.left-i.padding.right)/2,x=(i.padding.top-i.padding.bottom)/2,b=new t.Point(v.x+y,v.y+x).mult(o.scale/o.zoomScale(m));return{center:o.unproject(s.add(l).div(2).sub(b)),zoom:m,bearing:n}}t.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}else t.warnOnce("options.padding must be a positive number, or an Object with keys 'bottom', 'left', 'right', 'top'")},r.prototype.fitBounds=function(t,e,r){return this._fitInternal(this.cameraForBounds(t,e),e,r)},r.prototype.fitScreenCoordinates=function(e,r,n,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(t.Point.convert(e)),this.transform.pointLocation(t.Point.convert(r)),n,i),i,a)},r.prototype._fitInternal=function(e,r,n){return e?(r=t.extend(e,r)).linear?this.easeTo(r,n):this.flyTo(r,n):this},r.prototype.jumpTo=function(e,r){this.stop();var n=this.transform,i=!1,a=!1,o=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(i=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=t.LngLat.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(a=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.pitch=+e.pitch),this.fire(new t.Event("movestart",r)).fire(new t.Event("move",r)),i&&this.fire(new t.Event("zoomstart",r)).fire(new t.Event("zoom",r)).fire(new t.Event("zoomend",r)),a&&this.fire(new t.Event("rotatestart",r)).fire(new t.Event("rotate",r)).fire(new t.Event("rotateend",r)),o&&this.fire(new t.Event("pitchstart",r)).fire(new t.Event("pitch",r)).fire(new t.Event("pitchend",r)),this.fire(new t.Event("moveend",r))},r.prototype.easeTo=function(e,r){var n=this;this.stop(),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||t.browser.prefersReducedMotion)&&(e.duration=0);var i=this.transform,a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l="zoom"in e?+e.zoom:a,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h=i.centerPoint.add(t.Point.convert(e.offset)),f=i.pointLocation(h),p=t.LngLat.convert(e.center||f);this._normalizeCenter(p);var d,g,m=i.project(f),v=i.project(p).sub(m),y=i.zoomScale(l-a);return e.around&&(d=t.LngLat.convert(e.around),g=i.locationPoint(d)),this._zooming=l!==a,this._rotating=o!==c,this._pitching=u!==s,this._prepareEase(r,e.noMoveStart),clearTimeout(this._easeEndTimeoutID),this._ease((function(e){if(n._zooming&&(i.zoom=t.number(a,l,e)),n._rotating&&(i.bearing=t.number(o,c,e)),n._pitching&&(i.pitch=t.number(s,u,e)),d)i.setLocationAtPoint(d,g);else{var f=i.zoomScale(i.zoom-a),p=l>a?Math.min(2,y):Math.max(.5,y),x=Math.pow(p,1-e),b=i.unproject(m.add(v.mult(e*x)).mult(f));i.setLocationAtPoint(i.renderWorldCopies?b.wrap():b,h)}n._fireMoveEvents(r)}),(function(){e.delayEndEvents?n._easeEndTimeoutID=setTimeout((function(){return n._afterEase(r)}),e.delayEndEvents):n._afterEase(r)}),e),this},r.prototype._prepareEase=function(e,r){this._moving=!0,r||this.fire(new t.Event("movestart",e)),this._zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&this.fire(new t.Event("pitchstart",e))},r.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},r.prototype._afterEase=function(e){var r=this._zooming,n=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),i&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))},r.prototype.flyTo=function(e,r){var n=this;if(t.browser.prefersReducedMotion){var i=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,r)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var a=this.transform,o=this.getZoom(),s=this.getBearing(),l=this.getPitch(),c="zoom"in e?t.clamp(+e.zoom,a.minZoom,a.maxZoom):o,u="bearing"in e?this._normalizeBearing(e.bearing,s):s,h="pitch"in e?+e.pitch:l,f=a.zoomScale(c-o),p=a.centerPoint.add(t.Point.convert(e.offset)),d=a.pointLocation(p),g=t.LngLat.convert(e.center||d);this._normalizeCenter(g);var m=a.project(d),v=a.project(g).sub(m),y=e.curve,x=Math.max(a.width,a.height),b=x/f,_=v.mag();if("minZoom"in e){var w=t.clamp(Math.min(e.minZoom,o,c),a.minZoom,a.maxZoom),A=x/a.zoomScale(w-o);y=Math.sqrt(A/_*2)}var C=y*y;function M(t){var e=(b*b-x*x+(t?-1:1)*C*C*_*_)/(2*(t?b:x)*C*_);return Math.log(Math.sqrt(e*e+1)-e)}function k(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}var T=M(0),L=function(t){return I(T)/I(T+y*t)},S=function(t){return x*((I(T)*(k(e=T+y*t)/I(e))-k(T))/C)/_;var e},E=(M(1)-T)/y;if(Math.abs(_)<1e-6||!isFinite(E)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,r);var D=be.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=s!==u,this._pitching=h!==l,this._prepareEase(r,!1),this._ease((function(e){var i=e*E,f=1/L(i);a.zoom=1===e?c:o+a.scaleZoom(f),n._rotating&&(a.bearing=t.number(s,u,e)),n._pitching&&(a.pitch=t.number(l,h,e));var d=1===e?g:a.unproject(m.add(v.mult(S(i))).mult(f));a.setLocationAtPoint(a.renderWorldCopies?d.wrap():d,p),n._fireMoveEvents(r)}),(function(){return n._afterEase(r)}),e),this},r.prototype.isEasing=function(){return!!this._easeFrameId},r.prototype.stop=function(){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var t=this._onEaseEnd;delete this._onEaseEnd,t.call(this)}return this},r.prototype._ease=function(e,r,n){!1===n.animate||0===n.duration?(e(1),r()):(this._easeStart=t.browser.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},r.prototype._renderFrameCallback=function(){var e=Math.min((t.browser.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},r.prototype._normalizeBearing=function(e,r){e=t.wrap(e,-180,180);var n=Math.abs(e-r);return Math.abs(e-360-r)180?-360:r<-180?360:0}},r}(t.Evented),Ln=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_updateEditLink","_updateData","_updateCompact"],this)};Ln.prototype.getDefaultPosition=function(){return"bottom-right"},Ln.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=r.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._innerContainer=r.create("div","mapboxgl-ctrl-attrib-inner",this._container),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},Ln.prototype.onRemove=function(){r.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0},Ln.prototype._updateEditLink=function(){var e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));var r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){var n=r.reduce((function(t,e,n){return e.value&&(t+=e.key+"="+e.value+(n=0)return!1;return!0}))).join(" | ");o!==this._attribHTML&&(this._attribHTML=o,t.length?(this._innerContainer.innerHTML=o,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}},Ln.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact")};var Sn=function(){t.bindAll(["_updateLogo"],this),t.bindAll(["_updateCompact"],this)};Sn.prototype.onAdd=function(t){this._map=t,this._container=r.create("div","mapboxgl-ctrl");var e=r.create("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label","Mapbox logo"),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container},Sn.prototype.onRemove=function(){r.remove(this._container),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)},Sn.prototype.getDefaultPosition=function(){return"bottom-left"},Sn.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},Sn.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}},Sn.prototype._updateCompact=function(){var t=this._container.children;if(t.length){var e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}};var En=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};En.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},En.prototype.remove=function(t){for(var e=this._currentlyRunning,r=0,n=e?this._queue.concat(e):this._queue;re.maxZoom)throw new Error("maxZoom must be greater than minZoom");var a=new un(e.minZoom,e.maxZoom,e.renderWorldCopies);if(n.call(this,a,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new En,this._controls=[],this._mapId=t.uniqueId(),this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken),"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error("Container '"+e.container+"' not found.")}else{if(!(e.container instanceof Pn))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(function(){return i._update(!1)})),this.on("moveend",(function(){return i._update(!1)})),this.on("zoom",(function(){return i._update(!0)})),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1)),function(t,e){var n=t.getCanvasContainer(),i=null,a=!1,o=null;for(var s in In)t[s]=new In[s](t,e),e.interactive&&e[s]&&t[s].enable(e[s]);r.addEventListener(n,"mouseout",(function(e){t.fire(new pn("mouseout",t,e))})),r.addEventListener(n,"mousedown",(function(i){a=!0,o=r.mousePos(n,i);var s=new pn("mousedown",t,i);t.fire(s),s.defaultPrevented||(e.interactive&&!t.doubleClickZoom.isActive()&&t.stop(),t.boxZoom.onMouseDown(i),t.boxZoom.isActive()||t.dragPan.isActive()||t.dragRotate.onMouseDown(i),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onMouseDown(i))})),r.addEventListener(n,"mouseup",(function(e){var r=t.dragRotate.isActive();i&&!r&&t.fire(new pn("contextmenu",t,i)),i=null,a=!1,t.fire(new pn("mouseup",t,e))})),r.addEventListener(n,"mousemove",(function(e){if(!t.dragPan.isActive()&&!t.dragRotate.isActive()){for(var r=e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new pn("mousemove",t,e))}})),r.addEventListener(n,"mouseover",(function(e){for(var r=e.target;r&&r!==n;)r=r.parentNode;r===n&&t.fire(new pn("mouseover",t,e))})),r.addEventListener(n,"touchstart",(function(r){var n=new dn("touchstart",t,r);t.fire(n),n.defaultPrevented||(e.interactive&&t.stop(),t.boxZoom.isActive()||t.dragRotate.isActive()||t.dragPan.onTouchStart(r),t.touchZoomRotate.onStart(r),t.doubleClickZoom.onTouchStart(n))}),{passive:!1}),r.addEventListener(n,"touchmove",(function(e){t.fire(new dn("touchmove",t,e))}),{passive:!1}),r.addEventListener(n,"touchend",(function(e){t.fire(new dn("touchend",t,e))})),r.addEventListener(n,"touchcancel",(function(e){t.fire(new dn("touchcancel",t,e))})),r.addEventListener(n,"click",(function(i){var a=r.mousePos(n,i);(!o||a.equals(o)||a.dist(o)-1&&this._controls.splice(r,1),e.onRemove(this),this},i.prototype.resize=function(e){var r=this._containerDimensions(),n=r[0],i=r[1];return this._resizeCanvas(n,i),this.transform.resize(n,i),this.painter.resize(n,i),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)).fire(new t.Event("resize",e)).fire(new t.Event("moveend",e)),this},i.prototype.getBounds=function(){return this.transform.getBounds()},i.prototype.getMaxBounds=function(){return this.transform.getMaxBounds()},i.prototype.setMaxBounds=function(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()},i.prototype.setMinZoom=function(t){if((t=null==t?0:t)>=0&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},i.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},i.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update()},i.prototype.getMaxZoom=function(){return this.transform.maxZoom},i.prototype.project=function(e){return this.transform.locationPoint(t.LngLat.convert(e))},i.prototype.unproject=function(e){return this.transform.pointLocation(t.Point.convert(e))},i.prototype.isMoving=function(){return this._moving||this.dragPan.isActive()||this.dragRotate.isActive()||this.scrollZoom.isActive()},i.prototype.isZooming=function(){return this._zooming||this.scrollZoom.isZooming()},i.prototype.isRotating=function(){return this._rotating||this.dragRotate.isActive()},i.prototype.on=function(t,e,r){var i=this;if(void 0===r)return n.prototype.on.call(this,t,e);var a=function(){var n;if("mouseenter"===t||"mouseover"===t){var a=!1;return{layer:e,listener:r,delegates:{mousemove:function(n){var o=i.getLayer(e)?i.queryRenderedFeatures(n.point,{layers:[e]}):[];o.length?a||(a=!0,r.call(i,new pn(t,i,n.originalEvent,{features:o}))):a=!1},mouseout:function(){a=!1}}}}if("mouseleave"===t||"mouseout"===t){var o=!1;return{layer:e,listener:r,delegates:{mousemove:function(n){(i.getLayer(e)?i.queryRenderedFeatures(n.point,{layers:[e]}):[]).length?o=!0:o&&(o=!1,r.call(i,new pn(t,i,n.originalEvent)))},mouseout:function(e){o&&(o=!1,r.call(i,new pn(t,i,e.originalEvent)))}}}}return{layer:e,listener:r,delegates:(n={},n[t]=function(t){var n=i.getLayer(e)?i.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,r.call(i,t),delete t.features)},n)}}();for(var o in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(a),a.delegates)this.on(o,a.delegates[o]);return this},i.prototype.off=function(t,e,r){if(void 0===r)return n.prototype.off.call(this,t,e);if(this._delegatedListeners&&this._delegatedListeners[t])for(var i=this._delegatedListeners[t],a=0;a180;){var s=n.locationPoint(e);if(s.x>=0&&s.y>=0&&s.x<=n.width&&s.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e}Nn.prototype._updateZoomButtons=function(){var t=this._map.getZoom();t===this._map.getMaxZoom()?this._zoomInButton.classList.add("mapboxgl-ctrl-icon-disabled"):this._zoomInButton.classList.remove("mapboxgl-ctrl-icon-disabled"),t===this._map.getMinZoom()?this._zoomOutButton.classList.add("mapboxgl-ctrl-icon-disabled"):this._zoomOutButton.classList.remove("mapboxgl-ctrl-icon-disabled")},Nn.prototype._rotateCompassArrow=function(){var t=this.options.visualizePitch?"scale("+1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)+") rotateX("+this._map.transform.pitch+"deg) rotateZ("+this._map.transform.angle*(180/Math.PI)+"deg)":"rotate("+this._map.transform.angle*(180/Math.PI)+"deg)";this._compassArrow.style.transform=t},Nn.prototype.onAdd=function(t){return this._map=t,this.options.showZoom&&(this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new xn(t,{button:"left",element:this._compass}),r.addEventListener(this._compass,"mousedown",this._handler.onMouseDown),r.addEventListener(this._compass,"touchstart",this._handler.onMouseDown,{passive:!1}),this._handler.enable()),this._container},Nn.prototype.onRemove=function(){r.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),r.removeEventListener(this._compass,"mousedown",this._handler.onMouseDown),r.removeEventListener(this._compass,"touchstart",this._handler.onMouseDown,{passive:!1}),this._handler.disable(),delete this._handler),delete this._map},Nn.prototype._createButton=function(t,e,n){var i=r.create("button",t,this._container);return i.type="button",i.title=e,i.setAttribute("aria-label",e),i.addEventListener("click",n),i};var Bn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Yn(t,e,r){var n=t.classList;for(var i in Bn)n.remove("mapboxgl-"+r+"-anchor-"+i);n.add("mapboxgl-"+r+"-anchor-"+e)}var Vn,Un=function(e){function n(n,i){if(e.call(this),(n instanceof t.window.HTMLElement||i)&&(n=t.extend({element:n},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick"],this),this._anchor=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._draggable=n&&n.draggable||!1,this._state="inactive",n&&n.element)this._element=n.element,this._offset=t.Point.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=r.create("div");var a=r.createNS("http://www.w3.org/2000/svg","svg");a.setAttributeNS(null,"display","block"),a.setAttributeNS(null,"height","41px"),a.setAttributeNS(null,"width","27px"),a.setAttributeNS(null,"viewBox","0 0 27 41");var o=r.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");var s=r.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");var l=r.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");for(var c=0,u=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];c5280?Xn(e,c,f/5280,"mi"):Xn(e,c,f,"ft")}else r&&"nautical"===r.unit?Xn(e,c,h/1852,"nm"):Xn(e,c,h,"m")}function Xn(t,e,r,n){var i,a,o,s=(i=r,(a=Math.pow(10,(""+Math.floor(i)).length-1))*(o=(o=i/a)>=10?10:o>=5?5:o>=3?3:o>=2?2:o>=1?1:function(t){var e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(o))),l=s/r;"m"===n&&s>=1e3&&(s/=1e3,n="km"),t.style.width=e*l+"px",t.innerHTML=s+n}Wn.prototype.getDefaultPosition=function(){return"bottom-left"},Wn.prototype._onMove=function(){Zn(this._map,this._container,this.options)},Wn.prototype.onAdd=function(t){return this._map=t,this._container=r.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},Wn.prototype.onRemove=function(){r.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},Wn.prototype.setUnit=function(t){this.options.unit=t,Zn(this._map,this._container,this.options)};var Jn=function(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.window.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.window.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.window.document&&(this._fullscreenchange="MSFullscreenChange"),this._className="mapboxgl-ctrl"};Jn.prototype.onAdd=function(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=r.create("div",this._className+" mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer},Jn.prototype.onRemove=function(){r.remove(this._controlContainer),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)},Jn.prototype._checkFullscreenSupport=function(){return!!(t.window.document.fullscreenEnabled||t.window.document.mozFullScreenEnabled||t.window.document.msFullscreenEnabled||t.window.document.webkitFullscreenEnabled)},Jn.prototype._setupUI=function(){(this._fullscreenButton=r.create("button",this._className+"-icon "+this._className+"-fullscreen",this._controlContainer)).type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)},Jn.prototype._updateTitle=function(){var t=this._isFullscreen()?"Exit fullscreen":"Enter fullscreen";this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t},Jn.prototype._isFullscreen=function(){return this._fullscreen},Jn.prototype._changeIcon=function(){(t.window.document.fullscreenElement||t.window.document.mozFullScreenElement||t.window.document.webkitFullscreenElement||t.window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(this._className+"-shrink"),this._fullscreenButton.classList.toggle(this._className+"-fullscreen"),this._updateTitle())},Jn.prototype._onClickFullscreen=function(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.mozCancelFullScreen?t.window.document.mozCancelFullScreen():t.window.document.msExitFullscreen?t.window.document.msExitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()};var Kn={closeButton:!0,closeOnClick:!0,className:"",maxWidth:"240px"},Qn=function(e){function n(r){e.call(this),this.options=t.extend(Object.create(Kn),r),t.bindAll(["_update","_onClickClose","remove"],this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.addTo=function(e){var r=this;return this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClickClose),this._map.on("remove",this.remove),this._update(),this._trackPointer?(this._map.on("mousemove",(function(t){r._update(t.point)})),this._map.on("mouseup",(function(t){r._update(t.point)})),this._container.classList.add("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this},n.prototype.isOpen=function(){return!!this._map},n.prototype.remove=function(){return this._content&&r.remove(this._content),this._container&&(r.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("click",this._onClickClose),this._map.off("remove",this.remove),this._map.off("mousemove"),delete this._map),this.fire(new t.Event("close")),this},n.prototype.getLngLat=function(){return this._lngLat},n.prototype.setLngLat=function(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove"),this._container.classList.remove("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this},n.prototype.trackPointer=function(){var t=this;return this._trackPointer=!0,this._pos=null,this._map&&(this._map.off("move",this._update),this._map.on("mousemove",(function(e){t._update(e.point)})),this._map.on("drag",(function(e){t._update(e.point)})),this._container.classList.add("mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this},n.prototype.getElement=function(){return this._container},n.prototype.setText=function(e){return this.setDOMContent(t.window.document.createTextNode(e))},n.prototype.setHTML=function(e){var r,n=t.window.document.createDocumentFragment(),i=t.window.document.createElement("body");for(i.innerHTML=e;r=i.firstChild;)n.appendChild(r);return this.setDOMContent(n)},n.prototype.getMaxWidth=function(){return this._container.style.maxWidth},n.prototype.setMaxWidth=function(t){return this.options.maxWidth=t,this._update(),this},n.prototype.setDOMContent=function(t){return this._createContent(),this._content.appendChild(t),this._update(),this},n.prototype._createContent=function(){this._content&&r.remove(this._content),this._content=r.create("div","mapboxgl-popup-content",this._container),this.options.closeButton&&(this._closeButton=r.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClickClose))},n.prototype._update=function(e){var n=this,i=this._lngLat||this._trackPointer;if(this._map&&i&&this._content&&(this._container||(this._container=r.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=r.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((function(t){return n._container.classList.add(t)}))),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=jn(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||e)){var a=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat),o=this.options.anchor,s=function e(r){if(r){if("number"==typeof r){var n=Math.round(Math.sqrt(.5*Math.pow(r,2)));return{center:new t.Point(0,0),top:new t.Point(0,r),"top-left":new t.Point(n,n),"top-right":new t.Point(-n,n),bottom:new t.Point(0,-r),"bottom-left":new t.Point(n,-n),"bottom-right":new t.Point(-n,-n),left:new t.Point(r,0),right:new t.Point(-r,0)}}if(r instanceof t.Point||Array.isArray(r)){var i=t.Point.convert(r);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.Point.convert(r.center||[0,0]),top:t.Point.convert(r.top||[0,0]),"top-left":t.Point.convert(r["top-left"]||[0,0]),"top-right":t.Point.convert(r["top-right"]||[0,0]),bottom:t.Point.convert(r.bottom||[0,0]),"bottom-left":t.Point.convert(r["bottom-left"]||[0,0]),"bottom-right":t.Point.convert(r["bottom-right"]||[0,0]),left:t.Point.convert(r.left||[0,0]),right:t.Point.convert(r.right||[0,0])}}return e(new t.Point(0,0))}(this.options.offset);if(!o){var l,c=this._container.offsetWidth,u=this._container.offsetHeight;l=a.y+s.bottom.ythis._map.transform.height-u?["bottom"]:[],a.xthis._map.transform.width-c/2&&l.push("right"),o=0===l.length?"bottom":l.join("-")}var h=a.add(s[o]).round();r.setTransform(this._container,Bn[o]+" translate("+h.x+"px,"+h.y+"px)"),Yn(this._container,o,"popup")}},n.prototype._onClickClose=function(){this.remove()},n}(t.Evented),$n={version:t.version,supported:e,setRTLTextPlugin:t.setRTLTextPlugin,Map:zn,NavigationControl:Nn,GeolocateControl:Gn,AttributionControl:Ln,ScaleControl:Wn,FullscreenControl:Jn,Popup:Qn,Marker:Un,Style:Re,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,Evented:t.Evented,config:t.config,get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ot.workerCount},set workerCount(t){Ot.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage:function(e){t.clearTileCache(e)},workerUrl:""};return $n})),r}))},{}],429:[function(t,e,r){"use strict";e.exports=function(t){for(var e=1<p[1][2]&&(v[0]=-v[0]),p[0][2]>p[2][0]&&(v[1]=-v[1]),p[1][0]>p[0][1]&&(v[2]=-v[2]),!0}},{"./normalize":431,"gl-mat4/clone":262,"gl-mat4/create":263,"gl-mat4/determinant":264,"gl-mat4/invert":268,"gl-mat4/transpose":279,"gl-vec3/cross":336,"gl-vec3/dot":341,"gl-vec3/length":351,"gl-vec3/normalize":358}],431:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;i<16;i++)t[i]=e[i]*n;return!0}},{}],432:[function(t,e,r){var n=t("gl-vec3/lerp"),i=t("mat4-recompose"),a=t("mat4-decompose"),o=t("gl-mat4/determinant"),s=t("quat-slerp"),l=h(),c=h(),u=h();function h(){return{translate:f(),scale:f(1),skew:f(),perspective:[0,0,0,1],quaternion:[0,0,0,1]}}function f(t){return[t||0,t||0,t||0]}e.exports=function(t,e,r,h){if(0===o(e)||0===o(r))return!1;var f=a(e,l.translate,l.scale,l.skew,l.perspective,l.quaternion),p=a(r,c.translate,c.scale,c.skew,c.perspective,c.quaternion);return!(!f||!p||(n(u.translate,l.translate,c.translate,h),n(u.skew,l.skew,c.skew,h),n(u.scale,l.scale,c.scale,h),n(u.perspective,l.perspective,c.perspective,h),s(u.quaternion,l.quaternion,c.quaternion,h),i(t,u.translate,u.scale,u.skew,u.perspective,u.quaternion),0))}},{"gl-mat4/determinant":264,"gl-vec3/lerp":352,"mat4-decompose":430,"mat4-recompose":433,"quat-slerp":485}],433:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":263,"gl-mat4/fromRotationTranslation":266,"gl-mat4/identity":267,"gl-mat4/multiply":270,"gl-mat4/scale":277,"gl-mat4/translate":278}],434:[function(t,e,r){"use strict";e.exports=Math.log2||function(t){return Math.log(t)*Math.LOG2E}},{}],435:[function(t,e,r){"use strict";var n=t("binary-search-bounds"),i=t("mat4-interpolate"),a=t("gl-mat4/invert"),o=t("gl-mat4/rotateX"),s=t("gl-mat4/rotateY"),l=t("gl-mat4/rotateZ"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/translate"),h=(t("gl-mat4/scale"),t("gl-vec3/normalize")),f=[0,0,0];function p(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-1/0,1/0]}e.exports=function(t){return new p((t=t||{}).matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])};var d=p.prototype;d.recalcMatrix=function(t){var e=this._time,r=n.le(e,t),o=this.computedMatrix;if(!(r<0)){var s=this._components;if(r===e.length-1)for(var l=16*r,c=0;c<16;++c)o[c]=s[l++];else{var u=e[r+1]-e[r],f=(l=16*r,this.prevMatrix),p=!0;for(c=0;c<16;++c)f[c]=s[l++];var d=this.nextMatrix;for(c=0;c<16;++c)d[c]=s[l++],p=p&&f[c]===d[c];if(u<1e-6||p)for(c=0;c<16;++c)o[c]=f[c];else i(o,f,d,(t-e[r])/u)}var g=this.computedUp;g[0]=o[1],g[1]=o[5],g[2]=o[9],h(g,g);var m=this.computedInverse;a(m,o);var v=this.computedEye,y=m[15];v[0]=m[12]/y,v[1]=m[13]/y,v[2]=m[14]/y;var x=this.computedCenter,b=Math.exp(this.computedRadius[0]);for(c=0;c<3;++c)x[c]=v[c]-o[2+4*c]*b}},d.idle=function(t){if(!(t1&&n(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&n(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}r=new Array(s.length+o.length-2);for(var h=0,f=(i=0,o.length);i0;--p)r[h++]=s[p];return r};var n=t("robust-orientation")[3]},{"robust-orientation":509}],437:[function(t,e,r){"use strict";e.exports=function(t,e){e||(e=t,t=window);var r=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},s=!1;function l(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==o.alt,o.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==o.shift,o.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==o.control,o.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==o.meta,o.meta=!!t.metaKey),e}function c(t,s){var c=n.x(s),u=n.y(s);"buttons"in s&&(t=0|s.buttons),(t!==r||c!==i||u!==a||l(s))&&(r=0|t,i=c||0,a=u||0,e&&e(r,i,a,o))}function u(t){c(0,t)}function h(){(r||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,r=0,o.shift=o.alt=o.control=o.meta=!1,e&&e(0,0,0,o))}function f(t){l(t)&&e&&e(r,i,a,o)}function p(t){0===n.buttons(t)?c(0,t):c(r,t)}function d(t){c(r|n.buttons(t),t)}function g(t){c(r&~n.buttons(t),t)}function m(){s||(s=!0,t.addEventListener("mousemove",p),t.addEventListener("mousedown",d),t.addEventListener("mouseup",g),t.addEventListener("mouseleave",u),t.addEventListener("mouseenter",u),t.addEventListener("mouseout",u),t.addEventListener("mouseover",u),t.addEventListener("blur",h),t.addEventListener("keyup",f),t.addEventListener("keydown",f),t.addEventListener("keypress",f),t!==window&&(window.addEventListener("blur",h),window.addEventListener("keyup",f),window.addEventListener("keydown",f),window.addEventListener("keypress",f)))}m();var v={element:t};return Object.defineProperties(v,{enabled:{get:function(){return s},set:function(e){e?m():s&&(s=!1,t.removeEventListener("mousemove",p),t.removeEventListener("mousedown",d),t.removeEventListener("mouseup",g),t.removeEventListener("mouseleave",u),t.removeEventListener("mouseenter",u),t.removeEventListener("mouseout",u),t.removeEventListener("mouseover",u),t.removeEventListener("blur",h),t.removeEventListener("keyup",f),t.removeEventListener("keydown",f),t.removeEventListener("keypress",f),t!==window&&(window.removeEventListener("blur",h),window.removeEventListener("keyup",f),window.removeEventListener("keydown",f),window.removeEventListener("keypress",f)))},enumerable:!0},buttons:{get:function(){return r},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),v};var n=t("mouse-event")},{"mouse-event":439}],438:[function(t,e,r){var n={left:0,top:0};e.exports=function(t,e,r){e=e||t.currentTarget||t.srcElement,Array.isArray(r)||(r=[0,0]);var i,a=t.clientX||0,o=t.clientY||0,s=(i=e)===window||i===document||i===document.body?n:i.getBoundingClientRect();return r[0]=a-s.left,r[1]=o-s.top,r}},{}],439:[function(t,e,r){"use strict";function n(t){return t.target||t.srcElement||window}r.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){if(2===(e=t.which))return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1< 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var T=t.getters||[],L=new Array(k),S=0;S=0?L[S]=!0:L[S]=!1;return function(t,e,r,k,I,T){var L=T.length,S=I.length;if(S<2)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var E="extractContour"+I.join("_"),D=[],P=[],O=[],z=0;z0&&j.push(l(z,I[R-1])+"*"+s(I[R-1])),P.push(d(z,I[R])+"=("+j.join("-")+")|0")}for(z=0;z=0;--z)B.push(s(I[z]));for(P.push(w+"=("+B.join("*")+")|0",b+"=mallocUint32("+w+")",x+"=mallocUint32("+w+")",A+"=0"),P.push(g(0)+"=0"),R=1;R<1<0;C=C-1&d)w.push(x+"["+A+"+"+v(C)+"]");for(w.push(y(0)),C=0;C=0;--e)G(e,0);var r=[];for(e=0;e0){",p(I[e]),"=1;"),t(e-1,r|1<=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),a.push("1"),o.push("s["+l+"]-2"));var c=".lo("+a.join()+").hi("+o.join()+")";if(0===a.length&&(c=""),i>0){for(n.push("if(1"),l=0;l=0||e.indexOf(-(l+1))>=0||n.push("&&s[",l,"]>2");for(n.push("){grad",i,"(src.pick(",s.join(),")",c),l=0;l=0||e.indexOf(-(l+1))>=0||n.push(",dst.pick(",s.join(),",",l,")",c);n.push(");")}for(l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",f.join(),")-src.get(",p.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>1){diff(",h,",src.pick(",f.join(),")",c,",src.pick(",p.join(),")",c,");}else{zero(",h,");};");break;case"mirror":0===i?n.push("dst.set(",s.join(),",",u,",0);"):n.push("zero(",h,");");break;case"wrap":var d=s.slice(),g=s.slice();e[l]<0?(d[u]="s["+u+"]-2",g[u]="0"):(d[u]="s["+u+"]-1",g[u]="1"),0===i?n.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",d.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):n.push("if(s[",u,"]>2){diff(",h,",src.pick(",d.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",h,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}i>0&&n.push("};")}for(var s=0;s<1<>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var l={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in l){var e=l[t];r[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var u=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=n({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=n({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=n({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=n({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":148}],447:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;Array.isArray(a);)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":448,ndarray:452}],448:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":148}],449:[function(t,e,r){"use strict";var n=t("typedarray-pool"),i=32;function a(t){switch(t){case"uint8":return[n.mallocUint8,n.freeUint8];case"uint16":return[n.mallocUint16,n.freeUint16];case"uint32":return[n.mallocUint32,n.freeUint32];case"int8":return[n.mallocInt8,n.freeInt8];case"int16":return[n.mallocInt16,n.freeInt16];case"int32":return[n.mallocInt32,n.freeInt32];case"float32":return[n.mallocFloat,n.freeFloat];case"float64":return[n.mallocDouble,n.freeDouble];default:return null}}function o(t){for(var e=[],r=0;r0?s.push(["d",d,"=s",d,"-d",h,"*n",h].join("")):s.push(["d",d,"=s",d].join("")),h=d),0!=(p=t.length-1-l)&&(f>0?s.push(["e",p,"=s",p,"-e",f,"*n",f,",f",p,"=",c[p],"-f",f,"*n",f].join("")):s.push(["e",p,"=s",p,",f",p,"=",c[p]].join("")),f=p)}r.push("var "+s.join(","));var g=["0","n0-1","data","offset"].concat(o(t.length));r.push(["if(n0<=",i,"){","insertionSort(",g.join(","),")}else{","quickSort(",g.join(","),")}"].join("")),r.push("}return "+n);var m=new Function("insertionSort","quickSort",r.join("\n")),v=function(t,e){var r=["'use strict'"],n=["ndarrayInsertionSort",t.join("d"),e].join(""),i=["left","right","data","offset"].concat(o(t.length)),s=a(e),l=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var c=[],u=1;u1){for(r.push("dptr=0;sptr=ptr"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"b){break __l}"].join("")),u=t.length-1;u>=1;--u)r.push("sptr+=e"+u,"dptr+=f"+u,"}");for(r.push("dptr=cptr;sptr=cptr-s0"),u=t.length-1;u>=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"=0;--u)0!==(p=t[u])&&r.push(["for(i",p,"=0;i",p,"scratch)){",f("cptr",h("cptr-s0")),"cptr-=s0","}",f("cptr","scratch"));return r.push("}"),t.length>1&&s&&r.push("free(scratch)"),r.push("} return "+n),s?new Function("malloc","free",r.join("\n"))(s[0],s[1]):new Function(r.join("\n"))()}(t,e),y=function(t,e,r){var n=["'use strict'"],s=["ndarrayQuickSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(o(t.length)),c=a(e),u=0;n.push(["function ",s,"(",l.join(","),"){"].join(""));var h=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var f=[],p=1;p=0;--a)0!==(o=t[a])&&n.push(["for(i",o,"=0;i",o,"1)for(a=0;a1?n.push("ptr_shift+=d"+o):n.push("ptr0+=d"+o),n.push("}"))}}function y(e,r,i,a){if(1===r.length)n.push("ptr0="+d(r[0]));else{for(var o=0;o1)for(o=0;o=1;--o)i&&n.push("pivot_ptr+=f"+o),r.length>1?n.push("ptr_shift+=e"+o):n.push("ptr0+=e"+o),n.push("}")}function x(){t.length>1&&c&&n.push("free(pivot1)","free(pivot2)")}function b(e,r){var i="el"+e,a="el"+r;if(t.length>1){var o="__l"+ ++u;y(o,[i,a],!1,["comp=",g("ptr0"),"-",g("ptr1"),"\n","if(comp>0){tmp0=",i,";",i,"=",a,";",a,"=tmp0;break ",o,"}\n","if(comp<0){break ",o,"}"].join(""))}else n.push(["if(",g(d(i)),">",g(d(a)),"){tmp0=",i,";",i,"=",a,";",a,"=tmp0}"].join(""))}function _(e,r){t.length>1?v([e,r],!1,m("ptr0",g("ptr1"))):n.push(m(d(e),g(d(r))))}function w(e,r,i){if(t.length>1){var a="__l"+ ++u;y(a,[r],!0,[e,"=",g("ptr0"),"-pivot",i,"[pivot_ptr]\n","if(",e,"!==0){break ",a,"}"].join(""))}else n.push([e,"=",g(d(r)),"-pivot",i].join(""))}function A(e,r){t.length>1?v([e,r],!1,["tmp=",g("ptr0"),"\n",m("ptr0",g("ptr1")),"\n",m("ptr1","tmp")].join("")):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","tmp=",g("ptr0"),"\n",m("ptr0",g("ptr1")),"\n",m("ptr1","tmp")].join(""))}function C(e,r,i){t.length>1?(v([e,r,i],!1,["tmp=",g("ptr0"),"\n",m("ptr0",g("ptr1")),"\n",m("ptr1",g("ptr2")),"\n",m("ptr2","tmp")].join("")),n.push("++"+r,"--"+i)):n.push(["ptr0=",d(e),"\n","ptr1=",d(r),"\n","ptr2=",d(i),"\n","++",r,"\n","--",i,"\n","tmp=",g("ptr0"),"\n",m("ptr0",g("ptr1")),"\n",m("ptr1",g("ptr2")),"\n",m("ptr2","tmp")].join(""))}function M(t,e){A(t,e),n.push("--"+e)}function k(e,r,i){t.length>1?v([e,r],!0,[m("ptr0",g("ptr1")),"\n",m("ptr1",["pivot",i,"[pivot_ptr]"].join(""))].join("")):n.push(m(d(e),g(d(r))),m(d(r),"pivot"+i))}function I(e,r){n.push(["if((",r,"-",e,")<=",i,"){\n","insertionSort(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}else{\n",s,"(",e,",",r,",data,offset,",o(t.length).join(","),")\n","}"].join(""))}function T(e,r,i){t.length>1?(n.push(["__l",++u,":while(true){"].join("")),v([e],!0,["if(",g("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",u,"}"].join("")),n.push(i,"}")):n.push(["while(",g(d(e)),"===pivot",r,"){",i,"}"].join(""))}return n.push("var "+h.join(",")),b(1,2),b(4,5),b(1,3),b(2,3),b(1,4),b(3,4),b(2,5),b(2,3),b(4,5),t.length>1?v(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",g("ptr1"),"\n","pivot2[pivot_ptr]=",g("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",g("ptr0"),"\n","y=",g("ptr2"),"\n","z=",g("ptr4"),"\n",m("ptr5","x"),"\n",m("ptr6","y"),"\n",m("ptr7","z")].join("")):n.push(["pivot1=",g(d("el2")),"\n","pivot2=",g(d("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",g(d("el1")),"\n","y=",g(d("el3")),"\n","z=",g(d("el5")),"\n",m(d("index1"),"x"),"\n",m(d("index3"),"y"),"\n",m(d("index5"),"z")].join("")),_("index2","left"),_("index4","right"),n.push("if(pivots_are_equal){"),n.push("for(k=less;k<=great;++k){"),w("comp","k",1),n.push("if(comp===0){continue}"),n.push("if(comp<0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),n.push("while(true){"),w("comp","great",1),n.push("if(comp>0){"),n.push("great--"),n.push("}else if(comp<0){"),C("k","less","great"),n.push("break"),n.push("}else{"),M("k","great"),n.push("break"),n.push("}"),n.push("}"),n.push("}"),n.push("}"),n.push("}else{"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1<0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2>0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp>0){"),n.push("if(--greatindex5){"),T("less",1,"++less"),T("great",2,"--great"),n.push("for(k=less;k<=great;++k){"),w("comp_pivot1","k",1),n.push("if(comp_pivot1===0){"),n.push("if(k!==less){"),A("k","less"),n.push("}"),n.push("++less"),n.push("}else{"),w("comp_pivot2","k",2),n.push("if(comp_pivot2===0){"),n.push("while(true){"),w("comp","great",2),n.push("if(comp===0){"),n.push("if(--great1&&c?new Function("insertionSort","malloc","free",n.join("\n"))(r,c[0],c[1]):new Function("insertionSort",n.join("\n"))(r)}(t,e,v);return m(v,y)}},{"typedarray-pool":544}],450:[function(t,e,r){"use strict";var n=t("./lib/compile_sort.js"),i={};e.exports=function(t){var e=t.order,r=t.dtype,a=[e,r].join(":"),o=i[a];return o||(i[a]=o=n(e,r)),o(t),t}},{"./lib/compile_sort.js":449}],451:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_3_arg4_)}",args:[{name:"_inline_3_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_3_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_4_arg2_(this_warped,_inline_4_arg0_),_inline_4_arg1_=_inline_4_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_4_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_4_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_7_arg2_(this_warped,_inline_7_arg0_),_inline_7_arg1_=_inline_7_arg3_(_inline_7_arg4_,this_warped[0])}",args:[{name:"_inline_7_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_7_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_7_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_10_arg2_(this_warped,_inline_10_arg0_),_inline_10_arg1_=_inline_10_arg3_(_inline_10_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_10_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_10_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_10_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_13_arg2_(this_warped,_inline_13_arg0_),_inline_13_arg1_=_inline_13_arg3_(_inline_13_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_13_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_13_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_13_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":151,"ndarray-linear-interpolate":445}],452:[function(t,e,r){var n=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+l.join(",")+",v){"),i?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+l.join(",")+"){"),i?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",l.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+l.join(",")+"){return new "+r+"(this.data,"+o.map((function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")})).join(",")+","+o.map((function(t){return"this.stride["+t+"]"})).join(",")+",this.offset)}");var p=o.map((function(t){return"a"+t+"=this.shape["+t+"]"})),d=o.map((function(t){return"c"+t+"=this.stride["+t+"]"}));a.push("proto.lo=function "+r+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var g=0;g=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");for(a.push("return new "+r+"(this.data,"+o.map((function(t){return"a"+t})).join(",")+","+o.map((function(t){return"c"+t})).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+l.join(",")+"){var "+o.map((function(t){return"a"+t+"=this.shape["+t+"]"})).join(",")+","+o.map((function(t){return"b"+t+"=this.stride["+t+"]"})).join(",")+",c=this.offset,d=0,ceil=Math.ceil"),g=0;g=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map((function(t){return"shape["+t+"]"})).join(",")+","+o.map((function(t){return"stride["+t+"]"})).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(c[t],s)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,r,n){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===r){r=new Array(o);for(var s=o-1,u=1;s>=0;--s)r[s]=u,u*=e[s]}if(void 0===n)for(n=0,s=0;s>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),o=n.lo(t);return e>t==t>0?o===a?(r+=1,o=0):o+=1:0===o?(o=a,r-=1):o-=1,n.pack(o,r)}},{"double-bits":169}],454:[function(t,e,r){var n=Math.PI,i=c(120);function a(t,e,r,n){return["C",t,e,r,n,r,n]}function o(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}function s(t,e,r,a,o,c,u,h,f,p){if(p)A=p[0],C=p[1],_=p[2],w=p[3];else{var d=l(t,e,-o);t=d.x,e=d.y;var g=(t-(h=(d=l(h,f,-o)).x))/2,m=(e-(f=d.y))/2,v=g*g/(r*r)+m*m/(a*a);v>1&&(r*=v=Math.sqrt(v),a*=v);var y=r*r,x=a*a,b=(c==u?-1:1)*Math.sqrt(Math.abs((y*x-y*m*m-x*g*g)/(y*m*m+x*g*g)));b==1/0&&(b=1);var _=b*r*m/a+(t+h)/2,w=b*-a*g/r+(e+f)/2,A=Math.asin(((e-w)/a).toFixed(9)),C=Math.asin(((f-w)/a).toFixed(9));(A=t<_?n-A:A)<0&&(A=2*n+A),(C=h<_?n-C:C)<0&&(C=2*n+C),u&&A>C&&(A-=2*n),!u&&C>A&&(C-=2*n)}if(Math.abs(C-A)>i){var M=C,k=h,I=f;C=A+i*(u&&C>A?1:-1);var T=s(h=_+r*Math.cos(C),f=w+a*Math.sin(C),r,a,o,0,u,k,I,[C,M,_,w])}var L=Math.tan((C-A)/4),S=4/3*r*L,E=4/3*a*L,D=[2*t-(t+S*Math.sin(A)),2*e-(e-E*Math.cos(A)),h+S*Math.sin(C),f-E*Math.cos(C),h,f];if(p)return D;T&&(D=D.concat(T));for(var P=0;P7&&(r.push(v.splice(0,7)),v.unshift("C"));break;case"S":var x=p,b=d;"C"!=e&&"S"!=e||(x+=x-n,b+=b-i),v=["C",x,b,v[1],v[2],v[3],v[4]];break;case"T":"Q"==e||"T"==e?(h=2*p-h,f=2*d-f):(h=p,f=d),v=o(p,d,h,f,v[1],v[2]);break;case"Q":h=v[1],f=v[2],v=o(p,d,v[1],v[2],v[3],v[4]);break;case"L":v=a(p,d,v[1],v[2]);break;case"H":v=a(p,d,v[1],d);break;case"V":v=a(p,d,p,v[1]);break;case"Z":v=a(p,d,l,u)}e=y,p=v[v.length-2],d=v[v.length-1],v.length>4?(n=v[v.length-4],i=v[v.length-3]):(n=p,i=d),r.push(v)}return r}},{}],455:[function(t,e,r){r.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa){var b=i[c],_=1/Math.sqrt(m*y);for(x=0;x<3;++x){var w=(x+1)%3,A=(x+2)%3;b[x]+=_*(v[w]*g[A]-v[A]*g[w])}}}for(o=0;oa)for(_=1/Math.sqrt(C),x=0;x<3;++x)b[x]*=_;else for(x=0;x<3;++x)b[x]=0}return i},r.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),a=void 0===r?1e-6:r,o=0;oa?1/Math.sqrt(p):0,c=0;c<3;++c)f[c]*=p;i[o]=f}return i}},{}],456:[function(t,e,r){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ -"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,l=o(t),c=1;c0){var h=Math.sqrt(u+1);t[0]=.5*(o-l)/h,t[1]=.5*(s-n)/h,t[2]=.5*(r-a)/h,t[3]=.5*h}else{var f=Math.max(e,a,c);h=Math.sqrt(2*f-u+1),e>=f?(t[0]=.5*h,t[1]=.5*(i+r)/h,t[2]=.5*(s+n)/h,t[3]=.5*(o-l)/h):a>=f?(t[0]=.5*(r+i)/h,t[1]=.5*h,t[2]=.5*(l+o)/h,t[3]=.5*(s-n)/h):(t[0]=.5*(n+s)/h,t[1]=.5*(o+l)/h,t[2]=.5*h,t[3]=.5*(r-i)/h)}return t}},{}],458:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),u(r=[].slice.call(r,0,4),r);var i=new h(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i};var n=t("filtered-vector"),i=t("gl-mat4/lookAt"),a=t("gl-mat4/fromQuat"),o=t("gl-mat4/invert"),s=t("./lib/quatFromFrame");function l(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function c(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function u(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=c(r,n,i,a);o>1e-6?(t[0]=r/o,t[1]=n/o,t[2]=i/o,t[3]=a/o):(t[0]=t[1]=t[2]=0,t[3]=1)}function h(t,e,r){this.radius=n([r]),this.center=n(e),this.rotation=n(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}var f=h.prototype;f.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},f.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;u(e,e);var r=this.computedMatrix;a(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;l<3;++l){for(var c=0,h=0;h<3;++h)c+=r[l+4*h]*i[h];r[12+l]=-c}},f.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r},f.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},f.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},f.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=i[1],o=i[5],s=i[9],c=l(a,o,s);a/=c,o/=c,s/=c;var u=i[0],h=i[4],f=i[8],p=u*a+h*o+f*s,d=l(u-=a*p,h-=o*p,f-=s*p);u/=d,h/=d,f/=d;var g=i[2],m=i[6],v=i[10],y=g*a+m*o+v*s,x=g*u+m*h+v*f,b=l(g-=y*a+x*u,m-=y*o+x*h,v-=y*s+x*f);g/=b,m/=b,v/=b;var _=u*e+a*r,w=h*e+o*r,A=f*e+s*r;this.center.move(t,_,w,A);var C=Math.exp(this.computedRadius[0]);C=Math.max(1e-4,C+n),this.radius.set(t,Math.log(C))},f.rotate=function(t,e,r,n){this.recalcMatrix(t),e=e||0,r=r||0;var i=this.computedMatrix,a=i[0],o=i[4],s=i[8],u=i[1],h=i[5],f=i[9],p=i[2],d=i[6],g=i[10],m=e*a+r*u,v=e*o+r*h,y=e*s+r*f,x=-(d*y-g*v),b=-(g*m-p*y),_=-(p*v-d*m),w=Math.sqrt(Math.max(0,1-Math.pow(x,2)-Math.pow(b,2)-Math.pow(_,2))),A=c(x,b,_,w);A>1e-6?(x/=A,b/=A,_/=A,w/=A):(x=b=_=0,w=1);var C=this.computedRotation,M=C[0],k=C[1],I=C[2],T=C[3],L=M*w+T*x+k*_-I*b,S=k*w+T*b+I*x-M*_,E=I*w+T*_+M*b-k*x,D=T*w-M*x-k*b-I*_;if(n){x=p,b=d,_=g;var P=Math.sin(n)/l(x,b,_);x*=P,b*=P,_*=P,D=D*(w=Math.cos(e))-(L=L*w+D*x+S*_-E*b)*x-(S=S*w+D*b+E*x-L*_)*b-(E=E*w+D*_+L*b-S*x)*_}var O=c(L,S,E,D);O>1e-6?(L/=O,S/=O,E/=O,D/=O):(L=S=E=0,D=1),this.rotation.set(t,L,S,E,D)},f.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var a=this.computedMatrix;i(a,e,r,n);var o=this.computedRotation;s(o,a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]),u(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var l=0,c=0;c<3;++c)l+=Math.pow(r[c]-e[c],2);this.radius.set(t,.5*Math.log(Math.max(l,1e-6))),this.center.set(t,r[0],r[1],r[2])},f.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},f.setMatrix=function(t,e){var r=this.computedRotation;s(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),u(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;o(n,e);var i=n[15];if(Math.abs(i)>1e-6){var a=n[12]/i,l=n[13]/i,c=n[14]/i;this.recalcMatrix(t);var h=Math.exp(this.computedRadius[0]);this.center.set(t,a-n[2]*h,l-n[6]*h,c-n[10]*h),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},f.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},f.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},f.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},f.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},f.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":457,"filtered-vector":229,"gl-mat4/fromQuat":265,"gl-mat4/invert":268,"gl-mat4/lookAt":269}],459:[function(t,e,r){ -/*! - * pad-left - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT license. - */ -"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return n(r=void 0!==r?r+"":" ",e)+t}},{"repeat-string":502}],460:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)return[t];var r=[t];"string"==typeof e||Array.isArray(e)?e={brackets:e}:e||(e={});var n=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],i=e.escape||"___",a=!!e.flat;n.forEach((function(t){var e=new RegExp(["\\",t[0],"[^\\",t[0],"\\",t[1],"]*\\",t[1]].join("")),n=[];function a(e,a,o){var s=r.push(e.slice(t[0].length,-t[1].length))-1;return n.push(s),i+s+i}r.forEach((function(t,n){for(var i,o=0;t!=i;)if(i=t,t=t.replace(e,a),o++>1e4)throw Error("References have circular dependency. Please, check them.");r[n]=t})),n=n.reverse(),r=r.map((function(e){return n.forEach((function(r){e=e.replace(new RegExp("(\\"+i+r+"\\"+i+")","g"),t[0]+"$1"+t[1])})),e}))}));var o=new RegExp("\\"+i+"([0-9]+)\\"+i);return a?r:function t(e,r,n){for(var i,a=[],s=0;i=o.exec(e);){if(s++>1e4)throw Error("Circular references in parenthesis");a.push(e.slice(0,i.index)),a.push(t(r[i[1]],r)),e=e.slice(i.index+i[0].length)}return a.push(e),a}(r[0],r)}function i(t,e){if(e&&e.flat){var r,n=e&&e.escape||"___",i=t[0];if(!i)return"";for(var a=new RegExp("\\"+n+"([0-9]+)\\"+n),o=0;i!=r;){if(o++>1e4)throw Error("Circular references in "+t);r=i,i=i.replace(a,s)}return i}return t.reduce((function t(e,r){return Array.isArray(r)&&(r=r.reduce(t,"")),e+r}),"");function s(e,r){if(null==t[r])throw Error("Reference "+r+"is undefined");return t[r]}}function a(t,e){return Array.isArray(t)?i(t,e):n(t,e)}a.parse=n,a.stringify=i,e.exports=a},{}],461:[function(t,e,r){"use strict";var n=t("pick-by-alias");e.exports=function(t){var e;return arguments.length>1&&(t=arguments),"string"==typeof t?t=t.split(/\s/).map(parseFloat):"number"==typeof t&&(t=[t]),t.length&&"number"==typeof t[0]?e=1===t.length?{width:t[0],height:t[0],x:0,y:0}:2===t.length?{width:t[0],height:t[1],x:0,y:0}:{x:t[0],y:t[1],width:t[2]-t[0]||0,height:t[3]-t[1]||0}:t&&(t=n(t,{left:"x l left Left",top:"y t top Top",width:"w width W Width",height:"h height W Width",bottom:"b bottom Bottom",right:"r right Right"}),e={x:t.left||0,y:t.top||0},null==t.width?t.right?e.width=t.right-e.x:e.width=0:e.width=t.width,null==t.height?t.bottom?e.height=t.bottom-e.y:e.height=0:e.height=t.height),e}},{"pick-by-alias":467}],462:[function(t,e,r){e.exports=function(t){var e=[];return t.replace(i,(function(t,r,i){var o=r.toLowerCase();for(i=function(t){var e=t.match(a);return e?e.map(Number):[]}(i),"m"==o&&i.length>2&&(e.push([r].concat(i.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(i.length==n[o])return i.unshift(r),e.push(i);if(i.length0;--o)a=l[o],r=s[o],s[o]=s[a],s[a]=r,l[o]=l[r],l[r]=a,c=(c+r)*o;return n.freeUint32(l),n.freeUint32(s),c},r.unrank=function(t,e,r){switch(t){case 0:return r||[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}var n,i,a,o=1;for((r=r||new Array(t))[0]=0,a=1;a0;--a)e=e-(n=e/o|0)*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}},{"invert-permutation":417,"typedarray-pool":544}],467:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n,a,o={};if("string"==typeof e&&(e=i(e)),Array.isArray(e)){var s={};for(a=0;a0){o=a[u][r][0],l=u;break}s=o[1^l];for(var h=0;h<2;++h)for(var f=a[h][r],p=0;p0&&(o=d,s=g,l=h)}return i?s:(o&&c(o,l),s)}function h(t,r){var i=a[r][t][0],o=[t];c(i,r);for(var s=i[1^r];;){for(;s!==t;)o.push(s),s=u(o[o.length-2],s,!1);if(a[0][t].length+a[1][t].length===0)break;var l=o[o.length-1],h=t,f=o[1],p=u(l,h,!0);if(n(e[l],e[h],e[f],e[p])<0)break;o.push(t),s=u(l,h)}return o}function f(t,e){return e[1]===e[e.length-1]}for(o=0;o0;){a[0][o].length;var g=h(o,p);f(0,g)?d.push.apply(d,g):(d.length>0&&l.push(d),d=g)}d.length>0&&l.push(d)}return l};var n=t("compare-angle")},{"compare-angle":129}],469:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=n(t,e.length),i=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var c=o.pop();i[c]=!1;var u=r[c];for(s=0;s0}))).length,m=new Array(g),v=new Array(g);for(p=0;p0;){var N=R.pop(),j=T[N];l(j,(function(t,e){return t-e}));var B,Y=j.length,V=F[N];if(0===V){var U=d[N];B=[U]}for(p=0;p=0||(F[H]=1^V,R.push(H),0===V&&(z(U=d[H])||(U.reverse(),B.push(U))))}0===V&&r.push(B)}return r};var n=t("edges-to-adjacency-list"),i=t("planar-dual"),a=t("point-in-big-polygon"),o=t("two-product"),s=t("robust-sum"),l=t("uniq"),c=t("./lib/trim-leaves");function u(t,e){for(var r=new Array(t),n=0;n>>1;e.dtype||(e.dtype="array"),"string"==typeof e.dtype?g=new(h(e.dtype))(v):e.dtype&&(g=e.dtype,Array.isArray(g)&&(g.length=v));for(var y=0;yr||s>p){for(var f=0;fl||k>c||I=S||o===s)){var u=x[a];void 0===s&&(s=u.length);for(var h=o;h=m&&p<=y&&d>=v&&d<=A&&E.push(f)}var g=b[a],_=g[4*o+0],w=g[4*o+1],C=g[4*o+2],L=g[4*o+3],D=function(t,e){for(var r=null,n=0;null===r;)if(r=t[4*e+n],++n>t.length)return null;return r}(g,o+1),P=.5*i,O=a+1;e(r,n,P,O,_,w||C||L||D),e(r,n+P,P,O,w,C||L||D),e(r+P,n,P,O,C,L||D),e(r+P,n+P,P,O,L,D)}}}(0,0,1,0,0,1),E},g;function L(t,e,r){for(var n=1,i=.5,a=.5,o=.5,s=0;s0&&e[i]===r[0]))return 1;a=t[i-1]}for(var s=1;a;){var l=a.key,c=n(r,l[0],l[1]);if(l[0][0]0))return 0;s=-1,a=a.right}else if(c>0)a=a.left;else{if(!(c<0))return 0;s=1,a=a.right}}return s}}(v.slabs,v.coordinates);return 0===a.length?y:function(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}(l(a),y)};var n=t("robust-orientation")[3],i=t("slab-decomposition"),a=t("interval-tree-1d"),o=t("binary-search-bounds");function s(){return!0}function l(t){for(var e={},r=0;r=-t},pointBetween:function(e,r,n){var i=e[1]-r[1],a=n[0]-r[0],o=e[0]-r[0],s=n[1]-r[1],l=o*a+i*s;return!(l-t)},pointsSameX:function(e,r){return Math.abs(e[0]-r[0])t!=o-i>t&&(a-c)*(i-u)/(o-u)+c-n>t&&(s=!s),a=c,o=u}return s}};return e}},{}],478:[function(t,e,r){var n={toPolygon:function(t,e){function r(e){if(e.length<=0)return t.segments({inverted:!1,regions:[]});function r(e){var r=e.slice(0,e.length-1);return t.segments({inverted:!1,regions:[r]})}for(var n=r(e[0]),i=1;i0}))}function u(t,n){var i=t.seg,a=n.seg,o=i.start,s=i.end,c=a.start,u=a.end;r&&r.checkIntersection(i,a);var h=e.linesIntersect(o,s,c,u);if(!1===h){if(!e.pointsCollinear(o,s,c))return!1;if(e.pointsSame(o,u)||e.pointsSame(s,c))return!1;var f=e.pointsSame(o,c),p=e.pointsSame(s,u);if(f&&p)return n;var d=!f&&e.pointBetween(o,c,u),g=!p&&e.pointBetween(s,c,u);if(f)return g?l(n,s):l(t,u),n;d&&(p||(g?l(n,s):l(t,u)),l(n,o))}else 0===h.alongA&&(-1===h.alongB?l(t,c):0===h.alongB?l(t,h.pt):1===h.alongB&&l(t,u)),0===h.alongB&&(-1===h.alongA?l(n,o):0===h.alongA?l(n,h.pt):1===h.alongA&&l(n,s));return!1}for(var h=[];!a.isEmpty();){var f=a.getHead();if(r&&r.vert(f.pt[0]),f.isStart){r&&r.segmentNew(f.seg,f.primary);var p=c(f),d=p.before?p.before.ev:null,g=p.after?p.after.ev:null;function m(){if(d){var t=u(f,d);if(t)return t}return!!g&&u(f,g)}r&&r.tempStatus(f.seg,!!d&&d.seg,!!g&&g.seg);var v,y,x=m();if(x&&(t?(y=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below)&&(x.seg.myFill.above=!x.seg.myFill.above):x.seg.otherFill=f.seg.myFill,r&&r.segmentUpdate(x.seg),f.other.remove(),f.remove()),a.getHead()!==f){r&&r.rewind(f.seg);continue}t?(y=null===f.seg.myFill.below||f.seg.myFill.above!==f.seg.myFill.below,f.seg.myFill.below=g?g.seg.myFill.above:i,f.seg.myFill.above=y?!f.seg.myFill.below:f.seg.myFill.below):null===f.seg.otherFill&&(v=g?f.primary===g.primary?g.seg.otherFill.above:g.seg.myFill.above:f.primary?o:i,f.seg.otherFill={above:v,below:v}),r&&r.status(f.seg,!!d&&d.seg,!!g&&g.seg),f.other.status=p.insert(n.node({ev:f}))}else{var b=f.status;if(null===b)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(s.exists(b.prev)&&s.exists(b.next)&&u(b.prev.ev,b.next.ev),r&&r.statusRemove(b.ev.seg),b.remove(),!f.primary){var _=f.seg.myFill;f.seg.myFill=f.seg.otherFill,f.seg.otherFill=_}h.push(f.seg)}a.getHead().remove()}return r&&r.done(),h}return t?{addRegion:function(t){for(var n,i,a,o=t[t.length-1],l=0;l=c?(C=1,y=c+2*f+d):y=f*(C=-f/c)+d):(C=0,p>=0?(M=0,y=d):-p>=h?(M=1,y=h+2*p+d):y=p*(M=-p/h)+d);else if(M<0)M=0,f>=0?(C=0,y=d):-f>=c?(C=1,y=c+2*f+d):y=f*(C=-f/c)+d;else{var k=1/A;y=(C*=k)*(c*C+u*(M*=k)+2*f)+M*(u*C+h*M+2*p)+d}else C<0?(b=h+p)>(x=u+f)?(_=b-x)>=(w=c-2*u+h)?(C=1,M=0,y=c+2*f+d):y=(C=_/w)*(c*C+u*(M=1-C)+2*f)+M*(u*C+h*M+2*p)+d:(C=0,b<=0?(M=1,y=h+2*p+d):p>=0?(M=0,y=d):y=p*(M=-p/h)+d):M<0?(b=c+f)>(x=u+p)?(_=b-x)>=(w=c-2*u+h)?(M=1,C=0,y=h+2*p+d):y=(C=1-(M=_/w))*(c*C+u*M+2*f)+M*(u*C+h*M+2*p)+d:(M=0,b<=0?(C=1,y=c+2*f+d):f>=0?(C=0,y=d):y=f*(C=-f/c)+d):(_=h+p-u-f)<=0?(C=0,M=1,y=h+2*p+d):_>=(w=c-2*u+h)?(C=1,M=0,y=c+2*f+d):y=(C=_/w)*(c*C+u*(M=1-C)+2*f)+M*(u*C+h*M+2*p)+d;var I=1-C-M;for(l=0;l1)for(var r=1;r0){var c=t[r-1];if(0===n(s,c)&&a(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}},{"cell-orientation":114,"compare-cell":130,"compare-oriented-cell":131}],492:[function(t,e,r){"use strict";var n=t("array-bounds"),i=t("color-normalize"),a=t("update-diff"),o=t("pick-by-alias"),s=t("object-assign"),l=t("flatten-vertex-data"),c=t("to-float32"),u=c.float32,h=c.fract32;e.exports=function(t,e){if("function"==typeof t?(e||(e={}),e.regl=t):e=t,e.length&&(e.positions=e),!(t=e.regl).hasExtension("ANGLE_instanced_arrays"))throw Error("regl-error2d: `ANGLE_instanced_arrays` extension should be enabled");var r,c,p,d,g,m,v=t._gl,y={color:"black",capSize:5,lineWidth:1,opacity:1,viewport:null,range:null,offset:0,count:0,bounds:null,positions:[],errors:[]},x=[];return d=t.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array(0)}),c=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),p=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),g=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)}),m=t.buffer({usage:"static",type:"float",data:f}),A(e),r=t({vert:"\n\t\tprecision highp float;\n\n\t\tattribute vec2 position, positionFract;\n\t\tattribute vec4 error;\n\t\tattribute vec4 color;\n\n\t\tattribute vec2 direction, lineOffset, capOffset;\n\n\t\tuniform vec4 viewport;\n\t\tuniform float lineWidth, capSize;\n\t\tuniform vec2 scale, scaleFract, translate, translateFract;\n\n\t\tvarying vec4 fragColor;\n\n\t\tvoid main() {\n\t\t\tfragColor = color / 255.;\n\n\t\t\tvec2 pixelOffset = lineWidth * lineOffset + (capSize + lineWidth) * capOffset;\n\n\t\t\tvec2 dxy = -step(.5, direction.xy) * error.xz + step(direction.xy, vec2(-.5)) * error.yw;\n\n\t\t\tvec2 position = position + dxy;\n\n\t\t\tvec2 pos = (position + translate) * scale\n\t\t\t\t+ (positionFract + translateFract) * scale\n\t\t\t\t+ (position + translate) * scaleFract\n\t\t\t\t+ (positionFract + translateFract) * scaleFract;\n\n\t\t\tpos += pixelOffset / viewport.zw;\n\n\t\t\tgl_Position = vec4(pos * 2. - 1., 0, 1);\n\t\t}\n\t\t",frag:"\n\t\tprecision highp float;\n\n\t\tvarying vec4 fragColor;\n\n\t\tuniform float opacity;\n\n\t\tvoid main() {\n\t\t\tgl_FragColor = fragColor;\n\t\t\tgl_FragColor.a *= opacity;\n\t\t}\n\t\t",uniforms:{range:t.prop("range"),lineWidth:t.prop("lineWidth"),capSize:t.prop("capSize"),opacity:t.prop("opacity"),scale:t.prop("scale"),translate:t.prop("translate"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{color:{buffer:d,offset:function(t,e){return 4*e.offset},divisor:1},position:{buffer:c,offset:function(t,e){return 8*e.offset},divisor:1},positionFract:{buffer:p,offset:function(t,e){return 8*e.offset},divisor:1},error:{buffer:g,offset:function(t,e){return 16*e.offset},divisor:1},direction:{buffer:m,stride:24,offset:0},lineOffset:{buffer:m,stride:24,offset:8},capOffset:{buffer:m,stride:24,offset:16}},primitive:"triangles",blend:{enable:!0,color:[0,0,0,0],equation:{rgb:"add",alpha:"add"},func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:"one minus dst alpha",dstAlpha:"one"}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("viewport")},viewport:t.prop("viewport"),stencil:!1,instances:t.prop("count"),count:f.length}),s(b,{update:A,draw:_,destroy:C,regl:t,gl:v,canvas:v.canvas,groups:x}),b;function b(t){t?A(t):null===t&&C(),_()}function _(e){if("number"==typeof e)return w(e);e&&!Array.isArray(e)&&(e=[e]),t._refresh(),x.forEach((function(t,r){t&&(e&&(e[r]?t.draw=!0:t.draw=!1),t.draw?w(r):t.draw=!0)}))}function w(t){"number"==typeof t&&(t=x[t]),null!=t&&t&&t.count&&t.color&&t.opacity&&t.positions&&t.positions.length>1&&(t.scaleRatio=[t.scale[0]*t.viewport.width,t.scale[1]*t.viewport.height],r(t),t.after&&t.after(t))}function A(t){if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var e=0,r=0;if(b.groups=x=t.map((function(t,c){var u=x[c];return t?("function"==typeof t?t={after:t}:"number"==typeof t[0]&&(t={positions:t}),t=o(t,{color:"color colors fill",capSize:"capSize cap capsize cap-size",lineWidth:"lineWidth line-width width line thickness",opacity:"opacity alpha",range:"range dataBox",viewport:"viewport viewBox",errors:"errors error",positions:"positions position data points"}),u||(x[c]=u={id:c,scale:null,translate:null,scaleFract:null,translateFract:null,draw:!0},t=s({},y,t)),a(u,t,[{lineWidth:function(t){return.5*+t},capSize:function(t){return.5*+t},opacity:parseFloat,errors:function(t){return t=l(t),r+=t.length,t},positions:function(t,r){return t=l(t,"float64"),r.count=Math.floor(t.length/2),r.bounds=n(t,2),r.offset=e,e+=r.count,t}},{color:function(t,e){var r=e.count;if(t||(t="transparent"),!Array.isArray(t)||"number"==typeof t[0]){var n=t;t=Array(r);for(var a=0;a 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, id, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}\n"]),attributes:{lineEnd:{buffer:r,divisor:0,stride:8,offset:0},lineTop:{buffer:r,divisor:0,stride:8,offset:4},aColor:{buffer:t.prop("colorBuffer"),stride:4,offset:0,divisor:1},bColor:{buffer:t.prop("colorBuffer"),stride:4,offset:4,divisor:1},prevCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:0,divisor:1},aCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:8,divisor:1},bCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:16,divisor:1},nextCoord:{buffer:t.prop("positionBuffer"),stride:8,offset:24,divisor:1}}},n))}catch(t){e=i}return{fill:t({primitive:"triangle",elements:function(t,e){return e.triangles},offset:0,vert:o(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio, id;\nuniform vec4 viewport;\nuniform float opacity;\n\nvarying vec4 fragColor;\n\nconst float MAX_LINES = 256.;\n\nvoid main() {\n\tfloat depth = (MAX_LINES - 4. - id) / (MAX_LINES);\n\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}\n"]),frag:o(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}\n"]),uniforms:{scale:t.prop("scale"),color:t.prop("fill"),scaleFract:t.prop("scaleFract"),translateFract:t.prop("translateFract"),translate:t.prop("translate"),opacity:t.prop("opacity"),pixelRatio:t.context("pixelRatio"),id:t.prop("id"),viewport:function(t,e){return[e.viewport.x,e.viewport.y,t.viewportWidth,t.viewportHeight]}},attributes:{position:{buffer:t.prop("positionBuffer"),stride:8,offset:8},positionFract:{buffer:t.prop("positionFractBuffer"),stride:8,offset:8}},blend:n.blend,depth:{enable:!1},scissor:n.scissor,stencil:n.stencil,viewport:n.viewport}),rect:i,miter:e}},m.defaults={dashes:null,join:"miter",miterLimit:1,thickness:10,cap:"square",color:"black",opacity:1,overlay:!1,viewport:null,range:null,close:!1,fill:null},m.prototype.render=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];e.length&&(t=this).update.apply(t,e),this.draw()},m.prototype.draw=function(){for(var t=this,e=[],r=arguments.length;r--;)e[r]=arguments[r];return(e.length?e:this.passes).forEach((function(e,r){var n;if(e&&Array.isArray(e))return(n=t).draw.apply(n,e);"number"==typeof e&&(e=t.passes[e]),e&&e.count>1&&e.opacity&&(t.regl._refresh(),e.fill&&e.triangles&&e.triangles.length>2&&t.shaders.fill(e),e.thickness&&(e.scale[0]*e.viewport.width>m.precisionThreshold||e.scale[1]*e.viewport.height>m.precisionThreshold?t.shaders.rect(e):"rect"===e.join||!e.join&&(e.thickness<=2||e.count>=m.maxPoints)?t.shaders.rect(e):t.shaders.miter(e)))})),this},m.prototype.update=function(t){var e=this;if(t){null!=t.length?"number"==typeof t[0]&&(t=[{positions:t}]):Array.isArray(t)||(t=[t]);var r=this.regl,o=this.gl;if(t.forEach((function(t,h){var d=e.passes[h];if(void 0!==t)if(null!==t){if("number"==typeof t[0]&&(t={positions:t}),t=s(t,{positions:"positions points data coords",thickness:"thickness lineWidth lineWidths line-width linewidth width stroke-width strokewidth strokeWidth",join:"lineJoin linejoin join type mode",miterLimit:"miterlimit miterLimit",dashes:"dash dashes dasharray dash-array dashArray",color:"color colour stroke colors colours stroke-color strokeColor",fill:"fill fill-color fillColor",opacity:"alpha opacity",overlay:"overlay crease overlap intersect",close:"closed close closed-path closePath",range:"range dataBox",viewport:"viewport viewBox",hole:"holes hole hollow"}),d||(e.passes[h]=d={id:h,scale:null,scaleFract:null,translate:null,translateFract:null,count:0,hole:[],depth:0,dashLength:1,dashTexture:r.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"}),colorBuffer:r.buffer({usage:"dynamic",type:"uint8",data:new Uint8Array}),positionBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array}),positionFractBuffer:r.buffer({usage:"dynamic",type:"float",data:new Uint8Array})},t=a({},m.defaults,t)),null!=t.thickness&&(d.thickness=parseFloat(t.thickness)),null!=t.opacity&&(d.opacity=parseFloat(t.opacity)),null!=t.miterLimit&&(d.miterLimit=parseFloat(t.miterLimit)),null!=t.overlay&&(d.overlay=!!t.overlay,h 1.0 + delta) {\n\t\tdiscard;\n\t}\n\n\talpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n\tfloat borderRadius = fragBorderRadius;\n\tfloat ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n\tvec4 color = mix(fragColor, fragBorderColor, ratio);\n\tcolor.a *= alpha * opacity;\n\tgl_FragColor = color;\n}\n"]),l.vert=u(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform sampler2D palette;\nuniform vec2 paletteSize;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0, 1);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]),d&&(l.frag=l.frag.replace("smoothstep","smoothStep"),s.frag=s.frag.replace("smoothstep","smoothStep")),this.drawCircle=t(l)}y.defaults={color:"black",borderColor:"transparent",borderSize:0,size:12,opacity:1,marker:void 0,viewport:null,range:null,pixelSize:null,count:0,offset:0,bounds:null,positions:[],snap:1e4},y.prototype.render=function(){return arguments.length&&this.update.apply(this,arguments),this.draw(),this},y.prototype.draw=function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;nn)?e.tree=l(t,{bounds:h}):n&&n.length&&(e.tree=n),e.tree){var f={primitive:"points",usage:"static",data:e.tree,type:"uint32"};e.elements?e.elements(f):e.elements=s.elements(f)}return i({data:g.float(t),usage:"dynamic"}),a({data:g.fract(t),usage:"dynamic"}),c({data:new Uint8Array(u),type:"uint8",usage:"stream"}),t}},{marker:function(e,r,n){var i=r.activation;if(i.forEach((function(t){return t&&t.destroy&&t.destroy()})),i.length=0,e&&"number"!=typeof e[0]){for(var a=[],o=0,l=Math.min(e.length,r.count);o=0)return a;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)e=t;else{e=new Uint8Array(t.length);for(var o=0,s=t.length;o4*n&&(this.tooManyColors=!0),this.updatePalette(r),1===i.length?i[0]:i},y.prototype.updatePalette=function(t){if(!this.tooManyColors){var e=this.maxColors,r=this.paletteTexture,n=Math.ceil(.25*t.length/e);if(n>1)for(var i=.25*(t=t.slice()).length%e;i2?(s[0],s[2],n=s[1],i=s[3]):s.length?(n=s[0],i=s[1]):(s.x,n=s.y,s.x,s.width,i=s.y+s.height),l.length>2?(a=l[0],o=l[2],l[1],l[3]):l.length?(a=l[0],o=l[1]):(a=l.x,l.y,o=l.x+l.width,l.y,l.height),[a,n,o,i]}function p(t){if("number"==typeof t)return[t,t,t,t];if(2===t.length)return[t[0],t[1],t[0],t[1]];var e=l(t);return[e.x,e.y,e.x+e.width,e.y+e.height]}e.exports=u,u.prototype.render=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];return r.length&&(t=this).update.apply(t,r),this.regl.attributes.preserveDrawingBuffer?this.draw():(this.dirty?null==this.planned&&(this.planned=o((function(){e.draw(),e.dirty=!0,e.planned=null}))):(this.draw(),this.dirty=!0,o((function(){e.dirty=!1}))),this)},u.prototype.update=function(){for(var t,e=this,r=[],n=arguments.length;n--;)r[n]=arguments[n];if(r.length){for(var i=0;iC))&&(s.lower||!(A>>=e))<<3,(e|=r=(15<(t>>>=r))<<2)|(r=(3<(t>>>=r))<<1)|t>>>r>>1}function s(){function t(t){t:{for(var e=16;268435456>=e;e*=16)if(t<=e){t=e;break t}t=0}return 0<(e=r[o(t)>>2]).length?e.pop():new ArrayBuffer(t)}function e(t){r[o(t.byteLength)>>2].push(t)}var r=a(8,(function(){return[]}));return{alloc:t,free:e,allocType:function(e,r){var n=null;switch(e){case 5120:n=new Int8Array(t(r),0,r);break;case 5121:n=new Uint8Array(t(r),0,r);break;case 5122:n=new Int16Array(t(2*r),0,r);break;case 5123:n=new Uint16Array(t(2*r),0,r);break;case 5124:n=new Int32Array(t(4*r),0,r);break;case 5125:n=new Uint32Array(t(4*r),0,r);break;case 5126:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(t){e(t.buffer)}}}function l(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||W(t.data))}function c(t,e,r,n,i,a){for(var o=0;o(i=s)&&(i=n.buffer.byteLength,5123===h?i>>=1:5125===h&&(i>>=2)),n.vertCount=i,i=o,0>o&&(i=4,1===(o=n.buffer.dimension)&&(i=0),2===o&&(i=1),3===o&&(i=4)),n.primType=i}function o(t){n.elementsCount--,delete s[t.id],t.buffer.destroy(),t.buffer=null}var s={},c=0,u={uint8:5121,uint16:5123};e.oes_element_index_uint&&(u.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var h=[];return{create:function(t,e){function s(t){if(t)if("number"==typeof t)c(t),h.primType=4,h.vertCount=0|t,h.type=5121;else{var e=null,r=35044,n=-1,i=-1,o=0,f=0;Array.isArray(t)||W(t)||l(t)?e=t:("data"in t&&(e=t.data),"usage"in t&&(r=Q[t.usage]),"primitive"in t&&(n=rt[t.primitive]),"count"in t&&(i=0|t.count),"type"in t&&(f=u[t.type]),"length"in t?o=0|t.length:(o=i,5123===f||5122===f?o*=2:5125!==f&&5124!==f||(o*=4))),a(h,e,r,n,i,o,f)}else c(),h.primType=4,h.vertCount=0,h.type=5121;return s}var c=r.create(null,34963,!0),h=new i(c._buffer);return n.elementsCount++,s(t),s._reglType="elements",s._elements=h,s.subdata=function(t,e){return c.subdata(t,e),s},s.destroy=function(){o(h)},s},createStream:function(t){var e=h.pop();return e||(e=new i(r.create(null,34963,!0,!1)._buffer)),a(e,t,35040,-1,-1,0,0),e},destroyStream:function(t){h.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof i?t._elements:null},clear:function(){Z(s).forEach(o)}}}function g(t){for(var e=G.allocType(5123,t.length),r=0;r>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;e[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15>=i,r.height>>=i,p(r,n[i]),t.mipmask|=1<e;++e)t.images[e]=null;return t}function S(t){for(var e=t.images,r=0;re){for(var r=0;r=--this.refCount&&F(this)}}),o.profile&&(a.getTotalTextureSize=function(){var t=0;return Object.keys(vt).forEach((function(e){t+=vt[e].stats.size})),t}),{create2D:function(e,r){function n(t,e){var r=i.texInfo;E.call(r);var a=L();return"number"==typeof t?k(a,0|t,"number"==typeof e?0|e:0|t):t?(D(r,t),I(a,t)):k(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,c(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,z(i),T(a,3553),P(r,3553),R(),S(a),o.profile&&(i.stats.size=A(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=tt[i.internalformat],n.type=et[i.type],n.mag=rt[r.magFilter],n.min=nt[r.minFilter],n.wrapS=it[r.wrapS],n.wrapT=it[r.wrapT],n}var i=new O(3553);return vt[i.id]=i,a.textureCount++,n(e,r),n.subimage=function(t,e,r,a){e|=0,r|=0,a|=0;var o=v();return c(o,i),o.width=0,o.height=0,p(o,t),o.width=o.width||(i.width>>a)-e,o.height=o.height||(i.height>>a)-r,z(i),d(o,3553,e,r,a),R(),C(o),n},n.resize=function(e,r){var a=0|e,s=0|r||a;if(a===i.width&&s===i.height)return n;n.width=i.width=a,n.height=i.height=s,z(i);for(var l,c=i.channels,u=i.type,h=0;i.mipmask>>h;++h){var f=a>>h,p=s>>h;if(!f||!p)break;l=G.zero.allocType(u,f*p*c),t.texImage2D(3553,h,i.format,f,p,0,i.format,i.type,l),l&&G.zero.freeType(l)}return R(),o.profile&&(i.stats.size=A(i.internalformat,i.type,a,s,!1,!1)),n},n._reglType="texture2d",n._texture=i,o.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(e,r,n,i,s,l){function h(t,e,r,n,i,a){var s,l=f.texInfo;for(E.call(l),s=0;6>s;++s)g[s]=L();if("number"!=typeof t&&t){if("object"==typeof t)if(e)I(g[0],t),I(g[1],e),I(g[2],r),I(g[3],n),I(g[4],i),I(g[5],a);else if(D(l,t),u(f,t),"faces"in t)for(t=t.faces,s=0;6>s;++s)c(g[s],f),I(g[s],t[s]);else for(s=0;6>s;++s)I(g[s],t)}else for(t=0|t||1,s=0;6>s;++s)k(g[s],t,t);for(c(f,g[0]),f.mipmask=l.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,f.internalformat=g[0].internalformat,h.width=g[0].width,h.height=g[0].height,z(f),s=0;6>s;++s)T(g[s],34069+s);for(P(l,34067),R(),o.profile&&(f.stats.size=A(f.internalformat,f.type,h.width,h.height,l.genMipmaps,!0)),h.format=tt[f.internalformat],h.type=et[f.type],h.mag=rt[l.magFilter],h.min=nt[l.minFilter],h.wrapS=it[l.wrapS],h.wrapT=it[l.wrapT],s=0;6>s;++s)S(g[s]);return h}var f=new O(34067);vt[f.id]=f,a.cubeCount++;var g=Array(6);return h(e,r,n,i,s,l),h.subimage=function(t,e,r,n,i){r|=0,n|=0,i|=0;var a=v();return c(a,f),a.width=0,a.height=0,p(a,e),a.width=a.width||(f.width>>i)-r,a.height=a.height||(f.height>>i)-n,z(f),d(a,34069+t,r,n,i),R(),C(a),h},h.resize=function(e){if((e|=0)!==f.width){h.width=f.width=e,h.height=f.height=e,z(f);for(var r=0;6>r;++r)for(var n=0;f.mipmask>>n;++n)t.texImage2D(34069+r,n,f.format,e>>n,e>>n,0,f.format,f.type,null);return R(),o.profile&&(f.stats.size=A(f.internalformat,f.type,h.width,h.height,!1,!0)),h}},h._reglType="textureCube",h._texture=f,o.profile&&(h.stats=f.stats),h.destroy=function(){f.decRef()},h},clear:function(){for(var e=0;er;++r)if(0!=(e.mipmask&1<>r,e.height>>r,0,e.internalformat,e.type,null);else for(var n=0;6>n;++n)t.texImage2D(34069+n,r,e.internalformat,e.width>>r,e.height>>r,0,e.internalformat,e.type,null);P(e.texInfo,e.target)}))}}}function M(t,e,r,n,i,a){function o(t,e,r){this.target=t,this.texture=e,this.renderbuffer=r;var n=t=0;e?(t=e.width,n=e.height):r&&(t=r.width,n=r.height),this.width=t,this.height=n}function s(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function l(t,e,r){t&&(t.texture?t.texture._texture.refCount+=1:t.renderbuffer._renderbuffer.refCount+=1)}function c(e,r){r&&(r.texture?t.framebufferTexture2D(36160,e,r.target,r.texture._texture.texture,0):t.framebufferRenderbuffer(36160,e,36161,r.renderbuffer._renderbuffer.renderbuffer))}function u(t){var e=3553,r=null,n=null,i=t;return"object"==typeof t&&(i=t.data,"target"in t&&(e=0|t.target)),"texture2d"===(t=i._reglType)?r=i:"textureCube"===t?r=i:"renderbuffer"===t&&(n=i,e=36161),new o(e,r,n)}function h(t,e,r,a,s){return r?((t=n.create2D({width:t,height:e,format:a,type:s}))._texture.refCount=0,new o(3553,t,null)):((t=i.create({width:t,height:e,format:a}))._renderbuffer.refCount=0,new o(36161,null,t))}function f(t){return t&&(t.texture||t.renderbuffer)}function p(t,e,r){t&&(t.texture?t.texture.resize(e,r):t.renderbuffer&&t.renderbuffer.resize(e,r),t.width=e,t.height=r)}function d(){this.id=A++,C[this.id]=this,this.framebuffer=t.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(t){t.colorAttachments.forEach(s),s(t.depthAttachment),s(t.stencilAttachment),s(t.depthStencilAttachment)}function m(e){t.deleteFramebuffer(e.framebuffer),e.framebuffer=null,a.framebufferCount--,delete C[e.id]}function v(e){var n;t.bindFramebuffer(36160,e.framebuffer);var i=e.colorAttachments;for(n=0;ni;++i){for(c=0;ct;++t)r[t].resize(n);return e.width=e.height=n,e},_reglType:"framebufferCube",destroy:function(){r.forEach((function(t){t.destroy()}))}})},clear:function(){Z(C).forEach(m)},restore:function(){x.cur=null,x.next=null,x.dirty=!0,Z(C).forEach((function(e){e.framebuffer=t.createFramebuffer(),v(e)}))}})}function k(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function I(t,e,r,n){function i(t,e,r,n){this.name=t,this.id=e,this.location=r,this.info=n}function a(t,e){for(var r=0;rt&&(t=e.stats.uniformsCount)})),t},r.getMaxAttributesCount=function(){var t=0;return f.forEach((function(e){e.stats.attributesCount>t&&(t=e.stats.attributesCount)})),t}),{clear:function(){var e=t.deleteShader.bind(t);Z(c).forEach(e),c={},Z(u).forEach(e),u={},f.forEach((function(e){t.deleteProgram(e.program)})),f.length=0,h={},r.shaderCount=0},program:function(t,e,n){var i=h[e];i||(i=h[e]={});var a=i[t];return a||(a=new s(e,t),r.shaderCount++,l(a),i[t]=a,f.push(a)),a},restore:function(){c={},u={};for(var t=0;t"+e+"?"+i+".constant["+e+"]:0;"})).join(""),"}}else{","if(",o,"(",i,".buffer)){",u,"=",s,".createStream(",34962,",",i,".buffer);","}else{",u,"=",s,".getBuffer(",i,".buffer);","}",h,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",u,".dtype;",l.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",l.isStream,"){",s,".destroyStream(",u,");","}"),l}))})),o}function M(t,e,r,n,i){var o=_(t),s=function(t,e,r){function n(t){if(t in i){var r=i[t];t=!0;var n,o,s=0|r.x,l=0|r.y;return"width"in r?n=0|r.width:t=!1,"height"in r?o=0|r.height:t=!1,new O(!t&&e&&e.thisDep,!t&&e&&e.contextDep,!t&&e&&e.propDep,(function(t,e){var i=t.shared.context,a=n;"width"in r||(a=e.def(i,".","framebufferWidth","-",s));var c=o;return"height"in r||(c=e.def(i,".","framebufferHeight","-",l)),[s,l,a,c]}))}if(t in a){var c=a[t];return t=F(c,(function(t,e){var r=t.invoke(e,c),n=t.shared.context,i=e.def(r,".x|0"),a=e.def(r,".y|0");return[i,a,e.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=e.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",a,")")]})),e&&(t.thisDep=t.thisDep||e.thisDep,t.contextDep=t.contextDep||e.contextDep,t.propDep=t.propDep||e.propDep),t}return e?new O(e.thisDep,e.contextDep,e.propDep,(function(t,e){var r=t.shared.context;return[0,0,e.def(r,".","framebufferWidth"),e.def(r,".","framebufferHeight")]})):null}var i=t.static,a=t.dynamic;if(t=n("viewport")){var o=t;t=new O(t.thisDep,t.contextDep,t.propDep,(function(t,e){var r=o.append(t,e),n=t.shared.context;return e.set(n,".viewportWidth",r[2]),e.set(n,".viewportHeight",r[3]),r}))}return{viewport:t,scissor_box:n("scissor.box")}}(t,o),l=A(t),c=function(t,e){var r=t.static,n=t.dynamic,i={};return nt.forEach((function(t){function e(e,a){if(t in r){var s=e(r[t]);i[o]=R((function(){return s}))}else if(t in n){var l=n[t];i[o]=F(l,(function(t,e){return a(t,e,t.invoke(e,l))}))}}var o=v(t);switch(t){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return e((function(t){return t}),(function(t,e,r){return r}));case"depth.func":return e((function(t){return At[t]}),(function(t,e,r){return e.def(t.constants.compareFuncs,"[",r,"]")}));case"depth.range":return e((function(t){return t}),(function(t,e,r){return[e.def("+",r,"[0]"),e=e.def("+",r,"[1]")]}));case"blend.func":return e((function(t){return[wt["srcRGB"in t?t.srcRGB:t.src],wt["dstRGB"in t?t.dstRGB:t.dst],wt["srcAlpha"in t?t.srcAlpha:t.src],wt["dstAlpha"in t?t.dstAlpha:t.dst]]}),(function(t,e,r){function n(t,n){return e.def('"',t,n,'" in ',r,"?",r,".",t,n,":",r,".",t)}t=t.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),o=(i=e.def(t,"[",i,"]"),e.def(t,"[",n("src","Alpha"),"]"));return[i,a=e.def(t,"[",a,"]"),o,t=e.def(t,"[",n("dst","Alpha"),"]")]}));case"blend.equation":return e((function(t){return"string"==typeof t?[J[t],J[t]]:"object"==typeof t?[J[t.rgb],J[t.alpha]]:void 0}),(function(t,e,r){var n=t.constants.blendEquations,i=e.def(),a=e.def();return(t=t.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),t.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),e(t),[i,a]}));case"blend.color":return e((function(t){return a(4,(function(e){return+t[e]}))}),(function(t,e,r){return a(4,(function(t){return e.def("+",r,"[",t,"]")}))}));case"stencil.mask":return e((function(t){return 0|t}),(function(t,e,r){return e.def(r,"|0")}));case"stencil.func":return e((function(t){return[At[t.cmp||"keep"],t.ref||0,"mask"in t?t.mask:-1]}),(function(t,e,r){return[t=e.def('"cmp" in ',r,"?",t.constants.compareFuncs,"[",r,".cmp]",":",7680),e.def(r,".ref|0"),e=e.def('"mask" in ',r,"?",r,".mask|0:-1")]}));case"stencil.opFront":case"stencil.opBack":return e((function(e){return["stencil.opBack"===t?1029:1028,Ct[e.fail||"keep"],Ct[e.zfail||"keep"],Ct[e.zpass||"keep"]]}),(function(e,r,n){function i(t){return r.def('"',t,'" in ',n,"?",a,"[",n,".",t,"]:",7680)}var a=e.constants.stencilOps;return["stencil.opBack"===t?1029:1028,i("fail"),i("zfail"),i("zpass")]}));case"polygonOffset.offset":return e((function(t){return[0|t.factor,0|t.units]}),(function(t,e,r){return[e.def(r,".factor|0"),e=e.def(r,".units|0")]}));case"cull.face":return e((function(t){var e=0;return"front"===t?e=1028:"back"===t&&(e=1029),e}),(function(t,e,r){return e.def(r,'==="front"?',1028,":",1029)}));case"lineWidth":return e((function(t){return t}),(function(t,e,r){return r}));case"frontFace":return e((function(t){return Mt[t]}),(function(t,e,r){return e.def(r+'==="cw"?2304:2305')}));case"colorMask":return e((function(t){return t.map((function(t){return!!t}))}),(function(t,e,r){return a(4,(function(t){return"!!"+r+"["+t+"]"}))}));case"sample.coverage":return e((function(t){return["value"in t?t.value:1,!!t.invert]}),(function(t,e,r){return[e.def('"value" in ',r,"?+",r,".value:1"),e=e.def("!!",r,".invert")]}))}})),i}(t),u=w(t),h=s.viewport;return h&&(c.viewport=h),(s=s[h=v("scissor.box")])&&(c[h]=s),(o={framebuffer:o,draw:l,shader:u,state:c,dirty:s=0>1)",s],");")}function e(){r(l,".drawArraysInstancedANGLE(",[d,g,m,s],");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}function o(){function t(){r(u+".drawElements("+[d,m,v,g+"<<(("+v+"-5121)>>1)"]+");")}function e(){r(u+".drawArrays("+[d,g,m]+");")}p?y?t():(r("if(",p,"){"),t(),r("}else{"),e(),r("}")):e()}var s,l,c=t.shared,u=c.gl,h=c.draw,f=n.draw,p=function(){var i=f.elements,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(h,".","elements"),i&&a("if("+i+")"+u+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),d=i("primitive"),g=i("offset"),m=function(){var i=f.count,a=e;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(t,a)):i=a.def(h,".","count"),i}();if("number"==typeof m){if(0===m)return}else r("if(",m,"){"),r.exit("}");Q&&(s=i("instances"),l=t.instancing);var v=p+".type",y=f.elements&&z(f.elements);Q&&("number"!=typeof s||0<=s)?"string"==typeof s?(r("if(",s,">0){"),a(),r("}else if(",s,"<0){"),o(),r("}")):a():o()}function U(t,e,r,n,i){return i=(e=b()).proc("body",i),Q&&(e.instancing=i.def(e.shared.extensions,".angle_instanced_arrays")),t(e,i,r,n),e.compile().body}function H(t,e,r,n){S(t,e),j(t,e,r,n.attributes,(function(){return!0})),B(t,e,r,n.uniforms,(function(){return!0})),Y(t,e,e,r)}function G(t,e,r,n){function i(){return!0}t.batchId="a1",S(t,e),j(t,e,r,n.attributes,i),B(t,e,r,n.uniforms,i),Y(t,e,e,r)}function q(t,e,r,n){function i(t){return t.contextDep&&o||t.propDep}function a(t){return!i(t)}S(t,e);var o=r.contextDep,s=e.def(),l=e.def();t.shared.props=l,t.batchId=s;var c=t.scope(),u=t.scope();e(c.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",l,"=","a0","[",s,"];",u,"}",c.exit),r.needsContext&&k(t,u,r.context),r.needsFramebuffer&&I(t,u,r.framebuffer),L(t,u,r.state,i),r.profile&&i(r.profile)&&N(t,u,r,!1,!0),n?(j(t,c,r,n.attributes,a),j(t,u,r,n.attributes,i),B(t,c,r,n.uniforms,a),B(t,u,r,n.uniforms,i),Y(t,c,u,r)):(e=t.global.def("{}"),n=r.shader.progVar.append(t,u),l=u.def(n,".id"),c=u.def(e,"[",l,"]"),u(t.shared.gl,".useProgram(",n,".program);","if(!",c,"){",c,"=",e,"[",l,"]=",t.link((function(e){return U(G,t,r,e,2)})),"(",n,");}",c,".call(this,a0[",s,"],",s,");"))}function W(t,r){function n(e){var n=r.shader[e];n&&i.set(a.shader,"."+e,n.append(t,i))}var i=t.proc("scope",3);t.batchId="a2";var a=t.shared,o=a.current;k(t,i,r.context),r.framebuffer&&r.framebuffer.append(t,i),P(Object.keys(r.state)).forEach((function(e){var n=r.state[e].append(t,i);m(n)?n.forEach((function(r,n){i.set(t.next[e],"["+n+"]",r)})):i.set(a.next,"."+e,n)})),N(t,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach((function(e){var n=r.draw[e];n&&i.set(a.draw,"."+e,""+n.append(t,i))})),Object.keys(r.uniforms).forEach((function(n){i.set(a.uniforms,"["+e.id(n)+"]",r.uniforms[n].append(t,i))})),Object.keys(r.attributes).forEach((function(e){var n=r.attributes[e].append(t,i),a=t.scopeAttrib(e);Object.keys(new X).forEach((function(t){i.set(a,"."+t,n[t])}))})),n("vert"),n("frag"),0=--this.refCount&&o(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var t=0;return Object.keys(u).forEach((function(e){t+=u[e].stats.size})),t}),{create:function(e,r){function o(e,r){var n=0,a=0,u=32854;if("object"==typeof e&&e?("shape"in e?(n=0|(a=e.shape)[0],a=0|a[1]):("radius"in e&&(n=a=0|e.radius),"width"in e&&(n=0|e.width),"height"in e&&(a=0|e.height)),"format"in e&&(u=s[e.format])):"number"==typeof e?(n=0|e,a="number"==typeof r?0|r:n):e||(n=a=1),n!==c.width||a!==c.height||u!==c.format)return o.width=c.width=n,o.height=c.height=a,c.format=u,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,u,n,a),i.profile&&(c.stats.size=mt[c.format]*c.width*c.height),o.format=l[c.format],o}var c=new a(t.createRenderbuffer());return u[c.id]=c,n.renderbufferCount++,o(e,r),o.resize=function(e,r){var n=0|e,a=0|r||n;return n===c.width&&a===c.height?o:(o.width=c.width=n,o.height=c.height=a,t.bindRenderbuffer(36161,c.renderbuffer),t.renderbufferStorage(36161,c.format,n,a),i.profile&&(c.stats.size=mt[c.format]*c.width*c.height),o)},o._reglType="renderbuffer",o._renderbuffer=c,i.profile&&(o.stats=c.stats),o.destroy=function(){c.decRef()},o},clear:function(){Z(u).forEach(o)},restore:function(){Z(u).forEach((function(e){e.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,e.renderbuffer),t.renderbufferStorage(36161,e.format,e.width,e.height)})),t.bindRenderbuffer(36161,null)}}},yt=[];yt[6408]=4,yt[6407]=3;var xt=[];xt[5121]=1,xt[5126]=4,xt[36193]=2;var bt=["x","y","z","w"],_t="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),wt={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},At={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Ct={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Mt={cw:2304,ccw:2305},kt=new O(!1,!1,!1,(function(){}));return function(t){function e(){if(0===X.length)w&&w.update(),$=null;else{$=U.next(e),h();for(var t=X.length-1;0<=t;--t){var r=X[t];r&&r(E,null,0)}m.flush(),w&&w.update()}}function r(){!$&&0=X.length&&n()}}}}function u(){var t=W.viewport,e=W.scissor_box;t[0]=t[1]=e[0]=e[1]=0,E.viewportWidth=E.framebufferWidth=E.drawingBufferWidth=t[2]=e[2]=m.drawingBufferWidth,E.viewportHeight=E.framebufferHeight=E.drawingBufferHeight=t[3]=e[3]=m.drawingBufferHeight}function h(){E.tick+=1,E.time=g(),u(),G.procs.poll()}function f(){u(),G.procs.refresh(),w&&w.update()}function g(){return(H()-A)/1e3}if(!(t=i(t)))return null;var m=t.gl,v=m.getContextAttributes();m.isContextLost();var y=function(t,e){function r(e){var r;e=e.toLowerCase();try{r=n[e]=t.getExtension(e)}catch(t){}return!!r}for(var n={},i=0;ie;++e)tt(B({framebuffer:t.framebuffer.faces[e]},t),l);else tt(t,l);else l(0,t)},prop:V.define.bind(null,1),context:V.define.bind(null,2),this:V.define.bind(null,3),draw:s({}),buffer:function(t){return P.create(t,34962,!1,!1)},elements:function(t){return O.create(t,!1)},texture:R.create2D,cube:R.createCube,renderbuffer:F.create,framebuffer:Y.create,framebufferCube:Y.createCube,attributes:v,frame:c,on:function(t,e){var r;switch(t){case"frame":return c(e);case"lost":r=J;break;case"restore":r=K;break;case"destroy":r=Q}return r.push(e),{cancel:function(){for(var t=0;t - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ -"use strict";var n,i="";e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("expected a string");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;if(n!==t||void 0===n)n=t,i="";else if(i.length>=r)return i.substr(0,r);for(;r>i.length&&e>1;)1&e&&(i+=t),e>>=1,t+=t;return i=(i+=t).substr(0,r)}},{}],503:[function(t,r,n){(function(t){r.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],504:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];(l=o-((r=a+o)-a))&&(t[--n]=r,r=l)}var s=0;for(i=n;i>1;return["sum(",t(e.slice(0,r)),",",t(e.slice(r)),")"].join("")}(e);var n}function h(t){return new Function("sum","scale","prod","compress",["function robustDeterminant",t,"(m){return compress(",u(c(t)),")};return robustDeterminant",t].join(""))(i,a,n,o)}var f=[function(){return[0]},function(t){return[t[0][0]]}];!function(){for(;f.length>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return u(e,t)}function h(t){if(2===t.length)return[["diff(",u(t[0][0],t[1][1]),",",u(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0&&r.push(","),r.push("[");for(var o=0;o0&&r.push(","),o===i?r.push("+b[",a,"]"):r.push("+A[",a,"][",o,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var s=new Function("det",r.join(""));return s(t<6?n[t]:n)}var o=[function(){return[0]},function(t,e){return[[e[0]],[t[0][0]]]}];!function(){for(;o.length>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function u(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=33306690738754716e-32*n;return o>=s||o<=-s?o:f(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],h=e[2]-n[2],f=r[2]-n[2],d=a*c,g=o*l,m=o*s,v=i*c,y=i*l,x=a*s,b=u*(d-g)+h*(m-v)+f*(y-x),_=7771561172376103e-31*((Math.abs(d)+Math.abs(g))*Math.abs(u)+(Math.abs(m)+Math.abs(v))*Math.abs(h)+(Math.abs(y)+Math.abs(x))*Math.abs(f));return b>_||-b>_?b:p(t,e,r,n)}];function g(t){var e=d[t.length];return e||(e=d[t.length]=h(t.length)),e.apply(void 0,t)}!function(){for(;d.length<=s;)d.push(h(d.length));for(var t=[],r=["slow"],n=0;n<=s;++n)t.push("a"+n),r.push("o"+n);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i0&&o>0||a<0&&o<0)return!1;var s=n(r,t,e),l=n(i,t,e);return!(s>0&&l>0||s<0&&l<0)&&(0!==a||0!==o||0!==s||0!==l||function(t,e,r,n){for(var i=0;i<2;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],h=Math.min(c,u);if(Math.max(c,u)=n?(i=h,(l+=1)=n?(i=h,(l+=1)0?1:0}},{}],516:[function(t,e,r){"use strict";e.exports=function(t){return i(n(t))};var n=t("boundary-cells"),i=t("reduce-simplicial-complex")},{"boundary-cells":97,"reduce-simplicial-complex":491}],517:[function(t,e,r){"use strict";e.exports=function(t,e,r,s){if(r=r||0,void 0===s&&(s=function(t){for(var e=t.length,r=0,n=0;n>1,v=E[2*m+1];","if(v===b){return m}","if(b0&&l.push(","),l.push("[");for(var n=0;n0&&l.push(","),l.push("B(C,E,c[",i[0],"],c[",i[1],"])")}l.push("]")}l.push(");")}}for(a=t+1;a>1;--a){a>1,s=a(t[o],e);s<=0?(0===s&&(i=o),r=o+1):s>0&&(n=o-1)}return i}function u(t,e){for(var r=new Array(t.length),i=0,o=r.length;i=t.length||0!==a(t[m],s)););}return r}function h(t,e){if(e<0)return[];for(var r=[],i=(1<>>u&1&&c.push(i[u]);e.push(c)}return s(e)},r.skeleton=h,r.boundary=function(t){for(var e=[],r=0,n=t.length;r>1:(t>>1)-1}function x(t){for(var e=v(t);;){var r=e,n=2*t+1,i=2*(t+1),a=t;if(n0;){var r=y(t);if(!(r>=0&&e0){var t=C[0];return m(0,k-1),k-=1,x(0),t}return-1}function w(t,e){var r=C[t];return c[r]===e?t:(c[r]=-1/0,b(t),_(),c[r]=e,b((k+=1)-1))}function A(t){if(!u[t]){u[t]=!0;var e=s[t],r=l[t];s[r]>=0&&(s[r]=e),l[e]>=0&&(l[e]=r),M[e]>=0&&w(M[e],g(e)),M[r]>=0&&w(M[r],g(r))}}var C=[],M=new Array(a);for(h=0;h>1;h>=0;--h)x(h);for(;;){var I=_();if(I<0||c[I]>r)break;A(I)}var T=[];for(h=0;h=0&&r>=0&&e!==r){var n=M[e],i=M[r];n!==i&&S.push([n,i])}})),i.unique(i.normalize(S)),{positions:T,edges:S}};var n=t("robust-orientation"),i=t("simplicial-complex")},{"robust-orientation":509,"simplicial-complex":521}],524:[function(t,e,r){"use strict";e.exports=function(t,e){var r,a,o,s;if(e[0][0]e[1][0]))return i(e,t);r=e[1],a=e[0]}if(t[0][0]t[1][0]))return-i(t,e);o=t[1],s=t[0]}var l=n(r,a,s),c=n(r,a,o);if(l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=n(s,o,a),c=n(s,o,r),l<0){if(c<=0)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return a[0]-s[0]};var n=t("robust-orientation");function i(t,e){var r,i,a,o;if(e[0][0]e[1][0])){var s=Math.min(t[0][1],t[1][1]),l=Math.max(t[0][1],t[1][1]),c=Math.min(e[0][1],e[1][1]),u=Math.max(e[0][1],e[1][1]);return lu?s-u:l-u}r=e[1],i=e[0]}t[0][1]0)if(e[0]!==o[1][0])r=t,t=t.right;else{if(l=c(t.right,e))return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l;if(l=c(t.right,e))return l;t=t.left}}return r}function u(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function h(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}s.prototype.castUp=function(t){var e=n.le(this.coordinates,t[0]);if(e<0)return-1;this.slabs[e];var r=c(this.slabs[e],t),i=-1;if(r&&(i=r.value),this.coordinates[e]===t[0]){var s=null;if(r&&(s=r.key),e>0){var u=c(this.slabs[e-1],t);u&&(s?o(u.key,s)>0&&(s=u.key,i=u.value):(i=u.value,s=u.key))}var h=this.horizontal[e];if(h.length>0){var f=n.ge(h,t[1],l);if(f=h.length)return i;p=h[f]}}if(p.start)if(s){var d=a(s[0],s[1],[t[0],p.y]);s[0][0]>s[1][0]&&(d=-d),d>0&&(i=p.index)}else i=p.index;else p.y!==t[1]&&(i=p.index)}}}return i}},{"./lib/order-segments":524,"binary-search-bounds":93,"functional-red-black-tree":233,"robust-orientation":509}],526:[function(t,e,r){"use strict";var n=t("robust-dot-product"),i=t("robust-sum");function a(t,e){var r=i(n(t,e),[e[e.length-1]]);return r[r.length-1]}function o(t,e,r,n){var i=-e/(n-e);i<0?i=0:i>1&&(i=1);for(var a=1-i,o=t.length,s=new Array(o),l=0;l0||i>0&&u<0){var h=o(s,u,l,i);r.push(h),n.push(h.slice())}u<0?n.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),n.push(l.slice())),i=u}return{positive:r,negative:n}},e.exports.positive=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c>=0&&r.push(s.slice()),n=c}return r},e.exports.negative=function(t,e){for(var r=[],n=a(t[t.length-1],e),i=t[t.length-1],s=t[0],l=0;l0||n>0&&c<0)&&r.push(o(i,c,s,n)),c<=0&&r.push(s.slice()),n=c}return r}},{"robust-dot-product":506,"robust-sum":514}],527:[function(t,e,r){!function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function e(r){return function(r,n){var i,a,o,s,l,c,u,h,f,p=1,d=r.length,g="";for(a=0;a=0),s.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,s.width?parseInt(s.width):0);break;case"e":i=s.precision?parseFloat(i).toExponential(s.precision):parseFloat(i).toExponential();break;case"f":i=s.precision?parseFloat(i).toFixed(s.precision):parseFloat(i);break;case"g":i=s.precision?String(Number(i.toPrecision(s.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=s.precision?i.substring(0,s.precision):i;break;case"t":i=String(!!i),i=s.precision?i.substring(0,s.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=s.precision?i.substring(0,s.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=s.precision?i.substring(0,s.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(s.type)?g+=i:(!t.number.test(s.type)||h&&!s.sign?f="":(f=h?"+":"-",i=i.toString().replace(t.sign,"")),c=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",u=s.width-(f+i).length,l=s.width&&u>0?c.repeat(u):"",g+=s.align?f+i+l:"0"===c?f+l+i:l+f+i)}return g}(function(e){if(i[e])return i[e];for(var r,n=e,a=[],o=0;n;){if(null!==(r=t.text.exec(n)))a.push(r[0]);else if(null!==(r=t.modulo.exec(n)))a.push("%");else{if(null===(r=t.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var s=[],l=r[2],c=[];if(null===(c=t.key.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(c[1]);""!==(l=l.substring(c[0].length));)if(null!==(c=t.key_access.exec(l)))s.push(c[1]);else{if(null===(c=t.index_access.exec(l)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(c[1])}r[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}n=n.substring(r[0].length)}return i[e]=a}(r),arguments)}function n(t,r){return e.apply(null,[t].concat(r||[]))}var i=Object.create(null);void 0!==r&&(r.sprintf=e,r.vsprintf=n),"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}()},{}],528:[function(t,e,r){"use strict";var n=t("parenthesis");e.exports=function(t,e,r){if(null==t)throw Error("First argument should be a string");if(null==e)throw Error("Separator should be a string or a RegExp");r?("string"==typeof r||Array.isArray(r))&&(r={ignore:r}):r={},null==r.escape&&(r.escape=!0),null==r.ignore?r.ignore=["[]","()","{}","<>",'""',"''","``","“”","«»"]:("string"==typeof r.ignore&&(r.ignore=[r.ignore]),r.ignore=r.ignore.map((function(t){return 1===t.length&&(t+=t),t})));var i=n.parse(t,{flat:!0,brackets:r.ignore}),a=i[0].split(e);if(r.escape){for(var o=[],s=0;s0;){e=c[c.length-1];var p=t[e];if(a[e]=0&&s[e].push(o[g])}a[e]=d}else{if(n[e]===r[e]){var m=[],v=[],y=0;for(d=l.length-1;d>=0;--d){var x=l[d];if(i[x]=!1,m.push(x),v.push(s[x]),y+=s[x].length,o[x]=h.length,x===e){l.length=d;break}}h.push(m);var b=new Array(y);for(d=0;d c)|0 },"),"generic"===e&&a.push("getters:[0],");for(var s=[],l=[],c=0;c>>7){"),c=0;c<1<<(1<128&&c%128==0){h.length>0&&f.push("}}");var p="vExtra"+h.length;a.push("case ",c>>>7,":",p,"(m&0x7f,",l.join(),");break;"),f=["function ",p,"(m,",l.join(),"){switch(m){"],h.push(f)}f.push("case ",127&c,":");for(var d=new Array(r),g=new Array(r),m=new Array(r),v=new Array(r),y=0,x=0;xx)&&!(c&1<<_)!=!(c&1<0&&(M="+"+m[b]+"*c");var k=d[b].length/y*.5,I=.5+v[b]/y*.5;C.push("d"+b+"-"+I+"-"+k+"*("+d[b].join("+")+M+")/("+g[b].join("+")+")")}f.push("a.push([",C.join(),"]);","break;")}a.push("}},"),h.length>0&&f.push("}}");var T=[];for(c=0;c<1<1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)};r.default=function(t){var e=t.px,r=t.py,l=t.cx,c=t.cy,u=t.rx,h=t.ry,f=t.xAxisRotation,p=void 0===f?0:f,d=t.largeArcFlag,g=void 0===d?0:d,m=t.sweepFlag,v=void 0===m?0:m,y=[];if(0===u||0===h)return[];var x=Math.sin(p*i/360),b=Math.cos(p*i/360),_=b*(e-l)/2+x*(r-c)/2,w=-x*(e-l)/2+b*(r-c)/2;if(0===_&&0===w)return[];u=Math.abs(u),h=Math.abs(h);var A=Math.pow(_,2)/Math.pow(u,2)+Math.pow(w,2)/Math.pow(h,2);A>1&&(u*=Math.sqrt(A),h*=Math.sqrt(A));var C=function(t,e,r,n,a,o,l,c,u,h,f,p){var d=Math.pow(a,2),g=Math.pow(o,2),m=Math.pow(f,2),v=Math.pow(p,2),y=d*g-d*v-g*m;y<0&&(y=0),y/=d*v+g*m;var x=(y=Math.sqrt(y)*(l===c?-1:1))*a/o*p,b=y*-o/a*f,_=h*x-u*b+(t+r)/2,w=u*x+h*b+(e+n)/2,A=(f-x)/a,C=(p-b)/o,M=(-f-x)/a,k=(-p-b)/o,I=s(1,0,A,C),T=s(A,C,M,k);return 0===c&&T>0&&(T-=i),1===c&&T<0&&(T+=i),[_,w,I,T]}(e,r,l,c,u,h,g,v,x,b,_,w),M=n(C,4),k=M[0],I=M[1],T=M[2],L=M[3],S=Math.abs(L)/(i/4);Math.abs(1-S)<1e-7&&(S=1);var E=Math.max(Math.ceil(S),1);L/=E;for(var D=0;De[2]&&(e[2]=c[u+0]),c[u+1]>e[3]&&(e[3]=c[u+1]);return e}},{"abs-svg-path":63,assert:70,"is-svg-path":426,"normalize-svg-path":533,"parse-svg-path":462}],533:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=[],o=0,s=0,l=0,c=0,u=null,h=null,f=0,p=0,d=0,g=t.length;d4?(o=m[m.length-4],s=m[m.length-3]):(o=f,s=p),r.push(m)}return r};var n=t("svg-arc-to-cubic-bezier");function i(t,e,r,n){return["C",t,e,r,n,r,n]}function a(t,e,r,n,i,a){return["C",t/3+2/3*r,e/3+2/3*n,i/3+2/3*r,a/3+2/3*n,i,a]}},{"svg-arc-to-cubic-bezier":531}],534:[function(t,e,r){"use strict";var n,i=t("svg-path-bounds"),a=t("parse-svg-path"),o=t("draw-svg-path"),s=t("is-svg-path"),l=t("bitmap-sdf"),c=document.createElement("canvas"),u=c.getContext("2d");e.exports=function(t,e){if(!s(t))throw Error("Argument should be valid svg path string");var r,h;e||(e={}),e.shape?(r=e.shape[0],h=e.shape[1]):(r=c.width=e.w||e.width||200,h=c.height=e.h||e.height||200);var f=Math.min(r,h),p=e.stroke||0,d=e.viewbox||e.viewBox||i(t),g=[r/(d[2]-d[0]),h/(d[3]-d[1])],m=Math.min(g[0]||0,g[1]||0)/2;if(u.fillStyle="black",u.fillRect(0,0,r,h),u.fillStyle="white",p&&("number"!=typeof p&&(p=1),u.strokeStyle=p>0?"white":"black",u.lineWidth=Math.abs(p)),u.translate(.5*r,.5*h),u.scale(m,m),function(){if(null!=n)return n;var t=document.createElement("canvas").getContext("2d");if(t.canvas.width=t.canvas.height=1,!window.Path2D)return n=!1;var e=new Path2D("M0,0h1v1h-1v-1Z");t.fillStyle="black",t.fill(e);var r=t.getImageData(0,0,1,1);return n=r&&r.data&&255===r.data[3]}()){var v=new Path2D(t);u.fill(v),p&&u.stroke(v)}else{var y=a(t);o(u,y),u.fill(),p&&u.stroke()}return u.setTransform(1,0,0,1,0,0),l(u,{cutoff:null!=e.cutoff?e.cutoff:.5,radius:null!=e.radius?e.radius:.5*f})}},{"bitmap-sdf":95,"draw-svg-path":170,"is-svg-path":426,"parse-svg-path":462,"svg-path-bounds":532}],535:[function(t,e,r){(function(r){"use strict";e.exports=function t(e,r,i){i=i||{};var o=a[e];o||(o=a[e]={" ":{data:new Float32Array(0),shape:.2}});var s=o[r];if(!s)if(r.length<=1||!/\d/.test(r))s=o[r]=function(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;o0&&(h+=.02);var p=new Float32Array(u),d=0,g=-.5*h;for(f=0;f1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=S(t,360),e=S(e,100),r=S(r,100),0===e)n=i=a=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),i=o(l,s,t),a=o(l,s,t-1/3)}return{r:255*n,g:255*i,b:255*a}}(e.h,h,p),d=!0,g="hsl"),e.hasOwnProperty("a")&&(u=e.a)),u=L(u),{ok:d,format:e.format||g,r:o(255,s(c.r,0)),g:o(255,s(c.g,0)),b:o(255,s(c.b,0)),a:u}}(e);this._originalInput=e,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=a(100*this._a)/100,this._format=l.format||u.format,this._gradientType=l.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=u.ok,this._tc_id=i++}function u(t,e,r){t=S(t,255),e=S(e,255),r=S(r,255);var n,i,a=s(t,e,r),l=o(t,e,r),c=(a+l)/2;if(a==l)n=i=0;else{var u=a-l;switch(i=c>.5?u/(2-a-l):u/(a+l),a){case t:n=(e-r)/u+(e>1)+720)%360;--e;)n.h=(n.h+i)%360,a.push(c(n));return a}function k(t,e){e=e||6;for(var r=c(t).toHsv(),n=r.h,i=r.s,a=r.v,o=[],s=1/e;e--;)o.push(c({h:n,s:i,v:a})),a=(a+s)%1;return o}c.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var e,r,n,i=this.toRgb();return e=i.r/255,r=i.g/255,n=i.b/255,.2126*(e<=.03928?e/12.92:t.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:t.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:t.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=L(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=h(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=h(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return f(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,r,n,i){var o=[P(a(t).toString(16)),P(a(e).toString(16)),P(a(r).toString(16)),P(z(n))];return i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*S(this._r,255))+"%",g:a(100*S(this._g,255))+"%",b:a(100*S(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*S(this._r,255))+"%, "+a(100*S(this._g,255))+"%, "+a(100*S(this._b,255))+"%)":"rgba("+a(100*S(this._r,255))+"%, "+a(100*S(this._g,255))+"%, "+a(100*S(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(T[f(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+p(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var i=c(t);r="#"+p(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return c(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(v,arguments)},brighten:function(){return this._applyModification(y,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(g,arguments)},greyscale:function(){return this._applyModification(m,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(_,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(C,arguments)},triad:function(){return this._applyCombination(w,arguments)},tetrad:function(){return this._applyCombination(A,arguments)}},c.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:O(t[n]));t=r}return c(t,e)},c.equals=function(t,e){return!(!t||!e)&&c(t).toRgbString()==c(e).toRgbString()},c.random=function(){return c.fromRatio({r:l(),g:l(),b:l()})},c.mix=function(t,e,r){r=0===r?0:r||50;var n=c(t).toRgb(),i=c(e).toRgb(),a=r/100;return c({r:(i.r-n.r)*a+n.r,g:(i.g-n.g)*a+n.g,b:(i.b-n.b)*a+n.b,a:(i.a-n.a)*a+n.a})},c.readability=function(e,r){var n=c(e),i=c(r);return(t.max(n.getLuminance(),i.getLuminance())+.05)/(t.min(n.getLuminance(),i.getLuminance())+.05)},c.isReadable=function(t,e,r){var n,i,a,o,s,l=c.readability(t,e);switch(i=!1,(a=r,o=((a=a||{level:"AA",size:"small"}).level||"AA").toUpperCase(),s=(a.size||"small").toLowerCase(),"AA"!==o&&"AAA"!==o&&(o="AA"),"small"!==s&&"large"!==s&&(s="small"),n={level:o,size:s}).level+n.size){case"AAsmall":case"AAAlarge":i=l>=4.5;break;case"AAlarge":i=l>=3;break;case"AAAsmall":i=l>=7}return i},c.mostReadable=function(t,e,r){var n,i,a,o,s=null,l=0;i=(r=r||{}).includeFallbackColors,a=r.level,o=r.size;for(var u=0;ul&&(l=n,s=c(e[u]));return c.isReadable(t,s,{level:a,size:o})||!i?s:(r.includeFallbackColors=!1,c.mostReadable(t,["#fff","#000"],r))};var I=c.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},T=c.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(I);function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function S(e,r){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(e)&&(e="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(e);return e=o(r,s(0,parseFloat(e))),n&&(e=parseInt(e*r,10)/100),t.abs(e-r)<1e-6?1:e%r/parseFloat(r)}function E(t){return o(1,s(0,t))}function D(t){return parseInt(t,16)}function P(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}function z(e){return t.round(255*parseFloat(e)).toString(16)}function R(t){return D(t)/255}var F,N,j,B=(N="[\\s|\\(]+("+(F="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",j="[\\s|\\(]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")[,|\\s]+("+F+")\\s*\\)?",{CSS_UNIT:new RegExp(F),rgb:new RegExp("rgb"+N),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+N),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+N),hsva:new RegExp("hsva"+j),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function Y(t){return!!B.CSS_UNIT.exec(t)}void 0!==e&&e.exports?e.exports=c:window.tinycolor=c}(Math)},{}],537:[function(t,e,r){"use strict";e.exports=i,e.exports.float32=e.exports.float=i,e.exports.fract32=e.exports.fract=function(t){if(t.length){for(var e=i(t),r=0,n=e.length;rh&&(h=l[0]),l[1]f&&(f=l[1])}function i(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(i);break;case"Point":n(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(n)}}if(!e){var a,o,s=r(t),l=new Array(2),c=1/0,u=c,h=-c,f=-c;for(o in t.arcs.forEach((function(t){for(var e=-1,r=t.length;++eh&&(h=l[0]),l[1]f&&(f=l[1])})),t.objects)i(t.objects[o]);e=t.bbox=[c,u,h,f]}return e},i=function(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r};function a(t,e){var r=e.id,n=e.bbox,i=null==e.properties?{}:e.properties,a=o(t,e);return null==r&&null==n?{type:"Feature",properties:i,geometry:a}:null==n?{type:"Feature",id:r,properties:i,geometry:a}:{type:"Feature",id:r,bbox:n,properties:i,geometry:a}}function o(t,e){var n=r(t),a=t.arcs;function o(t,e){e.length&&e.pop();for(var r=a[t<0?~t:t],o=0,s=r.length;o1)n=function(t,e,r){var n,i=[],a=[];function o(t){var e=t<0?~t:t;(a[e]||(a[e]=[])).push({i:t,g:n})}function s(t){t.forEach(o)}function l(t){t.forEach(s)}return function t(e){switch(n=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":s(e.arcs);break;case"MultiLineString":case"Polygon":l(e.arcs);break;case"MultiPolygon":!function(t){t.forEach(l)}(e.arcs)}}(e),a.forEach(null==r?function(t){i.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&i.push(t[0].i)}),i}(0,e,r);else for(i=0,n=new Array(a=t.arcs.length);i1)for(var a,o,c=1,u=l(i[0]);cu&&(o=i[0],i[0]=i[c],i[c]=o,u=a);return i}))}}var u=function(t,e){for(var r=0,n=t.length;r>>1;t[i]=2))throw new Error("n must be ≥2");if(t.transform)throw new Error("already quantized");var r,i=n(t),a=i[0],o=(i[2]-a)/(e-1)||1,s=i[1],l=(i[3]-s)/(e-1)||1;function c(t){t[0]=Math.round((t[0]-a)/o),t[1]=Math.round((t[1]-s)/l)}function u(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(u);break;case"Point":c(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(c)}}for(r in t.arcs.forEach((function(t){for(var e,r,n,i=1,c=1,u=t.length,h=t[0],f=h[0]=Math.round((h[0]-a)/o),p=h[1]=Math.round((h[1]-s)/l);iMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,l=0;l<3;++l)a+=t[l]*t[l],o+=i[l]*t[l];for(l=0;l<3;++l)i[l]-=o/a*t[l];return s(i,i),i}function f(t,e,r,i,a,o,s,l){this.center=n(r),this.up=n(i),this.right=n(a),this.radius=n([o]),this.angle=n([s,l]),this.angle.bounds=[[-1/0,-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;c<16;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}var p=f.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-1/0,e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,n=0,i=0,a=0;a<3;++a)i+=e[a]*r[a],n+=e[a]*e[a];var l=Math.sqrt(n),u=0;for(a=0;a<3;++a)r[a]-=e[a]*i/n,u+=r[a]*r[a],e[a]/=l;var h=Math.sqrt(u);for(a=0;a<3;++a)r[a]/=h;var f=this.computedToward;o(f,e,r),s(f,f);var p=Math.exp(this.computedRadius[0]),d=this.computedAngle[0],g=this.computedAngle[1],m=Math.cos(d),v=Math.sin(d),y=Math.cos(g),x=Math.sin(g),b=this.computedCenter,_=m*y,w=v*y,A=x,C=-m*x,M=-v*x,k=y,I=this.computedEye,T=this.computedMatrix;for(a=0;a<3;++a){var L=_*r[a]+w*f[a]+A*e[a];T[4*a+1]=C*r[a]+M*f[a]+k*e[a],T[4*a+2]=L,T[4*a+3]=0}var S=T[1],E=T[5],D=T[9],P=T[2],O=T[6],z=T[10],R=E*z-D*O,F=D*P-S*z,N=S*O-E*P,j=c(R,F,N);for(R/=j,F/=j,N/=j,T[0]=R,T[4]=F,T[8]=N,a=0;a<3;++a)I[a]=b[a]+T[2+4*a]*p;for(a=0;a<3;++a){u=0;for(var B=0;B<3;++B)u+=T[a+4*B]*I[B];T[12+a]=-u}T[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;n<16;++n)e[n]=r[n];return e}return r};var d=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;d[0]=i[2],d[1]=i[6],d[2]=i[10];for(var o=this.computedUp,s=this.computedRight,l=this.computedToward,c=0;c<3;++c)i[4*c]=o[c],i[4*c+1]=s[c],i[4*c+2]=l[c];for(a(i,i,n,d),c=0;c<3;++c)o[c]=i[4*c],s[c]=i[4*c+1];this.up.set(t,o[0],o[1],o[2]),this.right.set(t,s[0],s[1],s[2])}},p.pan=function(t,e,r,n){e=e||0,r=r||0,n=n||0,this.recalcMatrix(t);var i=this.computedMatrix,a=(Math.exp(this.computedRadius[0]),i[1]),o=i[5],s=i[9],l=c(a,o,s);a/=l,o/=l,s/=l;var u=i[0],h=i[4],f=i[8],p=u*a+h*o+f*s,d=c(u-=a*p,h-=o*p,f-=s*p),g=(u/=d)*e+a*r,m=(h/=d)*e+o*r,v=(f/=d)*e+s*r;this.center.move(t,g,m,v);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+n),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,n){var a=1;"number"==typeof r&&(a=0|r),(a<0||a>3)&&(a=1);var o=(a+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var s=e[a],l=e[a+4],h=e[a+8];if(n){var f=Math.abs(s),p=Math.abs(l),d=Math.abs(h),g=Math.max(f,p,d);f===g?(s=s<0?-1:1,l=h=0):d===g?(h=h<0?-1:1,s=l=0):(l=l<0?-1:1,s=h=0)}else{var m=c(s,l,h);s/=m,l/=m,h/=m}var v,y,x=e[o],b=e[o+4],_=e[o+8],w=x*s+b*l+_*h,A=c(x-=s*w,b-=l*w,_-=h*w),C=l*(_/=A)-h*(b/=A),M=h*(x/=A)-s*_,k=s*b-l*x,I=c(C,M,k);if(C/=I,M/=I,k/=I,this.center.jump(t,H,G,q),this.radius.idle(t),this.up.jump(t,s,l,h),this.right.jump(t,x,b,_),2===a){var T=e[1],L=e[5],S=e[9],E=T*x+L*b+S*_,D=T*C+L*M+S*k;v=R<0?-Math.PI/2:Math.PI/2,y=Math.atan2(D,E)}else{var P=e[2],O=e[6],z=e[10],R=P*s+O*l+z*h,F=P*x+O*b+z*_,N=P*C+O*M+z*k;v=Math.asin(u(R)),y=Math.atan2(N,F)}this.angle.jump(t,y,v),this.recalcMatrix(t);var j=e[2],B=e[6],Y=e[10],V=this.computedMatrix;i(V,e);var U=V[15],H=V[12]/U,G=V[13]/U,q=V[14]/U,W=Math.exp(this.computedRadius[0]);this.center.jump(t,H-j*W,G-B*W,q-Y*W)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter;var i=(n=n||this.computedUp)[0],a=n[1],o=n[2],s=c(i,a,o);if(!(s<1e-6)){i/=s,a/=s,o/=s;var l=e[0]-r[0],h=e[1]-r[1],f=e[2]-r[2],p=c(l,h,f);if(!(p<1e-6)){l/=p,h/=p,f/=p;var d=this.computedRight,g=d[0],m=d[1],v=d[2],y=i*g+a*m+o*v,x=c(g-=y*i,m-=y*a,v-=y*o);if(!(x<.01&&(x=c(g=a*f-o*h,m=o*l-i*f,v=i*h-a*l))<1e-6)){g/=x,m/=x,v/=x,this.up.set(t,i,a,o),this.right.set(t,g,m,v),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(p));var b=a*v-o*m,_=o*g-i*v,w=i*m-a*g,A=c(b,_,w),C=i*l+a*h+o*f,M=g*l+m*h+v*f,k=(b/=A)*l+(_/=A)*h+(w/=A)*f,I=Math.asin(u(C)),T=Math.atan2(k,M),L=this.angle._state,S=L[L.length-1],E=L[L.length-2];S%=2*Math.PI;var D=Math.abs(S+2*Math.PI-T),P=Math.abs(S-T),O=Math.abs(S-2*Math.PI-T);D0?r.pop():new ArrayBuffer(t)}function f(t){return new Uint8Array(h(t),0,t)}function p(t){return new Uint16Array(h(2*t),0,t)}function d(t){return new Uint32Array(h(4*t),0,t)}function g(t){return new Int8Array(h(t),0,t)}function m(t){return new Int16Array(h(2*t),0,t)}function v(t){return new Int32Array(h(4*t),0,t)}function y(t){return new Float32Array(h(4*t),0,t)}function x(t){return new Float64Array(h(8*t),0,t)}function b(t){return o?new Uint8ClampedArray(h(t),0,t):f(t)}function _(t){return new DataView(h(t),0,t)}function w(t){t=i.nextPow2(t);var e=i.log2(t),n=c[e];return n.length>0?n.pop():new r(t)}n.free=function(t){if(r.isBuffer(t))c[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,n=0|i.log2(e);l[n].push(t)}},n.freeUint8=n.freeUint16=n.freeUint32=n.freeInt8=n.freeInt16=n.freeInt32=n.freeFloat32=n.freeFloat=n.freeFloat64=n.freeDouble=n.freeUint8Clamped=n.freeDataView=function(t){u(t.buffer)},n.freeArrayBuffer=u,n.freeBuffer=function(t){c[i.log2(t.length)].push(t)},n.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return h(t);switch(e){case"uint8":return f(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return g(t);case"int16":return m(t);case"int32":return v(t);case"float":case"float32":return y(t);case"double":case"float64":return x(t);case"uint8_clamped":return b(t);case"buffer":return w(t);case"data":case"dataview":return _(t);default:return null}return null},n.mallocArrayBuffer=h,n.mallocUint8=f,n.mallocUint16=p,n.mallocUint32=d,n.mallocInt8=g,n.mallocInt16=m,n.mallocInt32=v,n.mallocFloat32=n.mallocFloat=y,n.mallocFloat64=n.mallocDouble=x,n.mallocUint8Clamped=b,n.mallocDataView=_,n.mallocBuffer=w,n.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,l[t].length=0,c[t].length=0}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":94,buffer:107,dup:172}],545:[function(t,e,r){"use strict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e0&&(a=n.size),n.lineSpacing&&n.lineSpacing>0&&(o=n.lineSpacing),n.styletags&&n.styletags.breaklines&&(s.breaklines=!!n.styletags.breaklines),n.styletags&&n.styletags.bolds&&(s.bolds=!!n.styletags.bolds),n.styletags&&n.styletags.italics&&(s.italics=!!n.styletags.italics),n.styletags&&n.styletags.subscripts&&(s.subscripts=!!n.styletags.subscripts),n.styletags&&n.styletags.superscripts&&(s.superscripts=!!n.styletags.superscripts)),r.font=[n.fontStyle,n.fontVariant,n.fontWeight,a+"px",n.font].filter((function(t){return t})).join(" "),r.textAlign="start",r.textBaseline="alphabetic",r.direction="ltr",w(function(t,e,r,n,a,o){r=r.replace(/\n/g,""),r=!0===o.breaklines?r.replace(/\/g,"\n"):r.replace(/\/g," ");var s="",l=[];for(A=0;A-1?parseInt(t[1+i]):0,l=a>-1?parseInt(r[1+a]):0;s!==l&&(n=n.replace(F(),"?px "),k*=Math.pow(.75,l-s),n=n.replace("?px ",F())),M+=.25*L*(l-s)}if(!0===o.superscripts){var c=t.indexOf(d),h=r.indexOf(d),p=c>-1?parseInt(t[1+c]):0,g=h>-1?parseInt(r[1+h]):0;p!==g&&(n=n.replace(F(),"?px "),k*=Math.pow(.75,g-p),n=n.replace("?px ",F())),M-=.25*L*(g-p)}if(!0===o.bolds){var m=t.indexOf(u)>-1,y=r.indexOf(u)>-1;!m&&y&&(n=x?n.replace("italic ","italic bold "):"bold "+n),m&&!y&&(n=n.replace("bold ",""))}if(!0===o.italics){var x=t.indexOf(f)>-1,b=r.indexOf(f)>-1;!x&&b&&(n="italic "+n),x&&!b&&(n=n.replace("italic ",""))}e.font=n}for(w=0;w",a="",o=i.length,s=a.length,l=e[0]===d||e[0]===v,c=0,u=-s;c>-1&&-1!==(c=r.indexOf(i,c))&&-1!==(u=r.indexOf(a,c+o))&&!(u<=c);){for(var h=c;h=u)n[h]=null,r=r.substr(0,h)+" "+r.substr(h+1);else if(null!==n[h]){var f=n[h].indexOf(e[0]);-1===f?n[h]+=e:l&&(n[h]=n[h].substr(0,f+1)+(1+parseInt(n[h][f+1]))+n[h].substr(f+2))}var p=c+o,g=r.substr(p,u-p).indexOf(i);c=-1!==g?g:u+s}return n}function b(t,e){var r=n(t,128);return e?a(r.cells,r.positions,.25):{edges:r.cells,positions:r.positions}}function _(t,e,r,n){var i=b(t,n),a=function(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;l=0?e[a]:i}))},has___:{value:x((function(e){var n=y(e);return n?r in n:t.indexOf(e)>=0}))},set___:{value:x((function(n,i){var a,o=y(n);return o?o[r]=i:(a=t.indexOf(n))>=0?e[a]=i:(a=t.length,e[a]=i,t[a]=n),this}))},delete___:{value:x((function(n){var i,a,o=y(n);return o?r in o&&delete o[r]:!((i=t.indexOf(n))<0||(a=t.length-1,t[i]=void 0,e[i]=e[a],t[i]=t[a],t.length=a,e.length=a,0))}))}})};g.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},delete:{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof r?function(){function n(){this instanceof g||b();var e,n=new r,i=void 0,a=!1;return e=t?function(t,e){return n.set(t,e),n.has(t)||(i||(i=new g),i.set(t,e)),this}:function(t,e){if(a)try{n.set(t,e)}catch(r){i||(i=new g),i.set___(t,e)}else n.set(t,e);return this},Object.create(g.prototype,{get___:{value:x((function(t,e){return i?n.has(t)?n.get(t):i.get___(t,e):n.get(t,e)}))},has___:{value:x((function(t){return n.has(t)||!!i&&i.has___(t)}))},set___:{value:x(e)},delete___:{value:x((function(t){var e=!!n.delete(t);return i&&i.delete___(t)||e}))},permitHostObjects___:{value:x((function(t){if(t!==m)throw new Error("bogus call to permitHostObjects___");a=!0}))}})}t&&"undefined"!=typeof Proxy&&(Proxy=void 0),n.prototype=g.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=g)}function m(t){t.permitHostObjects___&&t.permitHostObjects___(m)}function v(t){return!(t.substr(0,l.length)==l&&"___"===t.substr(t.length-3))}function y(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[c];if(e&&e.key===t)return e;if(s(t)){e={key:t};try{return o(t,c,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(t){return}}}function x(t){return t.prototype=null,Object.freeze(t)}function b(){p||"undefined"==typeof console||(p=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()},{}],552:[function(t,e,r){var n=t("./hidden-store.js");e.exports=function(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:n(e,t)}}},{"./hidden-store.js":553}],553:[function(t,e,r){e.exports=function(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}},{}],554:[function(t,e,r){var n=t("./create-store.js");e.exports=function(){var t=n();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){return t(e).value=r,this},has:function(e){return"value"in t(e)},delete:function(e){return delete t(e).value}}}},{"./create-store.js":552}],555:[function(t,e,r){var n=t("get-canvas-context");e.exports=function(t){return n("webgl",t)}},{"get-canvas-context":235}],556:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Chinese",jdEpoch:1721425.5,hasYearZero:!1,minMonth:0,firstMonth:0,minDay:1,regionalOptions:{"":{name:"Chinese",epochs:["BEC","EC"],monthNumbers:function(t,e){if("string"==typeof t){var r=t.match(l);return r?r[0]:""}var n=this._validateYear(t),i=t.month(),a=""+this.toChineseMonth(n,i);return e&&a.length<2&&(a="0"+a),this.isIntercalaryMonth(n,i)&&(a+="i"),a},monthNames:function(t){if("string"==typeof t){var e=t.match(c);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="闰"+i),i},monthNamesShort:function(t){if("string"==typeof t){var e=t.match(u);return e?e[0]:""}var r=this._validateYear(t),n=t.month(),i=["一","二","三","四","五","六","七","八","九","十","十一","十二"][this.toChineseMonth(r,n)-1];return this.isIntercalaryMonth(r,n)&&(i="闰"+i),i},parseMonth:function(t,e){t=this._validateYear(t);var r,n=parseInt(e);if(isNaN(n))"闰"===e[0]&&(r=!0,e=e.substring(1)),"月"===e[e.length-1]&&(e=e.substring(0,e.length-1)),n=1+["一","二","三","四","五","六","七","八","九","十","十一","十二"].indexOf(e);else{var i=e[e.length-1];r="i"===i||"I"===i}return this.toMonthIndex(t,n,r)},dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},_validateYear:function(t,e){if(t.year&&(t=t.year()),"number"!=typeof t||t<1888||t>2111)throw e.replace(/\{0\}/,this.local.name);return t},toMonthIndex:function(t,e,r){var i=this.intercalaryMonth(t);if(r&&e!==i||e<1||e>12)throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return i?!r&&e<=i?e-1:e:e-1},toChineseMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);if(e<0||e>(r?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r?e>13},isIntercalaryMonth:function(t,e){t.year&&(e=(t=t.year()).month());var r=this.intercalaryMonth(t);return!!r&&r===e},leapYear:function(t){return 0!==this.intercalaryMonth(t)},weekOfYear:function(t,e,r){var i,o=this._validateYear(t,n.local.invalidyear),s=f[o-f[0]],l=s>>9&4095,c=s>>5&15,u=31&s;(i=a.newDate(l,c,u)).add(4-(i.dayOfWeek()||7),"d");var h=this.toJD(t,e,r)-i.toJD();return 1+Math.floor(h/7)},monthsInYear:function(t){return this.leapYear(t)?13:12},daysInMonth:function(t,e){t.year&&(e=t.month(),t=t.year()),t=this._validateYear(t);var r=h[t-h[0]];if(e>(r>>13?12:11))throw n.local.invalidMonth.replace(/\{0\}/,this.local.name);return r&1<<12-e?30:29},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,s,r,n.local.invalidDate);t=this._validateYear(i.year()),e=i.month(),r=i.day();var o=this.isIntercalaryMonth(t,e),s=this.toChineseMonth(t,e),l=function(t,e,r,n,i){var a,o,s;if("object"==typeof t)o=t,a=e||{};else{var l;if(!("number"==typeof t&&t>=1888&&t<=2111))throw new Error("Lunar year outside range 1888-2111");if(!("number"==typeof e&&e>=1&&e<=12))throw new Error("Lunar month outside range 1 - 12");if(!("number"==typeof r&&r>=1&&r<=30))throw new Error("Lunar day outside range 1 - 30");"object"==typeof n?(l=!1,a=n):(l=!!n,a=i||{}),o={year:t,month:e,day:r,isIntercalary:l}}s=o.day-1;var c,u=h[o.year-h[0]],p=u>>13;c=p?o.month>p?o.month:o.isIntercalary?o.month:o.month-1:o.month-1;for(var d=0;d>9&4095,(g>>5&15)-1,(31&g)+s);return a.year=m.getFullYear(),a.month=1+m.getMonth(),a.day=m.getDate(),a}(t,s,r,o);return a.toJD(l.year,l.month,l.day)},fromJD:function(t){var e=a.fromJD(t),r=function(t,e,r,n){var i,a;if("object"==typeof t)i=t,a=e||{};else{if(!("number"==typeof t&&t>=1888&&t<=2111))throw new Error("Solar year outside range 1888-2111");if(!("number"==typeof e&&e>=1&&e<=12))throw new Error("Solar month outside range 1 - 12");if(!("number"==typeof r&&r>=1&&r<=31))throw new Error("Solar day outside range 1 - 31");i={year:t,month:e,day:r},a=n||{}}var o=f[i.year-f[0]],s=i.year<<9|i.month<<5|i.day;a.year=s>=o?i.year:i.year-1,o=f[a.year-f[0]];var l,c=new Date(o>>9&4095,(o>>5&15)-1,31&o),u=new Date(i.year,i.month-1,i.day);l=Math.round((u-c)/864e5);var p,d=h[a.year-h[0]];for(p=0;p<13;p++){var g=d&1<<12-p?30:29;if(l>13;return!m||p=2&&n<=6},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{century:o[Math.floor((i.year()-1)/100)+1]||""}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year()+(i.year()<0?1:0),e=i.month(),(r=i.day())+(e>1?16:0)+(e>2?32*(e-2):0)+400*(t-1)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t+.5)-Math.floor(this.jdEpoch)-1;var e=Math.floor(t/400)+1;t-=400*(e-1),t+=t>15?16:0;var r=Math.floor(t/32)+1,n=t-32*(r-1)+1;return this.newDate(e<=0?e-1:e,r,n)}});var o={20:"Fruitbat",21:"Anchovy"};n.calendars.discworld=a},{"../main":570,"object-assign":456}],559:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Ethiopian",jdEpoch:1724220.5,daysPerMonth:[30,30,30,30,30,30,30,30,30,30,30,30,5],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Ethiopian",epochs:["BEE","EE"],monthNames:["Meskerem","Tikemet","Hidar","Tahesas","Tir","Yekatit","Megabit","Miazia","Genbot","Sene","Hamle","Nehase","Pagume"],monthNamesShort:["Mes","Tik","Hid","Tah","Tir","Yek","Meg","Mia","Gen","Sen","Ham","Neh","Pag"],dayNames:["Ehud","Segno","Maksegno","Irob","Hamus","Arb","Kidame"],dayNamesShort:["Ehu","Seg","Mak","Iro","Ham","Arb","Kid"],dayNamesMin:["Eh","Se","Ma","Ir","Ha","Ar","Ki"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()+(e.year()<0?1:0))%4==3||t%4==-1},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear),13},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(13===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return(t=i.year())<0&&t++,i.day()+30*(i.month()-1)+365*(t-1)+Math.floor(t/4)+this.jdEpoch-1},fromJD:function(t){var e=Math.floor(t)+.5-this.jdEpoch,r=Math.floor((e-Math.floor((e+366)/1461))/365)+1;r<=0&&r--,e=Math.floor(t)+.5-this.newDate(r,1,1).toJD();var n=Math.floor(e/30)+1,i=e-30*(n-1)+1;return this.newDate(r,n,i)}}),n.calendars.ethiopian=a},{"../main":570,"object-assign":456}],560:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Hebrew",jdEpoch:347995.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29,29],hasYearZero:!1,minMonth:1,firstMonth:7,minDay:1,regionalOptions:{"":{name:"Hebrew",epochs:["BAM","AM"],monthNames:["Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Shevat","Adar","Adar II"],monthNamesShort:["Nis","Iya","Siv","Tam","Av","Elu","Tis","Che","Kis","Tev","She","Ada","Ad2"],dayNames:["Yom Rishon","Yom Sheni","Yom Shlishi","Yom Revi'i","Yom Chamishi","Yom Shishi","Yom Shabbat"],dayNamesShort:["Ris","She","Shl","Rev","Cha","Shi","Sha"],dayNamesMin:["Ri","She","Shl","Re","Ch","Shi","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return this._leapYear(e.year())},_leapYear:function(t){return o(7*(t=t<0?t+1:t)+1,19)<7},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),this._leapYear(t.year?t.year():t)?13:12},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),this.toJD(-1===t?1:t+1,7,1)-this.toJD(t,7,1)},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),12===e&&this.leapYear(t)?30:8===e&&5===o(this.daysInYear(t),10)?30:9===e&&3===o(this.daysInYear(t),10)?29:this.daysPerMonth[e-1]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return{yearType:(this.leapYear(i)?"embolismic":"common")+" "+["deficient","regular","complete"][this.daysInYear(i)%10-3]}},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t<=0?t+1:t,o=this.jdEpoch+this._delay1(a)+this._delay2(a)+r+1;if(e<7){for(var s=7;s<=this.monthsInYear(t);s++)o+=this.daysInMonth(t,s);for(s=1;s=this.toJD(-1===e?1:e+1,7,1);)e++;for(var r=tthis.toJD(e,r,this.daysInMonth(e,r));)r++;var n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.hebrew=a},{"../main":570,"object-assign":456}],561:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Islamic",jdEpoch:1948439.5,daysPerMonth:[30,29,30,29,30,29,30,29,30,29,30,29],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Islamic",epochs:["BH","AH"],monthNames:["Muharram","Safar","Rabi' al-awwal","Rabi' al-thani","Jumada al-awwal","Jumada al-thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-ahad","Yawm al-ithnayn","Yawm ath-thulaathaa'","Yawm al-arbi'aa'","Yawm al-khamīs","Yawm al-jum'a","Yawm as-sabt"],dayNamesShort:["Aha","Ith","Thu","Arb","Kha","Jum","Sab"],dayNamesMin:["Ah","It","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!1}},leapYear:function(t){return(11*this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year()+14)%30<11},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){return this.leapYear(t)?355:354},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),t=t<=0?t+1:t,(r=i.day())+Math.ceil(29.5*(e-1))+354*(t-1)+Math.floor((3+11*t)/30)+this.jdEpoch-1},fromJD:function(t){t=Math.floor(t)+.5;var e=Math.floor((30*(t-this.jdEpoch)+10646)/10631);e=e<=0?e-1:e;var r=Math.min(12,Math.ceil((t-29-this.toJD(e,1,1))/29.5)+1),n=t-this.toJD(e,r,1)+1;return this.newDate(e,r,n)}}),n.calendars.islamic=a},{"../main":570,"object-assign":456}],562:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Julian",jdEpoch:1721423.5,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Julian",epochs:["BC","AD"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"mm/dd/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return(t=e.year()<0?e.year()+1:e.year())%4==0},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(4-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=i.year(),e=i.month(),r=i.day(),t<0&&t++,e<=2&&(t--,e+=12),Math.floor(365.25*(t+4716))+Math.floor(30.6001*(e+1))+r-1524.5},fromJD:function(t){var e=Math.floor(t+.5)+1524,r=Math.floor((e-122.1)/365.25),n=Math.floor(365.25*r),i=Math.floor((e-n)/30.6001),a=i-Math.floor(i<14?1:13),o=r-Math.floor(a>2?4716:4715),s=e-n-Math.floor(30.6001*i);return o<=0&&o--,this.newDate(o,a,s)}}),n.calendars.julian=a},{"../main":570,"object-assign":456}],563:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}function o(t,e){return t-e*Math.floor(t/e)}function s(t,e){return o(t-1,e)+1}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Mayan",jdEpoch:584282.5,hasYearZero:!0,minMonth:0,firstMonth:0,minDay:0,regionalOptions:{"":{name:"Mayan",epochs:["",""],monthNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],monthNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],dayNames:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesShort:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],dayNamesMin:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"],digits:null,dateFormat:"YYYY.m.d",firstDay:0,isRTL:!1,haabMonths:["Pop","Uo","Zip","Zotz","Tzec","Xul","Yaxkin","Mol","Chen","Yax","Zac","Ceh","Mac","Kankin","Muan","Pax","Kayab","Cumku","Uayeb"],tzolkinMonths:["Imix","Ik","Akbal","Kan","Chicchan","Cimi","Manik","Lamat","Muluc","Oc","Chuen","Eb","Ben","Ix","Men","Cib","Caban","Etznab","Cauac","Ahau"]}},leapYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),!1},formatYear:function(t){t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year();var e=Math.floor(t/400);return t%=400,t+=t<0?400:0,e+"."+Math.floor(t/20)+"."+t%20},forYear:function(t){if((t=t.split(".")).length<3)throw"Invalid Mayan year";for(var e=0,r=0;r19||r>0&&n<0)throw"Invalid Mayan year";e=20*e+n}return e},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),18},weekOfYear:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),0},daysInYear:function(t){return this._validate(t,this.minMonth,this.minDay,n.local.invalidYear),360},daysInMonth:function(t,e){return this._validate(t,e,this.minDay,n.local.invalidMonth),20},daysInWeek:function(){return 5},dayOfWeek:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate).day()},weekDay:function(t,e,r){return this._validate(t,e,r,n.local.invalidDate),!0},extraInfo:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate).toJD(),a=this._toHaab(i),o=this._toTzolkin(i);return{haabMonthName:this.local.haabMonths[a[0]-1],haabMonth:a[0],haabDay:a[1],tzolkinDayName:this.local.tzolkinMonths[o[0]-1],tzolkinDay:o[0],tzolkinTrecena:o[1]}},_toHaab:function(t){var e=o(8+(t-=this.jdEpoch)+340,365);return[Math.floor(e/20)+1,o(e,20)]},_toTzolkin:function(t){return[s(20+(t-=this.jdEpoch),20),s(t+4,13)]},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return i.day()+20*i.month()+360*i.year()+this.jdEpoch},fromJD:function(t){t=Math.floor(t)+.5-this.jdEpoch;var e=Math.floor(t/360);t%=360,t+=t<0?360:0;var r=Math.floor(t/20),n=t%20;return this.newDate(e,r,n)}}),n.calendars.mayan=a},{"../main":570,"object-assign":456}],564:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar;var o=n.instance("gregorian");i(a.prototype,{name:"Nanakshahi",jdEpoch:2257673.5,daysPerMonth:[31,31,31,31,31,30,30,30,30,30,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Nanakshahi",epochs:["BN","AN"],monthNames:["Chet","Vaisakh","Jeth","Harh","Sawan","Bhadon","Assu","Katak","Maghar","Poh","Magh","Phagun"],monthNamesShort:["Che","Vai","Jet","Har","Saw","Bha","Ass","Kat","Mgr","Poh","Mgh","Pha"],dayNames:["Somvaar","Mangalvar","Budhvaar","Veervaar","Shukarvaar","Sanicharvaar","Etvaar"],dayNamesShort:["Som","Mangal","Budh","Veer","Shukar","Sanichar","Et"],dayNamesMin:["So","Ma","Bu","Ve","Sh","Sa","Et"],digits:null,dateFormat:"dd-mm-yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear||n.regionalOptions[""].invalidYear);return o.leapYear(e.year()+(e.year()<1?1:0)+1469)},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(1-(n.dayOfWeek()||7),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidMonth);(t=i.year())<0&&t++;for(var a=i.day(),s=1;s=this.toJD(e+1,1,1);)e++;for(var r=t-Math.floor(this.toJD(e,1,1)+.5)+1,n=1;r>this.daysInMonth(e,n);)r-=this.daysInMonth(e,n),n++;return this.newDate(e,n,r)}}),n.calendars.nanakshahi=a},{"../main":570,"object-assign":456}],565:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"Nepali",jdEpoch:1700709.5,daysPerMonth:[31,31,32,32,31,30,30,29,30,29,30,30],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,daysPerYear:365,regionalOptions:{"":{name:"Nepali",epochs:["BBS","ABS"],monthNames:["Baisakh","Jestha","Ashadh","Shrawan","Bhadra","Ashwin","Kartik","Mangsir","Paush","Mangh","Falgun","Chaitra"],monthNamesShort:["Bai","Je","As","Shra","Bha","Ash","Kar","Mang","Pau","Ma","Fal","Chai"],dayNames:["Aaitabaar","Sombaar","Manglbaar","Budhabaar","Bihibaar","Shukrabaar","Shanibaar"],dayNamesShort:["Aaita","Som","Mangl","Budha","Bihi","Shukra","Shani"],dayNamesMin:["Aai","So","Man","Bu","Bi","Shu","Sha"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:1,isRTL:!1}},leapYear:function(t){return this.daysInYear(t)!==this.daysPerYear},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){if(t=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear).year(),void 0===this.NEPALI_CALENDAR_DATA[t])return this.daysPerYear;for(var e=0,r=this.minMonth;r<=12;r++)e+=this.NEPALI_CALENDAR_DATA[t][r];return e},daysInMonth:function(t,e){return t.year&&(e=t.month(),t=t.year()),this._validate(t,e,this.minDay,n.local.invalidMonth),void 0===this.NEPALI_CALENDAR_DATA[t]?this.daysPerMonth[e-1]:this.NEPALI_CALENDAR_DATA[t][e]},weekDay:function(t,e,r){return 6!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=n.instance(),o=0,s=e,l=t;this._createMissingCalendarData(t);var c=t-(s>9||9===s&&r>=this.NEPALI_CALENDAR_DATA[l][0]?56:57);for(9!==e&&(o=r,s--);9!==s;)s<=0&&(s=12,l--),o+=this.NEPALI_CALENDAR_DATA[l][s],s--;return 9===e?(o+=r-this.NEPALI_CALENDAR_DATA[l][0])<0&&(o+=a.daysInYear(c)):o+=this.NEPALI_CALENDAR_DATA[l][9]-this.NEPALI_CALENDAR_DATA[l][0],a.newDate(c,1,1).add(o,"d").toJD()},fromJD:function(t){var e=n.instance().fromJD(t),r=e.year(),i=e.dayOfYear(),a=r+56;this._createMissingCalendarData(a);for(var o=9,s=this.NEPALI_CALENDAR_DATA[a][0],l=this.NEPALI_CALENDAR_DATA[a][o]-s+1;i>l;)++o>12&&(o=1,a++),l+=this.NEPALI_CALENDAR_DATA[a][o];var c=this.NEPALI_CALENDAR_DATA[a][o]-(l-i);return this.newDate(a,o,c)},_createMissingCalendarData:function(t){var e=this.daysPerMonth.slice(0);e.unshift(17);for(var r=t-1;r0?474:473))%2820+474+38)%2816<682},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-(n.dayOfWeek()+1)%7,"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(12===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);t=i.year(),e=i.month(),r=i.day();var a=t-(t>=0?474:473),s=474+o(a,2820);return r+(e<=7?31*(e-1):30*(e-1)+6)+Math.floor((682*s-110)/2816)+365*(s-1)+1029983*Math.floor(a/2820)+this.jdEpoch-1},fromJD:function(t){var e=(t=Math.floor(t)+.5)-this.toJD(475,1,1),r=Math.floor(e/1029983),n=o(e,1029983),i=2820;if(1029982!==n){var a=Math.floor(n/366),s=o(n,366);i=Math.floor((2134*a+2816*s+2815)/1028522)+a+1}var l=i+2820*r+474;l=l<=0?l-1:l;var c=t-this.toJD(l,1,1)+1,u=c<=186?Math.ceil(c/31):Math.ceil((c-6)/30),h=t-this.toJD(l,u,1)+1;return this.newDate(l,u,h)}}),n.calendars.persian=a,n.calendars.jalali=a},{"../main":570,"object-assign":456}],567:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Taiwan",jdEpoch:2419402.5,yearsOffset:1911,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Taiwan",epochs:["BROC","ROC"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:1,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return t=this._t2gYear(e.year()),a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return t=this._t2gYear(i.year()),a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=this._t2gYear(i.year()),a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)},_g2tYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)}}),n.calendars.taiwan=o},{"../main":570,"object-assign":456}],568:[function(t,e,r){var n=t("../main"),i=t("object-assign"),a=n.instance();function o(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}o.prototype=new n.baseCalendar,i(o.prototype,{name:"Thai",jdEpoch:1523098.5,yearsOffset:543,daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Thai",epochs:["BBE","BE"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],digits:null,dateFormat:"dd/mm/yyyy",firstDay:0,isRTL:!1}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return t=this._t2gYear(e.year()),a.leapYear(t)},weekOfYear:function(t,e,r){var i=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return t=this._t2gYear(i.year()),a.weekOfYear(t,i.month(),i.day())},daysInMonth:function(t,e){var r=this._validate(t,e,this.minDay,n.local.invalidMonth);return this.daysPerMonth[r.month()-1]+(2===r.month()&&this.leapYear(r.year())?1:0)},weekDay:function(t,e,r){return(this.dayOfWeek(t,e,r)||7)<6},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate);return t=this._t2gYear(i.year()),a.toJD(t,i.month(),i.day())},fromJD:function(t){var e=a.fromJD(t),r=this._g2tYear(e.year());return this.newDate(r,e.month(),e.day())},_t2gYear:function(t){return t-this.yearsOffset-(t>=1&&t<=this.yearsOffset?1:0)},_g2tYear:function(t){return t+this.yearsOffset+(t>=-this.yearsOffset&&t<=-1?1:0)}}),n.calendars.thai=o},{"../main":570,"object-assign":456}],569:[function(t,e,r){var n=t("../main"),i=t("object-assign");function a(t){this.local=this.regionalOptions[t||""]||this.regionalOptions[""]}a.prototype=new n.baseCalendar,i(a.prototype,{name:"UmmAlQura",hasYearZero:!1,minMonth:1,firstMonth:1,minDay:1,regionalOptions:{"":{name:"Umm al-Qura",epochs:["BH","AH"],monthNames:["Al-Muharram","Safar","Rabi' al-awwal","Rabi' Al-Thani","Jumada Al-Awwal","Jumada Al-Thani","Rajab","Sha'aban","Ramadan","Shawwal","Dhu al-Qi'dah","Dhu al-Hijjah"],monthNamesShort:["Muh","Saf","Rab1","Rab2","Jum1","Jum2","Raj","Sha'","Ram","Shaw","DhuQ","DhuH"],dayNames:["Yawm al-Ahad","Yawm al-Ithnain","Yawm al-Thalāthā’","Yawm al-Arba‘ā’","Yawm al-Khamīs","Yawm al-Jum‘a","Yawm al-Sabt"],dayNamesMin:["Ah","Ith","Th","Ar","Kh","Ju","Sa"],digits:null,dateFormat:"yyyy/mm/dd",firstDay:6,isRTL:!0}},leapYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,n.local.invalidYear);return 355===this.daysInYear(e.year())},weekOfYear:function(t,e,r){var n=this.newDate(t,e,r);return n.add(-n.dayOfWeek(),"d"),Math.floor((n.dayOfYear()-1)/7)+1},daysInYear:function(t){for(var e=0,r=1;r<=12;r++)e+=this.daysInMonth(t,r);return e},daysInMonth:function(t,e){for(var r=this._validate(t,e,this.minDay,n.local.invalidMonth).toJD()-24e5+.5,i=0,a=0;ar)return o[i]-o[i-1];i++}return 30},weekDay:function(t,e,r){return 5!==this.dayOfWeek(t,e,r)},toJD:function(t,e,r){var i=this._validate(t,e,r,n.local.invalidDate),a=12*(i.year()-1)+i.month()-15292;return i.day()+o[a-1]-1+24e5-.5},fromJD:function(t){for(var e=t-24e5+.5,r=0,n=0;ne);n++)r++;var i=r+15292,a=Math.floor((i-1)/12),s=a+1,l=i-12*a,c=e-o[r-1]+1;return this.newDate(s,l,c)},isValid:function(t,e,r){var i=n.baseCalendar.prototype.isValid.apply(this,arguments);return i&&(i=(t=null!=t.year?t.year:t)>=1276&&t<=1500),i},_validate:function(t,e,r,i){var a=n.baseCalendar.prototype._validate.apply(this,arguments);if(a.year<1276||a.year>1500)throw i.replace(/\{0\}/,this.local.name);return a}}),n.calendars.ummalqura=a;var o=[20,50,79,109,138,168,197,227,256,286,315,345,374,404,433,463,492,522,551,581,611,641,670,700,729,759,788,818,847,877,906,936,965,995,1024,1054,1083,1113,1142,1172,1201,1231,1260,1290,1320,1350,1379,1409,1438,1468,1497,1527,1556,1586,1615,1645,1674,1704,1733,1763,1792,1822,1851,1881,1910,1940,1969,1999,2028,2058,2087,2117,2146,2176,2205,2235,2264,2294,2323,2353,2383,2413,2442,2472,2501,2531,2560,2590,2619,2649,2678,2708,2737,2767,2796,2826,2855,2885,2914,2944,2973,3003,3032,3062,3091,3121,3150,3180,3209,3239,3268,3298,3327,3357,3386,3416,3446,3476,3505,3535,3564,3594,3623,3653,3682,3712,3741,3771,3800,3830,3859,3889,3918,3948,3977,4007,4036,4066,4095,4125,4155,4185,4214,4244,4273,4303,4332,4362,4391,4421,4450,4480,4509,4539,4568,4598,4627,4657,4686,4716,4745,4775,4804,4834,4863,4893,4922,4952,4981,5011,5040,5070,5099,5129,5158,5188,5218,5248,5277,5307,5336,5366,5395,5425,5454,5484,5513,5543,5572,5602,5631,5661,5690,5720,5749,5779,5808,5838,5867,5897,5926,5956,5985,6015,6044,6074,6103,6133,6162,6192,6221,6251,6281,6311,6340,6370,6399,6429,6458,6488,6517,6547,6576,6606,6635,6665,6694,6724,6753,6783,6812,6842,6871,6901,6930,6960,6989,7019,7048,7078,7107,7137,7166,7196,7225,7255,7284,7314,7344,7374,7403,7433,7462,7492,7521,7551,7580,7610,7639,7669,7698,7728,7757,7787,7816,7846,7875,7905,7934,7964,7993,8023,8053,8083,8112,8142,8171,8201,8230,8260,8289,8319,8348,8378,8407,8437,8466,8496,8525,8555,8584,8614,8643,8673,8702,8732,8761,8791,8821,8850,8880,8909,8938,8968,8997,9027,9056,9086,9115,9145,9175,9205,9234,9264,9293,9322,9352,9381,9410,9440,9470,9499,9529,9559,9589,9618,9648,9677,9706,9736,9765,9794,9824,9853,9883,9913,9943,9972,10002,10032,10061,10090,10120,10149,10178,10208,10237,10267,10297,10326,10356,10386,10415,10445,10474,10504,10533,10562,10592,10621,10651,10680,10710,10740,10770,10799,10829,10858,10888,10917,10947,10976,11005,11035,11064,11094,11124,11153,11183,11213,11242,11272,11301,11331,11360,11389,11419,11448,11478,11507,11537,11567,11596,11626,11655,11685,11715,11744,11774,11803,11832,11862,11891,11921,11950,11980,12010,12039,12069,12099,12128,12158,12187,12216,12246,12275,12304,12334,12364,12393,12423,12453,12483,12512,12542,12571,12600,12630,12659,12688,12718,12747,12777,12807,12837,12866,12896,12926,12955,12984,13014,13043,13072,13102,13131,13161,13191,13220,13250,13280,13310,13339,13368,13398,13427,13456,13486,13515,13545,13574,13604,13634,13664,13693,13723,13752,13782,13811,13840,13870,13899,13929,13958,13988,14018,14047,14077,14107,14136,14166,14195,14224,14254,14283,14313,14342,14372,14401,14431,14461,14490,14520,14550,14579,14609,14638,14667,14697,14726,14756,14785,14815,14844,14874,14904,14933,14963,14993,15021,15051,15081,15110,15140,15169,15199,15228,15258,15287,15317,15347,15377,15406,15436,15465,15494,15524,15553,15582,15612,15641,15671,15701,15731,15760,15790,15820,15849,15878,15908,15937,15966,15996,16025,16055,16085,16114,16144,16174,16204,16233,16262,16292,16321,16350,16380,16409,16439,16468,16498,16528,16558,16587,16617,16646,16676,16705,16734,16764,16793,16823,16852,16882,16912,16941,16971,17001,17030,17060,17089,17118,17148,17177,17207,17236,17266,17295,17325,17355,17384,17414,17444,17473,17502,17532,17561,17591,17620,17650,17679,17709,17738,17768,17798,17827,17857,17886,17916,17945,17975,18004,18034,18063,18093,18122,18152,18181,18211,18241,18270,18300,18330,18359,18388,18418,18447,18476,18506,18535,18565,18595,18625,18654,18684,18714,18743,18772,18802,18831,18860,18890,18919,18949,18979,19008,19038,19068,19098,19127,19156,19186,19215,19244,19274,19303,19333,19362,19392,19422,19452,19481,19511,19540,19570,19599,19628,19658,19687,19717,19746,19776,19806,19836,19865,19895,19924,19954,19983,20012,20042,20071,20101,20130,20160,20190,20219,20249,20279,20308,20338,20367,20396,20426,20455,20485,20514,20544,20573,20603,20633,20662,20692,20721,20751,20780,20810,20839,20869,20898,20928,20957,20987,21016,21046,21076,21105,21135,21164,21194,21223,21253,21282,21312,21341,21371,21400,21430,21459,21489,21519,21548,21578,21607,21637,21666,21696,21725,21754,21784,21813,21843,21873,21902,21932,21962,21991,22021,22050,22080,22109,22138,22168,22197,22227,22256,22286,22316,22346,22375,22405,22434,22464,22493,22522,22552,22581,22611,22640,22670,22700,22730,22759,22789,22818,22848,22877,22906,22936,22965,22994,23024,23054,23083,23113,23143,23173,23202,23232,23261,23290,23320,23349,23379,23408,23438,23467,23497,23527,23556,23586,23616,23645,23674,23704,23733,23763,23792,23822,23851,23881,23910,23940,23970,23999,24029,24058,24088,24117,24147,24176,24206,24235,24265,24294,24324,24353,24383,24413,24442,24472,24501,24531,24560,24590,24619,24648,24678,24707,24737,24767,24796,24826,24856,24885,24915,24944,24974,25003,25032,25062,25091,25121,25150,25180,25210,25240,25269,25299,25328,25358,25387,25416,25446,25475,25505,25534,25564,25594,25624,25653,25683,25712,25742,25771,25800,25830,25859,25888,25918,25948,25977,26007,26037,26067,26096,26126,26155,26184,26214,26243,26272,26302,26332,26361,26391,26421,26451,26480,26510,26539,26568,26598,26627,26656,26686,26715,26745,26775,26805,26834,26864,26893,26923,26952,26982,27011,27041,27070,27099,27129,27159,27188,27218,27248,27277,27307,27336,27366,27395,27425,27454,27484,27513,27542,27572,27602,27631,27661,27691,27720,27750,27779,27809,27838,27868,27897,27926,27956,27985,28015,28045,28074,28104,28134,28163,28193,28222,28252,28281,28310,28340,28369,28399,28428,28458,28488,28517,28547,28577,28607,28636,28665,28695,28724,28754,28783,28813,28843,28872,28901,28931,28960,28990,29019,29049,29078,29108,29137,29167,29196,29226,29255,29285,29315,29345,29375,29404,29434,29463,29492,29522,29551,29580,29610,29640,29669,29699,29729,29759,29788,29818,29847,29876,29906,29935,29964,29994,30023,30053,30082,30112,30141,30171,30200,30230,30259,30289,30318,30348,30378,30408,30437,30467,30496,30526,30555,30585,30614,30644,30673,30703,30732,30762,30791,30821,30850,30880,30909,30939,30968,30998,31027,31057,31086,31116,31145,31175,31204,31234,31263,31293,31322,31352,31381,31411,31441,31471,31500,31530,31559,31589,31618,31648,31676,31706,31736,31766,31795,31825,31854,31884,31913,31943,31972,32002,32031,32061,32090,32120,32150,32180,32209,32239,32268,32298,32327,32357,32386,32416,32445,32475,32504,32534,32563,32593,32622,32652,32681,32711,32740,32770,32799,32829,32858,32888,32917,32947,32976,33006,33035,33065,33094,33124,33153,33183,33213,33243,33272,33302,33331,33361,33390,33420,33450,33479,33509,33539,33568,33598,33627,33657,33686,33716,33745,33775,33804,33834,33863,33893,33922,33952,33981,34011,34040,34069,34099,34128,34158,34187,34217,34247,34277,34306,34336,34365,34395,34424,34454,34483,34512,34542,34571,34601,34631,34660,34690,34719,34749,34778,34808,34837,34867,34896,34926,34955,34985,35015,35044,35074,35103,35133,35162,35192,35222,35251,35280,35310,35340,35370,35399,35429,35458,35488,35517,35547,35576,35605,35635,35665,35694,35723,35753,35782,35811,35841,35871,35901,35930,35960,35989,36019,36048,36078,36107,36136,36166,36195,36225,36254,36284,36314,36343,36373,36403,36433,36462,36492,36521,36551,36580,36610,36639,36669,36698,36728,36757,36786,36816,36845,36875,36904,36934,36963,36993,37022,37052,37081,37111,37141,37170,37200,37229,37259,37288,37318,37347,37377,37406,37436,37465,37495,37524,37554,37584,37613,37643,37672,37701,37731,37760,37790,37819,37849,37878,37908,37938,37967,37997,38027,38056,38085,38115,38144,38174,38203,38233,38262,38292,38322,38351,38381,38410,38440,38469,38499,38528,38558,38587,38617,38646,38676,38705,38735,38764,38794,38823,38853,38882,38912,38941,38971,39001,39030,39059,39089,39118,39148,39178,39208,39237,39267,39297,39326,39355,39385,39414,39444,39473,39503,39532,39562,39592,39621,39650,39680,39709,39739,39768,39798,39827,39857,39886,39916,39946,39975,40005,40035,40064,40094,40123,40153,40182,40212,40241,40271,40300,40330,40359,40389,40418,40448,40477,40507,40536,40566,40595,40625,40655,40685,40714,40744,40773,40803,40832,40862,40892,40921,40951,40980,41009,41039,41068,41098,41127,41157,41186,41216,41245,41275,41304,41334,41364,41393,41422,41452,41481,41511,41540,41570,41599,41629,41658,41688,41718,41748,41777,41807,41836,41865,41894,41924,41953,41983,42012,42042,42072,42102,42131,42161,42190,42220,42249,42279,42308,42337,42367,42397,42426,42456,42485,42515,42545,42574,42604,42633,42662,42692,42721,42751,42780,42810,42839,42869,42899,42929,42958,42988,43017,43046,43076,43105,43135,43164,43194,43223,43253,43283,43312,43342,43371,43401,43430,43460,43489,43519,43548,43578,43607,43637,43666,43696,43726,43755,43785,43814,43844,43873,43903,43932,43962,43991,44021,44050,44080,44109,44139,44169,44198,44228,44258,44287,44317,44346,44375,44405,44434,44464,44493,44523,44553,44582,44612,44641,44671,44700,44730,44759,44788,44818,44847,44877,44906,44936,44966,44996,45025,45055,45084,45114,45143,45172,45202,45231,45261,45290,45320,45350,45380,45409,45439,45468,45498,45527,45556,45586,45615,45644,45674,45704,45733,45763,45793,45823,45852,45882,45911,45940,45970,45999,46028,46058,46088,46117,46147,46177,46206,46236,46265,46295,46324,46354,46383,46413,46442,46472,46501,46531,46560,46590,46620,46649,46679,46708,46738,46767,46797,46826,46856,46885,46915,46944,46974,47003,47033,47063,47092,47122,47151,47181,47210,47240,47269,47298,47328,47357,47387,47417,47446,47476,47506,47535,47565,47594,47624,47653,47682,47712,47741,47771,47800,47830,47860,47890,47919,47949,47978,48008,48037,48066,48096,48125,48155,48184,48214,48244,48273,48303,48333,48362,48392,48421,48450,48480,48509,48538,48568,48598,48627,48657,48687,48717,48746,48776,48805,48834,48864,48893,48922,48952,48982,49011,49041,49071,49100,49130,49160,49189,49218,49248,49277,49306,49336,49365,49395,49425,49455,49484,49514,49543,49573,49602,49632,49661,49690,49720,49749,49779,49809,49838,49868,49898,49927,49957,49986,50016,50045,50075,50104,50133,50163,50192,50222,50252,50281,50311,50340,50370,50400,50429,50459,50488,50518,50547,50576,50606,50635,50665,50694,50724,50754,50784,50813,50843,50872,50902,50931,50960,50990,51019,51049,51078,51108,51138,51167,51197,51227,51256,51286,51315,51345,51374,51403,51433,51462,51492,51522,51552,51582,51611,51641,51670,51699,51729,51758,51787,51816,51846,51876,51906,51936,51965,51995,52025,52054,52083,52113,52142,52171,52200,52230,52260,52290,52319,52349,52379,52408,52438,52467,52497,52526,52555,52585,52614,52644,52673,52703,52733,52762,52792,52822,52851,52881,52910,52939,52969,52998,53028,53057,53087,53116,53146,53176,53205,53235,53264,53294,53324,53353,53383,53412,53441,53471,53500,53530,53559,53589,53619,53648,53678,53708,53737,53767,53796,53825,53855,53884,53913,53943,53973,54003,54032,54062,54092,54121,54151,54180,54209,54239,54268,54297,54327,54357,54387,54416,54446,54476,54505,54535,54564,54593,54623,54652,54681,54711,54741,54770,54800,54830,54859,54889,54919,54948,54977,55007,55036,55066,55095,55125,55154,55184,55213,55243,55273,55302,55332,55361,55391,55420,55450,55479,55508,55538,55567,55597,55627,55657,55686,55716,55745,55775,55804,55834,55863,55892,55922,55951,55981,56011,56040,56070,56100,56129,56159,56188,56218,56247,56276,56306,56335,56365,56394,56424,56454,56483,56513,56543,56572,56601,56631,56660,56690,56719,56749,56778,56808,56837,56867,56897,56926,56956,56985,57015,57044,57074,57103,57133,57162,57192,57221,57251,57280,57310,57340,57369,57399,57429,57458,57487,57517,57546,57576,57605,57634,57664,57694,57723,57753,57783,57813,57842,57871,57901,57930,57959,57989,58018,58048,58077,58107,58137,58167,58196,58226,58255,58285,58314,58343,58373,58402,58432,58461,58491,58521,58551,58580,58610,58639,58669,58698,58727,58757,58786,58816,58845,58875,58905,58934,58964,58994,59023,59053,59082,59111,59141,59170,59200,59229,59259,59288,59318,59348,59377,59407,59436,59466,59495,59525,59554,59584,59613,59643,59672,59702,59731,59761,59791,59820,59850,59879,59909,59939,59968,59997,60027,60056,60086,60115,60145,60174,60204,60234,60264,60293,60323,60352,60381,60411,60440,60469,60499,60528,60558,60588,60618,60648,60677,60707,60736,60765,60795,60824,60853,60883,60912,60942,60972,61002,61031,61061,61090,61120,61149,61179,61208,61237,61267,61296,61326,61356,61385,61415,61445,61474,61504,61533,61563,61592,61621,61651,61680,61710,61739,61769,61799,61828,61858,61888,61917,61947,61976,62006,62035,62064,62094,62123,62153,62182,62212,62242,62271,62301,62331,62360,62390,62419,62448,62478,62507,62537,62566,62596,62625,62655,62685,62715,62744,62774,62803,62832,62862,62891,62921,62950,62980,63009,63039,63069,63099,63128,63157,63187,63216,63246,63275,63305,63334,63363,63393,63423,63453,63482,63512,63541,63571,63600,63630,63659,63689,63718,63747,63777,63807,63836,63866,63895,63925,63955,63984,64014,64043,64073,64102,64131,64161,64190,64220,64249,64279,64309,64339,64368,64398,64427,64457,64486,64515,64545,64574,64603,64633,64663,64692,64722,64752,64782,64811,64841,64870,64899,64929,64958,64987,65017,65047,65076,65106,65136,65166,65195,65225,65254,65283,65313,65342,65371,65401,65431,65460,65490,65520,65549,65579,65608,65638,65667,65697,65726,65755,65785,65815,65844,65874,65903,65933,65963,65992,66022,66051,66081,66110,66140,66169,66199,66228,66258,66287,66317,66346,66376,66405,66435,66465,66494,66524,66553,66583,66612,66641,66671,66700,66730,66760,66789,66819,66849,66878,66908,66937,66967,66996,67025,67055,67084,67114,67143,67173,67203,67233,67262,67292,67321,67351,67380,67409,67439,67468,67497,67527,67557,67587,67617,67646,67676,67705,67735,67764,67793,67823,67852,67882,67911,67941,67971,68e3,68030,68060,68089,68119,68148,68177,68207,68236,68266,68295,68325,68354,68384,68414,68443,68473,68502,68532,68561,68591,68620,68650,68679,68708,68738,68768,68797,68827,68857,68886,68916,68946,68975,69004,69034,69063,69092,69122,69152,69181,69211,69240,69270,69300,69330,69359,69388,69418,69447,69476,69506,69535,69565,69595,69624,69654,69684,69713,69743,69772,69802,69831,69861,69890,69919,69949,69978,70008,70038,70067,70097,70126,70156,70186,70215,70245,70274,70303,70333,70362,70392,70421,70451,70481,70510,70540,70570,70599,70629,70658,70687,70717,70746,70776,70805,70835,70864,70894,70924,70954,70983,71013,71042,71071,71101,71130,71159,71189,71218,71248,71278,71308,71337,71367,71397,71426,71455,71485,71514,71543,71573,71602,71632,71662,71691,71721,71751,71781,71810,71839,71869,71898,71927,71957,71986,72016,72046,72075,72105,72135,72164,72194,72223,72253,72282,72311,72341,72370,72400,72429,72459,72489,72518,72548,72577,72607,72637,72666,72695,72725,72754,72784,72813,72843,72872,72902,72931,72961,72991,73020,73050,73080,73109,73139,73168,73197,73227,73256,73286,73315,73345,73375,73404,73434,73464,73493,73523,73552,73581,73611,73640,73669,73699,73729,73758,73788,73818,73848,73877,73907,73936,73965,73995,74024,74053,74083,74113,74142,74172,74202,74231,74261,74291,74320,74349,74379,74408,74437,74467,74497,74526,74556,74586,74615,74645,74675,74704,74733,74763,74792,74822,74851,74881,74910,74940,74969,74999,75029,75058,75088,75117,75147,75176,75206,75235,75264,75294,75323,75353,75383,75412,75442,75472,75501,75531,75560,75590,75619,75648,75678,75707,75737,75766,75796,75826,75856,75885,75915,75944,75974,76003,76032,76062,76091,76121,76150,76180,76210,76239,76269,76299,76328,76358,76387,76416,76446,76475,76505,76534,76564,76593,76623,76653,76682,76712,76741,76771,76801,76830,76859,76889,76918,76948,76977,77007,77036,77066,77096,77125,77155,77185,77214,77243,77273,77302,77332,77361,77390,77420,77450,77479,77509,77539,77569,77598,77627,77657,77686,77715,77745,77774,77804,77833,77863,77893,77923,77952,77982,78011,78041,78070,78099,78129,78158,78188,78217,78247,78277,78307,78336,78366,78395,78425,78454,78483,78513,78542,78572,78601,78631,78661,78690,78720,78750,78779,78808,78838,78867,78897,78926,78956,78985,79015,79044,79074,79104,79133,79163,79192,79222,79251,79281,79310,79340,79369,79399,79428,79458,79487,79517,79546,79576,79606,79635,79665,79695,79724,79753,79783,79812,79841,79871,79900,79930,79960,79990]},{"../main":570,"object-assign":456}],570:[function(t,e,r){var n=t("object-assign");function i(){this.regionalOptions=[],this.regionalOptions[""]={invalidCalendar:"Calendar {0} not found",invalidDate:"Invalid {0} date",invalidMonth:"Invalid {0} month",invalidYear:"Invalid {0} year",differentCalendars:"Cannot mix {0} and {1} dates"},this.local=this.regionalOptions[""],this.calendars={},this._localCals={}}function a(t,e,r,n){if(this._calendar=t,this._year=e,this._month=r,this._day=n,0===this._calendar._validateLevel&&!this._calendar.isValid(this._year,this._month,this._day))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name)}function o(t,e){return"000000".substring(0,e-(t=""+t).length)+t}function s(){this.shortYearCutoff="+10"}function l(t){this.local=this.regionalOptions[t]||this.regionalOptions[""]}n(i.prototype,{instance:function(t,e){t=(t||"gregorian").toLowerCase(),e=e||"";var r=this._localCals[t+"-"+e];if(!r&&this.calendars[t]&&(r=new this.calendars[t](e),this._localCals[t+"-"+e]=r),!r)throw(this.local.invalidCalendar||this.regionalOptions[""].invalidCalendar).replace(/\{0\}/,t);return r},newDate:function(t,e,r,n,i){return(n=(null!=t&&t.year?t.calendar():"string"==typeof n?this.instance(n,i):n)||this.instance()).newDate(t,e,r)},substituteDigits:function(t){return function(e){return(e+"").replace(/[0-9]/g,(function(e){return t[e]}))}},substituteChineseDigits:function(t,e){return function(r){for(var n="",i=0;r>0;){var a=r%10;n=(0===a?"":t[a]+e[i])+n,i++,r=Math.floor(r/10)}return 0===n.indexOf(t[1]+e[1])&&(n=n.substr(1)),n||t[0]}}}),n(a.prototype,{newDate:function(t,e,r){return this._calendar.newDate(null==t?this:t,e,r)},year:function(t){return 0===arguments.length?this._year:this.set(t,"y")},month:function(t){return 0===arguments.length?this._month:this.set(t,"m")},day:function(t){return 0===arguments.length?this._day:this.set(t,"d")},date:function(t,e,r){if(!this._calendar.isValid(t,e,r))throw(c.local.invalidDate||c.regionalOptions[""].invalidDate).replace(/\{0\}/,this._calendar.local.name);return this._year=t,this._month=e,this._day=r,this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(t,e){return this._calendar.add(this,t,e)},set:function(t,e){return this._calendar.set(this,t,e)},compareTo:function(t){if(this._calendar.name!==t._calendar.name)throw(c.local.differentCalendars||c.regionalOptions[""].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,t._calendar.local.name);var e=this._year!==t._year?this._year-t._year:this._month!==t._month?this.monthOfYear()-t.monthOfYear():this._day-t._day;return 0===e?0:e<0?-1:1},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(t){return this._calendar.fromJD(t)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(t){return this._calendar.fromJSDate(t)},toString:function(){return(this.year()<0?"-":"")+o(Math.abs(this.year()),4)+"-"+o(this.month(),2)+"-"+o(this.day(),2)}}),n(s.prototype,{_validateLevel:0,newDate:function(t,e,r){return null==t?this.today():(t.year&&(this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),r=t.day(),e=t.month(),t=t.year()),new a(this,t,e,r))},today:function(){return this.fromJSDate(new Date)},epoch:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear).year()<0?this.local.epochs[0]:this.local.epochs[1]},formatYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return(e.year()<0?"-":"")+o(Math.abs(e.year()),4)},monthsInYear:function(t){return this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear),12},monthOfYear:function(t,e){var r=this._validate(t,e,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth);return(r.month()+this.monthsInYear(r)-this.firstMonth)%this.monthsInYear(r)+this.minMonth},fromMonthOfYear:function(t,e){var r=(e+this.firstMonth-2*this.minMonth)%this.monthsInYear(t)+this.minMonth;return this._validate(t,r,this.minDay,c.local.invalidMonth||c.regionalOptions[""].invalidMonth),r},daysInYear:function(t){var e=this._validate(t,this.minMonth,this.minDay,c.local.invalidYear||c.regionalOptions[""].invalidYear);return this.leapYear(e)?366:365},dayOfYear:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return n.toJD()-this.newDate(n.year(),this.fromMonthOfYear(n.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate);return(Math.floor(this.toJD(n))+2)%this.daysInWeek()},extraInfo:function(t,e,r){return this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),{}},add:function(t,e,r){return this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate),this._correctAdd(t,this._add(t,e,r),e,r)},_add:function(t,e,r){if(this._validateLevel++,"d"===r||"w"===r){var n=t.toJD()+e*("w"===r?this.daysInWeek():1),i=t.calendar().fromJD(n);return this._validateLevel--,[i.year(),i.month(),i.day()]}try{var a=t.year()+("y"===r?e:0),o=t.monthOfYear()+("m"===r?e:0);i=t.day(),"y"===r?(t.month()!==this.fromMonthOfYear(a,o)&&(o=this.newDate(a,t.month(),this.minDay).monthOfYear()),o=Math.min(o,this.monthsInYear(a)),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o)))):"m"===r&&(function(t){for(;oe-1+t.minMonth;)a++,o-=e,e=t.monthsInYear(a)}(this),i=Math.min(i,this.daysInMonth(a,this.fromMonthOfYear(a,o))));var s=[a,this.fromMonthOfYear(a,o),i];return this._validateLevel--,s}catch(t){throw this._validateLevel--,t}},_correctAdd:function(t,e,r,n){if(!(this.hasYearZero||"y"!==n&&"m"!==n||0!==e[0]&&t.year()>0==e[0]>0)){var i={y:[1,1,"y"],m:[1,this.monthsInYear(-1),"m"],w:[this.daysInWeek(),this.daysInYear(-1),"d"],d:[1,this.daysInYear(-1),"d"]}[n],a=r<0?-1:1;e=this._add(t,r*i[0]+a*i[1],i[2])}return t.date(e[0],e[1],e[2])},set:function(t,e,r){this._validate(t,this.minMonth,this.minDay,c.local.invalidDate||c.regionalOptions[""].invalidDate);var n="y"===r?e:t.year(),i="m"===r?e:t.month(),a="d"===r?e:t.day();return"y"!==r&&"m"!==r||(a=Math.min(a,this.daysInMonth(n,i))),t.date(n,i,a)},isValid:function(t,e,r){this._validateLevel++;var n=this.hasYearZero||0!==t;if(n){var i=this.newDate(t,e,this.minDay);n=e>=this.minMonth&&e-this.minMonth=this.minDay&&r-this.minDay13.5?13:1),c=i-(l>2.5?4716:4715);return c<=0&&c--,this.newDate(c,l,s)},toJSDate:function(t,e,r){var n=this._validate(t,e,r,c.local.invalidDate||c.regionalOptions[""].invalidDate),i=new Date(n.year(),n.month()-1,n.day());return i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),i.setHours(i.getHours()>12?i.getHours()+2:0),i},fromJSDate:function(t){return this.newDate(t.getFullYear(),t.getMonth()+1,t.getDate())}});var c=e.exports=new i;c.cdate=a,c.baseCalendar=s,c.calendars.gregorian=l},{"object-assign":456}],571:[function(t,e,r){var n=t("object-assign"),i=t("./main");n(i.regionalOptions[""],{invalidArguments:"Invalid arguments",invalidFormat:"Cannot format a date from another calendar",missingNumberAt:"Missing number at position {0}",unknownNameAt:"Unknown name at position {0}",unexpectedLiteralAt:"Unexpected literal at position {0}",unexpectedText:"Additional text found at end"}),i.local=i.regionalOptions[""],n(i.cdate.prototype,{formatDate:function(t,e){return"string"!=typeof t&&(e=t,t=""),this._calendar.formatDate(t||"",this,e)}}),n(i.baseCalendar.prototype,{UNIX_EPOCH:i.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:86400,TICKS_EPOCH:i.instance().jdEpoch,TICKS_PER_DAY:864e9,ATOM:"yyyy-mm-dd",COOKIE:"D, dd M yyyy",FULL:"DD, MM d, yyyy",ISO_8601:"yyyy-mm-dd",JULIAN:"J",RFC_822:"D, d M yy",RFC_850:"DD, dd-M-yy",RFC_1036:"D, d M yy",RFC_1123:"D, d M yyyy",RFC_2822:"D, d M yyyy",RSS:"D, d M yy",TICKS:"!",TIMESTAMP:"@",W3C:"yyyy-mm-dd",formatDate:function(t,e,r){if("string"!=typeof t&&(r=e,e=t,t=""),!e)return"";if(e.calendar()!==this)throw i.local.invalidFormat||i.regionalOptions[""].invalidFormat;t=t||this.local.dateFormat;for(var n,a,o,s,l=(r=r||{}).dayNamesShort||this.local.dayNamesShort,c=r.dayNames||this.local.dayNames,u=r.monthNumbers||this.local.monthNumbers,h=r.monthNamesShort||this.local.monthNamesShort,f=r.monthNames||this.local.monthNames,p=(r.calculateWeek||this.local.calculateWeek,function(e,r){for(var n=1;w+n1}),d=function(t,e,r,n){var i=""+e;if(p(t,n))for(;i.length1},x=function(t,r){var n=y(t,r),a=[2,3,n?4:2,n?4:2,10,11,20]["oyYJ@!".indexOf(t)+1],o=new RegExp("^-?\\d{1,"+a+"}"),s=e.substring(M).match(o);if(!s)throw(i.local.missingNumberAt||i.regionalOptions[""].missingNumberAt).replace(/\{0\}/,M);return M+=s[0].length,parseInt(s[0],10)},b=this,_=function(){if("function"==typeof l){y("m");var t=l.call(b,e.substring(M));return M+=t.length,t}return x("m")},w=function(t,r,n,a){for(var o=y(t,a)?n:r,s=0;s-1){p=1,d=g;for(var T=this.daysInMonth(f,p);d>T;T=this.daysInMonth(f,p))p++,d-=T}return h>-1?this.fromJD(h):this.newDate(f,p,d)},determineDate:function(t,e,r,n,i){r&&"object"!=typeof r&&(i=n,n=r,r=null),"string"!=typeof n&&(i=n,n="");var a=this;return e=e?e.newDate():null,t=null==t?e:"string"==typeof t?function(t){try{return a.parseDate(n,t,i)}catch(t){}for(var e=((t=t.toLowerCase()).match(/^c/)&&r?r.newDate():null)||a.today(),o=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,s=o.exec(t);s;)e.add(parseInt(s[1],10),s[2]||"d"),s=o.exec(t);return e}(t):"number"==typeof t?isNaN(t)||t===1/0||t===-1/0?e:a.today().add(t,"d"):a.newDate(t)}})},{"./main":570,"object-assign":456}],572:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":148}],573:[function(t,e,r){"use strict";e.exports=function(t,e){var r=[];return e=+e||0,n(t.hi(t.shape[0]-1),r,e),r};var n=t("./lib/zc-core")},{"./lib/zc-core":572}],574:[function(t,e,r){"use strict";e.exports=[{path:"",backoff:0},{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0,noRotate:!0},{path:"M2,2V-2H-2V2Z",backoff:0,noRotate:!0}]},{}],575:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../plot_api/plot_template").templatedArray;e.exports=o("annotation",{visible:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},text:{valType:"string",editType:"calc+arraydraw"},textangle:{valType:"angle",dflt:0,editType:"calc+arraydraw"},font:i({editType:"calc+arraydraw",colorEditType:"arraydraw"}),width:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},height:{valType:"number",min:1,dflt:null,editType:"calc+arraydraw"},opacity:{valType:"number",min:0,max:1,dflt:1,editType:"arraydraw"},align:{valType:"enumerated",values:["left","center","right"],dflt:"center",editType:"arraydraw"},valign:{valType:"enumerated",values:["top","middle","bottom"],dflt:"middle",editType:"arraydraw"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"arraydraw"},borderpad:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},borderwidth:{valType:"number",min:0,dflt:1,editType:"calc+arraydraw"},showarrow:{valType:"boolean",dflt:!0,editType:"calc+arraydraw"},arrowcolor:{valType:"color",editType:"arraydraw"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},startarrowhead:{valType:"integer",min:0,max:n.length,dflt:1,editType:"arraydraw"},arrowside:{valType:"flaglist",flags:["end","start"],extras:["none"],dflt:"end",editType:"arraydraw"},arrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},startarrowsize:{valType:"number",min:.3,dflt:1,editType:"calc+arraydraw"},arrowwidth:{valType:"number",min:.1,editType:"calc+arraydraw"},standoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},startstandoff:{valType:"number",min:0,dflt:0,editType:"calc+arraydraw"},ax:{valType:"any",editType:"calc+arraydraw"},ay:{valType:"any",editType:"calc+arraydraw"},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()],editType:"calc"},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()],editType:"calc"},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()],editType:"calc"},x:{valType:"any",editType:"calc+arraydraw"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto",editType:"calc+arraydraw"},xshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()],editType:"calc"},y:{valType:"any",editType:"calc+arraydraw"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto",editType:"calc+arraydraw"},yshift:{valType:"number",dflt:0,editType:"calc+arraydraw"},clicktoshow:{valType:"enumerated",values:[!1,"onoff","onout"],dflt:!1,editType:"arraydraw"},xclick:{valType:"any",editType:"arraydraw"},yclick:{valType:"any",editType:"arraydraw"},hovertext:{valType:"string",editType:"arraydraw"},hoverlabel:{bgcolor:{valType:"color",editType:"arraydraw"},bordercolor:{valType:"color",editType:"arraydraw"},font:i({editType:"arraydraw"}),editType:"arraydraw"},captureevents:{valType:"boolean",editType:"arraydraw"},editType:"calc",_deprecated:{ref:{valType:"string",editType:"calc"}}})},{"../../plot_api/plot_template":755,"../../plots/cartesian/constants":771,"../../plots/font_attributes":791,"./arrow_paths":574}],576:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("./draw").draw;function o(t){var e=t._fullLayout;n.filterVisible(e.annotations).forEach((function(e){var r=i.getFromId(t,e.xref),n=i.getFromId(t,e.yref);e._extremes={},r&&s(e,r),n&&s(e,n)}))}function s(t,e){var r,n=e._id,a=n.charAt(0),o=t[a],s=t["a"+a],l=t[a+"ref"],c=t["a"+a+"ref"],u=t["_"+a+"padplus"],h=t["_"+a+"padminus"],f={x:1,y:-1}[a]*t[a+"shift"],p=3*t.arrowsize*t.arrowwidth||0,d=p+f,g=p-f,m=3*t.startarrowsize*t.arrowwidth||0,v=m+f,y=m-f;if(c===l){var x=i.findExtremes(e,[e.r2c(o)],{ppadplus:d,ppadminus:g}),b=i.findExtremes(e,[e.r2c(s)],{ppadplus:Math.max(u,v),ppadminus:Math.max(h,y)});r={min:[x.min[0],b.min[0]],max:[x.max[0],b.max[0]]}}else v=s?v+s:v,y=s?y-s:y,r=i.findExtremes(e,[e.r2c(o)],{ppadplus:Math.max(u,d,v),ppadminus:Math.max(h,g,y)});t._extremes[n]=r}e.exports=function(t){var e=t._fullLayout;if(n.filterVisible(e.annotations).length&&t._fullData.length)return n.syncOrAsync([a,o],t)}},{"../../lib":717,"../../plots/cartesian/axes":765,"./draw":581}],577:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("../../plot_api/plot_template").arrayEditor;function o(t,e){var r,n,i,a,o,l,c,u=t._fullLayout.annotations,h=[],f=[],p=[],d=(e||[]).length;for(r=0;r0||r.explicitOff.length>0},onClick:function(t,e){var r,s,l=o(t,e),c=l.on,u=l.off.concat(l.explicitOff),h={},f=t._fullLayout.annotations;if(c.length||u.length){for(r=0;r2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}for(var H=!1,G=["x","y"],q=0;q1)&&(tt===$?((ct=et.r2fraction(e["a"+Q]))<0||ct>1)&&(H=!0):H=!0),W=et._offset+et.r2p(e[Q]),J=.5}else"x"===Q?(X=e[Q],W=b.l+b.w*X):(X=1-e[Q],W=b.t+b.h*X),J=e.showarrow?.5:X;if(e.showarrow){lt.head=W;var ut=e["a"+Q];K=nt*Y(.5,e.xanchor)-it*Y(.5,e.yanchor),tt===$?(lt.tail=et._offset+et.r2p(ut),Z=K):(lt.tail=W+ut,Z=K+ut),lt.text=lt.tail+K;var ht=x["x"===Q?"width":"height"];if("paper"===$&&(lt.head=o.constrain(lt.head,1,ht-1)),"pixel"===tt){var ft=-Math.max(lt.tail-3,lt.text),pt=Math.min(lt.tail+3,lt.text)-ht;ft>0?(lt.tail+=ft,lt.text+=ft):pt>0&&(lt.tail-=pt,lt.text-=pt)}lt.tail+=st,lt.head+=st}else Z=K=at*Y(J,ot),lt.text=W+K;lt.text+=st,K+=st,Z+=st,e["_"+Q+"padplus"]=at/2+Z,e["_"+Q+"padminus"]=at/2-Z,e["_"+Q+"size"]=at,e["_"+Q+"shift"]=K}if(H)P.remove();else{var dt=0,gt=0;if("left"!==e.align&&(dt=(w-v)*("center"===e.align?.5:1)),"top"!==e.valign&&(gt=(D-y)*("middle"===e.valign?.5:1)),u)n.select("svg").attr({x:R+dt-1,y:R+gt}).call(c.setClipUrl,N?k:null,t);else{var mt=R+gt-d.top,vt=R+dt-d.left;V.call(h.positionText,vt,mt).call(c.setClipUrl,N?k:null,t)}j.select("rect").call(c.setRect,R,R,w,D),F.call(c.setRect,O/2,O/2,z-O,B-O),P.call(c.setTranslate,Math.round(I.x.text-z/2),Math.round(I.y.text-B/2)),S.attr({transform:"rotate("+T+","+I.x.text+","+I.y.text+")"});var yt,xt=function(r,n){L.selectAll(".annotation-arrow-g").remove();var u=I.x.head,h=I.y.head,f=I.x.tail+r,d=I.y.tail+n,v=I.x.text+r,y=I.y.text+n,x=o.rotationXYMatrix(T,v,y),w=o.apply2DTransform(x),k=o.apply2DTransform2(x),E=+F.attr("width"),D=+F.attr("height"),O=v-.5*E,z=O+E,R=y-.5*D,N=R+D,j=[[O,R,O,N],[O,N,z,N],[z,N,z,R],[z,R,O,R]].map(k);if(!j.reduce((function(t,e){return t^!!o.segmentsIntersect(u,h,u+1e6,h+1e6,e[0],e[1],e[2],e[3])}),!1)){j.forEach((function(t){var e=o.segmentsIntersect(f,d,u,h,t[0],t[1],t[2],t[3]);e&&(f=e.x,d=e.y)}));var B=e.arrowwidth,Y=e.arrowcolor,V=e.arrowside,U=L.append("g").style({opacity:l.opacity(Y)}).classed("annotation-arrow-g",!0),H=U.append("path").attr("d","M"+f+","+d+"L"+u+","+h).style("stroke-width",B+"px").call(l.stroke,l.rgb(Y));if(g(H,V,e),_.annotationPosition&&H.node().parentNode&&!a){var G=u,q=h;if(e.standoff){var W=Math.sqrt(Math.pow(u-f,2)+Math.pow(h-d,2));G+=e.standoff*(f-u)/W,q+=e.standoff*(d-h)/W}var Z,X,J=U.append("path").classed("annotation-arrow",!0).classed("anndrag",!0).classed("cursor-move",!0).attr({d:"M3,3H-3V-3H3ZM0,0L"+(f-G)+","+(d-q),transform:"translate("+G+","+q+")"}).style("stroke-width",B+6+"px").call(l.stroke,"rgba(0,0,0,0)").call(l.fill,"rgba(0,0,0,0)");p.init({element:J.node(),gd:t,prepFn:function(){var t=c.getTranslate(P);Z=t.x,X=t.y,s&&s.autorange&&A(s._name+".autorange",!0),m&&m.autorange&&A(m._name+".autorange",!0)},moveFn:function(t,r){var n=w(Z,X),i=n[0]+t,a=n[1]+r;P.call(c.setTranslate,i,a),C("x",s?s.p2r(s.r2p(e.x)+t):e.x+t/b.w),C("y",m?m.p2r(m.r2p(e.y)+r):e.y-r/b.h),e.axref===e.xref&&C("ax",s.p2r(s.r2p(e.ax)+t)),e.ayref===e.yref&&C("ay",m.p2r(m.r2p(e.ay)+r)),U.attr("transform","translate("+t+","+r+")"),S.attr({transform:"rotate("+T+","+i+","+a+")"})},doneFn:function(){i.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}};e.showarrow&&xt(0,0),E&&p.init({element:P.node(),gd:t,prepFn:function(){yt=S.attr("transform")},moveFn:function(t,r){var n="pointer";if(e.showarrow)e.axref===e.xref?C("ax",s.p2r(s.r2p(e.ax)+t)):C("ax",e.ax+t),e.ayref===e.yref?C("ay",m.p2r(m.r2p(e.ay)+r)):C("ay",e.ay+r),xt(t,r);else{if(a)return;var i,o;if(s)i=s.p2r(s.r2p(e.x)+t);else{var l=e._xsize/b.w,c=e.x+(e._xshift-e.xshift)/b.w-l/2;i=p.align(c+t/b.w,l,0,1,e.xanchor)}if(m)o=m.p2r(m.r2p(e.y)+r);else{var u=e._ysize/b.h,h=e.y-(e._yshift+e.yshift)/b.h-u/2;o=p.align(h-r/b.h,u,0,1,e.yanchor)}C("x",i),C("y",o),s&&m||(n=p.getCursor(s?.5:i,m?.5:o,e.xanchor,e.yanchor))}S.attr({transform:"translate("+t+","+r+")"+yt}),f(P,n)},clickFn:function(r,n){e.captureevents&&t.emit("plotly_clickannotation",U(n))},doneFn:function(){f(P),i.call("_guiRelayout",t,M());var e=document.querySelector(".js-notes-box-panel");e&&e.redraw(e.selectedObj)}})}}}e.exports={draw:function(t){var e=t._fullLayout;e._infolayer.selectAll(".annotation").remove();for(var r=0;r=0,m=e.indexOf("end")>=0,v=h.backoff*p+r.standoff,y=f.backoff*d+r.startstandoff;if("line"===u.nodeName){o={x:+t.attr("x1"),y:+t.attr("y1")},s={x:+t.attr("x2"),y:+t.attr("y2")};var x=o.x-s.x,b=o.y-s.y;if(c=(l=Math.atan2(b,x))+Math.PI,v&&y&&v+y>Math.sqrt(x*x+b*b))return void E();if(v){if(v*v>x*x+b*b)return void E();var _=v*Math.cos(l),w=v*Math.sin(l);s.x+=_,s.y+=w,t.attr({x2:s.x,y2:s.y})}if(y){if(y*y>x*x+b*b)return void E();var A=y*Math.cos(l),C=y*Math.sin(l);o.x-=A,o.y-=C,t.attr({x1:o.x,y1:o.y})}}else if("path"===u.nodeName){var M=u.getTotalLength(),k="";if(M1){c=!0;break}}c?t.fullLayout._infolayer.select(".annotation-"+t.id+'[data-index="'+s+'"]').remove():(l._pdata=i(t.glplot.cameraParams,[e.xaxis.r2l(l.x)*r[0],e.yaxis.r2l(l.y)*r[1],e.zaxis.r2l(l.z)*r[2]]),n(t.graphDiv,l,s,t.id,l._xa,l._ya))}}},{"../../plots/gl3d/project":814,"../annotations/draw":581}],588:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports={moduleType:"component",name:"annotations3d",schema:{subplots:{scene:{annotations:t("./attributes")}}},layoutAttributes:t("./attributes"),handleDefaults:t("./defaults"),includeBasePlot:function(t,e){var r=n.subplotsRegistry.gl3d;if(r)for(var a=r.attrRegex,o=Object.keys(t),s=0;s=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return a?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}a.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},a.rgb=function(t){return a.tinyRGB(n(t))},a.opacity=function(t){return t?n(t).getAlpha():0},a.addOpacity=function(t,e){var r=n(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},a.combine=function(t,e){var r=n(t).toRgb();if(1===r.a)return n(t).toRgbString();var i=n(e||l).toRgb(),a=1===i.a?i:{r:255*(1-i.a)+i.r*i.a,g:255*(1-i.a)+i.g*i.a,b:255*(1-i.a)+i.b*i.a},o={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return n(o).toRgbString()},a.contrast=function(t,e,r){var i=n(t);return 1!==i.getAlpha()&&(i=n(a.combine(t,l))),(i.isDark()?e?i.lighten(e):l:r?i.darken(r):s).toString()},a.stroke=function(t,e){var r=n(e);t.style({stroke:a.tinyRGB(r),"stroke-opacity":r.getAlpha()})},a.fill=function(t,e){var r=n(e);t.style({fill:a.tinyRGB(r),"fill-opacity":r.getAlpha()})},a.clean=function(t){if(t&&"object"==typeof t){var e,r,n,i,o=Object.keys(t);for(e=0;e0?n>=l:n<=l));i++)n>u&&n0?n>=l:n<=l));i++)n>r[0]&&n1){var X=Math.pow(10,Math.floor(Math.log(Z)/Math.LN10));q*=X*c.roundUp(Z/X,[2,5,10]),(Math.abs(L.start)/L.size+1e-6)%1<2e-6&&(G.tick0=0)}G.dtick=q}G.domain=[V+j,V+R-j],G.setScale(),t.attr("transform","translate("+Math.round(l.l)+","+Math.round(l.t)+")");var J,K=t.select("."+C.cbtitleunshift).attr("transform","translate(-"+Math.round(l.l)+",-"+Math.round(l.t)+")"),Q=t.select("."+C.cbaxis),$=0;function tt(n,i){var a={propContainer:G,propName:e._propPrefix+"title",traceIndex:e._traceIndex,_meta:e._meta,placeholder:o._dfltTitle.colorbar,containerGroup:t.select("."+C.cbtitle)},s="h"===n.charAt(0)?n.substr(1):"h"+n;t.selectAll("."+s+",."+s+"-math-group").remove(),d.draw(r,n,u(a,i||{}))}return c.syncOrAsync([a.previousPromises,function(){if(-1!==["top","bottom"].indexOf(M)){var t,r=l.l+(e.x+F)*l.w,n=G.title.font.size;t="top"===M?(1-(V+R-j))*l.h+l.t+3+.75*n:(1-(V+j))*l.h+l.t-3-.25*n,tt(G._id+"title",{attributes:{x:r,y:t,"text-anchor":"start"}})}},function(){if(-1!==["top","bottom"].indexOf(M)){var a=t.select("."+C.cbtitle),o=a.select("text"),u=[-e.outlinewidth/2,e.outlinewidth/2],h=a.select(".h"+G._id+"title-math-group").node(),p=15.6;if(o.node()&&(p=parseInt(o.node().style.fontSize,10)*_),h?($=f.bBox(h).height)>p&&(u[1]-=($-p)/2):o.node()&&!o.classed(C.jsPlaceholder)&&($=f.bBox(o.node()).height),$){if($+=5,"top"===M)G.domain[1]-=$/l.h,u[1]*=-1;else{G.domain[0]+=$/l.h;var d=g.lineCount(o);u[1]+=(1-d)*p}a.attr("transform","translate("+u+")"),G.setScale()}}t.selectAll("."+C.cbfills+",."+C.cblines).attr("transform","translate(0,"+Math.round(l.h*(1-G.domain[1]))+")"),Q.attr("transform","translate(0,"+Math.round(-l.t)+")");var v=t.select("."+C.cbfills).selectAll("rect."+C.cbfill).data(E);v.enter().append("rect").classed(C.cbfill,!0).style("stroke","none"),v.exit().remove();var y=k.map(G.c2p).map(Math.round).sort((function(t,e){return t-e}));v.each((function(t,a){var o=[0===a?k[0]:(E[a]+E[a-1])/2,a===E.length-1?k[1]:(E[a]+E[a+1])/2].map(G.c2p).map(Math.round);o[1]=c.constrain(o[1]+(o[1]>o[0])?1:-1,y[0],y[1]);var s=n.select(this).attr({x:B,width:Math.max(P,2),y:n.min(o),height:Math.max(n.max(o)-n.min(o),2)});if(e._fillgradient)f.gradient(s,r,e._id,"vertical",e._fillgradient,"fill");else{var l=T(t).replace("e-","");s.attr("fill",i(l).toHexString())}}));var x=t.select("."+C.cblines).selectAll("path."+C.cbline).data(m.color&&m.width?D:[]);x.enter().append("path").classed(C.cbline,!0),x.exit().remove(),x.each((function(t){n.select(this).attr("d","M"+B+","+(Math.round(G.c2p(t))+m.width/2%1)+"h"+P).call(f.lineGroupStyle,m.width,I(t),m.dash)})),Q.selectAll("g."+G._id+"tick,path").remove();var b=B+P+(e.outlinewidth||0)/2-("outside"===e.ticks?1:0),w=s.calcTicks(G),A=s.makeTransFn(G),L=s.getTickSigns(G)[2];return s.drawTicks(r,G,{vals:"inside"===G.ticks?s.clipEnds(G,w):w,layer:Q,path:s.makeTickPath(G,b,L),transFn:A}),s.drawLabels(r,G,{vals:w,layer:Q,transFn:A,labelFns:s.makeLabelFns(G,b)})},function(){if(-1===["top","bottom"].indexOf(M)){var t=G.title.font.size,e=G._offset+G._length/2,i=l.l+(G.position||0)*l.w+("right"===G.side?10+t*(G.showticklabels?1:.5):-10-t*(G.showticklabels?.5:0));tt("h"+G._id+"title",{avoid:{selection:n.select(r).selectAll("g."+G._id+"tick"),side:M,offsetLeft:l.l,offsetTop:0,maxShift:o.width},attributes:{x:i,y:e,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}},a.previousPromises,function(){var n=P+e.outlinewidth/2+f.bBox(Q.node()).width;if((J=K.select("text")).node()&&!J.classed(C.jsPlaceholder)){var i,o=K.select(".h"+G._id+"title-math-group").node();i=o&&-1!==["top","bottom"].indexOf(M)?f.bBox(o).width:f.bBox(K.node()).right-B-l.l,n=Math.max(n,i)}var s=2*e.xpad+n+e.borderwidth+e.outlinewidth/2,c=U-H;t.select("."+C.cbbg).attr({x:B-e.xpad-(e.borderwidth+e.outlinewidth)/2,y:H-N,width:Math.max(s,2),height:Math.max(c+2*N,2)}).call(p.fill,e.bgcolor).call(p.stroke,e.bordercolor).style("stroke-width",e.borderwidth),t.selectAll("."+C.cboutline).attr({x:B,y:H+e.ypad+("top"===M?$:0),width:Math.max(P,2),height:Math.max(c-2*e.ypad-$,2)}).call(p.stroke,e.outlinecolor).style({fill:"none","stroke-width":e.outlinewidth});var u=({center:.5,right:1}[e.xanchor]||0)*s;t.attr("transform","translate("+(l.l-u)+","+l.t+")");var h={},d=w[e.yanchor],g=A[e.yanchor];"pixels"===e.lenmode?(h.y=e.y,h.t=c*d,h.b=c*g):(h.t=h.b=0,h.yt=e.y+e.len*d,h.yb=e.y-e.len*g);var m=w[e.xanchor],v=A[e.xanchor];if("pixels"===e.thicknessmode)h.x=e.x,h.l=s*m,h.r=s*v;else{var y=s-P;h.l=y*m,h.r=y*v,h.xl=e.x-e.thickness*m,h.xr=e.x+e.thickness*v}a.autoMargin(r,e._id,h)}],r)}(r,e,t);m&&m.then&&(t._promises||[]).push(m),t._context.edits.colorbarPosition&&function(t,e,r){var n,i,a,s=r._fullLayout._size;l.init({element:t.node(),gd:r,prepFn:function(){n=t.attr("transform"),h(t)},moveFn:function(r,o){t.attr("transform",n+" translate("+r+","+o+")"),i=l.align(e._xLeftFrac+r/s.w,e._thickFrac,0,1,e.xanchor),a=l.align(e._yBottomFrac-o/s.h,e._lenFrac,0,1,e.yanchor);var c=l.getCursor(i,a,e.xanchor,e.yanchor);h(t,c)},doneFn:function(){if(h(t),void 0!==i&&void 0!==a){var n={};n[e._propPrefix+"x"]=i,n[e._propPrefix+"y"]=a,void 0!==e._traceIndex?o.call("_guiRestyle",r,n,e._traceIndex):o.call("_guiRelayout",r,n)}}})}(r,e,t)})),e.exit().each((function(e){a.autoMargin(t,e._id)})).remove(),e.order()}}},{"../../constants/alignment":686,"../../lib":717,"../../lib/extend":708,"../../lib/setcursor":737,"../../lib/svg_text_utils":741,"../../plots/cartesian/axes":765,"../../plots/cartesian/axis_defaults":767,"../../plots/cartesian/layout_attributes":777,"../../plots/cartesian/position_defaults":780,"../../plots/plots":826,"../../registry":846,"../color":592,"../colorscale/helpers":603,"../dragelement":610,"../drawing":613,"../titles":679,"./constants":594,d3:165,tinycolor2:536}],597:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){return n.isPlainObject(t.colorbar)}},{"../../lib":717}],598:[function(t,e,r){"use strict";e.exports={moduleType:"component",name:"colorbar",attributes:t("./attributes"),supplyDefaults:t("./defaults"),draw:t("./draw").draw,hasColorbar:t("./has_colorbar")}},{"./attributes":593,"./defaults":595,"./draw":596,"./has_colorbar":597}],599:[function(t,e,r){"use strict";var n=t("../colorbar/attributes"),i=t("../../lib/regex").counter,a=t("./scales.js").scales;function o(t){return"`"+t+"`"}Object.keys(a),e.exports=function(t,e){t=t||"";var r,s=(e=e||{}).cLetter||"c",l=("onlyIfNumerical"in e?e.onlyIfNumerical:Boolean(t),"noScale"in e?e.noScale:"marker.line"===t),c="showScaleDflt"in e?e.showScaleDflt:"z"===s,u="string"==typeof e.colorscaleDflt?a[e.colorscaleDflt]:null,h=e.editTypeOverride||"",f=t?t+".":"";"colorAttr"in e?(r=e.colorAttr,e.colorAttr):o(f+(r={z:"z",c:"color"}[s]));var p=s+"auto",d=s+"min",g=s+"max",m=s+"mid",v=(o(f+p),o(f+d),o(f+g),{});v[d]=v[g]=void 0;var y={};y[p]=!1;var x={};return"color"===r&&(x.color={valType:"color",arrayOk:!0,editType:h||"style"},e.anim&&(x.color.anim=!0)),x[p]={valType:"boolean",dflt:!0,editType:"calc",impliedEdits:v},x[d]={valType:"number",dflt:null,editType:h||"plot",impliedEdits:y},x[g]={valType:"number",dflt:null,editType:h||"plot",impliedEdits:y},x[m]={valType:"number",dflt:null,editType:"calc",impliedEdits:v},x.colorscale={valType:"colorscale",editType:"calc",dflt:u,impliedEdits:{autocolorscale:!1}},x.autocolorscale={valType:"boolean",dflt:!1!==e.autoColorDflt,editType:"calc",impliedEdits:{colorscale:void 0}},x.reversescale={valType:"boolean",dflt:!1,editType:"plot"},l||(x.showscale={valType:"boolean",dflt:c,editType:"calc"},x.colorbar=n),e.noColorAxis||(x.coloraxis={valType:"subplotid",regex:i("coloraxis"),dflt:null,editType:"calc"}),x}},{"../../lib/regex":733,"../colorbar/attributes":593,"./scales.js":607}],600:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./helpers").extractOpts;e.exports=function(t,e,r){var o,s=t._fullLayout,l=r.vals,c=r.containerStr,u=c?i.nestedProperty(e,c).get():e,h=a(u),f=!1!==h.auto,p=h.min,d=h.max,g=h.mid,m=function(){return i.aggNums(Math.min,null,l)},v=function(){return i.aggNums(Math.max,null,l)};void 0===p?p=m():f&&(p=u._colorAx&&n(p)?Math.min(p,m()):m()),void 0===d?d=v():f&&(d=u._colorAx&&n(d)?Math.max(d,v()):v()),f&&void 0!==g&&(d-g>g-p?p=g-(d-g):d-g=0?s.colorscale.sequential:s.colorscale.sequentialminus,h._sync("colorscale",o))}},{"../../lib":717,"./helpers":603,"fast-isnumeric":228}],601:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./helpers").hasColorscale,a=t("./helpers").extractOpts;e.exports=function(t,e){function r(t,e){var r=t["_"+e];void 0!==r&&(t[e]=r)}function o(t,i){var o=i.container?n.nestedProperty(t,i.container).get():t;if(o)if(o.coloraxis)o._colorAx=e[o.coloraxis];else{var s=a(o),l=s.auto;(l||void 0===s.min)&&r(o,i.min),(l||void 0===s.max)&&r(o,i.max),s.autocolorscale&&r(o,"colorscale")}}for(var s=0;s=0;n--,i++){var a=t[n];r[i]=[1-a[0],a[1]]}return r}function d(t,e){e=e||{};for(var r=t.domain,o=t.range,l=o.length,c=new Array(l),u=0;u4/3-s?o:s}},{}],609:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":717}],610:[function(t,e,r){"use strict";var n=t("mouse-event-offset"),i=t("has-hover"),a=t("has-passive-events"),o=t("../../lib").removeElement,s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");function u(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function h(t){return n(t.changedTouches?t.changedTouches[0]:t,document.body)}l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){var e,r,n,c,f,p,d,g,m=t.gd,v=1,y=m._context.doubleClickDelay,x=t.element;m._mouseDownTime||(m._mouseDownTime=0),x.style.pointerEvents="all",x.onmousedown=_,a?(x._ontouchstart&&x.removeEventListener("touchstart",x._ontouchstart),x._ontouchstart=_,x.addEventListener("touchstart",_,{passive:!1})):x.ontouchstart=_;var b=t.clampFn||function(t,e,r){return Math.abs(t)y&&(v=Math.max(v-1,1)),m._dragged)t.doneFn&&t.doneFn();else if(t.clickFn&&t.clickFn(v,p),!g){var r;try{r=new MouseEvent("click",e)}catch(t){var n=h(e);(r=document.createEvent("MouseEvents")).initMouseEvent("click",e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,n[0],n[1],e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}d.dispatchEvent(r)}m._dragging=!1,m._dragged=!1}else m._dragged=!1}},l.coverSlip=u},{"../../lib":717,"../../plots/cartesian/constants":771,"./align":608,"./cursor":609,"./unhover":611,"has-hover":412,"has-passive-events":413,"mouse-event-offset":438}],611:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=t("../../lib/throttle"),a=t("../../lib/dom").getGraphDiv,o=t("../fx/constants"),s=e.exports={};s.wrapped=function(t,e,r){(t=a(t))._fullLayout&&i.clear(t._fullLayout._uid+o.HOVERID),s.raw(t,e,r)},s.raw=function(t,e){var r=t._fullLayout,i=t._hoverdata;e||(e={}),e.target&&!1===n.triggerHandler(t,"plotly_beforehover",e)||(r._hoverlayer.selectAll("g").remove(),r._hoverlayer.selectAll("line").remove(),r._hoverlayer.selectAll("circle").remove(),t._hoverdata=void 0,e.target&&i&&t.emit("plotly_unhover",{event:e,points:i}))}},{"../../lib/dom":706,"../../lib/events":707,"../../lib/throttle":742,"../fx/constants":625}],612:[function(t,e,r){"use strict";r.dash={valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid",editType:"style"}},{}],613:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("tinycolor2"),o=t("../../registry"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),h=t("../../constants/xmlns_namespaces"),f=t("../../constants/alignment").LINE_SPACING,p=t("../../constants/interactions").DESELECTDIM,d=t("../../traces/scatter/subtypes"),g=t("../../traces/scatter/make_bubble_size_func"),m=t("../../components/fx/helpers").appendArrayPointValue,v=e.exports={};v.font=function(t,e,r,n){c.isPlainObject(e)&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},v.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},v.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},v.setRect=function(t,e,r,n,i){t.call(v.setPosition,e,r).call(v.setSize,n,i)},v.translatePoint=function(t,e,r,n){var a=r.c2p(t.x),o=n.c2p(t.y);return!!(i(a)&&i(o)&&e.node())&&("text"===e.node().nodeName?e.attr("x",a).attr("y",o):e.attr("transform","translate("+a+","+o+")"),!0)},v.translatePoints=function(t,e,r){t.each((function(t){var i=n.select(this);v.translatePoint(t,i,e,r)}))},v.hideOutsideRangePoint=function(t,e,r,n,i,a){e.attr("display",r.isPtWithinRange(t,i)&&n.isPtWithinRange(t,a)?null:"none")},v.hideOutsideRangePoints=function(t,e){if(e._hasClipOnAxisFalse){var r=e.xaxis,i=e.yaxis;t.each((function(e){var a=e[0].trace,s=a.xcalendar,l=a.ycalendar,c=o.traceIs(a,"bar-like")?".bartext":".point,.textpoint";t.selectAll(c).each((function(t){v.hideOutsideRangePoint(t,n.select(this),r,i,s,l)}))}))}},v.crispRound=function(t,e,r){return e&&i(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},v.singleLineStyle=function(t,e,r,n,i){e.style("fill","none");var a=(((t||[])[0]||{}).trace||{}).line||{},o=r||a.width||0,l=i||a.dash||"";s.stroke(e,n||a.color),v.dashLine(e,l,o)},v.lineGroupStyle=function(t,e,r,i){t.style("fill","none").each((function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=i||a.dash||"";n.select(this).call(s.stroke,r||a.color).call(v.dashLine,l,o)}))},v.dashLine=function(t,e,r){r=+r||0,e=v.dashStyle(e,r),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},v.dashStyle=function(t,e){e=+e||1;var r=Math.max(e,3);return"solid"===t?t="":"dot"===t?t=r+"px,"+r+"px":"dash"===t?t=3*r+"px,"+3*r+"px":"longdash"===t?t=5*r+"px,"+5*r+"px":"dashdot"===t?t=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===t&&(t=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t},v.singleFillStyle=function(t){var e=(((n.select(t.node()).data()[0]||[])[0]||{}).trace||{}).fillcolor;e&&t.call(s.fill,e)},v.fillGroupStyle=function(t){t.style("stroke-width",0).each((function(t){var e=n.select(this);t[0].trace&&e.call(s.fill,t[0].trace.fillcolor)}))};var y=t("./symbol_defs");v.symbolNames=[],v.symbolFuncs=[],v.symbolNeedLines={},v.symbolNoDot={},v.symbolNoFill={},v.symbolList=[],Object.keys(y).forEach((function(t){var e=y[t],r=e.n;v.symbolList.push(r,t,r+100,t+"-open"),v.symbolNames[r]=t,v.symbolFuncs[r]=e.f,e.needLine&&(v.symbolNeedLines[r]=!0),e.noDot?v.symbolNoDot[r]=!0:v.symbolList.push(r+200,t+"-dot",r+300,t+"-open-dot"),e.noFill&&(v.symbolNoFill[r]=!0)}));var x=v.symbolNames.length,b="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";function _(t,e){var r=t%100;return v.symbolFuncs[r](e)+(t>=200?b:"")}v.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),(t=v.symbolNames.indexOf(t))>=0&&(t+=e)}return t%100>=x||t>=400?0:Math.floor(Math.max(t,0))};var w={x1:1,x2:0,y1:0,y2:0},A={x1:0,x2:0,y1:1,y2:0},C=n.format("~.1f"),M={radial:{node:"radialGradient"},radialreversed:{node:"radialGradient",reversed:!0},horizontal:{node:"linearGradient",attrs:w},horizontalreversed:{node:"linearGradient",attrs:w,reversed:!0},vertical:{node:"linearGradient",attrs:A},verticalreversed:{node:"linearGradient",attrs:A,reversed:!0}};v.gradient=function(t,e,r,i,o,l){for(var u=o.length,h=M[i],f=new Array(u),p=0;p"+v(t);d._gradientUrlQueryParts[y]=1},v.initGradients=function(t){var e=t._fullLayout;c.ensureSingle(e._defs,"g","gradients").selectAll("linearGradient,radialGradient").remove(),e._gradientUrlQueryParts={}},v.pointStyle=function(t,e,r){if(t.size()){var i=v.makePointStyleFns(e);t.each((function(t){v.singlePointStyle(t,n.select(this),e,i,r)}))}},v.singlePointStyle=function(t,e,r,n,i){var a=r.marker,o=a.line;if(e.style("opacity",n.selectedOpacityFn?n.selectedOpacityFn(t):void 0===t.mo?a.opacity:t.mo),n.ms2mrc){var l;l="various"===t.ms||"various"===a.size?3:n.ms2mrc(t.ms),t.mrc=l,n.selectedSizeFn&&(l=t.mrc=n.selectedSizeFn(t));var u=v.symbolNumber(t.mx||a.symbol)||0;t.om=u%200>=100,e.attr("d",_(u,l))}var h,f,p,d=!1;if(t.so)p=o.outlierwidth,f=o.outliercolor,h=a.outliercolor;else{var g=(o||{}).width;p=(t.mlw+1||g+1||(t.trace?(t.trace.marker.line||{}).width:0)+1)-1||0,f="mlc"in t?t.mlcc=n.lineScale(t.mlc):c.isArrayOrTypedArray(o.color)?s.defaultLine:o.color,c.isArrayOrTypedArray(a.color)&&(h=s.defaultLine,d=!0),h="mc"in t?t.mcc=n.markerScale(t.mc):a.color||"rgba(0,0,0,0)",n.selectedColorFn&&(h=n.selectedColorFn(t))}if(t.om)e.call(s.stroke,h).style({"stroke-width":(p||1)+"px",fill:"none"});else{e.style("stroke-width",(t.isBlank?0:p)+"px");var m=a.gradient,y=t.mgt;if(y?d=!0:y=m&&m.type,Array.isArray(y)&&(y=y[0],M[y]||(y=0)),y&&"none"!==y){var x=t.mgc;x?d=!0:x=m.color;var b=r.uid;d&&(b+="-"+t.i),v.gradient(e,i,b,y,[[0,x],[1,h]],"fill")}else s.fill(e,h);p&&s.stroke(e,f)}},v.makePointStyleFns=function(t){var e={},r=t.marker;return e.markerScale=v.tryColorscale(r,""),e.lineScale=v.tryColorscale(r,"line"),o.traceIs(t,"symbols")&&(e.ms2mrc=d.isBubble(t)?g(t):function(){return(r.size||6)/2}),t.selectedpoints&&c.extendFlat(e,v.makeSelectedPointStyleFns(t)),e},v.makeSelectedPointStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.marker||{},a=r.marker||{},s=n.marker||{},l=i.opacity,u=a.opacity,h=s.opacity,f=void 0!==u,d=void 0!==h;(c.isArrayOrTypedArray(l)||f||d)&&(e.selectedOpacityFn=function(t){var e=void 0===t.mo?i.opacity:t.mo;return t.selected?f?u:e:d?h:p*e});var g=i.color,m=a.color,v=s.color;(m||v)&&(e.selectedColorFn=function(t){var e=t.mcc||g;return t.selected?m||e:v||e});var y=i.size,x=a.size,b=s.size,_=void 0!==x,w=void 0!==b;return o.traceIs(t,"symbols")&&(_||w)&&(e.selectedSizeFn=function(t){var e=t.mrc||y/2;return t.selected?_?x/2:e:w?b/2:e}),e},v.makeSelectedTextStyleFns=function(t){var e={},r=t.selected||{},n=t.unselected||{},i=t.textfont||{},a=r.textfont||{},o=n.textfont||{},l=i.color,c=a.color,u=o.color;return e.selectedTextColorFn=function(t){var e=t.tc||l;return t.selected?c||e:u||(c?e:s.addOpacity(e,p))},e},v.selectedPointStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedPointStyleFns(e),i=e.marker||{},a=[];r.selectedOpacityFn&&a.push((function(t,e){t.style("opacity",r.selectedOpacityFn(e))})),r.selectedColorFn&&a.push((function(t,e){s.fill(t,r.selectedColorFn(e))})),r.selectedSizeFn&&a.push((function(t,e){var n=e.mx||i.symbol||0,a=r.selectedSizeFn(e);t.attr("d",_(v.symbolNumber(n),a)),e.mrc2=a})),a.length&&t.each((function(t){for(var e=n.select(this),r=0;r0?r:0}v.textPointStyle=function(t,e,r){if(t.size()){var i;if(e.selectedpoints){var a=v.makeSelectedTextStyleFns(e);i=a.selectedTextColorFn}var o=e.texttemplate,s=r._fullLayout;t.each((function(t){var a=n.select(this),l=o?c.extractOption(t,e,"txt","texttemplate"):c.extractOption(t,e,"tx","text");if(l||0===l){if(o){var h=e._module.formatLabels?e._module.formatLabels(t,e,s):{},f={};m(f,e,t.i);var p=e._meta||{};l=c.texttemplateString(l,h,s._d3locale,f,t,p)}var d=t.tp||e.textposition,g=T(t,e),y=i?i(t):t.tc||e.textfont.color;a.call(v.font,t.tf||e.textfont.family,g,y).text(l).call(u.convertToTspans,r).call(I,d,g,t.mrc)}else a.remove()}))}},v.selectedTextStyle=function(t,e){if(t.size()&&e.selectedpoints){var r=v.makeSelectedTextStyleFns(e);t.each((function(t){var i=n.select(this),a=r.selectedTextColorFn(t),o=t.tp||e.textposition,l=T(t,e);s.fill(i,a),I(i,o,l,t.mrc2||t.mrc)}))}};var L=.5;function S(t,e,r,i){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,L/2),u=Math.pow(s*s+l*l,L/2),h=(u*u*a-c*c*s)*i,f=(u*u*o-c*c*l)*i,p=3*u*(c+u),d=3*c*(c+u);return[[n.round(e[0]+(p&&h/p),2),n.round(e[1]+(p&&f/p),2)],[n.round(e[0]-(d&&h/d),2),n.round(e[1]-(d&&f/d),2)]]}v.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,n="M"+t[0],i=[];for(r=1;r=1e4&&(v.savedBBoxes={},P=0),r&&(v.savedBBoxes[r]=m),P++,c.extendFlat({},m)},v.setClipUrl=function(t,e,r){t.attr("clip-path",z(e,r))},v.getTranslate=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\btranslate\((-?\d*\.?\d*)[^-\d]*(-?\d*\.?\d*)[^\d].*/,(function(t,e,r){return[e,r].join(" ")})).split(" ");return{x:+e[0]||0,y:+e[1]||0}},v.setTranslate=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||0,r=r||0,a=a.replace(/(\btranslate\(.*?\);?)/,"").trim(),a=(a+=" translate("+e+", "+r+")").trim(),t[i]("transform",a),a},v.getScale=function(t){var e=(t[t.attr?"attr":"getAttribute"]("transform")||"").replace(/.*\bscale\((\d*\.?\d*)[^\d]*(\d*\.?\d*)[^\d].*/,(function(t,e,r){return[e,r].join(" ")})).split(" ");return{x:+e[0]||1,y:+e[1]||1}},v.setScale=function(t,e,r){var n=t.attr?"attr":"getAttribute",i=t.attr?"attr":"setAttribute",a=t[n]("transform")||"";return e=e||1,r=r||1,a=a.replace(/(\bscale\(.*?\);?)/,"").trim(),a=(a+=" scale("+e+", "+r+")").trim(),t[i]("transform",a),a};var R=/\s*sc.*/;v.setPointGroupScale=function(t,e,r){if(e=e||1,r=r||1,t){var n=1===e&&1===r?"":" scale("+e+","+r+")";t.each((function(){var t=(this.getAttribute("transform")||"").replace(R,"");t=(t+=n).trim(),this.setAttribute("transform",t)}))}};var F=/translate\([^)]*\)\s*$/;v.setTextPointsScale=function(t,e,r){t&&t.each((function(){var t,i=n.select(this),a=i.select("text");if(a.node()){var o=parseFloat(a.attr("x")||0),s=parseFloat(a.attr("y")||0),l=(i.attr("transform")||"").match(F);t=1===e&&1===r?[]:["translate("+o+","+s+")","scale("+e+","+r+")","translate("+-o+","+-s+")"],l&&t.push(l),i.attr("transform",t.join(" "))}}))}},{"../../components/fx/helpers":627,"../../constants/alignment":686,"../../constants/interactions":692,"../../constants/xmlns_namespaces":694,"../../lib":717,"../../lib/svg_text_utils":741,"../../registry":846,"../../traces/scatter/make_bubble_size_func":1137,"../../traces/scatter/subtypes":1144,"../color":592,"../colorscale":604,"./symbol_defs":614,d3:165,"fast-isnumeric":228,tinycolor2:536}],614:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+","+n.round(t/2,2)+"H"+e+"L0,-"+n.round(t,2)+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+e+",-"+n.round(t/2,2)+"H"+e+"L0,"+n.round(t,2)+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M"+n.round(t/2,2)+",-"+e+"V"+e+"L-"+n.round(t,2)+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2);return"M-"+n.round(t/2,2)+",-"+e+"V"+e+"L"+n.round(t,2)+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(-.309*t,2);return"M"+e+","+a+"L"+r+","+n.round(.809*t,2)+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(-.309*e,2),c=n.round(.118*e,2),u=n.round(.809*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+n.round(.382*e,2)+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0,noFill:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0,noFill:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0,noFill:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0,noFill:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0,noFill:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0,noFill:!0}}},{d3:165}],615:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean",editType:"calc"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"],editType:"calc"},symmetric:{valType:"boolean",editType:"calc"},array:{valType:"data_array",editType:"calc"},arrayminus:{valType:"data_array",editType:"calc"},value:{valType:"number",min:0,dflt:10,editType:"calc"},valueminus:{valType:"number",min:0,dflt:10,editType:"calc"},traceref:{valType:"integer",min:0,dflt:0,editType:"style"},tracerefminus:{valType:"integer",min:0,dflt:0,editType:"style"},copy_ystyle:{valType:"boolean",editType:"plot"},copy_zstyle:{valType:"boolean",editType:"style"},color:{valType:"color",editType:"style"},thickness:{valType:"number",min:0,dflt:2,editType:"style"},width:{valType:"number",min:0,editType:"plot"},editType:"calc",_deprecated:{opacity:{valType:"number",editType:"style"}}}},{}],616:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../registry"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),s=t("./compute_error");function l(t,e,r,i){var l=e["error_"+i]||{},c=[];if(l.visible&&-1!==["linear","log"].indexOf(r.type)){for(var u=s(l),h=0;h0;e.each((function(e){var h,f=e[0].trace,p=f.error_x||{},d=f.error_y||{};f.ids&&(h=function(t){return t.id});var g=o.hasMarkers(f)&&f.marker.maxdisplayed>0;d.visible||p.visible||(e=[]);var m=n.select(this).selectAll("g.errorbar").data(e,h);if(m.exit().remove(),e.length){p.visible||m.selectAll("path.xerror").remove(),d.visible||m.selectAll("path.yerror").remove(),m.style("opacity",1);var v=m.enter().append("g").classed("errorbar",!0);u&&v.style("opacity",0).transition().duration(s.duration).style("opacity",1),a.setClipUrl(m,r.layerClipId,t),m.each((function(t){var e=n.select(this),r=function(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),i(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),i(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}(t,l,c);if(!g||t.vis){var a,o=e.select("path.yerror");if(d.visible&&i(r.x)&&i(r.yh)&&i(r.ys)){var h=d.width;a="M"+(r.x-h)+","+r.yh+"h"+2*h+"m-"+h+",0V"+r.ys,r.noYS||(a+="m-"+h+",0h"+2*h),o.size()?u&&(o=o.transition().duration(s.duration).ease(s.easing)):o=e.append("path").style("vector-effect","non-scaling-stroke").classed("yerror",!0),o.attr("d",a)}else o.remove();var f=e.select("path.xerror");if(p.visible&&i(r.y)&&i(r.xh)&&i(r.xs)){var m=(p.copy_ystyle?d:p).width;a="M"+r.xh+","+(r.y-m)+"v"+2*m+"m0,-"+m+"H"+r.xs,r.noXS||(a+="m0,-"+m+"v"+2*m),f.size()?u&&(f=f.transition().duration(s.duration).ease(s.easing)):f=e.append("path").style("vector-effect","non-scaling-stroke").classed("xerror",!0),f.attr("d",a)}else f.remove()}}))}}))}},{"../../traces/scatter/subtypes":1144,"../drawing":613,d3:165,"fast-isnumeric":228}],621:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each((function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)}))}},{"../color":592,d3:165}],622:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("./layout_attributes").hoverlabel,a=t("../../lib/extend").extendFlat;e.exports={hoverlabel:{bgcolor:a({},i.bgcolor,{arrayOk:!0}),bordercolor:a({},i.bordercolor,{arrayOk:!0}),font:n({arrayOk:!0,editType:"none"}),align:a({},i.align,{arrayOk:!0}),namelength:a({},i.namelength,{arrayOk:!0}),editType:"none"}}},{"../../lib/extend":708,"../../plots/font_attributes":791,"./layout_attributes":631}],623:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry");function a(t,e,r,i){i=i||n.identity,Array.isArray(t)&&(e[0][r]=i(t))}e.exports=function(t){var e=t.calcdata,r=t._fullLayout;function o(t){return function(e){return n.coerceHoverinfo({hoverinfo:e},{_module:t._module},r)}}for(var s=0;s=0&&r.index_[0]._length||$<0||$>w[0]._length)return f.unhoverRaw(t,e)}else Q="xpx"in e?e.xpx:_[0]._length/2,$="ypx"in e?e.ypx:w[0]._length/2;if(e.pointerX=Q+_[0]._offset,e.pointerY=$+w[0]._offset,P="xval"in e?g.flat(l,e.xval):g.p2c(_,Q),O="yval"in e?g.flat(l,e.yval):g.p2c(w,$),!i(P[0])||!i(O[0]))return o.warn("Fx.hover failed",e,t),f.unhoverRaw(t,e)}var et=1/0;for(R=0;RG&&(Z.splice(0,G),et=Z[0].distance),v&&0!==W&&0===Z.length){H.distance=W,H.index=!1;var ot=N._module.hoverPoints(H,V,U,"closest",u._hoverlayer);if(ot&&(ot=ot.filter((function(t){return t.spikeDistance<=W}))),ot&&ot.length){var st,lt=ot.filter((function(t){return t.xa.showspikes}));if(lt.length){var ct=lt[0];i(ct.x0)&&i(ct.y0)&&(st=pt(ct),(!J.vLinePoint||J.vLinePoint.spikeDistance>st.spikeDistance)&&(J.vLinePoint=st))}var ut=ot.filter((function(t){return t.ya.showspikes}));if(ut.length){var ht=ut[0];i(ht.x0)&&i(ht.y0)&&(st=pt(ht),(!J.hLinePoint||J.hLinePoint.spikeDistance>st.spikeDistance)&&(J.hLinePoint=st))}}}}function ft(t,e){for(var r,n=null,i=1/0,a=0;a1||Z.length>1)||"closest"===D&&K&&Z.length>1,kt=h.combine(u.plot_bgcolor||h.background,u.paper_bgcolor),It={hovermode:D,rotateLabels:Mt,bgColor:kt,container:u._hoverlayer,outerContainer:u._paperdiv,commonLabelOpts:u.hoverlabel,hoverdistance:u.hoverdistance},Tt=M(Z,It,t);if(function(t,e,r){var n,i,a,o,s,l,c,u=0,h=1,f=t.size(),p=new Array(f),d=0;function g(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(c<=0);o--)(l=t[o]).pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(t.each((function(t){var n=t[e],i="x"===n._id.charAt(0),a=n.range;0===d&&a&&a[0]>a[1]!==i&&(h=-1),p[d++]=[{datum:t,traceIndex:t.trace.index,dp:0,pos:t.pos,posref:t.posref,size:t.by*(i?x:1)/2,pmin:0,pmax:i?r.width:r.height}]})),p.sort((function(t,e){return t[0].posref-e[0].posref||h*(e[0].traceIndex-t[0].traceIndex)}));!n&&u<=f;){for(u++,n=!0,o=0;o.01&&y.pmin===b.pmin&&y.pmax===b.pmax){for(s=v.length-1;s>=0;s--)v[s].dp+=i;for(m.push.apply(m,v),p.splice(o+1,1),c=0,s=m.length-1;s>=0;s--)c+=m[s].dp;for(a=c/m.length,s=m.length-1;s>=0;s--)m[s].dp-=a;n=!1}else o++}p.forEach(g)}for(o=p.length-1;o>=0;o--){var _=p[o];for(s=_.length-1;s>=0;s--){var w=_[s],A=w.datum;A.offset=w.dp,A.del=w.del}}}(Tt,Mt?"xa":"ya",u),k(Tt,Mt),e.target&&e.target.tagName){var Lt=d.getComponentMethod("annotations","hasClickToShow")(t,_t);c(n.select(e.target),Lt?"pointer":"")}e.target&&!a&&function(t,e,r){if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber)||String(i.pointNumbers)!==String(a.pointNumbers))return!0}return!1}(t,0,bt)&&(bt&&t.emit("plotly_unhover",{event:e,points:bt}),t.emit("plotly_hover",{event:e,points:t._hoverdata,xaxes:_,yaxes:w,xvals:P,yvals:O}))}(t,e,r,a)}))},r.loneHover=function(t,e){var r=!0;Array.isArray(t)||(r=!1,t=[t]);var i=t.map((function(t){return{color:t.color||h.defaultLine,x0:t.x0||t.x||0,x1:t.x1||t.x||0,y0:t.y0||t.y||0,y1:t.y1||t.y||0,xLabel:t.xLabel,yLabel:t.yLabel,zLabel:t.zLabel,text:t.text,name:t.name,idealAlign:t.idealAlign,borderColor:t.borderColor,fontFamily:t.fontFamily,fontSize:t.fontSize,fontColor:t.fontColor,nameLength:t.nameLength,textAlign:t.textAlign,trace:t.trace||{index:0,hoverinfo:""},xa:{_offset:0},ya:{_offset:0},index:0,hovertemplate:t.hovertemplate||!1,eventData:t.eventData||!1,hovertemplateLabels:t.hovertemplateLabels||!1}})),a=n.select(e.container),o=e.outerContainer?n.select(e.outerContainer):a,s={hovermode:"closest",rotateLabels:!1,bgColor:e.bgColor||h.background,container:a,outerContainer:o},l=M(i,s,e.gd),c=0,u=0;return l.sort((function(t,e){return t.y0-e.y0})).each((function(t,r){var n=t.y0-t.by/2;t.offset=n-5([\s\S]*)<\/extra>/;function M(t,e,r){var i=r._fullLayout,a=e.hovermode,s=e.rotateLabels,c=e.bgColor,f=e.container,p=e.outerContainer,d=e.commonLabelOpts||{},g=e.fontFamily||m.HOVERFONT,y=e.fontSize||m.HOVERFONTSIZE,x=t[0],b=x.xa,_=x.ya,M="y"===a?"yLabel":"xLabel",k=x[M],I=(String(k)||"").split(" ")[0],T=p.node().getBoundingClientRect(),L=T.top,E=T.width,D=T.height,P=void 0!==k&&x.distance<=e.hoverdistance&&("x"===a||"y"===a);if(P){var O,z,R=!0;for(O=0;Oi.width-D?(C=i.width-D,s.attr("d","M"+(D-w)+",0L"+D+","+E+w+"v"+E+(2*A+S.height)+"H-"+D+"V"+E+w+"H"+(D-2*w)+"Z")):s.attr("d","M0,0L"+w+","+E+w+"H"+(A+S.width/2)+"v"+E+(2*A+S.height)+"H-"+(A+S.width/2)+"V"+E+w+"H-"+w+"Z")}else{var P,O,z;"right"===_.side?(P="start",O=1,z="",C=b._offset+b._length):(P="end",O=-1,z="-",C=b._offset),T=_._offset+(x.y0+x.y1)/2,c.attr("text-anchor",P),s.attr("d","M0,0L"+z+w+","+w+"V"+(A+S.height/2)+"h"+z+(2*A+S.width)+"V-"+(A+S.height/2)+"H"+z+w+"V-"+w+"Z");var R,F=S.height/2,N=L-S.top-F,j="clip"+i._uid+"commonlabel"+_._id;if(C"),void 0!==t.yLabel&&(p+="y: "+t.yLabel+"
"),"choropleth"!==t.trace.type&&"choroplethmapbox"!==t.trace.type&&(p+=(p?"z: ":"")+t.zLabel)):P&&t[a+"Label"]===k?p=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&"scattercarpet"!==t.trace.type&&(p=t.yLabel):p=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",!t.text&&0!==t.text||Array.isArray(t.text)||(p+=(p?"
":"")+t.text),void 0!==t.extraText&&(p+=(p?"
":"")+t.extraText),""!==p||t.hovertemplate||(""===f&&e.remove(),p=f);var _=i._d3locale,M=t.hovertemplate||!1,I=t.hovertemplateLabels||t,T=t.eventData[0]||{};M&&(p=(p=o.hovertemplateString(M,I,_,T,t.trace._meta)).replace(C,(function(e,r){return f=S(r,t.nameLength),""})));var O=e.select("text.nums").call(u.font,t.fontFamily||g,t.fontSize||y,t.fontColor||b).text(p).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r),z=e.select("text.name"),R=0,F=0;if(f&&f!==p){z.call(u.font,t.fontFamily||g,t.fontSize||y,x).text(f).attr("data-notex",1).call(l.positionText,0,0).call(l.convertToTspans,r);var N=z.node().getBoundingClientRect();R=N.width+2*A,F=N.height+2*A}else z.remove(),e.select("rect").remove();e.select("path").style({fill:m,stroke:b});var j,B,Y=O.node().getBoundingClientRect(),V=t.xa._offset+(t.x0+t.x1)/2,U=t.ya._offset+(t.y0+t.y1)/2,H=Math.abs(t.x1-t.x0),G=Math.abs(t.y1-t.y0),q=Y.width+w+A+R;if(t.ty0=L-Y.top,t.bx=Y.width+2*A,t.by=Math.max(Y.height+2*A,F),t.anchor="start",t.txwidth=Y.width,t.tx2width=R,t.offset=0,s)t.pos=V,j=U+G/2+q<=D,B=U-G/2-q>=0,"top"!==t.idealAlign&&j||!B?j?(U+=G/2,t.anchor="start"):t.anchor="middle":(U-=G/2,t.anchor="end");else if(t.pos=U,j=V+H/2+q<=E,B=V-H/2-q>=0,"left"!==t.idealAlign&&j||!B)if(j)V+=H/2,t.anchor="start";else{t.anchor="middle";var W=q/2,Z=V+W-E,X=V-W;Z>0&&(V-=Z),X<0&&(V+=-X)}else V-=H/2,t.anchor="end";O.attr("text-anchor",t.anchor),R&&z.attr("text-anchor",t.anchor),e.attr("transform","translate("+V+","+U+")"+(s?"rotate("+v+")":""))})),j}function k(t,e){t.each((function(t){var r=n.select(this);if(t.del)return r.remove();var i=r.select("text.nums"),a=t.anchor,o="end"===a?-1:1,s={start:1,end:-1,middle:0}[a],c=s*(w+A),h=c+s*(t.txwidth+A),f=0,p=t.offset;"middle"===a&&(c-=t.tx2width/2,h+=t.txwidth/2+A),e&&(p*=-_,f=t.offset*b),r.select("path").attr("d","middle"===a?"M-"+(t.bx/2+t.tx2width/2)+","+(p-t.by/2)+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(o*w+f)+","+(w+p)+"v"+(t.by/2-w)+"h"+o*t.bx+"v-"+t.by+"H"+(o*w+f)+"V"+(p-w)+"Z");var d=c+f,g=p+t.ty0-t.by/2+A,m=t.textAlign||"auto";"auto"!==m&&("left"===m&&"start"!==a?(i.attr("text-anchor","start"),d="middle"===a?-t.bx/2-t.tx2width/2+A:-t.bx-A):"right"===m&&"end"!==a&&(i.attr("text-anchor","end"),d="middle"===a?t.bx/2-t.tx2width/2-A:t.bx+A)),i.call(l.positionText,d,g),t.tx2width&&(r.select("text.name").call(l.positionText,h+s*A+f,p+t.ty0-t.by/2+A),r.select("rect").call(u.setRect,h+(s-1)*t.tx2width/2+f,p-t.by/2-1,t.tx2width,t.by+2))}))}function I(t,e){var r=t.index,n=t.trace||{},a=t.cd[0],s=t.cd[r]||{};function l(t){return t||i(t)&&0===t}var c=Array.isArray(r)?function(t,e){var i=o.castOption(a,r,t);return l(i)?i:o.extractOption({},n,"",e)}:function(t,e){return o.extractOption(s,n,t,e)};function u(e,r,n){var i=c(r,n);l(i)&&(t[e]=i)}if(u("hoverinfo","hi","hoverinfo"),u("bgcolor","hbg","hoverlabel.bgcolor"),u("borderColor","hbc","hoverlabel.bordercolor"),u("fontFamily","htf","hoverlabel.font.family"),u("fontSize","hts","hoverlabel.font.size"),u("fontColor","htc","hoverlabel.font.color"),u("nameLength","hnl","hoverlabel.namelength"),u("textAlign","hta","hoverlabel.align"),t.posref="y"===e||"closest"===e&&"h"===n.orientation?t.xa._offset+(t.x0+t.x1)/2:t.ya._offset+(t.y0+t.y1)/2,t.x0=o.constrain(t.x0,0,t.xa._length),t.x1=o.constrain(t.x1,0,t.xa._length),t.y0=o.constrain(t.y0,0,t.ya._length),t.y1=o.constrain(t.y1,0,t.ya._length),void 0!==t.xLabelVal&&(t.xLabel="xLabel"in t?t.xLabel:p.hoverLabelText(t.xa,t.xLabelVal),t.xVal=t.xa.c2d(t.xLabelVal)),void 0!==t.yLabelVal&&(t.yLabel="yLabel"in t?t.yLabel:p.hoverLabelText(t.ya,t.yLabelVal),t.yVal=t.ya.c2d(t.yLabelVal)),void 0!==t.zLabelVal&&void 0===t.zLabel&&(t.zLabel=String(t.zLabelVal)),!(isNaN(t.xerr)||"log"===t.xa.type&&t.xerr<=0)){var h=p.tickText(t.xa,t.xa.c2l(t.xerr),"hover").text;void 0!==t.xerrneg?t.xLabel+=" +"+h+" / -"+p.tickText(t.xa,t.xa.c2l(t.xerrneg),"hover").text:t.xLabel+=" ± "+h,"x"===e&&(t.distance+=1)}if(!(isNaN(t.yerr)||"log"===t.ya.type&&t.yerr<=0)){var f=p.tickText(t.ya,t.ya.c2l(t.yerr),"hover").text;void 0!==t.yerrneg?t.yLabel+=" +"+f+" / -"+p.tickText(t.ya,t.ya.c2l(t.yerrneg),"hover").text:t.yLabel+=" ± "+f,"y"===e&&(t.distance+=1)}var d=t.hoverinfo||t.trace.hoverinfo;return d&&"all"!==d&&(-1===(d=Array.isArray(d)?d:d.split("+")).indexOf("x")&&(t.xLabel=void 0),-1===d.indexOf("y")&&(t.yLabel=void 0),-1===d.indexOf("z")&&(t.zLabel=void 0),-1===d.indexOf("text")&&(t.text=void 0),-1===d.indexOf("name")&&(t.name=void 0)),t}function T(t,e,r){var n,i,o=r.container,s=r.fullLayout,l=s._size,c=r.event,f=!!e.hLinePoint,d=!!e.vLinePoint;if(o.selectAll(".spikeline").remove(),d||f){var g=h.combine(s.plot_bgcolor,s.paper_bgcolor);if(f){var m,v,y=e.hLinePoint;n=y&&y.xa,"cursor"===(i=y&&y.ya).spikesnap?(m=c.pointerX,v=c.pointerY):(m=n._offset+y.x,v=i._offset+y.y);var x,b,_=a.readability(y.color,g)<1.5?h.contrast(g):y.color,w=i.spikemode,A=i.spikethickness,C=i.spikecolor||_,M=p.getPxPosition(t,i);if(-1!==w.indexOf("toaxis")||-1!==w.indexOf("across")){if(-1!==w.indexOf("toaxis")&&(x=M,b=m),-1!==w.indexOf("across")){var k=i._counterDomainMin,I=i._counterDomainMax;"free"===i.anchor&&(k=Math.min(k,i.position),I=Math.max(I,i.position)),x=l.l+k*l.w,b=l.l+I*l.w}o.insert("line",":first-child").attr({x1:x,x2:b,y1:v,y2:v,"stroke-width":A,stroke:C,"stroke-dasharray":u.dashStyle(i.spikedash,A)}).classed("spikeline",!0).classed("crisp",!0),o.insert("line",":first-child").attr({x1:x,x2:b,y1:v,y2:v,"stroke-width":A+2,stroke:g}).classed("spikeline",!0).classed("crisp",!0)}-1!==w.indexOf("marker")&&o.insert("circle",":first-child").attr({cx:M+("right"!==i.side?A:-A),cy:v,r:A,fill:C}).classed("spikeline",!0)}if(d){var T,L,S=e.vLinePoint;n=S&&S.xa,i=S&&S.ya,"cursor"===n.spikesnap?(T=c.pointerX,L=c.pointerY):(T=n._offset+S.x,L=i._offset+S.y);var E,D,P=a.readability(S.color,g)<1.5?h.contrast(g):S.color,O=n.spikemode,z=n.spikethickness,R=n.spikecolor||P,F=p.getPxPosition(t,n);if(-1!==O.indexOf("toaxis")||-1!==O.indexOf("across")){if(-1!==O.indexOf("toaxis")&&(E=F,D=L),-1!==O.indexOf("across")){var N=n._counterDomainMin,j=n._counterDomainMax;"free"===n.anchor&&(N=Math.min(N,n.position),j=Math.max(j,n.position)),E=l.t+(1-j)*l.h,D=l.t+(1-N)*l.h}o.insert("line",":first-child").attr({x1:T,x2:T,y1:E,y2:D,"stroke-width":z,stroke:R,"stroke-dasharray":u.dashStyle(n.spikedash,z)}).classed("spikeline",!0).classed("crisp",!0),o.insert("line",":first-child").attr({x1:T,x2:T,y1:E,y2:D,"stroke-width":z+2,stroke:g}).classed("spikeline",!0).classed("crisp",!0)}-1!==O.indexOf("marker")&&o.insert("circle",":first-child").attr({cx:T,cy:F-("top"!==n.side?z:-z),r:z,fill:R}).classed("spikeline",!0)}}}function L(t,e){return!e||e.vLinePoint!==t._spikepoints.vLinePoint||e.hLinePoint!==t._spikepoints.hLinePoint}function S(t,e){return l.plainText(t||"",{len:e,allowedTags:["br","sub","sup","b","i","em"]})}},{"../../lib":717,"../../lib/events":707,"../../lib/override_cursor":728,"../../lib/svg_text_utils":741,"../../plots/cartesian/axes":765,"../../registry":846,"../color":592,"../dragelement":610,"../drawing":613,"./constants":625,"./helpers":627,d3:165,"fast-isnumeric":228,tinycolor2:536}],629:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r,i){r("hoverlabel.bgcolor",(i=i||{}).bgcolor),r("hoverlabel.bordercolor",i.bordercolor),r("hoverlabel.namelength",i.namelength),n.coerceFont(r,"hoverlabel.font",i.font),r("hoverlabel.align",i.align)}},{"../../lib":717}],630:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../dragelement"),o=t("./helpers"),s=t("./layout_attributes"),l=t("./hover");e.exports={moduleType:"component",name:"fx",constants:t("./constants"),schema:{layout:s},attributes:t("./attributes"),layoutAttributes:s,supplyLayoutGlobalDefaults:t("./layout_global_defaults"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),getDistanceFunction:o.getDistanceFunction,getClosest:o.getClosest,inbox:o.inbox,quadrature:o.quadrature,appendArrayPointValue:o.appendArrayPointValue,castHoverOption:function(t,e,r){return i.castOption(t,e,"hoverlabel."+r)},castHoverinfo:function(t,e,r){return i.castOption(t,r,"hoverinfo",(function(r){return i.coerceHoverinfo({hoverinfo:r},{_module:t._module},e)}))},hover:l.hover,unhover:a.unhover,loneHover:l.loneHover,loneUnhover:function(t){var e=i.isD3Selection(t)?t:n.select(t);e.selectAll("g.hovertext").remove(),e.selectAll(".spikeline").remove()},click:t("./click")}},{"../../lib":717,"../dragelement":610,"./attributes":622,"./calc":623,"./click":624,"./constants":625,"./defaults":626,"./helpers":627,"./hover":628,"./layout_attributes":631,"./layout_defaults":632,"./layout_global_defaults":633,d3:165}],631:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../plots/font_attributes")({editType:"none"});i.family.dflt=n.HOVERFONT,i.size.dflt=n.HOVERFONTSIZE,e.exports={clickmode:{valType:"flaglist",flags:["event","select"],dflt:"event",editType:"plot",extras:["none"]},dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable",!1],dflt:"zoom",editType:"modebar"},hovermode:{valType:"enumerated",values:["x","y","closest",!1],editType:"modebar"},hoverdistance:{valType:"integer",min:-1,dflt:20,editType:"none"},spikedistance:{valType:"integer",min:-1,dflt:20,editType:"none"},hoverlabel:{bgcolor:{valType:"color",editType:"none"},bordercolor:{valType:"color",editType:"none"},font:i,align:{valType:"enumerated",values:["left","right","auto"],dflt:"auto",editType:"none"},namelength:{valType:"integer",min:-1,dflt:15,editType:"none"},editType:"none"},selectdirection:{valType:"enumerated",values:["h","v","d","any"],dflt:"any",editType:"none"}}},{"../../plots/font_attributes":791,"./constants":625}],632:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}var o,s=a("clickmode");"select"===a("dragmode")&&a("selectdirection"),e._has("cartesian")?s.indexOf("select")>-1?o="closest":(e._isHoriz=function(t,e){for(var r=e._scatterStackOpts||{},n=0;n1){f||p||d||"independent"===C("pattern")&&(f=!0),m._hasSubplotGrid=f;var x,b,_="top to bottom"===C("roworder"),w=f?.2:.1,A=f?.3:.1;g&&e._splomGridDflt&&(x=e._splomGridDflt.xside,b=e._splomGridDflt.yside),m._domains={x:u("x",C,w,x,y),y:u("y",C,A,b,v,_)}}else delete e.grid}function C(t,e){return n.coerce(r,m,l,t,e)}},contentDefaults:function(t,e){var r=e.grid;if(r&&r._domains){var n,i,a,o,s,l,u,f=t.grid||{},p=e._subplots,d=r._hasSubplotGrid,g=r.rows,m=r.columns,v="independent"===r.pattern,y=r._axisMap={};if(d){var x=f.subplots||[];l=r.subplots=new Array(g);var b=1;for(n=0;n1);if(!1!==g||c.uirevision){var m=a.newContainer(e,"legend");if(_("uirevision",e.uirevision),!1!==g){_("bgcolor",e.paper_bgcolor),_("bordercolor"),_("borderwidth"),i.coerceFont(_,"font",e.font);var v,y,x,b=_("orientation");"h"===b?(v=0,n.getComponentMethod("rangeslider","isVisible")(t.xaxis)?(y=1.1,x="bottom"):(y=-.1,x="top")):(v=1.02,y=1,x="auto"),_("traceorder",f),l.isGrouped(e.legend)&&_("tracegroupgap"),_("itemsizing"),_("itemclick"),_("itemdoubleclick"),_("x",v),_("xanchor"),_("y",y),_("yanchor",x),_("valign"),i.noneOrAll(c,m,["x","y"]),_("title.text")&&(_("title.side","h"===b?"left":"top"),i.coerceFont(_,"title.font",e.font))}}function _(t,e){return i.coerce(c,m,o,t,e)}}},{"../../lib":717,"../../plot_api/plot_template":755,"../../plots/layout_attributes":817,"../../registry":846,"./attributes":640,"./helpers":646}],643:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib/events"),l=t("../dragelement"),c=t("../drawing"),u=t("../color"),h=t("../../lib/svg_text_utils"),f=t("./handle_click"),p=t("./constants"),d=t("../../constants/alignment"),g=d.LINE_SPACING,m=d.FROM_TL,v=d.FROM_BR,y=t("./get_legend_data"),x=t("./style"),b=t("./helpers");function _(t,e,r,n,i){var a=r.data()[0][0].trace,l={event:i,node:r.node(),curveNumber:a.index,expandedIndex:a._expandedIndex,data:t.data,layout:t.layout,frames:t._transitionData._frames,config:t._context,fullData:t._fullData,fullLayout:t._fullLayout};a._group&&(l.group=a._group),o.traceIs(a,"pie-like")&&(l.label=r.datum()[0].label),!1!==s.triggerHandler(t,"plotly_legendclick",l)&&(1===n?e._clickTimeout=setTimeout((function(){f(r,t,n)}),t._context.doubleClickDelay):2===n&&(e._clickTimeout&&clearTimeout(e._clickTimeout),t._legendMouseDownTime=0,!1!==s.triggerHandler(t,"plotly_legenddoubleclick",l)&&f(r,t,n)))}function w(t,e){var r=t.data()[0][0],n=e._fullLayout.legend,a=r.trace,s=o.traceIs(a,"pie-like"),l=a.index,u=e._context.edits.legendText&&!s,f=n._maxNameLength,d=s?r.label:a.name;a._meta&&(d=i.templateString(d,a._meta));var g=i.ensureSingle(t,"text","legendtext");g.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,n.font).text(u?A(d,f):d),h.positionText(g,p.textGap,0),u?g.call(h.makeEditable,{gd:e,text:d}).call(M,t,e).on("edit",(function(n){this.text(A(n,f)).call(M,t,e);var a=r.trace._fullInput||{},s={};if(o.hasTransform(a,"groupby")){var c=o.getTransformIndices(a,"groupby"),u=c[c.length-1],h=i.keyedContainer(a,"transforms["+u+"].styles","target","value.name");h.set(r.trace._group,n),s=h.constructUpdate()}else s.name=n;return o.call("_guiRestyle",e,s,l)})):M(g,t,e)}function A(t,e){var r=Math.max(4,e);if(t&&t.trim().length>=r/2)return t;for(var n=r-(t=t||"").length;n>0;n--)t+=" ";return t}function C(t,e){var r,a=e._context.doubleClickDelay,o=1,s=i.ensureSingle(t,"rect","legendtoggle",(function(t){t.style("cursor","pointer").attr("pointer-events","all").call(u.fill,"rgba(0,0,0,0)")}));s.on("mousedown",(function(){(r=(new Date).getTime())-e._legendMouseDownTimea&&(o=Math.max(o-1,1)),_(e,r,t,o,n.event)}}))}function M(t,e,r){h.convertToTspans(t,r,(function(){!function(t,e){var r=t.data()[0][0];if(!r||r.trace.showlegend){var n,i,a=t.select("g[class*=math-group]"),o=a.node(),s=e._fullLayout.legend.borderwidth,l=e._fullLayout.legend,u=(r?l:l.title).font.size*g;if(o){var f=c.bBox(o);n=f.height,i=f.width,r?c.setTranslate(a,0,.25*n):c.setTranslate(a,s,.75*n+s)}else{var d=t.select(r?".legendtext":".legendtitletext"),m=h.lineCount(d),v=d.node();n=u*m,i=v?c.bBox(v).width:0;var y=u*((m-1)/2-.3);r?h.positionText(d,p.textGap,-y):h.positionText(d,p.titlePad+s,u+s)}r?(r.lineHeight=u,r.height=Math.max(n,16)+3,r.width=i):(l._titleWidth=i,l._titleHeight=n)}else t.remove()}(e,r)}))}function k(t){return i.isRightAnchor(t)?"right":i.isCenterAnchor(t)?"center":"left"}function I(t){return i.isBottomAnchor(t)?"bottom":i.isMiddleAnchor(t)?"middle":"top"}e.exports=function(t){var e=t._fullLayout,r="legend"+e._uid;if(e._infolayer&&t.calcdata){t._legendMouseDownTime||(t._legendMouseDownTime=0);var s=e.legend,h=e.showlegend&&y(t.calcdata,s),f=e.hiddenlabels||[];if(!e.showlegend||!h.length)return e._infolayer.selectAll(".legend").remove(),e._topdefs.select("#"+r).remove(),a.autoMargin(t,"legend");var d=i.ensureSingle(e._infolayer,"g","legend",(function(t){t.attr("pointer-events","all")})),g=i.ensureSingleById(e._topdefs,"clipPath",r,(function(t){t.append("rect")})),A=i.ensureSingle(d,"rect","bg",(function(t){t.attr("shape-rendering","crispEdges")}));A.call(u.stroke,s.bordercolor).call(u.fill,s.bgcolor).style("stroke-width",s.borderwidth+"px");var T=i.ensureSingle(d,"g","scrollbox"),L=s.title;if(s._titleWidth=0,s._titleHeight=0,L.text){var S=i.ensureSingle(T,"text","legendtitletext");S.attr("text-anchor","start").classed("user-select-none",!0).call(c.font,L.font).text(L.text),M(S,T,t)}var E=i.ensureSingle(d,"rect","scrollbar",(function(t){t.attr(p.scrollBarEnterAttrs).call(u.fill,p.scrollBarColor)})),D=T.selectAll("g.groups").data(h);D.enter().append("g").attr("class","groups"),D.exit().remove();var P=D.selectAll("g.traces").data(i.identity);P.enter().append("g").attr("class","traces"),P.exit().remove(),P.style("opacity",(function(t){var e=t[0].trace;return o.traceIs(e,"pie-like")?-1!==f.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1})).each((function(){n.select(this).call(w,t)})).call(x,t).each((function(){n.select(this).call(C,t)})),i.syncOrAsync([a.previousPromises,function(){return function(t,e,r){var i=t._fullLayout,a=i.legend,o=i._size,s=b.isVertical(a),l=b.isGrouped(a),u=a.borderwidth,h=2*u,f=p.textGap,d=p.itemGap,g=2*(u+d),m=I(a),v=a.y<0||0===a.y&&"top"===m,y=a.y>1||1===a.y&&"bottom"===m;a._maxHeight=Math.max(v||y?i.height/2:o.h,30);var x=0;a._width=0,a._height=0;var _=function(t){var e=0,r=0,n=t.title.side;return n&&(-1!==n.indexOf("left")&&(e=t._titleWidth),-1!==n.indexOf("top")&&(r=t._titleHeight)),[e,r]}(a);if(s)r.each((function(t){var e=t[0].height;c.setTranslate(this,u+_[0],u+_[1]+a._height+e/2+d),a._height+=e,a._width=Math.max(a._width,t[0].width)})),x=f+a._width,a._width+=d+f+h,a._height+=g,l&&(e.each((function(t,e){c.setTranslate(this,0,e*a.tracegroupgap)})),a._height+=(a._lgroupsLength-1)*a.tracegroupgap);else{var w=k(a),A=a.x<0||0===a.x&&"right"===w,C=a.x>1||1===a.x&&"left"===w,M=y||v,T=i.width/2;a._maxWidth=Math.max(A?M&&"left"===w?o.l+o.w:T:C?M&&"right"===w?o.r+o.w:T:o.w,2*f);var L=0,S=0;r.each((function(t){var e=t[0].width+f;L=Math.max(L,e),S+=e})),x=null;var E=0;if(l){var D=0,P=0,O=0;e.each((function(){var t=0,e=0;n.select(this).selectAll("g.traces").each((function(r){var n=r[0].height;c.setTranslate(this,_[0],_[1]+u+d+n/2+e),e+=n,t=Math.max(t,f+r[0].width)})),D=Math.max(D,e);var r=t+d;r+u+P>a._maxWidth&&(E=Math.max(E,P),P=0,O+=D+a.tracegroupgap,D=e),c.setTranslate(this,P,O),P+=r})),a._width=Math.max(E,P)+u,a._height=O+D+g}else{var z=r.size(),R=S+h+(z-1)*da._maxWidth&&(E=Math.max(E,B),N=0,j+=F,a._height+=F,F=0),c.setTranslate(this,_[0]+u+N,_[1]+u+j+e/2+d),B=N+r+d,N+=n,F=Math.max(F,e)})),R?(a._width=N+h,a._height=F+g):(a._width=Math.max(E,B)+h,a._height+=F+g)}}a._width=Math.ceil(Math.max(a._width+_[0],a._titleWidth+2*(u+p.titlePad))),a._height=Math.ceil(Math.max(a._height+_[1],a._titleHeight+2*(u+p.itemGap))),a._effHeight=Math.min(a._height,a._maxHeight);var Y=t._context.edits,V=Y.legendText||Y.legendPosition;r.each((function(t){var e=n.select(this).select(".legendtoggle"),r=t[0].height,i=V?f:x||f+t[0].width;s||(i+=d/2),c.setRect(e,0,-r/2,i,r)}))}(t,D,P)},function(){if(!function(t){var e=t._fullLayout.legend,r=k(e),n=I(e);return a.autoMargin(t,"legend",{x:e.x,y:e.y,l:e._width*m[r],r:e._width*v[r],b:e._effHeight*v[n],t:e._effHeight*m[n]})}(t)){var u,h,f,y,x=e._size,b=s.borderwidth,w=x.l+x.w*s.x-m[k(s)]*s._width,C=x.t+x.h*(1-s.y)-m[I(s)]*s._effHeight;if(e.margin.autoexpand){var M=w,L=C;w=i.constrain(w,0,e.width-s._width),C=i.constrain(C,0,e.height-s._effHeight),w!==M&&i.log("Constrain legend.x to make legend fit inside graph"),C!==L&&i.log("Constrain legend.y to make legend fit inside graph")}if(c.setTranslate(d,w,C),E.on(".drag",null),d.on("wheel",null),s._height<=s._maxHeight||t._context.staticPlot)A.attr({width:s._width-b,height:s._effHeight-b,x:b/2,y:b/2}),c.setTranslate(T,0,0),g.select("rect").attr({width:s._width-2*b,height:s._effHeight-2*b,x:b,y:b}),c.setClipUrl(T,r,t),c.setRect(E,0,0,0,0),delete s._scrollY;else{var S,D,P,O=Math.max(p.scrollBarMinHeight,s._effHeight*s._effHeight/s._height),z=s._effHeight-O-2*p.scrollBarMargin,R=s._height-s._effHeight,F=z/R,N=Math.min(s._scrollY||0,R);A.attr({width:s._width-2*b+p.scrollBarWidth+p.scrollBarMargin,height:s._effHeight-b,x:b/2,y:b/2}),g.select("rect").attr({width:s._width-2*b+p.scrollBarWidth+p.scrollBarMargin,height:s._effHeight-2*b,x:b,y:b+N}),c.setClipUrl(T,r,t),Y(N,O,F),d.on("wheel",(function(){Y(N=i.constrain(s._scrollY+n.event.deltaY/z*R,0,R),O,F),0!==N&&N!==R&&n.event.preventDefault()}));var j=n.behavior.drag().on("dragstart",(function(){var t=n.event.sourceEvent;S="touchstart"===t.type?t.changedTouches[0].clientY:t.clientY,P=N})).on("drag",(function(){var t=n.event.sourceEvent;2===t.buttons||t.ctrlKey||(D="touchmove"===t.type?t.changedTouches[0].clientY:t.clientY,Y(N=function(t,e,r){var n=(r-e)/F+t;return i.constrain(n,0,R)}(P,S,D),O,F))}));E.call(j);var B=n.behavior.drag().on("dragstart",(function(){var t=n.event.sourceEvent;"touchstart"===t.type&&(S=t.changedTouches[0].clientY,P=N)})).on("drag",(function(){var t=n.event.sourceEvent;"touchmove"===t.type&&(D=t.changedTouches[0].clientY,Y(N=function(t,e,r){var n=(e-r)/F+t;return i.constrain(n,0,R)}(P,S,D),O,F))}));T.call(B)}t._context.edits.legendPosition&&(d.classed("cursor-move",!0),l.init({element:d.node(),gd:t,prepFn:function(){var t=c.getTranslate(d);f=t.x,y=t.y},moveFn:function(t,e){var r=f+t,n=y+e;c.setTranslate(d,r,n),u=l.align(r,0,x.l,x.l+x.w,s.xanchor),h=l.align(n,0,x.t+x.h,x.t,s.yanchor)},doneFn:function(){void 0!==u&&void 0!==h&&o.call("_guiRelayout",t,{"legend.x":u,"legend.y":h})},clickFn:function(r,n){var i=e._infolayer.selectAll("g.traces").filter((function(){var t=this.getBoundingClientRect();return n.clientX>=t.left&&n.clientX<=t.right&&n.clientY>=t.top&&n.clientY<=t.bottom}));i.size()>0&&_(t,d,i,r,n)}}))}function Y(e,r,n){s._scrollY=t._fullLayout.legend._scrollY=e,c.setTranslate(T,0,-e),c.setRect(E,s._width,p.scrollBarMargin+e*n,p.scrollBarWidth,r),g.select("rect").attr("y",b+e)}}],t)}}},{"../../constants/alignment":686,"../../lib":717,"../../lib/events":707,"../../lib/svg_text_utils":741,"../../plots/plots":826,"../../registry":846,"../color":592,"../dragelement":610,"../drawing":613,"./constants":641,"./get_legend_data":644,"./handle_click":645,"./helpers":646,"./style":648,d3:165}],644:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("./helpers");e.exports=function(t,e){var r,a,o={},s=[],l=!1,c={},u=0,h=0;function f(t,r){if(""!==t&&i.isGrouped(e))-1===s.indexOf(t)?(s.push(t),l=!0,o[t]=[[r]]):o[t].push([r]);else{var n="~~i"+u;s.push(n),o[n]=[[r]],u++}}for(r=0;r0))return 0;i=e.width}return y?n:Math.min(i,r)};function b(t,e,r){var a=t[0].trace,o=a.marker||{},l=o.line||{},c=r?a.visible&&a.type===r:i.traceIs(a,"bar"),u=n.select(e).select("g.legendpoints").selectAll("path.legend"+r).data(c?[t]:[]);u.enter().append("path").classed("legend"+r,!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),u.exit().remove(),u.each((function(t){var e=n.select(this),r=t[0],i=x(r.mlw,o.line,m,d);e.style("stroke-width",i+"px").call(s.fill,r.mc||o.color),i&&s.stroke(e,r.mlc||l.color)}))}function _(t,e,r){var o=t[0],s=o.trace,l=r?s.visible&&s.type===r:i.traceIs(s,r),c=n.select(e).select("g.legendpoints").selectAll("path.legend"+r).data(l?[t]:[]);if(c.enter().append("path").classed("legend"+r,!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),c.exit().remove(),c.size()){var f=(s.marker||{}).line,p=x(h(f.width,o.pts),f,m,d),g=a.minExtend(s,{marker:{line:{width:p}}});g.marker.line.color=f.color;var v=a.minExtend(o,{trace:g});u(c,v,g)}}t.each((function(t){var e=n.select(this),i=a.ensureSingle(e,"g","layers");i.style("opacity",t[0].trace.opacity);var o=r.valign,s=t[0].lineHeight,l=t[0].height;if("middle"!==o&&s&&l){var c={top:1,bottom:-1}[o]*(.5*(s-l+3));i.attr("transform","translate(0,"+c+")")}else i.attr("transform",null);i.selectAll("g.legendfill").data([t]).enter().append("g").classed("legendfill",!0),i.selectAll("g.legendlines").data([t]).enter().append("g").classed("legendlines",!0);var u=i.selectAll("g.legendsymbols").data([t]);u.enter().append("g").classed("legendsymbols",!0),u.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)})).each((function(t){var r,i=t[0].trace,c=[];if(i.visible)switch(i.type){case"histogram2d":case"heatmap":c=[["M-15,-2V4H15V-2Z"]],r=!0;break;case"choropleth":case"choroplethmapbox":c=[["M-6,-6V6H6V-6Z"]],r=!0;break;case"densitymapbox":c=[["M-6,0 a6,6 0 1,0 12,0 a 6,6 0 1,0 -12,0"]],r="radial";break;case"cone":c=[["M-6,2 A2,2 0 0,0 -6,6 V6L6,4Z"],["M-6,-6 A2,2 0 0,0 -6,-2 L6,-4Z"],["M-6,-2 A2,2 0 0,0 -6,2 L6,0Z"]],r=!1;break;case"streamtube":c=[["M-6,2 A2,2 0 0,0 -6,6 H6 A2,2 0 0,1 6,2 Z"],["M-6,-6 A2,2 0 0,0 -6,-2 H6 A2,2 0 0,1 6,-6 Z"],["M-6,-2 A2,2 0 0,0 -6,2 H6 A2,2 0 0,1 6,-2 Z"]],r=!1;break;case"surface":c=[["M-6,-6 A2,3 0 0,0 -6,0 H6 A2,3 0 0,1 6,-6 Z"],["M-6,1 A2,3 0 0,1 -6,6 H6 A2,3 0 0,0 6,0 Z"]],r=!0;break;case"mesh3d":c=[["M-6,6H0L-6,-6Z"],["M6,6H0L6,-6Z"],["M-6,-6H6L0,6Z"]],r=!1;break;case"volume":c=[["M-6,6H0L-6,-6Z"],["M6,6H0L6,-6Z"],["M-6,-6H6L0,6Z"]],r=!0;break;case"isosurface":c=[["M-6,6H0L-6,-6Z"],["M6,6H0L6,-6Z"],["M-6,-6 A12,24 0 0,0 6,-6 L0,6Z"]],r=!1}var u=n.select(this).select("g.legendpoints").selectAll("path.legend3dandfriends").data(c);u.enter().append("path").classed("legend3dandfriends",!0).attr("transform","translate(20,0)").style("stroke-miterlimit",1),u.exit().remove(),u.each((function(t,c){var u,h=n.select(this),f=l(i),p=f.colorscale,d=f.reversescale;if(p){if(!r){var g=p.length;u=0===c?p[d?g-1:0][1]:1===c?p[d?0:g-1][1]:p[Math.floor((g-1)/2)][1]}}else{var m=i.vertexcolor||i.facecolor||i.color;u=a.isArrayOrTypedArray(m)?m[c]||m[0]:m}h.attr("d",t[0]),u?h.call(s.fill,u):h.call((function(t){if(t.size()){var n="legendfill-"+i.uid;o.gradient(t,e,n,v(d,"radial"===r),p,"fill")}}))}))})).each((function(t){var e=t[0].trace,r=[];e.visible&&"waterfall"===e.type&&(r=t[0].hasTotals?[["increasing","M-6,-6V6H0Z"],["totals","M6,6H0L-6,-6H-0Z"],["decreasing","M6,6V-6H0Z"]]:[["increasing","M-6,-6V6H6Z"],["decreasing","M6,6V-6H-6Z"]]);var i=n.select(this).select("g.legendpoints").selectAll("path.legendwaterfall").data(r);i.enter().append("path").classed("legendwaterfall",!0).attr("transform","translate(20,0)").style("stroke-miterlimit",1),i.exit().remove(),i.each((function(t){var r=n.select(this),i=e[t[0]].marker,a=x(void 0,i.line,m,d);r.attr("d",t[1]).style("stroke-width",a+"px").call(s.fill,i.color),a&&r.call(s.stroke,i.line.color)}))})).each((function(t){b(t,this,"funnel")})).each((function(t){b(t,this)})).each((function(t){var r=t[0].trace,l=n.select(this).select("g.legendpoints").selectAll("path.legendbox").data(r.visible&&i.traceIs(r,"box-violin")?[t]:[]);l.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),l.exit().remove(),l.each((function(){var t=n.select(this);if("all"!==r.boxpoints&&"all"!==r.points||0!==s.opacity(r.fillcolor)||0!==s.opacity((r.line||{}).color)){var i=x(void 0,r.line,m,d);t.style("stroke-width",i+"px").call(s.fill,r.fillcolor),i&&s.stroke(t,r.line.color)}else{var c=a.minExtend(r,{marker:{size:y?f:a.constrain(r.marker.size,2,16),sizeref:1,sizemin:1,sizemode:"diameter"}});l.call(o.pointStyle,c,e)}}))})).each((function(t){_(t,this,"funnelarea")})).each((function(t){_(t,this,"pie")})).each((function(t){var r,i,s=t[0],u=s.trace,h=u.visible&&u.fill&&"none"!==u.fill,f=c.hasLines(u),d=u.contours,m=!1,y=!1,b=l(u),_=b.colorscale,w=b.reversescale;if(d){var A=d.coloring;"lines"===A?m=!0:f="none"===A||"heatmap"===A||d.showlines,"constraint"===d.type?h="="!==d._operation:"fill"!==A&&"heatmap"!==A||(y=!0)}var C=c.hasMarkers(u)||c.hasText(u),M=h||y,k=f||m,I=C||!M?"M5,0":k?"M5,-2":"M5,-3",T=n.select(this),L=T.select(".legendfill").selectAll("path").data(h||y?[t]:[]);if(L.enter().append("path").classed("js-fill",!0),L.exit().remove(),L.attr("d",I+"h30v6h-30z").call(h?o.fillGroupStyle:function(t){if(t.size()){var r="legendfill-"+u.uid;o.gradient(t,e,r,v(w),_,"fill")}}),f||m){var S=x(void 0,u.line,g,p);i=a.minExtend(u,{line:{width:S}}),r=[a.minExtend(s,{trace:i})]}var E=T.select(".legendlines").selectAll("path").data(f||m?[r]:[]);E.enter().append("path").classed("js-line",!0),E.exit().remove(),E.attr("d",I+(m?"l30,0.0001":"h30")).call(f?o.lineGroupStyle:function(t){if(t.size()){var r="legendline-"+u.uid;o.lineGroupStyle(t),o.gradient(t,e,r,v(w),_,"stroke")}})})).each((function(t){var r,i,s=t[0],l=s.trace,u=c.hasMarkers(l),h=c.hasText(l),g=c.hasLines(l);function m(t,e,r,n){var i=a.nestedProperty(l,t).get(),o=a.isArrayOrTypedArray(i)&&e?e(i):i;if(y&&o&&void 0!==n&&(o=n),r){if(or[1])return r[1]}return o}function v(t){return t[0]}if(u||h||g){var x={},b={};if(u){x.mc=m("marker.color",v),x.mx=m("marker.symbol",v),x.mo=m("marker.opacity",a.mean,[.2,1]),x.mlc=m("marker.line.color",v),x.mlw=m("marker.line.width",a.mean,[0,5],d),b.marker={sizeref:1,sizemin:1,sizemode:"diameter"};var _=m("marker.size",a.mean,[2,16],f);x.ms=_,b.marker.size=_}g&&(b.line={width:m("line.width",v,[0,10],p)}),h&&(x.tx="Aa",x.tp=m("textposition",v),x.ts=10,x.tc=m("textfont.color",v),x.tf=m("textfont.family",v)),r=[a.minExtend(s,x)],(i=a.minExtend(l,b)).selectedpoints=null,i.texttemplate=null}var w=n.select(this).select("g.legendpoints"),A=w.selectAll("path.scatterpts").data(u?r:[]);A.enter().insert("path",":first-child").classed("scatterpts",!0).attr("transform","translate(20,0)"),A.exit().remove(),A.call(o.pointStyle,i,e),u&&(r[0].mrc=3);var C=w.selectAll("g.pointtext").data(h?r:[]);C.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),C.exit().remove(),C.selectAll("text").call(o.textPointStyle,i,e)})).each((function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendcandle").data(e.visible&&"candlestick"===e.type?[t,t]:[]);r.enter().append("path").classed("legendcandle",!0).attr("d",(function(t,e){return e?"M-15,0H-8M-8,6V-6H8Z":"M15,0H8M8,-6V6H-8Z"})).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each((function(t,r){var i=n.select(this),a=e[r?"increasing":"decreasing"],o=x(void 0,a.line,m,d);i.style("stroke-width",o+"px").call(s.fill,a.fillcolor),o&&s.stroke(i,a.line.color)}))})).each((function(t){var e=t[0].trace,r=n.select(this).select("g.legendpoints").selectAll("path.legendohlc").data(e.visible&&"ohlc"===e.type?[t,t]:[]);r.enter().append("path").classed("legendohlc",!0).attr("d",(function(t,e){return e?"M-15,0H0M-8,-6V0":"M15,0H0M8,6V0"})).attr("transform","translate(20,0)").style("stroke-miterlimit",1),r.exit().remove(),r.each((function(t,r){var i=n.select(this),a=e[r?"increasing":"decreasing"],l=x(void 0,a.line,m,d);i.style("fill","none").call(o.dashLine,a.line.dash,l),l&&s.stroke(i,a.line.color)}))}))}},{"../../lib":717,"../../registry":846,"../../traces/pie/helpers":1099,"../../traces/pie/style_one":1105,"../../traces/scatter/subtypes":1144,"../color":592,"../colorscale/helpers":603,"../drawing":613,d3:165}],649:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axis_ids"),o=t("../../lib"),s=t("../../fonts/ploticon"),l=o._,c=e.exports={};function u(t,e){var r,i,o=e.currentTarget,s=o.getAttribute("data-attr"),l=o.getAttribute("data-val")||!0,c=t._fullLayout,u={},h=a.list(t,null,!0),f=c._cartesianSpikesEnabled;if("zoom"===s){var p,d="in"===l?.5:2,g=(1+d)/2,m=(1-d)/2;for(i=0;i1?(M=["toggleHover"],k=["resetViews"]):f?(C=["zoomInGeo","zoomOutGeo"],M=["hoverClosestGeo"],k=["resetGeo"]):h?(M=["hoverClosest3d"],k=["resetCameraDefault3d","resetCameraLastSave3d"]):v?(C=["zoomInMapbox","zoomOutMapbox"],M=["toggleHover"],k=["resetViewMapbox"]):g?M=["hoverClosestGl2d"]:p?M=["hoverClosestPie"]:x?(M=["hoverClosestCartesian","hoverCompareCartesian"],k=["resetViewSankey"]):M=["toggleHover"],u&&(M=["toggleSpikelines","hoverClosestCartesian","hoverCompareCartesian"]),function(t){for(var e=0;e0)){var g=function(t,e,r){for(var n=r.filter((function(r){return e[r].anchor===t._id})),i=0,a=0;a0?f+c:c;return{ppad:c,ppadplus:u?d:g,ppadminus:u?g:d}}return{ppad:c}}function u(t,e,r,n,i){var s="category"===t.type||"multicategory"===t.type?t.r2c:t.d2c;if(void 0!==e)return[s(e),s(r)];if(n){var l,c,u,h,f=1/0,p=-1/0,d=n.match(a.segmentRE);for("date"===t.type&&(s=o.decodeDate(s)),l=0;lp&&(p=h)));return p>=f?[f,p]:void 0}}e.exports=function(t){var e=t._fullLayout,r=n.filterVisible(e.shapes);if(r.length&&t._fullData.length)for(var o=0;o10?t/2:10;return n.append("circle").attr({"data-line-point":"start-point",cx:z?U(r.xanchor)+r.x0:U(r.x0),cy:R?H(r.yanchor)-r.y0:H(r.y0),r:a}).style(i).classed("cursor-grab",!0),n.append("circle").attr({"data-line-point":"end-point",cx:z?U(r.xanchor)+r.x1:U(r.x1),cy:R?H(r.yanchor)-r.y1:H(r.y1),r:a}).style(i).classed("cursor-grab",!0),n}():e,Z={element:W.node(),gd:t,prepFn:function(n){z&&(_=U(r.xanchor)),R&&(w=H(r.yanchor)),"path"===r.type?E=r.path:(v=z?r.x0:U(r.x0),y=R?r.y0:H(r.y0),x=z?r.x1:U(r.x1),b=R?r.y1:H(r.y1)),vb?(A=y,I="y0",C=b,T="y1"):(A=b,I="y1",C=y,T="y0"),X(n),Q(p,r),function(t,e,r){var n=e.xref,i=e.yref,o=a.getFromId(r,n),l=a.getFromId(r,i),c="";"paper"===n||o.autorange||(c+=n),"paper"===i||l.autorange||(c+=i),s.setClipUrl(t,c?"clip"+r._fullLayout._uid+c:null,r)}(e,r,t),Z.moveFn="move"===D?J:K},doneFn:function(){u(e),$(p),d(e,t,r),n.call("_guiRelayout",t,j.getUpdateObj())},clickFn:function(){$(p)}};function X(t){if(F)D="path"===t.target.tagName?"move":"start-point"===t.target.attributes["data-line-point"].value?"resize-over-start-point":"resize-over-end-point";else{var r=Z.element.getBoundingClientRect(),n=r.right-r.left,i=r.bottom-r.top,a=t.clientX-r.left,o=t.clientY-r.top,s=!N&&n>P&&i>O&&!t.shiftKey?c.getCursor(a/n,1-o/i):"move";u(e,s),D=s.split("-")[0]}}function J(n,i){if("path"===r.type){var a=function(t){return t},o=a,s=a;z?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(U(t)+n)},Y&&"date"===Y.type&&(o=f.encodeDate(o))),R?B("yanchor",r.yanchor=q(w+i)):(s=function(t){return q(H(t)+i)},V&&"date"===V.type&&(s=f.encodeDate(s))),B("path",r.path=m(E,o,s))}else z?B("xanchor",r.xanchor=G(_+n)):(B("x0",r.x0=G(v+n)),B("x1",r.x1=G(x+n))),R?B("yanchor",r.yanchor=q(w+i)):(B("y0",r.y0=q(y+i)),B("y1",r.y1=q(b+i)));e.attr("d",g(t,r)),Q(p,r)}function K(n,i){if(N){var a=function(t){return t},o=a,s=a;z?B("xanchor",r.xanchor=G(_+n)):(o=function(t){return G(U(t)+n)},Y&&"date"===Y.type&&(o=f.encodeDate(o))),R?B("yanchor",r.yanchor=q(w+i)):(s=function(t){return q(H(t)+i)},V&&"date"===V.type&&(s=f.encodeDate(s))),B("path",r.path=m(E,o,s))}else if(F){if("resize-over-start-point"===D){var l=v+n,c=R?y-i:y+i;B("x0",r.x0=z?l:G(l)),B("y0",r.y0=R?c:q(c))}else if("resize-over-end-point"===D){var u=x+n,h=R?b-i:b+i;B("x1",r.x1=z?u:G(u)),B("y1",r.y1=R?h:q(h))}}else{var d=~D.indexOf("n")?A+i:A,j=~D.indexOf("s")?C+i:C,W=~D.indexOf("w")?M+n:M,Z=~D.indexOf("e")?k+n:k;~D.indexOf("n")&&R&&(d=A-i),~D.indexOf("s")&&R&&(j=C-i),(!R&&j-d>O||R&&d-j>O)&&(B(I,r[I]=R?d:q(d)),B(T,r[T]=R?j:q(j))),Z-W>P&&(B(L,r[L]=z?W:G(W)),B(S,r[S]=z?Z:G(Z)))}e.attr("d",g(t,r)),Q(p,r)}function Q(t,e){(z||R)&&function(){var r="path"!==e.type,n=t.selectAll(".visual-cue").data([0]);n.enter().append("path").attr({fill:"#fff","fill-rule":"evenodd",stroke:"#000","stroke-width":1}).classed("visual-cue",!0);var a=U(z?e.xanchor:i.midRange(r?[e.x0,e.x1]:f.extractPathCoords(e.path,h.paramIsX))),o=H(R?e.yanchor:i.midRange(r?[e.y0,e.y1]:f.extractPathCoords(e.path,h.paramIsY)));if(a=f.roundPositionForSharpStrokeRendering(a,1),o=f.roundPositionForSharpStrokeRendering(o,1),z&&R){var s="M"+(a-1-1)+","+(o-1-1)+"h-8v2h8 v8h2v-8 h8v-2h-8 v-8h-2 Z";n.attr("d",s)}else if(z){var l="M"+(a-1-1)+","+(o-9-1)+"v18 h2 v-18 Z";n.attr("d",l)}else{var c="M"+(a-9-1)+","+(o-1-1)+"h18 v2 h-18 Z";n.attr("d",c)}}()}function $(t){t.selectAll(".visual-cue").remove()}c.init(Z),W.node().onmousemove=X}(t,x,r,e,p)}}function d(t,e,r){var n=(r.xref+r.yref).replace(/paper/g,"");s.setClipUrl(t,n?"clip"+e._fullLayout._uid+n:null,e)}function g(t,e){var r,n,o,s,l,c,u,p,d=e.type,g=a.getFromId(t,e.xref),m=a.getFromId(t,e.yref),v=t._fullLayout._size;if(g?(r=f.shapePositionToRange(g),n=function(t){return g._offset+g.r2p(r(t,!0))}):n=function(t){return v.l+v.w*t},m?(o=f.shapePositionToRange(m),s=function(t){return m._offset+m.r2p(o(t,!0))}):s=function(t){return v.t+v.h*(1-t)},"path"===d)return g&&"date"===g.type&&(n=f.decodeDate(n)),m&&"date"===m.type&&(s=f.decodeDate(s)),function(t,e,r){var n=t.path,a=t.xsizemode,o=t.ysizemode,s=t.xanchor,l=t.yanchor;return n.replace(h.segmentRE,(function(t){var n=0,c=t.charAt(0),u=h.paramIsX[c],f=h.paramIsY[c],p=h.numParams[c],d=t.substr(1).replace(h.paramRE,(function(t){return u[n]?t="pixel"===a?e(s)+Number(t):e(t):f[n]&&(t="pixel"===o?r(l)-Number(t):r(t)),++n>p&&(t="X"),t}));return n>p&&(d=d.replace(/[\s,]*X.*/,""),i.log("Ignoring extra params in segment "+t)),c+d}))}(e,n,s);if("pixel"===e.xsizemode){var y=n(e.xanchor);l=y+e.x0,c=y+e.x1}else l=n(e.x0),c=n(e.x1);if("pixel"===e.ysizemode){var x=s(e.yanchor);u=x-e.y0,p=x-e.y1}else u=s(e.y0),p=s(e.y1);if("line"===d)return"M"+l+","+u+"L"+c+","+p;if("rect"===d)return"M"+l+","+u+"H"+c+"V"+p+"H"+l+"Z";var b=(l+c)/2,_=(u+p)/2,w=Math.abs(b-l),A=Math.abs(_-u),C="A"+w+","+A,M=b+w+","+_;return"M"+M+C+" 0 1,1 "+b+","+(_-A)+C+" 0 0,1 "+M+"Z"}function m(t,e,r){return t.replace(h.segmentRE,(function(t){var n=0,i=t.charAt(0),a=h.paramIsX[i],o=h.paramIsY[i],s=h.numParams[i];return i+t.substr(1).replace(h.paramRE,(function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)}))}))}e.exports={draw:function(t){var e=t._fullLayout;for(var r in e._shapeUpperLayer.selectAll("path").remove(),e._shapeLowerLayer.selectAll("path").remove(),e._plots){var n=e._plots[r].shapelayer;n&&n.selectAll("path").remove()}for(var i=0;i0&&(s=s.transition().duration(e.transition.duration).ease(e.transition.easing)),s.attr("transform","translate("+(o-.5*u.gripWidth)+","+e._dims.currentValueTotalHeight+")")}}function I(t,e){var r=t._dims;return r.inputAreaStart+u.stepInset+(r.inputAreaLength-2*u.stepInset)*Math.min(1,Math.max(0,e))}function T(t,e){var r=t._dims;return Math.min(1,Math.max(0,(e-u.stepInset-r.inputAreaStart)/(r.inputAreaLength-2*u.stepInset-2*r.inputAreaStart)))}function L(t,e,r){var n=r._dims,i=s.ensureSingle(t,"rect",u.railTouchRectClass,(function(n){n.call(C,e,t,r).style("pointer-events","all")}));i.attr({width:n.inputAreaLength,height:Math.max(n.inputAreaWidth,u.tickOffset+r.ticklen+n.labelHeight)}).call(a.fill,r.bgcolor).attr("opacity",0),o.setTranslate(i,0,n.currentValueTotalHeight)}function S(t,e){var r=e._dims,n=r.inputAreaLength-2*u.railInset,i=s.ensureSingle(t,"rect",u.railRectClass);i.attr({width:n,height:u.railWidth,rx:u.railRadius,ry:u.railRadius,"shape-rendering":"crispEdges"}).call(a.stroke,e.bordercolor).call(a.fill,e.bgcolor).style("stroke-width",e.borderwidth+"px"),o.setTranslate(i,u.railInset,.5*(r.inputAreaWidth-u.railWidth)+r.currentValueTotalHeight)}e.exports=function(t){var e=t._fullLayout,r=function(t,e){for(var r=t[u.name],n=[],i=0;i0?[0]:[]);function s(e){e._commandObserver&&(e._commandObserver.remove(),delete e._commandObserver),i.autoMargin(t,g(e))}if(a.enter().append("g").classed(u.containerClassName,!0).style("cursor","ew-resize"),a.exit().each((function(){n.select(this).selectAll("g."+u.groupClassName).each(s)})).remove(),0!==r.length){var l=a.selectAll("g."+u.groupClassName).data(r,m);l.enter().append("g").classed(u.groupClassName,!0),l.exit().each(s).remove();for(var c=0;c0||h<0){var m={left:[-p,0],right:[p,0],top:[0,-p],bottom:[0,p]}[x.side];e.attr("transform","translate("+m+")")}}}return O.call(z),D&&(I?O.on(".opacity",null):(C=0,M=!0,O.text(v).on("mouseover.opacity",(function(){n.select(this).transition().duration(h.SHOW_PLACEHOLDER).style("opacity",1)})).on("mouseout.opacity",(function(){n.select(this).transition().duration(h.HIDE_PLACEHOLDER).style("opacity",0)}))),O.call(u.makeEditable,{gd:t}).on("edit",(function(e){void 0!==y?o.call("_guiRestyle",t,m,e,y):o.call("_guiRelayout",t,m,e)})).on("cancel",(function(){this.text(this.attr("data-unformatted")).call(z)})).on("input",(function(t){this.text(t||" ").call(u.positionText,b.x,b.y)}))),O.classed("js-placeholder",M),w}}},{"../../constants/alignment":686,"../../constants/interactions":692,"../../lib":717,"../../lib/svg_text_utils":741,"../../plots/plots":826,"../../registry":846,"../color":592,"../drawing":613,d3:165,"fast-isnumeric":228}],680:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o=t("../../plot_api/edit_types").overrideAll,s=t("../../plots/pad_attributes"),l=t("../../plot_api/plot_template").templatedArray,c=l("button",{visible:{valType:"boolean"},method:{valType:"enumerated",values:["restyle","relayout","animate","update","skip"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},args2:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""},execute:{valType:"boolean",dflt:!0}});e.exports=o(l("updatemenu",{_arrayAttrRegexps:[/^updatemenus\[(0|[1-9][0-9]+)\]\.buttons/],visible:{valType:"boolean"},type:{valType:"enumerated",values:["dropdown","buttons"],dflt:"dropdown"},direction:{valType:"enumerated",values:["left","right","up","down"],dflt:"down"},active:{valType:"integer",min:-1,dflt:0},showactive:{valType:"boolean",dflt:!0},buttons:c,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"top"},pad:a(s({editType:"arraydraw"}),{}),font:n({}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1,editType:"arraydraw"}}),"arraydraw","from-root")},{"../../lib/extend":708,"../../plot_api/edit_types":748,"../../plot_api/plot_template":755,"../../plots/font_attributes":791,"../../plots/pad_attributes":825,"../color/attributes":591}],681:[function(t,e,r){"use strict";e.exports={name:"updatemenus",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",dropdownButtonGroupClassName:"updatemenu-dropdown-button-group",dropdownButtonClassName:"updatemenu-dropdown-button",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:24,arrowPadX:16,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF",arrowSymbol:{left:"◄",right:"►",up:"▲",down:"▼"}}},{}],682:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/array_container_defaults"),a=t("./attributes"),o=t("./constants").name,s=a.buttons;function l(t,e,r){function o(r,i){return n.coerce(t,e,a,r,i)}o("visible",i(t,e,{name:"buttons",handleItemDefaults:c}).length>0)&&(o("active"),o("direction"),o("type"),o("showactive"),o("x"),o("y"),n.noneOrAll(t,e,["x","y"]),o("xanchor"),o("yanchor"),o("pad.t"),o("pad.r"),o("pad.b"),o("pad.l"),n.coerceFont(o,"font",r.font),o("bgcolor",r.paper_bgcolor),o("bordercolor"),o("borderwidth"))}function c(t,e){function r(r,i){return n.coerce(t,e,s,r,i)}r("visible","skip"===t.method||Array.isArray(t.args))&&(r("method"),r("args"),r("args2"),r("label"),r("execute"))}e.exports=function(t,e){i(t,e,{name:o,handleItemDefaults:l})}},{"../../lib":717,"../../plots/array_container_defaults":761,"./attributes":680,"./constants":681}],683:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/plots"),a=t("../color"),o=t("../drawing"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../../plot_api/plot_template").arrayEditor,u=t("../../constants/alignment").LINE_SPACING,h=t("./constants"),f=t("./scrollbox");function p(t){return t._index}function d(t,e){return+t.attr(h.menuIndexAttrName)===e._index}function g(t,e,r,n,i,a,o,s){e.active=o,c(t.layout,h.name,e).applyUpdate("active",o),"buttons"===e.type?v(t,n,null,null,e):"dropdown"===e.type&&(i.attr(h.menuIndexAttrName,"-1"),m(t,n,i,a,e),s||v(t,n,i,a,e))}function m(t,e,r,n,i){var a=s.ensureSingle(e,"g",h.headerClassName,(function(t){t.style("pointer-events","all")})),l=i._dims,c=i.active,u=i.buttons[c]||h.blankHeaderOpts,f={y:i.pad.t,yPad:0,x:i.pad.l,xPad:0,index:0},p={width:l.headerWidth,height:l.headerHeight};a.call(y,i,u,t).call(k,i,f,p),s.ensureSingle(e,"text",h.headerArrowClassName,(function(t){t.classed("user-select-none",!0).attr("text-anchor","end").call(o.font,i.font).text(h.arrowSymbol[i.direction])})).attr({x:l.headerWidth-h.arrowOffsetX+i.pad.l,y:l.headerHeight/2+h.textOffsetY+i.pad.t}),a.on("click",(function(){r.call(I,String(d(r,i)?-1:i._index)),v(t,e,r,n,i)})),a.on("mouseover",(function(){a.call(w)})),a.on("mouseout",(function(){a.call(A,i)})),o.setTranslate(e,l.lx,l.ly)}function v(t,e,r,a,o){r||(r=e).attr("pointer-events","all");var l=function(t){return-1==+t.attr(h.menuIndexAttrName)}(r)&&"buttons"!==o.type?[]:o.buttons,c="dropdown"===o.type?h.dropdownButtonClassName:h.buttonClassName,u=r.selectAll("g."+c).data(s.filterVisible(l)),f=u.enter().append("g").classed(c,!0),p=u.exit();"dropdown"===o.type?(f.attr("opacity","0").transition().attr("opacity","1"),p.transition().attr("opacity","0").remove()):p.remove();var d=0,m=0,v=o._dims,x=-1!==["up","down"].indexOf(o.direction);"dropdown"===o.type&&(x?m=v.headerHeight+h.gapButtonHeader:d=v.headerWidth+h.gapButtonHeader),"dropdown"===o.type&&"up"===o.direction&&(m=-h.gapButtonHeader+h.gapButton-v.openHeight),"dropdown"===o.type&&"left"===o.direction&&(d=-h.gapButtonHeader+h.gapButton-v.openWidth);var b={x:v.lx+d+o.pad.l,y:v.ly+m+o.pad.t,yPad:h.gapButton,xPad:h.gapButton,index:0},C={l:b.x+o.borderwidth,t:b.y+o.borderwidth};u.each((function(s,l){var c=n.select(this);c.call(y,o,s,t).call(k,o,b),c.on("click",(function(){n.event.defaultPrevented||(s.execute&&(s.args2&&o.active===l?(g(t,o,0,e,r,a,-1),i.executeAPICommand(t,s.method,s.args2)):(g(t,o,0,e,r,a,l),i.executeAPICommand(t,s.method,s.args))),t.emit("plotly_buttonclicked",{menu:o,button:s,active:o.active}))})),c.on("mouseover",(function(){c.call(w)})),c.on("mouseout",(function(){c.call(A,o),u.call(_,o)}))})),u.call(_,o),x?(C.w=Math.max(v.openWidth,v.headerWidth),C.h=b.y-C.t):(C.w=b.x-C.l,C.h=Math.max(v.openHeight,v.headerHeight)),C.direction=o.direction,a&&(u.size()?function(t,e,r,n,i,a){var o,s,l,c=i.direction,u="up"===c||"down"===c,f=i._dims,p=i.active;if(u)for(s=0,l=0;l0?[0]:[]);if(o.enter().append("g").classed(h.containerClassName,!0).style("cursor","pointer"),o.exit().each((function(){n.select(this).selectAll("g."+h.headerGroupClassName).each(a)})).remove(),0!==r.length){var l=o.selectAll("g."+h.headerGroupClassName).data(r,p);l.enter().append("g").classed(h.headerGroupClassName,!0);for(var c=s.ensureSingle(o,"g",h.dropdownButtonGroupClassName,(function(t){t.style("pointer-events","all")})),u=0;uw,M=s.barLength+2*s.barPad,k=s.barWidth+2*s.barPad,I=d,T=m+v;T+k>c&&(T=c-k);var L=this.container.selectAll("rect.scrollbar-horizontal").data(C?[0]:[]);L.exit().on(".drag",null).remove(),L.enter().append("rect").classed("scrollbar-horizontal",!0).call(i.fill,s.barColor),C?(this.hbar=L.attr({rx:s.barRadius,ry:s.barRadius,x:I,y:T,width:M,height:k}),this._hbarXMin=I+M/2,this._hbarTranslateMax=w-M):(delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax);var S=v>A,E=s.barWidth+2*s.barPad,D=s.barLength+2*s.barPad,P=d+g,O=m;P+E>l&&(P=l-E);var z=this.container.selectAll("rect.scrollbar-vertical").data(S?[0]:[]);z.exit().on(".drag",null).remove(),z.enter().append("rect").classed("scrollbar-vertical",!0).call(i.fill,s.barColor),S?(this.vbar=z.attr({rx:s.barRadius,ry:s.barRadius,x:P,y:O,width:E,height:D}),this._vbarYMin=O+D/2,this._vbarTranslateMax=A-D):(delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax);var R=this.id,F=u-.5,N=S?h+E+.5:h+.5,j=f-.5,B=C?p+k+.5:p+.5,Y=o._topdefs.selectAll("#"+R).data(C||S?[0]:[]);if(Y.exit().remove(),Y.enter().append("clipPath").attr("id",R).append("rect"),C||S?(this._clipRect=Y.select("rect").attr({x:Math.floor(F),y:Math.floor(j),width:Math.ceil(N)-Math.floor(F),height:Math.ceil(B)-Math.floor(j)}),this.container.call(a.setClipUrl,R,this.gd),this.bg.attr({x:d,y:m,width:g,height:v})):(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),C||S){var V=n.behavior.drag().on("dragstart",(function(){n.event.sourceEvent.preventDefault()})).on("drag",this._onBoxDrag.bind(this));this.container.on("wheel",null).on("wheel",this._onBoxWheel.bind(this)).on(".drag",null).call(V);var U=n.behavior.drag().on("dragstart",(function(){n.event.sourceEvent.preventDefault(),n.event.sourceEvent.stopPropagation()})).on("drag",this._onBarDrag.bind(this));C&&this.hbar.on(".drag",null).call(U),S&&this.vbar.on(".drag",null).call(U)}this.setTranslate(e,r)},s.prototype.disable=function(){(this.hbar||this.vbar)&&(this.bg.attr({width:0,height:0}),this.container.on("wheel",null).on(".drag",null).call(a.setClipUrl,null),delete this._clipRect),this.hbar&&(this.hbar.on(".drag",null),this.hbar.remove(),delete this.hbar,delete this._hbarXMin,delete this._hbarTranslateMax),this.vbar&&(this.vbar.on(".drag",null),this.vbar.remove(),delete this.vbar,delete this._vbarYMin,delete this._vbarTranslateMax)},s.prototype._onBoxDrag=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t-=n.event.dx),this.vbar&&(e-=n.event.dy),this.setTranslate(t,e)},s.prototype._onBoxWheel=function(){var t=this.translateX,e=this.translateY;this.hbar&&(t+=n.event.deltaY),this.vbar&&(e+=n.event.deltaY),this.setTranslate(t,e)},s.prototype._onBarDrag=function(){var t=this.translateX,e=this.translateY;if(this.hbar){var r=t+this._hbarXMin,i=r+this._hbarTranslateMax;t=(o.constrain(n.event.x,r,i)-r)/(i-r)*(this.position.w-this._box.w)}if(this.vbar){var a=e+this._vbarYMin,s=a+this._vbarTranslateMax;e=(o.constrain(n.event.y,a,s)-a)/(s-a)*(this.position.h-this._box.h)}this.setTranslate(t,e)},s.prototype.setTranslate=function(t,e){var r=this.position.w-this._box.w,n=this.position.h-this._box.h;if(t=o.constrain(t||0,0,r),e=o.constrain(e||0,0,n),this.translateX=t,this.translateY=e,this.container.call(a.setTranslate,this._box.l-this.position.l-t,this._box.t-this.position.t-e),this._clipRect&&this._clipRect.attr({x:Math.floor(this.position.l+t-.5),y:Math.floor(this.position.t+e-.5)}),this.hbar){var i=t/r;this.hbar.call(a.setTranslate,t+i*this._hbarTranslateMax,e)}if(this.vbar){var s=e/n;this.vbar.call(a.setTranslate,t,e+s*this._vbarTranslateMax)}}},{"../../lib":717,"../color":592,"../drawing":613,d3:165}],686:[function(t,e,r){"use strict";e.exports={FROM_BL:{left:0,center:.5,right:1,bottom:0,middle:.5,top:1},FROM_TL:{left:0,center:.5,right:1,bottom:1,middle:.5,top:0},FROM_BR:{left:1,center:.5,right:0,bottom:0,middle:.5,top:1},LINE_SPACING:1.3,CAP_SHIFT:.7,MID_SHIFT:.35,OPPOSITE_SIDE:{left:"right",right:"left",top:"bottom",bottom:"top"}}},{}],687:[function(t,e,r){"use strict";e.exports={INCREASING:{COLOR:"#3D9970",SYMBOL:"▲"},DECREASING:{COLOR:"#FF4136",SYMBOL:"▼"}}},{}],688:[function(t,e,r){"use strict";e.exports={FORMAT_LINK:"https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format",DATE_FORMAT_LINK:"https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format"}},{}],689:[function(t,e,r){"use strict";e.exports={COMPARISON_OPS:["=","!=","<",">=",">","<="],COMPARISON_OPS2:["=","<",">=",">","<="],INTERVAL_OPS:["[]","()","[)","(]","][",")(","](",")["],SET_OPS:["{}","}{"],CONSTRAINT_REDUCTION:{"=":"=","<":"<","<=":"<",">":">",">=":">","[]":"[]","()":"[]","[)":"[]","(]":"[]","][":"][",")(":"][","](":"][",")[":"]["}}},{}],690:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],691:[function(t,e,r){"use strict";e.exports={circle:"●","circle-open":"○",square:"■","square-open":"□",diamond:"◆","diamond-open":"◇",cross:"+",x:"❌"}},{}],692:[function(t,e,r){"use strict";e.exports={SHOW_PLACEHOLDER:100,HIDE_PLACEHOLDER:1e3,DESELECTDIM:.2}},{}],693:[function(t,e,r){"use strict";e.exports={BADNUM:void 0,FP_SAFE:Number.MAX_VALUE/1e4,ONEAVGYEAR:315576e5,ONEAVGMONTH:26298e5,ONEDAY:864e5,ONEHOUR:36e5,ONEMIN:6e4,ONESEC:1e3,EPOCHJD:2440587.5,ALMOST_EQUAL:1-1e-6,LOG_CLIP:10,MINUS_SIGN:"−"}},{}],694:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],695:[function(t,e,r){"use strict";r.version="1.52.2",t("es6-promise").polyfill(),t("../build/plotcss"),t("./fonts/mathjax_config")();for(var n=t("./registry"),i=r.register=n.register,a=t("./plot_api"),o=Object.keys(a),s=0;splotly-logomark"}}},{}],698:[function(t,e,r){"use strict";r.isLeftAnchor=function(t){return"left"===t.xanchor||"auto"===t.xanchor&&t.x<=1/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isTopAnchor=function(t){return"top"===t.yanchor||"auto"===t.yanchor&&t.y>=2/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3}},{}],699:[function(t,e,r){"use strict";var n=t("./mod"),i=n.mod,a=n.modHalf,o=Math.PI,s=2*o;function l(t){return Math.abs(t[1]-t[0])>s-1e-14}function c(t,e){return a(e-t,s)}function u(t,e){if(l(e))return!0;var r,n;e[0](n=i(n,s))&&(n+=s);var a=i(t,s),o=a+s;return a>=r&&a<=n||o>=r&&o<=n}function h(t,e,r,n,i,a,c){i=i||0,a=a||0;var u,h,f,p,d,g=l([r,n]);function m(t,e){return[t*Math.cos(e)+i,a-t*Math.sin(e)]}g?(u=0,h=o,f=s):r=i&&t<=a);var i,a},pathArc:function(t,e,r,n,i){return h(null,t,e,r,n,i,0)},pathSector:function(t,e,r,n,i){return h(null,t,e,r,n,i,1)},pathAnnulus:function(t,e,r,n,i,a){return h(t,e,r,n,i,a,1)}}},{"./mod":724}],700:[function(t,e,r){"use strict";var n=Array.isArray,i="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer:{isView:function(){return!1}},a="undefined"==typeof DataView?function(){}:DataView;function o(t){return i.isView(t)&&!(t instanceof a)}function s(t){return n(t)||o(t)}function l(t,e,r){if(s(t)){if(s(t[0])){for(var n=r,i=0;ii.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;!0!==n.strict&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorlist:{coerceFunction:function(t,e,r){Array.isArray(t)&&t.length&&t.every((function(t){return i(t).isValid()}))?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o.get(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?e.set(u(+t,360)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r,n){var i=n.regex||c(r);"string"==typeof t&&i.test(t)?e.set(t):e.set(r)},validateFunction:function(t,e){var r=e.dflt;return t===r||"string"==typeof t&&!!c(r).test(t)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"==typeof t)if(-1===(n.extras||[]).indexOf(t)){for(var i=t.split("+"),a=0;a=n&&t<=i?t:u}if("string"!=typeof t&&"number"!=typeof t)return u;t=String(t);var c=_(e),v=t.charAt(0);!c||"G"!==v&&"g"!==v||(t=t.substr(1),e="");var w=c&&"chinese"===e.substr(0,7),A=t.match(w?x:y);if(!A)return u;var C=A[1],M=A[3]||"1",k=Number(A[5]||1),I=Number(A[7]||0),T=Number(A[9]||0),L=Number(A[11]||0);if(c){if(2===C.length)return u;var S;C=Number(C);try{var E=m.getComponentMethod("calendars","getCal")(e);if(w){var D="i"===M.charAt(M.length-1);M=parseInt(M,10),S=E.newDate(C,E.toMonthIndex(C,M,D),k)}else S=E.newDate(C,Number(M),k)}catch(t){return u}return S?(S.toJD()-g)*h+I*f+T*p+L*d:u}C=2===C.length?(Number(C)+2e3-b)%100+b:Number(C),M-=1;var P=new Date(Date.UTC(2e3,M,k,I,T));return P.setUTCFullYear(C),P.getUTCMonth()!==M?u:P.getUTCDate()!==k?u:P.getTime()+L*d},n=r.MIN_MS=r.dateTime2ms("-9999"),i=r.MAX_MS=r.dateTime2ms("9999-12-31 23:59:59.9999"),r.isDateTime=function(t,e){return r.dateTime2ms(t,e)!==u};var A=90*h,C=3*f,M=5*p;function k(t,e,r,n,i){if((e||r||n||i)&&(t+=" "+w(e,2)+":"+w(r,2),(n||i)&&(t+=":"+w(n,2),i))){for(var a=4;i%10==0;)a-=1,i/=10;t+="."+w(i,a)}return t}r.ms2DateTime=function(t,e,r){if("number"!=typeof t||!(t>=n&&t<=i))return u;e||(e=0);var a,o,s,c,y,x,b=Math.floor(10*l(t+.05,1)),w=Math.round(t-b/10);if(_(r)){var I=Math.floor(w/h)+g,T=Math.floor(l(t,h));try{a=m.getComponentMethod("calendars","getCal")(r).fromJD(I).formatDate("yyyy-mm-dd")}catch(t){a=v("G%Y-%m-%d")(new Date(w))}if("-"===a.charAt(0))for(;a.length<11;)a="-0"+a.substr(1);else for(;a.length<10;)a="0"+a;o=e=n+h&&t<=i-h))return u;var e=Math.floor(10*l(t+.05,1)),r=new Date(Math.round(t-e/10));return k(a.time.format("%Y-%m-%d")(r),r.getHours(),r.getMinutes(),r.getSeconds(),10*r.getUTCMilliseconds()+e)},r.cleanDate=function(t,e,n){if(t===u)return e;if(r.isJSDate(t)||"number"==typeof t&&isFinite(t)){if(_(n))return s.error("JS Dates and milliseconds are incompatible with world calendars",t),e;if(!(t=r.ms2DateTimeLocal(+t))&&void 0!==e)return e}else if(!r.isDateTime(t,n))return s.error("unrecognized date",t),e;return t};var I=/%\d?f/g;function T(t,e,r,n){t=t.replace(I,(function(t){var r=Math.min(+t.charAt(1)||6,6);return(e/1e3%1+2).toFixed(r).substr(2).replace(/0+$/,"")||"0"}));var i=new Date(Math.floor(e+.05));if(_(n))try{t=m.getComponentMethod("calendars","worldCalFmt")(t,e,n)}catch(t){return"Invalid"}return r(t)(i)}var L=[59,59.9,59.99,59.999,59.9999];r.formatDate=function(t,e,r,n,i,a){if(i=_(i)&&i,!e)if("y"===r)e=a.year;else if("m"===r)e=a.month;else{if("d"!==r)return function(t,e){var r=l(t+.05,h),n=w(Math.floor(r/f),2)+":"+w(l(Math.floor(r/p),60),2);if("M"!==e){o(e)||(e=0);var i=(100+Math.min(l(t/d,60),L[e])).toFixed(e).substr(1);e>0&&(i=i.replace(/0+$/,"").replace(/[\.]$/,"")),n+=":"+i}return n}(t,r)+"\n"+T(a.dayMonthYear,t,n,i);e=a.dayMonth+"\n"+a.year}return T(e,t,n,i)};var S=3*h;r.incrementMonth=function(t,e,r){r=_(r)&&r;var n=l(t,h);if(t=Math.round(t-n),r)try{var i=Math.round(t/h)+g,a=m.getComponentMethod("calendars","getCal")(r),o=a.fromJD(i);return e%12?a.add(o,e,"m"):a.add(o,e/12,"y"),(o.toJD()-g)*h+n}catch(e){s.error("invalid ms "+t+" in calendar "+r)}var c=new Date(t+S);return c.setUTCMonth(c.getUTCMonth()+e)+n-S},r.findExactDates=function(t,e){for(var r,n,i=0,a=0,s=0,l=0,c=_(e)&&m.getComponentMethod("calendars","getCal")(e),u=0;u0&&t[e+1][0]<0)return e;return null}switch(e="RUS"===s||"FJI"===s?function(t){var e;if(null===c(t))e=t;else for(e=new Array(t.length),i=0;ie?r[n++]=[t[i][0]+360,t[i][1]]:i===e?(r[n++]=t[i],r[n++]=[t[i][0],-90]):r[n++]=t[i];var a=f.tester(r);a.pts.pop(),l.push(a)}:function(t){l.push(f.tester(t))},a.type){case"MultiPolygon":for(r=0;ri&&(i=c,e=l)}else e=r;return o.default(e).geometry.coordinates}(u),n.fIn=t,n.fOut=u,s.push(u)}else c.log(["Location",n.loc,"does not have a valid GeoJSON geometry.","Traces with locationmode *geojson-id* only support","*Polygon* and *MultiPolygon* geometries."].join(" "))}delete i[r]}switch(r.type){case"FeatureCollection":var f=r.features;for(n=0;n100?(clearInterval(a),n("Unexpected error while fetching from "+t)):void i++}),50)}))}for(var o=0;o0&&(r.push(i),i=[])}return i.length>0&&r.push(i),r},r.makeLine=function(t){return 1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}},r.makePolygon=function(t){if(1===t.length)return{type:"Polygon",coordinates:t};for(var e=new Array(t.length),r=0;r1||g<0||g>1?null:{x:t+l*g,y:e+h*g}}function l(t,e,r,n,i){var a=n*t+i*e;if(a<0)return n*n+i*i;if(a>r){var o=n-t,s=i-e;return o*o+s*s}var l=n*e-i*t;return l*l/r}r.segmentsIntersect=s,r.segmentDistance=function(t,e,r,n,i,a,o,c){if(s(t,e,r,n,i,a,o,c))return 0;var u=r-t,h=n-e,f=o-i,p=c-a,d=u*u+h*h,g=f*f+p*p,m=Math.min(l(u,h,d,i-t,a-e),l(u,h,d,o-t,c-e),l(f,p,g,t-i,e-a),l(f,p,g,r-i,n-a));return Math.sqrt(m)},r.getTextLocation=function(t,e,r,s){if(t===i&&s===a||(n={},i=t,a=s),n[r])return n[r];var l=t.getPointAtLength(o(r-s/2,e)),c=t.getPointAtLength(o(r+s/2,e)),u=Math.atan((c.y-l.y)/(c.x-l.x)),h=t.getPointAtLength(o(r,e)),f={x:(4*h.x+l.x+c.x)/6,y:(4*h.y+l.y+c.y)/6,theta:u};return n[r]=f,f},r.clearLocationCache=function(){i=null},r.getVisibleSegment=function(t,e,r){var n,i,a=e.left,o=e.right,s=e.top,l=e.bottom,c=0,u=t.getTotalLength(),h=u;function f(e){var r=t.getPointAtLength(e);0===e?n=r:e===u&&(i=r);var c=r.xo?r.x-o:0,h=r.yl?r.y-l:0;return Math.sqrt(c*c+h*h)}for(var p=f(c);p;){if((c+=p+r)>h)return;p=f(c)}for(p=f(h);p;){if(c>(h-=p+r))return;p=f(h)}return{min:c,max:h,len:h-c,total:u,isClosed:0===c&&h===u&&Math.abs(n.x-i.x)<.1&&Math.abs(n.y-i.y)<.1}},r.findPointOnPath=function(t,e,r,n){for(var i,a,o,s=(n=n||{}).pathLength||t.getTotalLength(),l=n.tolerance||.001,c=n.iterationLimit||30,u=t.getPointAtLength(0)[r]>t.getPointAtLength(s)[r]?-1:1,h=0,f=0,p=s;h0?p=i:f=i,h++}return a}},{"./mod":724}],714:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("color-normalize"),o=t("../components/colorscale"),s=t("../components/color/attributes").defaultLine,l=t("./array").isArrayOrTypedArray,c=a(s),u=1;function h(t,e){var r=t;return r[3]*=e,r}function f(t){if(n(t))return c;var e=a(t);return e.length?e:c}function p(t){return n(t)?t:u}e.exports={formatColor:function(t,e,r){var n,i,s,d,g,m=t.color,v=l(m),y=l(e),x=o.extractOpts(t),b=[];if(n=void 0!==x.colorscale?o.makeColorScaleFuncFromTrace(t):f,i=v?function(t,e){return void 0===t[e]?c:a(n(t[e]))}:f,s=y?function(t,e){return void 0===t[e]?u:p(t[e])}:p,v||y)for(var _=0;_o?s:i(t)?Number(t):s:s},l.isIndex=function(t,e){return!(void 0!==e&&t>=e)&&i(t)&&t>=0&&t%1==0},l.noop=t("./noop"),l.identity=t("./identity"),l.repeat=function(t,e){for(var r=new Array(e),n=0;nr?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},l.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},l.simpleMap=function(t,e,r,n){for(var i=t.length,a=new Array(i),o=0;o=Math.pow(2,r)?i>10?(l.warn("randstr failed uniqueness"),c):t(e,r,n,(i||0)+1):c},l.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={optionList:[],_newoption:function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)}};return r["_"+e]=t,r},l.smooth=function(t,e){if((e=Math.round(e)||0)<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},l.syncOrAsync=function(t,e,r){var n;function i(){return l.syncOrAsync(t,e,r)}for(;t.length;)if((n=(0,t.splice(0,1)[0])(e))&&n.then)return n.then(i).then(void 0,l.promiseError);return r&&r(e)},l.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},l.noneOrAll=function(t,e,r){if(t){var n,i=!1,a=!0;for(n=0;n0?e:0}))},l.fillArray=function(t,e,r,n){if(n=n||l.identity,l.isArrayOrTypedArray(t))for(var i=0;i1?i+o[1]:"";if(a&&(o.length>1||s.length>4||r))for(;n.test(s);)s=s.replace(n,"$1"+a+"$2");return s+l},l.TEMPLATE_STRING_REGEX=/%{([^\s%{}:]*)([:|\|][^}]*)?}/g;var L=/^\w*$/;l.templateString=function(t,e){var r={};return t.replace(l.TEMPLATE_STRING_REGEX,(function(t,n){var i;return L.test(n)?i=e[n]:(r[n]=r[n]||l.nestedProperty(e,n).get,i=r[n]()),l.isValidTextValue(i)?i:""}))};var S={max:10,count:0,name:"hovertemplate"};l.hovertemplateString=function(){return P.apply(S,arguments)};var E={max:10,count:0,name:"texttemplate"};l.texttemplateString=function(){return P.apply(E,arguments)};var D=/^[:|\|]/;function P(t,e,r){var i=this,a=arguments;e||(e={});var o={};return t.replace(l.TEMPLATE_STRING_REGEX,(function(t,s,c){var u,h,f,p;for(f=3;f=48&&o<=57,c=s>=48&&s<=57;if(l&&(n=10*n+o-48),c&&(i=10*i+s-48),!l||!c){if(n!==i)return n-i;if(o!==s)return o-s}}return i-n};var O=2e9;l.seedPseudoRandom=function(){O=2e9},l.pseudoRandom=function(){var t=O;return O=(69069*O+1)%4294967296,Math.abs(O-t)<429496729?l.pseudoRandom():O/4294967296},l.fillText=function(t,e,r){var n=Array.isArray(r)?function(t){r.push(t)}:function(t){r.text=t},i=l.extractOption(t,e,"htx","hovertext");if(l.isValidTextValue(i))return n(i);var a=l.extractOption(t,e,"tx","text");return l.isValidTextValue(a)?n(a):void 0},l.isValidTextValue=function(t){return t||0===t},l.formatPercent=function(t,e){e=e||0;for(var r=(Math.round(100*t*Math.pow(10,e))*Math.pow(.1,e)).toFixed(e)+"%",n=0;n1&&(c=1):c=0,"translate("+(i-c*(r+o))+","+(a-c*(n+s))+")"+(c<1?"scale("+c+")":"")+(l?"rotate("+l+(e?"":" "+r+" "+n)+")":"")},l.ensureUniformFontSize=function(t,e){var r=l.extendFlat({},e);return r.size=Math.max(e.size,t._fullLayout.uniformtext.minsize||0),r}},{"../constants/numerical":693,"./anchor_utils":698,"./angles":699,"./array":700,"./clean_number":701,"./clear_responsive":703,"./coerce":704,"./dates":705,"./dom":706,"./extend":708,"./filter_unique":709,"./filter_visible":710,"./geometry2d":713,"./identity":716,"./is_plain_object":718,"./keyed_container":719,"./localize":720,"./loggers":721,"./make_trace_groups":722,"./matrix":723,"./mod":724,"./nested_property":725,"./noop":726,"./notifier":727,"./push_unique":731,"./regex":733,"./relative_attr":734,"./relink_private":735,"./search":736,"./stats":739,"./throttle":742,"./to_log_range":743,d3:165,"fast-isnumeric":228}],718:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],719:[function(t,e,r){"use strict";var n=t("./nested_property"),i=/^\w*$/;e.exports=function(t,e,r,a){var o,s,l;r=r||"name",a=a||"value";var c={};e&&e.length?(l=n(t,e),s=l.get()):s=t,e=e||"";var u={};if(s)for(o=0;o2)return c[e]=2|c[e],f.set(t,null);if(h){for(o=e;o1){var e=["LOG:"];for(t=0;t1){var r=[];for(t=0;t"),"long")}},a.warn=function(){var t;if(n.logging>0){var e=["WARN:"];for(t=0;t0){var r=[];for(t=0;t"),"stick")}},a.error=function(){var t;if(n.logging>0){var e=["ERROR:"];for(t=0;t0){var r=[];for(t=0;t"),"stick")}}},{"../plot_api/plot_config":753,"./notifier":727}],722:[function(t,e,r){"use strict";var n=t("d3");e.exports=function(t,e,r){var i=t.selectAll("g."+r.replace(/\s/g,".")).data(e,(function(t){return t[0].trace.uid}));i.exit().remove(),i.enter().append("g").attr("class",r),i.order();var a=t.classed("rangeplot")?"nodeRangePlot3":"node3";return i.each((function(t){t[0][a]=n.select(this)})),i}},{d3:165}],723:[function(t,e,r){"use strict";r.init2dArray=function(t,e){for(var r=new Array(t),n=0;ne/2?t-Math.round(t/e)*e:t}}},{}],725:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./array").isArrayOrTypedArray;function a(t,e){return function(){var r,n,o,s,l,c=t;for(s=0;s/g),l=0;la||c===i||cs||e&&l(t))}:function(t,e){var l=t[0],c=t[1];if(l===i||la||c===i||cs)return!1;var u,h,f,p,d,g=r.length,m=r[0][0],v=r[0][1],y=0;for(u=1;uMath.max(h,m)||c>Math.max(f,v)))if(cu||Math.abs(n(o,f))>i)return!0;return!1},a.filter=function(t,e){var r=[t[0]],n=0,i=0;function o(o){t.push(o);var s=r.length,l=n;r.splice(i+1);for(var c=l+1;c1&&o(t.pop()),{addPt:o,raw:t,filtered:r}}},{"../constants/numerical":693,"./matrix":723}],730:[function(t,r,n){(function(e){"use strict";var n=t("./show_no_webgl_msg"),i=t("regl");r.exports=function(t,r){var a=t._fullLayout,o=!0;return a._glcanvas.each((function(n){if(!n.regl&&(!n.pick||a._has("parcoords"))){try{n.regl=i({canvas:this,attributes:{antialias:!n.pick,preserveDrawingBuffer:!0},pixelRatio:t._context.plotGlPixelRatio||e.devicePixelRatio,extensions:r||[]})}catch(t){o=!1}o&&this.addEventListener("webglcontextlost",(function(e){t&&t.emit&&t.emit("plotly_webglcontextlost",{event:e,layer:n.key})}),!1)}})),o||n({container:a._glcontainer.node()}),o}}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./show_no_webgl_msg":738,regl:501}],731:[function(t,e,r){"use strict";e.exports=function(t,e){if(e instanceof RegExp){for(var r=e.toString(),n=0;ni.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--))},startSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},stopSequence:function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},undo:function(t){var e,r;if(t.framework&&t.framework.isPolar)t.framework.undo();else if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function c(t,e){return t>=e}r.findBin=function(t,e,r){if(n(e.start))return r?Math.ceil((t-e.start)/e.size-1e-9)-1:Math.floor((t-e.start)/e.size+1e-9);var a,u,h=0,f=e.length,p=0,d=f>1?(e[f-1]-e[0])/(f-1):1;for(u=d>=0?r?o:s:r?c:l,t+=1e-9*d*(r?-1:1)*(d>=0?1:-1);h90&&i.log("Long binary search..."),h-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;i0&&(n=1),r&&n)return t.sort(e)}return n?t:t.reverse()},r.findIndexOfMin=function(t,e){e=e||a;for(var r,n=1/0,i=0;ia.length)&&(o=a.length),n(e)||(e=!1),i(a[0])){for(l=new Array(o),s=0;st.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"./array":700,"fast-isnumeric":228}],740:[function(t,e,r){"use strict";var n=t("color-normalize");e.exports=function(t){return t?n(t):[0,0,0,1]}},{"color-normalize":122}],741:[function(t,e,r){"use strict";var n=t("d3"),i=t("../lib"),a=t("../constants/xmlns_namespaces"),o=t("../constants/alignment").LINE_SPACING;function s(t,e){return t.node().getBoundingClientRect()[e]}var l=/([^$]*)([$]+[^$]*[$]+)([^$]*)/;r.convertToTspans=function(t,e,k){var I=t.text(),L=!t.attr("data-notex")&&"undefined"!=typeof MathJax&&I.match(l),S=n.select(t.node().parentNode);if(!S.empty()){var E=t.attr("class")?t.attr("class").split(" ")[0]:"text";return E+="-math",S.selectAll("svg."+E).remove(),S.selectAll("g."+E+"-group").remove(),t.style("display",null).attr({"data-unformatted":I,"data-math":"N"}),L?(e&&e._promises||[]).push(new Promise((function(e){t.style("display","none");var r=parseInt(t.node().style.fontSize,10),a={fontSize:r};!function(t,e,r){var a,o,s,l;MathJax.Hub.Queue((function(){return o=i.extendDeepAll({},MathJax.Hub.config),s=MathJax.Hub.processSectionDelay,void 0!==MathJax.Hub.processSectionDelay&&(MathJax.Hub.processSectionDelay=0),MathJax.Hub.Config({messageStyle:"none",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]},displayAlign:"left"})}),(function(){if("SVG"!==(a=MathJax.Hub.config.menuSettings.renderer))return MathJax.Hub.setRenderer("SVG")}),(function(){var r="math-output-"+i.randstr({},64);return l=n.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(t.replace(c,"\\lt ").replace(u,"\\gt ")),MathJax.Hub.Typeset(l.node())}),(function(){var e=n.select("body").select("#MathJax_SVG_glyphs");if(l.select(".MathJax_SVG").empty()||!l.select("svg").node())i.log("There was an error in the tex syntax.",t),r();else{var o=l.select("svg").node().getBoundingClientRect();r(l.select(".MathJax_SVG"),e,o)}if(l.remove(),"SVG"!==a)return MathJax.Hub.setRenderer(a)}),(function(){return void 0!==s&&(MathJax.Hub.processSectionDelay=s),MathJax.Hub.Config(o)}))}(L[2],a,(function(n,i,a){S.selectAll("svg."+E).remove(),S.selectAll("g."+E+"-group").remove();var o=n&&n.select("svg");if(!o||!o.node())return D(),void e();var l=S.append("g").classed(E+"-group",!0).attr({"pointer-events":"none","data-unformatted":I,"data-math":"Y"});l.node().appendChild(o.node()),i&&i.node()&&o.node().insertBefore(i.node().cloneNode(!0),o.node().firstChild),o.attr({class:E,height:a.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=t.node().style.fill||"black",u=o.select("g");u.attr({fill:c,stroke:c});var h=s(u,"width"),f=s(u,"height"),p=+t.attr("x")-h*{start:0,middle:.5,end:1}[t.attr("text-anchor")||"start"],d=-(r||s(t,"height"))/4;"y"===E[0]?(l.attr({transform:"rotate("+[-90,+t.attr("x"),+t.attr("y")]+") translate("+[-h/2,d-f/2]+")"}),o.attr({x:+t.attr("x"),y:+t.attr("y")})):"l"===E[0]?o.attr({x:t.attr("x"),y:d-f/2}):"a"===E[0]&&0!==E.indexOf("atitle")?o.attr({x:0,y:d}):o.attr({x:p,y:+t.attr("y")+d-f/2}),k&&k.call(t,l),e(l)}))}))):D(),t}function D(){S.empty()||(E=t.attr("class")+"-math",S.select("svg."+E).remove()),t.text("").style("white-space","pre"),function(t,e){e=e.replace(m," ");var r,s=!1,l=[],c=-1;function u(){c++;var e=document.createElementNS(a.svg,"tspan");n.select(e).attr({class:"line",dy:c*o+"em"}),t.appendChild(e),r=e;var i=l;if(l=[{node:e}],i.length>1)for(var s=1;s doesnt match end tag <"+t+">. Pretending it did match.",e),r=l[l.length-1].node}else i.log("Ignoring unexpected end tag .",e)}x.test(e)?u():(r=t,l=[{node:t}]);for(var S=e.split(v),E=0;E|>|>)/g,h={sup:"font-size:70%",sub:"font-size:70%",b:"font-weight:bold",i:"font-style:italic",a:"cursor:pointer",span:"",em:"font-style:italic;font-weight:bold"},f={sub:"0.3em",sup:"-0.6em"},p={sub:"-0.21em",sup:"0.42em"},d="​",g=["http:","https:","mailto:","",void 0,":"],m=r.NEWLINES=/(\r\n?|\n)/g,v=/(<[^<>]*>)/,y=/<(\/?)([^ >]*)(\s+(.*))?>/i,x=//i;r.BR_TAG_ALL=//gi;var b=/(^|[\s"'])style\s*=\s*("([^"]*);?"|'([^']*);?')/i,_=/(^|[\s"'])href\s*=\s*("([^"]*)"|'([^']*)')/i,w=/(^|[\s"'])target\s*=\s*("([^"\s]*)"|'([^'\s]*)')/i,A=/(^|[\s"'])popup\s*=\s*("([\w=,]*)"|'([\w=,]*)')/i;function C(t,e){if(!t)return null;var r=t.match(e),n=r&&(r[3]||r[4]);return n&&T(n)}var M=/(^|;)\s*color:/;r.plainText=function(t,e){for(var r=void 0!==(e=e||{}).len&&-1!==e.len?e.len:1/0,n=void 0!==e.allowedTags?e.allowedTags:["br"],i="...".length,a=t.split(v),o=[],s="",l=0,c=0;ci?o.push(u.substr(0,d-i)+"..."):o.push(u.substr(0,d));break}s=""}}return o.join("")};var k={mu:"μ",amp:"&",lt:"<",gt:">",nbsp:" ",times:"×",plusmn:"±",deg:"°"},I=/&(#\d+|#x[\da-fA-F]+|[a-z]+);/g;function T(t){return t.replace(I,(function(t,e){return("#"===e.charAt(0)?function(t){if(!(t>1114111)){var e=String.fromCodePoint;if(e)return e(t);var r=String.fromCharCode;return t<=65535?r(t):r(55232+(t>>10),t%1024+56320)}}("x"===e.charAt(1)?parseInt(e.substr(2),16):parseInt(e.substr(1),10)):k[e])||t}))}function L(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}r.convertEntities=T,r.lineCount=function(t){return t.selectAll("tspan.line").size()||1},r.positionText=function(t,e,r){return t.each((function(){var t=n.select(this);function i(e,r){return void 0===r?null===(r=t.attr(e))&&(t.attr(e,0),r=0):t.attr(e,r),r}var a=i("x",e),o=i("y",r);"text"===this.nodeName&&t.selectAll("tspan.line").attr({x:a,y:o})}))},r.makeEditable=function(t,e){var r=e.gd,i=e.delegate,a=n.dispatch("edit","input","cancel"),o=i||t;if(t.style({"pointer-events":i?"none":"all"}),1!==t.size())throw new Error("boo");function s(){var i,s,c,u,h;i=n.select(r).select(".svg-container"),s=i.append("div"),c=t.node().style,u=parseFloat(c.fontSize||12),void 0===(h=e.text)&&(h=t.attr("data-unformatted")),s.classed("plugin-editable editable",!0).style({position:"absolute","font-family":c.fontFamily||"Arial","font-size":u,color:e.fill||c.fill||"black",opacity:1,"background-color":e.background||"transparent",outline:"#ffffff33 1px solid",margin:[-u/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(h).call(L(t,i,e)).on("blur",(function(){r._editing=!1,t.text(this.textContent).style({opacity:1});var e,i=n.select(this).attr("class");(e=i?"."+i.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(e).style({opacity:0});var o=this.textContent;n.select(this).transition().duration(0).remove(),n.select(document).on("mouseup",null),a.edit.call(t,o)})).on("focus",(function(){var t=this;r._editing=!0,n.select(document).on("mouseup",(function(){if(n.event.target===t)return!1;document.activeElement===s.node()&&s.node().blur()}))})).on("keyup",(function(){27===n.event.which?(r._editing=!1,t.style({opacity:1}),n.select(this).style({opacity:0}).on("blur",(function(){return!1})).transition().remove(),a.cancel.call(t,this.textContent)):(a.input.call(t,this.textContent),n.select(this).call(L(t,i,e)))})).on("keydown",(function(){13===n.event.which&&this.blur()})).call(l),t.style({opacity:0});var f,p=o.attr("class");(f=p?"."+p.split(" ")[0]+"-math-group":"[class*=-math-group]")&&n.select(t.node().parentNode).select(f).style({opacity:0})}function l(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}return e.immediate?s():o.on("click",s),n.rebind(t,a,"on")}},{"../constants/alignment":686,"../constants/xmlns_namespaces":694,"../lib":717,d3:165}],742:[function(t,e,r){"use strict";var n={};function i(t){t&&null!==t.timer&&(clearTimeout(t.timer),t.timer=null)}r.throttle=function(t,e,r){var a=n[t],o=Date.now();if(!a){for(var s in n)n[s].tsa.ts+e?l():a.timer=setTimeout((function(){l(),a.timer=null}),e)},r.done=function(t){var e=n[t];return e&&e.timer?new Promise((function(t){var r=e.onDone;e.onDone=function(){r&&r(),t(),e.onDone=null}})):Promise.resolve()},r.clear=function(t){if(t)i(n[t]),delete n[t];else for(var e in n)r.clear(e)}},{}],743:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t,e){if(t>0)return Math.log(t)/Math.LN10;var r=Math.log(Math.min(e[0],e[1]))/Math.LN10;return n(r)||(r=Math.log(Math.max(e[0],e[1]))/Math.LN10-6),r}},{"fast-isnumeric":228}],744:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson-client").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":793,"topojson-client":539}],745:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en-US",dictionary:{"Click to enter Colorscale title":"Click to enter Colorscale title"},format:{date:"%m/%d/%Y"}}},{}],746:[function(t,e,r){"use strict";e.exports={moduleType:"locale",name:"en",dictionary:{"Click to enter Colorscale title":"Click to enter Colourscale title"},format:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],periods:["AM","PM"],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",decimal:".",thousands:",",grouping:[3],currency:["$",""],year:"%Y",month:"%b %Y",dayMonth:"%b %-d",dayMonthYear:"%b %-d, %Y"}}},{}],747:[function(t,e,r){"use strict";var n=t("../registry");e.exports=function(t){for(var e,r,i=n.layoutArrayContainers,a=n.layoutArrayRegexes,o=t.split("[")[0],s=0;s0&&o.log("Clearing previous rejected promises from queue."),t._promises=[]},r.cleanLayout=function(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var a=(s.subplotsRegistry.cartesian||{}).attrRegex,l=(s.subplotsRegistry.polar||{}).attrRegex,h=(s.subplotsRegistry.ternary||{}).attrRegex,f=(s.subplotsRegistry.gl3d||{}).attrRegex,g=Object.keys(t);for(e=0;e3?(E.x=1.02,E.xanchor="left"):E.x<-2&&(E.x=-.02,E.xanchor="right"),E.y>3?(E.y=1.02,E.yanchor="bottom"):E.y<-2&&(E.y=-.02,E.yanchor="top")),d(t),"rotate"===t.dragmode&&(t.dragmode="orbit"),c.clean(t),t.template&&t.template.layout&&r.cleanLayout(t.template.layout),t},r.cleanData=function(t){for(var e=0;e0)return t.substr(0,e)}r.hasParent=function(t,e){for(var r=b(e);r;){if(r in t)return!0;r=b(r)}return!1};var _=["x","y","z"];r.clearAxisTypes=function(t,e,r){for(var n=0;n1&&a.warn("Full array edits are incompatible with other edits",h);var y=r[""][""];if(c(y))e.set(null);else{if(!Array.isArray(y))return a.warn("Unrecognized full array edit value",h,y),!0;e.set(y)}return!g&&(f(m,v),p(t),!0)}var x,b,_,w,A,C,M,k,I=Object.keys(r).map(Number).sort(o),T=e.get(),L=T||[],S=u(v,h).get(),E=[],D=-1,P=L.length;for(x=0;xL.length-(M?0:1))a.warn("index out of range",h,_);else if(void 0!==C)A.length>1&&a.warn("Insertion & removal are incompatible with edits to the same index.",h,_),c(C)?E.push(_):M?("add"===C&&(C={}),L.splice(_,0,C),S&&S.splice(_,0,{})):a.warn("Unrecognized full object edit value",h,_,C),-1===D&&(D=_);else for(b=0;b=0;x--)L.splice(E[x],1),S&&S.splice(E[x],1);if(L.length?T||e.set(L):e.set(null),g)return!1;if(f(m,v),d!==i){var O;if(-1===D)O=I;else{for(P=Math.max(L.length,P),O=[],x=0;x=D);x++)O.push(_);for(x=D;x=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function z(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if(void 0===e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),O(t,e,"currentIndices"),void 0===r||Array.isArray(r)||(r=[r]),void 0!==r&&O(t,r,"newIndices"),void 0!==r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function R(t,e,r,n,a){!function(t,e,r,n){var i=o.isPlainObject(n);if(!Array.isArray(t.data))throw new Error("gd.data must be an array");if(!o.isPlainObject(e))throw new Error("update must be a key:value object");if(void 0===r)throw new Error("indices must be an integer or array of integers");for(var a in O(t,r,"indices"),e){if(!Array.isArray(e[a])||e[a].length!==r.length)throw new Error("attribute "+a+" must be an array of length equal to indices array length");if(i&&(!(a in n)||!Array.isArray(n[a])||n[a].length!==e[a].length))throw new Error("when maxPoints is set as a key:value object it must contain a 1:1 corrispondence with the keys and number of traces in the update object")}}(t,e,r,n);for(var l=function(t,e,r,n){var a,l,c,u,h,f=o.isPlainObject(n),p=[];for(var d in Array.isArray(r)||(r=[r]),r=P(r,t.data.length-1),e)for(var g=0;g-1?l(r,r.replace("titlefont","title.font")):r.indexOf("titleposition")>-1?l(r,r.replace("titleposition","title.position")):r.indexOf("titleside")>-1?l(r,r.replace("titleside","title.side")):r.indexOf("titleoffset")>-1&&l(r,r.replace("titleoffset","title.offset")):l(r,r.replace("title","title.text"));function l(e,r){t[r]=t[e],delete t[e]}}function H(t,e,r){if(t=o.getGraphDiv(t),A.clearPromiseQueue(t),t.framework&&t.framework.isPolar)return Promise.resolve(t);var n={};if("string"==typeof e)n[e]=r;else{if(!o.isPlainObject(e))return o.warn("Relayout fail.",e,r),Promise.reject();n=o.extendFlat({},e)}Object.keys(n).length&&(t.changed=!0);var i=J(t,n),a=i.flags;a.calc&&(t.calcdata=void 0);var s=[f.previousPromises];a.layoutReplot?s.push(C.layoutReplot):Object.keys(n).length&&(G(t,a,i)||f.supplyDefaults(t),a.legend&&s.push(C.doLegend),a.layoutstyle&&s.push(C.layoutStyles),a.axrange&&q(s,i.rangesAltered),a.ticks&&s.push(C.doTicksRelayout),a.modebar&&s.push(C.doModeBar),a.camera&&s.push(C.doCamera),a.colorbars&&s.push(C.doColorBars),s.push(L)),s.push(f.rehover,f.redrag),c.add(t,H,[t,i.undoit],H,[t,i.redoit]);var l=o.syncOrAsync(s,t);return l&&l.then||(l=Promise.resolve(t)),l.then((function(){return t.emit("plotly_relayout",i.eventData),t}))}function G(t,e,r){var n=t._fullLayout;if(!e.axrange)return!1;for(var i in e)if("axrange"!==i&&e[i])return!1;for(var a in r.rangesAltered){var o=d.id2name(a),s=t.layout[o],l=n[o];if(l.autorange=s.autorange,l.range=s.range.slice(),l.cleanRange(),l._matchGroup)for(var c in l._matchGroup)if(c!==a){var u=n[d.id2name(c)];u.autorange=l.autorange,u.range=l.range.slice(),u._input.range=l.range.slice()}}return!0}function q(t,e){var r=e?function(t){var r=[],n=!0;for(var i in e){var a=d.getFromId(t,i);if(r.push(i),a._matchGroup)for(var o in a._matchGroup)e[o]||r.push(o);a.automargin&&(n=!1)}return d.draw(t,r,{skipTitle:n})}:function(t){return d.draw(t,"redraw")};t.push(b,C.doAutoRangeAndConstraints,r,C.drawData,C.finalDraw)}var W=/^[xyz]axis[0-9]*\.range(\[[0|1]\])?$/,Z=/^[xyz]axis[0-9]*\.autorange$/,X=/^[xyz]axis[0-9]*\.domain(\[[0|1]\])?$/;function J(t,e){var r,n,i,a=t.layout,l=t._fullLayout,c=l._guiEditing,f=B(l._preGUI,c),p=Object.keys(e),g=d.list(t),m=o.extendDeepAll({},e),v={};for(U(e),p=Object.keys(e),n=0;n0&&"string"!=typeof P.parts[z];)z--;var R=P.parts[z],F=P.parts[z-1]+"."+R,N=P.parts.slice(0,z).join("."),Y=s(t.layout,N).get(),V=s(l,N).get(),H=P.get();if(void 0!==O){C[D]=O,I[D]="reverse"===R?O:j(H);var G=h.getLayoutValObject(l,P.parts);if(G&&G.impliedEdits&&null!==O)for(var q in G.impliedEdits)T(o.relativeAttr(D,q),G.impliedEdits[q]);if(-1!==["width","height"].indexOf(D))if(O){T("autosize",null);var J="height"===D?"width":"height";T(J,l[J])}else l[D]=t._initialAutoSize[D];else if("autosize"===D)T("width",O?null:l.width),T("height",O?null:l.height);else if(F.match(W))E(F),s(l,N+"._inputRange").set(null);else if(F.match(Z)){E(F),s(l,N+"._inputRange").set(null);var Q=s(l,N).get();Q._inputDomain&&(Q._input.domain=Q._inputDomain.slice())}else F.match(X)&&s(l,N+"._inputDomain").set(null);if("type"===R){var $=Y,tt="linear"===V.type&&"log"===O,et="log"===V.type&&"linear"===O;if(tt||et){if($&&$.range)if(V.autorange)tt&&($.range=$.range[1]>$.range[0]?[1,2]:[2,1]);else{var rt=$.range[0],nt=$.range[1];tt?(rt<=0&&nt<=0&&T(N+".autorange",!0),rt<=0?rt=nt/1e6:nt<=0&&(nt=rt/1e6),T(N+".range[0]",Math.log(rt)/Math.LN10),T(N+".range[1]",Math.log(nt)/Math.LN10)):(T(N+".range[0]",Math.pow(10,rt)),T(N+".range[1]",Math.pow(10,nt)))}else T(N+".autorange",!0);Array.isArray(l._subplots.polar)&&l._subplots.polar.length&&l[P.parts[0]]&&"radialaxis"===P.parts[1]&&delete l[P.parts[0]]._subplot.viewInitial["radialaxis.range"],u.getComponentMethod("annotations","convertCoords")(t,V,O,T),u.getComponentMethod("images","convertCoords")(t,V,O,T)}else T(N+".autorange",!0),T(N+".range",null);s(l,N+"._inputRange").set(null)}else if(R.match(k)){var it=s(l,D).get(),at=(O||{}).type;at&&"-"!==at||(at="linear"),u.getComponentMethod("annotations","convertCoords")(t,it,at,T),u.getComponentMethod("images","convertCoords")(t,it,at,T)}var ot=w.containerArrayMatch(D);if(ot){r=ot.array,n=ot.index;var st=ot.property,lt=G||{editType:"calc"};""!==n&&""===st&&(w.isAddVal(O)?I[D]=null:w.isRemoveVal(O)?I[D]=(s(a,r).get()||[])[n]:o.warn("unrecognized full object value",e)),M.update(_,lt),v[r]||(v[r]={});var ct=v[r][n];ct||(ct=v[r][n]={}),ct[st]=O,delete e[D]}else"reverse"===R?(Y.range?Y.range.reverse():(T(N+".autorange",!0),Y.range=[1,0]),V.autorange?_.calc=!0:_.plot=!0):(l._has("scatter-like")&&l._has("regl")&&"dragmode"===D&&("lasso"===O||"select"===O)&&"lasso"!==H&&"select"!==H?_.plot=!0:l._has("gl2d")?_.plot=!0:G?M.update(_,G):_.calc=!0,P.set(O))}}for(r in v)w.applyContainerArrayChanges(t,f(a,r),v[r],_,f)||(_.plot=!0);var ut=l._axisConstraintGroups||[];for(L in S)for(n=0;n1;)if(n.pop(),void 0!==(r=s(e,n.join(".")+".uirevision").get()))return r;return e.uirevision}function it(t,e){for(var r=0;r=i.length?i[0]:i[t]:i}function l(t){return Array.isArray(a)?t>=a.length?a[0]:a[t]:a}function c(t,e){var r=0;return function(){if(t&&++r===e)return t()}}return(void 0===n._frameWaitingCnt&&(n._frameWaitingCnt=0),new Promise((function(a,u){function h(){n._currentFrame&&n._currentFrame.onComplete&&n._currentFrame.onComplete();var e=n._currentFrame=n._frameQueue.shift();if(e){var r=e.name?e.name.toString():null;t._fullLayout._currentFrame=r,n._lastFrameAt=Date.now(),n._timeToNext=e.frameOpts.duration,f.transition(t,e.frame.data,e.frame.layout,A.coerceTraceIndices(t,e.frame.traces),e.frameOpts,e.transitionOpts).then((function(){e.onComplete&&e.onComplete()})),t.emit("plotly_animatingframe",{name:r,frame:e.frame,animation:{frame:e.frameOpts,transition:e.transitionOpts}})}else t.emit("plotly_animated"),window.cancelAnimationFrame(n._animationRaf),n._animationRaf=null}function p(){t.emit("plotly_animating"),n._lastFrameAt=-1/0,n._timeToNext=0,n._runningTransitions=0,n._currentFrame=null;var e=function(){n._animationRaf=window.requestAnimationFrame(e),Date.now()-n._lastFrameAt>n._timeToNext&&h()};e()}var d,g,m=0;function v(t){return Array.isArray(i)?m>=i.length?t.transitionOpts=i[m]:t.transitionOpts=i[0]:t.transitionOpts=i,m++,t}var y=[],x=null==e,b=Array.isArray(e);if(x||b||!o.isPlainObject(e)){if(x||-1!==["string","number"].indexOf(typeof e))for(d=0;d0&&CC)&&M.push(g);y=M}}y.length>0?function(e){if(0!==e.length){for(var i=0;i=0;n--)if(o.isPlainObject(e[n])){var g=e[n].name,m=(u[g]||d[g]||{}).name,v=e[n].name,y=u[m]||d[m];m&&v&&"number"==typeof v&&y&&Ie.index?-1:t.index=0;n--){if("number"==typeof(i=p[n].frame).name&&o.warn("Warning: addFrames accepts frames with numeric names, but the numbers areimplicitly cast to strings"),!i.name)for(;u[i.name="frame "+t._transitionData._counter++];);if(u[i.name]){for(a=0;a=0;r--)n=e[r],a.push({type:"delete",index:n}),s.unshift({type:"insert",index:n,value:i[n]});var l=f.modifyFrames,u=f.modifyFrames,h=[t,s],p=[t,a];return c&&c.add(t,l,h,u,p),f.modifyFrames(t,a)},r.addTraces=function t(e,n,i){e=o.getGraphDiv(e);var a,s,l=[],u=r.deleteTraces,h=t,f=[e,l],p=[e,n];for(function(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if(void 0===e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&r=0&&r=a.length)return!1;if(2===t.dimensions){if(r++,e.length===r)return t;var o=e[r];if(!A(o))return!1;t=a[i][o]}else t=a[i]}else t=a}}return t}function A(t){return t===Math.round(t)&&t>=0}function C(){var t,e,r={};for(t in d(r,o),n.subplotsRegistry)if((e=n.subplotsRegistry[t]).layoutAttributes)if(Array.isArray(e.attr))for(var i=0;i=l.length)return!1;i=(r=(n.transformsRegistry[l[c].type]||{}).attributes)&&r[e[2]],s=3}else if("area"===t.type)i=u[o];else{var h=t._module;if(h||(h=(n.modules[t.type||a.type.dflt]||{})._module),!h)return!1;if(!(i=(r=h.attributes)&&r[o])){var f=h.basePlotModule;f&&f.attributes&&(i=f.attributes[o])}i||(i=a[o])}return w(i,e,s)},r.getLayoutValObject=function(t,e){return w(function(t,e){var r,i,a,s,l=t._basePlotModules;if(l){var c;for(r=0;r=i&&(r._input||{})._templateitemname;s&&(o=i);var l,c=e+"["+o+"]";function u(){l={},s&&(l[c]={},l[c][a]=s)}function h(t,e){s?n.nestedProperty(l[c],t).set(e):l[c+"."+t]=e}function f(){var t=l;return u(),t}return u(),{modifyBase:function(t,e){l[t]=e},modifyItem:h,getUpdateObj:f,applyUpdate:function(e,r){e&&h(e,r);var i=f();for(var a in i)n.nestedProperty(t,a).set(i[a])}}}},{"../lib":717,"../plots/attributes":762}],756:[function(t,e,r){"use strict";var n=t("d3"),i=t("../registry"),a=t("../plots/plots"),o=t("../lib"),s=t("../lib/clear_gl_canvases"),l=t("../components/color"),c=t("../components/drawing"),u=t("../components/titles"),h=t("../components/modebar"),f=t("../plots/cartesian/axes"),p=t("../constants/alignment"),d=t("../plots/cartesian/constraints"),g=d.enforce,m=d.clean,v=t("../plots/cartesian/autorange").doAutoRange,y="start",x="middle",b="end";function _(t,e,r){for(var n=0;n=t[1]||i[1]<=t[0])&&a[0]e[0])return!0}return!1}function w(t){var e,i,s,u,d,g,m=t._fullLayout,v=m._size,y=v.p,x=f.list(t,"",!0);if(m._paperdiv.style({width:t._context.responsive&&m.autosize&&!t._context._hasZeroWidth&&!t.layout.width?"100%":m.width+"px",height:t._context.responsive&&m.autosize&&!t._context._hasZeroHeight&&!t.layout.height?"100%":m.height+"px"}).selectAll(".main-svg").call(c.setSize,m.width,m.height),t._context.setBackground(t,m.paper_bgcolor),r.drawMainTitle(t),h.manage(t),!m._has("cartesian"))return a.previousPromises(t);function b(t,e,r){var n=t._lw/2;return"x"===t._id.charAt(0)?e?"top"===r?e._offset-y-n:e._offset+e._length+y+n:v.t+v.h*(1-(t.position||0))+n%1:e?"right"===r?e._offset+e._length+y+n:e._offset-y-n:v.l+v.w*(t.position||0)+n%1}for(e=0;eA?u.push({code:"unused",traceType:y,templateCount:w,dataCount:A}):A>w&&u.push({code:"reused",traceType:y,templateCount:w,dataCount:A})}}else u.push({code:"data"});if(function t(e,r){for(var n in e)if("_"!==n.charAt(0)){var a=e[n],o=g(e,n,r);i(a)?(Array.isArray(e)&&!1===a._template&&a.templateitemname&&u.push({code:"missing",path:o,templateitemname:a.templateitemname}),t(a,o)):Array.isArray(a)&&m(a)&&t(a,o)}}({data:p,layout:f},""),u.length)return u.map(v)}},{"../lib":717,"../plots/attributes":762,"../plots/plots":826,"./plot_config":753,"./plot_schema":754,"./plot_template":755}],758:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./plot_api"),a=t("../lib"),o=t("../snapshot/helpers"),s=t("../snapshot/tosvg"),l=t("../snapshot/svgtoimg"),c={format:{valType:"enumerated",values:["png","jpeg","webp","svg"],dflt:"png"},width:{valType:"number",min:1},height:{valType:"number",min:1},scale:{valType:"number",min:0,dflt:1},setBackground:{valType:"any",dflt:!1},imageDataOnly:{valType:"boolean",dflt:!1}};e.exports=function(t,e){var r,u,h,f;function p(t){return!(t in e)||a.validate(e[t],c[t])}if(e=e||{},a.isPlainObject(t)?(r=t.data||[],u=t.layout||{},h=t.config||{},f={}):(t=a.getGraphDiv(t),r=a.extendDeep([],t.data),u=a.extendDeep({},t.layout),h=t._context,f=t._fullLayout||{}),!p("width")&&null!==e.width||!p("height")&&null!==e.height)throw new Error("Height and width should be pixel values.");if(!p("format"))throw new Error("Image format is not jpeg, png, svg or webp.");var d={};function g(t,r){return a.coerce(e,d,c,t,r)}var m=g("format"),v=g("width"),y=g("height"),x=g("scale"),b=g("setBackground"),_=g("imageDataOnly"),w=document.createElement("div");w.style.position="absolute",w.style.left="-5000px",document.body.appendChild(w);var A=a.extendFlat({},u);v?A.width=v:null===e.width&&n(f.width)&&(A.width=f.width),y?A.height=y:null===e.height&&n(f.height)&&(A.height=f.height);var C=a.extendFlat({},h,{_exportedPlot:!0,staticPlot:!0,setBackground:b}),M=o.getRedrawFunc(w);function k(){return new Promise((function(t){setTimeout(t,o.getDelay(w._fullLayout))}))}function I(){return new Promise((function(t,e){var r=s(w,m,x),n=w._fullLayout.width,c=w._fullLayout.height;if(i.purge(w),document.body.removeChild(w),"svg"===m)return t(_?r:o.encodeSVG(r));var u=document.createElement("canvas");u.id=a.randstr(),l({format:m,width:n,height:c,scale:x,canvas:u,svg:r,promise:!0}).then(t).catch(e)}))}return new Promise((function(t,e){i.plot(w,r,A,C).then(M).then(k).then(I).then((function(e){t(function(t){return _?t.replace(o.IMAGE_URL_PREFIX,""):t}(e))})).catch((function(t){e(t)}))}))}},{"../lib":717,"../snapshot/helpers":850,"../snapshot/svgtoimg":852,"../snapshot/tosvg":854,"./plot_api":752,"fast-isnumeric":228}],759:[function(t,e,r){"use strict";var n=t("../lib"),i=t("../plots/plots"),a=t("./plot_schema"),o=t("./plot_config").dfltConfig,s=n.isPlainObject,l=Array.isArray,c=n.isArrayOrTypedArray;function u(t,e,r,i,a,o){o=o||[];for(var h=Object.keys(t),f=0;fx.length&&i.push(d("unused",a,v.concat(x.length)));var M,k,I,T,L,S=x.length,E=Array.isArray(C);if(E&&(S=Math.min(S,C.length)),2===b.dimensions)for(k=0;kx[k].length&&i.push(d("unused",a,v.concat(k,x[k].length)));var D=x[k].length;for(M=0;M<(E?Math.min(D,C[k].length):D);M++)I=E?C[k][M]:C,T=y[k][M],L=x[k][M],n.validate(T,I)?L!==T&&L!==+T&&i.push(d("dynamic",a,v.concat(k,M),T,L)):i.push(d("value",a,v.concat(k,M),T))}else i.push(d("array",a,v.concat(k),y[k]));else for(k=0;k1&&p.push(d("object","layout"))),i.supplyDefaults(g);for(var m=g._fullData,v=r.length,y=0;y0&&((b=M-o(m)-o(v))>k?_/b>I&&(y=m,x=v,I=_/b):_/M>I&&(y={val:m.val,pad:0},x={val:v.val,pad:0},I=_/M));if(f===p){var T=f-1,L=f+1;if(A)if(0===f)a=[0,1];else{var S=(f>0?h:u).reduce((function(t,e){return Math.max(t,o(e))}),0),E=f/(1-Math.min(.5,S/M));a=f>0?[0,E]:[E,0]}else a=C?[Math.max(0,T),Math.max(1,L)]:[T,L]}else A?(y.val>=0&&(y={val:0,pad:0}),x.val<=0&&(x={val:0,pad:0})):C&&(y.val-I*o(y)<0&&(y={val:0,pad:0}),x.val<=0&&(x={val:1,pad:0})),I=(x.val-y.val)/(M-o(y)-o(x)),a=[y.val-I*o(y),x.val+I*o(x)];return d&&a.reverse(),i.simpleMap(a,e.l2r||Number)}function l(t){var e=t._length/20;return"domain"===t.constrain&&t._inputDomain&&(e*=(t._inputDomain[1]-t._inputDomain[0])/(t.domain[1]-t.domain[0])),function(t){return t.pad+(t.extrapad?e:0)}}function c(t,e){var r,n,i,a=e._id,o=t._fullData,s=t._fullLayout,l=[],c=[];function f(t,e){for(r=0;r=r&&(c.extrapad||!o)){s=!1;break}i(e,c.val)&&c.pad<=r&&(o||!c.extrapad)&&(t.splice(l,1),l--)}if(s){var u=a&&0===e;t.push({val:e,pad:u?0:r,extrapad:!u&&o})}}function p(t){return n(t)&&Math.abs(t)=e}e.exports={getAutoRange:s,makePadFn:l,doAutoRange:function(t,e){if(e.setScale(),e.autorange){e.range=s(t,e),e._r=e.range.slice(),e._rl=i.simpleMap(e._r,e.r2l);var r=e._input,n={};n[e._attr+".range"]=e.range,n[e._attr+".autorange"]=e.autorange,o.call("_storeDirectGUIEdit",t.layout,t._fullLayout._preGUI,n),r.range=e.range.slice(),r.autorange=e.autorange}var a=e._anchorAxis;if(a&&a.rangeslider){var l=a.rangeslider[e._name];l&&"auto"===l.rangemode&&(l.range=s(t,e)),a._input.rangeslider[e._name]=i.extendFlat({},l)}},findExtremes:function(t,e,r){r||(r={}),t._m||t.setScale();var i,o,s,l,c,f,d,g,m,v=[],y=[],x=e.length,b=r.padded||!1,_=r.tozero&&("linear"===t.type||"-"===t.type),w="log"===t.type,A=!1,C=r.vpadLinearized||!1;function M(t){if(Array.isArray(t))return A=!0,function(e){return Math.max(Number(t[e]||0),0)};var e=Math.max(Number(t||0),0);return function(){return e}}var k=M((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),I=M((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),T=M(r.vpadplus||r.vpad),L=M(r.vpadminus||r.vpad);if(!A){if(g=1/0,m=-1/0,w)for(i=0;i0&&(g=o),o>m&&o-a&&(g=o),o>m&&o=D;i--)E(i);return{min:v,max:y,opts:r}},concatExtremes:c}},{"../../constants/numerical":693,"../../lib":717,"../../registry":846,"fast-isnumeric":228}],765:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../registry"),s=t("../../lib"),l=t("../../lib/svg_text_utils"),c=t("../../components/titles"),u=t("../../components/color"),h=t("../../components/drawing"),f=t("./layout_attributes"),p=t("./clean_ticks"),d=t("../../constants/numerical"),g=d.ONEAVGYEAR,m=d.ONEAVGMONTH,v=d.ONEDAY,y=d.ONEHOUR,x=d.ONEMIN,b=d.ONESEC,_=d.MINUS_SIGN,w=d.BADNUM,A=t("../../constants/alignment"),C=A.MID_SHIFT,M=A.CAP_SHIFT,k=A.LINE_SPACING,I=A.OPPOSITE_SIDE,T=e.exports={};T.setConvert=t("./set_convert");var L=t("./axis_autotype"),S=t("./axis_ids");T.id2name=S.id2name,T.name2id=S.name2id,T.cleanId=S.cleanId,T.list=S.list,T.listIds=S.listIds,T.getFromId=S.getFromId,T.getFromTrace=S.getFromTrace;var E=t("./autorange");T.getAutoRange=E.getAutoRange,T.findExtremes=E.findExtremes,T.coerceRef=function(t,e,r,n,i,a){var o=n.charAt(n.length-1),l=r._fullLayout._subplots[o+"axis"],c=n+"ref",u={};return i||(i=l[0]||a),a||(a=i),u[c]={valType:"enumerated",values:l.concat(a?[a]:[]),dflt:i},s.coerce(t,e,u,c)},T.coercePosition=function(t,e,r,n,i,a){var o,l;if("paper"===n||"pixel"===n)o=s.ensureNumber,l=r(i,a);else{var c=T.getFromId(e,n);l=r(i,a=c.fraction2r(a)),o=c.cleanPos}t[i]=o(l)},T.cleanPosition=function(t,e,r){return("paper"===r||"pixel"===r?s.ensureNumber:T.getFromId(e,r).cleanPos)(t)},T.redrawComponents=function(t,e){e=e||T.listIds(t);var r=t._fullLayout;function n(n,i,a,s){for(var l=o.getComponentMethod(n,i),c={},u=0;u2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;i.3*f||u(n)||u(a))){var p=r.dtick/2;t+=t+p.8){var o=Number(r.substr(1));a.exactYears>.8&&o%12==0?t=T.tickIncrement(t,"M6","reverse")+1.5*v:a.exactMonths>.8?t=T.tickIncrement(t,"M1","reverse")+15.5*v:t-=v/2;var l=T.tickIncrement(t,r);if(l<=n)return l}return t}(x,t,y,c,a)),m=x;m<=u;)m=T.tickIncrement(m,y,!1,a);return{start:e.c2r(x,0,a),end:e.c2r(m,0,a),size:y,_dataSpan:u-c}},T.prepTicks=function(t){var e=s.simpleMap(t.range,t.r2l);if("auto"===t.tickmode||!t.dtick){var r,n=t.nticks;n||("category"===t.type||"multicategory"===t.type?(r=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/r):(r="y"===t._id.charAt(0)?40:80,n=s.constrain(t._length/r,4,9)+1),"radialaxis"===t._name&&(n*=2)),"array"===t.tickmode&&(n*=100),T.autoTicks(t,Math.abs(e[1]-e[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t.l2r(t._forceTick0))}t.tick0||(t.tick0="date"===t.type?"2000-01-01":0),"date"===t.type&&t.dtick<.1&&(t.dtick=.1),U(t)},T.calcTicks=function(t){T.prepTicks(t);var e=s.simpleMap(t.range,t.r2l);if("array"===t.tickmode)return function(t){var e=t.tickvals,r=t.ticktext,n=new Array(e.length),i=s.simpleMap(t.range,t.r2l),a=1.0001*i[0]-1e-4*i[1],o=1.0001*i[1]-1e-4*i[0],l=Math.min(a,o),c=Math.max(a,o),u=0;Array.isArray(r)||(r=[]);var h="category"===t.type?t.d2l_noadd:t.d2l;"log"===t.type&&"L"!==String(t.dtick).charAt(0)&&(t.dtick="L"+Math.pow(10,Math.floor(Math.min(t.range[0],t.range[1]))-1));for(var f=0;fl&&p=n:h<=n)&&!(o.length>u||h===c);h=T.tickIncrement(h,t.dtick,a,t.calendar)){c=h;var f=!1;l&&h!==(0|h)&&(f=!0),o.push({minor:f,value:h})}ot(t)&&360===Math.abs(e[1]-e[0])&&o.pop(),t._tmax=(o[o.length-1]||{}).value,t._prevDateHead="",t._inCalcTicks=!0;for(var p=new Array(o.length),d=0;d10||"01-01"!==n.substr(5)?t._tickround="d":t._tickround=+e.substr(1)%12==0?"y":"m";else if(e>=v&&a<=10||e>=15*v)t._tickround="d";else if(e>=x&&a<=16||e>=y)t._tickround="M";else if(e>=b&&a<=19||e>=x)t._tickround="S";else{var o=t.l2r(r+e).replace(/^-/,"").length;t._tickround=Math.max(a,o)-20,t._tickround<0&&(t._tickround=4)}}else if(i(e)||"L"===e.charAt(0)){var s=t.range.map(t.r2d||Number);i(e)||(e=Number(e.substr(1))),t._tickround=2-Math.floor(Math.log(e)/Math.LN10+.01);var l=Math.max(Math.abs(s[0]),Math.abs(s[1])),c=Math.floor(Math.log(l)/Math.LN10+.01);Math.abs(c)>3&&(q(t.exponentformat)&&!W(c)?t._tickexponent=3*Math.round((c-1)/3):t._tickexponent=c)}else t._tickround=null}function H(t,e,r){var n=t.tickfont||{};return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}T.autoTicks=function(t,e){var r;function n(t){return Math.pow(t,Math.floor(Math.log(e)/Math.LN10))}if("date"===t.type){t.tick0=s.dateTick0(t.calendar);var a=2*e;a>g?(e/=g,r=n(10),t.dtick="M"+12*V(e,r,z)):a>m?(e/=m,t.dtick="M"+V(e,1,R)):a>v?(t.dtick=V(e,v,N),t.tick0=s.dateTick0(t.calendar,!0)):a>y?t.dtick=V(e,y,R):a>x?t.dtick=V(e,x,F):a>b?t.dtick=V(e,b,F):(r=n(10),t.dtick=V(e,r,z))}else if("log"===t.type){t.tick0=0;var o=s.simpleMap(t.range,t.r2l);if(e>.7)t.dtick=Math.ceil(e);else if(Math.abs(o[1]-o[0])<1){var l=1.5*Math.abs((o[1]-o[0])/e);e=Math.abs(Math.pow(10,o[1])-Math.pow(10,o[0]))/l,r=n(10),t.dtick="L"+V(e,r,z)}else t.dtick=e>.3?"D2":"D1"}else"category"===t.type||"multicategory"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):ot(t)?(t.tick0=0,r=1,t.dtick=V(e,r,Y)):(t.tick0=0,r=n(10),t.dtick=V(e,r,z));if(0===t.dtick&&(t.dtick=1),!i(t.dtick)&&"string"!=typeof t.dtick){var c=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(c)}},T.tickIncrement=function(t,e,r,a){var o=r?-1:1;if(i(e))return t+o*e;var l=e.charAt(0),c=o*Number(e.substr(1));if("M"===l)return s.incrementMonth(t,c,a);if("L"===l)return Math.log(Math.pow(10,t)+c)/Math.LN10;if("D"===l){var u="D2"===e?B:j,h=t+.01*o,f=s.roundUp(s.mod(h,1),u,r);return Math.floor(h)+Math.log(n.round(Math.pow(10,f),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.r2l||Number,r=s.simpleMap(t.range,e),a=r[1]"+l,t._prevDateHead=l)),e.text=c}(t,o,r,c):"log"===u?function(t,e,r,n,a){var o=t.dtick,l=e.x,c=t.tickformat,u="string"==typeof o&&o.charAt(0);if("never"===a&&(a=""),n&&"L"!==u&&(o="L3",u="L"),c||"L"===u)e.text=Z(Math.pow(10,l),t,a,n);else if(i(o)||"D"===u&&s.mod(l+.01,1)<.1){var h=Math.round(l),f=Math.abs(h),p=t.exponentformat;"power"===p||q(p)&&W(h)?(e.text=0===h?1:1===h?"10":"10"+(h>1?"":_)+f+"",e.fontSize*=1.25):("e"===p||"E"===p)&&f>2?e.text="1"+p+(h>0?"+":_)+f:(e.text=Z(Math.pow(10,l),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6))}else{if("D"!==u)throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,s.mod(l,1)))),e.fontSize*=.75}if("D1"===t.dtick){var d=String(e.text).charAt(0);"0"!==d&&"1"!==d||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(l<0?.5:.25)))}}(t,o,0,c,g):"category"===u?function(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}(t,o):"multicategory"===u?function(t,e,r){var n=Math.round(e.x),i=t._categories[n]||[],a=void 0===i[1]?"":String(i[1]),o=void 0===i[0]?"":String(i[0]);r?e.text=o+" - "+a:(e.text=a,e.text2=o)}(t,o,r):ot(t)?function(t,e,r,n,i){if("radians"!==t.thetaunit||r)e.text=Z(e.x,t,i,n);else{var a=e.x/180;if(0===a)e.text="0";else{var o=function(t){function e(t,e){return Math.abs(t-e)<=1e-6}var r=function(t){for(var r=1;!e(Math.round(t*r)/r,t);)r*=10;return r}(t),n=t*r,i=Math.abs(function t(r,n){return e(n,0)?r:t(n,r%n)}(n,r));return[Math.round(n/i),Math.round(r/i)]}(a);if(o[1]>=100)e.text=Z(s.deg2rad(e.x),t,i,n);else{var l=e.x<0;1===o[1]?1===o[0]?e.text="π":e.text=o[0]+"π":e.text=["",o[0],"","⁄","",o[1],"","π"].join(""),l&&(e.text=_+e.text)}}}}(t,o,r,c,g):function(t,e,r,n,i){"never"===i?i="":"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=Z(e.x,t,i,n)}(t,o,0,c,g),n||(t.tickprefix&&!d(t.showtickprefix)&&(o.text=t.tickprefix+o.text),t.ticksuffix&&!d(t.showticksuffix)&&(o.text+=t.ticksuffix)),"boundaries"===t.tickson||t.showdividers){var m=function(e){var r=t.l2p(e);return r>=0&&r<=t._length?e:null};o.xbnd=[m(o.x-.5),m(o.x+t.dtick-.5)]}return o},T.hoverLabelText=function(t,e,r){if(r!==w&&r!==e)return T.hoverLabelText(t,e)+" - "+T.hoverLabelText(t,r);var n="log"===t.type&&e<=0,i=T.tickText(t,t.c2l(n?-e:e),"hover").text;return n?0===e?"0":_+i:i};var G=["f","p","n","μ","m","","k","M","G","T"];function q(t){return"SI"===t||"B"===t}function W(t){return t>14||t<-15}function Z(t,e,r,n){var a=t<0,o=e._tickround,l=r||e.exponentformat||"B",c=e._tickexponent,u=T.getTickFormat(e),h=e.separatethousands;if(n){var f={exponentformat:l,dtick:"none"===e.showexponent?e.dtick:i(t)&&Math.abs(t)||1,range:"none"===e.showexponent?e.range.map(e.r2d):[0,t||1]};U(f),o=(Number(f._tickround)||0)+4,c=f._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return e._numFormat(u)(t).replace(/-/g,_);var p,d=Math.pow(10,-o)/2;if("none"===l&&(c=0),(t=Math.abs(t))"+p+"":"B"===l&&9===c?t+="B":q(l)&&(t+=G[c/3+5])),a?_+t:t}function X(t,e){for(var r=[],n={},i=0;i1&&r=0,a=u(t,e[1])<=0;return(r||i)&&(n||a)}if(t.tickformatstops&&t.tickformatstops.length>0)switch(t.type){case"date":case"linear":for(e=0;e=o(i)))){r=n;break}break;case"log":for(e=0;e0?r.bottom-u:0,h)))),e.automargin){n={x:0,y:0,r:0,l:0,t:0,b:0};var p=[0,1];if("x"===d){if("b"===l?n[l]=e._depth:(n[l]=e._depth=Math.max(r.width>0?u-r.top:0,h),p.reverse()),r.width>0){var m=r.right-(e._offset+e._length);m>0&&(n.xr=1,n.r=m);var v=e._offset-r.left;v>0&&(n.xl=0,n.l=v)}}else if("l"===l?n[l]=e._depth=Math.max(r.height>0?u-r.left:0,h):(n[l]=e._depth=Math.max(r.height>0?r.right-u:0,h),p.reverse()),r.height>0){var y=r.bottom-(e._offset+e._length);y>0&&(n.yb=0,n.b=y);var x=e._offset-r.top;x>0&&(n.yt=1,n.t=x)}n[g]="free"===e.anchor?e.position:e._anchorAxis.domain[p[0]],e.title.text!==f._dfltTitle[d]&&(n[l]+=K(e)+(e.title.standoff||0)),e.mirror&&"free"!==e.anchor&&((i={x:0,y:0,r:0,l:0,t:0,b:0})[c]=e.linewidth,e.mirror&&!0!==e.mirror&&(i[c]+=h),!0===e.mirror||"ticks"===e.mirror?i[g]=e._anchorAxis.domain[p[1]]:"all"!==e.mirror&&"allticks"!==e.mirror||(i[g]=[e._counterDomainMin,e._counterDomainMax][p[1]]))}Z&&(s=o.getComponentMethod("rangeslider","autoMarginOpts")(t,e)),a.autoMargin(t,tt(e),n),a.autoMargin(t,et(e),i),a.autoMargin(t,rt(e),s)})),r.skipTitle||Z&&"bottom"===e.side||q.push((function(){return function(t,e){var r,n=t._fullLayout,i=e._id,a=i.charAt(0),o=e.title.font.size;e.title.hasOwnProperty("standoff")?r=e._depth+e.title.standoff+K(e):(r="multicategory"===e.type?e._depth:10+1.5*o+(e.linewidth?e.linewidth-1:0),r+="x"===a?"top"===e.side?o*(e.showticklabels?1:0):o*(e.showticklabels?1.5:.5):"right"===e.side?o*(e.showticklabels?1:.5):o*(e.showticklabels?.5:0));var s,l,u,f,p=T.getPxPosition(t,e);if("x"===a?(l=e._offset+e._length/2,u="top"===e.side?p-r:p+r):(u=e._offset+e._length/2,l="right"===e.side?p+r:p-r,s={rotate:"-90",offset:0}),"multicategory"!==e.type){var d=e._selections[e._id+"tick"];if(f={selection:d,side:e.side},d&&d.node()&&d.node().parentNode){var g=h.getTranslate(d.node().parentNode);f.offsetLeft=g.x,f.offsetTop=g.y}e.title.hasOwnProperty("standoff")&&(f.pad=0)}return c.draw(t,i+"title",{propContainer:e,propName:e._name+".title.text",placeholder:n._dfltTitle[a],avoid:f,transform:s,attributes:{x:l,y:u,"text-anchor":"middle"}})}(t,e)})),s.syncOrAsync(q)}}function Q(t){var r=p+(t||"tick");return w[r]||(w[r]=function(t,e){var r,n,i,a;return t._selections[e].size()?(r=1/0,n=-1/0,i=1/0,a=-1/0,t._selections[e].each((function(){var t=$(this),e=h.bBox(t.node().parentNode);r=Math.min(r,e.top),n=Math.max(n,e.bottom),i=Math.min(i,e.left),a=Math.max(a,e.right)}))):(r=0,n=0,i=0,a=0),{top:r,bottom:n,left:i,right:a,height:n-r,width:a-i}}(e,r)),w[r]}},T.getTickSigns=function(t){var e=t._id.charAt(0),r={x:"top",y:"right"}[e],n=t.side===r?1:-1,i=[-1,1,n,-n];return"inside"!==t.ticks==("x"===e)&&(i=i.map((function(t){return-t}))),t.side&&i.push({l:-1,t:-1,r:1,b:1}[t.side.charAt(0)]),i},T.makeTransFn=function(t){var e=t._id.charAt(0),r=t._offset;return"x"===e?function(e){return"translate("+(r+t.l2p(e.x))+",0)"}:function(e){return"translate(0,"+(r+t.l2p(e.x))+")"}},T.makeTickPath=function(t,e,r,n){n=void 0!==n?n:t.ticklen;var i=t._id.charAt(0),a=(t.linewidth||1)/2;return"x"===i?"M0,"+(e+a*r)+"v"+n*r:"M"+(e+a*r)+",0h"+n*r},T.makeLabelFns=function(t,e,r){var n=t._id.charAt(0),a="boundaries"!==t.tickson&&"outside"===t.ticks,o=0,l=0;if(a&&(o+=t.ticklen),r&&"outside"===t.ticks){var c=s.deg2rad(r);o=t.ticklen*Math.cos(c)+1,l=t.ticklen*Math.sin(c)}t.showticklabels&&(a||t.showline)&&(o+=.2*t.tickfont.size);var u,h,f,p,d={labelStandoff:o+=(t.linewidth||1)/2,labelShift:l};return"x"===n?(p="bottom"===t.side?1:-1,u=l*p,h=e+o*p,f="bottom"===t.side?1:-.2,d.xFn=function(t){return t.dx+u},d.yFn=function(t){return t.dy+h+t.fontSize*f},d.anchorFn=function(t,e){return i(e)&&0!==e&&180!==e?e*p<0?"end":"start":"middle"},d.heightFn=function(e,r,n){return r<-60||r>60?-.5*n:"top"===t.side?-n:0}):"y"===n&&(p="right"===t.side?1:-1,u=o,h=-l*p,f=90===Math.abs(t.tickangle)?.5:0,d.xFn=function(t){return t.dx+e+(u+t.fontSize*f)*p},d.yFn=function(t){return t.dy+h+t.fontSize*C},d.anchorFn=function(e,r){return i(r)&&90===Math.abs(r)?"middle":"right"===t.side?"start":"end"},d.heightFn=function(e,r,n){return(r*="left"===t.side?1:-1)<-30?-n:r<30?-.5*n:0}),d},T.drawTicks=function(t,e,r){r=r||{};var n=e._id+"tick",i=r.layer.selectAll("path."+n).data(e.ticks?r.vals:[],J);i.exit().remove(),i.enter().append("path").classed(n,1).classed("ticks",1).classed("crisp",!1!==r.crisp).call(u.stroke,e.tickcolor).style("stroke-width",h.crispRound(t,e.tickwidth,1)+"px").attr("d",r.path),i.attr("transform",r.transFn)},T.drawGrid=function(t,e,r){r=r||{};var n=e._id+"grid",i=r.vals,a=r.counterAxis;if(!1===e.showgrid)i=[];else if(a&&T.shouldShowZeroLine(t,e,a))for(var o="array"===e.tickmode,s=0;s1)for(n=1;n2*o}(t,e)?"date":function(t){for(var e=Math.max(1,(t.length-1)/1e3),r=0,n=0,o={},s=0;s2*r}(t)?"category":function(t){if(!t)return!1;for(var e=0;en?1:-1:+(t.substr(1)||1)-+(e.substr(1)||1)},r.getAxisGroup=function(t,e){for(var r=t._axisMatchGroups,n=0;n0;o&&(i="array");var s,l=r("categoryorder",i);"array"===l&&(s=r("categoryarray")),o||"array"!==l||(l=e.categoryorder="trace"),"trace"===l?e._initialCategories=[]:"array"===l?e._initialCategories=s.slice():(s=function(t,e){var r,n,i,a=e.dataAttr||t._id.charAt(0),o={};if(e.axData)r=e.axData;else for(r=[],n=0;nl*x)||A)for(r=0;rP&&RE&&(E=R);p/=(E-S)/(2*D),S=c.l2r(S),E=c.l2r(E),c.range=c._input.range=I=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function O(t,e,r,n,i){return t.append("path").attr("class","zoombox").style({fill:e>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+r+", "+n+")").attr("d",i+"Z")}function z(t,e,r){return t.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+e+", "+r+")").attr("d","M0,0Z")}function R(t,e,r,n,i,a){t.attr("d",n+"M"+r.l+","+r.t+"v"+r.h+"h"+r.w+"v-"+r.h+"h-"+r.w+"Z"),F(t,e,i,a)}function F(t,e,r,n){r||(t.transition().style("fill",n>.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),e.transition().style("opacity",1).duration(200))}function N(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function j(t){I&&t.data&&t._context.showTips&&(s.notifier(s._(t,"Double-click to zoom back out"),"long"),I=!1)}function B(t){return"lasso"===t||"select"===t}function Y(t){var e=Math.floor(Math.min(t.b-t.t,t.r-t.l,k)/2);return"M"+(t.l-3.5)+","+(t.t-.5+e)+"h3v"+-e+"h"+e+"v-3h-"+(e+3)+"ZM"+(t.r+3.5)+","+(t.t-.5+e)+"h-3v"+-e+"h"+-e+"v-3h"+(e+3)+"ZM"+(t.r+3.5)+","+(t.b+.5-e)+"h-3v"+e+"h"+-e+"v3h"+(e+3)+"ZM"+(t.l-3.5)+","+(t.b+.5-e)+"h3v"+e+"h"+e+"v3h-"+(e+3)+"Z"}function V(t,e,r,n){for(var i,a,o,l,c=!1,u={},h={},f=0;f-1&&w(i,t,Z,X,e.id,It),a.indexOf("event")>-1&&h.click(t,i,e.id);else if(1===r&&pt){var s=I?G:F,c="s"===I||"w"===T?0:1,u=s._name+".range["+c+"]",f=function(t,e){var r,i=t.range[e],a=Math.abs(i-t.range[1-e]);return"date"===t.type?i:"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,n.format("."+r+"g")(Math.pow(10,i))):(r=Math.floor(Math.log(Math.abs(i))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,n.format("."+String(r)+"g")(i))}(s,c),p="left",d="middle";if(s.fixedrange)return;I?(d="n"===I?"top":"bottom","right"===s.side&&(p="right")):"e"===T&&(p="right"),t._context.showAxisRangeEntryBoxes&&n.select(mt).call(l.makeEditable,{gd:t,immediate:!0,background:t._fullLayout.paper_bgcolor,text:String(f),fill:s.tickfont?s.tickfont.color:"#444",horizontalAlign:p,verticalAlign:d}).on("edit",(function(e){var r=s.d2r(e);void 0!==r&&o.call("_guiRelayout",t,u,r)}))}}function St(e,r){if(t._transitioningWithDuration)return!1;var n=Math.max(0,Math.min(Q,e+vt)),i=Math.max(0,Math.min($,r+yt)),a=Math.abs(n-vt),o=Math.abs(i-yt);function s(){At="",xt.r=xt.l,xt.t=xt.b,Mt.attr("d","M0,0Z")}if(xt.l=Math.min(vt,n),xt.r=Math.max(vt,n),xt.t=Math.min(yt,i),xt.b=Math.max(yt,i),tt.isSubplotConstrained)a>k||o>k?(At="xy",a/Q>o/$?(o=a*$/Q,yt>i?xt.t=yt-o:xt.b=yt+o):(a=o*Q/$,vt>n?xt.l=vt-a:xt.r=vt+a),Mt.attr("d",Y(xt))):s();else if(et.isSubplotConstrained)if(a>k||o>k){At="xy";var l=Math.min(xt.l/Q,($-xt.b)/$),c=Math.max(xt.r/Q,($-xt.t)/$);xt.l=l*Q,xt.r=c*Q,xt.b=(1-l)*$,xt.t=(1-c)*$,Mt.attr("d",Y(xt))}else s();else!nt||og[1]-1/4096&&(e.domain=s),i.noneOrAll(t.domain,e.domain,s)}return r("layer"),e}},{"../../lib":717,"fast-isnumeric":228}],781:[function(t,e,r){"use strict";var n=t("../../constants/alignment").FROM_BL;e.exports=function(t,e,r){void 0===r&&(r=n[t.constraintoward||"center"]);var i=[t.r2l(t.range[0]),t.r2l(t.range[1])],a=i[0]+(i[1]-i[0])*r;t.range=t._input.range=[t.l2r(a+(i[0]-a)*e),t.l2r(a+(i[1]-a)*e)]}},{"../../constants/alignment":686}],782:[function(t,e,r){"use strict";var n=t("polybooljs"),i=t("../../registry"),a=t("../../components/color"),o=t("../../components/fx"),s=t("../../lib"),l=t("../../lib/polygon"),c=t("../../lib/throttle"),u=t("../../components/fx/helpers").makeEventData,h=t("./axis_ids").getFromId,f=t("../../lib/clear_gl_canvases"),p=t("../../plot_api/subroutines").redrawReglTraces,d=t("./constants"),g=d.MINSELECT,m=l.filter,v=l.tester;function y(t){return t._id}function x(t,e,r,n,i,a,o){var s,l,c,u,h,f,p,d,g,m=e._hoverdata,v=e._fullLayout.clickmode.indexOf("event")>-1,y=[];if(function(t){return t&&Array.isArray(t)&&!0!==t[0].hoverOnBox}(m)){A(t,e,a);var x=function(t,e){var r,n,i=t[0],a=-1,o=[];for(n=0;n0?function(t,e){var r,n,i,a=[];for(i=0;i0&&a.push(r);if(1===a.length&&a[0]===e.searchInfo&&(n=e.searchInfo.cd[0].trace).selectedpoints.length===e.pointNumbers.length){for(i=0;i1)return!1;if((i+=r.selectedpoints.length)>1)return!1}return 1===i}(s)&&(f=I(x))){for(o&&o.remove(),g=0;g0?"M"+i.join("M")+"Z":"M0,0Z",e.attr("d",n)}function I(t){var e=t.searchInfo.cd[0].trace,r=t.pointNumber,n=t.pointNumbers,i=n.length>0?n[0]:r;return!!e.selectedpoints&&e.selectedpoints.indexOf(i)>-1}function T(t,e,r){var n,a,o,s;for(n=0;n-1&&x(e,I,i.xaxes,i.yaxes,i.subplot,i,G),"event"===r&&I.emit("plotly_selected",void 0);o.click(I,e)})).catch(s.error)},i.doneFn=function(){W.remove(),c.done(Z).then((function(){c.clear(Z),i.gd.emit("plotly_selected",_),p&&i.selectionDefs&&(p.subtract=H,i.selectionDefs.push(p),i.mergedPolygons.length=0,[].push.apply(i.mergedPolygons,f)),i.doneFnCompleted&&i.doneFnCompleted(X)})).catch(s.error)}},clearSelect:S,selectOnClick:x}},{"../../components/color":592,"../../components/fx":630,"../../components/fx/helpers":627,"../../lib":717,"../../lib/clear_gl_canvases":702,"../../lib/polygon":729,"../../lib/throttle":742,"../../plot_api/subroutines":756,"../../registry":846,"./axis_ids":768,"./constants":771,polybooljs:475}],783:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=a.cleanNumber,s=a.ms2DateTime,l=a.dateTime2ms,c=a.ensureNumber,u=a.isArrayOrTypedArray,h=t("../../constants/numerical"),f=h.FP_SAFE,p=h.BADNUM,d=h.LOG_CLIP,g=t("./constants"),m=t("./axis_ids");function v(t){return Math.pow(10,t)}function y(t){return null!=t}e.exports=function(t,e){e=e||{};var r=t._id||"x",h=r.charAt(0);function x(e,r){if(e>0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-2*d*Math.abs(n-i))}return p}function b(e,r,n){var o=l(e,n||t.calendar);if(o===p){if(!i(e))return p;e=+e;var s=Math.floor(10*a.mod(e+.05,1)),c=Math.round(e-s/10);o=l(new Date(c))+s/10}return o}function _(e,r,n){return s(e,r,n||t.calendar)}function w(e){return t._categories[Math.round(e)]}function A(e){if(y(e)){if(void 0===t._categoriesMap&&(t._categoriesMap={}),void 0!==t._categoriesMap[e])return t._categoriesMap[e];t._categories.push("number"==typeof e?String(e):e);var r=t._categories.length-1;return t._categoriesMap[e]=r,r}return p}function C(e){if(t._categoriesMap)return t._categoriesMap[e]}function M(t){var e=C(t);return void 0!==e?e:i(t)?+t:void 0}function k(e){return i(e)?n.round(t._b+t._m*e,2):p}function I(e){return(e-t._b)/t._m}t.c2l="log"===t.type?x:c,t.l2c="log"===t.type?v:c,t.l2p=k,t.p2l=I,t.c2p="log"===t.type?function(t,e){return k(x(t,e))}:k,t.p2c="log"===t.type?function(t){return v(I(t))}:I,-1!==["linear","-"].indexOf(t.type)?(t.d2r=t.r2d=t.d2c=t.r2c=t.d2l=t.r2l=o,t.c2d=t.c2r=t.l2d=t.l2r=c,t.d2p=t.r2p=function(e){return t.l2p(o(e))},t.p2d=t.p2r=I,t.cleanPos=c):"log"===t.type?(t.d2r=t.d2l=function(t,e){return x(o(t),e)},t.r2d=t.r2c=function(t){return v(o(t))},t.d2c=t.r2l=o,t.c2d=t.l2r=c,t.c2r=x,t.l2d=v,t.d2p=function(e,r){return t.l2p(t.d2r(e,r))},t.p2d=function(t){return v(I(t))},t.r2p=function(e){return t.l2p(o(e))},t.p2r=I,t.cleanPos=c):"date"===t.type?(t.d2r=t.r2d=a.identity,t.d2c=t.r2c=t.d2l=t.r2l=b,t.c2d=t.c2r=t.l2d=t.l2r=_,t.d2p=t.r2p=function(e,r,n){return t.l2p(b(e,0,n))},t.p2d=t.p2r=function(t,e,r){return _(I(t),e,r)},t.cleanPos=function(e){return a.cleanDate(e,p,t.calendar)}):"category"===t.type?(t.d2c=t.d2l=A,t.r2d=t.c2d=t.l2d=w,t.d2r=t.d2l_noadd=M,t.r2c=function(e){var r=M(e);return void 0!==r?r:t.fraction2r(.5)},t.l2r=t.c2r=c,t.r2l=M,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return w(I(t))},t.r2p=t.d2p,t.p2r=I,t.cleanPos=function(t){return"string"==typeof t&&""!==t?t:c(t)}):"multicategory"===t.type&&(t.r2d=t.c2d=t.l2d=w,t.d2r=t.d2l_noadd=M,t.r2c=function(e){var r=M(e);return void 0!==r?r:t.fraction2r(.5)},t.r2c_just_indices=C,t.l2r=t.c2r=c,t.r2l=M,t.d2p=function(e){return t.l2p(t.r2c(e))},t.p2d=function(t){return w(I(t))},t.r2p=t.d2p,t.p2r=I,t.cleanPos=function(t){return Array.isArray(t)||"string"==typeof t&&""!==t?t:c(t)},t.setupMultiCategory=function(n){var i,o,s=t._traceIndices,l=e._axisMatchGroups;if(l&&l.length&&0===t._categories.length)for(i=0;if&&(s[n]=f),s[0]===s[1]){var c=Math.max(1,Math.abs(1e-6*s[0]));s[0]-=c,s[1]+=c}}else a.nestedProperty(t,e).set(o)},t.setScale=function(r){var n=e._size;if(t.overlaying){var i=m.getFromId({_fullLayout:e},t.overlaying);t.domain=i.domain}var a=r&&t._r?"_r":"range",o=t.calendar;t.cleanRange(a);var s=t.r2l(t[a][0],o),l=t.r2l(t[a][1],o);if("y"===h?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(s-l),t._b=-t._m*l):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(l-s),t._b=-t._m*s),!isFinite(t._m)||!isFinite(t._b)||t._length<0)throw e._replotting=!1,new Error("Something went wrong with axis scaling")},t.makeCalcdata=function(e,r){var n,i,o,s,l=t.type,c="date"===l&&e[r+"calendar"];if(r in e){if(n=e[r],s=e._length||a.minRowLength(n),a.isTypedArray(n)&&("linear"===l||"log"===l)){if(s===n.length)return n;if(n.subarray)return n.subarray(0,s)}if("multicategory"===l)return function(t,e){for(var r=new Array(e),n=0;nr.duration?(function(){for(var r={},n=0;n rect").call(o.setTranslate,0,0).call(o.setScale,1,1),t.plot.call(o.setTranslate,e._offset,r._offset).call(o.setScale,1,1);var n=t.plot.selectAll(".scatterlayer .trace");n.selectAll(".point").call(o.setPointGroupScale,1,1),n.selectAll(".textpoint").call(o.setTextPointsScale,1,1),n.call(o.hideOutsideRangePoints,t)}function m(e,r){var n=e.plotinfo,i=n.xaxis,l=n.yaxis,c=i._length,u=l._length,h=!!e.xr1,f=!!e.yr1,p=[];if(h){var d=a.simpleMap(e.xr0,i.r2l),g=a.simpleMap(e.xr1,i.r2l),m=d[1]-d[0],v=g[1]-g[0];p[0]=(d[0]*(1-r)+r*g[0]-d[0])/(d[1]-d[0])*c,p[2]=c*(1-r+r*v/m),i.range[0]=i.l2r(d[0]*(1-r)+r*g[0]),i.range[1]=i.l2r(d[1]*(1-r)+r*g[1])}else p[0]=0,p[2]=c;if(f){var y=a.simpleMap(e.yr0,l.r2l),x=a.simpleMap(e.yr1,l.r2l),b=y[1]-y[0],_=x[1]-x[0];p[1]=(y[1]*(1-r)+r*x[1]-y[1])/(y[0]-y[1])*u,p[3]=u*(1-r+r*_/b),l.range[0]=i.l2r(y[0]*(1-r)+r*x[0]),l.range[1]=l.l2r(y[1]*(1-r)+r*x[1])}else p[1]=0,p[3]=u;s.drawOne(t,i,{skipTitle:!0}),s.drawOne(t,l,{skipTitle:!0}),s.redrawComponents(t,[i._id,l._id]);var w=h?c/p[2]:1,A=f?u/p[3]:1,C=h?p[0]:0,M=f?p[1]:0,k=h?p[0]/p[2]*c:0,I=f?p[1]/p[3]*u:0,T=i._offset-k,L=l._offset-I;n.clipRect.call(o.setTranslate,C,M).call(o.setScale,1/w,1/A),n.plot.call(o.setTranslate,T,L).call(o.setScale,w,A),o.setPointGroupScale(n.zoomScalePts,1/w,1/A),o.setTextPointsScale(n.zoomScaleTxt,1/w,1/A)}s.redrawComponents(t)}},{"../../components/drawing":613,"../../lib":717,"../../registry":846,"./axes":765,d3:165}],788:[function(t,e,r){"use strict";var n=t("../../registry").traceIs,i=t("./axis_autotype");function a(t){return{v:"x",h:"y"}[t.orientation||"v"]}function o(t,e){var r=a(t),i=n(t,"box-violin"),o=n(t._fullInput||{},"candlestick");return i&&!o&&e===r&&void 0===t[r]&&void 0===t[r+"0"]}e.exports=function(t,e,r,s){"-"===r("type",(s.splomStash||{}).type)&&(function(t,e){if("-"===t.type){var r,s=t._id,l=s.charAt(0);-1!==s.indexOf("scene")&&(s=l);var c=function(t,e,r){for(var n=0;n0&&(i["_"+r+"axes"]||{})[e])return i;if((i[r+"axis"]||r)===e){if(o(i,r))return i;if((i[r]||[]).length||i[r+"0"])return i}}}(e,s,l);if(c)if("histogram"!==c.type||l!=={v:"y",h:"x"}[c.orientation||"v"]){var u=l+"calendar",h=c[u],f={noMultiCategory:!n(c,"cartesian")||n(c,"noMultiCategory")};if("box"===c.type&&c._hasPreCompStats&&l==={h:"x",v:"y"}[c.orientation||"v"]&&(f.noMultiCategory=!0),o(c,l)){var p=a(c),d=[];for(r=0;r0?".":"")+a;i.isPlainObject(o)?l(o,e,s,n+1):e(s,a,o)}}))}r.manageCommandObserver=function(t,e,n,o){var s={},l=!0;e&&e._commandObserver&&(s=e._commandObserver),s.cache||(s.cache={}),s.lookupTable={};var c=r.hasSimpleAPICommandBindings(t,n,s.lookupTable);if(e&&e._commandObserver){if(c)return s;if(e._commandObserver.remove)return e._commandObserver.remove(),e._commandObserver=null,s}if(c){a(t,c,s.cache),s.check=function(){if(l){var e=a(t,c,s.cache);return e.changed&&o&&void 0!==s.lookupTable[e.value]&&(s.disable(),Promise.resolve(o({value:e.value,type:c.type,prop:c.prop,traces:c.traces,index:s.lookupTable[e.value]})).then(s.enable,s.enable)),e.changed}};for(var u=["plotly_relayout","plotly_redraw","plotly_restyle","plotly_update","plotly_animatingframe","plotly_afterplot"],h=0;h0&&i<0&&(i+=360);var s=(i-n)/4;return{type:"Polygon",coordinates:[[[n,a],[n,o],[n+s,o],[n+2*s,o],[n+3*s,o],[i,o],[i,a],[i-s,a],[i-2*s,a],[i-3*s,a],[n,a]]]}}e.exports=function(t){return new b(t)},_.plot=function(t,e,r){var n=this,i=e[this.id],a=[],o=!1;for(var s in m.layerNameToAdjective)if("frame"!==s&&i["show"+s]){o=!0;break}for(var l=0;l0&&a._module.calcGeoJSON(i,e)}if(!this.updateProjection(t,e)){this.viewInitial&&this.scope===r.scope||this.saveViewInitial(r),this.scope=r.scope,this.updateBaseLayers(e,r),this.updateDims(e,r),this.updateFx(e,r),c.generalUpdatePerTraceModule(this.graphDiv,this,t,r);var o=this.layers.frontplot.select(".scatterlayer");this.dataPoints.point=o.selectAll(".point"),this.dataPoints.text=o.selectAll("text"),this.dataPaths.line=o.selectAll(".js-line");var s=this.layers.backplot.select(".choroplethlayer");this.dataPaths.choropleth=s.selectAll("path"),this.render()}},_.updateProjection=function(t,e){var r=this.graphDiv,o=e[this.id],s=e._size,l=o.domain,c=o.projection,u=o.lonaxis,f=o.lataxis,p=u._ax,d=f._ax,g=this.projection=function(t){for(var e=t.projection.type,r=n.geo[m.projNames[e]](),i=t._isClipped?m.lonaxisSpan[e]/2:null,a=["center","rotate","parallels","clipExtent"],o=function(t){return t?r:[]},s=0;si*Math.PI/180}return!1},r.getPath=function(){return n.geo.path().projection(r)},r.getBounds=function(t){return r.getPath().bounds(t)},r.fitExtent=function(t,e){var n=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=r.clipExtent&&r.clipExtent();r.scale(150).translate([0,0]),a&&r.clipExtent(null);var o=r.getBounds(e),s=Math.min(n/(o[1][0]-o[0][0]),i/(o[1][1]-o[0][1])),l=+t[0][0]+(n-s*(o[1][0]+o[0][0]))/2,c=+t[0][1]+(i-s*(o[1][1]+o[0][1]))/2;return a&&r.clipExtent(a),r.scale(150*s).translate([l,c])},r.precision(m.precision),i&&r.clipAngle(i-m.clipPad),r}(o),v=[[s.l+s.w*l.x[0],s.t+s.h*(1-l.y[1])],[s.l+s.w*l.x[1],s.t+s.h*(1-l.y[0])]],y=o.center||{},x=c.rotation||{},b=u.range||[],_=f.range||[];if(o.fitbounds){p._length=v[1][0]-v[0][0],d._length=v[1][1]-v[0][1],p.range=h(r,p),d.range=h(r,d);var A=(p.range[0]+p.range[1])/2,C=(d.range[0]+d.range[1])/2;if(o._isScoped)y={lon:A,lat:C};else if(o._isClipped){y={lon:A,lat:C},x={lon:A,lat:C,roll:x.roll};var M=c.type,k=m.lonaxisSpan[M]/2||180,I=m.lataxisSpan[M]/2||180;b=[A-k,A+k],_=[C-I,C+I]}else y={lon:A,lat:C},x={lon:A,lat:x.lat,roll:x.roll}}g.center([y.lon-x.lon,y.lat-x.lat]).rotate([-x.lon,-x.lat,x.roll]).parallels(c.parallels);var T=w(b,_);g.fitExtent(v,T);var L=this.bounds=g.getBounds(T),S=this.fitScale=g.scale(),E=g.translate();if(!isFinite(L[0][0])||!isFinite(L[0][1])||!isFinite(L[1][0])||!isFinite(L[1][1])||isNaN(E[0])||isNaN(E[0])){for(var D=["fitbounds","projection.rotation","center","lonaxis.range","lataxis.range"],P="Invalid geo settings, relayout'ing to default view.",O={},z=0;z-1&&d(n.event,a,[r.xaxis],[r.yaxis],r.id,h),c.indexOf("event")>-1&&l.click(a,n.event))}))}function m(t){return r.projection.invert([t[0]+r.xaxis._offset,t[1]+r.yaxis._offset])}},_.makeFramework=function(){var t=this,e=t.graphDiv,r=e._fullLayout,i="clip"+r._uid+t.id;t.clipDef=r._clips.append("clipPath").attr("id",i),t.clipRect=t.clipDef.append("rect"),t.framework=n.select(t.container).append("g").attr("class","geo "+t.id).call(s.setClipUrl,i,e),t.project=function(e){var r=t.projection(e);return r?[r[0]-t.xaxis._offset,r[1]-t.yaxis._offset]:[null,null]},t.xaxis={_id:"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={_id:"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,r)},_.saveViewInitial=function(t){var e,r=t.center||{},n=t.projection,i=n.rotation||{};this.viewInitial={fitbounds:t.fitbounds,"projection.scale":n.scale},e=t._isScoped?{"center.lon":r.lon,"center.lat":r.lat}:t._isClipped?{"projection.rotation.lon":i.lon,"projection.rotation.lat":i.lat}:{"center.lon":r.lon,"center.lat":r.lat,"projection.rotation.lon":i.lon},a.extendFlat(this.viewInitial,e)},_.render=function(){var t,e=this.projection,r=e.getPath();function n(t){var r=e(t.lonlat);return r?"translate("+r[0]+","+r[1]+")":null}function i(t){return e.isLonLatOverEdges(t.lonlat)?"none":null}for(t in this.basePaths)this.basePaths[t].attr("d",r);for(t in this.dataPaths)this.dataPaths[t].attr("d",(function(t){return r(t.geojson)}));for(t in this.dataPoints)this.dataPoints[t].attr("display",i).attr("transform",n)}},{"../../components/color":592,"../../components/dragelement":610,"../../components/drawing":613,"../../components/fx":630,"../../lib":717,"../../lib/geo_location_utils":711,"../../lib/topojson_utils":744,"../../registry":846,"../cartesian/autorange":764,"../cartesian/axes":765,"../cartesian/select":782,"../plots":826,"./constants":793,"./projections":798,"./zoom":799,d3:165,"topojson-client":539}],795:[function(t,e,r){"use strict";var n=t("../../plots/get_data").getSubplotCalcData,i=t("../../lib").counterRegex,a=t("./geo"),o="geo",s=i(o),l={};l[o]={valType:"subplotid",dflt:o,editType:"calc"},e.exports={attr:o,name:o,idRoot:o,idRegex:s,attrRegex:s,attributes:l,layoutAttributes:t("./layout_attributes"),supplyLayoutDefaults:t("./layout_defaults"),plot:function(t){for(var e=t._fullLayout,r=t.calcdata,i=e._subplots[o],s=0;s0&&S<0&&(S+=360);var E,D,P,O=(L+S)/2;if(!p){var z=d?h.projRotate:[O,0,0];E=r("projection.rotation.lon",z[0]),r("projection.rotation.lat",z[1]),r("projection.rotation.roll",z[2]),r("showcoastlines",!d&&y)&&(r("coastlinecolor"),r("coastlinewidth")),r("showocean",!!y&&void 0)&&r("oceancolor")}p?(D=-96.6,P=38.7):(D=d?O:E,P=(T[0]+T[1])/2),r("center.lon",D),r("center.lat",P),g&&r("projection.parallels",h.projParallels||[0,60]),r("projection.scale"),r("showland",!!y&&void 0)&&r("landcolor"),r("showlakes",!!y&&void 0)&&r("lakecolor"),r("showrivers",!!y&&void 0)&&(r("rivercolor"),r("riverwidth")),r("showcountries",d&&"usa"!==u&&y)&&(r("countrycolor"),r("countrywidth")),("usa"===u||"north america"===u&&50===c)&&(r("showsubunits",y),r("subunitcolor"),r("subunitwidth")),d||r("showframe",y)&&(r("framecolor"),r("framewidth")),r("bgcolor"),r("fitbounds")&&(delete e.projection.scale,d?(delete e.center.lon,delete e.center.lat):m?(delete e.center.lon,delete e.center.lat,delete e.projection.rotation.lon,delete e.projection.rotation.lat,delete e.lonaxis.range,delete e.lataxis.range):(delete e.center.lon,delete e.center.lat,delete e.projection.rotation.lon))}e.exports=function(t,e,r){i(t,e,r,{type:"geo",attributes:s,handleDefaults:c,fullData:r,partition:"y"})}},{"../../lib":717,"../get_data":800,"../subplot_defaults":840,"./constants":793,"./layout_attributes":796}],798:[function(t,e,r){"use strict";e.exports=function(t){function e(t,e){return{type:"Feature",id:t.id,properties:t.properties,geometry:r(t.geometry,e)}}function r(e,n){if(!e)return null;if("GeometryCollection"===e.type)return{type:"GeometryCollection",geometries:object.geometries.map((function(t){return r(t,n)}))};if(!c.hasOwnProperty(e.type))return null;var i=c[e.type];return t.geo.stream(e,n(i)),i.result()}t.geo.project=function(t,e){var i=e.stream;if(!i)throw new Error("not yet supported");return(t&&n.hasOwnProperty(t.type)?n[t.type]:r)(t,i)};var n={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map((function(t){return e(t,r)}))}}},i=[],a=[],o={point:function(t,e){i.push([t,e])},result:function(){var t=i.length?i.length<2?{type:"Point",coordinates:i[0]}:{type:"MultiPoint",coordinates:i}:null;return i=[],t}},s={lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){i.length&&(a.push(i),i=[])},result:function(){var t=a.length?a.length<2?{type:"LineString",coordinates:a[0]}:{type:"MultiLineString",coordinates:a}:null;return a=[],t}},l={polygonStart:u,lineStart:u,point:function(t,e){i.push([t,e])},lineEnd:function(){var t=i.length;if(t){do{i.push(i[0].slice())}while(++t<4);a.push(i),i=[]}},polygonEnd:u,result:function(){if(!a.length)return null;var t=[],e=[];return a.forEach((function(r){!function(t){if((e=t.length)<4)return!1;for(var e,r=0,n=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++rn^p>n&&r<(f-c)*(n-u)/(p-u)+c&&(i=!i)}return i}(t[0],r))return t.push(e),!0}))||t.push([e])})),a=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},c={Point:o,MultiPoint:o,LineString:s,MultiLineString:s,Polygon:l,MultiPolygon:l,Sphere:l};function u(){}var h=1e-6,f=h*h,p=Math.PI,d=p/2,g=(Math.sqrt(p),p/180),m=180/p;function v(t){return t>1?d:t<-1?-d:Math.asin(t)}function y(t){return t>1?0:t<-1?p:Math.acos(t)}var x=t.geo.projection,b=t.geo.projectionMutator;function _(t,e){var r=(2+d)*Math.sin(e);e/=2;for(var n=0,i=1/0;n<10&&Math.abs(i)>h;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(p*(4+p))*t*(1+Math.cos(e)),2*Math.sqrt(p/(4+p))*Math.sin(e)]}t.geo.interrupt=function(e){var r,n=[[[[-p,0],[0,d],[p,0]]],[[[-p,0],[0,-d],[p,0]]]];function i(t,r){for(var i=r<0?-1:1,a=n[+(r<0)],o=0,s=a.length-1;oa[o][2][0];++o);var l=e(t-a[o][1][0],r);return l[0]+=e(a[o][1][0],i*r>i*a[o][0][1]?a[o][0][1]:r)[0],l}function a(){r=n.map((function(t){return t.map((function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]}))}))}e.invert&&(i.invert=function(t,a){for(var o=r[+(a<0)],s=n[+(a<0)],l=0,u=o.length;l=0;--i){var f;o=180*(f=n[1][i])[0][0]/p,s=180*f[0][1]/p,c=180*f[1][1]/p,u=180*f[2][0]/p,h=180*f[2][1]/p,r.push(l([[u-e,h-e],[u-e,c+e],[o+e,c+e],[o+e,s-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}(),a)},i},o.lobes=function(t){return arguments.length?(n=t.map((function(t){return t.map((function(t){return[[t[0][0]*p/180,t[0][1]*p/180],[t[1][0]*p/180,t[1][1]*p/180],[t[2][0]*p/180,t[2][1]*p/180]]}))})),a(),o):n.map((function(t){return t.map((function(t){return[[180*t[0][0]/p,180*t[0][1]/p],[180*t[1][0]/p,180*t[1][1]/p],[180*t[2][0]/p,180*t[2][1]/p]]}))}))},o},_.invert=function(t,e){var r=.5*e*Math.sqrt((4+p)/p),n=v(r),i=Math.cos(n);return[t/(2/Math.sqrt(p*(4+p))*(1+i)),v((n+r*(i+2))/(2+d))]},(t.geo.eckert4=function(){return x(_)}).raw=_;var w=t.geo.azimuthalEqualArea.raw;function A(t,e){if(arguments.length<2&&(e=t),1===e)return w;if(e===1/0)return C;function r(r,n){var i=w(r/e,n);return i[0]*=t,i}return r.invert=function(r,n){var i=w.invert(r/t,n);return i[0]*=e,i},r}function C(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function M(t,e){return[3*t/(2*p)*Math.sqrt(p*p/3-e*e),e]}function k(t,e){return[t,1.25*Math.log(Math.tan(p/4+.4*e))]}function I(t){return function(e){var r,n=t*Math.sin(e),i=30;do{e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e))}while(Math.abs(r)>h&&--i>0);return e/2}}C.invert=function(t,e){var r=2*v(e/2);return[t*Math.cos(r/2)/Math.cos(r),r]},(t.geo.hammer=function(){var t=2,e=b(A),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}).raw=A,M.invert=function(t,e){return[2/3*p*t/Math.sqrt(p*p/3-e*e),e]},(t.geo.kavrayskiy7=function(){return x(M)}).raw=M,k.invert=function(t,e){return[t,2.5*Math.atan(Math.exp(.8*e))-.625*p]},(t.geo.miller=function(){return x(k)}).raw=k,I(p);var T=function(t,e,r){var n=I(r);function i(r,i){return[t*r*Math.cos(i=n(i)),e*Math.sin(i)]}return i.invert=function(n,i){var a=v(i/e);return[n/(t*Math.cos(a)),v((2*a+Math.sin(2*a))/r)]},i}(Math.SQRT2/d,Math.SQRT2,p);function L(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791)),e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))]}(t.geo.mollweide=function(){return x(T)}).raw=T,L.invert=function(t,e){var r,n=e,i=25;do{var a=n*n,o=a*a;n-=r=(n*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-e)/(1.007226+a*(.045255+o*(.259866*a-.311325-.005916*11*o)))}while(Math.abs(r)>h&&--i>0);return[t/(.8707+(a=n*n)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979)),n]},(t.geo.naturalEarth=function(){return x(L)}).raw=L;var S=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];function E(t,e){var r,n=Math.min(18,36*Math.abs(e)/p),i=Math.floor(n),a=n-i,o=(r=S[i])[0],s=r[1],l=(r=S[++i])[0],c=r[1],u=(r=S[Math.min(19,++i)])[0],h=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?d:-d)*(c+a*(h-s)/2+a*a*(h-2*c+s)/2)]}function D(t,e){return[t*Math.cos(e),e]}function P(t,e){var r,n=Math.cos(e),i=(r=y(n*Math.cos(t/=2)))?r/Math.sin(r):1;return[2*n*Math.sin(t)*i,Math.sin(e)*i]}function O(t,e){var r=P(t,e);return[(r[0]+t/d)/2,(r[1]+e)/2]}S.forEach((function(t){t[1]*=1.0144})),E.invert=function(t,e){var r=e/d,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=S[a][1],s=S[a+1][1],l=S[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,h=2*(Math.abs(r)-s)/c,p=u/c,v=h*(1-p*h*(1-2*p*h));if(v>=0||1===a){n=(e>=0?5:-5)*(v+i);var y,x=50;do{v=(i=Math.min(18,Math.abs(n)/5))-(a=Math.floor(i)),o=S[a][1],s=S[a+1][1],l=S[Math.min(19,a+2)][1],n-=(y=(e>=0?d:-d)*(s+v*(l-o)/2+v*v*(l-2*s+o)/2)-e)*m}while(Math.abs(y)>f&&--x>0);break}}while(--a>=0);var b=S[a][0],_=S[a+1][0],w=S[Math.min(19,a+2)][0];return[t/(_+v*(w-b)/2+v*v*(w-2*_+b)/2),n*g]},(t.geo.robinson=function(){return x(E)}).raw=E,D.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return x(D)}).raw=D,P.invert=function(t,e){if(!(t*t+4*e*e>p*p+h)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),l=Math.cos(r/2),c=Math.sin(n),u=Math.cos(n),f=Math.sin(2*n),d=c*c,g=u*u,m=s*s,v=1-g*l*l,x=v?y(u*l)*Math.sqrt(a=1/v):a=0,b=2*x*u*s-t,_=x*c-e,w=a*(g*m+x*u*l*d),A=a*(.5*o*f-2*x*c*s),C=.25*a*(f*s-x*c*g*o),M=a*(d*l+x*m*u),k=A*C-M*w;if(!k)break;var I=(_*A-b*M)/k,T=(b*C-_*w)/k;r-=I,n-=T}while((Math.abs(I)>h||Math.abs(T)>h)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return x(P)}).raw=P,O.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),l=Math.sin(2*n),c=s*s,u=o*o,f=Math.sin(r),p=Math.cos(r/2),g=Math.sin(r/2),m=g*g,v=1-u*p*p,x=v?y(o*p)*Math.sqrt(a=1/v):a=0,b=.5*(2*x*o*g+r/d)-t,_=.5*(x*s+n)-e,w=.5*a*(u*m+x*o*p*c)+.5/d,A=a*(f*l/4-x*s*g),C=.125*a*(l*g-x*s*u*f),M=.5*a*(c*p+x*m*o)+.5,k=A*C-M*w,I=(_*A-b*M)/k,T=(b*C-_*w)/k;r-=I,n-=T}while((Math.abs(I)>h||Math.abs(T)>h)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return x(O)}).raw=O}},{}],799:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../registry"),o=Math.PI/180,s=180/Math.PI,l={cursor:"pointer"},c={cursor:"auto"};function u(t,e){return n.behavior.zoom().translate(e.translate()).scale(e.scale())}function h(t,e,r){var n=t.id,o=t.graphDiv,s=o.layout,l=s[n],c=o._fullLayout,u=c[n],h={},f={};function p(t,e){h[n+"."+t]=i.nestedProperty(l,t).get(),a.call("_storeDirectGUIEdit",s,c._preGUI,h);var r=i.nestedProperty(u,t);r.get()!==e&&(r.set(e),i.nestedProperty(l,t).set(e),f[n+"."+t]=e)}r(p),p("projection.scale",e.scale()/t.fitScale),p("fitbounds",!1),o.emit("plotly_relayout",f)}function f(t,e){var r=u(0,e);function i(r){var n=e.invert(t.midPt);r("center.lon",n[0]),r("center.lat",n[1])}return r.on("zoomstart",(function(){n.select(this).style(l)})).on("zoom",(function(){e.scale(n.event.scale).translate(n.event.translate),t.render();var r=e.invert(t.midPt);t.graphDiv.emit("plotly_relayouting",{"geo.projection.scale":e.scale()/t.fitScale,"geo.center.lon":r[0],"geo.center.lat":r[1]})})).on("zoomend",(function(){n.select(this).style(c),h(t,e,i)})),r}function p(t,e){var r,i,a,o,s,f,p,d,g,m=u(0,e),v=2;function y(t){return e.invert(t)}function x(r){var n=e.rotate(),i=e.invert(t.midPt);r("projection.rotation.lon",-n[0]),r("center.lon",i[0]),r("center.lat",i[1])}return m.on("zoomstart",(function(){n.select(this).style(l),r=n.mouse(this),i=e.rotate(),a=e.translate(),o=i,s=y(r)})).on("zoom",(function(){if(f=n.mouse(this),function(t){var r=y(t);if(!r)return!0;var n=e(r);return Math.abs(n[0]-t[0])>v||Math.abs(n[1]-t[1])>v}(r))return m.scale(e.scale()),void m.translate(e.translate());e.scale(n.event.scale),e.translate([a[0],n.event.translate[1]]),s?y(f)&&(d=y(f),p=[o[0]+(d[0]-s[0]),i[1],i[2]],e.rotate(p),o=p):s=y(r=f),g=!0,t.render();var l=e.rotate(),c=e.invert(t.midPt);t.graphDiv.emit("plotly_relayouting",{"geo.projection.scale":e.scale()/t.fitScale,"geo.center.lon":c[0],"geo.center.lat":c[1],"geo.projection.rotation.lon":-l[0]})})).on("zoomend",(function(){n.select(this).style(c),g&&h(t,e,x)})),m}function d(t,e){var r,i={r:e.rotate(),k:e.scale()},a=u(0,e),o=function(t){for(var e=0,r=arguments.length,i=[];++ed?(a=(h>0?90:-90)-p,i=0):(a=Math.asin(h/d)*s-p,i=Math.sqrt(d*d-h*h));var g=180-a-2*p,m=(Math.atan2(f,u)-Math.atan2(c,i))*s,v=(Math.atan2(f,u)-Math.atan2(c,-i))*s;return b(r[0],r[1],a,m)<=b(r[0],r[1],g,v)?[a,m,r[2]]:[g,v,r[2]]}function b(t,e,r,n){var i=_(r-t),a=_(n-e);return Math.sqrt(i*i+a*a)}function _(t){return(t%360+540)%360-180}function w(t,e,r){var n=r*o,i=t.slice(),a=0===e?1:0,s=2===e?1:2,l=Math.cos(n),c=Math.sin(n);return i[a]=t[a]*l-t[s]*c,i[s]=t[s]*l+t[a]*c,i}function A(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*s,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*s,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*s]}function C(t,e){for(var r=0,n=0,i=t.length;nMath.abs(s)?(c.boxEnd[1]=c.boxStart[1]+Math.abs(a)*_*(s>=0?1:-1),c.boxEnd[1]l[3]&&(c.boxEnd[1]=l[3],c.boxEnd[0]=c.boxStart[0]+(l[3]-c.boxStart[1])/Math.abs(_))):(c.boxEnd[0]=c.boxStart[0]+Math.abs(s)/_*(a>=0?1:-1),c.boxEnd[0]l[2]&&(c.boxEnd[0]=l[2],c.boxEnd[1]=c.boxStart[1]+(l[2]-c.boxStart[0])*Math.abs(_)))}}else c.boxEnabled?(a=c.boxStart[0]!==c.boxEnd[0],s=c.boxStart[1]!==c.boxEnd[1],a||s?(a&&(m(0,c.boxStart[0],c.boxEnd[0]),t.xaxis.autorange=!1),s&&(m(1,c.boxStart[1],c.boxEnd[1]),t.yaxis.autorange=!1),t.relayoutCallback()):t.glplot.setDirty(),c.boxEnabled=!1,c.boxInited=!1):c.boxInited&&(c.boxInited=!1);break;case"pan":c.boxEnabled=!1,c.boxInited=!1,e?(c.panning||(c.dragStart[0]=n,c.dragStart[1]=i),Math.abs(c.dragStart[0]-n).999&&(m="turntable"):m="turntable")}else m="turntable";r("dragmode",m),r("hovermode",n.getDfltFromLayout("hovermode"))}e.exports=function(t,e,r){var i=e._basePlotModules.length>1;o(t,e,r,{type:u,attributes:l,handleDefaults:h,fullLayout:e,font:e.font,fullData:r,getDfltFromLayout:function(e){if(!i)return n.validate(t[e],l[e])?t[e]:void 0},paper_bgcolor:e.paper_bgcolor,calendar:e.calendar})}},{"../../../components/color":592,"../../../lib":717,"../../../registry":846,"../../get_data":800,"../../subplot_defaults":840,"./axis_defaults":808,"./layout_attributes":811}],811:[function(t,e,r){"use strict";var n=t("./axis_attributes"),i=t("../../domain").attributes,a=t("../../../lib/extend").extendFlat,o=t("../../../lib").counterRegex;function s(t,e,r){return{x:{valType:"number",dflt:t,editType:"camera"},y:{valType:"number",dflt:e,editType:"camera"},z:{valType:"number",dflt:r,editType:"camera"},editType:"camera"}}e.exports={_arrayAttrRegexps:[o("scene",".annotations",!0)],bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)",editType:"plot"},camera:{up:a(s(0,0,1),{}),center:a(s(0,0,0),{}),eye:a(s(1.25,1.25,1.25),{}),projection:{type:{valType:"enumerated",values:["perspective","orthographic"],dflt:"perspective",editType:"calc"},editType:"calc"},editType:"camera"},domain:i({name:"scene",editType:"plot"}),aspectmode:{valType:"enumerated",values:["auto","cube","data","manual"],dflt:"auto",editType:"plot",impliedEdits:{"aspectratio.x":void 0,"aspectratio.y":void 0,"aspectratio.z":void 0}},aspectratio:{x:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},y:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},z:{valType:"number",min:0,editType:"plot",impliedEdits:{"^aspectmode":"manual"}},editType:"plot",impliedEdits:{aspectmode:"manual"}},xaxis:n,yaxis:n,zaxis:n,dragmode:{valType:"enumerated",values:["orbit","turntable","zoom","pan",!1],editType:"plot"},hovermode:{valType:"enumerated",values:["closest",!1],dflt:"closest",editType:"modebar"},uirevision:{valType:"any",editType:"none"},editType:"plot",_deprecated:{cameraposition:{valType:"info_array",editType:"camera"}}}},{"../../../lib":717,"../../../lib/extend":708,"../../domain":790,"./axis_attributes":807}],812:[function(t,e,r){"use strict";var n=t("../../../lib/str2rgbarray"),i=["xaxis","yaxis","zaxis"];function a(){this.enabled=[!0,!0,!0],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.drawSides=[!0,!0,!0],this.lineWidth=[1,1,1]}a.prototype.merge=function(t){for(var e=0;e<3;++e){var r=t[i[e]];r.visible?(this.enabled[e]=r.showspikes,this.colors[e]=n(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness):(this.enabled[e]=!1,this.drawSides[e]=!1)}},e.exports=function(t){var e=new a;return e.merge(t),e}},{"../../../lib/str2rgbarray":740}],813:[function(t,e,r){"use strict";e.exports=function(t){for(var e=t.axesOptions,r=t.glplot.axesPixels,s=t.fullSceneLayout,l=[[],[],[]],c=0;c<3;++c){var u=s[a[c]];if(u._length=(r[c].hi-r[c].lo)*r[c].pixelsPerDataUnit/t.dataScale[c],Math.abs(u._length)===1/0||isNaN(u._length))l[c]=[];else{u._input_range=u.range.slice(),u.range[0]=r[c].lo/t.dataScale[c],u.range[1]=r[c].hi/t.dataScale[c],u._m=1/(t.dataScale[c]*r[c].pixelsPerDataUnit),u.range[0]===u.range[1]&&(u.range[0]-=1,u.range[1]+=1);var h=u.tickmode;if("auto"===u.tickmode){u.tickmode="linear";var f=u.nticks||i.constrain(u._length/40,4,9);n.autoTicks(u,Math.abs(u.range[1]-u.range[0])/f)}for(var p=n.calcTicks(u),d=0;d/g," "));l[c]=p,u.tickmode=h}}for(e.ticks=l,c=0;c<3;++c)for(o[c]=.5*(t.glplot.bounds[0][c]+t.glplot.bounds[1][c]),d=0;d<2;++d)e.bounds[d][c]=t.glplot.bounds[d][c];t.contourLevels=function(t){for(var e=new Array(3),r=0;r<3;++r){for(var n=t[r],i=new Array(n.length),a=0;a1&&(e=!0),e}();function w(t,e){var r=document.createElement("div"),n=t.container;this.graphDiv=t.graphDiv;var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.top=i.style.left="0px",i.style.width=i.style.height="100%",i.style["z-index"]=20,i.style["pointer-events"]="none",r.appendChild(i),this.svgContainer=i,r.id=t.id,r.style.position="absolute",r.style.top=r.style.left="0px",r.style.width=r.style.height="100%",n.appendChild(r),this.fullLayout=e,this.id=t.id||"scene",this.fullSceneLayout=e[this.id],this.plotArgs=[[],{},{}],this.axesOptions=v(e,e[this.id]),this.spikeOptions=y(e[this.id]),this.container=r,this.staticMode=!!t.staticPlot,this.pixelRatio=this.pixelRatio||t.plotGlPixelRatio||2,this.dataScale=[1,1,1],this.contourLevels=[[],[],[]],this.convertAnnotations=u.getComponentMethod("annotations3d","convert"),this.drawAnnotations=u.getComponentMethod("annotations3d","draw"),this.initializeGLPlot()}var A=w.prototype;A.tryCreatePlot=function(){var t={canvas:this.canvas,gl:this.gl,glOptions:{preserveDrawingBuffer:_,premultipliedAlpha:!0,antialias:!0},container:this.container,axes:this.axesOptions,spikes:this.spikeOptions,pickRadius:10,snapToData:!0,autoScale:!0,autoBounds:!1,cameraObject:this.camera,pixelRatio:this.pixelRatio};if(this.staticMode){if(!(i||(n=document.createElement("canvas"),i=l({canvas:n,preserveDrawingBuffer:!0,premultipliedAlpha:!0,antialias:!0}))))throw new Error("error creating static canvas/context for image server");t.gl=i,t.canvas=n}var e=0;try{this.glplot=s(t)}catch(r){e++;try{this.glplot=s(t)}catch(t){e++}}return e<2},A.initializeGLCamera=function(){var t=this.fullSceneLayout.camera,e="orthographic"===t.projection.type;this.camera=o(this.container,{center:[t.center.x,t.center.y,t.center.z],eye:[t.eye.x,t.eye.y,t.eye.z],up:[t.up.x,t.up.y,t.up.z],_ortho:e,zoomMin:.01,zoomMax:100,mode:"orbit"})},A.initializeGLPlot=function(){var t=this;if(t.initializeGLCamera(),!t.tryCreatePlot())return g(t);t.traces={},t.make4thDimension();var e=t.graphDiv,r=e.layout,n=function(){var e={};return t.isCameraChanged(r)&&(e[t.id+".camera"]=t.getCamera()),t.isAspectChanged(r)&&(e[t.id+".aspectratio"]=t.glplot.getAspectratio()),e},i=function(t){if(!1!==t.fullSceneLayout.dragmode){var e=n();t.saveLayout(r),t.graphDiv.emit("plotly_relayout",e)}};return t.glplot.canvas.addEventListener("mouseup",(function(){i(t)})),t.glplot.canvas.addEventListener("wheel",(function(r){if(e._context._scrollZoom.gl3d){if(t.camera._ortho){var n=r.deltaX>r.deltaY?1.1:1/1.1,a=t.glplot.getAspectratio();t.glplot.setAspectratio({x:n*a.x,y:n*a.y,z:n*a.z})}i(t)}}),!!c&&{passive:!1}),t.glplot.canvas.addEventListener("mousemove",(function(){if(!1!==t.fullSceneLayout.dragmode&&0!==t.camera.mouseListener.buttons){var e=n();t.graphDiv.emit("plotly_relayouting",e)}})),t.staticMode||t.glplot.canvas.addEventListener("webglcontextlost",(function(r){e&&e.emit&&e.emit("plotly_webglcontextlost",{event:r,layer:t.id})}),!1),t.glplot.oncontextloss=function(){t.recoverContext()},t.glplot.onrender=function(){t.render()},!0},A.render=function(){var t,e=this,r=e.graphDiv,n=e.svgContainer,i=e.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),x(e),e.glplot.axes.update(e.axesOptions);for(var s,l=Object.keys(e.traces),c=null,u=e.glplot.selection,d=0;d")):"isosurface"===t.type||"volume"===t.type?(w.valueLabel=f.tickText(e._mockAxis,e._mockAxis.d2l(u.traceCoordinate[3]),"hover").text,k.push("value: "+w.valueLabel),u.textLabel&&k.push(u.textLabel),y=k.join("
")):y=u.textLabel;var I={x:u.traceCoordinate[0],y:u.traceCoordinate[1],z:u.traceCoordinate[2],data:b._input,fullData:b,curveNumber:b.index,pointNumber:_};p.appendArrayPointValue(I,b,_),t._module.eventData&&(I=b._module.eventData(I,u,b,{},_));var T={points:[I]};e.fullSceneLayout.hovermode&&p.loneHover({trace:b,x:(.5+.5*v[0]/v[3])*a,y:(.5-.5*v[1]/v[3])*o,xLabel:w.xLabel,yLabel:w.yLabel,zLabel:w.zLabel,text:y,name:c.name,color:p.castHoverOption(b,_,"bgcolor")||c.color,borderColor:p.castHoverOption(b,_,"bordercolor"),fontFamily:p.castHoverOption(b,_,"font.family"),fontSize:p.castHoverOption(b,_,"font.size"),fontColor:p.castHoverOption(b,_,"font.color"),nameLength:p.castHoverOption(b,_,"namelength"),textAlign:p.castHoverOption(b,_,"align"),hovertemplate:h.castOption(b,_,"hovertemplate"),hovertemplateLabels:h.extendFlat({},I,w),eventData:[I]},{container:n,gd:r}),u.buttons&&u.distance<5?r.emit("plotly_click",T):r.emit("plotly_hover",T),s=T}else p.loneUnhover(n),r.emit("plotly_unhover",s);e.drawAnnotations(e)},A.recoverContext=function(){var t=this;t.glplot.dispose();var e=function(){t.glplot.gl.isContextLost()?requestAnimationFrame(e):t.initializeGLPlot()?t.plot.apply(t,t.plotArgs):h.error("Catastrophic and unrecoverable WebGL error. Context lost.")};requestAnimationFrame(e)};var C=["xaxis","yaxis","zaxis"];function M(t,e,r){for(var n=t.fullSceneLayout,i=0;i<3;i++){var a=C[i],o=a.charAt(0),s=n[a],l=e[o],c=e[o+"calendar"],u=e["_"+o+"length"];if(h.isArrayOrTypedArray(l))for(var f,p=0;p<(u||l.length);p++)if(h.isArrayOrTypedArray(l[p]))for(var d=0;dg[1][a])g[0][a]=-1,g[1][a]=1;else{var T=g[1][a]-g[0][a];g[0][a]-=T/32,g[1][a]+=T/32}if("reversed"===s.autorange){var L=g[0][a];g[0][a]=g[1][a],g[1][a]=L}}else{var S=s.range;g[0][a]=s.r2l(S[0]),g[1][a]=s.r2l(S[1])}g[0][a]===g[1][a]&&(g[0][a]-=1,g[1][a]+=1),m[a]=g[1][a]-g[0][a],this.glplot.setBounds(a,{min:g[0][a]*f[a],max:g[1][a]*f[a]})}var E,D=[1,1,1];for(a=0;a<3;++a){var P=v[l=(s=c[C[a]]).type];D[a]=Math.pow(P.acc,1/P.count)/f[a]}if("auto"===c.aspectmode)E=Math.max.apply(null,D)/Math.min.apply(null,D)<=4?D:[1,1,1];else if("cube"===c.aspectmode)E=[1,1,1];else if("data"===c.aspectmode)E=D;else{if("manual"!==c.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var O=c.aspectratio;E=[O.x,O.y,O.z]}c.aspectratio.x=u.aspectratio.x=E[0],c.aspectratio.y=u.aspectratio.y=E[1],c.aspectratio.z=u.aspectratio.z=E[2],this.glplot.setAspectratio(c.aspectratio),this.viewInitial.aspectratio||(this.viewInitial.aspectratio={x:c.aspectratio.x,y:c.aspectratio.y,z:c.aspectratio.z});var z=c.domain||null,R=e._size||null;if(z&&R){var F=this.container.style;F.position="absolute",F.left=R.l+z.x[0]*R.w+"px",F.top=R.t+(1-z.y[1])*R.h+"px",F.width=R.w*(z.x[1]-z.x[0])+"px",F.height=R.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},A.destroy=function(){this.glplot&&(this.camera.mouseListener.enabled=!1,this.container.removeEventListener("wheel",this.camera.wheelListener),this.camera=null,this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null)},A.getCamera=function(){var t;return this.camera.view.recalcMatrix(this.camera.view.lastT()),{up:{x:(t=this.camera).up[0],y:t.up[1],z:t.up[2]},center:{x:t.center[0],y:t.center[1],z:t.center[2]},eye:{x:t.eye[0],y:t.eye[1],z:t.eye[2]},projection:{type:!0===t._ortho?"orthographic":"perspective"}}},A.setViewport=function(t){var e,r=t.camera;this.camera.lookAt.apply(this,[[(e=r).eye.x,e.eye.y,e.eye.z],[e.center.x,e.center.y,e.center.z],[e.up.x,e.up.y,e.up.z]]),this.glplot.setAspectratio(t.aspectratio),"orthographic"===r.projection.type!==this.camera._ortho&&(this.glplot.redraw(),this.glplot.clearRGBA(),this.glplot.dispose(),this.initializeGLPlot())},A.isCameraChanged=function(t){var e=this.getCamera(),r=h.nestedProperty(t,this.id+".camera").get();function n(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var i=!1;if(void 0===r)i=!0;else{for(var a=0;a<3;a++)for(var o=0;o<3;o++)if(!n(e,r,a,o)){i=!0;break}(!r.projection||e.projection&&e.projection.type!==r.projection.type)&&(i=!0)}return i},A.isAspectChanged=function(t){var e=this.glplot.getAspectratio(),r=h.nestedProperty(t,this.id+".aspectratio").get();return void 0===r||r.x!==e.x||r.y!==e.y||r.z!==e.z},A.saveLayout=function(t){var e,r,n,i,a,o,s=this.fullLayout,l=this.isCameraChanged(t),c=this.isAspectChanged(t),f=l||c;if(f){var p={};l&&(e=this.getCamera(),n=(r=h.nestedProperty(t,this.id+".camera")).get(),p[this.id+".camera"]=n),c&&(i=this.glplot.getAspectratio(),o=(a=h.nestedProperty(t,this.id+".aspectratio")).get(),p[this.id+".aspectratio"]=o),u.call("_storeDirectGUIEdit",t,s._preGUI,p),l&&(r.set(e),h.nestedProperty(s,this.id+".camera").set(e)),c&&(a.set(i),h.nestedProperty(s,this.id+".aspectratio").set(i),this.glplot.redraw())}return f},A.updateFx=function(t,e){var r=this.camera;if(r)if("orbit"===t)r.mode="orbit",r.keyBindingMode="rotate";else if("turntable"===t){r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate";var n=this.graphDiv,i=n._fullLayout,a=this.fullSceneLayout.camera,o=a.up.x,s=a.up.y,l=a.up.z;if(l/Math.sqrt(o*o+s*s+l*l)<.999){var c=this.id+".camera.up",f={x:0,y:0,z:1},p={};p[c]=f;var d=n.layout;u.call("_storeDirectGUIEdit",d,i._preGUI,p),a.up=f,h.nestedProperty(d,c).set(f)}}else r.keyBindingMode=t;this.fullSceneLayout.hovermode=e},A.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(n),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,i=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var a=new Uint8Array(r*i*4);e.readPixels(0,0,r,i,e.RGBA,e.UNSIGNED_BYTE,a);for(var o=0,s=i-1;o© OpenStreetMap',tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png","https://b.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-osm-tiles",type:"raster",source:"plotly-osm-tiles",minzoom:0,maxzoom:22}]},"white-bg":{id:"white-bg",version:8,sources:{},layers:[{id:"white-bg",type:"background",paint:{"background-color":"#FFFFFF"},minzoom:0,maxzoom:22}]},"carto-positron":{id:"carto-positron",version:8,sources:{"plotly-carto-positron":{type:"raster",attribution:'© CARTO',tiles:["https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-carto-positron",type:"raster",source:"plotly-carto-positron",minzoom:0,maxzoom:22}]},"carto-darkmatter":{id:"carto-darkmatter",version:8,sources:{"plotly-carto-darkmatter":{type:"raster",attribution:'© CARTO',tiles:["https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-carto-darkmatter",type:"raster",source:"plotly-carto-darkmatter",minzoom:0,maxzoom:22}]},"stamen-terrain":{id:"stamen-terrain",version:8,sources:{"plotly-stamen-terrain":{type:"raster",attribution:'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under ODbL.',tiles:["https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-stamen-terrain",type:"raster",source:"plotly-stamen-terrain",minzoom:0,maxzoom:22}]},"stamen-toner":{id:"stamen-toner",version:8,sources:{"plotly-stamen-toner":{type:"raster",attribution:'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under ODbL.',tiles:["https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-stamen-toner",type:"raster",source:"plotly-stamen-toner",minzoom:0,maxzoom:22}]},"stamen-watercolor":{id:"stamen-watercolor",version:8,sources:{"plotly-stamen-watercolor":{type:"raster",attribution:'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under CC BY SA.',tiles:["https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png"],tileSize:256}},layers:[{id:"plotly-stamen-watercolor",type:"raster",source:"plotly-stamen-watercolor",minzoom:0,maxzoom:22}]}},i=Object.keys(n);e.exports={requiredVersion:"1.3.2",styleUrlPrefix:"mapbox://styles/mapbox/",styleUrlSuffix:"v9",styleValuesMapbox:["basic","streets","outdoors","light","dark","satellite","satellite-streets"],styleValueDflt:"basic",stylesNonMapbox:n,styleValuesNonMapbox:i,traceLayerPrefix:"plotly-trace-layer-",layoutLayerPrefix:"plotly-layout-layer-",wrongVersionErrorMsg:["Your custom plotly.js bundle is not using the correct mapbox-gl version","Please install mapbox-gl@1.3.2."].join("\n"),noAccessTokenErrorMsg:["Missing Mapbox access token.","Mapbox trace type require a Mapbox access token to be registered.","For example:"," Plotly.plot(gd, data, layout, { mapboxAccessToken: 'my-access-token' });","More info here: https://www.mapbox.com/help/define-access-token/"].join("\n"),missingStyleErrorMsg:["No valid mapbox style found, please set `mapbox.style` to one of:",i.join(", "),"or register a Mapbox access token to use a Mapbox-served style."].join("\n"),multipleTokensErrorMsg:["Set multiple mapbox access token across different mapbox subplot,","using first token found as mapbox-gl does not allow multipleaccess tokens on the same page."].join("\n"),mapOnErrorMsg:"Mapbox error.",mapboxLogo:{path0:"m 10.5,1.24 c -5.11,0 -9.25,4.15 -9.25,9.25 0,5.1 4.15,9.25 9.25,9.25 5.1,0 9.25,-4.15 9.25,-9.25 0,-5.11 -4.14,-9.25 -9.25,-9.25 z m 4.39,11.53 c -1.93,1.93 -4.78,2.31 -6.7,2.31 -0.7,0 -1.41,-0.05 -2.1,-0.16 0,0 -1.02,-5.64 2.14,-8.81 0.83,-0.83 1.95,-1.28 3.13,-1.28 1.27,0 2.49,0.51 3.39,1.42 1.84,1.84 1.89,4.75 0.14,6.52 z",path1:"M 10.5,-0.01 C 4.7,-0.01 0,4.7 0,10.49 c 0,5.79 4.7,10.5 10.5,10.5 5.8,0 10.5,-4.7 10.5,-10.5 C 20.99,4.7 16.3,-0.01 10.5,-0.01 Z m 0,19.75 c -5.11,0 -9.25,-4.15 -9.25,-9.25 0,-5.1 4.14,-9.26 9.25,-9.26 5.11,0 9.25,4.15 9.25,9.25 0,5.13 -4.14,9.26 -9.25,9.26 z",path2:"M 14.74,6.25 C 12.9,4.41 9.98,4.35 8.23,6.1 5.07,9.27 6.09,14.91 6.09,14.91 c 0,0 5.64,1.02 8.81,-2.14 C 16.64,11 16.59,8.09 14.74,6.25 Z m -2.27,4.09 -0.91,1.87 -0.9,-1.87 -1.86,-0.91 1.86,-0.9 0.9,-1.87 0.91,1.87 1.86,0.9 z",polygon:"11.56,12.21 10.66,10.34 8.8,9.43 10.66,8.53 11.56,6.66 12.47,8.53 14.33,9.43 12.47,10.34"},styleRules:{map:"overflow:hidden;position:relative;","missing-css":"display:none;",canary:"background-color:salmon;","ctrl-bottom-left":"position: absolute; pointer-events: none; z-index: 2; bottom: 0; left: 0;","ctrl-bottom-right":"position: absolute; pointer-events: none; z-index: 2; right: 0; bottom: 0;",ctrl:"clear: both; pointer-events: auto; transform: translate(0, 0);","ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner":"display: none;","ctrl-attrib.mapboxgl-compact:hover .mapboxgl-ctrl-attrib-inner":"display: block; margin-top:2px","ctrl-attrib.mapboxgl-compact:hover":"padding: 2px 24px 2px 4px; visibility: visible; margin-top: 6px;","ctrl-attrib.mapboxgl-compact::after":'content: ""; cursor: pointer; position: absolute; background-image: url(\'data:image/svg+xml;charset=utf-8,%3Csvg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"%3E %3Cpath fill="%23333333" fill-rule="evenodd" d="M4,10a6,6 0 1,0 12,0a6,6 0 1,0 -12,0 M9,7a1,1 0 1,0 2,0a1,1 0 1,0 -2,0 M9,10a1,1 0 1,1 2,0l0,3a1,1 0 1,1 -2,0"/%3E %3C/svg%3E\'); background-color: rgba(255, 255, 255, 0.5); width: 24px; height: 24px; box-sizing: border-box; border-radius: 12px;',"ctrl-attrib.mapboxgl-compact":"min-height: 20px; padding: 0; margin: 10px; position: relative; background-color: #fff; border-radius: 3px 12px 12px 3px;","ctrl-bottom-right > .mapboxgl-ctrl-attrib.mapboxgl-compact::after":"bottom: 0; right: 0","ctrl-bottom-left > .mapboxgl-ctrl-attrib.mapboxgl-compact::after":"bottom: 0; left: 0","ctrl-bottom-left .mapboxgl-ctrl":"margin: 0 0 10px 10px; float: left;","ctrl-bottom-right .mapboxgl-ctrl":"margin: 0 10px 10px 0; float: right;","ctrl-attrib":"color: rgba(0, 0, 0, 0.75); text-decoration: none; font-size: 12px","ctrl-attrib a":"color: rgba(0, 0, 0, 0.75); text-decoration: none; font-size: 12px","ctrl-attrib a:hover":"color: inherit; text-decoration: underline;","ctrl-attrib .mapbox-improve-map":"font-weight: bold; margin-left: 2px;","attrib-empty":"display: none;","ctrl-logo":'display:block; width: 21px; height: 21px; background-image: url(\'data:image/svg+xml;charset=utf-8,%3C?xml version="1.0" encoding="utf-8"?%3E %3Csvg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 21 21" style="enable-background:new 0 0 21 21;" xml:space="preserve"%3E%3Cg transform="translate(0,0.01)"%3E%3Cpath d="m 10.5,1.24 c -5.11,0 -9.25,4.15 -9.25,9.25 0,5.1 4.15,9.25 9.25,9.25 5.1,0 9.25,-4.15 9.25,-9.25 0,-5.11 -4.14,-9.25 -9.25,-9.25 z m 4.39,11.53 c -1.93,1.93 -4.78,2.31 -6.7,2.31 -0.7,0 -1.41,-0.05 -2.1,-0.16 0,0 -1.02,-5.64 2.14,-8.81 0.83,-0.83 1.95,-1.28 3.13,-1.28 1.27,0 2.49,0.51 3.39,1.42 1.84,1.84 1.89,4.75 0.14,6.52 z" style="opacity:0.9;fill:%23ffffff;enable-background:new" class="st0"/%3E%3Cpath d="M 10.5,-0.01 C 4.7,-0.01 0,4.7 0,10.49 c 0,5.79 4.7,10.5 10.5,10.5 5.8,0 10.5,-4.7 10.5,-10.5 C 20.99,4.7 16.3,-0.01 10.5,-0.01 Z m 0,19.75 c -5.11,0 -9.25,-4.15 -9.25,-9.25 0,-5.1 4.14,-9.26 9.25,-9.26 5.11,0 9.25,4.15 9.25,9.25 0,5.13 -4.14,9.26 -9.25,9.26 z" style="opacity:0.35;enable-background:new" class="st1"/%3E%3Cpath d="M 14.74,6.25 C 12.9,4.41 9.98,4.35 8.23,6.1 5.07,9.27 6.09,14.91 6.09,14.91 c 0,0 5.64,1.02 8.81,-2.14 C 16.64,11 16.59,8.09 14.74,6.25 Z m -2.27,4.09 -0.91,1.87 -0.9,-1.87 -1.86,-0.91 1.86,-0.9 0.9,-1.87 0.91,1.87 1.86,0.9 z" style="opacity:0.35;enable-background:new" class="st1"/%3E%3Cpolygon points="11.56,12.21 10.66,10.34 8.8,9.43 10.66,8.53 11.56,6.66 12.47,8.53 14.33,9.43 12.47,10.34 " style="opacity:0.9;fill:%23ffffff;enable-background:new" class="st0"/%3E%3C/g%3E%3C/svg%3E\')'}}},{}],819:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){var r=t.split(" "),i=r[0],a=r[1],o=n.isArrayOrTypedArray(e)?n.mean(e):e,s=.5+o/100,l=1.5+o/100,c=["",""],u=[0,0];switch(i){case"top":c[0]="top",u[1]=-l;break;case"bottom":c[0]="bottom",u[1]=l}switch(a){case"left":c[1]="right",u[0]=-s;break;case"right":c[1]="left",u[0]=s}return{anchor:c[0]&&c[1]?c.join("-"):c[0]?c[0]:c[1]?c[1]:"center",offset:u}}},{"../../lib":717}],820:[function(t,e,r){"use strict";var n=t("mapbox-gl"),i=t("../../lib"),a=t("../../plots/get_data").getSubplotCalcData,o=t("../../constants/xmlns_namespaces"),s=t("d3"),l=t("../../components/drawing"),c=t("../../lib/svg_text_utils"),u=t("./mapbox"),h=r.constants=t("./constants");function f(t){return"string"==typeof t&&(-1!==h.styleValuesMapbox.indexOf(t)||0===t.indexOf("mapbox://"))}r.name="mapbox",r.attr="subplot",r.idRoot="mapbox",r.idRegex=r.attrRegex=i.counterRegex("mapbox"),r.attributes={subplot:{valType:"subplotid",dflt:"mapbox",editType:"calc"}},r.layoutAttributes=t("./layout_attributes"),r.supplyLayoutDefaults=t("./layout_defaults"),r.plot=function(t){var e=t._fullLayout,r=t.calcdata,o=e._subplots.mapbox;if(n.version!==h.requiredVersion)throw new Error(h.wrongVersionErrorMsg);var s=function(t,e){var r=t._fullLayout;if(""===t._context.mapboxAccessToken)return"";for(var n=[],a=[],o=!1,s=!1,l=0;l1&&i.warn(h.multipleTokensErrorMsg),n[0]):(a.length&&i.log(["Listed mapbox access token(s)",a.join(","),"but did not use a Mapbox map style, ignoring token(s)."].join(" ")),"")}(t,o);n.accessToken=s;for(var l=0;lx/2){var b=g.split("|").join("
");v.text(b).attr("data-unformatted",b).call(c.convertToTspans,t),y=l.bBox(v.node())}v.attr("transform","translate(-3, "+(8-y.height)+")"),m.insert("rect",".static-attribution").attr({x:-y.width-6,y:-y.height-3,width:y.width+6,height:y.height+3,fill:"rgba(255, 255, 255, 0.75)"});var _=1;y.width+6>x&&(_=x/(y.width+6));var w=[n.l+n.w*u.x[1],n.t+n.h*(1-u.y[0])];m.attr("transform","translate("+w[0]+","+w[1]+") scale("+_+")")}},r.updateFx=function(t){for(var e=t._fullLayout,r=e._subplots.mapbox,n=0;n0){for(var r=0;r0}function c(t){var e={},r={};switch(t.type){case"circle":n.extendFlat(r,{"circle-radius":t.circle.radius,"circle-color":t.color,"circle-opacity":t.opacity});break;case"line":n.extendFlat(r,{"line-width":t.line.width,"line-color":t.color,"line-opacity":t.opacity,"line-dasharray":t.line.dash});break;case"fill":n.extendFlat(r,{"fill-color":t.color,"fill-outline-color":t.fill.outlinecolor,"fill-opacity":t.opacity});break;case"symbol":var a=t.symbol,o=i(a.textposition,a.iconsize);n.extendFlat(e,{"icon-image":a.icon+"-15","icon-size":a.iconsize/10,"text-field":a.text,"text-size":a.textfont.size,"text-anchor":o.anchor,"text-offset":o.offset,"symbol-placement":a.placement}),n.extendFlat(r,{"icon-color":t.color,"text-color":a.textfont.color,"text-opacity":t.opacity});break;case"raster":n.extendFlat(r,{"raster-fade-duration":0,"raster-opacity":t.opacity})}return{layout:e,paint:r}}s.update=function(t){this.visible?this.needsNewImage(t)?this.updateImage(t):this.needsNewSource(t)?(this.removeLayer(),this.updateSource(t),this.updateLayer(t)):this.needsNewLayer(t)?this.updateLayer(t):this.updateStyle(t):(this.updateSource(t),this.updateLayer(t)),this.visible=l(t)},s.needsNewImage=function(t){return this.subplot.map.getSource(this.idSource)&&"image"===this.sourceType&&"image"===t.sourcetype&&(this.source!==t.source||JSON.stringify(this.coordinates)!==JSON.stringify(t.coordinates))},s.needsNewSource=function(t){return this.sourceType!==t.sourcetype||this.source!==t.source||this.layerType!==t.type},s.needsNewLayer=function(t){return this.layerType!==t.type||this.below!==this.subplot.belowLookup["layout-"+this.index]},s.updateImage=function(t){this.subplot.map.getSource(this.idSource).updateImage({url:t.source,coordinates:t.coordinates})},s.updateSource=function(t){var e=this.subplot.map;if(e.getSource(this.idSource)&&e.removeSource(this.idSource),this.sourceType=t.sourcetype,this.source=t.source,l(t)){var r=function(t){var e,r=t.sourcetype,n=t.source,i={type:r};return"geojson"===r?e="data":"vector"===r?e="string"==typeof n?"url":"tiles":"raster"===r?(e="tiles",i.tileSize=256):"image"===r&&(e="url",i.coordinates=t.coordinates),i[e]=n,t.sourceattribution&&(i.attribution=t.sourceattribution),i}(t);e.addSource(this.idSource,r)}},s.updateLayer=function(t){var e,r=this.subplot,n=c(t),i=this.subplot.belowLookup["layout-"+this.index];if("traces"===i)for(var o=r.getMapLayers(),s=0;s1)for(r=0;r-1&&h(e.originalEvent,n,[r.xaxis],[r.yaxis],r.id,t),a.indexOf("event")>-1&&i.click(n,e.originalEvent)}}},g.updateFx=function(t){var e=this,r=e.map,n=e.gd;if(!e.isStatic){var i,o=t.dragmode;i="select"===o?function(t,r){(t.range={})[e.id]=[l([r.xmin,r.ymin]),l([r.xmax,r.ymax])]}:function(t,r,n){(t.lassoPoints={})[e.id]=n.filtered.map(l)};var s=e.dragOptions;e.dragOptions=a.extendDeep(s||{},{element:e.div,gd:n,plotinfo:{id:e.id,xaxis:e.xaxis,yaxis:e.yaxis,fillRangeItems:i},xaxes:[e.xaxis],yaxes:[e.yaxis],subplot:e.id}),r.off("click",e.onClickInPanHandler),"select"===o||"lasso"===o?(r.dragPan.disable(),r.on("zoomstart",e.clearSelect),e.dragOptions.prepFn=function(t,r,n){u(t,r,n,e.dragOptions,o)},c.init(e.dragOptions)):(r.dragPan.enable(),r.off("zoomstart",e.clearSelect),e.div.onmousedown=null,e.onClickInPanHandler=e.onClickInPanFn(e.dragOptions),r.on("click",e.onClickInPanHandler))}function l(t){var r=e.map.unproject(t);return[r.lng,r.lat]}},g.updateFramework=function(t){var e=t[this.id].domain,r=t._size,n=this.div.style;n.width=r.w*(e.x[1]-e.x[0])+"px",n.height=r.h*(e.y[1]-e.y[0])+"px",n.left=r.l+e.x[0]*r.w+"px",n.top=r.t+(1-e.y[1])*r.h+"px",this.xaxis._offset=r.l+e.x[0]*r.w,this.xaxis._length=r.w*(e.x[1]-e.x[0]),this.yaxis._offset=r.t+(1-e.y[1])*r.h,this.yaxis._length=r.h*(e.y[1]-e.y[0])},g.updateLayers=function(t){var e,r=t[this.id].layers,n=this.layerList;if(r.length!==n.length){for(e=0;e=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&function(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",(function(){v.sendDataToCloud(t)}));else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}(t,o),s.text(o.text()&&u.text()?" - ":"")}},v.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=(window.PLOTLYENV||{}).BASE_URL||t._context.plotlyServerURL,r=n.select(t).append("div").attr("id","hiddenform").style("display","none"),i=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"});return i.append("input").attr({type:"text",name:"data"}).node().value=v.graphJson(t,!1,"keepdata"),i.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1};var b=["days","shortDays","months","shortMonths","periods","dateTime","date","time","decimal","thousands","grouping","currency"],_=["year","month","dayMonth","dayMonthYear"];function w(t,e){var r=t._context.locale,n=!1,i={};function o(t){for(var r=!0,a=0;a1&&D.length>1){for(a.getComponentMethod("grid","sizeDefaults")(c,s),o=0;o15&&D.length>15&&0===s.shapes.length&&0===s.images.length,s._hasCartesian=s._has("cartesian"),s._hasGeo=s._has("geo"),s._hasGL3D=s._has("gl3d"),s._hasGL2D=s._has("gl2d"),s._hasTernary=s._has("ternary"),s._hasPie=s._has("pie"),v.linkSubplots(h,s,u,i),v.cleanPlot(h,s,u,i),i._zoomlayer&&!t._dragging&&i._zoomlayer.selectAll(".select-outline").remove(),function(t,e){var r,n=[];e.meta&&(r=e._meta={meta:e.meta,layout:{meta:e.meta}});for(var i=0;i0){var h=1-2*s;n=Math.round(h*n),a=Math.round(h*a)}}var f=v.layoutAttributes.width.min,p=v.layoutAttributes.height.min;n1,g=!e.height&&Math.abs(r.height-a)>1;(g||d)&&(d&&(r.width=n),g&&(r.height=a)),t._initialAutoSize||(t._initialAutoSize={width:n,height:a}),v.sanitizeMargins(r)},v.supplyLayoutModuleDefaults=function(t,e,r,n){var i,o,s,c=a.componentsRegistry,u=e._basePlotModules,h=a.subplotsRegistry.cartesian;for(i in c)(s=c[i]).includeBasePlot&&s.includeBasePlot(t,e);for(var f in u.length||u.push(h),e._has("cartesian")&&(a.getComponentMethod("grid","contentDefaults")(t,e),h.finalizeSubplots(t,e)),e._subplots)e._subplots[f].sort(l.subplotSort);for(o=0;o.5*n.width&&(l.log("Margin push",e,"is too big in x, dropping"),r.l=r.r=0),r.b+r.t>.5*n.height&&(l.log("Margin push",e,"is too big in y, dropping"),r.b=r.t=0);var c=void 0!==r.xl?r.xl:r.x,u=void 0!==r.xr?r.xr:r.x,h=void 0!==r.yt?r.yt:r.y,f=void 0!==r.yb?r.yb:r.y;i[e]={l:{val:c,size:r.l+o},r:{val:u,size:r.r+o},b:{val:f,size:r.b+o},t:{val:h,size:r.t+o}},a[e]=1}else delete i[e],delete a[e];if(!n._replotting)return v.doAutoMargin(t)}},v.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),k(e);var r=e._size,n=e.margin,o=l.extendFlat({},r),s=n.l,c=n.r,u=n.t,h=n.b,f=e.width,p=e.height,d=e._pushmargin,g=e._pushmarginIds;if(!1!==e.margin.autoexpand){for(var m in d)g[m]||delete d[m];for(var y in d.base={l:{val:0,size:s},r:{val:1,size:c},t:{val:1,size:u},b:{val:0,size:h}},d){var x=d[y].l||{},b=d[y].b||{},_=x.val,w=x.size,A=b.val,C=b.size;for(var M in d){if(i(w)&&d[M].r){var I=d[M].r.val,T=d[M].r.size;if(I>_){var L=(w*I+(T-f)*_)/(I-_),S=(T*(1-_)+(w-f)*(1-I))/(I-_);L>=0&&S>=0&&f-(L+S)>0&&L+S>s+c&&(s=L,c=S)}}if(i(C)&&d[M].t){var E=d[M].t.val,D=d[M].t.size;if(E>A){var P=(C*E+(D-p)*A)/(E-A),O=(D*(1-A)+(C-p)*(1-E))/(E-A);P>=0&&O>=0&&p-(O+P)>0&&P+O>h+u&&(h=P,u=O)}}}}}if(r.l=Math.round(s),r.r=Math.round(c),r.t=Math.round(u),r.b=Math.round(h),r.p=Math.round(n.pad),r.w=Math.round(f)-r.l-r.r,r.h=Math.round(p)-r.t-r.b,!e._replotting&&v.didMarginChange(o,r)){"_redrawFromAutoMarginCount"in e?e._redrawFromAutoMarginCount++:e._redrawFromAutoMarginCount=1;var z=3*(1+Object.keys(g).length);if(e._redrawFromAutoMarginCount0&&(t._transitioningWithDuration=!0),t._transitionData._interruptCallbacks.push((function(){n=!0})),r.redraw&&t._transitionData._interruptCallbacks.push((function(){return a.call("redraw",t)})),t._transitionData._interruptCallbacks.push((function(){t.emit("plotly_transitioninterrupted",[])}));var o=0,s=0;function l(){return o++,function(){var e;s++,n||s!==o||(e=i,t._transitionData&&(function(t){if(t)for(;t.length;)t.shift()}(t._transitionData._interruptCallbacks),Promise.resolve().then((function(){if(r.redraw)return a.call("redraw",t)})).then((function(){t._transitioning=!1,t._transitioningWithDuration=!1,t.emit("plotly_transitioned",[])})).then(e)))}}r.runFn(l),setTimeout(l())}))}],o=l.syncOrAsync(i,t);return o&&o.then||(o=Promise.resolve()),o.then((function(){return t}))}v.didMarginChange=function(t,e){for(var r=0;r1)return!0}return!1},v.graphJson=function(t,e,r,n,i){(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&v.supplyDefaults(t);var a=i?t._fullData:t.data,o=i?t._fullLayout:t.layout,s=(t._transitionData||{})._frames;function c(t){if("function"==typeof t)return null;if(l.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if("string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0&&!l.isPlainObject(t.stream))continue}else if("keepall"!==r&&"string"==typeof(n=t[e+"src"])&&n.indexOf(":")>0)continue;i[e]=c(t[e])}return i}return Array.isArray(t)?t.map(c):l.isTypedArray(t)?l.simpleMap(t,l.identity):l.isJSDate(t)?l.ms2DateTimeLocal(+t):t}var u={data:(a||[]).map((function(t){var r=c(t);return e&&delete r.fit,r}))};return e||(u.layout=c(o)),t.framework&&t.framework.isPolar&&(u=t.framework.getConfig()),s&&(u.frames=c(s)),"object"===n?u:JSON.stringify(u)},v.modifyFrames=function(t,e){var r,n,i,a=t._transitionData._frames,o=t._transitionData._frameHash;for(r=0;r=0;s--)if(o[s].enabled){r._indexToPoints=o[s]._indexToPoints;break}n&&n.calc&&(a=n.calc(t,r))}Array.isArray(a)&&a[0]||(a=[{x:u,y:u}]),a[0].t||(a[0].t={}),a[0].trace=r,d[e]=a}}for(S(c,f,p),i=0;i1e-10?t:0}function f(t,e,r){e=e||0,r=r||0;for(var n=t.length,i=new Array(n),a=0;a0?r:1/0})),i=n.mod(r+1,e.length);return[e[r],e[i]]},findIntersectionXY:c,findXYatLength:function(t,e,r,n){var i=-e*r,a=e*e+1,o=2*(e*i-r),s=i*i+r*r-t*t,l=Math.sqrt(o*o-4*a*s),c=(-o+l)/(2*a),u=(-o-l)/(2*a);return[[c,e*c+i+n],[u,e*u+i+n]]},clampTiny:h,pathPolygon:function(t,e,r,n,i,a){return"M"+f(u(t,e,r,n),i,a).join("L")},pathPolygonAnnulus:function(t,e,r,n,i,a,o){var s,l;t=0?f.angularAxis.domain:n.extent(A),T=Math.abs(A[1]-A[0]);M&&!C&&(T=0);var L=I.slice();k&&C&&(L[1]+=T);var S=f.angularAxis.ticksCount||4;S>8&&(S=S/(S/8)+S%8),f.angularAxis.ticksStep&&(S=(L[1]-L[0])/S);var E=f.angularAxis.ticksStep||(L[1]-L[0])/(S*(f.minorTicks+1));w&&(E=Math.max(Math.round(E),1)),L[2]||(L[2]=E);var D=n.range.apply(this,L);if(D=D.map((function(t,e){return parseFloat(t.toPrecision(12))})),s=n.scale.linear().domain(L.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=k?T:0,void 0===(t=n.select(this).select("svg.chart-root"))||t.empty()){var P=(new DOMParser).parseFromString("' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '","application/xml"),O=this.appendChild(this.ownerDocument.importNode(P.documentElement,!0));t=n.select(O)}t.select(".guides-group").style({"pointer-events":"none"}),t.select(".angular.axis-group").style({"pointer-events":"none"}),t.select(".radial.axis-group").style({"pointer-events":"none"});var z,R=t.select(".chart-group"),F={fill:"none",stroke:f.tickColor},N={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map((function(t,e){return" "+t+" 0 "+f.font.outlineColor})).join(",")};if(f.showLegend){z=t.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var j=p.map((function(t,e){var r=o.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend=void 0===t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r}));o.Legend().config({data:p.map((function(t,e){return t.name||"Element"+e})),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:z,elements:j,reverseOrder:f.legend.reverseOrder})})();var B=z.node().getBBox();x=Math.min(f.width-B.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),z.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else z=t.select(".legend-group").style({display:"none"});t.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),R.attr("transform","translate("+_+")").style({cursor:"crosshair"});var Y=[(f.width-(f.margin.left+f.margin.right+2*x+(B?B.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(Y[0]=Math.max(0,Y[0]),Y[1]=Math.max(0,Y[1]),t.select(".outer-group").attr("transform","translate("+Y+")"),f.title&&f.title.text){var V=t.select("g.title-group text").style(N).text(f.title.text),U=V.node().getBBox();V.attr({x:_[0]-U.width/2,y:_[1]-x-20})}var H=t.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=H.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(F),G.attr("r",r),G.exit().remove()}H.select("circle.outside-circle").attr({r:x}).style(F);var q=t.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});function W(t,e){return s(t)%360+f.orientation}if(f.radialAxis.visible){var Z=n.svg.axis().scale(r).ticks(5).tickSize(5);H.call(Z).attr({transform:"rotate("+f.radialAxis.orientation+")"}),H.selectAll(".domain").style(F),H.selectAll("g>text").text((function(t,e){return this.textContent+f.radialAxis.ticksSuffix})).style(N).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,N["font-size"]]+")":"translate("+[0,N["font-size"]]+")"}}),H.selectAll("g>line").style({stroke:"black"})}var X=t.select(".angular.axis-group").selectAll("g.angular-tick").data(D),J=X.enter().append("g").classed("angular-tick",!0);X.attr({transform:function(t,e){return"rotate("+W(t)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),X.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",(function(t,e){return e%(f.minorTicks+1)==0})).classed("minor",(function(t,e){return!(e%(f.minorTicks+1)==0)})).style(F),J.selectAll(".minor").style({stroke:f.minorTickColor}),X.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(N);var K=X.select("text.axis-text").attr({x:x+f.labelOffset,dy:a+"em",transform:function(t,e){var r=W(t),n=x+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text((function(t,e){return e%(f.minorTicks+1)!=0?"":w?w[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix})).style(N);f.angularAxis.rewriteTicks&&K.text((function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)}));var Q=n.max(R.selectAll(".angular-tick text")[0].map((function(t,e){return t.getCTM().e+t.getBBox().width})));z.attr({transform:"translate("+[x+Q,f.margin.top]+")"});var $=t.select("g.geometry-group").selectAll("g").size()>0,tt=t.select("g.geometry-group").selectAll("g.geometry").data(p);if(tt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),tt.exit().remove(),p[0]||$){var et=[];p.forEach((function(t,e){var n={};n.radialScale=r,n.angularScale=s,n.container=tt.filter((function(t,r){return r==e})),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,et.push({data:t,geometryConfig:n})}));var rt=n.nest().key((function(t,e){return void 0!==t.data.groupId||"unstacked"})).entries(et),nt=[];rt.forEach((function(t,e){"unstacked"===t.key?nt=nt.concat(t.values.map((function(t,e){return[t]}))):nt.push(t.values)})),nt.forEach((function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map((function(t,e){return i(o[r].defaultConfig(),t)}));o[r]().config(n)()}))}var it,at,ot=t.select(".guides-group"),st=t.select(".tooltips-group"),lt=o.tooltipPanel().config({container:st,fontSize:8})(),ct=o.tooltipPanel().config({container:st,fontSize:8})(),ut=o.tooltipPanel().config({container:st,hasTick:!0})();if(!C){var ht=ot.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});R.on("mousemove.angular-guide",(function(t,e){var r=o.util.getMousePos(q).angle;ht.attr({x2:-x,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;it=s.invert(n);var i=o.util.convertToCartesian(x+12,r+180);lt.text(o.util.round(it)).move([i[0]+_[0],i[1]+_[1]])})).on("mouseout.angular-guide",(function(t,e){ot.select("line").style({opacity:0})}))}var ft=ot.select("circle").style({stroke:"grey",fill:"none"});R.on("mousemove.radial-guide",(function(t,e){var n=o.util.getMousePos(q).radius;ft.attr({r:n}).style({opacity:.5}),at=r.invert(o.util.getMousePos(q).radius);var i=o.util.convertToCartesian(n,f.radialAxis.orientation);ct.text(o.util.round(at)).move([i[0]+_[0],i[1]+_[1]])})).on("mouseout.radial-guide",(function(t,e){ft.style({opacity:0}),ut.hide(),lt.hide(),ct.hide()})),t.selectAll(".geometry-group .mark").on("mouseover.tooltip",(function(e,r){var i=n.select(this),a=this.style.fill,s="black",l=this.style.opacity||1;if(i.attr({"data-opacity":l}),a&&"none"!==a){i.attr({"data-fill":a}),s=n.hsl(a).darker().toString(),i.style({fill:s,opacity:1});var c={t:o.util.round(e[0]),r:o.util.round(e[1])};C&&(c.t=w[e[0]]);var u="t: "+c.t+", r: "+c.r,h=this.getBoundingClientRect(),f=t.node().getBoundingClientRect(),p=[h.left+h.width/2-Y[0]-f.left,h.top+h.height/2-Y[1]-f.top];ut.config({color:s}).text(u),ut.move(p)}else a=this.style.stroke||"black",i.attr({"data-stroke":a}),s=n.hsl(a).darker().toString(),i.style({stroke:s,opacity:1})})).on("mousemove.tooltip",(function(t,e){if(0!=n.event.which)return!1;n.select(this).attr("data-fill")&&ut.show()})).on("mouseout.tooltip",(function(t,e){ut.hide();var r=n.select(this),i=r.attr("data-fill");i?r.style({fill:i,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})}))}))}(c),this},config:function(t){if(!arguments.length)return l;var e=o.util.cloneJson(t);return e.data.forEach((function(t,e){l.data[e]||(l.data[e]={}),i(l.data[e],o.Axis.defaultConfig().data[0]),i(l.data[e],t)})),i(l.layout,o.Axis.defaultConfig().layout),i(l.layout,e.layout),this},getLiveConfig:function(){return u},getinputConfig:function(){return c},radialScale:function(t){return r},angularScale:function(t){return s},svg:function(){return t}};return n.rebind(f,h,"on"),f},o.Axis.defaultConfig=function(t,e){return{data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:n.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}}},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},o.util._extend=function(t,e){for(var r in t)e[r]=t[r]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var r=e||6;return n.range(0,360+r,r).map((function(e,r){var n=e*Math.PI/180;return[e,t(n)]}))},o.util.dataFromEquation=function(t,e,r){var i=e||6,a=[],o=[];n.range(0,360+i,i).forEach((function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)}));var s={t:a,r:o};return r&&(s.name=r),s},o.util.ensureArray=function(t,e){if(void 0===t)return null;var r=[].concat(t);return n.range(e).map((function(t,e){return r[e]||r[0]}))},o.util.fillArrays=function(t,e,r){return e.forEach((function(e,n){t[e]=o.util.ensureArray(t[e],r)})),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},o.util.sumArrays=function(t,e){return n.zip(t,e).map((function(t,e){return n.sum(t)}))},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter((function(t,e,r){return r.indexOf(t)==e}))},o.util.convertToCartesian=function(t,e){var r=e*Math.PI/180;return[t*Math.cos(r),t*Math.sin(r)]},o.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},o.util.getMousePos=function(t){var e=n.mouse(t.node()),r=e[0],i=e[1],a={};return a.x=r,a.y=i,a.pos=e,a.angle=180*(Math.atan2(i,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+i*i),a},o.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var l=n.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:u(s),transform:function(t,r){return"rotate("+(e.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return d.fill(r,i,a)},"fill-opacity":0,stroke:function(t,e){return d.stroke(r,i,a)},"stroke-width":function(t,e){return d["stroke-width"](r,i,a)},"stroke-dasharray":function(t,e){return d["stroke-dasharray"](r,i,a)},opacity:function(t,e){return d.opacity(r,i,a)},display:function(t,e){return d.display(r,i,a)}})}};var h=e.angularScale.range(),f=Math.abs(h[1]-h[0])/o[0].length*Math.PI/180,p=n.svg.arc().startAngle((function(t){return-f/2})).endAngle((function(t){return f/2})).innerRadius((function(t){return e.radialScale(l+(t[2]||0))})).outerRadius((function(t){return e.radialScale(l+(t[2]||0))+e.radialScale(t[1])}));c.arc=function(t,r,i){n.select(this).attr({class:"mark arc",d:p,transform:function(t,r){return"rotate("+(e.orientation+s(t[0])+90)+")"}})};var d={fill:function(e,r,n){return t[n].data.color},stroke:function(e,r,n){return t[n].data.strokeColor},"stroke-width":function(e,r,n){return t[n].data.strokeSize+"px"},"stroke-dasharray":function(e,n,i){return r[t[i].data.strokeDash]},opacity:function(e,r,n){return t[n].data.opacity},display:function(e,r,n){return void 0===t[n].data.visible||t[n].data.visible?"block":"none"}},g=n.select(this).selectAll("g.layer").data(o);g.enter().append("g").attr({class:"layer"});var m=g.selectAll("path.mark").data((function(t,e){return t}));m.enter().append("path").attr({class:"mark"}),m.style(d).each(c[e.geometryType]),m.exit().remove(),g.exit().remove()}))}return a.config=function(e){return arguments.length?(e.forEach((function(e,r){t[r]||(t[r]={}),i(t[r],o.PolyChart.defaultConfig()),i(t[r],e)})),this):t},a.getColorScale=function(){},n.rebind(a,e,"on"),a},o.PolyChart.defaultConfig=function(){return{data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:n.scale.category20()}}},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){return{geometryConfig:{geometryType:"bar"}}},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){return{geometryConfig:{geometryType:"arc"}}},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){return{geometryConfig:{geometryType:"dot",dotType:"circle"}}},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){return{geometryConfig:{geometryType:"line"}}},o.Legend=function(){var t=o.Legend.defaultConfig(),e=n.dispatch("hover");function r(){var e=t.legendConfig,a=t.data.map((function(t,r){return[].concat(t).map((function(t,n){var a=i({},e.elements[r]);return a.name=t,a.color=[].concat(e.elements[r].color)[n],a}))})),o=n.merge(a);o=o.filter((function(t,r){return e.elements[r]&&(e.elements[r].visibleInLegend||void 0===e.elements[r].visibleInLegend)})),e.reverseOrder&&(o=o.reverse());var s=e.container;("string"==typeof s||s.nodeName)&&(s=n.select(s));var l=o.map((function(t,e){return t.color})),c=e.fontSize,u=null==e.isContinuous?"number"==typeof o[0]:e.isContinuous,h=u?e.height:c*o.length,f=s.classed("legend-group",!0).selectAll("svg").data([0]),p=f.enter().append("svg").attr({width:300,height:h+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var d=n.range(o.length),g=n.scale[u?"linear":"ordinal"]().domain(d).range(l),m=n.scale[u?"linear":"ordinal"]().domain(d)[u?"range":"rangePoints"]([0,h]);if(u){var v=f.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);v.enter().append("stop"),v.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),f.append("rect").classed("legend-mark",!0).attr({height:e.height,width:e.colorBandWidth,fill:"url(#grad1)"})}else{var y=f.select(".legend-marks").selectAll("path.legend-mark").data(o);y.enter().append("path").classed("legend-mark",!0),y.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r,i,a,o=t.symbol;return a=3*(i=c),"line"===(r=o)?"M"+[[-i/2,-i/12],[i/2,-i/12],[i/2,i/12],[-i/2,i/12]]+"Z":-1!=n.svg.symbolTypes.indexOf(r)?n.svg.symbol().type(r).size(a)():n.svg.symbol().type("square").size(a)()},fill:function(t,e){return g(e)}}),y.exit().remove()}var x=n.svg.axis().scale(m).orient("right"),b=f.select("g.legend-axis").attr({transform:"translate("+[u?e.colorBandWidth:c,c/2]+")"}).call(x);return b.selectAll(".domain").style({fill:"none",stroke:"none"}),b.selectAll("line").style({fill:"none",stroke:u?e.textColor:"none"}),b.selectAll("text").style({fill:e.textColor,"font-size":e.fontSize}).text((function(t,e){return o[e].name})),r}return r.config=function(e){return arguments.length?(i(t,e),this):t},n.rebind(r,e,"on"),r},o.Legend.defaultConfig=function(t,e){return{data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}}},o.tooltipPanel=function(){var t,e,r,a={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+o.tooltipPanel.uid++,l=10,c=function(){var n=(t=a.container.selectAll("g."+s).data([0])).enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=n.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=n.append("text").attr({dx:a.padding+l,dy:.3*+a.fontSize}),c};return c.text=function(i){var o=n.hsl(a.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",h=i||"";e.style({fill:u,"font-size":a.fontSize+"px"}).text(h);var f=a.padding,p=e.node().getBBox(),d={fill:a.color,stroke:s,"stroke-width":"2px"},g=p.width+2*f+l,m=p.height+2*f;return r.attr({d:"M"+[[l,-m/2],[l,-m/4],[a.hasTick?0:l,0],[l,m/4],[l,m/2],[g,m/2],[g,-m/2]].join("L")+"Z"}).style(d),t.attr({transform:"translate("+[l,-m/2+2*f]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(a,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={convert:function(t,e){var r={};if(t.data&&(r.data=t.data.map((function(t,r){var n=i({},t);return[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]].forEach((function(t,r){o.util.translator.apply(null,t.concat(e))})),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",!0===n.dotVisible?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n})),!e&&t.layout&&"stack"===t.layout.barmode)){var a=o.util.duplicates(r.data.map((function(t,e){return t.geometry})));r.data.forEach((function(t,e){var n=a.indexOf(t.geometry);-1!=n&&(r.data[e].groupId=n)}))}if(t.layout){var s=i({},t.layout);if([[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]].forEach((function(t,r){o.util.translator.apply(null,t.concat(e))})),e?(void 0!==s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&void 0!==s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&void 0!==s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&void 0!==s.margin.t){var l=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],u={};n.entries(s.margin).forEach((function(t,e){u[c[l.indexOf(t.key)]]=t.value})),s.margin=u}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r}};return t}},{"../../../constants/alignment":686,"../../../lib":717,d3:165}],836:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../../lib"),a=t("../../../components/color"),o=t("./micropolar"),s=t("./undo_manager"),l=i.extendDeepAll,c=e.exports={};c.framework=function(t){var e,r,i,a,u,h=new s;function f(r,s){return s&&(u=s),n.select(n.select(u).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),e=e?l(e,r):r,i||(i=o.Axis()),a=o.adapter.plotly().convert(e),i.config(a).render(u),t.data=e.data,t.layout=e.layout,c.fillLayout(t),e}return f.isPolar=!0,f.svg=function(){return i.svg()},f.getConfig=function(){return e},f.getLiveConfig=function(){return o.adapter.plotly().convert(i.getLiveConfig(),!0)},f.getLiveScales=function(){return{t:i.angularScale(),r:i.radialScale()}},f.setUndoPoint=function(){var t,n,i=this,a=o.util.cloneJson(e);t=a,n=r,h.add({undo:function(){n&&i(n)},redo:function(){i(t)}}),r=o.util.cloneJson(a)},f.undo=function(){h.undo()},f.redo=function(){h.redo()},f},c.fillLayout=function(t){var e=n.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),i=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:a.background,_container:e,_paperdiv:r,_paper:i};t._fullLayout=l(o,t.layout)}},{"../../../components/color":592,"../../../lib":717,"./micropolar":835,"./undo_manager":837,d3:165}],837:[function(t,e,r){"use strict";e.exports=function(){var t,e=[],r=-1,n=!1;function i(t,e){return t?(n=!0,t[e](),n=!1,this):this}return{add:function(t){return n?this:(e.splice(r+1,e.length-r),e.push(t),r=e.length-1,this)},setCallback:function(e){t=e},undo:function(){var n=e[r];return n?(i(n,"undo"),r-=1,t&&t(n.undo),this):this},redo:function(){var n=e[r+1];return n?(i(n,"redo"),r+=1,t&&t(n.redo),this):this},clear:function(){e=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r=90||s>90&&l>=450?1:u<=0&&f<=0?0:Math.max(u,f),e=s<=180&&l>=180||s>180&&l>=540?-1:c>=0&&h>=0?0:Math.min(c,h),r=s<=270&&l>=270||s>270&&l>=630?-1:u>=0&&f>=0?0:Math.min(u,f),n=l>=360?1:c<=0&&h<=0?0:Math.max(c,h),[e,r,n,i]}(f),x=y[2]-y[0],b=y[3]-y[1],_=h/u,w=Math.abs(b/x);_>w?(p=u,v=(h-(d=u*w))/n.h/2,g=[o[0],o[1]],m=[c[0]+v,c[1]-v]):(d=h,v=(u-(p=h/w))/n.w/2,g=[o[0]+v,o[1]-v],m=[c[0],c[1]]),this.xLength2=p,this.yLength2=d,this.xDomain2=g,this.yDomain2=m;var A=this.xOffset2=n.l+n.w*g[0],C=this.yOffset2=n.t+n.h*(1-m[1]),M=this.radius=p/x,k=this.innerRadius=e.hole*M,I=this.cx=A-M*y[0],S=this.cy=C+M*y[3],E=this.cxx=I-A,D=this.cyy=S-C;this.radialAxis=this.mockAxis(t,e,i,{_id:"x",side:{counterclockwise:"top",clockwise:"bottom"}[i.side],domain:[k/n.w,M/n.w]}),this.angularAxis=this.mockAxis(t,e,a,{side:"right",domain:[0,Math.PI],autorange:!1}),this.doAutoRange(t,e),this.updateAngularAxis(t,e),this.updateRadialAxis(t,e),this.updateRadialAxisTitle(t,e),this.xaxis=this.mockCartesianAxis(t,e,{_id:"x",domain:g}),this.yaxis=this.mockCartesianAxis(t,e,{_id:"y",domain:m});var P=this.pathSubplot();this.clipPaths.forTraces.select("path").attr("d",P).attr("transform",R(E,D)),r.frontplot.attr("transform",R(A,C)).call(l.setClipUrl,this._hasClipOnAxisFalse?null:this.clipIds.forTraces,this.gd),r.bg.attr("d",P).attr("transform",R(I,S)).call(s.fill,e.bgcolor)},D.mockAxis=function(t,e,r,n){var i=o.extendFlat({},r,n);return f(i,e,t),i},D.mockCartesianAxis=function(t,e,r){var n=this,i=r._id,a=o.extendFlat({type:"linear"},r);h(a,t);var s={x:[0,2],y:[1,3]};return a.setRange=function(){var t=n.sectorBBox,r=s[i],o=n.radialAxis._rl,l=(o[1]-o[0])/(1-e.hole);a.range=[t[r[0]]*l,t[r[1]]*l]},a.isPtWithinRange="x"===i?function(t){return n.isPtInside(t)}:function(){return!0},a.setRange(),a.setScale(),a},D.doAutoRange=function(t,e){var r=this.gd,n=this.radialAxis,i=e.radialaxis;n.setScale(),p(r,n);var a=n.range;i.range=a.slice(),i._input.range=a.slice(),n._rl=[n.r2l(a[0],null,"gregorian"),n.r2l(a[1],null,"gregorian")]},D.updateRadialAxis=function(t,e){var r=this,n=r.gd,i=r.layers,a=r.radius,l=r.innerRadius,c=r.cx,h=r.cy,f=e.radialaxis,p=T(e.sector[0],360),d=r.radialAxis,g=l90&&p<=270&&(d.tickangle=180);var m=function(t){return"translate("+(d.l2p(t.x)+l)+",0)"},v=P(f);if(r.radialTickLayout!==v&&(i["radial-axis"].selectAll(".xtick").remove(),r.radialTickLayout=v),g){d.setScale();var y=u.calcTicks(d),x=u.clipEnds(d,y),b=u.getTickSigns(d)[2];u.drawTicks(n,d,{vals:y,layer:i["radial-axis"],path:u.makeTickPath(d,0,b),transFn:m,crisp:!1}),u.drawGrid(n,d,{vals:x,layer:i["radial-grid"],path:function(t){return r.pathArc(d.r2p(t.x)+l)},transFn:o.noop,crisp:!1}),u.drawLabels(n,d,{vals:y,layer:i["radial-axis"],transFn:m,labelFns:u.makeLabelFns(d,0)})}var _=r.radialAxisAngle=r.vangles?S(O(L(f.angle),r.vangles)):f.angle,w=R(c,h),A=w+F(-_);z(i["radial-axis"],g&&(f.showticklabels||f.ticks),{transform:A}),z(i["radial-grid"],g&&f.showgrid,{transform:w}),z(i["radial-line"].select("line"),g&&f.showline,{x1:l,y1:0,x2:a,y2:0,transform:A}).attr("stroke-width",f.linewidth).call(s.stroke,f.linecolor)},D.updateRadialAxisTitle=function(t,e,r){var n=this.gd,i=this.radius,a=this.cx,o=this.cy,s=e.radialaxis,c=this.id+"title",u=void 0!==r?r:this.radialAxisAngle,h=L(u),f=Math.cos(h),p=Math.sin(h),d=0;if(s.title){var g=l.bBox(this.layers["radial-axis"].node()).height,m=s.title.font.size;d="counterclockwise"===s.side?-g-.4*m:g+.8*m}this.layers["radial-axis-title"]=v.draw(n,c,{propContainer:s,propName:this.id+".radialaxis.title",placeholder:I(n,"Click to enter radial axis title"),attributes:{x:a+i/2*f+d*p,y:o-i/2*p+d*f,"text-anchor":"middle"},transform:{rotate:-u}})},D.updateAngularAxis=function(t,e){var r=this,n=r.gd,i=r.layers,a=r.radius,l=r.innerRadius,c=r.cx,h=r.cy,f=e.angularaxis,p=r.angularAxis;r.fillViewInitialKey("angularaxis.rotation",f.rotation),p.setGeometry(),p.setScale();var d=function(t){return p.t2g(t.x)};"linear"===p.type&&"radians"===p.thetaunit&&(p.tick0=S(p.tick0),p.dtick=S(p.dtick));var g=function(t){return R(c+a*Math.cos(t),h-a*Math.sin(t))},m=u.makeLabelFns(p,0).labelStandoff,v={xFn:function(t){var e=d(t);return Math.cos(e)*m},yFn:function(t){var e=d(t),r=Math.sin(e)>0?.2:1;return-Math.sin(e)*(m+t.fontSize*r)+Math.abs(Math.cos(e))*(t.fontSize*C)},anchorFn:function(t){var e=d(t),r=Math.cos(e);return Math.abs(r)<.1?"middle":r>0?"start":"end"},heightFn:function(t,e,r){var n=d(t);return-.5*(1+Math.sin(n))*r}},y=P(f);r.angularTickLayout!==y&&(i["angular-axis"].selectAll("."+p._id+"tick").remove(),r.angularTickLayout=y);var x,b=u.calcTicks(p);if("linear"===e.gridshape?(x=b.map(d),o.angleDelta(x[0],x[1])<0&&(x=x.slice().reverse())):x=null,r.vangles=x,"category"===p.type&&(b=b.filter((function(t){return o.isAngleInsideSector(d(t),r.sectorInRad)}))),p.visible){var _="inside"===p.ticks?-1:1,w=(p.linewidth||1)/2;u.drawTicks(n,p,{vals:b,layer:i["angular-axis"],path:"M"+_*w+",0h"+_*p.ticklen,transFn:function(t){var e=d(t);return g(e)+F(-S(e))},crisp:!1}),u.drawGrid(n,p,{vals:b,layer:i["angular-grid"],path:function(t){var e=d(t),r=Math.cos(e),n=Math.sin(e);return"M"+[c+l*r,h-l*n]+"L"+[c+a*r,h-a*n]},transFn:o.noop,crisp:!1}),u.drawLabels(n,p,{vals:b,layer:i["angular-axis"],repositionOnUpdate:!0,transFn:function(t){return g(d(t))},labelFns:v})}z(i["angular-line"].select("path"),f.showline,{d:r.pathSubplot(),transform:R(c,h)}).attr("stroke-width",f.linewidth).call(s.stroke,f.linecolor)},D.updateFx=function(t,e){this.gd._context.staticPlot||(this.updateAngularDrag(t),this.updateRadialDrag(t,e,0),this.updateRadialDrag(t,e,1),this.updateMainDrag(t))},D.updateMainDrag=function(t){var e=this,r=e.gd,o=e.layers,s=t._zoomlayer,l=M.MINZOOM,c=M.OFFEDGE,u=e.radius,h=e.innerRadius,f=e.cx,p=e.cy,v=e.cxx,_=e.cyy,w=e.sectorInRad,A=e.vangles,C=e.radialAxis,I=k.clampTiny,T=k.findXYatLength,L=k.findEnclosingVertexAngles,S=M.cornerHalfWidth,E=M.cornerLen/2,D=d.makeDragger(o,"path","maindrag","crosshair");n.select(D).attr("d",e.pathSubplot()).attr("transform",R(f,p));var P,O,z,F,N,j,B,Y,V,U={element:D,gd:r,subplot:e.id,plotinfo:{id:e.id,xaxis:e.xaxis,yaxis:e.yaxis},xaxes:[e.xaxis],yaxes:[e.yaxis]};function H(t,e){return Math.sqrt(t*t+e*e)}function G(t,e){return H(t-v,e-_)}function q(t,e){return Math.atan2(_-e,t-v)}function W(t,e){return[t*Math.cos(e),t*Math.sin(-e)]}function Z(t,r){if(0===t)return e.pathSector(2*S);var n=E/t,i=r-n,a=r+n,o=Math.max(0,Math.min(t,u)),s=o-S,l=o+S;return"M"+W(s,i)+"A"+[s,s]+" 0,0,0 "+W(s,a)+"L"+W(l,a)+"A"+[l,l]+" 0,0,1 "+W(l,i)+"Z"}function X(t,r,n){if(0===t)return e.pathSector(2*S);var i,a,o=W(t,r),s=W(t,n),l=I((o[0]+s[0])/2),c=I((o[1]+s[1])/2);if(l&&c){var u=c/l,h=-1/u,f=T(S,u,l,c);i=T(E,h,f[0][0],f[0][1]),a=T(E,h,f[1][0],f[1][1])}else{var p,d;c?(p=E,d=S):(p=S,d=E),i=[[l-p,c-d],[l+p,c-d]],a=[[l-p,c+d],[l+p,c+d]]}return"M"+i.join("L")+"L"+a.reverse().join("L")+"Z"}function J(t,e){return e=Math.max(Math.min(e,u),h),tl?(t-1&&1===t&&x(n,r,[e.xaxis],[e.yaxis],e.id,U),i.indexOf("event")>-1&&m.click(r,n,e.id)}U.prepFn=function(t,n,a){var o=r._fullLayout.dragmode,l=D.getBoundingClientRect();if(P=n-l.left,O=a-l.top,A){var c=k.findPolygonOffset(u,w[0],w[1],A);P+=v+c[0],O+=_+c[1]}switch(o){case"zoom":U.moveFn=A?tt:Q,U.clickFn=nt,U.doneFn=et,function(){z=null,F=null,N=e.pathSubplot(),j=!1;var t=r._fullLayout[e.id];B=i(t.bgcolor).getLuminance(),(Y=d.makeZoombox(s,B,f,p,N)).attr("fill-rule","evenodd"),V=d.makeCorners(s,f,p),b(r)}();break;case"select":case"lasso":y(t,n,a,U,o)}},D.onmousemove=function(t){m.hover(r,t,e.id),r._fullLayout._lasthover=D,r._fullLayout._hoversubplot=e.id},D.onmouseout=function(t){r._dragging||g.unhover(r,t)},g.init(U)},D.updateRadialDrag=function(t,e,r){var i=this,s=i.gd,l=i.layers,c=i.radius,u=i.innerRadius,h=i.cx,f=i.cy,p=i.radialAxis,m=M.radialDragBoxSize,v=m/2;if(p.visible){var y,x,_,C=L(i.radialAxisAngle),k=p._rl,I=k[0],T=k[1],E=k[r],D=.75*(k[1]-k[0])/(1-e.hole)/c;r?(y=h+(c+v)*Math.cos(C),x=f-(c+v)*Math.sin(C),_="radialdrag"):(y=h+(u-v)*Math.cos(C),x=f-(u-v)*Math.sin(C),_="radialdrag-inner");var P,N,j,B=d.makeRectDragger(l,_,"crosshair",-v,-v,m,m),Y={element:B,gd:s};z(n.select(B),p.visible&&u0==(r?j>I:jn?function(t){return t<=0}:function(t){return t>=0};t.c2g=function(r){var n=t.c2l(r)-e;return(s(n)?n:0)+o},t.g2c=function(r){return t.l2c(r+e-o)},t.g2p=function(t){return t*a},t.c2p=function(e){return t.g2p(t.c2g(e))}}}(t,e);break;case"angularaxis":!function(t,e){var r=t.type;if("linear"===r){var i=t.d2c,s=t.c2d;t.d2c=function(t,e){return function(t,e){return"degrees"===e?a(t):t}(i(t),e)},t.c2d=function(t,e){return s(function(t,e){return"degrees"===e?o(t):t}(t,e))}}t.makeCalcdata=function(e,i){var a,o,s=e[i],l=e._length,c=function(r){return t.d2c(r,e.thetaunit)};if(s){if(n.isTypedArray(s)&&"linear"===r){if(l===s.length)return s;if(s.subarray)return s.subarray(0,l)}for(a=new Array(l),o=0;o0){for(var n=[],i=0;i=u&&(p.min=0,g.min=0,m.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}function d(t,e,r,n){var i=h[e._name];function o(r,n){return a.coerce(t,e,i,r,n)}o("uirevision",n.uirevision),e.type="linear";var f=o("color"),p=f!==i.color.dflt?f:r.font.color,d=e._name.charAt(0).toUpperCase(),g="Component "+d,m=o("title.text",g);e._hovertitle=m===g?m:d,a.coerceFont(o,"title.font",{family:r.font.family,size:Math.round(1.2*r.font.size),color:p}),o("min"),c(t,e,o,"linear"),s(t,e,o,"linear",{}),l(t,e,o,{outerTicks:!0}),o("showticklabels")&&(a.coerceFont(o,"tickfont",{family:r.font.family,size:r.font.size,color:p}),o("tickangle"),o("tickformat")),u(t,e,o,{dfltColor:f,bgColor:r.bgColor,blend:60,showLine:!0,showGrid:!0,noZeroLine:!0,attributes:i}),o("hoverformat"),o("layer")}e.exports=function(t,e,r){o(t,e,r,{type:"ternary",attributes:h,handleDefaults:p,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../components/color":592,"../../lib":717,"../../plot_api/plot_template":755,"../cartesian/line_grid_defaults":779,"../cartesian/tick_label_defaults":784,"../cartesian/tick_mark_defaults":785,"../cartesian/tick_value_defaults":786,"../subplot_defaults":840,"./layout_attributes":843}],845:[function(t,e,r){"use strict";var n=t("d3"),i=t("tinycolor2"),a=t("../../registry"),o=t("../../lib"),s=o._,l=t("../../components/color"),c=t("../../components/drawing"),u=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,f=t("../plots"),p=t("../cartesian/axes"),d=t("../../components/dragelement"),g=t("../../components/fx"),m=t("../../components/titles"),v=t("../cartesian/select").prepSelect,y=t("../cartesian/select").selectOnClick,x=t("../cartesian/select").clearSelect,b=t("../cartesian/constants");function _(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework(e),this.aTickLayout=null,this.bTickLayout=null,this.cTickLayout=null}e.exports=_;var w=_.prototype;w.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={},this.layers={}},w.plot=function(t,e){var r=e[this.id],n=e._size;this._hasClipOnAxisFalse=!1;for(var i=0;iA*x?i=(a=x)*A:a=(i=y)/A,o=m*i/y,s=v*a/x,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-g)-a/2,f.x0=r,f.y0=n,f.w=i,f.h=a,f.sum=b,f.xaxis={type:"linear",range:[_+2*C-b,b-_-2*w],domain:[d-o/2,d+o/2],_id:"x"},u(f.xaxis,f.graphDiv._fullLayout),f.xaxis.setScale(),f.xaxis.isPtWithinRange=function(t){return t.a>=f.aaxis.range[0]&&t.a<=f.aaxis.range[1]&&t.b>=f.baxis.range[1]&&t.b<=f.baxis.range[0]&&t.c>=f.caxis.range[1]&&t.c<=f.caxis.range[0]},f.yaxis={type:"linear",range:[_,b-w-C],domain:[g-s/2,g+s/2],_id:"y"},u(f.yaxis,f.graphDiv._fullLayout),f.yaxis.setScale(),f.yaxis.isPtWithinRange=function(){return!0};var M=f.yaxis.domain[0],k=f.aaxis=h({},t.aaxis,{range:[_,b-w-C],side:"left",tickangle:(+t.aaxis.tickangle||0)-30,domain:[M,M+s*A],anchor:"free",position:0,_id:"y",_length:i});u(k,f.graphDiv._fullLayout),k.setScale();var I=f.baxis=h({},t.baxis,{range:[b-_-C,w],side:"bottom",domain:f.xaxis.domain,anchor:"free",position:0,_id:"x",_length:i});u(I,f.graphDiv._fullLayout),I.setScale();var T=f.caxis=h({},t.caxis,{range:[b-_-w,C],side:"right",tickangle:(+t.caxis.tickangle||0)+30,domain:[M,M+s*A],anchor:"free",position:0,_id:"y",_length:i});u(T,f.graphDiv._fullLayout),T.setScale();var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";f.clipDef.select("path").attr("d",L),f.layers.plotbg.select("path").attr("d",L);var S="M0,"+a+"h"+i+"l-"+i/2+",-"+a+"Z";f.clipDefRelative.select("path").attr("d",S);var E="translate("+r+","+n+")";f.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",E),f.clipDefRelative.select("path").attr("transform",null);var D="translate("+(r-I._offset)+","+(n+a)+")";f.layers.baxis.attr("transform",D),f.layers.bgrid.attr("transform",D);var P="translate("+(r+i/2)+","+n+")rotate(30)translate(0,"+-k._offset+")";f.layers.aaxis.attr("transform",P),f.layers.agrid.attr("transform",P);var O="translate("+(r+i/2)+","+n+")rotate(-30)translate(0,"+-T._offset+")";f.layers.caxis.attr("transform",O),f.layers.cgrid.attr("transform",O),f.drawAxes(!0),f.layers.aline.select("path").attr("d",k.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(l.stroke,k.linecolor||"#000").style("stroke-width",(k.linewidth||0)+"px"),f.layers.bline.select("path").attr("d",I.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(l.stroke,I.linecolor||"#000").style("stroke-width",(I.linewidth||0)+"px"),f.layers.cline.select("path").attr("d",T.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(l.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),f.graphDiv._context.staticPlot||f.initInteractions(),c.setClipUrl(f.layers.frontplot,f._hasClipOnAxisFalse?null:f.clipId,f.graphDiv)},w.drawAxes=function(t){var e=this.graphDiv,r=this.id.substr(7)+"title",n=this.layers,i=this.aaxis,a=this.baxis,o=this.caxis;if(this.drawAx(i),this.drawAx(a),this.drawAx(o),t){var l=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0)),c=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;n["a-title"]=m.draw(e,"a"+r,{propContainer:i,propName:this.id+".aaxis.title",placeholder:s(e,"Click to enter Component A title"),attributes:{x:this.x0+this.w/2,y:this.y0-i.title.font.size/3-l,"text-anchor":"middle"}}),n["b-title"]=m.draw(e,"b"+r,{propContainer:a,propName:this.id+".baxis.title",placeholder:s(e,"Click to enter Component B title"),attributes:{x:this.x0-c,y:this.y0+this.h+.83*a.title.font.size+c,"text-anchor":"middle"}}),n["c-title"]=m.draw(e,"c"+r,{propContainer:o,propName:this.id+".caxis.title",placeholder:s(e,"Click to enter Component C title"),attributes:{x:this.x0+this.w+c,y:this.y0+this.h+.83*o.title.font.size+c,"text-anchor":"middle"}})}},w.drawAx=function(t){var e,r=this.graphDiv,n=t._name,i=n.charAt(0),a=t._id,s=this.layers[n],l=i+"tickLayout",c=(e=t).ticks+String(e.ticklen)+String(e.showticklabels);this[l]!==c&&(s.selectAll("."+a+"tick").remove(),this[l]=c),t.setScale();var u=p.calcTicks(t),h=p.clipEnds(t,u),f=p.makeTransFn(t),d=p.getTickSigns(t)[2],g=o.deg2rad(30),m=d*(t.linewidth||1)/2,v=d*t.ticklen,y=this.w,x=this.h,b="b"===i?"M0,"+m+"l"+Math.sin(g)*v+","+Math.cos(g)*v:"M"+m+",0l"+Math.cos(g)*v+","+-Math.sin(g)*v,_={a:"M0,0l"+x+",-"+y/2,b:"M0,0l-"+y/2+",-"+x,c:"M0,0l-"+x+","+y/2}[i];p.drawTicks(r,t,{vals:"inside"===t.ticks?h:u,layer:s,path:b,transFn:f,crisp:!1}),p.drawGrid(r,t,{vals:h,layer:this.layers[i+"grid"],path:_,transFn:f,crisp:!1}),p.drawLabels(r,t,{vals:u,layer:s,transFn:f,labelFns:p.makeLabelFns(t,0,30)})};var C=b.MINZOOM/2+.87,M="m-0.87,.5h"+C+"v3h-"+(C+5.2)+"l"+(C/2+2.6)+",-"+(.87*C+4.5)+"l2.6,1.5l-"+C/2+","+.87*C+"Z",k="m0.87,.5h-"+C+"v3h"+(C+5.2)+"l-"+(C/2+2.6)+",-"+(.87*C+4.5)+"l-2.6,1.5l"+C/2+","+.87*C+"Z",I="m0,1l"+C/2+","+.87*C+"l2.6,-1.5l-"+(C/2+2.6)+",-"+(.87*C+4.5)+"l-"+(C/2+2.6)+","+(.87*C+4.5)+"l2.6,1.5l"+C/2+",-"+.87*C+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",L=!0;function S(t){n.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}w.initInteractions=function(){var t,e,r,n,u,h,f,p,m,_,w=this,C=w.layers.plotbg.select("path").node(),E=w.graphDiv,D=E._fullLayout._zoomlayer,P={element:C,gd:E,plotinfo:{id:w.id,xaxis:w.xaxis,yaxis:w.yaxis},subplot:w.id,prepFn:function(a,o,s){P.xaxes=[w.xaxis],P.yaxes=[w.yaxis];var c=E._fullLayout.dragmode;P.minDrag="lasso"===c?1:void 0,"zoom"===c?(P.moveFn=j,P.clickFn=z,P.doneFn=B,function(a,o,s){var c=C.getBoundingClientRect();t=o-c.left,e=s-c.top,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,n=w.aaxis.range[1]-r.a,h=i(w.graphDiv._fullLayout[w.id].bgcolor).getLuminance(),f="M0,"+w.h+"L"+w.w/2+", 0L"+w.w+","+w.h+"Z",p=!1,m=D.append("path").attr("class","zoombox").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:h>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",f),_=D.append("path").attr("class","zoombox-corners").attr("transform","translate("+w.x0+", "+w.y0+")").style({fill:l.background,stroke:l.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),x(E)}(0,o,s)):"pan"===c?(P.moveFn=Y,P.clickFn=z,P.doneFn=V,r={a:w.aaxis.range[0],b:w.baxis.range[1],c:w.caxis.range[1]},u=r,x(E)):"select"!==c&&"lasso"!==c||v(a,o,s,P,c)}};function O(t){var e={};return e[w.id+".aaxis.min"]=t.a,e[w.id+".baxis.min"]=t.b,e[w.id+".caxis.min"]=t.c,e}function z(t,e){var r=E._fullLayout.clickmode;S(E),2===t&&(E.emit("plotly_doubleclick",null),a.call("_guiRelayout",E,O({a:0,b:0,c:0}))),r.indexOf("select")>-1&&1===t&&y(e,E,[w.xaxis],[w.yaxis],w.id,P),r.indexOf("event")>-1&&g.click(E,e,w.id)}function R(t,e){return 1-e/w.h}function F(t,e){return 1-(t+(w.h-e)/Math.sqrt(3))/w.w}function N(t,e){return(t-(w.h-e)/Math.sqrt(3))/w.w}function j(i,a){var o=t+i,s=e+a,l=Math.max(0,Math.min(1,R(0,e),R(0,s))),c=Math.max(0,Math.min(1,F(t,e),F(o,s))),d=Math.max(0,Math.min(1,N(t,e),N(o,s))),g=(l/2+d)*w.w,v=(1-l/2-c)*w.w,y=(g+v)/2,x=v-g,C=(1-l)*w.h,L=C-x/A;x.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),_.transition().style("opacity",1).duration(200),p=!0),E.emit("plotly_relayouting",O(u))}function B(){S(E),u!==r&&(a.call("_guiRelayout",E,O(u)),L&&E.data&&E._context.showTips&&(o.notifier(s(E,"Double-click to zoom back out"),"long"),L=!1))}function Y(t,e){var n=t/w.xaxis._m,i=e/w.yaxis._m,a=[(u={a:r.a-i,b:r.b+(n+i)/2,c:r.c-(n-i)/2}).a,u.b,u.c].sort(),o=a.indexOf(u.a),s=a.indexOf(u.b),l=a.indexOf(u.c);a[0]<0&&(a[1]+a[0]/2<0?(a[2]+=a[0]+a[1],a[0]=a[1]=0):(a[2]+=a[0]/2,a[1]+=a[0]/2,a[0]=0),u={a:a[o],b:a[s],c:a[l]},e=(r.a-u.a)*w.yaxis._m,t=(r.c-u.c-r.b+u.b)*w.xaxis._m);var h="translate("+(w.x0+t)+","+(w.y0+e)+")";w.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",h);var f="translate("+-t+","+-e+")";w.clipDefRelative.select("path").attr("transform",f),w.aaxis.range=[u.a,w.sum-u.b-u.c],w.baxis.range=[w.sum-u.a-u.c,u.b],w.caxis.range=[w.sum-u.a-u.b,u.c],w.drawAxes(!1),w._hasClipOnAxisFalse&&w.plotContainer.select(".scatterlayer").selectAll(".trace").call(c.hideOutsideRangePoints,w),E.emit("plotly_relayouting",O(u))}function V(){a.call("_guiRelayout",E,O(u))}C.onmousemove=function(t){g.hover(E,t,w.id),E._fullLayout._lasthover=C,E._fullLayout._hoversubplot=w.id},C.onmouseout=function(t){E._dragging||d.unhover(E,t)},d.init(P)}},{"../../components/color":592,"../../components/dragelement":610,"../../components/drawing":613,"../../components/fx":630,"../../components/titles":679,"../../lib":717,"../../lib/extend":708,"../../registry":846,"../cartesian/axes":765,"../cartesian/constants":771,"../cartesian/select":782,"../cartesian/set_convert":783,"../plots":826,d3:165,tinycolor2:536}],846:[function(t,e,r){"use strict";var n=t("./lib/loggers"),i=t("./lib/noop"),a=t("./lib/push_unique"),o=t("./lib/is_plain_object"),s=t("./lib/dom").addStyleRule,l=t("./lib/extend"),c=t("./plots/attributes"),u=t("./plots/layout_attributes"),h=l.extendFlat,f=l.extendDeepAll;function p(t){var e=t.name,i=t.categories,a=t.meta;if(r.modules[e])n.log("Type "+e+" already registered");else{r.subplotsRegistry[t.basePlotModule.name]||function(t){var e=t.name;if(r.subplotsRegistry[e])n.log("Plot type "+e+" already registered.");else for(var i in v(t),r.subplotsRegistry[e]=t,r.componentsRegistry)b(i,t.name)}(t.basePlotModule);for(var o={},l=0;l-1&&(h[p[r]].title={text:""});for(r=0;r")?"":e.html(t).text()}));return e.remove(),r}(A)).replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")).replace(c,"'"),i.isIE()&&(A=(A=(A=A.replace(/"/gi,"'")).replace(/(\('#)([^']*)('\))/gi,'("#$2")')).replace(/(\\')/gi,'"')),A}},{"../components/color":592,"../components/drawing":613,"../constants/xmlns_namespaces":694,"../lib":717,d3:165}],855:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;r0&&h.s>0||(c=!1)}o._extremes[t._id]=s.findExtremes(t,l,{tozero:!c,padded:!0})}}function v(t){for(var e=t.traces,r=0;rh+c||!n(u))}for(var p=0;p0&&_.s>0||(v=!1)}}g._extremes[t._id]=s.findExtremes(t,m,{tozero:!v,padded:y})}}function x(t){return t._id.charAt(0)}e.exports={crossTraceCalc:function(t,e){for(var r=e.xaxis,n=e.yaxis,i=t._fullLayout,a=t._fullData,s=t.calcdata,l=[],c=[],h=0;ha))return e}return void 0!==r?r:t.dflt},r.coerceColor=function(t,e,r){return i(e).isValid()?e:void 0!==r?r:t.dflt},r.coerceEnumerated=function(t,e,r){return t.coerceNumber&&(e=+e),-1!==t.values.indexOf(e)?e:void 0!==r?r:t.dflt},r.getValue=function(t,e){var r;return Array.isArray(t)?e0?i+=a:e<0&&(i-=a)}return n.inbox(r-e,i-e,x+(i-e)/(i-r)-1)}"h"===g.orientation?(a=r,s=e,c="y",u="x",h=I,f=k):(a=e,s=r,c="x",u="y",f=I,h=k);var T=t[c+"a"],L=t[u+"a"];p=Math.abs(T.r2c(T.range[1])-T.r2c(T.range[0]));var S=n.getDistanceFunction(i,h,f,(function(t){return(h(t)+f(t))/2}));if(n.getClosest(d,S,t),!1!==t.index){v||(A=function(t){return Math.min(_(t),t.p-m.bargroupwidth/2)},C=function(t){return Math.max(w(t),t.p+m.bargroupwidth/2)});var E=d[t.index],D=g.base?E.b+E.s:E.s;t[u+"0"]=t[u+"1"]=L.c2p(E[u],!0),t[u+"LabelVal"]=D;var P=m.extents[m.extents.round(E.p)];return t[c+"0"]=T.c2p(v?A(E):P[0],!0),t[c+"1"]=T.c2p(v?C(E):P[1],!0),t[c+"LabelVal"]=E.p,t.labelLabel=l(T,t[c+"LabelVal"]),t.valueLabel=l(L,t[u+"LabelVal"]),t.spikeDistance=(I(E)+function(t){return M(_(t),w(t))}(E))/2+b-x,t[c+"Spike"]=T.c2p(E.p,!0),o(E,g,t),t.hovertemplate=g.hovertemplate,t}}function u(t,e){var r=e.mcc||t.marker.color,n=e.mlcc||t.marker.line.color,i=s(t,e);return a.opacity(r)?r:a.opacity(n)&&i?n:void 0}e.exports={hoverPoints:function(t,e,r,n){var a=c(t,e,r,n);if(a){var o=a.cd,s=o[0].trace,l=o[a.index];return a.color=u(s,l),i.getComponentMethod("errorbars","hoverInfo")(l,s,a),[a]}},hoverOnBars:c,getTraceColor:u}},{"../../components/color":592,"../../components/fx":630,"../../lib":717,"../../plots/cartesian/axes":765,"../../registry":846,"./helpers":862}],864:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults").supplyDefaults,crossTraceDefaults:t("./defaults").crossTraceDefaults,supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc").crossTraceCalc,colorbar:t("../scatter/marker_colorbar"),arraysToCalcdata:t("./arrays_to_calcdata"),plot:t("./plot").plot,style:t("./style").style,styleOnSelect:t("./style").styleOnSelect,hoverPoints:t("./hover").hoverPoints,eventData:t("./event_data"),selectPoints:t("./select"),moduleType:"trace",name:"bar",basePlotModule:t("../../plots/cartesian"),categories:["bar-like","cartesian","svg","bar","oriented","errorBarsOK","showLegend","zoomScale"],animatable:!0,meta:{}}},{"../../plots/cartesian":776,"../scatter/marker_colorbar":1138,"./arrays_to_calcdata":855,"./attributes":856,"./calc":857,"./cross_trace_calc":859,"./defaults":860,"./event_data":861,"./hover":863,"./layout_attributes":865,"./layout_defaults":866,"./plot":867,"./select":868,"./style":870}],865:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group",editType:"calc"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:"",editType:"calc"},bargap:{valType:"number",min:0,max:1,editType:"calc"},bargroupgap:{valType:"number",min:0,max:1,dflt:0,editType:"calc"}}},{}],866:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,h={},f=s("barmode"),p=0;p0}function I(t){return"auto"===t?0:t}function T(t,e){var r=Math.PI/180*e,n=Math.abs(Math.sin(r)),i=Math.abs(Math.cos(r));return{x:t.width*i+t.height*n,y:t.width*n+t.height*i}}function L(t,e,r,n,i,a){var o=!!a.isHorizontal,s=!!a.constrained,l=a.angle||0,c=a.anchor||"end",u="end"===c,h="start"===c,f=((a.leftToRight||0)+1)/2,p=1-f,d=i.width,g=i.height,m=Math.abs(e-t),v=Math.abs(n-r),y=m>2*_&&v>2*_?_:0;m-=2*y,v-=2*y;var x=I(l);"auto"!==l||d<=m&&g<=v||!(d>m||g>v)||(d>v||g>m)&&d.01?W:function(t,e){return Math.abs(t-e)>=2?W(t):t>e?Math.ceil(t):Math.floor(t)};U&&(R=Z(R,F),F=Z(F,R)),H&&(N=Z(N,j),j=Z(j,N))}var X=M(a.ensureSingle(A,"path"),E,m,v);if(X.style("vector-effect","non-scaling-stroke").attr("d","M"+R+","+N+"V"+j+"H"+F+"V"+N+"Z").call(l.setClipUrl,e.layerClipId,t),!E.uniformtext.mode&&k(m)){var J=l.makePointStyleFns(h);l.singlePointStyle(c,X,h,J,t)}!function(t,e,r,n,i,s,c,h,p,m,v){var w,A=e.xaxis,k=e.yaxis,S=t._fullLayout;function E(e,r,n){return a.ensureSingle(e,"text").text(r).attr({class:"bartext bartext-"+w,"text-anchor":"middle","data-notex":1}).call(l.font,n).call(o.convertToTspans,t)}var D=n[0].trace,P="h"===D.orientation,O=function(t,e,r,n,i){var o,s=e[0].trace;return o=s.texttemplate?function(t,e,r,n,i){var o=e[0].trace,s=a.castOption(o,r,"texttemplate");if(!s)return"";var l,c,h,f,p="waterfall"===o.type,d="funnel"===o.type;function g(t){return u(f,+t,!0).text}"h"===o.orientation?(l="y",c=i,h="x",f=n):(l="x",c=n,h="y",f=i);var m,v=e[r],y={};y.label=v.p,y.labelLabel=y[l+"Label"]=(m=v.p,u(c,m,!0).text);var x=a.castOption(o,v.i,"text");(0===x||x)&&(y.text=x),y.value=v.s,y.valueLabel=y[h+"Label"]=g(v.s);var _={};b(_,o,v.i),p&&(y.delta=+v.rawS||v.s,y.deltaLabel=g(y.delta),y.final=v.v,y.finalLabel=g(y.final),y.initial=y.final-y.delta,y.initialLabel=g(y.initial)),d&&(y.value=v.s,y.valueLabel=g(y.value),y.percentInitial=v.begR,y.percentInitialLabel=a.formatPercent(v.begR),y.percentPrevious=v.difR,y.percentPreviousLabel=a.formatPercent(v.difR),y.percentTotal=v.sumR,y.percenTotalLabel=a.formatPercent(v.sumR));var w=a.castOption(o,v.i,"customdata");return w&&(y.customdata=w),a.texttemplateString(s,y,t._d3locale,_,y,o._meta||{})}(t,e,r,n,i):s.textinfo?function(t,e,r,n){var i=t[0].trace,o="h"===i.orientation,s="waterfall"===i.type,l="funnel"===i.type;function c(t){return u(o?r:n,+t,!0).text}var h,f,p=i.textinfo,d=t[e],g=p.split("+"),m=[],v=function(t){return-1!==g.indexOf(t)};if(v("label")&&m.push((f=t[e].p,u(o?n:r,f,!0).text)),v("text")&&(0===(h=a.castOption(i,d.i,"text"))||h)&&m.push(h),s){var y=+d.rawS||d.s,x=d.v,b=x-y;v("initial")&&m.push(c(b)),v("delta")&&m.push(c(y)),v("final")&&m.push(c(x))}if(l){v("value")&&m.push(c(d.s));var _=0;v("percent initial")&&_++,v("percent previous")&&_++,v("percent total")&&_++;var w=_>1;v("percent initial")&&(h=a.formatPercent(d.begR),w&&(h+=" of initial"),m.push(h)),v("percent previous")&&(h=a.formatPercent(d.difR),w&&(h+=" of previous"),m.push(h)),v("percent total")&&(h=a.formatPercent(d.sumR),w&&(h+=" of total"),m.push(h))}return m.join("
")}(e,r,n,i):g.getValue(s.text,r),g.coerceString(y,o)}(S,n,i,A,k);w=function(t,e){var r=g.getValue(t.textposition,e);return g.coerceEnumerated(x,r)}(D,i);var z="stack"===m.mode||"relative"===m.mode,R=n[i],F=!z||R._outmost;if(O&&"none"!==w&&(!R.isBlank&&s!==c&&h!==p||"auto"!==w&&"inside"!==w)){var N=S.font,j=d.getBarColor(n[i],D),B=d.getInsideTextFont(D,i,N,j),Y=d.getOutsideTextFont(D,i,N),V=r.datum();P?"log"===A.type&&V.s0<=0&&(s=A.range[0]=G*(X/q):X>=q*(Z/G);G>0&&q>0&&(J||K||Q)?w="inside":(w="outside",U.remove(),U=null)}else w="inside";if(!U){W=a.ensureUniformFontSize(t,"outside"===w?Y:B);var $=(U=E(r,O,W)).attr("transform");if(U.attr("transform",""),H=l.bBox(U.node()),G=H.width,q=H.height,U.attr("transform",$),G<=0||q<=0)return void U.remove()}var tt,et,rt=D.textangle;"outside"===w?(et="both"===D.constraintext||"outside"===D.constraintext,tt=function(t,e,r,n,i,a){var o,s=!!a.isHorizontal,l=!!a.constrained,c=a.angle||0,u=i.width,h=i.height,f=Math.abs(e-t),p=Math.abs(n-r);o=s?p>2*_?_:0:f>2*_?_:0;var d=1;l&&(d=s?Math.min(1,p/h):Math.min(1,f/u));var g=I(c),m=T(i,g),v=(s?m.x:m.y)/2,y=(i.left+i.right)/2,x=(i.top+i.bottom)/2,b=(t+e)/2,w=(r+n)/2,A=0,M=0,k=s?C(e,t):C(r,n);return s?(b=e-k*o,A=k*v):(w=n+k*o,M=-k*v),{textX:y,textY:x,targetX:b,targetY:w,anchorX:A,anchorY:M,scale:d,rotate:g}}(s,c,h,p,H,{isHorizontal:P,constrained:et,angle:rt})):(et="both"===D.constraintext||"inside"===D.constraintext,tt=L(s,c,h,p,H,{isHorizontal:P,constrained:et,angle:rt,anchor:D.insidetextanchor})),tt.fontSize=W.size,f(D.type,tt,S),R.transform=tt,M(U,S,m,v).attr("transform",a.getTextTransform(tt))}else r.select("text").remove()}(t,e,A,r,p,R,F,N,j,m,v),e.layerClipId&&l.hideOutsideRangePoint(c,A.select("text"),w,S,h.xcalendar,h.ycalendar)}));var j=!1===h.cliponaxis;l.setClipUrl(c,j?null:e.layerClipId,t)}));c.getComponentMethod("errorbars","plot")(t,D,e,m)},toMoveInsideBar:L}},{"../../components/color":592,"../../components/drawing":613,"../../components/fx/helpers":627,"../../lib":717,"../../lib/svg_text_utils":741,"../../plots/cartesian/axes":765,"../../registry":846,"./attributes":856,"./constants":858,"./helpers":862,"./style":870,"./uniform_text":872,d3:165,"fast-isnumeric":228}],868:[function(t,e,r){"use strict";function n(t,e,r,n,i){var a=e.c2p(n?t.s0:t.p0,!0),o=e.c2p(n?t.s1:t.p1,!0),s=r.c2p(n?t.p0:t.s0,!0),l=r.c2p(n?t.p1:t.s1,!0);return i?[(a+o)/2,(s+l)/2]:n?[o,(s+l)/2]:[(a+o)/2,l]}e.exports=function(t,e){var r,i=t.cd,a=t.xaxis,o=t.yaxis,s=i[0].trace,l="funnel"===s.type,c="h"===s.orientation,u=[];if(!1===e)for(r=0;r1||0===i.bargap&&0===i.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")})),e.selectAll("g.points").each((function(e){d(n.select(this),e[0].trace,t)})),s.getComponentMethod("errorbars","style")(e)},styleTextPoints:g,styleOnSelect:function(t,e,r){var i=e[0].trace;i.selectedpoints?function(t,e,r){a.selectedPointStyle(t.selectAll("path"),e),function(t,e,r){t.each((function(t){var i,s=n.select(this);if(t.selected){i=o.ensureUniformFontSize(r,m(s,t,e,r));var l=e.selected.textfont&&e.selected.textfont.color;l&&(i.color=l),a.font(s,i)}else a.selectedTextStyle(s,e)}))}(t.selectAll("text"),e,r)}(r,i,t):(d(r,i,t),s.getComponentMethod("errorbars","style")(r))},getInsideTextFont:y,getOutsideTextFont:x,getBarColor:_,resizeText:l}},{"../../components/color":592,"../../components/drawing":613,"../../lib":717,"../../registry":846,"./attributes":856,"./helpers":862,"./uniform_text":872,d3:165}],871:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width"),r("marker.opacity"),r("selected.marker.color"),r("unselected.marker.color")}},{"../../components/color":592,"../../components/colorscale/defaults":602,"../../components/colorscale/helpers":603}],872:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib");function a(t){return"_"+t+"Text_minsize"}e.exports={recordMinTextSize:function(t,e,r){if(r.uniformtext.mode){var n=a(t),i=r.uniformtext.minsize,o=e.scale*e.fontSize;e.hide=of.range[1]&&(x+=Math.PI),n.getClosest(c,(function(t){return g(y,x,[t.rp0,t.rp1],[t.thetag0,t.thetag1],d)?m+Math.min(1,Math.abs(t.thetag1-t.thetag0)/v)-1+(t.rp1-y)/(t.rp1-t.rp0)-1:1/0}),t),!1!==t.index){var b=c[t.index];t.x0=t.x1=b.ct[0],t.y0=t.y1=b.ct[1];var _=i.extendFlat({},b,{r:b.s,theta:b.p});return o(b,u,t),s(_,u,h,t),t.hovertemplate=u.hovertemplate,t.color=a(u,b),t.xLabelVal=t.yLabelVal=void 0,b.s<0&&(t.idealAlign="left"),[t]}}},{"../../components/fx":630,"../../lib":717,"../../plots/polar/helpers":828,"../bar/hover":863,"../scatterpolar/hover":1197}],877:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"barpolar",basePlotModule:t("../../plots/polar"),categories:["polar","bar","showLegend"],attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot"),colorbar:t("../scatter/marker_colorbar"),formatLabels:t("../scatterpolar/format_labels"),style:t("../bar/style").style,styleOnSelect:t("../bar/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../bar/select"),meta:{}}},{"../../plots/polar":829,"../bar/select":868,"../bar/style":870,"../scatter/marker_colorbar":1138,"../scatterpolar/format_labels":1196,"./attributes":873,"./calc":874,"./defaults":875,"./hover":876,"./layout_attributes":878,"./layout_defaults":879,"./plot":880}],878:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","overlay"],dflt:"stack",editType:"calc"},bargap:{valType:"number",dflt:.1,min:0,max:1,editType:"calc"}}},{}],879:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){var a,o={};function s(r,o){return n.coerce(t[a]||{},e[a],i,r,o)}for(var l=0;l0?(c=o,u=l):(c=l,u=o);var h=[s.findEnclosingVertexAngles(c,t.vangles)[0],(c+u)/2,s.findEnclosingVertexAngles(u,t.vangles)[1]];return s.pathPolygonAnnulus(n,i,c,u,h,e,r)}:function(t,n,i,o){return a.pathAnnulus(t,n,i,o,e,r)}}(e),p=e.layers.frontplot.select("g.barlayer");a.makeTraceGroups(p,r,"trace bars").each((function(){var r=n.select(this),s=a.ensureSingle(r,"g","points").selectAll("g.point").data(a.identity);s.enter().append("g").style("vector-effect","non-scaling-stroke").style("stroke-miterlimit",2).classed("point",!0),s.exit().remove(),s.each((function(t){var e,r=n.select(this),o=t.rp0=u.c2p(t.s0),s=t.rp1=u.c2p(t.s1),p=t.thetag0=h.c2g(t.p0),d=t.thetag1=h.c2g(t.p1);if(i(o)&&i(s)&&i(p)&&i(d)&&o!==s&&p!==d){var g=u.c2g(t.s1),m=(p+d)/2;t.ct=[l.c2p(g*Math.cos(m)),c.c2p(g*Math.sin(m))],e=f(o,s,p,d)}else e="M0,0Z";a.ensureSingle(r,"path").attr("d",e)})),o.setClipUrl(r,e._hasClipOnAxisFalse?e.clipIds.forTraces:null,t)}))}},{"../../components/drawing":613,"../../lib":717,"../../plots/polar/helpers":828,d3:165,"fast-isnumeric":228}],881:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../bar/attributes"),a=t("../../components/color/attributes"),o=t("../../plots/template_attributes").hovertemplateAttrs,s=t("../../lib/extend").extendFlat,l=n.marker,c=l.line;e.exports={y:{valType:"data_array",editType:"calc+clearAxisTypes"},x:{valType:"data_array",editType:"calc+clearAxisTypes"},x0:{valType:"any",editType:"calc+clearAxisTypes"},y0:{valType:"any",editType:"calc+clearAxisTypes"},dx:{valType:"number",editType:"calc"},dy:{valType:"number",editType:"calc"},name:{valType:"string",editType:"calc+clearAxisTypes"},q1:{valType:"data_array",editType:"calc+clearAxisTypes"},median:{valType:"data_array",editType:"calc+clearAxisTypes"},q3:{valType:"data_array",editType:"calc+clearAxisTypes"},lowerfence:{valType:"data_array",editType:"calc"},upperfence:{valType:"data_array",editType:"calc"},notched:{valType:"boolean",editType:"calc"},notchwidth:{valType:"number",min:0,max:.5,dflt:.25,editType:"calc"},notchspan:{valType:"data_array",editType:"calc"},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],editType:"calc"},jitter:{valType:"number",min:0,max:1,editType:"calc"},pointpos:{valType:"number",min:-2,max:2,editType:"calc"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],editType:"calc"},mean:{valType:"data_array",editType:"calc"},sd:{valType:"data_array",editType:"calc"},orientation:{valType:"enumerated",values:["v","h"],editType:"calc+clearAxisTypes"},quartilemethod:{valType:"enumerated",values:["linear","exclusive","inclusive"],dflt:"linear",editType:"calc"},width:{valType:"number",min:0,dflt:0,editType:"calc"},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)",editType:"style"},symbol:s({},l.symbol,{arrayOk:!1,editType:"plot"}),opacity:s({},l.opacity,{arrayOk:!1,dflt:1,editType:"style"}),size:s({},l.size,{arrayOk:!1,editType:"calc"}),color:s({},l.color,{arrayOk:!1,editType:"style"}),line:{color:s({},c.color,{arrayOk:!1,dflt:a.defaultLine,editType:"style"}),width:s({},c.width,{arrayOk:!1,dflt:0,editType:"style"}),outliercolor:{valType:"color",editType:"style"},outlierwidth:{valType:"number",min:0,dflt:1,editType:"style"},editType:"style"},editType:"plot"},line:{color:{valType:"color",editType:"style"},width:{valType:"number",min:0,dflt:2,editType:"style"},editType:"plot"},fillcolor:n.fillcolor,whiskerwidth:{valType:"number",min:0,max:1,dflt:.5,editType:"calc"},offsetgroup:i.offsetgroup,alignmentgroup:i.alignmentgroup,selected:{marker:n.selected.marker,editType:"style"},unselected:{marker:n.unselected.marker,editType:"style"},text:s({},n.text,{}),hovertext:s({},n.hovertext,{}),hovertemplate:o({}),hoveron:{valType:"flaglist",flags:["boxes","points"],dflt:"boxes+points",editType:"style"}}},{"../../components/color/attributes":591,"../../lib/extend":708,"../../plots/template_attributes":841,"../bar/attributes":856,"../scatter/attributes":1120}],882:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("../../constants/numerical").BADNUM,s=a._;e.exports=function(t,e){var r,l,v,y,x,b,_=t._fullLayout,w=i.getFromId(t,e.xaxis||"x"),A=i.getFromId(t,e.yaxis||"y"),C=[],M="violin"===e.type?"_numViolins":"_numBoxes";"h"===e.orientation?(v=w,y="x",x=A,b="y"):(v=A,y="y",x=w,b="x");var k,I,T,L,S,E,D=function(t,e,r,i){var o,s=e+"0"in t,l="d"+e in t;if(e in t||s&&l)return r.makeCalcdata(t,e);o=s?t[e+"0"]:"name"in t&&("category"===r.type||n(t.name)&&-1!==["linear","log"].indexOf(r.type)||a.isDateTime(t.name)&&"date"===r.type)?t.name:i;for(var c="multicategory"===r.type?r.r2c_just_indices(o):r.d2c(o,0,t[e+"calendar"]),u=t._length,h=new Array(u),f=0;fk.uf};if(e._hasPreCompStats){var F=e[y],N=function(t){return v.d2c((e[t]||[])[r])},j=1/0,B=-1/0;for(r=0;r=k.q1&&k.q3>=k.med){var V=N("lowerfence");k.lf=V!==o&&V<=k.q1?V:f(k,T,L);var U=N("upperfence");k.uf=U!==o&&U>=k.q3?U:p(k,T,L);var H=N("mean");k.mean=H!==o?H:L?a.mean(T,L):(k.q1+k.q3)/2;var G=N("sd");k.sd=H!==o&&G>=0?G:L?a.stdev(T,L,k.mean):k.q3-k.q1,k.lo=d(k),k.uo=g(k);var q=N("notchspan");q=q!==o&&q>0?q:m(k,L),k.ln=k.med-q,k.un=k.med+q;var W=k.lf,Z=k.uf;e.boxpoints&&T.length&&(W=Math.min(W,T[0]),Z=Math.max(Z,T[L-1])),e.notched&&(W=Math.min(W,k.ln),Z=Math.max(Z,k.un)),k.min=W,k.max=Z}else{var X;a.warn(["Invalid input - make sure that q1 <= median <= q3","q1 = "+k.q1,"median = "+k.med,"q3 = "+k.q3].join("\n")),X=k.med!==o?k.med:k.q1!==o?k.q3!==o?(k.q1+k.q3)/2:k.q1:k.q3!==o?k.q3:0,k.med=X,k.q1=k.q3=X,k.lf=k.uf=X,k.mean=k.sd=X,k.ln=k.un=X,k.min=k.max=X}j=Math.min(j,k.min),B=Math.max(B,k.max),k.pts2=I.filter(R),C.push(k)}}e._extremes[v._id]=i.findExtremes(v,[j,B],{padded:!0})}else{var J=v.makeCalcdata(e,y),K=function(t,e){for(var r=t.length,n=new Array(r+1),i=0;i=0&&tt0){var ot,st;(k={}).pos=k[b]=O[r],I=k.pts=$[r].sort(u),L=(T=k[y]=I.map(h)).length,k.min=T[0],k.max=T[L-1],k.mean=a.mean(T,L),k.sd=a.stdev(T,L,k.mean),k.med=a.interp(T,.5),L%2&&(it||at)?(it?(ot=T.slice(0,L/2),st=T.slice(L/2+1)):at&&(ot=T.slice(0,L/2+1),st=T.slice(L/2)),k.q1=a.interp(ot,.5),k.q3=a.interp(st,.5)):(k.q1=a.interp(T,.25),k.q3=a.interp(T,.75)),k.lf=f(k,T,L),k.uf=p(k,T,L),k.lo=d(k),k.uo=g(k);var lt=m(k,L);k.ln=k.med-lt,k.un=k.med+lt,et=Math.min(et,k.ln),rt=Math.max(rt,k.un),k.pts2=I.filter(R),C.push(k)}e._extremes[v._id]=i.findExtremes(v,e.notched?J.concat([et,rt]):J,{padded:!0})}return function(t,e){if(a.isArrayOrTypedArray(e.selectedpoints))for(var r=0;r0?(C[0].t={num:_[M],dPos:z,posLetter:b,valLetter:y,labels:{med:s(t,"median:"),min:s(t,"min:"),q1:s(t,"q1:"),q3:s(t,"q3:"),max:s(t,"max:"),mean:"sd"===e.boxmean?s(t,"mean ± σ:"):s(t,"mean:"),lf:s(t,"lower fence:"),uf:s(t,"upper fence:")}},_[M]++,C):[{t:{empty:!0}}]};var l={text:"tx",hovertext:"htx"};function c(t,e,r){for(var n in l)a.isArrayOrTypedArray(e[n])&&(Array.isArray(r)?a.isArrayOrTypedArray(e[n][r[0]])&&(t[l[n]]=e[n][r[0]][r[1]]):t[l[n]]=e[n][r])}function u(t,e){return t.v-e.v}function h(t){return t.v}function f(t,e,r){return 0===r?t.q1:Math.min(t.q1,e[Math.min(a.findBin(2.5*t.q1-1.5*t.q3,e,!0)+1,r-1)])}function p(t,e,r){return 0===r?t.q3:Math.max(t.q3,e[Math.max(a.findBin(2.5*t.q3-1.5*t.q1,e),0)])}function d(t){return 4*t.q1-3*t.q3}function g(t){return 4*t.q3-3*t.q1}function m(t,e){return 0===e?0:1.57*(t.q3-t.q1)/Math.sqrt(e)}},{"../../constants/numerical":693,"../../lib":717,"../../plots/cartesian/axes":765,"fast-isnumeric":228}],883:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib"),a=t("../../plots/cartesian/axis_ids").getAxisGroup,o=["v","h"];function s(t,e,r,o){var s,l,c,u=e.calcdata,h=e._fullLayout,f=o._id,p=f.charAt(0),d=[],g=0;for(s=0;s1,b=1-h[t+"gap"],_=1-h[t+"groupgap"];for(s=0;s0){var H=T.pointpos,G=T.jitter,q=T.marker.size/2,W=0;H+G>=0&&((W=V*(H+G))>k?(U=!0,B=q,N=W):W>R&&(B=q,N=k)),W<=k&&(N=k);var Z=0;H-G<=0&&((Z=-V*(H-G))>I?(U=!0,Y=q,j=Z):Z>F&&(Y=q,j=I)),Z<=I&&(j=I)}else N=k,j=I;var X=new Array(c.length);for(l=0;l0?(m="v",v=x>0?Math.min(_,b):Math.min(b)):x>0?(m="h",v=Math.min(_)):v=0;if(v){e._length=v;var M=r("orientation",m);e._hasPreCompStats?"v"===M&&0===x?(r("x0",0),r("dx",1)):"h"===M&&0===y&&(r("y0",0),r("dy",1)):"v"===M&&0===x?r("x0"):"h"===M&&0===y&&r("y0"),i.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x","y"],a)}else e.visible=!1}function u(t,e,r,i){var a=i.prefix,o=n.coerce2(t,e,l,"marker.outliercolor"),s=r("marker.line.outliercolor"),c="outliers";e._hasPreCompStats?c="all":(o||s)&&(c="suspectedoutliers");var u=r(a+"points",c);u?(r("jitter","all"===u?.3:0),r("pointpos","all"===u?-1.5:0),r("marker.symbol"),r("marker.opacity"),r("marker.size"),r("marker.color",e.line.color),r("marker.line.color"),r("marker.line.width"),"suspectedoutliers"===u&&(r("marker.line.outliercolor",e.marker.color),r("marker.line.outlierwidth")),r("selected.marker.color"),r("unselected.marker.color"),r("selected.marker.size"),r("unselected.marker.size"),r("text"),r("hovertext")):delete e.marker;var h=r("hoveron");"all"!==h&&-1===h.indexOf("points")||r("hovertemplate"),n.coerceSelectionMarkerOpacity(e,r)}e.exports={supplyDefaults:function(t,e,r,i){function o(r,i){return n.coerce(t,e,l,r,i)}if(c(t,e,o,i),!1!==e.visible){var s=e._hasPreCompStats;s&&(o("lowerfence"),o("upperfence")),o("line.color",(t.marker||{}).color||r),o("line.width"),o("fillcolor",a.addOpacity(e.line.color,.5));var h=!1;if(s){var f=o("mean"),p=o("sd");f&&f.length&&(h=!0,p&&p.length&&(h="sd"))}o("boxmean",h),o("whiskerwidth"),o("width"),o("quartilemethod");var d=!1;if(s){var g=o("notchspan");g&&g.length&&(d=!0)}else n.validate(t.notchwidth,l.notchwidth)&&(d=!0);o("notched",d)&&o("notchwidth"),u(t,e,o,{prefix:"box"})}},crossTraceDefaults:function(t,e){var r,i;function a(t){return n.coerce(i._input,i,l,t)}for(var s=0;st.lo&&(_.so=!0)}return a}));d.enter().append("path").classed("point",!0),d.exit().remove(),d.call(a.translatePoints,l,c)}function u(t,e,r,a){var o,s,l=e.pos,c=e.val,u=a.bPos,h=a.bPosPxOffset||0,f=r.boxmean||(r.meanline||{}).visible;Array.isArray(a.bdPos)?(o=a.bdPos[0],s=a.bdPos[1]):(o=a.bdPos,s=a.bdPos);var p=t.selectAll("path.mean").data("box"===r.type&&r.boxmean||"violin"===r.type&&r.box.visible&&r.meanline.visible?i.identity:[]);p.enter().append("path").attr("class","mean").style({fill:"none","vector-effect":"non-scaling-stroke"}),p.exit().remove(),p.each((function(t){var e=l.c2l(t.pos+u,!0),i=l.l2p(e)+h,a=l.l2p(e-o)+h,p=l.l2p(e+s)+h,d=c.c2p(t.mean,!0),g=c.c2p(t.mean-t.sd,!0),m=c.c2p(t.mean+t.sd,!0);"h"===r.orientation?n.select(this).attr("d","M"+d+","+a+"V"+p+("sd"===f?"m0,0L"+g+","+i+"L"+d+","+a+"L"+m+","+i+"Z":"")):n.select(this).attr("d","M"+a+","+d+"H"+p+("sd"===f?"m0,0L"+i+","+g+"L"+a+","+d+"L"+i+","+m+"Z":""))}))}e.exports={plot:function(t,e,r,a){var o=e.xaxis,s=e.yaxis;i.makeTraceGroups(a,r,"trace boxes").each((function(t){var e,r,i=n.select(this),a=t[0],h=a.t,f=a.trace;h.wdPos=h.bdPos*f.whiskerwidth,!0!==f.visible||h.empty?i.remove():("h"===f.orientation?(e=s,r=o):(e=o,r=s),l(i,{pos:e,val:r},f,h),c(i,{x:o,y:s},f,h),u(i,{pos:e,val:r},f,h))}))},plotBoxAndWhiskers:l,plotPoints:c,plotBoxMean:u}},{"../../components/drawing":613,"../../lib":717,d3:165}],891:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n,i=t.cd,a=t.xaxis,o=t.yaxis,s=[];if(!1===e)for(r=0;r=10)return null;for(var i=1/0,a=-1/0,o=e.length,s=0;s0?Math.floor:Math.ceil,D=L>0?Math.ceil:Math.floor,P=L>0?Math.min:Math.max,O=L>0?Math.max:Math.min,z=E(I+S),R=D(T-S),F=[[h=k(I)]];for(a=z;a*L=0;i--)a[u-i]=t[h][i],o[u-i]=e[h][i];for(s.push({x:a,y:o,bicubic:l}),i=h,a=[],o=[];i>=0;i--)a[h-i]=t[i][0],o[h-i]=e[i][0];return s.push({x:a,y:o,bicubic:c}),s}},{}],905:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e,r){var a,o,s,l,c,u,h,f,p,d,g,m,v,y,x=t["_"+e],b=t[e+"axis"],_=b._gridlines=[],w=b._minorgridlines=[],A=b._boundarylines=[],C=t["_"+r],M=t[r+"axis"];"array"===b.tickmode&&(b.tickvals=x.slice());var k=t._xctrl,I=t._yctrl,T=k[0].length,L=k.length,S=t._a.length,E=t._b.length;n.prepTicks(b),"array"===b.tickmode&&delete b.tickvals;var D=b.smoothing?3:1;function P(n){var i,a,o,s,l,c,u,h,p,d,g,m,v=[],y=[],x={};if("b"===e)for(a=t.b2j(n),o=Math.floor(Math.max(0,Math.min(E-2,a))),s=a-o,x.length=E,x.crossLength=S,x.xy=function(e){return t.evalxy([],e,a)},x.dxy=function(e,r){return t.dxydi([],e,o,r,s)},i=0;i0&&(p=t.dxydi([],i-1,o,0,s),v.push(l[0]+p[0]/3),y.push(l[1]+p[1]/3),d=t.dxydi([],i-1,o,1,s),v.push(h[0]-d[0]/3),y.push(h[1]-d[1]/3)),v.push(h[0]),y.push(h[1]),l=h;else for(i=t.a2i(n),c=Math.floor(Math.max(0,Math.min(S-2,i))),u=i-c,x.length=S,x.crossLength=E,x.xy=function(e){return t.evalxy([],i,e)},x.dxy=function(e,r){return t.dxydj([],c,e,u,r)},a=0;a0&&(g=t.dxydj([],c,a-1,u,0),v.push(l[0]+g[0]/3),y.push(l[1]+g[1]/3),m=t.dxydj([],c,a-1,u,1),v.push(h[0]-m[0]/3),y.push(h[1]-m[1]/3)),v.push(h[0]),y.push(h[1]),l=h;return x.axisLetter=e,x.axis=b,x.crossAxis=M,x.value=n,x.constvar=r,x.index=f,x.x=v,x.y=y,x.smoothing=M.smoothing,x}function O(n){var i,a,o,s,l,c=[],u=[],h={};if(h.length=x.length,h.crossLength=C.length,"b"===e)for(o=Math.max(0,Math.min(E-2,n)),l=Math.min(1,Math.max(0,n-o)),h.xy=function(e){return t.evalxy([],e,n)},h.dxy=function(e,r){return t.dxydi([],e,o,r,l)},i=0;ix.length-1||_.push(i(O(o),{color:b.gridcolor,width:b.gridwidth}));for(f=u;fx.length-1||g<0||g>x.length-1))for(m=x[s],v=x[g],a=0;ax[x.length-1]||w.push(i(P(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&A.push(i(O(0),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&A.push(i(O(x.length-1),{color:b.endlinecolor,width:b.endlinewidth}))}else{for(l=5e-15,u=(c=[Math.floor((x[x.length-1]-b.tick0)/b.dtick*(1+l)),Math.ceil((x[0]-b.tick0)/b.dtick/(1+l))].sort((function(t,e){return t-e})))[0],h=c[1],f=u;f<=h;f++)p=b.tick0+b.dtick*f,_.push(i(P(p),{color:b.gridcolor,width:b.gridwidth}));for(f=u-1;fx[x.length-1]||w.push(i(P(d),{color:b.minorgridcolor,width:b.minorgridwidth}));b.startline&&A.push(i(P(x[0]),{color:b.startlinecolor,width:b.startlinewidth})),b.endline&&A.push(i(P(x[x.length-1]),{color:b.endlinecolor,width:b.endlinewidth}))}}},{"../../lib/extend":708,"../../plots/cartesian/axes":765}],906:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes"),i=t("../../lib/extend").extendFlat;e.exports=function(t,e){var r,a,o,s=e._labels=[],l=e._gridlines;for(r=0;re.length&&(t=t.slice(0,e.length)):t=[],i=0;i90&&(p-=180,l=-l),{angle:p,flip:l,p:t.c2p(n,e,r),offsetMultplier:c}}},{}],920:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("./map_1d_array"),o=t("./makepath"),s=t("./orient_text"),l=t("../../lib/svg_text_utils"),c=t("../../lib"),u=t("../../constants/alignment");function h(t,e,r,i,s,l){var c="const-"+s+"-lines",u=r.selectAll("."+c).data(l);u.enter().append("path").classed(c,!0).style("vector-effect","non-scaling-stroke"),u.each((function(r){var i=r,s=i.x,l=i.y,c=a([],s,t.c2p),u=a([],l,e.c2p),h="M"+o(c,u,i.smoothing);n.select(this).attr("d",h).style("stroke-width",i.width).style("stroke",i.color).style("fill","none")})),u.exit().remove()}function f(t,e,r,a,o,c,u,h){var f=c.selectAll("text."+h).data(u);f.enter().append("text").classed(h,!0);var p=0,d={};return f.each((function(o,c){var u;if("auto"===o.axis.tickangle)u=s(a,e,r,o.xy,o.dxy);else{var h=(o.axis.tickangle+180)*Math.PI/180;u=s(a,e,r,o.xy,[Math.cos(h),Math.sin(h)])}c||(d={angle:u.angle,flip:u.flip});var f=(o.endAnchor?-1:1)*u.flip,g=n.select(this).attr({"text-anchor":f>0?"start":"end","data-notex":1}).call(i.font,o.font).text(o.text).call(l.convertToTspans,t),m=i.bBox(this);g.attr("transform","translate("+u.p[0]+","+u.p[1]+") rotate("+u.angle+")translate("+o.axis.labelpadding*f+","+.3*m.height+")"),p=Math.max(p,m.width+o.axis.labelpadding)})),f.exit().remove(),d.maxExtent=p,d}e.exports=function(t,e,r,i){var l=e.xaxis,u=e.yaxis,p=t._fullLayout._clips;c.makeTraceGroups(i,r,"trace").each((function(e){var r=n.select(this),i=e[0],d=i.trace,m=d.aaxis,v=d.baxis,y=c.ensureSingle(r,"g","minorlayer"),x=c.ensureSingle(r,"g","majorlayer"),b=c.ensureSingle(r,"g","boundarylayer"),_=c.ensureSingle(r,"g","labellayer");r.style("opacity",d.opacity),h(l,u,x,0,"a",m._gridlines),h(l,u,x,0,"b",v._gridlines),h(l,u,y,0,"a",m._minorgridlines),h(l,u,y,0,"b",v._minorgridlines),h(l,u,b,0,"a-boundary",m._boundarylines),h(l,u,b,0,"b-boundary",v._boundarylines);var w=f(t,l,u,d,0,_,m._labels,"a-label"),A=f(t,l,u,d,0,_,v._labels,"b-label");!function(t,e,r,n,i,a,o,l){var u,h,f,p,d=c.aggNums(Math.min,null,r.a),m=c.aggNums(Math.max,null,r.a),v=c.aggNums(Math.min,null,r.b),y=c.aggNums(Math.max,null,r.b);u=.5*(d+m),h=v,f=r.ab2xy(u,h,!0),p=r.dxyda_rough(u,h),void 0===o.angle&&c.extendFlat(o,s(r,i,a,f,r.dxydb_rough(u,h))),g(t,e,r,0,f,p,r.aaxis,i,a,o,"a-title"),u=d,h=.5*(v+y),f=r.ab2xy(u,h,!0),p=r.dxydb_rough(u,h),void 0===l.angle&&c.extendFlat(l,s(r,i,a,f,r.dxyda_rough(u,h))),g(t,e,r,0,f,p,r.baxis,i,a,l,"b-title")}(t,_,d,0,l,u,w,A),function(t,e,r,n,i){var s,l,u,h,f=r.select("#"+t._clipPathId);f.size()||(f=r.append("clipPath").classed("carpetclip",!0));var p=c.ensureSingle(f,"path","carpetboundary"),d=e.clipsegments,g=[];for(h=0;h90&&m<270,y=n.select(this);y.text(u.title.text).call(l.convertToTspans,t),v&&(x=(-l.lineCount(y)+d)*p*a-x),y.attr("transform","translate("+e.p[0]+","+e.p[1]+") rotate("+e.angle+") translate(0,"+x+")").classed("user-select-none",!0).attr("text-anchor","middle").call(i.font,u.title.font)})),y.exit().remove()}},{"../../components/drawing":613,"../../constants/alignment":686,"../../lib":717,"../../lib/svg_text_utils":741,"./makepath":917,"./map_1d_array":918,"./orient_text":919,d3:165}],921:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/search").findBin,a=t("./compute_control_points"),o=t("./create_spline_evaluator"),s=t("./create_i_derivative_evaluator"),l=t("./create_j_derivative_evaluator");e.exports=function(t){var e=t._a,r=t._b,c=e.length,u=r.length,h=t.aaxis,f=t.baxis,p=e[0],d=e[c-1],g=r[0],m=r[u-1],v=e[e.length-1]-e[0],y=r[r.length-1]-r[0],x=v*n.RELATIVE_CULL_TOLERANCE,b=y*n.RELATIVE_CULL_TOLERANCE;p-=x,d+=x,g-=b,m+=b,t.isVisible=function(t,e){return t>p&&tg&&ed||em},t.setScale=function(){var e=t._x,r=t._y,n=a(t._xctrl,t._yctrl,e,r,h.smoothing,f.smoothing);t._xctrl=n[0],t._yctrl=n[1],t.evalxy=o([t._xctrl,t._yctrl],c,u,h.smoothing,f.smoothing),t.dxydi=s([t._xctrl,t._yctrl],h.smoothing,f.smoothing),t.dxydj=l([t._xctrl,t._yctrl],h.smoothing,f.smoothing)},t.i2a=function(t){var r=Math.max(0,Math.floor(t[0]),c-2),n=t[0]-r;return(1-n)*e[r]+n*e[r+1]},t.j2b=function(t){var e=Math.max(0,Math.floor(t[1]),c-2),n=t[1]-e;return(1-n)*r[e]+n*r[e+1]},t.ij2ab=function(e){return[t.i2a(e[0]),t.j2b(e[1])]},t.a2i=function(t){var r=Math.max(0,Math.min(i(t,e),c-2)),n=e[r],a=e[r+1];return Math.max(0,Math.min(c-1,r+(t-n)/(a-n)))},t.b2j=function(t){var e=Math.max(0,Math.min(i(t,r),u-2)),n=r[e],a=r[e+1];return Math.max(0,Math.min(u-1,e+(t-n)/(a-n)))},t.ab2ij=function(e){return[t.a2i(e[0]),t.b2j(e[1])]},t.i2c=function(e,r){return t.evalxy([],e,r)},t.ab2xy=function(n,i,a){if(!a&&(ne[c-1]|ir[u-1]))return[!1,!1];var o=t.a2i(n),s=t.b2j(i),l=t.evalxy([],o,s);if(a){var h,f,p,d,g=0,m=0,v=[];ne[c-1]?(h=c-2,f=1,g=(n-e[c-1])/(e[c-1]-e[c-2])):f=o-(h=Math.max(0,Math.min(c-2,Math.floor(o)))),ir[u-1]?(p=u-2,d=1,m=(i-r[u-1])/(r[u-1]-r[u-2])):d=s-(p=Math.max(0,Math.min(u-2,Math.floor(s)))),g&&(t.dxydi(v,h,p,f,d),l[0]+=v[0]*g,l[1]+=v[1]*g),m&&(t.dxydj(v,h,p,f,d),l[0]+=v[0]*m,l[1]+=v[1]*m)}return l},t.c2p=function(t,e,r){return[e.c2p(t[0]),r.c2p(t[1])]},t.p2x=function(t,e,r){return[e.p2c(t[0]),r.p2c(t[1])]},t.dadi=function(t){var r=Math.max(0,Math.min(e.length-2,t));return e[r+1]-e[r]},t.dbdj=function(t){var e=Math.max(0,Math.min(r.length-2,t));return r[e+1]-r[e]},t.dxyda=function(e,r,n,i){var a=t.dxydi(null,e,r,n,i),o=t.dadi(e,n);return[a[0]/o,a[1]/o]},t.dxydb=function(e,r,n,i){var a=t.dxydj(null,e,r,n,i),o=t.dbdj(r,i);return[a[0]/o,a[1]/o]},t.dxyda_rough=function(e,r,n){var i=v*(n||.1),a=t.ab2xy(e+i,r,!0),o=t.ab2xy(e-i,r,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dxydb_rough=function(e,r,n){var i=y*(n||.1),a=t.ab2xy(e,r+i,!0),o=t.ab2xy(e,r-i,!0);return[.5*(a[0]-o[0])/i,.5*(a[1]-o[1])/i]},t.dpdx=function(t){return t._m},t.dpdy=function(t){return t._m}}},{"../../lib/search":736,"./compute_control_points":909,"./constants":910,"./create_i_derivative_evaluator":911,"./create_j_derivative_evaluator":912,"./create_spline_evaluator":913}],922:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a,o,s=[],l=[],c=t[0].length,u=t.length;function h(e,r){var n,i=0,a=0;return e>0&&void 0!==(n=t[r][e-1])&&(a++,i+=n),e0&&void 0!==(n=t[r-1][e])&&(a++,i+=n),r0&&a0&&i1e-5);return n.log("Smoother converged to",C,"after",M,"iterations"),t}},{"../../lib":717}],923:[function(t,e,r){"use strict";var n=t("../../lib").isArray1D;e.exports=function(t,e,r){var i=r("x"),a=i&&i.length,o=r("y"),s=o&&o.length;if(!a&&!s)return!1;if(e._cheater=!i,a&&!n(i)||s&&!n(o))e._length=null;else{var l=a?i.length:1/0;s&&(l=Math.min(l,o.length)),e.a&&e.a.length&&(l=Math.min(l,e.a.length)),e.b&&e.b.length&&(l=Math.min(l,e.b.length)),e._length=l}return!0}},{"../../lib":717}],924:[function(t,e,r){"use strict";var n=t("../../plots/template_attributes").hovertemplateAttrs,i=t("../scattergeo/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../plots/attributes"),s=t("../../components/color/attributes").defaultLine,l=t("../../lib/extend").extendFlat,c=i.marker.line;e.exports=l({locations:{valType:"data_array",editType:"calc"},locationmode:i.locationmode,z:{valType:"data_array",editType:"calc"},geojson:l({},i.geojson,{}),featureidkey:i.featureidkey,text:l({},i.text,{}),hovertext:l({},i.hovertext,{}),marker:{line:{color:l({},c.color,{dflt:s}),width:l({},c.width,{dflt:1}),editType:"calc"},opacity:{valType:"number",arrayOk:!0,min:0,max:1,dflt:1,editType:"style"},editType:"calc"},selected:{marker:{opacity:i.selected.marker.opacity,editType:"plot"},editType:"plot"},unselected:{marker:{opacity:i.unselected.marker.opacity,editType:"plot"},editType:"plot"},hoverinfo:l({},o.hoverinfo,{editType:"calc",flags:["location","z","text","name"]}),hovertemplate:n(),showlegend:l({},o.showlegend,{dflt:!1})},a("",{cLetter:"z",editTypeOverride:"calc"}))},{"../../components/color/attributes":591,"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../scattergeo/attributes":1161}],925:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../constants/numerical").BADNUM,a=t("../../components/colorscale/calc"),o=t("../scatter/arrays_to_calcdata"),s=t("../scatter/calc_selection");function l(t){return t&&"string"==typeof t}e.exports=function(t,e){var r,c=e._length,u=new Array(c);r=e.geojson?function(t){return l(t)||n(t)}:l;for(var h=0;h")}}(t,h,o,f.mockAxis),[t]}},{"../../lib":717,"../../plots/cartesian/axes":765,"./attributes":924}],929:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../heatmap/colorbar"),calc:t("./calc"),calcGeoJSON:t("./plot").calcGeoJSON,plot:t("./plot").plot,style:t("./style").style,styleOnSelect:t("./style").styleOnSelect,hoverPoints:t("./hover"),eventData:t("./event_data"),selectPoints:t("./select"),moduleType:"trace",name:"choropleth",basePlotModule:t("../../plots/geo"),categories:["geo","noOpacity","showLegend"],meta:{}}},{"../../plots/geo":795,"../heatmap/colorbar":1003,"./attributes":924,"./calc":925,"./defaults":926,"./event_data":927,"./hover":928,"./plot":930,"./select":931,"./style":932}],930:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../lib/geo_location_utils"),o=t("../../lib/topojson_utils").getTopojsonFeatures,s=t("../../plots/cartesian/autorange").findExtremes,l=t("./style").style;e.exports={calcGeoJSON:function(t,e){for(var r=t[0].trace,n=e[r.geo],i=n._subplot,l=r.locationmode,c=r._length,u="geojson-id"===l?a.extractTraceFeature(t):o(r,i.topojson),h=[],f=[],p=0;p=0;n--){var i=r[n].id;if("string"==typeof i&&0===i.indexOf("water"))for(var a=n+1;a=0;r--)t.removeLayer(e[r][1])},s.dispose=function(){var t=this.subplot.map;this._removeLayers(),t.removeSource(this.sourceId)},e.exports=function(t,e){var r=e[0].trace,i=new o(t,r.uid),a=i.sourceId,s=n(e),l=i.below=t.belowLookup["trace-"+r.uid];return t.map.addSource(a,{type:"geojson",data:s.geojson}),i._addLayers(s,l),e[0].trace._glTrace=i,i}},{"../../plots/mapbox/constants":818,"./convert":934}],938:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../plots/template_attributes").hovertemplateAttrs,a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l={x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},u:{valType:"data_array",editType:"calc"},v:{valType:"data_array",editType:"calc"},w:{valType:"data_array",editType:"calc"},sizemode:{valType:"enumerated",values:["scaled","absolute"],editType:"calc",dflt:"scaled"},sizeref:{valType:"number",editType:"calc",min:0},anchor:{valType:"enumerated",editType:"calc",values:["tip","tail","cm","center"],dflt:"cm"},text:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"},hovertemplate:i({editType:"calc"},{keys:["norm"]}),showlegend:s({},o.showlegend,{dflt:!1})};s(l,n("",{colorAttr:"u/v/w norm",showScaleDflt:!0,editTypeOverride:"calc"})),["opacity","lightposition","lighting"].forEach((function(t){l[t]=a[t]})),l.hoverinfo=s({},o.hoverinfo,{editType:"calc",flags:["x","y","z","u","v","w","norm","text","name"],dflt:"x+y+z+norm+text+name"}),l.transforms=void 0,e.exports=l},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../mesh3d/attributes":1061}],939:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){for(var r=e.u,i=e.v,a=e.w,o=Math.min(e.x.length,e.y.length,e.z.length,r.length,i.length,a.length),s=-1/0,l=1/0,c=0;co.level||o.starts.length&&a===o.level)}break;case"constraint":if(n.prefixBoundary=!1,n.edgepaths.length)return;var s=n.x.length,l=n.y.length,c=-1/0,u=1/0;for(r=0;r":p>c&&(n.prefixBoundary=!0);break;case"<":(pc||n.starts.length&&f===u)&&(n.prefixBoundary=!0);break;case"][":h=Math.min(p[0],p[1]),f=Math.max(p[0],p[1]),hc&&(n.prefixBoundary=!0)}}}},{}],946:[function(t,e,r){"use strict";var n=t("../../components/colorscale"),i=t("./make_color_map"),a=t("./end_plus");e.exports={min:"zmin",max:"zmax",calc:function(t,e,r){var o=e.contours,s=e.line,l=o.size||1,c=o.coloring,u=i(e,{isColorbar:!0});if("heatmap"===c){var h=n.extractOpts(e);r._fillgradient=h.reversescale?n.flipScale(h.colorscale):h.colorscale,r._zrange=[h.min,h.max]}else"fill"===c&&(r._fillcolor=u);r._line={color:"lines"===c?u:s.color,width:!1!==o.showlines?s.width:0,dash:s.dash},r._levels={start:o.start,end:a(o),size:l}}}},{"../../components/colorscale":604,"./end_plus":954,"./make_color_map":959}],947:[function(t,e,r){"use strict";e.exports={BOTTOMSTART:[1,9,13,104,713],TOPSTART:[4,6,7,104,713],LEFTSTART:[8,12,14,208,1114],RIGHTSTART:[2,3,11,208,1114],NEWDELTA:[null,[-1,0],[0,-1],[-1,0],[1,0],null,[0,-1],[-1,0],[0,1],[0,1],null,[0,1],[1,0],[1,0],[0,-1]],CHOOSESADDLE:{104:[4,1],208:[2,8],713:[7,13],1114:[11,14]},SADDLEREMAINDER:{1:4,2:8,4:1,7:13,8:2,11:14,13:7,14:11},LABELDISTANCE:2,LABELINCREASE:10,LABELMIN:3,LABELMAX:10,LABELOPTIMIZER:{EDGECOST:1,ANGLECOST:1,NEIGHBORCOST:5,SAMELEVELFACTOR:10,SAMELEVELDISTANCE:5,MAXCOST:100,INITIALSEARCHPOINTS:10,ITERATIONS:5}}},{}],948:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("./label_defaults"),a=t("../../components/color"),o=a.addOpacity,s=a.opacity,l=t("../../constants/filter_ops"),c=l.CONSTRAINT_REDUCTION,u=l.COMPARISON_OPS2;e.exports=function(t,e,r,a,l,h){var f,p,d,g=e.contours,m=r("contours.operation");g._operation=c[m],function(t,e){var r;-1===u.indexOf(e.operation)?(t("contours.value",[0,1]),Array.isArray(e.value)?e.value.length>2?e.value=e.value.slice(2):0===e.length?e.value=[0,1]:e.length<2?(r=parseFloat(e.value[0]),e.value=[r,r+1]):e.value=[parseFloat(e.value[0]),parseFloat(e.value[1])]:n(e.value)&&(r=parseFloat(e.value),e.value=[r,r+1])):(t("contours.value",0),n(e.value)||(Array.isArray(e.value)?e.value=parseFloat(e.value[0]):e.value=0))}(r,g),"="===m?f=g.showlines=!0:(f=r("contours.showlines"),d=r("fillcolor",o((t.line||{}).color||l,.5))),f&&(p=r("line.color",d&&s(d)?o(e.fillcolor,1):l),r("line.width",2),r("line.dash")),r("line.smoothing"),i(r,a,p,h)}},{"../../components/color":592,"../../constants/filter_ops":689,"./label_defaults":958,"fast-isnumeric":228}],949:[function(t,e,r){"use strict";var n=t("../../constants/filter_ops"),i=t("fast-isnumeric");function a(t,e){var r,a=Array.isArray(e);function o(t){return i(t)?+t:null}return-1!==n.COMPARISON_OPS2.indexOf(t)?r=o(a?e[0]:e):-1!==n.INTERVAL_OPS.indexOf(t)?r=a?[o(e[0]),o(e[1])]:[o(e),o(e)]:-1!==n.SET_OPS.indexOf(t)&&(r=a?e.map(o):[o(e)]),r}function o(t){return function(e){e=a(t,e);var r=Math.min(e[0],e[1]),n=Math.max(e[0],e[1]);return{start:r,end:n,size:n-r}}}function s(t){return function(e){return{start:e=a(t,e),end:1/0,size:1/0}}}e.exports={"[]":o("[]"),"][":o("]["),">":s(">"),"<":s("<"),"=":s("=")}},{"../../constants/filter_ops":689,"fast-isnumeric":228}],950:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=n("contours.start"),a=n("contours.end"),o=!1===i||!1===a,s=r("contours.size");!(o?e.autocontour=!0:r("autocontour",!1))&&s||r("ncontours")}},{}],951:[function(t,e,r){"use strict";var n=t("../../lib");function i(t){return n.extendFlat({},t,{edgepaths:n.extendDeep([],t.edgepaths),paths:n.extendDeep([],t.paths),starts:n.extendDeep([],t.starts)})}e.exports=function(t,e){var r,a,o,s=function(t){return t.reverse()},l=function(t){return t};switch(e){case"=":case"<":return t;case">":for(1!==t.length&&n.warn("Contour data invalid for the specified inequality operation."),a=t[0],r=0;r1e3){n.warn("Too many contours, clipping at 1000",t);break}return l}},{"../../lib":717,"./constraint_mapping":949,"./end_plus":954}],954:[function(t,e,r){"use strict";e.exports=function(t){return t.end+t.size/1e6}},{}],955:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./constants");function a(t,e,r,n){return Math.abs(t[0]-e[0])20&&e?208===t||1114===t?n=0===r[0]?1:-1:a=0===r[1]?1:-1:-1!==i.BOTTOMSTART.indexOf(t)?a=1:-1!==i.LEFTSTART.indexOf(t)?n=1:-1!==i.TOPSTART.indexOf(t)?a=-1:n=-1,[n,a]}(h,r,e),p=[s(t,e,[-f[0],-f[1]])],d=t.z.length,g=t.z[0].length,m=e.slice(),v=f.slice();for(c=0;c<1e4;c++){if(h>20?(h=i.CHOOSESADDLE[h][(f[0]||f[1])<0?0:1],t.crossings[u]=i.SADDLEREMAINDER[h]):delete t.crossings[u],!(f=i.NEWDELTA[h])){n.log("Found bad marching index:",h,e,t.level);break}p.push(s(t,e,f)),e[0]+=f[0],e[1]+=f[1],u=e.join(","),a(p[p.length-1],p[p.length-2],o,l)&&p.pop();var y=f[0]&&(e[0]<0||e[0]>g-2)||f[1]&&(e[1]<0||e[1]>d-2);if(e[0]===m[0]&&e[1]===m[1]&&f[0]===v[0]&&f[1]===v[1]||r&&y)break;h=t.crossings[u]}1e4===c&&n.log("Infinite loop in contour?");var x,b,_,w,A,C,M,k,I,T,L,S,E,D,P,O=a(p[0],p[p.length-1],o,l),z=0,R=.2*t.smoothing,F=[],N=0;for(c=1;c=N;c--)if((x=F[c])=N&&x+F[b]k&&I--,t.edgepaths[I]=L.concat(p,T));break}V||(t.edgepaths[k]=p.concat(T))}for(k=0;kt?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);return 5===r||10===r?t>(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4?5===r?713:1114:5===r?104:208:15===r?0:r}e.exports=function(t){var e,r,a,o,s,l,c,u,h,f=t[0].z,p=f.length,d=f[0].length,g=2===p||2===d;for(r=0;r=0&&(n=y,s=l):Math.abs(r[1]-n[1])<.01?Math.abs(r[1]-y[1])<.01&&(y[0]-r[0])*(n[0]-y[0])>=0&&(n=y,s=l):i.log("endpt to newendpt is not vert. or horz.",r,n,y)}if(r=n,s>=0)break;h+="L"+n}if(s===t.edgepaths.length){i.log("unclosed perimeter path");break}f=s,(d=-1===p.indexOf(f))&&(f=p[0],h+="Z")}for(f=0;fn.center?n.right-s:s-n.left)/(u+Math.abs(Math.sin(c)*o)),p=(l>n.middle?n.bottom-l:l-n.top)/(Math.abs(h)+Math.cos(c)*o);if(f<1||p<1)return 1/0;var d=v.EDGECOST*(1/(f-1)+1/(p-1));d+=v.ANGLECOST*c*c;for(var g=s-u,m=l-h,y=s+u,x=l+h,b=0;b2*v.MAXCOST)break;p&&(s/=2),l=(o=c-s/2)+1.5*s}if(f<=v.MAXCOST)return u},r.addLabelData=function(t,e,r,n){var i=e.width/2,a=e.height/2,o=t.x,s=t.y,l=t.theta,c=Math.sin(l),u=Math.cos(l),h=i*u,f=a*c,p=i*c,d=-a*u,g=[[o-h-f,s-p-d],[o+h-f,s+p-d],[o+h+f,s+p+d],[o-h+f,s-p+d]];r.push({text:e.text,x:o,y:s,dy:e.dy,theta:l,level:e.level,width:e.width,height:e.height}),n.push(g)},r.drawLabels=function(t,e,r,a,o){var l=t.selectAll("text").data(e,(function(t){return t.text+","+t.x+","+t.y+","+t.theta}));if(l.exit().remove(),l.enter().append("text").attr({"data-notex":1,"text-anchor":"middle"}).each((function(t){var e=t.x+Math.sin(t.theta)*t.dy,i=t.y-Math.cos(t.theta)*t.dy;n.select(this).text(t.text).attr({x:e,y:i,transform:"rotate("+180*t.theta/Math.PI+" "+e+" "+i+")"}).call(s.convertToTspans,r)})),o){for(var c="",u=0;ur.end&&(r.start=r.end=(r.start+r.end)/2),t._input.contours||(t._input.contours={}),i.extendFlat(t._input.contours,{start:r.start,end:r.end,size:r.size}),t._input.autocontour=!0}else if("constraint"!==r.type){var c,u=r.start,h=r.end,f=t._input.contours;u>h&&(r.start=f.start=h,h=r.end=f.end=u,u=r.start),r.size>0||(c=u===h?1:a(u,h,t.ncontours).dtick,f.size=r.size=c)}}},{"../../lib":717,"../../plots/cartesian/axes":765}],963:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("../heatmap/style"),o=t("./make_color_map");e.exports=function(t){var e=n.select(t).selectAll("g.contour");e.style("opacity",(function(t){return t[0].trace.opacity})),e.each((function(t){var e=n.select(this),r=t[0].trace,a=r.contours,s=r.line,l=a.size||1,c=a.start,u="constraint"===a.type,h=!u&&"lines"===a.coloring,f=!u&&"fill"===a.coloring,p=h||f?o(r):null;e.selectAll("g.contourlevel").each((function(t){n.select(this).selectAll("path").call(i.lineGroupStyle,s.width,h?p(t.level):s.color,s.dash)}));var d=a.labelfont;if(e.selectAll("g.contourlabels text").each((function(t){i.font(n.select(this),{family:d.family,size:d.size,color:d.color||(h?p(t.level):s.color)})})),u)e.selectAll("g.contourfill path").style("fill",r.fillcolor);else if(f){var g;e.selectAll("g.contourfill path").style("fill",(function(t){return void 0===g&&(g=t.level),p(t.level+.5*l)})),void 0===g&&(g=c),e.selectAll("g.contourbg path").style("fill",p(g-.5*l))}})),a(t)}},{"../../components/drawing":613,"../heatmap/style":1012,"./make_color_map":959,d3:165}],964:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults"),i=t("./label_defaults");e.exports=function(t,e,r,a,o){var s,l=r("contours.coloring"),c="";"fill"===l&&(s=r("contours.showlines")),!1!==s&&("lines"!==l&&(c=r("line.color","#000")),r("line.width",.5),r("line.dash")),"none"!==l&&(!0!==t.showlegend&&(e.showlegend=!1),e._dfltShowLegend=!1,n(t,e,a,r,{prefix:"",cLetter:"z"})),r("line.smoothing"),i(r,a,c,o)}},{"../../components/colorscale/defaults":602,"./label_defaults":958}],965:[function(t,e,r){"use strict";var n=t("../heatmap/attributes"),i=t("../contour/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat,s=i.contours;e.exports=o({carpet:{valType:"string",editType:"calc"},z:n.z,a:n.x,a0:n.x0,da:n.dx,b:n.y,b0:n.y0,db:n.dy,text:n.text,hovertext:n.hovertext,transpose:n.transpose,atype:n.xtype,btype:n.ytype,fillcolor:i.fillcolor,autocontour:i.autocontour,ncontours:i.ncontours,contours:{type:s.type,start:s.start,end:s.end,size:s.size,coloring:{valType:"enumerated",values:["fill","lines","none"],dflt:"fill",editType:"calc"},showlines:s.showlines,showlabels:s.showlabels,labelfont:s.labelfont,labelformat:s.labelformat,operation:s.operation,value:s.value,editType:"calc",impliedEdits:{autocontour:!1}},line:{color:i.line.color,width:i.line.width,dash:i.line.dash,smoothing:i.line.smoothing,editType:"plot"},transforms:void 0},a("",{cLetter:"z",autoColorDflt:!1}))},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../contour/attributes":943,"../heatmap/attributes":1e3}],966:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc"),i=t("../../lib"),a=t("../heatmap/convert_column_xyz"),o=t("../heatmap/clean_2d_array"),s=t("../heatmap/interp2d"),l=t("../heatmap/find_empties"),c=t("../heatmap/make_bound_array"),u=t("./defaults"),h=t("../carpet/lookup_carpetid"),f=t("../contour/set_contours");e.exports=function(t,e){var r=e._carpetTrace=h(t,e);if(r&&r.visible&&"legendonly"!==r.visible){if(!e.a||!e.b){var p=t.data[r.index],d=t.data[e.index];d.a||(d.a=p.a),d.b||(d.b=p.b),u(d,e,e._defaultColor,t._fullLayout)}var g=function(t,e){var r,u,h,f,p,d,g,m=e._carpetTrace,v=m.aaxis,y=m.baxis;v._minDtick=0,y._minDtick=0,i.isArray1D(e.z)&&a(e,v,y,"a","b",["z"]),r=e._a=e._a||e.a,f=e._b=e._b||e.b,r=r?v.makeCalcdata(e,"_a"):[],f=f?y.makeCalcdata(e,"_b"):[],u=e.a0||0,h=e.da||1,p=e.b0||0,d=e.db||1,g=e._z=o(e._z||e.z,e.transpose),e._emptypoints=l(g),s(g,e._emptypoints);var x=i.maxRowLength(g),b="scaled"===e.xtype?"":r,_=c(e,b,u,h,x,v),w="scaled"===e.ytype?"":f,A=c(e,w,p,d,g.length,y),C={a:_,b:A,z:g};return"levels"===e.contours.type&&"none"!==e.contours.coloring&&n(t,e,{vals:g,containerStr:"",cLetter:"z"}),[C]}(t,e);return f(e,e._z),g}}},{"../../components/colorscale/calc":600,"../../lib":717,"../carpet/lookup_carpetid":916,"../contour/set_contours":962,"../heatmap/clean_2d_array":1002,"../heatmap/convert_column_xyz":1004,"../heatmap/find_empties":1006,"../heatmap/interp2d":1009,"../heatmap/make_bound_array":1010,"./defaults":967}],967:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../heatmap/xyz_defaults"),a=t("./attributes"),o=t("../contour/constraint_defaults"),s=t("../contour/contours_defaults"),l=t("../contour/style_defaults");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,a,r,i)}if(u("carpet"),t.a&&t.b){if(!i(t,e,u,c,"a","b"))return void(e.visible=!1);u("text"),"constraint"===u("contours.type")?o(t,e,u,c,r,{hasHover:!1}):(s(t,e,u,(function(r){return n.coerce2(t,e,a,r)})),l(t,e,u,c,{hasHover:!1}))}else e._defaultColor=r,e._length=null}},{"../../lib":717,"../contour/constraint_defaults":948,"../contour/contours_defaults":950,"../contour/style_defaults":964,"../heatmap/xyz_defaults":1014,"./attributes":965}],968:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../contour/colorbar"),calc:t("./calc"),plot:t("./plot"),style:t("../contour/style"),moduleType:"trace",name:"contourcarpet",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","carpet","contour","symbols","showLegend","hasLines","carpetDependent","noHover","noSortingByValue"],meta:{}}},{"../../plots/cartesian":776,"../contour/colorbar":946,"../contour/style":963,"./attributes":965,"./calc":966,"./defaults":967,"./plot":969}],969:[function(t,e,r){"use strict";var n=t("d3"),i=t("../carpet/map_1d_array"),a=t("../carpet/makepath"),o=t("../../components/drawing"),s=t("../../lib"),l=t("../contour/make_crossings"),c=t("../contour/find_all_paths"),u=t("../contour/plot"),h=t("../contour/constants"),f=t("../contour/convert_to_constraints"),p=t("../contour/empty_pathinfo"),d=t("../contour/close_boundaries"),g=t("../carpet/lookup_carpetid"),m=t("../carpet/axis_aligned_line");function v(t,e,r){var n=t.getPointAtLength(e),i=t.getPointAtLength(r),a=i.x-n.x,o=i.y-n.y,s=Math.sqrt(a*a+o*o);return[a/s,o/s]}function y(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function x(t,e){var r=Math.abs(t[0]*e[0]+t[1]*e[1]);return Math.sqrt(1-r*r)/r}e.exports=function(t,e,r,b){var _=e.xaxis,w=e.yaxis;s.makeTraceGroups(b,r,"contour").each((function(r){var b=n.select(this),A=r[0],C=A.trace,M=C._carpetTrace=g(t,C),k=t.calcdata[M.index][0];if(M.visible&&"legendonly"!==M.visible){var I=A.a,T=A.b,L=C.contours,S=p(L,e,A),E="constraint"===L.type,D=L._operation,P=E?"="===D?"lines":"fill":L.coloring,O=[[I[0],T[T.length-1]],[I[I.length-1],T[T.length-1]],[I[I.length-1],T[0]],[I[0],T[0]]];l(S);var z=1e-8*(I[I.length-1]-I[0]),R=1e-8*(T[T.length-1]-T[0]);c(S,z,R);var F,N,j,B,Y=S;"constraint"===L.type&&(Y=f(S,D)),function(t,e){var r,n,i,a,o,s,l,c,u;for(r=0;r=0;B--)F=k.clipsegments[B],N=i([],F.x,_.c2p),j=i([],F.y,w.c2p),N.reverse(),j.reverse(),V.push(a(N,j,F.bicubic));var U="M"+V.join("L")+"Z";!function(t,e,r,n,o,l){var c,u,h,f,p=s.ensureSingle(t,"g","contourbg").selectAll("path").data("fill"!==l||o?[]:[0]);p.enter().append("path"),p.exit().remove();var d=[];for(f=0;f=0&&(f=L,d=g):Math.abs(h[1]-f[1])=0&&(f=L,d=g):s.log("endpt to newendpt is not vert. or horz.",h,f,L)}if(d>=0)break;y+=I(h,f),h=f}if(d===e.edgepaths.length){s.log("unclosed perimeter path");break}u=d,(b=-1===x.indexOf(u))&&(u=x[0],y+=I(h,f)+"Z",h=null)}for(u=0;ug&&(n.max=g),n.len=n.max-n.min}function m(t,e){var r,n=0;return(Math.abs(t[0]-l)<.1||Math.abs(t[0]-c)<.1)&&(r=y(i.dxydb_rough(t[0],t[1],.1)),n=Math.max(n,a*x(e,r)/2)),(Math.abs(t[1]-u)<.1||Math.abs(t[1]-h)<.1)&&(r=y(i.dxyda_rough(t[0],t[1],.1)),n=Math.max(n,a*x(e,r)/2)),n}}(this,r,t,n,c,e.height),!(n.len<(e.width+e.height)*h.LABELMIN)))for(var i=Math.min(Math.ceil(n.len/D),h.LABELMAX),a=0;a0?+p[u]:0),h.push({type:"Feature",geometry:{type:"Point",coordinates:v},properties:y})}}var b=o.extractOpts(e),_=b.reversescale?o.flipScale(b.colorscale):b.colorscale,w=_[0][1],A=["interpolate",["linear"],["heatmap-density"],0,a.opacity(w)<1?w:a.addOpacity(w,0)];for(u=1;u<_.length;u++)A.push(_[u][0],_[u][1]);var C=["interpolate",["linear"],["get","z"],b.min,0,b.max,1];return i.extendFlat(c.heatmap.paint,{"heatmap-weight":d?C:1/(b.max-b.min),"heatmap-color":A,"heatmap-radius":g?{type:"identity",property:"r"}:e.radius,"heatmap-opacity":e.opacity}),c.geojson={type:"FeatureCollection",features:h},c.heatmap.layout.visibility="visible",c}},{"../../components/color":592,"../../components/colorscale":604,"../../constants/numerical":693,"../../lib":717,"../../lib/geojson_utils":712,"fast-isnumeric":228}],973:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorscale/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}var l=s("lon")||[],c=s("lat")||[],u=Math.min(l.length,c.length);u?(e._length=u,s("z"),s("radius"),s("below"),s("text"),s("hovertext"),s("hovertemplate"),i(t,e,o,s,{prefix:"",cLetter:"z"})):e.visible=!1}},{"../../components/colorscale/defaults":602,"../../lib":717,"./attributes":970}],974:[function(t,e,r){"use strict";e.exports=function(t,e){return t.lon=e.lon,t.lat=e.lat,t.z=e.z,t}},{}],975:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../scattermapbox/hover");e.exports=function(t,e,r){var o=a(t,e,r);if(o){var s=o[0],l=s.cd,c=l[0].trace,u=l[s.index];if(delete s.color,"z"in u){var h=s.subplot.mockAxis;s.z=u.z,s.zLabel=i.tickText(h,h.c2l(u.z),"hover").text}return s.extraText=function(t,e,r){if(!t.hovertemplate){var i=(e.hi||t.hoverinfo).split("+"),a=-1!==i.indexOf("all"),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=e.lonlat,c=[];return a||o&&s?c.push("("+u(l[0])+", "+u(l[1])+")"):o?c.push(r.lon+u(l[0])):s&&c.push(r.lat+u(l[1])),(a||-1!==i.indexOf("text"))&&n.fillText(e,t,c),c.join("
")}function u(t){return t+"°"}}(c,u,l[0].t.labels),[s]}}},{"../../lib":717,"../../plots/cartesian/axes":765,"../scattermapbox/hover":1189}],976:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../heatmap/colorbar"),formatLabels:t("../scattermapbox/format_labels"),calc:t("./calc"),plot:t("./plot"),hoverPoints:t("./hover"),eventData:t("./event_data"),getBelow:function(t,e){for(var r=e.getMapLayers(),n=0;n=0;r--)t.removeLayer(e[r][1])},o.dispose=function(){var t=this.subplot.map;this._removeLayers(),t.removeSource(this.sourceId)},e.exports=function(t,e){var r=e[0].trace,i=new a(t,r.uid),o=i.sourceId,s=n(e),l=i.below=t.belowLookup["trace-"+r.uid];return t.map.addSource(o,{type:"geojson",data:s.geojson}),i._addLayers(s,l),i}},{"../../plots/mapbox/constants":818,"./convert":972}],978:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e){for(var r=0;r"),s.color=function(t,e){var r=t.marker,i=e.mc||r.color,a=e.mlc||r.line.color,o=e.mlw||r.line.width;return n(i)?i:n(a)&&o?a:void 0}(c,h),[s]}}},{"../../components/color":592,"../../lib":717,"../bar/hover":863}],986:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults").supplyDefaults,crossTraceDefaults:t("./defaults").crossTraceDefaults,supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style").style,hoverPoints:t("./hover"),eventData:t("./event_data"),selectPoints:t("../bar/select"),moduleType:"trace",name:"funnel",basePlotModule:t("../../plots/cartesian"),categories:["bar-like","cartesian","svg","oriented","showLegend","zoomScale"],meta:{}}},{"../../plots/cartesian":776,"../bar/select":868,"./attributes":979,"./calc":980,"./cross_trace_calc":982,"./defaults":983,"./event_data":984,"./hover":985,"./layout_attributes":987,"./layout_defaults":988,"./plot":989,"./style":990}],987:[function(t,e,r){"use strict";e.exports={funnelmode:{valType:"enumerated",values:["stack","group","overlay"],dflt:"stack",editType:"calc"},funnelgap:{valType:"number",min:0,max:1,editType:"calc"},funnelgroupgap:{valType:"number",min:0,max:1,dflt:0,editType:"calc"}}},{}],988:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){var a=!1;function o(r,a){return n.coerce(t,e,i,r,a)}for(var s=0;s path").each((function(t){if(!t.isBlank){var e=s.marker;n.select(this).call(a.fill,t.mc||e.color).call(a.stroke,t.mlc||e.line.color).call(i.dashLine,e.line.dash,t.mlw||e.line.width).style("opacity",s.selectedpoints&&!t.selected?o:1)}})),c(r,s,t),r.selectAll(".regions").each((function(){n.select(this).selectAll("path").style("stroke-width",0).call(a.fill,s.connector.fillcolor)})),r.selectAll(".lines").each((function(){var t=s.connector.line;i.lineGroupStyle(n.select(this).selectAll("path"),t.width,t.color,t.dash)}))}))}}},{"../../components/color":592,"../../components/drawing":613,"../../constants/interactions":692,"../bar/style":870,"../bar/uniform_text":872,d3:165}],991:[function(t,e,r){"use strict";var n=t("../pie/attributes"),i=t("../../plots/attributes"),a=t("../../plots/domain").attributes,o=t("../../plots/template_attributes").hovertemplateAttrs,s=t("../../plots/template_attributes").texttemplateAttrs,l=t("../../lib/extend").extendFlat;e.exports={labels:n.labels,label0:n.label0,dlabel:n.dlabel,values:n.values,marker:{colors:n.marker.colors,line:{color:l({},n.marker.line.color,{dflt:null}),width:l({},n.marker.line.width,{dflt:1}),editType:"calc"},editType:"calc"},text:n.text,hovertext:n.hovertext,scalegroup:l({},n.scalegroup,{}),textinfo:l({},n.textinfo,{flags:["label","text","value","percent"]}),texttemplate:s({editType:"plot"},{keys:["label","color","value","text","percent"]}),hoverinfo:l({},i.hoverinfo,{flags:["label","text","value","percent","name"]}),hovertemplate:o({},{keys:["label","color","value","text","percent"]}),textposition:l({},n.textposition,{values:["inside","none"],dflt:"inside"}),textfont:n.textfont,insidetextfont:n.insidetextfont,title:{text:n.title.text,font:n.title.font,position:l({},n.title.position,{values:["top left","top center","top right"],dflt:"top center"}),editType:"plot"},domain:a({name:"funnelarea",trace:!0,editType:"calc"}),aspectratio:{valType:"number",min:0,dflt:1,editType:"plot"},baseratio:{valType:"number",min:0,max:1,dflt:.333,editType:"plot"}}},{"../../lib/extend":708,"../../plots/attributes":762,"../../plots/domain":790,"../../plots/template_attributes":841,"../pie/attributes":1094}],992:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.name="funnelarea",r.plot=function(t,e,i,a){n.plotBasePlot(r.name,t,e,i,a)},r.clean=function(t,e,i,a){n.cleanBasePlot(r.name,t,e,i,a)}},{"../../plots/plots":826}],993:[function(t,e,r){"use strict";var n=t("../pie/calc");e.exports={calc:function(t,e){return n.calc(t,e)},crossTraceCalc:function(t){n.crossTraceCalc(t,{type:"funnelarea"})}}},{"../pie/calc":1096}],994:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../plots/domain").defaults,o=t("../bar/defaults").handleText,s=t("../pie/defaults").handleLabelsAndValues;e.exports=function(t,e,r,l){function c(r,a){return n.coerce(t,e,i,r,a)}var u=c("labels"),h=c("values"),f=s(u,h),p=f.len;if(e._hasLabels=f.hasLabels,e._hasValues=f.hasValues,!e._hasLabels&&e._hasValues&&(c("label0"),c("dlabel")),p){e._length=p,c("marker.line.width")&&c("marker.line.color",l.paper_bgcolor),c("marker.colors"),c("scalegroup");var d,g=c("text"),m=c("texttemplate");if(m||(d=c("textinfo",Array.isArray(g)?"text+percent":"percent")),c("hovertext"),c("hovertemplate"),m||d&&"none"!==d){var v=c("textposition");o(t,e,l,c,v,{moduleHasSelected:!1,moduleHasUnselected:!1,moduleHasConstrain:!1,moduleHasCliponaxis:!1,moduleHasTextangle:!1,moduleHasInsideanchor:!1})}a(e,l,c),c("title.text")&&(c("title.position"),n.coerceFont(c,"title.font",l.font)),c("aspectratio"),c("baseratio")}else e.visible=!1}},{"../../lib":717,"../../plots/domain":790,"../bar/defaults":860,"../pie/defaults":1097,"./attributes":991}],995:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"funnelarea",basePlotModule:t("./base_plot"),categories:["pie-like","funnelarea","showLegend"],attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot"),style:t("./style"),styleOne:t("../pie/style_one"),meta:{}}},{"../pie/style_one":1105,"./attributes":991,"./base_plot":992,"./calc":993,"./defaults":994,"./layout_attributes":996,"./layout_defaults":997,"./plot":998,"./style":999}],996:[function(t,e,r){"use strict";var n=t("../pie/layout_attributes").hiddenlabels;e.exports={hiddenlabels:n,funnelareacolorway:{valType:"colorlist",editType:"calc"},extendfunnelareacolors:{valType:"boolean",dflt:!0,editType:"calc"}}},{"../pie/layout_attributes":1101}],997:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels"),r("funnelareacolorway",e.colorway),r("extendfunnelareacolors")}},{"../../lib":717,"./layout_attributes":996}],998:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/drawing"),a=t("../../lib"),o=t("../../lib/svg_text_utils"),s=t("../bar/plot").toMoveInsideBar,l=t("../bar/uniform_text"),c=l.recordMinTextSize,u=l.clearMinTextSize,h=t("../pie/helpers"),f=t("../pie/plot"),p=f.attachFxHandlers,d=f.determineInsideTextFont,g=f.layoutAreas,m=f.prerenderTitles,v=f.positionTitleOutside,y=f.formatSliceLabel;function x(t,e){return"l"+(e[0]-t[0])+","+(e[1]-t[1])}e.exports=function(t,e){var r=t._fullLayout;u("funnelarea",r),m(e,t),g(e,r._size),a.makeTraceGroups(r._funnelarealayer,e,"trace").each((function(e){var l=n.select(this),u=e[0],f=u.trace;!function(t){if(t.length){var e=t[0],r=e.trace,n=r.aspectratio,i=r.baseratio;i>.999&&(i=.999);var a,o,s,l=Math.pow(i,2),c=e.vTotal,u=c,h=c*l/(1-l)/c,f=[];for(f.push(T()),o=t.length-1;o>-1;o--)if(!(s=t[o]).hidden){var p=s.v/u;h+=p,f.push(T())}var d=1/0,g=-1/0;for(o=0;o-1;o--)if(!(s=t[o]).hidden){var k=f[M+=1][0],I=f[M][1];s.TL=[-k,I],s.TR=[k,I],s.BL=A,s.BR=C,s.pxmid=(_=s.TR,w=s.BR,[.5*(_[0]+w[0]),.5*(_[1]+w[1])]),A=s.TL,C=s.TR}}function T(){var t,e={x:t=Math.sqrt(h),y:-t};return[e.x,e.y]}}(e),l.each((function(){var l=n.select(this).selectAll("g.slice").data(e);l.enter().append("g").classed("slice",!0),l.exit().remove(),l.each((function(l,g){if(l.hidden)n.select(this).selectAll("path,g").remove();else{l.pointNumber=l.i,l.curveNumber=f.index;var m=u.cx,v=u.cy,b=n.select(this),_=b.selectAll("path.surface").data([l]);_.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),b.call(p,t,e);var w="M"+(m+l.TR[0])+","+(v+l.TR[1])+x(l.TR,l.BR)+x(l.BR,l.BL)+x(l.BL,l.TL)+"Z";_.attr("d",w),y(t,l,u);var A=h.castOption(f.textposition,l.pts),C=b.selectAll("g.slicetext").data(l.text&&"none"!==A?[0]:[]);C.enter().append("g").classed("slicetext",!0),C.exit().remove(),C.each((function(){var u=a.ensureSingle(n.select(this),"text","",(function(t){t.attr("data-notex",1)})),h=a.ensureUniformFontSize(t,d(f,l,r.font));u.text(l.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(i.font,h).call(o.convertToTspans,t);var p,y,x,b=i.bBox(u.node()),_=Math.min(l.BL[1],l.BR[1])+v,w=Math.max(l.TL[1],l.TR[1])+v;y=Math.max(l.TL[0],l.BL[0])+m,x=Math.min(l.TR[0],l.BR[0])+m,(p=s(y,x,_,w,b,{isHorizontal:!0,constrained:!0,angle:0,anchor:"middle"})).fontSize=h.size,c(f.type,p,r),e[g].transform=p,u.attr("transform",a.getTextTransform(p))}))}}));var g=n.select(this).selectAll("g.titletext").data(f.title.text?[0]:[]);g.enter().append("g").classed("titletext",!0),g.exit().remove(),g.each((function(){var e=a.ensureSingle(n.select(this),"text","",(function(t){t.attr("data-notex",1)})),s=f.title.text;f._meta&&(s=a.templateString(s,f._meta)),e.text(s).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(i.font,f.title.font).call(o.convertToTspans,t);var l=v(u,r._size);e.attr("transform","translate("+l.x+","+l.y+")"+(l.scale<1?"scale("+l.scale+")":"")+"translate("+l.tx+","+l.ty+")")}))}))}))}},{"../../components/drawing":613,"../../lib":717,"../../lib/svg_text_utils":741,"../bar/plot":867,"../bar/uniform_text":872,"../pie/helpers":1099,"../pie/plot":1103,d3:165}],999:[function(t,e,r){"use strict";var n=t("d3"),i=t("../pie/style_one"),a=t("../bar/uniform_text").resizeText;e.exports=function(t){var e=t._fullLayout._funnelarealayer.selectAll(".trace");a(t,e,"funnelarea"),e.each((function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each((function(t){n.select(this).call(i,t,e)}))}))}},{"../bar/uniform_text":872,"../pie/style_one":1105,d3:165}],1e3:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../plots/template_attributes").hovertemplateAttrs,o=t("../../components/colorscale/attributes"),s=(t("../../constants/docs").FORMAT_LINK,t("../../lib/extend").extendFlat);e.exports=s({z:{valType:"data_array",editType:"calc"},x:s({},n.x,{impliedEdits:{xtype:"array"}}),x0:s({},n.x0,{impliedEdits:{xtype:"scaled"}}),dx:s({},n.dx,{impliedEdits:{xtype:"scaled"}}),y:s({},n.y,{impliedEdits:{ytype:"array"}}),y0:s({},n.y0,{impliedEdits:{ytype:"scaled"}}),dy:s({},n.dy,{impliedEdits:{ytype:"scaled"}}),text:{valType:"data_array",editType:"calc"},hovertext:{valType:"data_array",editType:"calc"},transpose:{valType:"boolean",dflt:!1,editType:"calc"},xtype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},ytype:{valType:"enumerated",values:["array","scaled"],editType:"calc+clearAxisTypes"},zsmooth:{valType:"enumerated",values:["fast","best",!1],dflt:!1,editType:"calc"},hoverongaps:{valType:"boolean",dflt:!0,editType:"none"},connectgaps:{valType:"boolean",editType:"calc"},xgap:{valType:"number",dflt:0,min:0,editType:"plot"},ygap:{valType:"number",dflt:0,min:0,editType:"plot"},zhoverformat:{valType:"string",dflt:"",editType:"none"},hovertemplate:a(),showlegend:s({},i.showlegend,{dflt:!1})},{transforms:void 0},o("",{cLetter:"z",autoColorDflt:!1}))},{"../../components/colorscale/attributes":599,"../../constants/docs":688,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../scatter/attributes":1120}],1001:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../../plots/cartesian/axes"),o=t("../histogram2d/calc"),s=t("../../components/colorscale/calc"),l=t("./convert_column_xyz"),c=t("./clean_2d_array"),u=t("./interp2d"),h=t("./find_empties"),f=t("./make_bound_array");e.exports=function(t,e){var r,p,d,g,m,v,y,x,b,_=a.getFromId(t,e.xaxis||"x"),w=a.getFromId(t,e.yaxis||"y"),A=n.traceIs(e,"contour"),C=n.traceIs(e,"histogram"),M=n.traceIs(e,"gl2d"),k=A?"best":e.zsmooth;if(_._minDtick=0,w._minDtick=0,C)r=(b=o(t,e)).x,p=b.x0,d=b.dx,g=b.y,m=b.y0,v=b.dy,y=b.z;else{var I=e.z;i.isArray1D(I)?(l(e,_,w,"x","y",["z"]),r=e._x,g=e._y,I=e._z):(r=e._x=e.x?_.makeCalcdata(e,"x"):[],g=e._y=e.y?w.makeCalcdata(e,"y"):[]),p=e.x0,d=e.dx,m=e.y0,v=e.dy,y=c(I,e,_,w),(A||e.connectgaps)&&(e._emptypoints=h(y),u(y,e._emptypoints))}function T(t){k=e._input.zsmooth=e.zsmooth=!1,i.warn('cannot use zsmooth: "fast": '+t)}if("fast"===k)if("log"===_.type||"log"===w.type)T("log axis found");else if(!C){if(r.length){var L=(r[r.length-1]-r[0])/(r.length-1),S=Math.abs(L/100);for(x=0;xS){T("x scale is not linear");break}}if(g.length&&"fast"===k){var E=(g[g.length-1]-g[0])/(g.length-1),D=Math.abs(E/100);for(x=0;xD){T("y scale is not linear");break}}}var P=i.maxRowLength(y),O="scaled"===e.xtype?"":r,z=f(e,O,p,d,P,_),R="scaled"===e.ytype?"":g,F=f(e,R,m,v,y.length,w);M||(e._extremes[_._id]=a.findExtremes(_,z),e._extremes[w._id]=a.findExtremes(w,F));var N={x:z,y:F,z:y,text:e._text||e.text,hovertext:e._hovertext||e.hovertext};if(O&&O.length===z.length-1&&(N.xCenter=O),R&&R.length===F.length-1&&(N.yCenter=R),C&&(N.xRanges=b.xRanges,N.yRanges=b.yRanges,N.pts=b.pts),A||s(t,e,{vals:y,cLetter:"z"}),A&&e.contours&&"heatmap"===e.contours.coloring){var j={type:"contour"===e.type?"heatmap":"histogram2d",xcalendar:e.xcalendar,ycalendar:e.ycalendar};N.xfill=f(j,O,p,d,P,_),N.yfill=f(j,R,m,v,y.length,w)}return[N]}},{"../../components/colorscale/calc":600,"../../lib":717,"../../plots/cartesian/axes":765,"../../registry":846,"../histogram2d/calc":1032,"./clean_2d_array":1002,"./convert_column_xyz":1004,"./find_empties":1006,"./interp2d":1009,"./make_bound_array":1010}],1002:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../constants/numerical").BADNUM;e.exports=function(t,e,r,o){var s,l,c,u,h,f;function p(t){if(n(t))return+t}if(e&&e.transpose){for(s=0,h=0;h=0;o--)(s=((h[[(r=(a=f[o])[0])-1,i=a[1]]]||g)[2]+(h[[r+1,i]]||g)[2]+(h[[r,i-1]]||g)[2]+(h[[r,i+1]]||g)[2])/20)&&(l[a]=[r,i,s],f.splice(o,1),c=!0);if(!c)throw"findEmpties iterated with no new neighbors";for(a in l)h[a]=l[a],u.push(l[a])}return u.sort((function(t,e){return e[2]-t[2]}))}},{"../../lib":717}],1007:[function(t,e,r){"use strict";var n=t("../../components/fx"),i=t("../../lib"),a=t("../../plots/cartesian/axes"),o=t("../../components/colorscale").extractOpts;e.exports=function(t,e,r,s,l,c){var u,h,f,p,d=t.cd[0],g=d.trace,m=t.xa,v=t.ya,y=d.x,x=d.y,b=d.z,_=d.xCenter,w=d.yCenter,A=d.zmask,C=g.zhoverformat,M=y,k=x;if(!1!==t.index){try{f=Math.round(t.index[1]),p=Math.round(t.index[0])}catch(e){return void i.error("Error hovering on heatmap, pointNumber must be [row,col], found:",t.index)}if(f<0||f>=b[0].length||p<0||p>b.length)return}else{if(n.inbox(e-y[0],e-y[y.length-1],0)>0||n.inbox(r-x[0],r-x[x.length-1],0)>0)return;if(c){var I;for(M=[2*y[0]-y[1]],I=1;Ig&&(v=Math.max(v,Math.abs(t[a][o]-d)/(m-g))))}return v}e.exports=function(t,e){var r,i=1;for(o(t,e),r=0;r.01;r++)i=o(t,e,a(i));return i>.01&&n.log("interp2d didn't converge quickly",i),t}},{"../../lib":717}],1010:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib").isArrayOrTypedArray;e.exports=function(t,e,r,a,o,s){var l,c,u,h=[],f=n.traceIs(t,"contour"),p=n.traceIs(t,"histogram"),d=n.traceIs(t,"gl2d");if(i(e)&&e.length>1&&!p&&"category"!==s.type){var g=e.length;if(!(g<=o))return f?e.slice(0,o):e.slice(0,o+1);if(f||d)h=e.slice(0,o);else if(1===o)h=[e[0]-.5,e[0]+.5];else{for(h=[1.5*e[0]-.5*e[1]],u=1;u0;)f=p.c2p(A[y]),y--;for(f0;)v=d.c2p(C[y]),y--;if(v0&&(a=!0);for(var l=0;la){var o=a-r[t];return r[t]=a,o}}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]c?t>o?t>1.1*i?i:t>1.1*a?a:o:t>s?s:t>l?l:c:Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function p(t,e,r,n,a,s){if(n&&t>o){var l=d(e,a,s),c=d(r,a,s),u=t===i?0:1;return l[u]!==c[u]}return Math.floor(r/t)-Math.floor(e/t)>.1}function d(t,e,r){var n=e.c2d(t,i,r).split("-");return""===n[0]&&(n.unshift(),n[0]="-"+n[0]),n}e.exports=function(t,e,r,n,a){var s,l,c=-1.1*e,f=-.1*e,p=t-f,d=r[0],g=r[1],m=Math.min(h(d+f,d+p,n,a),h(g+f,g+p,n,a)),v=Math.min(h(d+c,d+f,n,a),h(g+c,g+f,n,a));if(m>v&&vo){var y=s===i?1:6,x=s===i?"M12":"M1";return function(e,r){var o=n.c2d(e,i,a),s=o.indexOf("-",y);s>0&&(o=o.substr(0,s));var c=n.d2c(o,0,a);if(cr.r2l(N)&&(B=o.tickIncrement(B,b.size,!0,p)),O.start=r.l2r(B),F||i.nestedProperty(e,v+".start").set(O.start)}var Y=b.end,V=r.r2l(P.end),U=void 0!==V;if((b.endFound||U)&&V!==r.r2l(Y)){var H=U?V:i.aggNums(Math.max,null,d);O.end=r.l2r(H),U||i.nestedProperty(e,v+".start").set(O.end)}var G="autobin"+s;return!1===e._input[G]&&(e._input[v]=i.extendFlat({},e[v]||{}),delete e._input[G],delete e[G]),[O,d]}e.exports={calc:function(t,e){var r,a,p,d,g=[],m=[],v=o.getFromId(t,"h"===e.orientation?e.yaxis:e.xaxis),y="h"===e.orientation?"y":"x",x={x:"y",y:"x"}[y],b=e[y+"calendar"],_=e.cumulative,w=f(t,e,v,y),A=w[0],C=w[1],M="string"==typeof A.size,k=[],I=M?k:A,T=[],L=[],S=[],E=0,D=e.histnorm,P=e.histfunc,O=-1!==D.indexOf("density");_.enabled&&O&&(D=D.replace(/ ?density$/,""),O=!1);var z,R="max"===P||"min"===P?null:0,F=l.count,N=c[D],j=!1,B=function(t){return v.r2c(t,0,b)};for(i.isArrayOrTypedArray(e[x])&&"count"!==P&&(z=e[x],j="avg"===P,F=l[P]),r=B(A.start),p=B(A.end)+(r-o.tickIncrement(r,A.size,!1,b))/1e6;r=0&&d=0;n--)s(n);else if("increasing"===e){for(n=1;n=0;n--)t[n]+=t[n+1];"exclude"===r&&(t.push(0),t.shift())}}(m,_.direction,_.currentbin);var Z=Math.min(g.length,m.length),X=[],J=0,K=Z-1;for(r=0;r=J;r--)if(m[r]){K=r;break}for(r=J;r<=K;r++)if(n(g[r])&&n(m[r])){var Q={p:g[r],s:m[r],b:0};_.enabled||(Q.pts=S[r],U?Q.ph0=Q.ph1=S[r].length?C[S[r][0]]:g[r]:(Q.ph0=Y(k[r]),Q.ph1=Y(k[r+1],!0))),X.push(Q)}return 1===X.length&&(X[0].width1=o.tickIncrement(X[0].p,A.size,!1,b)-X[0].p),s(X,e),i.isArrayOrTypedArray(e.selectedpoints)&&i.tagSelected(X,e,q),X},calcAllAutoBins:f}},{"../../lib":717,"../../plots/cartesian/axes":765,"../../registry":846,"../bar/arrays_to_calcdata":855,"./average":1019,"./bin_functions":1021,"./bin_label_vals":1022,"./norm_functions":1030,"fast-isnumeric":228}],1024:[function(t,e,r){"use strict";e.exports={eventDataKeys:["binNumber"]}},{}],1025:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axis_ids"),a=t("../../registry").traceIs,o=t("../bar/defaults").handleGroupingDefaults,s=n.nestedProperty,l=i.getAxisGroup,c=[{aStr:{x:"xbins.start",y:"ybins.start"},name:"start"},{aStr:{x:"xbins.end",y:"ybins.end"},name:"end"},{aStr:{x:"xbins.size",y:"ybins.size"},name:"size"},{aStr:{x:"nbinsx",y:"nbinsy"},name:"nbins"}],u=["x","y"];e.exports=function(t,e){var r,h,f,p,d,g,m,v=e._histogramBinOpts={},y=[],x={},b=[];function _(t,e){return n.coerce(r._input,r,r._module.attributes,t,e)}function w(t){return"v"===t.orientation?"x":"y"}function A(t,r,a){var o=t.uid+"__"+a;r||(r=o);var s=function(t,r){return i.getFromTrace({_fullLayout:e},t,r).type}(t,a),l=t[a+"calendar"]||"",c=v[r],u=!0;c&&(s===c.axType&&l===c.calendar?(u=!1,c.traces.push(t),c.dirs.push(a)):(r=o,s!==c.axType&&n.warn(["Attempted to group the bins of trace",t.index,"set on a","type:"+s,"axis","with bins on","type:"+c.axType,"axis."].join(" ")),l!==c.calendar&&n.warn(["Attempted to group the bins of trace",t.index,"set with a",l,"calendar","with bins",c.calendar?"on a "+c.calendar+" calendar":"w/o a set calendar"].join(" ")))),u&&(v[r]={traces:[t],dirs:[a],axType:s,calendar:t[a+"calendar"]||""}),t["_"+a+"bingroup"]=r}for(d=0;dI&&A.splice(I,A.length-I),k.length>I&&k.splice(I,k.length-I);var T=[],L=[],S=[],E="string"==typeof w.size,D="string"==typeof M.size,P=[],O=[],z=E?P:w,R=D?O:M,F=0,N=[],j=[],B=e.histnorm,Y=e.histfunc,V=-1!==B.indexOf("density"),U="max"===Y||"min"===Y?null:0,H=a.count,G=o[B],q=!1,W=[],Z=[],X="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";X&&"count"!==Y&&(q="avg"===Y,H=a[Y]);var J=w.size,K=x(w.start),Q=x(w.end)+(K-i.tickIncrement(K,J,!1,v))/1e6;for(r=K;r=0&&p=0&&d0||n.inbox(r-o.y0,r-(o.y0+o.h*s.dy),0)>0)){var u=Math.floor((e-o.x0)/s.dx),h=Math.floor(Math.abs(r-o.y0)/s.dy);if(o.z[h][u]){var f,p=o.hi||s.hoverinfo;if(p){var d=p.split("+");-1!==d.indexOf("all")&&(d=["color"]),-1!==d.indexOf("color")&&(f=!0)}var g,m=s.colormodel,v=m.length,y=s._scaler(o.z[h][u]),x=a.colormodel[m].suffix,b=[];(s.hovertemplate||f)&&(b.push("["+[y[0]+x[0],y[1]+x[1],y[2]+x[2]].join(", ")),4===v&&b.push(", "+y[3]+x[3]),b.push("]"),b=b.join(""),t.extraText=m.toUpperCase()+": "+b),Array.isArray(s.hovertext)&&Array.isArray(s.hovertext[h])?g=s.hovertext[h][u]:Array.isArray(s.text)&&Array.isArray(s.text[h])&&(g=s.text[h][u]);var _=c.c2p(o.y0+(h+.5)*s.dy),w=o.x0+(u+.5)*s.dx,A=o.y0+(h+.5)*s.dy,C="["+o.z[h][u].slice(0,s.colormodel.length).join(", ")+"]";return[i.extendFlat(t,{index:[h,u],x0:l.c2p(o.x0+u*s.dx),x1:l.c2p(o.x0+(u+1)*s.dx),y0:_,y1:_,color:y,xVal:w,xLabelVal:w,yVal:A,yLabelVal:A,zLabelVal:C,text:g,hovertemplateLabels:{zLabel:C,colorLabel:b,"color[0]Label":y[0]+x[0],"color[1]Label":y[1]+x[1],"color[2]Label":y[2]+x[2],"color[3]Label":y[3]+x[3]}})]}}}},{"../../components/fx":630,"../../lib":717,"./constants":1042}],1046:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover"),eventData:t("./event_data"),moduleType:"trace",name:"image",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","2dMap","noSortingByValue"],animatable:!1,meta:{}}},{"../../plots/cartesian":776,"./attributes":1040,"./calc":1041,"./defaults":1043,"./event_data":1044,"./hover":1045,"./plot":1047,"./style":1048}],1047:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../constants/xmlns_namespaces"),o=t("./constants");e.exports=function(t,e,r,s){var l=e.xaxis,c=e.yaxis;i.makeTraceGroups(s,r,"im").each((function(t){var e,r,s,u,h,f,p=n.select(this),d=t[0],g=d.trace,m=d.z,v=d.x0,y=d.y0,x=d.w,b=d.h,_=g.dx,w=g.dy;for(f=0;void 0===e&&f0;)r=l.c2p(v+f*_),f--;for(f=0;void 0===u&&f0;)h=c.c2p(y+f*w),f--;r0}function x(t){t.each((function(t){d.stroke(n.select(this),t.line.color)})).each((function(t){d.fill(n.select(this),t.color)})).style("stroke-width",(function(t){return t.line.width}))}function b(t,e,r){var n=t._fullLayout,a=i.extendFlat({type:"linear",ticks:"outside",range:r,showline:!0},e),o={type:"linear",_id:"x"+e._id},s={letter:"x",font:n.font,noHover:!0,noTickson:!0};function l(t,e){return i.coerce(a,o,p,t,e)}return h(a,o,l,s,n),f(a,o,l,s),o}function _(t,e){return"translate("+t+","+e+")"}function w(t,e,r){return[Math.min(e/t.width,r/t.height),t,e+"x"+r]}function A(t,e,r,i){var a=document.createElementNS("http://www.w3.org/2000/svg","text"),o=n.select(a);return o.text(t).attr("x",0).attr("y",0).attr("text-anchor",r).attr("data-unformatted",t).call(c.convertToTspans,i).call(s.font,e),s.bBox(o.node())}function C(t,e,r,n,a,o){var s="_cache"+e;t[s]&&t[s].key===a||(t[s]={key:a,value:r});var l=i.aggNums(o,null,[t[s].value,n],2);return t[s].value=l,l}e.exports=function(t,e,r,h){var f,p=t._fullLayout;y(r)&&h&&(f=h()),i.makeTraceGroups(p._indicatorlayer,e,"trace").each((function(e){var h,M,k,I,T,L=e[0].trace,S=n.select(this),E=L._hasGauge,D=L._isAngular,P=L._isBullet,O=L.domain,z={w:p._size.w*(O.x[1]-O.x[0]),h:p._size.h*(O.y[1]-O.y[0]),l:p._size.l+p._size.w*O.x[0],r:p._size.r+p._size.w*(1-O.x[1]),t:p._size.t+p._size.h*(1-O.y[1]),b:p._size.b+p._size.h*O.y[0]},R=z.l+z.w/2,F=z.t+z.h/2,N=Math.min(z.w/2,z.h),j=l.innerRadius*N,B=L.align||"center";if(M=F,E){if(D&&(h=R,M=F+N/2,k=function(t){return function(t,e){var r=Math.sqrt(t.width/2*(t.width/2)+t.height*t.height);return[e/r,t,e]}(t,.9*j)}),P){var Y=l.bulletPadding,V=1-l.bulletNumberDomainSize+Y;h=z.l+(V+(1-V)*m[B])*z.w,k=function(t){return w(t,(l.bulletNumberDomainSize-Y)*z.w,z.h)}}}else h=z.l+m[B]*z.w,k=function(t){return w(t,z.w,z.h)};!function(t,e,r,a){var o,l,h,f=r[0].trace,p=a.numbersX,x=a.numbersY,w=f.align||"center",M=g[w],k=a.transitionOpts,I=a.onComplete,T=i.ensureSingle(e,"g","numbers"),L=[];f._hasNumber&&L.push("number"),f._hasDelta&&(L.push("delta"),"left"===f.delta.position&&L.reverse());var S=T.selectAll("text").data(L);function E(e,r,n,i){if(!e.match("s")||n>=0==i>=0||r(n).slice(-1).match(v)||r(i).slice(-1).match(v))return r;var a=e.slice().replace("s","f").replace(/\d+/,(function(t){return parseInt(t)-1})),o=b(t,{tickformat:a});return function(t){return Math.abs(t)<1?u.tickText(o,t).text:r(t)}}S.enter().append("text"),S.attr("text-anchor",(function(){return M})).attr("class",(function(t){return t})).attr("x",null).attr("y",null).attr("dx",null).attr("dy",null),S.exit().remove();var D,P=f.mode+f.align;if(f._hasDelta&&(D=function(){var e=b(t,{tickformat:f.delta.valueformat},f._range);e.setScale(),u.prepTicks(e);var i=function(t){return u.tickText(e,t).text},a=function(t){return f.delta.relative?t.relativeDelta:t.delta},o=function(t,e){return 0===t||"number"!=typeof t||isNaN(t)?"-":(t>0?f.delta.increasing.symbol:f.delta.decreasing.symbol)+e(t)},h=function(t){return t.delta>=0?f.delta.increasing.color:f.delta.decreasing.color};void 0===f._deltaLastValue&&(f._deltaLastValue=a(r[0]));var p=T.select("text.delta");function g(){p.text(o(a(r[0]),i)).call(d.fill,h(r[0])).call(c.convertToTspans,t)}return p.call(s.font,f.delta.font).call(d.fill,h({delta:f._deltaLastValue})),y(k)?p.transition().duration(k.duration).ease(k.easing).tween("text",(function(){var t=n.select(this),e=a(r[0]),s=f._deltaLastValue,l=E(f.delta.valueformat,i,s,e),c=n.interpolateNumber(s,e);return f._deltaLastValue=e,function(e){t.text(o(c(e),l)),t.call(d.fill,h({delta:c(e)}))}})).each("end",(function(){g(),I&&I()})).each("interrupt",(function(){g(),I&&I()})):g(),l=A(o(a(r[0]),i),f.delta.font,M,t),p}(),P+=f.delta.position+f.delta.font.size+f.delta.font.family+f.delta.valueformat,P+=f.delta.increasing.symbol+f.delta.decreasing.symbol,h=l),f._hasNumber&&(function(){var e=b(t,{tickformat:f.number.valueformat},f._range);e.setScale(),u.prepTicks(e);var i=function(t){return u.tickText(e,t).text},a=f.number.suffix,l=f.number.prefix,h=T.select("text.number");function p(){var e="number"==typeof r[0].y?l+i(r[0].y)+a:"-";h.text(e).call(s.font,f.number.font).call(c.convertToTspans,t)}y(k)?h.transition().duration(k.duration).ease(k.easing).each("end",(function(){p(),I&&I()})).each("interrupt",(function(){p(),I&&I()})).attrTween("text",(function(){var t=n.select(this),e=n.interpolateNumber(r[0].lastY,r[0].y);f._lastValue=r[0].y;var o=E(f.number.valueformat,i,r[0].lastY,r[0].y);return function(r){t.text(l+o(e(r))+a)}})):p(),o=A(l+i(r[0].y)+a,f.number.font,M,t)}(),P+=f.number.font.size+f.number.font.family+f.number.valueformat+f.number.suffix+f.number.prefix,h=o),f._hasDelta&&f._hasNumber){var O,z,R=[(o.left+o.right)/2,(o.top+o.bottom)/2],F=[(l.left+l.right)/2,(l.top+l.bottom)/2],N=.75*f.delta.font.size;"left"===f.delta.position&&(O=C(f,"deltaPos",0,-1*(o.width*m[f.align]+l.width*(1-m[f.align])+N),P,Math.min),z=R[1]-F[1],h={width:o.width+l.width+N,height:Math.max(o.height,l.height),left:l.left+O,right:o.right,top:Math.min(o.top,l.top+z),bottom:Math.max(o.bottom,l.bottom+z)}),"right"===f.delta.position&&(O=C(f,"deltaPos",0,o.width*(1-m[f.align])+l.width*m[f.align]+N,P,Math.max),z=R[1]-F[1],h={width:o.width+l.width+N,height:Math.max(o.height,l.height),left:o.left,right:l.right+O,top:Math.min(o.top,l.top+z),bottom:Math.max(o.bottom,l.bottom+z)}),"bottom"===f.delta.position&&(O=null,z=l.height,h={width:Math.max(o.width,l.width),height:o.height+l.height,left:Math.min(o.left,l.left),right:Math.max(o.right,l.right),top:o.bottom-o.height,bottom:o.bottom+l.height}),"top"===f.delta.position&&(O=null,z=o.top,h={width:Math.max(o.width,l.width),height:o.height+l.height,left:Math.min(o.left,l.left),right:Math.max(o.right,l.right),top:o.bottom-o.height-l.height,bottom:o.bottom}),D.attr({dx:O,dy:z})}(f._hasNumber||f._hasDelta)&&T.attr("transform",(function(){var t=a.numbersScaler(h);P+=t[2];var e,r=C(f,"numbersScale",1,t[0],P,Math.min);f._scaleNumbers||(r=1),e=f._isAngular?x-r*h.bottom:x-r*(h.top+h.bottom)/2,f._numbersTop=r*h.top+e;var n=h[w];"center"===w&&(n=(h.left+h.right)/2);var i=p-r*n;return _(i=C(f,"numbersTranslate",0,i,P,Math.max),e)+" scale("+r+")"}))}(t,S,e,{numbersX:h,numbersY:M,numbersScaler:k,transitionOpts:r,onComplete:f}),E&&(I={range:L.gauge.axis.range,color:L.gauge.bgcolor,line:{color:L.gauge.bordercolor,width:0},thickness:1},T={range:L.gauge.axis.range,color:"rgba(0, 0, 0, 0)",line:{color:L.gauge.bordercolor,width:L.gauge.borderwidth},thickness:1});var U=S.selectAll("g.angular").data(D?e:[]);U.exit().remove();var H=S.selectAll("g.angularaxis").data(D?e:[]);H.exit().remove(),D&&function(t,e,r,i){var s,l,c,h,f=r[0].trace,p=i.size,d=i.radius,g=i.innerRadius,m=i.gaugeBg,v=i.gaugeOutline,w=[p.l+p.w/2,p.t+p.h/2+d/2],A=i.gauge,C=i.layer,M=i.transitionOpts,k=i.onComplete,I=Math.PI/2;function T(t){var e=f.gauge.axis.range[0],r=(t-e)/(f.gauge.axis.range[1]-e)*Math.PI-I;return r<-I?-I:r>I?I:r}function L(t){return n.svg.arc().innerRadius((g+d)/2-t/2*(d-g)).outerRadius((g+d)/2+t/2*(d-g)).startAngle(-I)}function S(t){t.attr("d",(function(t){return L(t.thickness).startAngle(T(t.range[0])).endAngle(T(t.range[1]))()}))}A.enter().append("g").classed("angular",!0),A.attr("transform",_(w[0],w[1])),C.enter().append("g").classed("angularaxis",!0).classed("crisp",!0),C.selectAll("g.xangularaxistick,path,text").remove(),(s=b(t,f.gauge.axis)).type="linear",s.range=f.gauge.axis.range,s._id="xangularaxis",s.setScale();var E=function(t){return(s.range[0]-t.x)/(s.range[1]-s.range[0])*Math.PI+Math.PI},D={},P=u.makeLabelFns(s,0).labelStandoff;D.xFn=function(t){var e=E(t);return Math.cos(e)*P},D.yFn=function(t){var e=E(t),r=Math.sin(e)>0?.2:1;return-Math.sin(e)*(P+t.fontSize*r)+Math.abs(Math.cos(e))*(t.fontSize*o)},D.anchorFn=function(t){var e=E(t),r=Math.cos(e);return Math.abs(r)<.1?"middle":r>0?"start":"end"},D.heightFn=function(t,e,r){var n=E(t);return-.5*(1+Math.sin(n))*r};var O=function(t){return _(w[0]+d*Math.cos(t),w[1]-d*Math.sin(t))};if(c=function(t){return O(E(t))},l=u.calcTicks(s),h=u.getTickSigns(s)[2],s.visible){h="inside"===s.ticks?-1:1;var z=(s.linewidth||1)/2;u.drawTicks(t,s,{vals:l,layer:C,path:"M"+h*z+",0h"+h*s.ticklen,transFn:function(t){var e=E(t);return O(e)+"rotate("+-a(e)+")"}}),u.drawLabels(t,s,{vals:l,layer:C,transFn:c,labelFns:D})}var R=[m].concat(f.gauge.steps),F=A.selectAll("g.bg-arc").data(R);F.enter().append("g").classed("bg-arc",!0).append("path"),F.select("path").call(S).call(x),F.exit().remove();var N=L(f.gauge.bar.thickness),j=A.selectAll("g.value-arc").data([f.gauge.bar]);j.enter().append("g").classed("value-arc",!0).append("path");var B,Y,V,U=j.select("path");y(M)?(U.transition().duration(M.duration).ease(M.easing).each("end",(function(){k&&k()})).each("interrupt",(function(){k&&k()})).attrTween("d",(B=N,Y=T(r[0].lastY),V=T(r[0].y),function(){var t=n.interpolate(Y,V);return function(e){return B.endAngle(t(e))()}})),f._lastValue=r[0].y):U.attr("d","number"==typeof r[0].y?N.endAngle(T(r[0].y)):"M0,0Z"),U.call(x),j.exit().remove(),R=[];var H=f.gauge.threshold.value;H&&R.push({range:[H,H],color:f.gauge.threshold.color,line:{color:f.gauge.threshold.line.color,width:f.gauge.threshold.line.width},thickness:f.gauge.threshold.thickness});var G=A.selectAll("g.threshold-arc").data(R);G.enter().append("g").classed("threshold-arc",!0).append("path"),G.select("path").call(S).call(x),G.exit().remove();var q=A.selectAll("g.gauge-outline").data([v]);q.enter().append("g").classed("gauge-outline",!0).append("path"),q.select("path").call(S).call(x),q.exit().remove()}(t,0,e,{radius:N,innerRadius:j,gauge:U,layer:H,size:z,gaugeBg:I,gaugeOutline:T,transitionOpts:r,onComplete:f});var G=S.selectAll("g.bullet").data(P?e:[]);G.exit().remove();var q=S.selectAll("g.bulletaxis").data(P?e:[]);q.exit().remove(),P&&function(t,e,r,n){var i,a,o,s,c,h=r[0].trace,f=n.gauge,p=n.layer,g=n.gaugeBg,m=n.gaugeOutline,v=n.size,_=h.domain,w=n.transitionOpts,A=n.onComplete;f.enter().append("g").classed("bullet",!0),f.attr("transform","translate("+v.l+", "+v.t+")"),p.enter().append("g").classed("bulletaxis",!0).classed("crisp",!0),p.selectAll("g.xbulletaxistick,path,text").remove();var C=v.h,M=h.gauge.bar.thickness*C,k=_.x[0],I=_.x[0]+(_.x[1]-_.x[0])*(h._hasNumber||h._hasDelta?1-l.bulletNumberDomainSize:1);function T(t){t.attr("width",(function(t){return Math.max(0,i.c2p(t.range[1])-i.c2p(t.range[0]))})).attr("x",(function(t){return i.c2p(t.range[0])})).attr("y",(function(t){return.5*(1-t.thickness)*C})).attr("height",(function(t){return t.thickness*C}))}(i=b(t,h.gauge.axis))._id="xbulletaxis",i.domain=[k,I],i.setScale(),a=u.calcTicks(i),o=u.makeTransFn(i),s=u.getTickSigns(i)[2],c=v.t+v.h,i.visible&&(u.drawTicks(t,i,{vals:"inside"===i.ticks?u.clipEnds(i,a):a,layer:p,path:u.makeTickPath(i,c,s),transFn:o}),u.drawLabels(t,i,{vals:a,layer:p,transFn:o,labelFns:u.makeLabelFns(i,c)}));var L=[g].concat(h.gauge.steps),S=f.selectAll("g.bg-bullet").data(L);S.enter().append("g").classed("bg-bullet",!0).append("rect"),S.select("rect").call(T).call(x),S.exit().remove();var E=f.selectAll("g.value-bullet").data([h.gauge.bar]);E.enter().append("g").classed("value-bullet",!0).append("rect"),E.select("rect").attr("height",M).attr("y",(C-M)/2).call(x),y(w)?E.select("rect").transition().duration(w.duration).ease(w.easing).each("end",(function(){A&&A()})).each("interrupt",(function(){A&&A()})).attr("width",Math.max(0,i.c2p(Math.min(h.gauge.axis.range[1],r[0].y)))):E.select("rect").attr("width","number"==typeof r[0].y?Math.max(0,i.c2p(Math.min(h.gauge.axis.range[1],r[0].y))):0),E.exit().remove();var D=r.filter((function(){return h.gauge.threshold.value})),P=f.selectAll("g.threshold-bullet").data(D);P.enter().append("g").classed("threshold-bullet",!0).append("line"),P.select("line").attr("x1",i.c2p(h.gauge.threshold.value)).attr("x2",i.c2p(h.gauge.threshold.value)).attr("y1",(1-h.gauge.threshold.thickness)/2*C).attr("y2",(1-(1-h.gauge.threshold.thickness)/2)*C).call(d.stroke,h.gauge.threshold.line.color).style("stroke-width",h.gauge.threshold.line.width),P.exit().remove();var O=f.selectAll("g.gauge-outline").data([m]);O.enter().append("g").classed("gauge-outline",!0).append("rect"),O.select("rect").call(T).call(x),O.exit().remove()}(t,0,e,{gauge:G,layer:q,size:z,gaugeBg:I,gaugeOutline:T,transitionOpts:r,onComplete:f});var W=S.selectAll("text.title").data(e);W.exit().remove(),W.enter().append("text").classed("title",!0),W.attr("text-anchor",(function(){return P?g.right:g[L.title.align]})).text(L.title.text).call(s.font,L.title.font).call(c.convertToTspans,t),W.attr("transform",(function(){var t,e=z.l+z.w*m[L.title.align],r=l.titlePadding,n=s.bBox(W.node());return E?(D&&(t=L.gauge.axis.visible?s.bBox(H.node()).top-r-n.bottom:z.t+z.h/2-N/2-n.bottom-r),P&&(t=M-(n.top+n.bottom)/2,e=z.l-l.bulletPadding*z.w)):t=L._numbersTop-r-n.bottom,_(e,t)}))}))}},{"../../components/color":592,"../../components/drawing":613,"../../constants/alignment":686,"../../lib":717,"../../lib/svg_text_utils":741,"../../plots/cartesian/axes":765,"../../plots/cartesian/axis_defaults":767,"../../plots/cartesian/layout_attributes":777,"../../plots/cartesian/position_defaults":780,"./constants":1052,d3:165}],1056:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../plots/template_attributes").hovertemplateAttrs,a=t("../mesh3d/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l=t("../../plot_api/edit_types").overrideAll,c=e.exports=l(s({x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},value:{valType:"data_array"},isomin:{valType:"number"},isomax:{valType:"number"},surface:{show:{valType:"boolean",dflt:!0},count:{valType:"integer",dflt:2,min:1},fill:{valType:"number",min:0,max:1,dflt:1},pattern:{valType:"flaglist",flags:["A","B","C","D","E"],extras:["all","odd","even"],dflt:"all"}},spaceframe:{show:{valType:"boolean",dflt:!1},fill:{valType:"number",min:0,max:1,dflt:.15}},slices:{x:{show:{valType:"boolean",dflt:!1},locations:{valType:"data_array",dflt:[]},fill:{valType:"number",min:0,max:1,dflt:1}},y:{show:{valType:"boolean",dflt:!1},locations:{valType:"data_array",dflt:[]},fill:{valType:"number",min:0,max:1,dflt:1}},z:{show:{valType:"boolean",dflt:!1},locations:{valType:"data_array",dflt:[]},fill:{valType:"number",min:0,max:1,dflt:1}}},caps:{x:{show:{valType:"boolean",dflt:!0},fill:{valType:"number",min:0,max:1,dflt:1}},y:{show:{valType:"boolean",dflt:!0},fill:{valType:"number",min:0,max:1,dflt:1}},z:{show:{valType:"boolean",dflt:!0},fill:{valType:"number",min:0,max:1,dflt:1}}},text:{valType:"string",dflt:"",arrayOk:!0},hovertext:{valType:"string",dflt:"",arrayOk:!0},hovertemplate:i(),showlegend:s({},o.showlegend,{dflt:!1})},n("",{colorAttr:"`value`",showScaleDflt:!0,editTypeOverride:"calc"}),{opacity:a.opacity,lightposition:a.lightposition,lighting:a.lighting,flatshading:a.flatshading,contour:a.contour,hoverinfo:s({},o.hoverinfo)}),"calc","nested");c.flatshading.dflt=!0,c.lighting.facenormalsepsilon.dflt=0,c.x.editType=c.y.editType=c.z.editType=c.value.editType="calc+clearAxisTypes",c.transforms=void 0},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plot_api/edit_types":748,"../../plots/attributes":762,"../../plots/template_attributes":841,"../mesh3d/attributes":1061}],1057:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc"),i=t("../streamtube/calc").processGrid,a=t("../streamtube/calc").filter;e.exports=function(t,e){e._len=Math.min(e.x.length,e.y.length,e.z.length,e.value.length),e._x=a(e.x,e._len),e._y=a(e.y,e._len),e._z=a(e.z,e._len),e._value=a(e.value,e._len);var r=i(e);e._gridFill=r.fill,e._Xs=r.Xs,e._Ys=r.Ys,e._Zs=r.Zs,e._len=r.len;for(var o=1/0,s=-1/0,l=0;l0;r--){var n=Math.min(e[r],e[r-1]),i=Math.max(e[r],e[r-1]);if(i>n&&n-1}function R(t,e){return null===t?e:t}function F(e,r,n){S();var i,a,o,l=[r],c=[n];if(s>=1)l=[r],c=[n];else if(s>0){var u=function(t,e){var r=t[0],n=t[1],i=t[2],a=function(t,e,r){for(var n=[],i=0;i-1?n[p]:L(d,g,v);f[p]=x>-1?x:D(d,g,v,R(e,y))}i=f[0],a=f[1],o=f[2],t._meshI.push(i),t._meshJ.push(a),t._meshK.push(o),++m}}function N(t,e,r,n){var i=t[3];in&&(i=n);for(var a=(t[3]-i)/(t[3]-e[3]+1e-9),o=[],s=0;s<4;s++)o[s]=(1-a)*t[s]+a*e[s];return o}function j(t,e,r){return t>=e&&t<=r}function B(t){var e=.001*(T-I);return t>=I-e&&t<=T+e}function Y(e){for(var r=[],n=0;n<4;n++){var i=e[n];r.push([t._x[i],t._y[i],t._z[i],t._value[i]])}return r}var V=3;function U(t,e,r,n,i,a){a||(a=1),r=[-1,-1,-1];var o=!1,s=[j(e[0][3],n,i),j(e[1][3],n,i),j(e[2][3],n,i)];if(!s[0]&&!s[1]&&!s[2])return!1;var l=function(t,e,r){return B(e[0][3])&&B(e[1][3])&&B(e[2][3])?(F(t,e,r),!0):aMath.abs(d-k)?[M,d]:[d,k];tt(e,A[0],A[1])}}var L=[[Math.min(I,k),Math.max(I,k)],[Math.min(M,T),Math.max(M,T)]];["x","y","z"].forEach((function(e){for(var r=[],n=0;n0&&(u.push(p.id),"x"===e?h.push([p.distRatio,0,0]):"y"===e?h.push([0,p.distRatio,0]):h.push([0,0,p.distRatio]))}else c=it(1,"x"===e?b-1:"y"===e?_-1:w-1);u.length>0&&(r[i]="x"===e?et(null,u,a,o,h,r[i]):"y"===e?rt(null,u,a,o,h,r[i]):nt(null,u,a,o,h,r[i]),i++),c.length>0&&(r[i]="x"===e?J(null,c,a,o,r[i]):"y"===e?K(null,c,a,o,r[i]):Q(null,c,a,o,r[i]),i++)}var d=t.caps[e];d.show&&d.fill&&(O(d.fill),r[i]="x"===e?J(null,[0,b-1],a,o,r[i]):"y"===e?K(null,[0,_-1],a,o,r[i]):Q(null,[0,w-1],a,o,r[i]),i++)}})),0===m&&E(),t._meshX=n,t._meshY=i,t._meshZ=a,t._meshIntensity=o,t._Xs=v,t._Ys=y,t._Zs=x}(),t}e.exports={findNearestOnAxis:l,generateIsoMeshes:f,createIsosurfaceTrace:function(t,e){var r=t.glplot.gl,i=n({gl:r}),a=new c(t,i,e.uid);return i._trace=a,a.update(e),t.glplot.add(i),a}}},{"../../components/colorscale":604,"../../lib/gl_format_color":714,"../../lib/str2rgbarray":740,"../../plots/gl3d/zip3":816,"gl-mesh3d":283}],1059:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("../../components/colorscale/defaults");function s(t,e,r,n,a){var s=a("isomin"),l=a("isomax");null!=l&&null!=s&&s>l&&(e.isomin=null,e.isomax=null);var c=a("x"),u=a("y"),h=a("z"),f=a("value");c&&c.length&&u&&u.length&&h&&h.length&&f&&f.length?(i.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x","y","z"],n),["x","y","z"].forEach((function(t){var e="caps."+t;a(e+".show")&&a(e+".fill");var r="slices."+t;a(r+".show")&&(a(r+".fill"),a(r+".locations"))})),a("spaceframe.show")&&a("spaceframe.fill"),a("surface.show")&&(a("surface.count"),a("surface.fill"),a("surface.pattern")),a("contour.show")&&(a("contour.color"),a("contour.width")),["text","hovertext","hovertemplate","lighting.ambient","lighting.diffuse","lighting.specular","lighting.roughness","lighting.fresnel","lighting.vertexnormalsepsilon","lighting.facenormalsepsilon","lightposition.x","lightposition.y","lightposition.z","flatshading","opacity"].forEach((function(t){a(t)})),o(t,e,n,a,{prefix:"",cLetter:"c"}),e._length=null):e.visible=!1}e.exports={supplyDefaults:function(t,e,r,i){s(t,e,0,i,(function(r,i){return n.coerce(t,e,a,r,i)}))},supplyIsoDefaults:s}},{"../../components/colorscale/defaults":602,"../../lib":717,"../../registry":846,"./attributes":1056}],1060:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults").supplyDefaults,calc:t("./calc"),colorbar:{min:"cmin",max:"cmax"},plot:t("./convert").createIsosurfaceTrace,moduleType:"trace",name:"isosurface",basePlotModule:t("../../plots/gl3d"),categories:["gl3d","showLegend"],meta:{}}},{"../../plots/gl3d":805,"./attributes":1056,"./calc":1057,"./convert":1058,"./defaults":1059}],1061:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../plots/template_attributes").hovertemplateAttrs,a=t("../surface/attributes"),o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat;e.exports=s({x:{valType:"data_array",editType:"calc+clearAxisTypes"},y:{valType:"data_array",editType:"calc+clearAxisTypes"},z:{valType:"data_array",editType:"calc+clearAxisTypes"},i:{valType:"data_array",editType:"calc"},j:{valType:"data_array",editType:"calc"},k:{valType:"data_array",editType:"calc"},text:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"calc"},hovertemplate:i({editType:"calc"}),delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z",editType:"calc"},alphahull:{valType:"number",dflt:-1,editType:"calc"},intensity:{valType:"data_array",editType:"calc"},intensitymode:{valType:"enumerated",values:["vertex","cell"],dflt:"vertex",editType:"calc"},color:{valType:"color",editType:"calc"},vertexcolor:{valType:"data_array",editType:"calc"},facecolor:{valType:"data_array",editType:"calc"},transforms:void 0},n("",{colorAttr:"`intensity`",showScaleDflt:!0,editTypeOverride:"calc"}),{opacity:a.opacity,flatshading:{valType:"boolean",dflt:!1,editType:"calc"},contour:{show:s({},a.contours.x.show,{}),color:a.contours.x.color,width:a.contours.x.width,editType:"calc"},lightposition:{x:s({},a.lightposition.x,{dflt:1e5}),y:s({},a.lightposition.y,{dflt:1e5}),z:s({},a.lightposition.z,{dflt:0}),editType:"calc"},lighting:s({vertexnormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-12,editType:"calc"},facenormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-6,editType:"calc"},editType:"calc"},a.lighting),hoverinfo:s({},o.hoverinfo,{editType:"calc"}),showlegend:s({},o.showlegend,{dflt:!1})})},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../surface/attributes":1243}],1062:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){e.intensity&&n(t,e,{vals:e.intensity,containerStr:"",cLetter:"c"})}},{"../../components/colorscale/calc":600}],1063:[function(t,e,r){"use strict";var n=t("gl-mesh3d"),i=t("delaunay-triangulate"),a=t("alpha-shape"),o=t("convex-hull"),s=t("../../lib/gl_format_color").parseColorScale,l=t("../../lib/str2rgbarray"),c=t("../../components/colorscale").extractOpts,u=t("../../plots/gl3d/zip3");function h(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}var f=h.prototype;function p(t){for(var e=[],r=t.length,n=0;n=e-.5)return!1;return!0}f.handlePick=function(t){if(t.object===this.mesh){var e=t.index=t.data.index;t.data._cellCenter?t.traceCoordinate=t.data.dataCoordinate:t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]];var r=this.data.hovertext||this.data.text;return Array.isArray(r)&&void 0!==r[e]?t.textLabel=r[e]:r&&(t.textLabel=r),!0}},f.update=function(t){var e=this.scene,r=e.fullSceneLayout;this.data=t;var n,h=t.x.length,f=u(d(r.xaxis,t.x,e.dataScale[0],t.xcalendar),d(r.yaxis,t.y,e.dataScale[1],t.ycalendar),d(r.zaxis,t.z,e.dataScale[2],t.zcalendar));if(t.i&&t.j&&t.k){if(t.i.length!==t.j.length||t.j.length!==t.k.length||!m(t.i,h)||!m(t.j,h)||!m(t.k,h))return;n=u(g(t.i),g(t.j),g(t.k))}else n=0===t.alphahull?o(f):t.alphahull>0?a(t.alphahull,f):function(t,e){for(var r=["x","y","z"].indexOf(t),n=[],a=e.length,o=0;om):g=A>b,m=A;var C=l(b,_,w,A);C.pos=x,C.yc=(b+A)/2,C.i=y,C.dir=g?"increasing":"decreasing",C.x=C.pos,C.y=[w,_],p&&(C.tx=e.text[y]),d&&(C.htx=e.hovertext[y]),v.push(C)}else v.push({pos:x,empty:!0})}return e._extremes[s._id]=a.findExtremes(s,n.concat(h,u),{padded:!0}),v.length&&(v[0].t={labels:{open:i(t,"open:")+" ",high:i(t,"high:")+" ",low:i(t,"low:")+" ",close:i(t,"close:")+" "}}),v}e.exports={calc:function(t,e){var r=a.getFromId(t,e.xaxis),i=a.getFromId(t,e.yaxis),o=function(t,e,r){var i=r._minDiff;if(!i){var a,o=t._fullData,s=[];for(i=1/0,a=0;a"+c.labels[x]+n.hoverLabelText(s,b):((y=i.extendFlat({},f)).y0=y.y1=_,y.yLabelVal=b,y.yLabel=c.labels[x]+n.hoverLabelText(s,b),y.name="",h.push(y),m[b]=y)}return h}function f(t,e,r,i){var a=t.cd,o=t.ya,l=a[0].trace,h=a[0].t,f=u(t,e,r,i);if(!f)return[];var p=a[f.index],d=f.index=p.i,g=p.dir;function m(t){return h.labels[t]+n.hoverLabelText(o,l[t][d])}var v=p.hi||l.hoverinfo,y=v.split("+"),x="all"===v,b=x||-1!==y.indexOf("y"),_=x||-1!==y.indexOf("text"),w=b?[m("open"),m("high"),m("low"),m("close")+" "+c[g]]:[];return _&&s(p,l,w),f.extraText=w.join("
"),f.y0=f.y1=o.c2p(p.yc,!0),[f]}e.exports={hoverPoints:function(t,e,r,n){return t.cd[0].trace.hoverlabel.split?h(t,e,r,n):f(t,e,r,n)},hoverSplit:h,hoverOnPoints:f}},{"../../components/color":592,"../../components/fx":630,"../../constants/delta.js":687,"../../lib":717,"../../plots/cartesian/axes":765}],1070:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"ohlc",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","showLegend"],meta:{},attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc").calc,plot:t("./plot"),style:t("./style"),hoverPoints:t("./hover").hoverPoints,selectPoints:t("./select")}},{"../../plots/cartesian":776,"./attributes":1066,"./calc":1067,"./defaults":1068,"./hover":1069,"./plot":1072,"./select":1073,"./style":1074}],1071:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib");e.exports=function(t,e,r,a){var o=r("x"),s=r("open"),l=r("high"),c=r("low"),u=r("close");if(r("hoverlabel.split"),n.getComponentMethod("calendars","handleTraceDefaults")(t,e,["x"],a),s&&l&&c&&u){var h=Math.min(s.length,l.length,c.length,u.length);return o&&(h=Math.min(h,i.minRowLength(o))),e._length=h,h}}},{"../../lib":717,"../../registry":846}],1072:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib");e.exports=function(t,e,r,a){var o=e.xaxis,s=e.yaxis;i.makeTraceGroups(a,r,"trace ohlc").each((function(t){var e=n.select(this),r=t[0],a=r.t;if(!0!==r.trace.visible||a.empty)e.remove();else{var l=a.tickLen,c=e.selectAll("path").data(i.identity);c.enter().append("path"),c.exit().remove(),c.attr("d",(function(t){if(t.empty)return"M0,0Z";var e=o.c2p(t.pos,!0),r=o.c2p(t.pos-l,!0),n=o.c2p(t.pos+l,!0);return"M"+r+","+s.c2p(t.o,!0)+"H"+e+"M"+e+","+s.c2p(t.h,!0)+"V"+s.c2p(t.l,!0)+"M"+n+","+s.c2p(t.c,!0)+"H"+e}))}}))}},{"../../lib":717,d3:165}],1073:[function(t,e,r){"use strict";e.exports=function(t,e){var r,n=t.cd,i=t.xaxis,a=t.yaxis,o=[],s=n[0].t.bPos||0;if(!1===e)for(r=0;r=t.length)return!1;if(void 0!==e[t[r]])return!1;e[t[r]]=!0}return!0}(t.map((function(t){return t.displayindex}))))for(e=0;e0;c&&(o="array");var u=r("categoryorder",o);"array"===u?(r("categoryarray"),r("ticktext")):(delete t.categoryarray,delete t.ticktext),c||"array"!==u||(e.categoryorder="trace")}}e.exports=function(t,e,r,h){function f(r,i){return n.coerce(t,e,l,r,i)}var p=s(t,e,{name:"dimensions",handleItemDefaults:u}),d=function(t,e,r,o,s){s("line.shape"),s("line.hovertemplate");var l=s("line.color",o.colorway[0]);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,h,f);o(e,h,f),Array.isArray(p)&&p.length||(e.visible=!1),c(e,p,"values",d),f("hoveron"),f("hovertemplate"),f("arrangement"),f("bundlecolors"),f("sortpaths"),f("counts");var g={family:h.font.family,size:Math.round(h.font.size),color:h.font.color};n.coerceFont(f,"labelfont",g);var m={family:h.font.family,size:Math.round(h.font.size/1.2),color:h.font.color};n.coerceFont(f,"tickfont",m)}},{"../../components/colorscale/defaults":602,"../../components/colorscale/helpers":603,"../../lib":717,"../../plots/array_container_defaults":761,"../../plots/domain":790,"../parcoords/merge_length":1091,"./attributes":1075}],1079:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("./plot"),colorbar:{container:"line",min:"cmin",max:"cmax"},moduleType:"trace",name:"parcats",basePlotModule:t("./base_plot"),categories:["noOpacity"],meta:{}}},{"./attributes":1075,"./base_plot":1076,"./calc":1077,"./defaults":1078,"./plot":1081}],1080:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plot_api/plot_api"),a=t("../../components/fx"),o=t("../../lib"),s=t("../../components/drawing"),l=t("tinycolor2"),c=t("../../lib/svg_text_utils");function u(t,e,r,i){var a=t.map(z.bind(0,e,r)),l=i.selectAll("g.parcatslayer").data([null]);l.enter().append("g").attr("class","parcatslayer").style("pointer-events","all");var u=l.selectAll("g.trace.parcats").data(a,h),m=u.enter().append("g").attr("class","trace parcats");u.attr("transform",(function(t){return"translate("+t.x+", "+t.y+")"})),m.append("g").attr("class","paths");var v=u.select("g.paths").selectAll("path.path").data((function(t){return t.paths}),h);v.attr("fill",(function(t){return t.model.color}));var b=v.enter().append("path").attr("class","path").attr("stroke-opacity",0).attr("fill",(function(t){return t.model.color})).attr("fill-opacity",0);x(b),v.attr("d",(function(t){return t.svgD})),b.empty()||v.sort(p),v.exit().remove(),v.on("mouseover",d).on("mouseout",g).on("click",y),m.append("g").attr("class","dimensions");var A=u.select("g.dimensions").selectAll("g.dimension").data((function(t){return t.dimensions}),h);A.enter().append("g").attr("class","dimension"),A.attr("transform",(function(t){return"translate("+t.x+", 0)"})),A.exit().remove();var C=A.selectAll("g.category").data((function(t){return t.categories}),h),M=C.enter().append("g").attr("class","category");C.attr("transform",(function(t){return"translate(0, "+t.y+")"})),M.append("rect").attr("class","catrect").attr("pointer-events","none"),C.select("rect.catrect").attr("fill","none").attr("width",(function(t){return t.width})).attr("height",(function(t){return t.height})),_(M);var k=C.selectAll("rect.bandrect").data((function(t){return t.bands}),h);k.each((function(){o.raiseToTop(this)})),k.attr("fill",(function(t){return t.color}));var D=k.enter().append("rect").attr("class","bandrect").attr("stroke-opacity",0).attr("fill",(function(t){return t.color})).attr("fill-opacity",0);k.attr("fill",(function(t){return t.color})).attr("width",(function(t){return t.width})).attr("height",(function(t){return t.height})).attr("y",(function(t){return t.y})).attr("cursor",(function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"perpendicular"===t.parcatsViewModel.arrangement?"ns-resize":"move"})),w(D),k.exit().remove(),M.append("text").attr("class","catlabel").attr("pointer-events","none");var P=e._fullLayout.paper_bgcolor;C.select("text.catlabel").attr("text-anchor",(function(t){return f(t)?"start":"end"})).attr("alignment-baseline","middle").style("text-shadow",P+" -1px 1px 2px, "+P+" 1px 1px 2px, "+P+" 1px -1px 2px, "+P+" -1px -1px 2px").style("fill","rgb(0, 0, 0)").attr("x",(function(t){return f(t)?t.width+5:-5})).attr("y",(function(t){return t.height/2})).text((function(t){return t.model.categoryLabel})).each((function(t){s.font(n.select(this),t.parcatsViewModel.categorylabelfont),c.convertToTspans(n.select(this),e)})),M.append("text").attr("class","dimlabel"),C.select("text.dimlabel").attr("text-anchor","middle").attr("alignment-baseline","baseline").attr("cursor",(function(t){return"fixed"===t.parcatsViewModel.arrangement?"default":"ew-resize"})).attr("x",(function(t){return t.width/2})).attr("y",-5).text((function(t,e){return 0===e?t.parcatsViewModel.model.dimensions[t.model.dimensionInd].dimensionLabel:null})).each((function(t){s.font(n.select(this),t.parcatsViewModel.labelfont)})),C.selectAll("rect.bandrect").on("mouseover",I).on("mouseout",T),C.exit().remove(),A.call(n.behavior.drag().origin((function(t){return{x:t.x,y:0}})).on("dragstart",L).on("drag",S).on("dragend",E)),u.each((function(t){t.traceSelection=n.select(this),t.pathSelection=n.select(this).selectAll("g.paths").selectAll("path.path"),t.dimensionSelection=n.select(this).selectAll("g.dimensions").selectAll("g.dimension")})),u.exit().remove()}function h(t){return t.key}function f(t){var e=t.parcatsViewModel.dimensions.length,r=t.parcatsViewModel.dimensions[e-1].model.dimensionInd;return t.model.dimensionInd===r}function p(t,e){return t.model.rawColor>e.model.rawColor?1:t.model.rawColor"),L=n.mouse(h)[0];a.loneHover({trace:f,x:_-d.left+g.left,y:w-d.top+g.top,text:T,color:t.model.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:10,fontColor:A,idealAlign:L<_?"right":"left",hovertemplate:(f.line||{}).hovertemplate,hovertemplateLabels:k,eventData:[{data:f._input,fullData:f,count:C,probability:M}]},{container:p._hoverlayer.node(),outerContainer:p._paper.node(),gd:h})}}}function g(t){if(!t.parcatsViewModel.dragDimension&&(x(n.select(this)),a.loneUnhover(t.parcatsViewModel.graphDiv._fullLayout._hoverlayer.node()),t.parcatsViewModel.pathSelection.sort(p),-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip"))){var e=m(t),r=v(t);t.parcatsViewModel.graphDiv.emit("plotly_unhover",{points:e,event:n.event,constraints:r})}}function m(t){for(var e=[],r=D(t.parcatsViewModel),n=0;n1&&c.displayInd===l.dimensions.length-1?(r=o.left,i="left"):(r=o.left+o.width,i="right");var f=s.model.count,p=s.model.categoryLabel,d=f/s.parcatsViewModel.model.count,g={countLabel:f,categoryLabel:p,probabilityLabel:d.toFixed(3)},m=[];-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&m.push(["Count:",g.countLabel].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")&&m.push(["P("+g.categoryLabel+"):",g.probabilityLabel].join(" "));var v=m.join("
");return{trace:u,x:r-t.left,y:h-t.top,text:v,color:"lightgray",borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontSize:12,fontColor:"black",idealAlign:i,hovertemplate:u.hovertemplate,hovertemplateLabels:g,eventData:[{data:u._input,fullData:u,count:f,category:p,probability:d}]}}function I(t){if(!t.parcatsViewModel.dragDimension&&-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")){if(n.mouse(this)[1]<-1)return;var e,r=t.parcatsViewModel.graphDiv,i=r._fullLayout,s=i._paperdiv.node().getBoundingClientRect(),c=t.parcatsViewModel.hoveron;"color"===c?(function(t){var e=n.select(t).datum(),r=A(e);b(r),r.each((function(){o.raiseToTop(this)})),n.select(t.parentNode).selectAll("rect.bandrect").filter((function(t){return t.color===e.color})).each((function(){o.raiseToTop(this),n.select(this).attr("stroke","black").attr("stroke-width",1.5)}))}(this),M(this,"plotly_hover",n.event)):(function(t){n.select(t.parentNode).selectAll("rect.bandrect").each((function(t){var e=A(t);b(e),e.each((function(){o.raiseToTop(this)}))})),n.select(t.parentNode).select("rect.catrect").attr("stroke","black").attr("stroke-width",2.5)}(this),C(this,"plotly_hover",n.event)),-1===t.parcatsViewModel.hoverinfoItems.indexOf("none")&&("category"===c?e=k(s,this):"color"===c?e=function(t,e){var r,i,a=e.getBoundingClientRect(),o=n.select(e).datum(),s=o.categoryViewModel,c=s.parcatsViewModel,u=c.model.dimensions[s.model.dimensionInd],h=c.trace,f=a.y+a.height/2;c.dimensions.length>1&&u.displayInd===c.dimensions.length-1?(r=a.left,i="left"):(r=a.left+a.width,i="right");var p=s.model.categoryLabel,d=o.parcatsViewModel.model.count,g=0;o.categoryViewModel.bands.forEach((function(t){t.color===o.color&&(g+=t.count)}));var m=s.model.count,v=0;c.pathSelection.each((function(t){t.model.color===o.color&&(v+=t.model.count)}));var y=g/d,x=g/v,b=g/m,_={countLabel:d,categoryLabel:p,probabilityLabel:y.toFixed(3)},w=[];-1!==s.parcatsViewModel.hoverinfoItems.indexOf("count")&&w.push(["Count:",_.countLabel].join(" ")),-1!==s.parcatsViewModel.hoverinfoItems.indexOf("probability")&&(w.push("P(color ∩ "+p+"): "+_.probabilityLabel),w.push("P("+p+" | color): "+x.toFixed(3)),w.push("P(color | "+p+"): "+b.toFixed(3)));var A=w.join("
"),C=l.mostReadable(o.color,["black","white"]);return{trace:h,x:r-t.left,y:f-t.top,text:A,color:o.color,borderColor:"black",fontFamily:'Monaco, "Courier New", monospace',fontColor:C,fontSize:10,idealAlign:i,hovertemplate:h.hovertemplate,hovertemplateLabels:_,eventData:[{data:h._input,fullData:h,category:p,count:d,probability:y,categorycount:m,colorcount:v,bandcolorcount:g}]}}(s,this):"dimension"===c&&(e=function(t,e){var r=[];return n.select(e.parentNode.parentNode).selectAll("g.category").select("rect.catrect").each((function(){r.push(k(t,this))})),r}(s,this)),e&&a.loneHover(e,{container:i._hoverlayer.node(),outerContainer:i._paper.node(),gd:r}))}}function T(t){var e=t.parcatsViewModel;e.dragDimension||(x(e.pathSelection),_(e.dimensionSelection.selectAll("g.category")),w(e.dimensionSelection.selectAll("g.category").selectAll("rect.bandrect")),a.loneUnhover(e.graphDiv._fullLayout._hoverlayer.node()),e.pathSelection.sort(p),-1!==e.hoverinfoItems.indexOf("skip"))||("color"===t.parcatsViewModel.hoveron?M(this,"plotly_unhover",n.event):C(this,"plotly_unhover",n.event))}function L(t){"fixed"!==t.parcatsViewModel.arrangement&&(t.dragDimensionDisplayInd=t.model.displayInd,t.initialDragDimensionDisplayInds=t.parcatsViewModel.model.dimensions.map((function(t){return t.displayInd})),t.dragHasMoved=!1,t.dragCategoryDisplayInd=null,n.select(this).selectAll("g.category").select("rect.catrect").each((function(e){var r=n.mouse(this)[0],i=n.mouse(this)[1];-2<=r&&r<=e.width+2&&-2<=i&&i<=e.height+2&&(t.dragCategoryDisplayInd=e.model.displayInd,t.initialDragCategoryDisplayInds=t.model.categories.map((function(t){return t.displayInd})),e.model.dragY=e.y,o.raiseToTop(this.parentNode),n.select(this.parentNode).selectAll("rect.bandrect").each((function(e){e.yh.y+h.height/2&&(o.model.displayInd=h.model.displayInd,h.model.displayInd=l),t.dragCategoryDisplayInd=o.model.displayInd}if(null===t.dragCategoryDisplayInd||"freeform"===t.parcatsViewModel.arrangement){a.model.dragX=n.event.x;var f=t.parcatsViewModel.dimensions[r],p=t.parcatsViewModel.dimensions[i];void 0!==f&&a.model.dragXp.x&&(a.model.displayInd=p.model.displayInd,p.model.displayInd=t.dragDimensionDisplayInd),t.dragDimensionDisplayInd=a.model.displayInd}N(t.parcatsViewModel),F(t.parcatsViewModel),O(t.parcatsViewModel),P(t.parcatsViewModel)}}function E(t){if("fixed"!==t.parcatsViewModel.arrangement&&null!==t.dragDimensionDisplayInd){n.select(this).selectAll("text").attr("font-weight","normal");var e={},r=D(t.parcatsViewModel),a=t.parcatsViewModel.model.dimensions.map((function(t){return t.displayInd})),o=t.initialDragDimensionDisplayInds.some((function(t,e){return t!==a[e]}));o&&a.forEach((function(r,n){var i=t.parcatsViewModel.model.dimensions[n].containerInd;e["dimensions["+i+"].displayindex"]=r}));var s=!1;if(null!==t.dragCategoryDisplayInd){var l=t.model.categories.map((function(t){return t.displayInd}));if(s=t.initialDragCategoryDisplayInds.some((function(t,e){return t!==l[e]}))){var c=t.model.categories.slice().sort((function(t,e){return t.displayInd-e.displayInd})),u=c.map((function(t){return t.categoryValue})),h=c.map((function(t){return t.categoryLabel}));e["dimensions["+t.model.containerInd+"].categoryarray"]=[u],e["dimensions["+t.model.containerInd+"].ticktext"]=[h],e["dimensions["+t.model.containerInd+"].categoryorder"]="array"}}-1===t.parcatsViewModel.hoverinfoItems.indexOf("skip")&&!t.dragHasMoved&&t.potentialClickBand&&("color"===t.parcatsViewModel.hoveron?M(t.potentialClickBand,"plotly_click",n.event.sourceEvent):C(t.potentialClickBand,"plotly_click",n.event.sourceEvent)),t.model.dragX=null,null!==t.dragCategoryDisplayInd&&(t.parcatsViewModel.dimensions[t.dragDimensionDisplayInd].categories[t.dragCategoryDisplayInd].model.dragY=null,t.dragCategoryDisplayInd=null),t.dragDimensionDisplayInd=null,t.parcatsViewModel.dragDimension=null,t.dragHasMoved=null,t.potentialClickBand=null,N(t.parcatsViewModel),F(t.parcatsViewModel),n.transition().duration(300).ease("cubic-in-out").each((function(){O(t.parcatsViewModel,!0),P(t.parcatsViewModel,!0)})).each("end",(function(){(o||s)&&i.restyle(t.parcatsViewModel.graphDiv,e,[r])}))}}function D(t){for(var e,r=t.graphDiv._fullData,n=0;n=0;s--)u+="C"+c[s]+","+(e[s+1]+i)+" "+l[s]+","+(e[s]+i)+" "+(t[s]+r[s])+","+(e[s]+i),u+="l-"+r[s]+",0 ";return u+="Z"}function F(t){var e=t.dimensions,r=t.model,n=e.map((function(t){return t.categories.map((function(t){return t.y}))})),i=t.model.dimensions.map((function(t){return t.categories.map((function(t){return t.displayInd}))})),a=t.model.dimensions.map((function(t){return t.displayInd})),o=t.dimensions.map((function(t){return t.model.dimensionInd})),s=e.map((function(t){return t.x})),l=e.map((function(t){return t.width})),c=[];for(var u in r.paths)r.paths.hasOwnProperty(u)&&c.push(r.paths[u]);function h(t){var e=t.categoryInds.map((function(t,e){return i[e][t]}));return o.map((function(t){return e[t]}))}c.sort((function(e,r){var n=h(e),i=h(r);return"backward"===t.sortpaths&&(n.reverse(),i.reverse()),n.push(e.valueInds[0]),i.push(r.valueInds[0]),t.bundlecolors&&(n.unshift(e.rawColor),i.unshift(r.rawColor)),ni?1:0}));for(var f=new Array(c.length),p=e[0].model.count,d=e[0].categories.map((function(t){return t.height})).reduce((function(t,e){return t+e})),g=0;g0?d*(v.count/p):0;for(var y,x=new Array(n.length),b=0;b1?(t.width-80-16)/(n-1):0)*i;var a,o,s,l,c,u=[],h=t.model.maxCats,f=e.categories.length,p=e.count,d=t.height-8*(h-1),g=8*(h-f)/2,m=e.categories.map((function(t){return{displayInd:t.displayInd,categoryInd:t.categoryInd}}));for(m.sort((function(t,e){return t.displayInd-e.displayInd})),c=0;c0?o.count/p*d:0,s={key:o.valueInds[0],model:o,width:16,height:a,y:null!==o.dragY?o.dragY:g,bands:[],parcatsViewModel:t},g=g+a+8,u.push(s);return{key:e.dimensionInd,x:null!==e.dragX?e.dragX:r,y:0,width:16,model:e,categories:u,parcatsViewModel:t,dragCategoryDisplayInd:null,dragDimensionDisplayInd:null,initialDragDimensionDisplayInds:null,initialDragCategoryDisplayInds:null,dragHasMoved:null,potentialClickBand:null}}e.exports=function(t,e,r,n){u(r,t,n,e)}},{"../../components/drawing":613,"../../components/fx":630,"../../lib":717,"../../lib/svg_text_utils":741,"../../plot_api/plot_api":752,d3:165,tinycolor2:536}],1081:[function(t,e,r){"use strict";var n=t("./parcats");e.exports=function(t,e,r,i){var a=t._fullLayout,o=a._paper,s=a._size;n(t,o,e,{width:s.w,height:s.h,margin:{t:s.t,r:s.r,b:s.b,l:s.l}},r,i)}},{"./parcats":1080}],1082:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../../plots/cartesian/layout_attributes"),a=t("../../plots/font_attributes"),o=t("../../plots/domain").attributes,s=t("../../lib/extend").extendFlat,l=t("../../plot_api/plot_template").templatedArray;e.exports={domain:o({name:"parcoords",trace:!0,editType:"plot"}),labelangle:{valType:"angle",dflt:0,editType:"plot"},labelside:{valType:"enumerated",values:["top","bottom"],dflt:"top",editType:"plot"},labelfont:a({editType:"plot"}),tickfont:a({editType:"plot"}),rangefont:a({editType:"plot"}),dimensions:l("dimension",{label:{valType:"string",editType:"plot"},tickvals:s({},i.tickvals,{editType:"plot"}),ticktext:s({},i.ticktext,{editType:"plot"}),tickformat:s({},i.tickformat,{editType:"plot"}),visible:{valType:"boolean",dflt:!0,editType:"plot"},range:{valType:"info_array",items:[{valType:"number",editType:"plot"},{valType:"number",editType:"plot"}],editType:"plot"},constraintrange:{valType:"info_array",freeLength:!0,dimensions:"1-2",items:[{valType:"number",editType:"plot"},{valType:"number",editType:"plot"}],editType:"plot"},multiselect:{valType:"boolean",dflt:!0,editType:"plot"},values:{valType:"data_array",editType:"calc"},editType:"calc"}),line:s({editType:"calc"},n("line",{colorscaleDflt:"Viridis",autoColorDflt:!1,editTypeOverride:"calc"}))}},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plot_api/plot_template":755,"../../plots/cartesian/layout_attributes":777,"../../plots/domain":790,"../../plots/font_attributes":791}],1083:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("../../lib/gup").keyFun,o=t("../../lib/gup").repeat,s=t("../../lib").sorterAsc,l=n.bar.snapRatio;function c(t,e){return t*(1-l)+e*l}var u=n.bar.snapClose;function h(t,e){return t*(1-u)+e*u}function f(t,e,r,n){if(function(t,e){for(var r=0;r=e[r][0]&&t<=e[r][1])return!0;return!1}(r,n))return r;var i=t?-1:1,a=0,o=e.length-1;if(i<0){var s=a;a=o,o=s}for(var l=e[a],u=l,f=a;i*fe){f=r;break}}if(a=u,isNaN(a)&&(a=isNaN(h)||isNaN(f)?isNaN(h)?f:h:e-c[h][1]t[1]+r||e=.9*t[1]+.1*t[0]?"n":e<=.9*t[0]+.1*t[1]?"s":"ns"}(d,e);g&&(o.interval=l[a],o.intervalPix=d,o.region=g)}}if(t.ordinal&&!o.region){var v=t.unitTickvals,y=t.unitToPaddedPx.invert(e);for(r=0;r=x[0]&&y<=x[1]){o.clickableOrdinalRange=x;break}}}return o}function _(t,e){i.event.sourceEvent.stopPropagation();var r=e.height-i.mouse(t)[1]-2*n.verticalPadding,a=e.brush.svgBrush;a.wasDragged=!0,a._dragging=!0,a.grabbingBar?a.newExtent=[r-a.grabPoint,r+a.barLength-a.grabPoint].map(e.unitToPaddedPx.invert):a.newExtent=[a.startExtent,e.unitToPaddedPx.invert(r)].sort(s),e.brush.filterSpecified=!0,a.extent=a.stayingIntervals.concat([a.newExtent]),a.brushCallback(e),x(t.parentNode)}function w(t,e){var r=b(e,e.height-i.mouse(t)[1]-2*n.verticalPadding),a="crosshair";r.clickableOrdinalRange?a="pointer":r.region&&(a=r.region+"-resize"),i.select(document.body).style("cursor",a)}function A(t){t.on("mousemove",(function(t){i.event.preventDefault(),t.parent.inBrushDrag||w(this,t)})).on("mouseleave",(function(t){t.parent.inBrushDrag||v()})).call(i.behavior.drag().on("dragstart",(function(t){!function(t,e){i.event.sourceEvent.stopPropagation();var r=e.height-i.mouse(t)[1]-2*n.verticalPadding,a=e.unitToPaddedPx.invert(r),o=e.brush,s=b(e,r),l=s.interval,c=o.svgBrush;if(c.wasDragged=!1,c.grabbingBar="ns"===s.region,c.grabbingBar){var u=l.map(e.unitToPaddedPx);c.grabPoint=r-u[0]-n.verticalPadding,c.barLength=u[1]-u[0]}c.clickableOrdinalRange=s.clickableOrdinalRange,c.stayingIntervals=e.multiselect&&o.filterSpecified?o.filter.getConsolidated():[],l&&(c.stayingIntervals=c.stayingIntervals.filter((function(t){return t[0]!==l[0]&&t[1]!==l[1]}))),c.startExtent=s.region?l["s"===s.region?1:0]:a,e.parent.inBrushDrag=!0,c.brushStartCallback()}(this,t)})).on("drag",(function(t){_(this,t)})).on("dragend",(function(t){!function(t,e){var r=e.brush,n=r.filter,a=r.svgBrush;a._dragging||(w(t,e),_(t,e),e.brush.svgBrush.wasDragged=!1),a._dragging=!1,i.event.sourceEvent.stopPropagation();var o=a.grabbingBar;if(a.grabbingBar=!1,a.grabLocation=void 0,e.parent.inBrushDrag=!1,v(),!a.wasDragged)return a.wasDragged=void 0,a.clickableOrdinalRange?r.filterSpecified&&e.multiselect?a.extent.push(a.clickableOrdinalRange):(a.extent=[a.clickableOrdinalRange],r.filterSpecified=!0):o?(a.extent=a.stayingIntervals,0===a.extent.length&&M(r)):M(r),a.brushCallback(e),x(t.parentNode),void a.brushEndCallback(r.filterSpecified?n.getConsolidated():[]);var s=function(){n.set(n.getConsolidated())};if(e.ordinal){var l=e.unitTickvals;l[l.length-1]a.newExtent[0];a.extent=a.stayingIntervals.concat(c?[a.newExtent]:[]),a.extent.length||M(r),a.brushCallback(e),c?x(t.parentNode,s):(s(),x(t.parentNode))}else s();a.brushEndCallback(r.filterSpecified?n.getConsolidated():[])}(this,t)})))}function C(t,e){return t[0]-e[0]}function M(t){t.filterSpecified=!1,t.svgBrush.extent=[[-1/0,1/0]]}function k(t){for(var e,r=t.slice(),n=[],i=r.shift();i;){for(e=i.slice();(i=r.shift())&&i[0]<=e[1];)e[1]=Math.max(e[1],i[1]);n.push(e)}return n}e.exports={makeBrush:function(t,e,r,n,i,a){var o,l=function(){var t,e,r=[];return{set:function(n){1===(r=n.map((function(t){return t.slice().sort(s)})).sort(C)).length&&r[0][0]===-1/0&&r[0][1]===1/0&&(r=[[0,-1]]),t=k(r),e=r.reduce((function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}),[1/0,-1/0])},get:function(){return r.slice()},getConsolidated:function(){return t},getBounds:function(){return e}}}();return l.set(r),{filter:l,filterSpecified:e,svgBrush:{extent:[],brushStartCallback:n,brushCallback:(o=i,function(t){var e=t.brush,r=function(t){return t.svgBrush.extent.map((function(t){return t.slice()}))}(e).slice();e.filter.set(r),o()}),brushEndCallback:a}}},ensureAxisBrush:function(t){var e=t.selectAll("."+n.cn.axisBrush).data(o,a);e.enter().append("g").classed(n.cn.axisBrush,!0),function(t){var e=t.selectAll(".background").data(o);e.enter().append("rect").classed("background",!0).call(p).call(d).style("pointer-events","auto").attr("transform","translate(0 "+n.verticalPadding+")"),e.call(A).attr("height",(function(t){return t.height-n.verticalPadding}));var r=t.selectAll(".highlight-shadow").data(o);r.enter().append("line").classed("highlight-shadow",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width+n.bar.strokeWidth).attr("stroke",n.bar.strokeColor).attr("opacity",n.bar.strokeOpacity).attr("stroke-linecap","butt"),r.attr("y1",(function(t){return t.height})).call(y);var i=t.selectAll(".highlight").data(o);i.enter().append("line").classed("highlight",!0).attr("x",-n.bar.width/2).attr("stroke-width",n.bar.width-n.bar.strokeWidth).attr("stroke",n.bar.fillColor).attr("opacity",n.bar.fillOpacity).attr("stroke-linecap","butt"),i.attr("y1",(function(t){return t.height})).call(y)}(e)},cleanRanges:function(t,e){if(Array.isArray(t[0])?(t=t.map((function(t){return t.sort(s)})),t=e.multiselect?k(t.sort(C)):[t[0]]):t=[t.sort(s)],e.tickvals){var r=e.tickvals.slice().sort(s);if(!(t=t.map((function(t){var e=[f(0,r,t[0],[]),f(1,r,t[1],[])];if(e[1]>e[0])return e})).filter((function(t){return t}))).length)return}return t.length>1?t:t[0]}}},{"../../lib":717,"../../lib/gup":715,"./constants":1086,d3:165}],1084:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../constants/xmlns_namespaces");r.name="parcoords",r.plot=function(t){var e=i(t.calcdata,"parcoords")[0];e.length&&a(t,e)},r.clean=function(t,e,r,n){var i=n._has&&n._has("parcoords"),a=e._has&&e._has("parcoords");i&&!a&&(n._paperdiv.selectAll(".parcoords").remove(),n._glimages.selectAll("*").remove())},r.toSVG=function(t){var e=t._fullLayout._glimages,r=n.select(t).selectAll(".svg-container");r.filter((function(t,e){return e===r.size()-1})).selectAll(".gl-canvas-context, .gl-canvas-focus").each((function(){var t=this.toDataURL("image/png");e.append("svg:image").attr({xmlns:o.svg,"xlink:href":t,preserveAspectRatio:"none",x:0,y:0,width:this.width,height:this.height})})),window.setTimeout((function(){n.selectAll("#filterBarPattern").attr("id","filterBarPattern")}),60)}},{"../../constants/xmlns_namespaces":694,"../../plots/get_data":800,"./plot":1093,d3:165}],1085:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale"),a=t("../../lib/gup").wrap;e.exports=function(t,e){var r,o;return i.hasColorscale(e,"line")&&n(e.line.color)?(r=e.line.color,o=i.extractOpts(e.line).colorscale,i.calc(t,e,{vals:r,containerStr:"line",cLetter:"c"})):(r=function(t){for(var e=new Array(t),r=0;rh&&(n.log("parcoords traces support up to "+h+" dimensions at the moment"),d.splice(h));var g=s(t,e,{name:"dimensions",layout:l,handleItemDefaults:p}),m=function(t,e,r,o,s){var l=s("line.color",r);if(i(t,"line")&&n.isArrayOrTypedArray(l)){if(l.length)return s("line.colorscale"),a(t,e,o,s,{prefix:"line.",cLetter:"c"}),l.length;e.line.color=r}return 1/0}(t,e,r,l,u);o(e,l,u),Array.isArray(g)&&g.length||(e.visible=!1),f(e,g,"values",m);var v={family:l.font.family,size:Math.round(l.font.size/1.2),color:l.font.color};n.coerceFont(u,"labelfont",v),n.coerceFont(u,"tickfont",v),n.coerceFont(u,"rangefont",v),u("labelangle"),u("labelside")}},{"../../components/colorscale/defaults":602,"../../components/colorscale/helpers":603,"../../lib":717,"../../plots/array_container_defaults":761,"../../plots/cartesian/axes":765,"../../plots/domain":790,"./attributes":1082,"./axisbrush":1083,"./constants":1086,"./merge_length":1091}],1088:[function(t,e,r){"use strict";var n=t("../../lib").isTypedArray;r.convertTypedArray=function(t){return n(t)?Array.prototype.slice.call(t):t},r.isOrdinal=function(t){return!!t.tickvals},r.isVisible=function(t){return t.visible||!("visible"in t)}},{"../../lib":717}],1089:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("./plot"),colorbar:{container:"line",min:"cmin",max:"cmax"},moduleType:"trace",name:"parcoords",basePlotModule:t("./base_plot"),categories:["gl","regl","noOpacity","noHover"],meta:{}}},{"./attributes":1082,"./base_plot":1084,"./calc":1085,"./defaults":1087,"./plot":1093}],1090:[function(t,e,r){"use strict";var n=t("glslify"),i=n(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nattribute vec4 p01_04, p05_08, p09_12, p13_16,\n p17_20, p21_24, p25_28, p29_32,\n p33_36, p37_40, p41_44, p45_48,\n p49_52, p53_56, p57_60, colors;\n\nuniform mat4 dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D,\n loA, hiA, loB, hiB, loC, hiC, loD, hiD;\n\nuniform vec2 resolution, viewBoxPos, viewBoxSize;\nuniform sampler2D mask, palette;\nuniform float maskHeight;\nuniform float drwLayer; // 0: context, 1: focus, 2: pick\nuniform vec4 contextColor;\n\nbool isPick = (drwLayer > 1.5);\nbool isContext = (drwLayer < 0.5);\n\nconst vec4 ZEROS = vec4(0.0, 0.0, 0.0, 0.0);\nconst vec4 UNITS = vec4(1.0, 1.0, 1.0, 1.0);\n\nfloat val(mat4 p, mat4 v) {\n return dot(matrixCompMult(p, v) * UNITS, UNITS);\n}\n\nfloat axisY(float ratio, mat4 A, mat4 B, mat4 C, mat4 D) {\n float y1 = val(A, dim0A) + val(B, dim0B) + val(C, dim0C) + val(D, dim0D);\n float y2 = val(A, dim1A) + val(B, dim1B) + val(C, dim1C) + val(D, dim1D);\n return y1 * (1.0 - ratio) + y2 * ratio;\n}\n\nint iMod(int a, int b) {\n return a - b * (a / b);\n}\n\nbool fOutside(float p, float lo, float hi) {\n return (lo < hi) && (lo > p || p > hi);\n}\n\nbool vOutside(vec4 p, vec4 lo, vec4 hi) {\n return (\n fOutside(p[0], lo[0], hi[0]) ||\n fOutside(p[1], lo[1], hi[1]) ||\n fOutside(p[2], lo[2], hi[2]) ||\n fOutside(p[3], lo[3], hi[3])\n );\n}\n\nbool mOutside(mat4 p, mat4 lo, mat4 hi) {\n return (\n vOutside(p[0], lo[0], hi[0]) ||\n vOutside(p[1], lo[1], hi[1]) ||\n vOutside(p[2], lo[2], hi[2]) ||\n vOutside(p[3], lo[3], hi[3])\n );\n}\n\nbool outsideBoundingBox(mat4 A, mat4 B, mat4 C, mat4 D) {\n return mOutside(A, loA, hiA) ||\n mOutside(B, loB, hiB) ||\n mOutside(C, loC, hiC) ||\n mOutside(D, loD, hiD);\n}\n\nbool outsideRasterMask(mat4 A, mat4 B, mat4 C, mat4 D) {\n mat4 pnts[4];\n pnts[0] = A;\n pnts[1] = B;\n pnts[2] = C;\n pnts[3] = D;\n\n for(int i = 0; i < 4; ++i) {\n for(int j = 0; j < 4; ++j) {\n for(int k = 0; k < 4; ++k) {\n if(0 == iMod(\n int(255.0 * texture2D(mask,\n vec2(\n (float(i * 2 + j / 2) + 0.5) / 8.0,\n (pnts[i][j][k] * (maskHeight - 1.0) + 1.0) / maskHeight\n ))[3]\n ) / int(pow(2.0, float(iMod(j * 4 + k, 8)))),\n 2\n )) return true;\n }\n }\n }\n return false;\n}\n\nvec4 position(bool isContext, float v, mat4 A, mat4 B, mat4 C, mat4 D) {\n float x = 0.5 * sign(v) + 0.5;\n float y = axisY(x, A, B, C, D);\n float z = 1.0 - abs(v);\n\n z += isContext ? 0.0 : 2.0 * float(\n outsideBoundingBox(A, B, C, D) ||\n outsideRasterMask(A, B, C, D)\n );\n\n return vec4(\n 2.0 * (vec2(x, y) * viewBoxSize + viewBoxPos) / resolution - 1.0,\n z,\n 1.0\n );\n}\n\nvoid main() {\n mat4 A = mat4(p01_04, p05_08, p09_12, p13_16);\n mat4 B = mat4(p17_20, p21_24, p25_28, p29_32);\n mat4 C = mat4(p33_36, p37_40, p41_44, p45_48);\n mat4 D = mat4(p49_52, p53_56, p57_60, ZEROS);\n\n float v = colors[3];\n\n gl_Position = position(isContext, v, A, B, C, D);\n\n fragColor =\n isContext ? vec4(contextColor) :\n isPick ? vec4(colors.rgb, 1.0) : texture2D(palette, vec2(abs(v), 0.5));\n}\n"]),a=n(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}\n"]),o=t("./constants").maxDimensionCount,s=t("../../lib"),l=1e-6,c=2048,u=new Uint8Array(4),h=new Uint8Array(4),f={shape:[256,1],format:"rgba",type:"uint8",mag:"nearest",min:"nearest"};function p(t,e,r,n,i){var a=t._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,r,n,i),t.clear({color:[0,0,0,0],depth:1})}function d(t,e,r,n,i,a){var o=a.key;r.drawCompleted||(function(t){t.read({x:0,y:0,width:1,height:1,data:u})}(t),r.drawCompleted=!0),function s(l){var c=Math.min(n,i-l*n);0===l&&(window.cancelAnimationFrame(r.currentRafs[o]),delete r.currentRafs[o],p(t,a.scissorX,a.scissorY,a.scissorWidth,a.viewBoxSize[1])),r.clearOnly||(a.count=2*c,a.offset=2*l*n,e(a),l*n+c>>8*e)%256/255}function v(t,e,r){for(var n=new Array(8*e),i=0,a=0;ah&&(h=t[i].dim1.canvasX,o=i);0===s&&p(M,0,0,r.canvasWidth,r.canvasHeight);var f=function(t){var e,r,n,i=[[],[]];for(n=0;n<64;n++){var a=!t&&ni._length&&(I=I.slice(0,i._length));var T,L=i.tickvals;function S(t,e){return{val:t,text:T[e]}}function E(t,e){return t.val-e.val}if(Array.isArray(L)&&L.length){T=i.ticktext,Array.isArray(T)&&T.length?T.length>L.length?T=T.slice(0,L.length):L.length>T.length&&(L=L.slice(0,T.length)):T=L.map(n.format(i.tickformat));for(var D=1;D=r||l>=a)return;var c=t.lineLayer.readPixel(s,a-1-l),u=0!==c[3],h=u?c[2]+256*(c[1]+256*c[0]):null,f={x:s,y:l,clientX:e.clientX,clientY:e.clientY,dataIndex:t.model.key,curveNumber:h};h!==O&&(u?i.hover(f):i.unhover&&i.unhover(f),O=h)}})),P.style("opacity",(function(t){return t.pick?0:1})),u.style("background","rgba(255, 255, 255, 0)");var z=u.selectAll("."+g.cn.parcoords).data(C,h);z.exit().remove(),z.enter().append("g").classed(g.cn.parcoords,!0).style("shape-rendering","crispEdges").style("pointer-events","none"),z.attr("transform",(function(t){return"translate("+t.model.translateX+","+t.model.translateY+")"}));var R=z.selectAll("."+g.cn.parcoordsControlView).data(f,h);R.enter().append("g").classed(g.cn.parcoordsControlView,!0),R.attr("transform",(function(t){return"translate("+t.model.pad.l+","+t.model.pad.t+")"}));var F=R.selectAll("."+g.cn.yAxis).data((function(t){return t.dimensions}),h);F.enter().append("g").classed(g.cn.yAxis,!0),R.each((function(t){S(F,t)})),P.each((function(t){if(t.viewModel){!t.lineLayer||i?t.lineLayer=v(this,t):t.lineLayer.update(t),(t.key||0===t.key)&&(t.viewModel[t.key]=t.lineLayer);var e=!t.context||i;t.lineLayer.render(t.viewModel.panels,e)}})),F.attr("transform",(function(t){return"translate("+t.xScale(t.xIndex)+", 0)"})),F.call(n.behavior.drag().origin((function(t){return t})).on("drag",(function(t){var e=t.parent;A.linePickActive(!1),t.x=Math.max(-g.overdrag,Math.min(t.model.width+g.overdrag,n.event.x)),t.canvasX=t.x*t.model.canvasPixelRatio,F.sort((function(t,e){return t.x-e.x})).each((function(e,r){e.xIndex=r,e.x=t===e?e.x:e.xScale(e.xIndex),e.canvasX=e.x*e.model.canvasPixelRatio})),S(F,e),F.filter((function(e){return 0!==Math.abs(t.xIndex-e.xIndex)})).attr("transform",(function(t){return"translate("+t.xScale(t.xIndex)+", 0)"})),n.select(this).attr("transform","translate("+t.x+", 0)"),F.each((function(r,n,i){i===t.parent.key&&(e.dimensions[n]=r)})),e.contextLayer&&e.contextLayer.render(e.panels,!1,!M(e)),e.focusLayer.render&&e.focusLayer.render(e.panels)})).on("dragend",(function(t){var e=t.parent;t.x=t.xScale(t.xIndex),t.canvasX=t.x*t.model.canvasPixelRatio,S(F,e),n.select(this).attr("transform",(function(t){return"translate("+t.x+", 0)"})),e.contextLayer&&e.contextLayer.render(e.panels,!1,!M(e)),e.focusLayer&&e.focusLayer.render(e.panels),e.pickLayer&&e.pickLayer.render(e.panels,!0),A.linePickActive(!0),i&&i.axesMoved&&i.axesMoved(e.key,e.dimensions.map((function(t){return t.crossfilterDimensionIndex})))}))),F.exit().remove();var N=F.selectAll("."+g.cn.axisOverlays).data(f,h);N.enter().append("g").classed(g.cn.axisOverlays,!0),N.selectAll("."+g.cn.axis).remove();var j=N.selectAll("."+g.cn.axis).data(f,h);j.enter().append("g").classed(g.cn.axis,!0),j.each((function(t){var e=t.model.height/t.model.tickDistance,r=t.domainScale,i=r.domain();n.select(this).call(n.svg.axis().orient("left").tickSize(4).outerTickSize(2).ticks(e,t.tickFormat).tickValues(t.ordinal?i:null).tickFormat((function(e){return d.isOrdinal(t)?e:E(t.model.dimensions[t.visibleIndex],e)})).scale(r)),l.font(j.selectAll("text"),t.model.tickFont)})),j.selectAll(".domain, .tick>line").attr("fill","none").attr("stroke","black").attr("stroke-opacity",.25).attr("stroke-width","1px"),j.selectAll("text").style("text-shadow","1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff").style("cursor","default").style("user-select","none");var B=N.selectAll("."+g.cn.axisHeading).data(f,h);B.enter().append("g").classed(g.cn.axisHeading,!0);var Y=B.selectAll("."+g.cn.axisTitle).data(f,h);Y.enter().append("text").classed(g.cn.axisTitle,!0).attr("text-anchor","middle").style("cursor","ew-resize").style("user-select","none").style("pointer-events","auto"),Y.text((function(t){return t.label})).each((function(e){var r=n.select(this);l.font(r,e.model.labelFont),s.convertToTspans(r,t)})).attr("transform",(function(t){var e=L(t.model.labelAngle,t.model.labelSide),r=g.axisTitleOffset;return(e.dir>0?"":"translate(0,"+(2*r+t.model.height)+")")+"rotate("+e.degrees+")translate("+-r*e.dx+","+-r*e.dy+")"})).attr("text-anchor",(function(t){var e=L(t.model.labelAngle,t.model.labelSide);return 2*Math.abs(e.dx)>Math.abs(e.dy)?e.dir*e.dx<0?"start":"end":"middle"}));var V=N.selectAll("."+g.cn.axisExtent).data(f,h);V.enter().append("g").classed(g.cn.axisExtent,!0);var U=V.selectAll("."+g.cn.axisExtentTop).data(f,h);U.enter().append("g").classed(g.cn.axisExtentTop,!0),U.attr("transform","translate(0,"+-g.axisExtentOffset+")");var H=U.selectAll("."+g.cn.axisExtentTopText).data(f,h);H.enter().append("text").classed(g.cn.axisExtentTopText,!0).call(T),H.text((function(t){return D(t,!0)})).each((function(t){l.font(n.select(this),t.model.rangeFont)}));var G=V.selectAll("."+g.cn.axisExtentBottom).data(f,h);G.enter().append("g").classed(g.cn.axisExtentBottom,!0),G.attr("transform",(function(t){return"translate(0,"+(t.model.height+g.axisExtentOffset)+")"}));var q=G.selectAll("."+g.cn.axisExtentBottomText).data(f,h);q.enter().append("text").classed(g.cn.axisExtentBottomText,!0).attr("dy","0.75em").call(T),q.text((function(t){return D(t,!1)})).each((function(t){l.font(n.select(this),t.model.rangeFont)})),m.ensureAxisBrush(N)}},{"../../components/colorscale":604,"../../components/drawing":613,"../../lib":717,"../../lib/gup":715,"../../lib/svg_text_utils":741,"../../plots/cartesian/axes":765,"./axisbrush":1083,"./constants":1086,"./helpers":1088,"./lines":1090,"color-rgba":124,d3:165}],1093:[function(t,e,r){"use strict";var n=t("./parcoords"),i=t("../../lib/prepare_regl"),a=t("./helpers").isVisible;function o(t,e,r){var n=e.indexOf(r),i=t.indexOf(n);return-1===i&&(i+=e.length),i}e.exports=function(t,e){var r=t._fullLayout;if(i(t)){var s={},l={},c={},u={},h=r._size;e.forEach((function(e,r){var n=e[0].trace;c[r]=n.index;var i=u[r]=n._fullInput.index;s[r]=t.data[i].dimensions,l[r]=t.data[i].dimensions.slice()})),n(t,e,{width:h.w,height:h.h,margin:{t:h.t,r:h.r,b:h.b,l:h.l}},{filterChanged:function(e,n,i){var a=l[e][n],o=i.map((function(t){return t.slice()})),s="dimensions["+n+"].constraintrange",h=r._tracePreGUI[t._fullData[c[e]]._fullInput.uid];if(void 0===h[s]){var f=a.constraintrange;h[s]=f||null}var p=t._fullData[c[e]].dimensions[n];o.length?(1===o.length&&(o=o[0]),a.constraintrange=o,p.constraintrange=o.slice(),o=[o]):(delete a.constraintrange,delete p.constraintrange,o=null);var d={};d[s]=o,t.emit("plotly_restyle",[d,[u[e]]])},hover:function(e){t.emit("plotly_hover",e)},unhover:function(e){t.emit("plotly_unhover",e)},axesMoved:function(e,r){var n=function(t,e){return function(r,n){return o(t,e,r)-o(t,e,n)}}(r,l[e].filter(a));s[e].sort(n),l[e].filter((function(t){return!a(t)})).sort((function(t){return l[e].indexOf(t)})).forEach((function(t){s[e].splice(s[e].indexOf(t),1),s[e].splice(l[e].indexOf(t),0,t)})),t.emit("plotly_restyle",[{dimensions:[s[e]]},[u[e]]])}})}}},{"../../lib/prepare_regl":730,"./helpers":1088,"./parcoords":1092}],1094:[function(t,e,r){"use strict";var n=t("../../plots/attributes"),i=t("../../plots/domain").attributes,a=t("../../plots/font_attributes"),o=t("../../components/color/attributes"),s=t("../../plots/template_attributes").hovertemplateAttrs,l=t("../../plots/template_attributes").texttemplateAttrs,c=t("../../lib/extend").extendFlat,u=a({editType:"plot",arrayOk:!0,colorEditType:"plot"});e.exports={labels:{valType:"data_array",editType:"calc"},label0:{valType:"number",dflt:0,editType:"calc"},dlabel:{valType:"number",dflt:1,editType:"calc"},values:{valType:"data_array",editType:"calc"},marker:{colors:{valType:"data_array",editType:"calc"},line:{color:{valType:"color",dflt:o.defaultLine,arrayOk:!0,editType:"style"},width:{valType:"number",min:0,dflt:0,arrayOk:!0,editType:"style"},editType:"calc"},editType:"calc"},text:{valType:"data_array",editType:"plot"},hovertext:{valType:"string",dflt:"",arrayOk:!0,editType:"style"},scalegroup:{valType:"string",dflt:"",editType:"calc"},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"],editType:"calc"},hoverinfo:c({},n.hoverinfo,{flags:["label","text","value","percent","name"]}),hovertemplate:s({},{keys:["label","color","value","percent","text"]}),texttemplate:l({editType:"plot"},{keys:["label","color","value","percent","text"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0,editType:"plot"},textfont:c({},u,{}),insidetextorientation:{valType:"enumerated",values:["horizontal","radial","tangential","auto"],dflt:"auto",editType:"plot"},insidetextfont:c({},u,{}),outsidetextfont:c({},u,{}),automargin:{valType:"boolean",dflt:!1,editType:"plot"},title:{text:{valType:"string",dflt:"",editType:"plot"},font:c({},u,{}),position:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"plot"},editType:"plot"},domain:i({name:"pie",trace:!0,editType:"calc"}),hole:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},sort:{valType:"boolean",dflt:!0,editType:"calc"},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise",editType:"calc"},rotation:{valType:"number",min:-360,max:360,dflt:0,editType:"calc"},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0,editType:"calc"},_deprecated:{title:{valType:"string",dflt:"",editType:"calc"},titlefont:c({},u,{}),titleposition:{valType:"enumerated",values:["top left","top center","top right","middle center","bottom left","bottom center","bottom right"],editType:"calc"}}}},{"../../components/color/attributes":591,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/domain":790,"../../plots/font_attributes":791,"../../plots/template_attributes":841}],1095:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.name="pie",r.plot=function(t,e,i,a){n.plotBasePlot(r.name,t,e,i,a)},r.clean=function(t,e,i,a){n.cleanBasePlot(r.name,t,e,i,a)}},{"../../plots/plots":826}],1096:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("../../components/color"),o={};function s(t){return function(e,r){return!!e&&!!(e=i(e)).isValid()&&(e=a.addOpacity(e,e.getAlpha()),t[r]||(t[r]=e),e)}}function l(t,e){var r,n=JSON.stringify(t),a=e[n];if(!a){for(a=t.slice(),r=0;r0){s=!0;break}}s||(o=0)}return{hasLabels:r,hasValues:a,len:o}}e.exports={handleLabelsAndValues:l,supplyDefaults:function(t,e,r,n){function c(r,n){return i.coerce(t,e,a,r,n)}var u=l(c("labels"),c("values")),h=u.len;if(e._hasLabels=u.hasLabels,e._hasValues=u.hasValues,!e._hasLabels&&e._hasValues&&(c("label0"),c("dlabel")),h){e._length=h,c("marker.line.width")&&c("marker.line.color"),c("marker.colors"),c("scalegroup");var f,p=c("text"),d=c("texttemplate");if(d||(f=c("textinfo",Array.isArray(p)?"text+percent":"percent")),c("hovertext"),c("hovertemplate"),d||f&&"none"!==f){var g=c("textposition");s(t,e,n,c,g,{moduleHasSelected:!1,moduleHasUnselected:!1,moduleHasConstrain:!1,moduleHasCliponaxis:!1,moduleHasTextangle:!1,moduleHasInsideanchor:!1}),(Array.isArray(g)||"auto"===g||"outside"===g)&&c("automargin"),("inside"===g||"auto"===g||Array.isArray(g))&&c("insidetextorientation")}o(e,n,c);var m=c("hole");if(c("title.text")){var v=c("title.position",m?"middle center":"top center");m||"middle center"!==v||(e.title.position="top center"),i.coerceFont(c,"title.font",n.font)}c("sort"),c("direction"),c("rotation"),c("pull")}else e.visible=!1}}},{"../../lib":717,"../../plots/domain":790,"../bar/defaults":860,"./attributes":1094,"fast-isnumeric":228}],1098:[function(t,e,r){"use strict";var n=t("../../components/fx/helpers").appendArrayMultiPointValues;e.exports=function(t,e){var r={curveNumber:e.index,pointNumbers:t.pts,data:e._input,fullData:e,label:t.label,color:t.color,value:t.v,percent:t.percent,text:t.text,v:t.v};return 1===t.pts.length&&(r.pointNumber=r.i=t.pts[0]),n(r,e,t.pts),"funnelarea"===e.type&&(delete r.v,delete r.i),r}},{"../../components/fx/helpers":627}],1099:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)},r.getFirstFilled=function(t,e){if(Array.isArray(t))for(var r=0;r"),name:u.hovertemplate||-1!==h.indexOf("name")?u.name:void 0,idealAlign:t.pxmid[0]<0?"left":"right",color:p.castOption(b.bgcolor,t.pts)||t.color,borderColor:p.castOption(b.bordercolor,t.pts),fontFamily:p.castOption(_.family,t.pts),fontSize:p.castOption(_.size,t.pts),fontColor:p.castOption(_.color,t.pts),nameLength:p.castOption(b.namelength,t.pts),textAlign:p.castOption(b.align,t.pts),hovertemplate:p.castOption(u.hovertemplate,t.pts),hovertemplateLabels:t,eventData:[d(t,u)]},{container:r._hoverlayer.node(),outerContainer:r._paper.node(),gd:e}),o._hasHoverLabel=!0}o._hasHoverEvent=!0,e.emit("plotly_hover",{points:[d(t,u)],event:n.event})}})),t.on("mouseout",(function(t){var r=e._fullLayout,i=e._fullData[o.index],s=n.select(this).datum();o._hasHoverEvent&&(t.originalEvent=n.event,e.emit("plotly_unhover",{points:[d(s,i)],event:n.event}),o._hasHoverEvent=!1),o._hasHoverLabel&&(a.loneUnhover(r._hoverlayer.node()),o._hasHoverLabel=!1)})),t.on("click",(function(t){var r=e._fullLayout,i=e._fullData[o.index];e._dragging||!1===r.hovermode||(e._hoverdata=[d(t,i)],a.click(e,n.event))}))}function v(t,e,r){var n=p.castOption(t.insidetextfont.color,e.pts);!n&&t._input.textfont&&(n=p.castOption(t._input.textfont.color,e.pts));var i=p.castOption(t.insidetextfont.family,e.pts)||p.castOption(t.textfont.family,e.pts)||r.family,a=p.castOption(t.insidetextfont.size,e.pts)||p.castOption(t.textfont.size,e.pts)||r.size;return{color:n||o.contrast(e.color),family:i,size:a}}function y(t,e){for(var r,n,i=0;ie&&e>n||r=-4;v-=2)y(Math.PI*v,"tan");for(v=4;v>=-4;v-=2)y(Math.PI*(v+1),"tan")}if(h||p){for(v=4;v>=-4;v-=2)y(Math.PI*(v+1.5),"rad");for(v=4;v>=-4;v-=2)y(Math.PI*(v+.5),"rad")}}if(g||d||h){if((n={scale:l*c*2/i,rCenter:1-l,rotate:0}).textPosAngle=(e.startangle+e.stopangle)/2,n.scale>=1)return n;m.push(n)}(d||p)&&((n=b(t,c,s,a,o)).textPosAngle=(e.startangle+e.stopangle)/2,m.push(n)),(d||f)&&((n=_(t,c,s,a,o)).textPosAngle=(e.startangle+e.stopangle)/2,m.push(n));for(var x=0,w=0,A=0;A=1)break}return m[x]}function b(t,e,r,n,i){var a=t.width/t.height,o=C(a,n,e,r);return{scale:2*o/t.height,rCenter:w(a,o/e),rotate:A(i)}}function _(t,e,r,n,i){var a=t.height/t.width,o=C(a,n,e,r);return{scale:2*o/t.width,rCenter:w(a,o/e),rotate:A(i+Math.PI/2)}}function w(t,e){return Math.cos(e)-t*e}function A(t){return(180/Math.PI*t+720)%180-90}function C(t,e,r,n){var i=t+1/(2*Math.tan(e));return r*Math.min(1/(Math.sqrt(i*i+.5)+i),n/(Math.sqrt(t*t+n/2)+t))}function M(t,e){return t.v!==e.vTotal||e.trace.hole?Math.min(1/(1+1/Math.sin(t.halfangle)),t.ring/2):1}function k(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return r<0&&(i*=-1),n<0&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function I(t,e){var r,n,i,a=t.trace,o={x:t.cx,y:t.cy},s={tx:0,ty:0};s.ty+=a.title.font.size,i=L(a),-1!==a.title.position.indexOf("top")?(o.y-=(1+i)*t.r,s.ty-=t.titleBox.height):-1!==a.title.position.indexOf("bottom")&&(o.y+=(1+i)*t.r);var l,c,u=(l=t.r,c=t.trace.aspectratio,l/(void 0===c?1:c)),h=e.w*(a.domain.x[1]-a.domain.x[0])/2;return-1!==a.title.position.indexOf("left")?(h+=u,o.x-=(1+i)*u,s.tx+=t.titleBox.width/2):-1!==a.title.position.indexOf("center")?h*=2:-1!==a.title.position.indexOf("right")&&(h+=u,o.x+=(1+i)*u,s.tx-=t.titleBox.width/2),r=h/t.titleBox.width,n=T(t,e)/t.titleBox.height,{x:o.x,y:o.y,scale:Math.min(r,n),tx:s.tx,ty:s.ty}}function T(t,e){var r=t.trace,n=e.h*(r.domain.y[1]-r.domain.y[0]);return Math.min(t.titleBox.height,n/2)}function L(t){var e,r=t.pull;if(!r)return 0;if(Array.isArray(r))for(r=0,e=0;er&&(r=t.pull[e]);return r}function S(t,e){for(var r=[],n=0;n1?(c=r.r,u=c/i.aspectratio):(u=r.r,c=u*i.aspectratio),c*=(1+i.baseratio)/2,l=c*u}o=Math.min(o,l/r.vTotal)}for(n=0;n")}if(a){var x=l.castOption(i,e.i,"texttemplate");if(x){var b=function(t){return{label:t.label,value:t.v,valueLabel:p.formatPieValue(t.v,n.separators),percent:t.v/r.vTotal,percentLabel:p.formatPiePercent(t.v/r.vTotal,n.separators),color:t.color,text:t.text,customdata:l.castOption(i,t.i,"customdata")}}(e),_=p.getFirstFilled(i.text,e.pts);(g(_)||""===_)&&(b.text=_),e.text=l.texttemplateString(x,b,t._fullLayout._d3locale,b,i._meta||{})}else e.text=""}}function P(t,e){var r=t.rotate,n=t.scale;n>1&&(n=1);var i=r*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=(e.left+e.right)/2,l=(e.top+e.bottom)/2;t.textX=s*a-l*o,t.textY=s*o+l*a,t.noCenter=!0}e.exports={plot:function(t,e){var r=t._fullLayout,a=r._size;f("pie",r),y(e,t),S(e,a);var u=l.makeTraceGroups(r._pielayer,e,"trace").each((function(e){var u=n.select(this),f=e[0],d=f.trace;!function(t){var e,r,n,i=t[0],a=i.r,o=i.trace,s=o.rotation*Math.PI/180,l=2*Math.PI/i.vTotal,c="px0",u="px1";if("counterclockwise"===o.direction){for(e=0;ei.vTotal/2?1:0,r.halfangle=Math.PI*Math.min(r.v/i.vTotal,.5),r.ring=1-o.hole,r.rInscribed=M(r,i))}(e),u.attr("stroke-linejoin","round"),u.each((function(){var g=n.select(this).selectAll("g.slice").data(e);g.enter().append("g").classed("slice",!0),g.exit().remove();var y=[[[],[]],[[],[]]],b=!1;g.each((function(i,a){if(i.hidden)n.select(this).selectAll("path,g").remove();else{i.pointNumber=i.i,i.curveNumber=d.index,y[i.pxmid[1]<0?0:1][i.pxmid[0]<0?0:1].push(i);var o=f.cx,u=f.cy,g=n.select(this),_=g.selectAll("path.surface").data([i]);if(_.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),g.call(m,t,e),d.pull){var w=+p.castOption(d.pull,i.pts)||0;w>0&&(o+=w*i.pxmid[0],u+=w*i.pxmid[1])}i.cxFinal=o,i.cyFinal=u;var A=d.hole;if(i.v===f.vTotal){var C="M"+(o+i.px0[0])+","+(u+i.px0[1])+S(i.px0,i.pxmid,!0,1)+S(i.pxmid,i.px0,!0,1)+"Z";A?_.attr("d","M"+(o+A*i.px0[0])+","+(u+A*i.px0[1])+S(i.px0,i.pxmid,!1,A)+S(i.pxmid,i.px0,!1,A)+"Z"+C):_.attr("d",C)}else{var M=S(i.px0,i.px1,!0,1);if(A){var I=1-A;_.attr("d","M"+(o+A*i.px1[0])+","+(u+A*i.px1[1])+S(i.px1,i.px0,!1,A)+"l"+I*i.px0[0]+","+I*i.px0[1]+M+"Z")}else _.attr("d","M"+o+","+u+"l"+i.px0[0]+","+i.px0[1]+M+"Z")}D(t,i,f);var T=p.castOption(d.textposition,i.pts),L=g.selectAll("g.slicetext").data(i.text&&"none"!==T?[0]:[]);L.enter().append("g").classed("slicetext",!0),L.exit().remove(),L.each((function(){var g=l.ensureSingle(n.select(this),"text","",(function(t){t.attr("data-notex",1)})),m=l.ensureUniformFontSize(t,"outside"===T?function(t,e,r){var n=p.castOption(t.outsidetextfont.color,e.pts)||p.castOption(t.textfont.color,e.pts)||r.color,i=p.castOption(t.outsidetextfont.family,e.pts)||p.castOption(t.textfont.family,e.pts)||r.family,a=p.castOption(t.outsidetextfont.size,e.pts)||p.castOption(t.textfont.size,e.pts)||r.size;return{color:n,family:i,size:a}}(d,i,r.font):v(d,i,r.font));g.text(i.text).attr({class:"slicetext",transform:"","text-anchor":"middle"}).call(s.font,m).call(c.convertToTspans,t);var y,_=s.bBox(g.node());if("outside"===T)y=k(_,i);else if(y=x(_,i,f),"auto"===T&&y.scale<1){var w=l.ensureUniformFontSize(t,d.outsidetextfont);g.call(s.font,w),y=k(_=s.bBox(g.node()),i)}var A=y.textPosAngle,C=void 0===A?i.pxmid:E(f.r,A);if(y.targetX=o+C[0]*y.rCenter+(y.x||0),y.targetY=u+C[1]*y.rCenter+(y.y||0),P(y,_),y.outside){var M=y.targetY;i.yLabelMin=M-_.height/2,i.yLabelMid=M,i.yLabelMax=M+_.height/2,i.labelExtraX=0,i.labelExtraY=0,b=!0}y.fontSize=m.size,h(d.type,y,r),e[a].transform=y,g.attr("transform",l.getTextTransform(y))}))}function S(t,e,r,n){var a=n*(e[0]-t[0]),o=n*(e[1]-t[1]);return"a"+n*f.r+","+n*f.r+" 0 "+i.largeArc+(r?" 1 ":" 0 ")+a+","+o}}));var _=n.select(this).selectAll("g.titletext").data(d.title.text?[0]:[]);if(_.enter().append("g").classed("titletext",!0),_.exit().remove(),_.each((function(){var e,r=l.ensureSingle(n.select(this),"text","",(function(t){t.attr("data-notex",1)})),i=d.title.text;d._meta&&(i=l.templateString(i,d._meta)),r.text(i).attr({class:"titletext",transform:"","text-anchor":"middle"}).call(s.font,d.title.font).call(c.convertToTspans,t),e="middle center"===d.title.position?function(t){var e=Math.sqrt(t.titleBox.width*t.titleBox.width+t.titleBox.height*t.titleBox.height);return{x:t.cx,y:t.cy,scale:t.trace.hole*t.r*2/e,tx:0,ty:-t.titleBox.height/2+t.trace.title.font.size}}(f):I(f,a),r.attr("transform","translate("+e.x+","+e.y+")"+(e.scale<1?"scale("+e.scale+")":"")+"translate("+e.tx+","+e.ty+")")})),b&&function(t,e){var r,n,i,a,o,s,l,c,u,h,f,d,g;function m(t,e){return t.pxmid[1]-e.pxmid[1]}function v(t,e){return e.pxmid[1]-t.pxmid[1]}function y(t,r){r||(r={});var i,c,u,f,d=r.labelExtraY+(n?r.yLabelMax:r.yLabelMin),g=n?t.yLabelMin:t.yLabelMax,m=n?t.yLabelMax:t.yLabelMin,v=t.cyFinal+o(t.px0[1],t.px1[1]),y=d-g;if(y*l>0&&(t.labelExtraY=y),Array.isArray(e.pull))for(c=0;c=(p.castOption(e.pull,u.pts)||0)||((t.pxmid[1]-u.pxmid[1])*l>0?(y=u.cyFinal+o(u.px0[1],u.px1[1])-g-t.labelExtraY)*l>0&&(t.labelExtraY+=y):(m+t.labelExtraY-v)*l>0&&(i=3*s*Math.abs(c-h.indexOf(t)),(f=u.cxFinal+a(u.px0[0],u.px1[0])+i-(t.cxFinal+t.pxmid[0])-t.labelExtraX)*s>0&&(t.labelExtraX+=f)))}for(n=0;n<2;n++)for(i=n?m:v,o=n?Math.max:Math.min,l=n?1:-1,r=0;r<2;r++){for(a=r?Math.max:Math.min,s=r?1:-1,(c=t[n][r]).sort(i),u=t[1-n][r],h=u.concat(c),d=[],f=0;fMath.abs(h)?s+="l"+h*t.pxmid[0]/t.pxmid[1]+","+h+"H"+(a+t.labelExtraX+c):s+="l"+t.labelExtraX+","+u+"v"+(h-u)+"h"+c}else s+="V"+(t.yLabelMid+t.labelExtraY)+"h"+c;l.ensureSingle(r,"path","textline").call(o.stroke,e.outsidetextfont.color).attr({"stroke-width":Math.min(2,e.outsidetextfont.size/8),d:s,fill:"none"})}else r.select("path.textline").remove()}))}(g,d),b&&d.automargin){var w=s.bBox(u.node()),A=d.domain,C=a.w*(A.x[1]-A.x[0]),M=a.h*(A.y[1]-A.y[0]),T=(.5*C-f.r)/a.w,L=(.5*M-f.r)/a.h;i.autoMargin(t,"pie."+d.uid+".automargin",{xl:A.x[0]-T,xr:A.x[1]+T,yb:A.y[0]-L,yt:A.y[1]+L,l:Math.max(f.cx-f.r-w.left,0),r:Math.max(w.right-(f.cx+f.r),0),b:Math.max(w.bottom-(f.cy+f.r),0),t:Math.max(f.cy-f.r-w.top,0),pad:5})}}))}));setTimeout((function(){u.selectAll("tspan").each((function(){var t=n.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))}))}),0)},formatSliceLabel:D,transformInsideText:x,determineInsideTextFont:v,positionTitleOutside:I,prerenderTitles:y,layoutAreas:S,attachFxHandlers:m,computeTransform:P}},{"../../components/color":592,"../../components/drawing":613,"../../components/fx":630,"../../lib":717,"../../lib/svg_text_utils":741,"../../plots/plots":826,"../bar/uniform_text":872,"./event_data":1098,"./helpers":1099,d3:165}],1104:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one"),a=t("../bar/uniform_text").resizeText;e.exports=function(t){var e=t._fullLayout._pielayer.selectAll(".trace");a(t,e,"pie"),e.each((function(t){var e=t[0].trace,r=n.select(this);r.style({opacity:e.opacity}),r.selectAll("path.surface").each((function(t){n.select(this).call(i,t,e)}))}))}},{"../bar/uniform_text":872,"./style_one":1105,d3:165}],1105:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("./helpers").castOption;e.exports=function(t,e,r){var a=r.marker.line,o=i(a.color,e.pts)||n.defaultLine,s=i(a.width,e.pts)||0;t.style("stroke-width",s).call(n.fill,e.color).call(n.stroke,o)}},{"../../components/color":592,"./helpers":1099}],1106:[function(t,e,r){"use strict";var n=t("../scatter/attributes");e.exports={x:n.x,y:n.y,xy:{valType:"data_array",editType:"calc"},indices:{valType:"data_array",editType:"calc"},xbounds:{valType:"data_array",editType:"calc"},ybounds:{valType:"data_array",editType:"calc"},text:n.text,marker:{color:{valType:"color",arrayOk:!1,editType:"calc"},opacity:{valType:"number",min:0,max:1,dflt:1,arrayOk:!1,editType:"calc"},blend:{valType:"boolean",dflt:null,editType:"calc"},sizemin:{valType:"number",min:.1,max:2,dflt:.5,editType:"calc"},sizemax:{valType:"number",min:.1,dflt:20,editType:"calc"},border:{color:{valType:"color",arrayOk:!1,editType:"calc"},arearatio:{valType:"number",min:0,max:1,dflt:0,editType:"calc"},editType:"calc"},editType:"calc"},transforms:void 0}},{"../scatter/attributes":1120}],1107:[function(t,e,r){"use strict";var n=t("gl-pointcloud2d"),i=t("../../lib/str2rgbarray"),a=t("../../plots/cartesian/autorange").findExtremes,o=t("../scatter/get_trace_color");function s(t,e){this.scene=t,this.uid=e,this.type="pointcloud",this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=new Int32Array(0),this.bounds=[0,0,0,0],this.pointcloudOptions={positions:new Float32Array(0),idToIndex:this.idToIndex,sizemin:.5,sizemax:12,color:[0,0,0,1],areaRatio:1,borderColor:[0,0,0,1]},this.pointcloud=n(t.glplot,this.pointcloudOptions),this.pointcloud._trace=this}var l=s.prototype;l.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:this.pickXYData?[this.pickXYData[2*e],this.pickXYData[2*e+1]]:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:this.color,name:this.name,pointIndex:e,hoverinfo:this.hoverinfo}},l.update=function(t){this.index=t.index,this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-1/0,-1/0],this.updateFast(t),this.color=o(t,{})},l.updateFast=function(t){var e,r,n,o,s,l,c=this.xData=this.pickXData=t.x,u=this.yData=this.pickYData=t.y,h=this.pickXYData=t.xy,f=t.xbounds&&t.ybounds,p=t.indices,d=this.bounds;if(h){if(n=h,e=h.length>>>1,f)d[0]=t.xbounds[0],d[2]=t.xbounds[1],d[1]=t.ybounds[0],d[3]=t.ybounds[1];else for(l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);if(p)r=p;else for(r=new Int32Array(e),l=0;ld[2]&&(d[2]=o),sd[3]&&(d[3]=s);this.idToIndex=r,this.pointcloudOptions.idToIndex=r,this.pointcloudOptions.positions=n;var g=i(t.marker.color),m=i(t.marker.border.color),v=t.opacity*t.marker.opacity;g[3]*=v,this.pointcloudOptions.color=g;var y=t.marker.blend;null===y&&(y=c.length<100||u.length<100),this.pointcloudOptions.blend=y,m[3]*=v,this.pointcloudOptions.borderColor=m;var x=t.marker.sizemin,b=Math.max(t.marker.sizemax,t.marker.sizemin);this.pointcloudOptions.sizeMin=x,this.pointcloudOptions.sizeMax=b,this.pointcloudOptions.areaRatio=t.marker.border.arearatio,this.pointcloud.update(this.pointcloudOptions);var _=this.scene.xaxis,w=this.scene.yaxis,A=b/2||.5;t._extremes[_._id]=a(_,[d[0],d[2]],{ppad:A}),t._extremes[w._id]=a(w,[d[1],d[3]],{ppad:A})},l.dispose=function(){this.pointcloud.dispose()},e.exports=function(t,e){var r=new s(t,e.uid);return r.update(e),r}},{"../../lib/str2rgbarray":740,"../../plots/cartesian/autorange":764,"../scatter/get_trace_color":1130,"gl-pointcloud2d":295}],1108:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r){function a(r,a){return n.coerce(t,e,i,r,a)}a("x"),a("y"),a("xbounds"),a("ybounds"),t.xy&&t.xy instanceof Float32Array&&(e.xy=t.xy),t.indices&&t.indices instanceof Int32Array&&(e.indices=t.indices),a("text"),a("marker.color",r),a("marker.opacity"),a("marker.blend"),a("marker.sizemin"),a("marker.sizemax"),a("marker.border.color",r),a("marker.border.arearatio"),e._length=null}},{"../../lib":717,"./attributes":1106}],1109:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("../scatter3d/calc"),plot:t("./convert"),moduleType:"trace",name:"pointcloud",basePlotModule:t("../../plots/gl2d"),categories:["gl","gl2d","showLegend"],meta:{}}},{"../../plots/gl2d":803,"../scatter3d/calc":1148,"./attributes":1106,"./convert":1107,"./defaults":1108}],1110:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../../plots/attributes"),a=t("../../components/color/attributes"),o=t("../../components/fx/attributes"),s=t("../../plots/domain").attributes,l=t("../../plots/template_attributes").hovertemplateAttrs,c=t("../../components/colorscale/attributes"),u=t("../../plot_api/plot_template").templatedArray,h=t("../../lib/extend").extendFlat,f=t("../../plot_api/edit_types").overrideAll;t("../../constants/docs").FORMAT_LINK,(e.exports=f({hoverinfo:h({},i.hoverinfo,{flags:[],arrayOk:!1}),hoverlabel:o.hoverlabel,domain:s({name:"sankey",trace:!0}),orientation:{valType:"enumerated",values:["v","h"],dflt:"h"},valueformat:{valType:"string",dflt:".3s"},valuesuffix:{valType:"string",dflt:""},arrangement:{valType:"enumerated",values:["snap","perpendicular","freeform","fixed"],dflt:"snap"},textfont:n({}),node:{label:{valType:"data_array",dflt:[]},groups:{valType:"info_array",impliedEdits:{x:[],y:[]},dimensions:2,freeLength:!0,dflt:[],items:{valType:"number",editType:"calc"}},x:{valType:"data_array",dflt:[]},y:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:.5,arrayOk:!0}},pad:{valType:"number",arrayOk:!1,min:0,dflt:20},thickness:{valType:"number",arrayOk:!1,min:1,dflt:20},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel,hovertemplate:l({},{keys:["value","label"]})},link:{label:{valType:"data_array",dflt:[]},color:{valType:"color",arrayOk:!0},line:{color:{valType:"color",dflt:a.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}},source:{valType:"data_array",dflt:[]},target:{valType:"data_array",dflt:[]},value:{valType:"data_array",dflt:[]},hoverinfo:{valType:"enumerated",values:["all","none","skip"],dflt:"all"},hoverlabel:o.hoverlabel,hovertemplate:l({},{keys:["value","label"]}),colorscales:u("concentrationscales",{editType:"calc",label:{valType:"string",editType:"calc",dflt:""},cmax:{valType:"number",editType:"calc",dflt:1},cmin:{valType:"number",editType:"calc",dflt:0},colorscale:h(c().colorscale,{dflt:[[0,"white"],[1,"black"]]})})}},"calc","nested")).transforms=void 0},{"../../components/color/attributes":591,"../../components/colorscale/attributes":599,"../../components/fx/attributes":622,"../../constants/docs":688,"../../lib/extend":708,"../../plot_api/edit_types":748,"../../plot_api/plot_template":755,"../../plots/attributes":762,"../../plots/domain":790,"../../plots/font_attributes":791,"../../plots/template_attributes":841}],1111:[function(t,e,r){"use strict";var n=t("../../plot_api/edit_types").overrideAll,i=t("../../plots/get_data").getModuleCalcData,a=t("./plot"),o=t("../../components/fx/layout_attributes"),s=t("../../lib/setcursor"),l=t("../../components/dragelement"),c=t("../../plots/cartesian/select").prepSelect,u=t("../../lib"),h=t("../../registry");function f(t,e){var r=t._fullData[e],n=t._fullLayout,i=n.dragmode,a="pan"===n.dragmode?"move":"crosshair",o=r._bgRect;if("pan"!==i&&"zoom"!==i){s(o,a);var f={_id:"x",c2p:u.identity,_offset:r._sankey.translateX,_length:r._sankey.width},p={_id:"y",c2p:u.identity,_offset:r._sankey.translateY,_length:r._sankey.height},d={gd:t,element:o.node(),plotinfo:{id:e,xaxis:f,yaxis:p,fillRangeItems:u.noop},subplot:e,xaxes:[f],yaxes:[p],doneFnCompleted:function(r){var n,i=t._fullData[e],a=i.node.groups.slice(),o=[];function s(t){for(var e=i._sankey.graph.nodes,r=0;rv&&(v=a.source[e]),a.target[e]>v&&(v=a.target[e]);var y,x=v+1;t.node._count=x;var b=t.node.groups,_={};for(e=0;e0&&s(I,x)&&s(T,x)&&(!_.hasOwnProperty(I)||!_.hasOwnProperty(T)||_[I]!==_[T])){_.hasOwnProperty(T)&&(T=_[T]),_.hasOwnProperty(I)&&(I=_[I]),T=+T,h[I=+I]=h[T]=!0;var L="";a.label&&a.label[e]&&(L=a.label[e]);var S=null;L&&f.hasOwnProperty(L)&&(S=f[L]),c.push({pointNumber:e,label:L,color:u?a.color[e]:a.color,concentrationscale:S,source:I,target:T,value:+k}),M.source.push(I),M.target.push(T)}}var E=x+b.length,D=o(r.color),P=[];for(e=0;ex-1,childrenNodes:[],pointNumber:e,label:O,color:D?r.color[e]:r.color})}var z=!1;return function(t,e,r){for(var a=i.init2dArray(t,0),o=0;o1}))}(E,M.source,M.target)&&(z=!0),{circular:z,links:c,nodes:P,groups:b,groupLookup:_}}e.exports=function(t,e){var r=c(e);return a({circular:r.circular,_nodes:r.nodes,_links:r.links,_groups:r.groups,_groupLookup:r.groupLookup})}},{"../../components/colorscale":604,"../../lib":717,"../../lib/gup":715,"strongly-connected-components":529}],1113:[function(t,e,r){"use strict";e.exports={nodeTextOffsetHorizontal:4,nodeTextOffsetVertical:3,nodePadAcross:10,sankeyIterations:50,forceIterations:5,forceTicksPerFrame:10,duration:500,ease:"linear",cn:{sankey:"sankey",sankeyLinks:"sankey-links",sankeyLink:"sankey-link",sankeyNodeSet:"sankey-node-set",sankeyNode:"sankey-node",nodeRect:"node-rect",nodeCapture:"node-capture",nodeCentered:"node-entered",nodeLabelGuide:"node-label-guide",nodeLabel:"node-label",nodeLabelTextPath:"node-label-text-path"}}},{}],1114:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../components/color"),o=t("tinycolor2"),s=t("../../plots/domain").defaults,l=t("../../components/fx/hoverlabel_defaults"),c=t("../../plot_api/plot_template"),u=t("../../plots/array_container_defaults");function h(t,e){function r(r,a){return n.coerce(t,e,i.link.colorscales,r,a)}r("label"),r("cmin"),r("cmax"),r("colorscale")}e.exports=function(t,e,r,f){function p(r,a){return n.coerce(t,e,i,r,a)}var d=n.extendDeep(f.hoverlabel,t.hoverlabel),g=t.node,m=c.newContainer(e,"node");function v(t,e){return n.coerce(g,m,i.node,t,e)}v("label"),v("groups"),v("x"),v("y"),v("pad"),v("thickness"),v("line.color"),v("line.width"),v("hoverinfo",t.hoverinfo),l(g,m,v,d),v("hovertemplate");var y=f.colorway;v("color",m.label.map((function(t,e){return a.addOpacity(function(t){return y[t%y.length]}(e),.8)})));var x=t.link||{},b=c.newContainer(e,"link");function _(t,e){return n.coerce(x,b,i.link,t,e)}_("label"),_("source"),_("target"),_("value"),_("line.color"),_("line.width"),_("hoverinfo",t.hoverinfo),l(x,b,_,d),_("hovertemplate");var w,A=o(f.paper_bgcolor).getLuminance()<.333?"rgba(255, 255, 255, 0.6)":"rgba(0, 0, 0, 0.2)";_("color",n.repeat(A,b.value.length)),u(x,b,{name:"colorscales",handleItemDefaults:h}),s(e,f,p),p("orientation"),p("valueformat"),p("valuesuffix"),m.x.length&&m.y.length&&(w="freeform"),p("arrangement",w),n.coerceFont(p,"textfont",n.extendFlat({},f.font)),e._length=null}},{"../../components/color":592,"../../components/fx/hoverlabel_defaults":629,"../../lib":717,"../../plot_api/plot_template":755,"../../plots/array_container_defaults":761,"../../plots/domain":790,"./attributes":1110,tinycolor2:536}],1115:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),calc:t("./calc"),plot:t("./plot"),moduleType:"trace",name:"sankey",basePlotModule:t("./base_plot"),selectPoints:t("./select.js"),categories:["noOpacity"],meta:{}}},{"./attributes":1110,"./base_plot":1111,"./calc":1112,"./defaults":1114,"./plot":1116,"./select.js":1118}],1116:[function(t,e,r){"use strict";var n=t("d3"),i=t("./render"),a=t("../../components/fx"),o=t("../../components/color"),s=t("../../lib"),l=t("./constants").cn,c=s._;function u(t){return""!==t}function h(t,e){return t.filter((function(t){return t.key===e.traceId}))}function f(t,e){n.select(t).select("path").style("fill-opacity",e),n.select(t).select("rect").style("fill-opacity",e)}function p(t){n.select(t).select("text.name").style("fill","black")}function d(t){return function(e){return-1!==t.node.sourceLinks.indexOf(e.link)||-1!==t.node.targetLinks.indexOf(e.link)}}function g(t){return function(e){return-1!==e.node.sourceLinks.indexOf(t.link)||-1!==e.node.targetLinks.indexOf(t.link)}}function m(t,e,r){e&&r&&h(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(y.bind(0,e,r,!1))}function v(t,e,r){e&&r&&h(r,e).selectAll("."+l.sankeyLink).filter(d(e)).call(x.bind(0,e,r,!1))}function y(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",(function(t){if(!t.link.concentrationscale)return.4})),i&&h(e,t).selectAll("."+l.sankeyLink).filter((function(t){return t.link.label===i})).style("fill-opacity",(function(t){if(!t.link.concentrationscale)return.4})),r&&h(e,t).selectAll("."+l.sankeyNode).filter(g(t)).call(m)}function x(t,e,r,n){var i=n.datum().link.label;n.style("fill-opacity",(function(t){return t.tinyColorAlpha})),i&&h(e,t).selectAll("."+l.sankeyLink).filter((function(t){return t.link.label===i})).style("fill-opacity",(function(t){return t.tinyColorAlpha})),r&&h(e,t).selectAll(l.sankeyNode).filter(g(t)).call(v)}function b(t,e){var r=t.hoverlabel||{},n=s.nestedProperty(r,e).get();return!Array.isArray(n)&&n}e.exports=function(t,e){for(var r=t._fullLayout,s=r._paper,h=r._size,d=0;d"),color:b(s,"bgcolor")||o.addOpacity(d.color,1),borderColor:b(s,"bordercolor"),fontFamily:b(s,"font.family"),fontSize:b(s,"font.size"),fontColor:b(s,"font.color"),nameLength:b(s,"namelength"),textAlign:b(s,"align"),idealAlign:n.event.x"),color:b(o,"bgcolor")||i.tinyColorHue,borderColor:b(o,"bordercolor"),fontFamily:b(o,"font.family"),fontSize:b(o,"font.size"),fontColor:b(o,"font.color"),nameLength:b(o,"namelength"),textAlign:b(o,"align"),idealAlign:"left",hovertemplate:o.hovertemplate,hovertemplateLabels:v,eventData:[i.node]},{container:r._hoverlayer.node(),outerContainer:r._paper.node(),gd:t});f(y,.85),p(y)}}},unhover:function(e,i,o){!1!==t._fullLayout.hovermode&&(n.select(e).call(v,i,o),"skip"!==i.node.trace.node.hoverinfo&&(i.node.fullData=i.node.trace,t.emit("plotly_unhover",{event:n.event,points:[i.node]})),a.loneUnhover(r._hoverlayer.node()))},select:function(e,r,i){var o=r.node;o.originalEvent=n.event,t._hoverdata=[o],n.select(e).call(v,r,i),a.click(t,{target:!0})}}})}},{"../../components/color":592,"../../components/fx":630,"../../lib":717,"./constants":1113,"./render":1117,d3:165}],1117:[function(t,e,r){"use strict";var n=t("./constants"),i=t("d3"),a=t("tinycolor2"),o=t("../../components/color"),s=t("../../components/drawing"),l=t("@plotly/d3-sankey"),c=t("@plotly/d3-sankey-circular"),u=t("d3-force"),h=t("../../lib"),f=t("../../lib/gup"),p=f.keyFun,d=f.repeat,g=f.unwrap,m=t("d3-interpolate").interpolateNumber,v=t("../../registry");function y(t,e,r){var i,o=g(e),s=o.trace,u=s.domain,f="h"===s.orientation,p=s.node.pad,d=s.node.thickness,m=t.width*(u.x[1]-u.x[0]),v=t.height*(u.y[1]-u.y[0]),y=o._nodes,x=o._links,b=o.circular;(i=b?c.sankeyCircular().circularLinkGap(0):l.sankey()).iterations(n.sankeyIterations).size(f?[m,v]:[v,m]).nodeWidth(d).nodePadding(p).nodeId((function(t){return t.pointNumber})).nodes(y).links(x);var _,w,A,C=i();for(var M in i.nodePadding()=i||(r=i-e.y0)>1e-6&&(e.y0+=r,e.y1+=r),i=e.y1+p}))}(function(t){var e,r,n=t.map((function(t,e){return{x0:t.x0,index:e}})).sort((function(t,e){return t.x0-e.x0})),i=[],a=-1,o=-1/0;for(_=0;_o+d&&(a+=1,e=s.x0),o=s.x0,i[a]||(i[a]=[]),i[a].push(s),r=e-s.x0,s.x0+=r,s.x1+=r}return i}(y=C.nodes)),i.update(C)}return{circular:b,key:r,trace:s,guid:h.randstr(),horizontal:f,width:m,height:v,nodePad:s.node.pad,nodeLineColor:s.node.line.color,nodeLineWidth:s.node.line.width,linkLineColor:s.link.line.color,linkLineWidth:s.link.line.width,valueFormat:s.valueformat,valueSuffix:s.valuesuffix,textFont:s.textfont,translateX:u.x[0]*t.width+t.margin.l,translateY:t.height-u.y[1]*t.height+t.margin.t,dragParallel:f?v:m,dragPerpendicular:f?m:v,arrangement:s.arrangement,sankey:i,graph:C,forceLayouts:{},interactionState:{dragInProgress:!1,hovered:!1}}}function x(t,e,r){var n=a(e.color),i=e.source.label+"|"+e.target.label+"__"+r;return e.trace=t.trace,e.curveNumber=t.trace.index,{circular:t.circular,key:i,traceId:t.key,pointNumber:e.pointNumber,link:e,tinyColorHue:o.tinyRGB(n),tinyColorAlpha:n.getAlpha(),linkPath:b,linkLineColor:t.linkLineColor,linkLineWidth:t.linkLineWidth,valueFormat:t.valueFormat,valueSuffix:t.valueSuffix,sankey:t.sankey,parent:t,interactionState:t.interactionState,flow:e.flow}}function b(){var t=.5;return function(e){if(e.link.circular)return r=e.link,n=r.width/2,i=r.circularPathData,"top"===r.circularLinkType?"M "+i.targetX+" "+(i.targetY+n)+" L"+i.rightInnerExtent+" "+(i.targetY+n)+"A"+(i.rightLargeArcRadius+n)+" "+(i.rightSmallArcRadius+n)+" 0 0 1 "+(i.rightFullExtent-n)+" "+(i.targetY-i.rightSmallArcRadius)+"L"+(i.rightFullExtent-n)+" "+i.verticalRightInnerExtent+"A"+(i.rightLargeArcRadius+n)+" "+(i.rightLargeArcRadius+n)+" 0 0 1 "+i.rightInnerExtent+" "+(i.verticalFullExtent-n)+"L"+i.leftInnerExtent+" "+(i.verticalFullExtent-n)+"A"+(i.leftLargeArcRadius+n)+" "+(i.leftLargeArcRadius+n)+" 0 0 1 "+(i.leftFullExtent+n)+" "+i.verticalLeftInnerExtent+"L"+(i.leftFullExtent+n)+" "+(i.sourceY-i.leftSmallArcRadius)+"A"+(i.leftLargeArcRadius+n)+" "+(i.leftSmallArcRadius+n)+" 0 0 1 "+i.leftInnerExtent+" "+(i.sourceY+n)+"L"+i.sourceX+" "+(i.sourceY+n)+"L"+i.sourceX+" "+(i.sourceY-n)+"L"+i.leftInnerExtent+" "+(i.sourceY-n)+"A"+(i.leftLargeArcRadius-n)+" "+(i.leftSmallArcRadius-n)+" 0 0 0 "+(i.leftFullExtent-n)+" "+(i.sourceY-i.leftSmallArcRadius)+"L"+(i.leftFullExtent-n)+" "+i.verticalLeftInnerExtent+"A"+(i.leftLargeArcRadius-n)+" "+(i.leftLargeArcRadius-n)+" 0 0 0 "+i.leftInnerExtent+" "+(i.verticalFullExtent+n)+"L"+i.rightInnerExtent+" "+(i.verticalFullExtent+n)+"A"+(i.rightLargeArcRadius-n)+" "+(i.rightLargeArcRadius-n)+" 0 0 0 "+(i.rightFullExtent+n)+" "+i.verticalRightInnerExtent+"L"+(i.rightFullExtent+n)+" "+(i.targetY-i.rightSmallArcRadius)+"A"+(i.rightLargeArcRadius-n)+" "+(i.rightSmallArcRadius-n)+" 0 0 0 "+i.rightInnerExtent+" "+(i.targetY-n)+"L"+i.targetX+" "+(i.targetY-n)+"Z":"M "+i.targetX+" "+(i.targetY-n)+" L"+i.rightInnerExtent+" "+(i.targetY-n)+"A"+(i.rightLargeArcRadius+n)+" "+(i.rightSmallArcRadius+n)+" 0 0 0 "+(i.rightFullExtent-n)+" "+(i.targetY+i.rightSmallArcRadius)+"L"+(i.rightFullExtent-n)+" "+i.verticalRightInnerExtent+"A"+(i.rightLargeArcRadius+n)+" "+(i.rightLargeArcRadius+n)+" 0 0 0 "+i.rightInnerExtent+" "+(i.verticalFullExtent+n)+"L"+i.leftInnerExtent+" "+(i.verticalFullExtent+n)+"A"+(i.leftLargeArcRadius+n)+" "+(i.leftLargeArcRadius+n)+" 0 0 0 "+(i.leftFullExtent+n)+" "+i.verticalLeftInnerExtent+"L"+(i.leftFullExtent+n)+" "+(i.sourceY+i.leftSmallArcRadius)+"A"+(i.leftLargeArcRadius+n)+" "+(i.leftSmallArcRadius+n)+" 0 0 0 "+i.leftInnerExtent+" "+(i.sourceY-n)+"L"+i.sourceX+" "+(i.sourceY-n)+"L"+i.sourceX+" "+(i.sourceY+n)+"L"+i.leftInnerExtent+" "+(i.sourceY+n)+"A"+(i.leftLargeArcRadius-n)+" "+(i.leftSmallArcRadius-n)+" 0 0 1 "+(i.leftFullExtent-n)+" "+(i.sourceY+i.leftSmallArcRadius)+"L"+(i.leftFullExtent-n)+" "+i.verticalLeftInnerExtent+"A"+(i.leftLargeArcRadius-n)+" "+(i.leftLargeArcRadius-n)+" 0 0 1 "+i.leftInnerExtent+" "+(i.verticalFullExtent-n)+"L"+i.rightInnerExtent+" "+(i.verticalFullExtent-n)+"A"+(i.rightLargeArcRadius-n)+" "+(i.rightLargeArcRadius-n)+" 0 0 1 "+(i.rightFullExtent+n)+" "+i.verticalRightInnerExtent+"L"+(i.rightFullExtent+n)+" "+(i.targetY+i.rightSmallArcRadius)+"A"+(i.rightLargeArcRadius-n)+" "+(i.rightSmallArcRadius-n)+" 0 0 1 "+i.rightInnerExtent+" "+(i.targetY+n)+"L"+i.targetX+" "+(i.targetY+n)+"Z";var r,n,i,a=e.link.source.x1,o=e.link.target.x0,s=m(a,o),l=s(t),c=s(1-t),u=e.link.y0-e.link.width/2,h=e.link.y0+e.link.width/2,f=e.link.y1-e.link.width/2,p=e.link.y1+e.link.width/2;return"M"+a+","+u+"C"+l+","+u+" "+c+","+f+" "+o+","+f+"L"+o+","+p+"C"+c+","+p+" "+l+","+h+" "+a+","+h+"Z"}}function _(t,e){var r=a(e.color),i=n.nodePadAcross,s=t.nodePad/2;e.dx=e.x1-e.x0,e.dy=e.y1-e.y0;var l=e.dx,c=Math.max(.5,e.dy),u="node_"+e.pointNumber;return e.group&&(u=h.randstr()),e.trace=t.trace,e.curveNumber=t.trace.index,{index:e.pointNumber,key:u,partOfGroup:e.partOfGroup||!1,group:e.group,traceId:t.key,trace:t.trace,node:e,nodePad:t.nodePad,nodeLineColor:t.nodeLineColor,nodeLineWidth:t.nodeLineWidth,textFont:t.textFont,size:t.horizontal?t.height:t.width,visibleWidth:Math.ceil(l),visibleHeight:c,zoneX:-i,zoneY:-s,zoneWidth:l+2*i,zoneHeight:c+2*s,labelY:t.horizontal?e.dy/2+1:e.dx/2+1,left:1===e.originalLayer,sizeAcross:t.width,forceLayouts:t.forceLayouts,horizontal:t.horizontal,darkBackground:r.getBrightness()<=128,tinyColorHue:o.tinyRGB(r),tinyColorAlpha:r.getAlpha(),valueFormat:t.valueFormat,valueSuffix:t.valueSuffix,sankey:t.sankey,graph:t.graph,arrangement:t.arrangement,uniqueNodeLabelPathId:[t.guid,t.key,u].join("_"),interactionState:t.interactionState,figure:t}}function w(t){t.attr("transform",(function(t){return"translate("+t.node.x0.toFixed(3)+", "+t.node.y0.toFixed(3)+")"}))}function A(t){t.call(w)}function C(t,e){t.call(A),e.attr("d",b())}function M(t){t.attr("width",(function(t){return t.node.x1-t.node.x0})).attr("height",(function(t){return t.visibleHeight}))}function k(t){return t.link.width>1||t.linkLineWidth>0}function I(t){return"translate("+t.translateX+","+t.translateY+")"+(t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)")}function T(t){return"translate("+(t.horizontal?0:t.labelY)+" "+(t.horizontal?t.labelY:0)+")"}function L(t){return i.svg.line()([[t.horizontal?t.left?-t.sizeAcross:t.visibleWidth+n.nodeTextOffsetHorizontal:n.nodeTextOffsetHorizontal,0],[t.horizontal?t.left?-n.nodeTextOffsetHorizontal:t.sizeAcross:t.visibleHeight-n.nodeTextOffsetHorizontal,0]])}function S(t){return t.horizontal?"matrix(1 0 0 1 0 0)":"matrix(0 1 1 0 0 0)"}function E(t){return t.horizontal?"scale(1 1)":"scale(-1 1)"}function D(t){return t.darkBackground&&!t.horizontal?"rgb(255,255,255)":"rgb(0,0,0)"}function P(t){return t.horizontal&&t.left?"100%":"0%"}function O(t,e,r){t.on(".basic",null).on("mouseover.basic",(function(t){t.interactionState.dragInProgress||t.partOfGroup||(r.hover(this,t,e),t.interactionState.hovered=[this,t])})).on("mousemove.basic",(function(t){t.interactionState.dragInProgress||t.partOfGroup||(r.follow(this,t),t.interactionState.hovered=[this,t])})).on("mouseout.basic",(function(t){t.interactionState.dragInProgress||t.partOfGroup||(r.unhover(this,t,e),t.interactionState.hovered=!1)})).on("click.basic",(function(t){t.interactionState.hovered&&(r.unhover(this,t,e),t.interactionState.hovered=!1),t.interactionState.dragInProgress||t.partOfGroup||r.select(this,t,e)}))}function z(t,e,r,a){var o=i.behavior.drag().origin((function(t){return{x:t.node.x0+t.visibleWidth/2,y:t.node.y0+t.visibleHeight/2}})).on("dragstart",(function(i){if("fixed"!==i.arrangement&&(h.ensureSingle(a._fullLayout._infolayer,"g","dragcover",(function(t){a._fullLayout._dragCover=t})),h.raiseToTop(this),i.interactionState.dragInProgress=i.node,F(i.node),i.interactionState.hovered&&(r.nodeEvents.unhover.apply(0,i.interactionState.hovered),i.interactionState.hovered=!1),"snap"===i.arrangement)){var o=i.traceId+"|"+i.key;i.forceLayouts[o]?i.forceLayouts[o].alpha(1):function(t,e,r,i){!function(t){for(var e=0;e0&&i.forceLayouts[e].alpha(0)}}(0,e,a,r)).stop()}(0,o,i),function(t,e,r,i,a){window.requestAnimationFrame((function o(){var s;for(s=0;s0)window.requestAnimationFrame(o);else{var l=r.node.originalX;r.node.x0=l-r.visibleWidth/2,r.node.x1=l+r.visibleWidth/2,R(r,a)}}))}(t,e,i,o,a)}})).on("drag",(function(r){if("fixed"!==r.arrangement){var n=i.event.x,a=i.event.y;"snap"===r.arrangement?(r.node.x0=n-r.visibleWidth/2,r.node.x1=n+r.visibleWidth/2,r.node.y0=a-r.visibleHeight/2,r.node.y1=a+r.visibleHeight/2):("freeform"===r.arrangement&&(r.node.x0=n-r.visibleWidth/2,r.node.x1=n+r.visibleWidth/2),a=Math.max(0,Math.min(r.size-r.visibleHeight/2,a)),r.node.y0=a-r.visibleHeight/2,r.node.y1=a+r.visibleHeight/2),F(r.node),"snap"!==r.arrangement&&(r.sankey.update(r.graph),C(t.filter(N(r)),e))}})).on("dragend",(function(t){if("fixed"!==t.arrangement){t.interactionState.dragInProgress=!1;for(var e=0;e5?t.node.label:""})).attr("text-anchor",(function(t){return t.horizontal&&t.left?"end":"start"})),U.transition().ease(n.ease).duration(n.duration).attr("startOffset",P).style("fill",D)}},{"../../components/color":592,"../../components/drawing":613,"../../lib":717,"../../lib/gup":715,"../../registry":846,"./constants":1113,"@plotly/d3-sankey":56,"@plotly/d3-sankey-circular":55,d3:165,"d3-force":158,"d3-interpolate":160,tinycolor2:536}],1118:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=[],n=t.cd[0].trace,i=n._sankey.graph.nodes,a=0;as&&M[m].gap;)m--;for(y=M[m].s,d=M.length-1;d>m;d--)M[d].s=y;for(;sk[u]&&u=0;i--){var a=t[i];if("scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}}}}},{}],1127:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./attributes"),o=t("./constants"),s=t("./subtypes"),l=t("./xy_defaults"),c=t("./stack_defaults"),u=t("./marker_defaults"),h=t("./line_defaults"),f=t("./line_shape_defaults"),p=t("./text_defaults"),d=t("./fillcolor_defaults");e.exports=function(t,e,r,g){function m(r,i){return n.coerce(t,e,a,r,i)}var v=l(t,e,g,m);if(v||(e.visible=!1),e.visible){var y=c(t,e,g,m),x=!y&&vG!=(F=D[S][1])>=G&&(O=D[S-1][0],z=D[S][0],F-R&&(P=O+(z-O)*(G-R)/(F-R),Y=Math.min(Y,P),V=Math.max(V,P)));Y=Math.max(Y,0),V=Math.min(V,f._length);var q=s.defaultLine;return s.opacity(h.fillcolor)?q=h.fillcolor:s.opacity((h.line||{}).color)&&(q=h.line.color),n.extendFlat(t,{distance:t.maxHoverDistance,x0:Y,x1:V,y0:G,y1:G,color:q,hovertemplate:!1}),delete t.index,h.text&&!Array.isArray(h.text)?t.text=String(h.text):t.text=h.name,[t]}}}},{"../../components/color":592,"../../components/fx":630,"../../lib":717,"../../registry":846,"./get_trace_color":1130}],1132:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports={hasLines:n.hasLines,hasMarkers:n.hasMarkers,hasText:n.hasText,isBubble:n.isBubble,attributes:t("./attributes"),supplyDefaults:t("./defaults"),crossTraceDefaults:t("./cross_trace_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./cross_trace_calc"),arraysToCalcdata:t("./arrays_to_calcdata"),plot:t("./plot"),colorbar:t("./marker_colorbar"),formatLabels:t("./format_labels"),style:t("./style").style,styleOnSelect:t("./style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("./select"),animatable:!0,moduleType:"trace",name:"scatter",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","errorBarsOK","showLegend","scatter-like","zoomScale"],meta:{}}},{"../../plots/cartesian":776,"./arrays_to_calcdata":1119,"./attributes":1120,"./calc":1121,"./cross_trace_calc":1125,"./cross_trace_defaults":1126,"./defaults":1127,"./format_labels":1129,"./hover":1131,"./marker_colorbar":1138,"./plot":1140,"./select":1141,"./style":1143,"./subtypes":1144}],1133:[function(t,e,r){"use strict";var n=t("../../lib").isArrayOrTypedArray,i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s,l){var c=(t.marker||{}).color;s("line.color",r),i(t,"line")?a(t,e,o,s,{prefix:"line.",cLetter:"c"}):s("line.color",!n(c)&&c||r),s("line.width"),(l||{}).noDash||s("line.dash")}},{"../../components/colorscale/defaults":602,"../../components/colorscale/helpers":603,"../../lib":717}],1134:[function(t,e,r){"use strict";var n=t("../../constants/numerical"),i=n.BADNUM,a=n.LOG_CLIP,o=a+.5,s=a-.5,l=t("../../lib"),c=l.segmentsIntersect,u=l.constrain,h=t("./constants");e.exports=function(t,e){var r,n,a,f,p,d,g,m,v,y,x,b,_,w,A,C,M,k,I=e.xaxis,T=e.yaxis,L="log"===I.type,S="log"===T.type,E=I._length,D=T._length,P=e.connectGaps,O=e.baseTolerance,z=e.shape,R="linear"===z,F=e.fill&&"none"!==e.fill,N=[],j=h.minTolerance,B=t.length,Y=new Array(B),V=0;function U(r){var n=t[r];if(!n)return!1;var a=e.linearized?I.l2p(n.x):I.c2p(n.x),l=e.linearized?T.l2p(n.y):T.c2p(n.y);if(a===i){if(L&&(a=I.c2p(n.x,!0)),a===i)return!1;S&&l===i&&(a*=Math.abs(I._m*D*(I._m>0?o:s)/(T._m*E*(T._m>0?o:s)))),a*=1e3}if(l===i){if(S&&(l=T.c2p(n.y,!0)),l===i)return!1;l*=1e3}return[a,l]}function H(t,e,r,n){var i=r-t,a=n-e,o=.5-t,s=.5-e,l=i*i+a*a,c=i*o+a*s;if(c>0&&crt||t[1]it)return[u(t[0],et,rt),u(t[1],nt,it)]}function st(t,e){return t[0]===e[0]&&(t[0]===et||t[0]===rt)||t[1]===e[1]&&(t[1]===nt||t[1]===it)||void 0}function lt(t,e,r){return function(n,i){var a=ot(n),o=ot(i),s=[];if(a&&o&&st(a,o))return s;a&&s.push(a),o&&s.push(o);var c=2*l.constrain((n[t]+i[t])/2,e,r)-((a||n)[t]+(o||i)[t]);return c&&((a&&o?c>0==a[t]>o[t]?a:o:a||o)[t]+=c),s}}function ct(t){var e=t[0],r=t[1],n=e===Y[V-1][0],i=r===Y[V-1][1];if(!n||!i)if(V>1){var a=e===Y[V-2][0],o=r===Y[V-2][1];n&&(e===et||e===rt)&&a?o?V--:Y[V-1]=t:i&&(r===nt||r===it)&&o?a?V--:Y[V-1]=t:Y[V++]=t}else Y[V++]=t}function ut(t){Y[V-1][0]!==t[0]&&Y[V-1][1]!==t[1]&&ct([X,J]),ct(t),K=null,X=J=0}function ht(t){if(M=t[0]/E,k=t[1]/D,W=t[0]rt?rt:0,Z=t[1]it?it:0,W||Z){if(V)if(K){var e=$(K,t);e.length>1&&(ut(e[0]),Y[V++]=e[1])}else Q=$(Y[V-1],t)[0],Y[V++]=Q;else Y[V++]=[W||t[0],Z||t[1]];var r=Y[V-1];W&&Z&&(r[0]!==W||r[1]!==Z)?(K&&(X!==W&&J!==Z?ct(X&&J?(n=K,a=(i=t)[0]-n[0],o=(i[1]-n[1])/a,(n[1]*i[0]-i[1]*n[0])/a>0?[o>0?et:rt,it]:[o>0?rt:et,nt]):[X||W,J||Z]):X&&J&&ct([X,J])),ct([W,Z])):X-W&&J-Z&&ct([W||X,Z||J]),K=t,X=W,J=Z}else K&&ut($(K,t)[0]),Y[V++]=t;var n,i,a,o}for("linear"===z||"spline"===z?$=function(t,e){for(var r=[],n=0,i=0;i<4;i++){var a=at[i],o=c(t[0],t[1],e[0],e[1],a[0],a[1],a[2],a[3]);o&&(!n||Math.abs(o.x-r[0][0])>1||Math.abs(o.y-r[0][1])>1)&&(o=[o.x,o.y],n&&q(o,t)G(d,ft))break;a=d,(_=v[0]*m[0]+v[1]*m[1])>x?(x=_,f=d,g=!1):_=t.length||!d)break;ht(d),n=d}}else ht(f)}K&&ct([X||K[0],J||K[1]]),N.push(Y.slice(0,V))}return N}},{"../../constants/numerical":693,"../../lib":717,"./constants":1124}],1135:[function(t,e,r){"use strict";e.exports=function(t,e,r){"spline"===r("line.shape")&&r("line.smoothing")}},{}],1136:[function(t,e,r){"use strict";var n={tonextx:1,tonexty:1,tonext:1};e.exports=function(t,e,r){var i,a,o,s,l,c={},u=!1,h=-1,f=0,p=-1;for(a=0;a=0?l=p:(l=p=f,f++),l0?Math.max(e,i):0}}},{"fast-isnumeric":228}],1138:[function(t,e,r){"use strict";e.exports={container:"marker",min:"cmin",max:"cmax"}},{}],1139:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/helpers").hasColorscale,a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l,c){var u=o.isBubble(t),h=(t.line||{}).color;c=c||{},h&&(r=h),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c.noSelect||(l("selected.marker.color"),l("unselected.marker.color"),l("selected.marker.size"),l("unselected.marker.size")),c.noLine||(l("marker.line.color",h&&!Array.isArray(h)&&e.marker.color!==h?h:u?n.background:n.defaultLine),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0)),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode")),c.gradient&&"none"!==l("marker.gradient.type")&&l("marker.gradient.color")}},{"../../components/color":592,"../../components/colorscale/defaults":602,"../../components/colorscale/helpers":603,"./subtypes":1144}],1140:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../registry"),a=t("../../lib"),o=a.ensureSingle,s=a.identity,l=t("../../components/drawing"),c=t("./subtypes"),u=t("./line_points"),h=t("./link_traces"),f=t("../../lib/polygon").tester;function p(t,e,r,h,p,d,g){var m;!function(t,e,r,i,o){var s=r.xaxis,l=r.yaxis,u=n.extent(a.simpleMap(s.range,s.r2c)),h=n.extent(a.simpleMap(l.range,l.r2c)),f=i[0].trace;if(c.hasMarkers(f)){var p=f.marker.maxdisplayed;if(0!==p){var d=i.filter((function(t){return t.x>=u[0]&&t.x<=u[1]&&t.y>=h[0]&&t.y<=h[1]})),g=Math.ceil(d.length/p),m=0;o.forEach((function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&r0;function y(t){return v?t.transition():t}var x=r.xaxis,b=r.yaxis,_=h[0].trace,w=_.line,A=n.select(d),C=o(A,"g","errorbars"),M=o(A,"g","lines"),k=o(A,"g","points"),I=o(A,"g","text");if(i.getComponentMethod("errorbars","plot")(t,C,r,g),!0===_.visible){var T,L;y(A).style("opacity",_.opacity);var S=_.fill.charAt(_.fill.length-1);"x"!==S&&"y"!==S&&(S=""),h[0][r.isRangePlot?"nodeRangePlot3":"node3"]=A;var E,D,P="",O=[],z=_._prevtrace;z&&(P=z._prevRevpath||"",L=z._nextFill,O=z._polygons);var R,F,N,j,B,Y,V,U="",H="",G=[],q=a.noop;if(T=_._ownFill,c.hasLines(_)||"none"!==_.fill){for(L&&L.datum(h),-1!==["hv","vh","hvh","vhv"].indexOf(w.shape)?(R=l.steps(w.shape),F=l.steps(w.shape.split("").reverse().join(""))):R=F="spline"===w.shape?function(t){var e=t[t.length-1];return t.length>1&&t[0][0]===e[0]&&t[0][1]===e[1]?l.smoothclosed(t.slice(1),w.smoothing):l.smoothopen(t,w.smoothing)}:function(t){return"M"+t.join("L")},N=function(t){return F(t.reverse())},G=u(h,{xaxis:x,yaxis:b,connectGaps:_.connectgaps,baseTolerance:Math.max(w.width||1,3)/4,shape:w.shape,simplify:w.simplify,fill:_.fill}),V=_._polygons=new Array(G.length),m=0;m1){var r=n.select(this);if(r.datum(h),t)y(r.style("opacity",0).attr("d",E).call(l.lineGroupStyle)).style("opacity",1);else{var i=y(r);i.attr("d",E),l.singleLineStyle(h,i)}}}}}var W=M.selectAll(".js-line").data(G);y(W.exit()).style("opacity",0).remove(),W.each(q(!1)),W.enter().append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").call(l.lineGroupStyle).each(q(!0)),l.setClipUrl(W,r.layerClipId,t),G.length?(T?(T.datum(h),j&&Y&&(S?("y"===S?j[1]=Y[1]=b.c2p(0,!0):"x"===S&&(j[0]=Y[0]=x.c2p(0,!0)),y(T).attr("d","M"+Y+"L"+j+"L"+U.substr(1)).call(l.singleFillStyle)):y(T).attr("d",U+"Z").call(l.singleFillStyle))):L&&("tonext"===_.fill.substr(0,6)&&U&&P?("tonext"===_.fill?y(L).attr("d",U+"Z"+P+"Z").call(l.singleFillStyle):y(L).attr("d",U+"L"+P.substr(1)+"Z").call(l.singleFillStyle),_._polygons=_._polygons.concat(O)):(X(L),_._polygons=null)),_._prevRevpath=H,_._prevPolygons=V):(T?X(T):L&&X(L),_._polygons=_._prevRevpath=_._prevPolygons=null),k.datum(h),I.datum(h),function(e,i,a){var o,u=a[0].trace,h=c.hasMarkers(u),f=c.hasText(u),p=tt(u),d=et,g=et;if(h||f){var m=s,_=u.stackgroup,w=_&&"infer zero"===t._fullLayout._scatterStackOpts[x._id+b._id][_].stackgaps;u.marker.maxdisplayed||u._needsCull?m=w?K:J:_&&!w&&(m=Q),h&&(d=m),f&&(g=m)}var A,C=(o=e.selectAll("path.point").data(d,p)).enter().append("path").classed("point",!0);v&&C.call(l.pointStyle,u,t).call(l.translatePoints,x,b).style("opacity",0).transition().style("opacity",1),o.order(),h&&(A=l.makePointStyleFns(u)),o.each((function(e){var i=n.select(this),a=y(i);l.translatePoint(e,a,x,b)?(l.singlePointStyle(e,a,u,A,t),r.layerClipId&&l.hideOutsideRangePoint(e,a,x,b,u.xcalendar,u.ycalendar),u.customdata&&i.classed("plotly-customdata",null!==e.data&&void 0!==e.data)):a.remove()})),v?o.exit().transition().style("opacity",0).remove():o.exit().remove(),(o=i.selectAll("g").data(g,p)).enter().append("g").classed("textpoint",!0).append("text"),o.order(),o.each((function(t){var e=n.select(this),i=y(e.select("text"));l.translatePoint(t,i,x,b)?r.layerClipId&&l.hideOutsideRangePoint(t,e,x,b,u.xcalendar,u.ycalendar):e.remove()})),o.selectAll("text").call(l.textPointStyle,u,t).each((function(t){var e=x.c2p(t.x),r=b.c2p(t.y);n.select(this).selectAll("tspan.line").each((function(){y(n.select(this)).attr({x:e,y:r})}))})),o.exit().remove()}(k,I,h);var Z=!1===_.cliponaxis?null:r.layerClipId;l.setClipUrl(k,Z,t),l.setClipUrl(I,Z,t)}function X(t){y(t).attr("d","M0,0Z")}function J(t){return t.filter((function(t){return!t.gap&&t.vis}))}function K(t){return t.filter((function(t){return t.vis}))}function Q(t){return t.filter((function(t){return!t.gap}))}function $(t){return t.id}function tt(t){if(t.ids)return $}function et(){return!1}}e.exports=function(t,e,r,i,a,c){var u,f,d=!a,g=!!a&&a.duration>0,m=h(t,e,r);(u=i.selectAll("g.trace").data(m,(function(t){return t[0].trace.uid}))).enter().append("g").attr("class",(function(t){return"trace scatter trace"+t[0].trace.uid})).style("stroke-miterlimit",2),u.order(),function(t,e,r){e.each((function(e){var i=o(n.select(this),"g","fills");l.setClipUrl(i,r.layerClipId,t);var a=e[0].trace,c=[];a._ownfill&&c.push("_ownFill"),a._nexttrace&&c.push("_nextFill");var u=i.selectAll("g").data(c,s);u.enter().append("g"),u.exit().each((function(t){a[t]=null})).remove(),u.order().each((function(t){a[t]=o(n.select(this),"path","js-fill")}))}))}(t,u,e),g?(c&&(f=c()),n.transition().duration(a.duration).ease(a.easing).each("end",(function(){f&&f()})).each("interrupt",(function(){f&&f()})).each((function(){i.selectAll("g.trace").each((function(r,n){p(t,n,e,r,m,this,a)}))}))):u.each((function(r,n){p(t,n,e,r,m,this,a)})),d&&u.exit().remove(),i.selectAll("path:not([d])").remove()}},{"../../components/drawing":613,"../../lib":717,"../../lib/polygon":729,"../../registry":846,"./line_points":1134,"./link_traces":1136,"./subtypes":1144,d3:165}],1141:[function(t,e,r){"use strict";var n=t("./subtypes");e.exports=function(t,e){var r,i,a,o,s=t.cd,l=t.xaxis,c=t.yaxis,u=[],h=s[0].trace;if(!n.hasMarkers(h)&&!n.hasText(h))return[];if(!1===e)for(r=0;r0){var f=i.c2l(u);i._lowerLogErrorBound||(i._lowerLogErrorBound=f),i._lowerErrorBound=Math.min(i._lowerLogErrorBound,f)}}else o[s]=[-l[0]*r,l[1]*r]}return o}e.exports=function(t,e,r){var n=[i(t.x,t.error_x,e[0],r.xaxis),i(t.y,t.error_y,e[1],r.yaxis),i(t.z,t.error_z,e[2],r.zaxis)],a=function(t){for(var e=0;e-1?-1:t.indexOf("right")>-1?1:0}function b(t){return null==t?0:t.indexOf("top")>-1?-1:t.indexOf("bottom")>-1?1:0}function _(t,e){return e(4*t)}function w(t){return p[t]}function A(t,e,r,n,i){var a=null;if(l.isArrayOrTypedArray(t)){a=[];for(var o=0;o=0){var g=function(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],l=[];for(n=0;n=0&&h("surfacecolor",f||p);for(var d=["x","y","z"],g=0;g<3;++g){var m="projection."+d[g];h(m+".show")&&(h(m+".opacity"),h(m+".scale"))}var v=n.getComponentMethod("errorbars","supplyDefaults");v(t,e,f||p||r,{axis:"z"}),v(t,e,f||p||r,{axis:"y",inherit:"z"}),v(t,e,f||p||r,{axis:"x",inherit:"z"})}else e.visible=!1}},{"../../lib":717,"../../registry":846,"../scatter/line_defaults":1133,"../scatter/marker_defaults":1139,"../scatter/subtypes":1144,"../scatter/text_defaults":1145,"./attributes":1147}],1152:[function(t,e,r){"use strict";e.exports={plot:t("./convert"),attributes:t("./attributes"),markerSymbols:t("../../constants/gl3d_markers"),supplyDefaults:t("./defaults"),colorbar:[{container:"marker",min:"cmin",max:"cmax"},{container:"line",min:"cmin",max:"cmax"}],calc:t("./calc"),moduleType:"trace",name:"scatter3d",basePlotModule:t("../../plots/gl3d"),categories:["gl3d","symbols","showLegend","scatter-like"],meta:{}}},{"../../constants/gl3d_markers":691,"../../plots/gl3d":805,"./attributes":1147,"./calc":1148,"./convert":1150,"./defaults":1151}],1153:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../plots/template_attributes").hovertemplateAttrs,o=t("../../plots/template_attributes").texttemplateAttrs,s=t("../../components/colorscale/attributes"),l=t("../../lib/extend").extendFlat,c=n.marker,u=n.line,h=c.line;e.exports={carpet:{valType:"string",editType:"calc"},a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},mode:l({},n.mode,{dflt:"markers"}),text:l({},n.text,{}),texttemplate:o({editType:"plot"},{keys:["a","b","text"]}),hovertext:l({},n.hovertext,{}),line:{color:u.color,width:u.width,dash:u.dash,shape:l({},u.shape,{values:["linear","spline"]}),smoothing:u.smoothing,editType:"calc"},connectgaps:n.connectgaps,fill:l({},n.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:n.fillcolor,marker:l({symbol:c.symbol,opacity:c.opacity,maxdisplayed:c.maxdisplayed,size:c.size,sizeref:c.sizeref,sizemin:c.sizemin,sizemode:c.sizemode,line:l({width:h.width,editType:"calc"},s("marker.line")),gradient:c.gradient,editType:"calc"},s("marker")),textfont:n.textfont,textposition:n.textposition,selected:n.selected,unselected:n.unselected,hoverinfo:l({},i.hoverinfo,{flags:["a","b","text","name"]}),hoveron:n.hoveron,hovertemplate:a()}},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../scatter/attributes":1120}],1154:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=t("../carpet/lookup_carpetid");e.exports=function(t,e){var r=e._carpetTrace=l(t,e);if(r&&r.visible&&"legendonly"!==r.visible){var c;e.xaxis=r.xaxis,e.yaxis=r.yaxis;var u,h,f=e._length,p=new Array(f),d=!1;for(c=0;c")}return o}function y(t,e){var r;r=t.labelprefix&&t.labelprefix.length>0?t.labelprefix.replace(/ = $/,""):t._hovertitle,m.push(r+": "+e.toFixed(3)+t.labelsuffix)}}},{"../../lib":717,"../scatter/hover":1131}],1159:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../scatter/marker_colorbar"),formatLabels:t("./format_labels"),calc:t("./calc"),plot:t("./plot"),style:t("../scatter/style").style,styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../scatter/select"),eventData:t("./event_data"),moduleType:"trace",name:"scattercarpet",basePlotModule:t("../../plots/cartesian"),categories:["svg","carpet","symbols","showLegend","carpetDependent","zoomScale"],meta:{}}},{"../../plots/cartesian":776,"../scatter/marker_colorbar":1138,"../scatter/select":1141,"../scatter/style":1143,"./attributes":1153,"./calc":1154,"./defaults":1155,"./event_data":1156,"./format_labels":1157,"./hover":1158,"./plot":1160}],1160:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../plots/cartesian/axes"),a=t("../../components/drawing");e.exports=function(t,e,r,o){var s,l,c,u=r[0][0].carpet,h={xaxis:i.getFromId(t,u.xaxis||"x"),yaxis:i.getFromId(t,u.yaxis||"y"),plot:e.plot};for(n(t,h,r,o),s=0;s")}function p(t){return t+"°"}}(c,g,t,l[0].t.labels),t.hovertemplate=c.hovertemplate,[t]}}},{"../../components/fx":630,"../../constants/numerical":693,"../../lib":717,"../scatter/get_trace_color":1130,"./attributes":1161}],1167:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../scatter/marker_colorbar"),formatLabels:t("./format_labels"),calc:t("./calc"),calcGeoJSON:t("./plot").calcGeoJSON,plot:t("./plot").plot,style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),eventData:t("./event_data"),selectPoints:t("./select"),moduleType:"trace",name:"scattergeo",basePlotModule:t("../../plots/geo"),categories:["geo","symbols","showLegend","scatter-like"],meta:{}}},{"../../plots/geo":795,"../scatter/marker_colorbar":1138,"../scatter/style":1143,"./attributes":1161,"./calc":1162,"./defaults":1163,"./event_data":1164,"./format_labels":1165,"./hover":1166,"./plot":1168,"./select":1169,"./style":1170}],1168:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../lib/topojson_utils").getTopojsonFeatures,o=t("../../lib/geojson_utils"),s=t("../../lib/geo_location_utils"),l=t("../../plots/cartesian/autorange").findExtremes,c=t("../../constants/numerical").BADNUM,u=t("../scatter/calc").calcMarkerSize,h=t("../scatter/subtypes"),f=t("./style");e.exports={calcGeoJSON:function(t,e){var r,n,i=t[0].trace,o=e[i.geo],h=o._subplot,f=i._length;if(Array.isArray(i.locations)){var p=i.locationmode,d="geojson-id"===p?s.extractTraceFeature(t):a(i,h.topojson);for(r=0;r=g,A=2*_,C={},M=e._x=y.makeCalcdata(e,"x"),k=e._y=x.makeCalcdata(e,"y"),I=new Array(A);for(r=0;r<_;r++)o=M[r],s=k[r],I[2*r]=o===d?NaN:o,I[2*r+1]=s===d?NaN:s;if("log"===y.type)for(r=0;r1&&i.extendFlat(s.line,f.linePositions(t,r,n)),s.errorX||s.errorY){var l=f.errorBarPositions(t,r,n,a,o);s.errorX&&i.extendFlat(s.errorX,l.x),s.errorY&&i.extendFlat(s.errorY,l.y)}return s.text&&(i.extendFlat(s.text,{positions:n},f.textPosition(t,r,s.text,s.marker)),i.extendFlat(s.textSel,{positions:n},f.textPosition(t,r,s.text,s.markerSel)),i.extendFlat(s.textUnsel,{positions:n},f.textPosition(t,r,s.text,s.markerUnsel))),s}(t,0,e,I,M,k),E=p(t,b);return u(v,e),w?S.marker&&(L=2*(S.marker.sizeAvg||Math.max(S.marker.size,3))):L=l(e,_),c(t,e,y,x,M,k,L),S.errorX&&m(e,y,S.errorX),S.errorY&&m(e,x,S.errorY),S.fill&&!E.fill2d&&(E.fill2d=!0),S.marker&&!E.scatter2d&&(E.scatter2d=!0),S.line&&!E.line2d&&(E.line2d=!0),!S.errorX&&!S.errorY||E.error2d||(E.error2d=!0),S.text&&!E.glText&&(E.glText=!0),S.marker&&(S.marker.snap=_),E.lineOptions.push(S.line),E.errorXOptions.push(S.errorX),E.errorYOptions.push(S.errorY),E.fillOptions.push(S.fill),E.markerOptions.push(S.marker),E.markerSelectedOptions.push(S.markerSel),E.markerUnselectedOptions.push(S.markerUnsel),E.textOptions.push(S.text),E.textSelectedOptions.push(S.textSel),E.textUnselectedOptions.push(S.textUnsel),E.selectBatch.push([]),E.unselectBatch.push([]),C._scene=E,C.index=E.count,C.x=M,C.y=k,C.positions=I,E.count++,[{x:!1,y:!1,t:C,trace:e}]}},{"../../constants/numerical":693,"../../lib":717,"../../plots/cartesian/autorange":764,"../../plots/cartesian/axis_ids":768,"../scatter/calc":1121,"../scatter/colorscale_calc":1123,"./constants":1173,"./convert":1174,"./scene_update":1182,"point-cluster":471}],1173:[function(t,e,r){"use strict";e.exports={TOO_MANY_POINTS:1e5,SYMBOL_SDF_SIZE:200,SYMBOL_SIZE:20,SYMBOL_STROKE:1,DOT_RE:/-dot/,OPEN_RE:/-open/,DASHES:{solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}}},{}],1174:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("svg-path-sdf"),a=t("color-normalize"),o=t("../../registry"),s=t("../../lib"),l=t("../../components/drawing"),c=t("../../plots/cartesian/axis_ids"),u=t("../../lib/gl_format_color").formatColor,h=t("../scatter/subtypes"),f=t("../scatter/make_bubble_size_func"),p=t("./helpers"),d=t("./constants"),g=t("../../constants/interactions").DESELECTDIM,m={start:1,left:1,end:-1,right:-1,middle:0,center:0,bottom:1,top:-1},v=t("../../components/fx/helpers").appendArrayPointValue;function y(t,e){var r,i=t._fullLayout,a=e._length,o=e.textfont,l=e.textposition,c=Array.isArray(l)?l:[l],u=o.color,h=o.size,f=o.family,p={},d=e.texttemplate;if(d){p.text=[];var g=i._d3locale,m=Array.isArray(d),y=m?Math.min(d.length,a):a,x=m?function(t){return d[t]}:function(){return d};for(r=0;rd.TOO_MANY_POINTS?"rect":h.hasMarkers(e)?"rect":"round";if(c&&e.connectgaps){var f=n[0],p=n[1];for(i=0;i1?l[i]:l[0]:l,d=Array.isArray(c)?c.length>1?c[i]:c[0]:c,g=m[p],v=m[d],y=u?u/.8+1:0,x=-v*y-.5*v;o.offset[i]=[g*y/f,x/f]}}return o}}},{"../../components/drawing":613,"../../components/fx/helpers":627,"../../constants/interactions":692,"../../lib":717,"../../lib/gl_format_color":714,"../../plots/cartesian/axis_ids":768,"../../registry":846,"../scatter/make_bubble_size_func":1137,"../scatter/subtypes":1144,"./constants":1173,"./helpers":1178,"color-normalize":122,"fast-isnumeric":228,"svg-path-sdf":534}],1175:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../registry"),a=t("./helpers"),o=t("./attributes"),s=t("../scatter/constants"),l=t("../scatter/subtypes"),c=t("../scatter/xy_defaults"),u=t("../scatter/marker_defaults"),h=t("../scatter/line_defaults"),f=t("../scatter/fillcolor_defaults"),p=t("../scatter/text_defaults");e.exports=function(t,e,r,d){function g(r,i){return n.coerce(t,e,o,r,i)}var m=!!t.marker&&a.isOpenSymbol(t.marker.symbol),v=l.isBubble(t),y=c(t,e,d,g);if(y){var x=y100},r.isDotSymbol=function(t){return"string"==typeof t?n.DOT_RE.test(t):t>200}},{"./constants":1173}],1179:[function(t,e,r){"use strict";var n=t("../../registry"),i=t("../../lib"),a=t("../scatter/get_trace_color");function o(t,e,r,o){var s=t.xa,l=t.ya,c=t.distance,u=t.dxy,h=t.index,f={pointNumber:h,x:e[h],y:r[h]};f.tx=Array.isArray(o.text)?o.text[h]:o.text,f.htx=Array.isArray(o.hovertext)?o.hovertext[h]:o.hovertext,f.data=Array.isArray(o.customdata)?o.customdata[h]:o.customdata,f.tp=Array.isArray(o.textposition)?o.textposition[h]:o.textposition;var p=o.textfont;p&&(f.ts=i.isArrayOrTypedArray(p.size)?p.size[h]:p.size,f.tc=Array.isArray(p.color)?p.color[h]:p.color,f.tf=Array.isArray(p.family)?p.family[h]:p.family);var d=o.marker;d&&(f.ms=i.isArrayOrTypedArray(d.size)?d.size[h]:d.size,f.mo=i.isArrayOrTypedArray(d.opacity)?d.opacity[h]:d.opacity,f.mx=i.isArrayOrTypedArray(d.symbol)?d.symbol[h]:d.symbol,f.mc=i.isArrayOrTypedArray(d.color)?d.color[h]:d.color);var g=d&&d.line;g&&(f.mlc=Array.isArray(g.color)?g.color[h]:g.color,f.mlw=i.isArrayOrTypedArray(g.width)?g.width[h]:g.width);var m=d&&d.gradient;m&&"none"!==m.type&&(f.mgt=Array.isArray(m.type)?m.type[h]:m.type,f.mgc=Array.isArray(m.color)?m.color[h]:m.color);var v=s.c2p(f.x,!0),y=l.c2p(f.y,!0),x=f.mrc||1,b=o.hoverlabel;b&&(f.hbg=Array.isArray(b.bgcolor)?b.bgcolor[h]:b.bgcolor,f.hbc=Array.isArray(b.bordercolor)?b.bordercolor[h]:b.bordercolor,f.hts=i.isArrayOrTypedArray(b.font.size)?b.font.size[h]:b.font.size,f.htc=Array.isArray(b.font.color)?b.font.color[h]:b.font.color,f.htf=Array.isArray(b.font.family)?b.font.family[h]:b.font.family,f.hnl=i.isArrayOrTypedArray(b.namelength)?b.namelength[h]:b.namelength);var _=o.hoverinfo;_&&(f.hi=Array.isArray(_)?_[h]:_);var w=o.hovertemplate;w&&(f.ht=Array.isArray(w)?w[h]:w);var A={};A[t.index]=f;var C=i.extendFlat({},t,{color:a(o,f),x0:v-x,x1:v+x,xLabelVal:f.x,y0:y-x,y1:y+x,yLabelVal:f.y,cd:A,distance:c,spikeDistance:u,hovertemplate:f.ht});return f.htx?C.text=f.htx:f.tx?C.text=f.tx:o.text&&(C.text=o.text),i.fillText(f,o,C),n.getComponentMethod("errorbars","hoverInfo")(f,o,C),C}e.exports={hoverPoints:function(t,e,r,n){var i,a,s,l,c,u,h,f,p,d=t.cd,g=d[0].t,m=d[0].trace,v=t.xa,y=t.ya,x=g.x,b=g.y,_=v.c2p(e),w=y.c2p(r),A=t.distance;if(g.tree){var C=v.p2c(_-A),M=v.p2c(_+A),k=y.p2c(w-A),I=y.p2c(w+A);i="x"===n?g.tree.range(Math.min(C,M),Math.min(y._rl[0],y._rl[1]),Math.max(C,M),Math.max(y._rl[0],y._rl[1])):g.tree.range(Math.min(C,M),Math.min(k,I),Math.max(C,M),Math.max(k,I))}else i=g.ids;var T=A;if("x"===n)for(c=0;c-1;c--)s=x[i[c]],l=b[i[c]],u=v.c2p(s)-_,h=y.c2p(l)-w,(f=Math.sqrt(u*u+h*h))m.glText.length){var _=x-m.glText.length;for(p=0;p<_;p++)m.glText.push(new o(b))}else if(xr&&(isNaN(e[n])||isNaN(e[n+1]));)n-=2;t.positions=e.slice(r,n+2)}return t})),m.line2d.update(m.lineOptions)),m.error2d){var A=(m.errorXOptions||[]).concat(m.errorYOptions||[]);m.error2d.update(A)}m.scatter2d&&m.scatter2d.update(m.markerOptions),m.fillOrder=s.repeat(null,x),m.fill2d&&(m.fillOptions=m.fillOptions.map((function(t,e){var n=r[e];if(t&&n&&n[0]&&n[0].trace){var i,a,o=n[0],s=o.trace,l=o.t,c=m.lineOptions[e],u=[];s._ownfill&&u.push(e),s._nexttrace&&u.push(e+1),u.length&&(m.fillOrder[e]=u);var h,f,p=[],d=c&&c.positions||l.positions;if("tozeroy"===s.fill){for(h=0;hh&&isNaN(d[f+1]);)f-=2;0!==d[h+1]&&(p=[d[h],0]),p=p.concat(d.slice(h,f+2)),0!==d[f+1]&&(p=p.concat([d[f],0]))}else if("tozerox"===s.fill){for(h=0;hh&&isNaN(d[f]);)f-=2;0!==d[h]&&(p=[0,d[h+1]]),p=p.concat(d.slice(h,f+2)),0!==d[f]&&(p=p.concat([0,d[f+1]]))}else if("toself"===s.fill||"tonext"===s.fill){for(p=[],i=0,a=0;a-1;for(p=0;p=0?Math.floor((e+180)/360):Math.ceil((e-180)/360)),d=e-p;if(n.getClosest(l,(function(t){var e=t.lonlat;if(e[0]===s)return 1/0;var n=i.modHalf(e[0],360),a=e[1],o=f.project([n,a]),l=o.x-u.c2p([d,a]),c=o.y-h.c2p([n,r]),p=Math.max(3,t.mrc||0);return Math.max(Math.sqrt(l*l+c*c)-p,1-3/p)}),t),!1!==t.index){var g=l[t.index],m=g.lonlat,v=[i.modHalf(m[0],360)+p,m[1]],y=u.c2p(v),x=h.c2p(v),b=g.mrc||1;t.x0=y-b,t.x1=y+b,t.y0=x-b,t.y1=x+b;var _={};_[c.subplot]={_subplot:f};var w=c._module.formatLabels(g,c,_);return t.lonLabel=w.lonLabel,t.latLabel=w.latLabel,t.color=a(c,g),t.extraText=function(t,e,r){if(!t.hovertemplate){var n=(e.hi||t.hoverinfo).split("+"),i=-1!==n.indexOf("all"),a=-1!==n.indexOf("lon"),s=-1!==n.indexOf("lat"),l=e.lonlat,c=[];return i||a&&s?c.push("("+u(l[0])+", "+u(l[1])+")"):a?c.push(r.lon+u(l[0])):s&&c.push(r.lat+u(l[1])),(i||-1!==n.indexOf("text"))&&o(e,t,c),c.join("
")}function u(t){return t+"°"}}(c,g,l[0].t.labels),t.hovertemplate=c.hovertemplate,[t]}}},{"../../components/fx":630,"../../constants/numerical":693,"../../lib":717,"../scatter/get_trace_color":1130}],1190:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../scatter/marker_colorbar"),formatLabels:t("./format_labels"),calc:t("../scattergeo/calc"),plot:t("./plot"),hoverPoints:t("./hover"),eventData:t("./event_data"),selectPoints:t("./select"),styleOnSelect:function(t,e){e&&e[0].trace._glTrace.update(e)},moduleType:"trace",name:"scattermapbox",basePlotModule:t("../../plots/mapbox"),categories:["mapbox","gl","symbols","showLegend","scatter-like"],meta:{}}},{"../../plots/mapbox":820,"../scatter/marker_colorbar":1138,"../scattergeo/calc":1162,"./attributes":1184,"./defaults":1186,"./event_data":1187,"./format_labels":1188,"./hover":1189,"./plot":1191,"./select":1192}],1191:[function(t,e,r){"use strict";var n=t("./convert"),i=t("../../plots/mapbox/constants").traceLayerPrefix,a=["fill","line","circle","symbol"];function o(t,e){this.type="scattermapbox",this.subplot=t,this.uid=e,this.sourceIds={fill:"source-"+e+"-fill",line:"source-"+e+"-line",circle:"source-"+e+"-circle",symbol:"source-"+e+"-symbol"},this.layerIds={fill:i+e+"-fill",line:i+e+"-line",circle:i+e+"-circle",symbol:i+e+"-symbol"},this.below=null}var s=o.prototype;s.addSource=function(t,e){this.subplot.map.addSource(this.sourceIds[t],{type:"geojson",data:e.geojson})},s.setSourceData=function(t,e){this.subplot.map.getSource(this.sourceIds[t]).setData(e.geojson)},s.addLayer=function(t,e,r){this.subplot.addLayer({type:t,id:this.layerIds[t],source:this.sourceIds[t],layout:e.layout,paint:e.paint},r)},s.update=function(t){var e,r,i,o=this.subplot,s=o.map,l=n(o.gd,t),c=o.belowLookup["trace-"+this.uid];if(c!==this.below){for(e=a.length-1;e>=0;e--)r=a[e],s.removeLayer(this.layerIds[r]);for(e=0;e=0;e--){var r=a[e];t.removeLayer(this.layerIds[r]),t.removeSource(this.sourceIds[r])}},e.exports=function(t,e){for(var r=e[0].trace,i=new o(t,r.uid),s=n(t.gd,e),l=i.below=t.belowLookup["trace-"+r.uid],c=0;c")}}e.exports={hoverPoints:function(t,e,r,a){var o=n(t,e,r,a);if(o&&!1!==o[0].index){var s=o[0];if(void 0===s.index)return o;var l=t.subplot,c=s.cd[s.index],u=s.trace;if(l.isPtInside(c))return s.xLabelVal=void 0,s.yLabelVal=void 0,i(c,u,l,s),s.hovertemplate=u.hovertemplate,o}},makeHoverPointText:i}},{"../scatter/hover":1131}],1198:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"scatterpolar",basePlotModule:t("../../plots/polar"),categories:["polar","symbols","showLegend","scatter-like"],attributes:t("./attributes"),supplyDefaults:t("./defaults").supplyDefaults,colorbar:t("../scatter/marker_colorbar"),formatLabels:t("./format_labels"),calc:t("./calc"),plot:t("./plot"),style:t("../scatter/style").style,styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover").hoverPoints,selectPoints:t("../scatter/select"),meta:{}}},{"../../plots/polar":829,"../scatter/marker_colorbar":1138,"../scatter/select":1141,"../scatter/style":1143,"./attributes":1193,"./calc":1194,"./defaults":1195,"./format_labels":1196,"./hover":1197,"./plot":1199}],1199:[function(t,e,r){"use strict";var n=t("../scatter/plot"),i=t("../../constants/numerical").BADNUM;e.exports=function(t,e,r){for(var a=e.layers.frontplot.select("g.scatterlayer"),o={xaxis:e.xaxis,yaxis:e.yaxis,plot:e.framework,layerClipId:e._hasClipOnAxisFalse?e.clipIds.forTraces:null},s=e.radialAxis,l=e.angularAxis,c=0;c=c&&(y.marker.cluster=d.tree),y.marker&&(y.markerSel.positions=y.markerUnsel.positions=y.marker.positions=_),y.line&&_.length>1&&l.extendFlat(y.line,s.linePositions(t,p,_)),y.text&&(l.extendFlat(y.text,{positions:_},s.textPosition(t,p,y.text,y.marker)),l.extendFlat(y.textSel,{positions:_},s.textPosition(t,p,y.text,y.markerSel)),l.extendFlat(y.textUnsel,{positions:_},s.textPosition(t,p,y.text,y.markerUnsel))),y.fill&&!f.fill2d&&(f.fill2d=!0),y.marker&&!f.scatter2d&&(f.scatter2d=!0),y.line&&!f.line2d&&(f.line2d=!0),y.text&&!f.glText&&(f.glText=!0),f.lineOptions.push(y.line),f.fillOptions.push(y.fill),f.markerOptions.push(y.marker),f.markerSelectedOptions.push(y.markerSel),f.markerUnselectedOptions.push(y.markerUnsel),f.textOptions.push(y.text),f.textSelectedOptions.push(y.textSel),f.textUnselectedOptions.push(y.textUnsel),f.selectBatch.push([]),f.unselectBatch.push([]),d.x=w,d.y=A,d.rawx=w,d.rawy=A,d.r=m,d.theta=v,d.positions=_,d._scene=f,d.index=f.count,f.count++}})),a(t,e,r)}}},{"../../lib":717,"../scattergl/constants":1173,"../scattergl/convert":1174,"../scattergl/plot":1181,"../scattergl/scene_update":1182,"fast-isnumeric":228,"point-cluster":471}],1207:[function(t,e,r){"use strict";var n=t("../../plots/template_attributes").hovertemplateAttrs,i=t("../../plots/template_attributes").texttemplateAttrs,a=t("../scatter/attributes"),o=t("../../plots/attributes"),s=t("../../components/colorscale/attributes"),l=t("../../components/drawing/attributes").dash,c=t("../../lib/extend").extendFlat,u=a.marker,h=a.line,f=u.line;e.exports={a:{valType:"data_array",editType:"calc"},b:{valType:"data_array",editType:"calc"},c:{valType:"data_array",editType:"calc"},sum:{valType:"number",dflt:0,min:0,editType:"calc"},mode:c({},a.mode,{dflt:"markers"}),text:c({},a.text,{}),texttemplate:i({editType:"plot"},{keys:["a","b","c","text"]}),hovertext:c({},a.hovertext,{}),line:{color:h.color,width:h.width,dash:l,shape:c({},h.shape,{values:["linear","spline"]}),smoothing:h.smoothing,editType:"calc"},connectgaps:a.connectgaps,cliponaxis:a.cliponaxis,fill:c({},a.fill,{values:["none","toself","tonext"],dflt:"none"}),fillcolor:a.fillcolor,marker:c({symbol:u.symbol,opacity:u.opacity,maxdisplayed:u.maxdisplayed,size:u.size,sizeref:u.sizeref,sizemin:u.sizemin,sizemode:u.sizemode,line:c({width:f.width,editType:"calc"},s("marker.line")),gradient:u.gradient,editType:"calc"},s("marker")),textfont:a.textfont,textposition:a.textposition,selected:a.selected,unselected:a.unselected,hoverinfo:c({},o.hoverinfo,{flags:["a","b","c","text","name"]}),hoveron:a.hoveron,hovertemplate:n()}},{"../../components/colorscale/attributes":599,"../../components/drawing/attributes":612,"../../lib/extend":708,"../../plots/attributes":762,"../../plots/template_attributes":841,"../scatter/attributes":1120}],1208:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../scatter/colorscale_calc"),a=t("../scatter/arrays_to_calcdata"),o=t("../scatter/calc_selection"),s=t("../scatter/calc").calcMarkerSize,l=["a","b","c"],c={a:["b","c"],b:["a","c"],c:["a","b"]};e.exports=function(t,e){var r,u,h,f,p,d,g=t._fullLayout[e.subplot].sum,m=e.sum||g,v={a:e.a,b:e.b,c:e.c};for(r=0;r"),o.hovertemplate=f.hovertemplate,a}function x(t,e){v.push(t._hovertitle+": "+e)}}},{"../scatter/hover":1131}],1213:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),supplyDefaults:t("./defaults"),colorbar:t("../scatter/marker_colorbar"),formatLabels:t("./format_labels"),calc:t("./calc"),plot:t("./plot"),style:t("../scatter/style").style,styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../scatter/select"),eventData:t("./event_data"),moduleType:"trace",name:"scatterternary",basePlotModule:t("../../plots/ternary"),categories:["ternary","symbols","showLegend","scatter-like"],meta:{}}},{"../../plots/ternary":842,"../scatter/marker_colorbar":1138,"../scatter/select":1141,"../scatter/style":1143,"./attributes":1207,"./calc":1208,"./defaults":1209,"./event_data":1210,"./format_labels":1211,"./hover":1212,"./plot":1214}],1214:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e,r){var i=e.plotContainer;i.select(".scatterlayer").selectAll("*").remove();var a={xaxis:e.xaxis,yaxis:e.yaxis,plot:i,layerClipId:e._hasClipOnAxisFalse?e.clipIdRelative:null},o=e.layers.frontplot.select("g.scatterlayer");n(t,a,r,o)}},{"../scatter/plot":1140}],1215:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),a=t("../../plots/template_attributes").hovertemplateAttrs,o=t("../scattergl/attributes"),s=t("../../plots/cartesian/constants").idRegex,l=t("../../plot_api/plot_template").templatedArray,c=t("../../lib/extend").extendFlat,u=n.marker,h=u.line,f=c(i("marker.line",{editTypeOverride:"calc"}),{width:c({},h.width,{editType:"calc"}),editType:"calc"}),p=c(i("marker"),{symbol:u.symbol,size:c({},u.size,{editType:"markerSize"}),sizeref:u.sizeref,sizemin:u.sizemin,sizemode:u.sizemode,opacity:u.opacity,colorbar:u.colorbar,line:f,editType:"calc"});function d(t){return{valType:"info_array",freeLength:!0,editType:"calc",items:{valType:"subplotid",regex:s[t],editType:"plot"}}}p.color.editType=p.cmin.editType=p.cmax.editType="style",e.exports={dimensions:l("dimension",{visible:{valType:"boolean",dflt:!0,editType:"calc"},label:{valType:"string",editType:"calc"},values:{valType:"data_array",editType:"calc+clearAxisTypes"},axis:{type:{valType:"enumerated",values:["linear","log","date","category"],editType:"calc+clearAxisTypes"},matches:{valType:"boolean",dflt:!1,editType:"calc"},editType:"calc+clearAxisTypes"},editType:"calc+clearAxisTypes"}),text:c({},o.text,{}),hovertext:c({},o.hovertext,{}),hovertemplate:a(),marker:p,xaxes:d("x"),yaxes:d("y"),diagonal:{visible:{valType:"boolean",dflt:!0,editType:"calc"},editType:"calc"},showupperhalf:{valType:"boolean",dflt:!0,editType:"calc"},showlowerhalf:{valType:"boolean",dflt:!0,editType:"calc"},selected:{marker:o.selected.marker,editType:"calc"},unselected:{marker:o.unselected.marker,editType:"calc"},opacity:o.opacity}},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plot_api/plot_template":755,"../../plots/cartesian/constants":771,"../../plots/template_attributes":841,"../scatter/attributes":1120,"../scattergl/attributes":1171}],1216:[function(t,e,r){"use strict";var n=t("regl-line2d"),i=t("../../registry"),a=t("../../lib/prepare_regl"),o=t("../../plots/get_data").getModuleCalcData,s=t("../../plots/cartesian"),l=t("../../plots/cartesian/axis_ids").getFromId,c=t("../../plots/cartesian/axes").shouldShowZeroLine,u="splom";function h(t,e,r){for(var n=r.matrixOptions.data.length,i=e._visibleDims,a=r.viewOpts.ranges=new Array(n),o=0;of?2*(b.sizeAvg||Math.max(b.size,3)):a(e,x),p=0;pa&&l?r._splomSubplots[I]=1:i-1,M=!0;if("lasso"===y||"select"===y||f.selectedpoints||C){var k=f._length;if(f.selectedpoints){d.selectBatch=f.selectedpoints;var I=f.selectedpoints,T={};for(s=0;s1&&(u=g[y-1],f=m[y-1],d=v[y-1]),e=0;eu?"-":"+")+"x")).replace("y",(h>f?"-":"+")+"y")).replace("z",(p>d?"-":"+")+"z");var L=function(){y=0,k=[],I=[],T=[]};(!y||y2?t.slice(1,e-1):2===e?[(t[0]+t[1])/2]:t}function p(t){var e=t.length;return 1===e?[.5,.5]:[t[1]-t[0],t[e-1]-t[e-2]]}function d(t,e){var r=t.fullSceneLayout,i=t.dataScale,u=e._len,h={};function d(t,e){var n=r[e],o=i[c[e]];return a.simpleMap(t,(function(t){return n.d2l(t)*o}))}if(h.vectors=l(d(e._u,"xaxis"),d(e._v,"yaxis"),d(e._w,"zaxis"),u),!u)return{positions:[],cells:[]};var g=d(e._Xs,"xaxis"),m=d(e._Ys,"yaxis"),v=d(e._Zs,"zaxis");if(h.meshgrid=[g,m,v],h.gridFill=e._gridFill,e._slen)h.startingPositions=l(d(e._startsX,"xaxis"),d(e._startsY,"yaxis"),d(e._startsZ,"zaxis"));else{for(var y=m[0],x=f(g),b=f(v),_=new Array(x.length*b.length),w=0,A=0;A=0};v?(r=Math.min(m.length,x.length),l=function(t){return M(m[t])&&k(t)},h=function(t){return String(m[t])}):(r=Math.min(y.length,x.length),l=function(t){return M(y[t])&&k(t)},h=function(t){return String(y[t])}),_&&(r=Math.min(r,b.length));for(var I=0;I1){for(var E=a.randstr(),D=0;D"),name:C||P("name")?l.name:void 0,color:A("hoverlabel.bgcolor")||y.color,borderColor:A("hoverlabel.bordercolor"),fontFamily:A("hoverlabel.font.family"),fontSize:A("hoverlabel.font.size"),fontColor:A("hoverlabel.font.color"),nameLength:A("hoverlabel.namelength"),textAlign:A("hoverlabel.align"),hovertemplate:C,hovertemplateLabels:S,eventData:[h(i,l,f.eventDataKeys)]};m&&(R.x0=I-i.rInscribed*i.rpx1,R.x1=I+i.rInscribed*i.rpx1,R.idealAlign=i.pxmid[0]<0?"left":"right"),v&&(R.x=I,R.idealAlign=I<0?"left":"right"),o.loneHover(R,{container:a._hoverlayer.node(),outerContainer:a._paper.node(),gd:r}),d._hasHoverLabel=!0}if(v){var F=t.select("path.surface");f.styleOne(F,i,l,{hovered:!0})}d._hasHoverEvent=!0,r.emit("plotly_hover",{points:[h(i,l,f.eventDataKeys)],event:n.event})}})),t.on("mouseout",(function(e){var i=r._fullLayout,a=r._fullData[d.index],s=n.select(this).datum();if(d._hasHoverEvent&&(e.originalEvent=n.event,r.emit("plotly_unhover",{points:[h(s,a,f.eventDataKeys)],event:n.event}),d._hasHoverEvent=!1),d._hasHoverLabel&&(o.loneUnhover(i._hoverlayer.node()),d._hasHoverLabel=!1),v){var l=t.select("path.surface");f.styleOne(l,s,a,{hovered:!1})}})),t.on("click",(function(t){var e=r._fullLayout,a=r._fullData[d.index],s=m&&(c.isHierarchyRoot(t)||c.isLeaf(t)),u=c.getPtId(t),p=c.isEntry(t)?c.findEntryWithChild(g,u):c.findEntryWithLevel(g,u),v=c.getPtId(p),y={points:[h(t,a,f.eventDataKeys)],event:n.event};s||(y.nextLevel=v);var x=l.triggerHandler(r,"plotly_"+d.type+"click",y);if(!1!==x&&e.hovermode&&(r._hoverdata=[h(t,a,f.eventDataKeys)],o.click(r,n.event)),!s&&!1!==x&&!r._dragging&&!r._transitioning){i.call("_storeDirectGUIEdit",a,e._tracePreGUI[a.uid],{level:a.level});var b={data:[{level:v}],traces:[d.index]},_={frame:{redraw:!1,duration:f.transitionTime},transition:{duration:f.transitionTime,easing:f.transitionEasing},mode:"immediate",fromcurrent:!0};o.loneUnhover(e._hoverlayer.node()),i.call("animate",r,b,_)}}))}},{"../../components/fx":630,"../../components/fx/helpers":627,"../../lib":717,"../../lib/events":707,"../../registry":846,"../pie/helpers":1099,"./helpers":1237,d3:165}],1237:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../../lib/setcursor"),o=t("../pie/helpers");function s(t){return t.data.data.pid}r.findEntryWithLevel=function(t,e){var n;return e&&t.eachAfter((function(t){if(r.getPtId(t)===e)return n=t.copy()})),n||t},r.findEntryWithChild=function(t,e){var n;return t.eachAfter((function(t){for(var i=t.children||[],a=0;a0)},r.getMaxDepth=function(t){return t.maxdepth>=0?t.maxdepth:1/0},r.isHeader=function(t,e){return!(r.isLeaf(t)||t.depth===e._maxDepth-1)},r.getParent=function(t,e){return r.findEntryWithLevel(t,s(e))},r.listPath=function(t,e){var n=t.parent;if(!n)return[];var i=e?[n.data[e]]:[n];return r.listPath(n,e).concat(i)},r.getPath=function(t){return r.listPath(t,"label").join("/")+"/"},r.formatValue=o.formatPieValue,r.formatPercent=function(t,e){var r=n.formatPercent(t,0);return"0%"===r&&(r=o.formatPiePercent(t,e)),r}},{"../../components/color":592,"../../lib":717,"../../lib/setcursor":737,"../pie/helpers":1099}],1238:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"sunburst",basePlotModule:t("./base_plot"),categories:[],animatable:!0,attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot").plot,style:t("./style").style,colorbar:t("../scatter/marker_colorbar"),meta:{}}},{"../scatter/marker_colorbar":1138,"./attributes":1231,"./base_plot":1232,"./calc":1233,"./defaults":1235,"./layout_attributes":1239,"./layout_defaults":1240,"./plot":1241,"./style":1242}],1239:[function(t,e,r){"use strict";e.exports={sunburstcolorway:{valType:"colorlist",editType:"calc"},extendsunburstcolors:{valType:"boolean",dflt:!0,editType:"calc"}}},{}],1240:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("sunburstcolorway",e.colorway),r("extendsunburstcolors")}},{"../../lib":717,"./layout_attributes":1239}],1241:[function(t,e,r){"use strict";var n=t("d3"),i=t("d3-hierarchy"),a=t("../../components/drawing"),o=t("../../lib"),s=t("../../lib/svg_text_utils"),l=t("../bar/uniform_text"),c=l.recordMinTextSize,u=l.clearMinTextSize,h=t("../pie/plot"),f=h.computeTransform,p=h.transformInsideText,d=t("./style").styleOne,g=t("../bar/style").resizeText,m=t("./fx"),v=t("./constants"),y=t("./helpers");function x(t,e,l,u){var h=t._fullLayout,g=!h.uniformtext.mode&&y.hasTransition(u),x=n.select(l).selectAll("g.slice"),_=e[0],w=_.trace,A=_.hierarchy,C=y.findEntryWithLevel(A,w.level),M=y.getMaxDepth(w),k=h._size,I=w.domain,T=k.w*(I.x[1]-I.x[0]),L=k.h*(I.y[1]-I.y[0]),S=.5*Math.min(T,L),E=_.cx=k.l+k.w*(I.x[1]+I.x[0])/2,D=_.cy=k.t+k.h*(1-I.y[0])-L/2;if(!C)return x.remove();var P=null,O={};g&&x.each((function(t){O[y.getPtId(t)]={rpx0:t.rpx0,rpx1:t.rpx1,x0:t.x0,x1:t.x1,transform:t.transform},!P&&y.isEntry(t)&&(P=t)}));var z=function(t){return i.partition().size([2*Math.PI,t.height+1])(t)}(C).descendants(),R=C.height+1,F=0,N=M;_.hasMultipleRoots&&y.isHierarchyRoot(C)&&(z=z.slice(1),R-=1,F=1,N+=1),z=z.filter((function(t){return t.y1<=N}));var j=Math.min(R,M),B=function(t){return(t-F)/j*S},Y=function(t,e){return[t*Math.cos(e),-t*Math.sin(e)]},V=function(t){return o.pathAnnulus(t.rpx0,t.rpx1,t.x0,t.x1,E,D)},U=function(t){return E+b(t)[0]*(t.transform.rCenter||0)+(t.transform.x||0)},H=function(t){return D+b(t)[1]*(t.transform.rCenter||0)+(t.transform.y||0)};(x=x.data(z,y.getPtId)).enter().append("g").classed("slice",!0),g?x.exit().transition().each((function(){var t=n.select(this);t.select("path.surface").transition().attrTween("d",(function(t){var e=function(t){var e,r=y.getPtId(t),i=O[r],a=O[y.getPtId(C)];if(a){var o=t.x1>a.x1?2*Math.PI:0;e=t.rpx1G?2*Math.PI:0;e={x0:a,x1:a}}else e={rpx0:S,rpx1:S},o.extendFlat(e,Z(t));else e={rpx0:0,rpx1:0};else e={x0:0,x1:0};return n.interpolate(e,i)}(t);return function(t){return V(e(t))}})):u.attr("d",V),l.call(m,C,t,e,{eventDataKeys:v.eventDataKeys,transitionTime:v.CLICK_TRANSITION_TIME,transitionEasing:v.CLICK_TRANSITION_EASING}).call(y.setSliceCursor,t,{hideOnRoot:!0,hideOnLeaves:!0,isTransitioning:t._transitioning}),u.call(d,i,w);var x=o.ensureSingle(l,"g","slicetext"),b=o.ensureSingle(x,"text","",(function(t){t.attr("data-notex",1)})),A=o.ensureUniformFontSize(t,y.determineTextFont(w,i,h.font));b.text(r.formatSliceLabel(i,C,w,e,h)).classed("slicetext",!0).attr("text-anchor","middle").call(a.font,A).call(s.convertToTspans,t);var M=a.bBox(b.node());i.transform=p(M,i,_),i.transform.targetX=U(i),i.transform.targetY=H(i);var k=function(t,e){var r=t.transform;return f(r,e),r.fontSize=A.size,c(w.type,r,h),o.getTextTransform(r)};g?b.transition().attrTween("transform",(function(t){var e=function(t){var e,r=O[y.getPtId(t)],i=t.transform;if(r)e=r;else if(e={rpx1:t.rpx1,transform:{textPosAngle:i.textPosAngle,scale:0,rotate:i.rotate,rCenter:i.rCenter,x:i.x,y:i.y}},P)if(t.parent)if(G){var a=t.x1>G?2*Math.PI:0;e.x0=e.x1=a}else o.extendFlat(e,Z(t));else e.x0=e.x1=0;else e.x0=e.x1=0;var s=n.interpolate(e.transform.textPosAngle,t.transform.textPosAngle),l=n.interpolate(e.rpx1,t.rpx1),u=n.interpolate(e.x0,t.x0),f=n.interpolate(e.x1,t.x1),p=n.interpolate(e.transform.scale,i.scale),d=n.interpolate(e.transform.rotate,i.rotate),g=0===i.rCenter?3:0===e.transform.rCenter?1/3:1,m=n.interpolate(e.transform.rCenter,i.rCenter);return function(t){var e=l(t),r=u(t),n=f(t),a=function(t){return m(Math.pow(t,g))}(t),o={pxmid:Y(e,(r+n)/2),rpx1:e,transform:{textPosAngle:s(t),rCenter:a,x:i.x,y:i.y}};return c(w.type,i,h),{transform:{targetX:U(o),targetY:H(o),scale:p(t),rotate:d(t),rCenter:a}}}}(t);return function(t){return k(e(t),M)}})):b.attr("transform",k(i,M))}))}function b(t){return e=t.rpx1,r=t.transform.textPosAngle,[e*Math.sin(r),-e*Math.cos(r)];var e,r}r.plot=function(t,e,r,i){var a,o,s=t._fullLayout,l=s._sunburstlayer,c=!r,h=!s.uniformtext.mode&&y.hasTransition(r);u("sunburst",s),(a=l.selectAll("g.trace.sunburst").data(e,(function(t){return t[0].trace.uid}))).enter().append("g").classed("trace",!0).classed("sunburst",!0).attr("stroke-linejoin","round"),a.order(),h?(i&&(o=i()),n.transition().duration(r.duration).ease(r.easing).each("end",(function(){o&&o()})).each("interrupt",(function(){o&&o()})).each((function(){l.selectAll("g.trace").each((function(e){x(t,e,this,r)}))}))):(a.each((function(e){x(t,e,this,r)})),s.uniformtext.mode&&g(t,s._sunburstlayer.selectAll(".trace"),"sunburst")),c&&a.exit().remove()},r.formatSliceLabel=function(t,e,r,n,i){var a=r.texttemplate,s=r.textinfo;if(!(a||s&&"none"!==s))return"";var l=i.separators,c=n[0],u=t.data.data,h=c.hierarchy,f=y.isHierarchyRoot(t),p=y.getParent(h,t),d=y.getValue(t);if(!a){var g,m=s.split("+"),v=function(t){return-1!==m.indexOf(t)},x=[];if(v("label")&&u.label&&x.push(u.label),u.hasOwnProperty("v")&&v("value")&&x.push(y.formatValue(u.v,l)),!f){v("current path")&&x.push(y.getPath(t.data));var b=0;v("percent parent")&&b++,v("percent entry")&&b++,v("percent root")&&b++;var _=b>1;if(b){var w,A=function(t){g=y.formatPercent(w,l),_&&(g+=" of "+t),x.push(g)};v("percent parent")&&!f&&(w=d/y.getValue(p),A("parent")),v("percent entry")&&(w=d/y.getValue(e),A("entry")),v("percent root")&&(w=d/y.getValue(h),A("root"))}}return v("text")&&(g=o.castOption(r,u.i,"text"),o.isValidTextValue(g)&&x.push(g)),x.join("
")}var C=o.castOption(r,u.i,"texttemplate");if(!C)return"";var M={};u.label&&(M.label=u.label),u.hasOwnProperty("v")&&(M.value=u.v,M.valueLabel=y.formatValue(u.v,l)),M.currentPath=y.getPath(t.data),f||(M.percentParent=d/y.getValue(p),M.percentParentLabel=y.formatPercent(M.percentParent,l),M.parent=y.getPtLabel(p)),M.percentEntry=d/y.getValue(e),M.percentEntryLabel=y.formatPercent(M.percentEntry,l),M.entry=y.getPtLabel(e),M.percentRoot=d/y.getValue(h),M.percentRootLabel=y.formatPercent(M.percentRoot,l),M.root=y.getPtLabel(h),u.hasOwnProperty("color")&&(M.color=u.color);var k=o.castOption(r,u.i,"text");return(o.isValidTextValue(k)||""===k)&&(M.text=k),M.customdata=o.castOption(r,u.i,"customdata"),o.texttemplateString(C,M,i._d3locale,M,r._meta||{})}},{"../../components/drawing":613,"../../lib":717,"../../lib/svg_text_utils":741,"../bar/style":870,"../bar/uniform_text":872,"../pie/plot":1103,"./constants":1234,"./fx":1236,"./helpers":1237,"./style":1242,d3:165,"d3-hierarchy":159}],1242:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/color"),a=t("../../lib"),o=t("../bar/uniform_text").resizeText;function s(t,e,r){var n=e.data.data,o=!e.children,s=n.i,l=a.castOption(r,s,"marker.line.color")||i.defaultLine,c=a.castOption(r,s,"marker.line.width")||0;t.style("stroke-width",c).call(i.fill,n.color).call(i.stroke,l).style("opacity",o?r.leaf.opacity:null)}e.exports={style:function(t){var e=t._fullLayout._sunburstlayer.selectAll(".trace");o(t,e,"sunburst"),e.each((function(t){var e=n.select(this),r=t[0].trace;e.style("opacity",r.opacity),e.selectAll("path.surface").each((function(t){n.select(this).call(s,t,r)}))}))},styleOne:s}},{"../../components/color":592,"../../lib":717,"../bar/uniform_text":872,d3:165}],1243:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/attributes"),a=t("../../plots/template_attributes").hovertemplateAttrs,o=t("../../plots/attributes"),s=t("../../lib/extend").extendFlat,l=t("../../plot_api/edit_types").overrideAll;function c(t){return{show:{valType:"boolean",dflt:!1},start:{valType:"number",dflt:null,editType:"plot"},end:{valType:"number",dflt:null,editType:"plot"},size:{valType:"number",dflt:null,min:0,editType:"plot"},project:{x:{valType:"boolean",dflt:!1},y:{valType:"boolean",dflt:!1},z:{valType:"boolean",dflt:!1}},color:{valType:"color",dflt:n.defaultLine},usecolormap:{valType:"boolean",dflt:!1},width:{valType:"number",min:1,max:16,dflt:2},highlight:{valType:"boolean",dflt:!0},highlightcolor:{valType:"color",dflt:n.defaultLine},highlightwidth:{valType:"number",min:1,max:16,dflt:2}}}var u=e.exports=l(s({z:{valType:"data_array"},x:{valType:"data_array"},y:{valType:"data_array"},text:{valType:"string",dflt:"",arrayOk:!0},hovertext:{valType:"string",dflt:"",arrayOk:!0},hovertemplate:a(),connectgaps:{valType:"boolean",dflt:!1,editType:"calc"},surfacecolor:{valType:"data_array"}},i("",{colorAttr:"z or surfacecolor",showScaleDflt:!0,autoColorDflt:!1,editTypeOverride:"calc"}),{contours:{x:c(),y:c(),z:c()},hidesurface:{valType:"boolean",dflt:!1},lightposition:{x:{valType:"number",min:-1e5,max:1e5,dflt:10},y:{valType:"number",min:-1e5,max:1e5,dflt:1e4},z:{valType:"number",min:-1e5,max:1e5,dflt:0}},lighting:{ambient:{valType:"number",min:0,max:1,dflt:.8},diffuse:{valType:"number",min:0,max:1,dflt:.8},specular:{valType:"number",min:0,max:2,dflt:.05},roughness:{valType:"number",min:0,max:1,dflt:.5},fresnel:{valType:"number",min:0,max:5,dflt:.2}},opacity:{valType:"number",min:0,max:1,dflt:1},_deprecated:{zauto:s({},i.zauto,{}),zmin:s({},i.zmin,{}),zmax:s({},i.zmax,{})},hoverinfo:s({},o.hoverinfo),showlegend:s({},o.showlegend,{dflt:!1})}),"calc","nested");u.x.editType=u.y.editType=u.z.editType="calc+clearAxisTypes",u.transforms=void 0},{"../../components/color":592,"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plot_api/edit_types":748,"../../plots/attributes":762,"../../plots/template_attributes":841}],1244:[function(t,e,r){"use strict";var n=t("../../components/colorscale/calc");e.exports=function(t,e){e.surfacecolor?n(t,e,{vals:e.surfacecolor,containerStr:"",cLetter:"c"}):n(t,e,{vals:e.z,containerStr:"",cLetter:"c"})}},{"../../components/colorscale/calc":600}],1245:[function(t,e,r){"use strict";var n=t("gl-surface3d"),i=t("ndarray"),a=t("ndarray-homography"),o=t("ndarray-fill"),s=t("../../lib").isArrayOrTypedArray,l=t("../../lib/gl_format_color").parseColorScale,c=t("../../lib/str2rgbarray"),u=t("../../components/colorscale").extractOpts,h=t("../heatmap/interp2d"),f=t("../heatmap/find_empties");function p(t,e,r){this.scene=t,this.uid=r,this.surface=e,this.data=null,this.showContour=[!1,!1,!1],this.contourStart=[null,null,null],this.contourEnd=[null,null,null],this.contourSize=[0,0,0],this.minValues=[1/0,1/0,1/0],this.maxValues=[-1/0,-1/0,-1/0],this.dataScaleX=1,this.dataScaleY=1,this.refineData=!0,this.objectOffset=[0,0,0]}var d=p.prototype;d.getXat=function(t,e,r,n){var i=s(this.data.x)?s(this.data.x[0])?this.data.x[e][t]:this.data.x[t]:t;return void 0===r?i:n.d2l(i,0,r)},d.getYat=function(t,e,r,n){var i=s(this.data.y)?s(this.data.y[0])?this.data.y[e][t]:this.data.y[e]:e;return void 0===r?i:n.d2l(i,0,r)},d.getZat=function(t,e,r,n){var i=this.data.z[e][t];return null===i&&this.data.connectgaps&&this.data._interpolatedZ&&(i=this.data._interpolatedZ[e][t]),void 0===r?i:n.d2l(i,0,r)},d.handlePick=function(t){if(t.object===this.surface){var e=(t.data.index[0]-1)/this.dataScaleX-1,r=(t.data.index[1]-1)/this.dataScaleY-1,n=Math.max(Math.min(Math.round(e),this.data.z[0].length-1),0),i=Math.max(Math.min(Math.round(r),this.data._ylength-1),0);t.index=[n,i],t.traceCoordinate=[this.getXat(n,i),this.getYat(n,i),this.getZat(n,i)],t.dataCoordinate=[this.getXat(n,i,this.data.xcalendar,this.scene.fullSceneLayout.xaxis),this.getYat(n,i,this.data.ycalendar,this.scene.fullSceneLayout.yaxis),this.getZat(n,i,this.data.zcalendar,this.scene.fullSceneLayout.zaxis)];for(var a=0;a<3;a++){var o=t.dataCoordinate[a];null!=o&&(t.dataCoordinate[a]*=this.scene.dataScale[a])}var s=this.data.hovertext||this.data.text;return Array.isArray(s)&&s[i]&&void 0!==s[i][n]?t.textLabel=s[i][n]:t.textLabel=s||"",t.data.dataCoordinate=t.dataCoordinate.slice(),this.surface.highlight(t.data),this.scene.glplot.spikes.position=t.dataCoordinate,!0}};var g=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999];function m(t,e){if(t0){r=g[n];break}return r}function x(t,e){if(!(t<1||e<1)){for(var r=v(t),n=v(e),i=1,a=0;aw;)r--,r/=y(r),++r<_&&(r=w);var n=Math.round(r/t);return n>1?n:1},d.refineCoords=function(t){for(var e=this.dataScaleX,r=this.dataScaleY,n=t[0].shape[0],o=t[0].shape[1],s=0|Math.floor(t[0].shape[0]*e+1),l=0|Math.floor(t[0].shape[1]*r+1),c=1+n+1,u=1+o+1,h=i(new Float32Array(c*u),[c,u]),f=0;f0&&null!==this.contourStart[t]&&null!==this.contourEnd[t]&&this.contourEnd[t]>this.contourStart[t]))for(i[t]=!0,e=this.contourStart[t];ea&&(this.minValues[e]=a),this.maxValues[e]",maxDimensionCount:60,overdrag:45,releaseTransitionDuration:120,releaseTransitionEase:"cubic-out",scrollbarCaptureWidth:18,scrollbarHideDelay:1e3,scrollbarHideDuration:1e3,scrollbarOffset:5,scrollbarWidth:8,transitionDuration:100,transitionEase:"cubic-out",uplift:5,wrapSpacer:" ",wrapSplitCharacter:" ",cn:{table:"table",tableControlView:"table-control-view",scrollBackground:"scroll-background",yColumn:"y-column",columnBlock:"column-block",scrollAreaClip:"scroll-area-clip",scrollAreaClipRect:"scroll-area-clip-rect",columnBoundary:"column-boundary",columnBoundaryClippath:"column-boundary-clippath",columnBoundaryRect:"column-boundary-rect",columnCells:"column-cells",columnCell:"column-cell",cellRect:"cell-rect",cellText:"cell-text",cellTextHolder:"cell-text-holder",scrollbarKit:"scrollbar-kit",scrollbar:"scrollbar",scrollbarSlider:"scrollbar-slider",scrollbarGlyph:"scrollbar-glyph",scrollbarCaptureZone:"scrollbar-capture-zone"}}},{}],1252:[function(t,e,r){"use strict";var n=t("./constants"),i=t("../../lib/extend").extendFlat,a=t("fast-isnumeric");function o(t){if(Array.isArray(t)){for(var e=0,r=0;r=e||c===t.length-1)&&(n[i]=o,o.key=l++,o.firstRowIndex=s,o.lastRowIndex=c,o={firstRowIndex:null,lastRowIndex:null,rows:[]},i+=a,s=c+1,a=0);return n}e.exports=function(t,e){var r=l(e.cells.values),p=function(t){return t.slice(e.header.values.length,t.length)},d=l(e.header.values);d.length&&!d[0].length&&(d[0]=[""],d=l(d));var g=d.concat(p(r).map((function(){return c((d[0]||[""]).length)}))),m=e.domain,v=Math.floor(t._fullLayout._size.w*(m.x[1]-m.x[0])),y=Math.floor(t._fullLayout._size.h*(m.y[1]-m.y[0])),x=e.header.values.length?g[0].map((function(){return e.header.height})):[n.emptyHeaderHeight],b=r.length?r[0].map((function(){return e.cells.height})):[],_=x.reduce(s,0),w=f(b,y-_+n.uplift),A=h(f(x,_),[]),C=h(w,A),M={},k=e._fullInput.columnorder.concat(p(r.map((function(t,e){return e})))),I=g.map((function(t,r){var n=Array.isArray(e.columnwidth)?e.columnwidth[Math.min(r,e.columnwidth.length-1)]:e.columnwidth;return a(n)?Number(n):1})),T=I.reduce(s,0);I=I.map((function(t){return t/T*v}));var L=Math.max(o(e.header.line.width),o(e.cells.line.width)),S={key:e.uid+t._context.staticPlot,translateX:m.x[0]*t._fullLayout._size.w,translateY:t._fullLayout._size.h*(1-m.y[1]),size:t._fullLayout._size,width:v,maxLineWidth:L,height:y,columnOrder:k,groupHeight:y,rowBlocks:C,headerRowBlocks:A,scrollY:0,cells:i({},e.cells,{values:r}),headerCells:i({},e.header,{values:g}),gdColumns:g.map((function(t){return t[0]})),gdColumnsOriginalOrder:g.map((function(t){return t[0]})),prevPages:[0,0],scrollbarState:{scrollbarScrollInProgress:!1},columns:g.map((function(t,e){var r=M[t];return M[t]=(r||0)+1,{key:t+"__"+M[t],label:t,specIndex:e,xIndex:k[e],xScale:u,x:void 0,calcdata:void 0,columnWidth:I[e]}}))};return S.columns.forEach((function(t){t.calcdata=S,t.x=u(t)})),S}},{"../../lib/extend":708,"./constants":1251,"fast-isnumeric":228}],1253:[function(t,e,r){"use strict";var n=t("../../lib/extend").extendFlat;r.splitToPanels=function(t){var e=[0,0],r=n({},t,{key:"header",type:"header",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!0,values:t.calcdata.headerCells.values[t.specIndex],rowBlocks:t.calcdata.headerRowBlocks,calcdata:n({},t.calcdata,{cells:t.calcdata.headerCells})});return[n({},t,{key:"cells1",type:"cells",page:0,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),n({},t,{key:"cells2",type:"cells",page:1,prevPages:e,currentRepaint:[null,null],dragHandle:!1,values:t.calcdata.cells.values[t.specIndex],rowBlocks:t.calcdata.rowBlocks}),r]},r.splitToCells=function(t){var e=function(t){var e=t.rowBlocks[t.page],r=e?e.rows[0].rowIndex:0,n=e?r+e.rows.length:0;return[r,n]}(t);return(t.values||[]).slice(e[0],e[1]).map((function(r,n){return{keyWithinBlock:n+("string"==typeof r&&r.match(/[<$&> ]/)?"_keybuster_"+Math.random():""),key:e[0]+n,column:t,calcdata:t.calcdata,page:t.page,rowBlocks:t.rowBlocks,value:r}}))}},{"../../lib/extend":708}],1254:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../plots/domain").defaults;e.exports=function(t,e,r,o){function s(r,a){return n.coerce(t,e,i,r,a)}a(e,o,s),s("columnwidth"),s("header.values"),s("header.format"),s("header.align"),s("header.prefix"),s("header.suffix"),s("header.height"),s("header.line.width"),s("header.line.color"),s("header.fill.color"),n.coerceFont(s,"header.font",n.extendFlat({},o.font)),function(t,e){for(var r=t.columnorder||[],n=t.header.values.length,i=r.slice(0,n),a=i.slice().sort((function(t,e){return t-e})),o=i.map((function(t){return a.indexOf(t)})),s=o.length;s/i),l=!o||s;t.mayHaveMarkup=o&&a.match(/[<&>]/);var c,u="string"==typeof(c=a)&&c.match(n.latexCheck);t.latex=u;var h,f,p=u?"":_(t.calcdata.cells.prefix,e,r)||"",d=u?"":_(t.calcdata.cells.suffix,e,r)||"",g=u?null:_(t.calcdata.cells.format,e,r)||null,m=p+(g?i.format(g)(t.value):t.value)+d;if(t.wrappingNeeded=!t.wrapped&&!l&&!u&&(h=b(m)),t.cellHeightMayIncrease=s||u||t.mayHaveMarkup||(void 0===h?b(m):h),t.needsConvertToTspans=t.mayHaveMarkup||t.wrappingNeeded||t.latex,t.wrappingNeeded){var v=(" "===n.wrapSplitCharacter?m.replace(/i&&n.push(a),i+=l}return n}(i,l,s);1===c.length&&(c[0]===i.length-1?c.unshift(c[0]-1):c.push(c[0]+1)),c[0]%2&&c.reverse(),e.each((function(t,e){t.page=c[e],t.scrollY=l})),e.attr("transform",(function(t){return"translate(0 "+(P(t.rowBlocks,t.page)-t.scrollY)+")"})),t&&(T(t,r,e,c,n.prevPages,n,0),T(t,r,e,c,n.prevPages,n,1),v(r,t))}}function I(t,e,r,a){return function(o){var s=o.calcdata?o.calcdata:o,l=e.filter((function(t){return s.key===t.key})),c=r||s.scrollbarState.dragMultiplier,u=s.scrollY;s.scrollY=void 0===a?s.scrollY+c*i.event.dy:a;var h=l.selectAll("."+n.cn.yColumn).selectAll("."+n.cn.columnBlock).filter(A);return k(t,h,l),s.scrollY===u}}function T(t,e,r,n,i,a,o){n[o]!==i[o]&&(clearTimeout(a.currentRepaint[o]),a.currentRepaint[o]=setTimeout((function(){var a=r.filter((function(t,e){return e===o&&n[e]!==i[e]}));y(t,e,a,r),i[o]=n[o]})))}function L(t,e,r,a){return function(){var o=i.select(e.parentNode);o.each((function(t){var e=t.fragments;o.selectAll("tspan.line").each((function(t,r){e[r].width=this.getComputedTextLength()}));var r,i,a=e[e.length-1].width,s=e.slice(0,-1),l=[],c=0,u=t.column.columnWidth-2*n.cellPad;for(t.value="";s.length;)c+(i=(r=s.shift()).width+a)>u&&(t.value+=l.join(n.wrapSpacer)+n.lineBreaker,l=[],c=0),l.push(r.text),c+=i;c&&(t.value+=l.join(n.wrapSpacer)),t.wrapped=!0})),o.selectAll("tspan.line").remove(),x(o.select("."+n.cn.cellText),r,t,a),i.select(e.parentNode.parentNode).call(D)}}function S(t,e,r,a,o){return function(){if(!o.settledY){var s=i.select(e.parentNode),l=R(o),c=o.key-l.firstRowIndex,u=l.rows[c].rowHeight,h=o.cellHeightMayIncrease?e.parentNode.getBoundingClientRect().height+2*n.cellPad:u,f=Math.max(h,u);f-l.rows[c].rowHeight&&(l.rows[c].rowHeight=f,t.selectAll("."+n.cn.columnCell).call(D),k(null,t.filter(A),0),v(r,a,!0)),s.attr("transform",(function(){var t=this.parentNode.getBoundingClientRect(),e=i.select(this.parentNode).select("."+n.cn.cellRect).node().getBoundingClientRect(),r=this.transform.baseVal.consolidate(),a=e.top-t.top+(r?r.matrix.f:n.cellPad);return"translate("+E(o,i.select(this.parentNode).select("."+n.cn.cellTextHolder).node().getBoundingClientRect().width)+" "+a+")"})),o.settledY=!0}}}function E(t,e){switch(t.align){case"left":return n.cellPad;case"right":return t.column.columnWidth-(e||0)-n.cellPad;case"center":return(t.column.columnWidth-(e||0))/2;default:return n.cellPad}}function D(t){t.attr("transform",(function(t){var e=t.rowBlocks[0].auxiliaryBlocks.reduce((function(t,e){return t+O(e,1/0)}),0);return"translate(0 "+(O(R(t),t.key)+e)+")"})).selectAll("."+n.cn.cellRect).attr("height",(function(t){return(e=R(t),r=t.key,e.rows[r-e.firstRowIndex]).rowHeight;var e,r}))}function P(t,e){for(var r=0,n=e-1;n>=0;n--)r+=z(t[n]);return r}function O(t,e){for(var r=0,n=0;n","<","|","/","\\"],dflt:">",editType:"plot"},thickness:{valType:"number",min:12,editType:"plot"},textfont:u({},s.textfont,{}),editType:"calc"},text:s.text,textinfo:l.textinfo,texttemplate:i({editType:"plot"},{keys:c.eventDataKeys.concat(["label","value"])}),hovertext:s.hovertext,hoverinfo:l.hoverinfo,hovertemplate:n({},{keys:c.eventDataKeys}),textfont:s.textfont,insidetextfont:s.insidetextfont,outsidetextfont:u({},s.outsidetextfont,{}),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"top left",editType:"plot"},domain:o({name:"treemap",trace:!0,editType:"calc"})}},{"../../components/colorscale/attributes":599,"../../lib/extend":708,"../../plots/domain":790,"../../plots/template_attributes":841,"../pie/attributes":1094,"../sunburst/attributes":1231,"./constants":1260}],1258:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.name="treemap",r.plot=function(t,e,i,a){n.plotBasePlot(r.name,t,e,i,a)},r.clean=function(t,e,i,a){n.cleanBasePlot(r.name,t,e,i,a)}},{"../../plots/plots":826}],1259:[function(t,e,r){"use strict";var n=t("../sunburst/calc");r.calc=function(t,e){return n.calc(t,e)},r.crossTraceCalc=function(t){return n._runCrossTraceCalc("treemap",t)}},{"../sunburst/calc":1233}],1260:[function(t,e,r){"use strict";e.exports={CLICK_TRANSITION_TIME:750,CLICK_TRANSITION_EASING:"poly",eventDataKeys:["currentPath","root","entry","percentRoot","percentEntry","percentParent"],gapWithPathbar:1}},{}],1261:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("../../components/color"),o=t("../../plots/domain").defaults,s=t("../bar/defaults").handleText,l=t("../bar/constants").TEXTPAD,c=t("../../components/colorscale"),u=c.hasColorscale,h=c.handleDefaults;e.exports=function(t,e,r,c){function f(r,a){return n.coerce(t,e,i,r,a)}var p=f("labels"),d=f("parents");if(p&&p.length&&d&&d.length){var g=f("values");g&&g.length?f("branchvalues"):f("count"),f("level"),f("maxdepth"),"squarify"===f("tiling.packing")&&f("tiling.squarifyratio"),f("tiling.flip"),f("tiling.pad");var m=f("text");f("texttemplate"),e.texttemplate||f("textinfo",Array.isArray(m)?"text+label":"label"),f("hovertext"),f("hovertemplate");var v=f("pathbar.visible");s(t,e,c,f,"auto",{hasPathbar:v,moduleHasSelected:!1,moduleHasUnselected:!1,moduleHasConstrain:!1,moduleHasCliponaxis:!1,moduleHasTextangle:!1,moduleHasInsideanchor:!1}),f("textposition");var y=-1!==e.textposition.indexOf("bottom");f("marker.line.width")&&f("marker.line.color",c.paper_bgcolor);var x=f("marker.colors"),b=e._hasColorscale=u(t,"marker","colors")||(t.marker||{}).coloraxis;b?h(t,e,c,f,{prefix:"marker.",cLetter:"c"}):f("marker.depthfade",!(x||[]).length);var _=2*e.textfont.size;f("marker.pad.t",y?_/4:_),f("marker.pad.l",_/4),f("marker.pad.r",_/4),f("marker.pad.b",y?_:_/4),b&&h(t,e,c,f,{prefix:"marker.",cLetter:"c"}),e._hovered={marker:{line:{width:2,color:a.contrast(c.paper_bgcolor)}}},v&&(f("pathbar.thickness",e.pathbar.textfont.size+2*l),f("pathbar.side"),f("pathbar.edgeshape")),o(e,c,f),e._length=null}else e.visible=!1}},{"../../components/color":592,"../../components/colorscale":604,"../../lib":717,"../../plots/domain":790,"../bar/constants":858,"../bar/defaults":860,"./attributes":1257}],1262:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../../lib/svg_text_utils"),s=t("./partition"),l=t("./style").styleOne,c=t("./constants"),u=t("../sunburst/helpers"),h=t("../sunburst/fx");e.exports=function(t,e,r,f,p){var d=p.barDifY,g=p.width,m=p.height,v=p.viewX,y=p.viewY,x=p.pathSlice,b=p.toMoveInsideSlice,_=p.strTransform,w=p.hasTransition,A=p.handleSlicesExit,C=p.makeUpdateSliceInterpolator,M=p.makeUpdateTextInterpolator,k={},I=t._fullLayout,T=e[0],L=T.trace,S=T.hierarchy,E=g/L._entryDepth,D=u.listPath(r.data,"id"),P=s(S.copy(),[g,m],{packing:"dice",pad:{inner:0,top:0,left:0,right:0,bottom:0}}).descendants();(P=P.filter((function(t){var e=D.indexOf(t.data.id);return-1!==e&&(t.x0=E*e,t.x1=E*(e+1),t.y0=d,t.y1=d+m,t.onPathbar=!0,!0)}))).reverse(),(f=f.data(P,u.getPtId)).enter().append("g").classed("pathbar",!0),A(f,!0,k,[g,m],x),f.order();var O=f;w&&(O=O.transition().each("end",(function(){var e=n.select(this);u.setSliceCursor(e,t,{hideOnRoot:!1,hideOnLeaves:!1,isTransitioning:!1})}))),O.each((function(s){s._hoverX=v(s.x1-Math.min(g,m)/2),s._hoverY=y(s.y1-m/2);var f=n.select(this),p=i.ensureSingle(f,"path","surface",(function(t){t.style("pointer-events","all")}));w?p.transition().attrTween("d",(function(t){var e=C(t,!0,k,[g,m]);return function(t){return x(e(t))}})):p.attr("d",x),f.call(h,r,t,e,{styleOne:l,eventDataKeys:c.eventDataKeys,transitionTime:c.CLICK_TRANSITION_TIME,transitionEasing:c.CLICK_TRANSITION_EASING}).call(u.setSliceCursor,t,{hideOnRoot:!1,hideOnLeaves:!1,isTransitioning:t._transitioning}),p.call(l,s,L,{hovered:!1}),s._text=(u.getPtLabel(s)||"").split("
").join(" ")||"";var d=i.ensureSingle(f,"g","slicetext"),A=i.ensureSingle(d,"text","",(function(t){t.attr("data-notex",1)})),T=i.ensureUniformFontSize(t,u.determineTextFont(L,s,I.font,{onPathbar:!0}));A.text(s._text||" ").classed("slicetext",!0).attr("text-anchor","start").call(a.font,T).call(o.convertToTspans,t),s.textBB=a.bBox(A.node()),s.transform=b(s,{fontSize:T.size,onPathbar:!0}),s.transform.fontSize=T.size,w?A.transition().attrTween("transform",(function(t){var e=M(t,!0,k,[g,m]);return function(t){return _(e(t))}})):A.attr("transform",_(s))}))}},{"../../components/drawing":613,"../../lib":717,"../../lib/svg_text_utils":741,"../sunburst/fx":1236,"../sunburst/helpers":1237,"./constants":1260,"./partition":1267,"./style":1269,d3:165}],1263:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../../lib/svg_text_utils"),s=t("./partition"),l=t("./style").styleOne,c=t("./constants"),u=t("../sunburst/helpers"),h=t("../sunburst/fx"),f=t("../sunburst/plot").formatSliceLabel;e.exports=function(t,e,r,p,d){var g=d.width,m=d.height,v=d.viewX,y=d.viewY,x=d.pathSlice,b=d.toMoveInsideSlice,_=d.strTransform,w=d.hasTransition,A=d.handleSlicesExit,C=d.makeUpdateSliceInterpolator,M=d.makeUpdateTextInterpolator,k=d.prevEntry,I=t._fullLayout,T=e[0].trace,L=-1!==T.textposition.indexOf("left"),S=-1!==T.textposition.indexOf("right"),E=-1!==T.textposition.indexOf("bottom"),D=!E&&!T.marker.pad.t||E&&!T.marker.pad.b,P=s(r,[g,m],{packing:T.tiling.packing,squarifyratio:T.tiling.squarifyratio,flipX:T.tiling.flip.indexOf("x")>-1,flipY:T.tiling.flip.indexOf("y")>-1,pad:{inner:T.tiling.pad,top:T.marker.pad.t,left:T.marker.pad.l,right:T.marker.pad.r,bottom:T.marker.pad.b}}).descendants(),O=1/0,z=-1/0;P.forEach((function(t){var e=t.depth;e>=T._maxDepth?(t.x0=t.x1=(t.x0+t.x1)/2,t.y0=t.y1=(t.y0+t.y1)/2):(O=Math.min(O,e),z=Math.max(z,e))})),p=p.data(P,u.getPtId),T._maxVisibleLayers=isFinite(z)?z-O+1:0,p.enter().append("g").classed("slice",!0),A(p,!1,{},[g,m],x),p.order();var R=null;if(w&&k){var F=u.getPtId(k);p.each((function(t){null===R&&u.getPtId(t)===F&&(R={x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1})}))}var N=function(){return R||{x0:0,x1:g,y0:0,y1:m}},j=p;return w&&(j=j.transition().each("end",(function(){var e=n.select(this);u.setSliceCursor(e,t,{hideOnRoot:!0,hideOnLeaves:!1,isTransitioning:!1})}))),j.each((function(s){var p=u.isHeader(s,T);s._hoverX=v(s.x1-T.marker.pad.r),s._hoverY=y(E?s.y1-T.marker.pad.b/2:s.y0+T.marker.pad.t/2);var d=n.select(this),A=i.ensureSingle(d,"path","surface",(function(t){t.style("pointer-events","all")}));w?A.transition().attrTween("d",(function(t){var e=C(t,!1,N(),[g,m]);return function(t){return x(e(t))}})):A.attr("d",x),d.call(h,r,t,e,{styleOne:l,eventDataKeys:c.eventDataKeys,transitionTime:c.CLICK_TRANSITION_TIME,transitionEasing:c.CLICK_TRANSITION_EASING}).call(u.setSliceCursor,t,{isTransitioning:t._transitioning}),A.call(l,s,T,{hovered:!1}),s.x0===s.x1||s.y0===s.y1?s._text="":s._text=p?D?"":u.getPtLabel(s)||"":f(s,r,T,e,I)||"";var k=i.ensureSingle(d,"g","slicetext"),P=i.ensureSingle(k,"text","",(function(t){t.attr("data-notex",1)})),O=i.ensureUniformFontSize(t,u.determineTextFont(T,s,I.font));P.text(s._text||" ").classed("slicetext",!0).attr("text-anchor",S?"end":L||p?"start":"middle").call(a.font,O).call(o.convertToTspans,t),s.textBB=a.bBox(P.node()),s.transform=b(s,{fontSize:O.size,isHeader:p}),s.transform.fontSize=O.size,w?P.transition().attrTween("transform",(function(t){var e=M(t,!1,N(),[g,m]);return function(t){return _(e(t))}})):P.attr("transform",_(s))})),R}},{"../../components/drawing":613,"../../lib":717,"../../lib/svg_text_utils":741,"../sunburst/fx":1236,"../sunburst/helpers":1237,"../sunburst/plot":1241,"./constants":1260,"./partition":1267,"./style":1269,d3:165}],1264:[function(t,e,r){"use strict";e.exports={moduleType:"trace",name:"treemap",basePlotModule:t("./base_plot"),categories:[],animatable:!0,attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc").calc,crossTraceCalc:t("./calc").crossTraceCalc,plot:t("./plot"),style:t("./style").style,colorbar:t("../scatter/marker_colorbar"),meta:{}}},{"../scatter/marker_colorbar":1138,"./attributes":1257,"./base_plot":1258,"./calc":1259,"./defaults":1261,"./layout_attributes":1265,"./layout_defaults":1266,"./plot":1268,"./style":1269}],1265:[function(t,e,r){"use strict";e.exports={treemapcolorway:{valType:"colorlist",editType:"calc"},extendtreemapcolors:{valType:"boolean",dflt:!0,editType:"calc"}}},{}],1266:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("treemapcolorway",e.colorway),r("extendtreemapcolors")}},{"../../lib":717,"./layout_attributes":1265}],1267:[function(t,e,r){"use strict";var n=t("d3-hierarchy");e.exports=function(t,e,r){var i,a=r.flipX,o=r.flipY,s="dice-slice"===r.packing,l=r.pad[o?"bottom":"top"],c=r.pad[a?"right":"left"],u=r.pad[a?"left":"right"],h=r.pad[o?"top":"bottom"];s&&(i=c,c=l,l=i,i=u,u=h,h=i);var f=n.treemap().tile(function(t,e){switch(t){case"squarify":return n.treemapSquarify.ratio(e);case"binary":return n.treemapBinary;case"dice":return n.treemapDice;case"slice":return n.treemapSlice;default:return n.treemapSliceDice}}(r.packing,r.squarifyratio)).paddingInner(r.pad.inner).paddingLeft(c).paddingRight(u).paddingTop(l).paddingBottom(h).size(s?[e[1],e[0]]:e)(t);return(s||a||o)&&function t(e,r,n){var i;n.swapXY&&(i=e.x0,e.x0=e.y0,e.y0=i,i=e.x1,e.x1=e.y1,e.y1=i),n.flipX&&(i=e.x0,e.x0=r[0]-e.x1,e.x1=r[0]-i),n.flipY&&(i=e.y0,e.y0=r[1]-e.y1,e.y1=r[1]-i);var a=e.children;if(a)for(var o=0;o-1?T+E:-(S+E):0,P={x0:L,x1:L,y0:D,y1:D+S},O=function(t,e,r){var n=m.tiling.pad,i=function(t){return t-n<=e.x0},a=function(t){return t+n>=e.x1},o=function(t){return t-n<=e.y0},s=function(t){return t+n>=e.y1};return{x0:i(t.x0-n)?0:a(t.x0-n)?r[0]:t.x0,x1:i(t.x1+n)?0:a(t.x1+n)?r[0]:t.x1,y0:o(t.y0-n)?0:s(t.y0-n)?r[1]:t.y0,y1:o(t.y1+n)?0:s(t.y1+n)?r[1]:t.y1}},z=null,R={},F={},N=null,j=function(t,e){return e?R[g(t)]:F[g(t)]},B=function(t,e,r,n){if(e)return R[g(v)]||P;var i=F[m.level]||r;return function(t){return t.data.depth-y.data.depth=(n-=v.r-o)){var y=(r+n)/2;r=y,n=y}var x;f?i<(x=a-v.b)&&x"===Q?(l.x-=a,c.x-=a,u.x-=a,h.x-=a):"/"===Q?(u.x-=a,h.x-=a,o.x-=a/2,s.x-=a/2):"\\"===Q?(l.x-=a,c.x-=a,o.x-=a/2,s.x-=a/2):"<"===Q&&(o.x-=a,s.x-=a),K(l),K(h),K(o),K(c),K(u),K(s),"M"+X(l.x,l.y)+"L"+X(c.x,c.y)+"L"+X(s.x,s.y)+"L"+X(u.x,u.y)+"L"+X(h.x,h.y)+"L"+X(o.x,o.y)+"Z"},toMoveInsideSlice:$,makeUpdateSliceInterpolator:et,makeUpdateTextInterpolator:rt,handleSlicesExit:nt,hasTransition:A,strTransform:it}):b.remove()}e.exports=function(t,e,r,a){var o,s,l=t._fullLayout,c=l._treemaplayer,f=!r;u("treemap",l),(o=c.selectAll("g.trace.treemap").data(e,(function(t){return t[0].trace.uid}))).enter().append("g").classed("trace",!0).classed("treemap",!0),o.order(),!l.uniformtext.mode&&i.hasTransition(r)?(a&&(s=a()),n.transition().duration(r.duration).ease(r.easing).each("end",(function(){s&&s()})).each("interrupt",(function(){s&&s()})).each((function(){c.selectAll("g.trace").each((function(e){m(t,e,this,r)}))}))):(o.each((function(e){m(t,e,this,r)})),l.uniformtext.mode&&h(t,l._treemaplayer.selectAll(".trace"),"treemap")),f&&o.exit().remove()}},{"../../lib":717,"../bar/constants":858,"../bar/plot":867,"../bar/style":870,"../bar/uniform_text":872,"../sunburst/helpers":1237,"./constants":1260,"./draw_ancestors":1262,"./draw_descendants":1263,d3:165}],1269:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../components/color"),a=t("../../lib"),o=t("../sunburst/helpers"),s=t("../bar/uniform_text").resizeText;function l(t,e,r,n){var s,l,c=(n||{}).hovered,u=e.data.data,h=u.i,f=u.color,p=o.isHierarchyRoot(e),d=1;if(c)s=r._hovered.marker.line.color,l=r._hovered.marker.line.width;else if(p&&"rgba(0,0,0,0)"===f)d=0,s="rgba(0,0,0,0)",l=0;else if(s=a.castOption(r,h,"marker.line.color")||i.defaultLine,l=a.castOption(r,h,"marker.line.width")||0,!r._hasColorscale&&!e.onPathbar){var g=r.marker.depthfade;if(g){var m,v=i.combine(i.addOpacity(r._backgroundColor,.75),f);if(!0===g){var y=o.getMaxDepth(r);m=isFinite(y)?o.isLeaf(e)?0:r._maxVisibleLayers-(e.data.depth-r._entryDepth):e.data.height+1}else m=e.data.depth-r._entryDepth,r._atRootLevel||m++;if(m>0)for(var x=0;x0){var y,x,b,_,w,A=t.xa,C=t.ya;"h"===f.orientation?(w=e,y="y",b=C,x="x",_=A):(w=r,y="x",b=A,x="y",_=C);var M=h[t.index];if(w>=M.span[0]&&w<=M.span[1]){var k=n.extendFlat({},t),I=_.c2p(w,!0),T=o.getKdeValue(M,f,w),L=o.getPositionOnKdePath(M,f,I),S=b._offset,E=b._length;k[y+"0"]=L[0],k[y+"1"]=L[1],k[x+"0"]=k[x+"1"]=I,k[x+"Label"]=x+": "+i.hoverLabelText(_,w)+", "+h[0].t.labels.kde+" "+T.toFixed(3),k.spikeDistance=v[0].spikeDistance;var D=y+"Spike";k[D]=v[0][D],v[0].spikeDistance=void 0,v[0][D]=void 0,k.hovertemplate=!1,m.push(k),(u={stroke:t.color})[y+"1"]=n.constrain(S+L[0],S,S+E),u[y+"2"]=n.constrain(S+L[1],S,S+E),u[x+"1"]=u[x+"2"]=_._offset+I}}d&&(m=m.concat(v))}-1!==p.indexOf("points")&&(c=a.hoverOnPoints(t,e,r));var P=l.selectAll(".violinline-"+f.uid).data(u?[0]:[]);return P.enter().append("line").classed("violinline-"+f.uid,!0).attr("stroke-width",1.5),P.exit().remove(),P.attr(u),"closest"===s?c?[c]:m:c?(m.push(c),m):m}},{"../../lib":717,"../../plots/cartesian/axes":765,"../box/hover":886,"./helpers":1274}],1276:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults"),crossTraceDefaults:t("../box/defaults").crossTraceDefaults,supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style"),styleOnSelect:t("../scatter/style").styleOnSelect,hoverPoints:t("./hover"),selectPoints:t("../box/select"),moduleType:"trace",name:"violin",basePlotModule:t("../../plots/cartesian"),categories:["cartesian","svg","symbols","oriented","box-violin","showLegend","violinLayout","zoomScale"],meta:{}}},{"../../plots/cartesian":776,"../box/defaults":884,"../box/select":891,"../scatter/style":1143,"./attributes":1270,"./calc":1271,"./cross_trace_calc":1272,"./defaults":1273,"./hover":1275,"./layout_attributes":1277,"./layout_defaults":1278,"./plot":1279,"./style":1280}],1277:[function(t,e,r){"use strict";var n=t("../box/layout_attributes"),i=t("../../lib").extendFlat;e.exports={violinmode:i({},n.boxmode,{}),violingap:i({},n.boxgap,{}),violingroupgap:i({},n.boxgroupgap,{})}},{"../../lib":717,"../box/layout_attributes":888}],1278:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes"),a=t("../box/layout_defaults");e.exports=function(t,e,r){a._supply(t,e,r,(function(r,a){return n.coerce(t,e,i,r,a)}),"violin")}},{"../../lib":717,"../box/layout_defaults":889,"./layout_attributes":1277}],1279:[function(t,e,r){"use strict";var n=t("d3"),i=t("../../lib"),a=t("../../components/drawing"),o=t("../box/plot"),s=t("../scatter/line_points"),l=t("./helpers");e.exports=function(t,e,r,c){var u=t._fullLayout,h=e.xaxis,f=e.yaxis;function p(t){var e=s(t,{xaxis:h,yaxis:f,connectGaps:!0,baseTolerance:.75,shape:"spline",simplify:!0,linearized:!0});return a.smoothopen(e[0],1)}i.makeTraceGroups(c,r,"trace violins").each((function(t){var r=n.select(this),a=t[0],s=a.t,c=a.trace;if(!0!==c.visible||s.empty)r.remove();else{var d=s.bPos,g=s.bdPos,m=e[s.valLetter+"axis"],v=e[s.posLetter+"axis"],y="both"===c.side,x=y||"positive"===c.side,b=y||"negative"===c.side,_=r.selectAll("path.violin").data(i.identity);_.enter().append("path").style("vector-effect","non-scaling-stroke").attr("class","violin"),_.exit().remove(),_.each((function(t){var e,r,i,a,o,l,h,f,_=n.select(this),w=t.density,A=w.length,C=v.c2l(t.pos+d,!0),M=v.l2p(C);if(c.width)e=s.maxKDE/g;else{var k=u._violinScaleGroupStats[c.scalegroup];e="count"===c.scalemode?k.maxKDE/g*(k.maxCount/t.pts.length):k.maxKDE/g}if(x){for(h=new Array(A),o=0;o")),c.color=function(t,e){var r=t[e.dir].marker,n=r.color,a=r.line.color,o=r.line.width;return i(n)?n:i(a)&&o?a:void 0}(h,d),[c]}function w(t){return n(p,t)}}},{"../../components/color":592,"../../constants/delta.js":687,"../../plots/cartesian/axes":765,"../bar/hover":863}],1292:[function(t,e,r){"use strict";e.exports={attributes:t("./attributes"),layoutAttributes:t("./layout_attributes"),supplyDefaults:t("./defaults").supplyDefaults,crossTraceDefaults:t("./defaults").crossTraceDefaults,supplyLayoutDefaults:t("./layout_defaults"),calc:t("./calc"),crossTraceCalc:t("./cross_trace_calc"),plot:t("./plot"),style:t("./style").style,hoverPoints:t("./hover"),eventData:t("./event_data"),selectPoints:t("../bar/select"),moduleType:"trace",name:"waterfall",basePlotModule:t("../../plots/cartesian"),categories:["bar-like","cartesian","svg","oriented","showLegend","zoomScale"],meta:{}}},{"../../plots/cartesian":776,"../bar/select":868,"./attributes":1285,"./calc":1286,"./cross_trace_calc":1288,"./defaults":1289,"./event_data":1290,"./hover":1291,"./layout_attributes":1293,"./layout_defaults":1294,"./plot":1295,"./style":1296}],1293:[function(t,e,r){"use strict";e.exports={waterfallmode:{valType:"enumerated",values:["group","overlay"],dflt:"group",editType:"calc"},waterfallgap:{valType:"number",min:0,max:1,editType:"calc"},waterfallgroupgap:{valType:"number",min:0,max:1,dflt:0,editType:"calc"}}},{}],1294:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,r){var a=!1;function o(r,a){return n.coerce(t,e,i,r,a)}for(var s=0;s0&&(g+=h?"M"+u[0]+","+p[1]+"V"+p[0]:"M"+u[1]+","+p[0]+"H"+u[0]),"between"!==f&&(r.isSum||o path").each((function(t){if(!t.isBlank){var e=s[t.dir].marker;n.select(this).call(a.fill,e.color).call(a.stroke,e.line.color).call(i.dashLine,e.line.dash,e.line.width).style("opacity",s.selectedpoints&&!t.selected?o:1)}})),c(r,s,t),r.selectAll(".lines").each((function(){var t=s.connector.line;i.lineGroupStyle(n.select(this).selectAll("path"),t.width,t.color,t.dash)}))}))}}},{"../../components/color":592,"../../components/drawing":613,"../../constants/interactions":692,"../bar/style":870,"../bar/uniform_text":872,d3:165}],1297:[function(t,e,r){"use strict";var n=t("../plots/cartesian/axes"),i=t("../lib"),a=t("../plot_api/plot_schema"),o=t("./helpers").pointsAccessorFunction,s=t("../constants/numerical").BADNUM;r.moduleType="transform",r.name="aggregate";var l=r.attributes={enabled:{valType:"boolean",dflt:!0,editType:"calc"},groups:{valType:"string",strict:!0,noBlank:!0,arrayOk:!0,dflt:"x",editType:"calc"},aggregations:{_isLinkedToArray:"aggregation",target:{valType:"string",editType:"calc"},func:{valType:"enumerated",values:["count","sum","avg","median","mode","rms","stddev","min","max","first","last","change","range"],dflt:"first",editType:"calc"},funcmode:{valType:"enumerated",values:["sample","population"],dflt:"sample",editType:"calc"},enabled:{valType:"boolean",dflt:!0,editType:"calc"},editType:"calc"},editType:"calc"},c=l.aggregations;function u(t,e,r,a){if(a.enabled){for(var o=a.target,l=i.nestedProperty(e,o),c=l.get(),u=function(t,e){var r=t.func,n=e.d2c,i=e.c2d;switch(r){case"count":return h;case"first":return f;case"last":return p;case"sum":return function(t,e){for(var r=0,a=0;aa&&(a=u,o=c)}}return a?i(o):s};case"rms":return function(t,e){for(var r=0,a=0,o=0;o":return function(t){return f(t)>s};case">=":return function(t){return f(t)>=s};case"[]":return function(t){var e=f(t);return e>=s[0]&&e<=s[1]};case"()":return function(t){var e=f(t);return e>s[0]&&e=s[0]&&es[0]&&e<=s[1]};case"][":return function(t){var e=f(t);return e<=s[0]||e>=s[1]};case")(":return function(t){var e=f(t);return es[1]};case"](":return function(t){var e=f(t);return e<=s[0]||e>s[1]};case")[":return function(t){var e=f(t);return e=s[1]};case"{}":return function(t){return-1!==s.indexOf(f(t))};case"}{":return function(t){return-1===s.indexOf(f(t))}}}(r,a.getDataToCoordFunc(t,e,s,i),f),x={},b={},_=0;d?(m=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set(new Array(h))},v=function(t,e){var r=x[t.astr][e];t.get()[e]=r}):(m=function(t){x[t.astr]=n.extendDeep([],t.get()),t.set([])},v=function(t,e){var r=x[t.astr][e];t.get().push(r)}),C(m);for(var w=o(e.transforms,r),A=0;A1?"%{group} (%{trace})":"%{group}");var l=t.styles,c=o.styles=[];if(l)for(a=0;aMath.abs(o)*c?(s<0&&(c=-c),r=c*o/s,n=c):(o<0&&(l=-l),r=l,n=l*s/o);return{x:i+r,y:a+n}},buildLayerMatrix:function(t){var e=n.map(n.range(o(t)+1),(function(){return[]}));return n.forEach(t.nodes(),(function(r){var i=t.node(r),a=i.rank;n.isUndefined(a)||(e[a][i.order]=r)})),e},normalizeRanks:function(t){var e=n.min(n.map(t.nodes(),(function(e){return t.node(e).rank})));n.forEach(t.nodes(),(function(r){var i=t.node(r);n.has(i,"rank")&&(i.rank-=e)}))},removeEmptyRanks:function(t){var e=n.min(n.map(t.nodes(),(function(e){return t.node(e).rank}))),r=[];n.forEach(t.nodes(),(function(n){var i=t.node(n).rank-e;r[i]||(r[i]=[]),r[i].push(n)}));var i=0,a=t.graph().nodeRankFactor;n.forEach(r,(function(e,r){n.isUndefined(e)&&r%a!=0?--i:i&&n.forEach(e,(function(e){t.node(e).rank+=i}))}))},addBorderNode:function(t,e,r,n){var i={width:0,height:0};arguments.length>=4&&(i.rank=r,i.order=n);return a(t,"border",i,e)},maxRank:o,partition:function(t,e){var r={lhs:[],rhs:[]};return n.forEach(t,(function(t){e(t)?r.lhs.push(t):r.rhs.push(t)})),r},time:function(t,e){var r=n.now();try{return e()}finally{console.log(t+" time: "+(n.now()-r)+"ms")}},notime:function(t,e){return e()}}},function(t,e,r){var n;try{n={clone:r(270),constant:r(64),each:r(94),filter:r(97),has:r(108),isArray:r(6),isEmpty:r(346),isFunction:r(29),isUndefined:r(109),keys:r(19),map:r(110),reduce:r(112),size:r(349),transform:r(355),union:r(356),values:r(117)}}catch(t){}n||(n=window._),t.exports=n},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(e,r){e.exports=t},function(t,e,r){var n;try{n=r(268)}catch(t){}n||(n=window.graphlib),t.exports=n},function(t,e,r){var n=r(77),i="object"==typeof self&&self&&self.Object===Object&&self,a=n||i||Function("return this")();t.exports=a},function(t,e,r){"use strict";var n,i,a;!function(t){t.ApplicationInsights||(t.ApplicationInsights={})}(a||(a={})),function(t){!function(t){var e=function(){};t.Base=e}(t.Telemetry||(t.Telemetry={}))}(a||(a={})),function(t){!function(t){var e=function(){this.ver=1,this.sampleRate=100,this.tags={}};t.Envelope=e}(t.Telemetry||(t.Telemetry={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){!function(t){t.Context||(t.Context={})}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),function(t){t.ApplicationInsights||(t.ApplicationInsights={})}(a||(a={})),function(t){t.ApplicationInsights||(t.ApplicationInsights={})}(a||(a={})),function(t){t.ApplicationInsights||(t.ApplicationInsights={})}(a||(a={})),function(t){!function(t){t[t.Verbose=0]="Verbose",t[t.Information=1]="Information",t[t.Warning=2]="Warning",t[t.Error=3]="Error",t[t.Critical=4]="Critical"}(t.SeverityLevel||(t.SeverityLevel={}))}(i||(i={})),function(t){t.ApplicationInsights||(t.ApplicationInsights={})}(a||(a={})),function(t){!function(t){var e=function(){function t(){}return t.newId=function(){for(var t="",e=1073741824*Math.random();e>0;){t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e%64),e=Math.floor(e/64)}return t},t}();t.UtilHelpers=e}(t.ApplicationInsights||(t.ApplicationInsights={}))}(a||(a={})),void 0===(n=function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){}return t._createLazyMethod=function(e){var r=window[t.appInsightsName];r[e]=function(){var t=arguments;r.queue?r.queue.push((function(){return r[e].apply(r,t)})):r[e].apply(r,t)}},t._defineLazyMethods=function(){var e=window[t.appInsightsName];try{e.cookie=document.cookie}catch(t){}e.queue=[];for(var r=["clearAuthenticatedUserContext","flush","setAuthenticatedUserContext","startTrackEvent","startTrackPage","stopTrackEvent","stopTrackPage","trackDependency","trackEvent","trackException","trackMetric","trackPageView","trackTrace"];r.length;)t._createLazyMethod(r.pop())},t._download=function(e){t.appInsightsInstance.config=e;var r=window[t.appInsightsName];if(r.queue||(r.queue=[]),setTimeout((function(){var t=document.createElement("script");t.src=e.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js",document.head.appendChild(t)})),!e.disableExceptionTracking){t._createLazyMethod("_onerror");var n=window.onerror;window.onerror=function(t,e,i,a,o){var s=n&&n(t,e,i,a,o);return!0!==s&&r._onerror(t,e,i,a,o),s}}},Object.defineProperty(t,"appInsightsInstance",{get:function(){if("undefined"!=typeof window)return window[t.appInsightsName]||(window[t.appInsightsName]={downloadAndSetup:t._download,_defineLazyMethods:t._defineLazyMethods},t._defineLazyMethods()),window[t.appInsightsName]},enumerable:!0,configurable:!0}),t.appInsightsInitialized=!1,t.appInsightsName="appInsights",t}();e.AppInsights=r.appInsightsInstance}.apply(e,[r,e]))||(t.exports=n)},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){var n=r(29),i=r(58);t.exports=function(t){return null!=t&&i(t.length)&&!n(t)}},function(t,e,r){var n=r(326),i=r(336),a=r(22),o=r(6),s=r(343);t.exports=function(t){return"function"==typeof t?t:null==t?a:"object"==typeof t?o(t)?i(t[0],t[1]):n(t):s(t)}},function(t,e,r){var n=r(80),i=r(60),a=r(17);t.exports=function(t){return a(t)?n(t):i(t)}},function(t,e,r){var n=r(281),i=r(286);t.exports=function(t,e){var r=i(t,e);return n(r)?r:void 0}},function(t,e,r){var n=r(24),i=r(282),a=r(283),o="[object Null]",s="[object Undefined]",l=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?s:o:l&&l in Object(t)?i(t):a(t)}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e,r){var n=r(13).Symbol;t.exports=n},function(t,e,r){(function(t){var n=r(13),i=r(302),a=e&&!e.nodeType&&e,o=a&&"object"==typeof t&&t&&!t.nodeType&&t,s=o&&o.exports===a?n.Buffer:void 0,l=(s?s.isBuffer:void 0)||i;t.exports=l}).call(this,r(32)(t))},function(t,e,r){var n=r(80),i=r(306),a=r(17);t.exports=function(t){return a(t)?n(t,!0):i(t)}},function(t,e,r){var n=r(311),i=r(55),a=r(312),o=r(89),s=r(313),l=r(21),c=r(78),u=c(n),h=c(i),f=c(a),p=c(o),d=c(s),g=l;(n&&"[object DataView]"!=g(new n(new ArrayBuffer(1)))||i&&"[object Map]"!=g(new i)||a&&"[object Promise]"!=g(a.resolve())||o&&"[object Set]"!=g(new o)||s&&"[object WeakMap]"!=g(new s))&&(g=function(t){var e=l(t),r="[object Object]"==e?t.constructor:void 0,n=r?c(r):"";if(n)switch(n){case u:return"[object DataView]";case h:return"[object Map]";case f:return"[object Promise]";case p:return"[object Set]";case d:return"[object WeakMap]"}return e}),t.exports=g},function(t,e,r){var n=r(21),i=r(15),a="[object Symbol]";t.exports=function(t){return"symbol"==typeof t||i(t)&&n(t)==a}},function(t,e,r){var n=r(21),i=r(10),a="[object AsyncFunction]",o="[object Function]",s="[object GeneratorFunction]",l="[object Proxy]";t.exports=function(t){if(!i(t))return!1;var e=n(t);return e==o||e==s||e==a||e==l}},function(t,e,r){var n=r(41),i=r(42);t.exports=function(t,e,r,a){var o=!r;r||(r={});for(var s=-1,l=e.length;++s-1||userAgent.indexOf("Trident/")>-1)}function o(t){return parseInt(String(t).split(/%|px|em|cm|vh|vw/)[0])}var s=function(){var t,e=document.createElement("fakeelement"),r={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in r)if(void 0!==e.style[t])return r[t]}(),l=!!/Mobi/.test(navigator.userAgent);window.$iziModal={},window.$iziModal.autoOpen=0,window.$iziModal.history=!1;var c=function(t,e){this.init(t,e)};return c.prototype={constructor:c,init:function(e,r){var a=this;this.$element=t(e),void 0!==this.$element[0].id&&""!==this.$element[0].id?this.id=this.$element[0].id:(this.id=n+Math.floor(1e7*Math.random()+1),this.$element.attr("id",this.id)),this.classes=void 0!==this.$element.attr("class")?this.$element.attr("class"):"",this.content=this.$element.html(),this.state=i.CLOSED,this.options=r,this.width=0,this.timer=null,this.timerTimeout=null,this.progressBar=null,this.isPaused=!1,this.isFullscreen=!1,this.headerHeight=0,this.modalHeight=0,this.$overlay=t('
'),this.$navigate=t('
Use
'),this.group={name:this.$element.attr("data-"+n+"-group"),index:null,ids:[]},this.$element.attr("aria-hidden","true"),this.$element.attr("aria-labelledby",this.id),this.$element.attr("role","dialog"),this.$element.hasClass("iziModal")||this.$element.addClass("iziModal"),void 0===this.group.name&&""!==r.group&&(this.group.name=r.group,this.$element.attr("data-"+n+"-group",r.group)),!0===this.options.loop&&this.$element.attr("data-"+n+"-loop",!0),t.each(this.options,(function(t,e){var i=a.$element.attr("data-"+n+"-"+t);try{void 0!==i&&(r[t]=""===i||"true"==i||"false"!=i&&("function"==typeof e?new Function(i):i))}catch(t){}})),!1!==r.appendTo&&this.$element.appendTo(r.appendTo),!0===r.iframe?(this.$element.html('
'+this.content+"
"),null!==r.iframeHeight&&this.$element.find("."+n+"-iframe").css("height",r.iframeHeight)):this.$element.html('
'+this.content+"
"),null!==this.options.background&&this.$element.css("background",this.options.background),this.$wrap=this.$element.find("."+n+"-wrap"),null===r.zindex||isNaN(parseInt(r.zindex))||(this.$element.css("z-index",r.zindex),this.$navigate.css("z-index",r.zindex-1),this.$overlay.css("z-index",r.zindex-2)),""!==r.radius&&this.$element.css("border-radius",r.radius),""!==r.padding&&this.$element.find("."+n+"-content").css("padding",r.padding),""!==r.theme&&("light"===r.theme?this.$element.addClass(n+"-light"):this.$element.addClass(r.theme)),!0===r.rtl&&this.$element.addClass(n+"-rtl"),!0===r.openFullscreen&&(this.isFullscreen=!0,this.$element.addClass("isFullscreen")),this.createHeader(),this.recalcWidth(),this.recalcVerticalPos(),!a.options.afterRender||"function"!=typeof a.options.afterRender&&"object"!=typeof a.options.afterRender||a.options.afterRender(a)},createHeader:function(){this.$header=t('

'+this.options.title+'

'+this.options.subtitle+'

'),!0===this.options.closeButton&&this.$header.find("."+n+"-header-buttons").append('
"),!0===this.options.fullscreen&&this.$header.find("."+n+"-header-buttons").append('"),!0!==this.options.timeoutProgressbar||isNaN(parseInt(this.options.timeout))||!1===this.options.timeout||0===this.options.timeout||this.$header.prepend('
'),""===this.options.subtitle&&this.$header.addClass(n+"-noSubtitle"),""!==this.options.title&&(null!==this.options.headerColor&&(!0===this.options.borderBottom&&this.$element.css("border-bottom","3px solid "+this.options.headerColor),this.$header.css("background",this.options.headerColor)),null===this.options.icon&&null===this.options.iconText||(this.$header.prepend(''),null!==this.options.icon&&this.$header.find("."+n+"-header-icon").addClass(this.options.icon).css("color",this.options.iconColor),null!==this.options.iconText&&this.$header.find("."+n+"-header-icon").html(this.options.iconText)),this.$element.css("overflow","hidden").prepend(this.$header))},setGroup:function(e){var r=this,i=this.group.name||e;if(this.group.ids=[],void 0!==e&&e!==this.group.name&&(i=e,this.group.name=i,this.$element.attr("data-"+n+"-group",i)),void 0!==i&&""!==i){var a=0;t.each(t("."+n+"[data-"+n+"-group="+i+"]"),(function(e,n){r.group.ids.push(t(this)[0].id),r.id==t(this)[0].id&&(r.group.index=a),a++}))}},toggle:function(){this.state==i.OPENED&&this.close(),this.state==i.CLOSED&&this.open()},open:function(e){var a=this;function o(){a.state=i.OPENED,a.$element.trigger(i.OPENED),!a.options.onOpened||"function"!=typeof a.options.onOpened&&"object"!=typeof a.options.onOpened||a.options.onOpened(a)}if(t.each(t("."+n),(function(e,r){if(void 0!==t(r).data().iziModal){var n=t(r).iziModal("getState");"opened"!=n&&"opening"!=n||t(r).iziModal("close")}})),function(){if(a.options.history){var t=document.title;document.title=t+" - "+a.options.title,document.location.hash=a.id,document.title=t,window.$iziModal.history=!0}else window.$iziModal.history=!1}(),this.state==i.CLOSED){if(a.$element.off("click","[data-"+n+"-close]").on("click","[data-"+n+"-close]",(function(e){e.preventDefault();var r=t(e.currentTarget).attr("data-"+n+"-transitionOut");void 0!==r?a.close({transition:r}):a.close()})),a.$element.off("click","[data-"+n+"-fullscreen]").on("click","[data-"+n+"-fullscreen]",(function(t){t.preventDefault(),!0===a.isFullscreen?(a.isFullscreen=!1,a.$element.removeClass("isFullscreen")):(a.isFullscreen=!0,a.$element.addClass("isFullscreen")),a.options.onFullscreen&&"function"==typeof a.options.onFullscreen&&a.options.onFullscreen(a),a.$element.trigger("fullscreen",a)})),a.$navigate.off("click","."+n+"-navigate-next").on("click","."+n+"-navigate-next",(function(t){a.next(t)})),a.$element.off("click","[data-"+n+"-next]").on("click","[data-"+n+"-next]",(function(t){a.next(t)})),a.$navigate.off("click","."+n+"-navigate-prev").on("click","."+n+"-navigate-prev",(function(t){a.prev(t)})),a.$element.off("click","[data-"+n+"-prev]").on("click","[data-"+n+"-prev]",(function(t){a.prev(t)})),this.setGroup(),this.state=i.OPENING,this.$element.trigger(i.OPENING),this.$element.attr("aria-hidden","false"),!0===this.options.iframe){this.$element.find("."+n+"-content").addClass(n+"-content-loader"),this.$element.find("."+n+"-iframe").on("load",(function(){t(this).parent().removeClass(n+"-content-loader")}));var c=null;try{c=""!==t(e.currentTarget).attr("href")?t(e.currentTarget).attr("href"):null}catch(t){}if(null!==this.options.iframeURL&&null==c&&(c=this.options.iframeURL),null==c)throw new Error("Failed to find iframe URL");this.$element.find("."+n+"-iframe").attr("src",c)}(this.options.bodyOverflow||l)&&(t("html").addClass(n+"-isOverflow"),l&&t("body").css("overflow","hidden")),this.options.onOpening&&"function"==typeof this.options.onOpening&&this.options.onOpening(this),function(){if(a.group.ids.length>1){a.$navigate.appendTo("body"),a.$navigate.addClass("fadeIn"),!0===a.options.navigateCaption&&a.$navigate.find("."+n+"-navigate-caption").show();var r=a.$element.outerWidth();!1!==a.options.navigateArrows?"closeScreenEdge"===a.options.navigateArrows?(a.$navigate.find("."+n+"-navigate-prev").css("left",0).show(),a.$navigate.find("."+n+"-navigate-next").css("right",0).show()):(a.$navigate.find("."+n+"-navigate-prev").css("margin-left",-(r/2+84)).show(),a.$navigate.find("."+n+"-navigate-next").css("margin-right",-(r/2+84)).show()):(a.$navigate.find("."+n+"-navigate-prev").hide(),a.$navigate.find("."+n+"-navigate-next").hide()),0===a.group.index&&0===t("."+n+"[data-"+n+'-group="'+a.group.name+'"][data-'+n+"-loop]").length&&!1===a.options.loop&&a.$navigate.find("."+n+"-navigate-prev").hide(),a.group.index+1===a.group.ids.length&&0===t("."+n+"[data-"+n+'-group="'+a.group.name+'"][data-'+n+"-loop]").length&&!1===a.options.loop&&a.$navigate.find("."+n+"-navigate-next").hide()}!0===a.options.overlay&&(!1===a.options.appendToOverlay?a.$overlay.appendTo("body"):a.$overlay.appendTo(a.options.appendToOverlay)),a.options.transitionInOverlay&&a.$overlay.addClass(a.options.transitionInOverlay);var i=a.options.transitionIn;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionIn||(i=e.transition||e.transitionIn)),""!==i&&void 0!==s?(a.$element.addClass("transitionIn "+i).show(),a.$wrap.one(s,(function(){a.$element.removeClass(i+" transitionIn"),a.$overlay.removeClass(a.options.transitionInOverlay),a.$navigate.removeClass("fadeIn"),o()}))):(a.$element.show(),o()),!0!==a.options.pauseOnHover||!0!==a.options.pauseOnHover||!1===a.options.timeout||isNaN(parseInt(a.options.timeout))||!1===a.options.timeout||0===a.options.timeout||(a.$element.off("mouseenter").on("mouseenter",(function(t){t.preventDefault(),a.isPaused=!0})),a.$element.off("mouseleave").on("mouseleave",(function(t){t.preventDefault(),a.isPaused=!1})))}(),!1===this.options.timeout||isNaN(parseInt(this.options.timeout))||!1===this.options.timeout||0===this.options.timeout||(!0===this.options.timeoutProgressbar?(this.progressBar={hideEta:null,maxHideTime:null,currentTime:(new Date).getTime(),el:this.$element.find("."+n+"-progressbar > div"),updateProgress:function(){if(!a.isPaused){a.progressBar.currentTime=a.progressBar.currentTime+10;var t=(a.progressBar.hideEta-a.progressBar.currentTime)/a.progressBar.maxHideTime*100;a.progressBar.el.width(t+"%"),t<0&&a.close()}}},this.options.timeout>0&&(this.progressBar.maxHideTime=parseFloat(this.options.timeout),this.progressBar.hideEta=(new Date).getTime()+this.progressBar.maxHideTime,this.timerTimeout=setInterval(this.progressBar.updateProgress,10))):this.timerTimeout=setTimeout((function(){a.close()}),a.options.timeout)),this.options.overlayClose&&!this.$element.hasClass(this.options.transitionOut)&&this.$overlay.click((function(){a.close()})),this.options.focusInput&&this.$element.find(":input:not(button):enabled:visible:first").focus(),function t(){a.recalcLayout(),a.timer=setTimeout(t,300)}(),r.on("keydown."+n,(function(t){a.options.closeOnEscape&&27===t.keyCode&&a.close()}))}},close:function(e){var a=this;function o(){a.state=i.CLOSED,a.$element.trigger(i.CLOSED),!0===a.options.iframe&&a.$element.find("."+n+"-iframe").attr("src",""),(a.options.bodyOverflow||l)&&(t("html").removeClass(n+"-isOverflow"),l&&t("body").css("overflow","auto")),a.options.onClosed&&"function"==typeof a.options.onClosed&&a.options.onClosed(a),!0===a.options.restoreDefaultContent&&a.$element.find("."+n+"-content").html(a.content),0===t("."+n+":visible").length&&t("html").removeClass(n+"-isAttached")}if(this.state==i.OPENED||this.state==i.OPENING){r.off("keydown."+n),this.state=i.CLOSING,this.$element.trigger(i.CLOSING),this.$element.attr("aria-hidden","true"),clearTimeout(this.timer),clearTimeout(this.timerTimeout),a.options.onClosing&&"function"==typeof a.options.onClosing&&a.options.onClosing(this);var c=this.options.transitionOut;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionOut||(c=e.transition||e.transitionOut)),!1===c||""===c||void 0===s?(this.$element.hide(),this.$overlay.remove(),this.$navigate.remove(),o()):(this.$element.attr("class",[this.classes,n,c,"light"==this.options.theme?n+"-light":this.options.theme,!0===this.isFullscreen?"isFullscreen":"",this.options.rtl?n+"-rtl":""].join(" ")),this.$overlay.attr("class",n+"-overlay "+this.options.transitionOutOverlay),!1!==a.options.navigateArrows&&this.$navigate.attr("class",n+"-navigate fadeOut"),this.$element.one(s,(function(){a.$element.hasClass(c)&&a.$element.removeClass(c+" transitionOut").hide(),a.$overlay.removeClass(a.options.transitionOutOverlay).remove(),a.$navigate.removeClass("fadeOut").remove(),o()})))}},next:function(e){var r=this,i="fadeInRight",a="fadeOutLeft",o=t("."+n+":visible"),s={};s.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),o=t(e.currentTarget),i=o.attr("data-"+n+"-transitionIn"),a=o.attr("data-"+n+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(i=e.transitionIn),void 0!==e.transitionOut&&(a=e.transitionOut)),this.close({transition:a}),setTimeout((function(){for(var e=t("."+n+"[data-"+n+'-group="'+r.group.name+'"][data-'+n+"-loop]").length,a=r.group.index+1;a<=r.group.ids.length;a++){try{s.in=t("#"+r.group.ids[a]).data().iziModal}catch(t){}if(void 0!==s.in){t("#"+r.group.ids[a]).iziModal("open",{transition:i});break}if(a==r.group.ids.length&&e>0||!0===r.options.loop)for(var o=0;o<=r.group.ids.length;o++)if(s.in=t("#"+r.group.ids[o]).data().iziModal,void 0!==s.in){t("#"+r.group.ids[o]).iziModal("open",{transition:i});break}}}),200),t(document).trigger(n+"-group-change",s)},prev:function(e){var r=this,i="fadeInLeft",a="fadeOutRight",o=t("."+n+":visible"),s={};s.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),o=t(e.currentTarget),i=o.attr("data-"+n+"-transitionIn"),a=o.attr("data-"+n+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(i=e.transitionIn),void 0!==e.transitionOut&&(a=e.transitionOut)),this.close({transition:a}),setTimeout((function(){for(var e=t("."+n+"[data-"+n+'-group="'+r.group.name+'"][data-'+n+"-loop]").length,a=r.group.index;a>=0;a--){try{s.in=t("#"+r.group.ids[a-1]).data().iziModal}catch(t){}if(void 0!==s.in){t("#"+r.group.ids[a-1]).iziModal("open",{transition:i});break}if(0===a&&e>0||!0===r.options.loop)for(var o=r.group.ids.length-1;o>=0;o--)if(s.in=t("#"+r.group.ids[o]).data().iziModal,void 0!==s.in){t("#"+r.group.ids[o]).iziModal("open",{transition:i});break}}}),200),t(document).trigger(n+"-group-change",s)},destroy:function(){var e=t.Event("destroy");this.$element.trigger(e),r.off("keydown."+n),clearTimeout(this.timer),clearTimeout(this.timerTimeout),!0===this.options.iframe&&this.$element.find("."+n+"-iframe").remove(),this.$element.html(this.$element.find("."+n+"-content").html()),this.$element.off("click","[data-"+n+"-close]"),this.$element.off("click","[data-"+n+"-fullscreen]"),this.$element.off("."+n).removeData(n).attr("style",""),this.$overlay.remove(),this.$navigate.remove(),this.$element.trigger(i.DESTROYED),this.$element=null},getState:function(){return this.state},getGroup:function(){return this.group},setWidth:function(t){this.options.width=t,this.recalcWidth();var e=this.$element.outerWidth();!0!==this.options.navigateArrows&&"closeToModal"!=this.options.navigateArrows||(this.$navigate.find("."+n+"-navigate-prev").css("margin-left",-(e/2+84)).show(),this.$navigate.find("."+n+"-navigate-next").css("margin-right",-(e/2+84)).show())},setTop:function(t){this.options.top=t,this.recalcVerticalPos(!1)},setBottom:function(t){this.options.bottom=t,this.recalcVerticalPos(!1)},setHeader:function(t){t?this.$element.find("."+n+"-header").show():(this.headerHeight=0,this.$element.find("."+n+"-header").hide())},setTitle:function(t){this.options.title=t,0===this.headerHeight&&this.createHeader(),0===this.$header.find("."+n+"-header-title").length&&this.$header.append('

'),this.$header.find("."+n+"-header-title").html(t)},setSubtitle:function(t){""===t?(this.$header.find("."+n+"-header-subtitle").remove(),this.$header.addClass(n+"-noSubtitle")):(0===this.$header.find("."+n+"-header-subtitle").length&&this.$header.append('

'),this.$header.removeClass(n+"-noSubtitle")),this.$header.find("."+n+"-header-subtitle").html(t),this.options.subtitle=t},setIcon:function(t){0===this.$header.find("."+n+"-header-icon").length&&this.$header.prepend(''),this.$header.find("."+n+"-header-icon").attr("class",n+"-header-icon "+t),this.options.icon=t},setIconText:function(t){this.$header.find("."+n+"-header-icon").html(t),this.options.iconText=t},setHeaderColor:function(t){!0===this.options.borderBottom&&this.$element.css("border-bottom","3px solid "+t),this.$header.css("background",t),this.options.headerColor=t},setBackground:function(t){!1===t?(this.options.background=null,this.$element.css("background","")):(this.$element.css("background",t),this.options.background=t)},setZindex:function(t){isNaN(parseInt(this.options.zindex))||(this.options.zindex=t,this.$element.css("z-index",t),this.$navigate.css("z-index",t-1),this.$overlay.css("z-index",t-2))},setFullscreen:function(t){t?(this.isFullscreen=!0,this.$element.addClass("isFullscreen")):(this.isFullscreen=!1,this.$element.removeClass("isFullscreen"))},setContent:function(t){"object"==typeof t&&(!0===(t.default||!1)&&(this.content=t.content),t=t.content),!1===this.options.iframe&&this.$element.find("."+n+"-content").html(t)},setTransitionIn:function(t){this.options.transitionIn=t},setTransitionOut:function(t){this.options.transitionOut=t},resetContent:function(){this.$element.find("."+n+"-content").html(this.content)},startLoading:function(){this.$element.find("."+n+"-loader").length||this.$element.append('
'),this.$element.find("."+n+"-loader").css({top:this.headerHeight,borderRadius:this.options.radius})},stopLoading:function(){var t=this.$element.find("."+n+"-loader");t.length||(this.$element.prepend('
'),t=this.$element.find("."+n+"-loader").css("border-radius",this.options.radius)),t.removeClass("fadeIn").addClass("fadeOut"),setTimeout((function(){t.remove()}),600)},recalcWidth:function(){if(this.$element.css("max-width",this.options.width),a()){var t=this.options.width;t.toString().split("%").length>1&&(t=this.$element.outerWidth()),this.$element.css({left:"50%",marginLeft:-t/2})}},recalcVerticalPos:function(t){null!==this.options.top&&!1!==this.options.top?(this.$element.css("margin-top",this.options.top),0===this.options.top&&this.$element.css({borderTopRightRadius:0,borderTopLeftRadius:0})):!1===t&&this.$element.css({marginTop:"",borderRadius:this.options.radius}),null!==this.options.bottom&&!1!==this.options.bottom?(this.$element.css("margin-bottom",this.options.bottom),0===this.options.bottom&&this.$element.css({borderBottomRightRadius:0,borderBottomLeftRadius:0})):!1===t&&this.$element.css({marginBottom:"",borderRadius:this.options.radius})},recalcLayout:function(){var r=this,s=e.height(),l=this.$element.outerHeight(),c=this.$element.outerWidth(),u=this.$element.find("."+n+"-content")[0].scrollHeight,h=u+this.headerHeight,f=this.$element.innerHeight()-this.headerHeight,p=(parseInt(-(this.$element.innerHeight()+1)/2),this.$wrap.scrollTop()),d=0;a()&&(c>=e.width()||!0===this.isFullscreen?this.$element.css({left:"0",marginLeft:""}):this.$element.css({left:"50%",marginLeft:-c/2})),!0===this.options.borderBottom&&""!==this.options.title&&(d=3),this.$element.find("."+n+"-header").length&&this.$element.find("."+n+"-header").is(":visible")?(this.headerHeight=parseInt(this.$element.find("."+n+"-header").innerHeight()),this.$element.css("overflow","hidden")):(this.headerHeight=0,this.$element.css("overflow","")),this.$element.find("."+n+"-loader").length&&this.$element.find("."+n+"-loader").css("top",this.headerHeight),l!==this.modalHeight&&(this.modalHeight=l,this.options.onResize&&"function"==typeof this.options.onResize&&this.options.onResize(this)),this.state!=i.OPENED&&this.state!=i.OPENING||(!0===this.options.iframe&&(s=e.width()?this.$element.find("."+n+"-button-fullscreen").hide():this.$element.find("."+n+"-button-fullscreen").show(),this.recalcButtons(),!1===this.isFullscreen&&(s=s-(o(this.options.top)||0)-(o(this.options.bottom)||0)),h>s?(this.options.top>0&&null===this.options.bottom&&u0&&null===this.options.top&&uf&&h>s?(r.$element.addClass("hasScroll"),r.$wrap.css("height",l-(r.headerHeight+d))):(r.$element.removeClass("hasScroll"),r.$wrap.css("height","auto")),f+p1){try{i.$el=document.createElement(id[0])}catch(t){}i.$el.id=this.selector.split("#")[1].trim()}else if(i.class.length>1){try{i.$el=document.createElement(i.class[0])}catch(t){}for(var a=1;a-1&&t%1==0&&t)?=?)",u("XRANGEIDENTIFIERLOOSE"),s[l.XRANGEIDENTIFIERLOOSE]=s[l.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*",u("XRANGEIDENTIFIER"),s[l.XRANGEIDENTIFIER]=s[l.NUMERICIDENTIFIER]+"|x|X|\\*",u("XRANGEPLAIN"),s[l.XRANGEPLAIN]="[v=\\s]*("+s[l.XRANGEIDENTIFIER]+")(?:\\.("+s[l.XRANGEIDENTIFIER]+")(?:\\.("+s[l.XRANGEIDENTIFIER]+")(?:"+s[l.PRERELEASE]+")?"+s[l.BUILD]+"?)?)?",u("XRANGEPLAINLOOSE"),s[l.XRANGEPLAINLOOSE]="[v=\\s]*("+s[l.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+s[l.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+s[l.XRANGEIDENTIFIERLOOSE]+")(?:"+s[l.PRERELEASELOOSE]+")?"+s[l.BUILD]+"?)?)?",u("XRANGE"),s[l.XRANGE]="^"+s[l.GTLT]+"\\s*"+s[l.XRANGEPLAIN]+"$",u("XRANGELOOSE"),s[l.XRANGELOOSE]="^"+s[l.GTLT]+"\\s*"+s[l.XRANGEPLAINLOOSE]+"$",u("COERCE"),s[l.COERCE]="(^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])",u("COERCERTL"),o[l.COERCERTL]=new RegExp(s[l.COERCE],"g"),u("LONETILDE"),s[l.LONETILDE]="(?:~>?)",u("TILDETRIM"),s[l.TILDETRIM]="(\\s*)"+s[l.LONETILDE]+"\\s+",o[l.TILDETRIM]=new RegExp(s[l.TILDETRIM],"g");u("TILDE"),s[l.TILDE]="^"+s[l.LONETILDE]+s[l.XRANGEPLAIN]+"$",u("TILDELOOSE"),s[l.TILDELOOSE]="^"+s[l.LONETILDE]+s[l.XRANGEPLAINLOOSE]+"$",u("LONECARET"),s[l.LONECARET]="(?:\\^)",u("CARETTRIM"),s[l.CARETTRIM]="(\\s*)"+s[l.LONECARET]+"\\s+",o[l.CARETTRIM]=new RegExp(s[l.CARETTRIM],"g");u("CARET"),s[l.CARET]="^"+s[l.LONECARET]+s[l.XRANGEPLAIN]+"$",u("CARETLOOSE"),s[l.CARETLOOSE]="^"+s[l.LONECARET]+s[l.XRANGEPLAINLOOSE]+"$",u("COMPARATORLOOSE"),s[l.COMPARATORLOOSE]="^"+s[l.GTLT]+"\\s*("+s[l.LOOSEPLAIN]+")$|^$",u("COMPARATOR"),s[l.COMPARATOR]="^"+s[l.GTLT]+"\\s*("+s[l.FULLPLAIN]+")$|^$",u("COMPARATORTRIM"),s[l.COMPARATORTRIM]="(\\s*)"+s[l.GTLT]+"\\s*("+s[l.LOOSEPLAIN]+"|"+s[l.XRANGEPLAIN]+")",o[l.COMPARATORTRIM]=new RegExp(s[l.COMPARATORTRIM],"g");u("HYPHENRANGE"),s[l.HYPHENRANGE]="^\\s*("+s[l.XRANGEPLAIN]+")\\s+-\\s+("+s[l.XRANGEPLAIN]+")\\s*$",u("HYPHENRANGELOOSE"),s[l.HYPHENRANGELOOSE]="^\\s*("+s[l.XRANGEPLAINLOOSE]+")\\s+-\\s+("+s[l.XRANGEPLAINLOOSE]+")\\s*$",u("STAR"),s[l.STAR]="(<|>)?=?\\s*\\*";for(var h=0;hi)return null;if(!(e.loose?o[l.LOOSE]:o[l.FULL]).test(t))return null;try{return new p(t,e)}catch(t){return null}}function p(t,e){if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),t instanceof p){if(t.loose===e.loose)return t;t=t.version}else if("string"!=typeof t)throw new TypeError("Invalid Version: "+t);if(t.length>i)throw new TypeError("version is longer than "+i+" characters");if(!(this instanceof p))return new p(t,e);n("SemVer",t,e),this.options=e,this.loose=!!e.loose;var r=t.trim().match(e.loose?o[l.LOOSE]:o[l.FULL]);if(!r)throw new TypeError("Invalid Version: "+t);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>a||this.major<0)throw new TypeError("Invalid major version");if(this.minor>a||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>a||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((function(t){if(/^[0-9]+$/.test(t)){var e=+t;if(e>=0&&e=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error("invalid increment argument: "+t)}return this.format(),this.raw=this.version,this},e.inc=function(t,e,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new p(t,r).inc(e,n).version}catch(t){return null}},e.diff=function(t,e){if(x(t,e))return null;var r=f(t),n=f(e),i="";if(r.prerelease.length||n.prerelease.length){i="pre";var a="prerelease"}for(var o in r)if(("major"===o||"minor"===o||"patch"===o)&&r[o]!==n[o])return i+o;return a},e.compareIdentifiers=g;var d=/^[0-9]+$/;function g(t,e){var r=d.test(t),n=d.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:t0}function y(t,e,r){return m(t,e,r)<0}function x(t,e,r){return 0===m(t,e,r)}function b(t,e,r){return 0!==m(t,e,r)}function _(t,e,r){return m(t,e,r)>=0}function w(t,e,r){return m(t,e,r)<=0}function A(t,e,r,n){switch(e){case"===":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t===r;case"!==":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t!==r;case"":case"=":case"==":return x(t,r,n);case"!=":return b(t,r,n);case">":return v(t,r,n);case">=":return _(t,r,n);case"<":return y(t,r,n);case"<=":return w(t,r,n);default:throw new TypeError("Invalid operator: "+e)}}function C(t,e){if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),t instanceof C){if(t.loose===!!e.loose)return t;t=t.value}if(!(this instanceof C))return new C(t,e);n("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===M?this.value="":this.value=this.operator+this.semver.version,n("comp",this)}e.rcompareIdentifiers=function(t,e){return g(e,t)},e.major=function(t,e){return new p(t,e).major},e.minor=function(t,e){return new p(t,e).minor},e.patch=function(t,e){return new p(t,e).patch},e.compare=m,e.compareLoose=function(t,e){return m(t,e,!0)},e.compareBuild=function(t,e,r){var n=new p(t,r),i=new p(e,r);return n.compare(i)||n.compareBuild(i)},e.rcompare=function(t,e,r){return m(e,t,r)},e.sort=function(t,r){return t.sort((function(t,n){return e.compareBuild(t,n,r)}))},e.rsort=function(t,r){return t.sort((function(t,n){return e.compareBuild(n,t,r)}))},e.gt=v,e.lt=y,e.eq=x,e.neq=b,e.gte=_,e.lte=w,e.cmp=A,e.Comparator=C;var M={};function k(t,e){if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),t instanceof k)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new k(t.raw,e);if(t instanceof C)return new k(t.value,e);if(!(this instanceof k))return new k(t,e);if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map((function(t){return this.parseRange(t.trim())}),this).filter((function(t){return t.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+t);this.format()}function I(t,e){for(var r=!0,n=t.slice(),i=n.pop();r&&n.length;)r=n.every((function(t){return i.intersects(t,e)})),i=n.pop();return r}function T(t){return!t||"x"===t.toLowerCase()||"*"===t}function L(t,e,r,n,i,a,o,s,l,c,u,h,f){return((e=T(r)?"":T(n)?">="+r+".0.0":T(i)?">="+r+"."+n+".0":">="+e)+" "+(s=T(l)?"":T(c)?"<"+(+l+1)+".0.0":T(u)?"<"+l+"."+(+c+1)+".0":h?"<="+l+"."+c+"."+u+"-"+h:"<="+s)).trim()}function S(t,e,r){for(var i=0;i0){var a=t[i].semver;if(a.major===e.major&&a.minor===e.minor&&a.patch===e.patch)return!0}return!1}return!0}function E(t,e,r){try{e=new k(e,r)}catch(t){return!1}return e.test(t)}function D(t,e,r,n){var i,a,o,s,l;switch(t=new p(t,n),e=new k(e,n),r){case">":i=v,a=w,o=y,s=">",l=">=";break;case"<":i=y,a=_,o=v,s="<",l="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(E(t,e,n))return!1;for(var c=0;c=0.0.0")),h=h||t,f=f||t,i(t.semver,h.semver,n)?h=t:o(t.semver,f.semver,n)&&(f=t)})),h.operator===s||h.operator===l)return!1;if((!f.operator||f.operator===s)&&a(t,f.semver))return!1;if(f.operator===l&&o(t,f.semver))return!1}return!0}C.prototype.parse=function(t){var e=this.options.loose?o[l.COMPARATORLOOSE]:o[l.COMPARATOR],r=t.match(e);if(!r)throw new TypeError("Invalid comparator: "+t);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new p(r[2],this.options.loose):this.semver=M},C.prototype.toString=function(){return this.value},C.prototype.test=function(t){if(n("Comparator.test",t,this.options.loose),this.semver===M||t===M)return!0;if("string"==typeof t)try{t=new p(t,this.options)}catch(t){return!1}return A(t,this.operator,this.semver,this.options)},C.prototype.intersects=function(t,e){if(!(t instanceof C))throw new TypeError("a Comparator is required");var r;if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),""===this.operator)return""===this.value||(r=new k(t.value,e),E(this.value,r,e));if(""===t.operator)return""===t.value||(r=new k(this.value,e),E(t.semver,r,e));var n=!(">="!==this.operator&&">"!==this.operator||">="!==t.operator&&">"!==t.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==t.operator&&"<"!==t.operator),a=this.semver.version===t.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==t.operator&&"<="!==t.operator),s=A(this.semver,"<",t.semver,e)&&(">="===this.operator||">"===this.operator)&&("<="===t.operator||"<"===t.operator),l=A(this.semver,">",t.semver,e)&&("<="===this.operator||"<"===this.operator)&&(">="===t.operator||">"===t.operator);return n||i||a&&o||s||l},e.Range=k,k.prototype.format=function(){return this.range=this.set.map((function(t){return t.join(" ").trim()})).join("||").trim(),this.range},k.prototype.toString=function(){return this.range},k.prototype.parseRange=function(t){var e=this.options.loose;t=t.trim();var r=e?o[l.HYPHENRANGELOOSE]:o[l.HYPHENRANGE];t=t.replace(r,L),n("hyphen replace",t),t=t.replace(o[l.COMPARATORTRIM],"$1$2$3"),n("comparator trim",t,o[l.COMPARATORTRIM]),t=(t=(t=t.replace(o[l.TILDETRIM],"$1~")).replace(o[l.CARETTRIM],"$1^")).split(/\s+/).join(" ");var i=e?o[l.COMPARATORLOOSE]:o[l.COMPARATOR],a=t.split(" ").map((function(t){return function(t,e){return n("comp",t,e),t=function(t,e){return t.trim().split(/\s+/).map((function(t){return function(t,e){n("caret",t,e);var r=e.loose?o[l.CARETLOOSE]:o[l.CARET];return t.replace(r,(function(e,r,i,a,o){var s;return n("caret",t,e,r,i,a,o),T(r)?s="":T(i)?s=">="+r+".0.0 <"+(+r+1)+".0.0":T(a)?s="0"===r?">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":">="+r+"."+i+".0 <"+(+r+1)+".0.0":o?(n("replaceCaret pr",o),s="0"===r?"0"===i?">="+r+"."+i+"."+a+"-"+o+" <"+r+"."+i+"."+(+a+1):">="+r+"."+i+"."+a+"-"+o+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+a+"-"+o+" <"+(+r+1)+".0.0"):(n("no pr"),s="0"===r?"0"===i?">="+r+"."+i+"."+a+" <"+r+"."+i+"."+(+a+1):">="+r+"."+i+"."+a+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+a+" <"+(+r+1)+".0.0"),n("caret return",s),s}))}(t,e)})).join(" ")}(t,e),n("caret",t),t=function(t,e){return t.trim().split(/\s+/).map((function(t){return function(t,e){var r=e.loose?o[l.TILDELOOSE]:o[l.TILDE];return t.replace(r,(function(e,r,i,a,o){var s;return n("tilde",t,e,r,i,a,o),T(r)?s="":T(i)?s=">="+r+".0.0 <"+(+r+1)+".0.0":T(a)?s=">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":o?(n("replaceTilde pr",o),s=">="+r+"."+i+"."+a+"-"+o+" <"+r+"."+(+i+1)+".0"):s=">="+r+"."+i+"."+a+" <"+r+"."+(+i+1)+".0",n("tilde return",s),s}))}(t,e)})).join(" ")}(t,e),n("tildes",t),t=function(t,e){return n("replaceXRanges",t,e),t.split(/\s+/).map((function(t){return function(t,e){t=t.trim();var r=e.loose?o[l.XRANGELOOSE]:o[l.XRANGE];return t.replace(r,(function(r,i,a,o,s,l){n("xRange",t,r,i,a,o,s,l);var c=T(a),u=c||T(o),h=u||T(s),f=h;return"="===i&&f&&(i=""),l=e.includePrerelease?"-0":"",c?r=">"===i||"<"===i?"<0.0.0-0":"*":i&&f?(u&&(o=0),s=0,">"===i?(i=">=",u?(a=+a+1,o=0,s=0):(o=+o+1,s=0)):"<="===i&&(i="<",u?a=+a+1:o=+o+1),r=i+a+"."+o+"."+s+l):u?r=">="+a+".0.0"+l+" <"+(+a+1)+".0.0"+l:h&&(r=">="+a+"."+o+".0"+l+" <"+a+"."+(+o+1)+".0"+l),n("xRange return",r),r}))}(t,e)})).join(" ")}(t,e),n("xrange",t),t=function(t,e){return n("replaceStars",t,e),t.trim().replace(o[l.STAR],"")}(t,e),n("stars",t),t}(t,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(a=a.filter((function(t){return!!t.match(i)}))),a=a.map((function(t){return new C(t,this.options)}),this)},k.prototype.intersects=function(t,e){if(!(t instanceof k))throw new TypeError("a Range is required");return this.set.some((function(r){return I(r,e)&&t.set.some((function(t){return I(t,e)&&r.every((function(r){return t.every((function(t){return r.intersects(t,e)}))}))}))}))},e.toComparators=function(t,e){return new k(t,e).set.map((function(t){return t.map((function(t){return t.value})).join(" ").trim().split(" ")}))},k.prototype.test=function(t){if(!t)return!1;if("string"==typeof t)try{t=new p(t,this.options)}catch(t){return!1}for(var e=0;e":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case"":case">=":r&&!v(r,e)||(r=e);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+t.operator)}}))}if(r&&t.test(r))return r;return null},e.validRange=function(t,e){try{return new k(t,e).range||"*"}catch(t){return null}},e.ltr=function(t,e,r){return D(t,e,"<",r)},e.gtr=function(t,e,r){return D(t,e,">",r)},e.outside=D,e.prerelease=function(t,e){var r=f(t,e);return r&&r.prerelease.length?r.prerelease:null},e.intersects=function(t,e,r){return t=new k(t,r),e=new k(e,r),t.intersects(e)},e.coerce=function(t,e){if(t instanceof p)return t;"number"==typeof t&&(t=String(t));if("string"!=typeof t)return null;var r=null;if((e=e||{}).rtl){for(var n;(n=o[l.COERCERTL].exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&n.index+n[0].length===r.index+r[0].length||(r=n),o[l.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;o[l.COERCERTL].lastIndex=-1}else r=t.match(o[l.COERCE]);if(null===r)return null;return f(r[2]+"."+(r[3]||"0")+"."+(r[4]||"0"),e)}}).call(this,r(75))},function(t,e,r){"use strict";var n=r(9);t.exports=s;var i="\0",a="\0",o="";function s(t){this._isDirected=!n.has(t,"directed")||t.directed,this._isMultigraph=!!n.has(t,"multigraph")&&t.multigraph,this._isCompound=!!n.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=n.constant(void 0),this._defaultEdgeLabelFn=n.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[a]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function l(t,e){t[e]?t[e]++:t[e]=1}function c(t,e){--t[e]||delete t[e]}function u(t,e,r,a){var s=""+e,l=""+r;if(!t&&s>l){var c=s;s=l,l=c}return s+o+l+o+(n.isUndefined(a)?i:a)}function h(t,e,r,n){var i=""+e,a=""+r;if(!t&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return n&&(s.name=n),s}function f(t,e){return u(t,e.v,e.w,e.name)}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(t){return this._label=t,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(t){return n.isFunction(t)||(t=n.constant(t)),this._defaultNodeLabelFn=t,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return n.keys(this._nodes)},s.prototype.sources=function(){var t=this;return n.filter(this.nodes(),(function(e){return n.isEmpty(t._in[e])}))},s.prototype.sinks=function(){var t=this;return n.filter(this.nodes(),(function(e){return n.isEmpty(t._out[e])}))},s.prototype.setNodes=function(t,e){var r=arguments,i=this;return n.each(t,(function(t){r.length>1?i.setNode(t,e):i.setNode(t)})),this},s.prototype.setNode=function(t,e){return n.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=a,this._children[t]={},this._children[a][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},s.prototype.node=function(t){return this._nodes[t]},s.prototype.hasNode=function(t){return n.has(this._nodes,t)},s.prototype.removeNode=function(t){var e=this;if(n.has(this._nodes,t)){var r=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],n.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),n.each(n.keys(this._in[t]),r),delete this._in[t],delete this._preds[t],n.each(n.keys(this._out[t]),r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},s.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n.isUndefined(e))e=a;else{for(var r=e+="";!n.isUndefined(r);r=this.parent(r))if(r===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},s.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},s.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==a)return e}},s.prototype.children=function(t){if(n.isUndefined(t)&&(t=a),this._isCompound){var e=this._children[t];if(e)return n.keys(e)}else{if(t===a)return this.nodes();if(this.hasNode(t))return[]}},s.prototype.predecessors=function(t){var e=this._preds[t];if(e)return n.keys(e)},s.prototype.successors=function(t){var e=this._sucs[t];if(e)return n.keys(e)},s.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return n.union(e,this.successors(t))},s.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},s.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var r=this;n.each(this._nodes,(function(r,n){t(n)&&e.setNode(n,r)})),n.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,r.edge(t))}));var i={};return this._isCompound&&n.each(e.nodes(),(function(t){e.setParent(t,function t(n){var a=r.parent(n);return void 0===a||e.hasNode(a)?(i[n]=a,a):a in i?i[a]:t(a)}(t))})),e},s.prototype.setDefaultEdgeLabel=function(t){return n.isFunction(t)||(t=n.constant(t)),this._defaultEdgeLabelFn=t,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return n.values(this._edgeObjs)},s.prototype.setPath=function(t,e){var r=this,i=arguments;return n.reduce(t,(function(t,n){return i.length>1?r.setEdge(t,n,e):r.setEdge(t,n),n})),this},s.prototype.setEdge=function(){var t,e,r,i,a=!1,o=arguments[0];"object"==typeof o&&null!==o&&"v"in o?(t=o.v,e=o.w,r=o.name,2===arguments.length&&(i=arguments[1],a=!0)):(t=o,e=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),t=""+t,e=""+e,n.isUndefined(r)||(r=""+r);var s=u(this._isDirected,t,e,r);if(n.has(this._edgeLabels,s))return a&&(this._edgeLabels[s]=i),this;if(!n.isUndefined(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[s]=a?i:this._defaultEdgeLabelFn(t,e,r);var c=h(this._isDirected,t,e,r);return t=c.v,e=c.w,Object.freeze(c),this._edgeObjs[s]=c,l(this._preds[e],t),l(this._sucs[t],e),this._in[e][s]=c,this._out[t][s]=c,this._edgeCount++,this},s.prototype.edge=function(t,e,r){var n=1===arguments.length?f(this._isDirected,arguments[0]):u(this._isDirected,t,e,r);return this._edgeLabels[n]},s.prototype.hasEdge=function(t,e,r){var i=1===arguments.length?f(this._isDirected,arguments[0]):u(this._isDirected,t,e,r);return n.has(this._edgeLabels,i)},s.prototype.removeEdge=function(t,e,r){var n=1===arguments.length?f(this._isDirected,arguments[0]):u(this._isDirected,t,e,r),i=this._edgeObjs[n];return i&&(t=i.v,e=i.w,delete this._edgeLabels[n],delete this._edgeObjs[n],c(this._preds[e],t),c(this._sucs[t],e),delete this._in[e][n],delete this._out[t][n],this._edgeCount--),this},s.prototype.inEdges=function(t,e){var r=this._in[t];if(r){var i=n.values(r);return e?n.filter(i,(function(t){return t.v===e})):i}},s.prototype.outEdges=function(t,e){var r=this._out[t];if(r){var i=n.values(r);return e?n.filter(i,(function(t){return t.w===e})):i}},s.prototype.nodeEdges=function(t,e){var r=this.inEdges(t,e);if(r)return r.concat(this.outEdges(t,e))}},function(t,e,r){var n=r(20)(r(13),"Map");t.exports=n},function(t,e,r){var n=r(287),i=r(294),a=r(296),o=r(297),s=r(298);function l(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e-1&&t%1==0&&t<=r}},function(t,e,r){(function(t){var n=r(77),i=e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,o=a&&a.exports===i&&n.process,s=function(){try{var t=a&&a.require&&a.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=s}).call(this,r(32)(t))},function(t,e,r){var n=r(45),i=r(304),a=Object.prototype.hasOwnProperty;t.exports=function(t){if(!n(t))return i(t);var e=[];for(var r in Object(t))a.call(t,r)&&"constructor"!=r&&e.push(r);return e}},function(t,e,r){var n=r(84),i=r(85),a=Object.prototype.propertyIsEnumerable,o=Object.getOwnPropertySymbols,s=o?function(t){return null==t?[]:(t=Object(t),n(o(t),(function(e){return a.call(t,e)})))}:i;t.exports=s},function(t,e){t.exports=function(t,e){for(var r=-1,n=e.length,i=t.length;++r0&&a(u)?r>1?t(u,r-1,a,o,s):n(s,u):o||(s[s.length]=u)}return s}},function(t,e,r){var n=r(28);t.exports=function(t,e,r){for(var i=-1,a=t.length;++i=0&&h.splice(e,1)}function v(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var n=function(){0;return r.nc}();n&&(t.attrs.nonce=n)}return y(e,t.attrs),g(t,e),e}function y(t,e){Object.keys(e).forEach((function(r){t.setAttribute(r,e[r])}))}function x(t,e){var r,n,i,a;if(e.transform&&t.css){if(!(a=e.transform(t.css)))return function(){};t.css=a}if(e.singleton){var o=u++;r=c||(c=v(e)),n=w.bind(null,r,o,!1),i=w.bind(null,r,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",y(e,t.attrs),g(t,e),e}(e),n=C.bind(null,r,e),i=function(){m(r),r.href&&URL.revokeObjectURL(r.href)}):(r=v(e),n=A.bind(null,r),i=function(){m(r)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else i()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var r=d(t,e);return p(r,e),function(t){for(var n=[],i=0;ie?1:0},j=null!=Object.assign?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r255)return;e.push(Math.floor(a))}var o=n[1]||n[2]||n[3],s=n[1]&&n[2]&&n[3];if(o&&!s)return;var l=r[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;e.push(l)}}return e}(t)||function(t){var e,r,n,i,a,o,s,l;function c(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}var u=new RegExp("^hsl[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(t);if(u){if((r=parseInt(u[1]))<0?r=(360- -1*r%360)%360:r>360&&(r%=360),r/=360,(n=parseFloat(u[2]))<0||n>100)return;if(n/=100,(i=parseFloat(u[3]))<0||i>100)return;if(i/=100,void 0!==(a=u[4])&&((a=parseFloat(a))<0||a>1))return;if(0===n)o=s=l=Math.round(255*i);else{var h=i<.5?i*(1+n):i+n-i*n,f=2*i-h;o=Math.round(255*c(f,h,r+1/3)),s=Math.round(255*c(f,h,r)),l=Math.round(255*c(f,h,r-1/3))}e=[o,s,l,a]}return e}(t)},Y={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},V=function(t){for(var e=t.map,r=t.keys,n=r.length,i=0;i1&&void 0!==arguments[1]?arguments[1]:5381,n=r;!(e=t.next()).done;)n=(n<<5)+n+e.value|0;return n},J=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;return(e<<5)+e+t|0},K=function(t,e){var r={value:0,done:!1},n=0,i=t.length;return X({next:function(){return n=0&&(t[n]!==e||(t.splice(n,1),r));n--);},yt=function(t){t.splice(0,t.length)},xt=function(t,e,r){return r&&(e=z(r,e)),t[e]},bt=function(t,e,r,n){r&&(e=z(r,e)),t[e]=n},_t="undefined"!=typeof Map?Map:function(){function t(){s(this,t),this._obj={}}return c(t,[{key:"set",value:function(t,e){return this._obj[t]=e,this}},{key:"delete",value:function(t){return this._obj[t]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(t){return void 0!==this._obj[t]}},{key:"get",value:function(t){return this._obj[t]}}]),t}(),wt=function(){function t(e){if(s(this,t),this._obj=Object.create(null),this.size=0,null!=e){var r;r=null!=e.instanceString&&e.instanceString()===this.instanceString()?e.toArray():e;for(var n=0;n0;){var C=x.pop(),M=m(C),k=C.id();if(f[k]=M,M!==1/0)for(var I=C.neighborhood().intersect(d),T=0;T0)for(r.unshift(e);h[i];){var a=h[i];r.unshift(a.edge),r.unshift(a.node),i=(n=a.node).id()}return s.spawn(r)}}}},Lt={kruskal:function(t){t=t||function(t){return 1};for(var e=this.byGroup(),r=e.nodes,n=e.edges,i=r.length,a=new Array(i),o=r,s=function(t){for(var e=0;e0;){if(c=m.pop(),u=c.id(),v.delete(u),w++,u===f){for(var A=[],C=i,M=f,k=x[M];A.unshift(C),null!=k&&A.unshift(k),null!=(C=y[M]);)k=x[M=C.id()];return{found:!0,distance:p[u],path:this.spawn(A),steps:w}}g[u]=!0;for(var I=c._private.edges,T=0;TI&&(p[k]=I,v[k]=M,x[k]=_),!i){var T=M*c+C;!i&&p[T]>I&&(p[T]=I,v[T]=C,x[T]=_)}}}for(var L=0;L1&&void 0!==arguments[1]?arguments[1]:a,n=v(t),i=[],o=n;;){if(null==o)return e.spawn();var l=m(o),c=l.edge,u=l.pred;if(i.unshift(o[0]),o.same(r)&&i.length>0)break;null!=c&&i.unshift(c),o=u}return s.spawn(i)},hasNegativeWeightCycle:d,negativeWeightCycles:[]}}},Rt=Math.sqrt(2),Ft=function(t,e,r){0===r.length&&ct("Karger-Stein must be run on a connected (sub)graph");for(var n=r[t],i=n[1],a=n[2],o=e[i],s=e[a],l=r,c=l.length-1;c>=0;c--){var u=l[c],h=u[1],f=u[2];(e[h]===o&&e[f]===s||e[h]===s&&e[f]===o)&&l.splice(c,1)}for(var p=0;pn;){var i=Math.floor(Math.random()*e.length);e=Ft(i,t,e),r--}return e},jt={kargerStein:function(){var t=this.byGroup(),e=t.nodes,r=t.edges;r.unmergeBy((function(t){return t.isLoop()}));var n=e.length,i=r.length,a=Math.ceil(Math.pow(Math.log(n)/Math.LN2,2)),o=Math.floor(n/Rt);if(!(n<2)){for(var s=[],l=0;l0?1:t<0?-1:0},Wt=function(t,e){return Math.sqrt(Zt(t,e))},Zt=function(t,e){var r=e.x-t.x,n=e.y-t.y;return r*r+n*n},Xt=function(t){for(var e=t.length,r=0,n=0;n=t.x1&&t.y2>=t.y1)return{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,w:t.x2-t.x1,h:t.y2-t.y1};if(null!=t.w&&null!=t.h&&t.w>=0&&t.h>=0)return{x1:t.x1,y1:t.y1,x2:t.x1+t.w,y2:t.y1+t.h,w:t.w,h:t.h}}},te=function(t,e,r){t.x1=Math.min(t.x1,e),t.x2=Math.max(t.x2,e),t.w=t.x2-t.x1,t.y1=Math.min(t.y1,r),t.y2=Math.max(t.y2,r),t.h=t.y2-t.y1},ee=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.x1-=e,t.x2+=e,t.y1-=e,t.y2+=e,t.w=t.x2-t.x1,t.h=t.y2-t.y1,t},re=function(t){var e,r,n,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===a.length)e=r=n=i=a[0];else if(2===a.length)e=n=a[0],i=r=a[1];else if(4===a.length){var o=u(a,4);e=o[0],r=o[1],n=o[2],i=o[3]}return t.x1-=i,t.x2+=r,t.y1-=e,t.y2+=n,t.w=t.x2-t.x1,t.h=t.y2-t.y1,t},ne=function(t,e){t.x1=e.x1,t.y1=e.y1,t.x2=e.x2,t.y2=e.y2,t.w=t.x2-t.x1,t.h=t.y2-t.y1},ie=function(t,e){t.x1+=e.x,t.x2+=e.x,t.y1+=e.y,t.y2+=e.y},ae=function(t,e){return!(t.x1>e.x2)&&(!(e.x1>t.x2)&&(!(t.x2e.y2)&&!(e.y1>t.y2)))))))},oe=function(t,e,r){return t.x1<=e&&e<=t.x2&&t.y1<=r&&r<=t.y2},se=function(t,e){return oe(t,e.x1,e.y1)&&oe(t,e.x2,e.y2)},le=function(t,e,r,n,i,a,o){var s,l=ke(i,a),c=i/2,u=a/2,h=n-u-o;if((s=be(t,e,r,n,r-c+l-o,h,r+c-l+o,h,!1)).length>0)return s;var f=r+c+o;if((s=be(t,e,r,n,f,n-u+l-o,f,n+u-l+o,!1)).length>0)return s;var p=n+u+o;if((s=be(t,e,r,n,r-c+l-o,p,r+c-l+o,p,!1)).length>0)return s;var d,g=r-c-o;if((s=be(t,e,r,n,g,n-u+l-o,g,n+u-l+o,!1)).length>0)return s;var m=r-c+l,v=n-u+l;if((d=ye(t,e,r,n,m,v,l+o)).length>0&&d[0]<=m&&d[1]<=v)return[d[0],d[1]];var y=r+c-l,x=n-u+l;if((d=ye(t,e,r,n,y,x,l+o)).length>0&&d[0]>=y&&d[1]<=x)return[d[0],d[1]];var b=r+c-l,_=n+u-l;if((d=ye(t,e,r,n,b,_,l+o)).length>0&&d[0]>=b&&d[1]>=_)return[d[0],d[1]];var w=r-c+l,A=n+u-l;return(d=ye(t,e,r,n,w,A,l+o)).length>0&&d[0]<=w&&d[1]>=A?[d[0],d[1]]:[]},ce=function(t,e,r,n,i,a,o){var s=o,l=Math.min(r,i),c=Math.max(r,i),u=Math.min(n,a),h=Math.max(n,a);return l-s<=t&&t<=c+s&&u-s<=e&&e<=h+s},ue=function(t,e,r,n,i,a,o,s,l){var c=Math.min(r,o,i)-l,u=Math.max(r,o,i)+l,h=Math.min(n,s,a)-l,f=Math.max(n,s,a)+l;return!(tu||ef)},he=function(t,e,r,n,i,a,o,s){var l=[];!function(t,e,r,n,i){var a,o,s,l,c,u,h,f;0===t&&(t=1e-5),s=-27*(n/=t)+(e/=t)*(9*(r/=t)-e*e*2),a=(o=(3*r-e*e)/9)*o*o+(s/=54)*s,i[1]=0,h=e/3,a>0?(c=(c=s+Math.sqrt(a))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),u=(u=s-Math.sqrt(a))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),i[0]=-h+c+u,h+=(c+u)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-u+c)/2,i[3]=h,i[5]=-h):(i[5]=i[3]=0,0===a?(f=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*f-h,i[4]=i[2]=-(f+h)):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),f=2*Math.sqrt(o),i[0]=-h+f*Math.cos(l/3),i[2]=-h+f*Math.cos((l+2*Math.PI)/3),i[4]=-h+f*Math.cos((l+4*Math.PI)/3)))}(1*r*r-4*r*i+2*r*o+4*i*i-4*i*o+o*o+n*n-4*n*a+2*n*s+4*a*a-4*a*s+s*s,9*r*i-3*r*r-3*r*o-6*i*i+3*i*o+9*n*a-3*n*n-3*n*s-6*a*a+3*a*s,3*r*r-6*r*i+r*o-r*t+2*i*i+2*i*t-o*t+3*n*n-6*n*a+n*s-n*e+2*a*a+2*a*e-s*e,1*r*i-r*r+r*t-i*t+n*a-n*n+n*e-a*e,l);for(var c=[],u=0;u<6;u+=2)Math.abs(l[u+1])<1e-7&&l[u]>=0&&l[u]<=1&&c.push(l[u]);c.push(1),c.push(0);for(var h,f,p,d=-1,g=0;g=0?pl?(t-i)*(t-i)+(e-a)*(e-a):c-h},pe=function(t,e,r){for(var n,i,a,o,s=0,l=0;l=t&&t>=a||n<=t&&t<=a))continue;(t-n)/(a-n)*(o-i)+i>e&&s++}return s%2!=0},de=function(t,e,r,n,i,a,o,s,l){var c,u=new Array(r.length);null!=s[0]?(c=Math.atan(s[1]/s[0]),s[0]<0?c+=Math.PI/2:c=-c-Math.PI/2):c=s;for(var h,f=Math.cos(-c),p=Math.sin(-c),d=0;d0){var g=me(u,-l);h=ge(g)}else h=u;return pe(t,e,h)},ge=function(t){for(var e,r,n,i,a,o,s,l,c=new Array(t.length/2),u=0;u=0&&d<=1&&m.push(d),g>=0&&g<=1&&m.push(g),0===m.length)return[];var v=m[0]*s[0]+t,y=m[0]*s[1]+e;return m.length>1?m[0]==m[1]?[v,y]:[v,y,m[1]*s[0]+t,m[1]*s[1]+e]:[v,y]},xe=function(t,e,r){return e<=t&&t<=r||r<=t&&t<=e?t:t<=e&&e<=r||r<=e&&e<=t?e:r},be=function(t,e,r,n,i,a,o,s,l){var c=t-i,u=r-t,h=o-i,f=e-a,p=n-e,d=s-a,g=h*f-d*c,m=u*f-p*c,v=d*u-h*p;if(0!==v){var y=g/v,x=m/v;return-.001<=y&&y<=1.001&&-.001<=x&&x<=1.001?[t+y*u,e+y*p]:l?[t+y*u,e+y*p]:[]}return 0===g||0===m?xe(t,r,o)===o?[o,s]:xe(t,r,i)===i?[i,a]:xe(i,o,r)===r?[r,n]:[]:[]},_e=function(t,e,r,n,i,a,o,s){var l,c,u,h,f,p,d=[],g=new Array(r.length),m=!0;if(null==a&&(m=!1),m){for(var v=0;v0){var y=me(g,-s);c=ge(y)}else c=g}else c=r;for(var x=0;xu&&(u=e)},f=function(t){return c[t]},p=0;p0?b.edgesTo(x)[0]:x.edgesTo(b)[0];var w=n(_);x=x.id(),p[x]>p[v]+w&&(p[x]=p[v]+w,d.nodes.indexOf(x)<0?d.push(x):d.updateItem(x),u[x]=0,c[x]=[]),p[x]==p[v]+w&&(u[x]=u[x]+u[v],c[x].push(v))}else for(var A=0;A0;)for(var I=r.pop(),T=0;T0&&o.push(r[s]);0!==o.length&&i.push(n.collection(o))}return i}(u,l,e,n);return x=function(t){for(var e=0;e5&&void 0!==arguments[5]?arguments[5]:We,o=n,s=0;s=2?$e(t,e,r,0,Je,Ke):$e(t,e,r,0,Xe)},squaredEuclidean:function(t,e,r){return $e(t,e,r,0,Je)},manhattan:function(t,e,r){return $e(t,e,r,0,Xe)},max:function(t,e,r){return $e(t,e,r,-1/0,Qe)}};function er(t,e,r,n,i,a){var o;return o=x(t)?t:tr[t]||tr.euclidean,0===e&&x(t)?o(i,a):o(e,r,n,i,a)}tr["squared-euclidean"]=tr.squaredEuclidean,tr.squaredeuclidean=tr.squaredEuclidean;var rr=mt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),nr=function(t){return rr(t)},ir=function(t,e,r,n,i){var a="kMedoids"!==i?function(t){return r[t]}:function(t){return n[t](r)},o=r,s=e;return er(t,n.length,a,(function(t){return n[t](e)}),o,s)},ar=function(t,e,r){for(var n=r.length,i=new Array(n),a=new Array(n),o=new Array(e),s=null,l=0;lr)return!1}return!0},cr=function(t,e,r){for(var n=0;ni&&(i=e[l][c],a=c);o[a].push(t[l])}for(var u=0;u=i.threshold||"dendrogram"===i.mode&&1===t.length)return!1;var p,d=e[o],g=e[n[o]];p="dendrogram"===i.mode?{left:d,right:g,key:d.key}:{value:d.value.concat(g.value),key:d.key},t[d.index]=p,t.splice(g.index,1),e[d.key]=p;for(var m=0;mr[g.key][v.key]&&(a=r[g.key][v.key])):"max"===i.linkage?(a=r[d.key][v.key],r[d.key][v.key]1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];n?t=t.slice(e,r):(r0&&t.splice(0,e));for(var o=0,s=t.length-1;s>=0;s--){var l=t[s];a?isFinite(l)||(t[s]=-1/0,o++):t.splice(s,1)}i&&t.sort((function(t,e){return t-e}));var c=t.length,u=Math.floor(c/2);return c%2!=0?t[u+1+o]:(t[u-1+o]+t[u+o])/2}(t):"mean"===e?function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,n=0,i=0,a=e;a1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,n=1/0,i=e;i1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,n=-1/0,i=e;io&&(a=l,o=e[i*t+l])}a>0&&n.push(a)}for(var c=0;c=I?(T=I,I=S,L=E):S>T&&(T=S);for(var D=0;D0?1:0;C[A%c.minIterations*e+N]=j,F+=j}if(F>0&&(A>=c.minIterations-1||A==c.maxIterations-1)){for(var B=0,Y=0;Y0&&n.push(i);return n}(e,a,o),H=function(t,e,r){for(var n=Mr(t,e,r),i=0;il&&(s=c,l=u)}r[i]=a[s]}return n=Mr(t,e,r)}(e,n,U),G={},q=0;q0:void 0}},clearQueue:function(){return function(){var t=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;for(var e=0;e0&&this.spawn(r).updateStyle().emit("class"),this},addClass:function(t){return this.toggleClass(t,!0)},hasClass:function(t){var e=this[0];return null!=e&&e._private.classes.has(t)},toggleClass:function(t,e){b(t)||(t=t.match(/\S+/g)||[]);for(var r=void 0===e,n=[],i=0,a=this.length;i0&&this.spawn(n).updateStyle().emit("class"),this},removeClass:function(t){return this.toggleClass(t,!1)},flashClass:function(t,e){var r=this;if(null==e)e=250;else if(0===e)return r;return r.addClass(t),setTimeout((function(){r.removeClass(t)}),e),r}};jr.className=jr.classNames=jr.classes;var Br={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])*"|'+"'(?:\\\\'|[^'])*'",number:F,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Br.variable="(?:[\\w-]|(?:\\\\"+Br.metaChar+"))+",Br.value=Br.string+"|"+Br.number,Br.className=Br.variable,Br.id=Br.variable,function(){var t,e,r;for(t=Br.comparatorOp.split("|"),r=0;r=0||"="!==e&&(Br.comparatorOp+="|\\!"+e)}();var Yr=0,Vr=1,Ur=2,Hr=3,Gr=4,qr=5,Wr=6,Zr=7,Xr=8,Jr=9,Kr=10,Qr=11,$r=12,tn=13,en=14,rn=15,nn=16,an=17,on=18,sn=19,ln=20,cn=[{selector:":selected",matches:function(t){return t.selected()}},{selector:":unselected",matches:function(t){return!t.selected()}},{selector:":selectable",matches:function(t){return t.selectable()}},{selector:":unselectable",matches:function(t){return!t.selectable()}},{selector:":locked",matches:function(t){return t.locked()}},{selector:":unlocked",matches:function(t){return!t.locked()}},{selector:":visible",matches:function(t){return t.visible()}},{selector:":hidden",matches:function(t){return!t.visible()}},{selector:":transparent",matches:function(t){return t.transparent()}},{selector:":grabbed",matches:function(t){return t.grabbed()}},{selector:":free",matches:function(t){return!t.grabbed()}},{selector:":removed",matches:function(t){return t.removed()}},{selector:":inside",matches:function(t){return!t.removed()}},{selector:":grabbable",matches:function(t){return t.grabbable()}},{selector:":ungrabbable",matches:function(t){return!t.grabbable()}},{selector:":animated",matches:function(t){return t.animated()}},{selector:":unanimated",matches:function(t){return!t.animated()}},{selector:":parent",matches:function(t){return t.isParent()}},{selector:":childless",matches:function(t){return t.isChildless()}},{selector:":child",matches:function(t){return t.isChild()}},{selector:":orphan",matches:function(t){return t.isOrphan()}},{selector:":nonorphan",matches:function(t){return t.isChild()}},{selector:":compound",matches:function(t){return t.isNode()?t.isParent():t.source().isParent()||t.target().isParent()}},{selector:":loop",matches:function(t){return t.isLoop()}},{selector:":simple",matches:function(t){return t.isSimple()}},{selector:":active",matches:function(t){return t.active()}},{selector:":inactive",matches:function(t){return!t.active()}},{selector:":backgrounding",matches:function(t){return t.backgrounding()}},{selector:":nonbackgrounding",matches:function(t){return!t.backgrounding()}}].sort((function(t,e){return function(t,e){return-1*N(t,e)}(t.selector,e.selector)})),un=function(){for(var t,e={},r=0;r0&&l.edgeCount>0)return ht("The selector `"+t+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return ht("The selector `"+t+"` is invalid because it uses multiple edge selectors"),!1;1===l.edgeCount&&ht("The selector `"+t+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var t=function(t){return null==t?"":t},e=function(e){return y(e)?'"'+e+'"':t(e)},r=function(t){return" "+t+" "},n=function(n,a){var o=n.type,s=n.value;switch(o){case Yr:var l=t(s);return l.substring(0,l.length-1);case Hr:var c=n.field,u=n.operator;return"["+c+r(t(u))+e(s)+"]";case qr:var h=n.operator,f=n.field;return"["+t(h)+f+"]";case Gr:return"["+n.field+"]";case Wr:var p=n.operator;return"[["+n.field+r(t(p))+e(s)+"]]";case Zr:return s;case Xr:return"#"+s;case Jr:return"."+s;case an:case rn:return i(n.parent,a)+r(">")+i(n.child,a);case on:case nn:return i(n.ancestor,a)+" "+i(n.descendant,a);case sn:var d=i(n.left,a),g=i(n.subject,a),m=i(n.right,a);return d+(d.length>0?" ":"")+g+m;case ln:return""}},i=function(t,e){return t.checks.reduce((function(r,i,a){return r+(e===t&&0===a?"$":"")+n(i,e)}),"")},a="",o=0;o1&&o=0&&(e=e.replace("!",""),u=!0),e.indexOf("@")>=0&&(e=e.replace("@",""),c=!0),(o||l||c)&&(i=o||s?""+t:"",a=""+r),c&&(t=i=i.toLowerCase(),r=a=a.toLowerCase()),e){case"*=":n=i.indexOf(a)>=0;break;case"$=":n=i.indexOf(a,i.length-a.length)>=0;break;case"^=":n=0===i.indexOf(a);break;case"=":n=t===r;break;case">":h=!0,n=t>r;break;case">=":h=!0,n=t>=r;break;case"<":h=!0,n=t0;){var c=i.shift();e(c),a.add(c.id()),o&&n(i,a,c)}return t}function Ln(t,e,r){if(r.isParent())for(var n=r._private.children,i=0;i1&&void 0!==arguments[1])||arguments[1];return Tn(this,t,e,Ln)},In.forEachUp=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Tn(this,t,e,Sn)},In.forEachUpAndDown=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Tn(this,t,e,En)},In.ancestors=In.parents,(Cn=Mn={data:Fr.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:Fr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Fr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Fr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Fr.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Fr.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var t=this[0];if(t)return t._private.data.id}}).attr=Cn.data,Cn.removeAttr=Cn.removeData;var Dn,Pn,On=Mn,zn={};function Rn(t){return function(e){if(void 0===e&&(e=!0),0!==this.length&&this.isNode()&&!this.removed()){for(var r=0,n=this[0],i=n._private.edges,a=0;ae})),minIndegree:Fn("indegree",(function(t,e){return te})),minOutdegree:Fn("outdegree",(function(t,e){return te}))}),j(zn,{totalDegree:function(t){for(var e=0,r=this.nodes(),n=0;n0,u=c;c&&(l=l[0]);var h=u?l.position():{x:0,y:0};return i={x:s.x-h.x,y:s.y-h.y},void 0===t?i:i[t]}for(var f=0;f0,m=g;g&&(d=d[0]);var v=m?d.position():{x:0,y:0};void 0!==e?p.position(t,e+v[t]):void 0!==i&&p.position({x:i.x+v.x,y:i.y+v.y})}}else if(!a)return;return this}}).modelPosition=Dn.point=Dn.position,Dn.modelPositions=Dn.points=Dn.positions,Dn.renderedPoint=Dn.renderedPosition,Dn.relativePoint=Dn.relativePosition;var Bn,Yn,Vn=Pn;Bn=Yn={},Yn.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),n=r.zoom(),i=r.pan(),a=e.x1*n+i.x,o=e.x2*n+i.x,s=e.y1*n+i.y,l=e.y2*n+i.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},Yn.dirtyCompoundBoundsCache=function(){var t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp((function(t){if(t.isParent()){var e=t._private;e.compoundBoundsClean=!1,e.bbCache=null,t.emitAndNotify("bounds")}})),this):this},Yn.updateCompoundBounds=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!t&&e.batching())return this;function r(t){if(t.isParent()){var e=t._private,r=t.children(),n="include"===t.pstyle("compound-sizing-wrt-labels").value,i={width:{val:t.pstyle("min-width").pfValue,left:t.pstyle("min-width-bias-left"),right:t.pstyle("min-width-bias-right")},height:{val:t.pstyle("min-height").pfValue,top:t.pstyle("min-height-bias-top"),bottom:t.pstyle("min-height-bias-bottom")}},a=r.boundingBox({includeLabels:n,includeOverlays:!1,useCache:!1}),o=e.position;0!==a.w&&0!==a.h||((a={w:t.pstyle("width").pfValue,h:t.pstyle("height").pfValue}).x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);var s=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(s=100*s/i.width.val);var l=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(l=100*l/i.width.val);var c=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(c=100*c/i.height.val);var u=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(u=100*u/i.height.val);var h=v(i.width.val-a.w,s,l),f=h.biasDiff,p=h.biasComplementDiff,d=v(i.height.val-a.h,c,u),g=d.biasDiff,m=d.biasComplementDiff;e.autoPadding=function(t,e,r,n){if("%"!==r.units)return"px"===r.units?r.pfValue:0;switch(n){case"width":return t>0?r.pfValue*t:0;case"height":return e>0?r.pfValue*e:0;case"average":return t>0&&e>0?r.pfValue*(t+e)/2:0;case"min":return t>0&&e>0?t>e?r.pfValue*e:r.pfValue*t:0;case"max":return t>0&&e>0?t>e?r.pfValue*t:r.pfValue*e:0;default:return 0}}(a.w,a.h,t.pstyle("padding"),t.pstyle("padding-relative-to").value),e.autoWidth=Math.max(a.w,i.width.val),o.x=(-f+a.x1+a.x2+p)/2,e.autoHeight=Math.max(a.h,i.height.val),o.y=(-g+a.y1+a.y2+m)/2}function v(t,e,r){var n=0,i=0,a=e+r;return t>0&&a>0&&(n=e/a*t,i=r/a*t),{biasDiff:n,biasComplementDiff:i}}}for(var n=0;nt.x2?n:t.x2,t.y1=rt.y2?i:t.y2,t.w=t.x2-t.x1,t.h=t.y2-t.y1)},Gn=function(t,e){return null==e?t:Hn(t,e.x1,e.y1,e.x2,e.y2)},qn=function(t,e,r){return xt(t,e,r)},Wn=function(t,e,r){if(!e.cy().headless()){var n,i,a=e._private,o=a.rstyle,s=o.arrowWidth/2;if("none"!==e.pstyle(r+"-arrow-shape").value){"source"===r?(n=o.srcX,i=o.srcY):"target"===r?(n=o.tgtX,i=o.tgtY):(n=o.midX,i=o.midY);var l=a.arrowBounds=a.arrowBounds||{},c=l[r]=l[r]||{};c.x1=n-s,c.y1=i-s,c.x2=n+s,c.y2=i+s,c.w=c.x2-c.x1,c.h=c.y2-c.y1,ee(c,1),Hn(t,c.x1,c.y1,c.x2,c.y2)}}},Zn=function(t,e,r){if(!e.cy().headless()){var n;n=r?r+"-":"";var i=e._private,a=i.rstyle;if(e.pstyle(n+"label").strValue){var o,s,l,c,u=e.pstyle("text-halign"),h=e.pstyle("text-valign"),f=qn(a,"labelWidth",r),p=qn(a,"labelHeight",r),d=qn(a,"labelX",r),g=qn(a,"labelY",r),m=e.pstyle(n+"text-margin-x").pfValue,v=e.pstyle(n+"text-margin-y").pfValue,y=e.isEdge(),x=e.pstyle(n+"text-rotation"),b=e.pstyle("text-outline-width").pfValue,_=e.pstyle("text-border-width").pfValue/2,w=e.pstyle("text-background-padding").pfValue,A=p,C=f,M=C/2,k=A/2;if(y)o=d-M,s=d+M,l=g-k,c=g+k;else{switch(u.value){case"left":o=d-C,s=d;break;case"center":o=d-M,s=d+M;break;case"right":o=d,s=d+C}switch(h.value){case"top":l=g-A,c=g;break;case"center":l=g-k,c=g+k;break;case"bottom":l=g,c=g+A}}o+=m-Math.max(b,_)-w,s+=m+Math.max(b,_)+w,l+=v-Math.max(b,_)-w,c+=v+Math.max(b,_)+w;var I=r||"main",T=i.labelBounds,L=T[I]=T[I]||{};L.x1=o,L.y1=l,L.x2=s,L.y2=c,L.w=s-o,L.h=c-l,ee(L,1);var S=y&&"autorotate"===x.strValue,E=null!=x.pfValue&&0!==x.pfValue;if(S||E){var D=S?qn(i.rstyle,"labelAngle",r):x.pfValue,P=Math.cos(D),O=Math.sin(D),z=(o+s)/2,R=(l+c)/2;if(!y){switch(u.value){case"left":z=s;break;case"right":z=o}switch(h.value){case"top":R=c;break;case"bottom":R=l}}var F=function(t,e){return{x:(t-=z)*P-(e-=R)*O+z,y:t*O+e*P+R}},N=F(o,l),j=F(o,c),B=F(s,l),Y=F(s,c);o=Math.min(N.x,j.x,B.x,Y.x),s=Math.max(N.x,j.x,B.x,Y.x),l=Math.min(N.y,j.y,B.y,Y.y),c=Math.max(N.y,j.y,B.y,Y.y)}var V=I+"Rot",U=T[V]=T[V]||{};U.x1=o,U.y1=l,U.x2=s,U.y2=c,U.w=s-o,U.h=c-l,Hn(t,o,l,s,c),Hn(i.labelBounds.all,o,l,s,c)}return t}},Xn=function(t){var e=0,r=function(t){return(t?1:0)<(n=k[1].x)){var I=r;r=n,n=I}if(i>(a=k[1].y)){var T=i;i=a,a=T}Hn(f,r-_,i-_,n+_,a+_)}}else if("bezier"===M||"unbundled-bezier"===M||"segments"===M||"taxi"===M){var L;switch(M){case"bezier":case"unbundled-bezier":L=m.bezierPts;break;case"segments":case"taxi":L=m.linePts}if(null!=L)for(var S=0;S(n=P.x)){var O=r;r=n,n=O}if((i=D.y)>(a=P.y)){var z=i;i=a,a=z}Hn(f,r-=_,i-=_,n+=_,a+=_)}if(u&&e.includeEdges&&g&&(Wn(f,t,"mid-source"),Wn(f,t,"mid-target"),Wn(f,t,"source"),Wn(f,t,"target")),u)if("yes"===t.pstyle("ghost").value){var R=t.pstyle("ghost-offset-x").pfValue,F=t.pstyle("ghost-offset-y").pfValue;Hn(f,f.x1+R,f.y1+F,f.x2+R,f.y2+F)}var N=p.bodyBounds=p.bodyBounds||{};ne(N,f),re(N,v),ee(N,1),u&&(r=f.x1,n=f.x2,i=f.y1,a=f.y2,Hn(f,r-b,i-b,n+b,a+b));var j=p.overlayBounds=p.overlayBounds||{};ne(j,f),re(j,v),ee(j,1);var B=p.labelBounds=p.labelBounds||{};null!=B.all?((l=B.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):B.all=$t(),u&&e.includeLabels&&(e.includeMainLabels&&Zn(f,t,null),g&&(e.includeSourceLabels&&Zn(f,t,"source"),e.includeTargetLabels&&Zn(f,t,"target")))}return f.x1=Un(f.x1),f.y1=Un(f.y1),f.x2=Un(f.x2),f.y2=Un(f.y2),f.w=Un(f.x2-f.x1),f.h=Un(f.y2-f.y1),f.w>0&&f.h>0&&x&&(re(f,v),ee(f,1)),f}(t,Qn),n.bbCache=r,n.bbCacheShift.x=n.bbCacheShift.y=0,n.bbCachePosKey=o):r=n.bbCache,!l&&(0!==n.bbCacheShift.x||0!==n.bbCacheShift.y)){var c=ie,u=n.bbCacheShift,h=function(t,e){null!=t&&c(t,e)};c(r,u);var f=n.bodyBounds,p=n.overlayBounds,d=n.labelBounds,g=n.arrowBounds;h(f,u),h(p,u),null!=g&&(h(g.source,u),h(g.target,u),h(g["mid-source"],u),h(g["mid-target"],u)),null!=d&&(h(d.main,u),h(d.all,u),h(d.source,u),h(d.target,u))}if(n.bbCacheShift.x=n.bbCacheShift.y=0,!a){var m=t.isNode();r=$t(),(e.includeNodes&&m||e.includeEdges&&!m)&&(e.includeOverlays?Gn(r,n.overlayBounds):Gn(r,n.bodyBounds)),e.includeLabels&&(e.includeMainLabels&&(!i||e.includeSourceLabels&&e.includeTargetLabels)?Gn(r,n.labelBounds.all):(e.includeMainLabels&&Gn(r,n.labelBounds.mainRot),e.includeSourceLabels&&Gn(r,n.labelBounds.sourceRot),e.includeTargetLabels&&Gn(r,n.labelBounds.targetRot))),r.w=r.x2-r.x1,r.h=r.y2-r.y1}return r},Qn={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,useCache:!0},$n=Xn(Qn),ti=mt(Qn);Yn.boundingBox=function(t){var e;if(1!==this.length||null==this[0]._private.bbCache||void 0!==t&&void 0!==t.useCache&&!0!==t.useCache){e=$t();var r=ti(t=t||Qn);if(this.cy().styleEnabled())for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:gi,e=arguments.length>1?arguments[1]:void 0,r=0;r=0;s--)o(s);return this},vi.removeAllListeners=function(){return this.removeListener("*")},vi.emit=vi.trigger=function(t,e,r){var n=this.listeners,i=n.length;return this.emitting++,b(e)||(e=[e]),bi(this,(function(t,a){null!=r&&(n=[{event:a.event,type:a.type,namespace:a.namespace,callback:r}],i=n.length);for(var o=function(r){var i=n[r];if(i.type===a.type&&(!i.namespace||i.namespace===a.namespace||".*"===i.namespace)&&t.eventMatches(t.context,i,a)){var o=[a];null!=e&&function(t,e){for(var r=0;r1&&!n){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[t]=a,r.set(o,{ele:a,index:t})}return this.length--,this},unmergeOne:function(t){t=t[0];var e=this._private,r=t._private.data.id,n=e.map.get(r);if(!n)return this;var i=n.index;return this.unmergeAt(i),this},unmerge:function(t){var e=this._private.cy;if(!t)return this;if(t&&y(t)){var r=t;t=e.mutableElements().filter(r)}for(var n=0;n=0;e--){t(this[e])&&this.unmergeAt(e)}return this},map:function(t,e){for(var r=[],n=0;nn&&(n=o,r=a)}return{value:n,ele:r}},min:function(t,e){for(var r,n=1/0,i=0;i=0&&i1&&void 0!==arguments[1])||arguments[1],r=this[0],n=r.cy();if(n.styleEnabled()&&r){var i=r._private.style[t];return null!=i?i:e?n.style().getDefaultProperty(t):null}},numericStyle:function(t){var e=this[0];if(e.cy().styleEnabled()&&e){var r=e.pstyle(t);return void 0!==r.pfValue?r.pfValue:r.value}},numericStyleUnits:function(t){var e=this[0];if(e.cy().styleEnabled())return e?e.pstyle(t).units:void 0},renderedStyle:function(t){var e=this.cy();if(!e.styleEnabled())return this;var r=this[0];return r?e.style().getRenderedStyle(r,t):void 0},style:function(t,e){var r=this.cy();if(!r.styleEnabled())return this;var n=r.style();if(_(t)){var i=t;n.applyBypass(this,i,!1),this.emitAndNotify("style")}else if(y(t)){if(void 0===e){var a=this[0];return a?n.getStylePropertyValue(a,t):void 0}n.applyBypass(this,t,e,!1),this.emitAndNotify("style")}else if(void 0===t){var o=this[0];return o?n.getRawStyle(o):void 0}return this},removeStyle:function(t){var e=this.cy();if(!e.styleEnabled())return this;var r=e.style();if(void 0===t)for(var n=0;n0&&e.push(u[0]),e.push(s[0])}return this.spawn(e,{unique:!0}).filter(t)}),"neighborhood"),closedNeighborhood:function(t){return this.neighborhood().add(this).filter(t)},openNeighborhood:function(t){return this.neighborhood(t)}}),Hi.neighbourhood=Hi.neighborhood,Hi.closedNeighbourhood=Hi.closedNeighborhood,Hi.openNeighbourhood=Hi.openNeighborhood,j(Hi,{source:kn((function(t){var e,r=this[0];return r&&(e=r._private.source||r.cy().collection()),e&&t?e.filter(t):e}),"source"),target:kn((function(t){var e,r=this[0];return r&&(e=r._private.target||r.cy().collection()),e&&t?e.filter(t):e}),"target"),sources:Zi({attr:"source"}),targets:Zi({attr:"target"})}),j(Hi,{edgesWith:kn(Xi(),"edgesWith"),edgesTo:kn(Xi({thisIsSrc:!0}),"edgesTo")}),j(Hi,{connectedEdges:kn((function(t){for(var e=[],r=0;r0);return a},component:function(){var t=this[0];return t.cy().mutableElements().components(t)[0]}}),Hi.componentsOf=Hi.components;var Ki=function(t,e,r){for(var n=null!=r?r:pt();t.hasElementWithId(n);)n=pt();return n},Qi=function(t,e,r){if(void 0!==t&&I(t)){var n=new _t,i=!1;if(e){if(e.length>0&&_(e[0])&&!M(e[0])){i=!0;for(var a=[],o=new At,s=0,l=e.length;s0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this,a=i.cy(),o=a._private,s=[],l=[],c=0,u=i.length;c0){for(var N=new Qi(a,t),j=0;j0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this,n=[],i={},a=r._private.cy;function o(t){for(var e=t._private.edges,r=0;r0&&(t?I.emitAndNotify("remove"):e&&I.emit("remove"));for(var T=0;T=a?function(e,n){for(var a=0;a0?i=l:n=l}while(Math.abs(a)>o&&++c1e-4&&Math.abs(s.v)>1e-4;);return a?function(t){return c[t*(c.length-1)|0]}:u}}(),na=function(t,e,r,n){var i=ea(t,e,r,n);return function(t,e,r){return t+(e-t)*i(r)}},ia={linear:function(t,e,r){return t+(e-t)*r},ease:na(.25,.1,.25,1),"ease-in":na(.42,0,1,1),"ease-out":na(0,0,.58,1),"ease-in-out":na(.42,0,.58,1),"ease-in-sine":na(.47,0,.745,.715),"ease-out-sine":na(.39,.575,.565,1),"ease-in-out-sine":na(.445,.05,.55,.95),"ease-in-quad":na(.55,.085,.68,.53),"ease-out-quad":na(.25,.46,.45,.94),"ease-in-out-quad":na(.455,.03,.515,.955),"ease-in-cubic":na(.55,.055,.675,.19),"ease-out-cubic":na(.215,.61,.355,1),"ease-in-out-cubic":na(.645,.045,.355,1),"ease-in-quart":na(.895,.03,.685,.22),"ease-out-quart":na(.165,.84,.44,1),"ease-in-out-quart":na(.77,0,.175,1),"ease-in-quint":na(.755,.05,.855,.06),"ease-out-quint":na(.23,1,.32,1),"ease-in-out-quint":na(.86,0,.07,1),"ease-in-expo":na(.95,.05,.795,.035),"ease-out-expo":na(.19,1,.22,1),"ease-in-out-expo":na(1,0,0,1),"ease-in-circ":na(.6,.04,.98,.335),"ease-out-circ":na(.075,.82,.165,1),"ease-in-out-circ":na(.785,.135,.15,.86),spring:function(t,e,r){if(0===r)return ia.linear;var n=ra(t,e,r);return function(t,e,r){return t+(e-t)*n(r)}},"cubic-bezier":na};function aa(t,e,r,n,i){if(1===n)return r;var a=i(e,r,n);return null==t?a:((t.roundValue||t.color)&&(a=Math.round(a)),void 0!==t.min&&(a=Math.max(a,t.min)),void 0!==t.max&&(a=Math.min(a,t.max)),a)}function oa(t,e){return null!=t.pfValue||null!=t.value?null==t.pfValue||null!=e&&"%"===e.type.units?t.value:t.pfValue:t}function sa(t,e,r,n,i){var a=null!=i?i.type:null;r<0?r=0:r>1&&(r=1);var o=oa(t,i),s=oa(e,i);if(w(o)&&w(s))return aa(a,o,s,r,n);if(b(o)&&b(s)){for(var l=[],c=0;c0?("spring"===h&&f.push(o.duration),o.easingImpl=ia[h].apply(null,f)):o.easingImpl=ia[h]}var p,d=o.easingImpl;if(p=0===o.duration?1:(r-l)/o.duration,o.applying&&(p=o.progress),p<0?p=0:p>1&&(p=1),null==o.delay){var g=o.startPosition,m=o.position;if(m&&i&&!t.locked()){var v={};ca(g.x,m.x)&&(v.x=sa(g.x,m.x,p,d)),ca(g.y,m.y)&&(v.y=sa(g.y,m.y,p,d)),t.position(v)}var x=o.startPan,b=o.pan,_=a.pan,w=null!=b&&n;w&&(ca(x.x,b.x)&&(_.x=sa(x.x,b.x,p,d)),ca(x.y,b.y)&&(_.y=sa(x.y,b.y,p,d)),t.emit("pan"));var A=o.startZoom,C=o.zoom,M=null!=C&&n;M&&(ca(A,C)&&(a.zoom=Qt(a.minZoom,sa(A,C,p,d),a.maxZoom)),t.emit("zoom")),(w||M)&&t.emit("viewport");var k=o.style;if(k&&k.length>0&&i){for(var I=0;I=0;e--){(0,t[e])()}t.splice(0,t.length)},h=a.length-1;h>=0;h--){var f=a[h],p=f._private;p.stopped?(a.splice(h,1),p.hooked=!1,p.playing=!1,p.started=!1,u(p.frames)):(p.playing||p.applying)&&(p.playing&&p.applying&&(p.applying=!1),p.started||ua(0,f,t),la(e,f,t,r),p.applying&&(p.applying=!1),u(p.frames),null!=p.step&&p.step(t),f.completed()&&(a.splice(h,1),p.hooked=!1,p.playing=!1,p.started=!1,u(p.completes)),s=!0)}return r||0!==a.length||0!==o.length||n.push(e),s}for(var a=!1,o=0;o0?e.notify("draw",r):e.notify("draw")),r.unmerge(n),e.emit("step")}var fa={animate:Fr.animate(),animation:Fr.animation(),animated:Fr.animated(),clearQueue:Fr.clearQueue(),delay:Fr.delay(),delayAnimation:Fr.delayAnimation(),stop:Fr.stop(),addToAnimationPool:function(t){this.styleEnabled()&&this._private.aniEles.merge(t)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var t=this;if(t._private.animationsRunning=!0,t.styleEnabled()){var e=t.renderer();e&&e.beforeRender?e.beforeRender((function(e,r){ha(r,t)}),e.beforeRenderPriorities.animations):function e(){t._private.animationsRunning&&W((function(r){ha(r,t),e()}))}()}}},pa={qualifierCompare:function(t,e){return null==t||null==e?null==t&&null==e:t.sameText(e)},eventMatches:function(t,e,r){var n=e.qualifier;return null==n||t!==r.target&&M(r.target)&&n.matches(r.target)},addEventFields:function(t,e){e.cy=t,e.target=t},callbackContext:function(t,e,r){return null!=e.qualifier?r.target:t}},da=function(t){return y(t)?new _n(t):t},ga={createEmitter:function(){var t=this._private;return t.emitter||(t.emitter=new mi(pa,this)),this},emitter:function(){return this._private.emitter},on:function(t,e,r){return this.emitter().on(t,da(e),r),this},removeListener:function(t,e,r){return this.emitter().removeListener(t,da(e),r),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(t,e,r){return this.emitter().one(t,da(e),r),this},once:function(t,e,r){return this.emitter().one(t,da(e),r),this},emit:function(t,e){return this.emitter().emit(t,e),this},emitAndNotify:function(t,e){return this.emit(t),this.notify(t,e),this}};Fr.eventAliasesOn(ga);var ma={png:function(t){return t=t||{},this._private.renderer.png(t)},jpg:function(t){var e=this._private.renderer;return(t=t||{}).bg=t.bg||"#fff",e.jpg(t)}};ma.jpeg=ma.jpg;var va={layout:function(t){if(null!=t)if(null!=t.name){var e=t.name,r=this.extension("layout",e);if(null!=r){var n;n=y(t.eles)?this.$(t.eles):null!=t.eles?t.eles:this.$();var i=new r(j({},t,{cy:this,eles:n}));return i}ct("No such layout `"+e+"` found. Did you forget to import it and `cytoscape.use()` it?")}else ct("A `name` must be specified to make a layout");else ct("Layout options must be specified to make a layout")}};va.createLayout=va.makeLayout=va.layout;var ya={notify:function(t,e){var r=this._private;if(this.batching()){r.batchNotifications=r.batchNotifications||{};var n=r.batchNotifications[t]=r.batchNotifications[t]||this.collection();null!=e&&n.merge(e)}else if(r.notificationsEnabled){var i=this.renderer();!this.destroyed()&&i&&i.notify(t,e)}},notifications:function(t){var e=this._private;return void 0===t?e.notificationsEnabled:(e.notificationsEnabled=!!t,this)},noNotifications:function(t){this.notifications(!1),t(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var t=this._private;return null==t.batchCount&&(t.batchCount=0),0===t.batchCount&&(t.batchStyleEles=this.collection(),t.batchNotifications={}),t.batchCount++,this},endBatch:function(){var t=this._private;if(0===t.batchCount)return this;if(t.batchCount--,0===t.batchCount){t.batchStyleEles.updateStyle();var e=this.renderer();Object.keys(t.batchNotifications).forEach((function(r){var n=t.batchNotifications[r];n.empty()?e.notify(r):e.notify(r,n)}))}return this},batch:function(t){return this.startBatch(),t(),this.endBatch(),this},batchData:function(t){var e=this;return this.batch((function(){for(var r=Object.keys(t),n=0;n0;)t.removeChild(t.childNodes[0]);this._private.renderer=null,this.mutableElements().forEach((function(t){var e=t._private;e.rscratch={},e.rstyle={},e.animation.current=[],e.animation.queue=[]}))},onRender:function(t){return this.on("render",t)},offRender:function(t){return this.off("render",t)}};ba.invalidateDimensions=ba.resize;var _a={collection:function(t,e){return y(t)?this.$(t):C(t)?t.collection():b(t)?new Qi(this,t,e):new Qi(this)},nodes:function(t){var e=this.$((function(t){return t.isNode()}));return t?e.filter(t):e},edges:function(t){var e=this.$((function(t){return t.isEdge()}));return t?e.filter(t):e},$:function(t){var e=this._private.elements;return t?e.filter(t):e.spawnSelf()},mutableElements:function(){return this._private.elements}};_a.elements=_a.filter=_a.$;var wa={};wa.apply=function(t){var e=this._private,r=e.cy.collection();e.newStyle&&(e.contextStyles={},e.propDiffs={},this.cleanElements(t,!0));for(var n=0;n0;if(h||u&&f){var p=void 0;h&&f?p=l.properties:h?p=l.properties:f&&(p=l.mappedProperties);for(var d=0;d1&&(g=1),s.color){var b=i.valueMin[0],_=i.valueMax[0],A=i.valueMin[1],C=i.valueMax[1],M=i.valueMin[2],k=i.valueMax[2],I=null==i.valueMin[3]?1:i.valueMin[3],T=null==i.valueMax[3]?1:i.valueMax[3],L=[Math.round(b+(_-b)*g),Math.round(A+(C-A)*g),Math.round(M+(k-M)*g),Math.round(I+(T-I)*g)];r={bypass:i.bypass,name:i.name,value:L,strValue:"rgb("+L[0]+", "+L[1]+", "+L[2]+")"}}else{if(!s.number)return!1;var S=i.valueMin+(i.valueMax-i.valueMin)*g;r=this.parse(i.name,S,i.bypass,"mapping")}if(!r)return d(),!1;r.mapping=i,i=r;break;case o.data:for(var E=i.field.split("."),D=h.data,P=0;P0&&a>0){for(var s={},l=!1,c=0;c0?t.delayAnimation(o).play().promise().then(e):e()})).then((function(){return t.animation({style:s,duration:a,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){r.removeBypasses(t,i),t.emitAndNotify("style"),n.transitioning=!1}))}else n.transitioning&&(this.removeBypasses(t,i),t.emitAndNotify("style"),n.transitioning=!1)},wa.checkTrigger=function(t,e,r,n,i,a){var o=this.properties[e],s=i(o);null!=s&&s(r,n)&&a(o)},wa.checkZOrderTrigger=function(t,e,r,n){var i=this;this.checkTrigger(t,e,r,n,(function(t){return t.triggersZOrder}),(function(){i._private.cy.notify("zorder",t)}))},wa.checkBoundsTrigger=function(t,e,r,n){this.checkTrigger(t,e,r,n,(function(t){return t.triggersBounds}),(function(i){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache(),"bezier"!==t.pstyle("curve-style").value&&("curve-style"!==e||"bezier"!==r&&"bezier"!==n)||!i.triggersBoundsOfParallelBeziers||t.parallelEdges().forEach((function(t){t.isBundledBezier()&&t.dirtyBoundingBoxCache()}))}))},wa.checkTriggers=function(t,e,r,n){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,n),this.checkBoundsTrigger(t,e,r,n)};var Aa={applyBypass:function(t,e,r,n){var i=[];if("*"===e||"**"===e){if(void 0!==r)for(var a=0;ae.length?i.substr(e.length):""}function o(){r=r.length>n.length?r.substr(n.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(i.match(/^\s*$/))break;var s=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!s){ht("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}e=s[0];var l=s[1];if("core"!==l)if(new _n(l).invalid){ht("Skipping parsing of block: Invalid selector found in string stylesheet: "+l),a();continue}var c=s[2],u=!1;r=c;for(var h=[];;){if(r.match(/^\s*$/))break;var f=r.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!f){ht("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+c),u=!0;break}n=f[0];var p=f[1],d=f[2];if(this.properties[p])this.parse(p,d)?(h.push({name:p,val:d}),o()):(ht("Skipping property: Invalid property definition in: "+n),o());else ht("Skipping property: Invalid property name in: "+n),o()}if(u){a();break}this.selector(l);for(var g=0;g=7&&"d"===e[0]&&(l=new RegExp(o.data.regex).exec(e))){if(r)return!1;var h=o.data;return{name:t,value:l,strValue:""+e,mapped:h,field:l[1],bypass:r}}if(e.length>=10&&"m"===e[0]&&(c=new RegExp(o.mapData.regex).exec(e))){if(r)return!1;if(u.multiple)return!1;var f=o.mapData;if(!u.color&&!u.number)return!1;var p=this.parse(t,c[4]);if(!p||p.mapped)return!1;var d=this.parse(t,c[5]);if(!d||d.mapped)return!1;if(p.pfValue===d.pfValue||p.strValue===d.strValue)return ht("`"+t+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+p.strValue+"`"),this.parse(t,p.strValue);if(u.color){var g=p.value,m=d.value;if(!(g[0]!==m[0]||g[1]!==m[1]||g[2]!==m[2]||g[3]!==m[3]&&(null!=g[3]&&1!==g[3]||null!=m[3]&&1!==m[3])))return!1}return{name:t,value:c,strValue:""+e,mapped:f,field:c[1],fieldMin:parseFloat(c[2]),fieldMax:parseFloat(c[3]),valueMin:p.value,valueMax:d.value,bypass:r}}}if(u.multiple&&"multiple"!==n){var v;if(v=s?e.split(/\s+/):b(e)?e:[e],u.evenMultiple&&v.length%2!=0)return null;for(var _=[],A=[],C=[],M="",k=!1,I=0;I0?" ":"")+T.strValue}return u.validate&&!u.validate(_,A)?null:u.singleEnum&&k?1===_.length&&y(_[0])?{name:t,value:_[0],strValue:_[0],bypass:r}:null:{name:t,value:_,pfValue:C,strValue:M,bypass:r,units:A}}var L,S,E=function(){for(var n=0;nu.max||u.strictMax&&e===u.max))return null;var N={name:t,value:e,strValue:""+e+(D||""),units:D,bypass:r};return u.unitless||"px"!==D&&"em"!==D?N.pfValue=e:N.pfValue="px"!==D&&D?this.getEmSizeInPixels()*e:e,"ms"!==D&&"s"!==D||(N.pfValue="ms"===D?e:1e3*e),"deg"!==D&&"rad"!==D||(N.pfValue="rad"===D?e:(L=e,Math.PI*L/180)),"%"===D&&(N.pfValue=e/100),N}if(u.propList){var j=[],Y=""+e;if("none"===Y);else{for(var V=Y.split(/\s*,\s*|\s+/),U=0;U0&&l>0&&!isNaN(r.w)&&!isNaN(r.h)&&r.w>0&&r.h>0)return{zoom:o=(o=(o=Math.min((s-2*e)/r.w,(l-2*e)/r.h))>this._private.maxZoom?this._private.maxZoom:o)=r.minZoom&&(r.maxZoom=e),this},minZoom:function(t){return void 0===t?this._private.minZoom:this.zoomRange({min:t})},maxZoom:function(t){return void 0===t?this._private.maxZoom:this.zoomRange({max:t})},getZoomedViewport:function(t){var e,r,n=this._private,i=n.pan,a=n.zoom,o=!1;if(n.zoomingEnabled||(o=!0),w(t)?r=t:_(t)&&(r=t.level,null!=t.position?e=Yt(t.position,a,i):null!=t.renderedPosition&&(e=t.renderedPosition),null==e||n.panningEnabled||(o=!0)),r=(r=r>n.maxZoom?n.maxZoom:r)e.maxZoom||!e.zoomingEnabled?a=!0:(e.zoom=s,i.push("zoom"))}if(n&&(!a||!t.cancelOnFailedZoom)&&e.panningEnabled){var l=t.pan;w(l.x)&&(e.pan.x=l.x,o=!1),w(l.y)&&(e.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(t){var e=this.getCenterPan(t);return e&&(this._private.pan=e,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(t,e){if(this._private.panningEnabled){if(y(t)){var r=t;t=this.mutableElements().filter(r)}else C(t)||(t=this.mutableElements());if(0!==t.length){var n=t.boundingBox(),i=this.width(),a=this.height();return{x:(i-(e=void 0===e?this._private.zoom:e)*(n.x1+n.x2))/2,y:(a-e*(n.y1+n.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var t,e,r=this._private,n=r.container;return r.sizeCache=r.sizeCache||(n?(t=h.getComputedStyle(n),e=function(e){return parseFloat(t.getPropertyValue(e))},{width:n.clientWidth-e("padding-left")-e("padding-right"),height:n.clientHeight-e("padding-top")-e("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var t=this._private.pan,e=this._private.zoom,r=this.renderedExtent(),n={x1:(r.x1-t.x)/e,x2:(r.x2-t.x)/e,y1:(r.y1-t.y)/e,y2:(r.y2-t.y)/e};return n.w=n.x2-n.x1,n.h=n.y2-n.y1,n},renderedExtent:function(){var t=this.width(),e=this.height();return{x1:0,y1:0,x2:t,y2:e,w:t,h:e}}};Pa.centre=Pa.center,Pa.autolockNodes=Pa.autolock,Pa.autoungrabifyNodes=Pa.autoungrabify;var Oa={data:Fr.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeData:Fr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0}),scratch:Fr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeScratch:Fr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0})};Oa.attr=Oa.data,Oa.removeAttr=Oa.removeData;var za=function(t){var e=this,r=(t=j({},t)).container;r&&!A(r)&&A(r[0])&&(r=r[0]);var n=r?r._cyreg:null;(n=n||{})&&n.cy&&(n.cy.destroy(),n={});var i=n.readies=n.readies||[];r&&(r._cyreg=n),n.cy=e;var a=void 0!==h&&void 0!==r&&!t.headless,o=t;o.layout=j({name:a?"grid":"null"},o.layout),o.renderer=j({name:a?"canvas":"null"},o.renderer);var s=function(t,e,r){return void 0!==e?e:void 0!==r?r:t},l=this._private={container:r,ready:!1,options:o,elements:new Qi(this),listeners:[],aniEles:new Qi(this),data:{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?a:o.styleEnabled,zoom:w(o.zoom)?o.zoom:1,pan:{x:_(o.pan)&&w(o.pan.x)?o.pan.x:0,y:_(o.pan)&&w(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});l.styleEnabled&&e.setStyle([]);var c=j({},o,o.renderer);e.initRenderer(c);!function(t,e){if(t.some(S))return Or.all(t).then(e);e(t)}([o.style,o.elements],(function(t){var r=t[0],a=t[1];l.styleEnabled&&e.style().append(r),function(t,r,n){e.notifications(!1);var i=e.mutableElements();i.length>0&&i.remove(),null!=t&&(_(t)||b(t))&&e.add(t),e.one("layoutready",(function(t){e.notifications(!0),e.emit(t),e.one("load",r),e.emitAndNotify("load")})).one("layoutstop",(function(){e.one("done",n),e.emit("done")}));var a=j({},e._private.options.layout);a.eles=e.elements(),e.layout(a).run()}(a,(function(){e.startAnimationLoop(),l.ready=!0,x(o.ready)&&e.on("ready",o.ready);for(var t=0;t0,c=$t(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(C(r.roots))t=r.roots;else if(b(r.roots)){for(var u=[],h=0;h0;){var D=L.shift(),P=T(D,S);if(P)D.outgoers().filter((function(t){return t.isNode()&&i.has(t)})).forEach(E);else if(null===P){ht("Detected double maximal shift for node `"+D.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}I();var O=0;if(r.avoidOverlap)for(var z=0;z0&&v[0].length<=3?l/2:0),h=2*Math.PI/v[n].length*i;return 0===n&&1===v[0].length&&(u=1),{x:Z+u*Math.cos(h),y:X+u*Math.sin(h)}}return{x:Z+(i+1-(a+1)/2)*o,y:(n+1)*s}})),this};var Ya={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(t,e){return!0},ready:void 0,stop:void 0,transform:function(t,e){return e}};function Va(t){this.options=j({},Ya,t)}Va.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles,i=void 0!==e.counterclockwise?!e.counterclockwise:e.clockwise,a=n.nodes().not(":parent");e.sort&&(a=a.sort(e.sort));for(var o,s=$t(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),l=s.x1+s.w/2,c=s.y1+s.h/2,u=(void 0===e.sweep?2*Math.PI-2*Math.PI/a.length:e.sweep)/Math.max(1,a.length-1),h=0,f=0;f1&&e.avoidOverlap){h*=1.75;var m=Math.cos(u)-Math.cos(0),v=Math.sin(u)-Math.sin(0),y=Math.sqrt(h*h/(m*m+v*v));o=Math.max(y,o)}return a.layoutPositions(this,e,(function(t,r){var n=e.startAngle+r*u*(i?1:-1),a=o*Math.cos(n),s=o*Math.sin(n);return{x:l+a,y:c+s}})),this};var Ua,Ha={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(t){return t.degree()},levelWidth:function(t){return t.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(t,e){return!0},ready:void 0,stop:void 0,transform:function(t,e){return e}};function Ga(t){this.options=j({},Ha,t)}Ga.prototype.run=function(){for(var t=this.options,e=t,r=void 0!==e.counterclockwise?!e.counterclockwise:e.clockwise,n=t.cy,i=e.eles.nodes().not(":parent"),a=$t(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),o=a.x1+a.w/2,s=a.y1+a.h/2,l=[],c=0,u=0;u0)Math.abs(v[0].value-x.value)>=g&&(v=[],m.push(v));v.push(x)}var b=c+e.minNodeSpacing;if(!e.avoidOverlap){var _=m.length>0&&m[0].length>1,w=(Math.min(a.w,a.h)/2-b)/(m.length+_?1:0);b=Math.min(b,w)}for(var A=0,C=0;C1&&e.avoidOverlap){var T=Math.cos(I)-Math.cos(0),L=Math.sin(I)-Math.sin(0),S=Math.sqrt(b*b/(T*T+L*L));A=Math.max(S,A)}M.r=A,A+=b}if(e.equidistant){for(var E=0,D=0,P=0;P=t.numIter)&&(to(n,t),n.temperature=n.temperature*t.coolingFactor,!(n.temperature=t.animationThreshold&&a(),W(e)):(fo(n,t),s())}()}else{for(;c;)c=o(l),l++;fo(n,t),s()}return this},Wa.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Wa.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Za=function(t,e,r){for(var n=r.eles.edges(),i=r.eles.nodes(),a={isCompound:t.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:n.size(),temperature:r.initialTemp,clientWidth:t.width(),clientHeight:t.width(),boundingBox:$t(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()})},o=r.eles.components(),s={},l=0;l0){a.graphSet.push(_);for(l=0;l<_.length;l++)f[++d]=_[l]}}for(l=0;ln.count?0:n.graph},Ja=function t(e,r,n,i){var a=i.graphSet[n];if(-10)var s=(c=n.nodeOverlap*o)*i/(g=Math.sqrt(i*i+a*a)),l=c*a/g;else{var c,u=ao(t,i,a),h=ao(e,-1*i,-1*a),f=h.x-u.x,p=h.y-u.y,d=f*f+p*p,g=Math.sqrt(d);s=(c=(t.nodeRepulsion+e.nodeRepulsion)/d)*f/g,l=c*p/g}t.isLocked||(t.offsetX-=s,t.offsetY-=l),e.isLocked||(e.offsetX+=s,e.offsetY+=l)}},io=function(t,e,r,n){if(r>0)var i=t.maxX-e.minX;else i=e.maxX-t.minX;if(n>0)var a=t.maxY-e.minY;else a=e.maxY-t.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},ao=function(t,e,r){var n=t.positionX,i=t.positionY,a=t.height||1,o=t.width||1,s=r/e,l=a/o,c={};return 0===e&&0r?(c.x=n,c.y=i+a/2,c):0e&&-1*l<=s&&s<=l?(c.x=n-o/2,c.y=i-o*r/2/e,c):0=l)?(c.x=n+a*e/2/r,c.y=i+a/2,c):0>r&&(s<=-1*l||s>=l)?(c.x=n-a*e/2/r,c.y=i-a/2,c):c},oo=function(t,e){for(var r=0;r1){var d=e.gravity*h/p,g=e.gravity*f/p;u.offsetX+=d,u.offsetY+=g}}}}},lo=function(t,e){var r=[],n=0,i=-1;for(r.push.apply(r,t.graphSet[0]),i+=t.graphSet[0].length;n<=i;){var a=r[n++],o=t.idToIndex[a],s=t.layoutNodes[o],l=s.children;if(0r)var i={x:r*t/n,y:r*e/n};else i={x:t,y:e};return i},ho=function t(e,r){var n=e.parentId;if(null!=n){var i=r.layoutNodes[r.idToIndex[n]],a=!1;return(null==i.maxX||e.maxX+i.padRight>i.maxX)&&(i.maxX=e.maxX+i.padRight,a=!0),(null==i.minX||e.minX-i.padLefti.maxY)&&(i.maxY=e.maxY+i.padBottom,a=!0),(null==i.minY||e.minY-i.padTopd&&(h+=p+e.componentSpacing,u=0,f=0,p=0)}}},po={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(t){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(t,e){return!0},ready:void 0,stop:void 0,transform:function(t,e){return e}};function go(t){this.options=j({},po,t)}go.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles.nodes().not(":parent");e.sort&&(n=n.sort(e.sort));var i=$t(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(0===i.h||0===i.w)n.layoutPositions(this,e,(function(t){return{x:i.x1,y:i.y1}}));else{var a=n.size(),o=Math.sqrt(a*i.h/i.w),s=Math.round(o),l=Math.round(i.w/i.h*o),c=function(t){if(null==t)return Math.min(s,l);Math.min(s,l)==s?s=t:l=t},u=function(t){if(null==t)return Math.max(s,l);Math.max(s,l)==s?s=t:l=t},h=e.rows,f=null!=e.cols?e.cols:e.columns;if(null!=h&&null!=f)s=h,l=f;else if(null!=h&&null==f)s=h,l=Math.ceil(a/s);else if(null==h&&null!=f)l=f,s=Math.ceil(a/l);else if(l*s>a){var p=c(),d=u();(p-1)*d>=a?c(p-1):(d-1)*p>=a&&u(d-1)}else for(;l*s=a?u(m+1):c(g+1)}var v=i.w/l,y=i.h/s;if(e.condense&&(v=0,y=0),e.avoidOverlap)for(var x=0;x=l&&(S=0,L++)},D={},P=0;P(n=fe(t,e,b[_],b[_+1],b[_+2],b[_+3])))return m(r,n),!0}else if("bezier"===a.edgeType||"multibezier"===a.edgeType||"self"===a.edgeType||"compound"===a.edgeType)for(b=a.allpts,_=0;_+5(n=he(t,e,b[_],b[_+1],b[_+2],b[_+3],b[_+4],b[_+5])))return m(r,n),!0;y=y||i.source,x=x||i.target;var w=o.getArrowWidth(l,u),A=[{name:"source",x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:"target",x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:"mid-source",x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:"mid-target",x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}];for(_=0;_0&&(v(y),v(x))}function x(t,e,r){return xt(t,e,r)}function b(r,n){var i,a=r._private,o=d;i=n?n+"-":"",r.boundingBox();var s=a.labelBounds[n||"main"],l=r.pstyle(i+"label").value;if("yes"===r.pstyle("text-events").strValue&&l){var c=a.rstyle,u=x(c,"labelX",n),h=x(c,"labelY",n),f=x(a.rscratch,"labelAngle",n),p=s.x1-o,g=s.x2+o,v=s.y1-o,y=s.y2+o;if(f){var b=Math.cos(f),_=Math.sin(f),w=function(t,e){return{x:(t-=u)*b-(e-=h)*_+u,y:t*_+e*b+h}},A=w(p,v),C=w(p,y),M=w(g,v),k=w(g,y),I=[A.x,A.y,M.x,M.y,k.x,k.y,C.x,C.y];if(pe(t,e,I))return m(r),!0}else if(oe(s,t,e))return m(r),!0}}r&&(l=l.interactive);for(var _=l.length-1;_>=0;_--){var w=l[_];w.isNode()?v(w)||b(w):y(w)||b(w)||b(w,"source")||b(w,"target")}return c},getAllInBox:function(t,e,r,n){for(var i,a,o=this.getCachedZSortedEles().interactive,s=[],l=Math.min(t,r),c=Math.max(t,r),u=Math.min(e,n),h=Math.max(e,n),f=$t({x1:t=l,y1:e=u,x2:r=c,y2:n=h}),p=0;p0?Math.max(t-e,0):Math.min(t+e,0)},b=x(v,g),_=x(y,m),w=!1;"auto"===c?c=Math.abs(b)>Math.abs(_)?"horizontal":"vertical":"upward"===c||"downward"===c?(c="vertical",w=!0):"leftward"!==c&&"rightward"!==c||(c="horizontal",w=!0);var A="vertical"===c,C=A?_:b,M=A?y:v,k=qt(M),I=!1;w&&d||!("downward"===u&&M<0||"upward"===u&&M>0||"leftward"===u&&M>0||"rightward"===u&&M<0)||(C=(k*=-1)*Math.abs(C),I=!0);var T=d?f*C:f*k,L=function(t){return Math.abs(t)=Math.abs(C)},S=L(T),E=L(C-T);if((S||E)&&!I)if(A){var D=Math.abs(M)<=a/2,P=Math.abs(v)<=o/2;if(D){var O=(n.x1+n.x2)/2,z=n.y1,R=n.y2;r.segpts=[O,z,O,R]}else if(P){var F=(n.y1+n.y2)/2,N=n.x1,j=n.x2;r.segpts=[N,F,j,F]}else r.segpts=[n.x1,n.y2]}else{var B=Math.abs(M)<=i/2,Y=Math.abs(y)<=s/2;if(B){var V=(n.y1+n.y2)/2,U=n.x1,H=n.x2;r.segpts=[U,V,H,V]}else if(Y){var G=(n.x1+n.x2)/2,q=n.y1,W=n.y2;r.segpts=[G,q,G,W]}else r.segpts=[n.x2,n.y1]}else if(A){var Z=n.y1+T+(l?a/2*k:0),X=n.x1,J=n.x2;r.segpts=[X,Z,J,Z]}else{var K=n.x1+T+(l?i/2*k:0),Q=n.y1,$=n.y2;r.segpts=[K,Q,K,$]}},To.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if("bezier"===r.edgeType){var n=e.srcPos,i=e.tgtPos,a=e.srcW,o=e.srcH,s=e.tgtW,l=e.tgtH,c=e.srcShape,u=e.tgtShape,h=!w(r.startX)||!w(r.startY),f=!w(r.arrowStartX)||!w(r.arrowStartY),p=!w(r.endX)||!w(r.endY),d=!w(r.arrowEndX)||!w(r.arrowEndY),g=3*(this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth),m=Wt({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),v=mf.poolIndex()){var p=h;h=f,f=p}var d=s.srcPos=h.position(),g=s.tgtPos=f.position(),m=s.srcW=h.outerWidth(),v=s.srcH=h.outerHeight(),y=s.tgtW=f.outerWidth(),x=s.tgtH=f.outerHeight(),b=s.srcShape=r.nodeShapes[e.getNodeShape(h)],_=s.tgtShape=r.nodeShapes[e.getNodeShape(f)];s.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var A=0;A=u||x){h={cp:m,segment:y};break}}if(h)break}var b=h.cp,_=h.segment,w=(u-p)/_.length,A=_.t1-_.t0,C=c?_.t0+A*w:_.t1-A*w;C=Qt(0,C,1),e=Kt(b.p0,b.p1,b.p2,C),l=function(t,e,r,n){var i=Qt(0,n-.001,1),a=Qt(0,n+.001,1),o=Kt(t,e,r,i),s=Kt(t,e,r,a);return zo(o,s)}(b.p0,b.p1,b.p2,C);break;case"straight":case"segments":case"haystack":for(var M,k,I,T,L=0,S=n.allpts.length,E=0;E+3=u));E+=2);var D=(u-k)/M;D=Qt(0,D,1),e=function(t,e,r,n){var i=e.x-t.x,a=e.y-t.y,o=Wt(t,e),s=i/o,l=a/o;return r=null==r?0:r,n=null!=n?n:r*o,{x:t.x+s*n,y:t.y+l*n}}(I,T,D),l=zo(I,T)}o("labelX",s,e.x),o("labelY",s,e.y),o("labelAutoAngle",s,l)}};l("source"),l("target"),this.applyLabelDimensions(t)}},Po.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))},Po.applyPrefixedLabelDimensions=function(t,e){var r=t._private,n=this.getLabelText(t,e),i=this.calculateLabelDimensions(t,n),a=t.pstyle("line-height").pfValue,o=t.pstyle("text-wrap").strValue,s=xt(r.rscratch,"labelWrapCachedLines",e)||[],l="wrap"!==o?1:Math.max(s.length,1),c=i.height/l,u=c*a,h=i.width,f=i.height+(l-1)*(a-1)*c;bt(r.rstyle,"labelWidth",e,h),bt(r.rscratch,"labelWidth",e,h),bt(r.rstyle,"labelHeight",e,f),bt(r.rscratch,"labelHeight",e,f),bt(r.rscratch,"labelLineHeight",e,u)},Po.getLabelText=function(t,e){var r=t._private,n=e?e+"-":"",i=t.pstyle(n+"label").strValue,a=t.pstyle("text-transform").value,o=function(t,n){return n?(bt(r.rscratch,t,e,n),n):xt(r.rscratch,t,e)};if(!i)return"";"none"==a||("uppercase"==a?i=i.toUpperCase():"lowercase"==a&&(i=i.toLowerCase()));var s=t.pstyle("text-wrap").value;if("wrap"===s){var l=o("labelKey");if(null!=l&&o("labelWrapKey")===l)return o("labelWrapCachedText");for(var c=i.split("\n"),u=t.pstyle("text-max-width").pfValue,h="anywhere"===t.pstyle("text-overflow-wrap").value,f=[],p=/[\s\u200b]+/,d=h?"":" ",g=0;gu){for(var x=m.split(p),b="",_=0;_C)break;M+=i[I],I===i.length-1&&(k=!0)}return k||(M+="…"),M}return i},Po.getLabelJustification=function(t){var e=t.pstyle("text-justification").strValue,r=t.pstyle("text-halign").strValue;if("auto"!==e)return e;if(!t.isNode())return"center";switch(r){case"left":return"right";case"right":return"left";default:return"center"}},Po.calculateLabelDimensions=function(t,e){var r=Q(e,t._private.labelDimsKey),n=this.labelDimCache||(this.labelDimCache=[]),i=n[r];if(null!=i)return i;var a=t.pstyle("font-style").strValue,o=1*t.pstyle("font-size").pfValue+"px",s=t.pstyle("font-family").strValue,l=t.pstyle("font-weight").strValue,c=this.labelCalcDiv;c||(c=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(c));var u=c.style;return u.fontFamily=s,u.fontStyle=a,u.fontSize=o,u.fontWeight=l,u.position="absolute",u.left="-9999px",u.top="-9999px",u.zIndex="-1",u.visibility="hidden",u.pointerEvents="none",u.padding="0",u.lineHeight="1","wrap"===t.pstyle("text-wrap").value?u.whiteSpace="pre":u.whiteSpace="normal",c.textContent=e,n[r]={width:Math.ceil(c.clientWidth/1),height:Math.ceil(c.clientHeight/1)}},Po.calculateLabelAngle=function(t,e){var r=t._private.rscratch,n=t.isEdge(),i=e?e+"-":"",a=t.pstyle(i+"text-rotation"),o=a.strValue;return"none"===o?0:n&&"autorotate"===o?r.labelAutoAngle:"autorotate"===o?0:a.pfValue},Po.calculateLabelAngles=function(t){var e=this,r=t.isEdge(),n=t._private.rscratch;n.labelAngle=e.calculateLabelAngle(t),r&&(n.sourceLabelAngle=e.calculateLabelAngle(t,"source"),n.targetLabelAngle=e.calculateLabelAngle(t,"target"))};var Ro={},Fo=!1;Ro.getNodeShape=function(t){var e=t.pstyle("shape").value;if("cutrectangle"===e&&(t.width()<28||t.height()<28))return Fo||(ht("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Fo=!0),"rectangle";if(t.isParent())return"rectangle"===e||"roundrectangle"===e||"cutrectangle"===e||"barrel"===e?e:"rectangle";if("polygon"===e){var r=t.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(r).name}return e};var No={registerCalculationListeners:function(){var t=this.cy,e=t.collection(),r=this,n=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.merge(t),r)for(var n=0;n=t.desktopTapThreshold2}var I=n(e);m&&(t.hoverData.tapholdCancelled=!0);i=!0,r(g,["mousemove","vmousemove","tapdrag"],e,{x:u[0],y:u[1]});var T=function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||o.emit({originalEvent:e,type:"boxstart",position:{x:u[0],y:u[1]}}),d[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()};if(3===t.hoverData.which){if(m){var L={originalEvent:e,type:"cxtdrag",position:{x:u[0],y:u[1]}};x?x.emit(L):o.emit(L),t.hoverData.cxtDragged=!0,t.hoverData.cxtOver&&g===t.hoverData.cxtOver||(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:u[0],y:u[1]}}),t.hoverData.cxtOver=g,g&&g.emit({originalEvent:e,type:"cxtdragover",position:{x:u[0],y:u[1]}}))}}else if(t.hoverData.dragging){if(i=!0,o.panningEnabled()&&o.userPanningEnabled()){var S;if(t.hoverData.justStartedPan){var E=t.hoverData.mdownPos;S={x:(u[0]-E[0])*s,y:(u[1]-E[1])*s},t.hoverData.justStartedPan=!1}else S={x:b[0]*s,y:b[1]*s};o.panBy(S),t.hoverData.dragged=!0}u=t.projectIntoViewport(e.clientX,e.clientY)}else if(1!=d[4]||null!=x&&!x.pannable()){if(x&&x.pannable()&&x.active()&&x.unactivate(),x&&x.grabbed()||g==v||(v&&r(v,["mouseout","tapdragout"],e,{x:u[0],y:u[1]}),g&&r(g,["mouseover","tapdragover"],e,{x:u[0],y:u[1]}),t.hoverData.last=g),x)if(m){if(o.boxSelectionEnabled()&&I)x&&x.grabbed()&&(h(_),x.emit("freeon"),_.emit("free"),t.dragData.didDrag&&(x.emit("dragfreeon"),_.emit("dragfree"))),T();else if(x&&x.grabbed()&&t.nodeIsDraggable(x)){var D=!t.dragData.didDrag;D&&t.redrawHint("eles",!0),t.dragData.didDrag=!0;var P=o.collection();t.hoverData.draggingEles||c(_,{inDragLayer:!0});var O={x:0,y:0};if(w(b[0])&&w(b[1])&&(O.x+=b[0],O.y+=b[1],D)){var z=t.hoverData.dragDelta;z&&w(z[0])&&w(z[1])&&(O.x+=z[0],O.y+=z[1])}for(var R=0;R<_.length;R++){var F=_[R];t.nodeIsDraggable(F)&&F.grabbed()&&P.merge(F)}t.hoverData.draggingEles=!0,P.silentShift(O).emit("position drag"),t.redrawHint("drag",!0),t.redraw()}}else!function(){var e=t.hoverData.dragDelta=t.hoverData.dragDelta||[];0===e.length?(e.push(b[0]),e.push(b[1])):(e[0]+=b[0],e[1]+=b[1])}();i=!0}else if(m){if(t.hoverData.dragging||!o.boxSelectionEnabled()||!I&&o.panningEnabled()&&o.userPanningEnabled()){if(!t.hoverData.selecting&&o.panningEnabled()&&o.userPanningEnabled()){a(x,t.hoverData.downs)&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,d[4]=0,t.data.bgActivePosistion=Ut(f),t.redrawHint("select",!0),t.redraw())}}else T();x&&x.pannable()&&x.active()&&x.unactivate()}return d[2]=u[0],d[3]=u[1],i?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),!1):void 0}}),!1),t.registerBinding(window,"mouseup",(function(i){if(t.hoverData.capture){t.hoverData.capture=!1;var a=t.cy,o=t.projectIntoViewport(i.clientX,i.clientY),s=t.selection,l=t.findNearestElement(o[0],o[1],!0,!1),c=t.dragData.possibleDragElements,u=t.hoverData.down,f=n(i);if(t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,u&&u.unactivate(),3===t.hoverData.which){var p={originalEvent:i,type:"cxttapend",position:{x:o[0],y:o[1]}};if(u?u.emit(p):a.emit(p),!t.hoverData.cxtDragged){var d={originalEvent:i,type:"cxttap",position:{x:o[0],y:o[1]}};u?u.emit(d):a.emit(d)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(1===t.hoverData.which){if(r(l,["mouseup","tapend","vmouseup"],i,{x:o[0],y:o[1]}),t.dragData.didDrag||t.hoverData.dragged||t.hoverData.selecting||t.hoverData.isOverThresholdDrag||r(u,["click","tap","vclick"],i,{x:o[0],y:o[1]}),null!=u||t.dragData.didDrag||t.hoverData.selecting||t.hoverData.dragged||n(i)||(a.$(e).unselect(["tapunselect"]),c.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=c=a.collection()),l!=u||t.dragData.didDrag||t.hoverData.selecting||null!=l&&l._private.selectable&&(t.hoverData.dragging||("additive"===a.selectionType()||f?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):f||(a.$(e).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var g=a.collection(t.getAllInBox(s[0],s[1],s[2],s[3]));t.redrawHint("select",!0),g.length>0&&t.redrawHint("eles",!0),a.emit({type:"boxend",originalEvent:i,position:{x:o[0],y:o[1]}});var m=function(t){return t.selectable()&&!t.selected()};"additive"===a.selectionType()?g.emit("box").stdFilter(m).select().emit("boxselect"):(f||a.$(e).unmerge(g).unselect(),g.emit("box").stdFilter(m).select().emit("boxselect")),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!s[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var v=u&&u.grabbed();h(c),v&&(u.emit("freeon"),c.emit("free"),t.dragData.didDrag&&(u.emit("dragfreeon"),c.emit("dragfree")))}}s[4]=0,t.hoverData.down=null,t.hoverData.cxtStarted=!1,t.hoverData.draggingEles=!1,t.hoverData.selecting=!1,t.hoverData.isOverThresholdDrag=!1,t.dragData.didDrag=!1,t.hoverData.dragged=!1,t.hoverData.dragDelta=[],t.hoverData.mdownPos=null,t.hoverData.mdownGPos=null}}),!1);var x,b,_,A,C,M,k,I,T,L,S,E,D;t.registerBinding(t.container,"wheel",(function(e){if(!t.scrollingPage){var r,n=t.cy,i=t.projectIntoViewport(e.clientX,e.clientY),a=[i[0]*n.zoom()+n.pan().x,i[1]*n.zoom()+n.pan().y];if(t.hoverData.draggingEles||t.hoverData.dragging||t.hoverData.cxtStarted||0!==t.selection[4])e.preventDefault();else if(n.panningEnabled()&&n.userPanningEnabled()&&n.zoomingEnabled()&&n.userZoomingEnabled())e.preventDefault(),t.data.wheelZooming=!0,clearTimeout(t.data.wheelTimeout),t.data.wheelTimeout=setTimeout((function(){t.data.wheelZooming=!1,t.redrawHint("eles",!0),t.redraw()}),150),r=null!=e.deltaY?e.deltaY/-250:null!=e.wheelDeltaY?e.wheelDeltaY/1e3:e.wheelDelta/1e3,r*=t.wheelSensitivity,1===e.deltaMode&&(r*=33),n.zoom({level:n.zoom()*Math.pow(10,r),renderedPosition:{x:a[0],y:a[1]}})}}),!0),t.registerBinding(window,"scroll",(function(e){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout((function(){t.scrollingPage=!1}),250)}),!0),t.registerBinding(t.container,"mouseout",(function(e){var r=t.projectIntoViewport(e.clientX,e.clientY);t.cy.emit({originalEvent:e,type:"mouseout",position:{x:r[0],y:r[1]}})}),!1),t.registerBinding(t.container,"mouseover",(function(e){var r=t.projectIntoViewport(e.clientX,e.clientY);t.cy.emit({originalEvent:e,type:"mouseover",position:{x:r[0],y:r[1]}})}),!1);var P,O,z,R,F=function(t,e,r,n){return Math.sqrt((r-t)*(r-t)+(n-e)*(n-e))},N=function(t,e,r,n){return(r-t)*(r-t)+(n-e)*(n-e)};if(t.registerBinding(t.container,"touchstart",P=function(e){if(y(e)){p(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var n=t.cy,i=t.touchData.now,a=t.touchData.earlier;if(e.touches[0]){var o=t.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=o[0],i[1]=o[1]}if(e.touches[1]){o=t.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);i[2]=o[0],i[3]=o[1]}if(e.touches[2]){o=t.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);i[4]=o[0],i[5]=o[1]}if(e.touches[1]){t.touchData.singleTouchMoved=!0,h(t.dragData.touchDragEles);var l=t.findContainerClientCoords();T=l[0],L=l[1],S=l[2],E=l[3],x=e.touches[0].clientX-T,b=e.touches[0].clientY-L,_=e.touches[1].clientX-T,A=e.touches[1].clientY-L,D=0<=x&&x<=S&&0<=_&&_<=S&&0<=b&&b<=E&&0<=A&&A<=E;var f=n.pan(),d=n.zoom();C=F(x,b,_,A),M=N(x,b,_,A),I=[((k=[(x+_)/2,(b+A)/2])[0]-f.x)/d,(k[1]-f.y)/d];if(M<4e4&&!e.touches[2]){var g=t.findNearestElement(i[0],i[1],!0,!0),m=t.findNearestElement(i[2],i[3],!0,!0);return g&&g.isNode()?(g.activate().emit({originalEvent:e,type:"cxttapstart",position:{x:i[0],y:i[1]}}),t.touchData.start=g):m&&m.isNode()?(m.activate().emit({originalEvent:e,type:"cxttapstart",position:{x:i[0],y:i[1]}}),t.touchData.start=m):n.emit({originalEvent:e,type:"cxttapstart",position:{x:i[0],y:i[1]}}),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!0,t.touchData.cxtDragged=!1,t.data.bgActivePosistion=void 0,void t.redraw()}}if(e.touches[2])n.boxSelectionEnabled()&&e.preventDefault();else if(e.touches[1]);else if(e.touches[0]){var v=t.findNearestElements(i[0],i[1],!0,!0),w=v[0];if(null!=w&&(w.activate(),t.touchData.start=w,t.touchData.starts=v,t.nodeIsGrabbable(w))){var P=t.dragData.touchDragEles=n.collection(),O=null;t.redrawHint("eles",!0),t.redrawHint("drag",!0),w.selected()?(O=n.$((function(e){return e.selected()&&t.nodeIsGrabbable(e)})),c(O,{addToList:P})):u(w,{addToList:P}),s(w);var z=function(t){return{originalEvent:e,type:t,position:{x:i[0],y:i[1]}}};w.emit(z("grabon")),O?O.forEach((function(t){t.emit(z("grab"))})):w.emit(z("grab"))}r(w,["touchstart","tapstart","vmousedown"],e,{x:i[0],y:i[1]}),null==w&&(t.data.bgActivePosistion={x:o[0],y:o[1]},t.redrawHint("select",!0),t.redraw()),t.touchData.singleTouchMoved=!1,t.touchData.singleTouchStartTime=+new Date,clearTimeout(t.touchData.tapholdTimeout),t.touchData.tapholdTimeout=setTimeout((function(){!1!==t.touchData.singleTouchMoved||t.pinching||t.touchData.selecting||r(t.touchData.start,["taphold"],e,{x:i[0],y:i[1]})}),t.tapholdDuration)}if(e.touches.length>=1){for(var R=t.touchData.startPosition=[],j=0;j=t.touchTapThreshold2}if(n&&t.touchData.cxt){e.preventDefault();var E=e.touches[0].clientX-T,P=e.touches[0].clientY-L,O=e.touches[1].clientX-T,z=e.touches[1].clientY-L,R=N(E,P,O,z);if(R/M>=2.25||R>=22500){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var j={originalEvent:e,type:"cxttapend",position:{x:s[0],y:s[1]}};t.touchData.start?(t.touchData.start.unactivate().emit(j),t.touchData.start=null):o.emit(j)}}if(n&&t.touchData.cxt){j={originalEvent:e,type:"cxtdrag",position:{x:s[0],y:s[1]}};t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(j):o.emit(j),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var B=t.findNearestElement(s[0],s[1],!0,!0);t.touchData.cxtOver&&B===t.touchData.cxtOver||(t.touchData.cxtOver&&t.touchData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:s[0],y:s[1]}}),t.touchData.cxtOver=B,B&&B.emit({originalEvent:e,type:"cxtdragover",position:{x:s[0],y:s[1]}}))}else if(n&&e.touches[2]&&o.boxSelectionEnabled())e.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||o.emit({originalEvent:e,type:"boxstart",position:{x:s[0],y:s[1]}}),t.touchData.selecting=!0,t.touchData.didSelect=!0,i[4]=1,i&&0!==i.length&&void 0!==i[0]?(i[2]=(s[0]+s[2]+s[4])/3,i[3]=(s[1]+s[3]+s[5])/3):(i[0]=(s[0]+s[2]+s[4])/3,i[1]=(s[1]+s[3]+s[5])/3,i[2]=(s[0]+s[2]+s[4])/3+1,i[3]=(s[1]+s[3]+s[5])/3+1),t.redrawHint("select",!0),t.redraw();else if(n&&e.touches[1]&&!t.touchData.didSelect&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){if(e.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),tt=t.dragData.touchDragEles){t.redrawHint("drag",!0);for(var Y=0;Y0&&!t.hoverData.draggingEles&&!t.swipePanning&&null!=t.data.bgActivePosistion&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},!1),t.registerBinding(window,"touchcancel",z=function(e){var r=t.touchData.start;t.touchData.capture=!1,r&&r.unactivate()}),t.registerBinding(window,"touchend",R=function(n){var i=t.touchData.start;if(t.touchData.capture){0===n.touches.length&&(t.touchData.capture=!1),n.preventDefault();var a=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var o,s=t.cy,l=s.zoom(),c=t.touchData.now,u=t.touchData.earlier;if(n.touches[0]){var f=t.projectIntoViewport(n.touches[0].clientX,n.touches[0].clientY);c[0]=f[0],c[1]=f[1]}if(n.touches[1]){f=t.projectIntoViewport(n.touches[1].clientX,n.touches[1].clientY);c[2]=f[0],c[3]=f[1]}if(n.touches[2]){f=t.projectIntoViewport(n.touches[2].clientX,n.touches[2].clientY);c[4]=f[0],c[5]=f[1]}if(i&&i.unactivate(),t.touchData.cxt){if(o={originalEvent:n,type:"cxttapend",position:{x:c[0],y:c[1]}},i?i.emit(o):s.emit(o),!t.touchData.cxtDragged){var p={originalEvent:n,type:"cxttap",position:{x:c[0],y:c[1]}};i?i.emit(p):s.emit(p)}return t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,void t.redraw()}if(!n.touches[2]&&s.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var d=s.collection(t.getAllInBox(a[0],a[1],a[2],a[3]));a[0]=void 0,a[1]=void 0,a[2]=void 0,a[3]=void 0,a[4]=0,t.redrawHint("select",!0),s.emit({type:"boxend",originalEvent:n,position:{x:c[0],y:c[1]}});d.emit("box").stdFilter((function(t){return t.selectable()&&!t.selected()})).select().emit("boxselect"),d.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if(null!=i&&i.unactivate(),n.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(n.touches[1]);else if(n.touches[0]);else if(!n.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var g=t.dragData.touchDragEles;if(null!=i){var m=i._private.grabbed;h(g),t.redrawHint("drag",!0),t.redrawHint("eles",!0),m&&(i.emit("freeon"),g.emit("free"),t.dragData.didDrag&&(i.emit("dragfreeon"),g.emit("dragfree"))),r(i,["touchend","tapend","vmouseup","tapdragout"],n,{x:c[0],y:c[1]}),i.unactivate(),t.touchData.start=null}else{var v=t.findNearestElement(c[0],c[1],!0,!0);r(v,["touchend","tapend","vmouseup","tapdragout"],n,{x:c[0],y:c[1]})}var y=t.touchData.startPosition[0]-c[0],x=y*y,b=t.touchData.startPosition[1]-c[1],_=(x+b*b)*l*l;t.touchData.singleTouchMoved||(i||s.$(":selected").unselect(["tapunselect"]),r(i,["tap","vclick"],n,{x:c[0],y:c[1]})),null!=i&&!t.dragData.didDrag&&i._private.selectable&&_2){for(var T=[c[0],c[1]],L=Math.pow(T[0]-t,2)+Math.pow(T[1]-e,2),S=1;S0)return g[0]}return null},f=Object.keys(u),p=0;p0?l:le(i,a,t,e,r,n,o)},checkPoint:function(t,e,r,n,i,a,o){var s=ke(n,i),l=2*s;if(de(t,e,this.points,a,o,n,i-l,[0,-1],r))return!0;if(de(t,e,this.points,a,o,n-l,i,[0,-1],r))return!0;var c=n/2+2*r,u=i/2+2*r;return!!pe(t,e,[a-c,o-u,a-c,o,a+c,o,a+c,o-u])||(!!ve(t,e,l,l,a+n/2-s,o+i/2-s,r)||!!ve(t,e,l,l,a-n/2+s,o+i/2-s,r))}}},Uo.registerNodeShapes=function(){var t=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",Ae(3,0)),this.generateRoundPolygon("round-triangle",Ae(3,0)),this.generatePolygon("rectangle",Ae(4,0)),t.square=t.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var r=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",r),this.generateRoundPolygon("round-diamond",r),this.generatePolygon("pentagon",Ae(5,0)),this.generateRoundPolygon("round-pentagon",Ae(5,0)),this.generatePolygon("hexagon",Ae(6,0)),this.generateRoundPolygon("round-hexagon",Ae(6,0)),this.generatePolygon("heptagon",Ae(7,0)),this.generateRoundPolygon("round-heptagon",Ae(7,0)),this.generatePolygon("octagon",Ae(8,0)),this.generateRoundPolygon("round-octagon",Ae(8,0));var n=new Array(20),i=Me(5,0),a=Me(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=t.deqFastCost*g)break}else if(i){if(p>=t.deqCost*l||p>=t.deqAvgCost*s)break}else if(d>=t.deqNoDrawCost*(1e3/60))break;var m=t.deq(e,h,u);if(!(m.length>0))break;for(var v=0;v0&&(t.onDeqd(e,c),!i&&t.shouldRedraw(e,c,h,u)&&n())}),a(e))}}},Xo=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ot;s(this,t),this.idsByKey=new _t,this.keyForId=new _t,this.cachesByLvl=new _t,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=r}return c(t,[{key:"getIdsFor",value:function(t){null==t&&ct("Can not get id list for null key");var e=this.idsByKey,r=this.idsByKey.get(t);return r||(r=new At,e.set(t,r)),r}},{key:"addIdForKey",value:function(t,e){null!=t&&this.getIdsFor(t).add(e)}},{key:"deleteIdForKey",value:function(t,e){null!=t&&this.getIdsFor(t).delete(e)}},{key:"getNumberOfIdsForKey",value:function(t){return null==t?0:this.getIdsFor(t).size}},{key:"updateKeyMappingFor",value:function(t){var e=t.id(),r=this.keyForId.get(e),n=this.getKey(t);this.deleteIdForKey(r,e),this.addIdForKey(n,e),this.keyForId.set(e,n)}},{key:"deleteKeyMappingFor",value:function(t){var e=t.id(),r=this.keyForId.get(e);this.deleteIdForKey(r,e),this.keyForId.delete(e)}},{key:"keyHasChangedFor",value:function(t){var e=t.id();return this.keyForId.get(e)!==this.getKey(t)}},{key:"isInvalid",value:function(t){return this.keyHasChangedFor(t)||this.doesEleInvalidateKey(t)}},{key:"getCachesAt",value:function(t){var e=this.cachesByLvl,r=this.lvls,n=e.get(t);return n||(n=new _t,e.set(t,n),r.push(t)),n}},{key:"getCache",value:function(t,e){return this.getCachesAt(e).get(t)}},{key:"get",value:function(t,e){var r=this.getKey(t),n=this.getCache(r,e);return null!=n&&this.updateKeyMappingFor(t),n}},{key:"getForCachedKey",value:function(t,e){var r=this.keyForId.get(t.id());return this.getCache(r,e)}},{key:"hasCache",value:function(t,e){return this.getCachesAt(e).has(t)}},{key:"has",value:function(t,e){var r=this.getKey(t);return this.hasCache(r,e)}},{key:"setCache",value:function(t,e,r){r.key=t,this.getCachesAt(e).set(t,r)}},{key:"set",value:function(t,e,r){var n=this.getKey(t);this.setCache(n,e,r),this.updateKeyMappingFor(t)}},{key:"deleteCache",value:function(t,e){this.getCachesAt(e).delete(t)}},{key:"delete",value:function(t,e){var r=this.getKey(t);this.deleteCache(r,e)}},{key:"invalidateKey",value:function(t){var e=this;this.lvls.forEach((function(r){return e.deleteCache(t,r)}))}},{key:"invalidate",value:function(t){var e=t.id(),r=this.keyForId.get(e);this.deleteKeyMappingFor(t);var n=this.doesEleInvalidateKey(t);return n&&this.invalidateKey(r),n||0===this.getNumberOfIdsForKey(r)}}]),t}(),Jo={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Ko=mt({getKey:null,doesEleInvalidateKey:ot,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:at,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Qo=function(t,e){this.renderer=t,this.onDequeues=[];var r=Ko(e);j(this,r),this.lookup=new Xo(r.getKey,r.doesEleInvalidateKey),this.setupDequeueing()},$o=Qo.prototype;$o.reasons=Jo,$o.getTextureQueue=function(t){return this.eleImgCaches=this.eleImgCaches||{},this.eleImgCaches[t]=this.eleImgCaches[t]||[]},$o.getRetiredTextureQueue=function(t){var e=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return e[t]=e[t]||[]},$o.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new a((function(t,e){return e.reqs-t.reqs}))},$o.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},$o.getElement=function(t,e,r,n,i){var a=this,o=this.renderer,s=o.cy.zoom(),l=this.lookup;if(0===e.w||0===e.h||isNaN(e.w)||isNaN(e.h)||!t.visible())return null;if(!a.allowEdgeTxrCaching&&t.isEdge()||!a.allowParentTxrCaching&&t.isParent())return null;if(null==n&&(n=Math.ceil(Gt(s*r))),n<-4)n=-4;else if(s>=7.99||n>3)return null;var c=Math.pow(2,n),u=e.h*c,h=e.w*c,f=o.eleTextBiggerThanMin(t,c);if(!this.isVisible(t,f))return null;var p,d=l.get(t,n);if(d&&d.invalidated&&(d.invalidated=!1,d.texture.invalidatedWidth-=d.width),d)return d;if(p=u<=25?25:u<=50?50:50*Math.ceil(u/50),u>1024||h>1024)return null;var g=a.getTextureQueue(p),m=g[g.length-2],v=function(){return a.recycleTexture(p,h)||a.addTexture(p,h)};m||(m=g[g.length-1]),m||(m=v()),m.width-m.usedWidthn;I--)M=a.getElement(t,e,r,I,Jo.downscale);k()}else{var T;if(!b&&!_&&!w)for(var L=n-1;L>=-4;L--){var S=l.get(t,L);if(S){T=S;break}}if(x(T))return a.queueElement(t,n),T;m.context.translate(m.usedWidth,0),m.context.scale(c,c),this.drawElement(m.context,t,e,f,!1),m.context.scale(1/c,1/c),m.context.translate(-m.usedWidth,0)}return d={x:m.usedWidth,texture:m,level:n,scale:c,width:h,height:u,scaledLabelShown:f},m.usedWidth+=Math.ceil(h+8),m.eleCaches.push(d),l.set(t,n,d),a.checkTextureFullness(m),d},$o.invalidateElements=function(t){for(var e=0;e=.2*t.width&&this.retireTexture(t)},$o.checkTextureFullness=function(t){var e=this.getTextureQueue(t.height);t.usedWidth/t.width>.8&&t.fullnessChecks>=10?vt(e,t):t.fullnessChecks++},$o.retireTexture=function(t){var e=t.height,r=this.getTextureQueue(e),n=this.lookup;vt(r,t),t.retired=!0;for(var i=t.eleCaches,a=0;a=e)return a.retired=!1,a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,yt(a.eleCaches),a.context.setTransform(1,0,0,1,0,0),a.context.clearRect(0,0,a.width,a.height),vt(n,a),r.push(a),a}},$o.queueElement=function(t,e){var r=this.getElementQueue(),n=this.getElementKeyToQueue(),i=this.getKey(t),a=n[i];if(a)a.level=Math.max(a.level,e),a.eles.merge(t),a.reqs++,r.updateItem(a);else{var o={eles:t.spawn().merge(t),level:e,reqs:1,key:i};r.push(o),n[i]=o}},$o.dequeue=function(t){for(var e=this.getElementQueue(),r=this.getElementKeyToQueue(),n=[],i=this.lookup,a=0;a<1&&e.size()>0;a++){var o=e.pop(),s=o.key,l=o.eles[0],c=i.hasCache(l,o.level);if(r[s]=null,!c){n.push(o);var u=this.getBoundingBox(l);this.getElement(l,u,t,o.level,Jo.dequeue)}}return n},$o.removeFromQueue=function(t){var e=this.getElementQueue(),r=this.getElementKeyToQueue(),n=this.getKey(t),i=r[n];null!=i&&(1===i.eles.length?(i.reqs=it,e.updateItem(i),e.pop(),r[n]=null):i.eles.unmerge(t))},$o.onDequeue=function(t){this.onDequeues.push(t)},$o.offDequeue=function(t){vt(this.onDequeues,t)},$o.setupDequeueing=Zo({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(t,e,r){return t.dequeue(e,r)},onDeqd:function(t,e){for(var r=0;r=3.99||r>2)return null;n.validateLayersElesOrdering(r,t);var o,s,l=n.layersByLevel,c=Math.pow(2,r),u=l[r]=l[r]||[];if(n.levelIsComplete(r,t))return u;!function(){var e=function(e){if(n.validateLayersElesOrdering(e,t),n.levelIsComplete(e,t))return s=l[e],!0},i=function(t){if(!s)for(var n=r+t;-4<=n&&n<=2&&!e(n);n+=t);};i(1),i(-1);for(var a=u.length-1;a>=0;a--){var o=u[a];o.invalid&&vt(u,o)}}();var h=function(e){var i=(e=e||{}).after;if(function(){if(!o){o=$t();for(var e=0;e16e6)return null;var a=n.makeLayer(o,r);if(null!=i){var s=u.indexOf(i)+1;u.splice(s,0,a)}else(void 0===e.insert||e.insert)&&u.unshift(a);return a};if(n.skipping&&!a)return null;for(var f=null,p=t.length/1,d=!a,g=0;g=p||!se(f.bb,m.boundingBox()))&&!(f=h({insert:!0,after:f})))return null;s||d?n.queueLayer(f,m):n.drawEleInLayer(f,m,r,e),f.eles.push(m),y[r]=f}}return s||(d?null:u)},es.getEleLevelForLayerLevel=function(t,e){return t},es.drawEleInLayer=function(t,e,r,n){var i=this.renderer,a=t.context,o=e.boundingBox();0!==o.w&&0!==o.h&&e.visible()&&(r=this.getEleLevelForLayerLevel(r,n),i.setImgSmoothing(a,!1),i.drawCachedElement(a,e,null,null,r,!0),i.setImgSmoothing(a,!0))},es.levelIsComplete=function(t,e){var r=this.layersByLevel[t];if(!r||0===r.length)return!1;for(var n=0,i=0;i0)return!1;if(a.invalid)return!1;n+=a.eles.length}return n===e.length},es.validateLayersElesOrdering=function(t,e){var r=this.layersByLevel[t];if(r)for(var n=0;n0){t=!0;break}}return t},es.invalidateElements=function(t){var e=this;0!==t.length&&(e.lastInvalidationTime=Z(),0!==t.length&&e.haveLayers()&&e.updateElementsInLayers(t,(function(t,r,n){e.invalidateLayer(t)})))},es.invalidateLayer=function(t){if(this.lastInvalidationTime=Z(),!t.invalid){var e=t.level,r=t.eles,n=this.layersByLevel[e];vt(n,t),t.elesQueue=[],t.invalid=!0,t.replacement&&(t.replacement.invalid=!0);for(var i=0;i3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this,s=e._private.rscratch;if((!a||e.visible())&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;r&&(l=r,t.translate(-l.x1,-l.y1));var c=a?e.pstyle("opacity").value:1,u=e.pstyle("line-style").value,h=e.pstyle("width").pfValue,f=e.pstyle("line-cap").value,p=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;t.lineWidth=h,t.lineCap=f,o.eleStrokeStyle(t,e,r),o.drawEdgePath(e,t,s.allpts,u),t.lineCap="butt"},d=function(){i&&o.drawEdgeOverlay(t,e)},g=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;o.drawArrowheads(t,e,r)},m=function(){o.drawElementText(t,e,null,n)};t.lineJoin="round";var v="yes"===e.pstyle("ghost").value;if(v){var y=e.pstyle("ghost-offset-x").pfValue,x=e.pstyle("ghost-offset-y").pfValue,b=e.pstyle("ghost-opacity").value,_=c*b;t.translate(y,x),p(_),g(_),t.translate(-y,-x)}p(),g(),d(),m(),r&&t.translate(l.x1,l.y1)}},drawEdgeOverlay:function(t,e){if(e.visible()){var r=e.pstyle("overlay-opacity").value;if(0!==r){var n=this,i=n.usePaths(),a=e._private.rscratch,o=2*e.pstyle("overlay-padding").pfValue,s=e.pstyle("overlay-color").value;t.lineWidth=o,"self"!==a.edgeType||i?t.lineCap="round":t.lineCap="butt",n.colorStrokeStyle(t,s[0],s[1],s[2],r),n.drawEdgePath(e,t,a.allpts,"solid")}}},drawEdgePath:function(t,e,r,n){var i,a=t._private.rscratch,o=e,s=!1,l=this.usePaths(),c=t.pstyle("line-dash-pattern").pfValue,u=t.pstyle("line-dash-offset").pfValue;if(l){var h=r.join("$");a.pathCacheKey&&a.pathCacheKey===h?(i=e=a.pathCache,s=!0):(i=e=new Path2D,a.pathCacheKey=h,a.pathCache=i)}if(o.setLineDash)switch(n){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(c),o.lineDashOffset=u;break;case"solid":o.setLineDash([])}if(!s&&!a.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(r[0],r[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var f=2;f+35&&void 0!==arguments[5]?arguments[5]:5;t.beginPath(),t.moveTo(e+a,r),t.lineTo(e+n-a,r),t.quadraticCurveTo(e+n,r,e+n,r+a),t.lineTo(e+n,r+i-a),t.quadraticCurveTo(e+n,r+i,e+n-a,r+i),t.lineTo(e+a,r+i),t.quadraticCurveTo(e,r+i,e,r+i-a),t.lineTo(e,r+a),t.quadraticCurveTo(e,r,e+a,r),t.closePath(),t.fill()}xs.eleTextBiggerThanMin=function(t,e){if(!e){var r=t.cy().zoom(),n=this.getPixelRatio(),i=Math.ceil(Gt(r*n));e=Math.pow(2,i)}return!(t.pstyle("font-size").pfValue*e5&&void 0!==arguments[5])||arguments[5],o=this;if(null==n){if(a&&!o.eleTextBiggerThanMin(e))return}else if(!1===n)return;if(e.isNode()){var s=e.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(e);t.textAlign=l,t.textBaseline="bottom"}else{var c=e.pstyle("label"),u=e.pstyle("source-label"),h=e.pstyle("target-label");if(!(c&&c.value||u&&u.value||h&&h.value))return;t.textAlign="center",t.textBaseline="bottom"}var f,p=!r;r&&(f=r,t.translate(-f.x1,-f.y1)),null==i?(o.drawText(t,e,null,p,a),e.isEdge()&&(o.drawText(t,e,"source",p,a),o.drawText(t,e,"target",p,a))):o.drawText(t,e,i,p,a),r&&t.translate(f.x1,f.y1)},xs.getFontCache=function(t){var e;this.fontCaches=this.fontCaches||[];for(var r=0;r2&&void 0!==arguments[2])||arguments[2],n=e.pstyle("font-style").strValue,i=e.pstyle("font-size").pfValue+"px",a=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=r?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,l=e.pstyle("text-outline-opacity").value*s,c=e.pstyle("color").value,u=e.pstyle("text-outline-color").value;t.font=n+" "+o+" "+i+" "+a,t.lineJoin="round",this.colorFillStyle(t,c[0],c[1],c[2],s),this.colorStrokeStyle(t,u[0],u[1],u[2],l)},xs.getTextAngle=function(t,e){var r=t._private.rscratch,n=e?e+"-":"",i=t.pstyle(n+"text-rotation"),a=xt(r,"labelAngle",e);return"autorotate"===i.strValue?t.isEdge()?a:0:"none"===i.strValue?0:i.pfValue},xs.drawText=function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=e._private,o=a.rscratch,s=i?e.effectiveOpacity():1;if(!i||0!==s&&0!==e.pstyle("text-opacity").value){"main"===r&&(r=null);var l,c,u=xt(o,"labelX",r),h=xt(o,"labelY",r),f=this.getLabelText(e,r);if(null!=f&&""!==f&&!isNaN(u)&&!isNaN(h)){this.setupTextStyle(t,e,i);var p,d=r?r+"-":"",g=xt(o,"labelWidth",r),m=xt(o,"labelHeight",r),v=e.pstyle(d+"text-margin-x").pfValue,y=e.pstyle(d+"text-margin-y").pfValue,x=e.isEdge(),b=e.pstyle("text-halign").value,_=e.pstyle("text-valign").value;switch(x&&(b="center",_="center"),u+=v,h+=y,0!==(p=n?this.getTextAngle(e,r):0)&&(l=u,c=h,t.translate(l,c),t.rotate(p),u=0,h=0),_){case"top":break;case"center":h+=m/2;break;case"bottom":h+=m}var w=e.pstyle("text-background-opacity").value,A=e.pstyle("text-border-opacity").value,C=e.pstyle("text-border-width").pfValue,M=e.pstyle("text-background-padding").pfValue;if(w>0||C>0&&A>0){var k=u-M;switch(b){case"left":k-=g;break;case"center":k-=g/2}var I=h-m-M,T=g+2*M,L=m+2*M;if(w>0){var S=t.fillStyle,E=e.pstyle("text-background-color").value;t.fillStyle="rgba("+E[0]+","+E[1]+","+E[2]+","+w*s+")";var D=e.pstyle("text-background-shape").strValue;"roundrectangle"==D?bs(t,k,I,T,L,2):t.fillRect(k,I,T,L),t.fillStyle=S}if(C>0&&A>0){var P=t.strokeStyle,O=t.lineWidth,z=e.pstyle("text-border-color").value,R=e.pstyle("text-border-style").value;if(t.strokeStyle="rgba("+z[0]+","+z[1]+","+z[2]+","+A*s+")",t.lineWidth=C,t.setLineDash)switch(R){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"double":t.lineWidth=C/4,t.setLineDash([]);break;case"solid":t.setLineDash([])}if(t.strokeRect(k,I,T,L),"double"===R){var F=C/2;t.strokeRect(k+F,I+F,T-2*F,L-2*F)}t.setLineDash&&t.setLineDash([]),t.lineWidth=O,t.strokeStyle=P}}var N=2*e.pstyle("text-outline-width").pfValue;if(N>0&&(t.lineWidth=N),"wrap"===e.pstyle("text-wrap").value){var j=xt(o,"labelWrapCachedLines",r),B=xt(o,"labelLineHeight",r),Y=g/2,V=this.getLabelJustification(e);switch("auto"===V||("left"===b?"left"===V?u+=-g:"center"===V&&(u+=-Y):"center"===b?"left"===V?u+=-Y:"right"===V&&(u+=Y):"right"===b&&("center"===V?u+=Y:"right"===V&&(u+=g))),_){case"top":h-=(j.length-1)*B;break;case"center":case"bottom":h-=(j.length-1)*B}for(var U=0;U0&&t.strokeText(j[U],u,h),t.fillText(j[U],u,h),h+=B}else N>0&&t.strokeText(f,u,h),t.fillText(f,u,h);0!==p&&(t.rotate(-p),t.translate(-l,-c))}}};var _s={drawNode:function(t,e,r){var n,i,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],l=this,c=e._private,u=c.rscratch,h=e.position();if(w(h.x)&&w(h.y)&&(!s||e.visible())){var f,p,d=s?e.effectiveOpacity():1,g=l.usePaths(),m=!1,v=e.padding();n=e.width()+2*v,i=e.height()+2*v,r&&(p=r,t.translate(-p.x1,-p.y1));for(var y=e.pstyle("background-image"),x=y.value,b=new Array(x.length),_=new Array(x.length),A=0,C=0;C0&&void 0!==arguments[0]?arguments[0]:S;l.eleFillStyle(t,e,r)},z=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:P;l.colorStrokeStyle(t,E[0],E[1],E[2],e)},R=e.pstyle("shape").strValue,F=e.pstyle("shape-polygon-points").pfValue;if(g){t.translate(h.x,h.y);var N=l.nodePathCache=l.nodePathCache||[],j=$("polygon"===R?R+","+F.join(","):R,""+i,""+n),B=N[j];null!=B?(f=B,m=!0,u.pathCache=f):(f=new Path2D,N[j]=u.pathCache=f)}var Y=function(){if(!m){var r=h;g&&(r={x:0,y:0}),l.nodeShapes[l.getNodeShape(e)].draw(f||t,r.x,r.y,n,i)}g?t.fill(f):t.fill()},V=function(){for(var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,n=c.backgrounding,i=0,a=0;a<_.length;a++)b[a]&&_[a].complete&&!_[a].error&&(i++,l.drawInscribedImage(t,_[a],e,a,r));c.backgrounding=!(i===A),n!==c.backgrounding&&e.updateStyle(!1)},U=function(){var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;l.hasPie(e)&&(l.drawPie(t,e,a),r&&(g||l.nodeShapes[l.getNodeShape(e)].draw(t,h.x,h.y,n,i)))},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,r=(T>0?T:-T)*e,n=T>0?0:255;0!==T&&(l.colorFillStyle(t,n,n,n,r),g?t.fill(f):t.fill())},G=function(){if(L>0){if(t.lineWidth=L,t.lineCap="butt",t.setLineDash)switch(D){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([])}if(g?t.stroke(f):t.stroke(),"double"===D){t.lineWidth=L/3;var e=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",g?t.stroke(f):t.stroke(),t.globalCompositeOperation=e}t.setLineDash&&t.setLineDash([])}},q=function(){o&&l.drawNodeOverlay(t,e,h,n,i)},W=function(){l.drawElementText(t,e,null,a)},Z="yes"===e.pstyle("ghost").value;if(Z){var X=e.pstyle("ghost-offset-x").pfValue,J=e.pstyle("ghost-offset-y").pfValue,K=e.pstyle("ghost-opacity").value,Q=K*d;t.translate(X,J),O(K*S),Y(),V(Q),U(0!==T||0!==L),H(Q),z(K*P),G(),t.translate(-X,-J)}O(),Y(),V(),U(0!==T||0!==L),H(),z(),G(),g&&t.translate(-h.x,-h.y),W(),q(),r&&t.translate(p.x1,p.y1)}},drawNodeOverlay:function(t,e,r,n,i){if(e.visible()){var a=e.pstyle("overlay-padding").pfValue,o=e.pstyle("overlay-opacity").value,s=e.pstyle("overlay-color").value;if(o>0){if(r=r||e.position(),null==n||null==i){var l=e.padding();n=e.width()+2*l,i=e.height()+2*l}this.colorFillStyle(t,s[0],s[1],s[2],o),this.nodeShapes.roundrectangle.draw(t,r.x,r.y,n+2*a,i+2*a),t.fill()}}},hasPie:function(t){return(t=t[0])._private.hasPie},drawPie:function(t,e,r,n){e=e[0],n=n||e.position();var i=e.cy().style(),a=e.pstyle("pie-size"),o=n.x,s=n.y,l=e.width(),c=e.height(),u=Math.min(l,c)/2,h=0;this.usePaths()&&(o=0,s=0),"%"===a.units?u*=a.pfValue:void 0!==a.pfValue&&(u=a.pfValue/2);for(var f=1;f<=i.pieBackgroundN;f++){var p=e.pstyle("pie-"+f+"-background-size").value,d=e.pstyle("pie-"+f+"-background-color").value,g=e.pstyle("pie-"+f+"-background-opacity").value*r,m=p/100;m+h>1&&(m=1-h);var v=1.5*Math.PI+2*Math.PI*h,y=v+2*Math.PI*m;0===p||h>=1||h+m>1||(t.beginPath(),t.moveTo(o,s),t.arc(o,s,u,v,y),t.closePath(),this.colorFillStyle(t,d[0],d[1],d[2],g),t.fill(),h+=m)}}},ws={};ws.getPixelRatio=function(){var t=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var e=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e},ws.paintCache=function(t){for(var e,r=this.paintCaches=this.paintCaches||[],n=!0,i=0;io.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!h&&(u[o.NODE]=!0,u[o.SELECT_BOX]=!0);var y=l.style(),x=l.zoom(),b=void 0!==i?i:x,_=l.pan(),w={x:_.x,y:_.y},A={zoom:x,pan:{x:_.x,y:_.y}},C=o.prevViewport;void 0===C||A.zoom!==C.zoom||A.pan.x!==C.pan.x||A.pan.y!==C.pan.y||g&&!d||(o.motionBlurPxRatio=1),a&&(w=a),b*=s,w.x*=s,w.y*=s;var M=o.getCachedZSortedEles();function k(t,e,r,n,i){var a=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",o.colorFillStyle(t,255,255,255,o.motionBlurTransparency),t.fillRect(e,r,n,i),t.globalCompositeOperation=a}function I(t,n){var s,l,u,h;o.clearingMotionBlur||t!==c.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]&&t!==c.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]?(s=w,l=b,u=o.canvasWidth,h=o.canvasHeight):(s={x:_.x*p,y:_.y*p},l=x*p,u=o.canvasWidth*p,h=o.canvasHeight*p),t.setTransform(1,0,0,1,0,0),"motionBlur"===n?k(t,0,0,u,h):e||void 0!==n&&!n||t.clearRect(0,0,u,h),r||(t.translate(s.x,s.y),t.scale(l,l)),a&&t.translate(a.x,a.y),i&&t.scale(i,i)}if(h||(o.textureDrawLastFrame=!1),h){if(o.textureDrawLastFrame=!0,!o.textureCache){o.textureCache={},o.textureCache.bb=l.mutableElements().boundingBox(),o.textureCache.texture=o.data.bufferCanvases[o.TEXTURE_BUFFER];var T=o.data.bufferContexts[o.TEXTURE_BUFFER];T.setTransform(1,0,0,1,0,0),T.clearRect(0,0,o.canvasWidth*o.textureMult,o.canvasHeight*o.textureMult),o.render({forcedContext:T,drawOnlyNodeLayer:!0,forcedPxRatio:s*o.textureMult}),(A=o.textureCache.viewport={zoom:l.zoom(),pan:l.pan(),width:o.canvasWidth,height:o.canvasHeight}).mpan={x:(0-A.pan.x)/A.zoom,y:(0-A.pan.y)/A.zoom}}u[o.DRAG]=!1,u[o.NODE]=!1;var L=c.contexts[o.NODE],S=o.textureCache.texture;A=o.textureCache.viewport;L.setTransform(1,0,0,1,0,0),f?k(L,0,0,A.width,A.height):L.clearRect(0,0,A.width,A.height);var E=y.core("outside-texture-bg-color").value,D=y.core("outside-texture-bg-opacity").value;o.colorFillStyle(L,E[0],E[1],E[2],D),L.fillRect(0,0,A.width,A.height);x=l.zoom();I(L,!1),L.clearRect(A.mpan.x,A.mpan.y,A.width/A.zoom/s,A.height/A.zoom/s),L.drawImage(S,A.mpan.x,A.mpan.y,A.width/A.zoom/s,A.height/A.zoom/s)}else o.textureOnViewport&&!e&&(o.textureCache=null);var P=l.extent(),O=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles||o.cy.animated(),z=o.hideEdgesOnViewport&&O,R=[];if(R[o.NODE]=!u[o.NODE]&&f&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,R[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),R[o.DRAG]=!u[o.DRAG]&&f&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,R[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),u[o.NODE]||r||n||R[o.NODE]){var F=f&&!R[o.NODE]&&1!==p;I(L=e||(F?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:c.contexts[o.NODE]),f&&!F?"motionBlur":void 0),z?o.drawCachedNodes(L,M.nondrag,s,P):o.drawLayeredElements(L,M.nondrag,s,P),o.debug&&o.drawDebugPoints(L,M.nondrag),r||f||(u[o.NODE]=!1)}if(!n&&(u[o.DRAG]||r||R[o.DRAG])){F=f&&!R[o.DRAG]&&1!==p;I(L=e||(F?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:c.contexts[o.DRAG]),f&&!F?"motionBlur":void 0),z?o.drawCachedNodes(L,M.drag,s,P):o.drawCachedElements(L,M.drag,s,P),o.debug&&o.drawDebugPoints(L,M.drag),r||f||(u[o.DRAG]=!1)}if(o.showFps||!n&&u[o.SELECT_BOX]&&!r){if(I(L=e||c.contexts[o.SELECT_BOX]),1==o.selection[4]&&(o.hoverData.selecting||o.touchData.selecting)){x=o.cy.zoom();var N=y.core("selection-box-border-width").value/x;L.lineWidth=N,L.fillStyle="rgba("+y.core("selection-box-color").value[0]+","+y.core("selection-box-color").value[1]+","+y.core("selection-box-color").value[2]+","+y.core("selection-box-opacity").value+")",L.fillRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),N>0&&(L.strokeStyle="rgba("+y.core("selection-box-border-color").value[0]+","+y.core("selection-box-border-color").value[1]+","+y.core("selection-box-border-color").value[2]+","+y.core("selection-box-opacity").value+")",L.strokeRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]))}if(c.bgActivePosistion&&!o.hoverData.selecting){x=o.cy.zoom();var j=c.bgActivePosistion;L.fillStyle="rgba("+y.core("active-bg-color").value[0]+","+y.core("active-bg-color").value[1]+","+y.core("active-bg-color").value[2]+","+y.core("active-bg-opacity").value+")",L.beginPath(),L.arc(j.x,j.y,y.core("active-bg-size").pfValue/x,0,2*Math.PI),L.fill()}var B=o.lastRedrawTime;if(o.showFps&&B){B=Math.round(B);var Y=Math.round(1e3/B);L.setTransform(1,0,0,1,0,0),L.fillStyle="rgba(255, 0, 0, 0.75)",L.strokeStyle="rgba(255, 0, 0, 0.75)",L.lineWidth=1,L.fillText("1 frame = "+B+" ms = "+Y+" fps",0,20);L.strokeRect(0,30,250,20),L.fillRect(0,30,250*Math.min(Y/60,1),20)}r||(u[o.SELECT_BOX]=!1)}if(f&&1!==p){var V=c.contexts[o.NODE],U=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],H=c.contexts[o.DRAG],G=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],q=function(t,e,r){t.setTransform(1,0,0,1,0,0),r||!v?t.clearRect(0,0,o.canvasWidth,o.canvasHeight):k(t,0,0,o.canvasWidth,o.canvasHeight);var n=p;t.drawImage(e,0,0,o.canvasWidth*n,o.canvasHeight*n,0,0,o.canvasWidth,o.canvasHeight)};(u[o.NODE]||R[o.NODE])&&(q(V,U,R[o.NODE]),u[o.NODE]=!1),(u[o.DRAG]||R[o.DRAG])&&(q(H,G,R[o.DRAG]),u[o.DRAG]=!1)}o.prevViewport=A,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),f&&(o.motionBlurTimeout=setTimeout((function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!h,o.mbFrames=0,u[o.NODE]=!0,u[o.DRAG]=!0,o.redraw()}),100)),e||l.emit("render")};for(var As={drawPolygonPath:function(t,e,r,n,i,a){var o=n/2,s=i/2;t.beginPath&&t.beginPath(),t.moveTo(e+o*a[0],r+s*a[1]);for(var l=1;l0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation="source-over";var p=this.getCachedZSortedEles();if(t.full)f.translate(-r.x1*l,-r.y1*l),f.scale(l,l),this.drawElements(f,p),f.scale(1/l,1/l),f.translate(r.x1*l,r.y1*l);else{var d=e.pan(),g={x:d.x*l,y:d.y*l};l*=e.zoom(),f.translate(g.x,g.y),f.scale(l,l),this.drawElements(f,p),f.scale(1/l,1/l),f.translate(-g.x,-g.y)}t.bg&&(f.globalCompositeOperation="destination-over",f.fillStyle=t.bg,f.rect(0,0,i,a),f.fill())}return h},Ss.png=function(t){return Ds(t,this.bufferCanvasImage(t),"image/png")},Ss.jpg=function(t){return Ds(t,this.bufferCanvasImage(t),"image/jpeg")};var Ps={nodeShapeImpl:function(t,e,r,n,i,a,o){switch(t){case"ellipse":return this.drawEllipsePath(e,r,n,i,a);case"polygon":return this.drawPolygonPath(e,r,n,i,a,o);case"round-polygon":return this.drawRoundPolygonPath(e,r,n,i,a,o);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,r,n,i,a);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,r,n,i,a);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,r,n,i,a);case"barrel":return this.drawBarrelPath(e,r,n,i,a)}}},Os=Rs,zs=Rs.prototype;function Rs(t){var e=this;e.data={canvases:new Array(zs.CANVAS_LAYERS),contexts:new Array(zs.CANVAS_LAYERS),canvasNeedsRedraw:new Array(zs.CANVAS_LAYERS),bufferCanvases:new Array(zs.BUFFER_COUNT),bufferContexts:new Array(zs.CANVAS_LAYERS)};e.data.canvasContainer=document.createElement("div");var r=e.data.canvasContainer.style;e.data.canvasContainer.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)",r.position="relative",r.zIndex="0",r.overflow="hidden";var n=t.cy.container();n.appendChild(e.data.canvasContainer),n.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)";var i={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};E()&&(i["-ms-touch-action"]="none",i["touch-action"]="none");for(var a=0;a1)for(var r=1;rf))return!1;var d=u.get(t);if(d&&u.get(e))return d==e;var g=-1,m=!0,v=r&s?new n:void 0;for(u.set(t,e),u.set(e,t);++g0&&(a=l.removeMin(),(o=s[a]).distance!==Number.POSITIVE_INFINITY);)n(a).forEach(c);return s}(t,String(e),r||a,n||function(e){return t.outEdges(e)})};var a=n.constant(1)},function(t,e,r){var n=r(9);function i(){this._arr=[],this._keyIndices={}}t.exports=i,i.prototype.size=function(){return this._arr.length},i.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},i.prototype.has=function(t){return n.has(this._keyIndices,t)},i.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},i.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},i.prototype.add=function(t,e){var r=this._keyIndices;if(t=String(t),!n.has(r,t)){var i=this._arr,a=i.length;return r[t]=a,i.push({key:t,priority:e}),this._decrease(a),!0}return!1},i.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},i.prototype.decrease=function(t,e){var r=this._keyIndices[t];if(e>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+e);this._arr[r].priority=e,this._decrease(r)},i.prototype._heapify=function(t){var e=this._arr,r=2*t,n=r+1,i=t;r>1].priority").addClass(this.tableClass).append(t).append(r).append(n);return this._header=e("
").addClass(this.gridHeaderClass).addClass(this._scrollBarWidth()?"jsgrid-header-scrollbar":"").append(i)},_createBody:function(){var t=this._content=e(""),r=this._bodyGrid=e("").addClass(this.tableClass).append(t);return this._body=e("
").addClass(this.gridBodyClass).append(r).on("scroll",e.proxy((function(t){this._header.scrollLeft(t.target.scrollLeft)}),this))},_createPagerContainer:function(){var t=this.pagerContainer||e("
").appendTo(this._container);return e(t).addClass(this.pagerContainerClass)},_eachField:function(t){var r=this;e.each(this.fields,(function(e,n){n.visible&&t.call(r,n,e)}))},_createHeaderRow:function(){if(e.isFunction(this.headerRowRenderer))return e(this.renderTemplate(this.headerRowRenderer,this));var t=e("
").addClass(this.headerRowClass);return this._eachField((function(r,n){var i=this._prepareCell("").addClass(this.filterRowClass);return this._eachField((function(e){this._prepareCell("").addClass(this.insertRowClass);return this._eachField((function(e){this._prepareCell(""),this._renderCells(n,t)),n.addClass(this._getRowClasses(t,r)).data("JSGridItem",t).on("click",e.proxy((function(e){this.rowClick({item:t,itemIndex:r,event:e})}),this)).on("dblclick",e.proxy((function(e){this.rowDoubleClick({item:t,itemIndex:r,event:e})}),this)),this.selecting&&this._attachRowHover(n),n},_getRowClasses:function(t,e){var r=[];return r.push((e+1)%2?this.oddRowClass:this.evenRowClass),r.push(o(this.rowClass,this,t,e)),r.join(" ")},_attachRowHover:function(t){var r=this.selectedRowClass;t.hover((function(){e(this).addClass(r)}),(function(){e(this).removeClass(r)}))},_renderCells:function(t,e){return this._eachField((function(r){t.append(this._createCell(e,r))})),this},_createCell:function(t,r){var n,i=this._getItemFieldValue(t,r),a={value:i,item:t};return n=e.isFunction(r.cellRenderer)?this.renderTemplate(r.cellRenderer,r,a):e("").addClass(this.editRowClass);return this._eachField((function(e){var n=this._getItemFieldValue(t,e);this._prepareCell("\n \n \n '),n.append("
\n
\n
\n
"),r&&n.append("
"+It.template.progressTemplate("metrics")+"
"),n.append("")}},t.prototype.populateRunProperties=function(t,e){It.populateBaseJobInfo(this.element,this.context,t,e)},t.prototype.populateRunArguments=function(t,e){this.element.find("#"+t).find("#arguments").text(e||"N/A")},t.prototype.renderRunMetrics=function(t,e){var r=this.element;r.find("#"+e).find(".single-metric").remove(),t&&t.length>0&&s.forEach(s.sortBy(t,(function(t){return s.toLower(t.name)})),(function(t){if(t&&t.series&&t.series[0]&&t.series[0].data&&1===t.series[0].data.length)r.find("#"+t.run_id).find(".table-details").append("\n \n \n ");else if(t&&t.series&&t.series[0]&&t.series[0].data&&t.series[0].data.length>1){!function(t,e){var n=It.getHashCode(t.title);r.find("#"+n).length<1&&r.find("#"+e).find("#chartContainer").append("
");var i=r.find("#"+n);i.length>0&&bt.lineChart(i[0],t)}({title:t.name,categories:t.categories,series:t.series},t.run_id)}}))},t.prototype.renderLogs=function(t,e){It.renderLogs(this.element.find("#"+t).find("#txtDriverLog"),e)},t.prototype.renderLeaderBoard=function(t){var e=this.element;if(t&&t.length>0){var r=[{name:"run_number",title:"Run Number",type:"number",width:110,validate:"required"},{name:"status",title:"Status",type:"text",width:100,itemTemplate:It.template.statusColTemplate},{name:"start_time",title:"Started",type:"text",width:170,itemTemplate:It.template.dateColTemplate},{name:"duration",title:"",type:"text",width:80,headerTemplate:It.template.headTemplate("Duration in hh:mm:ss","Duration"),sorter:"timesorter"},{name:"run_id",title:"Run Id",type:"text",width:400,itemTemplate:It.template.runIdTemplate}];It.renderJsGrid(e,t,r)}},t.prototype.renderChildrenMetricChart=function(t){var e=this.element,r=t;if(r&&null!=r.series){var n=e.find("#metricContainer");n.find(".progress").remove(),n.length>0&&(r.title="Run Metric : "+r.primaryMetricName,r.series=r.series[r.primaryMetricName],bt.lineChart(n[0],r,r.showLegend,null,"category"))}},t.prototype.renderGraph=function(t){var e=new Pt(this.element);It.renderGraph(this.element,this.context,t,e)},t.prototype.renderAccuracyTableBasedChart=function(t,e){var r=this.element;s.forEach(e,(function(e){var n=r.find("#"+e+"Container"),i=s.get(t,"series[0].data[0]");n.length>0&&bt.accuracyTableBasedCharts(n[0],i,e)}))},t.prototype.renderConfusionMatrix=function(t){var e=s.get(t,"series[0].data[0]"),r=this.element.find("#confusionMatrixContainer");r.length>0&&bt.confusionMatrix(r[0],e)},t.prototype.renderPredictedVsTrue=function(t){if(t){var e=this.element.find("#predictedVsTrueContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.predictedVsTrueChart(e[0],r)}},t.prototype.renderResiduals=function(t){var e=this.element.find("#residualsContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.residualsChart(e[0],r)},t.prototype.cleanFinalState=function(){It.cleanFinalState(this.element)},t.prototype.renderError=function(t){It.renderError(this.element.find("#errorContainer"),t)},t.prototype.renderFeatureImportance=function(t){var e=this.element.find("#featureImportanceContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.featureImportanceChart(e[0],r)},t}(),zt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return zt(e,t),e.prototype.render=function(){this.model&&this.model.on&&(this.model.on(wt.RUN_ID,this.runIdChanged,this),this.model.on(wt.RUN_PROPERTIES,this.runPropertiesChanged,this),this.model.on(wt.RUN_LOGS,this.run_logs_changed,this),this.model.on(wt.RUN_METRICS,this.run_metrics_changed,this),this.model.on(wt.CHILD_RUNS,this.childRunsChanged,this),this.model.on(wt.CHILD_RUNS_METRICS,this.childRunsMetricsChanged,this),this.model.on(wt.COMPUTE_TARGET_STATUS,this.runPropertiesChanged,this),this.model.on(wt.GRAPH,this.graphChanged,this),this.model.on(wt.ERROR,this.errorChanged,this)),this.initialize_render()},e.prototype.childRunsChanged=function(){var t=this.model.get(_t.CHILD_RUNS);this.renderer.renderLeaderBoard(t)},e.prototype.childRunsMetricsChanged=function(){var t=this.model.get(_t.CHILD_RUNS_METRICS);this.renderer.renderChildrenMetricChart(t)},e.prototype.runIdChanged=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.WORKBENCH_URI);this.renderer.renderBaseHTML(t,e)},e.prototype.run_metrics_changed=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.RUN_METRICS);this.$el.find(".progress").remove();var r=[At.ROC,At.PRECISION_RECALL,At.CONFUSION_MATRICES,At.PREDICTIONS];s.remove(e,(function(t){return s.includes(r,t.name)}));var n=s.remove(e,(function(t){return t.name===At.ACCURACY_TABLE}));s.isEmpty(n)||s.attempt(this.renderer.renderAccuracyTableBasedChart(n[0],["precisionRecall","roc","lift","gains","calibration"]));var i=[At.CONFUSION_MATRIX],a=s.remove(e,(function(t){return s.includes(i,t.name)}));s.isEmpty(a)||s.attempt(this.renderer.renderConfusionMatrix(a[0]));var o=[At.PREDICTED_TRUE],l=s.remove(e,(function(t){return s.includes(o,t.name)}));s.isEmpty(l)||s.attempt(this.renderer.renderPredictedVsTrue(l[0]));var c=[At.RESIDUALS],u=s.remove(e,(function(t){return s.includes(c,t.name)}));s.isEmpty(u)||s.attempt(this.renderer.renderResiduals(u[0]));var h=[At.MODEL_EXPLANATION],f=s.remove(e,(function(t){return s.includes(h,t.name)}));s.isEmpty(f)||this.renderer.renderFeatureImportance(f[0]),s.attempt(this.renderer.renderRunMetrics(e,t.run_id))},e.prototype.run_logs_changed=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.RUN_LOGS);this.renderer.renderLogs(t,e)},e.prototype.runPropertiesChanged=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.COMPUTE_TARGET_STATUS);this.renderer.populateRunProperties(t,e)},e.prototype.graphChanged=function(){var t=this.model.get(_t.GRAPH);s.isEmpty(t)||this.renderer.renderGraph(t)},e.prototype.errorChanged=function(){var t=this.model.get(_t.ERROR);this.renderer.renderError(t)},e.prototype.isFinished=function(){this.model.get(_t.IS_FINISHED)&&this.renderer.cleanFinalState()},e.prototype.initialize_render=function(){var e=this,r=this.model.get(_t.WIDGET_SETTINGS),n=this.model.get(_t.RUN_ID);this.renderer=new Ot(u(this.el),this,r),this.renderer.initRender(),n&&window.setTimeout((function(){e.runIdChanged(),e.runPropertiesChanged(),e.run_logs_changed(),e.run_metrics_changed(),e.childRunsChanged(),e.childRunsMetricsChanged(),e.graphChanged(),e.errorChanged(),e.isFinished(),t.prototype.sendHeartbeat.call(e)}))},e}(Dt),Ft=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Nt=function(){return(Nt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r\n \n \n \n \n \n \n "),r.append("
\n
"+It.template.progressTemplate("runs")+"
\n \n
"+It.template.progressTemplate("metrics")+'
\n \n \n \n \n ")}return!0},t.prototype.populateRunProperties=function(t,e){It.populateBaseJobInfo(this.element,this.context,t,e),this.element.find("#"+t.run_id).find("#max_concurrent_jobs").text(t.tags&&t.tags.max_concurrent_jobs?t.tags.max_concurrent_jobs:"N/A"),this.element.find("#"+t.run_id).find("#max_total_jobs").text(t.tags&&t.tags.max_total_jobs?t.tags.max_total_jobs:"N/A")},t.prototype.renderLeaderBoard=function(t,e){var r=this.getSortOrder(e),n=Object.keys(e.hyper_parameters);if(t&&t.length>0){var i=void 0,a=void 0;t[0].best_metric&&t[0].metric?(i={name:"metric",title:"Best Metric*",type:"number",width:170},a="metric"):(i={name:"best_metric",title:"Best Metric*",type:"number",width:170},a="best_metric");var o=[{name:"run_number",title:"Run",type:"number",width:70,validate:"required"},i,{name:"status",title:"Status",type:"text",width:100,itemTemplate:It.template.statusColTemplate},{name:"start_time",title:"Started",type:"text",width:170,itemTemplate:It.template.dateColTemplate},{name:"duration",title:"",type:"text",width:80,headerTemplate:It.template.headTemplate("Queue and run duration in hh:mm:ss","Duration"),sorter:"timesorter"},{name:"run_id",title:"Run Id",type:"text",width:350,itemTemplate:It.template.runIdTemplate}];n.forEach((function(t){o.push({name:"param_"+t,title:t,type:"number",width:200})})),It.renderJsGrid(this.element,t,o,a,r)}},t.prototype.renderPrimaryMetricChart=function(t,e,r){var n=this.element,i=e;if(i&&null!=i.series){var a=n.find("#metricContainer");if(a.find(".progress").remove(),a.length>0){if(i.title="HyperDrive Run Primary Metric : "+i.primaryMetricName,i.series=i.series[i.primaryMetricName],i.series&&i.series[0].data&&i.series[0].data.length>0){var o=i.series[0].data.filter((function(t){return"number"!=typeof t}));if(o&&o.length>0)return void It.renderError(this.element.find("#errorContainer"),"Non-numeric values for primary metric cannot be visualized in 'HyperDrive Run Primary Metric' chart.")}bt.lineChart(a[0],i,i.showLegend,null,"category",{field:"metric",order:this.getSortOrder(r)})}}},t.prototype.renderParameterMetricChart=function(t,e,r){var n=this,i=this.element,a=this.getSortOrder;if(t&&e&&null!=e.series){var o=this.element.find(".switchChart"),l=!0;o.show(),o.off().on("change",(function(c){var h=u(c.target),f={};f.allArguments=Object.keys(r.hyper_parameters);var p=n.element.find("#errorContainer");f.allArguments=f.allArguments.filter((function(t){return!(!Array.isArray(r.hyper_parameters[t])||0===r.hyper_parameters[t].length)||(p[0].innerHTML+="
HyperParameters structure is invalid for parameter = "+t,p.show(),!1)}));var d=f.allArguments.map((function(t){var e=r.hyper_parameters[t];return[t,It.convertPlotlyParameterTypeFromHyperDrive(e[0]),t+" ( "+e[0]+" ) "]}));l&&(o.val(f.allArguments&&f.allArguments.length>=3?"parallelCoordinates":"twoDimension"),l=!1),f.child_runs=t,f.metricName=e.primaryMetricName;var g=i.find(".parallelCoordinatesContainer"),m=i.find(".threeDimensionContainer"),v=i.find(".twoDimensionContainer");if(("threeDimension"!==h.val()&&(bt.purge(m.get(0)),m.hide()),"twoDimension"!==h.val()&&(bt.purge(v.get(0)),v.hide()),"parallelCoordinates"!==h.val()&&(bt.purge(g.get(0)),g.hide()),f.child_runs&&f.child_runs.length>0)&&!f.child_runs.map((function(t){return t.best_metric})).every((function(t){return s.isNumber(t)||s.isUndefined(t)})))return p[0].innerHTML+="
Non-numeric values for primary metric cannot be visualized in a 2D/3D/Parallel coordinates chart.",i.find(".switchChart").hide(),void p.show();switch(h.val()){case"threeDimension":m.show(),m.length>0&&(f.allArguments=d,bt.threeDimensionSurfaceChart(m[0],f,a(r)));break;case"twoDimension":v.show(),v.length>0&&(f.allArguments=d,bt.twoDimensionSurfaceChart(v[0],f,a(r)));break;case"parallelCoordinates":default:g.show(),g.length>0&&bt.parallelCoordinatesChart(g[0],f,a(r))}})).change()}},t.prototype.renderStatusBar=function(t){It.renderStatusChart(this.element,t)},t.prototype.renderLogs=function(t){It.renderLogs(this.element.find("#txtDriverLog"),t)},t.prototype.cleanFinalState=function(){It.cleanFinalState(this.element)},t.prototype.renderError=function(t){It.renderError(this.element.find("#errorContainer"),t)},t.prototype.getSortOrder=function(t){var e="asc";try{var r=JSON.parse(t.properties.primary_metric_config);"minimize"===r.goal?e="asc":"maximize"===r.goal&&(e="desc")}catch(t){e="asc"}return e},t}(),Yt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Yt(e,t),e.prototype.render=function(){this.model&&this.model.on&&(this.model.on(wt.RUN_ID,this.runIdChanged,this),this.model.on(wt.RUN_PROPERTIES,this.runPropertiesChanged,this),this.model.on(wt.RUN_LOGS,this.runLogs_changed,this),this.model.on(wt.CHILD_RUNS,this.childRunsChanged,this),this.model.on(wt.CHILD_RUNS_METRICS,this.childRunsMetricsChanged,this),this.model.on(wt.COMPUTE_TARGET_STATUS,this.runPropertiesChanged,this),this.model.on(wt.ERROR,this.errorChanged,this),this.model.on(wt.IS_FINISHED,this.isFinished,this)),this.initialize_render()},e.prototype.childRunsChanged=function(){var t=this.model.get(_t.CHILD_RUNS),e=this.model.get(_t.RUN_PROPERTIES),r=this.model.get(_t.CHILD_RUNS_METRICS);this.renderer.renderLeaderBoard(t,e),this.renderer.renderStatusBar(t),this.renderer.renderParameterMetricChart(t,r,e)},e.prototype.childRunsMetricsChanged=function(){var t=this.model.get(_t.CHILD_RUNS_METRICS),e=this.model.get(_t.RUN_PROPERTIES),r=this.model.get(_t.CHILD_RUNS);this.renderer.renderPrimaryMetricChart(r,t,e)},e.prototype.runIdChanged=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.WORKBENCH_URI);this.renderer.renderBaseHTML(t,e)},e.prototype.runLogs_changed=function(){var t=this.model.get(_t.RUN_LOGS);this.renderer.renderLogs(t)},e.prototype.runPropertiesChanged=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.COMPUTE_TARGET_STATUS);this.renderer.populateRunProperties(t,e)},e.prototype.errorChanged=function(){var t=this.model.get(_t.ERROR);this.renderer.renderError(t)},e.prototype.isFinished=function(){this.model.get(_t.IS_FINISHED)&&this.renderer.cleanFinalState()},e.prototype.initialize_render=function(){var e=this,r=this.model.get(_t.RUN_ID);this.renderer=new Bt(u(this.el),this),this.renderer.initRender(),r&&window.setTimeout((function(){e.runIdChanged(),e.runPropertiesChanged(),e.runLogs_changed(),e.childRunsChanged(),e.childRunsMetricsChanged(),e.errorChanged(),e.isFinished(),t.prototype.sendHeartbeat.call(e)}))},e}(Dt),Ut=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ht=function(){return(Ht=Object.assign||function(t){for(var e,r=1,n=arguments.length;r\n
\n
"+It.template.progressTemplate("runs")+"
\n \n
"+It.template.progressTemplate("metrics")+"
\n "),!0},t.prototype.renderHeatmapBar=function(t,e){if(t&&0!==t.length){var r={child_runs:t,colors:{lightgreen:"#a8e063",green:"#56ab2f",gray:"#eeeeee",red:"#ea5455",orange:"#995502",blue:"#5b86e5"}},n=this.element.find(".statusContainer");if(n.length>0){var i=s.get(e,"primaryMetricName"),a=s.get(e,["series",i]),o=s.get(e,"categories");r.child_runs_metrics={series:a,categories:o},bt.heatmapBarChart(n[0],r)}}},t.prototype.renderParentRunStatus=function(t){if(t&&t.run_id&&t.status){var e=t.run_id,r=this.element.find("#parentRunContainer");0===r.find("#parentRunID").length&&r.append('
'+e+':
\n
');var n=t.status;r.find(".parentStatusContainer").html("Status: "+It.template.statusColTemplate(n));var i=s.get(t,"properties.errors");if("Failed"===n&&i&&this.element.find("#hdgrid")){this.element.find(".progress").remove(),i=i.split("\\n").join("\n");var a=u('
').appendTo(r);u('
').text(i).appendTo(a)}}},t.prototype.renderLeaderBoard=function(t,e){var r=this.element,n=this.getSortOrder(t,e),i=s.some(t,(function(t){return t.start_time&&"None"!==t.start_time})),a=It.safeParseJson(s.get(e,"properties.ProblemInfoJsonString","{}")),o=s.get(a,"subsampling",!1),l=[{name:"iteration",title:"Iteration",type:"number",width:70,validate:"required"},{name:"run_name",title:"Pipeline",type:"text",width:300,itemTemplate:It.template.pipelineTemplate},{name:"primary_metric",title:"Iteration metric",type:"number",width:130},{name:"best_metric",title:"",type:"number",width:100,headerTemplate:It.template.headTemplate("Best metric value reached at the time of the iteration","Best metric")},{name:"status",title:"Status",type:"text",width:100,itemTemplate:It.template.statusColTemplate},{name:"duration",title:"",type:"text",width:80,headerTemplate:It.template.headTemplate("Duration in hh:mm:ss","Duration"),sorter:"timesorter"},{name:"training_percent",title:"Sampling",type:"text",width:80,headerTemplate:It.template.headTemplate("Sampling %","Sampling"),itemTemplate:It.template.samplingTemplate,visible:o},{name:"start_time",title:"Started",type:"text",width:170,itemTemplate:It.template.dateColTemplate,visible:i},{name:"run_id",title:"Run Id",type:"text",align:"center",width:60,itemTemplate:It.template.copyButtonTemplate}],c=u('
\n per page
');u(r.find("#paginationDropDownContainer")).length<1&&(u(c.children()[0]).val(5),r.find("#hdgrid").jsGrid({pageSize:5}));It.renderJsGrid(r,t,l,"primary_metric",n,c)},t.prototype.renderPrimaryMetricChart=function(t){var e=t;if(e&&null!=e.series){var r=this.element.find("#metricContainer");r.find(".progress").remove(),this.element.find("#pm_dropdown").length>0&&!s.isEmpty(u("#pm_dropdown").val())&&(e.primaryMetricName=u("#pm_dropdown option:selected").text()),r.length>0&&(e.title="AutoML Run Primary Metric : "+e.primaryMetricName,e.series.categories=e.categories,bt.changeableLineChart(r[0],this.element.find("#dropDownContainer"),e,!1))}},t.prototype.cleanFinalState=function(){It.cleanFinalState(this.element)},t.prototype.renderError=function(t){It.renderError(this.element.find("#errorContainer"),t)},t.prototype.getSortOrder=function(t,e){var r;try{var n=t[0].goal,i=e.properties.primary_metric;n===i+"_max"?r="desc":n===i+"_min"&&(r="asc")}catch(t){r="asc"}return r},t}(),Wt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Wt(e,t),e.prototype.render=function(){this.model&&this.model.on&&(this.model.on(wt.RUN_ID,this.runIdChanged,this),this.model.on(wt.RUN_PROPERTIES,this.runPropertiesChanged,this),this.model.on(wt.CHILD_RUNS,this.childRunsChanged,this),this.model.on(wt.CHILD_RUNS_METRICS,this.childRunsMetricsChanged,this),this.model.on(wt.COMPUTE_TARGET_STATUS,this.runPropertiesChanged,this),this.model.on(wt.ERROR,this.errorChanged,this),this.model.on(wt.IS_FINISHED,this.isFinished,this)),this.initialize_render()},e.prototype.childRunsChanged=function(){var t=this.model.get(_t.CHILD_RUNS),e=this.model.get(_t.RUN_PROPERTIES),r=this.model.get(_t.CHILD_RUNS_METRICS);this.renderer.renderLeaderBoard(t,e),this.renderer.renderHeatmapBar(t,r)},e.prototype.childRunsMetricsChanged=function(){var t=this.model.get(_t.CHILD_RUNS_METRICS),e=this.model.get(_t.CHILD_RUNS);this.renderer.renderHeatmapBar(e,t),this.renderer.renderPrimaryMetricChart(t)},e.prototype.runIdChanged=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.WORKBENCH_URI);this.renderer.renderBaseHTML(t,e)},e.prototype.runPropertiesChanged=function(){var t=this.model.get(_t.RUN_PROPERTIES);this.renderer.renderParentRunStatus(t)},e.prototype.errorChanged=function(){var t=this.model.get(_t.ERROR);this.renderer.renderError(t)},e.prototype.isFinished=function(){this.model.get(_t.IS_FINISHED)&&this.renderer.cleanFinalState()},e.prototype.initialize_render=function(){var e=this,r=this.model.get(_t.WIDGET_SETTINGS),n=this.model.get(_t.RUN_ID);y(r.send_telemetry,r.sdk_version,r.log_level),this.renderer=new qt(u(this.el)),this.renderer.initRender(),n&&window.setTimeout((function(){e.runIdChanged(),e.runPropertiesChanged(),e.childRunsChanged(),e.childRunsMetricsChanged(),e.errorChanged(),e.isFinished(),t.prototype.sendHeartbeat.call(e)}))},e}(Dt),Xt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Jt=function(){return(Jt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r\n
\n \n "),r.append("
\n
"+It.template.progressTemplate("runs")+"

\n
"+It.template.progressTemplate("pipeline")+"
\n ")}return!0},t.prototype.populateRunProperties=function(t,e){It.populateBaseJobInfo(this.element,this.context,t,e);var r="";if(t&&t.end_time_utc){var n=new Date(t.end_time_utc);r=n.toLocaleDateString()+" "+n.toLocaleTimeString()}this.element.find("#"+t.run_id).find("#endTime").text(r)},t.prototype.renderLeaderBoard=function(t){var e=this.element;if(t&&t.length>0){var r=[{name:"name",title:"Step",type:"text",width:110,validate:"required"},{name:"status",title:"Status",type:"text",width:100,itemTemplate:It.template.statusColTemplate},{name:"is_reused",title:"Reused",type:"text",width:80},{name:"created_time",title:"Created",type:"text",width:170,itemTemplate:It.template.dateColTemplate,sorter:"datesorter"},{name:"end_time",title:"Ended",type:"text",width:170,itemTemplate:It.template.dateColTemplate},{name:"duration",title:"",type:"text",width:80,headerTemplate:It.template.headTemplate("Duration in hh:mm:ss","Duration"),sorter:"timesorter"},{name:"run_id",title:"Run Id",type:"text",width:400,itemTemplate:It.template.runIdTemplate}];It.renderJsGrid(e,t,r,"created_time","desc")}},t.prototype.renderLogs=function(t){It.renderLogs(this.element.find("#txtDriverLog"),t)},t.prototype.renderGraph=function(t){var e=new Qt(this.element);It.renderGraph(this.element,this.context,t,e)},t.prototype.renderError=function(t){It.renderError(this.element.find("#errorContainer"),t)},t.prototype.cleanFinalState=function(){It.cleanFinalState(this.element)},t}(),te=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ee=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return te(e,t),e.prototype.render=function(){this.model&&this.model.on&&(this.model.on(wt.RUN_ID,this.runIdChanged,this),this.model.on(wt.RUN_PROPERTIES,this.runPropertiesChanged,this),this.model.on(wt.RUN_LOGS,this.runLogsChanged,this),this.model.on(wt.GRAPH,this.graphChanged,this),this.model.on(wt.COMPUTE_TARGET_STATUS,this.runPropertiesChanged,this),this.model.on(wt.ERROR,this.errorChanged,this),this.model.on(wt.IS_FINISHED,this.isFinished,this)),this.initialize_render()},e.prototype.runIdChanged=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.WORKBENCH_URI);this.renderer.renderBaseHTML(t,e)},e.prototype.runPropertiesChanged=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.COMPUTE_TARGET_STATUS);this.renderer.populateRunProperties(t,e)},e.prototype.runLogsChanged=function(){var t=this.model.get(_t.RUN_LOGS);this.renderer.renderLogs(t)},e.prototype.graphChanged=function(){var t=this.model.get(_t.GRAPH);this.renderer.renderGraph(t),t&&t.child_runs&&this.renderer.renderLeaderBoard(t.child_runs)},e.prototype.errorChanged=function(){var t=this.model.get(_t.ERROR);this.renderer.renderError(t)},e.prototype.isFinished=function(){this.model.get(_t.IS_FINISHED)&&this.renderer.cleanFinalState()},e.prototype.initialize_render=function(){var e=this,r=this.model.get(_t.RUN_ID);this.renderer=new $t(u(this.el),this),this.renderer.initRender(),r&&window.setTimeout((function(){e.runIdChanged(),e.runPropertiesChanged(),e.runLogsChanged(),e.graphChanged(),e.errorChanged(),e.isFinished(),t.prototype.sendHeartbeat.call(e)}))},e}(Dt),re=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ne=function(){return(ne=Object.assign||function(t){for(var e,r=1,n=arguments.length;r\n \n \n \n \n \n \n \n \n \n \n '),r.append("
\n
\n
\n
"),r.append("")}return!0},t.prototype.populateRunProperties=function(t,e){It.populateBaseJobInfo(this.element,this.context,t,e),this.element.find("#"+t.run_id).find("#queueTimeoutSeconds").text(t.queue_timeout_seconds?t.queue_timeout_seconds:"N/A"),this.element.find("#"+t.run_id).find("#clusterCoordinationTimeoutSeconds").text(t.cluster_coordination_timeout_seconds?t.cluster_coordination_timeout_seconds:"N/A")},t.prototype.populateRunArguments=function(t,e){this.element.find("#"+t).find("#arguments").text(e||"N/A")},t.prototype.renderRunMetrics=function(t,e){var r=this.element;r.find("#"+e).find(".single-metric").remove(),t&&t.length>0&&s.forEach(s.sortBy(t,(function(t){return s.toLower(t.name)})),(function(t){if(t&&t.series&&t.series[0]&&t.series[0].data&&1===t.series[0].data.length)r.find("#"+t.run_id).find(".table-details").append("\n \n \n ");else if(t&&t.series&&t.series[0]&&t.series[0].data&&t.series[0].data.length>1){!function(t,e){var n=It.getHashCode(t.title);r.find("#"+n).length<1&&r.find("#"+e).find("#chartContainer").append("
");var i=r.find("#"+n);i.length>0&&bt.lineChart(i[0],t)}({title:t.name,categories:t.categories,series:t.series},t.run_id)}}))},t.prototype.renderLogs=function(t,e){It.renderLogs(this.element.find("#"+t).find("#txtDriverLog"),e)},t.prototype.renderLeaderBoard=function(t){var e=this.element;if(t&&t.length>0){var r=[{name:"run_number",title:"Run Number",type:"number",width:110,validate:"required"},{name:"status",title:"Status",type:"text",width:100,itemTemplate:It.template.statusColTemplate},{name:"start_time",title:"Started",type:"text",width:170,itemTemplate:It.template.dateColTemplate},{name:"duration",title:"",type:"text",width:80,headerTemplate:It.template.headTemplate("Duration in hh:mm:ss","Duration"),sorter:"timesorter"},{name:"run_id",title:"Run Id",type:"text",width:400,itemTemplate:It.template.runIdTemplate}];It.renderJsGrid(e,t,r)}},t.prototype.renderChildrenMetricChart=function(t){var e=this.element,r=t;if(r&&null!=r.series){var n=e.find("#metricContainer");n.find(".progress").remove(),n.length>0&&(r.title="Run Metric : "+r.primaryMetricName,r.series=r.series[r.primaryMetricName],bt.lineChart(n[0],r,r.showLegend,null,"category"))}},t.prototype.renderAccuracyTableBasedChart=function(t,e){var r=this.element;s.forEach(e,(function(e){var n=r.find("#"+e+"Container"),i=s.get(t,"series[0].data[0]");n.length>0&&bt.accuracyTableBasedCharts(n[0],i,e)}))},t.prototype.renderConfusionMatrix=function(t){var e=s.get(t,"series[0].data[0]"),r=this.element.find("#confusionMatrixContainer");r.length>0&&bt.confusionMatrix(r[0],e)},t.prototype.renderPredictedVsTrue=function(t){if(t){var e=this.element.find("#predictedVsTrueContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.predictedVsTrueChart(e[0],r)}},t.prototype.renderResiduals=function(t){var e=this.element.find("#residualsContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.residualsChart(e[0],r)},t.prototype.cleanFinalState=function(){It.cleanFinalState(this.element)},t.prototype.renderError=function(t){It.renderError(this.element.find("#errorContainer"),t)},t.prototype.renderFeatureImportance=function(t){var e=this.element.find("#featureImportanceContainer"),r=s.get(t,"series[0].data[0]");e.length>0&&bt.featureImportanceChart(e[0],r)},t}(),oe=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),se=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return oe(e,t),e.prototype.render=function(){this.model&&this.model.on&&(this.model.on(wt.RUN_ID,this.runIdChanged,this),this.model.on(wt.RUN_PROPERTIES,this.runPropertiesChanged,this),this.model.on(wt.RUN_LOGS,this.run_logs_changed,this),this.model.on(wt.RUN_METRICS,this.run_metrics_changed,this),this.model.on(wt.CHILD_RUNS,this.childRunsChanged,this),this.model.on(wt.CHILD_RUNS_METRICS,this.childRunsMetricsChanged,this),this.model.on(wt.COMPUTE_TARGET_STATUS,this.runPropertiesChanged,this),this.model.on(wt.ERROR,this.errorChanged,this)),this.initialize_render()},e.prototype.childRunsChanged=function(){var t=this.model.get(_t.CHILD_RUNS);this.renderer.renderLeaderBoard(t)},e.prototype.childRunsMetricsChanged=function(){var t=this.model.get(_t.CHILD_RUNS_METRICS);this.renderer.renderChildrenMetricChart(t)},e.prototype.runIdChanged=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.WORKBENCH_URI);this.renderer.renderBaseHTML(t,e)},e.prototype.run_metrics_changed=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.RUN_METRICS);this.$el.find(".progress").remove();var r=[At.ROC,At.PRECISION_RECALL,At.CONFUSION_MATRICES,At.PREDICTIONS];s.remove(e,(function(t){return s.includes(r,t.name)}));var n=s.remove(e,(function(t){return t.name===At.ACCURACY_TABLE}));s.isEmpty(n)||s.attempt(this.renderer.renderAccuracyTableBasedChart(n[0],["precisionRecall","roc","lift","gains","calibration"]));var i=[At.CONFUSION_MATRIX],a=s.remove(e,(function(t){return s.includes(i,t.name)}));s.isEmpty(a)||s.attempt(this.renderer.renderConfusionMatrix(a[0]));var o=[At.PREDICTED_TRUE],l=s.remove(e,(function(t){return s.includes(o,t.name)}));s.isEmpty(l)||s.attempt(this.renderer.renderPredictedVsTrue(l[0]));var c=[At.RESIDUALS],u=s.remove(e,(function(t){return s.includes(c,t.name)}));s.isEmpty(u)||s.attempt(this.renderer.renderResiduals(u[0]));var h=[At.MODEL_EXPLANATION],f=s.remove(e,(function(t){return s.includes(h,t.name)}));s.isEmpty(f)||this.renderer.renderFeatureImportance(f[0]),s.attempt(this.renderer.renderRunMetrics(e,t.run_id))},e.prototype.run_logs_changed=function(){var t=this.model.get(_t.RUN_ID),e=this.model.get(_t.RUN_LOGS);this.renderer.renderLogs(t,e)},e.prototype.runPropertiesChanged=function(){var t=this.model.get(_t.RUN_PROPERTIES),e=this.model.get(_t.COMPUTE_TARGET_STATUS);this.renderer.populateRunProperties(t,e)},e.prototype.errorChanged=function(){var t=this.model.get(_t.ERROR);this.renderer.renderError(t)},e.prototype.isFinished=function(){this.model.get(_t.IS_FINISHED)&&this.renderer.cleanFinalState()},e.prototype.initialize_render=function(){var e=this,r=this.model.get(_t.WIDGET_SETTINGS),n=this.model.get(_t.RUN_ID);this.renderer=new ae(u(this.el),this,r),this.renderer.initRender(),n&&window.setTimeout((function(){e.runIdChanged(),e.runPropertiesChanged(),e.run_logs_changed(),e.run_metrics_changed(),e.childRunsChanged(),e.childRunsMetricsChanged(),e.errorChanged(),e.isFinished(),t.prototype.sendHeartbeat.call(e)}))},e}(Dt);r.d(e,"i",(function(){return St})),r.d(e,"j",(function(){return Rt})),r.d(e,"c",(function(){return jt})),r.d(e,"d",(function(){return Vt})),r.d(e,"a",(function(){return Gt})),r.d(e,"b",(function(){return Zt})),r.d(e,"e",(function(){return Kt})),r.d(e,"f",(function(){return ee})),r.d(e,"g",(function(){return ie})),r.d(e,"h",(function(){return se}))},function(t,e,r){var n;n=function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=r(2),a=r(1),o=r(4);function s(t){this.options=a({},i,t)}s.prototype.run=function(){var t=this.options,e=t.cy,r=t.eles,i=function(t,e){return"function"==typeof e?e.apply(t,[t]):e},a=t.boundingBox||{x1:0,y1:0,w:e.width(),h:e.height()};void 0===a.x2&&(a.x2=a.x1+a.w),void 0===a.w&&(a.w=a.x2-a.x1),void 0===a.y2&&(a.y2=a.y1+a.h),void 0===a.h&&(a.h=a.y2-a.y1);var s=new o.graphlib.Graph({multigraph:!0,compound:!0}),l={},c=function(t,e){null!=e&&(l[t]=e)};c("nodesep",t.nodeSep),c("edgesep",t.edgeSep),c("ranksep",t.rankSep),c("rankdir",t.rankDir),c("ranker",t.ranker),s.setGraph(l),s.setDefaultEdgeLabel((function(){return{}})),s.setDefaultNodeLabel((function(){return{}}));for(var u=r.nodes(),h=0;h1?e-1:0),n=1;n0&&e-1 in t)}A.fn=A.prototype={jquery:"3.4.1",constructor:A,length:0,toArray:function(){return l.call(this)},get:function(t){return null==t?l.call(this):t<0?this[t+this.length]:this[t]},pushStack:function(t){var e=A.merge(this.constructor(),t);return e.prevObject=this,e},each:function(t){return A.each(this,t)},map:function(t){return this.pushStack(A.map(this,(function(e,r){return t.call(e,r,e)})))},slice:function(){return this.pushStack(l.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(t){var e=this.length,r=+t+(t<0?e:0);return this.pushStack(r>=0&&r+~]|"+F+")"+F+"*"),G=new RegExp(F+"|>"),q=new RegExp(B),W=new RegExp("^"+N+"$"),Z={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N+"|[*])"),ATTR:new RegExp("^"+j),PSEUDO:new RegExp("^"+B),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+F+"*(even|odd|(([+-]|)(\\d*)n|)"+F+"*(?:([+-]|)"+F+"*(\\d+)|))"+F+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+F+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+F+"*((?:-\\d)?\\d*)"+F+"*\\)|)(?=[^-]|$)","i")},X=/HTML$/i,J=/^(?:input|select|textarea|button)$/i,K=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,$=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,tt=/[+~]/,et=new RegExp("\\\\([\\da-f]{1,6}"+F+"?|("+F+")|.)","ig"),rt=function(t,e,r){var n="0x"+e-65536;return n!=n||r?e:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},nt=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,it=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},at=function(){f()},ot=bt((function(t){return!0===t.disabled&&"fieldset"===t.nodeName.toLowerCase()}),{dir:"parentNode",next:"legend"});try{P.apply(S=O.call(_.childNodes),_.childNodes),S[_.childNodes.length].nodeType}catch(t){P={apply:S.length?function(t,e){D.apply(t,O.call(e))}:function(t,e){for(var r=t.length,n=0;t[r++]=e[n++];);t.length=r-1}}}function st(t,e,n,i){var a,s,c,u,h,d,v,y=e&&e.ownerDocument,w=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==w&&9!==w&&11!==w)return n;if(!i&&((e?e.ownerDocument||e:_)!==p&&f(e),e=e||p,g)){if(11!==w&&(h=$.exec(t)))if(a=h[1]){if(9===w){if(!(c=e.getElementById(a)))return n;if(c.id===a)return n.push(c),n}else if(y&&(c=y.getElementById(a))&&x(e,c)&&c.id===a)return n.push(c),n}else{if(h[2])return P.apply(n,e.getElementsByTagName(t)),n;if((a=h[3])&&r.getElementsByClassName&&e.getElementsByClassName)return P.apply(n,e.getElementsByClassName(a)),n}if(r.qsa&&!I[t+" "]&&(!m||!m.test(t))&&(1!==w||"object"!==e.nodeName.toLowerCase())){if(v=t,y=e,1===w&&G.test(t)){for((u=e.getAttribute("id"))?u=u.replace(nt,it):e.setAttribute("id",u=b),s=(d=o(t)).length;s--;)d[s]="#"+u+" "+xt(d[s]);v=d.join(","),y=tt.test(t)&&vt(e.parentNode)||e}try{return P.apply(n,y.querySelectorAll(v)),n}catch(e){I(t,!0)}finally{u===b&&e.removeAttribute("id")}}}return l(t.replace(V,"$1"),e,n,i)}function lt(){var t=[];return function e(r,i){return t.push(r+" ")>n.cacheLength&&delete e[t.shift()],e[r+" "]=i}}function ct(t){return t[b]=!0,t}function ut(t){var e=p.createElement("fieldset");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function ht(t,e){for(var r=t.split("|"),i=r.length;i--;)n.attrHandle[r[i]]=e}function ft(t,e){var r=e&&t,n=r&&1===t.nodeType&&1===e.nodeType&&t.sourceIndex-e.sourceIndex;if(n)return n;if(r)for(;r=r.nextSibling;)if(r===e)return-1;return t?1:-1}function pt(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function dt(t){return function(e){var r=e.nodeName.toLowerCase();return("input"===r||"button"===r)&&e.type===t}}function gt(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ot(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function mt(t){return ct((function(e){return e=+e,ct((function(r,n){for(var i,a=t([],r.length,e),o=a.length;o--;)r[i=a[o]]&&(r[i]=!(n[i]=r[i]))}))}))}function vt(t){return t&&void 0!==t.getElementsByTagName&&t}for(e in r=st.support={},a=st.isXML=function(t){var e=t.namespaceURI,r=(t.ownerDocument||t).documentElement;return!X.test(e||r&&r.nodeName||"HTML")},f=st.setDocument=function(t){var e,i,o=t?t.ownerDocument||t:_;return o!==p&&9===o.nodeType&&o.documentElement?(d=(p=o).documentElement,g=!a(p),_!==p&&(i=p.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",at,!1):i.attachEvent&&i.attachEvent("onunload",at)),r.attributes=ut((function(t){return t.className="i",!t.getAttribute("className")})),r.getElementsByTagName=ut((function(t){return t.appendChild(p.createComment("")),!t.getElementsByTagName("*").length})),r.getElementsByClassName=Q.test(p.getElementsByClassName),r.getById=ut((function(t){return d.appendChild(t).id=b,!p.getElementsByName||!p.getElementsByName(b).length})),r.getById?(n.filter.ID=function(t){var e=t.replace(et,rt);return function(t){return t.getAttribute("id")===e}},n.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var r=e.getElementById(t);return r?[r]:[]}}):(n.filter.ID=function(t){var e=t.replace(et,rt);return function(t){var r=void 0!==t.getAttributeNode&&t.getAttributeNode("id");return r&&r.value===e}},n.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var r,n,i,a=e.getElementById(t);if(a){if((r=a.getAttributeNode("id"))&&r.value===t)return[a];for(i=e.getElementsByName(t),n=0;a=i[n++];)if((r=a.getAttributeNode("id"))&&r.value===t)return[a]}return[]}}),n.find.TAG=r.getElementsByTagName?function(t,e){return void 0!==e.getElementsByTagName?e.getElementsByTagName(t):r.qsa?e.querySelectorAll(t):void 0}:function(t,e){var r,n=[],i=0,a=e.getElementsByTagName(t);if("*"===t){for(;r=a[i++];)1===r.nodeType&&n.push(r);return n}return a},n.find.CLASS=r.getElementsByClassName&&function(t,e){if(void 0!==e.getElementsByClassName&&g)return e.getElementsByClassName(t)},v=[],m=[],(r.qsa=Q.test(p.querySelectorAll))&&(ut((function(t){d.appendChild(t).innerHTML="",t.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+F+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||m.push("\\["+F+"*(?:value|"+R+")"),t.querySelectorAll("[id~="+b+"-]").length||m.push("~="),t.querySelectorAll(":checked").length||m.push(":checked"),t.querySelectorAll("a#"+b+"+*").length||m.push(".#.+[+~]")})),ut((function(t){t.innerHTML="";var e=p.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&m.push("name"+F+"*[*^$|!~]?="),2!==t.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),d.appendChild(t).disabled=!0,2!==t.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),m.push(",.*:")}))),(r.matchesSelector=Q.test(y=d.matches||d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut((function(t){r.disconnectedMatch=y.call(t,"*"),y.call(t,"[s!='']:x"),v.push("!=",B)})),m=m.length&&new RegExp(m.join("|")),v=v.length&&new RegExp(v.join("|")),e=Q.test(d.compareDocumentPosition),x=e||Q.test(d.contains)?function(t,e){var r=9===t.nodeType?t.documentElement:t,n=e&&e.parentNode;return t===n||!(!n||1!==n.nodeType||!(r.contains?r.contains(n):t.compareDocumentPosition&&16&t.compareDocumentPosition(n)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},T=e?function(t,e){if(t===e)return h=!0,0;var n=!t.compareDocumentPosition-!e.compareDocumentPosition;return n||(1&(n=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1)||!r.sortDetached&&e.compareDocumentPosition(t)===n?t===p||t.ownerDocument===_&&x(_,t)?-1:e===p||e.ownerDocument===_&&x(_,e)?1:u?z(u,t)-z(u,e):0:4&n?-1:1)}:function(t,e){if(t===e)return h=!0,0;var r,n=0,i=t.parentNode,a=e.parentNode,o=[t],s=[e];if(!i||!a)return t===p?-1:e===p?1:i?-1:a?1:u?z(u,t)-z(u,e):0;if(i===a)return ft(t,e);for(r=t;r=r.parentNode;)o.unshift(r);for(r=e;r=r.parentNode;)s.unshift(r);for(;o[n]===s[n];)n++;return n?ft(o[n],s[n]):o[n]===_?-1:s[n]===_?1:0},p):p},st.matches=function(t,e){return st(t,null,null,e)},st.matchesSelector=function(t,e){if((t.ownerDocument||t)!==p&&f(t),r.matchesSelector&&g&&!I[e+" "]&&(!v||!v.test(e))&&(!m||!m.test(e)))try{var n=y.call(t,e);if(n||r.disconnectedMatch||t.document&&11!==t.document.nodeType)return n}catch(t){I(e,!0)}return st(e,p,null,[t]).length>0},st.contains=function(t,e){return(t.ownerDocument||t)!==p&&f(t),x(t,e)},st.attr=function(t,e){(t.ownerDocument||t)!==p&&f(t);var i=n.attrHandle[e.toLowerCase()],a=i&&L.call(n.attrHandle,e.toLowerCase())?i(t,e,!g):void 0;return void 0!==a?a:r.attributes||!g?t.getAttribute(e):(a=t.getAttributeNode(e))&&a.specified?a.value:null},st.escape=function(t){return(t+"").replace(nt,it)},st.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},st.uniqueSort=function(t){var e,n=[],i=0,a=0;if(h=!r.detectDuplicates,u=!r.sortStable&&t.slice(0),t.sort(T),h){for(;e=t[a++];)e===t[a]&&(i=n.push(a));for(;i--;)t.splice(n[i],1)}return u=null,t},i=st.getText=function(t){var e,r="",n=0,a=t.nodeType;if(a){if(1===a||9===a||11===a){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)r+=i(t)}else if(3===a||4===a)return t.nodeValue}else for(;e=t[n++];)r+=i(e);return r},(n=st.selectors={cacheLength:50,createPseudo:ct,match:Z,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(et,rt),t[3]=(t[3]||t[4]||t[5]||"").replace(et,rt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||st.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&st.error(t[0]),t},PSEUDO:function(t){var e,r=!t[6]&&t[2];return Z.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":r&&q.test(r)&&(e=o(r,!0))&&(e=r.indexOf(")",r.length-e)-r.length)&&(t[0]=t[0].slice(0,e),t[2]=r.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(et,rt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=C[t+" "];return e||(e=new RegExp("(^|"+F+")"+t+"("+F+"|$)"))&&C(t,(function(t){return e.test("string"==typeof t.className&&t.className||void 0!==t.getAttribute&&t.getAttribute("class")||"")}))},ATTR:function(t,e,r){return function(n){var i=st.attr(n,t);return null==i?"!="===e:!e||(i+="","="===e?i===r:"!="===e?i!==r:"^="===e?r&&0===i.indexOf(r):"*="===e?r&&i.indexOf(r)>-1:"$="===e?r&&i.slice(-r.length)===r:"~="===e?(" "+i.replace(Y," ")+" ").indexOf(r)>-1:"|="===e&&(i===r||i.slice(0,r.length+1)===r+"-"))}},CHILD:function(t,e,r,n,i){var a="nth"!==t.slice(0,3),o="last"!==t.slice(-4),s="of-type"===e;return 1===n&&0===i?function(t){return!!t.parentNode}:function(e,r,l){var c,u,h,f,p,d,g=a!==o?"nextSibling":"previousSibling",m=e.parentNode,v=s&&e.nodeName.toLowerCase(),y=!l&&!s,x=!1;if(m){if(a){for(;g;){for(f=e;f=f[g];)if(s?f.nodeName.toLowerCase()===v:1===f.nodeType)return!1;d=g="only"===t&&!d&&"nextSibling"}return!0}if(d=[o?m.firstChild:m.lastChild],o&&y){for(x=(p=(c=(u=(h=(f=m)[b]||(f[b]={}))[f.uniqueID]||(h[f.uniqueID]={}))[t]||[])[0]===w&&c[1])&&c[2],f=p&&m.childNodes[p];f=++p&&f&&f[g]||(x=p=0)||d.pop();)if(1===f.nodeType&&++x&&f===e){u[t]=[w,p,x];break}}else if(y&&(x=p=(c=(u=(h=(f=e)[b]||(f[b]={}))[f.uniqueID]||(h[f.uniqueID]={}))[t]||[])[0]===w&&c[1]),!1===x)for(;(f=++p&&f&&f[g]||(x=p=0)||d.pop())&&((s?f.nodeName.toLowerCase()!==v:1!==f.nodeType)||!++x||(y&&((u=(h=f[b]||(f[b]={}))[f.uniqueID]||(h[f.uniqueID]={}))[t]=[w,x]),f!==e)););return(x-=i)===n||x%n==0&&x/n>=0}}},PSEUDO:function(t,e){var r,i=n.pseudos[t]||n.setFilters[t.toLowerCase()]||st.error("unsupported pseudo: "+t);return i[b]?i(e):i.length>1?(r=[t,t,"",e],n.setFilters.hasOwnProperty(t.toLowerCase())?ct((function(t,r){for(var n,a=i(t,e),o=a.length;o--;)t[n=z(t,a[o])]=!(r[n]=a[o])})):function(t){return i(t,0,r)}):i}},pseudos:{not:ct((function(t){var e=[],r=[],n=s(t.replace(V,"$1"));return n[b]?ct((function(t,e,r,i){for(var a,o=n(t,null,i,[]),s=t.length;s--;)(a=o[s])&&(t[s]=!(e[s]=a))})):function(t,i,a){return e[0]=t,n(e,null,a,r),e[0]=null,!r.pop()}})),has:ct((function(t){return function(e){return st(t,e).length>0}})),contains:ct((function(t){return t=t.replace(et,rt),function(e){return(e.textContent||i(e)).indexOf(t)>-1}})),lang:ct((function(t){return W.test(t||"")||st.error("unsupported lang: "+t),t=t.replace(et,rt).toLowerCase(),function(e){var r;do{if(r=g?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(r=r.toLowerCase())===t||0===r.indexOf(t+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}})),target:function(e){var r=t.location&&t.location.hash;return r&&r.slice(1)===e.id},root:function(t){return t===d},focus:function(t){return t===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:gt(!1),disabled:gt(!0),checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!n.pseudos.empty(t)},header:function(t){return K.test(t.nodeName)},input:function(t){return J.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:mt((function(){return[0]})),last:mt((function(t,e){return[e-1]})),eq:mt((function(t,e,r){return[r<0?r+e:r]})),even:mt((function(t,e){for(var r=0;re?e:r;--n>=0;)t.push(n);return t})),gt:mt((function(t,e,r){for(var n=r<0?r+e:r;++n1?function(e,r,n){for(var i=t.length;i--;)if(!t[i](e,r,n))return!1;return!0}:t[0]}function wt(t,e,r,n,i){for(var a,o=[],s=0,l=t.length,c=null!=e;s-1&&(a[c]=!(o[c]=h))}}else v=wt(v===o?v.splice(d,v.length):v),i?i(null,o,v,l):P.apply(o,v)}))}function Ct(t){for(var e,r,i,a=t.length,o=n.relative[t[0].type],s=o||n.relative[" "],l=o?1:0,u=bt((function(t){return t===e}),s,!0),h=bt((function(t){return z(e,t)>-1}),s,!0),f=[function(t,r,n){var i=!o&&(n||r!==c)||((e=r).nodeType?u(t,r,n):h(t,r,n));return e=null,i}];l1&&_t(f),l>1&&xt(t.slice(0,l-1).concat({value:" "===t[l-2].type?"*":""})).replace(V,"$1"),r,l0,i=t.length>0,a=function(a,o,s,l,u){var h,d,m,v=0,y="0",x=a&&[],b=[],_=c,A=a||i&&n.find.TAG("*",u),C=w+=null==_?1:Math.random()||.1,M=A.length;for(u&&(c=o===p||o||u);y!==M&&null!=(h=A[y]);y++){if(i&&h){for(d=0,o||h.ownerDocument===p||(f(h),s=!g);m=t[d++];)if(m(h,o||p,s)){l.push(h);break}u&&(w=C)}r&&((h=!m&&h)&&v--,a&&x.push(h))}if(v+=y,r&&y!==v){for(d=0;m=e[d++];)m(x,b,o,s);if(a){if(v>0)for(;y--;)x[y]||b[y]||(b[y]=E.call(l));b=wt(b)}P.apply(l,b),u&&!a&&b.length>0&&v+e.length>1&&st.uniqueSort(l)}return u&&(w=C,c=_),x};return r?ct(a):a}(a,i))).selector=t}return s},l=st.select=function(t,e,r,i){var a,l,c,u,h,f="function"==typeof t&&t,p=!i&&o(t=f.selector||t);if(r=r||[],1===p.length){if((l=p[0]=p[0].slice(0)).length>2&&"ID"===(c=l[0]).type&&9===e.nodeType&&g&&n.relative[l[1].type]){if(!(e=(n.find.ID(c.matches[0].replace(et,rt),e)||[])[0]))return r;f&&(e=e.parentNode),t=t.slice(l.shift().value.length)}for(a=Z.needsContext.test(t)?0:l.length;a--&&(c=l[a],!n.relative[u=c.type]);)if((h=n.find[u])&&(i=h(c.matches[0].replace(et,rt),tt.test(l[0].type)&&vt(e.parentNode)||e))){if(l.splice(a,1),!(t=i.length&&xt(l)))return P.apply(r,i),r;break}}return(f||s(t,p))(i,e,!g,r,!e||tt.test(t)&&vt(e.parentNode)||e),r},r.sortStable=b.split("").sort(T).join("")===b,r.detectDuplicates=!!h,f(),r.sortDetached=ut((function(t){return 1&t.compareDocumentPosition(p.createElement("fieldset"))})),ut((function(t){return t.innerHTML="","#"===t.firstChild.getAttribute("href")}))||ht("type|href|height|width",(function(t,e,r){if(!r)return t.getAttribute(e,"type"===e.toLowerCase()?1:2)})),r.attributes&&ut((function(t){return t.innerHTML="",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")}))||ht("value",(function(t,e,r){if(!r&&"input"===t.nodeName.toLowerCase())return t.defaultValue})),ut((function(t){return null==t.getAttribute("disabled")}))||ht(R,(function(t,e,r){var n;if(!r)return!0===t[e]?e.toLowerCase():(n=t.getAttributeNode(e))&&n.specified?n.value:null})),st}(r);A.find=k,A.expr=k.selectors,A.expr[":"]=A.expr.pseudos,A.uniqueSort=A.unique=k.uniqueSort,A.text=k.getText,A.isXMLDoc=k.isXML,A.contains=k.contains,A.escapeSelector=k.escape;var I=function(t,e,r){for(var n=[],i=void 0!==r;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(i&&A(t).is(r))break;n.push(t)}return n},T=function(t,e){for(var r=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&r.push(t);return r},L=A.expr.match.needsContext;function S(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()}var E=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function D(t,e,r){return y(e)?A.grep(t,(function(t,n){return!!e.call(t,n,t)!==r})):e.nodeType?A.grep(t,(function(t){return t===e!==r})):"string"!=typeof e?A.grep(t,(function(t){return h.call(e,t)>-1!==r})):A.filter(e,t,r)}A.filter=function(t,e,r){var n=e[0];return r&&(t=":not("+t+")"),1===e.length&&1===n.nodeType?A.find.matchesSelector(n,t)?[n]:[]:A.find.matches(t,A.grep(e,(function(t){return 1===t.nodeType})))},A.fn.extend({find:function(t){var e,r,n=this.length,i=this;if("string"!=typeof t)return this.pushStack(A(t).filter((function(){for(e=0;e1?A.uniqueSort(r):r},filter:function(t){return this.pushStack(D(this,t||[],!1))},not:function(t){return this.pushStack(D(this,t||[],!0))},is:function(t){return!!D(this,"string"==typeof t&&L.test(t)?A(t):t||[],!1).length}});var P,O=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(A.fn.init=function(t,e,r){var n,i;if(!t)return this;if(r=r||P,"string"==typeof t){if(!(n="<"===t[0]&&">"===t[t.length-1]&&t.length>=3?[null,t,null]:O.exec(t))||!n[1]&&e)return!e||e.jquery?(e||r).find(t):this.constructor(e).find(t);if(n[1]){if(e=e instanceof A?e[0]:e,A.merge(this,A.parseHTML(n[1],e&&e.nodeType?e.ownerDocument||e:o,!0)),E.test(n[1])&&A.isPlainObject(e))for(n in e)y(this[n])?this[n](e[n]):this.attr(n,e[n]);return this}return(i=o.getElementById(n[2]))&&(this[0]=i,this.length=1),this}return t.nodeType?(this[0]=t,this.length=1,this):y(t)?void 0!==r.ready?r.ready(t):t(A):A.makeArray(t,this)}).prototype=A.fn,P=A(o);var z=/^(?:parents|prev(?:Until|All))/,R={children:!0,contents:!0,next:!0,prev:!0};function F(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}A.fn.extend({has:function(t){var e=A(t,this),r=e.length;return this.filter((function(){for(var t=0;t-1:1===r.nodeType&&A.find.matchesSelector(r,t))){a.push(r);break}return this.pushStack(a.length>1?A.uniqueSort(a):a)},index:function(t){return t?"string"==typeof t?h.call(A(t),this[0]):h.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(A.uniqueSort(A.merge(this.get(),A(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),A.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return I(t,"parentNode")},parentsUntil:function(t,e,r){return I(t,"parentNode",r)},next:function(t){return F(t,"nextSibling")},prev:function(t){return F(t,"previousSibling")},nextAll:function(t){return I(t,"nextSibling")},prevAll:function(t){return I(t,"previousSibling")},nextUntil:function(t,e,r){return I(t,"nextSibling",r)},prevUntil:function(t,e,r){return I(t,"previousSibling",r)},siblings:function(t){return T((t.parentNode||{}).firstChild,t)},children:function(t){return T(t.firstChild)},contents:function(t){return void 0!==t.contentDocument?t.contentDocument:(S(t,"template")&&(t=t.content||t),A.merge([],t.childNodes))}},(function(t,e){A.fn[t]=function(r,n){var i=A.map(this,e,r);return"Until"!==t.slice(-5)&&(n=r),n&&"string"==typeof n&&(i=A.filter(n,i)),this.length>1&&(R[t]||A.uniqueSort(i),z.test(t)&&i.reverse()),this.pushStack(i)}}));var N=/[^\x20\t\r\n\f]+/g;function j(t){return t}function B(t){throw t}function Y(t,e,r,n){var i;try{t&&y(i=t.promise)?i.call(t).done(e).fail(r):t&&y(i=t.then)?i.call(t,e,r):e.apply(void 0,[t].slice(n))}catch(t){r.apply(void 0,[t])}}A.Callbacks=function(t){t="string"==typeof t?function(t){var e={};return A.each(t.match(N)||[],(function(t,r){e[r]=!0})),e}(t):A.extend({},t);var e,r,n,i,a=[],o=[],s=-1,l=function(){for(i=i||t.once,n=e=!0;o.length;s=-1)for(r=o.shift();++s-1;)a.splice(r,1),r<=s&&s--})),this},has:function(t){return t?A.inArray(t,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return i=o=[],a=r="",this},disabled:function(){return!a},lock:function(){return i=o=[],r||e||(a=r=""),this},locked:function(){return!!i},fireWith:function(t,r){return i||(r=[t,(r=r||[]).slice?r.slice():r],o.push(r),e||l()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!n}};return c},A.extend({Deferred:function(t){var e=[["notify","progress",A.Callbacks("memory"),A.Callbacks("memory"),2],["resolve","done",A.Callbacks("once memory"),A.Callbacks("once memory"),0,"resolved"],["reject","fail",A.Callbacks("once memory"),A.Callbacks("once memory"),1,"rejected"]],n="pending",i={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(t){return i.then(null,t)},pipe:function(){var t=arguments;return A.Deferred((function(r){A.each(e,(function(e,n){var i=y(t[n[4]])&&t[n[4]];a[n[1]]((function(){var t=i&&i.apply(this,arguments);t&&y(t.promise)?t.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[n[0]+"With"](this,i?[t]:arguments)}))})),t=null})).promise()},then:function(t,n,i){var a=0;function o(t,e,n,i){return function(){var s=this,l=arguments,c=function(){var r,c;if(!(t=a&&(n!==B&&(s=void 0,l=[r]),e.rejectWith(s,l))}};t?u():(A.Deferred.getStackHook&&(u.stackTrace=A.Deferred.getStackHook()),r.setTimeout(u))}}return A.Deferred((function(r){e[0][3].add(o(0,r,y(i)?i:j,r.notifyWith)),e[1][3].add(o(0,r,y(t)?t:j)),e[2][3].add(o(0,r,y(n)?n:B))})).promise()},promise:function(t){return null!=t?A.extend(t,i):i}},a={};return A.each(e,(function(t,r){var o=r[2],s=r[5];i[r[1]]=o.add,s&&o.add((function(){n=s}),e[3-t][2].disable,e[3-t][3].disable,e[0][2].lock,e[0][3].lock),o.add(r[3].fire),a[r[0]]=function(){return a[r[0]+"With"](this===a?void 0:this,arguments),this},a[r[0]+"With"]=o.fireWith})),i.promise(a),t&&t.call(a,a),a},when:function(t){var e=arguments.length,r=e,n=Array(r),i=l.call(arguments),a=A.Deferred(),o=function(t){return function(r){n[t]=this,i[t]=arguments.length>1?l.call(arguments):r,--e||a.resolveWith(n,i)}};if(e<=1&&(Y(t,a.done(o(r)).resolve,a.reject,!e),"pending"===a.state()||y(i[r]&&i[r].then)))return a.then();for(;r--;)Y(i[r],o(r),a.reject);return a.promise()}});var V=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;A.Deferred.exceptionHook=function(t,e){r.console&&r.console.warn&&t&&V.test(t.name)&&r.console.warn("jQuery.Deferred exception: "+t.message,t.stack,e)},A.readyException=function(t){r.setTimeout((function(){throw t}))};var U=A.Deferred();function H(){o.removeEventListener("DOMContentLoaded",H),r.removeEventListener("load",H),A.ready()}A.fn.ready=function(t){return U.then(t).catch((function(t){A.readyException(t)})),this},A.extend({isReady:!1,readyWait:1,ready:function(t){(!0===t?--A.readyWait:A.isReady)||(A.isReady=!0,!0!==t&&--A.readyWait>0||U.resolveWith(o,[A]))}}),A.ready.then=U.then,"complete"===o.readyState||"loading"!==o.readyState&&!o.documentElement.doScroll?r.setTimeout(A.ready):(o.addEventListener("DOMContentLoaded",H),r.addEventListener("load",H));var G=function(t,e,r,n,i,a,o){var s=0,l=t.length,c=null==r;if("object"===w(r))for(s in i=!0,r)G(t,e,s,r[s],!0,a,o);else if(void 0!==n&&(i=!0,y(n)||(o=!0),c&&(o?(e.call(t,n),e=null):(c=e,e=function(t,e,r){return c.call(A(t),r)})),e))for(;s1,null,!0)},removeData:function(t){return this.each((function(){$.remove(this,t)}))}}),A.extend({queue:function(t,e,r){var n;if(t)return e=(e||"fx")+"queue",n=Q.get(t,e),r&&(!n||Array.isArray(r)?n=Q.access(t,e,A.makeArray(r)):n.push(r)),n||[]},dequeue:function(t,e){e=e||"fx";var r=A.queue(t,e),n=r.length,i=r.shift(),a=A._queueHooks(t,e);"inprogress"===i&&(i=r.shift(),n--),i&&("fx"===e&&r.unshift("inprogress"),delete a.stop,i.call(t,(function(){A.dequeue(t,e)}),a)),!n&&a&&a.empty.fire()},_queueHooks:function(t,e){var r=e+"queueHooks";return Q.get(t,r)||Q.access(t,r,{empty:A.Callbacks("once memory").add((function(){Q.remove(t,[e+"queue",r])}))})}}),A.fn.extend({queue:function(t,e){var r=2;return"string"!=typeof t&&(e=t,t="fx",r--),arguments.length\x20\t\r\n\f]*)/i,vt=/^$|^module$|\/(?:java|ecma)script/i,yt={option:[1,""],thead:[1,"
",r,"headercss",this.headerCellClass).append(this.renderTemplate(r.headerTemplate,r)).appendTo(t);this.sorting&&r.sorting&&i.addClass(this.sortableClass).on("click",e.proxy((function(){this.sort(n)}),this))})),t},_prepareCell:function(t,r,n,i){return e(t).css("width",r.width).addClass(i||this.cellClass).addClass(n&&r[n]||r.css).addClass(r.align?"jsgrid-align-"+r.align:"")},_createFilterRow:function(){if(e.isFunction(this.filterRowRenderer))return e(this.renderTemplate(this.filterRowRenderer,this));var t=e("
",e,"filtercss").append(this.renderTemplate(e.filterTemplate,e)).appendTo(t)})),t},_createInsertRow:function(){if(e.isFunction(this.insertRowRenderer))return e(this.renderTemplate(this.insertRowRenderer,this));var t=e("
",e,"insertcss").append(this.renderTemplate(e.insertTemplate,e)).appendTo(t)})),t},_callEventHandler:function(t,r){return t.call(this,e.extend(r,{grid:this})),r},reset:function(){return this._resetSorting(),this._resetPager(),this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1,this._setPage(1)},_resetSorting:function(){this._sortField=null,this._sortOrder=a,this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing),this.cancelEdit(),this._refreshHeading(),this._refreshFiltering(),this._refreshInserting(),this._refreshContent(),this._refreshPager(),this._refreshSize(),this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var t=this._content;if(t.empty(),!this.data.length)return t.append(this._createNoDataRow()),this;for(var e=this._loadStrategy.firstDisplayIndex(),r=this._loadStrategy.lastDisplayIndex(),n=e;n").addClass(this.noDataRowClass).append(e("").addClass(this.cellClass).attr("colspan",t).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(t,r){var n;return e.isFunction(this.rowRenderer)?n=this.renderTemplate(this.rowRenderer,this,{item:t,itemIndex:r}):(n=e("
").append(this.renderTemplate(r.itemTemplate||i,r,a)),this._prepareCell(n,r)},_getItemFieldValue:function(t,e){for(var r=e.name.split("."),n=t[r.shift()];n&&r.length;)n=n[r.shift()];return n},_setItemFieldValue:function(t,e,r){for(var n=e.name.split("."),i=t,a=n[0];i&&n.length;)i=(t=i)[a=n.shift()];if(!i)for(;n.length;)t=t[a]={},a=n.shift();t[a]=r},sort:function(t,r){return e.isPlainObject(t)&&(r=t.order,t=t.field),this._clearSortingCss(),this._setSortingParams(t,r),this._setSortingCss(),this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDescClass)},_setSortingParams:function(t,e){t=this._normalizeField(t),e=e||(this._sortField===t?this._reversedSortOrder(this._sortOrder):a),this._sortField=t,this._sortOrder=e},_normalizeField:function(t){return e.isNumeric(t)?this.fields[t]:"string"==typeof t?e.grep(this.fields,(function(e){return e.name===t}))[0]:t},_reversedSortOrder:function(t){return t===a?"desc":a},_setSortingCss:function(){var t=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(t).addClass(this._sortOrder===a?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(t){return e.inArray(t,e.grep(this.fields,(function(t){return t.visible})))},_sortData:function(){var t=this._sortFactor(),e=this._sortField;e&&this.data.sort((function(r,n){return t*e.sortingFunc(r[e.name],n[e.name])}))},_sortFactor:function(){return this._sortOrder===a?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var t=this._itemsCount(),e=this.pageSize;return Math.floor(t/e)+(t%e?1:0)},_refreshPager:function(){var t=this._pagerContainer;t.empty(),this.paging&&t.append(this._createPager());var e=this.paging&&this._pagesCount()>1;t.toggle(e)},_createPager:function(){var t;return(t=e.isFunction(this.pagerRenderer)?e(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):e("
").append(this._createPagerByFormat())).addClass(this.pagerClass),t},_createPagerByFormat:function(){var t=this.pageIndex,r=this._pagesCount(),n=this._itemsCount(),i=this.pagerFormat.split(" ");return e.map(i,e.proxy((function(i){var a=i;return"{pages}"===i?a=this._createPages():"{first}"===i?a=this._createPagerNavButton(this.pageFirstText,1,t>1):"{prev}"===i?a=this._createPagerNavButton(this.pagePrevText,t-1,t>1):"{next}"===i?a=this._createPagerNavButton(this.pageNextText,t+1,t1&&n.push(this._createPagerPageNavButton(this.pageNavigatorPrevText,this.showPrevPages));for(var i=0,a=r;i").attr("href","javascript:void(0);").html(t).on("click",e.proxy(n,this));return e("").addClass(r).append(i)},_createPagerCurrentPage:function(){return e("").addClass(this.pageClass).addClass(this.currentPageClass).text(this.pageIndex)},_refreshSize:function(){this._refreshHeight(),this._refreshWidth()},_refreshWidth:function(){var t="auto"===this.width?this._getAutoWidth():this.width;this._container.width(t)},_getAutoWidth:function(){var t=this._headerGrid,e=this._header;t.width("auto");var r=t.outerWidth(),n=e.outerWidth()-e.innerWidth();return t.width(""),r+n},_scrollBarWidth:function(){if(void 0===n){var t=e("
"),r=e("
");t.append(r).appendTo("body");var i=r.innerWidth();t.css("overflow-y","auto");var a=r.innerWidth();t.remove(),n=i-a}return n},_refreshHeight:function(){var t,e=this._container,r=this._pagerContainer,n=this.height;e.height(n),"auto"!==n&&(n=e.height(),t=this._header.outerHeight(!0),r.parents(e).length&&(t+=r.outerHeight(!0)),this._body.outerHeight(n-t))},showPrevPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount;this._firstDisplayingPage=t>e?t-e:1,this._refreshPager()},showNextPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount,r=this._pagesCount();this._firstDisplayingPage=t+2*e>r?r-e+1:t+e,this._refreshPager()},openPage:function(t){t<1||t>this._pagesCount()||(this._setPage(t),this._loadStrategy.openPage(t))},_setPage:function(t){var e=this._firstDisplayingPage,r=this.pageButtonCount;this.pageIndex=t,te+r-1&&(this._firstDisplayingPage=t-r+1),this._callEventHandler(this.onPageChanged,{pageIndex:t})},_controllerCall:function(t,r,n,i){if(n)return e.Deferred().reject().promise();this._showLoading();var a,o,s=this._controller;if(!s||!s[t])throw Error("controller has no method '"+t+"'");return(a=s[t](r),o=e.Deferred(),a&&a.then?a.then((function(){o.resolve.apply(o,arguments)}),(function(){o.reject.apply(o,arguments)})):o.resolve(a),o.promise()).done(e.proxy(i,this)).fail(e.proxy(this._errorHandler,this)).always(e.proxy(this._hideLoading,this))},_errorHandler:function(){this._callEventHandler(this.onError,{args:e.makeArray(arguments)})},_showLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(e.proxy((function(){this._loadIndicator.show()}),this),this.loadIndicationDelay))},_hideLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadIndicator.hide())},search:function(t){return this._resetSorting(),this._resetPager(),this.loadData(t)},loadData:function(t){t=t||(this.filtering?this.getFilter():{}),e.extend(t,this._loadStrategy.loadParams(),this._sortingParams());var r=this._callEventHandler(this.onDataLoading,{filter:t});return this._controllerCall("loadData",t,r.cancel,(function(t){t&&(this._loadStrategy.finishLoad(t),this._callEventHandler(this.onDataLoaded,{data:t}))}))},getFilter:function(){var t={};return this._eachField((function(e){e.filtering&&this._setItemFieldValue(t,e,e.filterValue())})),t},_sortingParams:function(){return this.sorting&&this._sortField?{sortField:this._sortField.name,sortOrder:this._sortOrder}:{}},getSorting:function(){var t=this._sortingParams();return{field:t.sortField,order:t.sortOrder}},clearFilter:function(){var t=this._createFilterRow();return this._filterRow.replaceWith(t),this._filterRow=t,this.search()},insertItem:function(t){var r=t||this._getValidatedInsertItem();if(!r)return e.Deferred().reject().promise();var n=this._callEventHandler(this.onItemInserting,{item:r});return this._controllerCall("insertItem",r,n.cancel,(function(t){t=t||r,this._loadStrategy.finishInsert(t),this._callEventHandler(this.onItemInserted,{item:t})}))},_getValidatedInsertItem:function(){var t=this._getInsertItem();return this._validateItem(t,this._insertRow)?t:null},_getInsertItem:function(){var t={};return this._eachField((function(e){e.inserting&&this._setItemFieldValue(t,e,e.insertValue())})),t},_validateItem:function(t,r){var n=[],i={item:t,itemIndex:this._rowIndex(r),row:r};if(this._eachField((function(a){if(a.validate&&(r!==this._insertRow||a.inserting)&&(r!==this._getEditRow()||a.editing)){var o=this._getItemFieldValue(t,a),s=this._validation.validate(e.extend({value:o,rules:a.validate},i));this._setCellValidity(r.children().eq(this._visibleFieldIndex(a)),s),s.length&&n.push.apply(n,e.map(s,(function(t){return{field:a,message:t}})))}})),!n.length)return!0;var a=e.extend({errors:n},i);return this._callEventHandler(this.onItemInvalid,a),this.invalidNotify(a),!1},_setCellValidity:function(t,e){t.toggleClass(this.invalidClass,!!e.length).attr("title",e.join("\n"))},clearInsert:function(){var t=this._createInsertRow();this._insertRow.replaceWith(t),this._insertRow=t,this.refresh()},editItem:function(t){var e=this.rowByItem(t);e.length&&this._editRow(e)},rowByItem:function(t){return t.jquery||t.nodeType?e(t):this._content.find("tr").filter((function(){return e.data(this,"JSGridItem")===t}))},_editRow:function(t){if(this.editing){var e=t.data("JSGridItem");if(!this._callEventHandler(this.onItemEditing,{row:t,item:e,itemIndex:this._itemIndex(e)}).cancel){this._editingRow&&this.cancelEdit();var r=this._createEditRow(e);this._editingRow=t,t.hide(),r.insertBefore(t),t.data("JSGridEditRow",r)}}},_createEditRow:function(t){if(e.isFunction(this.editRowRenderer))return e(this.renderTemplate(this.editRowRenderer,this,{item:t,itemIndex:this._itemIndex(t)}));var r=e("
",e,"editcss").append(this.renderTemplate(e.editTemplate||"",e,{value:n,item:t})).appendTo(r)})),r},updateItem:function(t,e){1===arguments.length&&(e=t);var r=t?this.rowByItem(t):this._editingRow;if(e=e||this._getValidatedEditedItem())return this._updateRow(r,e)},_getValidatedEditedItem:function(){var t=this._getEditedItem();return this._validateItem(t,this._getEditRow())?t:null},_updateRow:function(t,r){var n=t.data("JSGridItem"),i=this._itemIndex(n),a=e.extend(!0,{},n,r),o=this._callEventHandler(this.onItemUpdating,{row:t,item:a,itemIndex:i,previousItem:n});return this._controllerCall("updateItem",a,o.cancel,(function(o){var s=e.extend(!0,{},n);a=o||e.extend(!0,n,r);var l=this._finishUpdate(t,a,i);this._callEventHandler(this.onItemUpdated,{row:l,item:a,itemIndex:i,previousItem:s})}))},_rowIndex:function(t){return this._content.children().index(e(t))},_itemIndex:function(t){return e.inArray(t,this.data)},_finishUpdate:function(t,e,r){this.cancelEdit(),this.data[r]=e;var n=this._createRow(e,r);return t.replaceWith(n),n},_getEditedItem:function(){var t={};return this._eachField((function(e){e.editing&&this._setItemFieldValue(t,e,e.editValue())})),t},cancelEdit:function(){this._editingRow&&(this._getEditRow().remove(),this._editingRow.show(),this._editingRow=null)},_getEditRow:function(){return this._editingRow&&this._editingRow.data("JSGridEditRow")},deleteItem:function(e){var r=this.rowByItem(e);if(r.length&&(!this.confirmDeleting||t.confirm(o(this.deleteConfirm,this,r.data("JSGridItem")))))return this._deleteRow(r)},_deleteRow:function(t){var e=t.data("JSGridItem"),r=this._itemIndex(e),n=this._callEventHandler(this.onItemDeleting,{row:t,item:e,itemIndex:r});return this._controllerCall("deleteItem",e,n.cancel,(function(){this._loadStrategy.finishDelete(e,r),this._callEventHandler(this.onItemDeleted,{row:t,item:e,itemIndex:r})}))}},e.fn.jsGrid=function(t){var r=e.makeArray(arguments),n=r.slice(1),a=this;return this.each((function(){var r,o=e(this),s=o.data(i);if(s)if("string"==typeof t){if(void 0!==(r=s[t].apply(s,n))&&r!==s)return a=r,!1}else s._detachWindowResizeCallback(),s._init(t),s.render();else new l(o,t)})),a};var c={},u={},h=function(t,r){e.each(r,(function(r,n){e.isPlainObject(n)?h(t[r]||t[r[0].toUpperCase()+r.slice(1)],n):t.hasOwnProperty(r)?t[r]=n:t.prototype[r]=n}))};t.jsGrid={Grid:l,fields:c,setDefaults:function(t){var r;e.isPlainObject(t)?r=l.prototype:(r=c[t].prototype,t=arguments[1]||{}),e.extend(r,t)},locales:u,locale:function(t){var r=e.isPlainObject(t)?t:u[t];if(!r)throw Error("unknown locale "+t);h(jsGrid,r)},version:"1.5.3"}}(window,t),function(t,e,r){function n(t){this._init(t)}n.prototype={container:"body",message:"Loading...",shading:!0,zIndex:1e3,shaderClass:"jsgrid-load-shader",loadPanelClass:"jsgrid-load-panel",_init:function(t){e.extend(!0,this,t),this._initContainer(),this._initShader(),this._initLoadPanel()},_initContainer:function(){this._container=e(this.container)},_initShader:function(){this.shading&&(this._shader=e("
").addClass(this.shaderClass).hide().css({position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:this.zIndex}).appendTo(this._container))},_initLoadPanel:function(){this._loadPanel=e("
").addClass(this.loadPanelClass).text(this.message).hide().css({position:"absolute",top:"50%",left:"50%",zIndex:this.zIndex}).appendTo(this._container)},show:function(){var t=this._loadPanel.show(),e=t.outerWidth(),r=t.outerHeight();t.css({marginTop:-r/2,marginLeft:-e/2}),this._shader.show()},hide:function(){this._loadPanel.hide(),this._shader.hide()}},t.LoadIndicator=n}(jsGrid,t),function(t,e,r){function n(t){this._grid=t}function i(t){this._grid=t,this._itemsCount=0}n.prototype={firstDisplayIndex:function(){var t=this._grid;return t.option("paging")?(t.option("pageIndex")-1)*t.option("pageSize"):0},lastDisplayIndex:function(){var t=this._grid,e=t.option("data").length;return t.option("paging")?Math.min(t.option("pageIndex")*t.option("pageSize"),e):e},itemsCount:function(){return this._grid.option("data").length},openPage:function(t){this._grid.refresh()},loadParams:function(){return{}},sort:function(){return this._grid._sortData(),this._grid.refresh(),e.Deferred().resolve().promise()},reset:function(){return this._grid.refresh(),e.Deferred().resolve().promise()},finishLoad:function(t){this._grid.option("data",t)},finishInsert:function(t){var e=this._grid;e.option("data").push(t),e.refresh()},finishDelete:function(t,e){var r=this._grid;r.option("data").splice(e,1),r.reset()}},i.prototype={firstDisplayIndex:function(){return 0},lastDisplayIndex:function(){return this._grid.option("data").length},itemsCount:function(){return this._itemsCount},openPage:function(t){this._grid.loadData()},loadParams:function(){var t=this._grid;return{pageIndex:t.option("pageIndex"),pageSize:t.option("pageSize")}},reset:function(){return this._grid.loadData()},sort:function(){return this._grid.loadData()},finishLoad:function(t){this._itemsCount=t.itemsCount,this._grid.option("data",t.data)},finishInsert:function(t){this._grid.search()},finishDelete:function(t,e){this._grid.search()}},t.loadStrategies={DirectLoadingStrategy:n,PageLoadingStrategy:i}}(jsGrid,t),function(t,e,r){var n=function(t){return null!=t},i={string:function(t,e){return n(t)||n(e)?n(t)?n(e)?(""+t).localeCompare(""+e):1:-1:0},number:function(t,e){return t-e},date:function(t,e){return t-e},numberAsString:function(t,e){return parseFloat(t)-parseFloat(e)}};t.sortStrategies=i}(jsGrid),function(t,e,r){function n(t){this._init(t)}n.prototype={_init:function(t){e.extend(!0,this,t)},validate:function(t){var r=[];return e.each(this._normalizeRules(t.rules),(function(n,i){if(!i.validator(t.value,t.item,i.param)){var a=e.isFunction(i.message)?i.message(t.value,t.item):i.message;r.push(a)}})),r},_normalizeRules:function(t){return e.isArray(t)||(t=[t]),e.map(t,e.proxy((function(t){return this._normalizeRule(t)}),this))},_normalizeRule:function(t){if("string"==typeof t&&(t={validator:t}),e.isFunction(t)&&(t={validator:t}),!e.isPlainObject(t))throw Error("wrong validation config specified");return t=e.extend({},t),e.isFunction(t.validator)?t:this._applyNamedValidator(t,t.validator)},_applyNamedValidator:function(t,r){delete t.validator;var n=i[r];if(!n)throw Error('unknown validator "'+r+'"');return e.isFunction(n)&&(n={validator:n}),e.extend({},n,t)}},t.Validation=n;var i={required:{message:"Field is required",validator:function(t){return null!=t&&""!==t}},rangeLength:{message:"Field value length is out of the defined range",validator:function(t,e,r){return t.length>=r[0]&&t.length<=r[1]}},minLength:{message:"Field value is too short",validator:function(t,e,r){return t.length>=r}},maxLength:{message:"Field value is too long",validator:function(t,e,r){return t.length<=r}},pattern:{message:"Field value is not matching the defined pattern",validator:function(t,e,r){return"string"==typeof r&&(r=new RegExp("^(?:"+r+")$")),r.test(t)}},range:{message:"Field value is out of the defined range",validator:function(t,e,r){return t>=r[0]&&t<=r[1]}},min:{message:"Field value is too small",validator:function(t,e,r){return t>=r}},max:{message:"Field value is too large",validator:function(t,e,r){return t<=r}}};t.validators=i}(jsGrid,t),function(t,e,r){function n(t){e.extend(!0,this,t),this.sortingFunc=this._getSortingFunc()}n.prototype={name:"",title:null,css:"",align:"",width:100,visible:!0,filtering:!0,inserting:!0,editing:!0,sorting:!0,sorter:"string",headerTemplate:function(){return void 0===this.title||null===this.title?this.name:this.title},itemTemplate:function(t,e){return t},filterTemplate:function(){return""},insertTemplate:function(){return""},editTemplate:function(t,e){return this._value=t,this.itemTemplate(t,e)},filterValue:function(){return""},insertValue:function(){return""},editValue:function(){return this._value},_getSortingFunc:function(){var r=this.sorter;if(e.isFunction(r))return r;if("string"==typeof r)return t.sortStrategies[r];throw Error('wrong sorter for the field "'+this.name+'"!')}},t.Field=n}(jsGrid,t),function(t,e,r){var n=t.Field;function i(t){n.call(this,t)}i.prototype=new n({autosearch:!0,readOnly:!1,filterTemplate:function(){if(!this.filtering)return"";var t=this._grid,e=this.filterControl=this._createTextBox();return this.autosearch&&e.on("keypress",(function(e){13===e.which&&(t.search(),e.preventDefault())})),e},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createTextBox();return e.val(t),e},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return e("").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.text=t.TextField=i}(jsGrid,t),function(t,e,r){var n=t.TextField;function i(t){n.call(this,t)}i.prototype=new n({sorter:"number",align:"right",readOnly:!1,filterValue:function(){return this.filterControl.val()?parseInt(this.filterControl.val()||0,10):void 0},insertValue:function(){return this.insertControl.val()?parseInt(this.insertControl.val()||0,10):void 0},editValue:function(){return this.editControl.val()?parseInt(this.editControl.val()||0,10):void 0},_createTextBox:function(){return e("").attr("type","number").prop("readonly",!!this.readOnly)}}),t.fields.number=t.NumberField=i}(jsGrid,t),function(t,e,r){var n=t.TextField;function i(t){n.call(this,t)}i.prototype=new n({insertTemplate:function(){return this.inserting?this.insertControl=this._createTextArea():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createTextArea();return e.val(t),e},_createTextArea:function(){return e("\n
\n \n
\n \n ';return r.append(n),!0}return!1},renderGraph:function(t,e,r,n){if(r){i.use(o.a);for(var a=[],s=0,l=Object.entries(r.datasource_nodes);s'+c+"");r=r?h.insertAfter(r):h.appendTo(t),n.set(c,h.get(0))}}return n},l=function(t){return["Completed","Canceled","Failed"].indexOf(t)>=0},c=u(t).find("#"+r.run_id).find("#computeTargetStatusContainer");if(!l(r.status)&&n&&n.allocation_state&&"resizing"===n.allocation_state.toLowerCase()){var h=c.find("#computeTargetState"),f=n.allocation_state;n.target_node_count&&(f+=" - "+n.current_node_count+"/"+n.target_node_count),h.text(f),c.show()}else c.hide();var p=u(t).find("#"+r.run_id).find("#computeTargetNodeStatusContainer");if(u(t).find("#"+r.run_id).find("#jobStatus").html(Ct.statusColTemplate(r.status)),n&&n.node_state_counts&&p.length>0&&!l(r.status)&&s.map(n.node_state_counts).filter((function(t){return t>0})).length>0){p.show();var d=p.find("#computeTargetNodeStatus");if(d.length>0){var g=n.node_state_counts,m={};for(var v in g)g.hasOwnProperty(v)&&0!==g[v]&&(m[v.split("NodeCount")[0]]=g[v]);bt.pieChart(d[0],m,{colorMap:{idle:"#2ca33e",leaving:"blue",preparing:"#cfbd1d",running:"blue",unusable:"red"},labelColor:"white",labelPosition:"inside"})}}else p.hide();var y=Mt(s.get(r,"ProblemInfoJsonString","{}")),x=s.get(y,"subsampling",!1),_=u(t).find("#"+r.run_id).find("#samplingContainer");x?_.text(r.training_percent):_.hide(),u(t).find("#"+r.run_id).find("#startTime").text(i.toLocaleDateString()+" "+i.toLocaleTimeString()),u(t).find("#"+r.run_id).find("#duration").text(a),u(t).find("#"+r.run_id).find("#runId").text(r.run_id?r.run_id:"N/A"),u(t).find("#"+r.run_id).find("#arguments").text(r.arguments?r.arguments:"N/A");var w=u(t).find("#"+r.run_id).find("#logSelectorContainer"),A=r.log_groups;if(A){for(var C=w.find("#logSelector"),M=w.find("input[type='checkbox'][name='autoSwitch']").is(":checked"),k=0,I=C.toArray();k=0?T.options.item(T.selectedIndex).value:null,D=o(T,s.flatten(A)).size>L&&E&&!s.last(A).includes(E);if(A.length>0&&(S||!E||M&&D)){var P=e.model,O=s.first(s.last(A));u(T).val(O).trigger("change"),P.set&&(P.set("selected_run_log",O),M&&b("AutoSwitch_LogSelector"),e.touch())}}w.show()}else w.hide()},renderError:function(t,e){e&&t.length>0?(u(t[0]).text(e),u(t[0]).show()):t.hide()},cleanFinalState:function(t){t.find(".progress").each((function(e,r){u(r).find(".progress-bar").hide(),u(t).find("."+u(r).attr("type")+"-related").hide(),u(r).find(".no-value").show()}))},popupElement:function(t,e){if("popup"===s.get(e,"display"))return window.setTimeout((function(){var e=u(t),r=e.find("#runId").text();e.iziModal({title:r,width:e.width(),padding:20,appendTo:"body",arrowKeys:!1,closeOnEscape:!0,closeButton:!0,focusInput:!1,onOpened:function(){var t=u(".iziModal");t.attr("aria-label","selected run is displayed in popup, you can press escape button to close window").attr("tabindex","2").attr("role","dialog");var e=t.find("select, input, button, a:not(.iziModal-button)").filter(":visible"),r=e.first(),n=e.last();r.focus(),n.on("keydown",(function(t){9!==t.which||t.shiftKey||(t.preventDefault(),r.focus())})),r.on("keydown",(function(t){9===t.which&&t.shiftKey&&(t.preventDefault(),n.focus())}))}}),e.iziModal("open")}))},safeParseJson:Mt,getHashCode:function(t){var e,r=0;if(!t||0===t.length)return r;for(e=0;e0&&this.model&&this.model.set){var r=u(e).attr("run_id");this.model.set("selected_run_id",r),this.touch(),this.model.set("selected_run_id",""),b("Click_Grid",{selected_run_id:r}),this.touch()}},e.prototype.handleTabClick=function(t){t.preventDefault();var e=u(t.target);e.siblings().removeClass("activeTab"),e.addClass("activeTab");var r=e[0].id+"-related";this.$el.find(".nav-tab-content").each((function(t,e){var n=u(e);n.hasClass(r)?n.show():n.hide()})),this.touch()},e.prototype.handleLogSelectorClick=function(t){t.preventDefault(),this.model.set&&(this.model.set("selected_run_log",u(t.target).val()),this.model.set("run_logs","Your job is submitted in Azure cloud and we are monitoring to get logs..."),b("Click_LogSelector"),this.touch())},e.prototype.events=function(){return{'click table[class="jsgrid-table"] tr':"handleGridClick","change #logSelector":"handleLogSelectorClick","click #charts":"handleTabClick","click #metrics":"handleTabClick","click #transformation":"handleTabClick"}},e.prototype.sendHeartbeat=function(){var t=(new Date).getTime()/1e3|0;this.model.set(_t.HEARTBEAT,t),this.model.save_changes()},e.prototype.remove=function(){t.prototype.remove.call(this),clearInterval(this.heartbeatInterval)},e}(n.DOMWidgetView),Pt=function(){function t(t){this.element=t}return t.prototype.getStatusColor=function(t){switch(t){case"dataType":return"#e5e5e5";case"operation":return"#e4d6f0";case"model":default:return"#e2f2d0"}},t.prototype.getLabelName=function(t){return t.name},t.prototype.renderContainer=function(){var t=this.element.find("#graphContainer");return u('
').appendTo(t)[0]},t}(),Ot=function(){function t(t,e,r){this.element=t,this.context=e,this.widgetSettings=r}return t.prototype.initRender=function(){0===this.element.find(".progress").length&&(this.element.append(It.template.progressTemplate("widget")),It.popupElement(this.element,this.widgetSettings))},t.prototype.renderBaseHTML=function(t,e){if(this.element.find(".progress").remove(),It.renderBaseHTML(this.element,t)){var r=t.toLowerCase().startsWith("automl_");r&&It.renderTabs(this.element,["Charts","Metrics","Transformation"]);var n=this.element.find("#"+t);n.find(".table-details").append('
Arguments
N/A
'+t.name+"
"+t.series[0].data[0]+"
Max concurrent runs'+It.strRetrieving+'
Max total runs'+It.strRetrieving+"
End Time'+It.strRetrieving+"
Job Queue Timeout Seconds'+It.strRetrieving+'
Cluster Coordination Timeout Seconds'+It.strRetrieving+'
Arguments
N/A
'+t.name+"
"+t.series[0].data[0]+"
","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function xt(t,e){var r;return r=void 0!==t.getElementsByTagName?t.getElementsByTagName(e||"*"):void 0!==t.querySelectorAll?t.querySelectorAll(e||"*"):[],void 0===e||e&&S(t,e)?A.merge([t],r):r}function bt(t,e){for(var r=0,n=t.length;r-1)i&&i.push(a);else if(c=st(a),o=xt(h.appendChild(a),"script"),c&&bt(o),r)for(u=0;a=o[u++];)vt.test(a.type||"")&&r.push(a);return h}_t=o.createDocumentFragment().appendChild(o.createElement("div")),(wt=o.createElement("input")).setAttribute("type","radio"),wt.setAttribute("checked","checked"),wt.setAttribute("name","t"),_t.appendChild(wt),v.checkClone=_t.cloneNode(!0).cloneNode(!0).lastChild.checked,_t.innerHTML="",v.noCloneChecked=!!_t.cloneNode(!0).lastChild.defaultValue;var Mt=/^key/,kt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,It=/^([^.]*)(?:\.(.+)|)/;function Tt(){return!0}function Lt(){return!1}function St(t,e){return t===function(){try{return o.activeElement}catch(t){}}()==("focus"===e)}function Et(t,e,r,n,i,a){var o,s;if("object"==typeof e){for(s in"string"!=typeof r&&(n=n||r,r=void 0),e)Et(t,s,r,n,e[s],a);return t}if(null==n&&null==i?(i=r,n=r=void 0):null==i&&("string"==typeof r?(i=n,n=void 0):(i=n,n=r,r=void 0)),!1===i)i=Lt;else if(!i)return t;return 1===a&&(o=i,(i=function(t){return A().off(t),o.apply(this,arguments)}).guid=o.guid||(o.guid=A.guid++)),t.each((function(){A.event.add(this,e,i,n,r)}))}function Dt(t,e,r){r?(Q.set(t,e,!1),A.event.add(t,e,{namespace:!1,handler:function(t){var n,i,a=Q.get(this,e);if(1&t.isTrigger&&this[e]){if(a.length)(A.event.special[e]||{}).delegateType&&t.stopPropagation();else if(a=l.call(arguments),Q.set(this,e,a),n=r(this,e),this[e](),a!==(i=Q.get(this,e))||n?Q.set(this,e,!1):i={},a!==i)return t.stopImmediatePropagation(),t.preventDefault(),i.value}else a.length&&(Q.set(this,e,{value:A.event.trigger(A.extend(a[0],A.Event.prototype),a.slice(1),this)}),t.stopImmediatePropagation())}})):void 0===Q.get(t,e)&&A.event.add(t,e,Tt)}A.event={global:{},add:function(t,e,r,n,i){var a,o,s,l,c,u,h,f,p,d,g,m=Q.get(t);if(m)for(r.handler&&(r=(a=r).handler,i=a.selector),i&&A.find.matchesSelector(ot,i),r.guid||(r.guid=A.guid++),(l=m.events)||(l=m.events={}),(o=m.handle)||(o=m.handle=function(e){return void 0!==A&&A.event.triggered!==e.type?A.event.dispatch.apply(t,arguments):void 0}),c=(e=(e||"").match(N)||[""]).length;c--;)p=g=(s=It.exec(e[c])||[])[1],d=(s[2]||"").split(".").sort(),p&&(h=A.event.special[p]||{},p=(i?h.delegateType:h.bindType)||p,h=A.event.special[p]||{},u=A.extend({type:p,origType:g,data:n,handler:r,guid:r.guid,selector:i,needsContext:i&&A.expr.match.needsContext.test(i),namespace:d.join(".")},a),(f=l[p])||((f=l[p]=[]).delegateCount=0,h.setup&&!1!==h.setup.call(t,n,d,o)||t.addEventListener&&t.addEventListener(p,o)),h.add&&(h.add.call(t,u),u.handler.guid||(u.handler.guid=r.guid)),i?f.splice(f.delegateCount++,0,u):f.push(u),A.event.global[p]=!0)},remove:function(t,e,r,n,i){var a,o,s,l,c,u,h,f,p,d,g,m=Q.hasData(t)&&Q.get(t);if(m&&(l=m.events)){for(c=(e=(e||"").match(N)||[""]).length;c--;)if(p=g=(s=It.exec(e[c])||[])[1],d=(s[2]||"").split(".").sort(),p){for(h=A.event.special[p]||{},f=l[p=(n?h.delegateType:h.bindType)||p]||[],s=s[2]&&new RegExp("(^|\\.)"+d.join("\\.(?:.*\\.|)")+"(\\.|$)"),o=a=f.length;a--;)u=f[a],!i&&g!==u.origType||r&&r.guid!==u.guid||s&&!s.test(u.namespace)||n&&n!==u.selector&&("**"!==n||!u.selector)||(f.splice(a,1),u.selector&&f.delegateCount--,h.remove&&h.remove.call(t,u));o&&!f.length&&(h.teardown&&!1!==h.teardown.call(t,d,m.handle)||A.removeEvent(t,p,m.handle),delete l[p])}else for(p in l)A.event.remove(t,p+e[c],r,n,!0);A.isEmptyObject(l)&&Q.remove(t,"handle events")}},dispatch:function(t){var e,r,n,i,a,o,s=A.event.fix(t),l=new Array(arguments.length),c=(Q.get(this,"events")||{})[s.type]||[],u=A.event.special[s.type]||{};for(l[0]=s,e=1;e=1))for(;c!==this;c=c.parentNode||this)if(1===c.nodeType&&("click"!==t.type||!0!==c.disabled)){for(a=[],o={},r=0;r-1:A.find(i,this,null,[c]).length),o[i]&&a.push(n);a.length&&s.push({elem:c,handlers:a})}return c=this,l\x20\t\r\n\f]*)[^>]*)\/>/gi,Ot=/\s*$/g;function Ft(t,e){return S(t,"table")&&S(11!==e.nodeType?e:e.firstChild,"tr")&&A(t).children("tbody")[0]||t}function Nt(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function jt(t){return"true/"===(t.type||"").slice(0,5)?t.type=t.type.slice(5):t.removeAttribute("type"),t}function Bt(t,e){var r,n,i,a,o,s,l,c;if(1===e.nodeType){if(Q.hasData(t)&&(a=Q.access(t),o=Q.set(e,a),c=a.events))for(i in delete o.handle,o.events={},c)for(r=0,n=c[i].length;r1&&"string"==typeof d&&!v.checkClone&&zt.test(d))return t.each((function(i){var a=t.eq(i);g&&(e[0]=d.call(this,i,a.html())),Vt(a,e,r,n)}));if(f&&(a=(i=Ct(e,t[0].ownerDocument,!1,t,n)).firstChild,1===i.childNodes.length&&(i=a),a||n)){for(s=(o=A.map(xt(i,"script"),Nt)).length;h")},clone:function(t,e,r){var n,i,a,o,s=t.cloneNode(!0),l=st(t);if(!(v.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||A.isXMLDoc(t)))for(o=xt(s),n=0,i=(a=xt(t)).length;n0&&bt(o,!l&&xt(t,"script")),s},cleanData:function(t){for(var e,r,n,i=A.event.special,a=0;void 0!==(r=t[a]);a++)if(J(r)){if(e=r[Q.expando]){if(e.events)for(n in e.events)i[n]?A.event.remove(r,n):A.removeEvent(r,n,e.handle);r[Q.expando]=void 0}r[$.expando]&&(r[$.expando]=void 0)}}}),A.fn.extend({detach:function(t){return Ut(this,t,!0)},remove:function(t){return Ut(this,t)},text:function(t){return G(this,(function(t){return void 0===t?A.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)}))}),null,t,arguments.length)},append:function(){return Vt(this,arguments,(function(t){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Ft(this,t).appendChild(t)}))},prepend:function(){return Vt(this,arguments,(function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=Ft(this,t);e.insertBefore(t,e.firstChild)}}))},before:function(){return Vt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this)}))},after:function(){return Vt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)}))},empty:function(){for(var t,e=0;null!=(t=this[e]);e++)1===t.nodeType&&(A.cleanData(xt(t,!1)),t.textContent="");return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map((function(){return A.clone(this,t,e)}))},html:function(t){return G(this,(function(t){var e=this[0]||{},r=0,n=this.length;if(void 0===t&&1===e.nodeType)return e.innerHTML;if("string"==typeof t&&!Ot.test(t)&&!yt[(mt.exec(t)||["",""])[1].toLowerCase()]){t=A.htmlPrefilter(t);try{for(;r=0&&(l+=Math.max(0,Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-a-l-s-.5))||0),l}function ae(t,e,r){var n=Gt(t),i=(!v.boxSizingReliable()||r)&&"border-box"===A.css(t,"boxSizing",!1,n),a=i,o=Wt(t,e,n),s="offset"+e[0].toUpperCase()+e.slice(1);if(Ht.test(o)){if(!r)return o;o="auto"}return(!v.boxSizingReliable()&&i||"auto"===o||!parseFloat(o)&&"inline"===A.css(t,"display",!1,n))&&t.getClientRects().length&&(i="border-box"===A.css(t,"boxSizing",!1,n),(a=s in t)&&(o=t[s])),(o=parseFloat(o)||0)+ie(t,e,r||(i?"border":"content"),a,n,o)+"px"}function oe(t,e,r,n,i){return new oe.prototype.init(t,e,r,n,i)}A.extend({cssHooks:{opacity:{get:function(t,e){if(e){var r=Wt(t,"opacity");return""===r?"1":r}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(t,e,r,n){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var i,a,o,s=X(e),l=te.test(e),c=t.style;if(l||(e=Qt(s)),o=A.cssHooks[e]||A.cssHooks[s],void 0===r)return o&&"get"in o&&void 0!==(i=o.get(t,!1,n))?i:c[e];"string"===(a=typeof r)&&(i=it.exec(r))&&i[1]&&(r=ht(t,e,i),a="number"),null!=r&&r==r&&("number"!==a||l||(r+=i&&i[3]||(A.cssNumber[s]?"":"px")),v.clearCloneStyle||""!==r||0!==e.indexOf("background")||(c[e]="inherit"),o&&"set"in o&&void 0===(r=o.set(t,r,n))||(l?c.setProperty(e,r):c[e]=r))}},css:function(t,e,r,n){var i,a,o,s=X(e);return te.test(e)||(e=Qt(s)),(o=A.cssHooks[e]||A.cssHooks[s])&&"get"in o&&(i=o.get(t,!0,r)),void 0===i&&(i=Wt(t,e,n)),"normal"===i&&e in re&&(i=re[e]),""===r||r?(a=parseFloat(i),!0===r||isFinite(a)?a||0:i):i}}),A.each(["height","width"],(function(t,e){A.cssHooks[e]={get:function(t,r,n){if(r)return!$t.test(A.css(t,"display"))||t.getClientRects().length&&t.getBoundingClientRect().width?ae(t,e,n):ut(t,ee,(function(){return ae(t,e,n)}))},set:function(t,r,n){var i,a=Gt(t),o=!v.scrollboxSize()&&"absolute"===a.position,s=(o||n)&&"border-box"===A.css(t,"boxSizing",!1,a),l=n?ie(t,e,n,s,a):0;return s&&o&&(l-=Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-parseFloat(a[e])-ie(t,e,"border",!1,a)-.5)),l&&(i=it.exec(r))&&"px"!==(i[3]||"px")&&(t.style[e]=r,r=A.css(t,e)),ne(0,r,l)}}})),A.cssHooks.marginLeft=Zt(v.reliableMarginLeft,(function(t,e){if(e)return(parseFloat(Wt(t,"marginLeft"))||t.getBoundingClientRect().left-ut(t,{marginLeft:0},(function(){return t.getBoundingClientRect().left})))+"px"})),A.each({margin:"",padding:"",border:"Width"},(function(t,e){A.cssHooks[t+e]={expand:function(r){for(var n=0,i={},a="string"==typeof r?r.split(" "):[r];n<4;n++)i[t+at[n]+e]=a[n]||a[n-2]||a[0];return i}},"margin"!==t&&(A.cssHooks[t+e].set=ne)})),A.fn.extend({css:function(t,e){return G(this,(function(t,e,r){var n,i,a={},o=0;if(Array.isArray(e)){for(n=Gt(t),i=e.length;o1)}}),A.Tween=oe,oe.prototype={constructor:oe,init:function(t,e,r,n,i,a){this.elem=t,this.prop=r,this.easing=i||A.easing._default,this.options=e,this.start=this.now=this.cur(),this.end=n,this.unit=a||(A.cssNumber[r]?"":"px")},cur:function(){var t=oe.propHooks[this.prop];return t&&t.get?t.get(this):oe.propHooks._default.get(this)},run:function(t){var e,r=oe.propHooks[this.prop];return this.options.duration?this.pos=e=A.easing[this.easing](t,this.options.duration*t,0,1,this.options.duration):this.pos=e=t,this.now=(this.end-this.start)*e+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),r&&r.set?r.set(this):oe.propHooks._default.set(this),this}},oe.prototype.init.prototype=oe.prototype,oe.propHooks={_default:{get:function(t){var e;return 1!==t.elem.nodeType||null!=t.elem[t.prop]&&null==t.elem.style[t.prop]?t.elem[t.prop]:(e=A.css(t.elem,t.prop,""))&&"auto"!==e?e:0},set:function(t){A.fx.step[t.prop]?A.fx.step[t.prop](t):1!==t.elem.nodeType||!A.cssHooks[t.prop]&&null==t.elem.style[Qt(t.prop)]?t.elem[t.prop]=t.now:A.style(t.elem,t.prop,t.now+t.unit)}}},oe.propHooks.scrollTop=oe.propHooks.scrollLeft={set:function(t){t.elem.nodeType&&t.elem.parentNode&&(t.elem[t.prop]=t.now)}},A.easing={linear:function(t){return t},swing:function(t){return.5-Math.cos(t*Math.PI)/2},_default:"swing"},A.fx=oe.prototype.init,A.fx.step={};var se,le,ce=/^(?:toggle|show|hide)$/,ue=/queueHooks$/;function he(){le&&(!1===o.hidden&&r.requestAnimationFrame?r.requestAnimationFrame(he):r.setTimeout(he,A.fx.interval),A.fx.tick())}function fe(){return r.setTimeout((function(){se=void 0})),se=Date.now()}function pe(t,e){var r,n=0,i={height:t};for(e=e?1:0;n<4;n+=2-e)i["margin"+(r=at[n])]=i["padding"+r]=t;return e&&(i.opacity=i.width=t),i}function de(t,e,r){for(var n,i=(ge.tweeners[e]||[]).concat(ge.tweeners["*"]),a=0,o=i.length;a1)},removeAttr:function(t){return this.each((function(){A.removeAttr(this,t)}))}}),A.extend({attr:function(t,e,r){var n,i,a=t.nodeType;if(3!==a&&8!==a&&2!==a)return void 0===t.getAttribute?A.prop(t,e,r):(1===a&&A.isXMLDoc(t)||(i=A.attrHooks[e.toLowerCase()]||(A.expr.match.bool.test(e)?me:void 0)),void 0!==r?null===r?void A.removeAttr(t,e):i&&"set"in i&&void 0!==(n=i.set(t,r,e))?n:(t.setAttribute(e,r+""),r):i&&"get"in i&&null!==(n=i.get(t,e))?n:null==(n=A.find.attr(t,e))?void 0:n)},attrHooks:{type:{set:function(t,e){if(!v.radioValue&&"radio"===e&&S(t,"input")){var r=t.value;return t.setAttribute("type",e),r&&(t.value=r),e}}}},removeAttr:function(t,e){var r,n=0,i=e&&e.match(N);if(i&&1===t.nodeType)for(;r=i[n++];)t.removeAttribute(r)}}),me={set:function(t,e,r){return!1===e?A.removeAttr(t,r):t.setAttribute(r,r),r}},A.each(A.expr.match.bool.source.match(/\w+/g),(function(t,e){var r=ve[e]||A.find.attr;ve[e]=function(t,e,n){var i,a,o=e.toLowerCase();return n||(a=ve[o],ve[o]=i,i=null!=r(t,e,n)?o:null,ve[o]=a),i}}));var ye=/^(?:input|select|textarea|button)$/i,xe=/^(?:a|area)$/i;function be(t){return(t.match(N)||[]).join(" ")}function _e(t){return t.getAttribute&&t.getAttribute("class")||""}function we(t){return Array.isArray(t)?t:"string"==typeof t&&t.match(N)||[]}A.fn.extend({prop:function(t,e){return G(this,A.prop,t,e,arguments.length>1)},removeProp:function(t){return this.each((function(){delete this[A.propFix[t]||t]}))}}),A.extend({prop:function(t,e,r){var n,i,a=t.nodeType;if(3!==a&&8!==a&&2!==a)return 1===a&&A.isXMLDoc(t)||(e=A.propFix[e]||e,i=A.propHooks[e]),void 0!==r?i&&"set"in i&&void 0!==(n=i.set(t,r,e))?n:t[e]=r:i&&"get"in i&&null!==(n=i.get(t,e))?n:t[e]},propHooks:{tabIndex:{get:function(t){var e=A.find.attr(t,"tabindex");return e?parseInt(e,10):ye.test(t.nodeName)||xe.test(t.nodeName)&&t.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),v.optSelected||(A.propHooks.selected={get:function(t){var e=t.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null},set:function(t){var e=t.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),A.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){A.propFix[this.toLowerCase()]=this})),A.fn.extend({addClass:function(t){var e,r,n,i,a,o,s,l=0;if(y(t))return this.each((function(e){A(this).addClass(t.call(this,e,_e(this)))}));if((e=we(t)).length)for(;r=this[l++];)if(i=_e(r),n=1===r.nodeType&&" "+be(i)+" "){for(o=0;a=e[o++];)n.indexOf(" "+a+" ")<0&&(n+=a+" ");i!==(s=be(n))&&r.setAttribute("class",s)}return this},removeClass:function(t){var e,r,n,i,a,o,s,l=0;if(y(t))return this.each((function(e){A(this).removeClass(t.call(this,e,_e(this)))}));if(!arguments.length)return this.attr("class","");if((e=we(t)).length)for(;r=this[l++];)if(i=_e(r),n=1===r.nodeType&&" "+be(i)+" "){for(o=0;a=e[o++];)for(;n.indexOf(" "+a+" ")>-1;)n=n.replace(" "+a+" "," ");i!==(s=be(n))&&r.setAttribute("class",s)}return this},toggleClass:function(t,e){var r=typeof t,n="string"===r||Array.isArray(t);return"boolean"==typeof e&&n?e?this.addClass(t):this.removeClass(t):y(t)?this.each((function(r){A(this).toggleClass(t.call(this,r,_e(this),e),e)})):this.each((function(){var e,i,a,o;if(n)for(i=0,a=A(this),o=we(t);e=o[i++];)a.hasClass(e)?a.removeClass(e):a.addClass(e);else void 0!==t&&"boolean"!==r||((e=_e(this))&&Q.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===t?"":Q.get(this,"__className__")||""))}))},hasClass:function(t){var e,r,n=0;for(e=" "+t+" ";r=this[n++];)if(1===r.nodeType&&(" "+be(_e(r))+" ").indexOf(e)>-1)return!0;return!1}});var Ae=/\r/g;A.fn.extend({val:function(t){var e,r,n,i=this[0];return arguments.length?(n=y(t),this.each((function(r){var i;1===this.nodeType&&(null==(i=n?t.call(this,r,A(this).val()):t)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=A.map(i,(function(t){return null==t?"":t+""}))),(e=A.valHooks[this.type]||A.valHooks[this.nodeName.toLowerCase()])&&"set"in e&&void 0!==e.set(this,i,"value")||(this.value=i))}))):i?(e=A.valHooks[i.type]||A.valHooks[i.nodeName.toLowerCase()])&&"get"in e&&void 0!==(r=e.get(i,"value"))?r:"string"==typeof(r=i.value)?r.replace(Ae,""):null==r?"":r:void 0}}),A.extend({valHooks:{option:{get:function(t){var e=A.find.attr(t,"value");return null!=e?e:be(A.text(t))}},select:{get:function(t){var e,r,n,i=t.options,a=t.selectedIndex,o="select-one"===t.type,s=o?null:[],l=o?a+1:i.length;for(n=a<0?l:o?a:0;n-1)&&(r=!0);return r||(t.selectedIndex=-1),a}}}}),A.each(["radio","checkbox"],(function(){A.valHooks[this]={set:function(t,e){if(Array.isArray(e))return t.checked=A.inArray(A(t).val(),e)>-1}},v.checkOn||(A.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})})),v.focusin="onfocusin"in r;var Ce=/^(?:focusinfocus|focusoutblur)$/,Me=function(t){t.stopPropagation()};A.extend(A.event,{trigger:function(t,e,n,i){var a,s,l,c,u,h,f,p,g=[n||o],m=d.call(t,"type")?t.type:t,v=d.call(t,"namespace")?t.namespace.split("."):[];if(s=p=l=n=n||o,3!==n.nodeType&&8!==n.nodeType&&!Ce.test(m+A.event.triggered)&&(m.indexOf(".")>-1&&(v=m.split("."),m=v.shift(),v.sort()),u=m.indexOf(":")<0&&"on"+m,(t=t[A.expando]?t:new A.Event(m,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=v.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+v.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=n),e=null==e?[t]:A.makeArray(e,[t]),f=A.event.special[m]||{},i||!f.trigger||!1!==f.trigger.apply(n,e))){if(!i&&!f.noBubble&&!x(n)){for(c=f.delegateType||m,Ce.test(c+m)||(s=s.parentNode);s;s=s.parentNode)g.push(s),l=s;l===(n.ownerDocument||o)&&g.push(l.defaultView||l.parentWindow||r)}for(a=0;(s=g[a++])&&!t.isPropagationStopped();)p=s,t.type=a>1?c:f.bindType||m,(h=(Q.get(s,"events")||{})[t.type]&&Q.get(s,"handle"))&&h.apply(s,e),(h=u&&s[u])&&h.apply&&J(s)&&(t.result=h.apply(s,e),!1===t.result&&t.preventDefault());return t.type=m,i||t.isDefaultPrevented()||f._default&&!1!==f._default.apply(g.pop(),e)||!J(n)||u&&y(n[m])&&!x(n)&&((l=n[u])&&(n[u]=null),A.event.triggered=m,t.isPropagationStopped()&&p.addEventListener(m,Me),n[m](),t.isPropagationStopped()&&p.removeEventListener(m,Me),A.event.triggered=void 0,l&&(n[u]=l)),t.result}},simulate:function(t,e,r){var n=A.extend(new A.Event,r,{type:t,isSimulated:!0});A.event.trigger(n,null,e)}}),A.fn.extend({trigger:function(t,e){return this.each((function(){A.event.trigger(t,e,this)}))},triggerHandler:function(t,e){var r=this[0];if(r)return A.event.trigger(t,e,r,!0)}}),v.focusin||A.each({focus:"focusin",blur:"focusout"},(function(t,e){var r=function(t){A.event.simulate(e,t.target,A.event.fix(t))};A.event.special[e]={setup:function(){var n=this.ownerDocument||this,i=Q.access(n,e);i||n.addEventListener(t,r,!0),Q.access(n,e,(i||0)+1)},teardown:function(){var n=this.ownerDocument||this,i=Q.access(n,e)-1;i?Q.access(n,e,i):(n.removeEventListener(t,r,!0),Q.remove(n,e))}}}));var ke=r.location,Ie=Date.now(),Te=/\?/;A.parseXML=function(t){var e;if(!t||"string"!=typeof t)return null;try{e=(new r.DOMParser).parseFromString(t,"text/xml")}catch(t){e=void 0}return e&&!e.getElementsByTagName("parsererror").length||A.error("Invalid XML: "+t),e};var Le=/\[\]$/,Se=/\r?\n/g,Ee=/^(?:submit|button|image|reset|file)$/i,De=/^(?:input|select|textarea|keygen)/i;function Pe(t,e,r,n){var i;if(Array.isArray(e))A.each(e,(function(e,i){r||Le.test(t)?n(t,i):Pe(t+"["+("object"==typeof i&&null!=i?e:"")+"]",i,r,n)}));else if(r||"object"!==w(e))n(t,e);else for(i in e)Pe(t+"["+i+"]",e[i],r,n)}A.param=function(t,e){var r,n=[],i=function(t,e){var r=y(e)?e():e;n[n.length]=encodeURIComponent(t)+"="+encodeURIComponent(null==r?"":r)};if(null==t)return"";if(Array.isArray(t)||t.jquery&&!A.isPlainObject(t))A.each(t,(function(){i(this.name,this.value)}));else for(r in t)Pe(r,t[r],e,i);return n.join("&")},A.fn.extend({serialize:function(){return A.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var t=A.prop(this,"elements");return t?A.makeArray(t):this})).filter((function(){var t=this.type;return this.name&&!A(this).is(":disabled")&&De.test(this.nodeName)&&!Ee.test(t)&&(this.checked||!gt.test(t))})).map((function(t,e){var r=A(this).val();return null==r?null:Array.isArray(r)?A.map(r,(function(t){return{name:e.name,value:t.replace(Se,"\r\n")}})):{name:e.name,value:r.replace(Se,"\r\n")}})).get()}});var Oe=/%20/g,ze=/#.*$/,Re=/([?&])_=[^&]*/,Fe=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ne=/^(?:GET|HEAD)$/,je=/^\/\//,Be={},Ye={},Ve="*/".concat("*"),Ue=o.createElement("a");function He(t){return function(e,r){"string"!=typeof e&&(r=e,e="*");var n,i=0,a=e.toLowerCase().match(N)||[];if(y(r))for(;n=a[i++];)"+"===n[0]?(n=n.slice(1)||"*",(t[n]=t[n]||[]).unshift(r)):(t[n]=t[n]||[]).push(r)}}function Ge(t,e,r,n){var i={},a=t===Ye;function o(s){var l;return i[s]=!0,A.each(t[s]||[],(function(t,s){var c=s(e,r,n);return"string"!=typeof c||a||i[c]?a?!(l=c):void 0:(e.dataTypes.unshift(c),o(c),!1)})),l}return o(e.dataTypes[0])||!i["*"]&&o("*")}function qe(t,e){var r,n,i=A.ajaxSettings.flatOptions||{};for(r in e)void 0!==e[r]&&((i[r]?t:n||(n={}))[r]=e[r]);return n&&A.extend(!0,t,n),t}Ue.href=ke.href,A.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:ke.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(ke.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ve,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":A.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(t,e){return e?qe(qe(t,A.ajaxSettings),e):qe(A.ajaxSettings,t)},ajaxPrefilter:He(Be),ajaxTransport:He(Ye),ajax:function(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var n,i,a,s,l,c,u,h,f,p,d=A.ajaxSetup({},e),g=d.context||d,m=d.context&&(g.nodeType||g.jquery)?A(g):A.event,v=A.Deferred(),y=A.Callbacks("once memory"),x=d.statusCode||{},b={},_={},w="canceled",C={readyState:0,getResponseHeader:function(t){var e;if(u){if(!s)for(s={};e=Fe.exec(a);)s[e[1].toLowerCase()+" "]=(s[e[1].toLowerCase()+" "]||[]).concat(e[2]);e=s[t.toLowerCase()+" "]}return null==e?null:e.join(", ")},getAllResponseHeaders:function(){return u?a:null},setRequestHeader:function(t,e){return null==u&&(t=_[t.toLowerCase()]=_[t.toLowerCase()]||t,b[t]=e),this},overrideMimeType:function(t){return null==u&&(d.mimeType=t),this},statusCode:function(t){var e;if(t)if(u)C.always(t[C.status]);else for(e in t)x[e]=[x[e],t[e]];return this},abort:function(t){var e=t||w;return n&&n.abort(e),M(0,e),this}};if(v.promise(C),d.url=((t||d.url||ke.href)+"").replace(je,ke.protocol+"//"),d.type=e.method||e.type||d.method||d.type,d.dataTypes=(d.dataType||"*").toLowerCase().match(N)||[""],null==d.crossDomain){c=o.createElement("a");try{c.href=d.url,c.href=c.href,d.crossDomain=Ue.protocol+"//"+Ue.host!=c.protocol+"//"+c.host}catch(t){d.crossDomain=!0}}if(d.data&&d.processData&&"string"!=typeof d.data&&(d.data=A.param(d.data,d.traditional)),Ge(Be,d,e,C),u)return C;for(f in(h=A.event&&d.global)&&0==A.active++&&A.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Ne.test(d.type),i=d.url.replace(ze,""),d.hasContent?d.data&&d.processData&&0===(d.contentType||"").indexOf("application/x-www-form-urlencoded")&&(d.data=d.data.replace(Oe,"+")):(p=d.url.slice(i.length),d.data&&(d.processData||"string"==typeof d.data)&&(i+=(Te.test(i)?"&":"?")+d.data,delete d.data),!1===d.cache&&(i=i.replace(Re,"$1"),p=(Te.test(i)?"&":"?")+"_="+Ie+++p),d.url=i+p),d.ifModified&&(A.lastModified[i]&&C.setRequestHeader("If-Modified-Since",A.lastModified[i]),A.etag[i]&&C.setRequestHeader("If-None-Match",A.etag[i])),(d.data&&d.hasContent&&!1!==d.contentType||e.contentType)&&C.setRequestHeader("Content-Type",d.contentType),C.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+Ve+"; q=0.01":""):d.accepts["*"]),d.headers)C.setRequestHeader(f,d.headers[f]);if(d.beforeSend&&(!1===d.beforeSend.call(g,C,d)||u))return C.abort();if(w="abort",y.add(d.complete),C.done(d.success),C.fail(d.error),n=Ge(Ye,d,e,C)){if(C.readyState=1,h&&m.trigger("ajaxSend",[C,d]),u)return C;d.async&&d.timeout>0&&(l=r.setTimeout((function(){C.abort("timeout")}),d.timeout));try{u=!1,n.send(b,M)}catch(t){if(u)throw t;M(-1,t)}}else M(-1,"No Transport");function M(t,e,o,s){var c,f,p,b,_,w=e;u||(u=!0,l&&r.clearTimeout(l),n=void 0,a=s||"",C.readyState=t>0?4:0,c=t>=200&&t<300||304===t,o&&(b=function(t,e,r){for(var n,i,a,o,s=t.contents,l=t.dataTypes;"*"===l[0];)l.shift(),void 0===n&&(n=t.mimeType||e.getResponseHeader("Content-Type"));if(n)for(i in s)if(s[i]&&s[i].test(n)){l.unshift(i);break}if(l[0]in r)a=l[0];else{for(i in r){if(!l[0]||t.converters[i+" "+l[0]]){a=i;break}o||(o=i)}a=a||o}if(a)return a!==l[0]&&l.unshift(a),r[a]}(d,C,o)),b=function(t,e,r,n){var i,a,o,s,l,c={},u=t.dataTypes.slice();if(u[1])for(o in t.converters)c[o.toLowerCase()]=t.converters[o];for(a=u.shift();a;)if(t.responseFields[a]&&(r[t.responseFields[a]]=e),!l&&n&&t.dataFilter&&(e=t.dataFilter(e,t.dataType)),l=a,a=u.shift())if("*"===a)a=l;else if("*"!==l&&l!==a){if(!(o=c[l+" "+a]||c["* "+a]))for(i in c)if((s=i.split(" "))[1]===a&&(o=c[l+" "+s[0]]||c["* "+s[0]])){!0===o?o=c[i]:!0!==c[i]&&(a=s[0],u.unshift(s[1]));break}if(!0!==o)if(o&&t.throws)e=o(e);else try{e=o(e)}catch(t){return{state:"parsererror",error:o?t:"No conversion from "+l+" to "+a}}}return{state:"success",data:e}}(d,b,C,c),c?(d.ifModified&&((_=C.getResponseHeader("Last-Modified"))&&(A.lastModified[i]=_),(_=C.getResponseHeader("etag"))&&(A.etag[i]=_)),204===t||"HEAD"===d.type?w="nocontent":304===t?w="notmodified":(w=b.state,f=b.data,c=!(p=b.error))):(p=w,!t&&w||(w="error",t<0&&(t=0))),C.status=t,C.statusText=(e||w)+"",c?v.resolveWith(g,[f,w,C]):v.rejectWith(g,[C,w,p]),C.statusCode(x),x=void 0,h&&m.trigger(c?"ajaxSuccess":"ajaxError",[C,d,c?f:p]),y.fireWith(g,[C,w]),h&&(m.trigger("ajaxComplete",[C,d]),--A.active||A.event.trigger("ajaxStop")))}return C},getJSON:function(t,e,r){return A.get(t,e,r,"json")},getScript:function(t,e){return A.get(t,void 0,e,"script")}}),A.each(["get","post"],(function(t,e){A[e]=function(t,r,n,i){return y(r)&&(i=i||n,n=r,r=void 0),A.ajax(A.extend({url:t,type:e,dataType:i,data:r,success:n},A.isPlainObject(t)&&t))}})),A._evalUrl=function(t,e){return A.ajax({url:t,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(t){A.globalEval(t,e)}})},A.fn.extend({wrapAll:function(t){var e;return this[0]&&(y(t)&&(t=t.call(this[0])),e=A(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map((function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t})).append(this)),this},wrapInner:function(t){return y(t)?this.each((function(e){A(this).wrapInner(t.call(this,e))})):this.each((function(){var e=A(this),r=e.contents();r.length?r.wrapAll(t):e.append(t)}))},wrap:function(t){var e=y(t);return this.each((function(r){A(this).wrapAll(e?t.call(this,r):t)}))},unwrap:function(t){return this.parent(t).not("body").each((function(){A(this).replaceWith(this.childNodes)})),this}}),A.expr.pseudos.hidden=function(t){return!A.expr.pseudos.visible(t)},A.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},A.ajaxSettings.xhr=function(){try{return new r.XMLHttpRequest}catch(t){}};var We={0:200,1223:204},Ze=A.ajaxSettings.xhr();v.cors=!!Ze&&"withCredentials"in Ze,v.ajax=Ze=!!Ze,A.ajaxTransport((function(t){var e,n;if(v.cors||Ze&&!t.crossDomain)return{send:function(i,a){var o,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)s[o]=t.xhrFields[o];for(o in t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest"),i)s.setRequestHeader(o,i[o]);e=function(t){return function(){e&&(e=n=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===t?s.abort():"error"===t?"number"!=typeof s.status?a(0,"error"):a(s.status,s.statusText):a(We[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=e(),n=s.onerror=s.ontimeout=e("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&r.setTimeout((function(){e&&n()}))},e=e("abort");try{s.send(t.hasContent&&t.data||null)}catch(t){if(e)throw t}},abort:function(){e&&e()}}})),A.ajaxPrefilter((function(t){t.crossDomain&&(t.contents.script=!1)})),A.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(t){return A.globalEval(t),t}}}),A.ajaxPrefilter("script",(function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET")})),A.ajaxTransport("script",(function(t){var e,r;if(t.crossDomain||t.scriptAttrs)return{send:function(n,i){e=A("