{
  "id": "mui_branch_flow",
  "name": "Branch Flow",
  "width": 1200,
  "height": 720,
  "cornerRadius": 0,
  "fit": "Layout",
  "backgroundColor": "#08070d",
  "opacity": 1,
  "x": -600,
  "y": -360,
  "responsive": {
    "enabled": true,
    "mode": "constraint",
    "width": {
      "type": "fixed"
    },
    "height": {
      "type": "fixed"
    },
    "maintainAspectRatio": false,
    "scaleObjects": false,
    "breakpoints": [
      {
        "id": "bp_mobile",
        "name": "Mobile",
        "minWidth": 0,
        "maxWidth": 599
      },
      {
        "id": "bp_tablet",
        "name": "Tablet",
        "minWidth": 600,
        "maxWidth": 1023
      },
      {
        "id": "bp_desktop",
        "name": "Desktop",
        "minWidth": 1024
      }
    ]
  },
  "layoutProps": {
    "mode": "linear",
    "direction": "vertical",
    "gap": 0,
    "padding": {
      "top": 0,
      "right": 0,
      "bottom": 0,
      "left": 0
    },
    "alignItems": "stretch",
    "layoutSizingHorizontal": "fixed",
    "layoutSizingVertical": "fixed"
  },
  "seo": {
    "title": "Branch Flow — Exode Motion UI",
    "description": "Signals originate from a root source, travel along branching bezier splines to child nodes, and pulse on arrival."
  },
  "stateMachine": {
    "inputs": [
      {
        "id": "in_root",
        "name": "root",
        "value": {
          "type": "Text",
          "value": "Source",
          "defaultValue": "Source"
        }
      },
      {
        "id": "in_branches",
        "name": "branches",
        "value": {
          "type": "Text",
          "value": "Auth,Database,Storage,Edge,AI",
          "defaultValue": "Auth,Database,Storage,Edge,AI"
        }
      },
      {
        "id": "in_speed",
        "name": "speed",
        "value": {
          "type": "Number",
          "value": 1,
          "defaultValue": 1
        }
      },
      {
        "id": "in_density",
        "name": "density",
        "value": {
          "type": "Number",
          "value": 6,
          "defaultValue": 6
        }
      },
      {
        "id": "in_accent",
        "name": "accent",
        "value": {
          "type": "Text",
          "value": "#5e17eb",
          "defaultValue": "#5e17eb"
        }
      },
      {
        "id": "in_accent2",
        "name": "accent2",
        "value": {
          "type": "Text",
          "value": "#00d68f",
          "defaultValue": "#00d68f"
        }
      },
      {
        "id": "in_text",
        "name": "text",
        "value": {
          "type": "Text",
          "value": "#f2f4f8",
          "defaultValue": "#f2f4f8"
        }
      },
      {
        "id": "in_bg",
        "name": "bg",
        "value": {
          "type": "Text",
          "value": "#08070d",
          "defaultValue": "#08070d"
        }
      }
    ],
    "layers": [
      {
        "name": "Base",
        "entryStateId": "s_idle",
        "states": [
          {
            "id": "s_idle",
            "name": "Idle",
            "loop": true,
            "transitions": []
          }
        ]
      }
    ],
    "logicNodes": []
  },
  "animations": [],
  "physics": {
    "enabled": false,
    "gravity": {
      "x": 0,
      "y": 9.8
    }
  },
  "animationFlow": [],
  "navigation": [],
  "stateVariables": [],
  "objects": [
    {
      "id": "stage",
      "name": "Stage",
      "type": "Group",
      "transform": {
        "x": 0,
        "y": 0,
        "rotation": 0,
        "scale_x": 1,
        "scale_y": 1,
        "opacity": 1,
        "skew_x": 0,
        "skew_y": 0
      },
      "width": 1200,
      "height": 720,
      "geometry": {
        "type": "Rectangle",
        "width": 1200,
        "height": 720,
        "cornerRadius": 0
      },
      "cornerRadius": 0,
      "children": [],
      "clipContent": true,
      "style": {
        "fill": {
          "type": "Solid",
          "color": "#08070d",
          "opacity": 1
        },
        "effects": [
          {
            "id": "fx_branch-flow",
            "type": "CustomEffect",
            "name": "Branch Flow",
            "isEnabled": true,
            "params": {},
            "code": "/* Shared by every motion-ui effect (prepended to each one).\n   Rules for this file and the effects: the .bexode compiler minifies effect\n   code, so use explicit semicolons, block comments only, and never write a\n   minus followed by a negative value (it collapses to a decrement). */\n\n/* Read a live state-machine input, falling back to a default. */\nfunction inp(env, name, fallback) {\n  const v = env.inputs ? env.inputs[name] : undefined;\n  if (v === undefined || v === null || v === '') return fallback;\n  if (typeof fallback === 'number') {\n    const n = Number(v);\n    return isFinite(n) ? n : fallback;\n  }\n  if (typeof fallback === 'boolean') return v === true || v === 1 || v === 'true';\n  return v;\n}\n\n/* '#rgb' / '#rrggbb' to [r, g, b]; anything else falls back to white. */\nfunction rgbOf(hex) {\n  let h = String(hex || '').trim().replace('#', '');\n  if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];\n  if (!/^[0-9a-fA-F]{6}$/.test(h)) return [255, 255, 255];\n  const n = parseInt(h, 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nfunction rgba(hex, a) {\n  const c = rgbOf(hex);\n  return 'rgba(' + c[0] + ',' + c[1] + ',' + c[2] + ',' + Math.max(0, Math.min(1, a)) + ')';\n}\n\nfunction mix(a, b, t) {\n  const x = rgbOf(a), y = rgbOf(b);\n  const r = Math.round(x[0] + (y[0] - x[0]) * t);\n  const g = Math.round(x[1] + (y[1] - x[1]) * t);\n  const bl = Math.round(x[2] + (y[2] - x[2]) * t);\n  return '#' + ((1 << 24) + (r << 16) + (g << 8) + bl).toString(16).slice(1);\n}\n\n/* A soft round glow, rendered once per colour and blitted with drawImage\n   (much cheaper than shadowBlur on every particle). */\nconst __glows = {};\nfunction glowSprite(hex) {\n  if (__glows[hex]) return __glows[hex];\n  const s = 64;\n  const c = document.createElement('canvas');\n  c.width = s; c.height = s;\n  const g = c.getContext('2d');\n  const gr = g.createRadialGradient(s / 2, s / 2, 0, s / 2, s / 2, s / 2);\n  gr.addColorStop(0, rgba(hex, 1));\n  gr.addColorStop(0.18, rgba(hex, 0.55));\n  gr.addColorStop(0.45, rgba(hex, 0.14));\n  gr.addColorStop(1, rgba(hex, 0));\n  g.fillStyle = gr;\n  g.fillRect(0, 0, s, s);\n  __glows[hex] = c;\n  return c;\n}\n\nfunction glow(ctx, hex, x, y, r, a) {\n  if (r <= 0 || a <= 0) return;\n  ctx.globalAlpha = Math.min(1, a);\n  ctx.drawImage(glowSprite(hex), x - r, y - r, r * 2, r * 2);\n  ctx.globalAlpha = 1;\n}\n\n/* Frame clock: seconds since start and a clamped delta. */\nfunction tick(S) {\n  const now = performance.now();\n  if (!S.t0) { S.t0 = now; S.last = now; }\n  S.dt = Math.min(0.05, Math.max(0.001, (now - S.last) / 1000));\n  S.last = now;\n  S.age = (now - S.t0) / 1000;\n  return S.dt;\n}\n\n/* Deterministic pseudo-random so layouts are stable across resizes. */\nfunction rng(seed) {\n  let s = seed >>> 0 || 1;\n  return function () {\n    s = (s * 1664525 + 1013904223) >>> 0;\n    return s / 4294967296;\n  };\n}\n\nfunction ease(x) { return x < 0.5 ? 4 * x * x * x : 1 + (Math.pow(2 * x - 2, 3)) / 2; }\nfunction clamp(v, a, b) { return v < a ? a : v > b ? b : v; }\n\nconst SANS = 'Inter, Helvetica, Arial, sans-serif';\nconst MONO = 'ui-monospace, Menlo, monospace';\n\nfunction roundRect(ctx, x, y, w, h, r) {\n  r = Math.min(r, w / 2, h / 2);\n  ctx.beginPath();\n  ctx.moveTo(x + r, y);\n  ctx.arcTo(x + w, y, x + w, y + h, r);\n  ctx.arcTo(x + w, y + h, x, y + h, r);\n  ctx.arcTo(x, y + h, x, y, r);\n  ctx.arcTo(x, y, x + w, y, r);\n  ctx.closePath();\n}\n\n/* Shared backdrop: flat colour, soft vignette and fine grain. */\nfunction backdrop(ctx, W, H, bg, tint, amt) {\n  ctx.fillStyle = bg;\n  ctx.fillRect(0, 0, W, H);\n  if (tint && amt > 0) {\n    const gr = ctx.createRadialGradient(W / 2, H * 0.45, 0, W / 2, H * 0.45, Math.max(W, H) * 0.7);\n    gr.addColorStop(0, rgba(tint, 0.10 * amt));\n    gr.addColorStop(1, rgba(tint, 0));\n    ctx.fillStyle = gr;\n    ctx.fillRect(0, 0, W, H);\n  }\n  const vg = ctx.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.3, W / 2, H / 2, Math.max(W, H) * 0.8);\n  vg.addColorStop(0, 'rgba(0,0,0,0)');\n  vg.addColorStop(1, 'rgba(0,0,0,0.45)');\n  ctx.fillStyle = vg;\n  ctx.fillRect(0, 0, W, H);\n}\n\n/* Greedy word wrap with the current ctx.font. */\nfunction wrap(ctx, text, maxW) {\n  const out = [];\n  String(text).split('\\n').forEach(function (para) {\n    const words = para.split(' ');\n    let cur = '';\n    for (let i = 0; i < words.length; i++) {\n      const next = cur ? cur + ' ' + words[i] : words[i];\n      if (cur && ctx.measureText(next).width > maxW) { out.push(cur); cur = words[i]; } else cur = next;\n    }\n    out.push(cur);\n  });\n  return out;\n}\n\n/* Largest font size (up to max) at which text wraps into maxLines within maxW. */\nfunction fitFont(ctx, text, weight, family, maxW, maxLines, max, min) {\n  let fs = max;\n  while (fs > min) {\n    ctx.font = weight + ' ' + fs + 'px ' + family;\n    if (wrap(ctx, text, maxW).length <= maxLines) break;\n    fs = fs * 0.92;\n  }\n  ctx.font = weight + ' ' + fs + 'px ' + family;\n  return fs;\n}\n\n/* Smoothed pointer that idles along a slow figure-eight when the cursor is away. */\nfunction follow(S, env, W, H, k) {\n  const pt = env.pointer || {};\n  const t = S.age || 0;\n  const tx = pt.isHovered ? pt.localX : W / 2 + Math.sin(t * 0.37) * W * 0.3;\n  const ty = pt.isHovered ? pt.localY : H / 2 + Math.sin(t * 0.74) * H * 0.22;\n  if (S.px === undefined) { S.px = tx; S.py = ty; }\n  S.px += (tx - S.px) * Math.min(1, S.dt * (k || 6));\n  S.py += (ty - S.py) * Math.min(1, S.dt * (k || 6));\n  S.inside = !!pt.isHovered;\n  return pt;\n}\n\n/* Optional centred headline over a background effect. */\nfunction title(ctx, W, H, text, sub, ink, accent, bg) {\n  if (!text) return;\n  if (bg) {\n    /* Soft scrim so the headline reads over busy motion. */\n    const sc = ctx.createRadialGradient(W / 2, H / 2, 0, W / 2, H / 2, Math.min(W * 0.5, 560));\n    sc.addColorStop(0, rgba(bg, 0.72));\n    sc.addColorStop(1, rgba(bg, 0));\n    ctx.fillStyle = sc;\n    ctx.fillRect(0, 0, W, H);\n  }\n  ctx.textAlign = 'center';\n  ctx.textBaseline = 'alphabetic';\n  const maxW = Math.min(W * 0.86, 900);\n  const fs = fitFont(ctx, text, 600, SANS, maxW, 2, clamp(W * 0.065, 26, 72), 16);\n  const lines = wrap(ctx, text, maxW);\n  const lh = fs * 1.08;\n  const y0 = H / 2 - (lines.length * lh) / 2 + fs * 0.8 - (sub ? fs * 0.35 : 0);\n  ctx.fillStyle = ink;\n  lines.forEach(function (l, i) { ctx.fillText(l, W / 2, y0 + i * lh); });\n  if (sub) {\n    ctx.font = '500 ' + clamp(fs * 0.24, 11, 15) + 'px ' + MONO;\n    ctx.fillStyle = rgba(accent, 0.85);\n    ctx.fillText(String(sub).toUpperCase(), W / 2, y0 + (lines.length - 1) * lh + fs * 0.9);\n  }\n}\n\n/* Branch Flow: an interactive tree-splitting motion flow inspired by\n   reactvibe.com/docs/motion/branch-flow. Signals originate from a root source,\n   travel along branching bezier splines to child nodes, and pulse on arrival. */\nlet S = null;\n\nfunction render(ctx, env) {\n  const W = env.width, H = env.height;\n  if (!S) {\n    S = {\n      packets: [],\n      nodes: [],\n      hoverNode: -1,\n    };\n  }\n  const dt = tick(S);\n\n  const rootLabel = String(inp(env, 'root', 'Source'));\n  const branchLabels = String(inp(env, 'branches', 'Auth,Database,Storage,Edge,AI')).split(',');\n  const speed = clamp(inp(env, 'speed', 1), 0.1, 4);\n  const density = clamp(inp(env, 'density', 6), 2, 20);\n  const A = inp(env, 'accent', '#5e17eb');\n  const A2 = inp(env, 'accent2', '#00d68f');\n  const ink = inp(env, 'text', '#f2f4f8');\n  const bg = inp(env, 'bg', '#08070d');\n\n  ctx.save();\n  ctx.translate(-W / 2, -H / 2);\n  backdrop(ctx, W, H, bg, A, 0.4);\n\n  const rootX = W * 0.18;\n  const rootY = H / 2;\n  const numBranches = branchLabels.length;\n  const targetX = W * 0.82;\n\n  // Compute node positions\n  const targets = [];\n  const spacing = Math.min(H * 0.78 / Math.max(1, numBranches - 1), 90);\n  const startY = H / 2 - ((numBranches - 1) * spacing) / 2;\n\n  for (let i = 0; i < numBranches; i++) {\n    targets.push({\n      x: targetX,\n      y: startY + i * spacing,\n      label: branchLabels[i].trim(),\n    });\n  }\n\n  // Draw branching curves\n  for (let i = 0; i < targets.length; i++) {\n    const tg = targets[i];\n    const cpx1 = rootX + (tg.x - rootX) * 0.45;\n    const cpy1 = rootY;\n    const cpx2 = rootX + (tg.x - rootX) * 0.55;\n    const cpy2 = tg.y;\n\n    // Cable glow & line\n    ctx.beginPath();\n    ctx.moveTo(rootX, rootY);\n    ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, tg.x, tg.y);\n    ctx.strokeStyle = rgba(A, 0.18);\n    ctx.lineWidth = 3;\n    ctx.stroke();\n\n    ctx.strokeStyle = rgba('#ffffff', 0.1);\n    ctx.lineWidth = 1;\n    ctx.stroke();\n  }\n\n  // Spawn and advance packets\n  if (Math.random() < dt * density * 3.5 * speed) {\n    const branchIdx = Math.floor(Math.random() * targets.length);\n    S.packets.push({\n      branch: branchIdx,\n      t: 0,\n      size: 3 + Math.random() * 2.5,\n      hue: Math.random() > 0.4 ? A : A2,\n    });\n  }\n\n  for (let i = S.packets.length - 1; i >= 0; i--) {\n    const p = S.packets[i];\n    p.t += dt * 0.65 * speed;\n    if (p.t >= 1) {\n      glow(ctx, p.hue, targets[p.branch].x, targets[p.branch].y, 35, 0.7);\n      S.packets.splice(i, 1);\n      continue;\n    }\n\n    const tg = targets[p.branch];\n    const cpx1 = rootX + (tg.x - rootX) * 0.45;\n    const cpy1 = rootY;\n    const cpx2 = rootX + (tg.x - rootX) * 0.55;\n    const cpy2 = tg.y;\n\n    const u = p.t;\n    const px = Math.pow(1 - u, 3) * rootX + 3 * Math.pow(1 - u, 2) * u * cpx1 + 3 * (1 - u) * u * u * cpx2 + Math.pow(u, 3) * tg.x;\n    const py = Math.pow(1 - u, 3) * rootY + 3 * Math.pow(1 - u, 2) * u * cpy1 + 3 * (1 - u) * u * u * cpy2 + Math.pow(u, 3) * tg.y;\n\n    glow(ctx, p.hue, px, py, 14, 0.85);\n    ctx.beginPath();\n    ctx.arc(px, py, p.size, 0, Math.PI * 2);\n    ctx.fillStyle = '#ffffff';\n    ctx.fill();\n  }\n\n  // Draw Root Node\n  const rootR = 26;\n  glow(ctx, A, rootX, rootY, rootR * 2.2, 0.6);\n\n  ctx.beginPath();\n  ctx.arc(rootX, rootY, rootR, 0, Math.PI * 2);\n  ctx.fillStyle = '#12101a';\n  ctx.fill();\n  ctx.strokeStyle = A;\n  ctx.lineWidth = 2.5;\n  ctx.stroke();\n\n  ctx.font = '600 13px ' + SANS;\n  ctx.textAlign = 'center';\n  ctx.textBaseline = 'middle';\n  ctx.fillStyle = ink;\n  ctx.fillText(rootLabel, rootX, rootY);\n\n  // Draw Branch Target Nodes\n  const pt = env.pointer || {};\n  for (let i = 0; i < targets.length; i++) {\n    const tg = targets[i];\n    const nR = 20;\n\n    const over = !!pt.isHovered && Math.hypot(pt.localX - tg.x, pt.localY - tg.y) < nR + 6;\n    if (over && pt.isDown && env.emit) env.emit('nodeClick');\n\n    if (over) glow(ctx, A2, tg.x, tg.y, nR * 2, 0.7);\n\n    ctx.beginPath();\n    ctx.arc(tg.x, tg.y, nR, 0, Math.PI * 2);\n    ctx.fillStyle = over ? '#1f1a2e' : '#110f18';\n    ctx.fill();\n    ctx.strokeStyle = over ? A2 : rgba(ink, 0.3);\n    ctx.lineWidth = over ? 2 : 1.2;\n    ctx.stroke();\n\n    // Node label tag\n    ctx.font = '500 12.5px ' + SANS;\n    ctx.textAlign = 'left';\n    ctx.fillStyle = over ? '#ffffff' : rgba(ink, 0.85);\n    ctx.fillText(tg.label, tg.x + nR + 12, tg.y);\n  }\n\n  ctx.restore();\n}\n"
          }
        ]
      },
      "layoutProps": {
        "layoutSizingHorizontal": "fill",
        "layoutSizingVertical": "fill"
      },
      "zIndex": 1,
      "interactions": []
    }
  ]
}
