@aceshooting/lyra-ui 28.1.6 → 29.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +10 -180
  2. package/README.md +10 -2
  3. package/dist/components/charts/chart/chart.class.js +2 -2
  4. package/dist/components/data/data-grid/data-grid.class.js +1 -1
  5. package/dist/components/data/table/table.class.js +2 -2
  6. package/dist/components/forms/combobox/option.class.js +1 -1
  7. package/dist/components/forms/select/select.class.js +1 -1
  8. package/dist/components/media/map/map-loader.d.ts +9 -1
  9. package/dist/components/media/map/map-loader.js +1 -1
  10. package/dist/components/media/map/map.class.d.ts +20 -11
  11. package/dist/components/media/map/map.class.js +4 -4
  12. package/dist/components/retrieval/graph/graph-model.d.ts +10 -1
  13. package/dist/components/retrieval/graph/graph-spatial-controller.js +30 -0
  14. package/dist/components/retrieval/graph/graph-spatial.js +1 -0
  15. package/dist/components/retrieval/graph/graph.class.d.ts +45 -6
  16. package/dist/components/retrieval/graph/graph.class.js +2 -2
  17. package/dist/components/retrieval/graph/graph.styles.js +1 -1
  18. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +22 -5
  19. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +6 -2
  20. package/dist/events.d.ts +10 -5
  21. package/dist/framework-types.d.ts +1 -1
  22. package/dist/internal/accessible-text-controller.js +1 -1
  23. package/dist/internal/autoloader-manifest.js +1 -1
  24. package/dist/internal/collection-source-tracker.js +1 -0
  25. package/dist/internal/default-strings/media.generated.js +1 -1
  26. package/dist/internal/default-strings/retrieval.generated.js +1 -1
  27. package/dist/internal/localization-types.d.ts +1 -1
  28. package/dist/internal/localization.js +1 -1
  29. package/dist/internal/package-metadata.js +1 -1
  30. package/dist/internal/positioner.js +1 -1
  31. package/dist/lyra.d.ts +1 -1
  32. package/llms/components/lr-geojson-viewer.md +1 -1
  33. package/llms/components/lr-graph.md +78 -8
  34. package/llms/components/lr-knowledge-graph-explorer.md +15 -2
  35. package/llms/components/lr-map.md +60 -25
  36. package/llms/index.md +1 -1
  37. package/llms/peers.md +4 -3
  38. package/llms/shared/ai-and-peers.md +4 -3
  39. package/llms/shared/imports-and-registration.md +1 -1
  40. package/llms/shared.md +5 -4
  41. package/locales.json +138 -138
  42. package/package.json +12 -6
  43. package/registrations.json +1 -1
  44. package/skills/lyra-ui/SKILL.md +8 -3
@@ -1,5 +1,5 @@
1
- import{__decorate}from"tslib";import{snapshotStructuredData,admitSnapshotArray,snapshotArrayStillAdmitted as chartArrayIsStillAdmitted,projectSnapshotArray}from"../../../internal/structured-snapshot.js";import{LazyChartSyncController}from"./chart-sync-lazy.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-host-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{createReducedMotionWatch}from"./chart-surface-shared.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{onAnnotationPluginRegistered}from"../../../internal/chart-annotation-registration.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import{chartSurfaceStyles}from"./chart-surface.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{formatChartValue}from"./chart-number-format.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{showChartActiveDatum}from"./chart-active-datum.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{FALLBACK_GRID_COLOR,FALLBACK_LEGEND_COLOR,FALLBACK_TICK_COLOR,FALLBACK_TICK_FONT_SIZE,FALLBACK_TOOLTIP_BG,FALLBACK_TOOLTIP_TEXT}from"./chart-colors.js";import{ChartTokenCache}from"./chart-token-cache.js";import{chartDataTableVisible,hasSlottedChartDataTable}from"./chart-data-table.js";import{normalizeSize}from"../../../internal/variants.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{canvasSentence,canvasTextDirection,isolateCanvasLabel,isolateCanvasText,isolatedMessage,isolateScaleTickLabels,tooltipIsolationHook,bidiStyles,isolateHtml}from"./chart-bidi.js";import{CSS_NUMBER_SOURCE}from"../../../internal/css-number.js";import{LYRA_DEFAULT_chartAnnotationsUnavailable,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPlotSampled,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartRenderUnavailable,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValuePercentageLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings/charts.generated.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_resetZoom}from"../../../internal/default-strings/shared.generated.js";const DIRECT_PIXEL_NUMBER=new RegExp(`^(${CSS_NUMBER_SOURCE})(?:px)?$`,"i");import{seriesPalette}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]);function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"?value:projectLegendPosition(value)??"top"}function isArcDatasetType(datasetType){return datasetType==="pie"||datasetType==="doughnut"||datasetType==="polarArea"}function isPointDatasetType(datasetType){return datasetType==="line"||datasetType==="radar"||datasetType==="scatter"||datasetType==="bubble"}function isChartRecord(value){try{return typeof value=="object"&&value!==null&&!Array.isArray(value)}catch{return!1}}const MAX_CHART_INPUT_ENTRIES=1e4,CHART_INPUT_CAP_WARNING_KEY="lr-chart-input-cap",MAX_CHART_CONFIGURATION_DEPTH=32,OMIT_CHART_CONFIGURATION_VALUE=Symbol("omit-chart-configuration-value");function warnChartInputCap(){devWarnOnce(CHART_INPUT_CAP_WARNING_KEY,"lr-chart: an input array exceeded 10,000 entries; only the first 10,000 are used.")}function admitChartArray(value){return admitSnapshotArray(value,warnChartInputCap)}function copyChartArrayEntries(admission){return projectSnapshotArray(admission,value=>value,{missing:void 0})??Object.freeze([])}function chartEnumerableKeys(value){try{return Object.keys(value)}catch{return}}const canonicalChartSeriesSnapshots=new WeakMap,admittedChartPlugins=new WeakSet,canonicalChartDatasetValues=new WeakMap,canonicalChartDatasetDataValues=new WeakMap;function canonicalChartSeries(value){if(isChartRecord(value))return canonicalChartSeriesSnapshots.has(value)?value:projectChartSeries(value)}function canonicalSeriesData(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.data??[]:[]}function canonicalSeriesPoints(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.points:void 0}function chartRecordValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectChartNumberData(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:null,{missing:null})}function projectChartPoint(value){if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label");return x===MISSING_OWN_DATA_DESCRIPTOR||x===UNSAFE_OWN_DATA_DESCRIPTOR||y===MISSING_OWN_DATA_DESCRIPTOR||y===UNSAFE_OWN_DATA_DESCRIPTOR||r===UNSAFE_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof x.value!="number"||!Number.isFinite(x.value)||typeof y.value!="number"||!Number.isFinite(y.value)?null:Object.freeze({x:x.value,y:y.value,...r!==MISSING_OWN_DATA_DESCRIPTOR&&typeof r.value=="number"&&Number.isFinite(r.value)&&r.value>=0?{r:r.value}:{},...id!==MISSING_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))?{id:id.value}:{},...label!==MISSING_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?{label:label.value}:{}})}function projectChartDatum(value){if(typeof value=="number")return Number.isFinite(value)?value:null;if(typeof value=="string"||typeof value=="bigint")return value;if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label"),output={};let hasValue=!1;for(const[property2,descriptor]of[["x",x],["y",y],["r",r]])descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value)||(output[property2]=descriptor.value,hasValue=!0);return label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"&&(output.label=label.value,hasValue=!0),id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))&&(output.id=id.value,hasValue=!0),hasValue?Object.freeze(output):null}function projectChartDatasetValues(admission){return projectSnapshotArray(admission,projectChartDatum,{missing:null})??Object.freeze([])}function projectChartPoints(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartPoint,{missing:null})}function projectChartStrings(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="string"?entry:"",{missing:""})}function projectChartPointRadii(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:Number.NaN,{missing:Number.NaN})}function projectHiddenDatasetIndexes(value){if(value!==void 0)return projectSnapshotArray(admitChartArray(value),entry=>typeof entry=="number"&&Number.isInteger(entry)?entry:void 0,{compact:!0})??Object.freeze([])}const CHART_ANNOTATION_TONES=new Set(["neutral","brand","success","warning","danger"]);function projectChartAnnotations(value){if(!Array.isArray(value))return Object.freeze([]);const output=[];for(const annotation of value){if(!isChartRecord(annotation))continue;const own=key=>Object.hasOwn(annotation,key)?annotation[key]:void 0,axis=own("axis"),line=own("value"),from=own("from"),to=own("to"),label=own("label"),tone=own("tone");if(axis!==void 0&&axis!=="x"&&axis!=="y"||label!==void 0&&typeof label!="string"||tone!==void 0&&(typeof tone!="string"||!CHART_ANNOTATION_TONES.has(tone)))continue;const common={...axis==="x"||axis==="y"?{axis}:{},...typeof label=="string"?{label}:{},...typeof tone=="string"?{tone}:{}};typeof line=="number"&&Number.isFinite(line)?output.push(Object.freeze({...common,value:line})):typeof from=="number"&&Number.isFinite(from)&&typeof to=="number"&&Number.isFinite(to)&&output.push(Object.freeze({...common,from:Math.min(from,to),to:Math.max(from,to)}))}return Object.freeze(output)}const CHART_SERIES_PROPERTIES=["label","data","points","color","fill","width","dash","noTooltip","axis","stack","pointColors","pointRadius","segmentColors","type"];function projectChartSeries(value){try{if(!isChartRecord(value))return;const descriptors=new Map;for(const property2 of CHART_SERIES_PROPERTIES){const descriptor=chartRecordValue(value,property2);if(descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;descriptors.set(property2,descriptor)}const valueAt=property2=>{const descriptor=descriptors.get(property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptor===void 0?void 0:descriptor.value},label=valueAt("label");if(label!==void 0&&typeof label!="string")return;const output={label:label??""},rawData=valueAt("data"),rawDataAdmission=admitChartArray(rawData),data=projectChartNumberData(rawData,rawDataAdmission),rawPoints=valueAt("points"),rawPointsAdmission=admitChartArray(rawPoints),points=projectChartPoints(rawPoints,rawPointsAdmission),color=valueAt("color"),fill=valueAt("fill"),width=valueAt("width"),dash=valueAt("dash"),noTooltip=valueAt("noTooltip"),axis=valueAt("axis"),stack=valueAt("stack"),pointColors=projectChartStrings(valueAt("pointColors")),pointRadius=valueAt("pointRadius"),segmentColors=projectChartStrings(valueAt("segmentColors")),type=valueAt("type");if(data&&rawDataAdmission&&(output.data=rawDataAdmission.source),points&&rawPointsAdmission&&(output.points=rawPointsAdmission.source),typeof color=="string")output.color=color;else{const colors=projectChartStrings(color);colors&&(output.color=colors)}if(typeof fill=="boolean"&&(output.fill=fill),typeof width=="number"&&Number.isFinite(width)&&(output.width=width),typeof dash=="boolean"&&(output.dash=dash),typeof noTooltip=="boolean"&&(output.noTooltip=noTooltip),(axis==="y"||axis==="y2")&&(output.axis=axis),typeof stack=="string"&&(output.stack=stack),pointColors&&(output.pointColors=pointColors),typeof pointRadius=="number"&&Number.isFinite(pointRadius))output.pointRadius=pointRadius;else{const radii=projectChartPointRadii(pointRadius);radii&&(output.pointRadius=radii)}segmentColors&&(output.segmentColors=segmentColors),(type==="line"||type==="bar")&&(output.type=type);const series=Object.freeze(output);return canonicalChartSeriesSnapshots.set(series,{data:data??Object.freeze([]),...points?{points}:{}}),series}catch{return}}function normalizeChartSeries(value){return projectSnapshotArray(admitChartArray(value),canonicalChartSeries,{compact:!0})??Object.freeze([])}function isSafeChartConfigurationRecord(value){if(!isChartRecord(value))return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype}catch{return!1}}function projectLegendPosition(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output={};for(const key of keys){if(UNSAFE_KEYS.has(key))return;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value))return;output[key]=descriptor.value}return Object.freeze(output)}function copyChartConfigurationValue(value,profile="chart"){const snapshot=snapshotStructuredData(value,{profile,omitKeys:UNSAFE_KEYS,onArrayTruncate:warnChartInputCap,onClone:(source,copied)=>{const canonical=canonicalChartDatasetDataValues.get(source);canonical&&canonicalChartDatasetDataValues.set(copied,canonical)}});return snapshot.value===void 0&&value!==void 0?OMIT_CHART_CONFIGURATION_VALUE:snapshot.value}function projectChartPlugins(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,candidate=>{if(candidate===null||typeof candidate!="object"&&typeof candidate!="function")return;const plugin=candidate;if(admittedChartPlugins.has(plugin))return plugin;const id=chartRecordValue(plugin,"id");if(!(id===MISSING_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||typeof id.value!="string"||id.value.trim()===""))return admittedChartPlugins.add(plugin),plugin},{compact:!0})??Object.freeze([])}function projectChartDatasetConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null),priorCanonicalValues=canonicalChartDatasetValues.get(value);let canonicalValues;for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const candidate=descriptor.value,array=admitChartArray(candidate);if(key==="data"){if(array){if(!chartArrayIsStillAdmitted(array)){output[key]=Object.freeze([]),canonicalValues=Object.freeze([]);continue}const copied=copyChartArrayEntries(array);output[key]=copied;const canonical=priorCanonicalValues??canonicalChartDatasetDataValues.get(array.source)??projectChartDatasetValues(array);canonicalValues=canonical,canonicalChartDatasetDataValues.set(copied,canonical)}continue}if(key==="label"){typeof candidate=="string"||typeof candidate=="number"||typeof candidate=="boolean"||typeof candidate=="bigint"?output[key]=candidate:array&&(output[key]=copyChartArrayEntries(array));continue}if(key==="hidden"||key==="noTooltip"){typeof candidate=="boolean"&&(output[key]=candidate);continue}if(key==="axis"||key==="yAxisID"||key==="type"||key==="stack"){typeof candidate=="string"&&(output[key]=candidate);continue}output[key]=array?copyChartArrayEntries(array):candidate}const dataset=Object.freeze(output);return canonicalValues&&canonicalChartDatasetValues.set(dataset,canonicalValues),dataset}function projectChartDatasetConfigurations(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartDatasetConfiguration,{compact:!0})??Object.freeze([])}function projectChartDataConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)){if(key==="labels"){const labels=admitChartArray(descriptor.value);output[key]=labels?copyChartArrayEntries(labels):Object.freeze([]);continue}if(key==="datasets"){output[key]=projectChartDatasetConfigurations(descriptor.value);continue}output[key]=descriptor.value}}return Object.freeze(output)}function projectChartConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const output=Object.create(null),type=chartRecordValue(value,"type"),data=chartRecordValue(value,"data"),options=chartRecordValue(value,"options"),plugins=chartRecordValue(value,"plugins");type!==MISSING_OWN_DATA_DESCRIPTOR&&type!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof type.value=="string"&&(output.type=type.value);for(const[property2,descriptor]of[["data",data],["options",options]]){if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const copied=copyChartConfigurationValue(descriptor.value,property2==="data"?"chartData":"chart");if(copied!==OMIT_CHART_CONFIGURATION_VALUE){if(property2==="data"){const projected=projectChartDataConfiguration(copied);output[property2]=projected??copied;continue}output[property2]=copied}}if(plugins!==MISSING_OWN_DATA_DESCRIPTOR&&plugins!==UNSAFE_OWN_DATA_DESCRIPTOR){const pluginArray=admitChartArray(plugins.value);if(pluginArray)output.plugins=projectChartPlugins(plugins.value,pluginArray);else{const copied=copyChartConfigurationValue(plugins.value);copied!==OMIT_CHART_CONFIGURATION_VALUE&&(output.plugins=copied)}}return Object.freeze(output)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]);function deepMerge(base,override,seen=new WeakMap){if(!isSafeChartConfigurationRecord(base)||!isSafeChartConfigurationRecord(override))return override===void 0?base:override;const baseRecord=base,overrideRecord=override,baseKeys=chartEnumerableKeys(baseRecord),overrideKeys=chartEnumerableKeys(overrideRecord);if(!baseKeys||!overrideKeys)return override;const previous=seen.get(overrideRecord);if(previous!==void 0)return previous;const result={};for(const key of baseKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(baseRecord,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(result[key]=descriptor.value)}seen.set(overrideRecord,result);try{for(const key of overrideKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(overrideRecord,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const baseDescriptor=chartRecordValue(baseRecord,key),baseValue=baseDescriptor===MISSING_OWN_DATA_DESCRIPTOR||baseDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:baseDescriptor.value;result[key]=deepMerge(baseValue,descriptor.value,seen)}}finally{seen.delete(overrideRecord)}return result}function normalizedChartPoint(value){return projectChartPoint(projectChartDatum(value))}function chartNumericValue(value){const numeric=typeof value=="number"?value:typeof value=="string"||typeof value=="bigint"?Number(value):Number.NaN;return Number.isFinite(numeric)?numeric:void 0}function chartDatumNumericValue(value){const projected=projectChartDatum(value);if(isChartRecord(projected))for(const property2 of["y","r","x"]){const descriptor=chartRecordValue(projected,property2);if(descriptor!==MISSING_OWN_DATA_DESCRIPTOR&&descriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof descriptor.value=="number"&&Number.isFinite(descriptor.value))return descriptor.value}return chartNumericValue(projected)}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value,depth=0){if(value==null)return"";if(typeof value=="string"||typeof value=="number"||typeof value=="boolean"||typeof value=="bigint")return String(value);const admission=admitChartArray(value);if(depth<MAX_CHART_CONFIGURATION_DEPTH&&admission){const values=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));values.push(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?"":labelText(descriptor.value,depth+1))}return values.join(" ")}return""}function chartDatasetValue(dataset,property2){if(!isChartRecord(dataset))return;const descriptor=chartRecordValue(dataset,property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function chartDatasetLabel(dataset){return labelText(chartDatasetValue(dataset,"label"))}function chartDatasetValues(dataset){if(isChartRecord(dataset)){const snapshot=canonicalChartDatasetValues.get(dataset);if(snapshot)return snapshot}const data=chartDatasetValue(dataset,"data"),admission=admitChartArray(data);return admission?canonicalChartDatasetDataValues.get(admission.source)??copyChartArrayEntries(admission):Object.freeze([])}function chartDatasetPeerValues(dataset){const admission=admitChartArray(chartDatasetValue(dataset,"data"));return admission?copyChartArrayEntries(admission):Object.freeze([])}function chartIndex(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>=0?value:void 0}function chartCallbackDatasetIndex(value){return chartIndex(chartDatasetValue(value,"datasetIndex"))}function chartCallbackIndexes(value){const datasetIndex=chartCallbackDatasetIndex(value),index=chartIndex(chartDatasetValue(value,"index"))??chartIndex(chartDatasetValue(value,"dataIndex"));return datasetIndex===void 0||index===void 0?void 0:{datasetIndex,index}}function projectChartLegendItem(value){if(!isChartRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(output[key]=descriptor.value)}return output}function projectChartLegendItems(value){const admission=admitChartArray(value);if(!admission||!chartArrayIsStillAdmitted(admission))return;const output=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectChartLegendItem(descriptor.value);item&&output.push(item)}return Object.freeze(output)}function chartDatasetBoolean(dataset,property2){const value=chartDatasetValue(dataset,property2);return typeof value=="boolean"?value:void 0}function chartDatasetAxis(dataset){return chartDatasetValue(dataset,"yAxisID")==="y2"||chartDatasetValue(dataset,"axis")==="y2"?"y2":"y"}function chartDatasetStack(dataset){const value=chartDatasetValue(dataset,"stack");return typeof value=="string"?value:void 0}function isDenseChartSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAnnotationsUnavailable:LYRA_DEFAULT_chartAnnotationsUnavailable,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPlotSampled:LYRA_DEFAULT_chartPlotSampled,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartRenderUnavailable:LYRA_DEFAULT_chartRenderUnavailable,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartValuePercentageLabel:LYRA_DEFAULT_chartValuePercentageLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,resetZoom:LYRA_DEFAULT_resetZoom}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-legend-visibility-change-request","lr-legend-visibility-change","lr-datum-visibility-change-request","lr-datum-visibility-change"])}static{this.ownedCollectionProperties=Object.freeze(["annotations","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,chartSurfaceStyles,styles,srOnly,bidiStyles]}constructor(){super(),this.canvasTokens=new ChartTokenCache(this),this.type="bar",this.labels=[],this._datasets=Object.freeze([]),this.datasetsSource=this._datasets,this._hiddenDatums=Object.freeze([]),this.hiddenDatumsSource=this._hiddenDatums,this.legendMode="auto",this.legendDisplay="auto",this.description=null,this.grid="both",this.axes="both",this.size="m",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this._plugins=Object.freeze([]),this.pluginsSource=this._plugins,this.area=!1,this.zoomable=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.withoutZeroBaseline=!1,this.withDataTable=!1,this.dataTableToggle=!1,this.dataTableExpandedOverride=null,this.dataTableId=nextId("chart-data-table"),this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.configSource=void 0,this.loading=!0,this.loadFailed=!1,this.canvasUnavailable=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadAnnotationFeature=()=>loadChartJsWithAnnotationResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.annotationLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.annotationFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.reducedMotionWatch=createReducedMotionWatch(this,()=>this.drawIfVisible()),this.scaledSliceDatasets=new Set,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.chartAreaPlugin={id:"lyra-chart-area",afterLayout:chart=>this.updateChartArea(chart),beforeTooltipDraw:tooltipIsolationHook(()=>this.effectiveDirection)},this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.announcements=new AnnouncementSinkController(this),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.syncGroup="",this.chartSync=new LazyChartSyncController(this,(label,index)=>this.syncPresentation(label,index),()=>this.resetSyncTooltip(),target=>target===this.canvasEl),this.forcedColorPatterns=new Map,this.visualPositions=new WeakMap,this.keyboardDatumShown=!1,this.onCanvasBlur=()=>{this.showKeyboardDatum(void 0)},new ThemeWatcher(this,()=>{this.chart&&this.canvasTokens.hasThemeChanged()&&this.refreshTheme()})}canonicalLabels(){const source=this.labels;if(this.labelsSnapshot&&Object.is(this.labelsSnapshot.source,source))return this.labelsSnapshot.value;const value=projectChartStrings(source)??Object.freeze([]);return this.labelsSnapshot={source,value},value}canonicalAnnotations(){const source=this.annotations;if(this.annotationsSnapshot&&Object.is(this.annotationsSnapshot.source,source))return this.annotationsSnapshot.value;const value=projectChartAnnotations(source);return this.annotationsSnapshot={source,value},value}canonicalHiddenDatasets(){const source=this.hiddenDatasets;if(this.hiddenDatasetsSnapshot&&Object.is(this.hiddenDatasetsSnapshot.source,source))return this.hiddenDatasetsSnapshot.value;const value=source===void 0?void 0:Object.freeze(Array.isArray(source)?source.filter(index=>typeof index=="number"&&Number.isInteger(index)):[]);return this.hiddenDatasetsSnapshot={source,value},value}get datasets(){return this._datasets}set datasets(value){if(Object.is(value,this.datasetsSource)||Object.is(value,this._datasets))return;const previous=this._datasets;this._datasets=normalizeChartSeries(value),this.datasetsSource=value,this.requestUpdate("datasets",previous)}get hiddenDatums(){return this._hiddenDatums}set hiddenDatums(value){if(Object.is(value,this.hiddenDatumsSource)||Object.is(value,this._hiddenDatums))return;const previous=this._hiddenDatums;this._hiddenDatums=projectHiddenDatasetIndexes(value)??Object.freeze([]),this.hiddenDatumsSource=value,this.requestUpdate("hiddenDatums",previous)}get compactPlot(){return isDenseChartSize(this.size)}get plugins(){return this._plugins}set plugins(value){if(Object.is(value,this.pluginsSource)||Object.is(value,this._plugins))return;const previous=this._plugins;this._plugins=projectChartPlugins(value),this.pluginsSource=value,this.requestUpdate("plugins",previous)}get dataTableVisible(){return chartDataTableVisible(this.withDataTable,this.dataTableToggle,this.dataTableExpandedOverride)}toggleDataTable(){this.dataTableExpandedOverride=!this.dataTableVisible}get config(){return this._config}set config(value){if(Object.is(value,this.configSource)||value!==void 0&&Object.is(value,this._config))return;const previous=this._config;this._config=projectChartConfiguration(value),this.configSource=value,this.requestUpdate("config",previous)}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const slot=event.currentTarget;slot===this.configSlotEl&&this.collectConfigFromSlot(slot)}collectConfigFromSlot(slot){const script=slot.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");next=projectChartConfiguration(parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const labels=this.canonicalLabels(),datasets=this.datasets,config=this.config??this.slottedConfig,memo=this.effectiveDataMemo;if(memo?.labels===labels&&memo.datasets===datasets&&memo.config===config)return memo.value;const generated={labels:[...labels],datasets:datasets.map(series=>{const{points:_points,...safeSeries}=series;return{...safeSeries,data:[...canonicalSeriesPoints(series)??canonicalSeriesData(series)],yAxisID:series.axis==="y2"?"y2":"y"}})},override=projectChartDataConfiguration(this.effectiveConfig()?.data),merged=override?deepMerge(generated,override):generated,projected=projectChartDataConfiguration(merged),value={labels:projected?.labels??[],datasets:projected?.datasets??[]};return this.effectiveDataMemo={labels,datasets,config,value},value}callbackDatasetIndex(value,effective=this.effectiveData()){const datasetIndex=chartCallbackDatasetIndex(value);if(datasetIndex===void 0)return;const visualDatasetCount=this.visualDatasetSourceIndexes?.length??effective.datasets.length;if(datasetIndex>=visualDatasetCount)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex;return effective.datasets[sourceDatasetIndex]?datasetIndex:void 0}callbackIndexes(value,effective=this.effectiveData()){const hit=chartCallbackIndexes(value);if(!hit)return;const visualDatasetCount=this.visualDatasetSourceIndexes?.length??effective.datasets.length;if(hit.datasetIndex>=visualDatasetCount)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,dataset=effective.datasets[sourceDatasetIndex];if(!dataset)return;const visualRowCount=this.visualRowSourceIndexes?.length??this.datasetValues(dataset).length;return hit.index<visualRowCount?hit:void 0}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.canonicalHiddenDatasets(),effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>chartDatasetBoolean(dataset,"hidden")===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const chart=this.chart,sourceDatasetCount=this.effectiveData().datasets.length,datasetCount=this.visualDatasetSourceIndexes?.length??sourceDatasetCount,controlled=normalizeHiddenDatasets(this.canonicalHiddenDatasets(),sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++)try{const metadata=chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}catch{}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;try{chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}catch{}}return datasetCount>0}isSliceChart(){return["pie","doughnut","polarArea"].includes(this.effectiveType())}applyDatumVisibility(){if(!this.chart||!this.isSliceChart())return!1;const sample=this.dataTableSample(),rows=this.visualRowSourceIndexes,hidden=new Set(normalizeHiddenDatasets(this.hiddenDatums,sample.rowCount));let changed=!1;for(let index=0;index<(rows?.length??sample.rowCount);index++){const visible=!hidden.has(rows?.[index]??index);try{this.chart.getDataVisibility?.(index)===!visible&&(this.chart.toggleDataVisibility?.(index),changed=!0)}catch{}}return changed}hasExplicitConfigData(){const config=this.effectiveConfig();if(!isSafeChartConfigurationRecord(config))return!1;const data=chartRecordValue(config,"data");return data!==MISSING_OWN_DATA_DESCRIPTOR&&data!==UNSAFE_OWN_DATA_DESCRIPTOR}datasetLabel(dataset,index){return chartDatasetLabel(dataset)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return chartDatasetValues(dataset)}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(value=>normalizedChartPoint(value)!==null)}appendData(label,values,maxPoints=0){const requested=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0,limit=requested>0?Math.min(requested,MAX_CHART_INPUT_ENTRIES):MAX_CHART_INPUT_ENTRIES,appendedValues=projectChartNumberData(values)??Object.freeze([]);if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=projectChartDataConfiguration(effectiveConfig?.data)??{},explicitLabels=admitChartArray(currentData.labels)!==void 0,explicitDatasets=admitChartArray(currentData.datasets)!==void 0,nextLabels=labels2.slice(-limit);if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(canonicalSeriesPoints(series)!==void 0)return series;const current=canonicalSeriesData(series),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),appendedValues[index]??null];return{...series,data:data.slice(-limit)}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),peer=chartDatasetPeerValues(dataset),padding=Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),data=[...peer,...padding,appendedValues[index]??null],canonical=[...current,...padding,appendedValues[index]??null],nextData2=data.slice(-limit),nextCanonical=canonical.slice(-limit);return canonicalChartDatasetDataValues.set(nextData2,Object.freeze(nextCanonical)),{...dataset,data:nextData2}})),this.config={...effectiveConfig,data:nextData}}return}const currentLabels=this.canonicalLabels();let domainLength=currentLabels.length;for(const series of this.datasets)canonicalSeriesPoints(series)===void 0&&(domainLength=Math.max(domainLength,canonicalSeriesData(series).length));const labels=[...currentLabels,...Array.from({length:Math.max(0,domainLength-currentLabels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>{if(canonicalSeriesPoints(series)!==void 0)return series;const current=canonicalSeriesData(series),data=[...current,...Array.from({length:Math.max(0,domainLength-current.length)},()=>null),appendedValues[index]??null];return{...series,data:data.slice(-limit)}});this.labels=labels.slice(-limit),this.datasets=datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.map(normalizedChartPoint).filter(point=>point!==null);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const exportCell=(value,metadata)=>typeof value!="number"||!Number.isFinite(value)?value??"":this.formatExportValue(value,metadata)??value,rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>normalizedChartPoint(this.datasetValues(dataset)[index])).find(point=>point!==null),label=labelText(effective.labels[index])||firstPoint?.label||"";return[label,...columns.flatMap((column,datasetIndex)=>{const value=this.datasetValues(column.dataset)[index],axis=this.datasetValueAxis(column.dataset),metadata={datasetIndex,index,label:label||void 0,seriesLabel:column.label,...axis===void 0?{}:{axis}};if(!column.point)return[exportCell(value,metadata)];const point=normalizedChartPoint(value);return point?[exportCell(point.x,{...metadata,statistic:"x"}),exportCell(point.y,{...metadata,statistic:"y"}),...column.radius?[point.r==null?"":exportCell(point.r,{...metadata,statistic:"r"})]:[],...column.pointLabel?[point.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
2
- `)}connectedCallback(){super.connectedCallback(),this.stopAnnotationRegistrationWatch?.(),this.stopAnnotationRegistrationWatch=onAnnotationPluginRegistered(()=>this.rebuildAfterAnnotationRegistration()),this.visible=!this.ownerWindow?.IntersectionObserver,this.armReducedMotionWatcher();const ownerWindow=this.ownerWindow,ResizeObserverCtor=ownerWindow?.ResizeObserver;ResizeObserverCtor&&(this.resizeObserver=new ResizeObserverCtor(entries=>{const width=entries[0]?.contentRect.width??this.getBoundingClientRect().width;if(Number.isFinite(width)&&this.lastObservedInlineSize!==void 0&&Math.abs(width-this.lastObservedInlineSize)<.5||(this.lastObservedInlineSize=width,this.resizeDrawFrame!==void 0))return;const frameOwner=this.ownerWindow;frameOwner&&(this.resizeDrawFrameOwner=frameOwner,this.resizeDrawFrame=frameOwner.requestAnimationFrame(()=>{this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,!(!this.isConnected||this.ownerWindow!==frameOwner)&&(this.updateAutoLegendPosition()||this.drawIfVisible())}))}),this.resizeObserver.observe(this)),this.updateAutoLegendPosition();const generation=++this.loadGeneration;this.zoomable&&this.requestZoomFeature(),this.loadLibrary(this.zoomable).then(async mod=>{try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),!(generation!==this.loadGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.loadFailed=!0;return}this.loadFailed=!1,this.chartJsModule=mod,this.drawIfVisible()}}),this.needsDataLabels&&this.requestDataLabelsFeature(),this.needsAnnotations&&this.requestAnnotationFeature();const IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}disconnectedCallback(){this.chartSync.disconnect(),super.disconnectedCallback(),this.stopAnnotationRegistrationWatch?.(),this.stopAnnotationRegistrationWatch=void 0,this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings.clear(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.resizeDrawFrame!==void 0&&this.resizeDrawFrameOwner?.cancelAnimationFrame(this.resizeDrawFrame),this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,this.lastObservedInlineSize=void 0,this.loadGeneration+=1,this.zoomLoadGeneration+=1,this.dataLabelsLoadGeneration+=1,this.annotationLoadGeneration+=1,this.discardChart(!1),this.builtPlugins=[],this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){this.chartSync.disconnect(),this.canvasTokens.clear(),super.adoptedCallback(),this.announcements.adopted(),this.requestUpdate(),this.disarmReducedMotionWatcher(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){this.reducedMotionWatch.arm()}disarmReducedMotionWatcher(){this.reducedMotionWatch.disarm()}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}computedStyle(element=this){const view=this.ownerWindow;return view?view.getComputedStyle(element):"style"in element?element.style:this.style}applyDataLabelsPlugin(plugin){this.dataLabelsPlugin=plugin;let rebuilt=!1;plugin&&this.needsDataLabels&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],rebuilt=!0),this.drawIfVisible(),rebuilt&&this.showsLegend&&this.requestUpdate()}get zoomFeatureAvailable(){return this.zoomable&&this.zoomFeatureState==="available"}featureWarningMessages(){if(this.loading||this.loadFailed)return[];const messages=[];return this.zoomable&&this.zoomFeatureState==="unavailable"&&messages.push(this.localize("chartZoomUnavailable")),this.dataLabelsFeatureState==="unavailable"&&(this.dataLabels&&messages.push(this.localize("chartDataLabelsUnavailable")),this.stackTotals&&messages.push(this.localize("chartStackTotalsUnavailable"))),this.needsAnnotations&&this.annotationFeatureState==="unavailable"&&messages.push(this.localize("chartAnnotationsUnavailable")),messages}requestZoomFeature(){const generation=++this.zoomLoadGeneration;if(!this.zoomable){this.zoomFeatureState="idle";return}this.zoomFeatureState="loading",this.loadZoomFeature().then(result=>{generation!==this.zoomLoadGeneration||!this.isConnected||!this.zoomable||(this.zoomFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.drawIfVisible(),this.requestUpdate())})}requestAnnotationFeature(){const generation=++this.annotationLoadGeneration;if(!this.needsAnnotations){this.annotationFeatureState="idle";return}this.annotationFeatureState="loading",this.loadAnnotationFeature().then(result=>{generation!==this.annotationLoadGeneration||!this.isConnected||!this.needsAnnotations||(result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.annotationFeatureState=result.kind==="available"?"available":"unavailable",this.applyAnnotationPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}applyAnnotationPlugin(plugin){this.annotationPlugin=plugin,plugin&&this.needsAnnotations&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[]),this.drawIfVisible()}rebuildAfterAnnotationRegistration(){!this.chart||this.needsAnnotations||(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],this.drawIfVisible())}requestDataLabelsFeature(){const generation=++this.dataLabelsLoadGeneration;if(!this.needsDataLabels){this.dataLabelsFeatureState="idle";return}this.dataLabelsFeatureState="loading",this.loadDataLabelsFeature().then(result=>{generation!==this.dataLabelsLoadGeneration||!this.isConnected||!this.needsDataLabels||(this.dataLabelsFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.applyDataLabelsPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}willUpdate(changed){super.willUpdate(changed),this.zoomed&&this.effectiveType()!==this.builtType&&(this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1}))}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{collectInitialSlotAssignment(this.configSlotEl,s=>this.collectConfigFromSlot(s))})}updated(changed){super.updated(changed);const appliedVisibility=this.appliedLegendVisibility;if(this.appliedLegendVisibility=void 0,!this.isConnected)return;let canvasChanges=changed;changed.has("hiddenDatasets")&&appliedVisibility!==void 0&&appliedVisibility.chart===this.chart&&appliedVisibility.hidden===this.canonicalHiddenDatasets()&&(canvasChanges=new Map(changed),canvasChanges.delete("hiddenDatasets"));const contentChanged=this.chartContentChanged(canvasChanges),syncDataChanged=contentChanged||changed.has("hiddenDatasets")||changed.has("hiddenDatums");this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible(),syncDataChanged);const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.announcements.announcePolite(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.announcements.announceAssertive(this.localize("chartMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed){const featureWarnings=this.featureWarningMessages();for(const warning of featureWarnings)this.announcedFeatureWarnings.has(warning)||this.announcements.announceAssertive(warning);this.announcedFeatureWarnings=new Set(featureWarnings),!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.announcements.announcePolite(dataTruncation))}if(this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;changed.has("zoomable")&&this.requestZoomFeature(),(changed.has("dataLabels")||changed.has("stackTotals"))&&this.requestDataLabelsFeature(),changed.has("annotations")&&this.requestAnnotationFeature();const effectiveDirection=this.effectiveDirection,effectiveLocale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==effectiveDirection||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==effectiveLocale;if(this.lastDrawnDirection=effectiveDirection,this.lastDrawnLocale=effectiveLocale,!contentChanged&&!contextChanged){changed.has("hiddenDatums")&&this.visible&&this.applyDatumVisibility()&&this.chart?.update("none");return}this.drawIfVisible()}chartContentChanged(changed){return["type","labels","datasets","hiddenDatasets","grid","axes","size","indexAxis","legendPosition","min","max","scaleType","annotations","plugins","autoLegendPosition","valueFormatter","formatter","tooltipTitleFormatter","tooltipFooterFormatter","area","height","xLabel","yLabel","y2Label","withoutZeroBaseline","stacked","stackedAxes","withoutAnimation","withoutLegend","withoutTooltip","syncGroup","dataLabels","stackTotals","config","slottedConfig","zoomable","locale","strings","loading"].some(name=>changed.has(name))}seriesToDataset(s,index,palette,effectiveType,chartStyle=this.chartStyleOptions(palette),rowIndexes){const series=canonicalChartSeries(s);if(!series)return{label:"",data:[]};const points=canonicalSeriesPoints(series),fullNormalizedData=points?points.map(normalizedChartPoint):canonicalSeriesData(series).map(value=>typeof value=="number"&&Number.isFinite(value)?value:null),normalizedData=rowIndexes?rowIndexes.map(rowIndex=>fullNormalizedData[rowIndex]??null):fullNormalizedData,borderFallback=chartStyle.borderColors[index%chartStyle.borderColors.length]??palette[index%palette.length],fillFallback=chartStyle.fillColors[index%chartStyle.fillColors.length]??palette[index%palette.length],sourceColors=projectChartStrings(series.color),authoredColors=sourceColors&&rowIndexes?rowIndexes.map(rowIndex=>sourceColors[rowIndex]??""):typeof series.color=="string"?series.color:sourceColors,colors=typeof authoredColors=="string"?[this.canvasTokens.resolve(authoredColors,borderFallback??"transparent")]:authoredColors?this.canvasTokens.resolveMany(authoredColors,borderFallback??"transparent"):void 0,sliceChart=effectiveType==="pie"||effectiveType==="doughnut"||effectiveType==="polarArea",sliceFillColors=sliceChart&&chartStyle.fillColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.fillColors[sourceIndex%chartStyle.fillColors.length]}):void 0,sliceBorderColors=sliceChart&&chartStyle.borderColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.borderColors[sourceIndex%chartStyle.borderColors.length]}):void 0,fill=series.fill??this.area,backgroundColor=colors??sliceFillColors??fillFallback,datasetType=series.type??effectiveType,authoredSegmentColors=series.segmentColors?.length&&rowIndexes?rowIndexes.map(rowIndex=>series.segmentColors[rowIndex%series.segmentColors.length]):series.segmentColors,segmentColors=authoredSegmentColors?this.canvasTokens.resolveMany(authoredSegmentColors,colors?.[0]??borderFallback??"transparent"):void 0,authoredPointColors=series.pointColors&&rowIndexes?rowIndexes.map(rowIndex=>series.pointColors[rowIndex]??""):series.pointColors,backgroundColors=projectChartStrings(backgroundColor),backgroundColorValue=typeof backgroundColor=="string"?backgroundColor:void 0,resolvedBackgroundColor=datasetType==="line"&&fill&&(colors||!chartStyle.authoredFillColors[index%chartStyle.authoredFillColors.length])?backgroundColors?backgroundColors.map(color=>this.canvasTokens.translucent(color)):backgroundColorValue&&this.canvasTokens.translucent(backgroundColorValue):backgroundColor,encoding=forcedColorEncoding(index),resolvedBackgroundColors=projectChartStrings(resolvedBackgroundColor),resolvedBackgroundColorValue=typeof resolvedBackgroundColor=="string"?resolvedBackgroundColor:void 0,encodedBackgroundColor=chartStyle.forcedColors?resolvedBackgroundColors?resolvedBackgroundColors.map((color,itemIndex)=>this.forcedColorPattern(sliceChart?itemIndex:index,color)):resolvedBackgroundColorValue&&this.forcedColorPattern(index,resolvedBackgroundColorValue):resolvedBackgroundColor,pointRadii=projectChartPointRadii(series.pointRadius);return{label:series.label,data:normalizedData,type:series.type,fill,...datasetType==="bar"&&this.hasConfiguredBarOption("borderRadius")?{}:{borderRadius:chartStyle.borderRadius},...datasetType==="bar"&&!Number.isFinite(series.width)&&this.hasConfiguredBarOption("borderWidth")||isArcDatasetType(datasetType)&&this.hasConfiguredElementOption(datasetType,"arc","borderWidth")?{}:{borderWidth:nonNegativeFinite(series.width,datasetType==="line"||datasetType==="radar"?chartStyle.lineBorderWidth:chartStyle.borderWidth)},borderDash:series.dash?[4,4]:chartStyle.forcedColors?[...encoding.dash]:void 0,pointStyle:chartStyle.forcedColors?encoding.pointStyle:void 0,backgroundColor:encodedBackgroundColor,borderColor:colors?.[0]??sliceBorderColors??borderFallback,pointBackgroundColor:authoredPointColors?this.canvasTokens.resolveMany(authoredPointColors,colors?.[0]??borderFallback??"transparent"):void 0,...isPointDatasetType(datasetType)&&this.hasConfiguredElementOption(datasetType,"point","radius")?{}:{pointRadius:pointRadii?(rowIndexes?rowIndexes.map(rowIndex=>pointRadii[rowIndex]):pointRadii).map(radius=>nonNegativeFinite(radius,chartStyle.pointRadius)):nonNegativeFinite(series.pointRadius,chartStyle.pointRadius)},...segmentColors?.length?{segment:{borderColor:ctx=>segmentColors[ctx.p0DataIndex%segmentColors.length]}}:{},yAxisID:series.axis==="y2"?"y2":"y",...series.stack!==void 0?{stack:series.stack}:{}}}hasConfiguredElementOption(datasetTypeKey,elementKey,option){const read=(value,key)=>{if(!isChartRecord(value))return;const descriptor=chartRecordValue(value,key);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value},options=this.effectiveConfig()?.options,dataset=read(read(options,"datasets"),datasetTypeKey),scopes=[dataset,read(read(dataset,"elements"),elementKey),read(read(options,"elements"),elementKey),options],prefixed=`${elementKey}${option[0].toUpperCase()}${option.slice(1)}`;return scopes.some(scope=>read(scope,prefixed)!==void 0||read(scope,option)!==void 0)}hasConfiguredBarOption(option){return this.hasConfiguredElementOption("bar","bar",option)}themeColors(){const cs=this.canvasTokens.sync()??this.computedStyle(),grid=cs.getPropertyValue("--grid-color").trim()||cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),tick=cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),legend=cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),tooltipBg=cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),tooltipText=cs.getPropertyValue("--lr-chart-tooltip-color").trim()||cs.getPropertyValue("--_lr-chart-tooltip-color").trim();return{grid:this.canvasTokens.resolve(grid,FALLBACK_GRID_COLOR),tick:this.canvasTokens.resolve(tick,FALLBACK_TICK_COLOR),tickFontSize:this.styleNumber("--lr-chart-tick-font-size","--_lr-chart-tick-font-size",FALLBACK_TICK_FONT_SIZE),legend:this.canvasTokens.resolve(legend,FALLBACK_LEGEND_COLOR),tooltipBg:this.canvasTokens.resolve(tooltipBg,FALLBACK_TOOLTIP_BG),tooltipText:this.canvasTokens.resolve(tooltipText,FALLBACK_TOOLTIP_TEXT)}}styleColor(name,fallback){const value=this.computedStyle().getPropertyValue(name).trim();return value?this.canvasTokens.resolve(value,fallback):fallback}styleNumber(name,fallbackToken,fallback){const computed=this.computedStyle(),value=computed.getPropertyValue(name).trim()||computed.getPropertyValue(fallbackToken).trim(),direct=DIRECT_PIXEL_NUMBER.exec(value);if(direct){const resolved2=Number.parseFloat(direct[1]);if(Number.isFinite(resolved2)&&resolved2>=0)return resolved2}if(!value||!this.ownerWindow)return fallback;const resolved=this.canvasTokens.length(value,()=>{const probe=this.ownerDocument.createElement("span");probe.hidden=!0,probe.setAttribute("aria-hidden","true"),probe.style.inlineSize=value,(this.shadowRoot??this).append(probe);try{return Number.parseFloat(this.computedStyle(probe).inlineSize)}finally{probe.remove()}});return Number.isFinite(resolved)&&resolved>=0?resolved:fallback}explicitTickFontSize(){const resolved=this.styleNumber("--lr-chart-tick-font-size","--lr-chart-tick-font-size",NaN);return Number.isNaN(resolved)?void 0:resolved}forcedColorPattern(index,background){if(!this.ownerWindow)return background;const surface=this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG),key=`${forcedColorEncoding(index).name}
1
+ import{__decorate}from"tslib";import{snapshotStructuredData,admitSnapshotArray,snapshotArrayStillAdmitted as chartArrayIsStillAdmitted,projectSnapshotArray}from"../../../internal/structured-snapshot.js";import{LazyChartSyncController}from"./chart-sync-lazy.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-host-tokens.styles.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{createReducedMotionWatch}from"./chart-surface-shared.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadChartJs}from"./chart-core-loader.js";import{onAnnotationPluginRegistered}from"../../../internal/chart-annotation-registration.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{loadChartJsWithZoom,loadChartJsWithZoomResult,loadChartJsWithDataLabelsResult,loadChartJsWithAnnotationResult}from"./chart-feature-loader.js";import{styles}from"./chart.styles.js";import{chartSurfaceStyles}from"./chart-surface.styles.js";import"../../overlays/skeleton/skeleton.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{formatChartValue}from"./chart-number-format.js";import{escapeCsvField}from"../../utility/export-button/csv.js";import{finiteAdd,finiteNumber}from"../../../internal/numbers.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{showChartActiveDatum}from"./chart-active-datum.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{FALLBACK_GRID_COLOR,FALLBACK_LEGEND_COLOR,FALLBACK_TICK_COLOR,FALLBACK_TICK_FONT_SIZE,FALLBACK_TOOLTIP_BG,FALLBACK_TOOLTIP_TEXT}from"./chart-colors.js";import{ChartTokenCache}from"./chart-token-cache.js";import{chartDataTableVisible,hasSlottedChartDataTable}from"./chart-data-table.js";import{normalizeSize}from"../../../internal/variants.js";import{createForcedColorPattern,forcedColorEncoding,forcedColorsActive}from"./chart-forced-colors.js";import{legendVisibilityDetail,normalizeHiddenDatasets}from"./chart-legend-visibility.js";import{sampleChartTableIndexes}from"./chart-table-sampling.js";import{canvasSentence,canvasTextDirection,isolateCanvasLabel,isolateCanvasText,isolatedMessage,isolateScaleTickLabels,tooltipIsolationHook,bidiStyles,isolateHtml}from"./chart-bidi.js";import{CSS_NUMBER_SOURCE}from"../../../internal/css-number.js";import{LYRA_DEFAULT_chartAnnotationsUnavailable,LYRA_DEFAULT_chartAxisTotal,LYRA_DEFAULT_chartBubblePointCoordinates,LYRA_DEFAULT_chartCategory,LYRA_DEFAULT_chartData,LYRA_DEFAULT_chartDataLabelsUnavailable,LYRA_DEFAULT_chartDataSampled,LYRA_DEFAULT_chartLabeledPoint,LYRA_DEFAULT_chartMissingLibrary,LYRA_DEFAULT_chartPlotSampled,LYRA_DEFAULT_chartPointCoordinates,LYRA_DEFAULT_chartPointLabel,LYRA_DEFAULT_chartPrimaryAxis,LYRA_DEFAULT_chartRenderUnavailable,LYRA_DEFAULT_chartSecondaryAxis,LYRA_DEFAULT_chartSeriesLabel,LYRA_DEFAULT_chartSeriesNoData,LYRA_DEFAULT_chartStackTotalsUnavailable,LYRA_DEFAULT_chartSummary,LYRA_DEFAULT_chartSummaryEmpty,LYRA_DEFAULT_chartSummarySeparator,LYRA_DEFAULT_chartSummaryWithData,LYRA_DEFAULT_chartTotal,LYRA_DEFAULT_chartTrendDecreasing,LYRA_DEFAULT_chartTrendFlat,LYRA_DEFAULT_chartTrendIncreasing,LYRA_DEFAULT_chartTypeBar,LYRA_DEFAULT_chartTypeBubble,LYRA_DEFAULT_chartTypeDoughnut,LYRA_DEFAULT_chartTypeLine,LYRA_DEFAULT_chartTypePie,LYRA_DEFAULT_chartTypePolarArea,LYRA_DEFAULT_chartTypeRadar,LYRA_DEFAULT_chartTypeScatter,LYRA_DEFAULT_chartValuePercentageLabel,LYRA_DEFAULT_chartZoomUnavailable,LYRA_DEFAULT_liteChartMarkSummary}from"../../../internal/default-strings/charts.generated.js";import{LYRA_DEFAULT_chart,LYRA_DEFAULT_chartValueLabel,LYRA_DEFAULT_loading,LYRA_DEFAULT_noData,LYRA_DEFAULT_resetZoom}from"../../../internal/default-strings/shared.generated.js";const DIRECT_PIXEL_NUMBER=new RegExp(`^(${CSS_NUMBER_SOURCE})(?:px)?$`,"i");import{seriesPalette}from"./chart-colors.js";const CHART_TYPES=new Set(["line","bar","scatter","pie","doughnut","radar","polarArea","bubble"]);function normalizeChartType(value){return typeof value=="string"&&CHART_TYPES.has(value)?value:"bar"}function normalizeChartGrid(value){return value==="x"||value==="y"||value==="none"||value==="both"?value:"both"}function normalizeLegendPosition(value){return value==="left"||value==="top"||value==="right"||value==="bottom"||value==="center"||value==="chartArea"||value==="start"||value==="end"||value==="auto"?value:projectLegendPosition(value)??"top"}function isArcDatasetType(datasetType){return datasetType==="pie"||datasetType==="doughnut"||datasetType==="polarArea"}function isPointDatasetType(datasetType){return datasetType==="line"||datasetType==="radar"||datasetType==="scatter"||datasetType==="bubble"}function isChartRecord(value){try{return typeof value=="object"&&value!==null&&!Array.isArray(value)}catch{return!1}}const MAX_CHART_INPUT_ENTRIES=1e4,CHART_INPUT_CAP_WARNING_KEY="lr-chart-input-cap",MAX_CHART_CONFIGURATION_DEPTH=32,OMIT_CHART_CONFIGURATION_VALUE=Symbol("omit-chart-configuration-value");function warnChartInputCap(){devWarnOnce(CHART_INPUT_CAP_WARNING_KEY,"lr-chart: an input array exceeded 10,000 entries; only the first 10,000 are used.")}function admitChartArray(value){return admitSnapshotArray(value,warnChartInputCap)}function copyChartArrayEntries(admission){return projectSnapshotArray(admission,value=>value,{missing:void 0})??Object.freeze([])}function chartEnumerableKeys(value){try{return Object.keys(value)}catch{return}}const canonicalChartSeriesSnapshots=new WeakMap,admittedChartPlugins=new WeakSet,canonicalChartDatasetValues=new WeakMap,canonicalChartDatasetDataValues=new WeakMap;function canonicalChartSeries(value){if(isChartRecord(value))return canonicalChartSeriesSnapshots.has(value)?value:projectChartSeries(value)}function canonicalSeriesData(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.data??[]:[]}function canonicalSeriesPoints(series){const canonical=canonicalChartSeries(series);return canonical?canonicalChartSeriesSnapshots.get(canonical)?.points:void 0}function chartRecordValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectChartNumberData(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:null,{missing:null})}function projectChartPoint(value){if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label");return x===MISSING_OWN_DATA_DESCRIPTOR||x===UNSAFE_OWN_DATA_DESCRIPTOR||y===MISSING_OWN_DATA_DESCRIPTOR||y===UNSAFE_OWN_DATA_DESCRIPTOR||r===UNSAFE_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof x.value!="number"||!Number.isFinite(x.value)||typeof y.value!="number"||!Number.isFinite(y.value)?null:Object.freeze({x:x.value,y:y.value,...r!==MISSING_OWN_DATA_DESCRIPTOR&&typeof r.value=="number"&&Number.isFinite(r.value)&&r.value>=0?{r:r.value}:{},...id!==MISSING_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))?{id:id.value}:{},...label!==MISSING_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?{label:label.value}:{}})}function projectChartDatum(value){if(typeof value=="number")return Number.isFinite(value)?value:null;if(typeof value=="string"||typeof value=="bigint")return value;if(!isChartRecord(value))return null;const x=chartRecordValue(value,"x"),y=chartRecordValue(value,"y"),r=chartRecordValue(value,"r"),id=chartRecordValue(value,"id"),label=chartRecordValue(value,"label"),output={};let hasValue=!1;for(const[property2,descriptor]of[["x",x],["y",y],["r",r]])descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value)||(output[property2]=descriptor.value,hasValue=!0);return label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"&&(output.label=label.value,hasValue=!0),id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&(typeof id.value=="string"||typeof id.value=="number"&&Number.isFinite(id.value))&&(output.id=id.value,hasValue=!0),hasValue?Object.freeze(output):null}function projectChartDatasetValues(admission){return projectSnapshotArray(admission,projectChartDatum,{missing:null})??Object.freeze([])}function projectChartPoints(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartPoint,{missing:null})}function projectChartStrings(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="string"?entry:"",{missing:""})}function projectChartPointRadii(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,entry=>typeof entry=="number"&&Number.isFinite(entry)?entry:Number.NaN,{missing:Number.NaN})}function projectHiddenDatasetIndexes(value){if(value!==void 0)return projectSnapshotArray(admitChartArray(value),entry=>typeof entry=="number"&&Number.isInteger(entry)?entry:void 0,{compact:!0})??Object.freeze([])}const CHART_ANNOTATION_TONES=new Set(["neutral","brand","success","warning","danger"]);function projectChartAnnotations(value){if(!Array.isArray(value))return Object.freeze([]);const output=[];for(const annotation of value){if(!isChartRecord(annotation))continue;const own=key=>Object.hasOwn(annotation,key)?annotation[key]:void 0,axis=own("axis"),line=own("value"),from=own("from"),to=own("to"),label=own("label"),tone=own("tone");if(axis!==void 0&&axis!=="x"&&axis!=="y"||label!==void 0&&typeof label!="string"||tone!==void 0&&(typeof tone!="string"||!CHART_ANNOTATION_TONES.has(tone)))continue;const common={...axis==="x"||axis==="y"?{axis}:{},...typeof label=="string"?{label}:{},...typeof tone=="string"?{tone}:{}};typeof line=="number"&&Number.isFinite(line)?output.push(Object.freeze({...common,value:line})):typeof from=="number"&&Number.isFinite(from)&&typeof to=="number"&&Number.isFinite(to)&&output.push(Object.freeze({...common,from:Math.min(from,to),to:Math.max(from,to)}))}return Object.freeze(output)}const CHART_SERIES_PROPERTIES=["label","data","points","color","fill","width","dash","noTooltip","axis","stack","pointColors","pointRadius","segmentColors","type"];function projectChartSeries(value){try{if(!isChartRecord(value))return;const descriptors=new Map;for(const property2 of CHART_SERIES_PROPERTIES){const descriptor=chartRecordValue(value,property2);if(descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)return;descriptors.set(property2,descriptor)}const valueAt=property2=>{const descriptor=descriptors.get(property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptor===void 0?void 0:descriptor.value},label=valueAt("label");if(label!==void 0&&typeof label!="string")return;const output={label:label??""},rawData=valueAt("data"),rawDataAdmission=admitChartArray(rawData),data=projectChartNumberData(rawData,rawDataAdmission),rawPoints=valueAt("points"),rawPointsAdmission=admitChartArray(rawPoints),points=projectChartPoints(rawPoints,rawPointsAdmission),color=valueAt("color"),fill=valueAt("fill"),width=valueAt("width"),dash=valueAt("dash"),noTooltip=valueAt("noTooltip"),axis=valueAt("axis"),stack=valueAt("stack"),pointColors=projectChartStrings(valueAt("pointColors")),pointRadius=valueAt("pointRadius"),segmentColors=projectChartStrings(valueAt("segmentColors")),type=valueAt("type");if(data&&rawDataAdmission&&(output.data=rawDataAdmission.source),points&&rawPointsAdmission&&(output.points=rawPointsAdmission.source),typeof color=="string")output.color=color;else{const colors=projectChartStrings(color);colors&&(output.color=colors)}if(typeof fill=="boolean"&&(output.fill=fill),typeof width=="number"&&Number.isFinite(width)&&(output.width=width),typeof dash=="boolean"&&(output.dash=dash),typeof noTooltip=="boolean"&&(output.noTooltip=noTooltip),(axis==="y"||axis==="y2")&&(output.axis=axis),typeof stack=="string"&&(output.stack=stack),pointColors&&(output.pointColors=pointColors),typeof pointRadius=="number"&&Number.isFinite(pointRadius))output.pointRadius=pointRadius;else{const radii=projectChartPointRadii(pointRadius);radii&&(output.pointRadius=radii)}segmentColors&&(output.segmentColors=segmentColors),(type==="line"||type==="bar")&&(output.type=type);const series=Object.freeze(output);return canonicalChartSeriesSnapshots.set(series,{data:data??Object.freeze([]),...points?{points}:{}}),series}catch{return}}function normalizeChartSeries(value){return projectSnapshotArray(admitChartArray(value),canonicalChartSeries,{compact:!0})??Object.freeze([])}function isSafeChartConfigurationRecord(value){if(!isChartRecord(value))return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype}catch{return!1}}function projectLegendPosition(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output={};for(const key of keys){if(UNSAFE_KEYS.has(key))return;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||typeof descriptor.value!="number"||!Number.isFinite(descriptor.value))return;output[key]=descriptor.value}return Object.freeze(output)}function copyChartConfigurationValue(value,profile="chart"){const snapshot=snapshotStructuredData(value,{profile,omitKeys:UNSAFE_KEYS,onArrayTruncate:warnChartInputCap,onClone:(source,copied)=>{const canonical=canonicalChartDatasetDataValues.get(source);canonical&&canonicalChartDatasetDataValues.set(copied,canonical)}});return snapshot.value===void 0&&value!==void 0?OMIT_CHART_CONFIGURATION_VALUE:snapshot.value}function projectChartPlugins(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,candidate=>{if(candidate===null||typeof candidate!="object"&&typeof candidate!="function")return;const plugin=candidate;if(admittedChartPlugins.has(plugin))return plugin;const id=chartRecordValue(plugin,"id");if(!(id===MISSING_OWN_DATA_DESCRIPTOR||id===UNSAFE_OWN_DATA_DESCRIPTOR||typeof id.value!="string"||id.value.trim()===""))return admittedChartPlugins.add(plugin),plugin},{compact:!0})??Object.freeze([])}function projectChartDatasetConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null),priorCanonicalValues=canonicalChartDatasetValues.get(value);let canonicalValues;for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const candidate=descriptor.value,array=admitChartArray(candidate);if(key==="data"){if(array){if(!chartArrayIsStillAdmitted(array)){output[key]=Object.freeze([]),canonicalValues=Object.freeze([]);continue}const copied=copyChartArrayEntries(array);output[key]=copied;const canonical=priorCanonicalValues??canonicalChartDatasetDataValues.get(array.source)??projectChartDatasetValues(array);canonicalValues=canonical,canonicalChartDatasetDataValues.set(copied,canonical)}continue}if(key==="label"){typeof candidate=="string"||typeof candidate=="number"||typeof candidate=="boolean"||typeof candidate=="bigint"?output[key]=candidate:array&&(output[key]=copyChartArrayEntries(array));continue}if(key==="hidden"||key==="noTooltip"){typeof candidate=="boolean"&&(output[key]=candidate);continue}if(key==="axis"||key==="yAxisID"||key==="type"||key==="stack"){typeof candidate=="string"&&(output[key]=candidate);continue}output[key]=array?copyChartArrayEntries(array):candidate}const dataset=Object.freeze(output);return canonicalValues&&canonicalChartDatasetValues.set(dataset,canonicalValues),dataset}function projectChartDatasetConfigurations(value,admission=admitChartArray(value)){return projectSnapshotArray(admission,projectChartDatasetConfiguration,{compact:!0})??Object.freeze([])}function projectChartDataConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)){if(key==="labels"){const labels=admitChartArray(descriptor.value);output[key]=labels?copyChartArrayEntries(labels):Object.freeze([]);continue}if(key==="datasets"){output[key]=projectChartDatasetConfigurations(descriptor.value);continue}output[key]=descriptor.value}}return Object.freeze(output)}function projectChartConfiguration(value){if(!isSafeChartConfigurationRecord(value))return;const output=Object.create(null),type=chartRecordValue(value,"type"),data=chartRecordValue(value,"data"),options=chartRecordValue(value,"options"),plugins=chartRecordValue(value,"plugins");type!==MISSING_OWN_DATA_DESCRIPTOR&&type!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof type.value=="string"&&(output.type=type.value);for(const[property2,descriptor]of[["data",data],["options",options]]){if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const copied=copyChartConfigurationValue(descriptor.value,property2==="data"?"chartData":"chart");if(copied!==OMIT_CHART_CONFIGURATION_VALUE){if(property2==="data"){const projected=projectChartDataConfiguration(copied);output[property2]=projected??copied;continue}output[property2]=copied}}if(plugins!==MISSING_OWN_DATA_DESCRIPTOR&&plugins!==UNSAFE_OWN_DATA_DESCRIPTOR){const pluginArray=admitChartArray(plugins.value);if(pluginArray)output.plugins=projectChartPlugins(plugins.value,pluginArray);else{const copied=copyChartConfigurationValue(plugins.value);copied!==OMIT_CHART_CONFIGURATION_VALUE&&(output.plugins=copied)}}return Object.freeze(output)}const UNSAFE_KEYS=new Set(["__proto__","constructor","prototype"]);function deepMerge(base,override,seen=new WeakMap){if(!isSafeChartConfigurationRecord(base)||!isSafeChartConfigurationRecord(override))return override===void 0?base:override;const baseRecord=base,overrideRecord=override,baseKeys=chartEnumerableKeys(baseRecord),overrideKeys=chartEnumerableKeys(overrideRecord);if(!baseKeys||!overrideKeys)return override;const previous=seen.get(overrideRecord);if(previous!==void 0)return previous;const result={};for(const key of baseKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(baseRecord,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(result[key]=descriptor.value)}seen.set(overrideRecord,result);try{for(const key of overrideKeys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(overrideRecord,key);if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable)continue;const baseDescriptor=chartRecordValue(baseRecord,key),baseValue=baseDescriptor===MISSING_OWN_DATA_DESCRIPTOR||baseDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:baseDescriptor.value;result[key]=deepMerge(baseValue,descriptor.value,seen)}}finally{seen.delete(overrideRecord)}return result}function normalizedChartPoint(value){return projectChartPoint(projectChartDatum(value))}function chartNumericValue(value){const numeric=typeof value=="number"?value:typeof value=="string"||typeof value=="bigint"?Number(value):Number.NaN;return Number.isFinite(numeric)?numeric:void 0}function chartDatumNumericValue(value){const projected=projectChartDatum(value);if(isChartRecord(projected))for(const property2 of["y","r","x"]){const descriptor=chartRecordValue(projected,property2);if(descriptor!==MISSING_OWN_DATA_DESCRIPTOR&&descriptor!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof descriptor.value=="number"&&Number.isFinite(descriptor.value))return descriptor.value}return chartNumericValue(projected)}function nonNegativeFinite(value,fallback){return typeof value=="number"&&Number.isFinite(value)&&value>=0?value:fallback}function labelText(value,depth=0){if(value==null)return"";if(typeof value=="string"||typeof value=="number"||typeof value=="boolean"||typeof value=="bigint")return String(value);const admission=admitChartArray(value);if(depth<MAX_CHART_CONFIGURATION_DEPTH&&admission){const values=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));values.push(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?"":labelText(descriptor.value,depth+1))}return values.join(" ")}return""}function chartDatasetValue(dataset,property2){if(!isChartRecord(dataset))return;const descriptor=chartRecordValue(dataset,property2);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function chartDatasetLabel(dataset){return labelText(chartDatasetValue(dataset,"label"))}function chartDatasetValues(dataset){if(isChartRecord(dataset)){const snapshot=canonicalChartDatasetValues.get(dataset);if(snapshot)return snapshot}const data=chartDatasetValue(dataset,"data"),admission=admitChartArray(data);return admission?canonicalChartDatasetDataValues.get(admission.source)??copyChartArrayEntries(admission):Object.freeze([])}function chartDatasetPeerValues(dataset){const admission=admitChartArray(chartDatasetValue(dataset,"data"));return admission?copyChartArrayEntries(admission):Object.freeze([])}function chartIndex(value){return typeof value=="number"&&Number.isSafeInteger(value)&&value>=0?value:void 0}function chartCallbackDatasetIndex(value){return chartIndex(chartDatasetValue(value,"datasetIndex"))}function chartCallbackIndexes(value){const datasetIndex=chartCallbackDatasetIndex(value),index=chartIndex(chartDatasetValue(value,"index"))??chartIndex(chartDatasetValue(value,"dataIndex"));return datasetIndex===void 0||index===void 0?void 0:{datasetIndex,index}}function projectChartLegendItem(value){if(!isChartRecord(value))return;const keys=chartEnumerableKeys(value);if(!keys||keys.length>MAX_CHART_INPUT_ENTRIES)return;const output=Object.create(null);for(const key of keys){if(UNSAFE_KEYS.has(key))continue;const descriptor=chartRecordValue(value,key);descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!descriptor.enumerable||(output[key]=descriptor.value)}return output}function projectChartLegendItems(value){const admission=admitChartArray(value);if(!admission||!chartArrayIsStillAdmitted(admission))return;const output=[];for(let index=0;index<admission.length;index+=1){const descriptor=chartRecordValue(admission.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectChartLegendItem(descriptor.value);item&&output.push(item)}return Object.freeze(output)}function chartDatasetBoolean(dataset,property2){const value=chartDatasetValue(dataset,property2);return typeof value=="boolean"?value:void 0}function chartDatasetAxis(dataset){return chartDatasetValue(dataset,"yAxisID")==="y2"||chartDatasetValue(dataset,"axis")==="y2"?"y2":"y"}function chartDatasetStack(dataset){const value=chartDatasetValue(dataset,"stack");return typeof value=="string"?value:void 0}function isDenseChartSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChart extends LyraElement{static{this.defaultStrings={...super.defaultStrings,chart:LYRA_DEFAULT_chart,chartAnnotationsUnavailable:LYRA_DEFAULT_chartAnnotationsUnavailable,chartAxisTotal:LYRA_DEFAULT_chartAxisTotal,chartBubblePointCoordinates:LYRA_DEFAULT_chartBubblePointCoordinates,chartCategory:LYRA_DEFAULT_chartCategory,chartData:LYRA_DEFAULT_chartData,chartDataLabelsUnavailable:LYRA_DEFAULT_chartDataLabelsUnavailable,chartDataSampled:LYRA_DEFAULT_chartDataSampled,chartLabeledPoint:LYRA_DEFAULT_chartLabeledPoint,chartMissingLibrary:LYRA_DEFAULT_chartMissingLibrary,chartPlotSampled:LYRA_DEFAULT_chartPlotSampled,chartPointCoordinates:LYRA_DEFAULT_chartPointCoordinates,chartPointLabel:LYRA_DEFAULT_chartPointLabel,chartPrimaryAxis:LYRA_DEFAULT_chartPrimaryAxis,chartRenderUnavailable:LYRA_DEFAULT_chartRenderUnavailable,chartSecondaryAxis:LYRA_DEFAULT_chartSecondaryAxis,chartSeriesLabel:LYRA_DEFAULT_chartSeriesLabel,chartSeriesNoData:LYRA_DEFAULT_chartSeriesNoData,chartStackTotalsUnavailable:LYRA_DEFAULT_chartStackTotalsUnavailable,chartSummary:LYRA_DEFAULT_chartSummary,chartSummaryEmpty:LYRA_DEFAULT_chartSummaryEmpty,chartSummarySeparator:LYRA_DEFAULT_chartSummarySeparator,chartSummaryWithData:LYRA_DEFAULT_chartSummaryWithData,chartTotal:LYRA_DEFAULT_chartTotal,chartTrendDecreasing:LYRA_DEFAULT_chartTrendDecreasing,chartTrendFlat:LYRA_DEFAULT_chartTrendFlat,chartTrendIncreasing:LYRA_DEFAULT_chartTrendIncreasing,chartTypeBar:LYRA_DEFAULT_chartTypeBar,chartTypeBubble:LYRA_DEFAULT_chartTypeBubble,chartTypeDoughnut:LYRA_DEFAULT_chartTypeDoughnut,chartTypeLine:LYRA_DEFAULT_chartTypeLine,chartTypePie:LYRA_DEFAULT_chartTypePie,chartTypePolarArea:LYRA_DEFAULT_chartTypePolarArea,chartTypeRadar:LYRA_DEFAULT_chartTypeRadar,chartTypeScatter:LYRA_DEFAULT_chartTypeScatter,chartValueLabel:LYRA_DEFAULT_chartValueLabel,chartValuePercentageLabel:LYRA_DEFAULT_chartValuePercentageLabel,chartZoomUnavailable:LYRA_DEFAULT_chartZoomUnavailable,liteChartMarkSummary:LYRA_DEFAULT_liteChartMarkSummary,loading:LYRA_DEFAULT_loading,noData:LYRA_DEFAULT_noData,resetZoom:LYRA_DEFAULT_resetZoom}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-legend-visibility-change-request","lr-legend-visibility-change","lr-datum-visibility-change-request","lr-datum-visibility-change"])}static{this.ownedCollectionProperties=Object.freeze(["annotations","hiddenDatasets"])}static{this.styles=[LyraElement.styles,specialistTokens,chartSurfaceStyles,styles,srOnly,bidiStyles]}constructor(){super(),this.canvasTokens=new ChartTokenCache(this),this.type="bar",this.labels=[],this._datasets=Object.freeze([]),this.datasetsSource=this._datasets,this._hiddenDatums=Object.freeze([]),this.hiddenDatumsSource=this._hiddenDatums,this.legendMode="auto",this.legendDisplay="auto",this.description=null,this.grid="both",this.axes="both",this.size="m",this.indexAxis="x",this.label=null,this.legendPosition="top",this.scaleType="linear",this.annotations=[],this.max=null,this.min=null,this._plugins=Object.freeze([]),this.pluginsSource=this._plugins,this.area=!1,this.zoomable=!1,this.height="280px",this.xLabel=null,this.yLabel=null,this.y2Label="",this.withoutZeroBaseline=!1,this.withDataTable=!1,this.dataTableToggle=!1,this.dataTableExpandedOverride=null,this.dataTableId=nextId("chart-data-table"),this.stacked=!1,this.withoutAnimation=!1,this.withoutLegend=!1,this.withoutTooltip=!1,this.dataLabels=!1,this.stackTotals=!1,this.configSource=void 0,this.loading=!0,this.loadFailed=!1,this.canvasUnavailable=!1,this.loadLibrary=withZoom=>withZoom?loadChartJsWithZoom():loadChartJs(),this.loadZoomFeature=()=>loadChartJsWithZoomResult(),this.loadDataLabelsFeature=()=>loadChartJsWithDataLabelsResult(),this.loadAnnotationFeature=()=>loadChartJsWithAnnotationResult(),this.loadGeneration=0,this.zoomLoadGeneration=0,this.dataLabelsLoadGeneration=0,this.annotationLoadGeneration=0,this.zoomFeatureState="idle",this.dataLabelsFeatureState="idle",this.annotationFeatureState="idle",this.zoomed=!1,this.visible=!0,this.intersectionGeneration=0,this.reducedMotionWatch=createReducedMotionWatch(this,()=>this.drawIfVisible()),this.scaledSliceDatasets=new Set,this.autoLegendPosition="right",this.chartAreaUpdateQueued=!1,this.chartAreaPlugin={id:"lyra-chart-area",afterLayout:chart=>this.updateChartArea(chart),beforeTooltipDraw:tooltipIsolationHook(()=>this.effectiveDirection)},this.builtPlugins=[],this.suppressZoomComplete=!1,this.descriptionId=nextId("chart-description"),this.keyboardDatumIndex=0,this.keyboardDatumAnnouncement="",this.announcements=new AnnouncementSinkController(this),this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings=new Set,this.syncGroup="",this.chartSync=new LazyChartSyncController(this,(label,index)=>this.syncPresentation(label,index),()=>this.resetSyncTooltip(),target=>target===this.canvasEl),this.forcedColorPatterns=new Map,this.visualPositions=new WeakMap,this.keyboardDatumShown=!1,this.onCanvasBlur=()=>{this.showKeyboardDatum(void 0)},new ThemeWatcher(this,()=>{this.chart&&this.canvasTokens.hasThemeChanged()&&this.refreshTheme()})}canonicalLabels(){const source=this.labels;if(this.labelsSnapshot&&Object.is(this.labelsSnapshot.source,source))return this.labelsSnapshot.value;const value=projectChartStrings(source)??Object.freeze([]);return this.labelsSnapshot={source,value},value}canonicalAnnotations(){const source=this.annotations;if(this.annotationsSnapshot&&Object.is(this.annotationsSnapshot.source,source))return this.annotationsSnapshot.value;const value=projectChartAnnotations(source);return this.annotationsSnapshot={source,value},value}canonicalHiddenDatasets(){const source=this.hiddenDatasets;if(this.hiddenDatasetsSnapshot&&Object.is(this.hiddenDatasetsSnapshot.source,source))return this.hiddenDatasetsSnapshot.value;const value=source===void 0?void 0:Object.freeze(Array.isArray(source)?source.filter(index=>typeof index=="number"&&Number.isInteger(index)):[]);return this.hiddenDatasetsSnapshot={source,value},value}get datasets(){return this._datasets}set datasets(value){if(Object.is(value,this.datasetsSource)||Object.is(value,this._datasets))return;const previous=this._datasets;this._datasets=normalizeChartSeries(value),this.datasetsSource=value,this.requestUpdate("datasets",previous)}get hiddenDatums(){return this._hiddenDatums}set hiddenDatums(value){if(Object.is(value,this.hiddenDatumsSource)||Object.is(value,this._hiddenDatums))return;const previous=this._hiddenDatums;this._hiddenDatums=projectHiddenDatasetIndexes(value)??Object.freeze([]),this.hiddenDatumsSource=value,this.requestUpdate("hiddenDatums",previous)}get compactPlot(){return isDenseChartSize(this.size)}get plugins(){return this._plugins}set plugins(value){if(Object.is(value,this.pluginsSource)||Object.is(value,this._plugins))return;const previous=this._plugins;this._plugins=projectChartPlugins(value),this.pluginsSource=value,this.requestUpdate("plugins",previous)}get dataTableVisible(){return chartDataTableVisible(this.withDataTable,this.dataTableToggle,this.dataTableExpandedOverride)}toggleDataTable(){this.dataTableExpandedOverride=!this.dataTableVisible}get config(){return this._config}set config(value){if(Object.is(value,this.configSource)||value!==void 0&&Object.is(value,this._config))return;const previous=this._config;this._config=projectChartConfiguration(value),this.configSource=value,this.requestUpdate("config",previous)}normalizeEffectiveConfig(config){return config}effectiveConfig(){return this.normalizeEffectiveConfig(this.config??this.slottedConfig)}onConfigSlotChange(event){const slot=event.currentTarget;slot===this.configSlotEl&&this.collectConfigFromSlot(slot)}collectConfigFromSlot(slot){const script=slot.assignedElements({flatten:!0}).find(element=>element.localName==="script"&&element.type.trim().toLowerCase()==="application/json");let next;if(script)try{const parsed=JSON.parse(script.textContent??"");next=projectChartConfiguration(parsed)}catch{next=void 0}this.slottedConfig=next}effectiveData(){const labels=this.canonicalLabels(),datasets=this.datasets,config=this.config??this.slottedConfig,memo=this.effectiveDataMemo;if(memo?.labels===labels&&memo.datasets===datasets&&memo.config===config)return memo.value;const generated={labels:[...labels],datasets:datasets.map(series=>{const{points:_points,...safeSeries}=series,values=canonicalSeriesPoints(series)??canonicalSeriesData(series),data=[...values];Object.freeze(data);const dataset={...safeSeries,data,yAxisID:series.axis==="y2"?"y2":"y"};return canonicalChartDatasetValues.set(dataset,values),Object.freeze(dataset)})};Object.freeze(generated.labels),Object.freeze(generated.datasets);const override=projectChartDataConfiguration(this.effectiveConfig()?.data);let value=generated;if(override){const projected=projectChartDataConfiguration(deepMerge(generated,override));value={labels:projected?.labels??[],datasets:projected?.datasets??[]}}return this.effectiveDataMemo={labels,datasets,config,value},value}callbackDatasetIndex(value,effective=this.effectiveData()){const datasetIndex=chartCallbackDatasetIndex(value);if(datasetIndex===void 0)return;const visualDatasetCount=this.visualDatasetSourceIndexes?.length??effective.datasets.length;if(datasetIndex>=visualDatasetCount)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[datasetIndex]??datasetIndex;return effective.datasets[sourceDatasetIndex]?datasetIndex:void 0}callbackIndexes(value,effective=this.effectiveData()){const hit=chartCallbackIndexes(value);if(!hit)return;const visualDatasetCount=this.visualDatasetSourceIndexes?.length??effective.datasets.length;if(hit.datasetIndex>=visualDatasetCount)return;const sourceDatasetIndex=this.visualDatasetSourceIndexes?.[hit.datasetIndex]??hit.datasetIndex,dataset=effective.datasets[sourceDatasetIndex];if(!dataset)return;const visualRowCount=this.visualRowSourceIndexes?.length??this.datasetValues(dataset).length;return hit.index<visualRowCount?hit:void 0}effectiveHiddenDatasetIndexes(){const effective=this.effectiveData(),controlled=normalizeHiddenDatasets(this.canonicalHiddenDatasets(),effective.datasets.length);return controlled!==void 0?controlled:effective.datasets.flatMap((dataset,index)=>chartDatasetBoolean(dataset,"hidden")===!0?[index]:[])}applyDatasetVisibility(){if(!this.chart)return!1;const chart=this.chart,sourceDatasetCount=this.effectiveData().datasets.length,datasetCount=this.visualDatasetSourceIndexes?.length??sourceDatasetCount,controlled=normalizeHiddenDatasets(this.canonicalHiddenDatasets(),sourceDatasetCount);if(controlled===void 0){for(let index=0;index<datasetCount;index++)try{const metadata=chart.getDatasetMeta?.(index);metadata&&(metadata.hidden=null)}catch{}return datasetCount>0}const hidden=new Set(controlled);for(let index=0;index<datasetCount;index++){const sourceIndex=this.visualDatasetSourceIndexes?.[index]??index;try{chart.setDatasetVisibility(index,!hidden.has(sourceIndex))}catch{}}return datasetCount>0}isSliceChart(){return["pie","doughnut","polarArea"].includes(this.effectiveType())}applyDatumVisibility(){if(!this.chart||!this.isSliceChart())return!1;const sample=this.dataTableSample(),rows=this.visualRowSourceIndexes,hidden=new Set(normalizeHiddenDatasets(this.hiddenDatums,sample.rowCount));let changed=!1;for(let index=0;index<(rows?.length??sample.rowCount);index++){const visible=!hidden.has(rows?.[index]??index);try{this.chart.getDataVisibility?.(index)===!visible&&(this.chart.toggleDataVisibility?.(index),changed=!0)}catch{}}return changed}hasExplicitConfigData(){const config=this.effectiveConfig();if(!isSafeChartConfigurationRecord(config))return!1;const data=chartRecordValue(config,"data");return data!==MISSING_OWN_DATA_DESCRIPTOR&&data!==UNSAFE_OWN_DATA_DESCRIPTOR}datasetLabel(dataset,index){return chartDatasetLabel(dataset)||this.localize("chartPointLabel",void 0,{n:getNumberFormat(this.effectiveLocale).format(index+1)})}datasetValues(dataset){return chartDatasetValues(dataset)}isPointDataset(dataset){const values=this.datasetValues(dataset);return this.effectiveType()==="scatter"||this.effectiveType()==="bubble"||values.some(value=>normalizedChartPoint(value)!==null)}appendData(label,values,maxPoints=0){const requested=Number.isFinite(maxPoints)?Math.max(0,Math.floor(maxPoints)):0,limit=requested>0?Math.min(requested,MAX_CHART_INPUT_ENTRIES):MAX_CHART_INPUT_ENTRIES,appendedValues=projectChartNumberData(values)??Object.freeze([]);if(this.hasExplicitConfigData()){const effective=this.effectiveData();let domainLength2=effective.labels.length;for(const dataset of effective.datasets)this.isPointDataset(dataset)||(domainLength2=Math.max(domainLength2,this.datasetValues(dataset).length));const labels2=[...effective.labels,...Array.from({length:Math.max(0,domainLength2-effective.labels.length)},()=>""),label],effectiveConfig=this.effectiveConfig(),currentData=projectChartDataConfiguration(effectiveConfig?.data)??{},explicitLabels=admitChartArray(currentData.labels)!==void 0,explicitDatasets=admitChartArray(currentData.datasets)!==void 0,nextLabels=labels2.slice(-limit);if(explicitLabels||(this.labels=nextLabels.map(labelText)),!explicitDatasets){const datasets2=this.datasets.map((series,index)=>{if(canonicalSeriesPoints(series)!==void 0)return series;const current=canonicalSeriesData(series),data=[...current,...Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),appendedValues[index]??null];return{...series,data:data.slice(-limit)}});this.datasets=datasets2}if(explicitLabels||explicitDatasets){const nextData={...currentData};explicitLabels&&(nextData.labels=nextLabels),explicitDatasets&&(nextData.datasets=effective.datasets.map((dataset,index)=>{if(this.isPointDataset(dataset))return dataset;const current=this.datasetValues(dataset),peer=chartDatasetPeerValues(dataset),padding=Array.from({length:Math.max(0,domainLength2-current.length)},()=>null),data=[...peer,...padding,appendedValues[index]??null],canonical=[...current,...padding,appendedValues[index]??null],nextData2=data.slice(-limit),nextCanonical=canonical.slice(-limit);return canonicalChartDatasetDataValues.set(nextData2,Object.freeze(nextCanonical)),{...dataset,data:nextData2}})),this.config={...effectiveConfig,data:nextData}}return}const currentLabels=this.canonicalLabels();let domainLength=currentLabels.length;for(const series of this.datasets)canonicalSeriesPoints(series)===void 0&&(domainLength=Math.max(domainLength,canonicalSeriesData(series).length));const labels=[...currentLabels,...Array.from({length:Math.max(0,domainLength-currentLabels.length)},()=>""),label],datasets=this.datasets.map((series,index)=>{if(canonicalSeriesPoints(series)!==void 0)return series;const current=canonicalSeriesData(series),data=[...current,...Array.from({length:Math.max(0,domainLength-current.length)},()=>null),appendedValues[index]??null];return{...series,data:data.slice(-limit)}});this.labels=labels.slice(-limit),this.datasets=datasets}exportData(format){if(format==="png")return this.chart?.toBase64Image?.()??"";const effective=this.effectiveData(),columns=effective.datasets.map((dataset,datasetIndex)=>{const values=this.datasetValues(dataset),label=this.datasetLabel(dataset,datasetIndex),points=values.map(normalizedChartPoint).filter(point=>point!==null);return{dataset,label,point:this.isPointDataset(dataset),radius:points.some(point=>point.r!=null),pointLabel:points.some(point=>point.label!=null)}}),header=["label",...columns.flatMap(column=>column.point?[`${column.label} x`,`${column.label} y`,...column.radius?[`${column.label} r`]:[],...column.pointLabel?[`${column.label} label`]:[]]:[column.label])].map(escapeCsvField).join(",");let rowCount=effective.labels.length;for(const dataset of effective.datasets)rowCount=Math.max(rowCount,this.datasetValues(dataset).length);const exportCell=(value,metadata)=>typeof value!="number"||!Number.isFinite(value)?value??"":this.formatExportValue(value,metadata)??value,rows=Array.from({length:rowCount},(_,index)=>{const firstPoint=effective.datasets.map(dataset=>normalizedChartPoint(this.datasetValues(dataset)[index])).find(point=>point!==null),label=labelText(effective.labels[index])||firstPoint?.label||"";return[label,...columns.flatMap((column,datasetIndex)=>{const value=this.datasetValues(column.dataset)[index],axis=this.datasetValueAxis(column.dataset),metadata={datasetIndex,index,label:label||void 0,seriesLabel:column.label,...axis===void 0?{}:{axis}};if(!column.point)return[exportCell(value,metadata)];const point=normalizedChartPoint(value);return point?[exportCell(point.x,{...metadata,statistic:"x"}),exportCell(point.y,{...metadata,statistic:"y"}),...column.radius?[point.r==null?"":exportCell(point.r,{...metadata,statistic:"r"})]:[],...column.pointLabel?[point.label??""]:[]]:["","",...column.radius?[""]:[],...column.pointLabel?[""]:[]]})].map(escapeCsvField).join(",")});return[header,...rows].join(`\r
2
+ `)}connectedCallback(){super.connectedCallback(),this.stopAnnotationRegistrationWatch?.(),this.stopAnnotationRegistrationWatch=onAnnotationPluginRegistered(()=>this.rebuildAfterAnnotationRegistration()),this.visible=!this.ownerWindow?.IntersectionObserver,this.armReducedMotionWatcher();const ownerWindow=this.ownerWindow,ResizeObserverCtor=ownerWindow?.ResizeObserver;ResizeObserverCtor&&(this.resizeObserver=new ResizeObserverCtor(entries=>{const width=entries[0]?.contentRect.width??this.getBoundingClientRect().width;if(Number.isFinite(width)&&this.lastObservedInlineSize!==void 0&&Math.abs(width-this.lastObservedInlineSize)<.5||(this.lastObservedInlineSize=width,this.resizeDrawFrame!==void 0))return;const frameOwner=this.ownerWindow;frameOwner&&(this.resizeDrawFrameOwner=frameOwner,this.resizeDrawFrame=frameOwner.requestAnimationFrame(()=>{this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,!(!this.isConnected||this.ownerWindow!==frameOwner)&&(this.updateAutoLegendPosition()||this.drawIfVisible())}))}),this.resizeObserver.observe(this)),this.updateAutoLegendPosition();const generation=++this.loadGeneration;this.zoomable&&this.requestZoomFeature(),this.loadLibrary(this.zoomable).then(async mod=>{try{await this.updateComplete}catch{return}if(await new Promise(resolve=>this.updateBrowserDerivedState(resolve)),!(generation!==this.loadGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.loadFailed=!0;return}this.loadFailed=!1,this.chartJsModule=mod,this.drawIfVisible()}}),this.needsDataLabels&&this.requestDataLabelsFeature(),this.needsAnnotations&&this.requestAnnotationFeature();const IntersectionObserverCtor=ownerWindow?.IntersectionObserver;if(IntersectionObserverCtor){const observerGeneration=++this.intersectionGeneration,observer=new IntersectionObserverCtor(entries=>{if(observerGeneration!==this.intersectionGeneration||this.intersectionObserver!==observer||!this.isConnected||this.ownerWindow!==ownerWindow)return;const wasVisible=this.visible;this.visible=entries[0]?.isIntersecting??!0,this.visible&&!wasVisible&&this.drawIfVisible()});this.intersectionObserver=observer,observer.observe(this)}}disconnectedCallback(){this.chartSync.disconnect(),super.disconnectedCallback(),this.stopAnnotationRegistrationWatch?.(),this.stopAnnotationRegistrationWatch=void 0,this.lastDataTruncationAnnouncement="",this.isMounting=!0,this.announcedFeatureWarnings.clear(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.resizeDrawFrame!==void 0&&this.resizeDrawFrameOwner?.cancelAnimationFrame(this.resizeDrawFrame),this.resizeDrawFrame=void 0,this.resizeDrawFrameOwner=void 0,this.lastObservedInlineSize=void 0,this.loadGeneration+=1,this.zoomLoadGeneration+=1,this.dataLabelsLoadGeneration+=1,this.annotationLoadGeneration+=1,this.discardChart(!1),this.builtPlugins=[],this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.intersectionGeneration+=1,this.visible=!0,this.disarmReducedMotionWatcher()}adoptedCallback(){this.chartSync.disconnect(),this.canvasTokens.clear(),super.adoptedCallback(),this.announcements.adopted(),this.requestUpdate(),this.disarmReducedMotionWatcher(),this.armReducedMotionWatcher()}armReducedMotionWatcher(){this.reducedMotionWatch.arm()}disarmReducedMotionWatcher(){this.reducedMotionWatch.disarm()}get ownerWindow(){return this.ownerDocument?.defaultView??void 0}computedStyle(element=this){const view=this.ownerWindow;return view?view.getComputedStyle(element):"style"in element?element.style:this.style}applyDataLabelsPlugin(plugin){this.dataLabelsPlugin=plugin;let rebuilt=!1;plugin&&this.needsDataLabels&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],rebuilt=!0),this.drawIfVisible(),rebuilt&&this.showsLegend&&this.requestUpdate()}get zoomFeatureAvailable(){return this.zoomable&&this.zoomFeatureState==="available"}featureWarningMessages(){if(this.loading||this.loadFailed)return[];const messages=[];return this.zoomable&&this.zoomFeatureState==="unavailable"&&messages.push(this.localize("chartZoomUnavailable")),this.dataLabelsFeatureState==="unavailable"&&(this.dataLabels&&messages.push(this.localize("chartDataLabelsUnavailable")),this.stackTotals&&messages.push(this.localize("chartStackTotalsUnavailable"))),this.needsAnnotations&&this.annotationFeatureState==="unavailable"&&messages.push(this.localize("chartAnnotationsUnavailable")),messages}requestZoomFeature(){const generation=++this.zoomLoadGeneration;if(!this.zoomable){this.zoomFeatureState="idle";return}this.zoomFeatureState="loading",this.loadZoomFeature().then(result=>{generation!==this.zoomLoadGeneration||!this.isConnected||!this.zoomable||(this.zoomFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.drawIfVisible(),this.requestUpdate())})}requestAnnotationFeature(){const generation=++this.annotationLoadGeneration;if(!this.needsAnnotations){this.annotationFeatureState="idle";return}this.annotationFeatureState="loading",this.loadAnnotationFeature().then(result=>{generation!==this.annotationLoadGeneration||!this.isConnected||!this.needsAnnotations||(result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.annotationFeatureState=result.kind==="available"?"available":"unavailable",this.applyAnnotationPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}applyAnnotationPlugin(plugin){this.annotationPlugin=plugin,plugin&&this.needsAnnotations&&this.chart&&(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[]),this.drawIfVisible()}rebuildAfterAnnotationRegistration(){!this.chart||this.needsAnnotations||(this.discardChart(!0),this.builtType=void 0,this.builtPlugins=[],this.drawIfVisible())}requestDataLabelsFeature(){const generation=++this.dataLabelsLoadGeneration;if(!this.needsDataLabels){this.dataLabelsFeatureState="idle";return}this.dataLabelsFeatureState="loading",this.loadDataLabelsFeature().then(result=>{generation!==this.dataLabelsLoadGeneration||!this.isConnected||!this.needsDataLabels||(this.dataLabelsFeatureState=result.kind==="available"?"available":"unavailable",result.kind!=="core-unavailable"&&!this.loading&&!this.chartJsModule&&(this.chartJsModule=result.mod),this.applyDataLabelsPlugin(result.kind==="available"?result.plugin:void 0),this.requestUpdate())})}willUpdate(changed){super.willUpdate(changed),this.zoomed&&this.effectiveType()!==this.builtType&&(this.zoomed=!1,this.emit("lr-zoom",{zoomed:!1}))}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{collectInitialSlotAssignment(this.configSlotEl,s=>this.collectConfigFromSlot(s))})}updated(changed){super.updated(changed);const appliedVisibility=this.appliedLegendVisibility;if(this.appliedLegendVisibility=void 0,!this.isConnected)return;let canvasChanges=changed;changed.has("hiddenDatasets")&&appliedVisibility!==void 0&&appliedVisibility.chart===this.chart&&appliedVisibility.hidden===this.canonicalHiddenDatasets()&&(canvasChanges=new Map(changed),canvasChanges.delete("hiddenDatasets"));const contentChanged=this.chartContentChanged(canvasChanges),syncDataChanged=contentChanged||changed.has("hiddenDatasets")||changed.has("hiddenDatums");this.chartSync.update(this.syncGroup,typeof this.syncGroup=="string"&&this.syncGroup.trim()!==""&&this.syncCompatible(),syncDataChanged);const wasMounting=this.isMounting;this.isMounting=!1,changed.has("keyboardDatumAnnouncement")&&changed.get("keyboardDatumAnnouncement")!==void 0&&this.keyboardDatumAnnouncement!==""&&this.announcements.announcePolite(this.keyboardDatumAnnouncement),changed.has("loadFailed")&&changed.get("loadFailed")!==void 0&&this.loadFailed&&this.announcements.announceAssertive(this.localize("chartMissingLibrary"));const dataTruncation=this.dataTruncationMessage();if(wasMounting&&(this.lastDataTruncationAnnouncement=dataTruncation),!this.loading&&!this.loadFailed){const featureWarnings=this.featureWarningMessages();for(const warning of featureWarnings)this.announcedFeatureWarnings.has(warning)||this.announcements.announceAssertive(warning);this.announcedFeatureWarnings=new Set(featureWarnings),!wasMounting&&dataTruncation!==this.lastDataTruncationAnnouncement&&(this.lastDataTruncationAnnouncement=dataTruncation,dataTruncation&&this.announcements.announcePolite(dataTruncation))}if(this.setAttribute("aria-busy",String(this.loading)),changed.has("height")){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--_lr-chart-height",height):this.style.removeProperty("--_lr-chart-height")}if(this.loading)return;changed.has("zoomable")&&this.requestZoomFeature(),(changed.has("dataLabels")||changed.has("stackTotals"))&&this.requestDataLabelsFeature(),changed.has("annotations")&&this.requestAnnotationFeature();const effectiveDirection=this.effectiveDirection,effectiveLocale=this.effectiveLocale,contextChanged=this.lastDrawnDirection!==void 0&&this.lastDrawnDirection!==effectiveDirection||this.lastDrawnLocale!==void 0&&this.lastDrawnLocale!==effectiveLocale;if(this.lastDrawnDirection=effectiveDirection,this.lastDrawnLocale=effectiveLocale,!contentChanged&&!contextChanged){changed.has("hiddenDatums")&&this.visible&&this.applyDatumVisibility()&&this.chart?.update("none");return}this.drawIfVisible()}chartContentChanged(changed){return["type","labels","datasets","hiddenDatasets","grid","axes","size","indexAxis","legendPosition","min","max","scaleType","annotations","plugins","autoLegendPosition","valueFormatter","formatter","tooltipTitleFormatter","tooltipFooterFormatter","area","height","xLabel","yLabel","y2Label","withoutZeroBaseline","stacked","stackedAxes","withoutAnimation","withoutLegend","withoutTooltip","syncGroup","dataLabels","stackTotals","config","slottedConfig","zoomable","locale","strings","loading"].some(name=>changed.has(name))}seriesToDataset(s,index,palette,effectiveType,chartStyle=this.chartStyleOptions(palette),rowIndexes){const series=canonicalChartSeries(s);if(!series)return{label:"",data:[]};const points=canonicalSeriesPoints(series),values=points??canonicalSeriesData(series),normalize=points?normalizedChartPoint:value=>typeof value=="number"&&Number.isFinite(value)?value:null,normalizedData=rowIndexes?rowIndexes.map(rowIndex=>normalize(values[rowIndex])):values.map(normalize),borderFallback=chartStyle.borderColors[index%chartStyle.borderColors.length]??palette[index%palette.length],fillFallback=chartStyle.fillColors[index%chartStyle.fillColors.length]??palette[index%palette.length],sourceColors=projectChartStrings(series.color),authoredColors=sourceColors&&rowIndexes?rowIndexes.map(rowIndex=>sourceColors[rowIndex]??""):typeof series.color=="string"?series.color:sourceColors,colors=typeof authoredColors=="string"?[this.canvasTokens.resolve(authoredColors,borderFallback??"transparent")]:authoredColors?this.canvasTokens.resolveMany(authoredColors,borderFallback??"transparent"):void 0,sliceChart=effectiveType==="pie"||effectiveType==="doughnut"||effectiveType==="polarArea",sliceFillColors=sliceChart&&chartStyle.fillColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.fillColors[sourceIndex%chartStyle.fillColors.length]}):void 0,sliceBorderColors=sliceChart&&chartStyle.borderColors.length?normalizedData.map((_,itemIndex)=>{const sourceIndex=rowIndexes?.[itemIndex]??itemIndex;return chartStyle.borderColors[sourceIndex%chartStyle.borderColors.length]}):void 0,fill=series.fill??this.area,backgroundColor=colors??sliceFillColors??fillFallback,datasetType=series.type??effectiveType,authoredSegmentColors=series.segmentColors?.length&&rowIndexes?rowIndexes.map(rowIndex=>series.segmentColors[rowIndex%series.segmentColors.length]):series.segmentColors,segmentColors=authoredSegmentColors?this.canvasTokens.resolveMany(authoredSegmentColors,colors?.[0]??borderFallback??"transparent"):void 0,authoredPointColors=series.pointColors&&rowIndexes?rowIndexes.map(rowIndex=>series.pointColors[rowIndex]??""):series.pointColors,backgroundColors=projectChartStrings(backgroundColor),backgroundColorValue=typeof backgroundColor=="string"?backgroundColor:void 0,resolvedBackgroundColor=datasetType==="line"&&fill&&(colors||!chartStyle.authoredFillColors[index%chartStyle.authoredFillColors.length])?backgroundColors?backgroundColors.map(color=>this.canvasTokens.translucent(color)):backgroundColorValue&&this.canvasTokens.translucent(backgroundColorValue):backgroundColor,encoding=forcedColorEncoding(index),resolvedBackgroundColors=projectChartStrings(resolvedBackgroundColor),resolvedBackgroundColorValue=typeof resolvedBackgroundColor=="string"?resolvedBackgroundColor:void 0,encodedBackgroundColor=chartStyle.forcedColors?resolvedBackgroundColors?resolvedBackgroundColors.map((color,itemIndex)=>this.forcedColorPattern(sliceChart?itemIndex:index,color)):resolvedBackgroundColorValue&&this.forcedColorPattern(index,resolvedBackgroundColorValue):resolvedBackgroundColor,pointRadii=projectChartPointRadii(series.pointRadius);return{label:series.label,data:normalizedData,type:series.type,fill,...datasetType==="bar"&&this.hasConfiguredBarOption("borderRadius")?{}:{borderRadius:chartStyle.borderRadius},...datasetType==="bar"&&!Number.isFinite(series.width)&&this.hasConfiguredBarOption("borderWidth")||isArcDatasetType(datasetType)&&this.hasConfiguredElementOption(datasetType,"arc","borderWidth")?{}:{borderWidth:nonNegativeFinite(series.width,datasetType==="line"||datasetType==="radar"?chartStyle.lineBorderWidth:chartStyle.borderWidth)},borderDash:series.dash?[4,4]:chartStyle.forcedColors?[...encoding.dash]:void 0,pointStyle:chartStyle.forcedColors?encoding.pointStyle:void 0,backgroundColor:encodedBackgroundColor,borderColor:colors?.[0]??sliceBorderColors??borderFallback,pointBackgroundColor:authoredPointColors?this.canvasTokens.resolveMany(authoredPointColors,colors?.[0]??borderFallback??"transparent"):void 0,...isPointDatasetType(datasetType)&&this.hasConfiguredElementOption(datasetType,"point","radius")?{}:{pointRadius:pointRadii?(rowIndexes?rowIndexes.map(rowIndex=>pointRadii[rowIndex]):pointRadii).map(radius=>nonNegativeFinite(radius,chartStyle.pointRadius)):nonNegativeFinite(series.pointRadius,chartStyle.pointRadius)},...segmentColors?.length?{segment:{borderColor:ctx=>segmentColors[ctx.p0DataIndex%segmentColors.length]}}:{},yAxisID:series.axis==="y2"?"y2":"y",...series.stack!==void 0?{stack:series.stack}:{}}}hasConfiguredElementOption(datasetTypeKey,elementKey,option){const read=(value,key)=>{if(!isChartRecord(value))return;const descriptor=chartRecordValue(value,key);return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value},options=this.effectiveConfig()?.options,dataset=read(read(options,"datasets"),datasetTypeKey),scopes=[dataset,read(read(dataset,"elements"),elementKey),read(read(options,"elements"),elementKey),options],prefixed=`${elementKey}${option[0].toUpperCase()}${option.slice(1)}`;return scopes.some(scope=>read(scope,prefixed)!==void 0||read(scope,option)!==void 0)}hasConfiguredBarOption(option){return this.hasConfiguredElementOption("bar","bar",option)}themeColors(){const cs=this.canvasTokens.sync()??this.computedStyle(),grid=cs.getPropertyValue("--grid-color").trim()||cs.getPropertyValue("--lr-chart-grid-color").trim()||cs.getPropertyValue("--_lr-chart-grid-color").trim(),tick=cs.getPropertyValue("--lr-chart-tick-color").trim()||cs.getPropertyValue("--_lr-chart-tick-color").trim(),legend=cs.getPropertyValue("--lr-chart-legend-color").trim()||cs.getPropertyValue("--_lr-chart-legend-color").trim(),tooltipBg=cs.getPropertyValue("--lr-chart-tooltip-bg").trim()||cs.getPropertyValue("--_lr-chart-tooltip-bg").trim(),tooltipText=cs.getPropertyValue("--lr-chart-tooltip-color").trim()||cs.getPropertyValue("--_lr-chart-tooltip-color").trim();return{grid:this.canvasTokens.resolve(grid,FALLBACK_GRID_COLOR),tick:this.canvasTokens.resolve(tick,FALLBACK_TICK_COLOR),tickFontSize:this.styleNumber("--lr-chart-tick-font-size","--_lr-chart-tick-font-size",FALLBACK_TICK_FONT_SIZE),legend:this.canvasTokens.resolve(legend,FALLBACK_LEGEND_COLOR),tooltipBg:this.canvasTokens.resolve(tooltipBg,FALLBACK_TOOLTIP_BG),tooltipText:this.canvasTokens.resolve(tooltipText,FALLBACK_TOOLTIP_TEXT)}}styleColor(name,fallback){const value=this.computedStyle().getPropertyValue(name).trim();return value?this.canvasTokens.resolve(value,fallback):fallback}styleNumber(name,fallbackToken,fallback){const computed=this.computedStyle(),value=computed.getPropertyValue(name).trim()||computed.getPropertyValue(fallbackToken).trim(),direct=DIRECT_PIXEL_NUMBER.exec(value);if(direct){const resolved2=Number.parseFloat(direct[1]);if(Number.isFinite(resolved2)&&resolved2>=0)return resolved2}if(!value||!this.ownerWindow)return fallback;const resolved=this.canvasTokens.length(value,()=>{const probe=this.ownerDocument.createElement("span");probe.hidden=!0,probe.setAttribute("aria-hidden","true"),probe.style.inlineSize=value,(this.shadowRoot??this).append(probe);try{return Number.parseFloat(this.computedStyle(probe).inlineSize)}finally{probe.remove()}});return Number.isFinite(resolved)&&resolved>=0?resolved:fallback}explicitTickFontSize(){const resolved=this.styleNumber("--lr-chart-tick-font-size","--lr-chart-tick-font-size",NaN);return Number.isNaN(resolved)?void 0:resolved}forcedColorPattern(index,background){if(!this.ownerWindow)return background;const surface=this.styleColor("--lr-color-surface",FALLBACK_TOOLTIP_BG),key=`${forcedColorEncoding(index).name}
3
3
  ${background}
4
4
  ${surface}`;let pattern=this.forcedColorPatterns.get(key);return pattern||(pattern=createForcedColorPattern(this.ownerDocument,index,background,surface),this.forcedColorPatterns.set(key,pattern)),pattern}chartStyleOptions(palette){const computed=this.computedStyle(),authoredFillColors=palette.map((_,index)=>index<6&&!!computed.getPropertyValue(`--fill-color-${index+1}`).trim()),borderColors=palette.map((fallback,index)=>index<6?this.styleColor(`--border-color-${index+1}`,fallback):fallback),fillColors=palette.map((fallback,index)=>index<6?this.styleColor(`--fill-color-${index+1}`,fallback):fallback);return{borderColors,fillColors,authoredFillColors,borderRadius:this.styleNumber("--border-radius","--lr-radius",6),borderWidth:this.styleNumber("--border-width","--lr-border-width-thin",1),gridBorderWidth:this.styleNumber("--grid-border-width","--lr-border-width-thin",1),lineBorderWidth:this.styleNumber("--line-border-width","--lr-border-width-medium",2),pointRadius:this.styleNumber("--point-radius","--lr-space-2xs",4),forcedColors:forcedColorsActive(this.ownerWindow)}}get needsDataLabels(){return this.dataLabels||this.stackTotals}get needsAnnotations(){return this.normalizedAnnotations().length>0}normalizedAnnotations(){return this.canonicalAnnotations()}annotationColor(tone){const token=`--lr-color-${tone??"neutral"}`,raw=this.computedStyle().getPropertyValue(token).trim();return this.canvasTokens.resolve(raw,FALLBACK_TICK_COLOR)}annotationOptions(tick){const entries={},direction=this.effectiveDirection==="rtl"?"rtl":"ltr";return this.normalizedAnnotations().forEach((entry,index)=>{const axis=entry.axis==="x"?"x":"y",color=this.annotationColor(entry.tone),label=entry.label?{content:isolateCanvasText(entry.label,direction),display:!0,color:tick}:void 0;if(typeof entry.value=="number"){entries[`lr-annotation-${index}`]={type:"line",scaleID:axis,value:entry.value,borderColor:color,borderWidth:2,...label?{label}:{}};return}const bounds=axis==="y"?{yMin:entry.from,yMax:entry.to}:{xMin:entry.from,xMax:entry.to};entries[`lr-annotation-${index}`]={type:"box",...bounds,backgroundColor:this.canvasTokens.translucent(color),borderColor:color,borderWidth:0,...label?{label}:{}}}),entries}datalabelsOptions(theme,effectiveType){if(!this.needsDataLabels)return{display:!1};const effective=this.effectiveData(),datasets=effective.datasets,stackTotalsPossible=this.stackTotals&&(effectiveType==="bar"||effectiveType==="line"),sourceDatasetIndex=visualIndex=>this.visualDatasetSourceIndexes?.[visualIndex]??visualIndex,sourceRowIndex=visualIndex=>this.visualRowSourceIndexes?.[visualIndex]??visualIndex,topDatasetIndexByGroup=new Map;if(stackTotalsPossible){const visualDatasetCount=this.visualDatasetSourceIndexes?.length??datasets.length;for(let visualIndex=0;visualIndex<visualDatasetCount;visualIndex+=1){const dataset=datasets[sourceDatasetIndex(visualIndex)],axis=chartDatasetAxis(dataset);if(!this.axisStacked(axis))continue;let byGroup=topDatasetIndexByGroup.get(axis);byGroup||(byGroup=new Map,topDatasetIndexByGroup.set(axis,byGroup)),byGroup.set(chartDatasetStack(dataset),visualIndex)}}const totalsByGroup=new Map,totalsFor=(axis,stack)=>{let byGroup=totalsByGroup.get(axis);byGroup||(byGroup=new Map,totalsByGroup.set(axis,byGroup));let totals=byGroup.get(stack);return totals||(totals=this.computeStackTotals(axis,stack),byGroup.set(stack,totals)),totals},stackTotalsActive=[...topDatasetIndexByGroup.values()].some(byGroup=>byGroup.size>0),direction=this.effectiveDirection==="rtl"?"rtl":"ltr",isolate=text=>text.split(`
5
5
  `).map(line=>isolateCanvasText(line,direction)).join(`