UNPKG

sryd-charts-enterprise

Version:

Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue

1,630 lines (1,628 loc) 3.13 MB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; // node_modules/ag-charts-core/dist/package/main.esm.mjs var __defProp2 = Object.defineProperty; var __export = (target, all) => { for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; var logger_exports = {}; __export(logger_exports, { error: () => error, errorOnce: () => errorOnce, log: () => log, logGroup: () => logGroup, reset: () => reset, table: () => table, warn: () => warn, warnOnce: () => warnOnce }); var doOnceCache = /* @__PURE__ */ new Set(); function log(...logContent) { console.log(...logContent); } function warn(message, ...logContent) { console.warn(`AG Charts - ${message}`, ...logContent); } function error(message, ...logContent) { if (typeof message === "object") { console.error(`AG Charts error`, message, ...logContent); } else { console.error(`AG Charts - ${message}`, ...logContent); } } function table(...logContent) { console.table(...logContent); } function warnOnce(message, ...logContent) { const cacheKey = `Logger.warn: ${message}`; if (doOnceCache.has(cacheKey)) return; warn(message, ...logContent); doOnceCache.add(cacheKey); } function errorOnce(message, ...logContent) { const cacheKey = `Logger.error: ${message}`; if (doOnceCache.has(cacheKey)) return; error(message, ...logContent); doOnceCache.add(cacheKey); } function reset() { doOnceCache.clear(); } function logGroup(name, cb) { console.groupCollapsed(name); try { return cb(); } finally { console.groupEnd(); } } var moduleRegistry_exports = {}; __export(moduleRegistry_exports, { detectChartDefinition: () => detectChartDefinition, getAxisModule: () => getAxisModule, getSeriesModule: () => getSeriesModule, hasModule: () => hasModule, listModulesByType: () => listModulesByType, register: () => register, registerMany: () => registerMany, reset: () => reset2 }); var ModuleType = /* @__PURE__ */ ((ModuleType2) => { ModuleType2["Axis"] = "axis"; ModuleType2["Chart"] = "chart"; ModuleType2["Preset"] = "preset"; ModuleType2["Plugin"] = "plugin"; ModuleType2["Series"] = "series"; return ModuleType2; })(ModuleType || {}); var registeredModules = /* @__PURE__ */ new Map(); function register(definition) { const existingDefinition = registeredModules.get(definition.name); if (existingDefinition && (existingDefinition.enterprise || !definition.enterprise)) { throw new Error(`AG Charts - Module '${definition.name}' already registered`); } registeredModules.set(definition.name, definition); } function registerMany(definitions) { for (const definition of definitions) { register(definition); } } function reset2() { registeredModules.clear(); } function hasModule(moduleName) { return registeredModules.has(moduleName); } function* listModulesByType(moduleType) { for (const definition of registeredModules.values()) { if (definition.type === moduleType) { yield definition; } } } function detectChartDefinition(options) { for (const definition of registeredModules.values()) { if (isChartModule(definition) && definition.detect(options)) { return definition; } } throw new Error( `AG Charts - Unknown chart type; Check options are correctly structured and series types are specified` ); } function getSeriesModule(moduleName) { const definition = registeredModules.get(moduleName); if (isSeriesModule(definition)) { return definition; } } function getAxisModule(moduleName) { const definition = registeredModules.get(moduleName); if (isAxisModule(definition)) { return definition; } } function isChartModule(definition) { return definition?.type === "chart"; } function isAxisModule(definition) { return definition?.type === "axis"; } function isSeriesModule(definition) { return definition?.type === "series"; } var EventEmitter = class { constructor() { this.events = /* @__PURE__ */ new Map(); } /** * Registers an event listener. * @param eventName The event name to listen for. * @param listener The callback to be invoked on the event. * @returns A function to unregister the listener. */ on(eventName, listener) { if (!this.events.has(eventName)) { this.events.set(eventName, /* @__PURE__ */ new Set()); } this.events.get(eventName)?.add(listener); return () => this.off(eventName, listener); } /** * Unregisters an event listener. * @param eventName The event name to stop listening for. * @param listener The callback to be removed. */ off(eventName, listener) { const eventListeners = this.events.get(eventName); if (eventListeners) { eventListeners.delete(listener); if (eventListeners.size === 0) { this.events.delete(eventName); } } } /** * Emits an event to all registered listeners. * @param eventName The name of the event to emit. * @param event The event payload. */ emit(eventName, event) { this.events.get(eventName)?.forEach((callback2) => callback2(event)); } /** * Clears all listeners for a specific event or all events if no event name is provided. * @param eventName (Optional) The name of the event to clear listeners for. If not provided, all listeners for all events are cleared. */ clear(eventName) { if (eventName) { this.events.delete(eventName); } else { this.events.clear(); } } }; function joinFormatted(values, conjunction = "and", format = String, maxItems = Infinity) { if (values.length === 1) { return format(values[0]); } values = values.map(format); const lastValue = values.pop(); if (values.length >= maxItems) { const remainingCount = values.length - (maxItems - 1); return `${values.slice(0, maxItems - 1).join(", ")}, and ${remainingCount} more ${conjunction} ${lastValue}`; } return `${values.join(", ")} ${conjunction} ${lastValue}`; } function stringifyValue(value, maxLength = Infinity) { if (typeof value === "number") { if (isNaN(value)) { return "NaN"; } else if (value === Infinity) { return "Infinity"; } else if (value === -Infinity) { return "-Infinity"; } } const strValue = JSON.stringify(value) ?? typeof value; if (strValue.length > maxLength) { return `${strValue.slice(0, maxLength)}... (+${strValue.length - maxLength} characters)`; } return strValue; } function countLines(text3) { let count = 1; for (let i = 0; i < text3.length; i++) { if (text3.charCodeAt(i) === 10) { count++; } } return count; } function levenshteinDistance(a, b) { if (a === b) return 0; const [shorter, longer] = a.length < b.length ? [a, b] : [b, a]; const m = shorter.length; const n = longer.length; let prevRow = new Array(m + 1).fill(0).map((_, i) => i); let currRow = new Array(m + 1); for (let i = 1; i <= n; i++) { currRow[0] = i; for (let j = 1; j <= m; j++) { const cost = longer[i - 1] === shorter[j - 1] ? 0 : 1; currRow[j] = Math.min( prevRow[j] + 1, // Deletion currRow[j - 1] + 1, // Insertion prevRow[j - 1] + cost // Substitution ); } [prevRow, currRow] = [currRow, prevRow]; } return prevRow[m]; } var verifiedGlobals = {}; if (typeof window !== "undefined") { verifiedGlobals.window = window; } else if (typeof global !== "undefined") { verifiedGlobals.window = global.window; } if (typeof document !== "undefined") { verifiedGlobals.document = document; } else if (typeof global !== "undefined") { verifiedGlobals.document = global.document; } function getDocument(propertyName) { return propertyName ? verifiedGlobals.document?.[propertyName] : verifiedGlobals.document; } function getWindow(propertyName) { return propertyName ? verifiedGlobals.window?.[propertyName] : verifiedGlobals.window; } function setDocument(document2) { verifiedGlobals.document = document2; } function setWindow(window2) { verifiedGlobals.window = window2; } function createElement(tagName, className, style) { const element2 = getDocument().createElement(tagName); if (typeof className === "object") { style = className; className = void 0; } if (className) { for (const name of className.split(" ")) { element2.classList.add(name); } } if (style) { Object.assign(element2.style, style); } return element2; } function createSvgElement(elementName) { return getDocument().createElementNS("http://www.w3.org/2000/svg", elementName); } function downloadUrl(dataUrl, fileName) { const body = getDocument("body"); const element2 = createElement("a", { display: "none" }); element2.href = dataUrl; element2.download = fileName; body.appendChild(element2); element2.click(); setTimeout(() => body.removeChild(element2)); } function parseColor(color2) { const OptionConstructor = getWindow("Option"); const { style } = new OptionConstructor(); style.color = color2; return style.color || null; } function isDefined(val) { return val != null; } function isArray(value) { return Array.isArray(value); } function isBoolean(value) { return typeof value === "boolean"; } function isDate(value) { return value instanceof Date; } function isValidDate(value) { return isDate(value) && !isNaN(Number(value)); } function isRegExp(value) { return value instanceof RegExp; } function isFunction(value) { return typeof value === "function"; } function isObject(value) { return typeof value === "object" && value !== null && !isArray(value); } function isPlainObject(value) { return typeof value === "object" && value !== null && value.constructor?.name === "Object"; } function isString(value) { return typeof value === "string"; } function isNumber(value) { return typeof value === "number"; } function isFiniteNumber(value) { return Number.isFinite(value); } function isHtmlElement(value) { return typeof window !== "undefined" && value instanceof HTMLElement; } function isEnumValue(enumObject, enumValue) { return Object.values(enumObject).includes(enumValue); } function isSymbol(value) { return typeof value === "symbol"; } function isColor(value) { return isString(value) && parseColor(value) != null; } var descriptionSymbol = Symbol("description"); var requiredSymbol = Symbol("required"); var ValidationError = class { constructor(message, path, required2, unknown) { this.message = message; this.path = path; this.required = required2; this.unknown = unknown; } toString() { return this.message; } }; function validate(options, optionsDefs2, path = "") { if (!isObject(options)) { const message = validateMessage(path, options, "an object", true); return { valid: null, errors: [new ValidationError(message, path, true)] }; } const unusedKeys = []; const optionsKeys = new Set(Object.keys(options)); const errors = []; const valid = {}; function extendPath(key) { if (isArray(optionsDefs2)) { return `${path}[${key}]`; } return path ? `${path}.${key}` : key; } for (const key of Object.keys(optionsDefs2)) { const validatorOrDefs = optionsDefs2[key]; const value = options[key]; const required2 = validatorOrDefs[requiredSymbol]; optionsKeys.delete(key); if (typeof value === "undefined") { unusedKeys.push(key); if (!required2) continue; } const keyPath = extendPath(key); if (isFunction(validatorOrDefs)) { const context = { options, path: keyPath }; if (validatorOrDefs(value, context)) { valid[key] = context.result?.valid ?? value; } else if (!context.result) { const message = validateMessage(keyPath, value, validatorOrDefs, required2); errors.push(new ValidationError(message, path, required2)); } if (context.result) { errors.push(...context.result.errors); } } else { const nestedResult = validate(value, validatorOrDefs, keyPath); if (nestedResult.valid != null) { valid[key] = nestedResult.valid; } errors.push(...nestedResult.errors); } } for (const key of optionsKeys) { const value = options[key]; if (typeof value === "undefined") continue; const message = unknownMessage(key, extendPath(key), unusedKeys); errors.push(new ValidationError(message, path, void 0, true)); } return { valid, errors }; } function validateMessage(path, value, validatorOrDefs, required2) { const description = isString(validatorOrDefs) ? validatorOrDefs : validatorOrDefs[descriptionSymbol]; const expecting = description ? `; expecting ${description}` : ""; const prefix = path ? `Option \`${path}\`` : "Value"; return required2 && value == null ? `${prefix} is required and has not been provided${expecting}, ignoring.` : `${prefix} cannot be set to \`${stringifyValue(value, 50)}\`${expecting}, ignoring.`; } function unknownMessage(key, keyPath, unusedKeys) { const match = findSuggestion(key, unusedKeys); const postfix = match ? `; Did you mean \`${match}\`? Ignoring.` : ", ignoring."; return `Unknown option \`${keyPath}\`${postfix}`; } function findSuggestion(value, suggestions, maxDistance = 2) { let smallestDistance = Infinity; const lowerCaseValue = value.toLowerCase(); return suggestions.reduce((res, item) => { const d = levenshteinDistance(lowerCaseValue, item.toLowerCase()); if (smallestDistance > d && d <= maxDistance) { smallestDistance = d; return item; } return res; }, null); } function attachDescription(validatorOrDefs, description) { return Object.assign( isFunction(validatorOrDefs) ? (value, context) => validatorOrDefs(value, context) : { ...validatorOrDefs }, { [descriptionSymbol]: description } ); } function required(validatorOrDefs) { return Object.assign( isFunction(validatorOrDefs) ? (value, context) => validatorOrDefs(value, context) : optionsDefs(validatorOrDefs), { [requiredSymbol]: true, [descriptionSymbol]: validatorOrDefs[descriptionSymbol] } ); } var optionsDefs = (defs, description = "an object") => attachDescription((value, context) => { context.result = validate(value, defs, context.path); return !context.result.errors.some((error2) => error2.required && error2.path === context.path); }, description); var partialDefs = (defs, description = "an object") => attachDescription((value, context) => { context.result = validate(value, defs, context.path); context.result.errors = context.result.errors.filter((error2) => !error2.unknown); return !context.result.errors.some((error2) => error2.required && error2.path === context.path); }, description); var and = (...validators) => attachDescription( (value, context) => validators.every((validator) => { const result = validator(value, context); if (context.result && !result) { delete context.result; } return result; }), validators.map((v) => v[descriptionSymbol]).filter(Boolean).join(" and ") ); var or = (...validators) => attachDescription( (value, context) => validators.some((validator) => { const result = validator(value, context); if (context.result && !result) { delete context.result; } return result; }), validators.map((v) => v[descriptionSymbol]).filter(Boolean).join(" or ") ); var isComparable = (value) => isFiniteNumber(value) || isValidDate(value); var isValidDateValue = (value) => isDate(value) || (isFiniteNumber(value) || isString(value)) && isValidDate(new Date(value)); var array = attachDescription(isArray, "an array"); var boolean = attachDescription(isBoolean, "a boolean"); var callback = attachDescription(isFunction, "a function"); var color = attachDescription(isColor, "a color string"); var date = attachDescription(isValidDateValue, "a date"); var defined = attachDescription(isDefined, "a defined value"); var number = attachDescription(isFiniteNumber, "a number"); var object = attachDescription(isObject, "an object"); var string = attachDescription(isString, "a string"); var arrayLength = (minLength, maxLength = Infinity) => { let message; if (maxLength === Infinity) { message = `an array of at least ${minLength} items`; } else if (minLength === maxLength) { message = `an array of exactly ${minLength} items`; } else if (minLength === 0) { message = `an array of no more than ${maxLength} items`; } else { message = `an array of at least ${minLength} and no more than ${maxLength} items`; } return attachDescription( (value) => isArray(value) && value.length >= minLength && value.length <= maxLength, message ); }; var numberMin = (min, inclusive = true) => attachDescription( (value) => isFiniteNumber(value) && (value > min || inclusive && value === min), `a number greater than ${inclusive ? "or equal to " : ""}${min}` ); var numberRange = (min, max) => attachDescription( (value) => isFiniteNumber(value) && value >= min && value <= max, `a number between ${min} and ${max} inclusive` ); var positiveNumber = numberMin(0); var positiveNumberNonZero = numberMin(0, false); var ratio = numberRange(0, 1); var lessThan = (otherField) => attachDescription( (value, { options }) => !isComparable(value) || !isComparable(options[otherField]) || value < options[otherField], `the value to be less than \`${otherField}\`` ); var greaterThan = (otherField) => attachDescription( (value, { options }) => !isComparable(value) || !isComparable(options[otherField]) || value > options[otherField], `the value to be greater than \`${otherField}\`` ); function union(...allowed) { if (isObject(allowed[0])) { allowed = Object.values(allowed[0]); } const keywords = joinFormatted(allowed, "or", (value) => `'${value}'`); return attachDescription((value) => allowed.includes(value), `a keyword such as ${keywords}`); } var constant = (allowed) => attachDescription((value) => allowed === value, `the value ${JSON.stringify(allowed)}`); var instanceOf = (instanceType, description) => attachDescription((value) => value instanceof instanceType, description ?? `an instance of ${instanceType.name}`); var arrayOf = (validator, description) => attachDescription( (value, context) => isArray(value) && value.every((v) => { const result = validator(v, context); delete context.result; return result; }), description ?? `${validator[descriptionSymbol]} array` ); var arrayOfDefs = (defs, description = "an object array") => attachDescription((value, context) => { if (!isArray(value)) return false; const valid = []; const errors = []; for (let i = 0; i < value.length; i++) { const indexPath = `${context.path}[${i}]`; const result = validate(value[i], defs, indexPath); errors.push(...result.errors); if (!result.errors.some((error2) => error2.required && error2.path === indexPath)) { valid.push(result.valid); } } context.result = { valid, errors }; return true; }, description); var typeUnion = (defs, description = "an object") => { const typeValidator = partialDefs({ type: required(union(...Object.keys(defs))) }); return attachDescription((value, context) => { if (typeValidator(value, context)) { const type = value.type; const typeDefs = { type: required(constant(type)), ...defs[type] }; const result = optionsDefs(typeDefs)(value, context); if (context.result) { for (const error2 of context.result.errors) { error2.message += ` (type="${type}")`; } } return result; } return false; }, description); }; var colorStop = optionsDefs({ color, stop: ratio }, ""); var colorStopsOrderValidator = attachDescription((value) => { let lastStop = -Infinity; for (const item of value) { if (item?.stop != null) { if (item.stop < lastStop) { return false; } lastStop = item.stop; } } return true; }, "color stops to be defined in ascending order"); var gradientColorStops = and(arrayLength(2), and(arrayOf(colorStop), colorStopsOrderValidator)); var gradientBounds = union("axis", "item", "series"); var gradientStrict = typeUnion( { gradient: { // @ts-expect-error undocumented options gradient: union("linear", "radial", "conic"), bounds: gradientBounds, colorStops: required(gradientColorStops), rotation: number, reverse: boolean } }, "a gradient object with color stops" ); var strokeOptionsDef = { stroke: color, strokeWidth: positiveNumber, strokeOpacity: ratio }; var fillGradientDefaults = optionsDefs({ type: required(constant("gradient")), gradient: required(union("linear", "radial", "conic")), bounds: required(gradientBounds), colorStops: required(or(gradientColorStops, and(arrayLength(2), arrayOf(color)))), rotation: required(number), reverse: required(boolean) }); var fillPatternDefaults = optionsDefs({ type: required(constant("pattern")), pattern: required( union( "vertical-lines", "horizontal-lines", "forward-slanted-lines", "backward-slanted-lines", "circles", "squares", "triangles", "diamonds", "stars", "hearts", "crosses" ) ), width: required(positiveNumber), height: required(positiveNumber), fill: required(color), fillOpacity: required(ratio), backgroundFill: required(color), backgroundFillOpacity: required(ratio), padding: required(positiveNumber), rotation: required(number), stroke: required(color), strokeWidth: required(positiveNumber), strokeOpacity: required(ratio) }); var gradientUndocumentedOpts = { // @ts-expect-error undocumented option gradient: union("linear", "radial", "conic"), bounds: gradientBounds, reverse: boolean }; var patternUndocumentedOpts = { // @ts-expect-error undocumented option rotation: number, padding: positiveNumber }; var colorObject = typeUnion( { gradient: { ...gradientUndocumentedOpts, colorStops: gradientColorStops, rotation: number }, pattern: { ...patternUndocumentedOpts, pattern: union( "vertical-lines", "horizontal-lines", "forward-slanted-lines", "backward-slanted-lines", "circles", "squares", "triangles", "diamonds", "stars", "hearts", "crosses" ), width: positiveNumber, height: positiveNumber, fill: color, fillOpacity: ratio, backgroundFill: color, backgroundFillOpacity: ratio, ...strokeOptionsDef } }, "a color object" ); var colorUnion = or(color, colorObject); var fillOptionsDef = { fill: colorUnion, fillOpacity: ratio }; fillOptionsDef.fillGradientDefaults = fillGradientDefaults; fillOptionsDef.fillPatternDefaults = fillPatternDefaults; var lineDashOptionsDef = { lineDash: arrayOf(positiveNumber), lineDashOffset: number }; var fontOptionsDef = { color, fontFamily: string, fontSize: positiveNumber, fontStyle: union("normal", "italic", "oblique"), fontWeight: or(positiveNumber, union("normal", "bold", "bolder", "lighter")) }; function toArray(value) { if (typeof value === "undefined") { return []; } return Array.isArray(value) ? value : [value]; } function unique(array2) { return Array.from(new Set(array2)); } function groupBy(array2, iteratee) { return array2.reduce((result, item) => { const groupKey = iteratee(item); result[groupKey] ?? (result[groupKey] = []); result[groupKey].push(item); return result; }, {}); } function arraysEqual(a, b) { if (a == null || b == null || a.length !== b.length) { return false; } for (let i = 0; i < a.length; i++) { if (Array.isArray(a[i]) && Array.isArray(b[i])) { if (!arraysEqual(a[i], b[i])) { return false; } } else if (a[i] !== b[i]) { return false; } } return true; } function circularSliceArray(data, size, offset4 = 0) { if (data.length === 0) { return []; } const result = []; for (let i = 0; i < size; i++) { result.push(data.at((i + offset4) % data.length)); } return result; } function sortBasedOnArray(baseArray, orderArray) { const orderMap = /* @__PURE__ */ new Map(); orderArray.forEach((item, index) => { orderMap.set(item, index); }); return baseArray.sort((a, b) => { const indexA = orderMap.get(a) ?? Infinity; const indexB = orderMap.get(b) ?? Infinity; return indexA - indexB; }); } function findMaxIndex(min, max, iteratee) { if (min > max) return; let found; while (max >= min) { const index = Math.floor((max + min) / 2); const value = iteratee(index); if (value) { found = index; min = index + 1; } else { max = index - 1; } } return found; } function findMinIndex(min, max, iteratee) { if (min > max) return; let found; while (max >= min) { const index = Math.floor((max + min) / 2); const value = iteratee(index); if (value) { found = index; max = index - 1; } else { min = index + 1; } } return found; } function findMaxValue(min, max, iteratee) { if (min > max) return; let found; while (max >= min) { const index = Math.floor((max + min) / 2); const value = iteratee(index); if (value == null) { max = index - 1; } else { found = value; min = index + 1; } } return found; } function findMinValue(min, max, iteratee) { if (min > max) return; let found; while (max >= min) { const index = Math.floor((max + min) / 2); const value = iteratee(index); if (value == null) { min = index + 1; } else { found = value; max = index - 1; } } return found; } function diffArrays(previous, current) { const size = Math.max(previous.length, current.length); const added = /* @__PURE__ */ new Set(); const removed = /* @__PURE__ */ new Set(); for (let i = 0; i < size; i++) { const prev = previous[i]; const curr = current[i]; if (prev === curr) continue; if (removed.has(curr)) { removed.delete(curr); } else if (curr) { added.add(curr); } if (added.has(prev)) { added.delete(prev); } else if (prev) { removed.add(prev); } } return { changed: added.size > 0 || removed.size > 0, added, removed }; } function debounce(callback2, waitMs = 0, options) { const { leading = false, trailing = true, maxWait = Infinity } = options ?? {}; let timerId; let startTime; if (maxWait < waitMs) { throw new Error("Value of maxWait cannot be lower than waitMs."); } function debounceCallback(...args) { if (leading && !startTime) { startTime = Date.now(); timerId = setTimeout(() => startTime = null, waitMs); callback2(...args); return; } let adjustedWaitMs = waitMs; if (maxWait !== Infinity && startTime) { const elapsedTime = Date.now() - startTime; if (waitMs > maxWait - elapsedTime) { adjustedWaitMs = maxWait - elapsedTime; } } clearTimeout(timerId); startTime ?? (startTime = Date.now()); timerId = setTimeout(() => { startTime = null; if (trailing) { callback2(...args); } }, adjustedWaitMs); } return Object.assign(debounceCallback, { cancel() { clearTimeout(timerId); startTime = null; } }); } function throttle(callback2, waitMs, options) { const { leading = true, trailing = true } = options ?? {}; let timerId; let lastArgs; let shouldWait = false; function timeoutHandler() { if (trailing && lastArgs) { timerId = setTimeout(timeoutHandler, waitMs); callback2(...lastArgs); } else { shouldWait = false; } lastArgs = null; } function throttleCallback(...args) { if (shouldWait) { lastArgs = args; } else { shouldWait = true; timerId = setTimeout(timeoutHandler, waitMs); if (leading) { callback2(...args); } else { lastArgs = args; } } } return Object.assign(throttleCallback, { cancel() { clearTimeout(timerId); shouldWait = false; lastArgs = null; } }); } function* iterate(...iterators) { for (const iterator of iterators) { yield* iterator; } } function toIterable(value) { return value != null && typeof value === "object" && Symbol.iterator in value ? value : [value]; } function first(iterable) { for (const value of iterable) { return value; } throw new Error("AG Charts - no first() value found"); } function* entries(obj) { const resultTuple = [void 0, void 0]; for (const key of Object.keys(obj)) { resultTuple[0] = key; resultTuple[1] = obj[key]; yield resultTuple; } } function clamp(min, value, max) { return Math.min(max, Math.max(min, value)); } function inRange(value, range4, epsilon2 = 1e-10) { return value >= range4[0] - epsilon2 && value <= range4[1] + epsilon2; } function isNumberEqual(a, b, epsilon2 = 1e-10) { return a === b || Math.abs(a - b) < epsilon2; } function isNegative(value) { return Math.sign(value) === -1 || Object.is(value, -0); } function isInteger(value) { return value % 1 === 0; } function roundTo(value, decimals = 2) { const base = 10 ** decimals; return Math.round(value * base) / base; } function modulus(n, m) { return Math.floor(n % m + (n < 0 ? Math.abs(m) : 0)); } function countFractionDigits(value) { if (Math.floor(value) === value) { return 0; } let valueString = String(value); let exponent = 0; if (value < 1e-6 || value >= 1e21) { let exponentString; [valueString, exponentString] = valueString.split("e"); if (exponentString != null) { exponent = Number(exponentString); } } const decimalPlaces2 = valueString.split(".")[1]?.length ?? 0; return Math.max(decimalPlaces2 - exponent, 0); } var formatRegEx = /^(?:(.)?([<>=^]))?([+\-( ])?([$€£¥₣₹#])?(0)?(\d+)?(,)?(?:\.(\d+))?(~)?([%a-z])?$/i; var surroundedRegEx = /^((?:[^#]|#[^{])*)#{([^}]+)}(.*)$/; function isValidNumberFormat(value) { if (!isString(value)) return false; const match = surroundedRegEx.exec(value); return formatRegEx.test(match ? match[2] : value); } function parseNumberFormat(format) { let prefix; let suffix; const surrounded = surroundedRegEx.exec(format); if (surrounded) { [, prefix, format, suffix] = surrounded; } const match = formatRegEx.exec(format); if (!match) { throw new Error(`The number formatter is invalid: ${format}`); } const [, fill, align2, sign, symbol, zero, width2, comma, precision, trim, type] = match; return { fill, align: align2, sign, symbol, zero, width: parseInt(width2), comma, precision: parseInt(precision), trim: Boolean(trim), type, prefix, suffix }; } function createNumberFormatter(format) { const options = typeof format === "string" ? parseNumberFormat(format) : format; const { fill, align: align2, sign = "-", symbol, zero, width: width2, comma, type, prefix = "", suffix = "", precision } = options; let { trim } = options; const precisionIsNaN = precision == null || isNaN(precision); let formatBody; if (!type) { formatBody = decimalTypes["g"]; trim = true; } else if (type in decimalTypes && type in integerTypes) { formatBody = precisionIsNaN ? integerTypes[type] : decimalTypes[type]; } else if (type in decimalTypes) { formatBody = decimalTypes[type]; } else if (type in integerTypes) { formatBody = integerTypes[type]; } else { throw new Error(`The number formatter type is invalid: ${type}`); } let formatterPrecision; if (precisionIsNaN) { formatterPrecision = type ? 6 : 12; } else { formatterPrecision = precision; } return (n) => { let result = formatBody(n, formatterPrecision); if (trim) { result = removeTrailingZeros(result); } if (comma) { result = insertSeparator(result, comma); } result = addSign(n, result, sign); if (symbol && symbol !== "#") { result = `${symbol}${result}`; } if (symbol === "#" && type === "x") { result = `0x${result}`; } if (type === "s") { result = `${result}${getSIPrefix(n)}`; } if (type === "%" || type === "p") { result = `${result}%`; } if (width2 != null && !isNaN(width2)) { result = addPadding(result, width2, fill ?? zero, align2); } result = `${prefix}${result}${suffix}`; return result; }; } var integerTypes = { b: (n) => absFloor(n).toString(2), c: (n) => String.fromCharCode(n), d: (n) => Math.round(Math.abs(n)).toFixed(0), o: (n) => absFloor(n).toString(8), x: (n) => absFloor(n).toString(16), X: (n) => integerTypes.x(n).toUpperCase(), n: (n) => integerTypes.d(n), "%": (n) => `${absFloor(n * 100).toFixed(0)}` }; var decimalTypes = { e: (n, f) => Math.abs(n).toExponential(f), E: (n, f) => decimalTypes.e(n, f).toUpperCase(), f: (n, f) => Math.abs(n).toFixed(f), F: (n, f) => decimalTypes.f(n, f).toUpperCase(), g: (n, f) => { if (n === 0) { return "0"; } const a = Math.abs(n); const p = Math.floor(Math.log10(a)); if (p >= -4 && p < f) { return a.toFixed(f - 1 - p); } return a.toExponential(f - 1); }, G: (n, f) => decimalTypes.g(n, f).toUpperCase(), n: (n, f) => decimalTypes.g(n, f), p: (n, f) => decimalTypes.r(n * 100, f), r: (n, f) => { if (n === 0) { return "0"; } const a = Math.abs(n); const p = Math.floor(Math.log10(a)); const q = p - (f - 1); if (q <= 0) { return a.toFixed(-q); } const x = 10 ** q; return (Math.round(a / x) * x).toFixed(); }, s: (n, f) => { const p = getSIPrefixPower(n); return decimalTypes.r(n / 10 ** p, f); }, "%": (n, f) => decimalTypes.f(n * 100, f) }; var minSIPrefix = -24; var maxSIPrefix = 24; var siPrefixes = { [minSIPrefix]: "y", [-21]: "z", [-18]: "a", [-15]: "f", [-12]: "p", [-9]: "n", [-6]: "\xB5", [-3]: "m", [0]: "", [3]: "k", [6]: "M", [9]: "G", [12]: "T", [15]: "P", [18]: "E", [21]: "Z", [maxSIPrefix]: "Y" }; var minusSign = "\u2212"; function absFloor(n) { return Math.floor(Math.abs(n)); } function removeTrailingZeros(numString) { return numString.replace(/\.0+$/, "").replace(/(\.[1-9])0+$/, "$1"); } function insertSeparator(numString, separator) { let dotIndex = numString.indexOf("."); if (dotIndex < 0) { dotIndex = numString.length; } const integerChars = numString.substring(0, dotIndex).split(""); const fractionalPart = numString.substring(dotIndex); for (let i = integerChars.length - 3; i > 0; i -= 3) { integerChars.splice(i, 0, separator); } return `${integerChars.join("")}${fractionalPart}`; } function getSIPrefix(n) { return siPrefixes[getSIPrefixPower(n)]; } function getSIPrefixPower(n) { return clamp(minSIPrefix, n ? Math.floor(Math.log10(Math.abs(n)) / 3) * 3 : 0, maxSIPrefix); } function addSign(num, numString, signType = "") { if (signType === "(") { return num >= 0 ? numString : `(${numString})`; } const plusSign = signType === "+" ? "+" : ""; return `${num >= 0 ? plusSign : minusSign}${numString}`; } function addPadding(numString, width2, fill = " ", align2 = ">") { let result = numString; if (align2 === ">" || !align2) { result = result.padStart(width2, fill); } else if (align2 === "<") { result = result.padEnd(width2, fill); } else if (align2 === "^") { const padWidth = Math.max(0, width2 - result.length); const padLeft = Math.ceil(padWidth / 2); const padRight = Math.floor(padWidth / 2); result = result.padStart(padLeft + result.length, fill); result = result.padEnd(padRight + result.length, fill); } return result; } // node_modules/ag-charts-community/dist/package/main.esm.mjs var __defProp3 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __export2 = (target, all) => { for (var name in all) __defProp3(target, name, { get: all[name], enumerable: true }); }; var __decorateClass2 = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc2(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp3(target, key, result); return result; }; var BaseModuleInstance = class { constructor() { this.destroyFns = []; } destroy() { for (const destroyFn of this.destroyFns) { destroyFn(); } } }; var ModuleRegistry = class { constructor() { this.modules = []; this.dependencies = /* @__PURE__ */ new Map(); this.modulesByOptionKey = /* @__PURE__ */ new Map(); } register(...modules) { for (const module of modules) { this.registerDependencies(module); const otherModule = this.modules.find( (other) => module.type === other.type && ("optionsKey" in module && "optionsKey" in other ? module.optionsKey === other.optionsKey : true) && module.identifier === other.identifier ); if (otherModule) { if (module.packageType === "enterprise" && otherModule.packageType === "community") { const index = this.modules.indexOf(otherModule); this.modules.splice(index, 1, module); if ("optionsKey" in module) { this.modulesByOptionKey.set(module.optionsKey, module); } } } else { this.modules.push(module); if ("optionsKey" in module) { this.modulesByOptionKey.set(module.optionsKey, module); } } } } hasEnterpriseModules() { return this.modules.some((m) => m.packageType === "enterprise"); } *byType(...types) { const yielded = /* @__PURE__ */ new Set(); const modulesByType = this.modules.filter((module) => types.includes(module.type)); const calculateDependencies = (module) => { const deps = this.dependencies.get(module); return deps?.flatMap(calculateDependencies).concat(deps) ?? []; }; const unresolvable = []; for (const module of modulesByType) { const uniqueKey = "optionsKey" in module ? module.optionsKey : module.contextKey; if (yielded.has(uniqueKey)) continue; for (const dependency of calculateDependencies(uniqueKey)) { if (yielded.has(dependency)) continue; const dependencyModule = this.modulesByOptionKey.get(dependency); if (!dependencyModule) { unresolvable.push(dependency); continue; } if (!types.includes(dependencyModule.type)) continue; yield dependencyModule; yielded.add(dependency); } yield module; yielded.add(uniqueKey); } if (unresolvable.length > 0) { throw new Error(`Could not resolve module dependencies: ${unresolvable}`); } } registerDependencies(module) { if (module.dependencies == null || module.dependencies.length === 0) return; const uniqueKey = "optionsKey" in module ? module.optionsKey : module.contextKey; this.dependencies.set(uniqueKey, module.dependencies); } }; var moduleRegistry = new ModuleRegistry(); var BBoxValues = { containsPoint, isEmpty, normalize }; function containsPoint(bbox, x, y) { return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height; } function isEmpty(bbox) { return bbox == null || bbox.height === 0 || bbox.width === 0 || isNaN(bbox.height) || isNaN(bbox.width); } function normalize(bbox) { let { x, y, width: width2, height: height2 } = bbox; if ((width2 == null || width2 > 0) && (height2 == null || height2 > 0)) return bbox; if (x != null && width2 != null && width2 < 0) { width2 = -width2; x = x - width2; } if (y != null && height2 != null && height2 < 0) { height2 = -height2; y = y - height2; } return { x, y, width: width2, height: height2 }; } var interpolate = Symbol("interpolate"); var isInterpolating = (x) => x[interpolate] != null; function nearestSquared(x, y, objects, maxDistanceSquared = Infinity) { const result = { nearest: void 0, distanceSquared: maxDistanceSquared }; for (const obj of objects) { const thisDistance = obj.distanceSquared(x, y); if (thisDistance === 0) { return { nearest: obj, distanceSquared: 0 }; } else if (thisDistance < result.distanceSquared) { result.nearest = obj; result.distanceSquared = thisDistance; } } return result; } function nearestSquaredInContainer(x, y, container, maxDistanceSquared = Infinity) { const { x: tx = x, y: ty = y } = container.transformPoint?.(x, y) ?? {}; const result = { nearest: void 0, distanceSquared: maxDistanceSquared }; for (const child of container.children) { const { nearest, distanceSquared: distanceSquared2 } = child.nearestSquared(tx, ty, result.distanceSquared); if (distanceSquared2 === 0) { return { nearest, distanceSquared: distanceSquared2 }; } else if (distanceSquared2 < result.distanceSquared) { result.nearest = nearest; result.distanceSquared = distanceSquared2; } } return result; } var _BBox = class _BBox2 { constructor(x, y, width2, height2) { this.x = x; this.y = y; this.width = width2; this.height = height2; } static fromDOMRect({ x, y, width: width2, height: height2 }) { return new _BBox2(x, y, width2, height2); } static merge(boxes) { let left = Infinity; let top = Infinity; let right = -Infinity; let bottom = -Infinity; for (const box of boxes) { if (box.x < left) { left = box.x; } if (box.y < top) { top = box.y; } if (box.x + box.width > right) { right = box.x + box.width; } if (box.y + box.height > bottom) { bottom = box.y + box.height; } } return new _BBox2(left, top, right - left, bottom - top); } static nearestBox(x, y, boxes) { return nearestSquared(x, y, boxes); } toDOMRect() { return { x: this.x, y: this.y, width: this.width, height: this.height, top: this.y, left: this.x, right: this.x + this.width, bottom: this.y + this.height, toJSON() { return {}; } }; } clone() { const { x, y, width: width2, height: height2 } = this; return new _BBox2(x, y, width2, height2); } equals(other) { return this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height; } containsPoint(x, y) { return BBoxValues.containsPoint(this, x, y); } intersection(other) { if (!this.collidesBBox(other)) return; const newX1 = clamp(other.x, this.x, other.x + other.width); const newY1 = clamp(other.y, this.y, other.y + other.height); const newX2 = clamp(other.x, this.x + this.width, other.x + other.width); const newY2 = clamp(other.y, this.y + this.height, other.y + other.height); return new _BBox2(newX1, newY1, newX2 - newX1, newY2 - newY1); } collidesBBox(other) { return this.x < other.x + other.width && this.x + this.width > other.x && this.y < other.y + other.height && this.y + this.height > other.y; } computeCenter() { return { x: this.x + this.width / 2, y: this.y + this.height / 2 }; } isFinite() { return Number.isFinite(this.x) && Number.isFinite(this.y) && Number.isFinite(this.width) && Number.isFinite(this.height); } distanceSquared(x, y) { if (this.containsPoint(x, y)) { return 0; } const dx2 = x - clamp(this.x, x, this.x + this.width); const dy2 = y - clamp(this.y, y, this.y + this.height); return dx2 * dx2 + dy2 * dy2; } shrink(amount, position) { if (typeof amount === "number") { this.applyMargin(amount, position); } else { for (const key of Object.keys(amount)) { const value = amount[key]; if (typeof value === "number") { this.applyMargin(value, key); } } } if (this.width < 0) { this.width = 0; } if (this.height < 0) { this.height = 0; } return this; } grow(amount, position) { if (typeof amount === "number") { this.applyMargin(-amount, position); } else { for (const key of Object.keys(amount)) { const value = amount[key]; if (typeof value === "number") { this.applyMargin(-value, key); } } } return this; } applyMargin(value, position) { switch (position) { case "top": this.y += value; case "bottom": this.height -= value; break; case "left": this.x += value; case "right": this.width -= value; break; case "vertical": this.y += value; this.height -= value * 2; break; case "horizontal": this.x += value; this.width -= value * 2; break; case void 0: this.x += value; this.y += value; this.width -= value * 2; this.height -= value * 2; break; } } translate(x, y) { this.x += x; this.y += y; return this; } [interpolate](other, d) { return new _BBox2( this.x * (1 - d) + other.x * d, this.y * (1 - d) + other.y * d, this.width * (1 - d) + other.width * d, this.height * (1 - d) + other.height * d ); } }; _BBox.zero = Object.freeze(new _BBox(0, 0, 0, 0)); _BBox.NaN = Object.freeze(new _BBox(NaN, NaN, NaN, NaN)); var BBox = _BBox; var LONG_TIME_PERIOD_THRESHOLD = 2e3; var timeOfLastLog = Date.now(); var logTimeGap = () => { const timeSinceLastLog = Date.now() - timeOfLastLog; if (timeSinceLastLog > LONG_TIME_PERIOD_THRESHOLD) { const prettyDuration = (Math.floor(timeSinceLastLog / 100) / 10).toFixed(1); logger_exports.log(`**** ${prettyDuration}s since last log message ****`); } timeOfLastLog = Date.now(); }; var Debug = { create(...debugSelectors) { const resultFn = (...logContent) => { if (Debug.check(...debugSelectors)) { if (typeof logContent[0] === "function") { logContent = toArray(logContent[0]()); } logTimeGap(); logger_exports.log(...logContent); } }; return Object.assign(resultFn, { check: () => Debug.check(...debugSelectors), group: (name, cb) => { if (Debug.check(...debugSelectors)) { return logger_exports.logGroup(name, cb); } return cb(); } }); }, check(...debugSelectors) { if (debugSelectors.length === 0) { debugSelectors.push(true); } const chartDebug = toArray(getWindow("agChartsDebug")); return chartDebug.some((selector) => debugSelectors.includes(selector)); }, inDevelopmentMode(fn) { if (Debug.check("dev")) { return fn(); } } }; function clearContext({ context, pixelRatio, width: width2, height: height2 }) { context.save(); context.resetTransform(); context.clearRect(0, 0, Math.ceil(width2 * pixelRatio), Math.ceil(height2 * pixelRatio)); context.restore(); } function debugContext(ctx) { if (Debug.check("canvas")) { const save = ctx.save.bind(ctx); const restore = ctx.restore.bind(ctx); let depth = 0; Object.assign(ctx, { save() { save(); depth++; }, restore() { if (depth === 0) { throw new Error("AG Charts - Unable to restore() past depth 0"); } restore(); depth--; }, verifyDepthZero() { if (depth !== 0) { throw new Error(`AG Charts - Save/restore depth is non-zero: ${depth}`); } } }); } } function canvasDimensions(width2, height2, pixelRatio) { return [Math.floor(width2 * pixelRatio), Math.floor(height2 * pixelRatio)]; } var HdpiOffscreenCanvas = class { constructor(options) { const { width: width2, height: height2, pixelRatio, willReadFrequently = false } = options; this.width = width2; this.height = height2; this.pixelRatio = pixelRatio; const [canvasWidth, canvasHeight] = canvasDimensions(width2, height2, pixelRatio); this.canvas = new OffscreenCanvas(canvasWidth, canvasHeight); this.context = this.canvas.getContext("2d", { willReadFrequently }); this.context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0); debugContext(this.context); } drawImage(context, dx2 = 0, dy2 = 0) { return context.drawImage(this.canvas, dx2, dy2); } transferToImageBitmap() { return this.canvas.transferToImageBitmap(); } resize(width2, height2, pixelRatio) { if (!(width2 > 0 && height2 > 0)) return; const { canvas, context } = this; if (width2 !== this.width || height2 !== this.height || pixelRatio !== this.pixelRatio) { const [canvasWidth, canvasHeight] = canvasDimensions(width2, height2, pixelRatio); canvas.width = canvasWidth; canvas.height = canvasHeight; } context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0); this.width = width2; this.height = height2; this.pixelRatio = pixelRatio; } clear() { clearContext(this); } destroy() { this.canvas.width = 0; this.canvas.height = 0; this.context.clearRect(0