@vielzeug/prism 2.2.4 → 2.2.5

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.
@@ -1,2 +1,2 @@
1
- const e=require("../core/layout.cjs"),t=require("../core/cartesian-model.cjs"),n=require("./events.cjs");function r(e,t,n){let r=null,i=1/0;for(let a=0;a<t.length;a++)for(let o=0;o<(t[a]?.length??0);o++){let s=e[a]?.[o],c=t[a]?.[o];if(!s||!c)continue;let l=Math.abs(c.x-n);l<i&&(i=l,r=s.key)}return r}function i(e,n,r,i){let a=t.keyId(r),o=null,s=1/0;for(let r=0;r<n.length;r++){let c=e[r]?.findIndex(e=>t.keyId(e.key)===a)??-1,l=c===-1?void 0:e[r]?.[c],u=c===-1?void 0:n[r]?.[c];if(!l||!u)continue;let d=Number.isFinite(i)?Math.abs(u.y-i):0;d<s&&(s=d,o={datum:l,point:u,seriesIndex:r})}return o}function a(a){let o=0;return{onClick:t=>{if(!a.onClick)return;let o=a.getPoints();if(o.length===0||o[0].length===0)return;let s=a.dims(),c=n.getMousePosition(a.svg,t,s.margin.left,s.margin.top),l=e.chartArea(s.width,s.height,s.margin);if(c.x<0||c.x>l.width||c.y<0||c.y>l.height)return;let u=r(a.getData(),o,c.x);if(u===null)return;let d=i(a.getData(),o,u,c.y),f=d?a.getSeriesList()[d.seriesIndex]:void 0;d&&f&&a.onClick({datum:d.datum,originalEvent:t,series:f})},onKeyDown:e=>{let n=a.getData(),r=a.getPoints(),s=[...new Map(n.flat().map(e=>[t.keyId(e.key),e.key])).values()];if(s.length!==0){if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),o=Math.max(0,Math.min(s.length-1,o+(e.key===`ArrowLeft`?-1:1)));let t=s[o],c=i(n,r,t,1/0),l=c?a.getSeriesList()[c.seriesIndex]:void 0;if(!c||!l)return;a.crosshair?.show(c.point.x,c.point.y,a.dims().width,a.dims().height,`${l.name}: ${c.datum.value}`),a.tooltip?.show(c.point.x+a.dims().margin.left,c.point.y+a.dims().margin.top,c.datum,l),a.onHover?.({datum:c.datum,originalEvent:e,series:l})}if((e.key===`Enter`||e.key===` `)&&a.onClick){e.preventDefault();let t=s[o],c=i(n,r,t,1/0),l=c?a.getSeriesList()[c.seriesIndex]:void 0;c&&l&&a.onClick({datum:c.datum,originalEvent:e,series:l})}e.key===`Escape`&&(a.crosshair?.hide(),a.tooltip?.hide(),a.onHover?.(null))}},onMouseLeave:()=>{a.crosshair?.hide(),a.tooltip?.hide(),a.onHover?.(null)},onMouseMove:t=>{let o=a.getPoints();if(o.length===0||o[0].length===0)return;let s=a.dims(),c=n.getMousePosition(a.svg,t,s.margin.left,s.margin.top),l=e.chartArea(s.width,s.height,s.margin);if(c.x<0||c.x>l.width||c.y<0||c.y>l.height){a.crosshair?.hide(),a.tooltip?.hide();return}let u=r(a.getData(),o,c.x);if(u===null)return;let d=i(a.getData(),o,u,c.y),f=d?a.getSeriesList()[d.seriesIndex]:void 0,p=a.crosshair?.snap===!1?c.x:d?.point.x??c.x,m=a.crosshair?.snap===!1?c.y:d?.point.y??c.y;a.crosshair?.show(p,m,l.width,l.height,f&&d?`${f.name}: ${d.datum.value}`:void 0),d&&f&&(a.tooltip?.show(d.point.x+s.margin.left,d.point.y+s.margin.top,d.datum,f),a.onHover?.({datum:d.datum,originalEvent:t,series:f}))}}}exports.createSeriesInteraction=a;
1
+ const e=require("../core/layout.cjs"),t=require("../core/cartesian-model.cjs"),n=require("./events.cjs");function r(e,t,n){let r=null,i=1/0;for(let a=0;a<t.length;a++)for(let o=0;o<(t[a]?.length??0);o++){let s=e[a]?.[o],c=t[a]?.[o];if(!s||!c)continue;let l=Math.abs(c.x-n);l<i&&(i=l,r=s.key)}return r}function i(e,n,r,i){let a=t.keyId(r),o=null,s=1/0;for(let r=0;r<n.length;r++){let c=e[r]?.findIndex(e=>t.keyId(e.key)===a)??-1,l=c===-1?void 0:e[r]?.[c],u=c===-1?void 0:n[r]?.[c];if(!l||!u)continue;let d=Number.isFinite(i)?Math.abs(u.y-i):0;d<s&&(s=d,o={datum:l,point:u,seriesIndex:r})}return o}function a(a){let o=0;return{onClick:t=>{if(!a.onClick)return;let o=a.getPoints();if(o.length===0||o[0].length===0)return;let s=a.dims(),c=n.getMousePosition(a.svg,t,s.margin.left,s.margin.top),l=e.chartArea(s.width,s.height,s.margin);if(c.x<0||c.x>l.width||c.y<0||c.y>l.height)return;let u=r(a.getData(),o,c.x);if(u===null)return;let d=i(a.getData(),o,u,c.y),f=d?a.getSeriesList()[d.seriesIndex]:void 0;d&&f&&a.onClick({datum:d.datum,originalEvent:t,series:f})},onKeyDown:e=>{let n=a.getData(),r=a.getPoints(),s=[...new Map(n.flat().map(e=>[t.keyId(e.key),e.key])).values()];if(s.length!==0){if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),o=Math.max(0,Math.min(s.length-1,o+(e.key===`ArrowLeft`?-1:1)));let t=s[o],c=i(n,r,t,1/0),l=c?a.getSeriesList()[c.seriesIndex]:void 0;if(!c||!l)return;let u=a.tooltip?void 0:`${l.name}: ${c.datum.value}`;a.crosshair?.show(c.point.x,c.point.y,a.dims().width,a.dims().height,u),a.tooltip?.show(c.point.x+a.dims().margin.left,c.point.y+a.dims().margin.top,c.datum,l),a.onHover?.({datum:c.datum,originalEvent:e,series:l})}if((e.key===`Enter`||e.key===` `)&&a.onClick){e.preventDefault();let t=s[o],c=i(n,r,t,1/0),l=c?a.getSeriesList()[c.seriesIndex]:void 0;c&&l&&a.onClick({datum:c.datum,originalEvent:e,series:l})}e.key===`Escape`&&(a.crosshair?.hide(),a.tooltip?.hide(),a.onHover?.(null))}},onMouseLeave:()=>{a.crosshair?.hide(),a.tooltip?.hide(),a.onHover?.(null)},onMouseMove:t=>{let o=a.getPoints();if(o.length===0||o[0].length===0)return;let s=a.dims(),c=n.getMousePosition(a.svg,t,s.margin.left,s.margin.top),l=e.chartArea(s.width,s.height,s.margin);if(c.x<0||c.x>l.width||c.y<0||c.y>l.height){a.crosshair?.hide(),a.tooltip?.hide();return}let u=r(a.getData(),o,c.x);if(u===null)return;let d=i(a.getData(),o,u,c.y),f=d?a.getSeriesList()[d.seriesIndex]:void 0,p=a.crosshair?.snap===!1?c.x:d?.point.x??c.x,m=a.crosshair?.snap===!1?c.y:d?.point.y??c.y,h=!a.tooltip&&f&&d?`${f.name}: ${d.datum.value}`:void 0;a.crosshair?.show(p,m,l.width,l.height,h),d&&f&&(a.tooltip?.show(d.point.x+s.margin.left,d.point.y+s.margin.top,d.datum,f),a.onHover?.({datum:d.datum,originalEvent:t,series:f}))}}}exports.createSeriesInteraction=a;
2
2
  //# sourceMappingURL=series-interaction.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"series-interaction.cjs","names":[],"sources":["../../src/interaction/series-interaction.ts"],"sourcesContent":["import { keyId } from '../core/cartesian-model';\nimport type { ChartEventHandlers } from '../core/chart-scaffold';\nimport { chartArea } from '../core/layout';\nimport type { Point } from '../svg/path';\nimport type { ChartDimensions, ChartEvent, Datum, Series } from '../types';\nimport type { CrosshairState } from './crosshair';\nimport { getMousePosition } from './events';\nimport type { TooltipState } from './tooltip';\n\nexport interface SeriesInteractionOptions {\n crosshair?: CrosshairState | null;\n dims: () => ChartDimensions;\n getData: () => Datum[][];\n getPoints: () => Point[][];\n getSeriesList: () => Series[];\n onClick?: ((event: ChartEvent) => void) | undefined;\n onHover?: ((event: ChartEvent | null) => void) | undefined;\n svg: SVGSVGElement;\n tooltip?: TooltipState | null;\n}\n\ntype SeriesPoint = { datum: Datum; point: Point; seriesIndex: number };\n\nfunction findNearestKey(allData: Datum[][], allPoints: Point[][], posX: number): Datum['key'] | null {\n let nearest: Datum['key'] | null = null;\n let minXDistance = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n for (let datumIndex = 0; datumIndex < (allPoints[seriesIndex]?.length ?? 0); datumIndex++) {\n const datum = allData[seriesIndex]?.[datumIndex];\n const point = allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Math.abs(point.x - posX);\n\n if (distance < minXDistance) {\n minXDistance = distance;\n nearest = datum.key;\n }\n }\n }\n\n return nearest;\n}\n\nfunction findNearestSeries(\n allData: Datum[][],\n allPoints: Point[][],\n key: Datum['key'],\n posY: number,\n): SeriesPoint | null {\n const id = keyId(key);\n let nearest: { datum: Datum; point: Point; seriesIndex: number } | null = null;\n let minYDist = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n const datumIndex = allData[seriesIndex]?.findIndex((datum) => keyId(datum.key) === id) ?? -1;\n const datum = datumIndex === -1 ? undefined : allData[seriesIndex]?.[datumIndex];\n const point = datumIndex === -1 ? undefined : allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Number.isFinite(posY) ? Math.abs(point.y - posY) : 0;\n\n if (distance < minYDist) {\n minYDist = distance;\n nearest = { datum, point, seriesIndex };\n }\n }\n\n return nearest;\n}\n\nexport function createSeriesInteraction(opts: SeriesInteractionOptions): ChartEventHandlers {\n let keyboardIndex = 0;\n\n const onMouseMove = (event: MouseEvent) => {\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n\n return;\n }\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n const crosshairX = opts.crosshair?.snap === false ? pos.x : (nearest?.point.x ?? pos.x);\n const crosshairY = opts.crosshair?.snap === false ? pos.y : (nearest?.point.y ?? pos.y);\n\n opts.crosshair?.show(\n crosshairX,\n crosshairY,\n area.width,\n area.height,\n series && nearest ? `${series.name}: ${nearest.datum.value}` : undefined,\n );\n\n if (nearest && series) {\n opts.tooltip?.show(nearest.point.x + dims.margin.left, nearest.point.y + dims.margin.top, nearest.datum, series);\n opts.onHover?.({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onMouseLeave = () => {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n };\n\n const onClick = (event: MouseEvent) => {\n if (!opts.onClick) return;\n\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) return;\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n\n if (nearest && series) {\n opts.onClick({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n const allData = opts.getData();\n const allPoints = opts.getPoints();\n const domain = [...new Map(allData.flat().map((datum) => [keyId(datum.key), datum.key])).values()];\n\n if (domain.length === 0) return;\n\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault();\n keyboardIndex = Math.max(0, Math.min(domain.length - 1, keyboardIndex + (event.key === 'ArrowLeft' ? -1 : 1)));\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (!candidate || !series) return;\n\n opts.crosshair?.show(\n candidate.point.x,\n candidate.point.y,\n opts.dims().width,\n opts.dims().height,\n `${series.name}: ${candidate.datum.value}`,\n );\n opts.tooltip?.show(\n candidate.point.x + opts.dims().margin.left,\n candidate.point.y + opts.dims().margin.top,\n candidate.datum,\n series,\n );\n opts.onHover?.({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && opts.onClick) {\n event.preventDefault();\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (candidate && series) opts.onClick({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if (event.key === 'Escape') {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n }\n };\n\n return { onClick, onKeyDown, onMouseLeave, onMouseMove };\n}\n"],"mappings":"yGAuBA,SAAS,EAAe,EAAoB,EAAsB,EAAmC,CACnG,IAAI,EAA+B,KAC/B,EAAe,IAEnB,IAAK,IAAI,EAAc,EAAG,EAAc,EAAU,OAAQ,IACxD,IAAK,IAAI,EAAa,EAAG,GAAc,EAAU,EAAY,EAAE,QAAU,GAAI,IAAc,CACzF,IAAM,EAAQ,EAAQ,EAAY,GAAG,GAC/B,EAAQ,EAAU,EAAY,GAAG,GAEvC,GAAI,CAAC,GAAS,CAAC,EAAO,SAEtB,IAAM,EAAW,KAAK,IAAI,EAAM,EAAI,CAAI,EAEpC,EAAW,IACb,EAAe,EACf,EAAU,EAAM,IAEpB,CAGF,OAAO,CACT,CAEA,SAAS,EACP,EACA,EACA,EACA,EACoB,CACpB,IAAM,EAAK,EAAA,MAAM,CAAG,EAChB,EAAsE,KACtE,EAAW,IAEf,IAAK,IAAI,EAAc,EAAG,EAAc,EAAU,OAAQ,IAAe,CACvE,IAAM,EAAa,EAAQ,EAAY,EAAE,UAAW,GAAU,EAAA,MAAM,EAAM,GAAG,IAAM,CAAE,GAAK,GACpF,EAAQ,IAAe,GAAK,IAAA,GAAY,EAAQ,EAAY,GAAG,GAC/D,EAAQ,IAAe,GAAK,IAAA,GAAY,E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ts"],"sourcesContent":["import { keyId } from '../core/cartesian-model';\nimport type { ChartEventHandlers } from '../core/chart-scaffold';\nimport { chartArea } from '../core/layout';\nimport type { Point } from '../svg/path';\nimport type { ChartDimensions, ChartEvent, Datum, Series } from '../types';\nimport type { CrosshairState } from './crosshair';\nimport { getMousePosition } from './events';\nimport type { TooltipState } from './tooltip';\n\nexport interface SeriesInteractionOptions {\n crosshair?: CrosshairState | null;\n dims: () => ChartDimensions;\n getData: () => Datum[][];\n getPoints: () => Point[][];\n getSeriesList: () => Series[];\n onClick?: ((event: ChartEvent) => void) | undefined;\n onHover?: ((event: ChartEvent | null) => void) | undefined;\n svg: SVGSVGElement;\n tooltip?: TooltipState | null;\n}\n\ntype SeriesPoint = { datum: Datum; point: Point; seriesIndex: number };\n\nfunction findNearestKey(allData: Datum[][], allPoints: Point[][], posX: number): Datum['key'] | null {\n let nearest: Datum['key'] | null = null;\n let minXDistance = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n for (let datumIndex = 0; datumIndex < (allPoints[seriesIndex]?.length ?? 0); datumIndex++) {\n const datum = allData[seriesIndex]?.[datumIndex];\n const point = allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Math.abs(point.x - posX);\n\n if (distance < minXDistance) {\n minXDistance = distance;\n nearest = datum.key;\n }\n }\n }\n\n return nearest;\n}\n\nfunction findNearestSeries(\n allData: Datum[][],\n allPoints: Point[][],\n key: Datum['key'],\n posY: number,\n): SeriesPoint | null {\n const id = keyId(key);\n let nearest: { datum: Datum; point: Point; seriesIndex: number } | null = null;\n let minYDist = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n const datumIndex = allData[seriesIndex]?.findIndex((datum) => keyId(datum.key) === id) ?? -1;\n const datum = datumIndex === -1 ? undefined : allData[seriesIndex]?.[datumIndex];\n const point = datumIndex === -1 ? undefined : allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Number.isFinite(posY) ? Math.abs(point.y - posY) : 0;\n\n if (distance < minYDist) {\n minYDist = distance;\n nearest = { datum, point, seriesIndex };\n }\n }\n\n return nearest;\n}\n\nexport function createSeriesInteraction(opts: SeriesInteractionOptions): ChartEventHandlers {\n let keyboardIndex = 0;\n\n const onMouseMove = (event: MouseEvent) => {\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n\n return;\n }\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n const crosshairX = opts.crosshair?.snap === false ? pos.x : (nearest?.point.x ?? pos.x);\n const crosshairY = opts.crosshair?.snap === false ? pos.y : (nearest?.point.y ?? pos.y);\n\n // When a tooltip is present it already carries role=\"status\" + aria-live=\"polite\",\n // so the crosshair's own live region must stay silent to avoid double-announcing.\n const announceText = !opts.tooltip && series && nearest ? `${series.name}: ${nearest.datum.value}` : undefined;\n\n opts.crosshair?.show(crosshairX, crosshairY, area.width, area.height, announceText);\n\n if (nearest && series) {\n opts.tooltip?.show(nearest.point.x + dims.margin.left, nearest.point.y + dims.margin.top, nearest.datum, series);\n opts.onHover?.({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onMouseLeave = () => {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n };\n\n const onClick = (event: MouseEvent) => {\n if (!opts.onClick) return;\n\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) return;\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n\n if (nearest && series) {\n opts.onClick({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n const allData = opts.getData();\n const allPoints = opts.getPoints();\n const domain = [...new Map(allData.flat().map((datum) => [keyId(datum.key), datum.key])).values()];\n\n if (domain.length === 0) return;\n\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault();\n keyboardIndex = Math.max(0, Math.min(domain.length - 1, keyboardIndex + (event.key === 'ArrowLeft' ? -1 : 1)));\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (!candidate || !series) return;\n\n // Same dedup as onMouseMove — tooltip announces when present.\n const announceText = !opts.tooltip ? `${series.name}: ${candidate.datum.value}` : undefined;\n\n opts.crosshair?.show(candidate.point.x, candidate.point.y, opts.dims().width, opts.dims().height, announceText);\n opts.tooltip?.show(\n candidate.point.x + opts.dims().margin.left,\n candidate.point.y + opts.dims().margin.top,\n candidate.datum,\n series,\n );\n opts.onHover?.({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && opts.onClick) {\n event.preventDefault();\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (candidate && series) opts.onClick({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if (event.key === 'Escape') {\n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AE,CAAC;IACzB,SAAS,EAAE,MAAM,KAAK,EAAE,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D,GAAG,EAAE,aAAa,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B;AAuDD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,kBAAkB,CAuH1F"}
@@ -51,7 +51,8 @@ function a(a) {
51
51
  e.preventDefault(), o = Math.max(0, Math.min(s.length - 1, o + (e.key === "ArrowLeft" ? -1 : 1)));
52
52
  let t = s[o], c = i(n, r, t, Infinity), l = c ? a.getSeriesList()[c.seriesIndex] : void 0;
53
53
  if (!c || !l) return;
54
- a.crosshair?.show(c.point.x, c.point.y, a.dims().width, a.dims().height, `${l.name}: ${c.datum.value}`), a.tooltip?.show(c.point.x + a.dims().margin.left, c.point.y + a.dims().margin.top, c.datum, l), a.onHover?.({
54
+ let u = a.tooltip ? void 0 : `${l.name}: ${c.datum.value}`;
55
+ a.crosshair?.show(c.point.x, c.point.y, a.dims().width, a.dims().height, u), a.tooltip?.show(c.point.x + a.dims().margin.left, c.point.y + a.dims().margin.top, c.datum, l), a.onHover?.({
55
56
  datum: c.datum,
56
57
  originalEvent: e,
57
58
  series: l
@@ -82,8 +83,8 @@ function a(a) {
82
83
  }
83
84
  let u = r(a.getData(), o, c.x);
84
85
  if (u === null) return;
85
- let d = i(a.getData(), o, u, c.y), f = d ? a.getSeriesList()[d.seriesIndex] : void 0, p = a.crosshair?.snap === !1 ? c.x : d?.point.x ?? c.x, m = a.crosshair?.snap === !1 ? c.y : d?.point.y ?? c.y;
86
- a.crosshair?.show(p, m, l.width, l.height, f && d ? `${f.name}: ${d.datum.value}` : void 0), d && f && (a.tooltip?.show(d.point.x + s.margin.left, d.point.y + s.margin.top, d.datum, f), a.onHover?.({
86
+ let d = i(a.getData(), o, u, c.y), f = d ? a.getSeriesList()[d.seriesIndex] : void 0, p = a.crosshair?.snap === !1 ? c.x : d?.point.x ?? c.x, m = a.crosshair?.snap === !1 ? c.y : d?.point.y ?? c.y, h = !a.tooltip && f && d ? `${f.name}: ${d.datum.value}` : void 0;
87
+ a.crosshair?.show(p, m, l.width, l.height, h), d && f && (a.tooltip?.show(d.point.x + s.margin.left, d.point.y + s.margin.top, d.datum, f), a.onHover?.({
87
88
  datum: d.datum,
88
89
  originalEvent: t,
89
90
  series: f
@@ -1 +1 @@
1
- {"version":3,"file":"series-interaction.js","names":[],"sources":["../../src/interaction/series-interaction.ts"],"sourcesContent":["import { keyId } from '../core/cartesian-model';\nimport type { ChartEventHandlers } from '../core/chart-scaffold';\nimport { chartArea } from '../core/layout';\nimport type { Point } from '../svg/path';\nimport type { ChartDimensions, ChartEvent, Datum, Series } from '../types';\nimport type { CrosshairState } from './crosshair';\nimport { getMousePosition } from './events';\nimport type { TooltipState } from './tooltip';\n\nexport interface SeriesInteractionOptions {\n crosshair?: CrosshairState | null;\n dims: () => ChartDimensions;\n getData: () => Datum[][];\n getPoints: () => Point[][];\n getSeriesList: () => Series[];\n onClick?: ((event: ChartEvent) => void) | undefined;\n onHover?: ((event: ChartEvent | null) => void) | undefined;\n svg: SVGSVGElement;\n tooltip?: TooltipState | null;\n}\n\ntype SeriesPoint = { datum: Datum; point: Point; seriesIndex: number };\n\nfunction findNearestKey(allData: Datum[][], allPoints: Point[][], posX: number): Datum['key'] | null {\n let nearest: Datum['key'] | null = null;\n let minXDistance = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n for (let datumIndex = 0; datumIndex < (allPoints[seriesIndex]?.length ?? 0); datumIndex++) {\n const datum = allData[seriesIndex]?.[datumIndex];\n const point = allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Math.abs(point.x - posX);\n\n if (distance < minXDistance) {\n minXDistance = distance;\n nearest = datum.key;\n }\n }\n }\n\n return nearest;\n}\n\nfunction findNearestSeries(\n allData: Datum[][],\n allPoints: Point[][],\n key: Datum['key'],\n posY: number,\n): SeriesPoint | null {\n const id = keyId(key);\n let nearest: { datum: Datum; point: Point; seriesIndex: number } | null = null;\n let minYDist = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n const datumIndex = allData[seriesIndex]?.findIndex((datum) => keyId(datum.key) === id) ?? -1;\n const datum = datumIndex === -1 ? undefined : allData[seriesIndex]?.[datumIndex];\n const point = datumIndex === -1 ? undefined : allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Number.isFinite(posY) ? Math.abs(point.y - posY) : 0;\n\n if (distance < minYDist) {\n minYDist = distance;\n nearest = { datum, point, seriesIndex };\n }\n }\n\n return nearest;\n}\n\nexport function createSeriesInteraction(opts: SeriesInteractionOptions): ChartEventHandlers {\n let keyboardIndex = 0;\n\n const onMouseMove = (event: MouseEvent) => {\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n\n return;\n }\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n const crosshairX = opts.crosshair?.snap === false ? pos.x : (nearest?.point.x ?? pos.x);\n const crosshairY = opts.crosshair?.snap === false ? pos.y : (nearest?.point.y ?? pos.y);\n\n opts.crosshair?.show(\n crosshairX,\n crosshairY,\n area.width,\n area.height,\n series && nearest ? `${series.name}: ${nearest.datum.value}` : undefined,\n );\n\n if (nearest && series) {\n opts.tooltip?.show(nearest.point.x + dims.margin.left, nearest.point.y + dims.margin.top, nearest.datum, series);\n opts.onHover?.({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onMouseLeave = () => {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n };\n\n const onClick = (event: MouseEvent) => {\n if (!opts.onClick) return;\n\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) return;\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n\n if (nearest && series) {\n opts.onClick({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n const allData = opts.getData();\n const allPoints = opts.getPoints();\n const domain = [...new Map(allData.flat().map((datum) => [keyId(datum.key), datum.key])).values()];\n\n if (domain.length === 0) return;\n\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault();\n keyboardIndex = Math.max(0, Math.min(domain.length - 1, keyboardIndex + (event.key === 'ArrowLeft' ? -1 : 1)));\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (!candidate || !series) return;\n\n opts.crosshair?.show(\n candidate.point.x,\n candidate.point.y,\n opts.dims().width,\n opts.dims().height,\n `${series.name}: ${candidate.datum.value}`,\n );\n opts.tooltip?.show(\n candidate.point.x + opts.dims().margin.left,\n candidate.point.y + opts.dims().margin.top,\n candidate.datum,\n series,\n );\n opts.onHover?.({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && opts.onClick) {\n event.preventDefault();\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (candidate && series) opts.onClick({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if (event.key === 'Escape') {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n }\n };\n\n return { onClick, onKeyDown, onMouseLeave, onMouseMove };\n}\n"],"mappings":";;;;AAuBA,SAAS,EAAe,GAAoB,GAAsB,GAAmC;CACnG,IAAI,IAA+B,MAC/B,IAAe;CAEnB,KAAK,IAAI,IAAc,GAAG,IAAc,EAAU,QAAQ,KACxD,KAAK,IAAI,IAAa,GAAG,KAAc,EAAU,EAAY,EAAE,UAAU,IAAI,KAAc;EACzF,IAAM,IAAQ,EAAQ,EAAY,GAAG,IAC/B,IAAQ,EAAU,EAAY,GAAG;EAEvC,IAAI,CAAC,KAAS,CAAC,GAAO;EAEtB,IAAM,IAAW,KAAK,IAAI,EAAM,IAAI,CAAI;EAExC,AAAI,IAAW,MACb,IAAe,GACf,IAAU,EAAM;CAEpB;CAGF,OAAO;AACT;AAEA,SAAS,EACP,GACA,GACA,GACA,GACoB;CACpB,IAAM,IAAK,EAAM,CAAG,GAChB,IAAsE,MACtE,IAAW;CAEf,KAAK,IAAI,IAAc,GAAG,IAAc,EAAU,QAAQ,KAAe;EACvE,IAAM,IAAa,EAAQ,EAAY,EAAE,WAAW,MAAU,EAAM,EAAM,GAAG,MAAM,CAAE,KAAK,IACpF,IAAQ,MAAe,KAAK,KAAA,IAAY,EAAQ,EAAY,GAAG,IAC/D,I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 {"version":3,"file":"series-interaction.js","names":[],"sources":["../../src/interaction/series-interaction.ts"],"sourcesContent":["import { keyId } from '../core/cartesian-model';\nimport type { ChartEventHandlers } from '../core/chart-scaffold';\nimport { chartArea } from '../core/layout';\nimport type { Point } from '../svg/path';\nimport type { ChartDimensions, ChartEvent, Datum, Series } from '../types';\nimport type { CrosshairState } from './crosshair';\nimport { getMousePosition } from './events';\nimport type { TooltipState } from './tooltip';\n\nexport interface SeriesInteractionOptions {\n crosshair?: CrosshairState | null;\n dims: () => ChartDimensions;\n getData: () => Datum[][];\n getPoints: () => Point[][];\n getSeriesList: () => Series[];\n onClick?: ((event: ChartEvent) => void) | undefined;\n onHover?: ((event: ChartEvent | null) => void) | undefined;\n svg: SVGSVGElement;\n tooltip?: TooltipState | null;\n}\n\ntype SeriesPoint = { datum: Datum; point: Point; seriesIndex: number };\n\nfunction findNearestKey(allData: Datum[][], allPoints: Point[][], posX: number): Datum['key'] | null {\n let nearest: Datum['key'] | null = null;\n let minXDistance = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n for (let datumIndex = 0; datumIndex < (allPoints[seriesIndex]?.length ?? 0); datumIndex++) {\n const datum = allData[seriesIndex]?.[datumIndex];\n const point = allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Math.abs(point.x - posX);\n\n if (distance < minXDistance) {\n minXDistance = distance;\n nearest = datum.key;\n }\n }\n }\n\n return nearest;\n}\n\nfunction findNearestSeries(\n allData: Datum[][],\n allPoints: Point[][],\n key: Datum['key'],\n posY: number,\n): SeriesPoint | null {\n const id = keyId(key);\n let nearest: { datum: Datum; point: Point; seriesIndex: number } | null = null;\n let minYDist = Infinity;\n\n for (let seriesIndex = 0; seriesIndex < allPoints.length; seriesIndex++) {\n const datumIndex = allData[seriesIndex]?.findIndex((datum) => keyId(datum.key) === id) ?? -1;\n const datum = datumIndex === -1 ? undefined : allData[seriesIndex]?.[datumIndex];\n const point = datumIndex === -1 ? undefined : allPoints[seriesIndex]?.[datumIndex];\n\n if (!datum || !point) continue;\n\n const distance = Number.isFinite(posY) ? Math.abs(point.y - posY) : 0;\n\n if (distance < minYDist) {\n minYDist = distance;\n nearest = { datum, point, seriesIndex };\n }\n }\n\n return nearest;\n}\n\nexport function createSeriesInteraction(opts: SeriesInteractionOptions): ChartEventHandlers {\n let keyboardIndex = 0;\n\n const onMouseMove = (event: MouseEvent) => {\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n\n return;\n }\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n const crosshairX = opts.crosshair?.snap === false ? pos.x : (nearest?.point.x ?? pos.x);\n const crosshairY = opts.crosshair?.snap === false ? pos.y : (nearest?.point.y ?? pos.y);\n\n // When a tooltip is present it already carries role=\"status\" + aria-live=\"polite\",\n // so the crosshair's own live region must stay silent to avoid double-announcing.\n const announceText = !opts.tooltip && series && nearest ? `${series.name}: ${nearest.datum.value}` : undefined;\n\n opts.crosshair?.show(crosshairX, crosshairY, area.width, area.height, announceText);\n\n if (nearest && series) {\n opts.tooltip?.show(nearest.point.x + dims.margin.left, nearest.point.y + dims.margin.top, nearest.datum, series);\n opts.onHover?.({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onMouseLeave = () => {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n };\n\n const onClick = (event: MouseEvent) => {\n if (!opts.onClick) return;\n\n const allPoints = opts.getPoints();\n\n if (allPoints.length === 0 || allPoints[0].length === 0) return;\n\n const dims = opts.dims();\n const pos = getMousePosition(opts.svg, event, dims.margin.left, dims.margin.top);\n const area = chartArea(dims.width, dims.height, dims.margin);\n\n if (pos.x < 0 || pos.x > area.width || pos.y < 0 || pos.y > area.height) return;\n\n const key = findNearestKey(opts.getData(), allPoints, pos.x);\n\n if (key === null) return;\n\n const nearest = findNearestSeries(opts.getData(), allPoints, key, pos.y);\n const series = nearest ? opts.getSeriesList()[nearest.seriesIndex] : undefined;\n\n if (nearest && series) {\n opts.onClick({ datum: nearest.datum, originalEvent: event, series });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n const allData = opts.getData();\n const allPoints = opts.getPoints();\n const domain = [...new Map(allData.flat().map((datum) => [keyId(datum.key), datum.key])).values()];\n\n if (domain.length === 0) return;\n\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault();\n keyboardIndex = Math.max(0, Math.min(domain.length - 1, keyboardIndex + (event.key === 'ArrowLeft' ? -1 : 1)));\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (!candidate || !series) return;\n\n // Same dedup as onMouseMove — tooltip announces when present.\n const announceText = !opts.tooltip ? `${series.name}: ${candidate.datum.value}` : undefined;\n\n opts.crosshair?.show(candidate.point.x, candidate.point.y, opts.dims().width, opts.dims().height, announceText);\n opts.tooltip?.show(\n candidate.point.x + opts.dims().margin.left,\n candidate.point.y + opts.dims().margin.top,\n candidate.datum,\n series,\n );\n opts.onHover?.({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && opts.onClick) {\n event.preventDefault();\n\n const key = domain[keyboardIndex]!;\n const candidate = findNearestSeries(allData, allPoints, key, Number.POSITIVE_INFINITY);\n const series = candidate ? opts.getSeriesList()[candidate.seriesIndex] : undefined;\n\n if (candidate && series) opts.onClick({ datum: candidate.datum, originalEvent: event, series });\n }\n\n if (event.key === 'Escape') {\n opts.crosshair?.hide();\n opts.tooltip?.hide();\n opts.onHover?.(null);\n }\n };\n\n return { onClick, onKeyDown, onMouseLeave, onMouseMove };\n}\n"],"mappings":";;;;AAuBA,SAAS,EAAe,GAAoB,GAAsB,GAAmC;CACnG,IAAI,IAA+B,MAC/B,IAAe;CAEnB,KAAK,IAAI,IAAc,GAAG,IAAc,EAAU,QAAQ,KACxD,KAAK,IAAI,IAAa,GAAG,KAAc,EAAU,EAAY,EAAE,UAAU,IAAI,KAAc;EACzF,IAAM,IAAQ,EAAQ,EAAY,GAAG,IAC/B,IAAQ,EAAU,EAAY,GAAG;EAEvC,IAAI,CAAC,KAAS,CAAC,GAAO;EAEtB,IAAM,IAAW,KAAK,IAAI,EAAM,IAAI,CAAI;EAExC,AAAI,IAAW,MACb,IAAe,GACf,IAAU,EAAM;CAEpB;CAGF,OAAO;AACT;AAEA,SAAS,EACP,GACA,GACA,GACA,GACoB;CACpB,IAAM,IAAK,EAAM,CAAG,GAChB,IAAsE,MACtE,IAAW;CAEf,KAAK,IAAI,IAAc,GAAG,IAAc,EAAU,QAAQ,KAAe;EACvE,IAAM,IAAa,EAAQ,EAAY,EAAE,WAAW,MAAU,EAAM,EAAM,GAAG,MAAM,CAAE,KAAK,IACpF,IAAQ,MAAe,KAAK,KAAA,IAAY,EAAQ,EAAY,GAAG,IAC/D,IAAQ,MAAe,KAAK,KAAA,IAAY,EAAU,EAAY,GAAG;EAEvE,IAAI,CAAC,KAAS,CAAC,GAAO;EAEtB,IAAM,IAAW,OAAO,SAAS,CAAI,IAAI,KAAK,IAAI,EAAM,IAAI,CAAI,IAAI;EAEpE,AAAI,IAAW,MACb,IAAW,GACX,IAAU;GAAE;GAAO;GAAO;EAAY;CAE1C;CAEA,OAAO;AACT;AAEA,SAAgB,EAAwB,GAAoD;CAC1F,IAAI,IAAgB;CAqHpB,OAAO;EAAE,UAxEQ,MAAsB;GACrC,IAA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,IAAO,EAAU,EAAK,OAAO,EAAK,QAAQ,EAAK,MAAM;GAE3D,IAAI,EAAI,IAAI,KAAK,EAAI,IAAI,EAAK,SAAS,EAAI,IAAI,KAAK,EAAI,IAAI,EAAK,QAAQ;IAEvE,AADA,EAAK,WAAW,KAAK,GACrB,EAAK,SAAS,KAAK;IAEnB;GACF;GAEA,IAAM,IAAM,EAAe,EAAK,QAAQ,GAAG,GAAW,EAAI,CAAC;GAE3D,IAAI,MAAQ,MAAM;GAElB,IAAM,IAAU,EAAkB,EAAK,QAAQ,GAAG,GAAW,GAAK,EAAI,CAAC,GACjE,IAAS,IAAU,EAAK,cAAc,CAAC,CAAC,EAAQ,eAAe,KAAA,GAC/D,IAAa,EAAK,WAAW,SAAS,KAAQ,EAAI,IAAK,GAAS,MAAM,KAAK,EAAI,GAC/E,IAAa,EAAK,WAAW,SAAS,KAAQ,EAAI,IAAK,GAAS,MAAM,KAAK,EAAI,GAI/E,IAAe,CAAC,EAAK,WAAW,KAAU,IAAU,GAAG,EAAO,KAAK,IAAI,EAAQ,MAAM,UAAU,KAAA;GAIrG,AAFA,EAAK,WAAW,KAAK,GAAY,GAAY,EAAK,OAAO,EAAK,QAAQ,CAAY,GAE9E,KAAW,MACb,EAAK,SAAS,KAAK,EAAQ,MAAM,IAAI,EAAK,OAAO,MAAM,EAAQ,MAAM,IAAI,EAAK,OAAO,KAAK,EAAQ,OAAO,CAAM,GAC/G,EAAK,UAAU;IAAE,OAAO,EAAQ;IAAO,eAAe;IAAO;GAAO,CAAC;EAEzE;CAgFuD;AACzD"}
@@ -1,2 +1,2 @@
1
- require("../_dev.cjs");let e=require("@vielzeug/orbit");function t(t,n){getComputedStyle(t).position===`static`&&(t.style.position=`relative`);let r=document.createElement(`div`);r.className=`prism-tooltip`,r.style.position=`absolute`,r.style.pointerEvents=`none`,r.style.top=`0`,r.style.left=`0`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`),t.appendChild(r);let i=n!==!0&&n?.offset||8,a=n===!0?void 0:n?.render,o=n===!0?void 0:n?.sanitize,s=null,c=null,l=!1,u=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{s!==null&&(cancelAnimationFrame(s),s=null)},f=()=>{d(),u(),r.remove()};return{dispose:f,el:r,hide(){d(),u(),l=!1,r.style.opacity=`0`,c=setTimeout(()=>{c=null,l||(r.textContent=``)},150)},show(n,c,d,f){if(!t.isConnected)return;if(u(),a){let e=a(d,f);o?r.innerHTML=o(e):r.textContent=e}else r.textContent=`${f.name}: ${d.value}`;let{x:p,y:m}=(0,e.computePosition)({getBoundingClientRect:()=>{let e=t.getBoundingClientRect();return{bottom:e.top+c,height:0,left:e.left+n,right:e.left+n,top:e.top+c,width:0,x:e.left+n,y:e.top+c}}},r,{containingBlock:t,middleware:[(0,e.offset)(i),(0,e.flip)(),(0,e.shift)({padding:8})],placement:`top`});if(r.style.left=`${p}px`,r.style.top=`${m}px`,l){s===null&&(r.style.opacity=`1`);return}l=!0,r.style.opacity=`0`,s=requestAnimationFrame(()=>{s=null,l&&(r.style.opacity=`1`)})},[Symbol.dispose]:f}}exports.createTooltip=t;
1
+ require("../_dev.cjs");let e=require("@vielzeug/orbit");function t(t,n){getComputedStyle(t).position===`static`&&(t.style.position=`relative`);let r=t.ownerDocument.createElement(`div`);r.className=`prism-tooltip`,r.style.position=`absolute`,r.style.pointerEvents=`none`,r.style.top=`0`,r.style.left=`0`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`),t.appendChild(r);let i=n!==!0&&n?.offset||8,a=n===!0?void 0:n?.render,o=n===!0?void 0:n?.sanitize,s=null,c=null,l=!1,u=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{s!==null&&(cancelAnimationFrame(s),s=null)},f=()=>{d(),u(),r.remove()};return{dispose:f,el:r,hide(){d(),u(),l=!1,r.style.opacity=`0`,c=setTimeout(()=>{c=null,l||(r.textContent=``)},150)},show(n,c,d,f){if(!t.isConnected)return;if(u(),a){let e=a(d,f);o?r.innerHTML=o(e):r.textContent=e}else r.textContent=`${f.name}: ${d.value}`;let{x:p,y:m}=(0,e.computePosition)({getBoundingClientRect:()=>{let e=t.getBoundingClientRect();return{bottom:e.top+c,height:0,left:e.left+n,right:e.left+n,top:e.top+c,width:0,x:e.left+n,y:e.top+c}}},r,{containingBlock:t,middleware:[(0,e.offset)(i),(0,e.flip)(),(0,e.shift)({padding:8})],placement:`top`});if(r.style.left=`${p}px`,r.style.top=`${m}px`,l){s===null&&(r.style.opacity=`1`);return}l=!0,r.style.opacity=`0`,s=requestAnimationFrame(()=>{s=null,l&&(r.style.opacity=`1`)})},[Symbol.dispose]:f}}exports.createTooltip=t;
2
2
  //# sourceMappingURL=tooltip.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.cjs","names":[],"sources":["../../src/interaction/tooltip.ts"],"sourcesContent":["import { computePosition, flip, offset, shift } from '@vielzeug/orbit';\nimport { warn } from '../_dev';\nimport type { Datum, Series, TooltipConfig } from '../types';\n\nexport interface TooltipState {\n dispose(): void;\n el: HTMLDivElement | null;\n hide(): void;\n show(x: number, y: number, datum: Datum, series: Series): void;\n [Symbol.dispose](): void;\n}\n\nexport function createTooltip(container: HTMLElement, config?: TooltipConfig | true): TooltipState {\n if (getComputedStyle(container).position === 'static') {\n container.style.position = 'relative';\n }\n\n const el = document.createElement('div');\n\n el.className = 'prism-tooltip';\n el.style.position = 'absolute';\n el.style.pointerEvents = 'none';\n el.style.top = '0';\n el.style.left = '0';\n // Non-modal status text — announced by assistive tech whenever content/hide state changes.\n el.setAttribute('role', 'status');\n el.setAttribute('aria-live', 'polite');\n container.appendChild(el);\n\n const tooltipOffset: number = (config !== true && config?.offset) || 8;\n const render = config !== true ? config?.render : undefined;\n const sanitize = config !== true ? config?.sanitize : undefined;\n\n if (render && !sanitize) {\n warn(\n 'createTooltip: `render` is set without `sanitize` — falling back to plain-text rendering of the returned string to avoid an XSS risk. Pass `sanitize` to render HTML.',\n );\n }\n\n let revealFrame: number | null = null;\n let clearTimer: ReturnType<typeof setTimeout> | null = null;\n let visible = false;\n\n const cancelClear = (): void => {\n if (clearTimer === null) return;\n\n clearTimeout(clearTimer);\n clearTimer = null;\n };\n\n const cancelReveal = (): void => {\n if (revealFrame === null) return;\n\n cancelAnimationFrame(revealFrame);\n revealFrame = null;\n };\n\n const disposeHandle = (): void => {\n cancelReveal();\n cancelClear();\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n hide() {\n cancelReveal();\n cancelClear();\n visible = false;\n el.style.opacity = '0';\n clearTimer = setTimeout(() => {\n clearTimer = null;\n\n if (!visible) el.textContent = '';\n }, 150);\n },\n show(x: number, y: number, datum: Datum, series: Series) {\n if (!container.isConnected) return;\n\n cancelClear();\n\n if (render) {\n const html = render(datum, series);\n\n if (sanitize) {\n el.innerHTML = sanitize(html);\n } else {\n // No sanitizer provided — never inject the raw string as HTML. Render it as text instead.\n el.textContent = html;\n }\n } else {\n el.textContent = `${series.name}: ${datum.value}`;\n }\n\n const virtualRef = {\n getBoundingClientRect: () => {\n const rect = container.getBoundingClientRect();\n\n return {\n bottom: rect.top + y,\n height: 0,\n left: rect.left + x,\n right: rect.left + x,\n top: rect.top + y,\n width: 0,\n x: rect.left + x,\n y: rect.top + y,\n };\n },\n };\n\n const { x: positionX, y: positionY } = computePosition(virtualRef, el, {\n containingBlock: container,\n middleware: [offset(tooltipOffset), flip(), shift({ padding: 8 })],\n placement: 'top',\n });\n\n el.style.left = `${positionX}px`;\n el.style.top = `${positionY}px`;\n\n if (visible) {\n if (revealFrame === null) el.style.opacity = '1';\n\n return;\n }\n\n visible = true;\n el.style.opacity = '0';\n revealFrame = requestAnimationFrame(() => {\n revealFrame = null;\n\n if (visible) el.style.opacity = '1';\n });\n },\n [Symbol.dispose]: disposeHandle,\n };\n}\n"],"mappings":"wDAYA,SAAgB,EAAc,EAAwB,EAA6C,CAC7F,iBAAiB,CAAS,CAAC,CAAC,WAAa,WAC3C,EAAU,MAAM,SAAW,YA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K,KAAO,EACnB,IAAK,EAAK,IAAM,EAChB,MAAO,EACP,EAAG,EAAK,KAAO,EACf,EAAG,EAAK,IAAM,CAChB,CACF,CAGqD,EAAY,EAAI,CACrE,gBAAiB,EACjB,WAAY,EAAC,EAAA,EAAA,OAAA,CAAO,CAAa,GAAG,EAAA,EAAA,KAAA,CAAK,GAAG,EAAA,EAAA,MAAA,CAAM,CAAE,QAAS,CAAE,CAAC,CAAC,EACjE,UAAW,KACb,CAAC,EAKD,GAHA,EAAG,MAAM,KAAO,GAAG,EAAU,IAC7B,EAAG,MAAM,IAAM,GAAG,EAAU,IAExB,EAAS,CACP,IAAgB,OAAM,EAAG,MAAM,QAAU,KAE7C,MACF,CAEA,EAAU,GACV,EAAG,MAAM,QAAU,IACnB,EAAc,0BAA4B,CACxC,EAAc,KAEV,IAAS,EAAG,MAAM,QAAU,IAClC,CAAC,CACH,GACC,OAAO,SAAU,CACpB,CACF"}
1
+ {"version":3,"file":"tooltip.cjs","names":[],"sources":["../../src/interaction/tooltip.ts"],"sourcesContent":["import { computePosition, flip, offset, shift } from '@vielzeug/orbit';\nimport { warn } from '../_dev';\nimport type { Datum, Series, TooltipConfig } from '../types';\n\nexport interface TooltipState {\n dispose(): void;\n el: HTMLDivElement | null;\n hide(): void;\n show(x: number, y: number, datum: Datum, series: Series): void;\n [Symbol.dispose](): void;\n}\n\nexport function createTooltip(container: HTMLElement, config?: TooltipConfig | true): TooltipState {\n if (getComputedStyle(container).position === 'static') {\n container.style.position = 'relative';\n }\n\n const el = container.ownerDocument.createElement('div');\n\n el.className = 'prism-tooltip';\n el.style.position = 'absolute';\n el.style.pointerEvents = 'none';\n el.style.top = '0';\n el.style.left = '0';\n // Non-modal status text — announced by assistive tech whenever content/hide state changes.\n el.setAttribute('role', 'status');\n el.setAttribute('aria-live', 'polite');\n container.appendChild(el);\n\n const tooltipOffset: number = (config !== true && config?.offset) || 8;\n const render = config !== true ? config?.render : undefined;\n const sanitize = config !== true ? config?.sanitize : undefined;\n\n if (render && !sanitize) {\n warn(\n 'createTooltip: `render` is set without `sanitize` — falling back to plain-text rendering of the returned string to avoid an XSS risk. Pass `sanitize` to render HTML.',\n );\n }\n\n let revealFrame: number | null = null;\n let clearTimer: ReturnType<typeof setTimeout> | null = null;\n let visible = false;\n\n const cancelClear = (): void => {\n if (clearTimer === null) return;\n\n clearTimeout(clearTimer);\n clearTimer = null;\n };\n\n const cancelReveal = (): void => {\n if (revealFrame === null) return;\n\n cancelAnimationFrame(revealFrame);\n revealFrame = null;\n };\n\n const disposeHandle = (): void => {\n cancelReveal();\n cancelClear();\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n hide() {\n cancelReveal();\n cancelClear();\n visible = false;\n el.style.opacity = '0';\n clearTimer = setTimeout(() => {\n clearTimer = null;\n\n if (!visible) el.textContent = '';\n }, 150);\n },\n show(x: number, y: number, datum: Datum, series: Series) {\n if (!container.isConnected) return;\n\n cancelClear();\n\n if (render) {\n const html = render(datum, series);\n\n if (sanitize) {\n el.innerHTML = sanitize(html);\n } else {\n // No sanitizer provided — never inject the raw string as HTML. Render it as text instead.\n el.textContent = html;\n }\n } else {\n el.textContent = `${series.name}: ${datum.value}`;\n }\n\n const virtualRef = {\n getBoundingClientRect: () => {\n const rect = container.getBoundingClientRect();\n\n return {\n bottom: rect.top + y,\n height: 0,\n left: rect.left + x,\n right: rect.left + x,\n top: rect.top + y,\n width: 0,\n x: rect.left + x,\n y: rect.top + y,\n };\n },\n };\n\n const { x: positionX, y: positionY } = computePosition(virtualRef, el, {\n containingBlock: container,\n middleware: [offset(tooltipOffset), flip(), shift({ padding: 8 })],\n placement: 'top',\n });\n\n el.style.left = `${positionX}px`;\n el.style.top = `${positionY}px`;\n\n if (visible) {\n if (revealFrame === null) el.style.opacity = '1';\n\n return;\n }\n\n visible = true;\n el.style.opacity = '0';\n revealFrame = requestAnimationFrame(() => {\n revealFrame = null;\n\n if (visible) el.style.opacity = '1';\n });\n },\n [Symbol.dispose]: disposeHand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BAA6B,CAC3B,IAAM,EAAO,EAAU,sBAAsB,EAE7C,MAAO,CACL,OAAQ,EAAK,IAAM,EACnB,OAAQ,EACR,KAAM,EAAK,KAAO,EAClB,MAAO,EAAK,KAAO,EACnB,IAAK,EAAK,IAAM,EAChB,MAAO,EACP,EAAG,EAAK,KAAO,EACf,EAAG,EAAK,IAAM,CAChB,CACF,CAGqD,EAAY,EAAI,CACrE,gBAAiB,EACjB,WAAY,EAAC,EAAA,EAAA,OAAA,CAAO,CAAa,GAAG,EAAA,EAAA,KAAA,CAAK,GAAG,EAAA,EAAA,MAAA,CAAM,CAAE,QAAS,CAAE,CAAC,CAAC,EACjE,UAAW,KACb,CAAC,EAKD,GAHA,EAAG,MAAM,KAAO,GAAG,EAAU,IAC7B,EAAG,MAAM,IAAM,GAAG,EAAU,IAExB,EAAS,CACP,IAAgB,OAAM,EAAG,MAAM,QAAU,KAE7C,MACF,CAEA,EAAU,GACV,EAAG,MAAM,QAAU,IACnB,EAAc,0BAA4B,CACxC,EAAc,KAEV,IAAS,EAAG,MAAM,QAAU,IAClC,CAAC,CACH,GACC,OAAO,SAAU,CACpB,CACF"}
@@ -3,7 +3,7 @@ import { computePosition as e, flip as t, offset as n, shift as r } from "@vielz
3
3
  //#region src/interaction/tooltip.ts
4
4
  function i(i, a) {
5
5
  getComputedStyle(i).position === "static" && (i.style.position = "relative");
6
- let o = document.createElement("div");
6
+ let o = i.ownerDocument.createElement("div");
7
7
  o.className = "prism-tooltip", o.style.position = "absolute", o.style.pointerEvents = "none", o.style.top = "0", o.style.left = "0", o.setAttribute("role", "status"), o.setAttribute("aria-live", "polite"), i.appendChild(o);
8
8
  let s = a !== !0 && a?.offset || 8, c = a === !0 ? void 0 : a?.render, l = a === !0 ? void 0 : a?.sanitize, u = null, d = null, f = !1, p = () => {
9
9
  d !== null && (clearTimeout(d), d = null);
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":[],"sources":["../../src/interaction/tooltip.ts"],"sourcesContent":["import { computePosition, flip, offset, shift } from '@vielzeug/orbit';\nimport { warn } from '../_dev';\nimport type { Datum, Series, TooltipConfig } from '../types';\n\nexport interface TooltipState {\n dispose(): void;\n el: HTMLDivElement | null;\n hide(): void;\n show(x: number, y: number, datum: Datum, series: Series): void;\n [Symbol.dispose](): void;\n}\n\nexport function createTooltip(container: HTMLElement, config?: TooltipConfig | true): TooltipState {\n if (getComputedStyle(container).position === 'static') {\n container.style.position = 'relative';\n }\n\n const el = document.createElement('div');\n\n el.className = 'prism-tooltip';\n el.style.position = 'absolute';\n el.style.pointerEvents = 'none';\n el.style.top = '0';\n el.style.left = '0';\n // Non-modal status text — announced by assistive tech whenever content/hide state changes.\n el.setAttribute('role', 'status');\n el.setAttribute('aria-live', 'polite');\n container.appendChild(el);\n\n const tooltipOffset: number = (config !== true && config?.offset) || 8;\n const render = config !== true ? config?.render : undefined;\n const sanitize = config !== true ? config?.sanitize : undefined;\n\n if (render && !sanitize) {\n warn(\n 'createTooltip: `render` is set without `sanitize` — falling back to plain-text rendering of the returned string to avoid an XSS risk. Pass `sanitize` to render HTML.',\n );\n }\n\n let revealFrame: number | null = null;\n let clearTimer: ReturnType<typeof setTimeout> | null = null;\n let visible = false;\n\n const cancelClear = (): void => {\n if (clearTimer === null) return;\n\n clearTimeout(clearTimer);\n clearTimer = null;\n };\n\n const cancelReveal = (): void => {\n if (revealFrame === null) return;\n\n cancelAnimationFrame(revealFrame);\n revealFrame = null;\n };\n\n const disposeHandle = (): void => {\n cancelReveal();\n cancelClear();\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n hide() {\n cancelReveal();\n cancelClear();\n visible = false;\n el.style.opacity = '0';\n clearTimer = setTimeout(() => {\n clearTimer = null;\n\n if (!visible) el.textContent = '';\n }, 150);\n },\n show(x: number, y: number, datum: Datum, series: Series) {\n if (!container.isConnected) return;\n\n cancelClear();\n\n if (render) {\n const html = render(datum, series);\n\n if (sanitize) {\n el.innerHTML = sanitize(html);\n } else {\n // No sanitizer provided — never inject the raw string as HTML. Render it as text instead.\n el.textContent = html;\n }\n } else {\n el.textContent = `${series.name}: ${datum.value}`;\n }\n\n const virtualRef = {\n getBoundingClientRect: () => {\n const rect = container.getBoundingClientRect();\n\n return {\n bottom: rect.top + y,\n height: 0,\n left: rect.left + x,\n right: rect.left + x,\n top: rect.top + y,\n width: 0,\n x: rect.left + x,\n y: rect.top + y,\n };\n },\n };\n\n const { x: positionX, y: positionY } = computePosition(virtualRef, el, {\n containingBlock: container,\n middleware: [offset(tooltipOffset), flip(), shift({ padding: 8 })],\n placement: 'top',\n });\n\n el.style.left = `${positionX}px`;\n el.style.top = `${positionY}px`;\n\n if (visible) {\n if (revealFrame === null) el.style.opacity = '1';\n\n return;\n }\n\n visible = true;\n el.style.opacity = '0';\n revealFrame = requestAnimationFrame(() => {\n revealFrame = null;\n\n if (visible) el.style.opacity = '1';\n });\n },\n [Symbol.dispose]: disposeHandle,\n };\n}\n"],"mappings":";;;AAYA,SAAgB,EAAc,GAAwB,GAA6C;CACjG,AAAI,iBAAiB,CAAS,CAAC,CAAC,aAAa,aAC3C,EAAU,MAAM,WAAW;CAG7B,IAAM,IAAK,SAAS,cAAc,KAAK;CAUvC,AARA,EAAG,YAAY,iBACf,EAAG,MAAM,WAAW,YACpB,EAAG,MAAM,gBAAgB,QACzB,EAAG,MAAM,MAAM,KACf,EAAG,MAAM,OAAO,KAEhB,EAAG,aAAa,QAAQ,QAAQ,GAChC,EAAG,aAAa,aAAa,QAAQ,GACrC,EAAU,YAAY,CAAE;CAExB,IAAM,IAAyB,MAAW,MAAQ,GAAQ,UAAW,GAC/D,IAAS,MAAW,KAAwB,KAAA,IAAjB,GAAQ,QACnC,IAAW,MAAW,KAA0B,KAAA,IAAnB,GAAQ,UAQvC,IAA6B,MAC7B,IAAmD,MACnD,IAAU,IAER,UAA0B;EAC1B,MAAe,SAEnB,aAAa,CAAU,GACvB,IAAa;CACf,GAEM,UAA2B;EAC3B,MAAgB,SAEpB,qBAAqB,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GACC,OAAO,UAAU;CACpB;AACF"}
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../src/interaction/tooltip.ts"],"sourcesContent":["import { computePosition, flip, offset, shift } from '@vielzeug/orbit';\nimport { warn } from '../_dev';\nimport type { Datum, Series, TooltipConfig } from '../types';\n\nexport interface TooltipState {\n dispose(): void;\n el: HTMLDivElement | null;\n hide(): void;\n show(x: number, y: number, datum: Datum, series: Series): void;\n [Symbol.dispose](): void;\n}\n\nexport function createTooltip(container: HTMLElement, config?: TooltipConfig | true): TooltipState {\n if (getComputedStyle(container).position === 'static') {\n container.style.position = 'relative';\n }\n\n const el = container.ownerDocument.createElement('div');\n\n el.className = 'prism-tooltip';\n el.style.position = 'absolute';\n el.style.pointerEvents = 'none';\n el.style.top = '0';\n el.style.left = '0';\n // Non-modal status text — announced by assistive tech whenever content/hide state changes.\n el.setAttribute('role', 'status');\n el.setAttribute('aria-live', 'polite');\n container.appendChild(el);\n\n const tooltipOffset: number = (config !== true && config?.offset) || 8;\n const render = config !== true ? config?.render : undefined;\n const sanitize = config !== true ? config?.sanitize : undefined;\n\n if (render && !sanitize) {\n warn(\n 'createTooltip: `render` is set without `sanitize` — falling back to plain-text rendering of the returned string to avoid an XSS risk. Pass `sanitize` to render HTML.',\n );\n }\n\n let revealFrame: number | null = null;\n let clearTimer: ReturnType<typeof setTimeout> | null = null;\n let visible = false;\n\n const cancelClear = (): void => {\n if (clearTimer === null) return;\n\n clearTimeout(clearTimer);\n clearTimer = null;\n };\n\n const cancelReveal = (): void => {\n if (revealFrame === null) return;\n\n cancelAnimationFrame(revealFrame);\n revealFrame = null;\n };\n\n const disposeHandle = (): void => {\n cancelReveal();\n cancelClear();\n el.remove();\n };\n\n return {\n dispose: disposeHandle,\n el,\n hide() {\n cancelReveal();\n cancelClear();\n visible = false;\n el.style.opacity = '0';\n clearTimer = setTimeout(() => {\n clearTimer = null;\n\n if (!visible) el.textContent = '';\n }, 150);\n },\n show(x: number, y: number, datum: Datum, series: Series) {\n if (!container.isConnected) return;\n\n cancelClear();\n\n if (render) {\n const html = render(datum, series);\n\n if (sanitize) {\n el.innerHTML = sanitize(html);\n } else {\n // No sanitizer provided — never inject the raw string as HTML. Render it as text instead.\n el.textContent = html;\n }\n } else {\n el.textContent = `${series.name}: ${datum.value}`;\n }\n\n const virtualRef = {\n getBoundingClientRect: () => {\n const rect = container.getBoundingClientRect();\n\n return {\n bottom: rect.top + y,\n height: 0,\n left: rect.left + x,\n right: rect.left + x,\n top: rect.top + y,\n width: 0,\n x: rect.left + x,\n y: rect.top + y,\n };\n },\n };\n\n const { x: positionX, y: positionY } = computePosition(virtualRef, el, {\n containingBlock: container,\n middleware: [offset(tooltipOffset), flip(), shift({ padding: 8 })],\n placement: 'top',\n });\n\n el.style.left = `${positionX}px`;\n el.style.top = `${positionY}px`;\n\n if (visible) {\n if (revealFrame === null) el.style.opacity = '1';\n\n return;\n }\n\n visible = true;\n el.style.opacity = '0';\n revealFrame = requestAnimationFrame(() => {\n revealFrame = null;\n\n if (visible) el.style.opacity = '1';\n });\n },\n [Symbol.dispose]: disposeHandle,\n };\n}\n"],"mappings":";;;AAYA,SAAgB,EAAc,GAAwB,GAA6C;CACjG,AAAI,iBAAiB,CAAS,CAAC,CAAC,aAAa,aAC3C,EAAU,MAAM,WAAW;CAG7B,IAAM,IAAK,EAAU,cAAc,cAAc,KAAK;CAUtD,AARA,EAAG,YAAY,iBACf,EAAG,MAAM,WAAW,YACpB,EAAG,MAAM,gBAAgB,QACzB,EAAG,MAAM,MAAM,KACf,EAAG,MAAM,OAAO,KAEhB,EAAG,aAAa,QAAQ,QAAQ,GAChC,EAAG,aAAa,aAAa,QAAQ,GACrC,EAAU,YAAY,CAAE;CAExB,IAAM,IAAyB,MAAW,MAAQ,GAAQ,UAAW,GAC/D,IAAS,MAAW,KAAwB,KAAA,IAAjB,GAAQ,QACnC,IAAW,MAAW,KAA0B,KAAA,IAAnB,GAAQ,UAQvC,IAA6B,MAC7B,IAAmD,MACn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AU,IACV,EAAG,MAAM,UAAU,KACnB,IAAc,4BAA4B;IAGxC,AAFA,IAAc,MAEV,MAAS,EAAG,MAAM,UAAU;GAClC,CAAC;EACH;GACC,OAAO,UAAU;CACpB;AACF"}
package/dist/prism.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/ripple"),t=require("@vielzeug/orbit");var n={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function r(e){return typeof e==`function`?e:e!==void 0&&Object.hasOwn(n,e)?n[e]:n[`ease-out`]}function i(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}function a(e,t,n){return e+(t-e)*n}function o(e,t,n,o){let s=i(t),c=s.duration,l=r(s.easing),u=s.stagger;if(c===0||e.length===0){for(let t of e)for(let[e,{to:n}]of Object.entries(t.attrs))t.el.setAttribute(e,String(n));return n?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(e.length-1));function m(t){if(f||o?.aborted)return;d===null&&(d=t);let r=t-d;for(let t=0;t<e.length;t++){let n=e[t],i=u*t,o=Math.max(0,r-i),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(n.attrs))n.el.setAttribute(e,String(a(t,r,d)))}r<p?requestAnimationFrame(m):n?.()}return requestAnimationFrame(m),()=>{f=!0}}var s=`http://www.w3.org/2000/svg`;function c(e,t){let n=document.createElementNS(s,e);return t&&l(n,t),n}function l(e,t){for(let[n,r]of Object.entries(t)){if(r===void 0){e.removeAttribute(n);continue}typeof r==`number`&&!Number.isFinite(r)&&`${n}${e.tagName}${r}`,e.setAttribute(n,String(r))}}function u(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function d(e,t){let n=c(`text`,t);return n.textContent=e,n}function f(e){return typeof e.bandwidth==`function`}function p(e,t){return f(e)?e.map(t)+e.bandwidth()/2:e.map(t)}var m=e=>e instanceof Date?e.toLocaleDateString(void 0,{month:`short`,year:`numeric`}):String(e);function h(e,t,n){let r=e.position??n,i=r===`bottom`||r===`top`?Math.max(2,Math.floor(t/80)):Math.max(2,Math.floor(t/50));return e.tickCount??i}function g(e,t,n,r,i=`bottom`){u(e);let a=n.position??i,o=a===`bottom`||a===`top`,s=a===`top`||a===`left`,f=s?-1:1,g=c(`line`,{"aria-hidden":`true`,class:`prism-axis-line`,x1:0,x2:o?r:0,y1:0,y2:o?0:r});e.appendChild(g);let _=t.ticks(h(n,r,i)),v=n.tickFormat??m;for(let n of _){let r=p(t,n),i=c(`line`,{"aria-hidden":`true`,class:`prism-axis-tick`,x1:o?r:0,x2:o?r:6*f,y1:o?0:r,y2:o?6*f:r});e.appendChild(i);let a=d(v(n),{"aria-hidden":`true`,class:`prism-axis-label`,"dominant-baseline":o?s?`auto`:`hanging`:`middle`,"text-anchor":o?`middle`:s?`end`:`start`,x:o?r:6*f*1.5,y:o?6*f*1.5:r});e.appendChild(a)}if(n.label){let t=d(n.label,{class:`prism-axis-title`,"dominant-baseline":`middle`,"text-anchor":`middle`});o?l(t,{x:r/2,y:6*f*3.5}):l(t,{transform:`translate(${6*f*4}, ${r/2}) rotate(-90)`}),e.appendChild(t)}}function _(e,t,n,r,i,a=10){u(e);let o=n!==!0&&n.color||void 0,s=n!==!0&&n.dash||void 0,l=t.ticks(a);for(let n of l){let a=p(t,n),l={class:`prism-grid-line`,stroke:o??`var(--prism-grid-color)`,"stroke-dasharray":s,"stroke-opacity":`var(--prism-grid-opacity)`};i===`vertical`?Object.assign(l,{x1:a,x2:a,y1:0,y2:r}):Object.assign(l,{x1:0,x2:r,y1:a,y2:a}),e.appendChild(c(`line`,l))}}function v(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function y(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return[0,1];if(e>t&&([e,t]=[t,e]),e===t)return[e-1,t+1];let r=v(v(t-e,!1)/Math.max(1,n-1),!0);return[Math.floor(e/r)*r,Math.ceil(t/r)*r]}function b(e){let t=()=>e.nice===!1?e.domain:y(e.domain[0],e.domain[1],10),n=()=>e.range;return{get domain(){return t()},invert(e){let[r,i]=t(),[a,o]=n();return o===a?r:r+(e-a)/(o-a)*(i-r)},map(r){let[i,a]=t(),[o,s]=n();if(a===i)return o;let c=(r-i)/(a-i);return e.clamp&&(c=Math.max(0,Math.min(1,c))),o+c*(s-o)},get range(){return n()},ticks(e=10){if(e<=0)return[];let[n,r]=t();if(n===r||e===1)return[n];let i=Math.min(n,r),a=Math.max(n,r),o=v(v(a-i,!1)/(e-1),!0),s=Math.ceil(i/o)*o,c=Math.floor(a/o)*o,l=[];for(let e=s;e<=c+o*.5;e+=o)l.push(Math.round(e*0xe8d4a51000)/0xe8d4a51000);return l}}}var x=1e3,S=60*x,C=60*S,w=24*C,T=30*w,E=365*w,D=[x,5*x,15*x,30*x,S,5*S,15*S,30*S,C,3*C,6*C,12*C,w,7*w,T,3*T,6*T,E];function O(e,t){let n=Math.abs(e)/Math.max(1,t);for(let e of D)if(e>=n)return e;return E}function k(e,t){let[n,r]=e;n.getTime()>r.getTime()&&([n,r]=[r,n]);let i=O(r.getTime()-n.getTime(),t);return[new Date(Math.floor(n.getTime()/i)*i),new Date(Math.ceil(r.getTime()/i)*i)]}function A(e){let t=()=>e.nice===!1?e.domain:k(e.domain,10),n=()=>e.range;return{get domain(){return t()},invert(e){let[r,i]=t(),[a,o]=n();if(o===a)return r;let s=(e-a)/(o-a);return new Date(r.getTime()+s*(i.getTime()-r.getTime()))},map(e){let[r,i]=t(),[a,o]=n(),s=i.getTime()-r.getTime();return s===0?a:a+(e.getTime()-r.getTime())/s*(o-a)},get range(){return n()},ticks(e=10){let[n,r]=t(),i=O(r.getTime()-n.getTime(),e),a=Math.ceil(n.getTime()/i)*i,o=[];for(let e=a;e<=r.getTime();e+=i)o.push(new Date(e));return o}}}function j(e,t){if(e.length===0||e.some(e=>e==null)||e.some(e=>typeof e==`number`&&!Number.isFinite(e)))return b({domain:[0,1],range:[0,t]});if(e[0]instanceof Date){let n=e,r=Math.min(...n.map(Number)),i=Math.max(...n.map(Number));return A({domain:[new Date(r),new Date(r===i?i+1:i)],range:[0,t]})}let n=e,r=Math.min(...n),i=Math.max(...n);return b({domain:[r,r===i?i+1:i],nice:!1,range:[0,t]})}function M(e,t,n=!0){if(e.length===0||e.some(e=>e==null)||e.some(e=>!Number.isFinite(e)))return b({domain:[0,1],range:[t,0]});let r=Math.min(...e),i=n?Math.min(0,r):r,a=Math.max(...e);return b({domain:[i,i===a?a+1:a],range:[t,0]})}function N(e){return e===!0?`bottom`:e.position??`bottom`}function P(e,t){let n=N(t),r=document.createElement(`div`);r.className=`prism-legend prism-legend-${n}`,n===`top`?e.insertBefore(r,e.firstChild):e.appendChild(r);let i=()=>{r.remove()};return{dispose:i,el:r,[Symbol.dispose]:i,update(e){r.innerHTML=``;for(let t of e){let e=document.createElement(`div`);e.className=`prism-legend-item`;let n=document.createElement(`span`);n.className=`prism-legend-dot`,n.style.backgroundColor=t.color;let i=document.createElement(`span`);i.className=`prism-legend-label`,i.textContent=t.name,e.appendChild(n),e.appendChild(i),r.appendChild(e)}}}}function ee(e,n){getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let r=document.createElement(`div`);r.className=`prism-tooltip`,r.style.position=`absolute`,r.style.pointerEvents=`none`,r.style.top=`0`,r.style.left=`0`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`),e.appendChild(r);let i=n!==!0&&n?.offset||8,a=n===!0?void 0:n?.render,o=n===!0?void 0:n?.sanitize,s=null,c=null,l=!1,u=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{s!==null&&(cancelAnimationFrame(s),s=null)},f=()=>{d(),u(),r.remove()};return{dispose:f,el:r,hide(){d(),u(),l=!1,r.style.opacity=`0`,c=setTimeout(()=>{c=null,l||(r.textContent=``)},150)},show(n,c,d,f){if(!e.isConnected)return;if(u(),a){let e=a(d,f);o?r.innerHTML=o(e):r.textContent=e}else r.textContent=`${f.name}: ${d.value}`;let{x:p,y:m}=(0,t.computePosition)({getBoundingClientRect:()=>{let t=e.getBoundingClientRect();return{bottom:t.top+c,height:0,left:t.left+n,right:t.left+n,top:t.top+c,width:0,x:t.left+n,y:t.top+c}}},r,{containingBlock:e,middleware:[(0,t.offset)(i),(0,t.flip)(),(0,t.shift)({padding:8})],placement:`top`});if(r.style.left=`${p}px`,r.style.top=`${m}px`,l){s===null&&(r.style.opacity=`1`);return}l=!0,r.style.opacity=`0`,s=requestAnimationFrame(()=>{s=null,l&&(r.style.opacity=`1`)})},[Symbol.dispose]:f}}var te=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},ne=class extends te{},F={bottom:40,left:50,right:20,top:20};function re(e){return{...F,...e}}function I(e,t,n){return{height:Math.max(0,t-n.top-n.bottom),width:Math.max(0,e-n.left-n.right)}}function ie(e,t){let n=null,r=new ResizeObserver(e=>{n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{n=null;let r=e[0];if(r){let{height:e,width:n}=r.contentRect;t(n,e)}})});return r.observe(e),()=>{n!==null&&cancelAnimationFrame(n),r.disconnect()}}function ae(t,n){if(!(typeof t==`object`&&t&&t.nodeType===1&&typeof t.appendChild==`function`&&typeof t.getBoundingClientRect==`function`)){let e=t;throw new ne(`Invalid chart configuration: \`container\` must be a DOM Element, received ${e===null?`null`:typeof e==`object`?e.constructor?.name??`object`:typeof e}.`)}let r=re(n.margin),i=n.a11y,a=c(`svg`,{...n.ariaHidden||i?.decorative?{"aria-hidden":`true`}:{...i?{"aria-label":i.ariaLabel,tabindex:`0`}:{},role:`img`},class:`prism-chart`,style:`display:block;width:100%;height:100%`}),o=c(`g`,{class:`prism-chart-area`,transform:`translate(${r.left},${r.top})`});a.appendChild(o);let s=t.getBoundingClientRect();s.width===0||s.height;let u=typeof getComputedStyle<`u`?getComputedStyle(t):null;u&&u.position;let d=(0,e.signal)({height:s.height||300,margin:r,width:s.width||600}),f=ie(t,(e,t)=>{d.value={height:t,margin:r,width:e},l(a,{height:t,viewBox:`0 0 ${e} ${t}`,width:e})}),p=s.width||600,m=s.height||300;return l(a,{height:m,viewBox:`0 0 ${p} ${m}`,width:p}),t.appendChild(a),{chartArea:o,dimensions:d,dispose(){f(),a.remove()},svg:a}}function L(e,t,n,r){u(e.series),u(e.grid),u(e.xAxis),u(e.yAxis),t?.update([]),n?.hide(),r?.hide()}function oe(t,n,r,i){let a=ae(t,{a11y:n.a11y,margin:n.margin}),o=n.tooltip?ee(t,n.tooltip):null,s=n.legend?P(t,n.legend):null,c=new AbortController,l=r(a,o,s,c.signal),u=!1,d=se(a.svg),f=(0,e.createScope)();f.run(()=>{(0,e.effect)(()=>{u||d.attach(i(l))},{scheduler:`microtask`})});let p=[];if(n.plugins){let e={container:t,dimensions:a.dimensions,disposalSignal:c.signal,svg:a.svg};for(let t of n.plugins)try{t.install(e),p.push(t)}catch{}}return{get disposalSignal(){return c.signal},dispose(){if(!u){u=!0,c.abort(),d.detach();for(let e of p)try{e.dispose()}catch{}o?.dispose(),s?.dispose(),f.dispose(),a.dispose()}},get disposed(){return u},el:a.svg,[Symbol.dispose](){this.dispose()}}}function se(e){let t=null;return{attach(n){t&&=(t.onMouseMove&&e.removeEventListener(`mousemove`,t.onMouseMove),t.onMouseLeave&&e.removeEventListener(`mouseleave`,t.onMouseLeave),t.onClick&&e.removeEventListener(`click`,t.onClick),t.onKeyDown&&e.removeEventListener(`keydown`,t.onKeyDown),null),n&&(t=n,n.onMouseMove&&e.addEventListener(`mousemove`,n.onMouseMove),n.onMouseLeave&&e.addEventListener(`mouseleave`,n.onMouseLeave),n.onClick&&e.addEventListener(`click`,n.onClick),n.onKeyDown&&e.addEventListener(`keydown`,n.onKeyDown))},detach(){this.attach(void 0)}}}function R(e,t,n){return oe(e,t,(t,n,r,i)=>{let a={grid:c(`g`,{"aria-hidden":`true`,class:`prism-grid`}),series:c(`g`,{class:`prism-series`}),xAxis:c(`g`,{class:`prism-x-axis`}),yAxis:c(`g`,{class:`prism-y-axis`})};return t.chartArea.appendChild(a.grid),t.chartArea.appendChild(a.xAxis),t.chartArea.appendChild(a.yAxis),t.chartArea.appendChild(a.series),{chartArea:t.chartArea,container:e,dimensions:t.dimensions,disposalSignal:i,groups:a,legend:r,svg:t.svg,tooltip:n}},n)}function ce(e,t,n){return oe(e,t,(t,n,r,i)=>({container:e,dimensions:t.dimensions,disposalSignal:i,legend:r,svg:t.svg,tooltip:n}),n)}function le(e,t){let n=t===!0||t?.vertical!==!1,r=t!==!0&&t?.horizontal===!0,i=t===!0||t?.snap!==!1,a=c(`g`,{"aria-hidden":`true`,class:`prism-crosshair`,style:`display:none`}),o=n?c(`line`,{class:`prism-crosshair-v`,"stroke-dasharray":`var(--prism-crosshair-dash, 4 2)`}):null,s=r?c(`line`,{class:`prism-crosshair-h`,"stroke-dasharray":`var(--prism-crosshair-dash, 4 2)`}):null;o&&a.appendChild(o),s&&a.appendChild(s),e.appendChild(a);let u=c(`text`,{"aria-live":`polite`,class:`prism-crosshair-live`,role:`status`,x:-9999,y:-9999});return e.appendChild(u),{hide(){a.style.display=`none`,u.textContent=``},show(e,t,n,r,i){a.style.display=``,o&&l(o,{x1:e,x2:e,y1:0,y2:r}),s&&l(s,{x1:0,x2:n,y1:t,y2:t}),i!==void 0&&(u.textContent=i)},snap:i}}function z(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}function ue(e,t){let n=[],r=new Map;return{domain:n,labels:r,series:e.map((e,i)=>{let a=new Map;for(let o of t[i]??[]){let t=z(o.key);if(a.has(t)){`${String(o.key)}${e.name}`;continue}a.set(t,o),r.has(t)||(r.set(t,o.key),n.push(t))}return{byKey:a,config:e}})}}function B(e,t,n,r){let i=e.getBoundingClientRect();return{x:t.clientX-i.left-n,y:t.clientY-i.top-r}}function de(e,t,n){let r=null,i=1/0;for(let a=0;a<t.length;a++)for(let o=0;o<(t[a]?.length??0);o++){let s=e[a]?.[o],c=t[a]?.[o];if(!s||!c)continue;let l=Math.abs(c.x-n);l<i&&(i=l,r=s.key)}return r}function V(e,t,n,r){let i=z(n),a=null,o=1/0;for(let n=0;n<t.length;n++){let s=e[n]?.findIndex(e=>z(e.key)===i)??-1,c=s===-1?void 0:e[n]?.[s],l=s===-1?void 0:t[n]?.[s];if(!c||!l)continue;let u=Number.isFinite(r)?Math.abs(l.y-r):0;u<o&&(o=u,a={datum:c,point:l,seriesIndex:n})}return a}function fe(e){let t=0;return{onClick:t=>{if(!e.onClick)return;let n=e.getPoints();if(n.length===0||n[0].length===0)return;let r=e.dims(),i=B(e.svg,t,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height)return;let o=de(e.getData(),n,i.x);if(o===null)return;let s=V(e.getData(),n,o,i.y),c=s?e.getSeriesList()[s.seriesIndex]:void 0;s&&c&&e.onClick({datum:s.datum,originalEvent:t,series:c})},onKeyDown:n=>{let r=e.getData(),i=e.getPoints(),a=[...new Map(r.flat().map(e=>[z(e.key),e.key])).values()];if(a.length!==0){if(n.key===`ArrowLeft`||n.key===`ArrowRight`){n.preventDefault(),t=Math.max(0,Math.min(a.length-1,t+(n.key===`ArrowLeft`?-1:1)));let o=a[t],s=V(r,i,o,1/0),c=s?e.getSeriesList()[s.seriesIndex]:void 0;if(!s||!c)return;e.crosshair?.show(s.point.x,s.point.y,e.dims().width,e.dims().height,`${c.name}: ${s.datum.value}`),e.tooltip?.show(s.point.x+e.dims().margin.left,s.point.y+e.dims().margin.top,s.datum,c),e.onHover?.({datum:s.datum,originalEvent:n,series:c})}if((n.key===`Enter`||n.key===` `)&&e.onClick){n.preventDefault();let o=a[t],s=V(r,i,o,1/0),c=s?e.getSeriesList()[s.seriesIndex]:void 0;s&&c&&e.onClick({datum:s.datum,originalEvent:n,series:c})}n.key===`Escape`&&(e.crosshair?.hide(),e.tooltip?.hide(),e.onHover?.(null))}},onMouseLeave:()=>{e.crosshair?.hide(),e.tooltip?.hide(),e.onHover?.(null)},onMouseMove:t=>{let n=e.getPoints();if(n.length===0||n[0].length===0)return;let r=e.dims(),i=B(e.svg,t,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height){e.crosshair?.hide(),e.tooltip?.hide();return}let o=de(e.getData(),n,i.x);if(o===null)return;let s=V(e.getData(),n,o,i.y),c=s?e.getSeriesList()[s.seriesIndex]:void 0,l=e.crosshair?.snap===!1?i.x:s?.point.x??i.x,u=e.crosshair?.snap===!1?i.y:s?.point.y??i.y;e.crosshair?.show(l,u,a.width,a.height,c&&s?`${c.name}: ${s.datum.value}`:void 0),s&&c&&(e.tooltip?.show(s.point.x+r.margin.left,s.point.y+r.margin.top,s.datum,c),e.onHover?.({datum:s.datum,originalEvent:t,series:c}))}}}var H=8;function pe(e){let t=document.documentElement;if(e.colors)for(let n=0;n<H;n++){let r=e.colors[n];r?t.style.setProperty(`--prism-color-${n+1}`,r):t.style.removeProperty(`--prism-color-${n+1}`)}e.fontFamily&&t.style.setProperty(`--prism-font-family`,e.fontFamily),e.gridColor&&t.style.setProperty(`--prism-grid-color`,e.gridColor),e.gridOpacity!==void 0&&t.style.setProperty(`--prism-grid-opacity`,String(e.gridOpacity))}function me(){let e=document.documentElement;for(let t=1;t<=H;t++)e.style.removeProperty(`--prism-color-${t}`);e.style.removeProperty(`--prism-font-family`),e.style.removeProperty(`--prism-grid-color`),e.style.removeProperty(`--prism-grid-opacity`)}function U(e,t){return t??`var(--prism-color-${e%H+1})`}function W(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=1;n<e.length;n++)t+=`L${e[n].x},${e[n].y}`;return t}function G(e){if(e.length<3)return W(e);let t=e.length,n=[];for(let r=0;r<t;r++)r===0?n.push({x:e[1].x-e[0].x,y:e[1].y-e[0].y}):r===t-1?n.push({x:e[t-1].x-e[t-2].x,y:e[t-1].y-e[t-2].y}):n.push({x:(e[r+1].x-e[r-1].x)/2,y:(e[r+1].y-e[r-1].y)/2});let r=`M${e[0].x},${e[0].y}`;for(let i=0;i<t-1;i++){let t=e[i],a=e[i+1],o=n[i],s=n[i+1],c=(a.x-t.x)/3;r+=`C${t.x+c},${t.y+o.y/3},${a.x-c},${a.y-s.y/3},${a.x},${a.y}`}return r}function K(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=1;n<e.length;n++){let r=(e[n-1].x+e[n].x)/2;t+=`H${r}V${e[n].y}H${e[n].x}`}return t}function q(e,t,n=`linear`){if(e.length===0)return``;let r=n===`monotone`?G(e):n===`step`?K(e):W(e),i=[...t].reverse();if(i.length>0){r+=`L${i[0].x},${i[0].y}`;for(let e=1;e<i.length;e++)r+=`L${i[e].x},${i[e].y}`}return r+=`Z`,r}var J=new WeakMap,Y=new WeakMap;function he(e,t){return t===`monotone`?G(e):t===`step`?K(e):W(e)}function ge(e,t,n,o){let s=i(o.transition,0),u=s.duration,d=r(s.easing),f=e.querySelector(`.prism-area-fill`);f||(f=c(`path`,{class:`prism-area-fill`}),e.appendChild(f)),l(f,{fill:o.color,"fill-opacity":o.fillOpacity,stroke:`none`});let p=null;if(o.showLine?(p=e.querySelector(`.prism-area-line`),p||(p=c(`path`,{class:`prism-area-line`,fill:`none`}),e.appendChild(p)),l(p,{stroke:o.color,"stroke-width":2})):e.querySelector(`.prism-area-line`)?.remove(),u===0){let e=t.map(e=>({x:e.x,y:n}));l(f,{d:q(t,e,o.curve)}),p&&l(p,{d:he(t,o.curve)});return}if(J.get(e)?.(),!f.hasAttribute(`d`)){let r=t.map(e=>({x:e.x,y:n}));l(f,{d:q(t,r,o.curve)}),p&&l(p,{d:he(t,o.curve)}),Y.set(e,t);return}let m=Y.get(e)??t,h=t.map((e,n)=>m[n]??m[m.length-1]??t[n]),g=null;function _(r){if(o.disposalSignal?.aborted){J.delete(e);return}g===null&&(g=r);let i=Math.min(1,(r-g)/u),s=d(i),c=t.map((e,t)=>({x:a(h[t].x,e.x,s),y:a(h[t].y,e.y,s)})),m=c.map(e=>({x:e.x,y:n}));if(l(f,{d:q(c,m,o.curve)}),p&&l(p,{d:he(c,o.curve)}),i<1){let t=requestAnimationFrame(_);J.set(e,()=>cancelAnimationFrame(t))}else J.delete(e),Y.set(e,t)}Y.set(e,h);let v=requestAnimationFrame(_);J.set(e,()=>cancelAnimationFrame(v))}function _e(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}function ve(t,n){let r=null;return R(t,n,t=>{let{groups:i,legend:a,tooltip:o}=t,s=t.dimensions.value,l=I(s.width,s.height,s.margin),u=(0,e.isReactive)(n.series)?n.series.value:n.series,d=u.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data),f=d.flat().map(e=>e.key),p=d.flat().map(e=>e.value);if(f.length===0){L(i,a,o,r);return}n.crosshair&&!r&&(r=le(t.chartArea,n.crosshair));let m=j(f,l.width),v=M(p,l.height),y=v.map(0);for(n.yAxis?.grid&&_(i.grid,v,n.yAxis.grid,l.width,`horizontal`,h(n.yAxis,l.height,`left`)),n.xAxis?.grid&&_(i.grid,m,n.xAxis.grid,l.height,`vertical`,h(n.xAxis,l.width,`bottom`)),n.xAxis&&(i.xAxis.setAttribute(`transform`,`translate(0,${l.height})`),g(i.xAxis,m,n.xAxis,l.width,`bottom`)),n.yAxis&&g(i.yAxis,v,n.yAxis,l.height,`left`);i.series.children.length>u.length;)i.series.removeChild(i.series.lastChild);let b=[];for(let e=0;e<u.length;e++){let r=u[e],a=i.series.children[e];a||(a=c(`g`,{class:`prism-area-series`}),i.series.appendChild(a));let o=_e(d[e],m,v);b.push(o),ge(a,o,y,{color:U(e,r.color),curve:r.curve??`linear`,disposalSignal:t.disposalSignal,fillOpacity:r.fillOpacity??.3,showLine:r.showLine!==!1,transition:n.transition})}return a?.update(u.map((e,t)=>({color:U(t,e.color),name:e.name}))),o?.hide(),fe({crosshair:r,dims:()=>t.dimensions.value,getData:()=>d,getPoints:()=>b,getSeriesList:()=>(0,e.isReactive)(n.series)?n.series.value:n.series,onClick:n.onClick,onHover:n.onHover,svg:t.svg,tooltip:o})})}function ye(e){let t=()=>e.domain,n=()=>e.range,r=()=>{let r=t().length;if(r===0)return 0;let[i,a]=n(),o=e.padding??.1;return(a-i)/(r+(r-1)*o+(e.paddingOuter??o)*2)};return{bandwidth:r,get domain(){return t()},gap(){let t=e.padding??.1;return r()*t},map(i){let a=t().indexOf(i);if(a===-1)return`${i}`,0;let[o]=n(),s=r(),c=e.padding??.1;return o+(e.paddingOuter??c)*s+a*(s+s*c)},get range(){return n()},ticks(e){let n=t();if(e===void 0||e>=n.length)return[...n];if(e<=0)return[];let r=Math.ceil(n.length/e);return n.filter((e,t)=>t%r===0)}}}function be(e,t,n){for(let r=0;r<t.length;r++){let i=n.bandCenter(t[r])-n.bandwidth/2;if(e>=i&&e<i+n.bandwidth)return r}return-1}function xe(e,t,n,r,i){if(r.stacked)if(r.horizontal){for(let n=0;n<i;n++)if(r.valueScale.map(r.stackedTops[n]?.[t]??0)>=e.x)return n;return i-1}else{for(let n=0;n<i;n++)if(r.valueScale.map(r.stackedTops[n]?.[t]??0)<=e.y)return n;return i-1}{let a=r.bandwidth/i,o=r.bandCenter(n[t])-r.bandwidth/2,s=r.horizontal?e.y-o:e.x-o,c=Math.floor(s/a);return Math.max(0,Math.min(i-1,c))}}function Se(e,t,n,r,i){let a=i-1,o=r.stacked?r.stackedTops[a]?.[t]??0:Math.max(...Array.from({length:i},(e,r)=>n[r]?.[t]?.value??0)),s=r.valueScale.map(o);return r.horizontal?e.x>s:e.y<s}var Ce=new WeakMap;function we(e,t,n,r,i,a){for(;e.children.length>t.length;){let t=e.lastElementChild;t&&e.removeChild(t)}let s=n.bandwidth(),u=a.stacked?s:s/a.seriesCount,d=a.stacked?0:u*a.seriesIndex,f=a.horizontal??!1,p=[],m=[];for(let o=0;o<t.length;o++){let s=t[o],h=n.map(s.key)+d,g=a.baselineYs?a.baselineYs[o]:i,_=r.map(s.y),v=e.children[o],y=!v;if(v||(v=c(`rect`,{class:`prism-bar`}),e.appendChild(v)),v.style.display=s.present?``:`none`,f){let e=Math.max(0,Math.abs(g-_)),t=Math.min(_,g);l(v,{fill:a.color,height:Math.max(0,u-1),rx:a.borderRadius,ry:a.borderRadius,y:h}),a.transition?y?(l(v,{width:0,x:g}),p.push({attrs:{width:{from:0,to:e},x:{from:g,to:t}},el:v})):m.push({attrs:{width:{from:Number(v.getAttribute(`width`)??e),to:e},x:{from:Number(v.getAttribute(`x`)??t),to:t}},el:v}):l(v,{width:e,x:t})}else{let e=Math.max(0,Math.abs(g-_)),t=Math.min(_,g);l(v,{fill:a.color,rx:a.borderRadius,ry:a.borderRadius,width:Math.max(0,u-1),x:h}),a.transition?y?(l(v,{height:0,y:g}),p.push({attrs:{height:{from:0,to:e},y:{from:g,to:t}},el:v})):m.push({attrs:{height:{from:Number(v.getAttribute(`height`)??e),to:e},y:{from:Number(v.getAttribute(`y`)??t),to:t}},el:v}):l(v,{height:e,y:t})}}if(a.transition){Ce.get(e)?.();let t=[];p.length>0&&t.push(o(p,a.transition,void 0,a.disposalSignal)),m.length>0&&t.push(o(m,{...a.transition,stagger:0},void 0,a.disposalSignal)),Ce.set(e,()=>{for(let e of t)e()})}}function Te(e){return{horizontal:e===`grouped-horizontal`||e===`stacked-horizontal`,stacked:e===`stacked`||e===`stacked-horizontal`}}function Ee(t,n){return R(t,n,t=>{let{groups:r,legend:i,tooltip:a}=t,o=t.dimensions.value,s=I(o.width,o.height,o.margin),l=(0,e.isReactive)(n.series)?n.series.value:n.series,u=ue(l,l.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data)),d=u.domain,f=u.series.map(({byKey:e})=>d.map(t=>e.get(t))),p=e=>{if(e)return{...e,tickFormat:t=>{let n=String(t),r=u.labels.get(n)??t;return e.tickFormat?e.tickFormat(r):String(r)}}};if(d.length===0){L(r,i,a);return}let{horizontal:m,stacked:v}=Te(n.variant??`grouped`),y,x;if(v){f.some(e=>e.some(e=>(e?.value??0)<0));let e=d.map((e,t)=>f.reduce((e,n)=>e+Math.max(0,n[t]?.value??0),0));y=Math.max(...e),x=0}else{let e=f.flatMap(e=>e.flatMap(e=>e?[e.value]:[]));y=Math.max(...e),x=Math.min(0,...e)}let S=ye(m?{domain:d,range:[0,s.height]}:{domain:d,range:[0,s.width]}),C=b(m?{domain:[x,y],range:[0,s.width]}:{domain:[x,y],range:[s.height,0]}),w=[],T=Object.create(null);for(let e of d)T[e]=0;let E={bandCenter:e=>S.map(e)+S.bandwidth()/2,bandwidth:S.bandwidth(),baselinePx:C.map(0),horizontal:m,stacked:v,stackedTops:w,valueScale:C};if(m){n.xAxis?.grid&&_(r.grid,C,n.xAxis.grid,s.height,`vertical`,h(n.xAxis,s.width,`bottom`));let e=p(n.yAxis);e&&g(r.yAxis,S,e,s.height,`left`),n.xAxis&&(r.xAxis.setAttribute(`transform`,`translate(0,${s.height})`),g(r.xAxis,C,n.xAxis,s.width,`bottom`))}else{n.yAxis?.grid&&_(r.grid,C,n.yAxis.grid,s.width,`horizontal`,h(n.yAxis,s.height,`left`));let e=p(n.xAxis);e&&(r.xAxis.setAttribute(`transform`,`translate(0,${s.height})`),g(r.xAxis,S,e,s.width,`bottom`)),n.yAxis&&g(r.yAxis,C,n.yAxis,s.height,`left`)}for(;r.series.children.length>l.length;){let e=r.series.lastElementChild;e&&r.series.removeChild(e)}for(let e=0;e<l.length;e++){let i=l[e],a=r.series.children[e];a||(a=c(`g`,{class:`prism-bar-series`}),r.series.appendChild(a));let o=d.map((t,n)=>{let r=f[e]?.[n];if(v){let e=T[t]??0,n=e+Math.max(0,r?.value??0);return T[t]=n,{base:e,key:t,present:r!==void 0,y:n}}return{base:0,key:t,present:r!==void 0,y:r?.value??0}});w[e]=o.map(e=>e.y);let s=v?o.map(e=>C.map(e.base)):void 0;we(a,o,S,C,E.baselinePx,{baselineYs:s,borderRadius:i.borderRadius??0,color:U(e,i.color),disposalSignal:t.disposalSignal,horizontal:m,seriesCount:l.length,seriesIndex:e,stacked:v,transition:n.transition})}return i?.update(l.map((e,t)=>({color:U(t,e.color),name:e.name}))),a?.hide(),{onClick:e=>{if(!n.onClick)return;let r=t.dimensions.value,i=B(t.svg,e,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height)return;let o=be(m?i.y:i.x,d,E);if(o===-1)return;let s=xe(i,o,d,E,l.length),c=f[s]?.[o];c&&n.onClick({datum:c,originalEvent:e,series:l[s]})},onMouseLeave:()=>{a?.hide(),n.onHover?.(null)},onMouseMove:e=>{let r=t.dimensions.value,i=B(t.svg,e,r.margin.left,r.margin.top),o=I(r.width,r.height,r.margin);if(i.x<0||i.x>o.width||i.y<0||i.y>o.height){a?.hide();return}let s=be(m?i.y:i.x,d,E);if(s===-1){a?.hide();return}if(Se(i,s,f,E,l.length)){a?.hide();return}let c=xe(i,s,d,E,l.length),u=f[c]?.[s];if(u){let t=E.bandCenter(d[s]),i=v?w[c]?.[s]??u.value:u.value,o=C.map(i),f=m?o+r.margin.left:t+r.margin.left,p=m?t+r.margin.top:o+r.margin.top;a?.show(f,p,u,l[c]),n.onHover?.({datum:u,originalEvent:e,series:l[c]})}}}})}var X=new WeakMap;function De(e,t){return t===`monotone`?G(e):t===`step`?K(e):W(e)}function Oe(e,t,n){let o=i(n.transition,0),s=o.duration,u=r(o.easing),d=e.querySelector(`.prism-line-path`);d||(d=c(`path`,{class:`prism-line-path`,fill:`none`}),e.appendChild(d)),l(d,{stroke:n.color,"stroke-width":n.strokeWidth});let f=e.querySelector(`.prism-line-dots`);if(n.showPoints?f||(f=c(`g`,{class:`prism-line-dots`}),e.appendChild(f)):f&&=(f.remove(),null),s===0){if(l(d,{d:De(t,n.curve)}),f){for(;f.children.length>t.length;)f.removeChild(f.lastChild);for(let e=0;e<t.length;e++){let r=f.children[e];r||(r=c(`circle`,{class:`prism-line-dot`}),f.appendChild(r)),l(r,{cx:t[e].x,cy:t[e].y,fill:n.color,r:n.pointRadius})}}return}X.get(e)?.();let p=!!d.getAttribute(`d`),m=[],h=null;if(f){let e=f.children.length;for(let t=0;t<e;t++){let e=f.children[t],n={x:Number(e.getAttribute(`cx`)),y:Number(e.getAttribute(`cy`))};m.push(n),h=n}for(;f.children.length>t.length;)f.removeChild(f.lastChild);for(let e=f.children.length;e<t.length;e++){let r=c(`circle`,{class:`prism-line-dot`});l(r,{cx:t[e].x,cy:t[e].y,fill:n.color,r:n.pointRadius}),f.appendChild(r)}}for(let e=m.length;e<t.length;e++)m.push(h??t[e]);let g=null;function _(r){if(n.disposalSignal?.aborted){X.delete(e);return}g===null&&(g=r);let i=Math.min(1,(r-g)/s),o=u(i),c=t.map((e,t)=>{let n=m[t]??e;return{x:a(n.x,e.x,o),y:a(n.y,e.y,o)}});if(l(d,{d:De(c,n.curve)}),f)for(let e=0;e<t.length;e++){let t=f.children[e];t&&l(t,{cx:c[e].x,cy:c[e].y})}if(i<1){let t=requestAnimationFrame(_);X.set(e,()=>cancelAnimationFrame(t))}else X.delete(e)}if(!p)l(d,{d:De(t,n.curve)});else{let t=requestAnimationFrame(_);X.set(e,()=>cancelAnimationFrame(t))}}function ke(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}function Ae(t,n){let r=null;return R(t,n,t=>{let{groups:i,legend:a,tooltip:o}=t,s=t.dimensions.value,l=I(s.width,s.height,s.margin),u=(0,e.isReactive)(n.series)?n.series.value:n.series,d=u.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data),f=d.flat().map(e=>e.key),p=d.flat().map(e=>e.value);if(f.length===0){L(i,a,o,r);return}n.crosshair&&!r&&(r=le(t.chartArea,n.crosshair));let m=j(f,l.width),v=M(p,l.height);for(n.yAxis?.grid&&_(i.grid,v,n.yAxis.grid,l.width,`horizontal`,h(n.yAxis,l.height,`left`)),n.xAxis?.grid&&_(i.grid,m,n.xAxis.grid,l.height,`vertical`,h(n.xAxis,l.width,`bottom`)),n.xAxis&&(i.xAxis.setAttribute(`transform`,`translate(0,${l.height})`),g(i.xAxis,m,n.xAxis,l.width,`bottom`)),n.yAxis&&g(i.yAxis,v,n.yAxis,l.height,`left`);i.series.children.length>u.length;)i.series.removeChild(i.series.lastChild);let y=[];for(let e=0;e<u.length;e++){let r=u[e],a=i.series.children[e];a||(a=c(`g`,{class:`prism-line-series`}),i.series.appendChild(a));let o=ke(d[e],m,v);y.push(o),Oe(a,o,{color:U(e,r.color),curve:r.curve??`linear`,disposalSignal:t.disposalSignal,pointRadius:r.pointRadius??3,showPoints:r.showPoints??!1,strokeWidth:r.strokeWidth??2,transition:n.transition})}return a?.update(u.map((e,t)=>({color:U(t,e.color),name:e.name}))),o?.hide(),fe({crosshair:r,dims:()=>t.dimensions.value,getData:()=>d,getPoints:()=>y,getSeriesList:()=>(0,e.isReactive)(n.series)?n.series.value:n.series,onClick:n.onClick,onHover:n.onHover,svg:t.svg,tooltip:o})})}function je(e,t,n,r,i,a,o,s,c,l,u=!1){let d=e.reduce((e,t)=>e+Math.max(0,t.value),0);if(d===0)return[];let f=o-a,p=r>0?Math.asin(Math.min(1,s/2/r)):0,m=a,h=e.length;return e.map((e,a)=>{let o=Math.max(0,e.value)/d*f,s=m,g=m+o;m+=o;let _=Math.min(p,o/2);return{capEnd:u&&a===h-1,capStart:u&&a===0,centerX:t,centerY:n,color:e.color??l(a),cornerRadius:c,endAngle:g,index:a,innerRadius:i,outerRadius:r,padAngle:_,slice:e,startAngle:s}})}function Z(e,t,n,r){return`${e+n*Math.sin(r)},${t-n*Math.cos(r)}`}function Q(e,t,n){return e+t*Math.sin(n)}function $(e,t,n){return e-t*Math.cos(n)}function Me(e){let{capEnd:t,capStart:n,centerX:r,centerY:i,cornerRadius:a,endAngle:o,innerRadius:s,outerRadius:c,padAngle:l,startAngle:u}=e,d=o-u;if(d<=0)return``;if(d>=2*Math.PI-1e-6){let e=u+Math.PI;return s<=0?`M${Z(r,i,c,u)}A${c},${c},0,1,1,${Z(r,i,c,e)}A${c},${c},0,1,1,${Z(r,i,c,u)}Z`:[`M${Z(r,i,c,u)}`,`A${c},${c},0,1,1,${Z(r,i,c,e)}`,`A${c},${c},0,1,1,${Z(r,i,c,u)}`,`M${Z(r,i,s,u)}`,`A${s},${s},0,1,0,${Z(r,i,s,e)}`,`A${s},${s},0,1,0,${Z(r,i,s,u)}`,`Z`].join(``)}let f=n?u:u+l,p=t?o:o-l;if(p<=f)return``;let m=p-f;if(a<=0){let e=+(m>Math.PI);return s<=0?`M${r},${i}L${Z(r,i,c,f)}A${c},${c},0,${e},1,${Z(r,i,c,p)}Z`:[`M${Z(r,i,c,f)}`,`A${c},${c},0,${e},1,${Z(r,i,c,p)}`,`L${Z(r,i,s,p)}`,`A${s},${s},0,${e},0,${Z(r,i,s,f)}`,`Z`].join(``)}let h=Math.min(a/c,m/2),g=Math.min(a/s,m/2),_=Math.min(a,(c-s)/2),v=(c-s)/2,y=f+(n?0:h),b=p-(t?0:h),x=f+(n?0:g),S=p-(t?0:g),C=+(b-y>Math.PI),w=+(S-x>Math.PI),T=Q(r,c,f),E=$(i,c,f),D=Q(r,c,p),O=$(i,c,p),k=Q(r,s,f),A=$(i,s,f),j=Q(r,s,p),M=$(i,s,p),N=_/(c-s),P=`${T+(k-T)*N},${E+(A-E)*N}`,ee=`${D+(j-D)*N},${O+(M-O)*N}`,te=`${k+(T-k)*N},${A+(E-A)*N}`,ne=`${j+(D-j)*N},${M+(O-M)*N}`,F=[];return n?F.push(`M${Z(r,i,c,f)}`):(F.push(`M${P}`),F.push(`Q${T},${E},${Z(r,i,c,y)}`)),F.push(`A${c},${c},0,${C},1,${Z(r,i,c,b)}`),t?F.push(`A${v},${v},0,0,1,${Z(r,i,s,p)}`):(F.push(`Q${D},${O},${ee}`),F.push(`L${ne}`),F.push(`Q${j},${M},${Z(r,i,s,S)}`)),F.push(`A${s},${s},0,${w},0,${Z(r,i,s,x)}`),n?F.push(`A${v},${v},0,0,0,${Z(r,i,c,f)}`):F.push(`Q${k},${A},${te}`),F.push(`Z`),F.join(``)}function Ne(e){let t=(e.startAngle+e.endAngle)/2,n=(e.outerRadius+e.innerRadius)/2;return{x:e.centerX+n*Math.sin(t),y:e.centerY-n*Math.cos(t)}}var Pe=2*Math.PI,Fe=-Math.PI/2,Ie=Math.PI/2;function Le(e){return e===`semi`?{end:Ie,start:Fe}:{end:Pe,start:0}}function Re(t,n){let o=n.variant??`pie`,s=n.padPixels??(o===`pie`?0:8),u=n.cornerRadius??(o===`pie`?0:8),d=c(`circle`,{class:`prism-pie-bg`,"pointer-events":`none`}),f=c(`g`,{class:`prism-pie-slices`,"shape-rendering":`geometricPrecision`}),p=c(`g`,{class:`prism-pie-labels`,"pointer-events":`none`}),m=[],h=null;function g(e){for(;p.children.length>m.length;)p.removeChild(p.lastChild);for(let t=0;t<m.length;t++){let n=m[t],r=e[t];if(!r?.label)continue;let{x:i,y:a}=Ne(n),o=p.children[t];o||(o=c(`text`,{class:`prism-pie-label`}),p.appendChild(o)),l(o,{"dominant-baseline":`middle`,fill:`var(--prism-pie-label-color, #fff)`,"font-family":`var(--prism-font-family, system-ui)`,"font-size":`var(--prism-pie-label-size, 12px)`,"text-anchor":`middle`,x:i,y:a}),o.textContent=r.label}}let _=ce(t,{a11y:n.a11y,legend:n.legend,plugins:n.plugins,tooltip:n.tooltip},_=>{let{legend:v,svg:y,tooltip:b}=_;y.contains(d)||(y.appendChild(d),y.appendChild(f),y.appendChild(p));let{height:x,width:S}=_.dimensions.value,C=o===`semi`,w=S/2,T=C?x*.85:x/2,E=C?Math.min(w,T)-8:Math.min(S,x)/2-8,D=o===`pie`?0:Math.round(E*.55),O=n.innerRadius===void 0?D:n.innerRadius,k=Math.max(O+1,E),A=(0,e.isReactive)(n.data)?n.data.value:n.data,{end:j,start:M}=Le(o);for(m=je(A,w,T,k,O,M,j,s,u,e=>U(e),!1),l(d,{cx:w,cy:T,r:O>0?O:0}),d.setAttribute(`style`,`fill:var(--prism-bg,#fff)`);f.children.length>m.length;)f.removeChild(f.lastChild);for(;p.children.length>m.length;)p.removeChild(p.lastChild);let N=i(n.transition,0),P=N.duration,ee=r(N.easing);for(let e=0;e<m.length;e++){let t=m[e],r=f.children[e];r||(r=c(`path`,{class:`prism-pie-slice`}),f.appendChild(r)),r.setAttribute(`fill`,t.color),r.setAttribute(`stroke`,`none`),r.style.cursor=n.onClick||n.onHover?`pointer`:``}if(h!==null&&(cancelAnimationFrame(h),h=null),P>0){let e=null,t=n=>{e===null&&(e=n);let r=ee(Math.min(1,(n-e)/P)),i=a(M,j,r);for(let e=0;e<m.length;e++){let t=m[e],n=f.children[e];if(n)if(i<=t.startAngle)l(n,{d:``});else{let e=Math.min(t.endAngle,i);l(n,{d:Me({...t,endAngle:e})})}}r<1?h=requestAnimationFrame(t):(h=null,g(A))};h=requestAnimationFrame(t)}else{for(let e=0;e<m.length;e++){let t=m[e],n=f.children[e];n&&l(n,{d:Me(t)})}g(A)}return v?.update(m.map(e=>({color:e.color,name:e.slice.label??``}))),b?.hide(),{onClick:e=>{if(!n.onClick)return;let t=y.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=ze(m,r,i,o);a>=0&&n.onClick(m[a].slice,a)},onMouseLeave:()=>{n.onHover?.(null,null),b?.hide()},onMouseMove:e=>{let r=y.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,s=ze(m,i,a,o);if(s>=0){let e=m[s];n.onHover?.(e.slice,s);let{x:i,y:a}=Ne(e),o=t.getBoundingClientRect();b?.show(i+(r.left-o.left),a+(r.top-o.top),{key:s,value:e.slice.value},{color:e.color,data:[],name:e.slice.label??``})}else n.onHover?.(null,null),b?.hide()}}});return{get disposalSignal(){return _.disposalSignal},dispose(){h!==null&&(cancelAnimationFrame(h),h=null),_.dispose()},get disposed(){return _.disposed},el:_.el,[Symbol.dispose](){this.dispose()}}}function ze(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i],o=t-a.centerX,s=n-a.centerY,c=Math.sqrt(o*o+s*s);if(c<a.outerRadius&&c>=a.innerRadius){let e=Math.atan2(o,-s);if(r===`semi`){if(e>=a.startAngle-1e-9&&e<=a.endAngle+1e-9)return i}else{let t=e<0?e+Pe:e;if(t>=a.startAngle-1e-9&&t<=a.endAngle+1e-9)return i}}}return-1}function Be(e,t,n){if(e.length===0)return[];let r=t/Math.max(1,e.length-1),i=Math.min(...e),a=Math.max(...e)-i||1;return e.map((e,t)=>({x:t*r,y:n-(e-i)/a*n}))}function Ve(e,t,n,r=`linear`){if(e.length===0)return``;let i=Be(e,t,n);return q(i,i.map(e=>({x:e.x,y:n})),r??`linear`)}function He(e,t,n,r){if(e.length===0)return``;let i=Be(e,t,n);return r===`monotone`?G(i):r===`step`?K(i):W(i)}function Ue(e,t,n,o,s,u,d){let f=t.length,p=Math.max(1,n/f-1),m=n/f,h=Math.min(0,...t),g=Math.max(...t)-h||1,_=i(u,0),v=_.duration,y=r(_.easing);for(;e.children.length>f;){let t=e.lastElementChild;t&&e.removeChild(t)}for(let n=0;n<f;n++){let r=Math.max(1,(t[n]-h)/g*o),i=o-r,u=e.children[n];if(u||(u=c(`rect`,{class:`prism-spark-bar`}),e.appendChild(u)),l(u,{fill:s,width:p,x:n*m}),v>0&&!u.hasAttribute(`data-init`)){u.setAttribute(`data-init`,`1`),l(u,{height:0,y:o});let e=null,t={h:0,y:o},n={h:r,y:i},s=r=>{if(d?.aborted)return;e===null&&(e=r);let i=y(Math.min(1,(r-e)/v));l(u,{height:a(t.h,n.h,i),y:a(t.y,n.y,i)}),i<1&&requestAnimationFrame(s)};requestAnimationFrame(s)}else u.setAttribute(`data-init`,`1`),l(u,{height:r,y:i})}}function We(e){return e.length>0&&e[0]!==null&&typeof e[0]==`object`}function Ge(e,t,n,r,i,a,o){let s=Math.min(i,n/2,r/2),c=a?s:0,l=a?s:0,u=o?s:0,d=o?s:0;return[`M${e+c},${t}`,`H${e+n-u}`,u?`Q${e+n},${t} ${e+n},${t+u}`:``,`V${t+r-d}`,d?`Q${e+n},${t+r} ${e+n-d},${t+r}`:``,`H${e+l}`,l?`Q${e},${t+r} ${e},${t+r-l}`:``,`V${t+c}`,c?`Q${e},${t} ${e+c},${t}`:``,`Z`].filter(Boolean).join(``)}function Ke(e){return`var(--prism-color-${e%8+1})`}function qe(t,n){let r=n.variant??`line`,i=n.color??`var(--prism-color-1)`,a=n.curve??`linear`,o=n.strokeWidth??1.5,s=n.fillOpacity??.2,u=ae(t,{...n.a11y?{a11y:n.a11y}:{ariaHidden:!0},margin:{bottom:0,left:0,right:0,top:0}}),{svg:d}=u;d.classList.add(`prism-sparkline`);let f=c(`g`,{class:`prism-spark-inner`});d.appendChild(f);let p;function m(){let{height:t,width:d}=u.dimensions.value,p=(0,e.isReactive)(n.data)?n.data.value:n.data;for(;f.firstChild;)f.removeChild(f.firstChild);if(p.length!==0){if(r===`stack`&&We(p)){let e=c(`g`,{class:`prism-spark-stack`});f.appendChild(e);let r=n.cornerRadius??4,i=p,a=i.reduce((e,t)=>e+Math.max(0,t.value),0);if(a>0){let o=(n.padPixels??0)/2,s=0;i.forEach((n,u)=>{let f=Math.round(s);s+=Math.max(0,n.value)/a*d;let p=u===i.length-1?d:Math.round(s),m=u===0,h=u===i.length-1,g=Ge(f+(m?0:o),0,Math.max(0,p-f-(m?0:o)-(h?0:o)),t,r,m,h),_=c(`path`,{class:`prism-spark-stack-segment`});l(_,{d:g,fill:n.color??Ke(u)}),e.appendChild(_)})}}else if(r===`bar`){let e=c(`g`,{class:`prism-spark-bars`});f.appendChild(e),Ue(e,p,d,t,i,n.transition,g.signal)}else{if(r===`area`){let e=c(`path`,{class:`prism-spark-fill`});l(e,{d:Ve(p,d,t,a),fill:i,"fill-opacity":s,stroke:`none`}),f.appendChild(e)}let e=c(`path`,{class:`prism-spark-line`});l(e,{d:He(p,d,t,a),fill:`none`,stroke:i,"stroke-width":o}),f.appendChild(e)}We(p)||h(p)}}function h(e){if(p?.(),p=void 0,!n.onHover&&!n.onClick||e.length<=1)return;let{width:t}=u.dimensions.value;d.style.cursor=`crosshair`;let r=t/(e.length-1),i=t=>{let i=d.getBoundingClientRect(),a=t.clientX-i.left,o=Math.max(0,Math.min(e.length-1,Math.round(a/r)));n.onHover?.(o,e[o])},a=()=>n.onHover?.(null,null),o=t=>{if(!n.onClick)return;let i=d.getBoundingClientRect(),a=t.clientX-i.left,o=Math.max(0,Math.min(e.length-1,Math.round(a/r)));n.onClick(o,e[o])};d.addEventListener(`mousemove`,i),d.addEventListener(`mouseleave`,a),d.addEventListener(`click`,o),p=()=>{d.removeEventListener(`mousemove`,i),d.removeEventListener(`mouseleave`,a),d.removeEventListener(`click`,o)}}let g=new AbortController,_=(0,e.createScope)();_.run(()=>{(0,e.effect)(()=>{m()},{scheduler:`microtask`})});let v=!1;return{get disposalSignal(){return g.signal},dispose(){v||(v=!0,g.abort(),p?.(),_.dispose(),u.dispose())},get disposed(){return v},el:d,[Symbol.dispose](){this.dispose()}}}exports.PrismError=te,exports.PrismRenderError=ne,exports.animate=o,exports.bandScale=ye,exports.createAreaChart=ve,exports.createBarChart=Ee,exports.createLineChart=Ae,exports.createPieChart=Re,exports.createSparkline=qe,exports.linearScale=b,exports.resetTheme=me,exports.seriesColor=U,exports.setTheme=pe,exports.timeScale=A;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/ripple"),t=require("@vielzeug/orbit");var n={"ease-in":e=>e*e,"ease-in-out":e=>e<.5?2*e*e:1-(-2*e+2)**2/2,"ease-out":e=>1-(1-e)*(1-e),linear:e=>e};function r(e){return typeof e==`function`?e:e!==void 0&&Object.hasOwn(n,e)?n[e]:n[`ease-out`]}function i(e,t=300){let n=e?.preference??`system`,r=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,i=n===`never`||n===`system`&&r?0:e?.duration??t;return{...e,duration:i,stagger:Math.max(0,e?.stagger??0)}}function a(e,t,n){return e+(t-e)*n}function o(e,t,n,o){let s=i(t),c=s.duration,l=r(s.easing),u=s.stagger;if(c===0||e.length===0){for(let t of e)for(let[e,{to:n}]of Object.entries(t.attrs))t.el.setAttribute(e,String(n));return n?.(),()=>{}}let d=null,f=!1,p=Math.max(c,c+u*(e.length-1));function m(t){if(f||o?.aborted)return;d===null&&(d=t);let r=t-d;for(let t=0;t<e.length;t++){let n=e[t],i=u*t,o=Math.max(0,r-i),s=Math.min(1,o/c),d=l(s);for(let[e,{from:t,to:r}]of Object.entries(n.attrs))n.el.setAttribute(e,String(a(t,r,d)))}r<p?requestAnimationFrame(m):n?.()}return requestAnimationFrame(m),()=>{f=!0}}var s=`http://www.w3.org/2000/svg`;function c(e,t){let n=document.createElementNS(s,e);return t&&l(n,t),n}function l(e,t){for(let[n,r]of Object.entries(t)){if(r===void 0){e.removeAttribute(n);continue}typeof r==`number`&&!Number.isFinite(r)&&`${n}${e.tagName}${r}`,e.setAttribute(n,String(r))}}function u(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function d(e,t){let n=c(`text`,t);return n.textContent=e,n}function f(e){return typeof e.bandwidth==`function`}function p(e,t){return f(e)?e.map(t)+e.bandwidth()/2:e.map(t)}var m=e=>e instanceof Date?e.toLocaleDateString(void 0,{month:`short`,year:`numeric`}):String(e);function h(e,t,n){let r=e.position??n,i=r===`bottom`||r===`top`?Math.max(2,Math.floor(t/80)):Math.max(2,Math.floor(t/50));return e.tickCount??i}function g(e,t,n,r,i=`bottom`){u(e);let a=n.position??i,o=a===`bottom`||a===`top`,s=a===`top`||a===`left`,f=s?-1:1,g=c(`line`,{"aria-hidden":`true`,class:`prism-axis-line`,x1:0,x2:o?r:0,y1:0,y2:o?0:r});e.appendChild(g);let _=t.ticks(h(n,r,i)),v=n.tickFormat??m;for(let n of _){let r=p(t,n),i=c(`line`,{"aria-hidden":`true`,class:`prism-axis-tick`,x1:o?r:0,x2:o?r:6*f,y1:o?0:r,y2:o?6*f:r});e.appendChild(i);let a=d(v(n),{"aria-hidden":`true`,class:`prism-axis-label`,"dominant-baseline":o?s?`auto`:`hanging`:`middle`,"text-anchor":o?`middle`:s?`end`:`start`,x:o?r:6*f*1.5,y:o?6*f*1.5:r});e.appendChild(a)}if(n.label){let t=d(n.label,{class:`prism-axis-title`,"dominant-baseline":`middle`,"text-anchor":`middle`});o?l(t,{x:r/2,y:6*f*3.5}):l(t,{transform:`translate(${6*f*4}, ${r/2}) rotate(-90)`}),e.appendChild(t)}}function _(e,t,n,r,i,a=10){u(e);let o=n!==!0&&n.color||void 0,s=n!==!0&&n.dash||void 0,l=t.ticks(a);for(let n of l){let a=p(t,n),l={class:`prism-grid-line`,stroke:o??`var(--prism-grid-color)`,"stroke-dasharray":s,"stroke-opacity":`var(--prism-grid-opacity)`};i===`vertical`?Object.assign(l,{x1:a,x2:a,y1:0,y2:r}):Object.assign(l,{x1:0,x2:r,y1:a,y2:a}),e.appendChild(c(`line`,l))}}function v(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function y(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return[0,1];if(e>t&&([e,t]=[t,e]),e===t)return[e-1,t+1];let r=v(v(t-e,!1)/Math.max(1,n-1),!0);return[Math.floor(e/r)*r,Math.ceil(t/r)*r]}function b(e){let t=()=>e.nice===!1?e.domain:y(e.domain[0],e.domain[1],10),n=()=>e.range;return{get domain(){return t()},invert(e){let[r,i]=t(),[a,o]=n();return o===a?r:r+(e-a)/(o-a)*(i-r)},map(r){let[i,a]=t(),[o,s]=n();if(a===i)return o;let c=(r-i)/(a-i);return e.clamp&&(c=Math.max(0,Math.min(1,c))),o+c*(s-o)},get range(){return n()},ticks(e=10){if(e<=0)return[];let[n,r]=t();if(n===r||e===1)return[n];let i=Math.min(n,r),a=Math.max(n,r),o=v(v(a-i,!1)/(e-1),!0),s=Math.ceil(i/o)*o,c=Math.floor(a/o)*o,l=[];for(let e=s;e<=c+o*.5;e+=o)l.push(Math.round(e*0xe8d4a51000)/0xe8d4a51000);return l}}}var x=1e3,S=60*x,C=60*S,w=24*C,T=30*w,E=365*w,D=[x,5*x,15*x,30*x,S,5*S,15*S,30*S,C,3*C,6*C,12*C,w,7*w,T,3*T,6*T,E];function O(e,t){let n=Math.abs(e)/Math.max(1,t);for(let e of D)if(e>=n)return e;return E}function k(e,t){let[n,r]=e;n.getTime()>r.getTime()&&([n,r]=[r,n]);let i=O(r.getTime()-n.getTime(),t);return[new Date(Math.floor(n.getTime()/i)*i),new Date(Math.ceil(r.getTime()/i)*i)]}function A(e){let t=()=>e.nice===!1?e.domain:k(e.domain,10),n=()=>e.range;return{get domain(){return t()},invert(e){let[r,i]=t(),[a,o]=n();if(o===a)return r;let s=(e-a)/(o-a);return new Date(r.getTime()+s*(i.getTime()-r.getTime()))},map(e){let[r,i]=t(),[a,o]=n(),s=i.getTime()-r.getTime();return s===0?a:a+(e.getTime()-r.getTime())/s*(o-a)},get range(){return n()},ticks(e=10){let[n,r]=t(),i=O(r.getTime()-n.getTime(),e),a=Math.ceil(n.getTime()/i)*i,o=[];for(let e=a;e<=r.getTime();e+=i)o.push(new Date(e));return o}}}function j(e,t){if(e.length===0||e.some(e=>e==null)||e.some(e=>typeof e==`number`&&!Number.isFinite(e)))return b({domain:[0,1],range:[0,t]});if(e[0]instanceof Date){let n=e,r=Math.min(...n.map(Number)),i=Math.max(...n.map(Number));return A({domain:[new Date(r),new Date(r===i?i+1:i)],range:[0,t]})}let n=e,r=Math.min(...n),i=Math.max(...n);return b({domain:[r,r===i?i+1:i],nice:!1,range:[0,t]})}function M(e,t,n=!0){if(e.length===0||e.some(e=>e==null)||e.some(e=>!Number.isFinite(e)))return b({domain:[0,1],range:[t,0]});let r=Math.min(...e),i=n?Math.min(0,r):r,a=Math.max(...e);return b({domain:[i,i===a?a+1:a],range:[t,0]})}function N(e){return e===!0?`bottom`:e.position??`bottom`}function P(e,t){let n=N(t),r=document.createElement(`div`);r.className=`prism-legend prism-legend-${n}`,n===`top`?e.insertBefore(r,e.firstChild):e.appendChild(r);let i=()=>{r.remove()};return{dispose:i,el:r,[Symbol.dispose]:i,update(e){r.innerHTML=``;for(let t of e){let e=document.createElement(`div`);e.className=`prism-legend-item`;let n=document.createElement(`span`);n.className=`prism-legend-dot`,n.style.backgroundColor=t.color;let i=document.createElement(`span`);i.className=`prism-legend-label`,i.textContent=t.name,e.appendChild(n),e.appendChild(i),r.appendChild(e)}}}}function ee(e,n){getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let r=e.ownerDocument.createElement(`div`);r.className=`prism-tooltip`,r.style.position=`absolute`,r.style.pointerEvents=`none`,r.style.top=`0`,r.style.left=`0`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`),e.appendChild(r);let i=n!==!0&&n?.offset||8,a=n===!0?void 0:n?.render,o=n===!0?void 0:n?.sanitize,s=null,c=null,l=!1,u=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{s!==null&&(cancelAnimationFrame(s),s=null)},f=()=>{d(),u(),r.remove()};return{dispose:f,el:r,hide(){d(),u(),l=!1,r.style.opacity=`0`,c=setTimeout(()=>{c=null,l||(r.textContent=``)},150)},show(n,c,d,f){if(!e.isConnected)return;if(u(),a){let e=a(d,f);o?r.innerHTML=o(e):r.textContent=e}else r.textContent=`${f.name}: ${d.value}`;let{x:p,y:m}=(0,t.computePosition)({getBoundingClientRect:()=>{let t=e.getBoundingClientRect();return{bottom:t.top+c,height:0,left:t.left+n,right:t.left+n,top:t.top+c,width:0,x:t.left+n,y:t.top+c}}},r,{containingBlock:e,middleware:[(0,t.offset)(i),(0,t.flip)(),(0,t.shift)({padding:8})],placement:`top`});if(r.style.left=`${p}px`,r.style.top=`${m}px`,l){s===null&&(r.style.opacity=`1`);return}l=!0,r.style.opacity=`0`,s=requestAnimationFrame(()=>{s=null,l&&(r.style.opacity=`1`)})},[Symbol.dispose]:f}}var te=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},ne=class extends te{},F={bottom:40,left:50,right:20,top:20};function re(e){return{...F,...e}}function I(e,t,n){return{height:Math.max(0,t-n.top-n.bottom),width:Math.max(0,e-n.left-n.right)}}function ie(e,t){let n=null,r=new ResizeObserver(e=>{n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{n=null;let r=e[0];if(r){let{height:e,width:n}=r.contentRect;t(n,e)}})});return r.observe(e),()=>{n!==null&&cancelAnimationFrame(n),r.disconnect()}}function ae(t,n){if(!(typeof t==`object`&&t&&t.nodeType===1&&typeof t.appendChild==`function`&&typeof t.getBoundingClientRect==`function`)){let e=t;throw new ne(`Invalid chart configuration: \`container\` must be a DOM Element, received ${e===null?`null`:typeof e==`object`?e.constructor?.name??`object`:typeof e}.`)}let r=re(n.margin),i=n.a11y,a=c(`svg`,{...n.ariaHidden||i?.decorative?{"aria-hidden":`true`}:{...i?{"aria-label":i.ariaLabel,tabindex:`0`}:{},role:`img`},class:`prism-chart`,style:`display:block;width:100%;height:100%`}),o=c(`g`,{class:`prism-chart-area`,transform:`translate(${r.left},${r.top})`});a.appendChild(o);let s=t.getBoundingClientRect();s.width===0||s.height;let u=typeof getComputedStyle<`u`?getComputedStyle(t):null;u&&u.position;let d=(0,e.signal)({height:s.height||300,margin:r,width:s.width||600}),f=ie(t,(e,t)=>{d.value={height:t,margin:r,width:e},l(a,{height:t,viewBox:`0 0 ${e} ${t}`,width:e})}),p=s.width||600,m=s.height||300;return l(a,{height:m,viewBox:`0 0 ${p} ${m}`,width:p}),t.appendChild(a),{chartArea:o,dimensions:d,dispose(){f(),a.remove()},svg:a}}function L(e,t,n,r){u(e.series),u(e.grid),u(e.xAxis),u(e.yAxis),t?.update([]),n?.hide(),r?.hide()}function oe(t,n,r,i){let a=ae(t,{a11y:n.a11y,margin:n.margin}),o=n.tooltip?ee(t,n.tooltip):null,s=n.legend?P(t,n.legend):null,c=new AbortController,l=r(a,o,s,c.signal),u=!1,d=se(a.svg),f=(0,e.createScope)();f.run(()=>{(0,e.effect)(()=>{u||d.attach(i(l))},{scheduler:`microtask`})});let p=[];if(n.plugins){let e={container:t,dimensions:a.dimensions,disposalSignal:c.signal,svg:a.svg};for(let t of n.plugins)try{t.install(e),p.push(t)}catch{}}return{get disposalSignal(){return c.signal},dispose(){if(!u){u=!0,c.abort(),d.detach();for(let e of p)try{e.dispose()}catch{}o?.dispose(),s?.dispose(),f.dispose(),a.dispose()}},get disposed(){return u},el:a.svg,[Symbol.dispose](){this.dispose()}}}function se(e){let t=null;return{attach(n){t&&=(t.onMouseMove&&e.removeEventListener(`mousemove`,t.onMouseMove),t.onMouseLeave&&e.removeEventListener(`mouseleave`,t.onMouseLeave),t.onClick&&e.removeEventListener(`click`,t.onClick),t.onKeyDown&&e.removeEventListener(`keydown`,t.onKeyDown),null),n&&(t=n,n.onMouseMove&&e.addEventListener(`mousemove`,n.onMouseMove),n.onMouseLeave&&e.addEventListener(`mouseleave`,n.onMouseLeave),n.onClick&&e.addEventListener(`click`,n.onClick),n.onKeyDown&&e.addEventListener(`keydown`,n.onKeyDown))},detach(){this.attach(void 0)}}}function R(e,t,n){return oe(e,t,(t,n,r,i)=>{let a={grid:c(`g`,{"aria-hidden":`true`,class:`prism-grid`}),series:c(`g`,{class:`prism-series`}),xAxis:c(`g`,{class:`prism-x-axis`}),yAxis:c(`g`,{class:`prism-y-axis`})};return t.chartArea.appendChild(a.grid),t.chartArea.appendChild(a.xAxis),t.chartArea.appendChild(a.yAxis),t.chartArea.appendChild(a.series),{chartArea:t.chartArea,container:e,dimensions:t.dimensions,disposalSignal:i,groups:a,legend:r,svg:t.svg,tooltip:n}},n)}function ce(e,t,n){return oe(e,t,(t,n,r,i)=>({container:e,dimensions:t.dimensions,disposalSignal:i,legend:r,svg:t.svg,tooltip:n}),n)}function le(e,t){let n=t===!0||t?.vertical!==!1,r=t!==!0&&t?.horizontal===!0,i=t===!0||t?.snap!==!1,a=c(`g`,{"aria-hidden":`true`,class:`prism-crosshair`,style:`display:none`}),o=n?c(`line`,{class:`prism-crosshair-v`,"stroke-dasharray":`var(--prism-crosshair-dash, 4 2)`}):null,s=r?c(`line`,{class:`prism-crosshair-h`,"stroke-dasharray":`var(--prism-crosshair-dash, 4 2)`}):null;o&&a.appendChild(o),s&&a.appendChild(s),e.appendChild(a);let u=c(`text`,{"aria-live":`polite`,class:`prism-crosshair-live`,role:`status`,x:-9999,y:-9999});return e.appendChild(u),{hide(){a.style.display=`none`,u.textContent=``},show(e,t,n,r,i){a.style.display=``,o&&l(o,{x1:e,x2:e,y1:0,y2:r}),s&&l(s,{x1:0,x2:n,y1:t,y2:t}),i!==void 0&&(u.textContent=i)},snap:i}}function z(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}function ue(e,t){let n=[],r=new Map;return{domain:n,labels:r,series:e.map((e,i)=>{let a=new Map;for(let o of t[i]??[]){let t=z(o.key);if(a.has(t)){`${String(o.key)}${e.name}`;continue}a.set(t,o),r.has(t)||(r.set(t,o.key),n.push(t))}return{byKey:a,config:e}})}}function B(e,t,n,r){let i=e.getBoundingClientRect();return{x:t.clientX-i.left-n,y:t.clientY-i.top-r}}function de(e,t,n){let r=null,i=1/0;for(let a=0;a<t.length;a++)for(let o=0;o<(t[a]?.length??0);o++){let s=e[a]?.[o],c=t[a]?.[o];if(!s||!c)continue;let l=Math.abs(c.x-n);l<i&&(i=l,r=s.key)}return r}function V(e,t,n,r){let i=z(n),a=null,o=1/0;for(let n=0;n<t.length;n++){let s=e[n]?.findIndex(e=>z(e.key)===i)??-1,c=s===-1?void 0:e[n]?.[s],l=s===-1?void 0:t[n]?.[s];if(!c||!l)continue;let u=Number.isFinite(r)?Math.abs(l.y-r):0;u<o&&(o=u,a={datum:c,point:l,seriesIndex:n})}return a}function fe(e){let t=0;return{onClick:t=>{if(!e.onClick)return;let n=e.getPoints();if(n.length===0||n[0].length===0)return;let r=e.dims(),i=B(e.svg,t,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height)return;let o=de(e.getData(),n,i.x);if(o===null)return;let s=V(e.getData(),n,o,i.y),c=s?e.getSeriesList()[s.seriesIndex]:void 0;s&&c&&e.onClick({datum:s.datum,originalEvent:t,series:c})},onKeyDown:n=>{let r=e.getData(),i=e.getPoints(),a=[...new Map(r.flat().map(e=>[z(e.key),e.key])).values()];if(a.length!==0){if(n.key===`ArrowLeft`||n.key===`ArrowRight`){n.preventDefault(),t=Math.max(0,Math.min(a.length-1,t+(n.key===`ArrowLeft`?-1:1)));let o=a[t],s=V(r,i,o,1/0),c=s?e.getSeriesList()[s.seriesIndex]:void 0;if(!s||!c)return;let l=e.tooltip?void 0:`${c.name}: ${s.datum.value}`;e.crosshair?.show(s.point.x,s.point.y,e.dims().width,e.dims().height,l),e.tooltip?.show(s.point.x+e.dims().margin.left,s.point.y+e.dims().margin.top,s.datum,c),e.onHover?.({datum:s.datum,originalEvent:n,series:c})}if((n.key===`Enter`||n.key===` `)&&e.onClick){n.preventDefault();let o=a[t],s=V(r,i,o,1/0),c=s?e.getSeriesList()[s.seriesIndex]:void 0;s&&c&&e.onClick({datum:s.datum,originalEvent:n,series:c})}n.key===`Escape`&&(e.crosshair?.hide(),e.tooltip?.hide(),e.onHover?.(null))}},onMouseLeave:()=>{e.crosshair?.hide(),e.tooltip?.hide(),e.onHover?.(null)},onMouseMove:t=>{let n=e.getPoints();if(n.length===0||n[0].length===0)return;let r=e.dims(),i=B(e.svg,t,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height){e.crosshair?.hide(),e.tooltip?.hide();return}let o=de(e.getData(),n,i.x);if(o===null)return;let s=V(e.getData(),n,o,i.y),c=s?e.getSeriesList()[s.seriesIndex]:void 0,l=e.crosshair?.snap===!1?i.x:s?.point.x??i.x,u=e.crosshair?.snap===!1?i.y:s?.point.y??i.y,d=!e.tooltip&&c&&s?`${c.name}: ${s.datum.value}`:void 0;e.crosshair?.show(l,u,a.width,a.height,d),s&&c&&(e.tooltip?.show(s.point.x+r.margin.left,s.point.y+r.margin.top,s.datum,c),e.onHover?.({datum:s.datum,originalEvent:t,series:c}))}}}var H=8;function pe(e){let t=document.documentElement;if(e.colors)for(let n=0;n<H;n++){let r=e.colors[n];r?t.style.setProperty(`--prism-color-${n+1}`,r):t.style.removeProperty(`--prism-color-${n+1}`)}e.fontFamily&&t.style.setProperty(`--prism-font-family`,e.fontFamily),e.gridColor&&t.style.setProperty(`--prism-grid-color`,e.gridColor),e.gridOpacity!==void 0&&t.style.setProperty(`--prism-grid-opacity`,String(e.gridOpacity))}function me(){let e=document.documentElement;for(let t=1;t<=H;t++)e.style.removeProperty(`--prism-color-${t}`);e.style.removeProperty(`--prism-font-family`),e.style.removeProperty(`--prism-grid-color`),e.style.removeProperty(`--prism-grid-opacity`)}function U(e,t){return t??`var(--prism-color-${e%H+1})`}function W(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=1;n<e.length;n++)t+=`L${e[n].x},${e[n].y}`;return t}function G(e){if(e.length<3)return W(e);let t=e.length,n=[];for(let r=0;r<t;r++)r===0?n.push({x:e[1].x-e[0].x,y:e[1].y-e[0].y}):r===t-1?n.push({x:e[t-1].x-e[t-2].x,y:e[t-1].y-e[t-2].y}):n.push({x:(e[r+1].x-e[r-1].x)/2,y:(e[r+1].y-e[r-1].y)/2});let r=`M${e[0].x},${e[0].y}`;for(let i=0;i<t-1;i++){let t=e[i],a=e[i+1],o=n[i],s=n[i+1],c=(a.x-t.x)/3;r+=`C${t.x+c},${t.y+o.y/3},${a.x-c},${a.y-s.y/3},${a.x},${a.y}`}return r}function K(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=1;n<e.length;n++){let r=(e[n-1].x+e[n].x)/2;t+=`H${r}V${e[n].y}H${e[n].x}`}return t}function q(e,t,n=`linear`){if(e.length===0)return``;let r=n===`monotone`?G(e):n===`step`?K(e):W(e),i=[...t].reverse();if(i.length>0){r+=`L${i[0].x},${i[0].y}`;for(let e=1;e<i.length;e++)r+=`L${i[e].x},${i[e].y}`}return r+=`Z`,r}var J=new WeakMap,Y=new WeakMap;function he(e,t){return t===`monotone`?G(e):t===`step`?K(e):W(e)}function ge(e,t,n,o){let s=i(o.transition,0),u=s.duration,d=r(s.easing),f=e.querySelector(`.prism-area-fill`);f||(f=c(`path`,{class:`prism-area-fill`}),e.appendChild(f)),l(f,{fill:o.color,"fill-opacity":o.fillOpacity,stroke:`none`});let p=null;if(o.showLine?(p=e.querySelector(`.prism-area-line`),p||(p=c(`path`,{class:`prism-area-line`,fill:`none`}),e.appendChild(p)),l(p,{stroke:o.color,"stroke-width":2})):e.querySelector(`.prism-area-line`)?.remove(),u===0){let e=t.map(e=>({x:e.x,y:n}));l(f,{d:q(t,e,o.curve)}),p&&l(p,{d:he(t,o.curve)});return}if(J.get(e)?.(),!f.hasAttribute(`d`)){let r=t.map(e=>({x:e.x,y:n}));l(f,{d:q(t,r,o.curve)}),p&&l(p,{d:he(t,o.curve)}),Y.set(e,t);return}let m=Y.get(e)??t,h=t.map((e,n)=>m[n]??m[m.length-1]??t[n]),g=null;function _(r){if(o.disposalSignal?.aborted){J.delete(e);return}g===null&&(g=r);let i=Math.min(1,(r-g)/u),s=d(i),c=t.map((e,t)=>({x:a(h[t].x,e.x,s),y:a(h[t].y,e.y,s)})),m=c.map(e=>({x:e.x,y:n}));if(l(f,{d:q(c,m,o.curve)}),p&&l(p,{d:he(c,o.curve)}),i<1){let t=requestAnimationFrame(_);J.set(e,()=>cancelAnimationFrame(t))}else J.delete(e),Y.set(e,t)}Y.set(e,h);let v=requestAnimationFrame(_);J.set(e,()=>cancelAnimationFrame(v))}function _e(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}function ve(t,n){let r=null;return R(t,n,t=>{let{groups:i,legend:a,tooltip:o}=t,s=t.dimensions.value,l=I(s.width,s.height,s.margin),u=(0,e.isReactive)(n.series)?n.series.value:n.series,d=u.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data),f=d.flat().map(e=>e.key),p=d.flat().map(e=>e.value);if(f.length===0){L(i,a,o,r);return}n.crosshair&&!r&&(r=le(t.chartArea,n.crosshair));let m=j(f,l.width),v=M(p,l.height),y=v.map(0);for(n.yAxis?.grid&&_(i.grid,v,n.yAxis.grid,l.width,`horizontal`,h(n.yAxis,l.height,`left`)),n.xAxis?.grid&&_(i.grid,m,n.xAxis.grid,l.height,`vertical`,h(n.xAxis,l.width,`bottom`)),n.xAxis&&(i.xAxis.setAttribute(`transform`,`translate(0,${l.height})`),g(i.xAxis,m,n.xAxis,l.width,`bottom`)),n.yAxis&&g(i.yAxis,v,n.yAxis,l.height,`left`);i.series.children.length>u.length;)i.series.removeChild(i.series.lastChild);let b=[];for(let e=0;e<u.length;e++){let r=u[e],a=i.series.children[e];a||(a=c(`g`,{class:`prism-area-series`}),i.series.appendChild(a));let o=_e(d[e],m,v);b.push(o),ge(a,o,y,{color:U(e,r.color),curve:r.curve??`linear`,disposalSignal:t.disposalSignal,fillOpacity:r.fillOpacity??.3,showLine:r.showLine!==!1,transition:n.transition})}return a?.update(u.map((e,t)=>({color:U(t,e.color),name:e.name}))),o?.hide(),fe({crosshair:r,dims:()=>t.dimensions.value,getData:()=>d,getPoints:()=>b,getSeriesList:()=>(0,e.isReactive)(n.series)?n.series.value:n.series,onClick:n.onClick,onHover:n.onHover,svg:t.svg,tooltip:o})})}function ye(e){let t=()=>e.domain,n=()=>e.range,r=()=>{let r=t().length;if(r===0)return 0;let[i,a]=n(),o=e.padding??.1;return(a-i)/(r+(r-1)*o+(e.paddingOuter??o)*2)};return{bandwidth:r,get domain(){return t()},gap(){let t=e.padding??.1;return r()*t},map(i){let a=t().indexOf(i);if(a===-1)return`${i}`,0;let[o]=n(),s=r(),c=e.padding??.1;return o+(e.paddingOuter??c)*s+a*(s+s*c)},get range(){return n()},ticks(e){let n=t();if(e===void 0||e>=n.length)return[...n];if(e<=0)return[];let r=Math.ceil(n.length/e);return n.filter((e,t)=>t%r===0)}}}function be(e,t,n){for(let r=0;r<t.length;r++){let i=n.bandCenter(t[r])-n.bandwidth/2;if(e>=i&&e<i+n.bandwidth)return r}return-1}function xe(e,t,n,r,i){if(r.stacked)if(r.horizontal){for(let n=0;n<i;n++)if(r.valueScale.map(r.stackedTops[n]?.[t]??0)>=e.x)return n;return i-1}else{for(let n=0;n<i;n++)if(r.valueScale.map(r.stackedTops[n]?.[t]??0)<=e.y)return n;return i-1}{let a=r.bandwidth/i,o=r.bandCenter(n[t])-r.bandwidth/2,s=r.horizontal?e.y-o:e.x-o,c=Math.floor(s/a);return Math.max(0,Math.min(i-1,c))}}function Se(e,t,n,r,i){let a=i-1,o=r.stacked?r.stackedTops[a]?.[t]??0:Math.max(...Array.from({length:i},(e,r)=>n[r]?.[t]?.value??0)),s=r.valueScale.map(o);return r.horizontal?e.x>s:e.y<s}var Ce=new WeakMap;function we(e,t,n,r,i,a){for(;e.children.length>t.length;){let t=e.lastElementChild;t&&e.removeChild(t)}let s=n.bandwidth(),u=a.stacked?s:s/a.seriesCount,d=a.stacked?0:u*a.seriesIndex,f=a.horizontal??!1,p=[],m=[];for(let o=0;o<t.length;o++){let s=t[o],h=n.map(s.key)+d,g=a.baselineYs?a.baselineYs[o]:i,_=r.map(s.y),v=e.children[o],y=!v;if(v||(v=c(`rect`,{class:`prism-bar`}),e.appendChild(v)),v.style.display=s.present?``:`none`,f){let e=Math.max(0,Math.abs(g-_)),t=Math.min(_,g);l(v,{fill:a.color,height:Math.max(0,u-1),rx:a.borderRadius,ry:a.borderRadius,y:h}),a.transition?y?(l(v,{width:0,x:g}),p.push({attrs:{width:{from:0,to:e},x:{from:g,to:t}},el:v})):m.push({attrs:{width:{from:Number(v.getAttribute(`width`)??e),to:e},x:{from:Number(v.getAttribute(`x`)??t),to:t}},el:v}):l(v,{width:e,x:t})}else{let e=Math.max(0,Math.abs(g-_)),t=Math.min(_,g);l(v,{fill:a.color,rx:a.borderRadius,ry:a.borderRadius,width:Math.max(0,u-1),x:h}),a.transition?y?(l(v,{height:0,y:g}),p.push({attrs:{height:{from:0,to:e},y:{from:g,to:t}},el:v})):m.push({attrs:{height:{from:Number(v.getAttribute(`height`)??e),to:e},y:{from:Number(v.getAttribute(`y`)??t),to:t}},el:v}):l(v,{height:e,y:t})}}if(a.transition){Ce.get(e)?.();let t=[];p.length>0&&t.push(o(p,a.transition,void 0,a.disposalSignal)),m.length>0&&t.push(o(m,{...a.transition,stagger:0},void 0,a.disposalSignal)),Ce.set(e,()=>{for(let e of t)e()})}}function Te(e){return{horizontal:e===`grouped-horizontal`||e===`stacked-horizontal`,stacked:e===`stacked`||e===`stacked-horizontal`}}function Ee(t,n){return R(t,n,t=>{let{groups:r,legend:i,tooltip:a}=t,o=t.dimensions.value,s=I(o.width,o.height,o.margin),l=(0,e.isReactive)(n.series)?n.series.value:n.series,u=ue(l,l.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data)),d=u.domain,f=u.series.map(({byKey:e})=>d.map(t=>e.get(t))),p=e=>{if(e)return{...e,tickFormat:t=>{let n=String(t),r=u.labels.get(n)??t;return e.tickFormat?e.tickFormat(r):String(r)}}};if(d.length===0){L(r,i,a);return}let{horizontal:m,stacked:v}=Te(n.variant??`grouped`),y,x;if(v){f.some(e=>e.some(e=>(e?.value??0)<0));let e=d.map((e,t)=>f.reduce((e,n)=>e+Math.max(0,n[t]?.value??0),0));y=Math.max(...e),x=0}else{let e=f.flatMap(e=>e.flatMap(e=>e?[e.value]:[]));y=Math.max(...e),x=Math.min(0,...e)}let S=ye(m?{domain:d,range:[0,s.height]}:{domain:d,range:[0,s.width]}),C=b(m?{domain:[x,y],range:[0,s.width]}:{domain:[x,y],range:[s.height,0]}),w=[],T=Object.create(null);for(let e of d)T[e]=0;let E={bandCenter:e=>S.map(e)+S.bandwidth()/2,bandwidth:S.bandwidth(),baselinePx:C.map(0),horizontal:m,stacked:v,stackedTops:w,valueScale:C};if(m){n.xAxis?.grid&&_(r.grid,C,n.xAxis.grid,s.height,`vertical`,h(n.xAxis,s.width,`bottom`));let e=p(n.yAxis);e&&g(r.yAxis,S,e,s.height,`left`),n.xAxis&&(r.xAxis.setAttribute(`transform`,`translate(0,${s.height})`),g(r.xAxis,C,n.xAxis,s.width,`bottom`))}else{n.yAxis?.grid&&_(r.grid,C,n.yAxis.grid,s.width,`horizontal`,h(n.yAxis,s.height,`left`));let e=p(n.xAxis);e&&(r.xAxis.setAttribute(`transform`,`translate(0,${s.height})`),g(r.xAxis,S,e,s.width,`bottom`)),n.yAxis&&g(r.yAxis,C,n.yAxis,s.height,`left`)}for(;r.series.children.length>l.length;){let e=r.series.lastElementChild;e&&r.series.removeChild(e)}for(let e=0;e<l.length;e++){let i=l[e],a=r.series.children[e];a||(a=c(`g`,{class:`prism-bar-series`}),r.series.appendChild(a));let o=d.map((t,n)=>{let r=f[e]?.[n];if(v){let e=T[t]??0,n=e+Math.max(0,r?.value??0);return T[t]=n,{base:e,key:t,present:r!==void 0,y:n}}return{base:0,key:t,present:r!==void 0,y:r?.value??0}});w[e]=o.map(e=>e.y);let s=v?o.map(e=>C.map(e.base)):void 0;we(a,o,S,C,E.baselinePx,{baselineYs:s,borderRadius:i.borderRadius??0,color:U(e,i.color),disposalSignal:t.disposalSignal,horizontal:m,seriesCount:l.length,seriesIndex:e,stacked:v,transition:n.transition})}return i?.update(l.map((e,t)=>({color:U(t,e.color),name:e.name}))),a?.hide(),{onClick:e=>{if(!n.onClick)return;let r=t.dimensions.value,i=B(t.svg,e,r.margin.left,r.margin.top),a=I(r.width,r.height,r.margin);if(i.x<0||i.x>a.width||i.y<0||i.y>a.height)return;let o=be(m?i.y:i.x,d,E);if(o===-1)return;let s=xe(i,o,d,E,l.length),c=f[s]?.[o];c&&n.onClick({datum:c,originalEvent:e,series:l[s]})},onMouseLeave:()=>{a?.hide(),n.onHover?.(null)},onMouseMove:e=>{let r=t.dimensions.value,i=B(t.svg,e,r.margin.left,r.margin.top),o=I(r.width,r.height,r.margin);if(i.x<0||i.x>o.width||i.y<0||i.y>o.height){a?.hide();return}let s=be(m?i.y:i.x,d,E);if(s===-1){a?.hide();return}if(Se(i,s,f,E,l.length)){a?.hide();return}let c=xe(i,s,d,E,l.length),u=f[c]?.[s];if(u){let t=E.bandCenter(d[s]),i=v?w[c]?.[s]??u.value:u.value,o=C.map(i),f=m?o+r.margin.left:t+r.margin.left,p=m?t+r.margin.top:o+r.margin.top;a?.show(f,p,u,l[c]),n.onHover?.({datum:u,originalEvent:e,series:l[c]})}}}})}var X=new WeakMap;function De(e,t){return t===`monotone`?G(e):t===`step`?K(e):W(e)}function Oe(e,t,n){let o=i(n.transition,0),s=o.duration,u=r(o.easing),d=e.querySelector(`.prism-line-path`);d||(d=c(`path`,{class:`prism-line-path`,fill:`none`}),e.appendChild(d)),l(d,{stroke:n.color,"stroke-width":n.strokeWidth});let f=e.querySelector(`.prism-line-dots`);if(n.showPoints?f||(f=c(`g`,{class:`prism-line-dots`}),e.appendChild(f)):f&&=(f.remove(),null),s===0){if(l(d,{d:De(t,n.curve)}),f){for(;f.children.length>t.length;)f.removeChild(f.lastChild);for(let e=0;e<t.length;e++){let r=f.children[e];r||(r=c(`circle`,{class:`prism-line-dot`}),f.appendChild(r)),l(r,{cx:t[e].x,cy:t[e].y,fill:n.color,r:n.pointRadius})}}return}X.get(e)?.();let p=!!d.getAttribute(`d`),m=[],h=null;if(f){let e=f.children.length;for(let t=0;t<e;t++){let e=f.children[t],n={x:Number(e.getAttribute(`cx`)),y:Number(e.getAttribute(`cy`))};m.push(n),h=n}for(;f.children.length>t.length;)f.removeChild(f.lastChild);for(let e=f.children.length;e<t.length;e++){let r=c(`circle`,{class:`prism-line-dot`});l(r,{cx:t[e].x,cy:t[e].y,fill:n.color,r:n.pointRadius}),f.appendChild(r)}}for(let e=m.length;e<t.length;e++)m.push(h??t[e]);let g=null;function _(r){if(n.disposalSignal?.aborted){X.delete(e);return}g===null&&(g=r);let i=Math.min(1,(r-g)/s),o=u(i),c=t.map((e,t)=>{let n=m[t]??e;return{x:a(n.x,e.x,o),y:a(n.y,e.y,o)}});if(l(d,{d:De(c,n.curve)}),f)for(let e=0;e<t.length;e++){let t=f.children[e];t&&l(t,{cx:c[e].x,cy:c[e].y})}if(i<1){let t=requestAnimationFrame(_);X.set(e,()=>cancelAnimationFrame(t))}else X.delete(e)}if(!p)l(d,{d:De(t,n.curve)});else{let t=requestAnimationFrame(_);X.set(e,()=>cancelAnimationFrame(t))}}function ke(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}function Ae(t,n){let r=null;return R(t,n,t=>{let{groups:i,legend:a,tooltip:o}=t,s=t.dimensions.value,l=I(s.width,s.height,s.margin),u=(0,e.isReactive)(n.series)?n.series.value:n.series,d=u.map(t=>(0,e.isReactive)(t.data)?t.data.value:t.data),f=d.flat().map(e=>e.key),p=d.flat().map(e=>e.value);if(f.length===0){L(i,a,o,r);return}n.crosshair&&!r&&(r=le(t.chartArea,n.crosshair));let m=j(f,l.width),v=M(p,l.height);for(n.yAxis?.grid&&_(i.grid,v,n.yAxis.grid,l.width,`horizontal`,h(n.yAxis,l.height,`left`)),n.xAxis?.grid&&_(i.grid,m,n.xAxis.grid,l.height,`vertical`,h(n.xAxis,l.width,`bottom`)),n.xAxis&&(i.xAxis.setAttribute(`transform`,`translate(0,${l.height})`),g(i.xAxis,m,n.xAxis,l.width,`bottom`)),n.yAxis&&g(i.yAxis,v,n.yAxis,l.height,`left`);i.series.children.length>u.length;)i.series.removeChild(i.series.lastChild);let y=[];for(let e=0;e<u.length;e++){let r=u[e],a=i.series.children[e];a||(a=c(`g`,{class:`prism-line-series`}),i.series.appendChild(a));let o=ke(d[e],m,v);y.push(o),Oe(a,o,{color:U(e,r.color),curve:r.curve??`linear`,disposalSignal:t.disposalSignal,pointRadius:r.pointRadius??3,showPoints:r.showPoints??!1,strokeWidth:r.strokeWidth??2,transition:n.transition})}return a?.update(u.map((e,t)=>({color:U(t,e.color),name:e.name}))),o?.hide(),fe({crosshair:r,dims:()=>t.dimensions.value,getData:()=>d,getPoints:()=>y,getSeriesList:()=>(0,e.isReactive)(n.series)?n.series.value:n.series,onClick:n.onClick,onHover:n.onHover,svg:t.svg,tooltip:o})})}function je(e,t,n,r,i,a,o,s,c,l,u=!1){let d=e.reduce((e,t)=>e+Math.max(0,t.value),0);if(d===0)return[];let f=o-a,p=r>0?Math.asin(Math.min(1,s/2/r)):0,m=a,h=e.length;return e.map((e,a)=>{let o=Math.max(0,e.value)/d*f,s=m,g=m+o;m+=o;let _=Math.min(p,o/2);return{capEnd:u&&a===h-1,capStart:u&&a===0,centerX:t,centerY:n,color:e.color??l(a),cornerRadius:c,endAngle:g,index:a,innerRadius:i,outerRadius:r,padAngle:_,slice:e,startAngle:s}})}function Z(e,t,n,r){return`${e+n*Math.sin(r)},${t-n*Math.cos(r)}`}function Q(e,t,n){return e+t*Math.sin(n)}function $(e,t,n){return e-t*Math.cos(n)}function Me(e){let{capEnd:t,capStart:n,centerX:r,centerY:i,cornerRadius:a,endAngle:o,innerRadius:s,outerRadius:c,padAngle:l,startAngle:u}=e,d=o-u;if(d<=0)return``;if(d>=2*Math.PI-1e-6){let e=u+Math.PI;return s<=0?`M${Z(r,i,c,u)}A${c},${c},0,1,1,${Z(r,i,c,e)}A${c},${c},0,1,1,${Z(r,i,c,u)}Z`:[`M${Z(r,i,c,u)}`,`A${c},${c},0,1,1,${Z(r,i,c,e)}`,`A${c},${c},0,1,1,${Z(r,i,c,u)}`,`M${Z(r,i,s,u)}`,`A${s},${s},0,1,0,${Z(r,i,s,e)}`,`A${s},${s},0,1,0,${Z(r,i,s,u)}`,`Z`].join(``)}let f=n?u:u+l,p=t?o:o-l;if(p<=f)return``;let m=p-f;if(a<=0){let e=+(m>Math.PI);return s<=0?`M${r},${i}L${Z(r,i,c,f)}A${c},${c},0,${e},1,${Z(r,i,c,p)}Z`:[`M${Z(r,i,c,f)}`,`A${c},${c},0,${e},1,${Z(r,i,c,p)}`,`L${Z(r,i,s,p)}`,`A${s},${s},0,${e},0,${Z(r,i,s,f)}`,`Z`].join(``)}let h=Math.min(a/c,m/2),g=Math.min(a/s,m/2),_=Math.min(a,(c-s)/2),v=(c-s)/2,y=f+(n?0:h),b=p-(t?0:h),x=f+(n?0:g),S=p-(t?0:g),C=+(b-y>Math.PI),w=+(S-x>Math.PI),T=Q(r,c,f),E=$(i,c,f),D=Q(r,c,p),O=$(i,c,p),k=Q(r,s,f),A=$(i,s,f),j=Q(r,s,p),M=$(i,s,p),N=_/(c-s),P=`${T+(k-T)*N},${E+(A-E)*N}`,ee=`${D+(j-D)*N},${O+(M-O)*N}`,te=`${k+(T-k)*N},${A+(E-A)*N}`,ne=`${j+(D-j)*N},${M+(O-M)*N}`,F=[];return n?F.push(`M${Z(r,i,c,f)}`):(F.push(`M${P}`),F.push(`Q${T},${E},${Z(r,i,c,y)}`)),F.push(`A${c},${c},0,${C},1,${Z(r,i,c,b)}`),t?F.push(`A${v},${v},0,0,1,${Z(r,i,s,p)}`):(F.push(`Q${D},${O},${ee}`),F.push(`L${ne}`),F.push(`Q${j},${M},${Z(r,i,s,S)}`)),F.push(`A${s},${s},0,${w},0,${Z(r,i,s,x)}`),n?F.push(`A${v},${v},0,0,0,${Z(r,i,c,f)}`):F.push(`Q${k},${A},${te}`),F.push(`Z`),F.join(``)}function Ne(e){let t=(e.startAngle+e.endAngle)/2,n=(e.outerRadius+e.innerRadius)/2;return{x:e.centerX+n*Math.sin(t),y:e.centerY-n*Math.cos(t)}}var Pe=2*Math.PI,Fe=-Math.PI/2,Ie=Math.PI/2;function Le(e){return e===`semi`?{end:Ie,start:Fe}:{end:Pe,start:0}}function Re(t,n){let o=n.variant??`pie`,s=n.padPixels??(o===`pie`?0:8),u=n.cornerRadius??(o===`pie`?0:8),d=c(`circle`,{class:`prism-pie-bg`,"pointer-events":`none`}),f=c(`g`,{class:`prism-pie-slices`,"shape-rendering":`geometricPrecision`}),p=c(`g`,{class:`prism-pie-labels`,"pointer-events":`none`}),m=[],h=null;function g(e){for(;p.children.length>m.length;)p.removeChild(p.lastChild);for(let t=0;t<m.length;t++){let n=m[t],r=e[t];if(!r?.label)continue;let{x:i,y:a}=Ne(n),o=p.children[t];o||(o=c(`text`,{class:`prism-pie-label`}),p.appendChild(o)),l(o,{"dominant-baseline":`middle`,fill:`var(--prism-pie-label-color, #fff)`,"font-family":`var(--prism-font-family, system-ui)`,"font-size":`var(--prism-pie-label-size, 12px)`,"text-anchor":`middle`,x:i,y:a}),o.textContent=r.label}}let _=ce(t,{a11y:n.a11y,legend:n.legend,plugins:n.plugins,tooltip:n.tooltip},_=>{let{legend:v,svg:y,tooltip:b}=_;y.contains(d)||(y.appendChild(d),y.appendChild(f),y.appendChild(p));let{height:x,width:S}=_.dimensions.value,C=o===`semi`,w=S/2,T=C?x*.85:x/2,E=C?Math.min(w,T)-8:Math.min(S,x)/2-8,D=o===`pie`?0:Math.round(E*.55),O=n.innerRadius===void 0?D:n.innerRadius,k=Math.max(O+1,E),A=(0,e.isReactive)(n.data)?n.data.value:n.data,{end:j,start:M}=Le(o);for(m=je(A,w,T,k,O,M,j,s,u,e=>U(e),!1),l(d,{cx:w,cy:T,r:O>0?O:0}),d.setAttribute(`style`,`fill:var(--prism-bg,#fff)`);f.children.length>m.length;)f.removeChild(f.lastChild);for(;p.children.length>m.length;)p.removeChild(p.lastChild);let N=i(n.transition,0),P=N.duration,ee=r(N.easing);for(let e=0;e<m.length;e++){let t=m[e],r=f.children[e];r||(r=c(`path`,{class:`prism-pie-slice`}),f.appendChild(r)),r.setAttribute(`fill`,t.color),r.setAttribute(`stroke`,`none`),r.style.cursor=n.onClick||n.onHover?`pointer`:``}if(h!==null&&(cancelAnimationFrame(h),h=null),P>0){let e=null,t=n=>{e===null&&(e=n);let r=ee(Math.min(1,(n-e)/P)),i=a(M,j,r);for(let e=0;e<m.length;e++){let t=m[e],n=f.children[e];if(n)if(i<=t.startAngle)l(n,{d:``});else{let e=Math.min(t.endAngle,i);l(n,{d:Me({...t,endAngle:e})})}}r<1?h=requestAnimationFrame(t):(h=null,g(A))};h=requestAnimationFrame(t)}else{for(let e=0;e<m.length;e++){let t=m[e],n=f.children[e];n&&l(n,{d:Me(t)})}g(A)}return v?.update(m.map(e=>({color:e.color,name:e.slice.label??``}))),b?.hide(),{onClick:e=>{if(!n.onClick)return;let t=y.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=ze(m,r,i,o);a>=0&&n.onClick(m[a].slice,a)},onMouseLeave:()=>{n.onHover?.(null,null),b?.hide()},onMouseMove:e=>{let r=y.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,s=ze(m,i,a,o);if(s>=0){let e=m[s];n.onHover?.(e.slice,s);let{x:i,y:a}=Ne(e),o=t.getBoundingClientRect();b?.show(i+(r.left-o.left),a+(r.top-o.top),{key:s,value:e.slice.value},{color:e.color,data:[],name:e.slice.label??``})}else n.onHover?.(null,null),b?.hide()}}});return{get disposalSignal(){return _.disposalSignal},dispose(){h!==null&&(cancelAnimationFrame(h),h=null),_.dispose()},get disposed(){return _.disposed},el:_.el,[Symbol.dispose](){this.dispose()}}}function ze(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i],o=t-a.centerX,s=n-a.centerY,c=Math.sqrt(o*o+s*s);if(c<a.outerRadius&&c>=a.innerRadius){let e=Math.atan2(o,-s);if(r===`semi`){if(e>=a.startAngle-1e-9&&e<=a.endAngle+1e-9)return i}else{let t=e<0?e+Pe:e;if(t>=a.startAngle-1e-9&&t<=a.endAngle+1e-9)return i}}}return-1}function Be(e,t,n){if(e.length===0)return[];let r=t/Math.max(1,e.length-1),i=Math.min(...e),a=Math.max(...e)-i||1;return e.map((e,t)=>({x:t*r,y:n-(e-i)/a*n}))}function Ve(e,t,n,r=`linear`){if(e.length===0)return``;let i=Be(e,t,n);return q(i,i.map(e=>({x:e.x,y:n})),r??`linear`)}function He(e,t,n,r){if(e.length===0)return``;let i=Be(e,t,n);return r===`monotone`?G(i):r===`step`?K(i):W(i)}function Ue(e,t,n,o,s,u,d){let f=t.length,p=Math.max(1,n/f-1),m=n/f,h=Math.min(0,...t),g=Math.max(...t)-h||1,_=i(u,0),v=_.duration,y=r(_.easing);for(;e.children.length>f;){let t=e.lastElementChild;t&&e.removeChild(t)}for(let n=0;n<f;n++){let r=Math.max(1,(t[n]-h)/g*o),i=o-r,u=e.children[n];if(u||(u=c(`rect`,{class:`prism-spark-bar`}),e.appendChild(u)),l(u,{fill:s,width:p,x:n*m}),v>0&&!u.hasAttribute(`data-init`)){u.setAttribute(`data-init`,`1`),l(u,{height:0,y:o});let e=null,t={h:0,y:o},n={h:r,y:i},s=r=>{if(d?.aborted)return;e===null&&(e=r);let i=y(Math.min(1,(r-e)/v));l(u,{height:a(t.h,n.h,i),y:a(t.y,n.y,i)}),i<1&&requestAnimationFrame(s)};requestAnimationFrame(s)}else u.setAttribute(`data-init`,`1`),l(u,{height:r,y:i})}}function We(e){return e.length>0&&e[0]!==null&&typeof e[0]==`object`}function Ge(e,t,n,r,i,a,o){let s=Math.min(i,n/2,r/2),c=a?s:0,l=a?s:0,u=o?s:0,d=o?s:0;return[`M${e+c},${t}`,`H${e+n-u}`,u?`Q${e+n},${t} ${e+n},${t+u}`:``,`V${t+r-d}`,d?`Q${e+n},${t+r} ${e+n-d},${t+r}`:``,`H${e+l}`,l?`Q${e},${t+r} ${e},${t+r-l}`:``,`V${t+c}`,c?`Q${e},${t} ${e+c},${t}`:``,`Z`].filter(Boolean).join(``)}function Ke(e){return`var(--prism-color-${e%8+1})`}function qe(t,n){let r=n.variant??`line`,i=n.color??`var(--prism-color-1)`,a=n.curve??`linear`,o=n.strokeWidth??1.5,s=n.fillOpacity??.2,u=ae(t,{...n.a11y?{a11y:n.a11y}:{ariaHidden:!0},margin:{bottom:0,left:0,right:0,top:0}}),{svg:d}=u;d.classList.add(`prism-sparkline`);let f=c(`g`,{class:`prism-spark-inner`});d.appendChild(f);let p;function m(){let{height:t,width:d}=u.dimensions.value,p=(0,e.isReactive)(n.data)?n.data.value:n.data;for(;f.firstChild;)f.removeChild(f.firstChild);if(p.length!==0){if(r===`stack`&&We(p)){let e=c(`g`,{class:`prism-spark-stack`});f.appendChild(e);let r=n.cornerRadius??4,i=p,a=i.reduce((e,t)=>e+Math.max(0,t.value),0);if(a>0){let o=(n.padPixels??0)/2,s=0;i.forEach((n,u)=>{let f=Math.round(s);s+=Math.max(0,n.value)/a*d;let p=u===i.length-1?d:Math.round(s),m=u===0,h=u===i.length-1,g=Ge(f+(m?0:o),0,Math.max(0,p-f-(m?0:o)-(h?0:o)),t,r,m,h),_=c(`path`,{class:`prism-spark-stack-segment`});l(_,{d:g,fill:n.color??Ke(u)}),e.appendChild(_)})}}else if(r===`bar`){let e=c(`g`,{class:`prism-spark-bars`});f.appendChild(e),Ue(e,p,d,t,i,n.transition,g.signal)}else{if(r===`area`){let e=c(`path`,{class:`prism-spark-fill`});l(e,{d:Ve(p,d,t,a),fill:i,"fill-opacity":s,stroke:`none`}),f.appendChild(e)}let e=c(`path`,{class:`prism-spark-line`});l(e,{d:He(p,d,t,a),fill:`none`,stroke:i,"stroke-width":o}),f.appendChild(e)}We(p)||h(p)}}function h(e){if(p?.(),p=void 0,!n.onHover&&!n.onClick||e.length<=1)return;let{width:t}=u.dimensions.value;d.style.cursor=`crosshair`;let r=t/(e.length-1),i=t=>{let i=d.getBoundingClientRect(),a=t.clientX-i.left,o=Math.max(0,Math.min(e.length-1,Math.round(a/r)));n.onHover?.(o,e[o])},a=()=>n.onHover?.(null,null),o=t=>{if(!n.onClick)return;let i=d.getBoundingClientRect(),a=t.clientX-i.left,o=Math.max(0,Math.min(e.length-1,Math.round(a/r)));n.onClick(o,e[o])};d.addEventListener(`mousemove`,i),d.addEventListener(`mouseleave`,a),d.addEventListener(`click`,o),p=()=>{d.removeEventListener(`mousemove`,i),d.removeEventListener(`mouseleave`,a),d.removeEventListener(`click`,o)}}let g=new AbortController,_=(0,e.createScope)();_.run(()=>{(0,e.effect)(()=>{m()},{scheduler:`microtask`})});let v=!1;return{get disposalSignal(){return g.signal},dispose(){v||(v=!0,g.abort(),p?.(),_.dispose(),u.dispose())},get disposed(){return v},el:d,[Symbol.dispose](){this.dispose()}}}exports.PrismError=te,exports.PrismRenderError=ne,exports.animate=o,exports.bandScale=ye,exports.createAreaChart=ve,exports.createBarChart=Ee,exports.createLineChart=Ae,exports.createPieChart=Re,exports.createSparkline=qe,exports.linearScale=b,exports.resetTheme=me,exports.seriesColor=U,exports.setTheme=pe,exports.timeScale=A;
2
2
  //# sourceMappingURL=prism.cjs.map