{
  "name": "cai-visual-sdk",
  "type": "registry:ui",
  "description": "CAI Visual SDK with original Fun Isometric animations and layered tiles",
  "files": [
    {
      "path": "sdk/visual/index.ts",
      "target": "sdk/visual/index.ts",
      "content": "export * from \"./isometric\"\nexport { CaiVisualTile, CaiVisualGrid, CaiVisualGridItem, CaiVisualScene, type CaiVisualTileProps, type CaiVisualLayer, type CaiVisualSize, type CaiSceneNode, type CaiSceneConnection } from \"./visual-tile\"\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/index.ts",
      "target": "sdk/visual/isometric/index.ts",
      "content": "export { ICONS as caiIsometricIcons } from \"./upstream/icons\"\nexport { brand, mono, hue, PALETTES, VIEWS, RISO, clock, paint, draw, play, FPS } from \"./upstream/fun\"\nexport type { Icon, Palette, Motion, View, PlayOptions, Player } from \"./upstream/fun\"\nexport * as caiIsometricMotions from \"./upstream/motions\"\nexport { CaiIsometric, type CaiIsometricProps } from \"./player\"\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/player.tsx",
      "target": "sdk/visual/isometric/player.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useRef, useMemo, type CSSProperties } from \"react\"\nimport { ICONS } from \"./upstream/icons\"\nimport { brand, paint, play, type Palette, type Player } from \"./upstream/fun\"\n\nexport type CaiIsometricProps = {\n  illustration: string\n  palette?: Partial<Palette>\n  primary?: string\n  secondary?: string\n  playback?: \"loop\" | \"once\" | \"on-hover\" | \"static\" | \"frame\"\n  frame?: number\n  delay?: number\n  className?: string\n  style?: CSSProperties\n  label?: string\n  decorative?: boolean\n}\n\nexport function CaiIsometric({ illustration, palette, primary = \"#10b981\", secondary, playback = \"loop\", frame = 0, delay = 0, className, style, label, decorative = true }: CaiIsometricProps) {\n  const canvas = useRef<HTMLCanvasElement>(null)\n  const player = useRef<Player | null>(null)\n  const icon = ICONS.find(item => item.name === illustration)\n  const paletteKey = JSON.stringify(palette ?? {})\n  const colors = useMemo(() => ({ ...brand(primary, secondary), ...JSON.parse(paletteKey) as Partial<Palette> }), [primary, secondary, paletteKey])\n  useEffect(() => {\n    const el = canvas.current\n    if (!el || !icon) return\n    const media = window.matchMedia(\"(prefers-reduced-motion: reduce)\")\n    let resize: ResizeObserver | undefined\n    let timer: ReturnType<typeof setTimeout> | undefined\n    const stop = () => {\n      if (timer !== undefined) clearTimeout(timer)\n      resize?.disconnect()\n      player.current?.stop()\n      player.current = null\n    }\n    const start = () => {\n      stop()\n      const staticMode = media.matches || playback === \"static\" || playback === \"frame\" || playback === \"on-hover\"\n      if (staticMode || document.hidden) {\n        const render = () => paint(el, icon, playback === \"frame\" ? frame : icon.still ?? 0, 1, colors)\n        render()\n        resize = new ResizeObserver(render)\n        resize.observe(el)\n      } else {\n        const run = () => { player.current = play(el, icon, { palette: colors, loop: playback === \"loop\" }) }\n        if (delay > 0) timer = setTimeout(run, delay)\n        else run()\n      }\n    }\n    start()\n    media.addEventListener(\"change\", start)\n    document.addEventListener(\"visibilitychange\", start)\n    return () => { stop(); media.removeEventListener(\"change\", start); document.removeEventListener(\"visibilitychange\", start) }\n  }, [icon, colors, playback, frame, delay])\n  if (!icon) return null\n  return <canvas ref={canvas} className={className} style={{ display: \"block\", width: \"100%\", aspectRatio: \"1\", ...style }}\n    role={decorative ? undefined : \"img\"} aria-hidden={decorative || undefined} aria-label={decorative ? undefined : label ?? icon.name}\n    onPointerEnter={() => {\n      if (playback !== \"on-hover\" || document.hidden || !canvas.current || window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return\n      if (player.current) player.current.replay()\n      else player.current = play(canvas.current, icon, { palette: colors, loop: false })\n    }} />\n}\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/upstream/fun.ts",
      "target": "sdk/visual/isometric/upstream/fun.ts",
      "content": "// fun-isometric runtime: slab stickers drawn on canvas, keyed exactly like lottie-web plays After Effects keys.\n\nexport type Vec = readonly [number, number]\n// out x, out y of the left key, in x, in y of the right key: AE's influence handles, the same numbers a Lottie stores\nexport type Ease = readonly [number, number, number, number]\n// 0 as the ease holds the value until the next key; arc bends a position segment along a curve, AE's spatial out and in tangents\nexport type Key<T> = readonly [t: number, v: T, e?: Ease | 0, arc?: readonly [Vec, Vec]]\nexport type Track<T> = ReadonlyArray<Key<T>>\nexport type Anim<T> = T | Track<T>\n\n// Additive keys laid over a layer's rest pose, so one preset drives any drawing\nexport type Motion = {\n  r?: Track<number> // degrees added\n  p?: Track<Vec> // px added, in the parent's space\n  s?: Track<Vec> // percent multiplied in\n  o?: Track<number> // opacity percent multiplied in\n  x?: Track<number> // px added to the extrusion of every slab on the layer\n  at?: number // frame the keys start from\n  k?: number // amplitude, negative mirrors\n  loop?: number // repeat period in frames, the icon's length by default\n}\n\n// Palette slots are roles (main bodies, gold coins and stars, a pale tint, ok for success, hot for hearts and alerts, a deep second colour), so any theme keeps each part's meaning\nexport type Palette = { main: string; gold: string; tint: string; ok: string; hot: string; deep: string; white: string; grey: string; paper: string; ink: string }\nexport const RISO: Palette = { main: '#ff58a8', gold: '#ffe14a', tint: '#ffd4e8', ok: '#15b9a6', hot: '#ff7a1a', deep: '#2b50e0', white: '#ffffff', grey: '#cccccc', paper: '#f7f7f7', ink: '#000000' }\nexport const ACCENTS = ['main', 'gold', 'tint', 'ok', 'hot', 'deep'] as const\n// named sets, each a whole palette so a sticker keeps its contrast in any of them\nexport const PALETTES = {\n  riso: RISO,\n  candy: { ...RISO, main: '#b49bff', gold: '#ffd9a8', tint: '#ece5ff', ok: '#7fdcc0', hot: '#ff8fb1', deep: '#6a5cff' },\n  matcha: { ...RISO, main: '#6cc46f', gold: '#f2d16b', tint: '#e2f4d6', ok: '#2bb39a', hot: '#ff8a5b', deep: '#1f6b55' },\n  sunset: { ...RISO, main: '#ff7a3d', gold: '#ffc94a', tint: '#ffe2d1', ok: '#2ec4b6', hot: '#ff4d6d', deep: '#6b2d91' },\n  clay: { ...RISO, main: '#f0845f', gold: '#f4c463', tint: '#fde3d6', ok: '#7fb894', hot: '#e0533d', deep: '#3d5a80' },\n  aqua: { ...RISO, main: '#22c3d3', gold: '#ffd75e', tint: '#d3f4f7', ok: '#3fc46a', hot: '#ff6f61', deep: '#0f5f73' },\n} satisfies Record<string, Palette>\nexport type PaletteName = keyof typeof PALETTES\n// a slot, so the colour follows the palette it is drawn with, or a fixed hex\nexport type Swatch = keyof Palette | `#${string}`\n\n/** Which way flat faces turn, as the layer tilt and icon extrude that draw it. right is the house view. */\nexport const VIEWS = {\n  right: { tilt: [-18, 36], extrude: [-4, 18] },\n  left: { tilt: [18, 36], extrude: [4, 18] },\n  front: { tilt: [0, 30], extrude: [0, 18] },\n  flat: { tilt: [-45, 55], extrude: [0, 20] },\n} as const satisfies Record<string, { tilt: Vec; extrude: Vec }>\nexport type View = keyof typeof VIEWS\n\nexport type Shape = {\n  d: Anim<string> // svg path data in layer space, morph keys need matching commands\n  fill?: Swatch\n  line?: boolean | number // ink outline, on by default: outside the edge on fills, centred on open paths\n  depth?: number // share of the icon's extrusion this shape is pushed by, 0 keeps it flat\n  side?: Swatch // colour of the extruded side, the fill by default\n  edges?: ReadonlyArray<Vec> // extra creases down the side for raw paths; poly() corners crease on their own\n  crease?: boolean // false drops the automatic corner creases\n  round?: boolean // round caps and joins instead of butt and miter\n  trim?: Anim<number> // drawn share of an open path, 0 to 1\n}\n\nexport type Layer = {\n  id?: string\n  parent?: string\n  clip?: string // id of a layer whose shapes mask this one, like a track matte\n  a?: Vec // pivot, in layer space\n  p?: Anim<Vec>\n  r?: Anim<number>\n  s?: Anim<Vec>\n  o?: Anim<number>\n  tilt?: Vec // spin the drawing in its own plane, then lean that plane back this many degrees, so faces foreshorten into parallelograms\n  ip?: number // first frame shown\n  op?: number // frame it is gone by\n  m?: Motion | ReadonlyArray<Motion>\n  shapes: ReadonlyArray<Shape>\n}\n\nexport type Icon = {\n  name: string\n  frames: number // loop length at 60fps\n  size?: number // square canvas, 500\n  line?: number // outline width, 4\n  ink?: Swatch // outline colour, the palette's ink by default\n  extrude?: Anim<Vec> // where every slab's side falls, in canvas space so it stays put while faces turn\n  still?: number // frame shown under reduced motion, and where a play once stops\n  layers: ReadonlyArray<Layer> // back to front\n}\n\nexport const FPS = 60\n\n// Easing, solved like bezier-easing in lottie-web: Newton steps, bisection when the slope flattens\n\nconst curves = new Map<string, (x: number) => number>()\n\nexport function bezier(x1: number, y1: number, x2: number, y2: number) {\n  const key = `${x1},${y1},${x2},${y2}`\n  const hit = curves.get(key)\n  if (hit) return hit\n  const [ax, bx, cx] = [1 + 3 * x1 - 3 * x2, 3 * x2 - 6 * x1, 3 * x1]\n  const [ay, by, cy] = [1 + 3 * y1 - 3 * y2, 3 * y2 - 6 * y1, 3 * y1]\n  const sx = (s: number) => ((ax * s + bx) * s + cx) * s\n  const sy = (s: number) => ((ay * s + by) * s + cy) * s\n  const dx = (s: number) => (3 * ax * s + 2 * bx) * s + cx\n  const fn = (x: number) => {\n    if (x <= 0) return 0\n    if (x >= 1) return 1\n    if (x1 === y1 && x2 === y2) return x\n    let s = x\n    for (let i = 0; i < 8; i++) {\n      const [e, d] = [sx(s) - x, dx(s)]\n      if (Math.abs(e) < 1e-7) return sy(s)\n      if (Math.abs(d) < 1e-6) break\n      s -= e / d\n    }\n    let [lo, hi] = [0, 1]\n    s = x\n    for (let i = 0; i < 40 && Math.abs(sx(s) - x) > 1e-7; i++) {\n      if (sx(s) < x) lo = s\n      else hi = s\n      s = (lo + hi) / 2\n    }\n    return sy(s)\n  }\n  curves.set(key, fn)\n  return fn\n}\n\n// Path data morphs number by number; the command letters come from the left key\nconst parsed = new Map<string, [Array<string>, Array<number>]>()\nconst NUM = /-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi\n\nfunction parse(d: string) {\n  let hit = parsed.get(d)\n  if (!hit) {\n    const nums = (d.match(NUM) ?? []).map(Number)\n    hit = [d.split(NUM), nums]\n    if (parsed.size > 4000) parsed.clear()\n    parsed.set(d, hit)\n  }\n  return hit\n}\n\nfunction mix<T>(a: T, b: T, y: number): T {\n  if (typeof a === 'number') return (a + ((b as number) - a) * y) as T\n  if (typeof a === 'string') {\n    if (y === 0 || a === b) return a\n    const [bits, na] = parse(a)\n    const nb = parse(b as string)[1]\n    let out = bits[0]\n    for (let i = 0; i < na.length; i++) out += +(na[i] + ((nb[i] ?? na[i]) - na[i]) * y).toFixed(3) + bits[i + 1]\n    return out as T\n  }\n  const [va, vb] = [a as Vec, b as Vec]\n  return [va[0] + (vb[0] - va[0]) * y, va[1] + (vb[1] - va[1]) * y] as unknown as T\n}\n\nconst isTrack = <T>(v: Anim<T>): v is Track<T> => Array.isArray(v) && Array.isArray(v[0])\n\n// A curved segment walked by distance, as lottie-web does: 150 samples, eased progress is a share of the length\nconst arcs = new WeakMap<object, { pts: Array<Vec>; lens: Array<number> }>()\nfunction along(key: Key<unknown>, a: Vec, b: Vec, y: number): Vec {\n  let hit = arcs.get(key)\n  if (!hit) {\n    const [to, ti] = key[3] as readonly [Vec, Vec]\n    const [c1, c2]: [Vec, Vec] = [[a[0] + to[0], a[1] + to[1]], [b[0] + ti[0], b[1] + ti[1]]]\n    const pts: Array<Vec> = []\n    const lens = [0]\n    for (let i = 0; i <= 150; i++) {\n      const s = i / 150\n      const u = 1 - s\n      const [w0, w1, w2, w3] = [u * u * u, 3 * u * u * s, 3 * u * s * s, s * s * s]\n      pts.push([w0 * a[0] + w1 * c1[0] + w2 * c2[0] + w3 * b[0], w0 * a[1] + w1 * c1[1] + w2 * c2[1] + w3 * b[1]])\n      if (i) lens.push(lens[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]))\n    }\n    hit = { pts, lens }\n    arcs.set(key, hit)\n  }\n  const { pts, lens } = hit\n  const goal = lens[150] * y\n  if (goal <= 0) return pts[0]\n  if (goal >= lens[150]) return pts[150]\n  let i = 1\n  while (lens[i] < goal) i++\n  const k = (goal - lens[i - 1]) / (lens[i] - lens[i - 1] || 1)\n  return [pts[i - 1][0] + (pts[i][0] - pts[i - 1][0]) * k, pts[i - 1][1] + (pts[i][1] - pts[i - 1][1]) * k]\n}\n\n// A track's value at frame f: held before the first key and after the last, eased per segment in between\nexport function at<T>(v: Anim<T>, f: number): T {\n  if (!isTrack(v)) return v\n  if (f <= v[0][0]) return v[0][1]\n  for (let i = 0; i < v.length - 1; i++) {\n    const [t0, a, e, bend] = v[i]\n    const [t1, b] = v[i + 1]\n    if (f >= t1) continue\n    if (e === 0) return a\n    const x = (f - t0) / (t1 - t0)\n    const y = e ? bezier(e[0], e[1], e[2], e[3])(x) : x\n    return bend ? (along(v[i], a as Vec, b as Vec, y) as T) : mix(a, b, y)\n  }\n  return v[v.length - 1][1]\n}\n\n// Shifts a track along the timeline, handy for staggering one preset across parts\nexport const shift = <T>(track: Track<T>, by: number): Track<T> => track.map(([t, v, e, bend]) => [t + by, v, e, bend] as const)\n\n// Transforms, 2d affine [a b c d e f] like canvas\n\ntype M = [number, number, number, number, number, number]\nconst mul = (m: M, n: M): M => [\n  m[0] * n[0] + m[2] * n[1],\n  m[1] * n[0] + m[3] * n[1],\n  m[0] * n[2] + m[2] * n[3],\n  m[1] * n[2] + m[3] * n[3],\n  m[0] * n[4] + m[2] * n[5] + m[4],\n  m[1] * n[4] + m[3] * n[5] + m[5],\n]\n\nconst mod = (a: number, n: number) => ((a % n) + n) % n\nconst r2 = (v: number) => +v.toFixed(2)\nconst pt = (p: Vec) => `${r2(p[0])} ${r2(p[1])}`\n\n// k is how much the tilts in the chain squash area, so outlines stay one width when a face leans\ntype Pose = { m: M; o: number; x: number; k: number }\n\n// a tilt's 2x2: spin in plane, then squash by the lean\nconst lean = ([spin, by]: Vec): M => {\n  const [a, k] = [(spin * Math.PI) / 180, Math.cos((by * Math.PI) / 180)]\n  return [Math.cos(a), Math.sin(a) * k, -Math.sin(a), Math.cos(a) * k, 0, 0]\n}\n\n/** Where a point drawn on a face with this tilt lands in the layer's parent, for pivots and sparkles kept off the face. */\nexport const onFace = (tilt: Vec, [x, y]: Vec): Vec => {\n  const t = lean(tilt)\n  return [r2(t[0] * x + t[2] * y), r2(t[1] * x + t[3] * y)]\n}\n\nfunction poseOf(L: Layer, f: number, frames: number): Pose {\n  let [p, r, s, o, x] = [at(L.p ?? [0, 0], f), at(L.r ?? 0, f), at(L.s ?? [100, 100], f), at(L.o ?? 100, f), 0]\n  const list = L.m ? (Array.isArray(L.m) ? L.m : [L.m]) : []\n  for (const m of list as ReadonlyArray<Motion>) {\n    const g = mod(f - (m.at ?? 0), m.loop ?? frames)\n    const k = m.k ?? 1\n    if (m.r) r += at(m.r, g) * k\n    if (m.p) {\n      const d = at(m.p, g)\n      p = [p[0] + d[0] * k, p[1] + d[1] * k]\n    }\n    if (m.s) {\n      const d = at(m.s, g)\n      s = [(s[0] * (100 + (d[0] - 100) * k)) / 100, (s[1] * (100 + (d[1] - 100) * k)) / 100]\n    }\n    if (m.o) o *= at(m.o, g) / 100\n    if (m.x) x += at(m.x, g) * k\n  }\n  const [a, rad] = [L.a ?? [0, 0], (r * Math.PI) / 180]\n  const [cos, sin, sx, sy] = [Math.cos(rad), Math.sin(rad), s[0] / 100, s[1] / 100]\n  // translate(p) rotate(r) scale(s) tilt translate(-a), the order After Effects composes a layer in, tilt added\n  let m: M = [cos * sx, sin * sx, -sin * sy, cos * sy, 0, 0]\n  const k = L.tilt ? Math.cos((L.tilt[1] * Math.PI) / 180) : 1\n  if (L.tilt) m = mul(m, lean(L.tilt))\n  m[4] = p[0] - (m[0] * a[0] + m[2] * a[1])\n  m[5] = p[1] - (m[1] * a[0] + m[3] * a[1])\n  return { m, o, x, k }\n}\n\n// Drawing\n\nconst paths = new Map<string, Path2D>()\nconst pathOf = (d: string) => {\n  let hit = paths.get(d)\n  if (!hit) {\n    if (paths.size > 4000) paths.clear()\n    hit = new Path2D(d)\n    paths.set(d, hit)\n  }\n  return hit\n}\n\n// an open path's length once on screen, for trims: sampled once, then measured through the layer's matrix\nconst samples = new Map<string, Array<Vec>>()\nfunction lengthOf(d: string, m: M) {\n  let pts = samples.get(d)\n  if (!pts) {\n    const el = document.createElementNS('http://www.w3.org/2000/svg', 'path')\n    el.setAttribute('d', d)\n    const l = el.getTotalLength()\n    pts = Array.from({ length: 65 }, (_, i): Vec => {\n      const q = el.getPointAtLength((l * i) / 64)\n      return [q.x, q.y]\n    })\n    if (samples.size > 4000) samples.clear()\n    samples.set(d, pts)\n  }\n  let sum = 0\n  for (let i = 1; i < pts.length; i++) {\n    const [dx, dy] = [pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]]\n    sum += Math.hypot(m[0] * dx + m[2] * dy, m[1] * dx + m[3] * dy)\n  }\n  return sum\n}\n\ntype Ctx = CanvasRenderingContext2D\n\n// One frame resolved: each live layer's world pose and each shape's path and trim, ready to paint or to compare\ntype Part = { L: Layer; pose: Pose; ds: Array<string>; trims: Array<number> }\ntype Scene = { f: number; ext: Vec; parts: Array<Part>; world: (L: Layer) => Pose; byId: Map<string, Layer> }\n\nfunction scene(icon: Icon, frame: number): Scene {\n  const f = mod(frame, icon.frames)\n  const byId = new Map(icon.layers.filter((l) => l.id).map((l) => [l.id as string, l]))\n  const memo = new Map<Layer, Pose>()\n  const world = (L: Layer): Pose => {\n    let hit = memo.get(L)\n    if (!hit) {\n      hit = poseOf(L, f, icon.frames)\n      const up = L.parent ? byId.get(L.parent) : undefined\n      if (up) hit = { ...hit, m: mul(world(up).m, hit.m), k: world(up).k * hit.k }\n      memo.set(L, hit)\n    }\n    return hit\n  }\n  const parts: Array<Part> = []\n  for (const L of icon.layers) {\n    if ((L.ip !== undefined && f < L.ip) || (L.op !== undefined && f >= L.op) || !L.shapes.length) continue\n    const p = world(L)\n    if (p.o > 0) parts.push({ L, pose: p, ds: L.shapes.map((S) => at(S.d, f)), trims: L.shapes.map((S) => (S.trim === undefined ? 1 : at(S.trim, f))) })\n  }\n  return { f, ext: at(icon.extrude ?? [-4, 14], f), parts, world, byId }\n}\n\n// what a scene would paint, as text, so a player skips the frames of a still hold\nfunction fingerprint({ ext, parts }: Scene) {\n  let out = `${ext[0].toFixed(2)},${ext[1].toFixed(2)}`\n  for (const { L, pose, ds, trims } of parts) {\n    out += `|${pose.m.map((v) => v.toFixed(2)).join()},${pose.o.toFixed(1)},${pose.x.toFixed(2)}`\n    L.shapes.forEach((S, i) => typeof S.d !== 'string' && (out += `;${ds[i]}`))\n    L.shapes.forEach((S, i) => S.trim !== undefined && (out += `;${trims[i].toFixed(3)}`))\n  }\n  return out\n}\n\nfunction render(ctx: Ctx, icon: Icon, sc: Scene, palette: Palette) {\n  const base = ctx.getTransform()\n  const colour = (c: Swatch) => (c[0] === '#' ? c : palette[c as keyof Palette])\n  const [W, ink, { ext, world, byId, f }] = [icon.line ?? 4, colour(icon.ink ?? 'ink'), sc]\n  const len = Math.hypot(ext[0], ext[1]) || 1\n  // sweep copies land under a device pixel apart, solid at any size without overdrawing a small sticker\n  const dev = Math.sqrt(Math.abs(base.a * base.d - base.b * base.c)) || 1\n  const step = new DOMMatrix()\n  ctx.save()\n  ctx.miterLimit = 4\n  for (const { L, pose, ds, trims } of sc.parts) {\n    const { m, o, x, k } = pose\n    // paths go to canvas space before stroking, so a leaning face keeps even outlines that still scale with the layer\n    const [det, dm] = [m[0] * m[3] - m[1] * m[2], new DOMMatrix(m)]\n    const grow = Math.sqrt(Math.abs(det) / Math.abs(k || 1))\n    ctx.globalAlpha = Math.min(1, o / 100)\n    const mask = L.clip ? byId.get(L.clip) : undefined\n    if (mask) {\n      ctx.save()\n      const region = new Path2D()\n      const mm = new DOMMatrix(world(mask).m)\n      for (const s of mask.shapes) region.addPath(pathOf(at(s.d, f)), mm)\n      ctx.setTransform(base)\n      ctx.clip(region)\n    }\n    L.shapes.forEach((S, i) => {\n      const d = ds[i]\n      const path = new Path2D()\n      path.addPath(pathOf(d), dm)\n      const w = (S.line === false ? 0 : typeof S.line === 'number' ? S.line : W) * grow\n      ctx.setTransform(base)\n      ctx.lineCap = S.round ? 'round' : 'butt'\n      ctx.lineJoin = S.round ? 'round' : 'miter'\n      // the slab: the face swept along the extrusion, stroked at 2w then filled, which leaves one w outline round the union\n      const depth = S.depth ?? 0\n      if (depth && S.fill) {\n        const kk = depth + x / len\n        const [vx, vy] = [ext[0] * kk, ext[1] * kk]\n        const n = Math.min(64, Math.max(2, Math.ceil((Math.hypot(vx, vy) * dev) / 0.8)))\n        const sweep = new Path2D()\n        for (let j = n; j >= 0; j--) (step.e = (vx * j) / n), (step.f = (vy * j) / n), sweep.addPath(path, step)\n        if (w) {\n          ctx.strokeStyle = ink\n          ctx.lineWidth = w * 2\n          ctx.stroke(sweep)\n        }\n        ctx.fillStyle = colour(S.side ?? S.fill)\n        ctx.fill(sweep)\n        // a slab creases down the corner where two visible side faces meet, which is what makes it read solid\n        const auto = S.crease === false ? undefined : corners.get(d)\n        if (w && (S.edges || auto)) {\n          const vl = Math.hypot(vx, vy) || 1\n          const lines: Array<Vec> = [...(S.edges ?? [])]\n          // edge normals go through the inverse transpose, so they stay true on a sheared face\n          const faces = (nx: number, ny: number) => {\n            const [wx, wy] = [(m[3] * nx - m[1] * ny) * Math.sign(det), (m[0] * ny - m[2] * nx) * Math.sign(det)]\n            return (wx * vx + wy * vy) / (Math.hypot(wx, wy) * vl) > 0.05\n          }\n          for (const [cx, cy, ax, ay, bx, by] of auto ?? []) if (faces(ax, ay) && faces(bx, by)) lines.push([cx, cy])\n          ctx.strokeStyle = ink\n          ctx.lineWidth = w\n          ctx.beginPath()\n          for (const [ex, ey] of lines) {\n            const [px, py] = [m[0] * ex + m[2] * ey + m[4], m[1] * ex + m[3] * ey + m[5]]\n            ctx.moveTo(px, py)\n            ctx.lineTo(px + vx, py + vy)\n          }\n          ctx.stroke()\n        }\n      }\n      if (S.fill) {\n        if (w) {\n          ctx.strokeStyle = ink\n          ctx.lineWidth = w * 2\n          ctx.stroke(path)\n        }\n        ctx.fillStyle = colour(S.fill)\n        ctx.fill(path)\n      } else if (w && trims[i] > 0) {\n        ctx.strokeStyle = ink\n        ctx.lineWidth = w\n        if (trims[i] < 1) {\n          const l = lengthOf(d, m)\n          ctx.setLineDash([l * trims[i], l])\n        }\n        ctx.stroke(path)\n        ctx.setLineDash([])\n      }\n    })\n    if (mask) ctx.restore()\n  }\n  ctx.restore()\n}\n\nconst themed = new Map<string, Palette>()\n// a partial palette laid over the default, kept per distinct palette so a running sticker does not rebuild it every frame\nconst resolve = (p?: Partial<Palette>): Palette => {\n  if (!p) return RISO\n  const key = JSON.stringify(p)\n  let hit = themed.get(key)\n  if (!hit) {\n    if (themed.size > 200) themed.clear()\n    hit = { ...RISO, ...p }\n    themed.set(key, hit)\n  }\n  return hit\n}\n\n/** Paints frame f of an icon into ctx, whose current transform maps icon units (0..size) to the box it should fill. */\nexport function draw(ctx: Ctx, icon: Icon, frame: number, palette?: Partial<Palette>) {\n  render(ctx, icon, scene(icon, frame), resolve(palette))\n}\n\n// Colour: palettes derived in OKLCH, so a new hue keeps each slot's lightness and the set keeps its contrast\n\ntype Lch = [l: number, c: number, h: number]\nconst lin = (c: number) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)\nconst gam = (c: number) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055)\n\nfunction lch(color: string): Lch {\n  const h = color.length === 4 ? color.replace(/[0-9a-f]/gi, (c) => c + c) : color\n  const n = parseInt(h.slice(1, 7), 16)\n  const [r, g, b] = [lin(((n >> 16) & 255) / 255), lin(((n >> 8) & 255) / 255), lin((n & 255) / 255)]\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n  const [A, B] = [1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s]\n  return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, Math.hypot(A, B), (Math.atan2(B, A) * 180) / Math.PI]\n}\n\n// back to hex, easing chroma down until the colour fits sRGB\nfunction hex([L, C, H]: Lch) {\n  const rgb = (c: number) => {\n    const [A, B] = [c * Math.cos((H * Math.PI) / 180), c * Math.sin((H * Math.PI) / 180)]\n    const [l, m, s] = [(L + 0.3963377774 * A + 0.2158037573 * B) ** 3, (L - 0.1055613458 * A - 0.0638541728 * B) ** 3, (L - 0.0894841775 * A - 1.291485548 * B) ** 3]\n    return [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s]\n  }\n  const fits = (c: number) => rgb(c).every((v) => v >= -1e-4 && v <= 1 + 1e-4)\n  let [lo, hi] = [0, C]\n  if (fits(C)) lo = C\n  else for (let i = 0; i < 24; i++) fits((lo + hi) / 2) ? (lo = (lo + hi) / 2) : (hi = (lo + hi) / 2)\n  return `#${rgb(lo)\n    .map((v) => Math.round(Math.min(1, Math.max(0, gam(v))) * 255).toString(16).padStart(2, '0'))\n    .join('')}`\n}\n\n/** Every accent turned deg around the hue wheel, each keeping its own lightness and strength. */\nexport function hue(deg: number, from: Palette = RISO): Palette {\n  const out = { ...from }\n  for (const k of ACCENTS) {\n    const [L, C, H] = lch(from[k])\n    out[k] = hex([L, C, H + deg])\n  }\n  return out\n}\n\n/** Two brand colours and their shades fill every accent: primary on bodies, tints and hearts, secondary on dark parts, coins and checks. */\nexport function brand(primary: string, secondary?: string, from: Palette = RISO): Palette {\n  const [, C, H] = lch(primary)\n  const two = secondary ?? hex([0.42, C, H])\n  const [, C2, H2] = lch(two)\n  return { ...from, main: primary, tint: hex([0.93, Math.min(C, 0.06), H]), hot: hex([0.6, C, H]), deep: two, gold: hex([0.86, Math.min(C2, 0.12), H2]), ok: hex([0.7, C2, H2]) }\n}\n\n/** One hue at six lightnesses for a single colour set; parts stay apart by lightness and the outlines do the rest. */\nexport function mono(color: string, from: Palette = RISO): Palette {\n  const [, C, H] = lch(color)\n  const steps = { tint: 0.94, gold: 0.81, ok: 0.72, main: 0.64, hot: 0.55, deep: 0.45 }\n  const out = { ...from }\n  for (const k of ACCENTS) out[k] = hex([steps[k], Math.min(C, lch(from[k])[1]), H])\n  return out\n}\n\n// Shape kit: everything returns svg path data, so a part is one string that can also be a morph key\n\n\nexport const rect = (x: number, y: number, w: number, h: number, r = 0) => poly([[x, y], [x + w, y], [x + w, y + h], [x, y + h]], r)\nexport const pill = (x: number, y: number, w: number, h: number) => rect(x, y, w, h, Math.min(w, h) / 2)\n\nexport const ellipse = (cx: number, cy: number, rx: number, ry = rx) =>\n  `M${pt([cx - rx, cy])}A${r2(rx)} ${r2(ry)} 0 1 1 ${pt([cx + rx, cy])}A${r2(rx)} ${r2(ry)} 0 1 1 ${pt([cx - rx, cy])}Z`\n\n// the convex corners each poly() leaves behind, as arc midpoint and both edges' outward normals, for the renderer's creases\ntype Corner = readonly [x: number, y: number, ax: number, ay: number, bx: number, by: number]\nconst corners = new Map<string, ReadonlyArray<Corner>>()\n\n/** Closed polygon with circular fillets, r per corner or one for all; the workhorse for sharp but friendly slabs. */\nexport function poly(points: ReadonlyArray<Vec>, r: number | ReadonlyArray<number> = 0) {\n  const n = points.length\n  let d = ''\n  let area = 0\n  for (let i = 0; i < n; i++) area += points[i][0] * points[(i + 1) % n][1] - points[(i + 1) % n][0] * points[i][1]\n  const marks: Array<Corner> = []\n  for (let i = 0; i < n; i++) {\n    const [P, A, B] = [points[i], points[(i + n - 1) % n], points[(i + 1) % n]]\n    const rad = typeof r === 'number' ? r : (r[i] ?? 0)\n    const [ua, ub] = [[A[0] - P[0], A[1] - P[1]], [B[0] - P[0], B[1] - P[1]]]\n    const [la, lb] = [Math.hypot(ua[0], ua[1]), Math.hypot(ub[0], ub[1])]\n    const cos = (ua[0] * ub[0] + ua[1] * ub[1]) / (la * lb)\n    const half = Math.acos(Math.max(-1, Math.min(1, cos))) / 2\n    let t = rad && half > 1e-3 ? rad / Math.tan(half) : 0\n    t = Math.min(t, la / 2, lb / 2)\n    const rr = t * Math.tan(half)\n    const T1: Vec = [P[0] + (ua[0] / la) * t, P[1] + (ua[1] / la) * t]\n    const T2: Vec = [P[0] + (ub[0] / lb) * t, P[1] + (ub[1] / lb) * t]\n    const cross = ua[0] * ub[1] - ua[1] * ub[0]\n    const sweep = cross < 0 ? 1 : 0\n    d += `${i ? 'L' : 'M'}${pt(T1)}A${r2(rr)} ${r2(rr)} 0 0 ${sweep} ${pt(T2)}`\n    // a corner rounded into its neighbour (a pill end) has no crease, it turns smoothly\n    const round = rad > 0 && t >= Math.min(la, lb) / 2 - 1e-6\n    if (Math.sign(cross) === -Math.sign(area) && !round) {\n      let [bx, by] = [ua[0] / la + ub[0] / lb, ua[1] / la + ub[1] / lb]\n      const bl = Math.hypot(bx, by) || 1\n      ;[bx, by] = [bx / bl, by / bl]\n      const k = half > 1e-3 ? rr / Math.sin(half) - rr : 0\n      // each edge's normal, turned away from the bisector, which points inside\n      const out = (u: ReadonlyArray<number>, l: number): Vec => {\n        const [nx, ny] = [-u[1] / l, u[0] / l]\n        return nx * bx + ny * by > 0 ? [-nx, -ny] : [nx, ny]\n      }\n      const [na, nb] = [out(ua, la), out(ub, lb)]\n      marks.push([P[0] + bx * k, P[1] + by * k, na[0], na[1], nb[0], nb[1]])\n    }\n  }\n  d += 'Z'\n  if (corners.size > 4000) corners.clear()\n  corners.set(d, marks)\n  return d\n}\n\n/** Four point sparkle with concave sides; pinch 0 is a bare cross, about .3 a fat star. Same commands at any pinch, so it morphs. */\nexport function spark(cx: number, cy: number, r: number, pinch = 0.28) {\n  const q = r * pinch\n  return `M${pt([cx, cy - r])}Q${pt([cx + q, cy - q])} ${pt([cx + r, cy])}Q${pt([cx + q, cy + q])} ${pt([cx, cy + r])}Q${pt([cx - q, cy + q])} ${pt([cx - r, cy])}Q${pt([cx - q, cy - q])} ${pt([cx, cy - r])}Z`\n}\n\n/** Scalloped rosette, the verified badge outline: n bumps bulging out from a ring of radius r. */\nexport function rosette(cx: number, cy: number, r: number, n = 8, bulge = 0.62) {\n  let d = ''\n  for (let i = 0; i <= n; i++) {\n    const a = (i / n) * Math.PI * 2 - Math.PI / 2\n    const p: Vec = [cx + Math.cos(a) * r, cy + Math.sin(a) * r]\n    const chord = 2 * r * Math.sin(Math.PI / n)\n    d += i ? `A${r2(chord * bulge)} ${r2(chord * bulge)} 0 0 1 ${pt(p)}` : `M${pt(p)}`\n  }\n  return d + 'Z'\n}\n\n/** Ring: outer edge clockwise, hole counter clockwise, so the hole stays open and its far wall shows when extruded. */\nexport const ring = (cx: number, cy: number, r: number, hole: number) =>\n  ellipse(cx, cy, r) + `M${pt([cx - hole, cy])}A${r2(hole)} ${r2(hole)} 0 1 0 ${pt([cx + hole, cy])}A${r2(hole)} ${r2(hole)} 0 1 0 ${pt([cx - hole, cy])}Z`\n\n/** n point star with lightly rounded tips. */\nexport const star = (cx: number, cy: number, r: number, inner = 0.48, n = 5, round = 3) =>\n  poly(\n    Array.from({ length: n * 2 }, (_, i): Vec => {\n      const [a, k] = [(i / (n * 2)) * Math.PI * 2 - Math.PI / 2, i % 2 ? inner : 1]\n      return [cx + Math.cos(a) * r * k, cy + Math.sin(a) * r * k]\n    }),\n    round,\n  )\n\n/** Orthographic view of a model, x forward, y to the right, z up, turned yaw degrees and seen from pitch degrees above: poly() its faces. */\nexport function view(yaw: number, pitch: number) {\n  const [a, e] = [(yaw * Math.PI) / 180, (pitch * Math.PI) / 180]\n  return ([x, y, z]: readonly [number, number, number]): Vec => [\n    r2(x * Math.cos(a) - y * Math.sin(a)),\n    r2(-((x * Math.sin(a) + y * Math.cos(a)) * Math.sin(e) + z * Math.cos(e))),\n  ]\n}\n\nexport const line = (...points: ReadonlyArray<Vec>) => points.map((p, i) => `${i ? 'L' : 'M'}${pt(p)}`).join('')\n\n/** Open circular arc, degrees clockwise from 3 o'clock. */\nexport function arc(cx: number, cy: number, r: number, from: number, to: number) {\n  const [a, b] = [(from * Math.PI) / 180, (to * Math.PI) / 180]\n  const large = Math.abs(to - from) > 180 ? 1 : 0\n  return `M${pt([cx + Math.cos(a) * r, cy + Math.sin(a) * r])}A${r2(r)} ${r2(r)} 0 ${large} ${to > from ? 1 : 0} ${pt([cx + Math.cos(b) * r, cy + Math.sin(b) * r])}`\n}\n\n// Player: one clock for every sticker on the page, frames advance at 60 per second times speed\n\nexport const clock = { frame: 0, speed: 1, paused: false }\n\n// The sticker entrance: scale .2 and -90 degrees to rest over 1s on a bounce that overshoots to 1.1424\nconst BOUNCE: ReadonlyArray<Vec> = [\n  [0, 0], [0.076, 0.5737], [0.1187, 0.8382], [0.1419, 0.9463], [0.1654, 1.0292], [0.1897, 1.0886], [0.2153, 1.1258], [0.2297, 1.137],\n  [0.2448, 1.1424], [0.261, 1.1423], [0.2786, 1.1366], [0.3101, 1.1165], [0.3862, 1.0507], [0.4257, 1.0219], [0.4699, 0.9995],\n  [0.5163, 0.9872], [0.5877, 0.9842], [0.8126, 1.0011], [1, 1],\n]\nexport function popBounce(t: number) {\n  if (t <= 0) return 0\n  if (t >= 1) return 1\n  const i = BOUNCE.findIndex(([x]) => x >= t)\n  const [[x0, y0], [x1, y1]] = [BOUNCE[i - 1], BOUNCE[i]]\n  return y0 + ((y1 - y0) * (t - x0)) / (x1 - x0)\n}\n\n// Lays the entrance over a scene and paints it at the canvas's css size and device resolution\nfunction present(canvas: HTMLCanvasElement, icon: Icon, sc: Scene, e: number, palette: Palette, css: number) {\n  const dpr = Math.min(3, window.devicePixelRatio || 1)\n  const px = Math.max(1, Math.round(css * dpr))\n  if (canvas.width !== px || canvas.height !== px) canvas.width = canvas.height = px\n  const ctx = canvas.getContext('2d')\n  if (!ctx) return\n  const size = icon.size ?? 500\n  ctx.setTransform(1, 0, 0, 1, 0, 0)\n  ctx.clearRect(0, 0, px, px)\n  const b = popBounce(e)\n  if (b <= 0) return\n  ctx.globalAlpha = Math.min(1, b)\n  ctx.translate(px / 2, px / 2)\n  ctx.rotate((-90 * (1 - b) * Math.PI) / 180)\n  ctx.scale(0.2 + 0.8 * b, 0.2 + 0.8 * b)\n  ctx.translate(-px / 2, -px / 2)\n  ctx.scale(px / size, px / size)\n  render(ctx, icon, sc, palette)\n}\n\n/** Paints one frame into a canvas sized by css, at device resolution, with the entrance at progress e (1 is rest). */\nexport function paint(canvas: HTMLCanvasElement, icon: Icon, frame: number, e = 1, palette?: Partial<Palette>) {\n  present(canvas, icon, scene(icon, frame), e, resolve(palette), canvas.clientWidth)\n}\n\nexport type PlayOptions = {\n  palette?: Partial<Palette> // slots to swap, over the default\n  loop?: boolean // false plays once from when it first shows, or from replay(), then rests on the icon's still\n  offset?: number // frames ahead of the page clock\n  enter?: number // seconds after it first shows to pop in on the bounce entrance; leave out to skip the entrance\n}\nexport type Player = { stop: () => void; replay: () => void; set: (next: PlayOptions & { icon?: Icon }) => void }\n\ntype Live = { canvas: HTMLCanvasElement; icon: Icon; o: PlayOptions; pal: Palette; start?: number; seen: number; shown: boolean; css: number; key: string; stop: () => void }\nconst live = new Set<Live>()\nlet [raf, last] = [0, 0]\nlet reduce: MediaQueryList | null | undefined\nconst still = () => {\n  if (reduce === undefined) reduce = typeof matchMedia === 'undefined' ? null : matchMedia('(prefers-reduced-motion: reduce)')\n  return !!reduce?.matches\n}\n\n// a loop rides the page clock so every sticker stays in step; a replay or a play once counts from its own start\nfunction frameOf({ icon, o, start }: Live) {\n  if (still()) return icon.still ?? 0\n  const t = clock.frame - (start ?? 0) + (o.offset ?? 0)\n  if (o.loop !== false) return t\n  return t < (icon.still || icon.frames) ? t : (icon.still ?? 0)\n}\n\nfunction tick(now: number) {\n  const dt = last ? Math.min(100, now - last) : 0\n  last = now\n  if (!clock.paused) clock.frame += (dt / 1000) * FPS * clock.speed\n  for (const l of live) {\n    if (!l.shown) continue\n    try {\n      if (!l.seen) l.seen = now\n      if (l.o.loop === false && l.start === undefined) l.start = clock.frame\n      const e = l.o.enter === undefined || still() ? 1 : (now - l.seen - l.o.enter * 1000) / 1000\n      const [sc, css] = [scene(l.icon, frameOf(l)), l.css || l.canvas.clientWidth]\n      // nothing moved and nothing resized, set() clears it for new colours: a still hold or a paused clock costs no paint\n      const key = e < 1 ? '' : `${css}|${window.devicePixelRatio}|${fingerprint(sc)}`\n      if (key && key === l.key) continue\n      present(l.canvas, l.icon, sc, e, l.pal, css)\n      l.key = key\n    } catch (err) {\n      console.error(`fun-isometric: ${l.icon.name} stopped`, err)\n      l.stop()\n    }\n  }\n  raf = live.size ? requestAnimationFrame(tick) : 0\n}\n\n/** Plays an icon in a canvas sized by css, sharing the page clock, until stop(); off screen stickers skip their paints. */\nexport function play(canvas: HTMLCanvasElement, icon: Icon, opts: PlayOptions = {}): Player {\n  const io = typeof IntersectionObserver === 'undefined' ? null : new IntersectionObserver(([en]) => (l.shown = en.isIntersecting))\n  const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(([en]) => (l.css = en.contentRect.width))\n  const stop = () => {\n    io?.disconnect()\n    ro?.disconnect()\n    live.delete(l)\n  }\n  const l: Live = { canvas, icon, o: { ...opts }, pal: resolve(opts.palette), seen: 0, shown: !io, css: 0, key: '', stop }\n  io?.observe(canvas)\n  ro?.observe(canvas)\n  live.add(l)\n  if (!raf) (last = 0), (raf = requestAnimationFrame(tick))\n  return {\n    stop,\n    replay: () => ((l.start = clock.frame), (l.key = '')),\n    set: ({ icon: next, ...o }) => {\n      if (next) l.icon = next\n      Object.assign(l.o, o)\n      l.pal = resolve(l.o.palette)\n      l.key = ''\n    },\n  }\n}\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/upstream/motions.ts",
      "target": "sdk/visual/isometric/upstream/motions.ts",
      "content": "// The sticker motion presets, as After Effects keys. Deltas over a rest pose, px on a 500 canvas, 60fps.\nimport { shift } from './fun'\nimport type { Ease, Motion, Track, Vec } from './fun'\n\n// The eases every preset is built from\nexport const EASY: Ease = [0.333, 0, 0.667, 1] // AE easy ease: sways, floats, wiggles, every half swing of a spring\nexport const POP: Ease = [0.75, 0, 0.25, 1] // stars popping, slow returns\nexport const SNAP: Ease = [0.8, 0, 0.2, 1] // a part travelling from one slot to another\nexport const OUT: Ease = [0, 0, 0, 1] // dealt in, all speed up front\nexport const SOFT: Ease = [0.2, 0, 0, 1] // a latch springing open\nexport const IN: Ease = [1, 0, 0.8, 1] // a latch slamming shut\nexport const DROP: Ease = [1, 0, 1, 1] // falling away\n\nconst SPRING: ReadonlyArray<Ease> = [\n  [0.17, 0.17, 0.55, 1],\n  [0.35, 0, 0.62, 1],\n  [0.31, 0, 0.67, 1],\n  [0.31, 0, 0.64, 1],\n  [0.3, 0, 0.64, 1],\n  [0.24, 0, 0.57, 1],\n]\nconst REACH = [1.448, 0.778, 1.11, 0.95, 1.012, 1]\nconst GAPS = [13, 16, 16, 15, 15, 16]\n\n/** The baked spring behind jolt, impact and the settles: overshoot to 1.448 of the travel, swings halving, 91 frames to rest. */\nexport function spring(to: Vec, start = 0, pace = 1, from: Vec = [0, 0]): Track<Vec> {\n  let t = start\n  const keys: Array<readonly [number, Vec, Ease | 0]> = [[t, from, SPRING[0]]]\n  REACH.forEach((k, i) => {\n    t += Math.round(GAPS[i] * pace)\n    keys.push([t, [from[0] + (to[0] - from[0]) * k, from[1] + (to[1] - from[1]) * k], SPRING[i + 1] ?? 0])\n  })\n  return keys\n}\nexport function springTurn(to: number, start = 0, pace = 1, from = 0): Track<number> {\n  return spring([to, 0], start, pace, [from, 0]).map(([t, v, e]) => [t, v[0], e] as const)\n}\n\n// Whole object presets\n\n/** Containers spilling contents: winds up 20 degrees, whips past to 22, lands hard and stays still. Pivot on the edge it swings from. */\nexport const toss: Motion = {\n  r: [[0, 0, [0.572, 0, 0.348, 1.001]], [22, -19.9, [0.879, 0, 0.746, 1]], [41, 21.8, [0.092, 0, 0, 1]], [86, 0]],\n  // it travels on arcs, not lines: these are its spatial tangents\n  p: [\n    [0, [0, 0], [0.57, 0, 0.35, 1], [[-1.23, -6.42], [5.77, 1.42]]],\n    [22, [-8.5, -11.5], [0.88, 0, 0.75, 1], [[10.73, 10.33], [2.46, -13.42]]],\n    [41, [-3.63, 22.63], [0.09, 0, 0, 1], [[6.23, -16.52], [1.54, 6.58]]],\n    [86, [0, 0]],\n  ],\n}\n/** What rides inside a toss: the near one barely, the far one swings wide and slides. */\nexport const tossLag: Motion = { r: [[0, 0, [0.57, 0, 0.35, 1]], [22, 9, [0.88, 0, 0.75, 1]], [41, -2, [0.09, 0, 0, 1]], [86, 0]] }\nexport const tossLag2: Motion = {\n  r: [[0, 0, [0.57, 0, 0.35, 1]], [22, 15.5, [0.88, 0, 0.75, 1]], [41, -11.3, [0.09, 0, 0, 1]], [86, 0]],\n  p: [[0, [0, 0], [0.57, 0, 0.35, 1]], [22, [9.4, 3.4], [0.88, 0, 0.75, 1]], [41, [0, 0]]],\n}\n\n/** Badges and hearts: rises tilting 9 degrees, slams through rest, rebounds twice. */\nexport const hop: Motion = {\n  r: [[0, 0, [0.44, 0, 0.42, 1]], [36, 9, [0.42, 0, 0.44, 1]], [54, -4, [0.59, 0, 0.66, 1]], [72, 2, [0.37, 0, 0.51, 1]], [94, 0]],\n  p: [[0, [0, 0], [0.64, 0, 0.47, 1]], [36, [7, -24.25], [0.59, 0, 0.52, 1]], [54, [-7.25, 23.25], [0.24, 0, 0.16, 1]], [88, [0, 0]]],\n}\n\n/** Coins and tokens: springs up and right to a raised spot, holds, then drops back through rest and springs home. */\nexport const bounce: Motion = {\n  p: [\n    [0, [0, 0], EASY], [11, [11.24, -14.24], EASY], [24, [6.02, -7.63], EASY], [37, [8.6, -10.9], EASY], [49, [7.35, -9.32], EASY],\n    [62, [7.87, -9.97], EASY], [79, [7.19, -8.98], EASY], [93, [-3.48, 4.4], EASY], [110, [1.74, -2.21], EASY], [126, [-0.84, 1.06], EASY],\n    [142, [0.41, -0.52], EASY], [158, [-0.11, 0.13], EASY], [175, [0, 0]],\n  ],\n  s: [[0, [100, 100], [0.47, 0, 0.33, 1]], [11, [103, 103], [0.45, 0, 0.69, 1]], [31, [100, 100]]],\n}\n\n/** Bells and hands: rocks back 20 degrees, taps twice and settles, sliding 12px on the second beat. */\nexport const wiggle: Motion = {\n  r: [[0, 0, EASY], [46, 20, EASY], [71, 11, EASY], [100, 19, EASY], [124, -3, EASY], [148, 5, EASY], [177, 0]],\n  p: [[46, [0, 0], [0.2, 0, 0, 1]], [71, [11.8, 0], [0.2, 0, 0.67, 1]], [100, [0, 0]]],\n}\n\n/** Cards and warnings: kicked along v with the spring, holds, eases home. */\nexport const jolt = (v: Vec = [-7.86, 13.25]): Motion => ({ p: [...spring(v, 2), [98, v, [0.65, 0, 0.35, 1]], [141, [0, 0]]] })\n\n/** A body under a lid: takes the hit on frame 24, springs, holds, eases back as the lid lifts. */\nexport const impact = (v: Vec = [8.7, 15.3]): Motion => ({ p: [...spring(v, 24, 0.92), [119, v, POP], [176, [0, 0]]] })\n/** A lid or cap: slams along v on an ease in, sits, pops back sharp at the end. */\nexport const latch = (v: Vec = [11.5, 21.3]): Motion => ({ p: [[0, [0, 0], IN], [30, v, 0], [146, v, SOFT], [176, [0, 0]]] })\n\n/** Locks and clips: lifts up and left as the shackle springs open, hangs, then slams down right and settles. 130 frame loop. */\nexport const clasp: Motion = {\n  p: [[10, [0, 0], [0.31, 0, 0.12, 1]], [48, [-8.13, -12.37], 0], [61, [-8.13, -12.37], [0.83, 0, 0.49, 1]], [85, [9.75, 14.12], [0.46, 0, 0.33, 1]], [112, [0, 0]]],\n}\n/** The shackle on the clasp's beat: swung open 33 degrees on a soft pop, back on a slam. Pivot on the leg that stays in. */\nexport const shackle: Motion = {\n  p: [[8, [0, 0], SOFT], [38, [-6, -16], 0], [54, [-6, -16], IN], [84, [0, 0]]],\n  r: [[8, 0, SOFT], [38, -33, 0], [54, -33, IN], [84, 0]],\n}\n\n/** Faces and mascots: dips and rocks a few degrees, never quite still. */\nexport const wobble: Motion = {\n  r: [[0, 0, [0.73, 0, 0.46, 1]], [28, -3.04, [0.59, 0, 0.66, 0.86]], [54, 2.03, [0.36, -0.33, 0.67, 1.01]], [77, 0, [0.52, -0.02, 0.66, 1]], [95, 2.02, [0.47, 0, 0.11, 1]], [128, -1.1, [0.58, 0, 0.56, 1]], [168, 0]],\n  p: [[0, [0, 0], [0.62, 0, 0.31, 1]], [35, [0, 17.5], [0.33, 0, 0.85, 0.63]], [84, [0, -0.15], [0.57, 0.91, 0.57, 1]], [108, [0, -13.9], [0.33, 0, 0.4, 1]], [168, [0, 0]]],\n}\n\n/** Things that fly: a lazy figure of eight with a slow bank, x and y on their own beats. */\nexport const drift: ReadonlyArray<Motion> = [\n  { r: [[0, 0, [0.6, 0, 0.58, 1]], [48, 3.12, [0.68, 0, 0.44, 0.37]], [110, 6.97, [0.34, 0, 0.3, 1]], [156, 0]] },\n  { p: [[0, [0, 0], EASY], [44, [28.5, 0], [0.33, 0, 0.68, 0.75]], [76, [-28.09, 0], [0.33, 2.85, 0.72, 2.83]], [106, [-33, 0], [0.34, 0.26, 0.64, 0.71]], [135, [7.64, 0], [0.27, -1.41, 0.48, 1]], [170, [0, 0]]] },\n  { p: [[0, [0, 0], EASY], [34, [0, -20.07], EASY], [82, [0, -7.42], EASY], [122, [0, -25.55], [0.33, 0, 0.43, 1]], [167, [0, 0]]] },\n]\n\n/** Keys and tools: turns home sharp, then a slow 17 degree twist out and back, floating 13px. */\nexport const twist: Motion = {\n  r: [[0, -7, [0.17, 0, 0, 1]], [30, 0, SNAP], [90, -17.27, [0.8, 0, 0, 1]], [150, 0, SNAP], [180, -7]],\n  p: [[0, [0, 0], EASY], [90, [8, -10], EASY], [180, [0, 0]]],\n}\n\n/** A body reacting to a hit: nudged down and right, eases back. */\nexport const nudge: Motion = {\n  p: [[0, [0, 0], [0.33, 0, 0.07, 1]], [48, [8.88, 9.85], [0.24, 0, 0.67, 0.28]], [68, [8.56, 9.38], [0.52, 0.1, 0.25, 1]], [114, [0, 0]]],\n}\n/** A small part flicking out and back, a tongue or a tab. */\nexport const flick: Motion = { r: [[31, 0, [0.24, 0, 0.58, 1]], [47, 10, [0.3, 0, 0.64, 0.96]], [62, -7.05, [0.2, -0.46, 0.83, 1]], [95, 0]] }\n\n/** Buttons and keys: pushed 23px into its base with a hint of overshoot, back, then pops 13px proud and settles. Give it a still base to sink into. */\nexport const press: Motion = {\n  p: [[0, [0, 0], [0.37, 0, 0.33, 1.31]], [34, [0, 22.69], [0.4, 0.2, 0.09, 1]], [69, [0, 0], 0], [76, [0, 0], [0.46, 0, 0.34, 1]], [114, [0, -13], [0.38, 0, 0.61, 1]], [145, [0, 0]]],\n  x: [[0, 0, [0.37, 0, 0.33, 1.3]], [35, -6.2, [0.4, 0.18, 0.09, 1]], [70, 0, 0], [78, 0, [0.46, 0, 0.3, 1]], [112, 3.2, [0.39, 0, 0.62, 1]], [143, 0]],\n}\n\n/** Pupils: a glance up left, a dart down right, home. */\nexport const look: Motion = {\n  p: [[0, [0, 0], [0.46, 0, 0, 1], [[0, 0], [3.5, 2.62]]], [42, [-4.5, -9], [0.49, 0, 0, 1], [[2.69, 1.44], [0, 0]]], [82, [3, 3], [0.58, 0, 0.18, 1]], [123, [0, 0]]],\n}\n\n// Ambient\n\n/** Idle: a 5 degree lean and back over 3 seconds. Use k to tune, at to put parts out of phase. */\nexport const sway: Motion = { r: [[0, 0, EASY], [90, -5, EASY], [180, 0]], loop: 180 }\n/** Idle: 10px down and up over 3 seconds; neighbours sit 20 frames apart. */\nexport const float: Motion = { p: [[0, [0, 0], EASY], [90, [0, 10], EASY], [180, [0, 0]]], loop: 180 }\n/** Idle: a smaller bob with a sideways lean, 160 frame period. */\nexport const bob: Motion = { p: [[0, [0, 0], EASY], [80, [-1.5, 5], EASY], [160, [0, 0]]], loop: 160 }\n\n// Builders\n\n/** Scenes: dealt in from off to rest in 60 frames, all speed up front, swooping in level. Stagger parts 14 to 20 frames. */\nexport const deal = (from: Vec, turn: number, start = 0, grow = false): Motion => ({\n  p: shift<Vec>([[0, from, OUT, [[0, 0], [from[0] * 0.6, 0]]], [60, [0, 0]]], start),\n  r: shift([[0, turn, OUT], [60, 0]], start),\n  ...(grow ? { s: shift<Vec>([[0, [85, 85], SNAP], [60, [100, 100]]], start) } : {}),\n})\n/** Falls away on an ease in, 28 frames: clears a scene before it loops. */\nexport const fall = (to: Vec, start: number, len = 28): Motion => ({ p: [[start, [0, 0], DROP], [start + len, to]] })\n/** Toggles and tiles: one part to another slot over 60 frames on SNAP, holds, comes home. */\nexport const slide = (to: Vec, start: number, hold = 60, len = 60): Motion => ({\n  p: [[start, [0, 0], SNAP], [start + len, to, 0], [start + len + hold, to, SNAP], [start + len * 2 + hold, [0, 0]]],\n})\n\n/** Glare: swells out of nothing on a slow start, eases to 80%, shrinks away, drifting up and right. 71 frames. */\nexport const glint = (start: number, size = 100): Motion => ({\n  s: shift<Vec>([[0, [0, 0], [1, 0, 0.76, 1]], [30, [size, size], [0.31, 0, 0.23, 1]], [54, [size * 0.8, size * 0.8], [0.17, 0, 0.83, 1]], [71, [0, 0]]], start),\n  p: shift<Vec>([[0, [0, 0], [0.9, 0, 0.83, 0.83]], [30, [7.5, -4.8]]], start),\n})\n/** Star: pops to 110 and settles in 30 frames; out reverses it. */\nexport const twinkle = (start: number, out = false): Motion => ({\n  s: shift<Vec>(out ? [[0, [100, 100], POP], [10, [110, 110], POP], [30, [0, 0]]] : [[0, [0, 0], POP], [10, [110, 110], POP], [30, [100, 100]]], start),\n})\n/** Sparkle: grows and turns 46 degrees fast, then shrinks back on an ease in, 84 frames. */\nexport const sparkle = (start: number): Motion => ({\n  s: shift<Vec>([[0, [0, 0], [0.13, 0, 0, 1]], [42, [100, 100], [1, 0, 0.81, 1]], [84, [0, 0]]], start),\n  r: shift([[0, 0, [0.13, 0, 0, 1]], [42, 45.89, [1, 0, 0.81, 1]], [84, 0]], start),\n})\n/** Text lines: erased in 15 frames, staggered 5 apart, drawn back on a slow start. For a shape's trim. */\nexport const erase = (start: number, back: number): Track<number> => [[start, 1, [0.3, 0, 0.1, 1]], [start + 15, 0, 0], [back, 0, [0.9, 0, 0.7, 1]], [back + 15, 1]]\n/** Flames: steps between drawn shapes every 40 frames, snapping out of each. For a shape's d. */\nexport const flicker = (shapes: ReadonlyArray<string>, gap = 40): Track<string> => [...shapes, shapes[0]].map((d, i) => [i * gap, d, [0.33, 0, 0, 1]] as const)\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/upstream/icons.ts",
      "target": "sdk/visual/isometric/upstream/icons.ts",
      "content": "// The fun-isometric set: everyday product icons drawn as slabs, each moving on one preset.\nimport { VIEWS, arc, ellipse, line, onFace, pill, poly, rect, ring, spark, star, view } from './fun'\nimport { EASY, SNAP, bob, bounce, clasp, deal, drift, erase, fall, flicker, float, glint, hop, impact, jolt, latch, look, press, shackle, slide, sparkle, springTurn, sway, toss, tossLag, tossLag2, twinkle, twist, wiggle, wobble } from './motions'\nimport type { Icon, Layer, Motion, Shape, Track, Vec } from './fun'\n\n// colours are palette slots, so draw(..., palette) or play(..., { palette }) recolours the whole set\nconst LINE = 5\n// the house view: faces turned 18 degrees in their plane and leaned back 36, sides falling down left\nconst { tilt: FACE, extrude: EXT } = VIEWS.right\n\n// a white sparkle riding a parent, popped by whatever motion it is given\nconst glow = (parent: string, p: Vec, r: number, m: Motion | ReadonlyArray<Motion>, extra: { ip?: number; op?: number } = {}): Layer => ({\n  parent,\n  a: p,\n  p,\n  m,\n  ...extra,\n  shapes: [{ d: spark(p[0], p[1], r), fill: 'white' }],\n})\n\n// grows or shrinks a path of plain x y pairs about a point, for rims and insets\nconst inset = (d: string, k: number, [cx, cy]: Vec) =>\n  d.replace(/(-?\\d+\\.?\\d*) (-?\\d+\\.?\\d*)/g, (_, x: string, y: string) => `${+(cx + (+x - cx) * k).toFixed(2)} ${+(cy + (+y - cy) * k).toFixed(2)}`)\n\nexport const folder: Icon = {\n  name: 'folder',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { parent: 'body', shapes: [{ d: poly([[-130, -100], [-56, -100], [-34, -76], [130, -76], [130, 92], [-130, 92]], [18, 8, 8, 18, 18, 18]), fill: 'main', depth: 1 }] },\n    {\n      parent: 'body',\n      a: [-108, 50],\n      p: [-108, 50],\n      m: tossLag2,\n      shapes: [{ d: rect(-104, -136, 206, 192, 12), fill: 'white', depth: 0.3 }, { d: line([-78, -118], [8, -118]) }],\n    },\n    { parent: 'body', a: [-116, 52], p: [-116, 52], m: tossLag, shapes: [{ d: rect(-116, -104, 226, 164, 12), fill: 'ok', depth: 0.3 }] },\n    {\n      id: 'body',\n      a: [-130, 20],\n      p: [126, 294],\n      tilt: FACE,\n      m: toss,\n      shapes: [{ d: rect(-130, -46, 260, 138, 18), fill: 'deep', depth: 1 }, { d: pill(-46, -12, 92, 28), fill: 'white', depth: 0.3 }],\n    },\n  ],\n}\n\nconst HEART = 'M0 92C-24 74 -132 8 -132 -48C-132 -94 -98 -122 -62 -122C-34 -122 -12 -106 0 -84C12 -106 34 -122 62 -122C98 -122 132 -94 132 -48C132 8 24 74 0 92Z'\n\nexport const heart: Icon = {\n  name: 'heart',\n  frames: 123,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'heart', p: [250, 262], m: hop, shapes: [] },\n    { parent: 'heart', tilt: [-14, 30], shapes: [{ d: HEART, fill: 'hot', depth: 1, edges: [[0, 92]] }, { d: inset(HEART, 0.7, [0, -22]) }] },\n    glow('heart', [128, -112], 30, twinkle(0, true), { op: 30 }),\n    glow('heart', [128, -112], 30, twinkle(48), { ip: 48 }),\n    glow('heart', [-150, 10], 18, twinkle(4, true), { op: 34 }),\n    glow('heart', [-150, 10], 18, twinkle(54), { ip: 54 }),\n  ],\n}\n\nconst COIN = (cx: number, cy: number) => ellipse(cx, cy, 112, 80)\n\nexport const coins: Icon = {\n  name: 'coins',\n  frames: 180,\n  line: LINE,\n  extrude: [-2, 18],\n  layers: [\n    { p: [252, 352], r: -10, shapes: [{ d: COIN(0, 0), fill: 'gold', depth: 1 }] },\n    { p: [246, 318], r: -10, shapes: [{ d: COIN(0, 0), fill: 'gold', depth: 1 }] },\n    {\n      id: 'coin',\n      p: [240, 278],\n      r: -10,\n      m: bounce,\n      shapes: [{ d: COIN(0, 0), fill: 'gold', depth: 1 }, { d: ellipse(0, 0, 86, 58) }, { d: star(0, 2, 40, 0.46, 5, 4), fill: 'ink', line: false }],\n    },\n    glow('coin', [96, -66], 26, glint(2, 98)),\n    glow('coin', [-104, -48], 26, glint(6, 122)),\n    glow('coin', [-26, 70], 22, glint(12, 107)),\n    glow('coin', [92, -70], 28, glint(65, 125)),\n  ],\n}\n\n// a bell seen from a little above: dome, flared skirt, and a lip whose front curves down\nconst BELL = 'M-96 40C-94 -20 -80 -96 0 -98C80 -96 94 -20 96 40C108 46 120 54 122 66Q0 96 -122 66C-120 54 -108 46 -96 40Z'\nconst LIP = 'M-122 66Q0 96 122 66A9 9 0 0 1 124 84Q0 116 -124 84A9 9 0 0 1 -122 66Z'\n\nexport const bell: Icon = {\n  name: 'bell',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { parent: 'bell', a: [0, 80], p: [0, 80], m: { ...wiggle, at: 6, k: 0.8 }, shapes: [{ d: ellipse(0, 112, 24), fill: 'hot', depth: 0.8 }] },\n    {\n      id: 'bell',\n      a: [0, -112],\n      p: [250, 136],\n      r: -8,\n      m: wiggle,\n      shapes: [\n        { d: ring(0, -116, 22, 9), fill: 'gold', depth: 0.6 },\n        { d: BELL, fill: 'gold', depth: 1 },\n        { d: LIP, fill: 'gold', depth: 1 },\n      ],\n    },\n  ],\n}\n\nconst BADGE = onFace(FACE, [100, 82])\n\nexport const calendar: Icon = {\n  name: 'calendar',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'cal', p: [244, 262], m: jolt(), shapes: [] },\n    {\n      parent: 'cal',\n      tilt: FACE,\n      shapes: [\n        { d: rect(-122, -104, 244, 214, 26), fill: 'white', depth: 1 },\n        { d: poly([[-122, -104], [122, -104], [122, -44], [-122, -44]], [26, 26, 0, 0]), fill: 'hot' },\n        ...[-1, 1].map((s): Shape => ({ d: pill(s * 60 - 13, -128, 26, 50), fill: 'grey', depth: 0.5 })),\n        ...[0, 1, 2, 3].flatMap((c) => [0, 1].map((r): Shape => ({ d: rect(-96 + c * 50, -22 + r * 52, 34, 34, 9), ...(c === 1 && r === 1 ? { fill: 'ok' } : {}) }))),\n      ],\n    },\n    {\n      parent: 'cal',\n      a: BADGE,\n      p: BADGE,\n      m: [twinkle(14), twinkle(100, true)],\n      shapes: [\n        { d: ellipse(BADGE[0], BADGE[1], 40), fill: 'ok', depth: 0.7 },\n        { d: line([BADGE[0] - 18, BADGE[1]], [BADGE[0] - 5, BADGE[1] + 13], [BADGE[0] + 20, BADGE[1] - 14]), line: 7 },\n      ],\n    },\n  ],\n}\n\nconst KEYHOLE = ellipse(0, -4, 17) + poly([[-8, 6], [8, 6], [13, 42], [-13, 42]], 3)\nconst SHACKLE = 'M-74 -40L-74 -122A74 74 0 0 1 74 -122L74 -40L42 -40L42 -122A42 42 0 0 0 -42 -122L-42 -40Z'\n\nexport const padlock: Icon = {\n  name: 'padlock',\n  frames: 130,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'lock', p: [256, 300], m: clasp, shapes: [] },\n    { parent: 'body', a: [-58, -62], p: [-58, -62], m: shackle, shapes: [{ d: SHACKLE, fill: 'grey', depth: 0.7 }] },\n    {\n      id: 'body',\n      parent: 'lock',\n      tilt: FACE,\n      shapes: [\n        { d: rect(-112, -80, 224, 176, 24), fill: 'ok', depth: 1 },\n        { d: ellipse(0, 8, 36, 50), fill: 'white', depth: 0.25 },\n        { d: KEYHOLE, fill: 'ink', line: false },\n      ],\n    },\n    glow('lock', [-142, -70], 30, twinkle(0, true), { op: 30 }),\n    glow('lock', [-142, -70], 30, twinkle(75), { ip: 75 }),\n  ],\n}\n\nconst BOW = 'M0 -80C-18 -126 -86 -136 -76 -98C-70 -80 -30 -80 0 -80ZM0 -80C18 -126 86 -136 76 -98C70 -80 30 -80 0 -80Z'\n\nexport const gift: Icon = {\n  name: 'gift',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'box', p: [250, 306], m: impact([3, 12]), shapes: [] },\n    {\n      id: 'crate',\n      parent: 'box',\n      tilt: FACE,\n      // the ribbon carries its own depth, so it wraps down the side\n      shapes: [{ d: rect(-112, -40, 224, 136, 16), fill: 'tint', depth: 1 }, { d: rect(-22, -40, 44, 136), fill: 'gold', depth: 1 }],\n    },\n    {\n      parent: 'crate',\n      p: [0, -44],\n      m: latch([0, 44]),\n      shapes: [\n        { d: BOW, fill: 'gold', depth: 0.5 },\n        { d: rect(-130, -80, 260, 52, 16), fill: 'tint', depth: 0.8 },\n        { d: rect(-24, -80, 48, 52), fill: 'gold', depth: 0.8 },\n        { d: pill(-20, -96, 40, 30), fill: 'gold', depth: 0.5 },\n      ],\n    },\n    // they swell as the lid lifts and finish after the seam, so at wraps them round the loop\n    glow('box', [-128, -128], 24, { ...glint(0, 110), at: 140 }),\n    glow('box', [122, -146], 30, { ...glint(0, 120), at: 146 }),\n  ],\n}\n\n// modelled in 3d, x forward, y to starboard, z up, so the folds keep true proportions; the near wing droops to show its face\nconst fly = view(50, 30)\nconst [NOSE, TAIL, KEEL, FAR, NEAR] = [fly([172, 0, 0]), fly([-128, 0, 0]), fly([-104, 0, -112]), fly([-144, 116, 20]), fly([-144, -116, -44])]\n// pivot on the middle of its bounds so drift turns it in place\nconst MID: Vec = [(Math.min(FAR[0], KEEL[0], NEAR[0]) + NOSE[0]) / 2, (NOSE[1] + Math.max(NEAR[1], KEEL[1])) / 2]\n\nexport const plane: Icon = {\n  name: 'plane',\n  frames: 180,\n  line: LINE,\n  extrude: [-4, 13],\n  layers: [\n    {\n      a: MID,\n      p: [256, 250],\n      m: drift,\n      shapes: [\n        { d: poly([NOSE, FAR, TAIL], 3), fill: 'paper', side: 'white', depth: 1 },\n        { d: poly([NOSE, TAIL, KEEL], 3), fill: 'grey', side: 'white', depth: 1 },\n        { d: poly([NOSE, TAIL, NEAR], 3), fill: 'paper', side: 'white', depth: 1 },\n      ],\n    },\n  ],\n}\n\nexport const search: Icon = {\n  name: 'search',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'lens', p: [222, 226], m: twist, shapes: [] },\n    {\n      parent: 'lens',\n      tilt: [-20, 28],\n      shapes: [\n        { d: poly([[54, 90], [90, 54], [178, 142], [142, 178]], [0, 0, 24, 24]), fill: 'hot', depth: 1 },\n        { d: poly([[48, 93], [93, 48], [113, 68], [68, 113]], 6), fill: 'grey', depth: 1 },\n        { d: ellipse(0, 0, 80), fill: 'white' },\n        { d: ring(0, 0, 104, 78), fill: 'main', depth: 1 },\n        { d: arc(0, 0, 56, 200, 255) },\n      ],\n    },\n    glow('lens', [30, -26], 22, sparkle(20)),\n    glow('lens', [-32, 30], 14, sparkle(96)),\n  ],\n}\n\nconst BUBBLE = poly([[-132, -96], [132, -96], [132, 74], [-36, 74], [-96, 120], [-80, 74], [-132, 74]], [30, 30, 30, 4, 6, 4, 30])\nconst BOT: Vec = [-16, 30]\n// it rocks on the bubble's bottom edge, placed so the face sits where it always did\nconst ROCK = onFace(BOT, [0, 74])\n\nexport const chat: Icon = {\n  name: 'chat',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'bot', a: ROCK, p: [252 + ROCK[0], 216 + ROCK[1]], m: wobble, shapes: [] },\n    {\n      id: 'face',\n      parent: 'bot',\n      tilt: BOT,\n      shapes: [\n        { d: pill(-8, -150, 16, 60), fill: 'grey', depth: 0.5 },\n        { d: ellipse(0, -152, 20), fill: 'gold', depth: 0.6 },\n        { d: BUBBLE, fill: 'main', depth: 1 },\n        { d: rect(-104, -70, 208, 118, 26), fill: 'tint' },\n        { d: arc(0, 4, 30, 25, 155) },\n      ],\n    },\n    { id: 'eyeL', parent: 'face', shapes: [{ d: ellipse(-46, -20, 26, 30), fill: 'white' }] },\n    { id: 'eyeR', parent: 'face', shapes: [{ d: ellipse(46, -20, 26, 30), fill: 'white' }] },\n    { parent: 'face', clip: 'eyeL', m: { ...look, k: 1.6 }, shapes: [{ d: ellipse(-40, -14, 15), fill: 'ink', line: false }] },\n    { parent: 'face', clip: 'eyeR', m: { ...look, k: 1.6 }, shapes: [{ d: ellipse(52, -14, 15), fill: 'ink', line: false }] },\n    glow('bot', [150, -118], 26, sparkle(16)),\n    glow('bot', [-156, -60], 16, sparkle(92)),\n  ],\n}\n\n// Devices: each part dealt in on its own beat, then dropped and cut one after another before the loop comes round\nconst exit = (start: number): Motion => fall([0, 15], start)\n\nexport const phone: Icon = {\n  name: 'phone',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  still: 120,\n  layers: [\n    {\n      p: [236, 270],\n      tilt: FACE,\n      op: 172,\n      m: [deal([-46, 34], -21, 0), exit(144)],\n      shapes: [\n        ...[-96, -46].map((y): Shape => ({ d: rect(-92, y, 16, 36, 5), fill: 'deep', depth: 0.9 })),\n        { d: rect(-84, -146, 168, 292, 30), fill: 'deep', depth: 0.9 },\n        { d: rect(-68, -128, 136, 256, 18), fill: 'tint' },\n        { d: pill(-20, -140, 40, 8), fill: 'ink', line: false },\n      ],\n    },\n    {\n      p: [284, 220],\n      tilt: FACE,\n      ip: 14,\n      op: 176,\n      m: [deal([54, 5], 30, 14), exit(148)],\n      shapes: [\n        { d: rect(-104, -38, 208, 76, 20), fill: 'white', depth: 0.7 },\n        { d: ellipse(-62, 0, 20), fill: 'ok' },\n        { d: line([-30, -12], [70, -12]) },\n        { d: line([-30, 12], [36, 12]) },\n      ],\n    },\n    {\n      p: [338, 152],\n      tilt: FACE,\n      ip: 34,\n      op: 180,\n      m: [deal([62, 5], 23, 34, true), exit(152)],\n      shapes: [\n        { d: ellipse(0, 0, 34), fill: 'hot', depth: 0.8 },\n        { d: 'M0 13C-4 10 -18 1 -18 -6C-18 -12 -13 -16 -8 -16C-4 -16 -1 -14 0 -11C1 -14 4 -16 8 -16C13 -16 18 -12 18 -6C18 1 4 10 0 13Z', fill: 'white', line: 3 },\n      ],\n    },\n  ],\n}\n\nexport const toggle: Icon = {\n  name: 'toggle',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    {\n      id: 'track',\n      p: [250, 262],\n      tilt: FACE,\n      // bob repeats every 160 frames, so it rests 20 frames to fit this 180 frame loop\n      m: { ...bob, loop: 180 },\n      shapes: [{ d: pill(-134, -58, 268, 116), fill: 'white', depth: 1 }, { d: pill(-114, -38, 228, 76), fill: 'grey' }],\n    },\n    {\n      parent: 'track',\n      a: [-114, 0],\n      p: [-114, 0],\n      m: { s: [[20, [36, 100], [0.8, 0, 0.2, 1]], [80, [100, 100], 0], [120, [100, 100], [0.8, 0, 0.2, 1]], [180, [36, 100]]] },\n      shapes: [{ d: pill(-114, -38, 228, 76), fill: 'ok' }],\n    },\n    { parent: 'track', m: slide([148, 0], 20, 40), shapes: [{ d: ellipse(-74, 0, 48), fill: 'white', depth: 0.8 }, { d: ellipse(-74, 0, 28) }] },\n  ],\n}\n\n// flame outlines share one command list so they morph point for point\nconst flame = (lean: number, tip: number, k = 1, dy = 0) => {\n  const y = (v: number) => v * k + dy\n  return (\n    `M0 ${y(110)}C${-70 * k} ${y(110)} ${-104 * k} ${y(60)} ${-100 * k} ${y(6)}C${-96 * k} ${y(-38)} ${(-62 + lean * 0.4) * k} ${y(-62)} ${(-56 + lean) * k} ${y(-108)}` +\n    `C${(-22 + lean * 0.6) * k} ${y(-86)} ${-6 * k} ${y(-62)} 0 ${y(-30)}C${16 * k} ${y(-62)} ${(34 + lean) * k} ${y(-94 - tip * 0.3)} ${(26 + lean * 1.4) * k} ${y(-140 - tip)}` +\n    `C${(86 + lean) * k} ${y(-100)} ${106 * k} ${y(-40)} ${100 * k} ${y(10)}C${98 * k} ${y(64)} ${66 * k} ${y(110)} 0 ${y(110)}Z`\n  )\n}\n\nexport const streak: Icon = {\n  name: 'streak',\n  frames: 160,\n  line: LINE,\n  extrude: [-1, 18],\n  layers: [\n    {\n      id: 'fire',\n      p: [250, 262],\n      r: -6,\n      m: bob,\n      shapes: [\n        { d: flicker([flame(0, 0), flame(-14, 10), flame(10, -6), flame(-14, 10)]), fill: 'hot', depth: 1 },\n        { d: flicker([flame(0, 0, 0.6, 34), flame(12, 14, 0.6, 34), flame(-10, -4, 0.6, 34), flame(12, 14, 0.6, 34)]), fill: 'gold', depth: 0.35 },\n        { d: flicker([flame(0, 0, 0.3, 58), flame(-8, 8, 0.3, 58), flame(8, -2, 0.3, 58), flame(-8, 8, 0.3, 58)]), fill: 'white' },\n      ],\n    },\n  ],\n}\n\nexport const notes: Icon = {\n  name: 'notes',\n  frames: 180,\n  still: 0,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    {\n      id: 'pad',\n      a: [0, 136],\n      p: [250, 374],\n      tilt: FACE,\n      m: { ...sway, k: 0.8 },\n      shapes: [\n        { d: rect(-118, -136, 236, 272, 24), fill: 'main', depth: 1 },\n        { d: rect(-96, -108, 192, 222, 10), fill: 'white', depth: 0.2 },\n        { d: pill(-52, -154, 104, 42), fill: 'grey', depth: 0.6 },\n        { d: pill(-20, -140, 40, 12), fill: 'ink', line: false },\n        ...[0, 1, 2, 3].map((i): Shape => ({ d: line([-68, -66 + i * 40], [i === 3 ? 10 : 68, -66 + i * 40]), trim: erase(22 - i * 5, 80 + i * 5) })),\n      ],\n    },\n  ],\n}\n\nexport const play: Icon = {\n  name: 'play',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'base', p: [250, 278], tilt: FACE, shapes: [{ d: rect(-132, -118, 264, 236, 48), fill: 'white', depth: 1 }] },\n    {\n      parent: 'base',\n      m: press,\n      shapes: [{ d: ellipse(0, -8, 80), fill: 'ok', depth: 1.6 }, { d: poly([[-20, -42], [38, -8], [-20, 26]], 7), fill: 'white' }],\n    },\n  ],\n}\n\n// A loop de loop written across the pad, in face space, sampled densely so the nib can be keyed onto it\nconst LOOPS = 4\nconst SCRIBBLE: Array<Vec> = (() => {\n  const [from, to] = [-Math.PI / 2, LOOPS * 2 * Math.PI + 0.7]\n  const pts = Array.from({ length: 721 }, (_, i): Vec => {\n    const t = from + ((to - from) * i) / 720\n    const tall = 30 * (1 + 0.14 * Math.sin(t / 2.6))\n    const x = 5.6 * t + 15 * Math.sin(t)\n    return [x, tall * Math.cos(t) - 0.14 * x]\n  })\n  const mid = (pts[0][0] + pts[720][0]) / 2\n  return pts.map(([x, y]) => [x - mid, y + 4])\n})()\n// on screen the pad leans, so speed and trims are measured after the tilt\nconst SEEN = SCRIBBLE.map((p) => onFace(FACE, p))\nconst RUN = SEEN.reduce<Array<number>>((acc, p, i) => (acc.push(i ? acc[i - 1] + Math.hypot(p[0] - SEEN[i - 1][0], p[1] - SEEN[i - 1][1]) : 0), acc), [])\nconst [WRITE, DONE, PIECES] = [16, 118, 8]\nconst frameAt = (s: number) => WRITE + ((DONE - WRITE) * s) / RUN[720]\nconst nibAt = (s: number): Vec => {\n  let i = 1\n  while (i < 720 && RUN[i] < s) i++\n  const k = (s - RUN[i - 1]) / (RUN[i] - RUN[i - 1] || 1)\n  return [+(SEEN[i - 1][0] + (SEEN[i][0] - SEEN[i - 1][0]) * k).toFixed(2), +(SEEN[i - 1][1] + (SEEN[i][1] - SEEN[i - 1][1]) * k).toFixed(2)]\n}\n// cut into pieces with their own trims, so a trim's end never drifts from the nib on a long path\nconst CUTS = Array.from({ length: PIECES + 1 }, (_, j) => RUN.findIndex((r) => r >= (RUN[720] * j) / PIECES))\nconst INK: ReadonlyArray<Shape> = CUTS.slice(0, -1).map((c, j) => ({\n  d: line(...SCRIBBLE.slice(c, CUTS[j + 1] + 1)),\n  line: 7,\n  round: true,\n  trim: [[frameAt(RUN[c]), 0], [frameAt(RUN[CUTS[j + 1]]), 1], [178, 1, 0], [179, 0]],\n}))\nconst SHINE = onFace(FACE, [104, -136])\nconst START = SEEN[0]\nconst END = SEEN[720]\nconst LIFT: Vec = [12, -40]\nconst HOVER: Vec = [START[0] + LIFT[0], START[1] + LIFT[1]]\n// the nib rides the line every two frames, rocking a little with each loop\nconst NIB: Track<Vec> = [\n  [0, HOVER, EASY],\n  ...Array.from({ length: (DONE - WRITE) / 2 }, (_, i) => [WRITE + i * 2, nibAt((RUN[720] * i * 2) / (DONE - WRITE))] as const),\n  [DONE, END, EASY],\n  [DONE + 16, [END[0] + LIFT[0], END[1] + LIFT[1]], SNAP, [[-30, -40], [30, -40]]],\n  [168, HOVER],\n]\nconst TURN: Track<number> = [\n  [0, 36, EASY],\n  [WRITE, 30],\n  ...Array.from({ length: (DONE - WRITE) / 2 - 1 }, (_, i) => [WRITE + (i + 1) * 2, 30 + 4 * Math.sin(((i + 1) * 2 * LOOPS * 2 * Math.PI) / (DONE - WRITE))] as const),\n  [DONE, 30, EASY],\n  [DONE + 16, 34, SNAP],\n  [168, 36],\n]\n\nexport const pen: Icon = {\n  name: 'pen',\n  frames: 180,\n  // the finished scribble, pen lifted and the sparkle out\n  still: 136,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'desk', p: [224, 322], shapes: [] },\n    { parent: 'desk', tilt: FACE, shapes: [{ d: rect(-116, -116, 232, 232, 28), fill: 'tint', depth: 1 }] },\n    { parent: 'desk', tilt: FACE, a: [0, 4], p: onFace(FACE, [0, 4]), m: twinkle(148, true), shapes: INK },\n    {\n      parent: 'desk',\n      p: NIB,\n      r: TURN,\n      shapes: [\n        { d: poly([[-21, -196], [21, -196], [21, -86], [-21, -86]], [20, 20, 0, 0]), fill: 'main', depth: 1 },\n        { d: rect(-21, -174, 42, 20), fill: 'deep', depth: 1 },\n        { d: rect(8, -168, 9, 58, 4.5), fill: 'grey', depth: 0.4 },\n        { d: rect(-21, -90, 42, 42, 6), fill: 'deep', depth: 1 },\n        { d: poly([[-19, -50], [19, -50], [4, -6], [-4, -6]], [4, 4, 3, 3]), fill: 'white', depth: 0.5 },\n        { d: ellipse(0, -6, 5.5), fill: 'ink', line: false },\n      ],\n    },\n    glow('desk', SHINE, 26, [twinkle(DONE + 4), twinkle(150, true)]),\n  ],\n}\n\n// the flag springs up when the post comes, the letter slides out of the door, both home before the loop\nconst BOX: Vec = FACE\nexport const mailbox: Icon = {\n  name: 'mailbox',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'mail', a: [0, 150], p: [250, 392], m: jolt([-4, 10]), shapes: [] },\n    { parent: 'mail', tilt: BOX, shapes: [{ d: rect(-18, 40, 36, 150, 6), fill: 'grey', depth: 0.8 }] },\n    {\n      parent: 'box',\n      a: [70, 0],\n      p: [70, 0],\n      m: slide([56, 0], 24, 72, 40),\n      shapes: [{ d: rect(30, -40, 96, 62, 6), fill: 'white', depth: 0.25 }, { d: line([44, -24], [78, -6], [112, -24]) }],\n    },\n    {\n      id: 'box',\n      parent: 'mail',\n      tilt: BOX,\n      shapes: [\n        { d: poly([[-136, -96], [136, -96], [136, 56], [-136, 56]], [72, 72, 10, 10]), fill: 'deep', depth: 1 },\n        { d: poly([[96, -96], [136, -96], [136, 56], [96, 56]], [0, 72, 10, 0]), fill: 'main', depth: 1 },\n      ],\n    },\n    {\n      parent: 'box',\n      a: [-60, -10],\n      p: [-60, -10],\n      r: 84,\n      m: { r: [...springTurn(-84, 18), [128, -84, SNAP], [168, 0]] },\n      shapes: [{ d: rect(-68, -130, 16, 124, 4), fill: 'grey', depth: 0.5 }, { d: rect(-68, -130, 70, 44, 6), fill: 'hot', depth: 0.5 }],\n    },\n  ],\n}\n\n// notes pop off the band on the beat while the set bops\nconst NOTE = (x: number, y: number): ReadonlyArray<Shape> => [\n  { d: poly([[x + 6, y - 54], [x + 34, y - 44], [x + 34, y - 28], [x + 14, y - 34], [x + 14, y], [x + 6, y]], 3), fill: 'gold', depth: 0.4 },\n  { d: ellipse(x - 4, y + 2, 16, 13), fill: 'gold', depth: 0.4 },\n]\nconst BAND = 'M-128 28A128 128 0 0 1 128 28L100 28A100 100 0 0 0 -100 28Z'\n\nexport const headphones: Icon = {\n  name: 'headphones',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'set', a: [0, 120], p: [250, 392], m: wobble, shapes: [] },\n    {\n      parent: 'set',\n      tilt: [-12, 24],\n      shapes: [\n        { d: BAND, fill: 'deep', depth: 0.8 },\n        ...[-1, 1].flatMap((side): Array<Shape> => [\n          { d: rect(side * 114 - 36, 4, 72, 126, 30), fill: 'main', depth: 1 },\n          { d: rect(side * 114 - 20, 22, 40, 90, 18), fill: 'tint', depth: 0.3 },\n        ]),\n      ],\n    },\n    { parent: 'set', a: [150, -110], p: [150, -110], m: [twinkle(20), twinkle(100, true)], shapes: NOTE(150, -110) },\n    { parent: 'set', a: [-150, -70], p: [-150, -70], m: [twinkle(60), twinkle(132, true)], shapes: NOTE(-150, -70) },\n  ],\n}\n\n// one plane leaned back like the calendar, rim in the silhouette, so the side reads as thickness and not a shadow\nconst CUP = 'M-100 -134L100 -134L100 -108L84 -108C84 -10 48 30 0 34C-48 30 -84 -10 -84 -108L-100 -108Z'\n\nexport const trophy: Icon = {\n  name: 'trophy',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'cup', p: [250, 266], m: hop, shapes: [] },\n    {\n      parent: 'cup',\n      tilt: FACE,\n      shapes: [\n        ...[-1, 1].map((side): Shape => ({ d: ring(side * 88, -60, 44, 24), fill: 'gold', depth: 0.6 })),\n        { d: CUP, fill: 'gold', depth: 1 },\n        { d: line([-84, -108], [84, -108]) },\n        { d: star(0, -46, 32, 0.46, 5, 4), fill: 'white' },\n        { d: rect(-16, 30, 32, 38), fill: 'gold', depth: 1 },\n        { d: rect(-76, 64, 152, 56, 12), fill: 'deep', depth: 1 },\n        { d: rect(-42, 81, 84, 22, 6), fill: 'white' },\n      ],\n    },\n    glow('cup', [138, -132], 30, twinkle(0, true), { op: 30 }),\n    glow('cup', [138, -132], 30, twinkle(54), { ip: 54 }),\n    glow('cup', [-150, 20], 18, twinkle(6, true), { op: 36 }),\n    glow('cup', [-150, 20], 18, twinkle(62), { ip: 62 }),\n  ],\n}\n\nconst SHUTTER = onFace(FACE, [92, -104])\nconst FLASH = onFace(FACE, [-96, -48])\n\nexport const camera: Icon = {\n  name: 'camera',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'cam', a: [0, 100], p: [250, 366], m: { ...sway, k: 0.6 }, shapes: [] },\n    { parent: 'cam', tilt: FACE, shapes: [{ d: rect(-64, -126, 128, 50, 14), fill: 'deep', depth: 0.8 }] },\n    { parent: 'cam', a: SHUTTER, p: SHUTTER, m: { ...press, k: 0.35 }, tilt: FACE, shapes: [{ d: pill(70, -118, 46, 28), fill: 'hot', depth: 0.6 }] },\n    {\n      parent: 'cam',\n      tilt: FACE,\n      shapes: [\n        { d: rect(-146, -90, 292, 192, 32), fill: 'deep', depth: 1 },\n        { d: rect(-146, -24, 292, 64), fill: 'tint' },\n        { d: rect(-124, -66, 52, 30, 8), fill: 'gold', depth: 0.3 },\n        { d: ellipse(20, 8, 82), fill: 'white', depth: 0.6 },\n        { d: ring(20, 8, 70, 46), fill: 'main', depth: 0.8 },\n        { d: ellipse(20, 8, 46), fill: 'deep' },\n        { d: arc(20, 8, 30, 200, 260) },\n      ],\n    },\n    glow('cam', FLASH, 28, glint(36, 120)),\n  ],\n}\n\nconst PIN = 'M0 118C-24 76 -96 22 -96 -42A96 96 0 0 1 96 -42C96 22 24 76 0 118Z'\n\nexport const pin: Icon = {\n  name: 'pin',\n  frames: 180,\n  line: LINE,\n  extrude: [-3, 16],\n  layers: [\n    { id: 'drop', a: [0, 118], p: [250, 362], m: { ...hop, at: 20 }, shapes: [] },\n    { parent: 'drop', shapes: [{ d: PIN, fill: 'main', depth: 1, edges: [[0, 118]] }, { d: ring(0, -42, 46, 22), fill: 'white', depth: 0.3 }] },\n    glow('drop', [104, -128], 26, sparkle(48)),\n    glow('drop', [-118, -20], 16, sparkle(110)),\n  ],\n}\n\nconst CLOUD = 'M-112 64A54 54 0 0 1 -116 -38A72 72 0 0 1 20 -76A64 64 0 0 1 124 -18A44 44 0 0 1 112 64Z'\n\nexport const cloud: Icon = {\n  name: 'cloud',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'sky', p: [250, 270], m: float, shapes: [] },\n    { parent: 'sky', tilt: FACE, shapes: [{ d: CLOUD, fill: 'white', depth: 1 }] },\n    {\n      parent: 'sky',\n      tilt: FACE,\n      m: slide([0, -40], 30, 50, 50),\n      shapes: [{ d: poly([[0, -66], [52, -10], [22, -10], [22, 50], [-22, 50], [-22, -10], [-52, -10]], 6), fill: 'ok', depth: 0.8 }],\n    },\n  ],\n}\n\nconst BULB = 'M-44 64L-44 44C-78 22 -96 -8 -96 -48A96 96 0 0 1 96 -48C96 -8 78 22 44 44L44 64Z'\n\nexport const bulb: Icon = {\n  name: 'bulb',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'lamp', a: [0, 120], p: [250, 372], m: hop, shapes: [] },\n    {\n      parent: 'lamp',\n      tilt: FACE,\n      shapes: [\n        { d: BULB, fill: 'gold', depth: 1 },\n        { d: line([-34, -24], [-17, -46], [0, -24], [17, -46], [34, -24]), round: true },\n        { d: line([-34, -24], [-30, 44]) },\n        { d: line([34, -24], [30, 44]) },\n        { d: arc(0, -48, 70, 196, 246) },\n        { d: rect(-50, 60, 100, 28, 9), fill: 'grey', depth: 0.8 },\n        { d: rect(-44, 84, 88, 26, 9), fill: 'grey', depth: 0.8 },\n        { d: rect(-24, 106, 48, 22, 10), fill: 'deep', depth: 0.6 },\n      ],\n    },\n    glow('lamp', [-126, -132], 26, [twinkle(36), twinkle(120, true)]),\n    glow('lamp', [134, -150], 30, [twinkle(42), twinkle(126, true)]),\n    glow('lamp', [150, -34], 16, [twinkle(48), twinkle(132, true)]),\n  ],\n}\n\n// the cells fill one by one, the bolt pops when it is full, then all of it drains before the loop\nconst CELL = (i: number): Vec => [-86 + i * 52, 0]\n\nexport const battery: Icon = {\n  name: 'battery',\n  frames: 180,\n  line: LINE,\n  extrude: EXT,\n  layers: [\n    { id: 'cell', p: [244, 262], m: float, shapes: [] },\n    {\n      id: 'batt',\n      parent: 'cell',\n      tilt: FACE,\n      shapes: [\n        { d: rect(116, -28, 26, 56, 8), fill: 'grey', depth: 0.8 },\n        { d: rect(-132, -66, 252, 132, 26), fill: 'white', depth: 1 },\n        { d: rect(-114, -48, 216, 96, 14), fill: 'paper' },\n      ],\n    },\n    ...[0, 1, 2, 3].map(\n      (i): Layer => ({ parent: 'batt', a: CELL(i), p: CELL(i), m: [twinkle(14 + i * 14), twinkle(132 + i * 6, true)], shapes: [{ d: rect(CELL(i)[0] - 22, -38, 44, 76, 8), fill: 'ok', depth: 0.3 }] }),\n    ),\n    {\n      parent: 'batt',\n      a: [-6, 0],\n      p: [-6, 0],\n      m: [twinkle(70), twinkle(124, true)],\n      shapes: [{ d: poly([[6, -62], [-34, 8], [-6, 8], [-18, 62], [26, -10], [-2, -10]], 4), fill: 'gold', depth: 0.5 }],\n    },\n    glow('cell', [150, -96], 24, [twinkle(76), twinkle(128, true)]),\n  ],\n}\n\nexport const ICONS: ReadonlyArray<Icon> = [pen, folder, heart, coins, bell, calendar, padlock, gift, plane, search, chat, phone, toggle, streak, notes, play, mailbox, headphones, trophy, camera, pin, cloud, bulb, battery]\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/upstream/Sticker.tsx",
      "target": "sdk/visual/isometric/upstream/Sticker.tsx",
      "content": "// fun-isometric in React: one canvas sized by css, on the shared page clock, recoloured and replayed without remounting.\nimport { useEffect, useRef } from 'react'\nimport { play } from './fun'\nimport type { CSSProperties } from 'react'\nimport type { Icon, PlayOptions, Player } from './fun'\n\ntype Props = PlayOptions & {\n  icon: Icon\n  replayOnHover?: boolean\n  label?: string // accessible name, the icon's name by default\n  className?: string\n  style?: CSSProperties\n}\n\nexport function Sticker({ icon, palette, loop, offset, enter, replayOnHover, label, className, style }: Props) {\n  const ref = useRef<HTMLCanvasElement>(null)\n  const player = useRef<Player | null>(null)\n  const opts = useRef<PlayOptions>({ palette, loop, offset, enter })\n  opts.current = { palette, loop, offset, enter }\n  // a new icon starts a new player; options reach the running one through set(), so the entrance never replays\n  useEffect(() => {\n    if (!ref.current) return\n    const p = play(ref.current, icon, opts.current)\n    player.current = p\n    return () => p.stop()\n  }, [icon])\n  // keyed on the palette's content, so an inline object does not repaint every render\n  const tone = JSON.stringify(palette ?? null)\n  useEffect(() => player.current?.set(opts.current), [tone, loop, offset])\n  return (\n    <canvas\n      ref={ref}\n      role=\"img\"\n      aria-label={label ?? icon.name}\n      className={className}\n      style={{ display: 'block', width: '100%', aspectRatio: '1', ...style }}\n      onPointerEnter={replayOnHover ? () => player.current?.replay() : undefined}\n    />\n  )\n}\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/isometric/upstream/LICENSE",
      "target": "sdk/visual/isometric/upstream/LICENSE",
      "content": "MIT License\n\nCopyright (c) 2026 kelvinkn17\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
      "type": "registry:ui"
    },
    {
      "path": "sdk/visual/visual-tile.tsx",
      "target": "sdk/visual/visual-tile.tsx",
      "content": "\"use client\"\n\nimport { useState, type CSSProperties, type ReactNode } from \"react\"\nimport { CaiIsometric, type CaiIsometricProps } from \"./isometric/player\"\n\nexport type CaiVisualLayer = Pick<CaiIsometricProps, \"illustration\" | \"primary\" | \"secondary\" | \"palette\" | \"playback\" | \"delay\"> & { x: number; y: number; size: number }\nexport type CaiVisualSize = \"hero\" | \"wide\" | \"tall\" | \"compact\"\nexport type CaiVisualTileProps = {\n  title: string\n  description?: string\n  image?: { light: string; dark?: string; alt: string }\n  preview?: ReactNode\n  layers?: CaiVisualLayer[]\n  className?: string\n  size?: CaiVisualSize\n  appearance?: \"card\" | \"freeform\"\n  playback?: CaiIsometricProps[\"playback\"]\n}\n\nexport function CaiVisualTile({ title, description, image, preview, layers = [], className, size = \"hero\", appearance = \"card\", playback = \"loop\" }: CaiVisualTileProps) {\n  const [loaded, setLoaded] = useState(!image)\n  const aspect = { hero: \"aspect-[16/9]\", wide: \"aspect-[3/1]\", tall: \"aspect-[3/4]\", compact: \"aspect-[2/1]\" }[size]\n  return <div className={\"relative isolate h-full min-w-0 overflow-hidden p-3 \" + (appearance === \"card\" ? \"border border-emerald-900/15 bg-emerald-50 text-emerald-950 dark:border-emerald-300/15 dark:bg-[#192b24] dark:text-emerald-50 \" : \"text-foreground \") + (className ?? \"\")}>\n    <div className=\"relative z-10\"><p className=\"text-base font-semibold\">{title}</p>{description && <p className=\"mt-1 text-xs opacity-75\">{description}</p>}</div>\n    <div className={\"relative mt-2 w-full \" + aspect}>\n      {preview && <div className=\"pointer-events-none absolute inset-0 overflow-hidden animate-in fade-in-0 duration-200 motion-reduce:animate-none\">{preview}</div>}\n      {image && <picture><source media=\"(prefers-color-scheme: dark)\" srcSet={image.dark ?? image.light}/><img src={image.light} alt={image.alt} onLoad={() => setLoaded(true)} onError={() => setLoaded(true)} className={\"absolute inset-0 h-full w-full object-contain transition-opacity duration-200 motion-reduce:transition-none \" + (loaded ? \"opacity-100\" : \"opacity-0\")} /></picture>}\n      {loaded && layers.map(({ x, y, size, delay, ...layer }, i) => <div key={i} className=\"pointer-events-none absolute\" style={{ left: x + \"%\", top: y + \"%\", width: size + \"%\", transform: \"translate(-50%, -50%)\" } as CSSProperties}><CaiIsometric playback={playback} {...layer} delay={delay ?? (image || preview ? 220 : 0) + i * 60} /></div>)}\n    </div>\n  </div>\n}\n\n/** Layout primitives: DOM order is preserved for reading and keyboard navigation. */\nexport function CaiVisualGrid({ children, className = \"\" }: { children: ReactNode; className?: string }) {\n  return <div className={\"grid min-w-0 grid-cols-2 items-start gap-2 \" + className}>{children}</div>\n}\nexport function CaiVisualGridItem({ children, size = \"compact\", className = \"\" }: { children: ReactNode; size?: CaiVisualSize; className?: string }) {\n  return <div className={(size === \"hero\" || size === \"wide\" ? \"col-span-2 \" : \"col-span-1 \") + (size === \"tall\" ? \"row-span-2 \" : \"\") + \"min-w-0 \" + className}>{children}</div>\n}\n\nexport type CaiSceneNode = { id: string; x: number; y: number; width: number; depth?: number; content: ReactNode; label?: string }\nexport type CaiSceneConnection = { from: string; to: string }\n/** Decorative free-form scene using normalized 0–100 coordinates. Provide equivalent text outside the scene. */\nexport function CaiVisualScene({ nodes, connections = [], className = \"\", aspectRatio = \"16 / 9\" }: { nodes: CaiSceneNode[]; connections?: CaiSceneConnection[]; className?: string; aspectRatio?: string }) {\n  return <div aria-hidden=\"true\" className={\"pointer-events-none relative isolate w-full overflow-hidden \" + className} style={{ aspectRatio }}>\n    <svg className=\"absolute inset-0 h-full w-full text-emerald-600/50 dark:text-emerald-300/50\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" fill=\"none\">\n      {connections.map(({ from, to }) => {\n        const a = nodes.find(n => n.id === from), b = nodes.find(n => n.id === to)\n        if (!a || !b) return null\n        return <path key={from + \":\" + to} d={`M ${a.x} ${a.y} C ${(a.x + b.x)/2} ${a.y}, ${(a.x+b.x)/2} ${b.y}, ${b.x} ${b.y}`} stroke=\"currentColor\" strokeWidth=\"1.5\" vectorEffect=\"non-scaling-stroke\" strokeDasharray=\"4 6\" />\n      })}\n    </svg>\n    {nodes.map(n => <div key={n.id} className=\"absolute -translate-x-1/2 -translate-y-1/2\" style={{ left: n.x + \"%\", top: n.y + \"%\", width: n.width + \"%\", zIndex: n.depth ?? 1 }}>{n.content}{n.label && <div className=\"text-center text-xs text-muted-foreground\">{n.label}</div>}</div>)}\n  </div>\n}\n",
      "type": "registry:ui"
    }
  ]
}