@motionscript/charts 0.1.0 → 0.1.1-alpha.1
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.
- package/CHANGELOG.md +38 -0
- package/README.md +98 -28
- package/dist/bar-chart/bar-chart.d.ts +242 -119
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +231 -260
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +16 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +59 -68
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +60 -91
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +88 -125
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +5 -13
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +2 -9
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +40 -132
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +70 -158
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
- package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +8 -17
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +8 -17
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +49 -35
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +80 -42
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +37 -40
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +53 -47
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +16 -59
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +38 -76
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +2 -0
- package/dist/kit/entries.d.ts.map +1 -1
- package/dist/kit/entries.js +2 -0
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/horizontal-axis.d.ts +77 -0
- package/dist/kit/horizontal-axis.d.ts.map +1 -0
- package/dist/kit/horizontal-axis.js +99 -0
- package/dist/kit/horizontal-axis.js.map +1 -0
- package/dist/kit/motion.d.ts +16 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +15 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/{pie-chart → kit}/pie-legend.d.ts +14 -29
- package/dist/kit/pie-legend.d.ts.map +1 -0
- package/dist/kit/pie-legend.js +93 -0
- package/dist/kit/pie-legend.js.map +1 -0
- package/dist/kit/polar.d.ts +31 -0
- package/dist/kit/polar.d.ts.map +1 -0
- package/dist/kit/polar.js +33 -0
- package/dist/kit/polar.js.map +1 -0
- package/dist/kit/shared.d.ts +60 -214
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +91 -291
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/style.d.ts +254 -0
- package/dist/kit/style.d.ts.map +1 -0
- package/dist/kit/style.js +197 -0
- package/dist/kit/style.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +36 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +69 -81
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +107 -40
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +172 -89
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -27
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +13 -28
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/index.d.ts +5 -18
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +3 -16
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +272 -119
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +309 -257
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +73 -130
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +195 -156
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +16 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +44 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +3 -13
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +9 -13
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +3 -15
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -11
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +147 -85
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +65 -86
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +65 -196
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +154 -292
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +78 -172
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +54 -177
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +5 -0
- package/dist/radar-chart/index.d.ts.map +1 -0
- package/dist/radar-chart/index.js +5 -0
- package/dist/radar-chart/index.js.map +1 -0
- package/dist/radar-chart/radar-chart.d.ts +218 -0
- package/dist/radar-chart/radar-chart.d.ts.map +1 -0
- package/dist/radar-chart/radar-chart.js +224 -0
- package/dist/radar-chart/radar-chart.js.map +1 -0
- package/dist/radar-chart/radar-grid.d.ts +43 -0
- package/dist/radar-chart/radar-grid.d.ts.map +1 -0
- package/dist/radar-chart/radar-grid.js +61 -0
- package/dist/radar-chart/radar-grid.js.map +1 -0
- package/dist/radar-chart/radar-series.d.ts +59 -0
- package/dist/radar-chart/radar-series.d.ts.map +1 -0
- package/dist/radar-chart/radar-series.js +71 -0
- package/dist/radar-chart/radar-series.js.map +1 -0
- package/dist/radar-chart/shared.d.ts +73 -0
- package/dist/radar-chart/shared.d.ts.map +1 -0
- package/dist/radar-chart/shared.js +123 -0
- package/dist/radar-chart/shared.js.map +1 -0
- package/dist/radial-chart/index.d.ts +6 -0
- package/dist/radial-chart/index.d.ts.map +1 -0
- package/dist/radial-chart/index.js +4 -0
- package/dist/radial-chart/index.js.map +1 -0
- package/dist/radial-chart/radial-chart.d.ts +216 -0
- package/dist/radial-chart/radial-chart.d.ts.map +1 -0
- package/dist/radial-chart/radial-chart.js +174 -0
- package/dist/radial-chart/radial-chart.js.map +1 -0
- package/dist/radial-chart/radial-rings.d.ts +121 -0
- package/dist/radial-chart/radial-rings.d.ts.map +1 -0
- package/dist/radial-chart/radial-rings.js +273 -0
- package/dist/radial-chart/radial-rings.js.map +1 -0
- package/dist/radial-chart/shared.d.ts +73 -0
- package/dist/radial-chart/shared.d.ts.map +1 -0
- package/dist/radial-chart/shared.js +79 -0
- package/dist/radial-chart/shared.js.map +1 -0
- package/package.json +4 -4
- package/registry.json +21 -6
- package/src/bar-chart/bar-chart.ts +274 -315
- package/src/bar-chart/category-axis.ts +53 -88
- package/src/bar-chart/chart-bars.ts +108 -205
- package/src/bar-chart/index.ts +8 -19
- package/src/bar-chart/shared.ts +81 -309
- package/src/engine.ts +8 -17
- package/src/index.ts +2 -0
- package/src/kit/cartesian.ts +118 -55
- package/src/kit/chart-canvas.ts +50 -80
- package/src/kit/chart-legend.ts +36 -97
- package/src/kit/entries.ts +4 -1
- package/src/kit/horizontal-axis.ts +114 -0
- package/src/kit/motion.ts +18 -2
- package/src/{pie-chart → kit}/pie-legend.ts +25 -65
- package/src/kit/polar.ts +54 -0
- package/src/kit/shared.ts +104 -487
- package/src/kit/style.ts +257 -0
- package/src/kit/vertical-axis.ts +81 -115
- package/src/line-chart/chart-line.ts +185 -91
- package/src/line-chart/chart-region.ts +14 -31
- package/src/line-chart/index.ts +14 -22
- package/src/line-chart/line-chart.ts +377 -315
- package/src/line-chart/shared.ts +229 -304
- package/src/line-chart/x-scale.ts +44 -121
- package/src/nodes.ts +9 -13
- package/src/pie-chart/index.ts +3 -35
- package/src/pie-chart/pie-chart.ts +83 -134
- package/src/pie-chart/pie-ring.ts +162 -368
- package/src/pie-chart/shared.ts +92 -379
- package/src/radar-chart/index.ts +4 -0
- package/src/radar-chart/radar-chart.ts +287 -0
- package/src/radar-chart/radar-grid.ts +78 -0
- package/src/radar-chart/radar-series.ts +88 -0
- package/src/radar-chart/shared.ts +146 -0
- package/src/radial-chart/index.ts +5 -0
- package/src/radial-chart/radial-chart.ts +210 -0
- package/src/radial-chart/radial-rings.ts +328 -0
- package/src/radial-chart/shared.ts +114 -0
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
- package/dist/kit/chart-border.d.ts +0 -27
- package/dist/kit/chart-border.d.ts.map +0 -1
- package/dist/kit/chart-border.js +0 -28
- package/dist/kit/chart-border.js.map +0 -1
- package/dist/line-chart/horizontal-axis.d.ts +0 -79
- package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
- package/dist/line-chart/horizontal-axis.js +0 -129
- package/dist/line-chart/horizontal-axis.js.map +0 -1
- package/dist/pie-chart/pie-legend.d.ts.map +0 -1
- package/dist/pie-chart/pie-legend.js +0 -117
- package/dist/pie-chart/pie-legend.js.map +0 -1
- package/src/kit/chart-border.ts +0 -50
- package/src/line-chart/horizontal-axis.ts +0 -151
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/kit/shared.ts", "../../../src/kit/style.ts", "../../../src/kit/cartesian.ts", "../../../src/kit/chart-canvas.ts", "../../../src/kit/entries.ts", "../../../src/kit/paints.ts", "../../../src/kit/horizontal-axis.ts", "../../../src/kit/motion.ts", "../../../src/kit/vertical-axis.ts", "../../../src/kit/chart-legend.ts", "../../../src/kit/pie-legend.ts", "../../../src/kit/polar.ts", "../../../src/engine.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * What every chart shares: series, axis scaling and formatting, and the theme\n * leaves each chart's theme is assembled from. No `Node` imports, so a host's\n * inspector mappings can build a partial theme without the components.\n *\n * A mapper merges partial input onto a `previous` resolved value (idempotent). A\n * tween interpolates two resolved values leaf by leaf, but categorical fields\n * (`fontFamily`, `textAlign`) and any field `undefined` on either side step at\n * the midpoint: defaulting the missing side to 0 would animate a font weight\n * down to nothing on the way to \"unset\".\n */\n\nimport {\n lerpNumber,\n type DataRecord,\n type Fill,\n type Insets,\n type Shadow,\n type Stroke,\n type TextStyle,\n} from \"@motionscript/sdk\"\nimport { niceStep } from \"@motionscript/sdk/component\"\n\n/** One series of a chart: a column of the table, captioned and painted. */\nexport interface ChartSeries {\n /** Key into each data row for this series' value. */\n field: string\n /** The legend caption; empty or absent shows `field`. */\n label?: string\n /** Overrides the theme palette's entry for this series' index, for its mark and legend swatch. */\n fill?: Fill\n /** Defaults to `true`. */\n enabled?: boolean\n}\n\n/** A `[min, max]` numeric range in data units. */\nexport type Range = [min: number, max: number]\n\n/** One axis's *data* domain, as opposed to {@link AxisConfig}, which is how it is styled. */\nexport interface AxisDomainConfig {\n /** Caption drawn alongside the axis; `\"\"` hides it. */\n label?: string\n /** Derived from the data bounds when omitted. */\n range?: Range\n /** Derived (five evenly spaced) when omitted. */\n ticks?: number[]\n /**\n * A `number-format` pattern such as `#,##0.00` or `$#,##0`. It lives here, not\n * in {@link AxisConfig}, because it says what the column holds and has to\n * survive a re-theme.\n */\n format?: string\n}\n\n/** An {@link AxisDomainConfig} with `range` and `ticks` worked out. */\nexport type ResolvedAxisDomain = AxisDomainConfig & { readonly range: Range; readonly ticks: number[] }\n\n/**\n * Merges partial input onto `previous`, so a later `.set({ yAxis: {...} })`\n * patches `label`/`range`/`ticks` independently. An unset `range`/`ticks` is the\n * auto-derive signal.\n */\nexport function resolveAxisDomain(\n domain: AxisDomainConfig | undefined,\n previous?: AxisDomainConfig\n): AxisDomainConfig {\n return {\n label: domain?.label ?? previous?.label ?? \"\",\n range: domain?.range ?? previous?.range,\n ticks: domain?.ticks ?? previous?.ticks,\n format: domain?.format ?? previous?.format,\n }\n}\n\n/**\n * Interpolates `range` and `ticks` numerically (ticks pairwise by index).\n * `label`, `format`, and either field when one side is auto, step at the\n * midpoint: there is no halfway between `$#,##0` and `0.0%`.\n */\nexport function lerpAxisDomain(\n from: AxisDomainConfig,\n to: AxisDomainConfig,\n t: number\n): AxisDomainConfig {\n return {\n label: t < 0.5 ? from.label : to.label,\n range: lerpOptionalRange(from.range, to.range, t),\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\n format: t < 0.5 ? from.format : to.format,\n }\n}\n\nfunction lerpOptionalRange(\n from: Range | undefined,\n to: Range | undefined,\n t: number\n): Range | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\n}\n\nfunction lerpOptionalTicks(\n from: number[] | undefined,\n to: number[] | undefined,\n t: number\n): number[] | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n const n = Math.max(from.length, to.length)\n const out: number[] = []\n for (let i = 0; i < n; i++) {\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\n }\n return out\n}\n\n/**\n * An axis domain part-way through a tween that leaves or reaches a `range` or\n * `ticks` left to the data: both ends as stored, and how far along. Only the\n * chart knows what an auto side draws as, so {@link settleAxisDomain} resolves\n * it there. Its own fields are the plain {@link lerpAxisDomain} of its ends, so\n * a mapper merging onto one still reads a domain.\n */\nexport interface AxisDomainBlend extends AxisDomainConfig {\n readonly blend: { readonly from: AxisDomainConfig; readonly to: AxisDomainConfig; readonly t: number }\n}\n\nfunction blendOf(domain: AxisDomainConfig): AxisDomainBlend[\"blend\"] | undefined {\n return (domain as Partial<AxisDomainBlend>).blend\n}\n\n/**\n * The axis entry tween behind `to({ yAxis: { range } })`. Between explicit\n * domains it is {@link lerpAxisDomain}, and a restated `range` without `ticks`\n * spreads ticks across it, keeping their count. When either end leaves `range`\n * or `ticks` to the data, the value between is an {@link AxisDomainBlend}, so a\n * rescale from an auto axis is continuous rather than a cut at the midpoint.\n */\nexport function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig {\n // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.\n const rangeMoved = to.range !== from.range\n const target = rangeMoved && to.range && to.ticks && to.ticks === from.ticks\n ? { ...to, ticks: markerValues(to.range, Math.max(2, to.ticks.length) - 1) }\n : to\n const blended = blendOf(from) !== undefined\n const moved = blended || rangeMoved || target.ticks !== from.ticks\n const auto = blended || from.range === undefined || from.ticks === undefined || target.range === undefined || target.ticks === undefined\n if (!moved || !auto) return lerpAxisDomain(from, target, t)\n if (t === 0) return from\n if (t === 1) return target\n const blend: AxisDomainBlend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } }\n return blend\n}\n\n/** `domain` as drawn: `drawn` resolves a plain domain's auto `range` and `ticks`; a blend is the lerp of what its ends draw. */\nexport function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig {\n const blend = blendOf(domain)\n if (!blend) return drawn(domain)\n return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t)\n}\n\n/** The colour tokens the default themes are built from: a dark plot panel with warm-grey axis furniture. */\nconst CHART_PALETTE = {\n plotFill: \"#15130e\",\n borderColor: \"#4a4036\",\n gridColor: \"#2c2820\",\n /** Axis markers, axis captions and legend labels. */\n markerColor: \"#8a7f70\",\n /** A spotlit region's dashed rules and wash. */\n regionColor: \"#d99a3a\",\n} as const\n\n/** Opacity an un-spotlighted series fades to, mark and legend entry alike. */\nexport const SPOTLIGHT_DIM = 0.2\n\n/**\n * Reads a numeric field off a row. A string column plots as 0, so a quoted or\n * unit-suffixed column needs the CSV parser's numeric coercion first.\n */\nexport function num(row: DataRecord, field: string | undefined): number {\n if (field === undefined) return 0\n const v = row[field]\n // A `NaN` or infinite cell is no more a measurement than a missing one: read\n // as 0, it cannot poison the scale and turn every point into `NaN`.\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0\n}\n\n/** The counterpart to {@link num} for the columns a chart names things by; a missing cell reads as empty, not `\"undefined\"`. */\nexport function text(row: DataRecord, field: string | undefined): string {\n if (field === undefined || field === \"\") return \"\"\n const v = row[field]\n return v === undefined || v === null ? \"\" : String(v)\n}\n\n/**\n * Every numeric column of `data` in header order, skipping `exclude`. A column\n * is numeric only if every non-empty cell is a number, so a stray text cell\n * drops the column rather than plotting zeros.\n */\nexport function numericFields(\n data: DataRecord[],\n exclude: string[] = []\n): string[] {\n if (data.length === 0) return []\n const skip = new Set(exclude)\n const seen = new Set<string>()\n const order: string[] = []\n for (const row of data)\n for (const key of Object.keys(row))\n if (!skip.has(key) && !seen.has(key)) {\n seen.add(key)\n order.push(key)\n }\n\n return order.filter((key) => {\n let sawValue = false\n for (const row of data) {\n const v = row[key]\n if (v === undefined || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n })\n}\n\n/** One axis's (x or y) style vocabulary. */\nexport interface AxisConfig {\n /** Style of each marker along the axis. */\n labelStyle: TextStyle\n titleStyle: TextStyle\n /** This axis's grid lines: weight and fill honoured, dash/cap/join ignored (they are filled rects). */\n lineStyle: Stroke\n /** Gap between the plot and the marker row; only the side facing the plot is read (`.top` horizontal, `.right` vertical). */\n tickPadding: Insets\n /** Gap between the marker row and the caption, read the same side. */\n titlePadding: Insets\n}\n\n/** A legend's per-series colour swatch. */\nexport interface LegendMarkerConfig {\n width: number\n height: number\n borderRadius: number\n stroke: Stroke\n shadow: Shadow\n}\n\nexport interface LegendConfig {\n padding: Insets\n /** Only the swatch carries the series colour. */\n textStyle: TextStyle\n itemGap: number\n markerStyle: LegendMarkerConfig\n}\n\nconst AXIS_LABEL_STYLE: TextStyle = {\n fontSize: 24,\n fontWeight: 700,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_TITLE_STYLE: TextStyle = {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\n\nexport const DEFAULT_X_AXIS: AxisConfig = {\n labelStyle: AXIS_LABEL_STYLE,\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 20,\n titlePadding: 4,\n}\n\nexport const DEFAULT_Y_AXIS: AxisConfig = {\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 40,\n titlePadding: 24,\n}\n\nexport const DEFAULT_LEGEND: LegendConfig = {\n padding: 0,\n textStyle: {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"left\",\n fill: CHART_PALETTE.markerColor,\n },\n itemGap: 44,\n markerStyle: {\n width: 60,\n height: 24,\n borderRadius: 6,\n stroke: [],\n shadow: [],\n },\n}\n\n/**\n * Format a marker value: integers plain, otherwise one decimal, or as many as\n * the tick `step` needs to tell neighbours apart (a unit axis ticked every 0.05\n * gets two, not `0.1 0.1 0.2 0.2 0.3`). Trailing zeros are dropped.\n */\nexport function formatMarker(value: number, step?: number): string {\n if (Number.isInteger(value)) return String(value)\n const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step))\n return value.toFixed(decimals).replace(/(\\.\\d*?)0+$/, \"$1\").replace(/\\.$/, \"\")\n}\n\n/** Decimal places needed to write `step` exactly, capped at six. */\nfunction decimalsFor(step: number): number {\n if (!(step > 0) || !Number.isFinite(step)) return 1\n for (let d = 0; d <= 6; d++) {\n const scaled = step * 10 ** d\n if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled)) return d\n }\n // An irrational-looking step (a third): as many places as separate the ticks.\n return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1))\n}\n\n/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */\nexport function markerStep(markers: readonly number[]): number | undefined {\n const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b)\n let step: number | undefined\n for (let i = 1; i < sorted.length; i++) {\n const gap = sorted[i] - sorted[i - 1]\n if (gap > 1e-12 && (step === undefined || gap < step)) step = gap\n }\n return step\n}\n\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\nexport function formatPercent(fraction: number): string {\n const pct = fraction * 100\n if (Number.isInteger(pct)) return `${pct}%`\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\n}\n\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\n const n = Math.max(2, Math.round(markerCount))\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\n}\n\n/** `[lo, hi]` nudged out to bounds a whole number of tidy steps apart, about `divisions` of them. */\nexport function niceRange([lo, hi]: Range, divisions: number): Range {\n const segments = Math.max(1, Math.round(divisions))\n if (hi === lo) return constantScale(lo, segments)\n const step = niceStep((hi - lo) / segments)\n return [Math.floor(lo / step) * step, Math.ceil(hi / step) * step]\n}\n\n/**\n * The scale for constant data. A zero-width scale would put every tick on one\n * value and the line on the floor, so it widens by a step sized to the\n * magnitude (`5` gets `[3, 7]`), or `[0, 1]` for zero.\n */\nfunction constantScale(value: number, segments: number): Range {\n if (value === 0) return [0, 1]\n const step = niceStep(Math.abs(value) / segments)\n return [value - step, value + step]\n}\n\n/**\n * Ticks for a range worked out from the data: every multiple of the tidiest\n * step (1, 2 or 5 times a power of ten) that divides it into about `divisions`\n * parts, so zero is a tick whenever the range spans it. A range no such step\n * divides (an author's) is split evenly instead.\n */\nexport function niceTicks([lo, hi]: Range, divisions: number): number[] {\n const span = hi - lo\n const target = Math.max(1, Math.round(divisions))\n if (!(span > 0)) return markerValues([lo, hi], target)\n const whole = (v: number) => Math.abs(v - Math.round(v)) < 1e-6\n const base = niceStep(span / target)\n let best: number | undefined\n for (const step of ladder(base)) {\n const parts = span / step\n if (!whole(parts) || !whole(lo / step) || parts < 2 || parts > 8) continue\n if (best === undefined || Math.abs(parts - target) < Math.abs(span / best - target)) best = step\n }\n if (best === undefined) return markerValues([lo, hi], target)\n const first = Math.round(lo / best)\n return Array.from({ length: Math.round(span / best) + 1 }, (_, k) => Number(((first + k) * best).toPrecision(12)))\n}\n\n/** `step` and its neighbours on the 1-2-5 ladder, two either side. */\nfunction ladder(step: number): number[] {\n const mag = 10 ** Math.floor(Math.log10(step))\n const rungs: number[] = []\n for (const m of [mag / 10, mag, mag * 10]) for (const k of [1, 2, 5]) rungs.push(k * m)\n const at = rungs.findIndex((r) => Math.abs(r - step) < step * 1e-9)\n return rungs.slice(Math.max(0, at - 2), at + 3)\n}\n", "/**\n * The chart family's style: one `style` entry per chart, built from the groups\n * below, so a look saved off one chart lays onto any other (a field the other\n * chart does not draw is dropped). A chart spreads the shared groups and adds a\n * `marks` group of its own.\n */\n\nimport {\n Types,\n type Fill,\n type StrokeResolved,\n type Stroke as _Stroke,\n type StyleInput,\n type TextStyle,\n // Named so the emitted style types reach these through the sdk, not core.\n type FillResolved as _FillResolved,\n type Type as _Type,\n} from \"@motionscript/sdk\"\n\nimport type { AxisConfig, ChartSeries, LegendConfig } from \"./shared\"\n\n/** The style family every chart shares; a host keys saved styles by it. */\nexport const CHART_STYLE_FAMILY = \"chart\"\n\n/** The out-of-the-box series colours, cycled by series (or row) index. */\nexport const CHART_PALETTE_DEFAULT = [\"#4f8cff\", \"#2fbf8f\", \"#f5a524\", \"#e5547a\", \"#9b6cf0\"] as const\n\nexport const CHART_COLORS = {\n /** A colour per series (a pie's or radial's per row), cycled. */\n palette: Types.palette(CHART_PALETTE_DEFAULT),\n /** Values, legend captions, centre text. */\n foreground: Types.fill(\"#f4f4f5\"),\n /** Axis markers and captions, spoke labels. */\n muted: Types.fill(\"#a1a1aa\"),\n /** Behind the plot; none by default, so the chart reads against the stage. */\n background: Types.fill([]),\n}\n\nexport const CHART_TEXT = {\n /** Empty: the scene's default face. */\n fontFamily: Types.font(\"\"),\n /** Marker and legend size at 1080p; titles and values scale from it. */\n fontSize: Types.number(28, { min: 8, max: 160, step: 1, unit: \"px\" }),\n fontWeight: Types.number(500, { min: 100, max: 900, step: 100 }),\n}\n\nexport const CARTESIAN_GRID = {\n /** The lines along the value ticks of a column chart (one per tick); empty draws none. */\n horizontalGrid: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** The lines under the category markers; empty draws none. */\n verticalGrid: Types.stroke([]),\n /** The baseline and the value-axis rule; empty draws none. */\n axisStroke: Types.stroke([]),\n /** Read as the chart is built: whether the category (x) axis row is drawn. */\n showXAxis: Types.boolean(true, { animatable: false }),\n /** Read as the chart is built: whether the value (y) axis column is drawn. */\n showYAxis: Types.boolean(true, { animatable: false }),\n}\n\nexport type LegendPosition = \"bottom\" | \"top\" | \"right\" | \"none\"\nexport type LegendSwatch = \"square\" | \"circle\" | \"line\"\n\nexport const CHART_LEGEND = {\n /** Read as the chart is built: where the legend sits, or `none`. */\n legend: Types.oneOf([\"bottom\", \"top\", \"right\", \"none\"] as const, { animatable: false }),\n swatch: Types.oneOf([\"square\", \"circle\", \"line\"] as const),\n}\n\n/** The type fields, and the two text colours: what every text helper reads. */\nexport interface ChartTextStyle {\n readonly foreground: Fill\n readonly muted: Fill\n readonly fontFamily: string\n readonly fontSize: number\n readonly fontWeight: number\n}\n\n/** The fields every chart's style resolves, whichever groups it spreads. */\nexport interface ChartStyleBase extends ChartTextStyle {\n readonly palette: readonly Fill[]\n readonly background: Fill\n readonly legend: LegendPosition\n readonly swatch: LegendSwatch\n}\n\n/** The cartesian grid fields, for the line and bar charts. */\nexport interface CartesianStyle extends ChartStyleBase {\n readonly horizontalGrid: StrokeResolved[]\n readonly verticalGrid: StrokeResolved[]\n readonly axisStroke: StrokeResolved[]\n readonly showXAxis: boolean\n readonly showYAxis: boolean\n}\n\n/** The rule and track fields a preset restates so its rules read on its background (a chart keeps those it draws). */\nconst _PRESET_RULES = {\n horizontalGrid: CARTESIAN_GRID.horizontalGrid,\n gridStroke: Types.stroke([]),\n spokeStroke: Types.stroke([]),\n track: Types.fill([]),\n}\n\n/** A preset's fields: any chart's, so one preset dresses every chart. */\nexport type ChartStylePreset = StyleInput<typeof CHART_COLORS & typeof CHART_TEXT & typeof _PRESET_RULES>\n\n/** Ready-made looks, each stating every colour so applying one replaces the last. */\nexport const CHART_STYLE_PRESETS = {\n midnight: {\n palette: [...CHART_PALETTE_DEFAULT],\n foreground: \"#f4f4f5\",\n muted: \"#a1a1aa\",\n horizontalGrid: { weight: 2, fill: \"white/15\" },\n gridStroke: { weight: 2, fill: \"white/15\" },\n spokeStroke: { weight: 2, fill: \"white/15\" },\n track: \"white/10\",\n background: [],\n },\n paper: {\n palette: [\"#2563eb\", \"#059669\", \"#d97706\", \"#db2777\", \"#7c3aed\"],\n foreground: \"#1c1917\",\n muted: \"#57534e\",\n horizontalGrid: { weight: 2, fill: \"#1c1917/12\" },\n gridStroke: { weight: 2, fill: \"#1c1917/12\" },\n spokeStroke: { weight: 2, fill: \"#1c1917/12\" },\n track: \"#1c1917/12\",\n background: \"#fafaf9\",\n },\n ember: {\n palette: [\"#d9603b\", \"#8194ad\", \"#e0a93b\", \"#5e9d6b\", \"#9ec85a\"],\n foreground: \"#e9e1d4\",\n muted: \"#8a7f70\",\n horizontalGrid: { weight: 2, fill: \"#2c2820\" },\n gridStroke: { weight: 2, fill: \"#2c2820\" },\n spokeStroke: { weight: 2, fill: \"#2c2820\" },\n track: \"#2c2820\",\n background: \"#15130e\",\n },\n neon: {\n palette: [\"#22d3ee\", \"#a3e635\", \"#f472b6\", \"#facc15\", \"#818cf8\"],\n foreground: \"#ffffff\",\n muted: \"#94a3b8\",\n horizontalGrid: { weight: 2, fill: \"white/10\" },\n gridStroke: { weight: 2, fill: \"white/10\" },\n spokeStroke: { weight: 2, fill: \"white/10\" },\n track: \"white/10\",\n background: [],\n },\n ocean: {\n palette: [\"#0ea5e9\", \"#14b8a6\", \"#6366f1\", \"#38bdf8\", \"#2dd4bf\"],\n foreground: \"#e0f2fe\",\n muted: \"#7dd3fc\",\n horizontalGrid: { weight: 2, fill: \"#7dd3fc/20\" },\n gridStroke: { weight: 2, fill: \"#7dd3fc/20\" },\n spokeStroke: { weight: 2, fill: \"#7dd3fc/20\" },\n track: \"#7dd3fc/20\",\n background: \"#082f49\",\n },\n sunset: {\n palette: [\"#f97316\", \"#ef4444\", \"#ec4899\", \"#f59e0b\", \"#a855f7\"],\n foreground: \"#fff7ed\",\n muted: \"#fdba74\",\n horizontalGrid: { weight: 2, fill: \"#fdba74/20\" },\n gridStroke: { weight: 2, fill: \"#fdba74/20\" },\n spokeStroke: { weight: 2, fill: \"#fdba74/20\" },\n track: \"#fdba74/20\",\n background: [],\n },\n pastel: {\n palette: [\"#a5b4fc\", \"#f9a8d4\", \"#86efac\", \"#fde68a\", \"#7dd3fc\"],\n foreground: \"#f8fafc\",\n muted: \"#cbd5e1\",\n horizontalGrid: { weight: 2, fill: \"white/12\" },\n gridStroke: { weight: 2, fill: \"white/12\" },\n spokeStroke: { weight: 2, fill: \"white/12\" },\n track: \"white/12\",\n background: [],\n },\n mono: {\n palette: [\"#fafafa\", \"#a3a3a3\", \"#737373\", \"#d4d4d4\", \"#525252\"],\n foreground: \"#fafafa\",\n muted: \"#a3a3a3\",\n horizontalGrid: { weight: 2, fill: \"white/12\" },\n gridStroke: { weight: 2, fill: \"white/12\" },\n spokeStroke: { weight: 2, fill: \"white/12\" },\n track: \"white/12\",\n background: [],\n },\n} satisfies Record<string, ChartStylePreset>\n\n/** Series `index`'s colour: its own `fill`, else the palette's, cycled. */\nexport function paletteFill(style: Pick<ChartStyleBase, \"palette\">, index: number, own?: Fill): Fill {\n if (own != null) return own\n const palette = style.palette\n return palette.length > 0 ? palette[index % palette.length] : \"white\"\n}\n\n/** {@link paletteFill} for a series. */\nexport function seriesFill(style: Pick<ChartStyleBase, \"palette\">, series: ChartSeries, index: number): Fill {\n return paletteFill(style, index, series.fill)\n}\n\nfunction face(style: Pick<ChartTextStyle, \"fontFamily\">): Pick<TextStyle, \"fontFamily\"> {\n return style.fontFamily ? { fontFamily: style.fontFamily } : {}\n}\n\n/** Axis markers, spoke labels: muted, at the base size. */\nexport function markerText(style: ChartTextStyle, textAlign: TextStyle[\"textAlign\"] = \"center\"): TextStyle {\n return { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign, fill: style.muted }\n}\n\n/** Axis captions: muted, a step larger and heavier than the markers. */\nexport function titleText(style: ChartTextStyle): TextStyle {\n return {\n ...face(style),\n fontSize: Math.round(style.fontSize * 1.1),\n fontWeight: Math.min(900, style.fontWeight + 100),\n textAlign: \"center\",\n fill: style.muted,\n }\n}\n\n/** Values on marks and legend captions: the foreground, at the base size. */\nexport function valueText(style: ChartTextStyle, textAlign: TextStyle[\"textAlign\"] = \"center\"): TextStyle {\n return { ...face(style), fontSize: style.fontSize, fontWeight: Math.min(900, style.fontWeight + 100), textAlign, fill: style.foreground }\n}\n\n/**\n * The kit axis parts' config from a style. `x` is the axis under the plot;\n * its grid lines are vertical (one per x marker), the `y` axis's horizontal.\n */\nexport function axisConfigOf(style: Pick<CartesianStyle, \"verticalGrid\" | \"horizontalGrid\"> & ChartTextStyle, axis: \"x\" | \"y\"): AxisConfig {\n const gap = Math.round(style.fontSize * 0.6)\n return {\n labelStyle: markerText(style, axis === \"x\" ? \"center\" : \"right\"),\n titleStyle: titleText(style),\n lineStyle: axis === \"x\" ? style.verticalGrid : style.horizontalGrid,\n tickPadding: axis === \"x\" ? { top: gap } : { right: gap },\n titlePadding: axis === \"x\" ? { top: Math.round(gap / 2) } : { right: gap },\n }\n}\n\n/** The kit legend's config: captions in the foreground, the swatch shaped by `swatch`. */\nexport function legendConfigOf(style: ChartTextStyle & Pick<ChartStyleBase, \"swatch\">): LegendConfig {\n const size = Math.max(8, Math.round(style.fontSize * 0.6))\n const marker =\n style.swatch === \"line\"\n ? { width: Math.round(size * 2), height: Math.max(3, Math.round(size / 4)), borderRadius: size }\n : style.swatch === \"circle\"\n ? { width: size, height: size, borderRadius: size / 2 }\n : { width: size, height: size, borderRadius: Math.round(size / 4) }\n return {\n padding: 0,\n textStyle: { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign: \"left\", fill: style.foreground },\n itemGap: Math.round(style.fontSize * 1.4),\n markerStyle: { ...marker, stroke: [], shadow: [] },\n }\n}\n", "import {\n Rect,\n RotatedBox,\n Text,\n textOps,\n type ChildView,\n type Fill,\n type FillResolved,\n type Insets,\n type Node2D,\n type Size2D,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport type { CartesianStyle, LegendPosition } from \"./style\"\n\n/** Space between the frame's rows and columns: the plot and the legend, the axes and the legend. */\nexport function frameGap(style: Pick<CartesianStyle, \"fontSize\">): number {\n return Math.round(style.fontSize * 0.9)\n}\n\n/** Room above the plot for the top value marker, which is centred on the top grid line. */\nexport function headroom(style: Pick<CartesianStyle, \"fontSize\">): number {\n return Math.ceil(style.fontSize * 0.7)\n}\n\n/** How far an end marker of a horizontal value axis may hang past the plot: half a short caption. */\nexport function overhang(style: Pick<CartesianStyle, \"fontSize\">): number {\n return Math.ceil(style.fontSize * 1.1)\n}\n\ninterface CartesianParts {\n /** The axis beside the plot, on its left. */\n readonly left?: Node2D\n /** An invisible twin of `left` under the plot, so the row there starts at the plot's left edge. */\n readonly ghost?: Node2D\n /** The box the grid and the marks share. */\n readonly plot: Node2D\n /** The axis under the plot. */\n readonly bottom?: Node2D\n readonly legend?: Node2D\n readonly legendAt: LegendPosition\n readonly gap: () => number\n readonly padding: () => Insets\n}\n\n/**\n * The frame the line and bar charts share. A legend above or below is centred\n * on the whole chart; one on the right is a column beside the plot. An axis the\n * style turns off is simply not here, and the plot takes its room.\n */\nexport function cartesianFrame(parts: CartesianParts): Node2D {\n const top = new Rect({ flow: \"horizontal\", width: \"fill\", height: \"fill\", children: [...(parts.left ? [parts.left] : []), parts.plot] })\n const rows: Node2D[] = [top as unknown as Node2D]\n if (parts.bottom) {\n rows.push(new Rect({ flow: \"horizontal\", width: \"fill\", height: \"hug\", children: [...(parts.ghost ? [parts.ghost] : []), parts.bottom] }) as unknown as Node2D)\n }\n const body = new Rect({ flow: \"vertical\", width: \"fill\", height: \"fill\", children: rows })\n const legend = parts.legend && parts.legendAt !== \"none\" ? parts.legend : undefined\n const main = new Rect({\n flow: \"horizontal\",\n width: \"fill\",\n height: \"fill\",\n align: \"center\",\n gap: parts.gap,\n children: [body, ...(legend && parts.legendAt === \"right\" ? [legend] : [])],\n })\n const across = (node: Node2D) => new Rect({ flow: \"horizontal\", width: \"fill\", height: \"hug\", align: \"center\", children: [node] })\n return new Rect({\n flow: \"vertical\",\n width: \"fill\",\n height: \"fill\",\n gap: parts.gap,\n padding: parts.padding,\n children: [\n ...(legend && parts.legendAt === \"top\" ? [across(legend)] : []),\n main,\n ...(legend && parts.legendAt === \"bottom\" ? [across(legend)] : []),\n ],\n }) as unknown as Node2D\n}\n\n/** Every view under `children`, depth first in build order: the axis beside the plot comes before its twin, which holds no parts. */\nexport function chartViews(children: readonly ChildView[]): ChildView[] {\n const out: ChildView[] = []\n const walk = (views: readonly ChildView[]) => {\n for (const view of views) {\n out.push(view)\n walk(view.children)\n }\n }\n walk(children)\n return out\n}\n\n/** A part's laid-out size; zero before it is built or laid out. */\nexport function laidOutSize(node: Node2D | undefined): Size2D {\n const bounds = node?.layoutBounds\n return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 }\n}\n\n/**\n * A text style as props bound to `read`, so a style tween reaches text built\n * once. Only the keys set at build are bound: an unset family stays unset, so\n * the host's default face still applies.\n */\nexport function boundText(read: () => TextStyle): Record<string, unknown> {\n const keys = Object.keys(textOps.styleProps(read())) as (keyof TextStyle)[]\n const props: Record<string, unknown> = {}\n for (const key of keys) props[key] = () => read()[key]\n return props\n}\n\ninterface GhostSpec {\n readonly captions: () => readonly string[]\n /** How many captions the real axis built. */\n readonly count: number\n readonly text: () => TextStyle\n readonly title: string\n readonly titleText: () => TextStyle\n readonly tickPad: () => number\n readonly titlePad: () => number\n}\n\n/**\n * An invisible column as wide as a vertical axis built from the same captions:\n * the widest caption plus the tick padding, and the rotated title before it. A\n * plain tree, so a command looking for the axis never finds this instead.\n */\nexport function columnGhost(spec: GhostSpec): Node2D {\n const captions = Array.from({ length: spec.count }, (_, i) => new Text({ ...boundText(spec.text), text: () => spec.captions()[i] ?? \"\" }))\n const children: Node2D[] = []\n if (spec.title !== \"\") {\n children.push(new RotatedBox({ angle: -90, width: \"hug\", height: \"hug\", children: new Text({ ...boundText(spec.titleText), text: spec.title }) }) as unknown as Node2D)\n }\n children.push(new Rect({ flow: \"vertical\", width: \"hug\", height: \"hug\", padding: () => ({ right: spec.tickPad() }), children: captions }) as unknown as Node2D)\n return new Rect({ opacity: 0, flow: \"horizontal\", gap: spec.titlePad, width: \"hug\", height: 0, children }) as unknown as Node2D\n}\n\n/** `fill` with every layer's opacity scaled by `k`. */\nexport function fade(fill: Fill, k: number): Fill {\n const layers = (Array.isArray(fill) ? fill : [fill]) as FillResolved[]\n return layers.map((layer) => (typeof layer === \"object\" && layer !== null ? { ...layer, opacity: ((layer as { opacity?: number }).opacity ?? 1) * k } : layer)) as Fill\n}\n", "import {\n Graphics2D,\n Types,\n component2d,\n fillOps,\n strokeOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RenderContext,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { loadPaints } from \"./paints\"\nimport type { Range } from \"./shared\"\n\nconst strokeEntry = () => Types.custom<Stroke, StrokeResolved[]>([], { resolve: strokeOps.resolve, lerp: strokeOps.lerp })\n\n/** Where along a scale a fraction lands in a run of `length` px centred on 0. */\nfunction along(value: number, [min, max]: Range, length: number): number {\n return (max <= min ? 0 : (value - min) / (max - min) - 0.5) * length\n}\n\n/** One rule per draw: stroking a union of open paths paints nothing, and a dashed rule keeps its own phase. */\nexport function rule(ctx: RenderContext, from: Vector2, to: Vector2, stroke: StrokeResolved[], opacity = 1): void {\n ctx.draw(new Graphics2D().line({ points: [from, to] }).stroke(stroke).opacity(opacity))\n}\n\n/**\n * The plot backdrop: the panel fill, the grid and the axis rules, sized from its\n * box. Grid lines are placed from data-unit marker positions mapped through the\n * extents, so each lands under its marker however the markers are spaced; a line\n * on an edge is drawn just inside it.\n */\nexport const ChartCanvas = component2d({\n key: \"chartCanvas\",\n state: {\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n /** The vertical grid lines, one per `xMarkers` entry. */\n xGridStroke: strokeEntry(),\n /** The horizontal grid lines, one per `yMarkers` entry. */\n yGridStroke: strokeEntry(),\n xMarkers: fresh<number[]>(() => []),\n yMarkers: fresh<number[]>(() => []),\n /** `[min, max]` of each scale, mapping the markers into the panel. */\n xExtent: fresh<Range>(() => [0, 1]),\n yExtent: fresh<Range>(() => [0, 1]),\n /** The baseline and the value-axis rule. */\n axisStroke: strokeEntry(),\n /** Where the horizontal axis rule sits on the y scale, or `null` for none. */\n xAxisAt: Types.custom<number | null>(null),\n /** Where the vertical axis rule sits on the x scale, or `null` for none. */\n yAxisAt: Types.custom<number | null>(null),\n },\n load: (loader, state) => loadPaints(loader, { fills: [state.fill], strokes: [state.xGridStroke, state.yGridStroke, state.axisStroke] }),\n render: (ctx, state) => {\n const { width: W, height: H } = ctx.size\n if (W <= 0 || H <= 0) return\n if (state.fill.length > 0) ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).fill(state.fill))\n\n const inside = (at: number, length: number, weight: number) => Math.max(-length / 2 + weight / 2, Math.min(length / 2 - weight / 2, at))\n const verticals = (values: readonly number[], stroke: StrokeResolved[]) => {\n const weight = stroke[0]?.weight ?? 0\n if (weight <= 0) return\n for (const v of values) {\n const x = inside(along(v, state.xExtent, W), W, weight)\n rule(ctx, { x, y: -H / 2 }, { x, y: H / 2 }, stroke)\n }\n }\n const horizontals = (values: readonly number[], stroke: StrokeResolved[]) => {\n const weight = stroke[0]?.weight ?? 0\n if (weight <= 0) return\n for (const v of values) {\n const y = inside(along(v, state.yExtent, H), H, weight)\n rule(ctx, { x: -W / 2, y }, { x: W / 2, y }, stroke)\n }\n }\n const within = ([min, max]: Range) => (v: number) => v >= Math.min(min, max) - 1e-9 && v <= Math.max(min, max) + 1e-9\n verticals(state.xMarkers.filter(within(state.xExtent)), state.xGridStroke)\n horizontals(state.yMarkers.filter(within(state.yExtent)), state.yGridStroke)\n if (state.xAxisAt !== null) horizontals([state.xAxisAt], state.axisStroke)\n if (state.yAxisAt !== null) verticals([state.yAxisAt], state.axisStroke)\n },\n})\n\nexport type ChartCanvas = NodeOf<typeof ChartCanvas>\n", "import { Types, type Element, type EntryOptions, type Node2D, type Type } from \"@motionscript/sdk\"\n\n/**\n * An entry made fresh for every node: each node gets its own array or box\n * rather than one shared literal, and a host is told no default for it.\n */\nexport function fresh<T, In = T>(make: () => T, options?: { readonly resolve?: (value: In) => T; readonly kind?: string }): Type<In, T> {\n // A function default is a factory: the component calls it once per node.\n return Types.custom<In, T>(make as unknown as In, options)\n}\n\n/**\n * Nodes a `children` builder made with `new`, as the elements it returns. A\n * part built that way can be read in a binding — its own box, or its parent's,\n * which is the component it was built for — where a call would hand back only\n * the element.\n */\nexport function asParts(nodes: readonly Node2D[]): readonly Element[] {\n return nodes as unknown as readonly Element[]\n}\n\n/** The argument every per-series command takes: an index into `series`, offered by name. */\nexport const SERIES_ARG = Types.custom<number, number, EntryOptions & { readonly min: number; readonly step: number }>(0, { kind: \"series\", min: 0, step: 1 })\n", "import type { FillResolved, Loader, ShadowResolved, StrokeResolved } from \"@motionscript/sdk\"\n\n/** Paints a chart part holds in entries of its own, which no paint entry loads for it. */\nexport interface PartPaints {\n readonly fills?: readonly (readonly FillResolved[])[]\n readonly strokes?: readonly (readonly StrokeResolved[])[]\n readonly shadows?: readonly (readonly ShadowResolved[])[]\n}\n\n/** Declare `paints` from a component's `load`. */\nexport function loadPaints(loader: Loader, paints: PartPaints): void {\n for (const fill of paints.fills ?? []) loader.fill(fill)\n for (const strokes of paints.strokes ?? []) for (const stroke of strokes) loader.fill(stroke.fill)\n for (const shadows of paints.shadows ?? []) for (const shadow of shadows) loader.fill(shadow.fill)\n}\n", "import {\n Rect,\n Text,\n Types,\n component2d,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\nimport { enterBudget } from \"@motionscript/sdk/component\"\n\nimport { boundText } from \"./cartesian\"\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport { DEFAULT_X_AXIS, type AxisConfig, type Range } from \"./shared\"\nimport { axisPads, markerCaption } from \"./vertical-axis\"\n\nconst SLIDE = 24\n\n/**\n * A row of {@link Text} markers under the plot, the mirror of `VerticalAxis`\n * (bound text and positions, landed resting state). Markers are placed by value\n * across the range, whatever they say: `2026-03` sits three months along, not\n * three slots along, unlike a bar chart's category axis. An end marker may hang\n * past the row by `overhang` px on either side, then is held inside it.\n */\nexport const HorizontalAxis = component2d({\n key: \"horizontalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\n /** Caption centred beneath the markers; empty hides it. */\n label: \"\",\n /** How far past the row's left and right ends a marker may reach, in px. */\n overhang: Types.custom<{ left: number; right: number }>({ left: 0, right: 0 }),\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const pads = () => axisPads(state.axis, \"top\")\n const sorted = () => [...state.markers].sort((a, b) => a - b)\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n\n const markers = state.markers.map((_, i) => {\n const width = () => (marker.parent as Node2D | null)?.layoutBounds.width ?? 0\n const marker: Node2D = new Text({\n ...boundText(() => state.axis.labelStyle),\n text: () => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n x: () => {\n const w = width()\n const half = marker.layoutBounds.width / 2\n const centred = (fracAt(sorted()[i]) - 0.5) * w\n return Math.max(-w / 2 - state.overhang.left + half, Math.min(w / 2 + state.overhang.right - half, centred))\n },\n opacity: () => arrivalOf(state.arrivals, i).opacity,\n y: () => arrivalOf(state.arrivals, i).shift,\n })\n return marker\n })\n\n const children: Node2D[] = [\n new Rect({ width: \"fill\", height: \"hug\", padding: () => ({ top: pads().tick }), children: markers }) as unknown as Node2D,\n ]\n if (state.label !== \"\") {\n children.push(\n new Text({\n ...boundText(() => state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n y: () => arrivalOf(state.arrivals, \"label\").shift,\n }) as unknown as Node2D\n )\n }\n return asParts([new Rect({ flow: \"vertical\", gap: () => pads().title, height: \"hug\", width: \"fill\", children }) as unknown as Node2D])\n },\n commands: {\n /** Stagger markers in left to right, then the caption. The duration is the whole entrance ({@link enterBudget}). */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type HorizontalAxis = NodeOf<typeof HorizontalAxis>\n", "import { Types, easeOut, type EasingFunction, type Piece, type Timeline } from \"@motionscript/sdk\"\n\nconst identity: EasingFunction = (t) => t\n\n/** Any component's timeline: these helpers only build pieces, which every timeline builds alike. */\nexport type AnyTimeline = Timeline<any, any>\n\n/** How far a legend starts below its slot when `enter` brings it in, in px. */\nexport const LEGEND_SLIDE = 20\n\n/** Where a legend waits before it comes up: below its place, above it, or to its right. */\nexport function legendAway(at: string): { x?: number; y?: number } {\n if (at === \"top\") return { y: LEGEND_SLIDE }\n if (at === \"right\") return { x: LEGEND_SLIDE }\n return { y: -LEGEND_SLIDE }\n}\n\n/** Marker count when an axis states no ticks. */\nexport const DEFAULT_MARKERS = 5\n\n/** How a cartesian `enter` splits its duration: axes arriving, marks drawing, legend coming up. Sums to 1. */\nexport const ENTER_SHARE = { axes: 0.35, marks: 0.5, legend: 0.15 } as const\n\n/**\n * The ease a part's own frames apply to `t`: none when its command was given\n * one, which already eases every frame the command builds, and otherwise the\n * ease-out every chart command defaults to.\n */\nexport function frameEase(timeline: { readonly easing: EasingFunction | undefined }): EasingFunction {\n return timeline.easing ? identity : easeOut()\n}\n\n/** A piece of a command placed at its own time: from `at` seconds, for `duration` seconds. */\nexport interface Beat {\n readonly at: number\n readonly duration: number\n readonly piece: Piece\n}\n\n/**\n * `beats` at their own offsets over the command, each eased on its own and held\n * at its last frame once it is done. A beat ahead of the playhead writes nothing,\n * so whatever stands before it is written by a piece ahead of these. Beats that\n * run past the command are played faster to end with it.\n */\nexport function beats(timeline: AnyTimeline, parts: readonly Beat[]): Piece {\n const total = timeline.duration\n const natural = parts.reduce((end, part) => Math.max(end, part.at + part.duration), 0)\n const k = natural > total && natural > 0 ? total / natural : 1\n return timeline.together(\n parts.map(({ at, duration, piece }) => {\n const start = at * k\n const length = duration * k\n return timeline.sequence([timeline.wait(start), piece, timeline.wait(Math.max(0, total - start - length))])\n })\n )\n}\n\n/** How far one piece of a staggered entrance has come: its opacity, and how far it still sits off its place. */\nexport interface Arrival {\n readonly opacity: number\n readonly shift: number\n}\n\n/** Each piece's arrival, by key. An unlisted piece has landed. */\nexport type Arrivals = Readonly<Record<string, Arrival>>\n\nconst LANDED: Arrival = { opacity: 1, shift: 0 }\n\n/**\n * A part's private record of its pieces' arrivals. A write merges into it, so\n * beats placed apart each write their own piece and leave the others as the\n * frame left them.\n */\nexport function arrivalsEntry() {\n return Types.custom<Arrivals>({}, { private: true, resolve: (next: Arrivals, previous?: Arrivals) => ({ ...previous, ...next }) })\n}\n\nexport function arrivalOf(arrivals: Arrivals, key: string | number): Arrival {\n return arrivals[key] ?? LANDED\n}\n\n/** Every piece in `keys` armed at `from`: the first frame of their entrance. */\nexport function armed(keys: readonly (string | number)[], from: Arrival): Arrivals {\n const record: Record<string, Arrival> = {}\n for (const key of keys) record[key] = from\n return record\n}\n\n/**\n * A piece arriving from `from` over its beat: a part armed at `from` tweened to\n * `{ opacity: 1, [axis]: 0 }`, eased by `ease`.\n */\nexport function arrival(timeline: AnyTimeline, key: string | number, from: Arrival, ease: EasingFunction): Piece {\n return timeline.animate((t) => {\n const e = ease(t)\n return {\n arrivals: {\n [key]: {\n opacity: from.opacity + (LANDED.opacity - from.opacity) * e,\n shift: from.shift + (LANDED.shift - from.shift) * e,\n },\n },\n }\n })\n}\n", "import {\n Rect,\n RotatedBox,\n Text,\n Types,\n component2d,\n insetsOps,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\nimport { enterBudget } from \"@motionscript/sdk/component\"\n\nimport { boundText } from \"./cartesian\"\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport {\n DEFAULT_Y_AXIS,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"./shared\"\n\nconst SLIDE = 24\n\n/** What a marker's caption reads: the one listed for its value, else its bare reading. */\nexport function markerCaption(s: { readonly markers: readonly number[]; readonly captions: readonly string[] }, value: number): string {\n const index = s.markers.indexOf(value)\n return (index >= 0 ? s.captions[index] : undefined) ?? formatMarker(value)\n}\n\n/** The gap between an axis's markers and the plot, and between the markers and the caption, read off its config. */\nexport function axisPads(axis: AxisConfig, side: \"top\" | \"right\"): { tick: number; title: number } {\n return { tick: insetsOps.resolve(axis.tickPadding)[side], title: insetsOps.resolve(axis.titlePadding)[side] }\n}\n\n/**\n * A column of right-aligned captions beside the plot: `place(i)` is caption\n * `i`'s centre height in the column (y-up), whose height it is handed. The\n * value axis and a horizontal bar chart's category axis are both this column.\n */\nexport function captionColumn(spec: {\n readonly count: number\n readonly axis: () => AxisConfig\n readonly text: (i: number) => string\n readonly place: (i: number, height: number) => number\n readonly arrivals: () => Readonly<Record<string, Arrival>>\n readonly opacity?: (i: number) => number\n readonly label: string\n}): Node2D {\n const pads = () => axisPads(spec.axis(), \"right\")\n const markers = Array.from({ length: spec.count }, (_, i) => {\n const column = () => (marker.parent as Node2D | null)?.layoutBounds ?? { width: 0, height: 0 }\n const marker: Node2D = new Text({\n ...boundText(() => spec.axis().labelStyle),\n text: () => spec.text(i),\n // Right-aligned against the tick padding: freeform children sit on the content box's centre.\n x: () => (column().width - pads().tick) / 2 - marker.layoutBounds.width / 2 + arrivalOf(spec.arrivals(), i).shift,\n y: () => spec.place(i, column().height),\n opacity: () => arrivalOf(spec.arrivals(), i).opacity * (spec.opacity?.(i) ?? 1),\n })\n return marker\n })\n const children: Node2D[] = []\n if (spec.label !== \"\") {\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\n children.push(\n new RotatedBox({\n angle: -90,\n width: \"hug\",\n height: \"hug\",\n children: new Text({\n ...boundText(() => spec.axis().titleStyle),\n text: spec.label,\n opacity: () => arrivalOf(spec.arrivals(), \"label\").opacity,\n x: () => arrivalOf(spec.arrivals(), \"label\").shift,\n }),\n }) as unknown as Node2D\n )\n }\n children.push(new Rect({ height: \"fill\", width: \"hug\", padding: () => ({ right: pads().tick }), children: markers }) as unknown as Node2D)\n return new Rect({ flow: \"horizontal\", gap: () => pads().title, height: \"fill\", children }) as unknown as Node2D\n}\n\n/**\n * The numeric vertical axis the cartesian charts share: a column of {@link Text}\n * markers, highest at the top, each centred on its value's fraction across\n * `range` and right-aligned against the plot. Caption and position are bound, so\n * a rescale tweens live; only the marker count is fixed at construction. The\n * resting state is landed.\n */\nexport const VerticalAxis = component2d({\n key: \"verticalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_Y_AXIS),\n /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const sorted = () => [...state.markers].sort((a, b) => b - a)\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n // A slot with no value (the live list is shorter than the column built) renders empty, not its neighbour.\n return asParts([\n captionColumn({\n count: state.markers.length,\n axis: () => state.axis,\n text: (i) => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n place: (i, height) => (fracAt(sorted()[i]) - 0.5) * height,\n arrivals: () => state.arrivals,\n label: state.label,\n }),\n ])\n },\n commands: {\n /**\n * Stagger markers in bottom to top, then the caption. The duration is the\n * whole entrance ({@link enterBudget}). `stagger` is seconds between markers\n * (derived when omitted); `slide` is the starting rightward offset in px.\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n // The bottom marker leads, so walk the top-to-bottom column in reverse.\n const markers = state.markers.map((_, i) => ({ at: (count - 1 - i) * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type VerticalAxis = NodeOf<typeof VerticalAxis>\n", "import {\n Flow,\n Paint,\n Rect,\n Shapes,\n Text,\n Types,\n component2d,\n type Fill,\n type NodeOf,\n // Named so the row's emitted type reaches the Rect surface it spreads through the sdk, not core.\n type Alignment as _Alignment,\n type CornerRadiusResolved as _CornerRadiusResolved,\n type CornerStyleResolved as _CornerStyleResolved,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RectCornerRadius as _RectCornerRadius,\n type RectCornerStyle as _RectCornerStyle,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\"\n\nimport { boundText } from \"./cartesian\"\nimport { fresh } from \"./entries\"\nimport { frameEase } from \"./motion\"\nimport {\n DEFAULT_LEGEND,\n SPOTLIGHT_DIM,\n type ChartSeries,\n type LegendConfig,\n} from \"./shared\"\n\nconst row = { ...Paint.state, ...Flow.state, ...Shapes.corners }\n\n/**\n * One legend entry, hugging its swatch and caption; `shown` scales its length\n * along the legend (`along`) from nothing. The length is measured from the\n * content at any reveal, so a frame never depends on the entry once having been\n * fully shown.\n */\nconst LegendEntry = component2d({\n key: \"legendEntry\",\n state: { ...row, shown: Types.number(1), along: Types.oneOf([\"horizontal\", \"vertical\"] as const) },\n commands: { ...Paint.commands },\n measure: (measurer, state, children) => {\n const size = Flow.measure(measurer, state, children, Paint.inset(state))\n if (state.shown >= 1) return size\n return state.along === \"vertical\" ? { ...size, height: state.shown * size.height } : { ...size, width: state.shown * size.width }\n },\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\n/** Written whole, or one entry at a time as `{ [index]: reveal }`, which leaves the others as the frame left them so two series can move at once. */\nfunction revealOf(value: readonly number[] | Readonly<Record<number, number>>, previous?: number[]): number[] {\n if (Array.isArray(value)) return value as number[]\n const next = [...(previous ?? [])]\n for (const [index, reveal] of Object.entries(value)) next[Number(index)] = reveal\n return next\n}\n\n/**\n * A chart's legend: one entry per series, a colour swatch then its caption, in\n * a row (`flow: \"horizontal\"`) or a column (`\"vertical\"`, for a legend beside\n * the plot). This node is the row, so the parent places it.\n */\nexport const ChartLegend = component2d({\n key: \"chartLegend\",\n state: {\n ...row,\n series: fresh<ChartSeries[]>(() => []),\n /** Swatch colour by series index, resolved by the chart; a missing entry is white. */\n swatches: fresh<Fill[]>(() => []),\n legend: Types.custom<LegendConfig>(DEFAULT_LEGEND),\n /**\n * How far each entry is shown, `0`-`1`, driving its length, opacity and gap\n * together. Entries are never added or removed: \"is this node a child\" is not\n * a function of time, while collapsed-but-present is.\n */\n reveal: fresh<number[], number[] | Readonly<Record<number, number>>>(() => [], { resolve: revealOf }),\n },\n // The flow must be stated: a `Rect` with none lays children out `freeform`, stacking every entry on one spot.\n defaults: {\n flow: \"horizontal\",\n width: \"hug\",\n height: \"hug\",\n gap: (state) => (state.flow === \"vertical\" ? Math.round(state.legend.itemGap * 0.4) : state.legend.itemGap),\n padding: (state) => state.legend.padding,\n align: (state) => (state.flow === \"vertical\" ? \"centerLeft\" : \"center\"),\n reveal: (state) => state.series.map((s) => ((s.enabled ?? true) ? 1 : 0)),\n },\n // Every entry stays a child, so one always comes back where it belongs.\n children: (state) => {\n const marker = () => state.legend.markerStyle\n const along = state.flow === \"vertical\" ? \"vertical\" : \"horizontal\"\n return state.series.map((series, index) =>\n LegendEntry({\n flow: \"horizontal\",\n gap: () => Math.round(((state.legend.textStyle.fontSize as number | undefined) ?? 24) * 0.45),\n align: \"center\",\n width: \"hug\",\n height: \"hug\",\n along,\n // The length follows the reveal in `measure`, and the flanking gap closes with the entry.\n opacity: () => state.reveal[index] ?? 0,\n gapScale: () => state.reveal[index] ?? 0,\n shown: () => state.reveal[index] ?? 0,\n children: [\n Rect({\n width: () => marker().width,\n height: () => marker().height,\n cornerRadius: () => marker().borderRadius,\n fill: () => state.swatches[index] ?? \"white\",\n stroke: () => marker().stroke,\n shadow: () => marker().shadow,\n }),\n Text({ ...boundText(() => state.legend.textStyle), text: series.label || series.field }),\n ],\n })\n )\n },\n commands: {\n ...Paint.commands,\n /** Grow series `index`'s entry back in at its position, the siblings sliding over. */\n showSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n // An index that is not a series takes its slot and moves nothing.\n run: (timeline, state) => (timeline.args.index in state.series\n ? timeline.animate(revealFrame(state, timeline.args.index, 1, frameEase(timeline)))\n : timeline.wait(timeline.duration)),\n },\n /** The mirror of `showSeries`. */\n hideSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n run: (timeline, state) => (timeline.args.index in state.series\n ? timeline.animate(revealFrame(state, timeline.args.index, 0, frameEase(timeline)))\n : timeline.wait(timeline.duration)),\n },\n /** Dim every entry but `index` to {@link SPOTLIGHT_DIM}, in place. A hidden series' entry is left as `hideSeries` left it. */\n spotlightSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n run: (timeline, state, children) =>\n timeline.together(\n children.flatMap((entry, i) =>\n (state.reveal[i] ?? 0) > 0 ? [entry.to({ opacity: i === timeline.args.index ? 1 : SPOTLIGHT_DIM })] : []\n )\n ),\n },\n },\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\n/** One entry's reveal ramping to `target` from where the command finds it, so a hide after a show starts where the show left it. */\nfunction revealFrame(state: { readonly reveal: readonly number[] }, index: number, target: number, ease: (t: number) => number) {\n const from = state.reveal[index] ?? 0\n return (t: number) => ({ reveal: { [index]: from + (target - from) * ease(t) } })\n}\n\nexport type ChartLegend = NodeOf<typeof ChartLegend>\n", "import {\n Flow,\n Paint,\n Rect,\n Shapes,\n Text,\n Types,\n clamp,\n component2d,\n textOps,\n type NodeOf,\n // Named so the column's emitted type reaches the Rect surface it spreads through the sdk, not core.\n type Alignment as _Alignment,\n type CornerRadiusResolved as _CornerRadiusResolved,\n type CornerStyleResolved as _CornerStyleResolved,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RectCornerRadius as _RectCornerRadius,\n type RectCornerStyle as _RectCornerStyle,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport { DEFAULT_LEGEND, type LegendConfig } from \"./shared\"\nimport type { PieSlice } from \"./polar\"\n\nconst SLIDE = 16\n\n/**\n * The legend of a {@link PieChart}: a column (it sits beside the ring, in the\n * vertical strip it leaves) of caption-and-swatch entries, one per slice. No\n * show/hide: removing a row would re-cut every other wedge's share. Selection\n * arrives through `dims`.\n */\nexport const PieLegend = component2d({\n key: \"pieLegend\",\n state: {\n ...Paint.state,\n ...Flow.state,\n ...Shapes.corners,\n /** One entry per slice, in ring order. */\n slices: fresh<PieSlice[]>(() => []),\n legend: Types.custom<LegendConfig>(DEFAULT_LEGEND),\n /** Per-slice opacity multiplier, the signal that dims the ring, so an entry fades in step with its wedge. Missing reads as 1. */\n dims: fresh<number[]>(() => []),\n arrivals: arrivalsEntry(),\n },\n // The flow must be stated: a `Rect` with none lays children out `freeform`, every caption on top of the last.\n defaults: {\n flow: \"vertical\",\n align: \"centerLeft\",\n width: \"hug\",\n height: \"hug\",\n gap: (state) => state.legend.itemGap / 3,\n padding: (state) => state.legend.padding,\n },\n // The selection dim rides a wrapper, so the entrance animates the entry's own opacity without the two fighting over one value.\n children: (state) => {\n const marker = () => state.legend.markerStyle\n return state.slices.map((_, index) =>\n Rect({\n width: \"hug\",\n height: \"hug\",\n flow: \"freeform\",\n opacity: () => clamp(state.dims[index] ?? 1, 0, 1),\n children: [\n Rect({\n flow: \"horizontal\",\n gap: () => Math.round(state.legend.textStyle.fontSize === undefined ? 12 : Number(state.legend.textStyle.fontSize) * 0.4),\n align: \"center\",\n width: \"hug\",\n height: \"hug\",\n opacity: () => arrivalOf(state.arrivals, index).opacity,\n x: () => arrivalOf(state.arrivals, index).shift,\n children: [\n Rect({\n width: () => marker().width,\n height: () => marker().height,\n cornerRadius: () => marker().borderRadius,\n fill: () => state.slices[index]?.fill ?? \"white\",\n }),\n Text({\n ...textOps.styleProps(state.legend.textStyle),\n fill: () => state.legend.textStyle.fill ?? \"white\",\n fontSize: () => state.legend.textStyle.fontSize ?? 28,\n fontWeight: () => state.legend.textStyle.fontWeight ?? 500,\n text: () => state.slices[index]?.category ?? \"\",\n }),\n ],\n }),\n ],\n })\n )\n },\n commands: {\n ...Paint.commands,\n /** Every entry shifted right and transparent: what a chart shows ahead of this legend's beat, since `enter` arms only on its first frame. */\n arm: (timeline, state) =>\n timeline.animate(() => ({ arrivals: armed([...state.slices.keys()], { opacity: 0, shift: SLIDE }) })),\n /** Slide and fade entries in from the right, top to bottom. The duration is the whole entrance, the stagger carved out of it. */\n enter: (timeline, state) => {\n const count = state.slices.length\n if (count === 0) return timeline.wait(timeline.duration)\n const from: Arrival = { opacity: 0, shift: SLIDE }\n const arm = timeline.animate(() => ({ arrivals: armed([...state.slices.keys()], from) }))\n // Each gap is a fifth of an entry's move, the axes' rhythm, solved from the budget.\n const per = timeline.duration / (1 + Math.max(0, count - 1) / 5)\n const step = per / 5\n const ease = frameEase(timeline)\n const entries = state.slices.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n return timeline.together([arm, beats(timeline, entries)])\n },\n },\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\nexport type PieLegend = NodeOf<typeof PieLegend>\n", "/** What the polar charts (pie, radial) share: slices, ring geometry, the hole's summary and the selection fade. */\n\nimport { clamp, fillOps, type Fill, type FillResolved, type TextStyle, type Vector2 } from \"@motionscript/sdk\"\n\n/** One resolved slice, which the ring and legend consume; the chart resolves it from `data` and two field names. */\nexport interface PieSlice {\n /** Label and legend caption. */\n category: string\n /** The wedge covers `value / (sum of all values)`. */\n value: number\n /** Wedge and swatch paint. */\n fill: Fill\n}\n\nexport const DEG = Math.PI / 180\n\n/**\n * Opacity of a slice under the selection: 1 while nothing is out (`focus` is the\n * most-grown pop) and for the selected slice itself, falling toward `dimOpacity`\n * for the rest as the selection grows.\n */\nexport function selectionFade(focus: number, dimOpacity: number, pop: number): number {\n if (focus <= 0) return 1\n return 1 - (1 - clamp(dimOpacity, 0, 1)) * focus * (1 - pop)\n}\n\n/** The point at radius `r`, angle `a` on a ring about the origin in centred y-up space. Angles run clockwise from 12 o'clock. */\nexport function ringPoint(r: number, a: number): Vector2 {\n return { x: r * Math.sin(a), y: r * Math.cos(a) }\n}\n\n/** The summary set in the ring's hole. */\nexport interface CenterConfig {\n labelStyle: TextStyle\n captionStyle: TextStyle\n}\n\n/** How far everything outside the selection fades while any slice is selected; fainter than a gapless chart's, as a ring's slices touch. */\nexport const PIE_SPOTLIGHT_DIM = 0.15\n\nconst resolvedFills = new WeakMap<object, FillResolved[]>()\n\nexport function resolvedFill(fill: Fill): FillResolved[] {\n if (typeof fill !== \"object\" || fill === null) return fillOps.resolve(fill)\n let resolved = resolvedFills.get(fill)\n if (resolved === undefined) resolvedFills.set(fill, resolved = fillOps.resolve(fill))\n return resolved\n}\n\n/** Each slice's paint, resolved once per fill object. */\nexport function ringFills(slices: readonly PieSlice[]): FillResolved[][] {\n return slices.map((slice) => resolvedFill(slice.fill))\n}\n\n", "/**\n * The chart kit: what the five charts share, and what a copied chart does not\n * copy. A chart finds its parts by component identity (`VerticalAxis.is`), so a\n * second copy of `VerticalAxis` would be a second component that the chart never\n * finds, with no error. Copies import the kit from `@motionscript/charts`.\n */\nexport * from \"./kit/shared\"\nexport * from \"./kit/style\"\nexport * from \"./kit/cartesian\"\nexport * from \"./kit/chart-canvas\"\nexport * from \"./kit/horizontal-axis\"\nexport * from \"./kit/chart-legend\"\nexport * from \"./kit/entries\"\nexport * from \"./kit/motion\"\nexport * from \"./kit/paints\"\nexport * from \"./kit/pie-legend\"\nexport * from \"./kit/polar\"\nexport * from \"./kit/vertical-axis\"\nexport * from \"@motionscript/sdk/component\"\n"],
|
|
5
|
+
"mappings": "AAYA,OACE,cAAAA,MAOK,oBACP,OAAS,YAAAC,MAAgB,8BAyCnB,SAAUC,GACdC,EACAC,EAA2B,CAE3B,MAAO,CACL,MAAOD,GAAQ,OAASC,GAAU,OAAS,GAC3C,MAAOD,GAAQ,OAASC,GAAU,MAClC,MAAOD,GAAQ,OAASC,GAAU,MAClC,OAAQD,GAAQ,QAAUC,GAAU,OAExC,CAOM,SAAUC,EACdC,EACAC,EACAC,EAAS,CAET,MAAO,CACL,MAAOA,EAAI,GAAMF,EAAK,MAAQC,EAAG,MACjC,MAAOE,GAAkBH,EAAK,MAAOC,EAAG,MAAOC,CAAC,EAChD,MAAOE,GAAkBJ,EAAK,MAAOC,EAAG,MAAOC,CAAC,EAChD,OAAQA,EAAI,GAAMF,EAAK,OAASC,EAAG,OAEvC,CAEA,SAASE,GACPH,EACAC,EACAC,EAAS,CAET,MAAI,CAACF,GAAQ,CAACC,EAAWC,EAAI,GAAMF,EAAOC,EACnC,CAACP,EAAWM,EAAK,CAAC,EAAGC,EAAG,CAAC,EAAGC,CAAC,EAAGR,EAAWM,EAAK,CAAC,EAAGC,EAAG,CAAC,EAAGC,CAAC,CAAC,CACtE,CAEA,SAASE,GACPJ,EACAC,EACAC,EAAS,CAET,GAAI,CAACF,GAAQ,CAACC,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B,EAAKzB,IAAUP,EAAM,KAAKgC,EAAKzB,EAAOL,GAAO,KAAK8B,EAAI,KAAMzB,CAAK,CAAC,EAC5E,EC5HD,OAAS,SAAA0B,GAAO,WAAAC,OAA2E,oBAYpF,IAAMC,GAAM,KAAK,GAAK,IAOvB,SAAUC,GAAcC,EAAeC,EAAoBC,EAAW,CAC1E,OAAIF,GAAS,EAAU,EAChB,GAAK,EAAIJ,GAAMK,EAAY,EAAG,CAAC,GAAKD,GAAS,EAAIE,EAC1D,CAGM,SAAUC,GAAUC,EAAWC,EAAS,CAC5C,MAAO,CAAE,EAAGD,EAAI,KAAK,IAAIC,CAAC,EAAG,EAAGD,EAAI,KAAK,IAAIC,CAAC,CAAC,CACjD,CASO,IAAMC,GAAoB,IAE3BC,GAAgB,IAAI,QAEpB,SAAUC,GAAaC,EAAU,CACrC,GAAI,OAAOA,GAAS,UAAYA,IAAS,KAAM,OAAOZ,GAAQ,QAAQY,CAAI,EAC1E,IAAIC,EAAWH,GAAc,IAAIE,CAAI,EACrC,OAAIC,IAAa,QAAWH,GAAc,IAAIE,EAAMC,EAAWb,GAAQ,QAAQY,CAAI,CAAC,EAC7EC,CACT,CAGM,SAAUC,GAAUC,EAA2B,CACnD,OAAOA,EAAO,IAAKC,GAAUL,GAAaK,EAAM,IAAI,CAAC,CACvD,CClCA,WAAc",
|
|
6
|
+
"names": ["lerpNumber", "niceStep", "resolveAxisDomain", "domain", "previous", "lerpAxisDomain", "from", "to", "t", "lerpOptionalRange", "lerpOptionalTicks", "out", "blendOf", "lerpAxisEntry", "rangeMoved", "target", "markerValues", "blended", "moved", "auto", "settleAxisDomain", "drawn", "blend", "CHART_PALETTE", "SPOTLIGHT_DIM", "num", "row", "field", "v", "text", "numericFields", "data", "exclude", "skip", "seen", "order", "key", "sawValue", "AXIS_LABEL_STYLE", "AXIS_TITLE_STYLE", "AXIS_LINE_STYLE", "DEFAULT_X_AXIS", "DEFAULT_Y_AXIS", "DEFAULT_LEGEND", "formatMarker", "value", "step", "decimals", "decimalsFor", "d", "scaled", "markerStep", "markers", "sorted", "a", "b", "i", "gap", "formatPercent", "fraction", "pct", "min", "max", "markerCount", "_", "niceRange", "lo", "hi", "divisions", "segments", "constantScale", "niceTicks", "span", "whole", "base", "best", "ladder", "parts", "first", "k", "mag", "rungs", "m", "at", "r", "Types", "CHART_STYLE_FAMILY", "CHART_PALETTE_DEFAULT", "CHART_COLORS", "CHART_TEXT", "CARTESIAN_GRID", "CHART_LEGEND", "_PRESET_RULES", "CHART_STYLE_PRESETS", "paletteFill", "style", "index", "own", "palette", "seriesFill", "series", "face", "markerText", "textAlign", "titleText", "valueText", "axisConfigOf", "axis", "gap", "legendConfigOf", "size", "marker", "Rect", "RotatedBox", "Text", "textOps", "frameGap", "style", "headroom", "overhang", "cartesianFrame", "parts", "rows", "body", "legend", "main", "across", "node", "chartViews", "children", "out", "walk", "views", "view", "laidOutSize", "bounds", "boundText", "read", "keys", "props", "key", "columnGhost", "spec", "captions", "_", "i", "fade", "fill", "k", "layer", "Graphics2D", "Types", "component2d", "fillOps", "strokeOps", "Types", "fresh", "make", "options", "asParts", "nodes", "SERIES_ARG", "loadPaints", "loader", "paints", "fill", "strokes", "stroke", "shadows", "shadow", "strokeEntry", "Types", "strokeOps", "along", "value", "min", "max", "length", "rule", "ctx", "from", "to", "stroke", "opacity", "Graphics2D", "ChartCanvas", "component2d", "fillOps", "fresh", "loader", "state", "loadPaints", "W", "H", "inside", "at", "weight", "verticals", "values", "v", "x", "horizontals", "y", "within", "Rect", "Text", "Types", "component2d", "enterBudget", "Types", "easeOut", "identity", "LEGEND_SLIDE", "legendAway", "at", "DEFAULT_MARKERS", "ENTER_SHARE", "frameEase", "timeline", "beats", "parts", "total", "natural", "end", "part", "k", "duration", "piece", "start", "length", "LANDED", "arrivalsEntry", "next", "previous", "arrivalOf", "arrivals", "key", "armed", "keys", "from", "record", "arrival", "ease", "t", "e", "Rect", "RotatedBox", "Text", "Types", "component2d", "insetsOps", "enterBudget", "SLIDE", "markerCaption", "s", "value", "index", "formatMarker", "axisPads", "axis", "side", "insetsOps", "captionColumn", "spec", "pads", "markers", "_", "column", "marker", "Text", "boundText", "arrivalOf", "children", "RotatedBox", "Rect", "VerticalAxis", "component2d", "fresh", "Types", "DEFAULT_Y_AXIS", "arrivalsEntry", "state", "sorted", "a", "b", "fracAt", "min", "max", "i", "height", "timeline", "stagger", "slide", "count", "captioned", "from", "keys", "arm", "armed", "step", "per", "caption", "enterBudget", "ease", "frameEase", "arrival", "label", "beats", "SLIDE", "HorizontalAxis", "component2d", "fresh", "Types", "DEFAULT_X_AXIS", "arrivalsEntry", "state", "pads", "axisPads", "sorted", "b", "fracAt", "value", "min", "max", "markers", "_", "i", "width", "marker", "Text", "boundText", "markerCaption", "w", "half", "centred", "arrivalOf", "children", "Rect", "timeline", "stagger", "slide", "count", "captioned", "from", "keys", "arm", "armed", "step", "per", "caption", "enterBudget", "ease", "frameEase", "arrival", "label", "beats", "Flow", "Paint", "Rect", "Shapes", "Text", "Types", "component2d", "row", "Paint", "Flow", "Shapes", "LegendEntry", "component2d", "Types", "measurer", "state", "children", "size", "box", "ctx", "revealOf", "value", "previous", "next", "index", "reveal", "ChartLegend", "fresh", "DEFAULT_LEGEND", "s", "marker", "along", "series", "Rect", "Text", "boundText", "timeline", "revealFrame", "frameEase", "entry", "i", "SPOTLIGHT_DIM", "target", "ease", "from", "t", "Flow", "Paint", "Rect", "Shapes", "Text", "Types", "clamp", "component2d", "textOps", "SLIDE", "PieLegend", "component2d", "Paint", "Flow", "Shapes", "fresh", "Types", "DEFAULT_LEGEND", "arrivalsEntry", "state", "marker", "_", "index", "Rect", "clamp", "arrivalOf", "Text", "textOps", "timeline", "armed", "count", "from", "arm", "per", "step", "ease", "frameEase", "entries", "i", "arrival", "beats", "measurer", "children", "box", "ctx", "clamp", "fillOps", "DEG", "selectionFade", "focus", "dimOpacity", "pop", "ringPoint", "r", "a", "PIE_SPOTLIGHT_DIM", "resolvedFills", "resolvedFill", "fill", "resolved", "ringFills", "slices", "slice"]
|
|
7
|
+
}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as Te,A as xe,B as $,C as j,D as ye,E as be,F as K,G as q,H as Gt,I as Ht,J as we,K as Se,L as Ut,M as Nt,N as Vo,O as F,P as Ae,Q as $e,R as L,S as ue,T as ke,U as Xt,V as I,W as Wo,X as ve,Y as Ee,Z as Re,_ as D,a as f,aa as Le,b as z,ba as Z,c as b,ca as Yo,d as S,e as Uo,f as V,g as w,h as N,i as P,j as W,k as ae,l as No,m as le,n as ce,o as v,p as Xo,q as O,r as x,s as A,t as Y,u as zo,v as R,w as ge,x as me,y as T,z as Bt}from"./chunks/chunk-TJNHLQGV.js";import{Rect as En,Types as G,component2d as Rn,easeOut as B}from"@motionscript/sdk";import{formatNumber as Tn}from"@motionscript/sdk/component";import{Graphics2D as et,Types as tt,component2d as fn,strokeOps as Yt}from"@motionscript/sdk";import{Fills as sn,fillOps as zt,lerpNumber as an,strokeOps as Vt}from"@motionscript/sdk";var J={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function Q(e){return e.right>e.left&&e.top>e.bottom}function je(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return J;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let y=Math.min(d[0],d[1]),U=Math.max(d[0],d[1]),k=Ye=>g+(Ye-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,k(y))),Math.max(g,Math.min(p,k(U))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Ke(e,t){if(e.length<2||!Q(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=cn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&ln(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function ln(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function cn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var un={...T,markerStyle:{...T.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:R,yAxis:ge,plotArea:me,legend:un,region:{stroke:{weight:3,fill:v.regionColor,dash:[14,12],cap:"butt"},fill:sn.color(v.regionColor,{opacity:.08}),dimOpacity:O}};function dn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:zt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function hn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:zt.lerp(e.fill,t.fill,r),dimOpacity:an(e.dimOpacity,t.dimOpacity,r)}}function qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),region:dn(e?.region,r.region)}}function Ze(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),region:hn(e.region,t.region,r)}}function Je(e,t,r){return e.map((n,o)=>[t.at(o),A(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Wt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=A(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function Qe(e,t,r,n){if(r)return r;let[o,i]=Wt(e,t),s=Math.max(1,Math.round(n));if(i===o)return pn(o,s);let a=ue((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function pn(e,t){if(e===0)return[0,1];let r=ue(Math.abs(e)/t);return[e-r,e+r]}function gn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var Me=fn({key:"chartLine",state:{points:f(()=>[]),stroke:tt.custom([],{resolve:Yt.resolve,lerp:Yt.lerp}),progress:1,enabled:!0,spotlight:f(()=>J),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:tt.number(0,{min:0,max:1}),to:tt.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=b(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=gn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!Q(a)){e.draw(new et().line({points:o,radius:s}).stroke(i));return}e.draw(new et().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Ke(o,a))e.draw(new et().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as $t,Types as jt,component2d as mn,fillOps as Kt,strokeOps as qt}from"@motionscript/sdk";var rt=mn({key:"chartRegion",state:{box:f(()=>J),stroke:jt.custom(X.region.stroke,{resolve:qt.resolve,lerp:qt.lerp}),fill:jt.custom(X.region.fill,{resolve:Kt.resolve,lerp:Kt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!Q(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new $t().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new $t().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Zt,Text as Jt,Types as nt,component2d as xn,insetsOps as Qt,textOps as er}from"@motionscript/sdk";var yn=24,Ce=xn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:nt.custom(R),label:"",arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=Qt.resolve(e.axis.tickPadding).top,r=Qt.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Jt({...er.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":Xt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>w(e.arrivals,u).opacity,y:()=>w(e.arrivals,u).shift});return d}),c=[new Zt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Jt({...er.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new Zt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:nt.custom(void 0),slide:nt.number(yn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=t.markers.map((p,y)=>({at:y*l,duration:u,piece:P(e,y,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...m,...g])])}}}});import{formatNumber as bn}from"@motionscript/sdk/component";var _e=864e5,ir=["january","february","march","april","may","june","july","august","september","october","november","december"],tr=2024;function rr(e){return e.length<3?-1:ir.findIndex(t=>t.startsWith(e))}function wn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*_e+(t-1)*7*_e}function ar(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:wn(n[1]===void 0?tr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=rr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?tr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=rr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function lr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ir[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*_e?String(n):t>60*_e?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function Sn(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function An(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=ar(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function nr(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function or(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return L([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of L([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function kn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var sr=new WeakMap;function ot(e,t,r){let n=sr.get(e);n||sr.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=vn(e,t,r)),i}function vn(e,t,r){if(t!==""&&Sn(e,t)){let s=e.map(a=>A(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:nr(s),label:a=>r===void 0?F(a):bn(a,r),ticks:L}}let n=e.map(s=>Y(s,t)),o=t===""?null:An(e,t);if(o){let s=nr(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>kn(o,n,c,l=>lr(l,a)),ticks:(c,l)=>or(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>or(i,s,a)}}var st=G.custom(0,{kind:"series",min:0,step:1}),cr=G.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Ln=20,it=5,Mn=.35,Cn=.5,_n=.15;function lt(e,t=e.xAxis.format){return ot(e.data,e.xField,t)}function Pn(e,t){let r=lt(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,it-1)}}function On(e,t){let r=(t.ticks?.length??it)-1,n=Qe(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,it-1)}}var ur=new WeakMap;function Pe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=ur.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:ce(n,c=>Pn(e,c)),y:ce(o,c=>On(e,c))};return ur.set(t,{xField:r,xAxis:n,yAxis:o,series:i,domains:a}),a}function Fn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=Je(e.data,lt(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function dr(e,t,r){let{width:n,height:o}=r;return je(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function hr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function pr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function fr(e,t){let r=In(e);return{range:r,ticks:L(r,Math.max(2,t.length)-1)}}function gr(e,t,r){return{...t.x&&{xAxis:ae(e.x,t.x,r)},...t.y&&{yAxis:ae(e.y,t.y,r)}}}function at(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Ce.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(Me.is),legend:t.below.find(Z.is)??null}}function mr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function xr(e,t,r,n){let o=at(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ct=Rn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:G.custom({},{resolve:W,lerp:le}),yAxis:G.custom({},{resolve:W,lerp:le}),theme:G.custom(X,{resolve:qe,lerp:Ze}),region:G.custom(null),regionReveal:0,showLegend:G.boolean(!0,{animatable:!1}),home:G.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Pe(e),n,o=()=>Re(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ae(d)):Tn(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Ce({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=lt(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Me({points:()=>Fn(e,r(),h,o()),stroke:()=>Ut(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>dr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>Nt(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new En({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new rt({box:()=>dr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.duration,i=hr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*Mn,c=s*Cn,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return S(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-Ln}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*_n,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?mr(e,t):n<=0||!hr(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>mr(e,t)},zoomTo:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Pe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...fr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...fr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...gr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Pe(t);return e.animate(o=>({home:null,...gr(n,r,o)}))}},showSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:O})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as qn,Types as C,component2d as Zn,easeOut as ee}from"@motionscript/sdk";import{formatNumber as Jn}from"@motionscript/sdk/component";import{Rect as ut,Text as yr,Types as dt,component2d as Dn,insetsOps as br,textOps as wr}from"@motionscript/sdk";var Bn=24,Oe=Dn({key:"categoryAxis",state:{categories:f(()=>[]),axis:dt.custom(R),label:"",dims:f(()=>[]),arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=br.resolve(e.axis.tickPadding).top,r=br.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new ut({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[l]??1),x:()=>i(l),children:[new yr({...wr.styleProps(e.axis.labelStyle),text:c,opacity:()=>w(e.arrivals,l).opacity,y:()=>w(e.arrivals,l).shift})]})),a=[new ut({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new yr({...wr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new ut({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:dt.custom(void 0),slide:dt.number(Bn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=(o-1)*l+u,g=t.categories.map((y,U)=>({at:U*l,duration:u,piece:P(e,U,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...g,...p])])}}}});import{Graphics2D as Nn,Text as Xn,Types as Be,component2d as zn,fillOps as Er,shadowOps as Rr,strokeOps as Tr,textOps as Vn}from"@motionscript/sdk";import{fillOps as Gn,lerpNumber as Fe,shadowOps as Sr,strokeOps as Ar,textOps as kr}from"@motionscript/sdk";function Ie(e,t,r){let n=0;return t.map(o=>{let i=A(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function ht(e,t){let r=-1;for(let n=0;n<t.length;n++)A(e,t[n].field)!==0&&(r=n);return r}function pt(e,t){return e.map(r=>Y(r,t))}function vr(e,t,r){let n=0,o=0;for(let i of e)for(let s of Ie(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function ft(e,t,r,n,o){if(n)return n;let[i,s]=vr(e,t,r),a=Math.max(1,Math.round(o)),c=ue((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var M={seriesFills:xe,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...R,labelStyle:{...R.labelStyle,fontWeight:600},tickPadding:16},yAxis:ge,plotArea:me,legend:T,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:v.markerColor},spotlight:{dimOpacity:O}};function Hn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:Ar.resolve(e?.stroke??t.stroke),shadow:Sr.resolve(e?.shadow??t.shadow)}}function Un(e,t,r){return{cornerRadius:Fe(e.cornerRadius,t.cornerRadius,r),slotFill:Fe(e.slotFill,t.slotFill,r),groupGap:Fe(e.groupGap,t.groupGap,r),stroke:Ar.lerp(e.stroke,t.stroke,r),shadow:Sr.lerp(e.shadow,t.shadow,r)}}function gt(e,t){let r=t??M;return{seriesFills:we(e?.seriesFills,r.seriesFills),bar:Hn(e?.bar,r.bar),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),valueStyle:kr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function mt(e,t,r){return{seriesFills:Se(e.seriesFills,t.seriesFills,r),bar:Un(e.bar,t.bar,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),valueStyle:kr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:Fe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function De(e,t,r){return t.fill!=null?Gn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var Wn=10,Yn=1.6,$n=24;function Lr(e,t){return e.enabled?x(e.dims[t]??1):0}function xt(e,t){let r=e.bars[t];if(!r)return null;let n=x(e.growth);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function Mr(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:$n}function Cr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function jn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Cr(e,t)){let n=xt(e,t);if(!n||Math.abs(n.end-n.base)<Mr(e)*Yn)return""}return r.caption??F(r.value)}function Kn(e,t){let r=xt(e,t);if(!r)return 0;if(Cr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(Wn+Mr(e)/2)}var Ge=zn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:Be.custom([],{resolve:Er.resolve,lerp:Er.lerp}),barStroke:Be.custom(M.bar.stroke,{resolve:Tr.resolve,lerp:Tr.lerp}),barShadow:Be.custom(M.bar.shadow,{resolve:Rr.resolve,lerp:Rr.lerp}),cornerRadius:M.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:Be.custom(M.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Xn({...Vn.styleProps(e.valueStyle),text:()=>jn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Kn(e,r),opacity:()=>Lr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=xt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Nn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Lr(t,r)))}e.children()}});var yt=C.custom(0,{kind:"series",min:0,step:1}),Qn=20,_r=5,eo=.35,to=.5,ro=.15;function no(e,t){let r=(t.ticks?.length??_r)-1,n=ft(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,_r-1)}}var Pr=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Pr.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=ce(o,a=>no(e,a));return Pr.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Ir(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ae(t.ticks)):Jn(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function oo(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function de(e,t){return Math.max(0,e.weights[t]??1)}function so(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*de(e,o))}),r}function io(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*x(e.theme.bar.slotFill),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=de(e,p);let h=l/(d>0?d:1),m=de(e,t),g=0;for(let p=0;p<t;p++)g+=de(e,p);return e.data.map((p,y)=>{let k=Ie(e.stacked?so(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ye=e.stacked?ht(p,e.series):t,rn=c(y)-l/2,nn=e.stacked?c(y):rn+h*g+h*m/2,on=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=A(p,o.field);return{x:nn,width:on,from:bt(i,r,k.from),to:bt(i,r,k.to),round:Ye===t,value:Dt,...n&&{caption:Ir(e,i,Dt)}}})}function Or(e){let t=x(e.spotlightReveal),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Oe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ge.is),legend:t.below.find(Z.is)??null}}function Fr(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>de(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=Zn({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:C.custom({},{resolve:W,lerp:le}),categoryAxis:C.custom({},{resolve:W,lerp:ae}),theme:C.custom(M,{resolve:gt,lerp:mt}),growth:1,weights:f(()=>[]),spotlight:C.custom(null),spotlightReveal:0,showLegend:C.boolean(!0,{animatable:!1}),showValues:C.boolean(!1,{animatable:!1}),showing:C.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Re(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Ir(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Oe({categories:pt(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Or(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ge({bars:()=>io(e,h,o(),i),baseline:()=>oo(r(),o()),fill:()=>De(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Or(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>De(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new qn({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*eo,s=o*to,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return S(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-Qn}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*ro,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:C.number(0,{min:0,step:1})},easing:ee(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:ee(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as tn,Types as se,component2d as Fo,easeOut as oe}from"@motionscript/sdk";import{Flow as kt,Paint as he,Rect as vt,Shapes as Dr,Text as ao,Types as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Br=16,He=co({key:"pieLegend",state:{...he.state,...kt.state,...Dr.corners,slices:f(()=>[]),legend:lo.custom(T),dims:f(()=>[]),arrivals:V()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[n]??1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>w(e.arrivals,n).opacity,x:()=>w(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),ao({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...he.commands,arm:(e,t)=>e.animate(()=>({arrivals:N([...t.slices.keys()],{opacity:0,shift:Br})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Br},o=e.animate(()=>({arrivals:N([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=b(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,S(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,he.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,he.inset(t)),render:(e,t)=>he.draw(e,t,Dr.rect(e.size,t))});import{Graphics2D as Ur,PathBuilder as wo,Rect as Ct,Text as re,Types as fe,component2d as So,fillOps as Nr,shadowOps as Ao,strokeOps as Xr,textOps as ne}from"@motionscript/sdk";import{lerpNumber as pe,shadowOps as Gr,strokeOps as Ue,textOps as E}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:Y(o,t),value:A(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var ho=Math.PI/180;function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Hr(e){let t=0;for(let r of e)t+=Tt(r);return t}function te(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ne(e,t){let r=Hr(e);if(r<=0)return[];let n=[],o=t*ho;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function Xe(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:v.markerColor},po=.1,_={sliceFills:xe,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:v.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:v.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:v.markerColor}},legend:T,spotlight:{dimOpacity:po}};function fo(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:Ue.resolve(e?.stroke??t.stroke),shadow:Gr.resolve(e?.shadow??t.shadow)}}function go(e,t,r){return{gap:pe(e.gap,t.gap,r),holeRadius:pe(e.holeRadius,t.holeRadius,r),startAngle:pe(e.startAngle,t.startAngle,r),selectedGrow:pe(e.selectedGrow,t.selectedGrow,r),stroke:Ue.lerp(e.stroke,t.stroke,r),shadow:Gr.lerp(e.shadow,t.shadow,r)}}function mo(e,t){return{textStyle:E.resolveStyle(e?.textStyle,t.textStyle),percentStyle:E.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:E.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:Ue.resolve(e?.leaderStroke??t.leaderStroke)}}function xo(e,t,r){return{textStyle:E.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:E.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:E.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:Ue.lerp(e.leaderStroke,t.leaderStroke,r)}}function yo(e,t){return{labelStyle:E.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:E.resolveStyle(e?.captionStyle,t.captionStyle)}}function bo(e,t,r){return{labelStyle:E.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:E.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??_;return{sliceFills:we(e?.sliceFills,r.sliceFills),ring:fo(e?.ring,r.ring),label:mo(e?.label,r.label),center:yo(e?.center,r.center),legend:K(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:Se(e.sliceFills,t.sliceFills,r),ring:go(e.ring,t.ring,r),label:xo(e.label,t.label,r),center:bo(e.center,t.center,r),legend:q(e.legend,t.legend,r),spotlight:{dimOpacity:pe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var zr=12,ko=14,_t=.62,vo=6,Vr=34,Wr=26,Yr=8,Eo=.18,Ro=240,To=8,$r=2,Zr=.44,Pt=.62,Lo=.78,Mo=.9,jr=.001,Jr=26;function H(e,t=Jr){let r=e.fontSize;return typeof r=="number"?r:t}function Co(e,t,r,n,o,i){let s=new wo,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*Ro)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,y=te(d,g+(p-g)*h/c);return{x:y.x+i,y:y.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var ze=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ne(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>jr?o/s:1/0,l=a>jr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?$e(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Zr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,Jr*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Mo/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*Lo/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:$r,right:$r};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Vr+Wr+Yr+this.captionGlyphs(n.index)*r+ko,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Vr}popOf(t){return x(this.s.pops[t]??0)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=te(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){let r=this.selectionStrength;return r<=0?1:1-(1-x(this.s.dimOpacity))*r*(1-this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return $e(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=te(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return Xe(a,n+zr,o,i),Xe(c,n+zr,o,i),[...a,...c].map(l=>{let u=te(this.anchorRadius(l.index)+vo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Eo),m=s+l.side*(r+Wr);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*Yr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var _o={width:0,height:0},Kr=new WeakMap;function Po(e){if(typeof e!="object"||e===null)return Nr.resolve(e);let t=Kr.get(e);return t===void 0&&Kr.set(e,t=Nr.resolve(e)),t}function qr(e){return e.map(t=>Po(t.fill))}function Oo(e){let t=[],r=()=>new ze(e,t[0]?.parent?.layoutBounds??_o),n=o=>{let i=()=>x(e.labelReveal)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Zr})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new re({...ne.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new re({...ne.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ne(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new re({...ne.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new re({...ne.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>x(e.centerReveal),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var Ve=So({key:"pieRing",state:{slices:f(()=>[]),ring:fe.custom(_.ring),label:fe.custom(_.label),centerStyle:fe.custom(_.center),labelMode:fe.custom("percent"),labelPlacement:fe.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:_.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Oo(e),load:(e,t)=>D(e,{fills:qr(t.slices),shadows:[Ao.resolve(t.ring.shadow)],strokes:[Xr.resolve(t.ring.stroke),Xr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=b(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=b(e),n=x(t.centerReveal);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new ze(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=x(t.growth),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=qr(t.slices);for(let p of o){let y=Math.min(p.a1,s);if(y<=p.a0)continue;let U=Co(p.a0,y,a,r.anchorRadius(p.index),c,l),k=new Ur().path(U.toPathState({centerBounds:d,width:h,height:h}));k.shadow(t.ring.shadow),k.fill(m[p.index]??[]),k.stroke(t.ring.stroke),e.draw(k.opacity(r.sliceOpacity(p.index)))}let g=x(t.labelReveal);if(g>.001)for(let p of r.placements())e.draw(new Ur().line({points:p.leader,radius:To}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Io=.65,Do=.35,Ft=se.number(0,{min:0,step:1});function Qr(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ie(e,t){return x(e.pops[t]??0)}function Bo(e,t){return ie(e,t)>.5}function Go(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ie(e,n));let r=e.theme.spotlight.dimOpacity;return t<=0?e.data.map(()=>1):e.data.map((n,o)=>1-(1-x(r))*t*(1-ie(e,o)))}function We(e,t,r){let n=t.data.map((i,s)=>ie(t,s)),o=t.data.map((i,s)=>x(r(s)));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function en(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=tn.is(r)?r.children.find(Ve.is):void 0;if(n)return{ring:n,legend:r.children.find(He.is)??null}}return null}var It=Fo({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:se.custom(_,{resolve:Lt,lerp:Mt}),labelMode:se.custom("percent"),labelPlacement:se.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:se.boolean(!0,{animatable:!1}),showCenter:se.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>Qr(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Qr(e),n=[new Ve({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new He({slices:r,legend:()=>t().legend,dims:()=>Go(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new tn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:oe(),run:(e,t,r)=>{let n=en(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Io,a=e.duration*Do,c=l=>({at:0,duration:0,piece:l});return S(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:oe(),run:(e,t,r)=>en(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:ie(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?0:ie(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:oe(),run:(e,t)=>We(e,t,()=>0)}}});var Ho=[ct,At,It];export{At as BarChart,v as CHART_PALETTE,Oe as CategoryAxis,Ge as ChartBars,Te as ChartBorder,Le as ChartCanvas,Z as ChartLegend,Me as ChartLine,rt as ChartRegion,M as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,T as DEFAULT_LEGEND,_ as DEFAULT_PIE_CHART_THEME,me as DEFAULT_PLOT_AREA,Xo as DEFAULT_SERIES_COLORS,xe as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,R as DEFAULT_X_AXIS,ge as DEFAULT_Y_AXIS,J as EMPTY_REGION_BOX,Ce as HorizontalAxis,Uo as LANDED,ct as LineChart,Ho as NODES,It as PieChart,He as PieLegend,Ve as PieRing,O as SPOTLIGHT_DIM,Wo as TOP_HEADROOM,I as VerticalAxis,N as armed,P as arrival,w as arrivalOf,V as arrivalsEntry,z as asParts,No as axisTweenTarget,pt as barCategories,St as barChartDomain,Ie as barSpans,vr as barValueExtent,S as beats,ve as cartesianFrame,Ee as cartesianViews,x as clampUnit,Ke as clipPolylineToBox,ke as enterBudget,lr as formatInstant,F as formatMarker,$e as formatPercent,b as frameEase,f as fresh,Q as hasRegion,Bo as isSliceSelected,Re as laidOutSize,Yo as legendShows,j as lerpAxisConfig,ae as lerpAxisDomain,le as lerpAxisEntry,mt as lerpBarChartTheme,Ze as lerpChartTheme,q as lerpLegendConfig,Mt as lerpPieChartTheme,be as lerpPlotArea,Se as lerpSeriesFills,Ht as lerpSeriesStrokes,Pe as lineChartDomains,D as loadPaints,Xt as markerCaption,Ae as markerStep,L as markerValues,ue as niceStep,A as num,zo as numericFields,ar as parseInstant,Ne as pieArcs,Xe as relaxLabels,$ as resolveAxisConfig,W as resolveAxisDomain,gt as resolveBarChartTheme,De as resolveBarFill,ft as resolveBarScale,qe as resolveChartTheme,K as resolveLegendConfig,Vo as resolvePalettePaint,Lt as resolvePieChartTheme,Rt as resolvePieSlices,ye as resolvePlotArea,je as resolveRegionBox,Nt as resolveSeriesFill,we as resolveSeriesFills,Ut as resolveSeriesStroke,Gt as resolveSeriesStrokes,ot as resolveXScale,Qe as resolveYScale,te as ringPoint,Je as seriesPoints,ce as settleAxisDomain,Hr as sliceTotal,Tt as sliceValue,ht as stackCapIndex,Y as text,Wt as yExtent};
|
|
1
|
+
import{$ as U,A as De,B as Be,C as Ne,D,E as k,F as H,G as _s,H as er,I as Ps,J as Is,K as we,L as st,M as Nt,N as q,O as Se,P as at,Q as Z,R as zs,S as oe,T as tr,U as Re,V as Ae,W as Y,X as Gs,Y as W,Z as X,_ as lt,a as Qe,aa as V,b as et,ba as ct,c as N,ca as G,d as tt,da as nr,e as nt,ea as Fs,f as ye,fa as ut,g as fe,ga as ke,h as rt,ha as B,i as Ge,ia as Me,j as y,ja as ve,k as $,ka as J,l as _,la as K,m as C,ma as ie,n as Dt,na as rr,o as ot,oa as Ee,p as Zn,q as it,r as j,s as I,t as T,u as z,v as Jn,w as Fe,x as Qn,y as Bt,z as be}from"./chunks/chunk-R3Q5EE6E.js";import{Rect as oi,Text as ii,Types as Q,clamp as Qt,component2d as si,easeOut as le}from"@motionscript/sdk";import{formatNumber as ai}from"@motionscript/sdk/component";import{Graphics2D as He,Types as ae,clamp as Ye,component2d as ur,fillOps as We,strokeOps as lr}from"@motionscript/sdk";import{Types as he}from"@motionscript/sdk";var de={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function se(e){return e.right>e.left&&e.top>e.bottom}function Ht(e,t,n,r){if(!e||e.x===void 0&&e.y===void 0)return de;let o=(f,[h,d],p,g)=>{if(f===void 0||d<=h)return[p,g,!1];let m=Math.min(f[0],f[1]),x=Math.max(f[0],f[1]),S=M=>p+(M-h)/(d-h)*(g-p);return[Math.max(p,Math.min(g,S(m))),Math.max(p,Math.min(g,S(x))),!0]},[i,s,a]=o(e.x,n,t.left,t.right),[l,c,u]=o(e.y,r,t.bottom,t.top);return{left:i,right:s,bottom:l,top:c,xBounded:a,yBounded:u}}function Yt(e,t){if(e.length<2||!se(t))return[];let n=[],r=[];for(let o=1;o<e.length;o++){let i=Wo(e[o-1],e[o],t);if(!i){r.length>=2&&n.push(r),r=[];continue}let[s,a]=i;r.length>0&&Yo(r[r.length-1],s)?r.push(a):(r.length>=2&&n.push(r),r=[s,a])}return r.length>=2&&n.push(r),n}function Yo(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function Wo(e,t,n){let r=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-r,e.x-n.left],[r,n.right-e.x],[-o,e.y-n.bottom],[o,n.top-e.y]];for(let[l,c]of a){if(l===0){if(c<0)return null;continue}let u=c/l;if(l<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*r,y:e.y+i*o},{x:e.x+s*r,y:e.y+s*o}]}function Xo(e,t,n){return e.map((r,o)=>[t.at(o),k(r,n.field)]).sort((r,o)=>r[0]-o[0])}function ar(e,t){let n=1/0,r=-1/0;for(let o of e)for(let i of t){let s=k(o,i.field);s<n&&(n=s),s>r&&(r=s)}return n<=r?[n,r]:[0,1]}function Uo(e,t,n,r){return n??Se(ar(e,t),r)}function Wt(e,t,n,r,o=[]){let i=e.map((c,u)=>u).sort((c,u)=>t.at(c)-t.at(u));if(r!=="stacked"&&r!=="percent")return n.map(c=>({points:i.map(u=>[t.at(u),k(e[u],c.field)]),base:null}));let s=c=>Math.max(0,o[c]??1),a=i.map(c=>n.reduce((u,f,h)=>u+Math.abs(k(e[c],f.field)*s(h)),0)),l=i.map(()=>0);return n.map((c,u)=>{let f=i.map((d,p)=>[t.at(d),l[p]]);return{points:i.map((d,p)=>{let g=k(e[d],c.field)*s(u);return l[p]+=r==="percent"?a[p]>0?g/a[p]*100:0:g,[t.at(d),l[p]]}),base:f}})}function ft(e){let t=1/0,n=-1/0;for(let{points:r,base:o}of e)for(let[,i]of[...r,...o??[]])i<t&&(t=i),i>n&&(n=i);return t<=n?[t,n]:[0,1]}var or=16;function Xt(e,t){if(t==="step"){let o=e.length>0?[e[0]]:[];for(let i=1;i<e.length;i++){let s=(e[i-1].x+e[i].x)/2;o.push({x:s,y:e[i-1].y},{x:s,y:e[i].y},e[i])}return o}if(t!=="smooth"||e.length<3)return[...e];let n=Vo(e),r=[e[0]];for(let o=1;o<e.length;o++){let i=e[o-1],s=e[o],a=(s.x-i.x)/3,l={x:i.x+a,y:i.y+a*n[o-1]},c={x:s.x-a,y:s.y-a*n[o]};for(let u=1;u<=or;u++){let f=u/or,h=1-f;r.push({x:h*h*h*i.x+3*h*h*f*l.x+3*h*f*f*c.x+f*f*f*s.x,y:h*h*h*i.y+3*h*h*f*l.y+3*h*f*f*c.y+f*f*f*s.y})}}return r}function Vo(e){let t=e.length,n=o=>{let i=e[o+1].x-e[o].x;return i===0?0:(e[o+1].y-e[o].y)/i},r=new Array(t).fill(0);for(let o=1;o<t-1;o++){let i=e[o].x-e[o-1].x,s=e[o+1].x-e[o].x,a=n(o-1),l=n(o),c=i+s===0?0:(a*s+l*i)/(i+s);r[o]=(Math.sign(a)+Math.sign(l))*Math.min(Math.abs(a),Math.abs(l),.5*Math.abs(c))||0}return r[0]=ir(n(0),r[1]),r[t-1]=ir(n(t-2),r[t-2]),r}function ir(e,t){let n=(3*e-t)/2;return e===0||Math.sign(n)!==Math.sign(e)?0:Math.abs(n)>3*Math.abs(e)?3*e:n}function Ut(e,t){if(e.length===0||t<e[0].x)return[];let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.x<=t){n.push(o);continue}let i=e[r-1];i&&o.x>i.x&&n.push({x:t,y:i.y+(o.y-i.y)*(t-i.x)/(o.x-i.x)});break}return n}function Vt(e,t){if(e.length<3||!se(t))return[];let n=[o=>o.x-t.left,o=>t.right-o.x,o=>o.y-t.bottom,o=>t.top-o.y],r=[...e];for(let o of n){let i=r;r=[];for(let s=0;s<i.length;s++){let a=i[s],l=i[(s+i.length-1)%i.length],c=o(a),u=o(l);c>=0?(u<0&&r.push(sr(l,a,u,c)),r.push(a)):u>=0&&r.push(sr(l,a,u,c))}if(r.length===0)return[]}return r}function sr(e,t,n,r){let o=n/(n-r);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}var Kt={strokeWidth:he.number(4,{min:0,max:24,step:.5,unit:"px"}),curve:he.oneOf(["smooth","linear","step"]),dots:he.boolean(!1),dotSize:he.number(12,{min:0,max:48,step:1,unit:"px"}),area:he.oneOf(["none","solid","gradient"]),areaOpacity:he.number(.4,{min:0,max:1,step:.05})},$t={values:he.oneOf(["none","above","below"],{animatable:!1})};function Xe(e,t){if(e.length===0)return 0;let n=e[0].x,r=e[e.length-1].x;return t>=1?1/0:n+(r-n)*t}function jt(e,t,n){let r=Xt(e,t);return n>=1?r:Ut(r,Xe(e,n))}var fr=()=>ae.custom("smooth");function Ko(e){return[...e.map((t,n)=>({type:n===0?"M":"L",x:t.x,y:t.y})),{type:"Z"}]}function $o(e,t,n,r){if(t.length<3||r<=0)return;let{width:o,height:i}=e.size,s=[-o/2,-i/2,o/2,i/2];e.draw(new He().path({data:Ko(t),centerBounds:s}).fill(n).opacity(r))}var ht=ur({key:"chartLine",state:{points:y(()=>[]),curve:fr(),stroke:ae.custom([],{resolve:lr.resolve,lerp:lr.lerp}),dotSize:0,dotFill:ae.custom([],{resolve:We.resolve,lerp:We.lerp}),progress:1,enabled:!0,spotlight:y(()=>de),dimOpacity:D},load:(e,t)=>C(e,{fills:[t.dotFill],strokes:[t.stroke]}),commands:{enter:{args:{from:ae.number(0,{min:0,max:1}),to:ae.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=T(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}},hold:{args:{shown:ae.boolean(!0)},run:e=>{let{shown:t}=e.args;return e.animate(n=>({progress:1,enabled:t||n<1}),{eased:!1})}}},render:(e,t)=>{if(!t.enabled)return;let n=t.points,r=Ye(t.progress,0,1);if(n.length===0||r<=0)return;let o=t.spotlight,i=se(o),s=Ye(t.dimOpacity,0,1),a=t.stroke,l=a[0]?.weight??0,c=jt(n,t.curve,r);if(c.length>=2&&l>0){let m=t.curve==="linear"?l*2:0;if(e.draw(new He().line({points:c,radius:m}).stroke(a).opacity(i?s:1)),i)for(let x of Yt(c,o))e.draw(new He().line({points:x,radius:m}).stroke(a))}let u=t.dotSize;if(u<=0)return;let f=Xe(n,r),h=new He,d=new He,p=!1,g=!1;for(let m of n){let x=f===1/0?1:Ye((f-m.x)/(u*2),0,1);if(x<=0)continue;let S=!i||m.x>=o.left&&m.x<=o.right&&m.y>=o.bottom&&m.y<=o.top;(S?h:d).ellipse({x:m.x,y:m.y,width:u*x,height:u*x}),S?p=!0:g=!0}g&&e.draw(d.fill(t.dotFill).opacity(s)),p&&e.draw(h.fill(t.dotFill))}}),qt=ur({key:"chartArea",state:{points:y(()=>[]),base:y(()=>[]),baseline:0,curve:fr(),area:ae.custom("solid"),fill:ae.custom([],{resolve:We.resolve,lerp:We.lerp}),areaOpacity:.4,progress:1,enabled:!0,spotlight:y(()=>de),dimOpacity:D},load:(e,t)=>C(e,{fills:[t.fill]}),render:(e,t)=>{let n=t.points,r=Ye(t.progress,0,1);if(!t.enabled||t.area==="none"||n.length<2||r<=0||t.fill.length===0)return;let o=c=>{let u=jt(n,t.curve,c);if(u.length<2)return[];let f=t.base.length===n.length?jt(t.base,t.curve,c):[{x:u[0].x,y:t.baseline},{x:u[u.length-1].x,y:t.baseline}];return[...u,...[...f].reverse()]},i=cr(o(1)),s=(c,u)=>$o(e,c,hr(t.fill,t.area,t.areaOpacity,i,cr(c)),u),a=o(r),l=t.spotlight;if(!se(l)){s(a,1);return}s(a,Ye(t.dimOpacity,0,1)),s(Vt(a,l),1)}});function cr(e){let t=-1/0,n=1/0;for(let r of e)r.y>t&&(t=r.y),r.y<n&&(n=r.y);return{top:t,bottom:n}}function hr(e,t,n,r,o){let i=e[e.length-1];if(t!=="gradient"||i?.type!=="solid"||!(o.top>o.bottom))return Ge(e,n);let[s,a,l,c]=i.color,u=(o.top+o.bottom)/2,f=(o.top-o.bottom)/2;return We.resolve({type:"linear-gradient",colors:[[s,a,l,c*n],[s,a,l,c*n*.04]],start:{x:0,y:(r.top-u)/f},end:{x:0,y:(r.bottom-u)/f}})}import{Graphics2D as jo,Types as dr,component2d as qo,fillOps as pr,strokeOps as gr}from"@motionscript/sdk";var Zt=qo({key:"chartRegion",state:{box:y(()=>de),stroke:dr.custom({weight:2,fill:"white/70",dash:[14,12],cap:"butt",align:"center"},{resolve:gr.resolve,lerp:gr.lerp}),fill:dr.custom("white/6",{resolve:pr.resolve,lerp:pr.lerp}),reveal:0},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let n=t.box;if(!se(n))return;let r=Math.max(0,Math.min(1,t.reveal));if(r<=0)return;let o=n.right-n.left,i=n.top-n.bottom,s=(n.left+n.right)/2,a=(n.bottom+n.top)/2;if(t.fill.length>0&&e.draw(new jo().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(r)),t.stroke.length!==0){if(n.xBounded){let l=i/2*r;for(let c of[n.left,n.right])Dt(e,{x:c,y:a-l},{x:c,y:a+l},t.stroke,r)}if(n.yBounded){let l=o/2*r;for(let c of[n.bottom,n.top])Dt(e,{x:s-l,y:c},{x:s+l,y:c},t.stroke,r)}}}});import{formatNumber as Zo}from"@motionscript/sdk/component";var dt=864e5,Sr=["january","february","march","april","may","june","july","august","september","october","november","december"],mr=2024;function xr(e){return e.length<3?-1:Sr.findIndex(t=>t.startsWith(e))}function Jo(e,t){let n=Date.UTC(e,0,4),r=(new Date(n).getUTCDay()+6)%7;return n-r*dt+(t-1)*7*dt}function Rr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let n=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(n){let s=Number(n[2]),a=n[3]===void 0?1:Number(n[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(n[1]),s-1,a)}let r=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(r){let s=Number(r[2]);return s<1||s>53?null:Jo(r[1]===void 0?mr:Number(r[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=xr(o[2]);if(s>=0){let a=o[1]??o[3],l=a===void 0?mr:Number(a);return Date.UTC(l,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=xr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function Ar(e,t){let n=new Date(e),r=n.getUTCFullYear(),o=Sr[n.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*dt?String(r):t>60*dt?`${i} ${r}`:`${i} ${n.getUTCDate()}`}function Qo(e,t){let n=!1;for(let r of e){let o=r[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;n=!0}}return n}function ei(e,t){let n=[],r=!1;for(let s of e){let a=s[t];if(a==null||a===""){n.push(null);continue}let l=Rr(a);if(l===null)return null;n.push(l),r=!0}if(!r)return null;let i=n.find(s=>s!==null);return n.map(s=>s===null?i:i=s)}function yr(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t<=n?[t,n]:[0,1]}var kr=12;function br(e,[t,n],r){let o=e.filter(l=>l>=t&&l<=n),i=[...new Set(o)].sort((l,c)=>l-c);if(i.length===0)return q([t,n],r);if(i.length<=kr&&ti(i))return i;let s=l=>i.reduce((c,u)=>Math.abs(u-l)<Math.abs(c-l)?u:c),a=[];for(let l of q([t,n],r)){let c=s(l);a[a.length-1]!==c&&a.push(c)}return a}function ti(e){if(e.length<3)return!0;let t=(e[e.length-1]-e[0])/(e.length-1);for(let n=1;n<e.length;n++)if(e[n]-e[n-1]<t*.75)return!1;return!0}function ni(e,t,n,r){let o=e.indexOf(n);return o>=0?t[o]:r(n)}var wr=new WeakMap;function Jt(e,t,n){let r=wr.get(e);r||wr.set(e,r=new Map);let o=JSON.stringify([t,n??null]),i=r.get(o);return i||r.set(o,i=ri(e,t,n)),i}function ri(e,t,n){if(t!==""&&Qo(e,t)){let s=e.map(a=>k(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:yr(s),label:a=>n===void 0?we(a):Zo(a,n),ticks:q}}let r=e.map(s=>H(s,t)),o=t===""?null:ei(e,t);if(o){let s=yr(o),a=s[1]-s[0];return{kind:"time",at:l=>o[l]??0,extent:s,label:l=>ni(o,r,l,c=>Ar(c,a)),ticks:(l,c)=>br(o,l,c)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>r[Math.round(s)]??"",ticks:(s,a)=>br(i,s,a)}}var li=Q.style(Y,{colors:W,text:X,grid:lt,marks:Kt,labels:$t,legend:U},{presets:V}),Mr=Q.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),zr=[0,100];function pt(e,t=e.xAxis.format){return Jt(e.data,e.xField,t)}function tn(e,t=!0){return Wt(e.data,pt(e),e.series,e.stack,t?e.weights:void 0)}function ci(e,t){let n=pt(e,t.format),r=t.range??n.extent;return{...t,range:r,ticks:t.ticks??n.ticks(r,j-1)}}function ui(e,t){let[n,r]=ft(tn(e,!1));if(e.stack==="percent"&&n>=0)return zr;let o=e.stack!=="none"||(e.style?.area??"none")!=="none";return Se(o?[Math.min(0,n),Math.max(0,r)]:[n,r],t)}function fi(e,t){let n=(t.ticks?.length??j)-1,r=t.range??ui(e,n),o=t.range!==void 0||e.stack==="percent"&&r===zr;return{...t,range:r,ticks:t.ticks??(o?q(r,j-1):at(r,j-1))}}var vr=new WeakMap;function Ue(e){let t=[e.xField,e.xAxis,e.yAxis,e.series,e.stack,e.style?.area],n=vr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domains;let r={x:Ne(e.xAxis,o=>ci(e,o)),y:Ne(e.yAxis,o=>fi(e,o))};return vr.set(e.data,{key:t,domains:r}),r}function Gr(e,t){let[n,r]=e.x.range,[o,i]=e.y.range;return{x:s=>r<=n?0:((s-n)/(r-n)-.5)*t.width,y:s=>i===o?0:((s-o)/(i-o)-.5)*t.height}}var hi={points:[],base:[],values:[]};function di(e,t,n,r){let o=tn(e)[n];if(!o)return hi;let i=Gr(t,r),s=([a,l])=>({x:i.x(a),y:i.y(l)});return{points:o.points.map(s),base:o.base?o.base.map(s):[],values:o.points.map(([,a],l)=>a-(o.base?.[l]?.[1]??0))}}function Er(e){let[t,n]=e.y.range;return Qt(0,Math.min(t,n),Math.max(t,n))}function pi(e,t){let[n,r]=ft(tn(e,!1)),[o,i]=pt(e).extent,s=(a,[l,c])=>a>=Math.min(l,c)-1e-9&&a<=Math.max(l,c)+1e-9;return!(s(n,t.y.range)&&s(r,t.y.range)&&s(o,t.x.range)&&s(i,t.x.range))}function gi(e,t,n){let{width:r,height:o}=n;return Ht(e.region,{left:-r/2,right:r/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function Lr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function Tr(e){return e!=null&&typeof e=="object"?e:{}}function mi([e,t]){return e<=t?[e,t]:[t,e]}function Cr(e,t){let n=mi(e);return{range:n,ticks:q(n,Math.max(2,t.length)-1)}}function Or(e,t,n){return{...t.x&&{xAxis:De(e.x,t.x,n)},...t.y&&{yAxis:De(e.y,t.y,n)}}}function _r(e,t,n){let r=e.yAxis.format;if(r!==void 0)return ai(t,r);let o=we(t,st(n));return e.stack==="percent"?`${o}%`:o}function xi(e,t){return Math.max(0,e.weights[t]??1)}function en(e){let t=nt(e);return{vAxis:t.find(Re.is)??null,hAxis:t.find(Ae.is)??null,lines:t.filter(ht.is),legend:t.find(Z.is)??null}}function Pr(e,t){let n=t.regionReveal,r=t.region;return n===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:r,regionReveal:n*(1-o)})}function Ir(e,t,n,r,o){let i=en(n),s=i.lines[r];if(!s)return e.wait(e.duration);let a=i.legend?[i.legend.run(o?"showSeries":"hideSeries",{index:r})]:[];if(t.stack==="none")return e.together([s.run("enter",o?{from:0,to:1}:{from:1,to:0}),...a]);let l=t.series.map((f,h)=>xi(t,h)),c=l[r]??1,u=o?1:0;return e.together([e.animate(f=>{let h=[...l];return h[r]=c+(u-c)*e.ease(f),{weights:h}},{eased:!1}),s.run("hold",{shown:o}),...a])}var nn=si({key:"lineChart",state:{data:y(()=>[],{kind:"dataset"}),xField:"",series:y(()=>[],{kind:"series"}),stack:Q.oneOf(["none","stacked","percent"]),xAxis:Q.custom({},{resolve:be,lerp:Be}),yAxis:Q.custom({},{resolve:be,lerp:Be}),style:li,region:Q.custom(null),regionReveal:0,home:Q.custom(null,{private:!0}),weights:Q.custom([],{private:!0}),clipped:Q.boolean(!1,{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ue(e),r,o=()=>ye(r),i=w=>di(e,n(),w,o()),s=e.series.map(w=>w.enabled??!0),a=e.style,l=()=>ke(t(),"y"),c=()=>ke(t(),"x"),u=()=>{let w=n().y.ticks;return w.map(b=>_r(e,b,w))},f=a.showYAxis?new Re({range:()=>n().y.range,markers:()=>n().y.ticks,captions:u,axis:l,label:e.yAxis.label??"",width:"hug",height:"fill"}):void 0,h=a.showXAxis?new Ae({range:()=>n().x.range,markers:()=>n().x.ticks,captions:()=>{let w=pt(e);return n().x.ticks.map(b=>w.label(b))},axis:c,label:e.xAxis.label??"",overhang:()=>({left:N(t()),right:N(t())}),width:"fill",height:"hug"}):void 0,d=f&&h?rt({captions:u,count:Ue(e).y.ticks.length,text:()=>l().labelStyle,title:e.yAxis.label??"",titleText:()=>l().titleStyle,tickPad:()=>oe(l(),"right").tick,titlePad:()=>oe(l(),"right").title}):void 0,p=()=>gi(e,n(),o()),g=()=>1-(1-D)*e.regionReveal,m=e.series.map((w,b)=>new ht({points:()=>i(b).points,curve:()=>t().curve,stroke:()=>({weight:t().strokeWidth,fill:G(t(),w,b),align:"center",cap:"round",join:"round"}),dotSize:()=>t().dots?t().dotSize:0,dotFill:()=>G(t(),w,b),enabled:s[b],spotlight:p,dimOpacity:g})),x=e.series.map((w,b)=>new qt({points:()=>i(b).points,base:()=>i(b).base,baseline:()=>Gr(n(),o()).y(Er(n())),curve:()=>t().curve,area:()=>t().area,fill:()=>G(t(),w,b),areaOpacity:()=>t().areaOpacity,progress:()=>m[b].progress,enabled:()=>m[b].enabled,opacity:()=>m[b].opacity,spotlight:p,dimOpacity:g})),S=[];if(a.values!=="none"){let w=a.values==="below";e.series.forEach((b,v)=>{e.data.forEach((F,E)=>{let L=m[v],ue=new ii({...fe(()=>({...ut(t()),fontSize:Math.round(t().fontSize*.8)})),text:()=>{let O=i(v).values[E];return O===void 0?"":_r(e,O,n().y.ticks)},x:()=>{let O=(o().width-ue.layoutBounds.width)/2;return Qt(i(v).points[E]?.x??0,-Math.max(0,O),Math.max(0,O))},y:()=>{let O=i(v).points[E],re=ue.layoutBounds.height/2+(t().dots?t().dotSize/2:t().strokeWidth/2)+Math.round(t().fontSize*.25);return(O?.y??0)+(w?-re:re)},opacity:()=>{let O=i(v).points[E];if(!L.enabled||!O)return 0;let re=Xe(i(v).points,L.progress);return L.opacity*(re===1/0?1:Qt((re-O.x)/24,0,1))}});S.push(ue)})})}let M=a.legend,R=M!=="none"?new Z({series:e.series,swatches:()=>e.series.map((w,b)=>G(t(),w,b)),legend:()=>B(t()),flow:M==="right"?"vertical":"horizontal"}):void 0;return r=new oi({clip:()=>e.clipped||pi(e,n()),children:[new ot({fill:()=>t().background,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:()=>n().x.ticks,yMarkers:()=>n().y.ticks,xExtent:()=>n().x.range,yExtent:()=>n().y.range,axisStroke:()=>t().axisStroke,xAxisAt:()=>Er(n()),yAxisAt:()=>n().x.range[0]}),new Zt({box:p,stroke:()=>({weight:2,fill:Ge(t().foreground,.7),dash:[14,12],cap:"butt",align:"center"}),fill:()=>Ge(t().foreground,.06),reveal:()=>e.regionReveal}),...x,...m,...S]}),[tt({left:f,ghost:d,plot:r,bottom:h,legend:R,legendAt:M,gap:()=>Qe(t()),padding:()=>({top:et(t()),right:h?N(t()):0,left:h&&!f?N(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:le(),run:(e,t,n)=>{let r=en(n),o=e.duration,i=Lr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*I.axes,l=s*I.marks,{legend:c}=r,u=h=>({at:0,duration:0,piece:h}),f=it(t.style.legend);return z(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...r.lines.map(h=>u(h.to({progress:0}))),...c?[u(c.to({opacity:0,...f}))]:[],...r.vAxis?[{at:0,duration:a,piece:r.vAxis.run("enter",{slide:24})}]:[],...r.hAxis?[{at:0,duration:a,piece:r.hAxis.run("enter",{slide:24})}]:[],...r.lines.map(h=>({at:a,duration:l,piece:h.run("enter")})),...c?[{at:a+l,duration:s*I.legend,piece:c.to({opacity:1,x:0,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(h=>({regionReveal:h}))}]:[],{at:0,duration:o,piece:e.wait(o)}])}},spotlightRegion:{args:{region:Mr},easing:le(),run:(e,t)=>{let n=Tr(e.args.region),r=t.regionReveal,o=t.region;return n.x===void 0&&n.y===void 0?Pr(e,t):r<=0||!Lr(t)?e.animate(i=>({region:n,regionReveal:r+(1-r)*i})):e.animate(i=>i<.5?{region:o,regionReveal:r*(1-e.ease(i*2))}:{region:n,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:le(),run:(e,t)=>Pr(e,t)},zoomTo:{args:{region:Mr},easing:le(),run:(e,t)=>{let n=Tr(e.args.region);if(!n.x&&!n.y)return e.wait(e.duration);let r=Ue(t),o=t.home??r,i={...n.x&&{x:{...r.x,...Cr(n.x,r.x.ticks)}},...n.y&&{y:{...r.y,...Cr(n.y,r.y.ticks)}}};return e.animate(s=>({home:o,clipped:!0,...Or(r,i,s)}))}},resetZoom:{args:{},easing:le(),run:(e,t)=>{let n=t.home;if(!n)return e.wait(e.duration);let r=Ue(t);return e.animate(o=>({home:null,clipped:o<1,...Or(r,n,o)}))}},showSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>Ir(e,t,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>Ir(e,t,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>{let r=en(n),o=e.args.seriesIndex;return e.together([...r.lines.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}}}});import{Rect as Li,Types as ee,clamp as xn,component2d as Ti,easeOut as Le}from"@motionscript/sdk";import{formatNumber as Ci}from"@motionscript/sdk/component";import{Rect as rn,Text as Fr,Types as gt,clamp as yi,component2d as bi}from"@motionscript/sdk";import{enterBudget as wi}from"@motionscript/sdk/component";var Si=24;function Ve(e,t,n){return t<=0?0:-n/2+n/t*(e+.5)}var mt=bi({key:"categoryAxis",state:{categories:y(()=>[]),axis:gt.custom(er),label:"",orientation:gt.oneOf(["horizontal","vertical"]),dims:y(()=>[]),arrivals:Jn()},defaults:{width:"fill",height:"fill"},children:e=>{let t=e.categories.length,n=s=>yi(e.dims[s]??1,0,1);if(e.orientation==="vertical")return[tr({count:t,axis:()=>e.axis,text:s=>e.categories[s]??"",place:(s,a)=>-Ve(s,e.categories.length,a),arrivals:()=>e.arrivals,opacity:n,label:e.label})];let r=()=>oe(e.axis,"top"),o=e.categories.map((s,a)=>{let l=new rn({width:"hug",height:"hug",flow:"freeform",opacity:()=>n(a),x:()=>Ve(a,e.categories.length,l.parent?.layoutBounds.width??0),children:[new Fr({...fe(()=>e.axis.labelStyle),text:s,opacity:()=>Fe(e.arrivals,a).opacity,y:()=>Fe(e.arrivals,a).shift})]});return l}),i=[new rn({width:"fill",height:"hug",padding:()=>({top:r().tick}),children:o})];return e.label!==""&&i.push(new Fr({...fe(()=>e.axis.titleStyle),text:e.label,opacity:()=>Fe(e.arrivals,"label").opacity,y:()=>Fe(e.arrivals,"label").shift})),[new rn({flow:"vertical",gap:()=>r().title,height:"hug",width:"fill",children:i})]},commands:{enter:{args:{stagger:gt.custom(void 0),slide:gt.number(Si)},run:(e,t)=>{let{stagger:n,slide:r}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:r},a=[...t.categories.keys(),...i?["label"]:[]],l=e.animate(()=>({arrivals:Qn(a,s)}));if(o===0)return l;let{step:c,per:u,caption:f}=wi(e.duration,o,i,n),h=T(e),d=t.categories.map((g,m)=>({at:m*c,duration:u,piece:Bt(e,m,s,h)})),p=i?[{at:(o-1)*c+u,duration:f,piece:Bt(e,"label",s,h)}]:[];return e.together([l,z(e,[...d,...p])])}}}});import{Graphics2D as Ai,Text as ki,Types as un,clamp as fn,component2d as Mi,fillOps as Br}from"@motionscript/sdk";import{Types as xt,fillOps as Ri}from"@motionscript/sdk";function yt(e,t,n,r=[]){let o=h=>Math.max(0,r[h]??1);if(n!=="stacked"&&n!=="percent")return t.map(h=>{let d=k(e,h.field);return{from:0,to:d,value:d,outer:!0}});let i=t.map((h,d)=>k(e,h.field)*o(d)),s=i.reduce((h,d)=>h+Math.abs(d),0),a=n==="percent"?i.map(h=>s>0?h/s*100:0):i,l=-1,c=-1;a.forEach((h,d)=>{h>0?l=d:h<0&&(c=d)});let u=0,f=0;return a.map((h,d)=>{if(h<0){let g=f;return f+=h,{from:g,to:f,value:h,outer:d===c}}let p=u;return u+=h,{from:p,to:u,value:h,outer:d===l}})}function on(e,t){return e.map(n=>H(n,t))}function Dr(e,t,n,r){let o=0,i=0;for(let s of e)for(let a of yt(s,t,n,r))o=Math.min(o,a.from,a.to),i=Math.max(i,a.from,a.to);return o<i?[o,i]:[0,1]}function sn(e,t,n,r,o,i){if(r)return r;let[s,a]=Dr(e,t,n,i);return n==="percent"?[s<0?-100:0,a>0?100:0]:Se([s,a],o)}function an(e){let t=Ri.resolve(e),n=t[t.length-1];if(n?.type!=="solid")return"white";let[r,o,i]=n.color,s=l=>l<=.03928?l/12.92:((l+.055)/1.055)**2.4;return .2126*s(r)+.7152*s(o)+.0722*s(i)>.4?"#0a0a0a":"white"}var ln={barRadius:xt.number(10,{min:0,max:64,step:1,unit:"px"}),barWidth:xt.number(.7,{min:.05,max:1,step:.05}),barGap:xt.number(6,{min:0,max:40,step:1,unit:"px"})},cn={values:xt.oneOf(["none","end","inside"],{animatable:!1})};var vi=.6;function Nr(e,t){return e.enabled?fn(e.dims[t]??1,0,1):0}function hn(e,t){let n=e.bars[t];if(!n)return null;let r=fn(e.growth,0,1);return{base:e.baseline+(n.from-e.baseline)*r,end:e.baseline+(n.to-e.baseline)*r}}function Yr(e){return typeof e.fontSize=="number"?e.fontSize:24}function Hr(e,t,n){let r=hn(e,t);if(!r)return 0;if(e.values==="inside")return(r.base+r.end)/2;let o=r.end>=r.base?1:-1;return r.end+o*(Yr(e.valueStyle)*.4+n/2)}function Ei(e,t,n,r){let o=e.bars[t],i=hn(e,t);if(!o||!i)return!1;let s=Yr(e.valueStyle)*vi;return Math.abs(i.end-i.base)>=n+s&&o.thickness>=r}var bt=Mi({key:"chartBars",state:{bars:y(()=>[]),baseline:0,horizontal:!1,fill:un.custom([],{resolve:Br.resolve,lerp:Br.lerp}),cornerRadius:8,growth:1,dims:y(()=>[]),values:un.custom("none"),valueStyle:un.custom({fontSize:24,fill:"white"}),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.values==="none"?[]:e.bars.map((t,n)=>{let r=new ki({...fe(()=>({...e.valueStyle,...e.values==="inside"&&{fill:an(e.fill)}})),text:()=>e.bars[n]?.caption??"",x:()=>e.horizontal?Hr(e,n,r.layoutBounds.width):e.bars[n]?.center??0,y:()=>e.horizontal?e.bars[n]?.center??0:Hr(e,n,r.layoutBounds.height),opacity:()=>{let o=r.layoutBounds,i=e.horizontal?o.width:o.height,s=e.horizontal?o.height:o.width;return e.values==="inside"&&!Ei(e,n,i,s)?0:Nr(e,n)*fn((e.growth-.6)/.4,0,1)}});return r}),load:(e,t)=>C(e,{fills:[t.fill]}),commands:{enter:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))}},render:(e,t)=>{if(t.enabled)for(let n=0;n<t.bars.length;n++){let r=t.bars[n],o=hn(t,n);if(!o||r.thickness<=0)continue;let i=r.round?0:1,s=Math.abs(o.end-o.base)+i;if(s<=i)continue;let a=r.round?Math.max(0,Math.min(t.cornerRadius,s,r.thickness/2)):0,l=o.end>=o.base,c=(o.base+o.end)/2+(l?i:-i)/2,u=t.horizontal?l?{topRight:a,bottomRight:a,topLeft:0,bottomLeft:0}:{topLeft:a,bottomLeft:a,topRight:0,bottomRight:0}:l?{topLeft:a,topRight:a,bottomLeft:0,bottomRight:0}:{bottomLeft:a,bottomRight:a,topLeft:0,topRight:0},f=new Ai().rect(t.horizontal?{x:c,y:r.center,width:s,height:r.thickness,cornerRadius:a>0?u:0}:{x:r.center,y:c,width:r.thickness,height:s,cornerRadius:a>0?u:0});f.fill(t.fill),e.draw(f.opacity(Nr(t,n)))}e.children()}});var Oi=ee.style(Y,{colors:W,text:X,grid:lt,marks:ln,labels:cn,legend:U},{presets:V});function _i(e,t){let n=(t.ticks?.length??j)-1,r=sn(e.data,e.series,e.stack,t.range,n),o=t.range!==void 0||e.stack==="percent";return{...t,range:r,ticks:t.ticks??(o?q(r,j-1):at(r,j-1))}}var Wr=new WeakMap;function St(e){let t=[e.series,e.stack,e.valueAxis],n=Wr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domain;let r=Ne(e.valueAxis,o=>_i(e,o));return Wr.set(e.data,{key:t,domain:r}),r}function pn(e,t,n){let r=e.valueAxis.format;if(r!==void 0)return Ci(n,r);let o=we(n,st(t.ticks));return e.stack==="percent"?`${o}%`:o}function gn(e,t,n){let[r,o]=e.range;return o===r?-t/2:((n-r)/(o-r)-.5)*t}function dn(e){let[t,n]=e.range;return xn(0,Math.min(t,n),Math.max(t,n))}function wt(e,t){return Math.max(0,e.weights[t]??1)}function Vr(e,t){return e.orientation==="horizontal"?{along:t.width,across:t.height}:{along:t.height,across:t.width}}function Pi(e,t,n){let r=Ve(t,e.data.length,n);return e.orientation==="horizontal"?-r:r}function Ii(e,t,n){let r=e.series[t];if(!r)return[];let o=St(e),{along:i,across:s}=Vr(e,n),a=e.data.length,c=(a>0?s/a:0)*xn(e.style.barWidth,0,1),u=e.stack!=="none",f=0;for(let x=0;x<e.series.length;x++)f+=wt(e,x);let h=c/(f>0?f:1),d=wt(e,t),p=0;for(let x=0;x<t;x++)p+=wt(e,x);let g=e.series.length>1?e.style.barGap:0,m=e.style.values;return e.data.map((x,S)=>{let R=yt(x,e.series,e.stack,e.weights)[t]??{from:0,to:0,value:0,outer:!1},w=Pi(e,S,s),b=-c/2+h*p+h*d/2,v="";return m!=="none"&&R.value!==0&&(!u||m==="inside"||e.stack==="percent"?v=pn(e,o,u?R.value:k(x,r.field)):R.outer&&(v=pn(e,o,R.to))),{center:u?w:w+(e.orientation==="horizontal"?-b:b),thickness:u?c:Math.max(0,h*d-g),from:gn(o,i,R.from),to:gn(o,i,R.to),round:R.outer,caption:v}})}function Xr(e){let t=xn(e.spotlightReveal,0,1),n=e.spotlight;return e.data.map((r,o)=>t<=0||n===o?1:1-(1-D)*t)}function mn(e){let t=nt(e);return{valueAxis:t.find(n=>Re.is(n)||Ae.is(n))??null,categoryAxis:t.find(mt.is)??null,bars:t.filter(bt.is),legend:t.find(Z.is)??null}}function Ur(e,t,n,r,o){let i=mn(n);if(!i.bars[r])return e.wait(e.duration);let s=t.series.map((c,u)=>wt(t,u)),a=s[r]??1,l=t.series.map((c,u)=>t.showing[u]??c.enabled??!0);return e.together([e.animate(c=>{let u=[...s];u[r]=a+(o-a)*e.ease(c);let f=[...l];return f[r]=o>0||c<1,{weights:u,showing:f}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:r})]:[]])}var yn=Ti({key:"barChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),orientation:ee.oneOf(["vertical","horizontal"],{animatable:!1}),stack:ee.oneOf(["none","stacked","percent"]),valueAxis:ee.custom({},{resolve:be,lerp:Be}),categoryAxis:ee.custom({},{resolve:be,lerp:De}),style:Oi,growth:1,spotlight:ee.custom(null),spotlightReveal:0,weights:ee.custom([],{private:!0}),showing:ee.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>St(e),r,o=()=>ye(r),i=e.style,s=e.orientation==="horizontal",a=on(e.data,e.categoryField),l=()=>ke(t(),s?"x":"y"),c=()=>ke(t(),s?"y":"x"),u=()=>{let E=n();return E.ticks.map(L=>pn(e,E,L))},f=s?i.showXAxis:i.showYAxis,h=s?i.showYAxis:i.showXAxis,d=f?s?new Ae({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",overhang:()=>({left:N(t()),right:N(t())}),width:"fill",height:"hug"}):new Re({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",width:"hug",height:"fill"}):void 0,p=h?new mt({categories:a,axis:c,label:e.categoryAxis.label??"",orientation:s?"vertical":"horizontal",dims:()=>Xr(e),width:s?"hug":"fill",height:s?"fill":"hug"}):void 0,g=s?p:d,m=s?d:p,x=s?c:l,S=g&&m?rt({captions:s?()=>a:u,count:s?a.length:St(e).ticks.length,text:()=>x().labelStyle,title:(s?e.categoryAxis.label:e.valueAxis.label)??"",titleText:()=>x().titleStyle,tickPad:()=>oe(x(),"right").tick,titlePad:()=>oe(x(),"right").title}):void 0,M=e.series.map((E,L)=>new bt({bars:()=>Ii(e,L,o()),baseline:()=>gn(n(),Vr(e,o()).along,dn(n())),horizontal:s,fill:()=>G(t(),E,L),cornerRadius:()=>t().barRadius,growth:()=>e.growth,dims:()=>Xr(e),values:()=>i.values==="end"&&e.stack==="percent"?"inside":i.values,valueStyle:()=>({...ut(t()),fontSize:Math.round(t().fontSize*.85)}),enabled:()=>e.showing[L]??E.enabled??!0})),R=i.legend,w=R!=="none"?new Z({series:e.series,swatches:()=>e.series.map((E,L)=>G(t(),E,L)),legend:()=>B(t()),flow:R==="right"?"vertical":"horizontal"}):void 0,b=e.data.length,v=()=>Array.from({length:Math.max(0,b-1)},(E,L)=>L+1),F=()=>[0,Math.max(1,b)];return r=new Li({children:[new ot({fill:()=>t().background,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:s?()=>n().ticks:v,yMarkers:s?v:()=>n().ticks,xExtent:s?()=>n().range:F,yExtent:s?F:()=>n().range,axisStroke:()=>t().axisStroke,xAxisAt:()=>s?0:dn(n()),yAxisAt:()=>s?dn(n()):0}),...M]}),[tt({left:g,ghost:S,plot:r,bottom:m,legend:w,legendAt:R,gap:()=>Qe(t()),padding:()=>({top:et(t()),right:s&&m?N(t()):0,left:s&&m&&!g?N(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:Le(),run:(e,t,n)=>{let r=mn(n),o=e.duration,i=o*I.axes,s=o*I.marks,{legend:a}=r,l=c=>({at:0,duration:0,piece:c});return z(e,[l(e.animate(()=>({growth:0}))),...a?[l(a.to({opacity:0,...it(t.style.legend)}))]:[],...r.valueAxis?[{at:0,duration:i,piece:r.valueAxis.run("enter",{slide:24})}]:[],...r.categoryAxis?[{at:0,duration:i,piece:r.categoryAxis.run("enter",{slide:24})}]:[],{at:i,duration:s,piece:e.animate(c=>({growth:c}))},...a?[{at:i+s,duration:o*I.legend,piece:a.to({opacity:1,x:0,y:0})}]:[]])}},showSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>Ur(e,t,n,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>Ur(e,t,n,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>{let r=mn(n),o=e.args.seriesIndex;return e.together([...r.bars.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}},spotlightCategory:{args:{categoryIndex:ee.number(0,{min:0,step:1})},easing:Le(),run:(e,t)=>{let n=e.args.categoryIndex;if(n<0||n>=t.data.length)return e.wait(e.duration);let r=t.spotlightReveal;return e.animate(o=>({spotlight:n,spotlightReveal:r+(1-r)*o}))}},clearCategory:{args:{},easing:Le(),run:(e,t)=>{let n=t.spotlightReveal;if(n===0)return e.wait(e.duration);let r=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:r,spotlightReveal:n*(1-o)})}}}});import{Rect as co,Types as Tt,clamp as uo,component2d as Zi,easeOut as Oe}from"@motionscript/sdk";import{Graphics2D as Zr,PathBuilder as zi,Rect as An,Text as Te,Types as Ke,clamp as pe,component2d as Gi,strokeOps as Fi,textOps as Ce}from"@motionscript/sdk";import{Types as Rt}from"@motionscript/sdk";function wn(e,t,n,r){return e.map((o,i)=>({category:H(o,t),value:k(o,n),fill:r.length>0?r[i%r.length]:"white"}))}function Sn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Kr(e){let t=0;for(let n of e)t+=Sn(n);return t}function At(e,t){let n=Kr(e);if(n<=0)return[];let r=[],o=t*ve;return e.forEach((i,s)=>{let a=Sn(i);if(a<=0)return;let l=a/n,c=o,u=c+l*Math.PI*2;o=u,r.push({index:s,a0:c,a1:u,mid:(c+u)/2,fraction:l})}),r}function kt(e,t,n,r){e.sort((s,a)=>a.ideal-s.ideal);let o=n;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=r;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Rn={colors:W,text:X,marks:{innerRadius:Rt.number(0,{min:0,max:.9,step:.05}),sliceGap:Rt.number(3,{min:0,max:40,step:1,unit:"px"}),sliceRadius:Rt.number(4,{min:0,max:60,step:1,unit:"px"})},labels:{labelPlacement:Rt.oneOf(["inside","outside","none"],{animatable:!1})},legend:U};function Mt(e){return B(e)}function bn(e){return e.fontFamily?{fontFamily:e.fontFamily}:{}}function $r(e){return{gap:e.sliceGap,holeRadius:e.innerRadius,startAngle:0,selectedGrow:1.08,cornerRadius:e.sliceRadius}}function jr(e){let t={...bn(e),fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:"center",fill:e.muted},n=Math.min(900,e.fontWeight+200);return{textStyle:t,percentStyle:{...t,fontWeight:n,fill:e.foreground},insideStyle:{...t,fontSize:Math.round(e.fontSize*1.9),fontWeight:n,fill:"#111113"},leaderStroke:{weight:2,fill:e.muted}}}function qr(e){return{labelStyle:{...bn(e),fontSize:Math.round(e.fontSize*1.8),fontWeight:Math.min(900,e.fontWeight+300),textAlign:"center",fill:e.foreground},captionStyle:{...bn(e),fontSize:Math.round(e.fontSize*.8),fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}}var Di={gap:3,holeRadius:0,startAngle:0,selectedGrow:1.08,cornerRadius:4},Bi={textStyle:{fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},percentStyle:{fontSize:28,fontWeight:700,textAlign:"center",fill:"#f4f4f5"},insideStyle:{fontSize:52,fontWeight:700,textAlign:"center",fill:"#111113"},leaderStroke:{weight:2,fill:"#a1a1aa"}},Ni={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function Jr(e){let n=rr(e).find(s=>s.type==="solid");if(!n)return"#111113";let[r,o,i]=n.color;return .2126*r+.7152*o+.0722*i>.45?"#111113":"#ffffff"}var Qr=12,Hi=14,kn=.62,Yi=6,eo=34,to=26,no=8,Wi=.18,Xi=240,Ui=8,ro=2,io=.44,Mn=.62,Vi=.78,Ki=.9,oo=.001,so=26;function ce(e,t=so){let n=e.fontSize;return typeof n=="number"?n:t}function $i(e,t,n,r,o,i,s){let a=new zi,l=t-e,c=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*Xi)),u=A=>A<=0?0:Math.min(o/A,l/2.2),f=(A,P)=>{let xe=K(A,P);return{x:xe.x+s,y:xe.y}},h=n>0,d=e+u(r),p=t-u(r),g=e+u(n),m=t-u(n),x=f(r,d),S=f(r,p),M=Math.max(.001,Math.min(l/2,Math.PI/2)),R=f(o>0?Math.min(o/Math.sin(M),r*.8):0,(e+t)/2),w=h?f(n,g):R,b=h?f(n,m):R,v=h?r-n:r,F=Math.max(0,Math.min(i,v/2.2,(p-d)*r/2.2,h?(m-g)*n/2.2:1/0)),E=F>=.5,L=(A,P,xe)=>{let Ie=Math.hypot(P.x-A.x,P.y-A.y)||1,ze=Math.min(.5,xe/Ie);return{x:A.x+(P.x-A.x)*ze,y:A.y+(P.y-A.y)*ze}},ue=E?F/Math.max(1,r):0,O=E&&h?F/n:0,re=(A,P,xe)=>{for(let Ie=0;Ie<=c;Ie++){let ze=f(A,P+(xe-P)*Ie/c);a.lineTo(ze.x,ze.y)}},Je=(A,P)=>{E?a.quadraticCurveTo(A.x,A.y,P.x,P.y):a.lineTo(A.x,A.y)},Ft=f(r,d+ue);if(a.moveTo(Ft.x,Ft.y),re(r,d+ue,p-ue),Je(S,L(S,b,F)),h){let A=L(b,S,F);a.lineTo(A.x,A.y),Je(b,f(n,m-O)),re(n,m-O,g+O),Je(w,L(w,x,F))}else a.lineTo(R.x,R.y);let qn=L(x,w,E?F:0);return a.lineTo(qn.x,qn.y),Je(x,Ft),a.close(),a}var vt=class{s;box;constructor(t,n){this.s=t,this.box=n}get arcs(){return At(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="outside"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let n=this.outerRadius,r=this.holeRadius,o=r>0?n-r:n*(1-Mn)*2,i=r>0?(r+n)/2:n*Mn,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),l=s>oo?o/s:1/0,c=a>oo?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(l,c))}insideGlyphs(t){let n=this.s.labelMode,r=this.s.slices[t.index]?.category.length??0,o=n==="both"||n==="percent"?Nt(t.fraction).length:0,i=n==="category"?r:n==="both"?r*io:0;return Math.max(1,o,i)}get insideFont(){let t=ce(this.s.label.insideStyle,so*1.9);for(let n of this.arcs){let r=this.insideRoom(n)*Ki/(this.insideGlyphs(n)*kn);t=Math.min(t,r)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=ce(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=ce(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*Vi/(a*kn))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=ce(this.s.label.textStyle)*1.25,n=ce(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+n+2:this.s.labelMode==="category"?t:n}captionGlyphs(t){let n=this.s.labelMode,r=n==="percent"||n==="both"?4:0,o=n==="category"||n==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(r,o)}get labelGutters(){let t={left:ro,right:ro};if(!this.hasLeaderLabels)return t;let n=ce(this.s.label.textStyle)*kn;for(let r of this.arcs){let o=eo+to+no+this.captionGlyphs(r.index)*n+Hi,i=vn(r.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:n}=this.labelGutters;return(t-n)/2}get outerRadius(){let{left:t,right:n}=this.labelGutters,r=Math.min((this.box.width-t-n)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,r/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let n=t<1?t*this.outerRadius:t;return Math.min(n,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+eo}popOf(t){return pe(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let n=this.anchorRadius(t),r=this.holeRadius;return r>0?(r+n)/2:n*Mn}insideAnchor(t){let n=this.arcs.find(o=>o.index===t);if(n===void 0)return{x:this.centerX,y:0};let r=K(this.bandMidRadius(t),n.mid);return{x:r.x+this.centerX,y:r.y}}get selectionStrength(){let t=0;for(let n=0;n<this.s.slices.length;n++)t=Math.max(t,this.popOf(n));return t}sliceOpacity(t){return J(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let n=this.arcs.find(r=>r.index===t);return Nt(n?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let n=this.elbowRadius,r=this.labelRowHeight,o=this.box.height/2-r/2,i=-o,s=this.centerX,a=[],l=[];for(let c of t){let u=vn(c.mid),f=K(n,c.mid).y;(u>0?a:l).push({index:c.index,side:u,mid:c.mid,ideal:f,y:f})}return kt(a,r+Qr,o,i),kt(l,r+Qr,o,i),[...a,...l].map(c=>{let u=K(this.anchorRadius(c.index)+Yi,c.mid),f=Math.sqrt(Math.max(0,n*n-c.y*c.y)),h=s+c.side*Math.max(f,n*Wi),d=s+c.side*(n+to);return{index:c.index,side:c.side,leader:[{x:u.x+s,y:u.y},{x:h,y:c.y},{x:d,y:c.y}],text:{x:d+c.side*no,y:c.y}}})}placementFor(t){return this.placements().find(n=>n.index===t)}};function vn(e){return Math.sin(e)>=0?1:-1}var ji={width:0,height:0};function qi(e){let t=[],n=()=>new vt(e,t[0]?.parent?.layoutBounds??ji),r=o=>{let i=()=>pe(e.labelReveal,0,1)*n().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let f=[];return a&&f.push(new Te({...Ce.styleProps(e.label.insideStyle),text:()=>n().percentText(o.index),fill:()=>Jr(e.slices[o.index]?.fill??"white"),fontSize:()=>n().insideFont})),s&&f.push(new Te({...Ce.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fill:()=>Jr(e.slices[o.index]?.fill??"white"),fontSize:()=>e.labelMode==="category"?n().insideFont:n().insideFont*io})),new An({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>n().insideAnchor(o.index),children:f})}let l=vn(o.mid),c=()=>n().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new Te({...Ce.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:l>0?"left":"right"})),a&&u.push(new Te({...Ce.styleProps(e.label.percentStyle),text:()=>n().percentText(o.index),textAlign:l>0?"left":"right"})),new An({flow:"vertical",width:"hug",height:"hug",gap:2,align:l>0?"centerLeft":"centerRight",opacity:i,centerLeft:l>0?c:void 0,centerRight:l>0?void 0:c,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of At(e.slices,e.ring.startAngle))t.push(r(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Te({...Ce.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Te({...Ce.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(ce(e.centerStyle.captionStyle,22)/ce(e.centerStyle.labelStyle,46))})),t.push(new An({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>pe(e.centerReveal,0,1)*pe(n().holeRadius/20,0,1),center:()=>({x:n().centerX,y:0}),children:o}))}return t}var Et=Gi({key:"pieRing",state:{slices:y(()=>[]),ring:Ke.custom(Di),label:Ke.custom(Bi),centerStyle:Ke.custom(Ni),labelMode:Ke.custom("percent"),labelPlacement:Ke.custom("outside"),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:ie,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>qi(e),load:(e,t)=>C(e,{fills:Ee(t.slices),strokes:[Fi.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=T(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=T(e),r=pe(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new vt(t,e.size),r=n.outerRadius,o=r>0?n.arcs:[];if(o.length>0){let i=pe(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=n.holeRadius,l=Math.max(0,t.ring.gap)/2,c=n.centerX,u=r+n.maxPop+1+Math.abs(c),f=[-u,-u,u,u],h=u*2,d=Ee(t.slices);for(let g of o){let m=Math.min(g.a1,s);if(m<=g.a0)continue;let x=$i(g.a0,m,a,n.anchorRadius(g.index),l,Math.max(0,t.ring.cornerRadius),c),S=new Zr().path(x.toPathState({centerBounds:f,width:h,height:h}));S.fill(d[g.index]??[]),e.draw(S.opacity(n.sliceOpacity(g.index)))}let p=pe(t.labelReveal,0,1);if(p>.001)for(let g of n.placements())e.draw(new Zr().line({points:g.leader,radius:Ui}).stroke(t.label.leaderStroke).opacity(p*n.sliceOpacity(g.index)))}e.children()}});var Ji=.65,Qi=.35,En=Tt.number(0,{min:0,step:1});function ao(e){return wn(e.data,e.categoryField,e.valueField,e.data.map((t,n)=>ct(e.style,n)))}function _e(e,t){return uo(e.pops[t]??0,0,1)}function es(e,t){return _e(e,t)>.5}function ts(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,_e(e,n));return e.data.map((n,r)=>J(t,ie,_e(e,r)))}function Lt(e,t,n){let r=t.data.map((i,s)=>_e(t,s)),o=t.data.map((i,s)=>uo(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function lo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=co.is(n)?n.children.find(Et.is):void 0;if(r)return{ring:r,legend:n.children.find(Me.is)??null}}return null}var Ln=Zi({key:"pieChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",style:Tt.style(Y,Rn,{presets:V}),labelMode:Tt.custom("percent"),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:Tt.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>ao(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>ao(e),r=[new Et({width:"fill",height:"fill",slices:n,ring:()=>$r(t()),label:()=>jr(t()),centerStyle:()=>qr(t()),labelMode:e.labelMode,labelPlacement:e.style.labelPlacement,pops:()=>e.pops,dimOpacity:ie,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=new Me({slices:n,legend:()=>Mt(t()),dims:()=>ts(e),flow:s?"vertical":"horizontal",align:"center",gap:s?Mt(e.style).itemGap/3:Mt(e.style).itemGap,padding:0});o==="top"?r.unshift(a):r.push(a)}let i=new co({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:Oe(),run:(e,t,n)=>{let r=lo(n);if(!r)return e.wait(e.duration);let{ring:o,legend:i}=r,s=e.duration*Ji,a=e.duration*Qi,l=c=>({at:0,duration:0,piece:c});return z(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:Oe(),run:(e,t,n)=>lo(n)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?1:_e(t,r))}},deselectSlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?0:_e(t,r))}},selectOnlySlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?1:0)}},clearSelection:{args:{},easing:Oe(),run:(e,t)=>Lt(e,t,()=>0)}}});import{Rect as Pe,Text as cs,Types as us,component2d as fs,easeOut as Pt,textOps as hs}from"@motionscript/sdk";import{Graphics2D as bo,Types as zn,clamp as ss,component2d as as,strokeOps as Ct}from"@motionscript/sdk";import{Types as te}from"@motionscript/sdk";var Cn={gridShape:te.oneOf(["polygon","circle"]),gridLevels:te.number(4,{min:1,max:10,step:1}),gridStroke:te.stroke({weight:2,fill:"white/15"}),spokeStroke:te.stroke({weight:2,fill:"white/15"}),spokeLabels:te.boolean(!0,{animatable:!1})},On={strokeWidth:te.number(4,{min:0,max:24,step:1,unit:"px"}),areaOpacity:te.number(.25,{min:0,max:1,step:.05}),dots:te.boolean(!0),dotSize:te.number(10,{min:2,max:40,step:1,unit:"px"})},ns=.55,rs=.58,Tn=10,fo=.35;function ne(e,t){let n=e/Math.max(1,t)*Math.PI*2;return{x:Math.sin(n),y:Math.cos(n)}}function _n(e,t){return e.map(n=>H(n,t))}function ho(e,t){return t.map(n=>e.map(r=>k(r,n.field)))}var os=[1,1.2,1.5,2,2.5,3,4,5,6,8,10];function po(e){if(!(e>0))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(os.find(o=>o>=n-1e-9)??10)*t}function go(e,t,n){if(n>t)return{min:t,max:n};let r=t;for(let i of e)for(let s of i)r=Math.max(r,s);let o=po(r-t);return{min:t,max:t+o}}function mo(e,t){let n=t.max-t.min;return n<=0?0:Math.min(1,Math.max(0,(e-t.min)/n))}function Pn(e,t){let{x:n,y:r}=ne(e,t);return n>fo?"centerLeft":n<-fo?"centerRight":r>=0?"bottomCenter":"topCenter"}function xo(e){return e*ns}function is(e,t){return{width:e.length*t*rs,height:t*1.25}}function In(e,t,n,r){let o=Math.min(e.width,e.height)/2-Tn;if(!r)return Math.max(0,o);let i=xo(n),s=t.length;return t.forEach((a,l)=>{let{x:c,y:u}=ne(l,s),f=is(a,n),h=Pn(l,s),d=h==="centerLeft"||h==="centerRight"?f.width:f.width/2,p=h==="bottomCenter"||h==="topCenter"?f.height:f.height/2;Math.abs(c)>1e-6&&(o=Math.min(o,(e.width/2-d-Tn/2)/Math.abs(c)-i)),Math.abs(u)>1e-6&&(o=Math.min(o,(e.height/2-p-Tn/2)/Math.abs(u)-i))}),Math.max(0,o)}function yo(e,t,n,r){let{x:o,y:i}=ne(e,t),s=n+xo(r);return{x:o*s,y:i*s}}var $e=as({key:"radarGrid",state:{count:0,radius:0,levels:4,shape:zn.custom("polygon"),stroke:zn.custom([],{resolve:Ct.resolve,lerp:Ct.lerp}),spokeStroke:zn.custom([],{resolve:Ct.resolve,lerp:Ct.lerp}),reveal:1},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{strokes:[t.stroke,t.spokeStroke]}),render:(e,t)=>{let n=ss(t.reveal,0,1),r=t.radius*n;if(r<=0||n<=0)return;let o=Math.max(0,Math.round(t.count)),i=Math.max(1,Math.round(t.levels)),s=t.shape==="circle"||o<3;for(let a=1;t.stroke.length>0&&a<=i;a++){let l=r*a/i,c=new bo;if(s)c.ellipse({width:l*2,height:l*2});else{let u=[];for(let f=0;f<o;f++){let h=ne(f,o);u.push({x:h.x*l,y:h.y*l})}c.line({points:u,closed:!0})}e.draw(c.stroke(t.stroke).opacity(n))}if(t.spokeStroke.length!==0)for(let a=0;a<o;a++){let l=ne(a,o);e.draw(new bo().line({points:[{x:0,y:0},{x:l.x*r,y:l.y*r}]}).stroke(t.spokeStroke).opacity(n))}}});import{Graphics2D as Gn,Types as Ot,clamp as wo,component2d as ls,fillOps as So,strokeOps as Ro}from"@motionscript/sdk";function Ao(e,t,n=1){return e.map((r,o)=>{let i=ne(o,e.length),s=t*r*n;return{x:i.x*s,y:i.y*s}})}var _t=ls({key:"radarSeries",state:{fractions:y(()=>[]),radius:0,fill:Ot.custom([],{resolve:So.resolve,lerp:So.lerp}),stroke:Ot.custom([],{resolve:Ro.resolve,lerp:Ro.lerp}),areaOpacity:.25,dots:!0,dotSize:10,progress:1,enabled:!0},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),commands:{enter:{args:{from:Ot.number(0,{min:0,max:1}),to:Ot.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=T(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let n=wo(t.progress,0,1);if(n<=0||t.radius<=0||t.fractions.length===0)return;let r=Ao(t.fractions,t.radius,n);if(r.length>=2){let o=new Gn().line({points:r,closed:!0});t.areaOpacity>0&&t.fill.length>0&&e.draw(o.fill(t.fill).opacity(wo(t.areaOpacity,0,1))),t.stroke.length>0&&e.draw(new Gn().line({points:r,closed:!0}).stroke(t.stroke))}if(t.dots&&t.dotSize>0&&t.fill.length>0){let o=new Gn;for(let i of r)o.ellipse({x:i.x,y:i.y,width:t.dotSize,height:t.dotSize});e.draw(o.fill(t.fill))}}});function vo(e){return go(ho(e.data,e.series),e.min,e.max)}function Eo(e,t){let n=e.series[t];if(!n)return[];let r=vo(e);return e.data.map(o=>{let i=o[n.field];return mo(typeof i=="number"&&Number.isFinite(i)?i:0,r)})}function Fn(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Pe.is(n))continue;let r=n.children.find(o=>Pe.is(o)&&o.children.some($e.is));if(r)return{grid:r.children.find($e.is),series:r.children.filter(_t.is),labels:r.children.find(Pe.is)??null,legend:n.children.find(Z.is)??null}}return null}function ko(e,t,n,r){let o=Fn(t),i=o?.series[n];return!o||!i?e.wait(e.duration):e.together([i.run("enter",r?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(r?"showSeries":"hideSeries",{index:n})]:[]])}var Mo=.3,Dn=fs({key:"radarChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),min:0,max:0,style:us.style(Y,{colors:W,text:X,grid:Cn,marks:On,legend:U},{presets:V})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.style,n,r=()=>ye(n),o=()=>In(r(),_n(e.data,e.categoryField),t().fontSize,t().spokeLabels),i=e.data.length,s=e.series.map(d=>d.enabled??!0),a=new $e({count:()=>e.data.length,radius:o,levels:()=>t().gridLevels,shape:()=>t().gridShape,stroke:()=>t().gridStroke,spokeStroke:()=>t().spokeStroke}),l=e.series.map((d,p)=>new _t({fractions:()=>Eo(e,p),radius:o,fill:()=>G(t(),d,p),stroke:()=>{let g=t().strokeWidth;return g>0?{weight:g,fill:G(t(),d,p),align:"center",join:"round"}:[]},areaOpacity:()=>t().areaOpacity,dots:()=>t().dots,dotSize:()=>t().dotSize,enabled:s[p]})),c=[a,...l];if(e.style.spokeLabels){let d=[];for(let p=0;p<i;p++){let g=Pn(p,i),m=g==="centerLeft"?"left":g==="centerRight"?"right":"center",x=()=>yo(p,i,o(),t().fontSize);d.push(new cs({...hs.styleProps(nr(e.style,m)),text:()=>_n(e.data,e.categoryField)[p]??"",fontSize:()=>t().fontSize,fontWeight:()=>t().fontWeight,fill:()=>t().muted,[g]:x}))}c.push(new Pe({width:"fill",height:"fill",children:d}))}n=new Pe({width:"fill",height:"fill",children:c});let u=[n],f=e.style.legend;if(f!=="none"){let d=f==="right",p=B(e.style),g=new Z({series:e.series,swatches:()=>e.series.map((m,x)=>G(t(),m,x)),legend:()=>B(t()),flow:d?"vertical":"horizontal",gap:d?Math.round(p.itemGap/2):p.itemGap,padding:p.padding});f==="top"?u.unshift(g):u.push(g)}let h=new Pe({flow:f==="right"?"horizontal":"vertical",width:"fill",height:"fill",gap:24,align:"center",fill:()=>t().background,children:u});return[h]},commands:{enter:{args:{},entrance:!0,easing:Pt(),run:(e,t,n)=>{let r=Fn(n);if(!r)return e.wait(e.duration);let o=e.duration,i=o*I.axes,s=o*I.marks,a=o*I.legend,l=Math.max(1,r.series.length),c=s/(1+Mo*(l-1)),{legend:u,labels:f}=r,h=d=>({at:0,duration:0,piece:d});return z(e,[h(r.grid.to({reveal:0})),...r.series.map(d=>h(d.to({progress:0}))),...f?[h(f.to({opacity:0}))]:[],...u?[h(u.to({opacity:0,y:-Zn}))]:[],{at:0,duration:i,piece:r.grid.to({reveal:1})},...r.series.map((d,p)=>({at:i+p*c*Mo,duration:c,piece:d.to({progress:1})})),...f?[{at:i+s*.6,duration:a+s*.4,piece:f.to({opacity:1})}]:[],...u?[{at:i+s,duration:a,piece:u.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>ko(e,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>ko(e,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>{let r=Fn(n);if(!r)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...r.series.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Bo,Types as $n,clamp as No,component2d as vs,easeOut as zt}from"@motionscript/sdk";import{Graphics2D as _o,PathBuilder as ps,Rect as Po,Text as Un,Types as je,clamp as me,component2d as gs,fillOps as ms,textOps as Vn}from"@motionscript/sdk";import{Types as ge,clamp as ds}from"@motionscript/sdk";function Nn(e,t,n,r){return e.map((o,i)=>({category:H(o,t),value:k(o,n),fill:ct(r,i)}))}function Hn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Lo(e,t){if(t>0&&Number.isFinite(t))return t;let n=0;for(let r of e)n=Math.max(n,Hn(r));return n>0?n:1}function Yn(e,t){let n=Lo(e,t);return e.map(r=>ds(Hn(r)/n,0,1))}var Wn={colors:W,text:X,marks:{innerRadius:ge.number(.3,{min:0,max:.9,step:.05}),ringGap:ge.number(8,{min:0,max:60,step:1,unit:"px"}),sweep:ge.number(360,{min:30,max:360,step:5,unit:"deg"}),startAngle:ge.number(0,{min:-360,max:360,step:5,unit:"deg"}),track:ge.fill("white/10"),roundCaps:ge.boolean(!0)},labels:{ringLabels:ge.boolean(!1)},legend:U};function To(e){return{innerRadius:e.innerRadius,ringGap:e.ringGap,sweep:e.sweep,startAngle:e.startAngle,track:e.track.length>0,roundCaps:e.roundCaps}}function Xn(e){return B(e)}function Bn(e){return e.fontFamily?{fontFamily:e.fontFamily}:{}}function Co(e){return{...Bn(e),fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}function Oo(e){return{labelStyle:{...Bn(e),fontSize:Math.round(e.fontSize*1.8),fontWeight:Math.min(900,e.fontWeight+300),textAlign:"center",fill:e.foreground},captionStyle:{...Bn(e),fontSize:Math.round(e.fontSize*.8),fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}}var Io=.12,xs=.12,ys=4*ve,zo=10,bs=.78,ws=.62,Go=4,Ss={innerRadius:.3,ringGap:8,sweep:360,startAngle:0,track:!0,roundCaps:!0},Rs={fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},As={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function qe(e,t){return typeof e.fontSize=="number"?e.fontSize:t}var Ze=class{s;box;constructor(t,n){this.s=t,this.box=n}get count(){return this.s.rows.length}get outerRadius(){return Math.max(0,Math.min(this.box.width,this.box.height)/2-Go)}get holeRadius(){return me(this.s.marks.innerRadius,0,.9)*this.outerRadius}get thickness(){let t=this.count;return t===0?0:Math.max(0,(this.outerRadius-this.holeRadius-(t-1)*Math.max(0,this.s.marks.ringGap))/t)}ringOuter(t){return this.outerRadius-t*(this.thickness+Math.max(0,this.s.marks.ringGap))}ringMid(t){return this.ringOuter(t)-this.thickness/2}get fractions(){return Yn(this.s.rows,this.s.max)}get startRad(){return this.s.marks.startAngle*ve}get sweepRad(){return me(this.s.marks.sweep,0,360)*ve}popOf(t){return me(this.s.pops[t]??0,0,1)}get selectionStrength(){let t=0;for(let n=0;n<this.count;n++)t=Math.max(t,this.popOf(n));return t}ringOpacity(t){return J(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}progress(t,n){let r=1+Io*Math.max(0,this.count-1);return me(n*r-t*Io,0,1)}get labelFont(){return Math.max(1,Math.min(qe(this.s.label,28),this.thickness*.62))}labelAnchor(t){let n=this.startRad,r={x:-Math.cos(n),y:Math.sin(n)},o=K(this.ringMid(t),n),i=r.x<=0?-1:1;return{at:{x:o.x+r.x*zo,y:o.y+r.y*zo},side:i}}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=qe(t.labelStyle,50),i=this.holeRadius;if(i<=0)return o;let s=qe(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*bs/(a*ws))}};function Kn(e,t,n,r,o){let i=new ps,s=(n+r)/2,a=(r-n)/2,l=o&&s>0?Math.min(a/s,(t-e)/2):0,c=e+l,u=t-l,f=Math.max(2,Math.ceil(Math.abs(u-c)/ys)),h=(p,g,m,x)=>{for(let S=0;S<=f;S++){let M=K(p,g+(m-g)*S/f);x&&S===0?i.moveTo(M.x,M.y):i.lineTo(M.x,M.y)}},d=(p,g,m)=>{let x=K(s,p),S={x:Math.sin(p),y:Math.cos(p)},M={x:Math.cos(p)*g,y:-Math.sin(p)*g},R=12;for(let w=1;w<R;w++){let b=Math.PI*w/R,v=m?Math.cos(b):-Math.cos(b);i.lineTo(x.x+a*(S.x*v+M.x*Math.sin(b)),x.y+a*(S.y*v+M.y*Math.sin(b)))}};return h(r,c,u,!0),o&&d(u,1,!0),h(n,u,c,!1),o&&d(c,-1,!1),i.close(),i}var ks={width:0,height:0};function Ms(e){let t=[],n=()=>new Ze(e,t[0]?.parent?.layoutBounds??ks),r=n().labelAnchor(0).side;if(e.rows.forEach((o,i)=>{let s=()=>n().labelAnchor(i).at;t.push(new Po({flow:"vertical",width:"hug",height:"hug",align:r>0?"centerLeft":"centerRight",opacity:()=>e.ringLabels?me(e.labelReveal,0,1)*n().ringOpacity(i):0,centerLeft:r>0?s:void 0,centerRight:r>0?void 0:s,children:[new Un({...Vn.styleProps(e.label),text:()=>e.rows[i]?.category??"",textAlign:r>0?"left":"right",fontSize:()=>n().labelFont})]}))}),e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Un({...Vn.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Un({...Vn.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(qe(e.centerStyle.captionStyle,22)/qe(e.centerStyle.labelStyle,50))})),t.push(new Po({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>me(e.centerReveal,0,1),center:{x:0,y:0},children:o}))}return t}var It=gs({key:"radialRings",state:{rows:y(()=>[]),max:0,marks:je.custom(Ss),label:je.custom(Rs),centerStyle:je.custom(As),trackFill:je.fill("white/15"),ringLabels:je.boolean(!1),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:.25,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Ms(e),load:(e,t)=>C(e,{fills:[...Ee(t.rows),ms.resolve(t.trackFill)]}),commands:{sweep:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=T(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=T(e),r=me(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new Ze(t,e.size),r=n.thickness;if(n.outerRadius>0&&n.count>0&&r>0){let o=n.outerRadius+Go+1,i={centerBounds:[-o,-o,o,o],width:o*2,height:o*2},s=Ee(t.rows),a=n.fractions,l=n.startRad,c=t.marks.roundCaps,u=[...t.rows.keys()].sort((f,h)=>n.popOf(f)-n.popOf(h));for(let f of u){let h=r*xs*n.popOf(f),d=n.ringOuter(f)+h,p=n.ringOuter(f)-r-h,g=n.ringOpacity(f);t.marks.track&&n.sweepRad>0&&e.draw(new _o().path(Kn(l,l+n.sweepRad,p,d,c).toPathState(i)).fill(t.trackFill).opacity(g));let m=n.sweepRad*a[f]*n.progress(f,t.growth);m<=1e-4||e.draw(new _o().path(Kn(l,l+m,p,d,c).toPathState(i)).fill(s[f]??[]).opacity(g))}}e.children()}});var Es=.7,Ls=.3;function Ts(e){return Nn(e.data,e.categoryField,e.valueField,e.style)}function Gt(e,t){return No(e.pops[t]??0,0,1)}function Cs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Gt(e,n));return e.data.map((n,r)=>J(t,Ho,Gt(e,r)))}var Ho=Math.max(ie,.25);function Fo(e,t,n){let r=t.data.map((i,s)=>Gt(t,s)),o=t.data.map((i,s)=>No(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function Do(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=Bo.is(n)?n.children.find(It.is):void 0;if(r)return{rings:r,legend:n.children.find(Me.is)??null}}return null}var jn=vs({key:"radialChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",max:$n.number(0,{min:0,step:1}),style:$n.style(Y,Wn,{presets:V}),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:$n.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>e.data.map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ts(e),r=[new It({width:"fill",height:"fill",rows:n,max:()=>e.max,marks:()=>To(t()),label:()=>Co(t()),centerStyle:()=>Oo(t()),trackFill:()=>t().track,ringLabels:()=>t().ringLabels,pops:()=>e.pops,dimOpacity:Ho,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=Xn(e.style),l=new Me({slices:n,legend:()=>Xn(t()),dims:()=>Cs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?a.itemGap/3:a.itemGap,padding:0});o==="top"?r.unshift(l):r.push(l)}let i=new Bo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:zt(),run:(e,t,n)=>{let r=Do(n);if(!r)return e.wait(e.duration);let{rings:o,legend:i}=r,s=e.duration*Es,a=e.duration*Ls,l=c=>({at:0,duration:0,piece:c});return z(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:zt(),run:(e,t,n)=>Do(n)?.rings.run("revealCenter")??e.wait(e.duration)},selectRing:{args:{ringIndex:_},easing:zt(),run:(e,t)=>{let n=e.args.ringIndex;return Fo(e,t,r=>r===n?1:Gt(t,r))}},clearSelection:{args:{},easing:zt(),run:(e,t)=>Fo(e,t,()=>0)}}});var Os=[nn,yn,Ln,Dn,jn];export{cn as BAR_LABELS,ln as BAR_MARKS,yn as BarChart,lt as CARTESIAN_GRID,W as CHART_COLORS,U as CHART_LEGEND,Gs as CHART_PALETTE_DEFAULT,Y as CHART_STYLE_FAMILY,V as CHART_STYLE_PRESETS,X as CHART_TEXT,mt as CategoryAxis,qt as ChartArea,bt as ChartBars,ot as ChartCanvas,Z as ChartLegend,ht as ChartLine,Zt as ChartRegion,Is as DEFAULT_LEGEND,j as DEFAULT_MARKERS,er as DEFAULT_X_AXIS,Ps as DEFAULT_Y_AXIS,ve as DEG,de as EMPTY_REGION_BOX,I as ENTER_SHARE,kr as EVERY_SAMPLE,Ae as HorizontalAxis,Zn as LEGEND_SLIDE,$t as LINE_LABELS,Kt as LINE_MARKS,nn as LineChart,Os as NODES,ie as PIE_SPOTLIGHT_DIM,Rn as PIE_STYLE_GROUPS,Ln as PieChart,Me as PieLegend,Et as PieRing,Cn as RADAR_GRID,On as RADAR_MARKS,Wn as RADIAL_STYLE_GROUPS,Dn as RadarChart,$e as RadarGrid,_t as RadarSeries,jn as RadialChart,Ze as RadialGeometry,It as RadialRings,_ as SERIES_ARG,D as SPOTLIGHT_DIM,Re as VerticalAxis,hr as areaFill,Qn as armed,Bt as arrival,Fe as arrivalOf,Jn as arrivalsEntry,$ as asParts,ke as axisConfigOf,oe as axisPads,Kn as bandPath,on as barCategories,St as barChartDomain,yt as barSpans,Dr as barValueExtent,z as beats,fe as boundText,tr as captionColumn,tt as cartesianFrame,nt as chartViews,Vt as clipPolygonToBox,Yt as clipPolylineToBox,rt as columnGhost,Xt as curvePoints,Ut as cutAt,Ge as fade,In as fitRadius,Ar as formatInstant,we as formatMarker,Nt as formatPercent,T as frameEase,Qe as frameGap,y as fresh,se as hasRegion,et as headroom,an as inkOn,es as isSliceSelected,ye as laidOutSize,it as legendAway,B as legendConfigOf,De as lerpAxisDomain,Be as lerpAxisEntry,Ue as lineChartDomains,C as loadPaints,zs as markerCaption,st as markerStep,nr as markerText,q as markerValues,po as niceCeil,Se as niceRange,at as niceTicks,k as num,_s as numericFields,N as overhang,ct as paletteFill,Rr as parseInstant,At as pieArcs,Eo as radarFractions,vo as radarScale,Yn as radialFractions,Lo as radialMax,kt as relaxLabels,be as resolveAxisDomain,sn as resolveBarScale,wn as resolvePieSlices,Nn as resolveRadialRows,Ht as resolveRegionBox,Jt as resolveXScale,Uo as resolveYScale,rr as resolvedFill,Ee as ringFills,K as ringPoint,Hn as rowValue,Dt as rule,J as selectionFade,G as seriesFill,Xo as seriesPoints,Ao as seriesVertices,Ne as settleAxisDomain,Kr as sliceTotal,Sn as sliceValue,Ve as slotCentre,ne as spokeDirection,ft as stackExtent,Wt as stackSeries,H as text,Fs as titleText,Xe as traceX,ut as valueText,ar as yExtent};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|