minerva-design 1.13.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/custom-elements.json +194 -12
  3. package/dist/angular/fesm2022/minerva-angular.mjs +20 -0
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +10 -1
  6. package/dist/charts/canvas.d.cts +1 -0
  7. package/dist/charts/canvas.d.ts +1 -0
  8. package/dist/charts/engine/canvas.cjs +1 -1
  9. package/dist/charts/engine/canvas.cjs.map +1 -1
  10. package/dist/charts/engine/canvas.js +152 -128
  11. package/dist/charts/engine/canvas.js.map +1 -1
  12. package/dist/charts/engine/chart.cjs +1 -1
  13. package/dist/charts/engine/chart.cjs.map +1 -1
  14. package/dist/charts/engine/chart.js +475 -405
  15. package/dist/charts/engine/chart.js.map +1 -1
  16. package/dist/charts/engine/controller.cjs +2 -2
  17. package/dist/charts/engine/controller.cjs.map +1 -1
  18. package/dist/charts/engine/controller.js +263 -248
  19. package/dist/charts/engine/controller.js.map +1 -1
  20. package/dist/charts/engine/dom.cjs +1 -1
  21. package/dist/charts/engine/dom.cjs.map +1 -1
  22. package/dist/charts/engine/dom.d.cts +34 -0
  23. package/dist/charts/engine/dom.d.ts +34 -0
  24. package/dist/charts/engine/dom.js +62 -51
  25. package/dist/charts/engine/dom.js.map +1 -1
  26. package/dist/charts/engine/graph/chart.cjs +1 -1
  27. package/dist/charts/engine/graph/chart.cjs.map +1 -1
  28. package/dist/charts/engine/graph/chart.js +835 -821
  29. package/dist/charts/engine/graph/chart.js.map +1 -1
  30. package/dist/charts/engine/graph/dom.cjs +1 -1
  31. package/dist/charts/engine/graph/dom.cjs.map +1 -1
  32. package/dist/charts/engine/graph/dom.js +44 -51
  33. package/dist/charts/engine/graph/dom.js.map +1 -1
  34. package/dist/charts/engine/hover-rect.cjs +2 -0
  35. package/dist/charts/engine/hover-rect.cjs.map +1 -0
  36. package/dist/charts/engine/hover-rect.d.cts +10 -0
  37. package/dist/charts/engine/hover-rect.d.ts +10 -0
  38. package/dist/charts/engine/hover-rect.js +47 -0
  39. package/dist/charts/engine/hover-rect.js.map +1 -0
  40. package/dist/charts/engine/items.cjs +1 -1
  41. package/dist/charts/engine/items.cjs.map +1 -1
  42. package/dist/charts/engine/items.js +8 -8
  43. package/dist/charts/engine/model.cjs +1 -1
  44. package/dist/charts/engine/model.cjs.map +1 -1
  45. package/dist/charts/engine/model.js +191 -191
  46. package/dist/charts/engine/model.js.map +1 -1
  47. package/dist/charts/engine/orderbook/depth.cjs +1 -1
  48. package/dist/charts/engine/orderbook/depth.cjs.map +1 -1
  49. package/dist/charts/engine/orderbook/depth.js +63 -63
  50. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  51. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  52. package/dist/charts/engine/orderbook/heatmap.js +155 -155
  53. package/dist/charts/engine/orderbook/host.cjs +1 -1
  54. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  55. package/dist/charts/engine/orderbook/host.js +87 -75
  56. package/dist/charts/engine/orderbook/host.js.map +1 -1
  57. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  58. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  59. package/dist/charts/engine/orderbook/ladder.js +41 -41
  60. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  61. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  62. package/dist/charts/engine/orderbook/tape.js +31 -31
  63. package/dist/charts/engine/presets.cjs +2 -2
  64. package/dist/charts/engine/presets.cjs.map +1 -1
  65. package/dist/charts/engine/presets.js +15 -15
  66. package/dist/charts/engine/renderers/vector-gpu.cjs +24 -0
  67. package/dist/charts/engine/renderers/vector-gpu.cjs.map +1 -0
  68. package/dist/charts/engine/renderers/vector-gpu.d.cts +22 -0
  69. package/dist/charts/engine/renderers/vector-gpu.d.ts +22 -0
  70. package/dist/charts/engine/renderers/vector-gpu.js +301 -0
  71. package/dist/charts/engine/renderers/vector-gpu.js.map +1 -0
  72. package/dist/charts/engine/renderers/vector.cjs +2 -0
  73. package/dist/charts/engine/renderers/vector.cjs.map +1 -0
  74. package/dist/charts/engine/renderers/vector.d.cts +140 -0
  75. package/dist/charts/engine/renderers/vector.d.ts +140 -0
  76. package/dist/charts/engine/renderers/vector.js +568 -0
  77. package/dist/charts/engine/renderers/vector.js.map +1 -0
  78. package/dist/charts/engine/scene.cjs +1 -1
  79. package/dist/charts/engine/scene.cjs.map +1 -1
  80. package/dist/charts/engine/scene.d.cts +43 -3
  81. package/dist/charts/engine/scene.d.ts +43 -3
  82. package/dist/charts/engine/scene.js +411 -338
  83. package/dist/charts/engine/scene.js.map +1 -1
  84. package/dist/charts/engine/shapes/bullet.cjs +1 -1
  85. package/dist/charts/engine/shapes/bullet.cjs.map +1 -1
  86. package/dist/charts/engine/shapes/bullet.js +36 -36
  87. package/dist/charts/engine/shapes/calendar.cjs +1 -1
  88. package/dist/charts/engine/shapes/calendar.cjs.map +1 -1
  89. package/dist/charts/engine/shapes/calendar.js +53 -53
  90. package/dist/charts/engine/shapes/chart.cjs +1 -1
  91. package/dist/charts/engine/shapes/chart.cjs.map +1 -1
  92. package/dist/charts/engine/shapes/chart.d.cts +3 -2
  93. package/dist/charts/engine/shapes/chart.d.ts +3 -2
  94. package/dist/charts/engine/shapes/chart.js +192 -162
  95. package/dist/charts/engine/shapes/chart.js.map +1 -1
  96. package/dist/charts/engine/shapes/draw.cjs +1 -1
  97. package/dist/charts/engine/shapes/draw.cjs.map +1 -1
  98. package/dist/charts/engine/shapes/draw.js +87 -86
  99. package/dist/charts/engine/shapes/draw.js.map +1 -1
  100. package/dist/charts/engine/shapes/layout.cjs +2 -2
  101. package/dist/charts/engine/shapes/layout.cjs.map +1 -1
  102. package/dist/charts/engine/shapes/layout.d.cts +8 -7
  103. package/dist/charts/engine/shapes/layout.d.ts +8 -7
  104. package/dist/charts/engine/shapes/layout.js +262 -166
  105. package/dist/charts/engine/shapes/layout.js.map +1 -1
  106. package/dist/charts/engine/shapes/types.d.cts +13 -1
  107. package/dist/charts/engine/shapes/types.d.ts +13 -1
  108. package/dist/charts/engine/three-d/chart.cjs +1 -1
  109. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  110. package/dist/charts/engine/three-d/chart.js +266 -257
  111. package/dist/charts/engine/three-d/chart.js.map +1 -1
  112. package/dist/charts/engine/three-d/dom.cjs +1 -1
  113. package/dist/charts/engine/three-d/dom.cjs.map +1 -1
  114. package/dist/charts/engine/three-d/dom.js +28 -35
  115. package/dist/charts/engine/three-d/dom.js.map +1 -1
  116. package/dist/charts/engine/three-d/geometry.cjs +1 -1
  117. package/dist/charts/engine/three-d/geometry.cjs.map +1 -1
  118. package/dist/charts/engine/three-d/geometry.js +70 -70
  119. package/dist/charts/engine/three-d/overlay.cjs +1 -1
  120. package/dist/charts/engine/three-d/overlay.cjs.map +1 -1
  121. package/dist/charts/engine/three-d/overlay.js +15 -15
  122. package/dist/charts/engine/tooltip.cjs +2 -0
  123. package/dist/charts/engine/tooltip.cjs.map +1 -0
  124. package/dist/charts/engine/tooltip.d.cts +94 -0
  125. package/dist/charts/engine/tooltip.d.ts +94 -0
  126. package/dist/charts/engine/tooltip.js +242 -0
  127. package/dist/charts/engine/tooltip.js.map +1 -0
  128. package/dist/charts/engine/trading/chart.cjs +1 -1
  129. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  130. package/dist/charts/engine/trading/chart.js +135 -135
  131. package/dist/charts/react/shapes.cjs +1 -1
  132. package/dist/charts/react/shapes.cjs.map +1 -1
  133. package/dist/charts/react/shapes.d.cts +10 -1
  134. package/dist/charts/react/shapes.d.ts +10 -1
  135. package/dist/charts/react/shapes.js +24 -19
  136. package/dist/charts/react/shapes.js.map +1 -1
  137. package/dist/core/contracts.cjs +1 -1
  138. package/dist/core/contracts.cjs.map +1 -1
  139. package/dist/core/contracts.js +1 -1
  140. package/dist/core/contracts.js.map +1 -1
  141. package/dist/native/charts/src/canvas.cjs +1 -1
  142. package/dist/native/charts/src/canvas.js +8 -7
  143. package/dist/native/charts/src/engine/canvas.cjs +1 -1
  144. package/dist/native/charts/src/engine/canvas.js +2 -0
  145. package/dist/native/charts/src/engine/controller.cjs +2 -2
  146. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  147. package/dist/native/charts/src/engine/controller.js +102 -87
  148. package/dist/native/charts/src/engine/controller.js.map +1 -1
  149. package/dist/native/charts/src/engine/hover-rect.cjs +2 -0
  150. package/dist/native/charts/src/engine/hover-rect.cjs.map +1 -0
  151. package/dist/native/charts/src/engine/hover-rect.js +47 -0
  152. package/dist/native/charts/src/engine/hover-rect.js.map +1 -0
  153. package/dist/native/charts/src/engine/scene.cjs +1 -1
  154. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  155. package/dist/native/charts/src/engine/scene.js +318 -245
  156. package/dist/native/charts/src/engine/scene.js.map +1 -1
  157. package/dist/native/charts/src/engine/shapes/draw.cjs +1 -1
  158. package/dist/native/charts/src/engine/shapes/draw.cjs.map +1 -1
  159. package/dist/native/charts/src/engine/shapes/draw.js +81 -80
  160. package/dist/native/charts/src/engine/shapes/draw.js.map +1 -1
  161. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  162. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  163. package/dist/native/charts/src/engine/shapes/layout.js +239 -143
  164. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  165. package/dist/native/charts/src/engine/tooltip.cjs +2 -0
  166. package/dist/native/charts/src/engine/tooltip.cjs.map +1 -0
  167. package/dist/native/charts/src/engine/tooltip.js +164 -0
  168. package/dist/native/charts/src/engine/tooltip.js.map +1 -0
  169. package/dist/native/components/Chart/scene.cjs +1 -1
  170. package/dist/native/components/Chart/scene.cjs.map +1 -1
  171. package/dist/native/components/Chart/scene.js +210 -187
  172. package/dist/native/components/Chart/scene.js.map +1 -1
  173. package/dist/native/source/components/Chart/scene.tsx +55 -2
  174. package/dist/taro/index.js +2026 -1626
  175. package/dist/uni/charts-canvas.js +1 -0
  176. package/dist/vue/components/Chart/BulletChart.vue.d.ts +2 -0
  177. package/dist/vue/components/Chart/CalendarHeatmap.vue.d.ts +2 -0
  178. package/dist/vue/components/Chart/ChordChart.vue.d.ts +2 -0
  179. package/dist/vue/components/Chart/DonutChart.vue.d.ts +2 -0
  180. package/dist/vue/components/Chart/FunnelChart.vue.d.ts +2 -0
  181. package/dist/vue/components/Chart/GaugeChart.vue.d.ts +2 -0
  182. package/dist/vue/components/Chart/PieChart.vue.d.ts +2 -0
  183. package/dist/vue/components/Chart/RadarChart.vue.d.ts +2 -0
  184. package/dist/vue/components/Chart/RadialBarChart.vue.d.ts +2 -0
  185. package/dist/vue/components/Chart/SankeyChart.vue.d.ts +2 -0
  186. package/dist/vue/components/Chart/SunburstChart.vue.d.ts +2 -0
  187. package/dist/vue/components/Chart/TreemapChart.vue.d.ts +2 -0
  188. package/dist/vue/components/Chart/props.d.ts +2 -0
  189. package/dist/vue/components/Chart/props.js +1 -0
  190. package/dist/vue/components/Chart/props.js.map +1 -1
  191. package/dist/vue/components/Chart/shape.d.ts +2 -1
  192. package/dist/vue/components/Chart/shape.js +2 -0
  193. package/dist/vue/components/Chart/shape.js.map +1 -1
  194. package/dist/vue/components/Chart/types.d.ts +2 -0
  195. package/dist/weapp/charts/canvas.js +2576 -1969
  196. package/dist/weapp/charts/core.js +1 -0
  197. package/dist/web-components/components/chart/shape-chart.d.ts +9 -7
  198. package/dist/web-components/components/chart/shape-chart.js +3 -0
  199. package/dist/web-components/components/chart/shape-chart.js.map +1 -1
  200. package/dist/web-components/components/chart/shapes-extended.d.ts +6 -6
  201. package/dist/web-components/components/chart/shapes-extended.js.map +1 -1
  202. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"chart.js","names":["assign","TAP_SLOP","uid","createShapeChart","doc","container","win","dom","createChartDom","canvas","ctx","runtime","createShapeRuntime","initial","options","theme","readTheme","scene","hover","tipKey","destroyed","frameId","frameIsTimeout","press","listeners","emit","listener","type","event","description","fontSet","measure","f","text","estimateText","cancelFrame","schedule","render","tooltipOptions","tooltipNode","custom","content","tooltipContent","fragment","header","swatch","row","el","n","v","updateTooltip","tip","hoverEvent","key","force","anchor","hoverAnchor","stageW","stageH","left","top","placeShapeTooltip","setHover","changed","sameHover","next","keyboard","width","height","dpr","pw","ph","frame","now","it","drawShapeScene","describeScene","renderLegend","entries","shapeLegend","config","legendConfig","focused","bottom","entry","item","toggle","updateAccessibility","describeChart","index","drill","path","activate","hit","local","rect","hitAt","hitTestShapes","x","y","onPointerMove","onPointerDown","onPointerUp","p","onPointerCancel","onPointerLeave","focusItem","describeItem","onKeyDown","current","direction","stepHover","items","e","onFocus","visible","onBlur","stage","resizeObserver","refreshTheme","unwatchTheme","watchTheme","previous"],"sources":["../../../../../charts/src/engine/shapes/chart.ts"],"sourcesContent":["// createShapeChart: DOM host of the shape charts. One Canvas2D layer sized\n// with the device pixel ratio, the house legend / tooltip / live region of\n// createChartDom, pointer + keyboard interaction, resize and theme watching.\n\nimport { createChartDom, styleElement, swatch } from \"../dom\";\nimport { readTheme, watchTheme, type ChartTheme } from \"../theme\";\nimport { drawShapeScene } from \"./draw\";\nimport { hitTestShapes, hoverAnchor, stepHover } from \"./hit\";\nimport {\n describeChart,\n describeItem,\n describeScene,\n hoverEvent,\n legendConfig,\n placeShapeTooltip,\n sameHover,\n shapeLegend,\n tooltipContent,\n} from \"./layout\";\nimport { createShapeRuntime, now } from \"./runtime\";\nimport {\n estimateText,\n type MeasureText,\n type ShapeHover,\n type ShapeScene,\n} from \"./scene\";\nimport type {\n ShapeChartEventMap,\n ShapeChartInstance,\n ShapeChartOptions,\n ShapeHoverEvent,\n} from \"./types\";\n\n/** Pointer travel (px) under which a press counts as a click / tap */\nconst TAP_SLOP = 6;\n\nlet uid = 0;\n\ninterface HoverState {\n hover: ShapeHover;\n x: number;\n y: number;\n keyboard: boolean;\n}\n\n/**\n * Creates a pie / donut, radar, gauge, funnel, treemap, sankey, sunburst,\n * radial bar, calendar heatmap or bullet chart in `container` (drawn with\n * Canvas2D, themed by the Minerva CSS variables).\n */\nexport const createShapeChart = (\n container: HTMLElement,\n initial: ShapeChartOptions,\n): ShapeChartInstance => {\n const doc = container.ownerDocument;\n const win = doc.defaultView;\n const dom = createChartDom(container);\n dom.root.classList.add(\"minerva-shape-chart\");\n dom.foreground.style.display = \"none\";\n dom.hover.style.display = \"none\";\n const canvas = dom.background;\n let ctx: CanvasRenderingContext2D | null = null;\n try {\n ctx = canvas.getContext(\"2d\");\n } catch {\n ctx = null;\n }\n\n const runtime = createShapeRuntime(initial);\n let options = initial;\n let theme: ChartTheme = readTheme(dom.root, options.palette);\n let scene: ShapeScene | null = null;\n let hover: HoverState | null = null;\n let tipKey = \"\";\n let destroyed = false;\n let frameId: number | null = null;\n let frameIsTimeout = false;\n let press: {\n x: number;\n y: number;\n id: number;\n touch: boolean;\n moved: boolean;\n } | null = null;\n\n const listeners: {\n [K in keyof ShapeChartEventMap]: Set<\n (event: ShapeChartEventMap[K]) => void\n >;\n } = {\n hover: new Set(),\n click: new Set(),\n toggle: new Set(),\n drill: new Set(),\n };\n const emit = <K extends keyof ShapeChartEventMap>(\n type: K,\n event: ShapeChartEventMap[K],\n ) => {\n for (const listener of [...listeners[type]]) listener(event);\n };\n\n // screen-reader summary of the data\n const description = doc.createElement(\"div\");\n description.id = `minerva-shape-chart-${++uid}`;\n styleElement(description, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n overflow: \"hidden\",\n clip: \"rect(0 0 0 0)\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n });\n dom.stage.appendChild(description);\n dom.stage.setAttribute(\"aria-describedby\", description.id);\n dom.stage.tabIndex = 0;\n\n let fontSet = \"\";\n const measure: MeasureText = (text, f) => {\n if (!ctx) return estimateText(text, f);\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n // ------------------------------------------------------------- frames\n\n const cancelFrame = () => {\n if (frameId === null) return;\n if (frameIsTimeout) clearTimeout(frameId);\n else win?.cancelAnimationFrame?.(frameId);\n frameId = null;\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (win && typeof win.requestAnimationFrame === \"function\") {\n frameIsTimeout = false;\n frameId = win.requestAnimationFrame(() => render());\n } else {\n frameIsTimeout = true;\n frameId = setTimeout(() => render(), 16) as unknown as number;\n }\n };\n\n const tooltipOptions = () =>\n options.tooltip === false\n ? null\n : typeof options.tooltip === \"object\"\n ? options.tooltip\n : {};\n\n const tooltipNode = (event: ShapeHoverEvent): Node | string | null => {\n const custom = tooltipOptions()?.render;\n if (custom) return custom(event);\n if (!scene || !hover) return null;\n const content = tooltipContent(scene, hover.hover);\n if (!content) return null;\n const fragment = doc.createDocumentFragment();\n const header = doc.createElement(\"div\");\n styleElement(header, {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"6px\",\n fontWeight: \"600\",\n marginBottom: \"4px\",\n color: \"var(--text-color, #1f2937)\",\n // long titles (full names of truncated labels) wrap\n whiteSpace: \"normal\",\n maxWidth: \"260px\",\n overflowWrap: \"anywhere\",\n });\n if (content.color) header.appendChild(swatch(doc, content.color, \"dot\"));\n header.appendChild(doc.createTextNode(content.title));\n fragment.append(header);\n for (const row of content.rows) {\n const el = doc.createElement(\"div\");\n styleElement(el, { display: \"flex\", alignItems: \"center\", gap: \"8px\" });\n if (row.color) el.appendChild(swatch(doc, row.color, \"dot\"));\n const n = doc.createElement(\"span\");\n styleElement(n, {\n flex: \"1 1 auto\",\n color: row.strong\n ? \"var(--text-color, #1f2937)\"\n : \"var(--text-secondary-color, #6b7280)\",\n fontWeight: row.strong ? \"600\" : \"400\",\n });\n n.textContent = row.name;\n const v = doc.createElement(\"span\");\n styleElement(v, {\n fontWeight: \"600\",\n fontVariantNumeric: \"tabular-nums\",\n marginLeft: \"12px\",\n });\n v.textContent = row.value;\n el.append(n, v);\n fragment.append(el);\n }\n return fragment;\n };\n\n /** Fills (when the hovered item changed) and places the tooltip */\n const updateTooltip = (force = false) => {\n const tip = dom.tooltip;\n const event = scene && hover ? hoverEvent(scene, hover.hover) : null;\n if (!event || !scene || !hover || !tooltipOptions() || press?.moved) {\n tip.style.display = \"none\";\n tipKey = \"\";\n return;\n }\n const key = `${event.index}:${event.indicator ?? \"\"}`;\n if (force || key !== tipKey) {\n tipKey = key;\n const content = tooltipNode(event);\n if (content === null || content === \"\") {\n tip.replaceChildren();\n tipKey = \"\";\n tip.style.display = \"none\";\n return;\n }\n if (typeof content === \"string\") {\n tip.textContent = content;\n tip.style.whiteSpace = \"pre\";\n } else {\n tip.replaceChildren(content);\n tip.style.whiteSpace = \"nowrap\";\n }\n } else if (!tip.firstChild) {\n return;\n }\n tip.style.display = \"block\";\n const anchor = hover.keyboard\n ? (hoverAnchor(scene, hover.hover) ?? hover)\n : hover;\n const stageW = dom.stage.clientWidth;\n const stageH = dom.stage.clientHeight;\n const { x: left, y: top } = placeShapeTooltip(\n scene,\n hover.hover,\n anchor,\n tip.offsetWidth,\n tip.offsetHeight,\n stageW,\n stageH,\n );\n tip.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;\n };\n\n const setHover = (\n next: ShapeHover | null,\n x: number,\n y: number,\n keyboard: boolean,\n ) => {\n const changed = !sameHover(hover?.hover ?? null, next);\n hover = next ? { hover: next, x, y, keyboard } : null;\n dom.stage.style.cursor = next && !keyboard ? \"pointer\" : \"\";\n updateTooltip();\n if (!changed) return;\n schedule();\n emit(\"hover\", scene && next ? hoverEvent(scene, next) : null);\n };\n\n function render() {\n frameId = null;\n if (destroyed) return;\n const width = dom.stage.clientWidth;\n const height = dom.stage.clientHeight;\n if (!(width > 0 && height > 0)) return;\n const dpr = win?.devicePixelRatio || 1;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${height}px`;\n fontSet = \"\";\n const frame = runtime.frame(now(), { theme, width, height, measure });\n scene = frame.scene;\n if (hover && !scene.items.some((it) => it.index === hover?.hover.index)) {\n hover = null;\n dom.stage.style.cursor = \"\";\n emit(\"hover\", null);\n }\n if (ctx) {\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, pw, ph);\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawShapeScene(ctx, scene, hover?.hover ?? null);\n fontSet = \"\";\n }\n updateTooltip();\n if (!frame.animating) {\n const text = describeScene(scene);\n if (description.textContent !== text) description.textContent = text;\n } else schedule();\n }\n\n // ------------------------------------------------------------- legend\n\n const renderLegend = () => {\n const entries = shapeLegend(options, theme, runtime.hidden);\n const config = legendConfig(options);\n const focused = [...dom.legend.children].indexOf(\n doc.activeElement as Element,\n );\n dom.legend.replaceChildren();\n dom.legend.style.display = entries ? \"flex\" : \"none\";\n if (!entries) return;\n const bottom = config.position === \"bottom\";\n dom.legend.style.order = bottom ? \"1\" : \"0\";\n dom.legend.style.padding = bottom ? \"8px 4px 0\" : \"0 4px 8px\";\n dom.legend.style.justifyContent = \"center\";\n for (const entry of entries) {\n const item = doc.createElement(config.toggle ? \"button\" : \"span\");\n if (item instanceof HTMLButtonElement) {\n item.type = \"button\";\n item.setAttribute(\"aria-pressed\", String(!entry.hidden));\n item.addEventListener(\"click\", () => toggle(entry.index));\n }\n styleElement(item, {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"6px\",\n padding: \"2px 4px\",\n margin: \"0\",\n border: \"0\",\n borderRadius: \"4px\",\n background: \"none\",\n font: \"inherit\",\n color: \"var(--text-secondary-color, #6b7280)\",\n cursor: config.toggle ? \"pointer\" : \"default\",\n opacity: entry.hidden ? \"0.45\" : \"1\",\n textDecoration: entry.hidden ? \"line-through\" : \"none\",\n transition: \"opacity 120ms ease-out\",\n });\n item.append(\n swatch(doc, entry.color, \"dot\"),\n doc.createTextNode(entry.name),\n );\n dom.legend.appendChild(item);\n }\n if (focused >= 0)\n (dom.legend.children[focused] as HTMLElement | undefined)?.focus();\n };\n\n const updateAccessibility = () => {\n dom.stage.setAttribute(\n \"aria-label\",\n options.ariaLabel ?? describeChart(options),\n );\n };\n\n function toggle(index: number) {\n if (destroyed) return;\n const event = runtime.toggle(index);\n if (!event) return;\n if (!options.hidden) {\n renderLegend();\n tipKey = \"\";\n schedule();\n }\n emit(\"toggle\", event);\n }\n\n function drill(path: readonly string[]) {\n if (destroyed) return;\n const event = runtime.drill(path);\n if (!event) return;\n if (options.type === \"sunburst\" && !options.drillPath) {\n tipKey = \"\";\n schedule();\n }\n emit(\"drill\", event);\n }\n\n /** Sunburst: drills into / out of an activated item */\n const activate = (hit: ShapeHover) => {\n if (options.type !== \"sunburst\" || options.drill === false || !scene)\n return;\n const item = scene.items.find((it) => it.index === hit.index);\n if (item?.drill) drill(item.drill);\n };\n\n // -------------------------------------------------------- interaction\n\n const local = (event: { clientX: number; clientY: number }) => {\n const rect = dom.stage.getBoundingClientRect();\n return { x: event.clientX - rect.left, y: event.clientY - rect.top };\n };\n\n const hitAt = (x: number, y: number) =>\n scene ? hitTestShapes(scene, x, y, hover?.hover ?? null) : null;\n\n const onPointerMove = (event: PointerEvent) => {\n const { x, y } = local(event);\n if (press && press.id === event.pointerId) {\n if (Math.hypot(x - press.x, y - press.y) > TAP_SLOP) press.moved = true;\n if (press.touch) return;\n } else if (event.pointerType === \"touch\") return;\n setHover(hitAt(x, y), x, y, false);\n };\n\n const onPointerDown = (event: PointerEvent) => {\n const { x, y } = local(event);\n press = {\n x,\n y,\n id: event.pointerId,\n touch: event.pointerType === \"touch\",\n moved: false,\n };\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const p = press;\n press = null;\n if (!p || p.id !== event.pointerId || p.moved) {\n updateTooltip();\n return;\n }\n const { x, y } = local(event);\n const hit = hitAt(x, y);\n // a tap shows the tooltip (there is no hover on touch screens)\n setHover(hit, x, y, false);\n if (hit && scene) {\n const e = hoverEvent(scene, hit);\n if (e) emit(\"click\", e);\n activate(hit);\n }\n };\n\n const onPointerCancel = () => {\n press = null;\n updateTooltip();\n };\n\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === \"touch\") return;\n press = null;\n if (hover && !hover.keyboard) setHover(null, 0, 0, false);\n };\n\n const focusItem = (next: ShapeHover | null) => {\n if (!scene || !next) return;\n const anchor = hoverAnchor(scene, next) ?? { x: 0, y: 0 };\n setHover(next, anchor.x, anchor.y, true);\n dom.live.textContent = describeItem(scene, next);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!scene) return;\n const current = hover?.hover ?? null;\n const keys: Record<string, \"next\" | \"prev\" | \"up\" | \"down\"> = {\n ArrowRight: \"next\",\n ArrowLeft: \"prev\",\n ArrowUp: \"up\",\n ArrowDown: \"down\",\n };\n const direction = keys[event.key];\n if (direction) {\n event.preventDefault();\n focusItem(stepHover(scene, current, direction));\n return;\n }\n switch (event.key) {\n case \"Home\":\n case \"End\": {\n const items = scene.items;\n if (!items.length) return;\n event.preventDefault();\n const it = event.key === \"Home\" ? items[0] : items[items.length - 1];\n focusItem(\n scene.type === \"radar\"\n ? { index: it.index, indicator: current?.indicator ?? 0 }\n : { index: it.index },\n );\n break;\n }\n case \"Enter\":\n case \" \": {\n if (!current) return;\n const e = hoverEvent(scene, current);\n if (!e) return;\n event.preventDefault();\n emit(\"click\", e);\n activate(current);\n break;\n }\n case \"Backspace\": {\n if (options.type !== \"sunburst\" || options.drill === false) return;\n const path = runtime.drillPath();\n if (!path.length) return;\n event.preventDefault();\n drill(path.slice(0, -1));\n break;\n }\n case \"Escape\":\n if (hover) {\n event.preventDefault();\n setHover(null, 0, 0, false);\n }\n break;\n default:\n break;\n }\n };\n\n const onFocus = () => {\n let visible: boolean;\n try {\n visible = dom.stage.matches(\":focus-visible\");\n } catch {\n visible = true;\n }\n // inset, like an outline drawn inside the stage edge: the drawing keeps a\n // padding, so the ring never covers labels or leader lines\n if (visible)\n dom.stage.style.boxShadow =\n \"inset 0 0 0 2px var(--primary-color, #4f46e5)\";\n };\n\n const onBlur = () => {\n dom.stage.style.boxShadow = \"\";\n if (hover?.keyboard) setHover(null, 0, 0, false);\n };\n\n const stage = dom.stage;\n stage.addEventListener(\"pointermove\", onPointerMove);\n stage.addEventListener(\"pointerdown\", onPointerDown);\n stage.addEventListener(\"pointerup\", onPointerUp);\n stage.addEventListener(\"pointercancel\", onPointerCancel);\n stage.addEventListener(\"pointerleave\", onPointerLeave);\n stage.addEventListener(\"keydown\", onKeyDown);\n stage.addEventListener(\"focus\", onFocus);\n stage.addEventListener(\"blur\", onBlur);\n\n const resizeObserver =\n typeof ResizeObserver === \"function\"\n ? new ResizeObserver(() => schedule())\n : null;\n resizeObserver?.observe(dom.stage);\n\n const refreshTheme = () => {\n if (destroyed) return;\n theme = readTheme(dom.root, options.palette);\n renderLegend();\n tipKey = \"\";\n schedule();\n };\n const unwatchTheme = watchTheme(refreshTheme);\n\n renderLegend();\n updateAccessibility();\n render();\n\n return {\n setOptions(next) {\n if (destroyed) return;\n const previous = options;\n options = next;\n runtime.setOptions(next);\n if ((next.palette ?? []).join() !== (previous.palette ?? []).join())\n theme = readTheme(dom.root, next.palette);\n if (next.type !== previous.type && hover) setHover(null, 0, 0, false);\n renderLegend();\n updateAccessibility();\n tipKey = \"\";\n schedule();\n },\n resize() {\n if (destroyed) return;\n cancelFrame();\n render();\n },\n refreshTheme,\n toggle,\n getHidden: () => runtime.hiddenIndexes(),\n drill,\n getDrillPath: () => runtime.drillPath(),\n on(type, listener) {\n listeners[type].add(listener);\n return () => {\n listeners[type].delete(listener);\n };\n },\n destroy() {\n if (destroyed) return;\n destroyed = true;\n cancelFrame();\n stage.removeEventListener(\"pointermove\", onPointerMove);\n stage.removeEventListener(\"pointerdown\", onPointerDown);\n stage.removeEventListener(\"pointerup\", onPointerUp);\n stage.removeEventListener(\"pointercancel\", onPointerCancel);\n stage.removeEventListener(\"pointerleave\", onPointerLeave);\n stage.removeEventListener(\"keydown\", onKeyDown);\n stage.removeEventListener(\"focus\", onFocus);\n stage.removeEventListener(\"blur\", onBlur);\n resizeObserver?.disconnect();\n unwatchTheme();\n listeners.hover.clear();\n listeners.click.clear();\n listeners.toggle.clear();\n listeners.drill.clear();\n dom.root.remove();\n },\n };\n};\n"],"mappings":";;;;;;;;AAkCA,IAAMC,KAAW,GAEbC,KAAM,GAcGC,KACX,GACA,MACuB;CACvB,IAAMC,IAAMC,EAAU,eAChBC,IAAMF,EAAI,aACVG,IAAMC,EAAeH,CAAS;CAGpC,AAFAE,EAAI,KAAK,UAAU,IAAI,qBAAqB,GAC5C,EAAI,WAAW,MAAM,UAAU,QAC/B,EAAI,MAAM,MAAM,UAAU;CAC1B,IAAME,IAASF,EAAI,YACfG,IAAuC;CAC3C,IAAI;EACF,IAAMD,EAAO,WAAW,IAAI;CAC9B,QAAQ;EACN,IAAM;CACR;CAEA,IAAME,IAAUC,GAAmBC,CAAO,GACtCC,IAAUD,GACVE,IAAoBC,EAAUT,EAAI,MAAMO,EAAQ,OAAO,GACvDG,IAA2B,MAC3BC,IAA2B,MAC3BC,IAAS,IACTC,IAAY,IACZC,IAAyB,MACzBC,IAAiB,IACjBC,IAMO,MAELC,IAIF;EACF,uBAAO,IAAI,IAAI;EACf,uBAAO,IAAI,IAAI;EACf,wBAAQ,IAAI,IAAI;EAChB,uBAAO,IAAI,IAAI;CACjB,GACMC,KACJ,GACA,MACG;EACH,KAAK,IAAMC,KAAY,CAAC,GAAGF,EAAUG,EAAK,GAAG,EAASC,CAAK;CAC7D,GAGMC,IAAczB,EAAI,cAAc,KAAK;CAa3C,AAZA,EAAY,KAAK,uBAAuB,EAAEF,MAC1CF,EAAa6B,GAAa;EACxB,UAAU;EACV,OAAO;EACP,QAAQ;EACR,UAAU;EACV,MAAM;EACN,UAAU;EACV,YAAY;CACd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,GAEA;EACL,WAAW,GAAM;GACf,IAAIjB,GAAW;GACf,IAAMsG,IAAW5G;GASjB,AARA,IAAUmD,GACVtD,EAAQ,WAAWsD,CAAI,IAClBA,EAAK,WAAW,CAAC,EAAA,CAAG,KAAK,OAAOyD,EAAS,WAAW,CAAC,EAAA,CAAG,KAAK,MAChE,IAAQ1G,EAAUT,EAAI,MAAM0D,EAAK,OAAO,IACtCA,EAAK,SAASyD,EAAS,QAAQxG,KAAO4C,EAAS,MAAM,GAAG,GAAG,EAAK,GACpEe,EAAa,GACbU,EAAoB,GACpB,IAAS,IACTnD,EAAS;EACX;EACA,SAAS;GACP,AAAIhB,MACJe,EAAY,GACZE,EAAO;EACT;EACA;EACA;EACA,iBAAiB1B,EAAQ,cAAc;EACvC;EACA,oBAAoBA,EAAQ,UAAU;EACtC,GAAG,GAAM,GAAU;GAEjB,OADAa,EAAUG,EAAK,CAAC,IAAID,CAAQ,SACf;IACX,EAAUC,EAAK,CAAC,OAAOD,CAAQ;GACjC;EACF;EACA,UAAU;GACR,AAAIN,MACJ,IAAY,IACZe,EAAY,GACZkF,EAAM,oBAAoB,eAAejB,CAAa,GACtDiB,EAAM,oBAAoB,eAAehB,CAAa,GACtDgB,EAAM,oBAAoB,aAAaf,CAAW,GAClDe,EAAM,oBAAoB,iBAAiBb,CAAe,GAC1Da,EAAM,oBAAoB,gBAAgBZ,CAAc,GACxDY,EAAM,oBAAoB,WAAWT,CAAS,GAC9CS,EAAM,oBAAoB,SAASH,EAAO,GAC1CG,EAAM,oBAAoB,QAAQD,EAAM,GACxCE,IAAgB,WAAW,GAC3BE,GAAa,GACbhG,EAAU,MAAM,MAAM,GACtBA,EAAU,MAAM,MAAM,GACtBA,EAAU,OAAO,MAAM,GACvBA,EAAU,MAAM,MAAM,GACtBjB,EAAI,KAAK,OAAO;EAClB;CACF;AACF"}
1
+ {"version":3,"file":"chart.js","names":["assign","TAP_SLOP","uid","createShapeChart","doc","container","win","dom","createChartDom","canvas","ctx","runtime","createShapeRuntime","initial","options","vector","backend","rendererToken","recorder","VectorRecorder","text","textCtx","theme","readTheme","scene","hover","tipKey","destroyed","frameId","frameIsTimeout","press","listeners","emit","listener","type","event","description","fontSet","measure","f","estimateText","cancelFrame","schedule","render","tooltipOptions","tooltipNode","custom","content","tooltipContent","fragment","header","swatch","row","el","v","updateTooltip","tip","hoverEvent","key","force","anchor","hoverAnchor","shown","hovered","placeShapeTooltip","size","stage","bounds","setHover","changed","sameHover","next","keyboard","width","height","dpr","pw","ph","gpu","target","target2d","layer","frame","now","it","drawShapeScene","describeScene","renderLegend","entries","shapeLegend","config","legendConfig","focused","bottom","entry","item","toggle","updateAccessibility","describeChart","index","drill","path","activate","hit","local","rect","hitAt","hitTestShapes","x","y","onPointerMove","onPointerDown","onPointerUp","p","onPointerCancel","onPointerLeave","focusItem","describeItem","onKeyDown","current","direction","stepHover","items","e","onFocus","visible","onBlur","resizeObserver","refreshTheme","unwatchTheme","watchTheme","applyBackend","t","initRenderer","token","createVectorRenderer","createDataCanvas","kind","exclude","unfollowDefault","followDefaultRenderer","previous"],"sources":["../../../../../charts/src/engine/shapes/chart.ts"],"sourcesContent":["// createShapeChart: DOM host of the shape charts. The shapes are drawn on\n// the GPU (WebGPU, then WebGL2 / WebGL) with the text on a 2D canvas above\n// them, or on one Canvas2D layer; plus the house legend / tooltip / live\n// region of createChartDom, pointer + keyboard interaction, resize and theme\n// watching.\n\nimport { createChartDom, createDataCanvas, styleElement, swatch } from \"../dom\";\nimport {\n createVectorRenderer,\n type VectorRenderer,\n} from \"../renderers/vector-gpu\";\nimport { VectorRecorder } from \"../renderers/vector\";\nimport { followDefaultRenderer } from \"../renderers/follow\";\nimport type { ChartRendererKind } from \"../types\";\nimport { readTheme, watchTheme, type ChartTheme } from \"../theme\";\nimport { placeTooltipElement } from \"../tooltip\";\nimport { drawShapeScene } from \"./draw\";\nimport { hitTestShapes, hoverAnchor, stepHover } from \"./hit\";\nimport {\n describeChart,\n describeItem,\n describeScene,\n hoverEvent,\n legendConfig,\n placeShapeTooltip,\n sameHover,\n shapeLegend,\n tooltipContent,\n} from \"./layout\";\nimport { createShapeRuntime, now } from \"./runtime\";\nimport {\n estimateText,\n type MeasureText,\n type ShapeHover,\n type ShapeScene,\n} from \"./scene\";\nimport type {\n ShapeChartEventMap,\n ShapeChartInstance,\n ShapeChartOptions,\n ShapeHoverEvent,\n} from \"./types\";\n\n/** Pointer travel (px) under which a press counts as a click / tap */\nconst TAP_SLOP = 6;\n\nlet uid = 0;\n\ninterface HoverState {\n hover: ShapeHover;\n x: number;\n y: number;\n keyboard: boolean;\n}\n\n/**\n * Creates a pie / donut, radar, gauge, funnel, treemap, sankey, sunburst,\n * radial bar, calendar heatmap, bullet or chord chart in `container` (drawn\n * on the GPU when available, else with Canvas2D; themed by the Minerva CSS\n * variables).\n */\nexport const createShapeChart = (\n container: HTMLElement,\n initial: ShapeChartOptions,\n): ShapeChartInstance => {\n const doc = container.ownerDocument;\n const win = doc.defaultView;\n const dom = createChartDom(container);\n dom.root.classList.add(\"minerva-shape-chart\");\n dom.foreground.style.display = \"none\";\n dom.hover.style.display = \"none\";\n const canvas = dom.background;\n let ctx: CanvasRenderingContext2D | null = null;\n try {\n ctx = canvas.getContext(\"2d\");\n } catch {\n ctx = null;\n }\n\n const runtime = createShapeRuntime(initial);\n let options = initial;\n /** GPU backend of the shapes; null while starting and with Canvas2D */\n let vector: VectorRenderer | null = null;\n /** Backend in use, once chosen */\n let backend: ChartRendererKind | null = null;\n let rendererToken = 0;\n const recorder = new VectorRecorder();\n let text: CanvasRenderingContext2D | null | undefined;\n /** 2D context of the text layer drawn above the GPU canvas */\n const textCtx = () => {\n if (text === undefined) {\n try {\n text = dom.foreground.getContext(\"2d\");\n } catch {\n text = null;\n }\n }\n return text;\n };\n let theme: ChartTheme = readTheme(dom.root, options.palette);\n let scene: ShapeScene | null = null;\n let hover: HoverState | null = null;\n let tipKey = \"\";\n let destroyed = false;\n let frameId: number | null = null;\n let frameIsTimeout = false;\n let press: {\n x: number;\n y: number;\n id: number;\n touch: boolean;\n moved: boolean;\n } | null = null;\n\n const listeners: {\n [K in keyof ShapeChartEventMap]: Set<\n (event: ShapeChartEventMap[K]) => void\n >;\n } = {\n hover: new Set(),\n click: new Set(),\n toggle: new Set(),\n drill: new Set(),\n };\n const emit = <K extends keyof ShapeChartEventMap>(\n type: K,\n event: ShapeChartEventMap[K],\n ) => {\n for (const listener of [...listeners[type]]) listener(event);\n };\n\n // screen-reader summary of the data\n const description = doc.createElement(\"div\");\n description.id = `minerva-shape-chart-${++uid}`;\n styleElement(description, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n overflow: \"hidden\",\n clip: \"rect(0 0 0 0)\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n });\n dom.stage.appendChild(description);\n dom.stage.setAttribute(\"aria-describedby\", description.id);\n dom.stage.tabIndex = 0;\n\n let fontSet = \"\";\n const measure: MeasureText = (text, f) => {\n if (!ctx) return estimateText(text, f);\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n // ------------------------------------------------------------- frames\n\n const cancelFrame = () => {\n if (frameId === null) return;\n if (frameIsTimeout) clearTimeout(frameId);\n else win?.cancelAnimationFrame?.(frameId);\n frameId = null;\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (win && typeof win.requestAnimationFrame === \"function\") {\n frameIsTimeout = false;\n frameId = win.requestAnimationFrame(() => render());\n } else {\n frameIsTimeout = true;\n frameId = setTimeout(() => render(), 16) as unknown as number;\n }\n };\n\n const tooltipOptions = () =>\n options.tooltip === false\n ? null\n : typeof options.tooltip === \"object\"\n ? options.tooltip\n : {};\n\n const tooltipNode = (event: ShapeHoverEvent): Node | string | null => {\n const custom = tooltipOptions()?.render;\n if (custom) return custom(event);\n if (!scene || !hover) return null;\n const content = tooltipContent(scene, hover.hover);\n if (!content) return null;\n const fragment = doc.createDocumentFragment();\n const header = doc.createElement(\"div\");\n styleElement(header, {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"6px\",\n fontWeight: \"600\",\n marginBottom: \"4px\",\n color: \"var(--text-color, #1f2937)\",\n // long titles (full names of truncated labels) wrap\n whiteSpace: \"normal\",\n maxWidth: \"260px\",\n overflowWrap: \"anywhere\",\n });\n if (content.color) header.appendChild(swatch(doc, content.color, \"dot\"));\n header.appendChild(doc.createTextNode(content.title));\n fragment.append(header);\n for (const row of content.rows) {\n const el = doc.createElement(\"div\");\n styleElement(el, { display: \"flex\", alignItems: \"center\", gap: \"8px\" });\n if (row.color) el.appendChild(swatch(doc, row.color, \"dot\"));\n const n = doc.createElement(\"span\");\n styleElement(n, {\n flex: \"1 1 auto\",\n color: row.strong\n ? \"var(--text-color, #1f2937)\"\n : \"var(--text-secondary-color, #6b7280)\",\n fontWeight: row.strong ? \"600\" : \"400\",\n });\n n.textContent = row.name;\n const v = doc.createElement(\"span\");\n styleElement(v, {\n fontWeight: \"600\",\n fontVariantNumeric: \"tabular-nums\",\n marginLeft: \"12px\",\n });\n v.textContent = row.value;\n el.append(n, v);\n fragment.append(el);\n }\n return fragment;\n };\n\n /** Fills (when the hovered item changed) and places the tooltip */\n const updateTooltip = (force = false) => {\n const tip = dom.tooltip;\n const event = scene && hover ? hoverEvent(scene, hover.hover) : null;\n if (!event || !scene || !hover || !tooltipOptions() || press?.moved) {\n tip.style.display = \"none\";\n tipKey = \"\";\n return;\n }\n const key = `${event.index}:${event.indicator ?? \"\"}`;\n if (force || key !== tipKey) {\n tipKey = key;\n const content = tooltipNode(event);\n if (content === null || content === \"\") {\n tip.replaceChildren();\n tipKey = \"\";\n tip.style.display = \"none\";\n return;\n }\n if (typeof content === \"string\") {\n tip.textContent = content;\n tip.style.whiteSpace = \"pre\";\n } else {\n tip.replaceChildren(content);\n tip.style.whiteSpace = \"nowrap\";\n }\n } else if (!tip.firstChild) {\n return;\n }\n tip.style.display = \"block\";\n const anchor = hover.keyboard\n ? (hoverAnchor(scene, hover.hover) ?? hover)\n : hover;\n const shown = scene;\n const hovered = hover.hover;\n placeTooltipElement(\n tip,\n dom.stage,\n (size, stage, bounds) =>\n placeShapeTooltip(\n shown,\n hovered,\n anchor,\n size.width,\n size.height,\n stage.width,\n stage.height,\n bounds,\n ),\n { animate: true },\n );\n };\n\n const setHover = (\n next: ShapeHover | null,\n x: number,\n y: number,\n keyboard: boolean,\n ) => {\n const changed = !sameHover(hover?.hover ?? null, next);\n hover = next ? { hover: next, x, y, keyboard } : null;\n dom.stage.style.cursor = next && !keyboard ? \"pointer\" : \"\";\n updateTooltip();\n if (!changed) return;\n schedule();\n emit(\"hover\", scene && next ? hoverEvent(scene, next) : null);\n };\n\n function render() {\n frameId = null;\n if (destroyed) return;\n const width = dom.stage.clientWidth;\n const height = dom.stage.clientHeight;\n if (!(width > 0 && height > 0)) return;\n const dpr = win?.devicePixelRatio || 1;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n // the GPU draws the shapes, the foreground canvas the text above them\n const gpu = vector;\n const target = gpu ? dom.foreground : canvas;\n const target2d = gpu ? textCtx() : ctx;\n for (const layer of gpu ? [dom.foreground, gpu.canvas] : [canvas]) {\n if (layer.width !== pw) layer.width = pw;\n if (layer.height !== ph) layer.height = ph;\n layer.style.width = `${width}px`;\n layer.style.height = `${height}px`;\n }\n fontSet = \"\";\n const frame = runtime.frame(now(), { theme, width, height, measure });\n scene = frame.scene;\n if (hover && !scene.items.some((it) => it.index === hover?.hover.index)) {\n hover = null;\n dom.stage.style.cursor = \"\";\n emit(\"hover\", null);\n }\n if (gpu) {\n if (target2d) {\n target2d.setTransform(1, 0, 0, 1, 0, 0);\n target2d.clearRect(0, 0, target.width, target.height);\n }\n recorder.reset(target2d, dpr);\n drawShapeScene(\n recorder as unknown as CanvasRenderingContext2D,\n scene,\n hover?.hover ?? null,\n );\n gpu.render(recorder.finish());\n } else if (ctx) {\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, pw, ph);\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawShapeScene(ctx, scene, hover?.hover ?? null);\n fontSet = \"\";\n }\n updateTooltip();\n if (!frame.animating) {\n const text = describeScene(scene);\n if (description.textContent !== text) description.textContent = text;\n } else schedule();\n }\n\n // ------------------------------------------------------------- legend\n\n const renderLegend = () => {\n const entries = shapeLegend(options, theme, runtime.hidden);\n const config = legendConfig(options);\n const focused = [...dom.legend.children].indexOf(\n doc.activeElement as Element,\n );\n dom.legend.replaceChildren();\n dom.legend.style.display = entries ? \"flex\" : \"none\";\n if (!entries) return;\n const bottom = config.position === \"bottom\";\n dom.legend.style.order = bottom ? \"1\" : \"0\";\n dom.legend.style.padding = bottom ? \"8px 4px 0\" : \"0 4px 8px\";\n dom.legend.style.justifyContent = \"center\";\n for (const entry of entries) {\n const item = doc.createElement(config.toggle ? \"button\" : \"span\");\n if (item instanceof HTMLButtonElement) {\n item.type = \"button\";\n item.setAttribute(\"aria-pressed\", String(!entry.hidden));\n item.addEventListener(\"click\", () => toggle(entry.index));\n }\n styleElement(item, {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"6px\",\n padding: \"2px 4px\",\n margin: \"0\",\n border: \"0\",\n borderRadius: \"4px\",\n background: \"none\",\n font: \"inherit\",\n color: \"var(--text-secondary-color, #6b7280)\",\n cursor: config.toggle ? \"pointer\" : \"default\",\n opacity: entry.hidden ? \"0.45\" : \"1\",\n textDecoration: entry.hidden ? \"line-through\" : \"none\",\n transition: \"opacity 120ms ease-out\",\n });\n item.append(\n swatch(doc, entry.color, \"dot\"),\n doc.createTextNode(entry.name),\n );\n dom.legend.appendChild(item);\n }\n if (focused >= 0)\n (dom.legend.children[focused] as HTMLElement | undefined)?.focus();\n };\n\n const updateAccessibility = () => {\n dom.stage.setAttribute(\n \"aria-label\",\n options.ariaLabel ?? describeChart(options),\n );\n };\n\n function toggle(index: number) {\n if (destroyed) return;\n const event = runtime.toggle(index);\n if (!event) return;\n if (!options.hidden) {\n renderLegend();\n tipKey = \"\";\n schedule();\n }\n emit(\"toggle\", event);\n }\n\n function drill(path: readonly string[]) {\n if (destroyed) return;\n const event = runtime.drill(path);\n if (!event) return;\n if (options.type === \"sunburst\" && !options.drillPath) {\n tipKey = \"\";\n schedule();\n }\n emit(\"drill\", event);\n }\n\n /** Sunburst: drills into / out of an activated item */\n const activate = (hit: ShapeHover) => {\n if (options.type !== \"sunburst\" || options.drill === false || !scene)\n return;\n const item = scene.items.find((it) => it.index === hit.index);\n if (item?.drill) drill(item.drill);\n };\n\n // -------------------------------------------------------- interaction\n\n const local = (event: { clientX: number; clientY: number }) => {\n const rect = dom.stage.getBoundingClientRect();\n return { x: event.clientX - rect.left, y: event.clientY - rect.top };\n };\n\n const hitAt = (x: number, y: number) =>\n scene ? hitTestShapes(scene, x, y, hover?.hover ?? null) : null;\n\n const onPointerMove = (event: PointerEvent) => {\n const { x, y } = local(event);\n if (press && press.id === event.pointerId) {\n if (Math.hypot(x - press.x, y - press.y) > TAP_SLOP) press.moved = true;\n if (press.touch) return;\n } else if (event.pointerType === \"touch\") return;\n setHover(hitAt(x, y), x, y, false);\n };\n\n const onPointerDown = (event: PointerEvent) => {\n const { x, y } = local(event);\n press = {\n x,\n y,\n id: event.pointerId,\n touch: event.pointerType === \"touch\",\n moved: false,\n };\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const p = press;\n press = null;\n if (!p || p.id !== event.pointerId || p.moved) {\n updateTooltip();\n return;\n }\n const { x, y } = local(event);\n const hit = hitAt(x, y);\n // a tap shows the tooltip (there is no hover on touch screens)\n setHover(hit, x, y, false);\n if (hit && scene) {\n const e = hoverEvent(scene, hit);\n if (e) emit(\"click\", e);\n activate(hit);\n }\n };\n\n const onPointerCancel = () => {\n press = null;\n updateTooltip();\n };\n\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === \"touch\") return;\n press = null;\n if (hover && !hover.keyboard) setHover(null, 0, 0, false);\n };\n\n const focusItem = (next: ShapeHover | null) => {\n if (!scene || !next) return;\n const anchor = hoverAnchor(scene, next) ?? { x: 0, y: 0 };\n setHover(next, anchor.x, anchor.y, true);\n dom.live.textContent = describeItem(scene, next);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!scene) return;\n const current = hover?.hover ?? null;\n const keys: Record<string, \"next\" | \"prev\" | \"up\" | \"down\"> = {\n ArrowRight: \"next\",\n ArrowLeft: \"prev\",\n ArrowUp: \"up\",\n ArrowDown: \"down\",\n };\n const direction = keys[event.key];\n if (direction) {\n event.preventDefault();\n focusItem(stepHover(scene, current, direction));\n return;\n }\n switch (event.key) {\n case \"Home\":\n case \"End\": {\n const items = scene.items;\n if (!items.length) return;\n event.preventDefault();\n const it = event.key === \"Home\" ? items[0] : items[items.length - 1];\n focusItem(\n scene.type === \"radar\"\n ? { index: it.index, indicator: current?.indicator ?? 0 }\n : { index: it.index },\n );\n break;\n }\n case \"Enter\":\n case \" \": {\n if (!current) return;\n const e = hoverEvent(scene, current);\n if (!e) return;\n event.preventDefault();\n emit(\"click\", e);\n activate(current);\n break;\n }\n case \"Backspace\": {\n if (options.type !== \"sunburst\" || options.drill === false) return;\n const path = runtime.drillPath();\n if (!path.length) return;\n event.preventDefault();\n drill(path.slice(0, -1));\n break;\n }\n case \"Escape\":\n if (hover) {\n event.preventDefault();\n setHover(null, 0, 0, false);\n }\n break;\n default:\n break;\n }\n };\n\n const onFocus = () => {\n let visible: boolean;\n try {\n visible = dom.stage.matches(\":focus-visible\");\n } catch {\n visible = true;\n }\n // inset, like an outline drawn inside the stage edge: the drawing keeps a\n // padding, so the ring never covers labels or leader lines\n if (visible)\n dom.stage.style.boxShadow =\n \"inset 0 0 0 2px var(--primary-color, #4f46e5)\";\n };\n\n const onBlur = () => {\n dom.stage.style.boxShadow = \"\";\n if (hover?.keyboard) setHover(null, 0, 0, false);\n };\n\n const stage = dom.stage;\n stage.addEventListener(\"pointermove\", onPointerMove);\n stage.addEventListener(\"pointerdown\", onPointerDown);\n stage.addEventListener(\"pointerup\", onPointerUp);\n stage.addEventListener(\"pointercancel\", onPointerCancel);\n stage.addEventListener(\"pointerleave\", onPointerLeave);\n stage.addEventListener(\"keydown\", onKeyDown);\n stage.addEventListener(\"focus\", onFocus);\n stage.addEventListener(\"blur\", onBlur);\n\n const resizeObserver =\n typeof ResizeObserver === \"function\"\n ? new ResizeObserver(() => schedule())\n : null;\n resizeObserver?.observe(dom.stage);\n\n const refreshTheme = () => {\n if (destroyed) return;\n theme = readTheme(dom.root, options.palette);\n renderLegend();\n tipKey = \"\";\n schedule();\n };\n const unwatchTheme = watchTheme(refreshTheme);\n\n // ------------------------------------------------------------- renderer\n\n const applyBackend = (next: VectorRenderer | null) => {\n if (vector) {\n vector.destroy();\n vector.canvas.remove();\n }\n vector = next;\n backend = next?.kind ?? \"canvas2d\";\n dom.root.dataset.renderer = backend;\n if (next) dom.stage.insertBefore(next.canvas, dom.foreground);\n canvas.style.display = next ? \"none\" : \"\";\n dom.foreground.style.display = next ? \"\" : \"none\";\n if (!next) {\n const t = textCtx();\n t?.setTransform(1, 0, 0, 1, 0, 0);\n t?.clearRect(0, 0, dom.foreground.width, dom.foreground.height);\n }\n schedule();\n };\n\n /**\n * Starts the GPU backend (WebGPU, then WebGL2 / WebGL, like the other\n * charts); the first frames are drawn with Canvas2D meanwhile\n */\n const initRenderer = async (exclude: Set<ChartRendererKind> = new Set()) => {\n const token = ++rendererToken;\n const next = await createVectorRenderer(\n options.renderer,\n () => createDataCanvas(doc),\n (kind) => {\n if (destroyed || vector?.kind !== kind) return;\n void initRenderer(new Set([...exclude, kind]));\n },\n exclude,\n );\n if (destroyed || token !== rendererToken) {\n next?.destroy();\n return;\n }\n applyBackend(next);\n };\n void initRenderer();\n const unfollowDefault = followDefaultRenderer(\n () => options.renderer,\n () => void initRenderer(),\n );\n\n renderLegend();\n updateAccessibility();\n render();\n\n return {\n setOptions(next) {\n if (destroyed) return;\n const previous = options;\n options = next;\n runtime.setOptions(next);\n if ((next.palette ?? []).join() !== (previous.palette ?? []).join())\n theme = readTheme(dom.root, next.palette);\n if (next.type !== previous.type && hover) setHover(null, 0, 0, false);\n if ((next.renderer ?? \"auto\") !== (previous.renderer ?? \"auto\"))\n void initRenderer();\n renderLegend();\n updateAccessibility();\n tipKey = \"\";\n schedule();\n },\n resize() {\n if (destroyed) return;\n cancelFrame();\n render();\n },\n refreshTheme,\n toggle,\n getHidden: () => runtime.hiddenIndexes(),\n drill,\n getDrillPath: () => runtime.drillPath(),\n getRenderer: () => backend,\n on(type, listener) {\n listeners[type].add(listener);\n return () => {\n listeners[type].delete(listener);\n };\n },\n destroy() {\n if (destroyed) return;\n destroyed = true;\n cancelFrame();\n stage.removeEventListener(\"pointermove\", onPointerMove);\n stage.removeEventListener(\"pointerdown\", onPointerDown);\n stage.removeEventListener(\"pointerup\", onPointerUp);\n stage.removeEventListener(\"pointercancel\", onPointerCancel);\n stage.removeEventListener(\"pointerleave\", onPointerLeave);\n stage.removeEventListener(\"keydown\", onKeyDown);\n stage.removeEventListener(\"focus\", onFocus);\n stage.removeEventListener(\"blur\", onBlur);\n resizeObserver?.disconnect();\n unwatchTheme();\n unfollowDefault();\n rendererToken++;\n vector?.destroy();\n vector = null;\n listeners.hover.clear();\n listeners.click.clear();\n listeners.toggle.clear();\n listeners.drill.clear();\n dom.root.remove();\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;AA4CA,IAAMC,KAAW,GAEbC,KAAM,GAeGC,KACX,GACA,MACuB;CACvB,IAAMC,IAAMC,EAAU,eAChBC,IAAMF,EAAI,aACVG,IAAMC,EAAeH,CAAS;CAGpC,AAFAE,EAAI,KAAK,UAAU,IAAI,qBAAqB,GAC5C,EAAI,WAAW,MAAM,UAAU,QAC/B,EAAI,MAAM,MAAM,UAAU;CAC1B,IAAME,IAASF,EAAI,YACfG,IAAuC;CAC3C,IAAI;EACF,IAAMD,EAAO,WAAW,IAAI;CAC9B,QAAQ;EACN,IAAM;CACR;CAEA,IAAME,IA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E,EAAS,YAAY,WACtDR,EAAkB,GACpB9C,EAAa,GACbU,EAAoB,GACpB,IAAS,IACTvD,EAAS;EACX;EACA,SAAS;GACP,AAAIf,MACJc,EAAY,GACZE,EAAO;EACT;EACA;EACA;EACA,iBAAiBhC,EAAQ,cAAc;EACvC;EACA,oBAAoBA,EAAQ,UAAU;EACtC,mBAAmBK;EACnB,GAAG,GAAM,GAAU;GAEjB,OADAe,EAAUG,EAAK,CAAC,IAAID,CAAQ,SACf;IACX,EAAUC,EAAK,CAAC,OAAOD,CAAQ;GACjC;EACF;EACA,UAAU;GACR,AAAIN,MACJ,IAAY,IACZc,EAAY,GACZyB,EAAM,oBAAoB,eAAe4C,EAAa,GACtD5C,EAAM,oBAAoB,eAAe6C,EAAa,GACtD7C,EAAM,oBAAoB,aAAa8C,EAAW,GAClD9C,EAAM,oBAAoB,iBAAiBgD,EAAe,GAC1DhD,EAAM,oBAAoB,gBAAgBiD,EAAc,GACxDjD,EAAM,oBAAoB,WAAWoD,EAAS,GAC9CpD,EAAM,oBAAoB,SAAS0D,EAAO,GAC1C1D,EAAM,oBAAoB,QAAQ4D,EAAM,GACxCC,IAAgB,WAAW,GAC3BE,GAAa,GACbU,GAAgB,GAChB,KACA5H,GAAQ,QAAQ,GAChB,IAAS,MACTgB,EAAU,MAAM,MAAM,GACtBA,EAAU,MAAM,MAAM,GACtBA,EAAU,OAAO,MAAM,GACvBA,EAAU,MAAM,MAAM,GACtBxB,EAAI,KAAK,OAAO;EAClB;CACF;AACF"}
@@ -1,2 +1,2 @@
1
- const e=require("../color.cjs"),t=require("../overlay.cjs"),n=require("./scene.cjs");var r=`rgba(15, 23, 42, 0.18)`,i=`rgba(255, 255, 255, 0.14)`,a=e=>Math.max(0,Math.min(e.pad,e.r1*(e.a1-e.a0)/3)),o=(e,t)=>t>0?Math.asin(Math.min(1,e/t)):Math.PI/2,s=(e,t,r=0,i=0)=>{let s=t.cx+r,c=t.cy+i,{r0:l,r1:u,a0:d,a1:f}=t,p=f-d;if(e.beginPath(),p<=0||u<=l)return;if(p>=n.TAU-1e-6){e.moveTo(s+u,c),e.arc(s,c,u,0,n.TAU),l>0&&(e.moveTo(s+l,c),e.arc(s,c,l,n.TAU,0,!0)),e.closePath();return}let m=a(t)/2,h=(e,t,n)=>{let r=e+t*o(m,n);return[s+n*Math.cos(r),c+n*Math.sin(r)]},g=(e,t)=>[s+t*Math.cos(e),c+t*Math.sin(e)],_=o(m,u),v=Math.max(0,p-2*_),y=l>0?o(m,l):0,b=l>0?p-2*y:0,x=l>0&&b>1e-4,S=u-l,C=Math.max(0,Math.min(t.corner,S/2,u*v/2-.01)),w=x?Math.max(0,Math.min(t.corner,S/2,l*b/2-.01)):0;if(C>.5){let t=h(d,1,u-C);e.moveTo(t[0],t[1]);let n=h(d,1,u),r=g(d+_+C/u,u);e.quadraticCurveTo(n[0],n[1],r[0],r[1]),e.arc(s,c,u,d+_+C/u,f-_-C/u);let i=h(f,-1,u),a=h(f,-1,u-C);e.quadraticCurveTo(i[0],i[1],a[0],a[1])}else{let t=g(d+_,u);e.moveTo(t[0],t[1]),e.arc(s,c,u,d+_,f-_)}if(x){if(w>.5){let t=h(f,-1,l+w);e.lineTo(t[0],t[1]);let n=h(f,-1,l),r=g(f-y-w/l,l);e.quadraticCurveTo(n[0],n[1],r[0],r[1]),e.arc(s,c,l,f-y-w/l,d+y+w/l,!0);let i=h(d,1,l),a=h(d,1,l+w);e.quadraticCurveTo(i[0],i[1],a[0],a[1])}else{let t=g(f-y,l);e.lineTo(t[0],t[1]),e.arc(s,c,l,f-y,d+y,!0)}}else if(m<=0)e.lineTo(s,c);else if(p<Math.PI){let t=m/Math.sin(p/2),n=(d+f)/2;e.lineTo(s+t*Math.cos(n),c+t*Math.sin(n))}else e.lineTo(s+m*Math.cos(f-Math.PI/2),c+m*Math.sin(f-Math.PI/2)),e.lineTo(s+m*Math.cos(d+Math.PI/2),c+m*Math.sin(d+Math.PI/2));e.closePath()},c=(e,t,n,r,i,a)=>{let o=t.length>>1;if(o<2)return;let s=e=>t[(r?o-1-e:e)*2]+i,c=e=>t[(r?o-1-e:e)*2+1]+a;if(n<=0||o<3){e.moveTo(s(0),c(0));for(let t=1;t<o;t++)e.lineTo(s(t),c(t));e.closePath();return}e.moveTo((s(o-1)+s(0))/2,(c(o-1)+c(0))/2);for(let t=0;t<o;t++){let r=(t+1)%o,i=(t+o-1)%o,a=Math.hypot(s(t)-s(i),c(t)-c(i)),l=Math.hypot(s(r)-s(t),c(r)-c(t)),u=Math.min(n,a/2,l/2);u>.01?e.arcTo(s(t),c(t),s(r),c(r),u):e.lineTo(s(t),c(t))}e.closePath()},l=(e,t,n=0,r=0)=>{e.beginPath(),c(e,t.points,t.radius??0,!1,n,r),t.hole&&c(e,t.hole,0,!0,n,r)},u=(e,t,n,r,i,a)=>{let o=Math.max(0,Math.min(a,r/2,i/2));if(e.beginPath(),o<=.01){e.moveTo(t,n),e.lineTo(t+r,n),e.lineTo(t+r,n+i),e.lineTo(t,n+i),e.closePath();return}e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.arcTo(t+r,n,t+r,n+o,o),e.lineTo(t+r,n+i-o),e.arcTo(t+r,n+i,t+r-o,n+i,o),e.lineTo(t+o,n+i),e.arcTo(t,n+i,t,n+i-o,o),e.lineTo(t,n+o),e.arcTo(t,n,t+o,n,o),e.closePath()},d=(e,t)=>{typeof e.setLineDash==`function`&&e.setLineDash(t)},f=(e,t,r,i)=>{e.beginPath(),e.arc(t,r,Math.max(0,i),0,n.TAU)},p=(e,t)=>!!t&&e.hit!==void 0&&(e.hit===t.index||!!e.also?.includes(t.index)),m=(e,t)=>{let n=(t.x0+t.x1)/2;e.beginPath(),e.moveTo(t.x0,t.y0),e.bezierCurveTo(n,t.y0,n,t.y1,t.x1,t.y1)},h=(e,t)=>{if(t.color0===t.color1||typeof e.createLinearGradient!=`function`||Math.abs(t.x1-t.x0)<1)return t.color0;let n=e.createLinearGradient(t.x0,0,t.x1,0);return n.addColorStop(0,t.color0),n.addColorStop(1,t.color1),n},g=e=>Math.abs(e.s0-e.t0)<1e-9&&Math.abs(e.s1-e.t1)<1e-9,_=e=>{let t=(e.s0+e.s1)/2;return[e.cx+e.r*.4*Math.cos(t),e.cy+e.r*.4*Math.sin(t)]},v=(e,t)=>{let{cx:n,cy:r,r:i}=t,a=(e,t=i)=>[n+t*Math.cos(e),r+t*Math.sin(e)];e.beginPath();let o=a(t.s0);if(e.moveTo(o[0],o[1]),t.s1>t.s0&&e.arc(n,r,i,t.s0,t.s1),g(t)){let[n,r]=_(t);e.quadraticCurveTo(n,r,o[0],o[1]),e.closePath();return}if(t.head>0){let o=a(t.t0,i-t.head),s=a((t.t0+t.t1)/2),c=a(t.t1,i-t.head);e.quadraticCurveTo(n,r,o[0],o[1]),e.lineTo(s[0],s[1]),e.lineTo(c[0],c[1])}else{let o=a(t.t0);e.quadraticCurveTo(n,r,o[0],o[1]),t.t1>t.t0&&e.arc(n,r,i,t.t0,t.t1)}e.quadraticCurveTo(n,r,o[0],o[1]),e.closePath()},y=(e,t)=>{if(t.color0===t.color1||typeof e.createLinearGradient!=`function`)return t.color0;let n=(t.s0+t.s1)/2,r=(t.t0+t.t1)/2,i=t.cx+t.r*Math.cos(n),a=t.cy+t.r*Math.sin(n),o=t.cx+t.r*Math.cos(r),s=t.cy+t.r*Math.sin(r);if(Math.hypot(o-i,s-a)<1)return t.color0;let c=e.createLinearGradient(i,a,o,s);return c.addColorStop(0,t.color0),c.addColorStop(1,t.color1),c},b=(e,t,n)=>{e.save();let a=t.enter,o=a?Math.max(0,Math.min(1,a.alpha)):1;a&&a.scale!==1&&(e.translate(a.cx,a.cy),e.scale(a.scale,a.scale),e.translate(-a.cx,-a.cy)),e.lineJoin=`round`,e.lineCap=`round`;for(let a of t.nodes){let c=a.hit!==void 0,g=p(a,n),_=g&&a.hit===n?.index,b=o*(a.alpha??1);if(n&&c&&!g&&(b*=t.dim),b<=.002)continue;e.globalAlpha=b;let x=_&&a.shift?a.shift[0]:0,S=_&&a.shift?a.shift[1]:0;switch(a.kind){case`sector`:s(e,a,x,S),e.fillStyle=a.fill,_?(e.save(),e.shadowColor=r,e.shadowBlur=14,e.shadowOffsetY=4,e.fill(),e.restore()):e.fill();break;case`polygon`:{l(e,a,x,S);let t=g&&a.hoverFill?a.hoverFill:a.fill;t&&(e.fillStyle=t,e.fill(),g&&a.brighten&&(e.fillStyle=i,e.fill())),a.stroke&&(e.strokeStyle=a.stroke,e.lineWidth=g&&a.hoverLineWidth?a.hoverLineWidth:a.lineWidth??1,e.stroke());break}case`rect`:u(e,a.x+x,a.y+S,a.width,a.height,a.radius),e.fillStyle=a.fill,e.fill(),g&&a.brighten&&(e.fillStyle=i,e.fill()),_&&a.hoverStroke&&a.width>3&&a.height>3&&(u(e,a.x+x+.75,a.y+S+.75,a.width-1.5,a.height-1.5,Math.max(0,a.radius-.75)),e.strokeStyle=a.hoverStroke,e.lineWidth=1.5,e.stroke());break;case`arc`:if(a.a1-a.a0<=1e-6||a.width<=0)break;e.beginPath(),e.arc(a.cx+x,a.cy+S,a.r,a.a0,a.a1),e.lineCap=a.cap,e.lineWidth=a.width,e.strokeStyle=a.color,e.stroke(),e.lineCap=`round`;break;case`circle`:{if(!a.fill&&!a.stroke)break;let t=g&&(a.indicator===void 0||a.indicator===n?.indicator),r=t&&a.hoverR?a.hoverR:a.r,i=a.cx+x,o=a.cy+S;t&&a.halo&&(f(e,i,o,r+5),e.fillStyle=a.halo,e.fill()),f(e,i,o,r),a.fill&&(e.fillStyle=a.fill,e.fill()),a.stroke&&(e.strokeStyle=a.stroke,e.lineWidth=a.lineWidth??1,e.stroke());break}case`line`:{let t=a.points;if(t.length<4)break;e.beginPath(),e.moveTo(t[0]+x,t[1]+S);for(let n=2;n<t.length;n+=2)e.lineTo(t[n]+(n===t.length-2?0:x),t[n+1]+(n===t.length-2?0:S));e.strokeStyle=a.color,e.lineWidth=a.width,a.dash&&d(e,a.dash),e.stroke(),a.dash&&d(e,[]);break}case`text`:{let t=a.indicator!==void 0&&n?.indicator===a.indicator;e.font=t&&a.hoverFont?a.hoverFont:a.font,e.textAlign=a.align,e.textBaseline=a.baseline;let r=!!a.rotate,i=a.x+x,o=a.y+S;r&&(e.save(),e.translate(i,o),e.rotate(a.rotate??0),i=0,o=0),a.halo&&(e.strokeStyle=a.halo,e.lineWidth=3,e.strokeText(a.text,i,o)),e.fillStyle=t&&a.hoverColor?a.hoverColor:a.color,e.fillText(a.text,i,o),r&&e.restore();break}case`link`:if(a.width<=0)break;g&&a.activeAlpha!==void 0&&(e.globalAlpha=o*a.activeAlpha),m(e,a),e.lineCap=`butt`,e.lineWidth=Math.max(1,a.width),e.strokeStyle=h(e,a),e.stroke(),e.lineCap=`round`;break;case`ribbon`:g&&a.activeAlpha!==void 0&&(e.globalAlpha=o*a.activeAlpha),v(e,a),e.fillStyle=y(e,a),e.fill(),_&&(e.strokeStyle=a.color0,e.lineWidth=1,e.stroke());break;case`guide`:{let t=n?.indicator;if(t===void 0||!a.ends[t])break;e.globalAlpha=o,e.beginPath(),e.moveTo(a.cx,a.cy),e.lineTo(a.ends[t][0],a.ends[t][1]),e.strokeStyle=a.color,e.lineWidth=1,d(e,[3,3]),e.stroke(),d(e,[]);break}}}e.restore()},x=(n,r,i)=>{n.save(),n.font=t.font(r,12),n.textBaseline=`middle`,n.textAlign=`left`;for(let t of i){let i=t.y+t.height/2;n.globalAlpha=t.hidden?.45:1,n.fillStyle=t.color,f(n,t.x+4.5,i,4.5),n.fill(),n.fillStyle=e.toCss(r.textMuted),n.fillText(t.name,t.x+15,i,Math.max(1,t.width-15)),t.hidden&&n.fillRect(t.x+15,i,t.width-15,1)}n.restore()},S=(n,i,a)=>{let{padding:o,lineHeight:s}=a;n.save(),n.globalAlpha=1,n.save(),n.shadowColor=r,n.shadowBlur=16,n.shadowOffsetY=6,u(n,a.x,a.y,a.width,a.height,8),n.fillStyle=e.toCss(i.background),n.fill(),n.restore(),u(n,a.x+.5,a.y+.5,a.width-1,a.height-1,8),n.strokeStyle=e.toCss(i.axis),n.lineWidth=1,n.stroke(),n.textBaseline=`middle`;let c=a.y+o+s/2,l=a.x+o+2,d=a.x+a.width-o-2;if(a.text){n.font=t.font(i,12),n.fillStyle=e.toCss(i.text),n.textAlign=`left`;for(let e of a.text)n.fillText(e,l,c),c+=s}else if(a.content){let{content:r}=a,o=l;r.color&&(n.fillStyle=r.color,f(n,o+4,c,4),n.fill(),o+=14),n.font=t.font(i,12,600),n.fillStyle=e.toCss(i.text),n.textAlign=`left`;for(let e of a.titleLines??[r.title])n.fillText(e,o,c),c+=s;for(let a of r.rows)o=l,a.color&&(n.fillStyle=a.color,f(n,o+4,c,4),n.fill(),o+=14),n.font=t.font(i,12,a.strong?600:400),n.textAlign=`left`,n.fillStyle=e.toCss(a.strong?i.text:i.textMuted),n.fillText(a.name,o,c),n.font=t.font(i,12,600),n.textAlign=`right`,n.fillStyle=e.toCss(i.text),n.fillText(a.value,d,c),c+=s}n.restore()};exports.drawShapeLegend=x,exports.drawShapeScene=b,exports.drawShapeTooltip=S,exports.loopControl=_,exports.nodeActive=p,exports.padAngleAt=o,exports.ribbonIsLoop=g,exports.roundRectPath=u,exports.sectorPad=a,exports.sectorPath=s;
1
+ const e=require("../tooltip.cjs"),t=require("../color.cjs"),n=require("../overlay.cjs"),r=require("./scene.cjs");var i=`rgba(15, 23, 42, 0.18)`,a=`rgba(255, 255, 255, 0.14)`,o=e=>Math.max(0,Math.min(e.pad,e.r1*(e.a1-e.a0)/3)),s=(e,t)=>t>0?Math.asin(Math.min(1,e/t)):Math.PI/2,c=(e,t,n=0,i=0)=>{let a=t.cx+n,c=t.cy+i,{r0:l,r1:u,a0:d,a1:f}=t,p=f-d;if(e.beginPath(),p<=0||u<=l)return;if(p>=r.TAU-1e-6){e.moveTo(a+u,c),e.arc(a,c,u,0,r.TAU),l>0&&(e.moveTo(a+l,c),e.arc(a,c,l,r.TAU,0,!0)),e.closePath();return}let m=o(t)/2,h=(e,t,n)=>{let r=e+t*s(m,n);return[a+n*Math.cos(r),c+n*Math.sin(r)]},g=(e,t)=>[a+t*Math.cos(e),c+t*Math.sin(e)],_=s(m,u),v=Math.max(0,p-2*_),y=l>0?s(m,l):0,b=l>0?p-2*y:0,x=l>0&&b>1e-4,S=u-l,C=Math.max(0,Math.min(t.corner,S/2,u*v/2-.01)),w=x?Math.max(0,Math.min(t.corner,S/2,l*b/2-.01)):0;if(C>.5){let t=h(d,1,u-C);e.moveTo(t[0],t[1]);let n=h(d,1,u),r=g(d+_+C/u,u);e.quadraticCurveTo(n[0],n[1],r[0],r[1]),e.arc(a,c,u,d+_+C/u,f-_-C/u);let i=h(f,-1,u),o=h(f,-1,u-C);e.quadraticCurveTo(i[0],i[1],o[0],o[1])}else{let t=g(d+_,u);e.moveTo(t[0],t[1]),e.arc(a,c,u,d+_,f-_)}if(x){if(w>.5){let t=h(f,-1,l+w);e.lineTo(t[0],t[1]);let n=h(f,-1,l),r=g(f-y-w/l,l);e.quadraticCurveTo(n[0],n[1],r[0],r[1]),e.arc(a,c,l,f-y-w/l,d+y+w/l,!0);let i=h(d,1,l),o=h(d,1,l+w);e.quadraticCurveTo(i[0],i[1],o[0],o[1])}else{let t=g(f-y,l);e.lineTo(t[0],t[1]),e.arc(a,c,l,f-y,d+y,!0)}}else if(m<=0)e.lineTo(a,c);else if(p<Math.PI){let t=m/Math.sin(p/2),n=(d+f)/2;e.lineTo(a+t*Math.cos(n),c+t*Math.sin(n))}else e.lineTo(a+m*Math.cos(f-Math.PI/2),c+m*Math.sin(f-Math.PI/2)),e.lineTo(a+m*Math.cos(d+Math.PI/2),c+m*Math.sin(d+Math.PI/2));e.closePath()},l=(e,t,n,r,i,a)=>{let o=t.length>>1;if(o<2)return;let s=e=>t[(r?o-1-e:e)*2]+i,c=e=>t[(r?o-1-e:e)*2+1]+a;if(n<=0||o<3){e.moveTo(s(0),c(0));for(let t=1;t<o;t++)e.lineTo(s(t),c(t));e.closePath();return}e.moveTo((s(o-1)+s(0))/2,(c(o-1)+c(0))/2);for(let t=0;t<o;t++){let r=(t+1)%o,i=(t+o-1)%o,a=Math.hypot(s(t)-s(i),c(t)-c(i)),l=Math.hypot(s(r)-s(t),c(r)-c(t)),u=Math.min(n,a/2,l/2);u>.01?e.arcTo(s(t),c(t),s(r),c(r),u):e.lineTo(s(t),c(t))}e.closePath()},u=(e,t,n=0,r=0)=>{e.beginPath(),l(e,t.points,t.radius??0,!1,n,r),t.hole&&l(e,t.hole,0,!0,n,r)},d=(e,t,n,r,i,a)=>{let o=Math.max(0,Math.min(a,r/2,i/2));if(e.beginPath(),o<=.01){e.moveTo(t,n),e.lineTo(t+r,n),e.lineTo(t+r,n+i),e.lineTo(t,n+i),e.closePath();return}e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.arcTo(t+r,n,t+r,n+o,o),e.lineTo(t+r,n+i-o),e.arcTo(t+r,n+i,t+r-o,n+i,o),e.lineTo(t+o,n+i),e.arcTo(t,n+i,t,n+i-o,o),e.lineTo(t,n+o),e.arcTo(t,n,t+o,n,o),e.closePath()},f=(e,t)=>{typeof e.setLineDash==`function`&&e.setLineDash(t)},p=(e,t,n,i)=>{e.beginPath(),e.arc(t,n,Math.max(0,i),0,r.TAU)},m=(e,t)=>!!t&&e.hit!==void 0&&(e.hit===t.index||!!e.also?.includes(t.index)),h=(e,t)=>{let n=(t.x0+t.x1)/2;e.beginPath(),e.moveTo(t.x0,t.y0),e.bezierCurveTo(n,t.y0,n,t.y1,t.x1,t.y1)},g=(e,t)=>{if(t.color0===t.color1||typeof e.createLinearGradient!=`function`||Math.abs(t.x1-t.x0)<1)return t.color0;let n=e.createLinearGradient(t.x0,0,t.x1,0);return n.addColorStop(0,t.color0),n.addColorStop(1,t.color1),n},_=e=>Math.abs(e.s0-e.t0)<1e-9&&Math.abs(e.s1-e.t1)<1e-9,v=e=>{let t=(e.s0+e.s1)/2;return[e.cx+e.r*.4*Math.cos(t),e.cy+e.r*.4*Math.sin(t)]},y=(e,t)=>{let{cx:n,cy:r,r:i}=t,a=(e,t=i)=>[n+t*Math.cos(e),r+t*Math.sin(e)];e.beginPath();let o=a(t.s0);if(e.moveTo(o[0],o[1]),t.s1>t.s0&&e.arc(n,r,i,t.s0,t.s1),_(t)){let[n,r]=v(t);e.quadraticCurveTo(n,r,o[0],o[1]),e.closePath();return}if(t.head>0){let o=a(t.t0,i-t.head),s=a((t.t0+t.t1)/2),c=a(t.t1,i-t.head);e.quadraticCurveTo(n,r,o[0],o[1]),e.lineTo(s[0],s[1]),e.lineTo(c[0],c[1])}else{let o=a(t.t0);e.quadraticCurveTo(n,r,o[0],o[1]),t.t1>t.t0&&e.arc(n,r,i,t.t0,t.t1)}e.quadraticCurveTo(n,r,o[0],o[1]),e.closePath()},b=(e,t)=>{if(t.color0===t.color1||typeof e.createLinearGradient!=`function`)return t.color0;let n=(t.s0+t.s1)/2,r=(t.t0+t.t1)/2,i=t.cx+t.r*Math.cos(n),a=t.cy+t.r*Math.sin(n),o=t.cx+t.r*Math.cos(r),s=t.cy+t.r*Math.sin(r);if(Math.hypot(o-i,s-a)<1)return t.color0;let c=e.createLinearGradient(i,a,o,s);return c.addColorStop(0,t.color0),c.addColorStop(1,t.color1),c},x=(e,t,n)=>{e.save();let r=t.enter,o=r?Math.max(0,Math.min(1,r.alpha)):1;r&&r.scale!==1&&(e.translate(r.cx,r.cy),e.scale(r.scale,r.scale),e.translate(-r.cx,-r.cy)),e.lineJoin=`round`,e.lineCap=`round`;for(let r of t.nodes){let s=r.hit!==void 0,l=m(r,n),_=l&&r.hit===n?.index,v=o*(r.alpha??1);if(n&&s&&!l&&(v*=t.dim),v<=.002)continue;e.globalAlpha=v;let x=_&&r.shift?r.shift[0]:0,S=_&&r.shift?r.shift[1]:0;switch(r.kind){case`sector`:c(e,r,x,S),e.fillStyle=r.fill,_?(e.save(),e.shadowColor=i,e.shadowBlur=14,e.shadowOffsetY=4,e.fill(),e.restore()):e.fill();break;case`polygon`:{u(e,r,x,S);let t=l&&r.hoverFill?r.hoverFill:r.fill;t&&(e.fillStyle=t,e.fill(),l&&r.brighten&&(e.fillStyle=a,e.fill())),r.stroke&&(e.strokeStyle=r.stroke,e.lineWidth=l&&r.hoverLineWidth?r.hoverLineWidth:r.lineWidth??1,e.stroke());break}case`rect`:d(e,r.x+x,r.y+S,r.width,r.height,r.radius),e.fillStyle=r.fill,e.fill(),l&&r.brighten&&(e.fillStyle=a,e.fill()),_&&r.hoverStroke&&r.width>3&&r.height>3&&(d(e,r.x+x+.75,r.y+S+.75,r.width-1.5,r.height-1.5,Math.max(0,r.radius-.75)),e.strokeStyle=r.hoverStroke,e.lineWidth=1.5,e.stroke());break;case`arc`:if(r.a1-r.a0<=1e-6||r.width<=0)break;e.beginPath(),e.arc(r.cx+x,r.cy+S,r.r,r.a0,r.a1),e.lineCap=r.cap,e.lineWidth=r.width,e.strokeStyle=r.color,e.stroke(),e.lineCap=`round`;break;case`circle`:{if(!r.fill&&!r.stroke)break;let t=l&&(r.indicator===void 0||r.indicator===n?.indicator),i=t&&r.hoverR?r.hoverR:r.r,a=r.cx+x,o=r.cy+S;t&&r.halo&&(p(e,a,o,i+5),e.fillStyle=r.halo,e.fill()),p(e,a,o,i),r.fill&&(e.fillStyle=r.fill,e.fill()),r.stroke&&(e.strokeStyle=r.stroke,e.lineWidth=r.lineWidth??1,e.stroke());break}case`line`:{let t=r.points;if(t.length<4)break;e.beginPath(),e.moveTo(t[0]+x,t[1]+S);for(let n=2;n<t.length;n+=2)e.lineTo(t[n]+(n===t.length-2?0:x),t[n+1]+(n===t.length-2?0:S));e.strokeStyle=r.color,e.lineWidth=r.width,r.dash&&f(e,r.dash),e.stroke(),r.dash&&f(e,[]);break}case`text`:{let t=r.indicator!==void 0&&n?.indicator===r.indicator;e.font=t&&r.hoverFont?r.hoverFont:r.font,e.textAlign=r.align,e.textBaseline=r.baseline;let i=!!r.rotate,a=r.x+x,o=r.y+S;i&&(e.save(),e.translate(a,o),e.rotate(r.rotate??0),a=0,o=0),r.halo&&(e.strokeStyle=r.halo,e.lineWidth=3,e.strokeText(r.text,a,o)),e.fillStyle=t&&r.hoverColor?r.hoverColor:r.color,e.fillText(r.text,a,o),i&&e.restore();break}case`link`:if(r.width<=0)break;l&&r.activeAlpha!==void 0&&(e.globalAlpha=o*r.activeAlpha),h(e,r),e.lineCap=`butt`,e.lineWidth=Math.max(1,r.width),e.strokeStyle=g(e,r),e.stroke(),e.lineCap=`round`;break;case`ribbon`:l&&r.activeAlpha!==void 0&&(e.globalAlpha=o*r.activeAlpha),y(e,r),e.fillStyle=b(e,r),e.fill(),_&&(e.strokeStyle=r.color0,e.lineWidth=1,e.stroke());break;case`guide`:{let t=n?.indicator;if(t===void 0||!r.ends[t])break;e.globalAlpha=o,e.beginPath(),e.moveTo(r.cx,r.cy),e.lineTo(r.ends[t][0],r.ends[t][1]),e.strokeStyle=r.color,e.lineWidth=1,f(e,[3,3]),e.stroke(),f(e,[]);break}}}e.restore()},S=(e,r,i)=>{e.save(),e.font=n.font(r,12),e.textBaseline=`middle`,e.textAlign=`left`;for(let n of i){let i=n.y+n.height/2;e.globalAlpha=n.hidden?.45:1,e.fillStyle=n.color,p(e,n.x+4.5,i,4.5),e.fill(),e.fillStyle=t.toCss(r.textMuted),e.fillText(n.name,n.x+15,i,Math.max(1,n.width-15)),n.hidden&&e.fillRect(n.x+15,i,n.width-15,1)}e.restore()},C=(r,a,o)=>{let{padding:s,lineHeight:c}=o;r.save(),r.globalAlpha=1,r.save(),r.shadowColor=i,r.shadowBlur=16,r.shadowOffsetY=6,d(r,o.x,o.y,o.width,o.height,8),r.fillStyle=t.toCss(a.background,e.CANVAS_TOOLTIP_ALPHA),r.fill(),r.restore(),d(r,o.x+.5,o.y+.5,o.width-1,o.height-1,8),r.strokeStyle=t.toCss(a.axis),r.lineWidth=1,r.stroke(),r.textBaseline=`middle`;let l=o.y+s+c/2,u=o.x+s+2,f=o.x+o.width-s-2;if(o.text){r.font=n.font(a,12),r.fillStyle=t.toCss(a.text),r.textAlign=`left`;for(let e of o.text)r.fillText(e,u,l),l+=c}else if(o.content){let{content:e}=o,i=u;e.color&&(r.fillStyle=e.color,p(r,i+4,l,4),r.fill(),i+=14),r.font=n.font(a,12,600),r.fillStyle=t.toCss(a.text),r.textAlign=`left`;for(let t of o.titleLines??[e.title])r.fillText(t,i,l),l+=c;for(let o of e.rows)i=u,o.color&&(r.fillStyle=o.color,p(r,i+4,l,4),r.fill(),i+=14),r.font=n.font(a,12,o.strong?600:400),r.textAlign=`left`,r.fillStyle=t.toCss(o.strong?a.text:a.textMuted),r.fillText(o.name,i,l),r.font=n.font(a,12,600),r.textAlign=`right`,r.fillStyle=t.toCss(a.text),r.fillText(o.value,f,l),l+=c}r.restore()};exports.drawShapeLegend=S,exports.drawShapeScene=x,exports.drawShapeTooltip=C,exports.loopControl=v,exports.nodeActive=m,exports.padAngleAt=s,exports.ribbonIsLoop=_,exports.roundRectPath=d,exports.sectorPad=o,exports.sectorPath=c;
2
2
  //# sourceMappingURL=draw.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"draw.cjs","names":["TAU","font","toCss","require_color","require_overlay","require_scene","SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","theme","box","boxes","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":"qFAoBA,IAAMM,EAAS,yBACTC,EAAW,4BAGJC,EAAa,GACxB,KAAK,IAAI,EAAG,KAAK,IAAIC,EAAK,IAAMA,EAAK,IAAMA,EAAK,GAAKA,EAAK,IAAO,CAAC,CAAC,EAGxDC,GAAc,EAAc,IACvCC,EAAI,EAAI,KAAK,KAAK,KAAK,IAAI,EAAGC,EAAOD,CAAC,CAAC,EAAI,KAAK,GAAK,EAG1CE,GACX,EACA,EACA,EAAK,EACL,EAAK,IACF,CACH,IAAMC,EAAKL,EAAK,GAAKM,EACfC,EAAKP,EAAK,GAAKQ,EACf,CAAE,KAAI,KAAI,KAAI,MAAOR,EACrBS,EAAOC,EAAKC,EAElB,GADAC,EAAI,UAAU,EACVH,GAAQ,GAAKI,GAAMC,EAAI,OAC3B,GAAIL,GAAQlB,EAAAA,IAAM,KAAM,CACtBqB,EAAI,OAAOP,EAAKQ,EAAIN,CAAE,EACtBK,EAAI,IAAIP,EAAIE,EAAIM,EAAI,EAAGtB,EAAAA,GAA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S,IAAM,GAAG,EACjD,EAAI,UAAY,OAChB,EAAI,UAAY7G,EAAAA,MAAM6G,EAAI,OAASV,EAAM,KAAOA,EAAM,SAAS,EAC/DhF,EAAI,SAAS0F,EAAI,KAAMnD,EAAGC,CAAC,EAC3B,EAAI,KAAO5D,EAAAA,KAAKoG,EAAO,GAAI,GAAG,EAC9B,EAAI,UAAY,QAChB,EAAI,UAAYnG,EAAAA,MAAMmG,EAAM,IAAI,EAChChF,EAAI,SAAS0F,EAAI,MAAOH,EAAO/C,CAAC,EAChC,GAAK6C,CAET,CACArF,EAAI,QAAQ,CACd"}
1
+ {"version":3,"file":"draw.cjs","names":["TAU","font","toCss","CANVAS_TOOLTIP_ALPHA","require_tooltip","require_color","require_overlay","require_scene","SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","theme","box","boxes","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport { CANVAS_TOOLTIP_ALPHA } from \"../tooltip\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background, CANVAS_TOOLTIP_ALPHA);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":"iHAqBA,IAAMQ,EAAS,yBACTC,EAAW,4BAGJC,EAAa,GACxB,KAAK,IAAI,EAAG,KAAK,IAAIC,EAAK,IAAMA,EAAK,IAAMA,EAAK,GAAKA,EAAK,IAAO,CAAC,CAAC,EAGxDC,GAAc,EAAc,IACvCC,EAAI,EAAI,KAAK,KAAK,KAAK,IAAI,EAAGC,EAAOD,CAAC,CAAC,EAAI,KAAK,GAAK,EAG1CE,GACX,EACA,EACA,EAAK,EACL,EAAK,IACF,CACH,IAAMC,EAAKL,EAAK,GAAKM,EACfC,EAAKP,EAAK,GAAKQ,EACf,CAAE,KAAI,KAAI,KAAI,MAAOR,EACrBS,EAAOC,EAAKC,EAElB,GADAC,EAAI,UAAU,EACVH,GAAQ,GAAKI,GAAMC,EAAI,OAC3B,GAAIL,GAAQpB,EAAAA,IAAM,KAAM,CACtBuB,EAAI,OAAOP,EAAKQ,EAAIN,CAAE,EACtBK,EAAI,IAAIP,EAAIE,EAAIM,EAAI,EAAGxB,EAAAA,GAAG,EACtByB,EAAK,IACPF,EAAI,OAAOP,EAAKS,EAAIP,CAAE,EACtBK,EAAI,IAAIP,EAAIE,EAAIO,EAAIzB,EAAAA,IAAK,EAAG,EAAI,GAElCuB,EAAI,UAAU,EACd,MACF,CACA,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