Skip to content

Write HTML. Render video. Built for agents.

29.7 KB
Raw Blame
{"html":"<!doctype html>\n<!-- Demo plate for the catalog preview. Same helpers as hw-arrow.html, with an\n     opaque root background so the transparent overlay reads, and NON-DEFAULT\n     control states shown side by side per the control-surface convention:\n     swoop+spray+lively / gentle+sharp / straight+soft+boil-off — every\n     declared pose of every control renders here (state contact sheet).\n     Not installed by `hyperframes add` - registry-item.json lists hw-arrow.html only. -->\n<html lang=\"en\">\n  <head><base href=\"/public/catalog/items/hw-arrow/\">\n    <meta charset=\"utf-8\" />\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\n      @font-face {\n        font-family: \"Caveat\";\n        src: url(\"/public/catalog/assets/891951df5e8b5b0f.woff2\") format(\"woff2\");\n        font-weight: 700;\n        font-display: block;\n      }\n      *,\n      *::before,\n      *::after {\n        margin: 0;\n        padding: 0;\n        box-sizing: border-box;\n      }\n      body {\n        background: #17161a;\n        overflow: hidden;\n      }\n      /* ---- hw-arrow ------------------------------------------------------\n         Hand-wobbled draw-on arrow, boiling, with a travel-aligned\n         arrival stretch on the head. Position the wrapper, build with a\n         CONFIG (arrowStyle / strokeType / boil), wire with a position\n         only: hwArrowBuild + hwArrowOn / hwArrowOff. Requires the hw\n         family helpers below (hwOnUpdate / hwHash / hwBoil / hwBoilPose /\n         springEase / hwStrokeApply / hwDrawOn) in the host script. */\n      .hw-arrow {\n        position: absolute;\n        pointer-events: none;\n      }\n      .hw-arrow svg {\n        width: 100%;\n        height: 100%;\n        overflow: visible;\n      }\n      .hw-arrow path {\n        fill: none;\n        stroke: var(--hw-arrow-color, var(--hw-ink, #f4f2ec));\n        stroke-width: var(--hw-arrow-w, 6);\n        stroke-linecap: round;\n        stroke-linejoin: round;\n      }\n      .hw-arrow.hw-soft path {\n        filter: blur(0.6px);\n      }\n      /* self-preview scene */\n      #hw-ar-scene {\n        position: absolute;\n        inset: 0;\n        background: linear-gradient(135deg, #274060 0%, #123 100%);\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        font-family: var(--hw-font-print, \"Caveat\", cursive);\n        font-weight: 700;\n        font-size: 80px;\n        color: rgba(244, 242, 236, 0.92);\n      }\n      #hw-ar-scene span {\n        position: absolute;\n        top: 650px;\n        width: 420px;\n        text-align: center;\n        font-size: 42px;\n        color: rgba(244, 242, 236, 0.75);\n      }\n    </style>\n  </head>\n  <body>\n    <!-- Self-preview. WIRING (g09): copy the .hw-arrow CSS, the markup\n         pattern (positioned wrapper + empty svg with a viewBox), and the\n         helpers into your host. Build with a CONFIG, wire with a position\n         only — the helper owns its durations, eases, and seeds:\n\n           hwArrowBuild(\"#hw-my-arrow\", {\n             arrowStyle: \"swoop\",  // \"straight\" | \"gentle\" | \"swoop\"\n             strokeType: \"spray\",  // \"plain\" | \"soft\" | \"sharp\" | \"spray\"\n             boil: \"calm\",         // \"off\" | \"calm\" | \"lively\"\n           });\n           hwArrowOn(tl, \"#hw-my-arrow\", 2.0);\n           hwArrowOff(tl, \"#hw-my-arrow\", 8.0);\n\n         Each built target needs a UNIQUE id — the wobble seed and the\n         sharp/spray mask id derive from it (an id-less target\n         console.errors and falls back to a shared \"hw-arrow\" slot).\n\n         Legacy single-path wiring (a <path> in the svg + hwArrowPath)\n         keeps working exactly as before:\n\n           document.querySelector(\"#hw-my-arrow path\")\n             .setAttribute(\"d\", hwArrowPath(360, 160, \"swoop\", 3));\n           hwArrowOn(tl, \"#hw-my-arrow\", 2.0);\n           hwBoil(tl, \"#hw-my-arrow\", { frameDrop: 3, seed: 3 });\n           hwArrowOff(tl, \"#hw-my-arrow\", 8.0);\n    -->\n    <div\n      id=\"hw-ar-root\"\n      data-composition-id=\"hw-arrow-demo\"\n      data-start=\"0\"\n      data-duration=\"4\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n    >\n      <div id=\"hw-ar-scene\">\n        <span style=\"left: 140px\">swoop &middot; spray &middot; lively</span>\n        <span style=\"left: 750px\">gentle &middot; sharp</span>\n        <span style=\"left: 1360px\">straight &middot; soft &middot; boil off</span>\n      </div>\n      <div\n        class=\"hw-arrow\"\n        id=\"hw-ar-a\"\n        style=\"left: 140px; top: 360px; width: 420px; height: 220px\"\n      >\n        <svg viewBox=\"0 0 420 220\"></svg>\n      </div>\n      <div\n        class=\"hw-arrow\"\n        id=\"hw-ar-b\"\n        style=\"left: 750px; top: 360px; width: 420px; height: 220px\"\n      >\n        <svg viewBox=\"0 0 420 220\"></svg>\n      </div>\n      <div\n        class=\"hw-arrow\"\n        id=\"hw-ar-c\"\n        style=\"left: 1360px; top: 360px; width: 420px; height: 220px\"\n      >\n        <svg viewBox=\"0 0 420 220\"></svg>\n      </div>\n      <div\n        id=\"hw-ar-drv\"\n        class=\"clip\"\n        data-start=\"0\"\n        data-duration=\"4\"\n        data-track-index=\"0\"\n        style=\"position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none\"\n      ></div>\n    </div>\n    <script>\n      (function () {\n        window.__timelines = window.__timelines || {};\n\n        /* ---- hw-boil helpers (shared family runtime — copy once per host) ---- */\n        window.hwOnUpdate = function (tl, fn) {\n          if (!tl.__hwRenders) {\n            tl.__hwRenders = [];\n            tl.eventCallback(\"onUpdate\", function () {\n              for (var i = 0; i < tl.__hwRenders.length; i++) tl.__hwRenders[i]();\n            });\n          }\n          tl.__hwRenders.push(fn);\n          fn();\n        };\n        window.hwHash = function (n, seed) {\n          var x = Math.sin(n * 127.1 + (seed || 1) * 311.7) * 43758.5453;\n          return (x - Math.floor(x)) * 2 - 1;\n        };\n        window.hwBoil = function (tl, target, opts) {\n          opts = opts || {};\n          var amp = opts.amp !== undefined ? opts.amp : 1.6;\n          var rot = opts.rot !== undefined ? opts.rot : 0.5;\n          var fps = opts.fps || 30;\n          var drop = opts.frameDrop || 3;\n          var seed = opts.seed || 1;\n          var els = gsap.utils.toArray(target);\n          window.hwOnUpdate(tl, function () {\n            var step = Math.floor((tl.time() * fps) / drop);\n            for (var i = 0; i < els.length; i++) {\n              gsap.set(els[i], {\n                x: window.hwHash(step * 3 + i * 97, seed) * amp,\n                y: window.hwHash(step * 3 + 1 + i * 97, seed) * amp,\n                rotation: (opts.baseRot || 0) + window.hwHash(step * 3 + 2 + i * 97, seed) * rot,\n              });\n            }\n          });\n        };\n        // boil control: authored poses over the family-locked frameDrop.\n        // Unknown pose → default + console error (bounded-controls law).\n        window.hwBoilPose = function (tl, target, pose, opts) {\n          opts = opts || {};\n          var poses = { calm: { amp: 1.6, rot: 0.5 }, lively: { amp: 2.6, rot: 0.9 } };\n          if (pose === \"off\") return;\n          var p = poses[pose];\n          if (!p) {\n            console.error('hw: unknown boil pose \"' + pose + '\" — falling back to \"calm\"');\n            p = poses.calm;\n          }\n          window.hwBoil(tl, target, { amp: p.amp, rot: p.rot, frameDrop: 3, seed: opts.seed || 1 });\n        };\n\n        /* ---- spring library (snappy register; factory duration consumed verbatim) ---- */\n        var LN1000 = Math.log(1000);\n        var FEELS = {\n          snappy: { zeta: 0.9, response: 0.22 },\n        };\n        window.springEase = function (opts) {\n          var f = opts.feel ? FEELS[opts.feel] : opts;\n          var zeta = f.zeta,\n            response = f.response;\n          var w0 = (2 * Math.PI) / response;\n          var T = LN1000 / (zeta * w0);\n          var x;\n          if (zeta < 1) {\n            var wd = w0 * Math.sqrt(1 - zeta * zeta);\n            x = function (t) {\n              return (\n                1 -\n                Math.exp(-zeta * w0 * t) *\n                  (Math.cos(wd * t) + ((zeta * w0) / wd) * Math.sin(wd * t))\n              );\n            };\n          } else {\n            x = function (t) {\n              return 1 - Math.exp(-w0 * t) * (1 + w0 * t);\n            };\n          }\n          var xT = x(T);\n          return {\n            ease: function (p) {\n              return p >= 1 ? 1 : x(p * T) / xT;\n            },\n            duration: T,\n            zeta: zeta,\n            response: response,\n          };\n        };\n\n        /* ---- pen-velocity ease: pure function of the path geometry ----\n           Sample 25–75 curvature-adaptive points, speed ∝ 1/(1+k·curvature)\n           floored at 0.22 (a pen slows into curves, never stalls), integrate\n           ds/speed, invert to a normalized time→distance ease. Seek-safe:\n           no per-frame state. */\n        window.hwPenEase = function (pathEl, opts) {\n          opts = opts || {};\n          var kCurve = opts.kCurve !== undefined ? opts.kCurve : 10;\n          var L = pathEl.getTotalLength();\n          if (L <= 0)\n            return {\n              ease: function (t) {\n                return t;\n              },\n              samples: 2,\n              inkTime: 1,\n              len: 0,\n            };\n          var PRE = 48;\n          var pts = [];\n          for (var i = 0; i <= PRE; i++) pts.push(pathEl.getPointAtLength((L * i) / PRE));\n          var curv = [0];\n          for (i = 1; i < PRE; i++) {\n            var ax = pts[i].x - pts[i - 1].x,\n              ay = pts[i].y - pts[i - 1].y;\n            var bx = pts[i + 1].x - pts[i].x,\n              by = pts[i + 1].y - pts[i].y;\n            var la = Math.hypot(ax, ay) || 1e-6,\n              lb = Math.hypot(bx, by) || 1e-6;\n            var dot = Math.max(-1, Math.min(1, (ax * bx + ay * by) / (la * lb)));\n            curv.push(Math.acos(dot) / ((la + lb) / 2));\n          }\n          curv.push(0);\n          var mass = 0;\n          for (i = 0; i < curv.length; i++) mass += curv[i];\n          var N = Math.max(25, Math.min(75, Math.round(25 + mass * 18)));\n          var seg = L / N;\n          var times = [0];\n          var t = 0;\n          for (i = 1; i <= N; i++) {\n            var u = ((i - 0.5) / N) * PRE;\n            var i0 = Math.floor(u),\n              f = u - i0;\n            var c = curv[Math.min(i0, PRE)] * (1 - f) + curv[Math.min(i0 + 1, PRE)] * f;\n            var speed = Math.max(1 / (1 + kCurve * c * 14), 0.22);\n            t += seg / speed;\n            times.push(t);\n          }\n          var total = times[N];\n          for (i = 0; i <= N; i++) times[i] /= total;\n          var easeFn = function (p) {\n            if (p <= 0) return 0;\n            if (p >= 1) return 1;\n            var lo = 0,\n              hi = N;\n            while (hi - lo > 1) {\n              var mid = (lo + hi) >> 1;\n              if (times[mid] <= p) lo = mid;\n              else hi = mid;\n            }\n            var span = times[hi] - times[lo] || 1e-9;\n            return (lo + (p - times[lo]) / span) / N;\n          };\n          return { ease: easeFn, samples: N, inkTime: total, len: L };\n        };\n\n        /* ---- stroke matrix: plain | soft | sharp | spray -------------------\n           strokeType is a g09 variant control. Authored constants per type;\n           unknown value → default (\"plain\") + console error (bounded-controls\n           law). sharp = micro stroke-dasharray gaps (dry marker) — draw-on\n           therefore rides a MASK clone (the visible dasharray never animates).\n           spray = index-seeded deterministic dots along the path via hwHash;\n           NO feTurbulence anywhere.\n           Returns { draw: pathToDashAnimate, group: maskedGroupOrNull } */\n        window.hwStrokeTypes = {\n          plain: {},\n          soft: { blur: 0.6 },\n          sharp: { dash: [3.0, 1.55] }, // × stroke-width\n          spray: {\n            coreOpacity: 0.5,\n            coreBlur: 0.4,\n            density: 0.16,\n            scatter: 2.6,\n            rMin: 1.1,\n            rMax: 2.6,\n          },\n        };\n        window.hwStrokeApply = function (pathEl, type, opts) {\n          opts = opts || {};\n          var cfg = window.hwStrokeTypes[type];\n          if (!cfg) {\n            console.error('hw: unknown strokeType \"' + type + '\" — falling back to \"plain\"');\n            type = \"plain\";\n            cfg = window.hwStrokeTypes.plain;\n          }\n          var svg = pathEl.ownerSVGElement;\n          var ns = \"http://www.w3.org/2000/svg\";\n          var w = parseFloat(getComputedStyle(pathEl).strokeWidth) || 6;\n          if (type === \"plain\") return { draw: pathEl, group: null, type: type };\n          if (type === \"soft\") {\n            pathEl.style.filter = \"blur(\" + cfg.blur + \"px)\";\n            return { draw: pathEl, group: null, type: type };\n          }\n          // sharp + spray: wrap in a masked group, draw-on animates the mask clone\n          var id =\n            opts.id ||\n            \"hwsm-\" + Math.abs(Math.round(window.hwHash((opts.seed || 1) * 13.7, 5) * 1e6));\n          var defs = svg.querySelector(\"defs\");\n          if (!defs) {\n            defs = document.createElementNS(ns, \"defs\");\n            svg.insertBefore(defs, svg.firstChild);\n          }\n          var mask = document.createElementNS(ns, \"mask\");\n          mask.setAttribute(\"id\", id);\n          mask.setAttribute(\"maskUnits\", \"userSpaceOnUse\");\n          var clone = document.createElementNS(ns, \"path\");\n          clone.setAttribute(\"d\", pathEl.getAttribute(\"d\"));\n          clone.setAttribute(\"fill\", \"none\");\n          clone.setAttribute(\"stroke\", \"#fff\");\n          clone.setAttribute(\n            \"stroke-width\",\n            w * (type === \"spray\" ? 2 + (cfg.scatter * 2) / w : 1.7),\n          );\n          clone.setAttribute(\"stroke-linecap\", \"round\");\n          clone.setAttribute(\"stroke-linejoin\", \"round\");\n          mask.appendChild(clone);\n          defs.appendChild(mask);\n          var group = document.createElementNS(ns, \"g\");\n          group.setAttribute(\"mask\", \"url(#\" + id + \")\");\n          pathEl.parentNode.insertBefore(group, pathEl);\n          group.appendChild(pathEl);\n          if (type === \"sharp\") {\n            pathEl.setAttribute(\n              \"stroke-dasharray\",\n              (cfg.dash[0] * w).toFixed(1) + \" \" + (cfg.dash[1] * w).toFixed(1),\n            );\n          } else {\n            // spray: faint core + seeded dots\n            pathEl.setAttribute(\"stroke-opacity\", cfg.coreOpacity);\n            pathEl.style.filter = \"blur(\" + cfg.coreBlur + \"px)\";\n            var len = pathEl.getTotalLength();\n            var n = Math.round(len * cfg.density * (opts.densityScale || 1));\n            var seed = opts.seed || 1;\n            var dots = document.createElementNS(ns, \"g\");\n            for (var i = 0; i < n; i++) {\n              var t = Math.min(\n                1,\n                Math.max(0, (i + 0.5) / n + (window.hwHash(i * 7, seed) * 0.35) / n),\n              );\n              var pt = pathEl.getPointAtLength(t * len);\n              var pt2 = pathEl.getPointAtLength(Math.min(len, t * len + 0.5));\n              var tx = pt2.x - pt.x,\n                ty = pt2.y - pt.y;\n              var tl2 = Math.hypot(tx, ty) || 1;\n              var nx = -ty / tl2,\n                nyv = tx / tl2;\n              var off = window.hwHash(i * 7 + 1, seed) * (cfg.scatter + w * 0.55);\n              var r = cfg.rMin + Math.abs(window.hwHash(i * 7 + 2, seed)) * (cfg.rMax - cfg.rMin);\n              var c = document.createElementNS(ns, \"circle\");\n              c.setAttribute(\"cx\", (pt.x + nx * off).toFixed(1));\n              c.setAttribute(\"cy\", (pt.y + nyv * off).toFixed(1));\n              c.setAttribute(\"r\", r.toFixed(2));\n              c.setAttribute(\"fill\", getComputedStyle(pathEl).stroke);\n              dots.appendChild(c);\n            }\n            group.appendChild(dots);\n          }\n          return { draw: clone, group: group, type: type };\n        };\n\n        /* Draw-on across the stroke matrix: dash-animate whatever hwStrokeApply\n           says. The draw target is always solid (plain/soft: the path itself;\n           sharp/spray: the mask clone — the visible path keeps its texture\n           dasharray untouched). Optionally pen-velocity eased (opts.pen). */\n        window.hwDrawOn = function (tl, applied, at, dur, opts) {\n          opts = opts || {};\n          var p = applied.draw;\n          var len = p.getTotalLength();\n          // the draw target is always solid (plain/soft: the path itself; sharp/spray:\n          // the mask clone — the visible path keeps its texture dasharray untouched)\n          p.setAttribute(\"stroke-dasharray\", len + \" \" + len);\n          p.setAttribute(\"stroke-dashoffset\", len);\n          gsap.set(p, { opacity: 0 }); // kill the round-cap start nub pre-draw\n          var ease = opts.pen ? window.hwPenEase(p, opts).ease : opts.ease || \"power2.inOut\";\n          tl.set(p, { opacity: 1 }, at);\n          tl.to(\n            p,\n            { strokeDashoffset: 0, duration: dur === undefined ? 0.7 : dur, ease: ease },\n            at,\n          );\n        };\n\n        // ---- hw-arrow helpers (copy these too) ----\n        // Wobbled arrow path in a w x h box, tail at left, head at right.\n        // curve: \"straight\" | \"gentle\" | \"swoop\"\n        window.hwArrowPath = function (w, h, curve, seed) {\n          seed = seed || 1;\n          var bend = curve === \"swoop\" ? 0.55 : curve === \"gentle\" ? 0.28 : 0.06;\n          function wob(v, n, range) {\n            return v + window.hwHash(n, seed) * range;\n          }\n          var x0 = wob(4, 1, 3),\n            y0 = wob(h * 0.72, 2, 4),\n            x1 = wob(w - 10, 3, 4),\n            y1 = wob(h * 0.3, 4, 4);\n          var cx1 = wob(w * 0.35, 5, 10),\n            cy1 = wob(h * (0.72 + bend * 0.5), 6, 8);\n          var cx2 = wob(w * 0.7, 7, 10),\n            cy2 = wob(h * (0.3 + bend), 8, 8);\n          var ang = Math.atan2(y1 - cy2, x1 - cx2);\n          function head(da, len) {\n            var a = ang + Math.PI + da;\n            return (\n              \"M \" +\n              x1.toFixed(1) +\n              \" \" +\n              y1.toFixed(1) +\n              \" l \" +\n              (Math.cos(a) * len).toFixed(1) +\n              \" \" +\n              (Math.sin(a) * len).toFixed(1)\n            );\n          }\n          return (\n            \"M \" +\n            x0.toFixed(1) +\n            \" \" +\n            y0.toFixed(1) +\n            \" C \" +\n            cx1.toFixed(1) +\n            \" \" +\n            cy1.toFixed(1) +\n            \", \" +\n            cx2.toFixed(1) +\n            \" \" +\n            cy2.toFixed(1) +\n            \", \" +\n            x1.toFixed(1) +\n            \" \" +\n            y1.toFixed(1) +\n            \" \" +\n            head(0.5, wob(34, 9, 6)) +\n            \" \" +\n            head(-0.5, wob(34, 10, 6))\n          );\n        };\n\n        // ---- hwArrowBuild: CONFIG-reading component builder (g09) ----\n        // Builds the arrow as TWO paths (curve + head group) inside the\n        // target's svg with the same wobble math and seed slots as\n        // hwArrowPath, applies CONFIG.strokeType to the curve (the head\n        // stays plain — texture on a ~30px head reads as noise), and rigs\n        // the travel-aligned arrival wrapper: an outer g rotated to the\n        // travel direction + an inner g counter-rotated. The pair cancels,\n        // so geometry stays put while scaleX on the outer acts along\n        // travel. NO transform-box styles on these g's — they fight GSAP's\n        // baked SVG origins (the outer's fill-box would derive from its\n        // rotated child and the cancellation breaks).\n        // `seed` is internal — defaults per target from the element id\n        // (a pure hash of the id string: deterministic across page loads);\n        // it is NOT a control. Targets must carry unique ids: id-less\n        // targets fall back to a shared \"hw-arrow\" slot (identical wobble;\n        // duplicate mask ids cross-wire sharp/spray reveals), so that case\n        // fails loudly (bounded-controls law).\n        window.hwArrowBuild = function (target, CONFIG, seed) {\n          CONFIG = CONFIG || {};\n          var el = typeof target === \"string\" ? document.querySelector(target) : target;\n          var svg = el.querySelector(\"svg\");\n          if (!el.id)\n            console.error(\n              'hw: hwArrowBuild target has no id — falling back to the shared \"hw-arrow\" seed/mask slot; give each built target a unique id',\n            );\n          if (seed === undefined) {\n            var idStr = el.id || \"hw-arrow\";\n            seed = 0;\n            for (var si = 0; si < idStr.length; si++)\n              seed = (seed * 31 + idStr.charCodeAt(si)) % 997;\n            seed = (seed % 96) + 1;\n          }\n          var style = CONFIG.arrowStyle === undefined ? \"gentle\" : CONFIG.arrowStyle;\n          if (style !== \"straight\" && style !== \"gentle\" && style !== \"swoop\") {\n            console.error('hw: unknown arrowStyle \"' + style + '\" — falling back to \"gentle\"');\n            style = \"gentle\";\n          }\n          var vb = svg.viewBox.baseVal;\n          var w = vb && vb.width ? vb.width : el.clientWidth;\n          var h = vb && vb.height ? vb.height : el.clientHeight;\n          // same wobble math + hash slots as hwArrowPath (1–8 body, 9/10 head)\n          var bend = style === \"swoop\" ? 0.55 : style === \"gentle\" ? 0.28 : 0.06;\n          function wob(v, n, range) {\n            return v + window.hwHash(n, seed) * range;\n          }\n          var x0 = wob(4, 1, 3),\n            y0 = wob(h * 0.72, 2, 4),\n            x1 = wob(w - 10, 3, 4),\n            y1 = wob(h * 0.3, 4, 4);\n          var cx1 = wob(w * 0.35, 5, 10),\n            cy1 = wob(h * (0.72 + bend * 0.5), 6, 8);\n          var cx2 = wob(w * 0.7, 7, 10),\n            cy2 = wob(h * (0.3 + bend), 8, 8);\n          var ang = Math.atan2(y1 - cy2, x1 - cx2);\n          function headSeg(da, len) {\n            var a = ang + Math.PI + da;\n            return (\n              \"M \" +\n              x1.toFixed(1) +\n              \" \" +\n              y1.toFixed(1) +\n              \" l \" +\n              (Math.cos(a) * len).toFixed(1) +\n              \" \" +\n              (Math.sin(a) * len).toFixed(1)\n            );\n          }\n          var ns = \"http://www.w3.org/2000/svg\";\n          var curve = document.createElementNS(ns, \"path\");\n          curve.setAttribute(\n            \"d\",\n            \"M \" +\n              x0.toFixed(1) +\n              \" \" +\n              y0.toFixed(1) +\n              \" C \" +\n              cx1.toFixed(1) +\n              \" \" +\n              cy1.toFixed(1) +\n              \", \" +\n              cx2.toFixed(1) +\n              \" \" +\n              cy2.toFixed(1) +\n              \", \" +\n              x1.toFixed(1) +\n              \" \" +\n              y1.toFixed(1),\n          );\n          svg.appendChild(curve);\n          var headG = document.createElementNS(ns, \"g\");\n          var headInner = document.createElementNS(ns, \"g\");\n          var head = document.createElementNS(ns, \"path\");\n          head.setAttribute(\"d\", headSeg(0.5, wob(34, 9, 6)) + \" \" + headSeg(-0.5, wob(34, 10, 6)));\n          headInner.appendChild(head);\n          headG.appendChild(headInner);\n          svg.appendChild(headG);\n          // curve texture; mask id derived from the element id — deterministic\n          // and collision-free across id-bearing instances (id-less targets\n          // errored above and share the fallback)\n          var applied = window.hwStrokeApply(\n            curve,\n            CONFIG.strokeType === undefined ? \"plain\" : CONFIG.strokeType,\n            { seed: seed, id: (el.id || \"hw-arrow\") + \"-sm\" },\n          );\n          if (applied.group) {\n            // the item CSS (.hw-arrow path) outranks the mask clone's\n            // presentation attributes — pin them as inline styles so the\n            // reveal mask keeps its authored width and white stroke\n            applied.draw.style.stroke = \"#fff\";\n            applied.draw.style.strokeWidth = applied.draw.getAttribute(\"stroke-width\");\n          }\n          // arrival rig: rotate the WRAPPER to travel, counter-rotate the\n          // content — wrapper scaleX then acts along travel\n          var angDeg = (ang * 180) / Math.PI;\n          gsap.set(headG, { transformOrigin: \"50% 50%\", rotation: angDeg, opacity: 0 });\n          gsap.set(headInner, { transformOrigin: \"50% 50%\", rotation: -angDeg });\n          el.__hwArrowBuild = {\n            el: el,\n            applied: applied,\n            headG: headG,\n            headInner: headInner,\n            seed: seed,\n            boil: CONFIG.boil === undefined ? \"calm\" : CONFIG.boil,\n            boiled: false,\n          };\n          return el.__hwArrowBuild;\n        };\n\n        // Draw-on. Built targets (hwArrowBuild): accelerating draw (causal\n        // arrival), then the head pops with the g21 travel-aligned stretch —\n        // v measured numerically from the draw ease end-slope, S = min(0.06\n        // × v/2000, 0.25), volume preserved (scaleX × scaleY ≈ 1, asserted),\n        // 2-frame apply + snappy spring recovery (factory duration verbatim).\n        // Legacy single-path targets keep the shipped dashoffset behavior.\n        window.hwArrowOn = function (tl, target, at, dur) {\n          var el = typeof target === \"string\" ? document.querySelector(target) : target;\n          var b = el && el.__hwArrowBuild;\n          if (!b) {\n            var p = document.querySelector(target + \" path\");\n            var len = p.getTotalLength();\n            gsap.set(p, { strokeDasharray: len, strokeDashoffset: len });\n            tl.to(\n              p,\n              {\n                strokeDashoffset: 0,\n                duration: dur === undefined ? 0.7 : dur,\n                ease: \"power2.inOut\",\n              },\n              at,\n            );\n            return;\n          }\n          // built targets (g09): durations are item-locked — a\n          // legacy-signature `dur` is ignored + console.error (edit the item\n          // source to change); the legacy branch above keeps honoring it\n          if (dur !== undefined)\n            console.error(\n              \"hw: hwArrowOn draw duration is locked for built targets — ignoring dur=\" + dur,\n            );\n          dur = 0.7;\n          // the pen ACCELERATES into the head (power2.in) so the measured\n          // arrival velocity is real — a settling ease ends at ~zero slope\n          // and would make the stretch invisible\n          var drawEase = gsap.parseEase(\"power2.in\");\n          window.hwDrawOn(tl, b.applied, at, dur, { ease: drawEase });\n          var dlen = b.applied.draw.getTotalLength();\n          var eps = 1e-4;\n          var v = ((drawEase(1) - drawEase(1 - eps)) / eps) * (dlen / dur);\n          var S = Math.min(0.06 * (v / 2000), 0.25);\n          var rec = window.springEase({ feel: \"snappy\" });\n          var FPS = 30;\n          var st = { s: 0 };\n          var hg = b.headG;\n          window.hwOnUpdate(tl, function () {\n            // stretch ALONG travel (the wrapper's local x after rotation)\n            var along = 1 + st.s;\n            gsap.set(hg, { scaleX: along, scaleY: 1 / along });\n            var ax = parseFloat(gsap.getProperty(hg, \"scaleX\"));\n            var ay = parseFloat(gsap.getProperty(hg, \"scaleY\"));\n            if (Math.abs(ax * ay - 1) > 0.01)\n              console.error(\"hw volume law violated (arrowhead): \" + (ax * ay).toFixed(4));\n          });\n          tl.set(hg, { opacity: 1 }, at + dur);\n          tl.to(st, { s: S, duration: 2 / FPS, ease: \"power3.out\" }, at + dur);\n          tl.to(st, { s: 0, duration: rec.duration, ease: rec.ease }, at + dur + 3 / FPS);\n          // boil pose (recorded from CONFIG at build; hwBoil needs the\n          // timeline, so it registers on first wiring). Boil owns x/y/rotation\n          // of the WRAPPER element — the arrival stretch lives on the nested\n          // head rig, never on the boiled element.\n          if (!b.boiled) {\n            b.boiled = true;\n            window.hwBoilPose(tl, el, b.boil, { seed: b.seed });\n          }\n        };\n        window.hwArrowOff = function (tl, target, at) {\n          tl.to(target, { opacity: 0, duration: 0.3, ease: \"power2.in\" }, at);\n        };\n\n        // ---- demo: non-default control states, side by side ----\n        var tl = gsap.timeline({ paused: true });\n        window.hwArrowBuild(\"#hw-ar-a\", {\n          arrowStyle: \"swoop\",\n          strokeType: \"spray\",\n          boil: \"lively\",\n        });\n        window.hwArrowBuild(\"#hw-ar-b\", {\n          arrowStyle: \"gentle\",\n          strokeType: \"sharp\",\n          boil: \"calm\",\n        });\n        window.hwArrowBuild(\"#hw-ar-c\", {\n          arrowStyle: \"straight\",\n          strokeType: \"soft\",\n          boil: \"off\",\n        });\n        window.hwArrowOn(tl, \"#hw-ar-a\", 0.4);\n        window.hwArrowOn(tl, \"#hw-ar-b\", 0.9);\n        window.hwArrowOn(tl, \"#hw-ar-c\", 1.4);\n        window.hwArrowOff(tl, \"#hw-ar-a\", 3.4);\n        window.hwArrowOff(tl, \"#hw-ar-b\", 3.4);\n        window.hwArrowOff(tl, \"#hw-ar-c\", 3.4);\n        tl.set(\"#hw-ar-root\", { visibility: \"hidden\" }, 3.98);\n        window.__timelines[\"hw-arrow-demo\"] = tl;\n      })();\n    </script>\n  </body>\n</html>\n"}