react-swarm-rebuild 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +12 -0
- package/README.md +292 -2
- package/dist/audio.d.cts +9 -0
- package/dist/audio.d.ts +9 -0
- package/dist/bounds.d.cts +3 -0
- package/dist/bounds.d.ts +3 -0
- package/dist/engine.d.cts +4 -0
- package/dist/engine.d.ts +4 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +7 -0
- package/dist/math.d.cts +7 -0
- package/dist/math.d.ts +7 -0
- package/dist/presentation.d.cts +4 -0
- package/dist/presentation.d.ts +4 -0
- package/dist/snapshot.d.cts +83 -0
- package/dist/snapshot.d.ts +83 -0
- package/dist/types.d.cts +97 -0
- package/dist/types.d.ts +97 -0
- package/package.json +66 -4
- package/scripts/build.cjs +16 -0
- package/src/audio.ts +35 -0
- package/src/bounds.ts +26 -0
- package/src/engine.ts +662 -0
- package/src/index.tsx +62 -0
- package/src/math.ts +9 -0
- package/src/presentation.ts +42 -0
- package/src/snapshot.ts +541 -0
- package/src/types.ts +99 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.tsx", "../src/audio.ts", "../src/bounds.ts", "../src/math.ts", "../src/presentation.ts", "../src/snapshot.ts", "../src/engine.ts"],
|
|
4
|
+
"sourcesContent": ["import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { createSwarmRebuild, initialState } from './engine';\nimport type { SwarmController, SwarmOptions, SwarmState } from './types';\nexport { createSwarmRebuild } from './engine';\nexport type { SwarmController, SwarmOptions, SwarmPhase, SwarmState } from './types';\n\nexport interface UseSwarmRebuildResult extends SwarmController { state: SwarmState; }\nexport function useSwarmRebuild(options: SwarmOptions = {}): UseSwarmRebuildResult {\n const optionsRef = useRef(options); optionsRef.current = options;\n const settings = useRef<Pick<SwarmOptions, 'speed' | 'sound' | 'tour' | 'ready' | 'cursorCount'>>({});\n const instance = useRef<SwarmController | null>(null);\n const [state, setState] = useState(() => initialState(options));\n const api = useRef<SwarmController | null>(null);\n if (!api.current) {\n const ensure = () => {\n if (!instance.current) instance.current = createSwarmRebuild({\n ...optionsRef.current,\n ...settings.current,\n onStateChange: next => {\n settings.current = { ...settings.current, speed: next.speed, sound: next.sound, tour: next.tour };\n setState(next); optionsRef.current.onStateChange?.(next);\n },\n onComplete: () => optionsRef.current.onComplete?.(),\n onError: error => { if (optionsRef.current.onError) optionsRef.current.onError(error); else console.error('[react-swarm-rebuild]', error); },\n });\n return instance.current;\n };\n api.current = {\n start: () => { instance.current?.destroy(); instance.current = null; ensure().start(); },\n replay: () => api.current!.start(),\n pause: () => instance.current?.pause(), resume: () => instance.current?.resume(),\n goLive: () => instance.current?.goLive(), stop: () => instance.current?.stop(),\n setSpeed: value => ensure().setSpeed(value),\n setSound: value => ensure().setSound(value),\n setTour: value => ensure().setTour(value),\n setReady: value => { settings.current.ready = value; instance.current?.setReady(value); },\n setCursorCount: value => { settings.current.cursorCount = value; instance.current?.setCursorCount(value); },\n getState: () => instance.current?.getState() ?? initialState(optionsRef.current),\n destroy: () => { instance.current?.destroy(); instance.current = null; setState(initialState(optionsRef.current)); },\n };\n }\n useEffect(() => () => { instance.current?.destroy(); instance.current = null; }, []);\n useEffect(() => { if (options.speed !== undefined) instance.current?.setSpeed(options.speed); }, [options.speed]);\n useEffect(() => { if (options.sound !== undefined) instance.current?.setSound(options.sound); }, [options.sound]);\n useEffect(() => { if (options.tour !== undefined) instance.current?.setTour(options.tour); }, [options.tour]);\n useEffect(() => { if (options.ready !== undefined) api.current?.setReady(options.ready); }, [options.ready]);\n useEffect(() => { if (options.cursorCount !== undefined) api.current?.setCursorCount(options.cursorCount); }, [options.cursorCount]);\n return { ...api.current, state };\n}\n\nexport interface SwarmRebuildProps extends SwarmOptions {\n /** Run on mount and whenever this changes from false to true. Default: true. */\n active?: boolean;\n}\n/** Render once beside the UI to rebuild. It adds no wrapper to your React tree. */\nexport const SwarmRebuild = forwardRef<SwarmController, SwarmRebuildProps>(function SwarmRebuild({ active = true, ...options }, ref) {\n const swarm = useSwarmRebuild(options);\n useImperativeHandle(ref, () => swarm, [swarm]);\n const { start, stop } = swarm;\n useEffect(() => { if (active) start(); else stop(); return stop; }, [active, start, stop]);\n return null;\n});\n", "/** Small, original Web Audio instrument. No audio files or network requests. */\nexport class SwarmAudio {\n private context?: AudioContext;\n private enabled = false;\n private last = 0;\n setEnabled(enabled: boolean) {\n this.enabled = enabled;\n if (enabled) {\n try {\n this.context ??= new AudioContext();\n void this.context.resume().catch(() => {});\n } catch { /* Audio is optional in restricted browsers. */ }\n }\n }\n play(kind: 'type' | 'draw' | 'complete', x = .5) {\n const ctx = this.context;\n if (!this.enabled || !ctx || ctx.state !== 'running' || ctx.currentTime - this.last < .035) return;\n this.last = ctx.currentTime;\n const oscillator = ctx.createOscillator(), gain = ctx.createGain(), pan = ctx.createStereoPanner();\n const time = ctx.currentTime;\n oscillator.type = kind === 'type' ? 'triangle' : 'sine';\n const notes = [164.81, 185, 207.65, 246.94, 277.18, 329.63, 369.99];\n const frequency = kind === 'type' ? 650 + Math.random() * 800 : notes[Math.floor(Math.max(0, Math.min(.999, x)) * notes.length)];\n oscillator.frequency.setValueAtTime(frequency, time);\n oscillator.frequency.exponentialRampToValueAtTime(kind === 'type' ? 180 : frequency, time + .04);\n const duration = kind === 'complete' ? .8 : kind === 'type' ? .035 : .18;\n gain.gain.setValueAtTime(.0001, time);\n gain.gain.exponentialRampToValueAtTime(kind === 'type' ? .018 : .035, time + .004);\n gain.gain.exponentialRampToValueAtTime(.0001, time + duration);\n pan.pan.value = Math.max(-1, Math.min(1, x * 2 - 1));\n oscillator.connect(gain).connect(pan).connect(ctx.destination);\n oscillator.start(); oscillator.stop(time + duration + .01);\n }\n destroy() { if (this.context) void this.context.close().catch(() => {}); this.context = undefined; }\n}\n", "/** Intersect a component with its viewport and any scrolling/clipping ancestors. */\nexport function visibleBounds(target: HTMLElement): DOMRect {\n const rect = target.getBoundingClientRect();\n let left = Math.max(0, rect.left), top = Math.max(0, rect.top);\n let right = Math.min(window.innerWidth, rect.right), bottom = Math.min(window.innerHeight, rect.bottom);\n for (let parent = target.parentElement; parent; parent = parent.parentElement) {\n const css = getComputedStyle(parent), box = parent.getBoundingClientRect();\n if (/^(hidden|clip|auto|scroll)$/.test(css.overflowX)) {\n left = Math.max(left, box.left + parent.clientLeft);\n right = Math.min(right, box.left + parent.clientLeft + parent.clientWidth);\n }\n if (/^(hidden|clip|auto|scroll)$/.test(css.overflowY)) {\n top = Math.max(top, box.top + parent.clientTop);\n bottom = Math.min(bottom, box.top + parent.clientTop + parent.clientHeight);\n }\n }\n return new DOMRect(left, top, Math.max(0, right - left), Math.max(0, bottom - top));\n}\n\nexport function backgroundColor(target: HTMLElement): string {\n for (let node: HTMLElement | null = target; node; node = node.parentElement) {\n const color = getComputedStyle(node).backgroundColor;\n if (color && color !== 'transparent' && color !== 'rgba(0, 0, 0, 0)') return color;\n }\n return '#ffffff';\n}\n", "export const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));\nexport const ease = (t: number) => 1 - (1 - clamp(t, 0, 1)) ** 3;\nexport function finite(n: number | undefined, fallback: number, min: number, max: number) {\n return Number.isFinite(n) ? clamp(n!, min, max) : fallback;\n}\nexport function stepSpring(position: number, velocity: number, target: number, dt: number) {\n const nextVelocity = (velocity + (target - position) * 20 * dt) * Math.exp(-7 * dt);\n return { position: position + nextVelocity * dt, velocity: nextVelocity };\n}\n", "export const PALETTE = ['#f56551', '#8b5cf6', '#25a9ed', '#31bd8c', '#e35b9d', '#e9a52a', '#526cf5', '#19b8bc'];\nexport const NAMES = ['C\u01B0\u1EDDng', 'Linh', 'Alex', 'Maya', 'Kai', 'An', 'Sam', 'Minh', 'Jules', 'Quinn', 'Rin', 'Noah'];\nexport function cursorMarkup(color: string) {\n return `<svg class=\"pointer\" width=\"26\" height=\"29\" viewBox=\"0 0 26 29\" fill=\"none\"><path d=\"M3 2.5L7.4 23.5L12.2 16.5L20.8 15.9L3 2.5Z\" fill=\"${color.replace(/[^#\\w(),.%\\s-]/g, '')}\" stroke=\"white\" stroke-width=\"1.75\" stroke-linejoin=\"round\"/></svg><svg class=\"cross\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\"><path d=\"M11 1V21M1 11H21\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\"/><circle cx=\"11\" cy=\"11\" r=\"2.2\" fill=\"#fff\" stroke=\"currentColor\" stroke-width=\"1.4\"/></svg><svg class=\"ibeam\" width=\"12\" height=\"24\" viewBox=\"0 0 12 24\" preserveAspectRatio=\"none\" aria-hidden=\"true\"><path d=\"M3 1H9M6 1V23M3 23H9\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg><span class=\"pen\">\u2712</span>`;\n}\nexport const styles = `\n:host{all:initial;color-scheme:light;font:12px/1.4 -apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;color:#fff}\n.toolbar,.help,.worker{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif}\n*,*::before,*::after{box-sizing:border-box}button{font:inherit;cursor:pointer}\n.cover{position:fixed;inset:0;overflow:hidden;pointer-events:auto;isolation:isolate}\n.stage{position:absolute;inset:0;pointer-events:none;transform-origin:0 0}\n.workers{position:fixed;inset:0;pointer-events:none;overflow:hidden}\n.worker{position:absolute;left:0;top:0;will-change:transform,opacity;color:var(--color);filter:drop-shadow(0 2px 4px #0000002e)}\n.worker .pointer{display:block;transform-origin:4px 3.5px;transform:translate(-3px,-2.5px)}\n.worker .cross,.worker .ibeam,.worker .pen{display:none;position:absolute;left:-11px;top:-11px}\n.worker[data-tool=cross] .pointer,.worker[data-tool=type] .pointer,.worker[data-tool=pen] .pointer{display:none}\n.worker[data-tool=cross] .cross,.worker[data-tool=type] .ibeam,.worker[data-tool=pen] .pen{display:block}\n.worker .ibeam{left:-6px;top:0;width:12px;height:var(--caret-height,24px);color:var(--color);transform-origin:6px 0;transform:rotate(var(--caret-angle,0deg));filter:drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 4px var(--color))}\n.pen{font:22px/1 serif;transform-origin:2px 20px}\n.worker[data-tool=duplicate]::before{content:'\u2325';position:absolute;left:-11px;top:-15px;font:600 10px/1.2 ui-monospace,monospace;background:#fff;color:var(--color);border:1px solid var(--color);border-radius:3px;padding:0 3px;box-shadow:0 1px 3px #0002}\n.name{display:block;position:absolute;left:13px;top:19px;background:var(--color);border:1px solid #fff6;border-radius:4px;padding:1.5px 6px;color:#fff;font-size:10px;font-weight:500;white-space:nowrap;opacity:.95;box-shadow:0 2px 6px #0002}\n.selection{position:absolute;pointer-events:none;border:1.25px solid var(--color);min-width:1px;min-height:1px;box-shadow:0 0 0 1px #ffffff55;border-radius:1px}\n.selection::before,.selection::after{content:'';position:absolute;width:6px;height:6px;background:#fff;border:1.5px solid var(--color);border-radius:1.5px;box-shadow:0 1px 2px #0002}\n.selection::before{left:-3.5px;top:-3.5px}.selection::after{right:-3.5px;bottom:-3.5px}\n.badge{position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);font:600 10px/1.35 ui-monospace,monospace;font-variant-numeric:tabular-nums;padding:2px 6px;background:var(--color);color:white;border-radius:4px;white-space:nowrap;box-shadow:0 2px 6px #00000029}\n.guide{position:fixed;top:var(--swarm-top,20px);height:var(--swarm-height,100vh);border-left:1px solid #f16a56;opacity:.65;pointer-events:none}\n.measure{position:absolute;top:-19px;left:0;right:0;border-bottom:1px solid #f16a56;color:#f16a56;text-align:center;font:10px/1.5 monospace}\n.ruler-x{position:fixed;left:var(--swarm-left,20px);width:var(--swarm-width,100vw);top:var(--swarm-top,0px);height:20px;background:repeating-linear-gradient(90deg,#aaa5 0px,#aaa5 1px,transparent 1px,transparent 10px),#fafafae8;border-bottom:1px solid #ddd8;color:#999;font:9px/18px monospace;pointer-events:none}\n.ruler-y{position:fixed;left:var(--swarm-left,0px);top:var(--swarm-top,20px);height:var(--swarm-height,100vh);width:20px;background:repeating-linear-gradient(0deg,#aaa5 0px,#aaa5 1px,transparent 1px,transparent 10px),#fafafae8;border-right:1px solid #ddd8;pointer-events:none}\n.toolbar{pointer-events:auto;position:fixed;bottom:var(--swarm-bottom,24px);left:var(--swarm-center-x,50%);transform:translateX(-50%);display:flex;align-items:center;gap:7px;padding:8px 10px;background:#25292eef;color:#f8fafc;border:1px solid #ffffff28;border-radius:14px;box-shadow:0 12px 40px #0003,0 0 0 5px #ffffff80;backdrop-filter:blur(16px);white-space:nowrap;max-width:calc(var(--swarm-width,100vw) - 24px);z-index:5;font-size:11px}\n.toolbar button{background:none;color:#dce1e9;border:0;border-radius:6px;padding:6px 8px;min-height:30px;white-space:nowrap}\n.toolbar button:hover,.toolbar button[aria-pressed=true]{background:#ffffff18;color:#fff}\n.toolbar button:focus-visible{outline:2px solid #7dcfff;outline-offset:2px}\n.toolbar .live{background:#e4f5c8;color:#24351c;font-weight:650}\n.status{min-width:115px;color:#c4cbd5;font-variant-numeric:tabular-nums}.track{width:54px;height:3px;background:#ffffff24;border-radius:9px;overflow:hidden}.fill{height:100%;background:#b8ee8a;width:0;transition:width .2s}\n.avatars{display:flex;padding-left:5px}.avatar{width:16px;height:16px;border:2px solid #30343a;border-radius:50%;margin-left:-5px}\n.divider{height:16px;width:1px;background:#ffffff20}.intro{position:fixed;left:var(--swarm-center-x,50%);top:var(--swarm-center-y,46%);transform:translate(-50%,-50%);width:48px;height:48px;display:grid;place-items:center;background:#25292e;color:#e4f5c8;border-radius:14px;font-size:26px;box-shadow:0 6px 24px #00000024,0 0 0 6px #25292e14;transition:opacity .3s,transform .3s}\n.help{position:fixed;bottom:calc(var(--swarm-bottom,24px) + 64px);left:var(--swarm-center-x,50%);transform:translateX(-50%);color:#687078;font-size:11px;pointer-events:none;background:#ffffffc9;padding:5px 12px;border-radius:20px}\n.toolbar.minimal{gap:12px;box-shadow:0 6px 24px #0002;max-width:calc(var(--swarm-width,100vw) - 24px)}\n.toolbar.minimal .status{min-width:0}\n@media(max-width:600px){.toolbar{gap:2px;bottom:var(--swarm-bottom,14px);padding:6px}.toolbar button{padding:6px}.avatars,.track,.divider{display:none}.status{min-width:90px;font-size:10px}.name{font-size:9px}.help{bottom:calc(var(--swarm-bottom,14px) + 60px)}}\n`;\n", "export interface TextUnit {\n end: number;\n startX: number; x: number; y: number; height: number;\n}\nexport interface TextRun {\n node: HTMLElement; value: string; opacity: string; units: TextUnit[];\n /** Custom writer, used for form fields whose text lives in a cloned control. */\n write?: (value: string) => void;\n shown?: string;\n}\n/**\n * A coordinate frame in the stage. Layers inside a transformed element are\n * measured with that element's own transform neutralized, then placed inside\n * a group that re-applies the transform, so rotated/scaled UI is rebuilt in\n * place instead of straightening during the animation.\n */\nexport interface Container {\n id: number;\n node: HTMLElement;\n /** Page coordinate (in the measuring frame) of this container's origin. */\n ox: number; oy: number;\n /** Local \u2192 page affine mapping. Undefined means local coords are page coords. */\n matrix?: { a: number; b: number; c: number; d: number; e: number; f: number };\n /** Rotation of the frame in degrees, for carets and crosshairs. */\n angle: number;\n /** Nearest transformed group (or the stage) for selection outlines. */\n frame: Container;\n}\nexport interface Layer {\n id: number;\n kind: 'box' | 'text' | 'media' | 'line';\n x: number; y: number; width: number; height: number;\n /** Final on-page center, after transforms. Used for scheduling. */\n cx: number; cy: number;\n element: HTMLElement;\n container: Container;\n text?: TextRun[];\n signature: string;\n master?: Layer;\n parent?: Layer;\n done: boolean;\n started: boolean;\n progress: number;\n opacity: string;\n}\nexport interface Snapshot { layers: Layer[]; background: string; }\n\nconst boxProps = ['background', 'background-image', 'background-size', 'background-position', 'background-repeat', 'background-origin', 'background-clip', '-webkit-background-clip', 'border-top', 'border-right', 'border-bottom', 'border-left', 'border-radius', 'box-shadow', 'opacity', 'filter', 'backdrop-filter', '-webkit-backdrop-filter', 'mix-blend-mode', 'outline', 'outline-offset', 'clip-path'];\n// Shorthands first so the longhands that follow win.\nconst textProps = ['font-family', 'font-size', 'font-weight', 'font-style', 'font-stretch', 'font-variant', 'font-variant-ligatures', 'font-variant-caps', 'font-variant-numeric', 'font-variant-east-asian', 'font-variant-position', 'font-feature-settings', 'font-variation-settings', 'font-kerning', 'font-optical-sizing', 'font-synthesis', 'font-size-adjust', 'text-rendering', '-webkit-font-smoothing', 'color', 'letter-spacing', 'word-spacing', 'text-transform', 'text-shadow', '-webkit-text-fill-color', '-webkit-text-stroke-width', '-webkit-text-stroke-color', 'paint-order', 'direction', 'unicode-bidi'];\nconst decorationProps = ['text-decoration-line', 'text-decoration-color', 'text-decoration-style', 'text-decoration-thickness', 'text-underline-offset', 'text-underline-position'];\nconst transparent = (value: string) => value === 'transparent' || value === 'rgba(0, 0, 0, 0)' || !value;\nconst ignoredTags = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'HEAD', 'LINK', 'META', 'OPTION']);\nconst mediaTags = new Set(['IMG', 'SVG', 'VIDEO', 'CANVAS', 'IFRAME', 'INPUT', 'TEXTAREA', 'SELECT', 'PICTURE', 'OBJECT', 'EMBED']);\nconst typedInputs = new Set(['', 'text', 'search', 'email', 'url', 'tel', 'number', 'password', 'button', 'submit', 'reset']);\n\ntype Segment = { segment: string; index: number };\ntype SegmenterCtor = new (locale?: string, options?: { granularity: string }) => { segment(text: string): Iterable<Segment> };\nconst Segmenter = typeof Intl !== 'undefined' ? (Intl as unknown as { Segmenter?: SegmenterCtor }).Segmenter : undefined;\nlet graphemeSegmenter: { segment(text: string): Iterable<Segment> } | undefined;\n/** Segment by grapheme so emoji, combining accents and Vietnamese are never split. */\nexport function graphemes(text: string): Iterable<Segment> {\n if (Segmenter) return (graphemeSegmenter ??= new Segmenter(undefined, { granularity: 'grapheme' })).segment(text);\n return codePoints(text);\n}\nfunction* codePoints(text: string) {\n let index = 0;\n for (const segment of text) {\n yield { segment, index };\n index += segment.length;\n }\n}\n\nfunction copyStyles(from: Element, to: Element) {\n if (!(to instanceof HTMLElement || to instanceof SVGElement)) return;\n const css = getComputedStyle(from);\n for (const property of css) to.style.setProperty(property, css.getPropertyValue(property));\n to.style.animation = 'none';\n to.style.transition = 'none';\n to.removeAttribute('id');\n // Snapshot content is inert. Never mount executable/custom-element DOM.\n for (const attr of Array.from(to.attributes)) {\n if (/^on/i.test(attr.name) || ['autofocus', 'autoplay', 'srcdoc'].includes(attr.name)) to.removeAttribute(attr.name);\n }\n Array.from(from.children).forEach((child, i) => {\n if (to.children[i]) copyStyles(child, to.children[i]);\n });\n}\n\nconst near = (value: number, expected: number) => Math.abs(value - expected) < 1e-4;\n/** True when a transform changes shape (rotate/scale/skew), not just position. */\nfunction linearTransform(css: CSSStyleDeclaration) {\n const rotate = css.getPropertyValue('rotate'), scale = css.getPropertyValue('scale');\n if (rotate && rotate !== 'none' && !/^(0|0deg|0rad|0turn|0grad)$/.test(rotate.trim())) return true;\n if (scale && scale !== 'none' && scale.trim().split(/\\s+/).some(value => parseFloat(value) !== 1)) return true;\n const transform = css.transform;\n if (!transform || transform === 'none') return false;\n try {\n const m = new DOMMatrixReadOnly(transform);\n if (!near(m.a, 1) || !near(m.b, 0) || !near(m.c, 0) || !near(m.d, 1)) return true;\n return !m.is2D && (!near(m.m13, 0) || !near(m.m23, 0) || !near(m.m31, 0) || !near(m.m32, 0) || !near(m.m33, 1) || !near(m.m14, 0) || !near(m.m24, 0) || !near(m.m34, 0));\n } catch { return false; }\n}\nfunction hasBoxSurface(css: CSSStyleDeclaration) {\n const hasBorder = ['top', 'right', 'bottom', 'left'].some(s => parseFloat(css.getPropertyValue(`border-${s}-width`)) > 0 && css.getPropertyValue(`border-${s}-style`) !== 'none');\n const textClip = css.getPropertyValue('-webkit-background-clip') === 'text' || css.getPropertyValue('background-clip') === 'text';\n const paints = !textClip && (!transparent(css.backgroundColor) || css.backgroundImage !== 'none');\n return paints || hasBorder || css.boxShadow !== 'none';\n}\n/**\n * Temporarily measure an element without its own transform. Layout is not\n * affected by transforms, so descendants keep their relative geometry. An\n * identity translate keeps the containing block and stacking context intact.\n * The application sits underneath the opaque cover while this happens.\n */\nfunction neutralize(el: HTMLElement | SVGElement, hasKeyframe: boolean) {\n const style = el.style;\n const properties = hasKeyframe ? ['transform', 'rotate', 'scale', 'translate', 'animation'] : ['transform', 'rotate', 'scale', 'translate'];\n const values: Record<string, string> = { transform: 'translate(0px)', rotate: 'none', scale: 'none', translate: 'none', animation: 'none' };\n const saved = [...properties, 'transition'].map(name => [name, style.getPropertyValue(name), style.getPropertyPriority(name)] as const);\n style.setProperty('transition', 'none', 'important');\n for (const name of properties) style.setProperty(name, values[name], 'important');\n return () => {\n const restore = ([name, value, priority]: readonly [string, string, string]) => {\n if (style.getPropertyPriority(name) !== 'important') return;\n if (value) style.setProperty(name, value, priority); else style.removeProperty(name);\n };\n saved.filter(([name]) => name !== 'transition').forEach(entry => {\n if (style.getPropertyValue(entry[0]).replace(/\\s/g, '') === values[entry[0]].replace(/\\s/g, '')) restore(entry);\n });\n void getComputedStyle(el).transform; // Flush while transitions are off.\n const transition = saved.find(([name]) => name === 'transition')!;\n if (style.getPropertyValue('transition') === 'none') restore(transition);\n };\n}\n\ninterface Flow {\n visual: HTMLDivElement;\n runs: TextRun[];\n left: number; top: number; right: number; bottom: number;\n originX: number; originY: number;\n owner?: Layer; clip?: DOMRect; container: Container; opacity: number;\n}\ninterface FlowHolder {\n current?: Flow;\n owner?: Layer; clip?: DOMRect; container: Container;\n ellipsis?: { limit: number; width: number; done: boolean };\n flush: () => void;\n}\n\n/** A flat visual display list. Transforms are neutralized only while measuring. */\nexport function* snapshotSteps(target: HTMLElement, stage: HTMLElement, maxLayers: number, viewport?: DOMRect): Generator<void, Snapshot> {\n const layers: Layer[] = [];\n const masters = new Map<string, Layer>();\n const scrollX = window.scrollX, scrollY = window.scrollY;\n const rootStyle = getComputedStyle(target);\n let background = rootStyle.backgroundColor;\n if (transparent(background)) background = getComputedStyle(document.documentElement).backgroundColor;\n if (transparent(background)) background = '#ffffff';\n let containerId = 0, transformDepth = 0;\n const root: Container = { id: containerId++, node: stage, ox: 0, oy: 0, angle: 0, frame: undefined as unknown as Container };\n root.frame = root;\n const decorations = new Map<Element, CSSStyleDeclaration | null>();\n const clipSources = new Map<Element, Element | null>();\n let measure: CanvasRenderingContext2D | null | undefined;\n\n const visible = (rect: DOMRect, clip?: DOMRect) => !clip ||\n (rect.bottom > clip.top && rect.top < clip.bottom && rect.right > clip.left && rect.left < clip.right);\n const insetFor = (rect: { left: number; top: number; right: number; bottom: number }, clip: DOMRect) =>\n `inset(${Math.max(0, clip.top - rect.top)}px ${Math.max(0, rect.right - clip.right)}px ${Math.max(0, rect.bottom - clip.bottom)}px ${Math.max(0, clip.left - rect.left)}px)`;\n const toPage = (container: Container, x: number, y: number) => {\n const m = container.matrix;\n if (!m) return { x, y };\n const lx = x - container.ox, ly = y - container.oy;\n return { x: m.a * lx + m.c * ly + m.e, y: m.b * lx + m.d * ly + m.f };\n };\n /** Read a container's real on-page mapping, including every ancestor group. */\n const probe = (container: Container) => {\n const origin = stage.getBoundingClientRect();\n const points = [[0, 0], [100, 0], [0, 100]].map(([x, y]) => {\n const dot = document.createElement('i');\n dot.style.cssText = `position:absolute;left:${x}px;top:${y}px;width:0;height:0;`;\n container.node.append(dot);\n const box = dot.getBoundingClientRect();\n dot.remove();\n return { x: box.left - origin.left, y: box.top - origin.top };\n });\n const [p0, p1, p2] = points;\n container.matrix = { a: (p1.x - p0.x) / 100, b: (p1.y - p0.y) / 100, c: (p2.x - p0.x) / 100, d: (p2.y - p0.y) / 100, e: p0.x, f: p0.y };\n container.angle = Math.atan2(container.matrix.b, container.matrix.a) * 180 / Math.PI;\n };\n const child = (parent: Container, node: HTMLElement, x: number, y: number, group: boolean): Container => {\n parent.node.append(node);\n const container: Container = { id: containerId++, node, ox: x, oy: y, angle: parent.angle, frame: parent.frame };\n if (group) container.frame = container;\n if (group || parent.matrix) probe(container);\n return container;\n };\n\n const add = (kind: Layer['kind'], rect: { left: number; top: number; width: number; height: number }, visual: HTMLElement, container: Container, parent?: Layer, signature = '') => {\n const element = document.createElement('div');\n element.dataset.swarmKind = kind;\n const x = rect.left + scrollX, y = rect.top + scrollY;\n // Computed SVG styles often explicitly set visibility:visible. Opacity\n // hides the entire composited subtree, which descendants cannot override.\n element.style.cssText = `position:absolute;left:${x - container.ox}px;top:${y - container.oy}px;width:${rect.width}px;height:${rect.height}px;visibility:hidden;opacity:0;pointer-events:none;box-sizing:border-box;`;\n element.append(visual);\n container.node.append(element);\n const center = toPage(container, x + rect.width / 2, y + rect.height / 2);\n const layer: Layer = { id: layers.length, kind, x, y, width: rect.width, height: rect.height, cx: center.x, cy: center.y, element, container, parent, signature, done: false, started: false, progress: 0, opacity: visual.style.opacity };\n if (kind === 'box' && signature) {\n const key = `${container.id}|${signature}`;\n layer.master = masters.get(key);\n if (!layer.master) masters.set(key, layer);\n }\n layers.push(layer);\n return layer;\n };\n\n /** Text decorations propagate from ancestors; computed values do not inherit. */\n const decoration = (el: Element): CSSStyleDeclaration | null => {\n if (decorations.has(el)) return decorations.get(el)!;\n let found: CSSStyleDeclaration | null = null;\n for (let node: Element | null = el, depth = 0; node && depth < 12; node = node.parentElement, depth++) {\n const css = getComputedStyle(node);\n if (css.textDecorationLine && css.textDecorationLine !== 'none') { found = css; break; }\n if (node === target || /^inline-|^table/.test(css.display) || css.float !== 'none' || css.position === 'absolute' || css.position === 'fixed') break;\n }\n decorations.set(el, found);\n return found;\n };\n /** Gradient text: the background paints through the glyphs of descendants. */\n const clipSource = (el: Element): Element | null => {\n if (clipSources.has(el)) return clipSources.get(el)!;\n let found: Element | null = null;\n for (let node: Element | null = el, depth = 0; node && depth < 6; node = node.parentElement, depth++) {\n const css = getComputedStyle(node);\n if (css.getPropertyValue('-webkit-background-clip') === 'text' || css.getPropertyValue('background-clip') === 'text') { found = node; break; }\n if (node === target) break;\n }\n clipSources.set(el, found);\n return found;\n };\n const runStyle = (span: HTMLElement, el: Element, css: CSSStyleDeclaration, opacity: number) => {\n for (const property of textProps) span.style.setProperty(property, css.getPropertyValue(property));\n const decorated = decoration(el);\n if (decorated) for (const property of decorationProps) span.style.setProperty(property, decorated.getPropertyValue(property));\n span.style.opacity = String(opacity);\n };\n const paintClip = (span: HTMLElement, el: Element, left: number, top: number) => {\n const source = clipSource(el);\n if (!source) return;\n const css = getComputedStyle(source), box = source.getBoundingClientRect();\n span.style.backgroundImage = css.backgroundImage;\n span.style.backgroundColor = css.backgroundColor;\n span.style.backgroundRepeat = css.backgroundRepeat;\n span.style.backgroundSize = /px/.test(css.backgroundSize) && !/auto|%|cover|contain/.test(css.backgroundSize) ? css.backgroundSize : `${box.width}px ${box.height}px`;\n span.style.backgroundPosition = `${box.left - left}px ${box.top - top}px`;\n span.style.setProperty('-webkit-background-clip', 'text');\n span.style.setProperty('background-clip', 'text');\n span.style.setProperty('-webkit-text-fill-color', css.getPropertyValue('-webkit-text-fill-color') || 'transparent');\n };\n\n const commit = (flow: Flow) => {\n if (!flow.runs.length || layers.length >= maxLayers) return;\n const rect = { left: flow.left, top: flow.top, width: flow.right - flow.left, height: flow.bottom - flow.top };\n flow.visual.style.cssText = `position:absolute;left:${flow.originX - flow.left}px;top:${flow.originY - flow.top}px;`;\n const layer = add('text', rect, flow.visual, flow.container, flow.owner);\n layer.text = flow.runs;\n if (flow.clip) layer.element.style.clipPath = insetFor(flow, flow.clip);\n };\n\n /** Measure one text node into the current paragraph-level flow. */\n function* measureText(node: Text, el: Element, css: CSSStyleDeclaration, opacity: number, holder: FlowHolder, whitespaceOnly = false): Generator<void> {\n const range = document.createRange();\n range.selectNodeContents(node);\n const bounds = range.getBoundingClientRect();\n if (!bounds.width || !bounds.height || !visible(bounds, holder.clip)) return;\n if (holder.ellipsis?.done) return;\n let flow = holder.current;\n if (!flow) {\n flow = holder.current = { visual: document.createElement('div'), runs: [], left: Infinity, top: Infinity, right: -Infinity, bottom: -Infinity, originX: bounds.left, originY: bounds.top, owner: holder.owner, clip: holder.clip, container: holder.container, opacity };\n }\n const rtl = css.direction === 'rtl';\n const justify = css.textAlign === 'justify';\n const preformatted = /^pre|break-spaces/.test(css.whiteSpace);\n const raw = (node.textContent ?? '').slice(0, 12000);\n let current: TextRun | undefined = whitespaceOnly ? flow.runs[flow.runs.length - 1] : undefined;\n let lastTop = -Infinity, lastEdge = NaN, afterSpace = false;\n let measured = 0;\n const ellipsis = holder.ellipsis;\n for (const { segment, index } of graphemes(raw)) {\n if (transformDepth === 0 && measured++ % 24 === 0) yield;\n range.setStart(node, index); range.setEnd(node, index + segment.length);\n const char = range.getBoundingClientRect();\n const space = /^\\s+$/.test(segment);\n const token = !preformatted && space && segment.length === 1 && segment !== ' ' ? ' ' : segment;\n if (!char.width && space) {\n if (whitespaceOnly) continue;\n // Keep a wrapped/collapsed space in the text sequence without\n // moving its caret to the empty Range's (0, 0) rectangle.\n const previous = current?.units[current.units.length - 1];\n if (current && previous) {\n current.value += token;\n current.units.push({ ...previous, end: current.value.length });\n afterSpace = true;\n }\n continue;\n }\n if (!char.width && !char.height) continue;\n if (ellipsis && !rtl && char.right > ellipsis.limit + .5) {\n // Recreate text-overflow:ellipsis, which Range geometry ignores.\n ellipsis.done = true;\n if (current) {\n const previous = current.units[current.units.length - 1];\n current.value += '\u2026';\n current.units.push({ end: current.value.length, startX: previous.x, x: previous.x + ellipsis.width, y: previous.y, height: previous.height });\n }\n break;\n }\n const edge = rtl ? char.right : char.left;\n const lineBreak = !whitespaceOnly && (Math.abs(char.top - lastTop) > 2 || (rtl ? edge > lastEdge + 2 : edge < lastEdge - 2));\n if (!current || lineBreak || (justify && afterSpace && !space)) {\n const span = document.createElement('span');\n runStyle(span, el, css, opacity);\n const x = char.left - flow.originX, y = char.top - flow.originY;\n span.style.cssText += rtl\n ? `;position:absolute;right:${flow.originX - char.right}px;top:${y}px;white-space:pre;line-height:${char.height}px;`\n : `;position:absolute;left:${x}px;top:${y}px;white-space:pre;line-height:${char.height}px;`;\n paintClip(span, el, char.left, char.top);\n flow.visual.append(span);\n current = { node: span, value: '', opacity: String(opacity), units: [] };\n flow.runs.push(current);\n afterSpace = false;\n }\n current.value += token;\n current.units.push({ end: current.value.length, startX: (rtl ? char.right : char.left) + scrollX, x: (rtl ? char.left : char.right) + scrollX, y: char.top + scrollY, height: char.height });\n if (space) afterSpace = true;\n flow.left = Math.min(flow.left, char.left); flow.top = Math.min(flow.top, char.top);\n flow.right = Math.max(flow.right, char.right); flow.bottom = Math.max(flow.bottom, char.bottom);\n lastTop = char.top; lastEdge = edge;\n }\n }\n\n /** Inputs reveal their empty control first, then type value or placeholder. */\n const fieldText = (el: HTMLInputElement | HTMLTextAreaElement, clone: HTMLInputElement | HTMLTextAreaElement, css: CSSStyleDeclaration, rect: DOMRect, layer: Layer) => {\n if (layers.length >= maxLayers) return;\n const isInput = el instanceof HTMLInputElement;\n if (isInput && !typedInputs.has(el.type)) return;\n const shownValue = isInput && el.type === 'password' && el.value ? '\u2022'.repeat(Math.min(12, [...el.value].length)) : el.value;\n const attr: 'value' | 'placeholder' = shownValue ? 'value' : 'placeholder';\n const value = (shownValue || el.placeholder || '').slice(0, 2000);\n if (!value.trim()) return;\n clone.value = ''; clone.placeholder = '';\n measure ??= document.createElement('canvas').getContext('2d');\n const font = `${css.fontStyle} ${css.fontWeight} ${css.fontSize} ${css.fontFamily}`;\n if (measure) measure.font = font;\n const spacing = parseFloat(css.letterSpacing) || 0;\n const px = (name: string) => parseFloat(css.getPropertyValue(name)) || 0;\n const left = rect.left + px('border-left-width') + px('padding-left');\n const right = rect.right - px('border-right-width') - px('padding-right');\n const fontSize = px('font-size') || 14;\n const lineHeight = parseFloat(css.lineHeight) || fontSize * 1.25;\n const width = (text: string) => (measure ? measure.measureText(text).width : text.length * fontSize * .55) + [...text].length * spacing;\n const lines = isInput ? [value] : value.split('\\n');\n const align = css.textAlign;\n const units: TextUnit[] = [];\n let offset = 0;\n lines.forEach((line, row) => {\n const total = width(line), available = right - left;\n const start = align === 'center' || (isInput && /button|submit|reset/.test(el.type) && align !== 'left' && align !== 'start')\n ? left + Math.max(0, available - total) / 2\n : align === 'right' || align === 'end' ? left + Math.max(0, available - total) : left;\n const top = isInput ? rect.top + (rect.height - lineHeight) / 2 : rect.top + px('border-top-width') + px('padding-top') + row * lineHeight;\n let prefix = '';\n for (const { segment } of graphemes(line)) {\n const startX = Math.min(right, start + width(prefix));\n prefix += segment;\n units.push({ end: offset + prefix.length, startX: startX + scrollX, x: Math.min(right, start + width(prefix)) + scrollX, y: Math.max(rect.top, top) + scrollY, height: Math.min(lineHeight, rect.height) });\n }\n offset += line.length + 1;\n if (row < lines.length - 1 && units.length) units[units.length - 1] = { ...units[units.length - 1], end: offset };\n });\n if (!units.length) return;\n const marker = document.createElement('div');\n const textLayer = add('text', rect, marker, layer.container, layer);\n textLayer.element.style.visibility = 'hidden';\n textLayer.text = [{ node: marker, value, opacity: '1', units, write: text => { clone[attr] = text; } }];\n };\n\n function* walk(el: Element, parent: Layer | undefined, opacity: number, clip: DOMRect | undefined, container: Container, inline?: FlowHolder): Generator<void> {\n if (transformDepth === 0) yield;\n if (layers.length >= maxLayers || ignoredTags.has(el.tagName.toUpperCase()) || el.hasAttribute('data-swarm-ignore') || el.hasAttribute('data-swarm-overlay')) return;\n const css = getComputedStyle(el);\n if (css.display === 'none' || css.visibility === 'hidden' || css.getPropertyValue('content-visibility') === 'hidden') return;\n opacity *= Number(css.opacity);\n if (opacity < .01) return;\n const tag = el.tagName.toUpperCase();\n const styled = el instanceof HTMLElement || el instanceof SVGElement;\n const transformed = !inline && styled && linearTransform(css);\n // Read live computed transform values before neutralizing them.\n const transform = transformed ? { transform: css.transform, rotate: css.getPropertyValue('rotate'), scale: css.getPropertyValue('scale'), translate: css.getPropertyValue('translate'), origin: css.transformOrigin } : undefined;\n const restore = transformed ? (transformDepth++, neutralize(el as HTMLElement | SVGElement, Boolean(css.animationName && css.animationName !== 'none'))) : undefined;\n try {\n const rect = el.getBoundingClientRect();\n if (rect.top + scrollY > 40000 || rect.bottom + scrollY < 0) return;\n if (transform && rect.width > 0 && rect.height > 0) {\n // Clip from outside the group lives in the parent frame.\n let host = container;\n if (clip) {\n const wrapper = document.createElement('div');\n wrapper.style.cssText = `position:absolute;left:${clip.left + scrollX - host.ox}px;top:${clip.top + scrollY - host.oy}px;width:${clip.width}px;height:${clip.height}px;overflow:hidden;pointer-events:none;`;\n host = child(host, wrapper, clip.left + scrollX, clip.top + scrollY, false);\n clip = undefined;\n }\n const group = document.createElement('div');\n const x = rect.left + scrollX, y = rect.top + scrollY;\n group.style.cssText = `position:absolute;left:${x - host.ox}px;top:${y - host.oy}px;width:${rect.width}px;height:${rect.height}px;pointer-events:none;transform-origin:${transform.origin};`;\n group.style.transform = transform.transform === 'none' ? '' : transform.transform;\n if (transform.translate && transform.translate !== 'none') group.style.setProperty('translate', transform.translate);\n if (transform.rotate && transform.rotate !== 'none') group.style.setProperty('rotate', transform.rotate);\n if (transform.scale && transform.scale !== 'none') group.style.setProperty('scale', transform.scale);\n group.dataset.swarmGroup = '';\n container = child(host, group, x, y, true);\n }\n let own = parent;\n const withClip = (layer: Layer) => { if (clip) layer.element.style.clipPath = insetFor(rect, clip); };\n if (rect.width > 0 && rect.height > 0 && visible(rect, clip)) {\n if (mediaTags.has(tag)) {\n const visual = document.createElement('div');\n visual.style.cssText = 'width:100%;height:100%;overflow:hidden;';\n let clone: Element;\n if (el instanceof HTMLCanvasElement) {\n const canvas = document.createElement('canvas');\n canvas.width = el.width; canvas.height = el.height;\n try { canvas.getContext('2d')?.drawImage(el, 0, 0); } catch { /* A protected drawing surface stays blank. */ }\n clone = canvas;\n } else if (el instanceof HTMLVideoElement) {\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, el.videoWidth); canvas.height = Math.max(1, el.videoHeight);\n try { canvas.getContext('2d')?.drawImage(el, 0, 0); } catch { /* Poster is used if the video cannot be read. */ }\n if (el.poster && el.readyState < 2) { const image = document.createElement('img'); image.src = el.poster; clone = image; } else clone = canvas;\n } else if (el instanceof HTMLIFrameElement || tag === 'OBJECT' || tag === 'EMBED') {\n clone = document.createElement('div');\n clone.textContent = 'Embedded content';\n } else {\n clone = el.cloneNode(true) as Element;\n }\n copyStyles(el, clone);\n if (clone instanceof HTMLElement || clone instanceof SVGElement) {\n clone.style.cssText += ';position:relative!important;inset:auto!important;margin:0!important;transform:none!important;rotate:none!important;scale:none!important;translate:none!important;width:100%!important;height:100%!important;box-sizing:border-box!important;';\n if (el instanceof HTMLInputElement && clone instanceof HTMLInputElement) {\n clone.value = el.type === 'password' ? '\u2022\u2022\u2022\u2022\u2022\u2022' : el.value;\n clone.name = ''; clone.disabled = true;\n }\n if (el instanceof HTMLTextAreaElement && clone instanceof HTMLTextAreaElement) clone.value = el.value;\n if (el instanceof HTMLSelectElement && clone instanceof HTMLSelectElement) clone.selectedIndex = el.selectedIndex;\n }\n visual.append(clone);\n const layer = add('media', rect, visual, container, parent);\n withClip(layer);\n if ((el instanceof HTMLInputElement && clone instanceof HTMLInputElement) || (el instanceof HTMLTextAreaElement && clone instanceof HTMLTextAreaElement)) fieldText(el, clone, css, rect, layer);\n return;\n }\n if (hasBoxSurface(css)) {\n const visual = document.createElement('div');\n visual.style.cssText = 'width:100%;height:100%;box-sizing:border-box;';\n for (const property of boxProps) visual.style.setProperty(property, css.getPropertyValue(property));\n visual.style.opacity = String(opacity);\n const signature = `${Math.round(rect.width)}:${Math.round(rect.height)}:${css.background}:${css.border}:${css.borderRadius}`;\n own = add(rect.height <= 3 || rect.width <= 3 ? 'line' : 'box', rect, visual, container, parent, signature);\n withClip(own);\n }\n }\n const childClip = (() => {\n if (inline) return clip;\n if (!['hidden', 'clip', 'auto', 'scroll'].some(v => css.overflowX === v || css.overflowY === v)) return clip;\n if (el === document.body || el === document.documentElement) return clip;\n if (!clip) return rect;\n return new DOMRect(Math.max(clip.left, rect.left), Math.max(clip.top, rect.top), Math.max(0, Math.min(clip.right, rect.right) - Math.max(clip.left, rect.left)), Math.max(0, Math.min(clip.bottom, rect.bottom) - Math.max(clip.top, rect.top)));\n })();\n // Text in one inline formatting context, including text inside inline\n // links/spans/bold, becomes one sequential typing task in reading order.\n let holder = inline;\n if (!holder) {\n const ownHolder: FlowHolder = { owner: own, clip: childClip, container, flush: () => { if (ownHolder.current) commit(ownHolder.current); ownHolder.current = undefined; } };\n if (css.textOverflow === 'ellipsis' && css.overflowX !== 'visible' && el instanceof HTMLElement && el.scrollWidth > el.clientWidth + 1) {\n measure ??= document.createElement('canvas').getContext('2d');\n if (measure) measure.font = `${css.fontStyle} ${css.fontWeight} ${css.fontSize} ${css.fontFamily}`;\n const width = measure ? measure.measureText('\u2026').width : parseFloat(css.fontSize) * .8;\n ownHolder.ellipsis = { limit: rect.right - (parseFloat(css.borderRightWidth) || 0) - (parseFloat(css.paddingRight) || 0) - width, width, done: false };\n }\n holder = ownHolder;\n }\n for (const node of Array.from(el.childNodes)) {\n if (layers.length >= maxLayers) break;\n if (node.nodeType === Node.ELEMENT_NODE) {\n const next = node as Element;\n const nextTag = next.tagName.toUpperCase();\n const nextCss = getComputedStyle(next);\n const continues = (nextCss.display === 'inline' || nextCss.display === 'contents') && !mediaTags.has(nextTag) && !hasBoxSurface(nextCss) && !linearTransform(nextCss);\n if (continues) yield* walk(next, own, opacity, childClip, container, holder);\n else { holder.flush(); yield* walk(next, own, opacity, childClip, container); }\n continue;\n }\n if (node.nodeType !== Node.TEXT_NODE || !node.textContent) continue;\n const trimmed = node.textContent.trim();\n if (!trimmed) {\n if (holder.current?.runs.length) yield* measureText(node as Text, el, css, opacity, holder, true);\n continue;\n }\n yield* measureText(node as Text, el, css, opacity, holder, false);\n }\n if (el.shadowRoot) {\n holder.flush();\n for (const shadowChild of Array.from(el.shadowRoot.children)) yield* walk(shadowChild, own, opacity, childClip, container);\n }\n if (!inline) holder.flush();\n } finally {\n if (restore) { transformDepth--; restore(); }\n }\n }\n yield* walk(target, undefined, 1, viewport, root);\n return { layers, background };\n}\n\n/** Map a point in a layer's measuring frame to its final page position. */\nexport function layerPoint(layer: Layer, x: number, y: number) {\n const m = layer.container.matrix;\n if (!m) return { x, y };\n const lx = x - layer.container.ox, ly = y - layer.container.oy;\n return { x: m.a * lx + m.c * ly + m.e, y: m.b * lx + m.d * ly + m.f };\n}\n\n/** Synchronous entry for callers that already own a scheduling budget. */\nexport function snapshot(target: HTMLElement, stage: HTMLElement, maxLayers: number, viewport?: DOMRect): Snapshot {\n const steps = snapshotSteps(target, stage, maxLayers, viewport);\n let next = steps.next();\n while (!next.done) next = steps.next();\n return next.value;\n}\n", "import { SwarmAudio } from './audio';\nimport { backgroundColor, visibleBounds } from './bounds';\nimport { clamp, finite, stepSpring } from './math';\nimport { cursorMarkup, NAMES, PALETTE, styles } from './presentation';\nimport { layerPoint, snapshotSteps, type Layer, type Snapshot } from './snapshot';\nimport type { SwarmController, SwarmOptions, SwarmPhase, SwarmState } from './types';\n\ninterface Worker {\n node: HTMLDivElement; selection: HTMLDivElement; badge: HTMLSpanElement;\n index: number; angle: number; scale: number;\n x: number; y: number; vx: number; vy: number;\n fromX: number; fromY: number; fromVx: number; fromVy: number;\n travel: number; curve: number; elapsed: number; duration: number;\n idleX: number; idleY: number; idleTime: number; delay: number;\n exitX: number; exitY: number; exitCurveX: number; exitCurveY: number; exitAngle: number;\n task?: Layer; pending?: Layer; color: string; retiring: boolean; bornAt: number;\n}\nconst smooth = (t: number) => { const x = clamp(t, 0, 1); return x * x * (3 - 2 * x); };\nexport const initialState = (options: SwarmOptions = {}): SwarmState => ({ phase: 'idle', completed: 0, total: 0, progress: 0, agents: 0, speed: finite(options.speed, 1, .25, 8), sound: options.sound ?? false, tour: options.tour ?? false });\n\n/** Create an imperative instance. Safe to import during SSR; call in the browser. */\nexport function createSwarmRebuild(options: SwarmOptions = {}): SwarmController {\n let state = initialState(options);\n let host: HTMLDivElement | undefined, shadow: ShadowRoot | undefined;\n let cover: HTMLDivElement, stage: HTMLDivElement, workersRoot: HTMLDivElement, intro: HTMLDivElement;\n let status: HTMLSpanElement, progress: HTMLDivElement, help: HTMLDivElement;\n let workers: Worker[] = [], layers: Layer[] = [];\n let frame = 0, last = 0, elapsed = 0, lastEmit = 0;\n let destroyed = false, active = false, previousFocus: HTMLElement | null = null;\n let savedPhase: SwarmPhase = 'building';\n let pointer = { x: 0, y: 0 }, cleanup: (() => void)[] = [];\n let viewportWidth = 0, viewportHeight = 0;\n let target: HTMLElement, scoped = false, ready = options.ready !== false;\n let bounds: DOMRect, capturedBounds: DOMRect | undefined;\n let snapshotTaken = false;\n let captureSteps: Generator<void, Snapshot> | undefined;\n let motionTime = 0, entranceTime = 0, transitionTime = 0, exitTime = 0;\n let desiredCount = Math.floor(finite(options.cursorCount, 16, 2, 48)), nextWorkerId = 0;\n const audio = new SwarmAudio();\n const getState = () => ({ ...state });\n const emit = () => {\n if (host) host.dataset.swarmPhase = state.phase;\n updateToolbar(); options.onStateChange?.(getState());\n };\n const listen = (target: EventTarget, name: string, handler: EventListener, settings?: AddEventListenerOptions) => {\n target.addEventListener(name, handler, settings);\n cleanup.push(() => target.removeEventListener(name, handler, settings));\n };\n const element = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, parent?: Node) => {\n const node = document.createElement(tag); node.className = className; parent?.appendChild(node); return node;\n };\n function setPhase(phase: SwarmPhase) { state.phase = phase; emit(); }\n function updateToolbar() {\n if (!shadow) return;\n if (status) status.textContent = state.phase === 'scanning' ? 'Scanning page\u2026' : state.phase === 'intro' ? ready ? 'Gathering the swarm\u2026' : 'Preparing content\u2026' : state.phase === 'transition' ? 'Preparing the canvas\u2026' : state.phase === 'exiting' ? 'Ready.' : state.phase === 'complete' ? 'Built.' : `${state.completed} / ${state.total} layers`;\n if (progress) progress.style.width = `${state.progress * 100}%`;\n const update = (action: string, text: string, pressed?: boolean) => {\n const button = shadow!.querySelector<HTMLButtonElement>(`[data-action=\"${action}\"]`);\n if (button) { button.textContent = text; if (pressed !== undefined) button.setAttribute('aria-pressed', String(pressed)); }\n };\n update('speed', `${state.speed}\u00D7`);\n update('sound', state.sound ? '\u266A On' : '\u266A Off', state.sound);\n update('tour', 'Tour', state.tour);\n update('pause', state.phase === 'paused' ? 'Resume' : 'Pause', state.phase === 'paused');\n if (help) help.textContent = state.phase === 'complete' ? 'Move your mouse \u00B7 Go live to use the page' : 'Scroll to build more \u00B7 Esc to exit';\n }\n function dispose() {\n const restoreFocus = !!shadow?.activeElement;\n active = false;\n captureSteps?.return(undefined as never); captureSteps = undefined;\n if (frame) window.cancelAnimationFrame(frame);\n frame = 0;\n cleanup.splice(0).forEach(fn => fn());\n host?.remove(); host = undefined; shadow = undefined;\n workers = []; layers = [];\n audio.setEnabled(false);\n if (restoreFocus && previousFocus?.isConnected) previousFocus.focus({ preventScroll: true });\n previousFocus = null;\n }\n function stop() { dispose(); state.agents = 0; setPhase('idle'); }\n function goLive() { dispose(); state.agents = 0; setPhase('live'); }\n function pause() {\n if (!active || state.phase === 'paused' || state.phase === 'scanning') return;\n savedPhase = state.phase; setPhase('paused');\n }\n function resume() { if (state.phase === 'paused') { last = performance.now(); setPhase(savedPhase); } }\n function setSpeed(speed: number) { state.speed = finite(speed, state.speed, .25, 8); emit(); }\n function setSound(enabled: boolean) { state.sound = enabled; audio.setEnabled(enabled && active); emit(); }\n function setTour(enabled: boolean) { state.tour = enabled; emit(); }\n function setReady(value: boolean) {\n ready = value;\n if (!value && captureSteps) {\n captureSteps.return(undefined as never); captureSteps = undefined;\n capturedBounds = undefined;\n // Drop partial geometry if data became pending again before handoff.\n for (const node of Array.from(stage.children)) {\n if (!node.classList.contains('selection')) node.remove();\n }\n }\n }\n function toolbar() {\n if (!options.controls) return;\n const minimal = options.controls === 'minimal';\n const bar = element('div', minimal ? 'toolbar minimal' : 'toolbar', shadow);\n bar.setAttribute('role', 'toolbar'); bar.setAttribute('aria-label', 'Swarm rebuild controls');\n if (minimal) {\n bar.style.pointerEvents = 'none';\n status = element('span', 'status', bar);\n status.setAttribute('role', 'status');\n return;\n }\n const avatars = element('div', 'avatars', bar);\n PALETTE.slice(0, 5).forEach(color => { const avatar = element('span', 'avatar', avatars); avatar.style.background = color; });\n status = element('span', 'status', bar);\n status.setAttribute('role', 'status'); status.setAttribute('aria-live', 'polite');\n const track = element('div', 'track', bar); progress = element('div', 'fill', track);\n element('div', 'divider', bar);\n const actions: [string, string, () => void][] = [\n ['pause', 'Pause / resume animation', () => state.phase === 'paused' ? resume() : pause()],\n ['tour', 'Toggle automatic scrolling', () => setTour(!state.tour)],\n ['speed', 'Change playback speed', () => setSpeed(state.speed >= 3 ? 1 : Math.floor(state.speed) + 1)],\n ['sound', 'Toggle sound', () => setSound(!state.sound)],\n ['replay', 'Replay animation', start],\n ['live', 'Go live', goLive],\n ['close', 'Close animation', stop],\n ];\n actions.forEach(([action, label, handler]) => {\n const button = element('button', action === 'live' ? 'live' : '', bar);\n button.type = 'button'; button.dataset.action = action;\n button.setAttribute('aria-label', label); button.title = label;\n button.textContent = ({ replay: 'Replay', live: 'Go live', close: '\u00D7' } as Record<string, string>)[action] ?? action;\n listen(button, 'click', handler);\n });\n help = element('div', 'help', shadow);\n }\n function resolveTarget(): HTMLElement {\n const target = options.target;\n const resolved = typeof target === 'string' ? document.querySelector(target) : target && 'current' in target ? target.current : target ?? document.body;\n if (!(resolved instanceof HTMLElement) || !resolved.isConnected) throw new Error('Swarm target must be a connected HTMLElement. Check your selector or ref.');\n return resolved;\n }\n function start() {\n if (destroyed) return;\n if (typeof window === 'undefined' || typeof document === 'undefined') throw new Error('Start Swarm Rebuild in a browser effect or event handler.');\n dispose();\n try { target = resolveTarget(); }\n catch (error) { setPhase('idle'); options.onError?.(error as Error); if (!options.onError) throw error; return; }\n state = { ...state, phase: 'scanning', completed: 0, total: 0, progress: 0, agents: 0 };\n if (options.respectReducedMotion !== false && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {\n state.progress = 1; setPhase('live'); options.onComplete?.(); return;\n }\n scoped = options.scope === 'target' || (options.scope !== 'viewport' && target !== document.body && target !== document.documentElement);\n viewportWidth = window.innerWidth; viewportHeight = window.innerHeight;\n bounds = scoped ? visibleBounds(target) : new DOMRect(0, 0, viewportWidth, viewportHeight);\n capturedBounds = undefined; snapshotTaken = false; captureSteps = undefined;\n motionTime = 0; entranceTime = 0; transitionTime = 0; exitTime = 0;\n pointer = { x: bounds.left + bounds.width / 2, y: bounds.top + bounds.height * .46 };\n previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n host = document.createElement('div');\n host.setAttribute('data-swarm-overlay', '');\n host.style.cssText = `all:initial;position:fixed;inset:0;display:block;z-index:${finite(options.zIndex, 2147483000, 0, 2147483647)};isolation:isolate;`;\n host.style.pointerEvents = 'none';\n host.dataset.swarmScope = scoped ? 'target' : 'viewport';\n shadow = host.attachShadow({ mode: 'open' });\n const style = document.createElement('style'); style.textContent = styles; shadow.append(style);\n cover = element('div', 'cover', shadow);\n cover.style.background = options.background ?? backgroundColor(target);\n stage = element('div', 'stage', cover);\n stage.inert = true;\n stage.setAttribute('aria-hidden', 'true');\n workersRoot = element('div', 'workers', shadow);\n workersRoot.setAttribute('aria-hidden', 'true');\n intro = element('div', 'intro', shadow); intro.textContent = '\u2197';\n intro.setAttribute('aria-hidden', 'true');\n toolbar();\n document.documentElement.append(host);\n updateBounds();\n active = true; elapsed = 0; last = performance.now(); lastEmit = 0;\n listen(window, 'pointermove', ((event: PointerEvent) => { pointer = { x: event.clientX, y: event.clientY }; }) as EventListener, { passive: true });\n listen(window, 'keydown', ((event: KeyboardEvent) => {\n if (event.key === 'Escape') { event.preventDefault(); stop(); }\n if ((!scoped || shadow?.activeElement) && event.key.toLowerCase() === 'm' && !event.ctrlKey && !event.metaKey && !event.altKey) setSound(!state.sound);\n if (event.key === 'Tab' && shadow && !scoped) {\n const buttons = Array.from(shadow.querySelectorAll<HTMLButtonElement>('button'));\n if (!buttons.length) return;\n const index = buttons.indexOf(shadow.activeElement as HTMLButtonElement);\n event.preventDefault();\n buttons[(index + (event.shiftKey ? -1 : 1) + buttons.length) % buttons.length].focus();\n }\n }) as EventListener);\n if (options.clickToSkip !== false) {\n cover.style.cursor = 'pointer';\n cover.tabIndex = 0;\n cover.setAttribute('role', 'button');\n cover.setAttribute('aria-label', 'Skip animation');\n listen(cover, 'click', event => {\n // Remove on click, not pointerdown, so the released click cannot\n // activate a link/button in the real application underneath.\n event.preventDefault(); event.stopPropagation(); goLive();\n });\n listen(cover, 'keydown', ((event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault(); event.stopPropagation(); goLive();\n }\n }) as EventListener);\n }\n // A fresh snapshot after layout changes avoids stale geometry. Ignore mobile browser chrome height changes.\n listen(window, 'resize', () => {\n if (Math.abs(window.innerWidth - viewportWidth) > 2) { if (scoped) goLive(); else start(); }\n else viewportHeight = window.innerHeight;\n }, { passive: true });\n audio.setEnabled(state.sound);\n emit();\n if (scoped) {\n // Once geometry is captured, scrolling reveals the real UI instead of\n // animating stale positions or blocking the surrounding application.\n listen(document, 'scroll', () => { if (snapshotTaken || captureSteps) goLive(); }, { capture: true, passive: true });\n }\n createWorkers();\n setPhase('intro');\n frame = window.requestAnimationFrame(tick);\n }\n function updateBounds() {\n if (!host) return;\n bounds = scoped ? visibleBounds(target) : new DOMRect(0, 0, window.innerWidth, window.innerHeight);\n if (scoped) {\n host.style.clipPath = `inset(${bounds.top}px ${Math.max(0, window.innerWidth - bounds.right)}px ${Math.max(0, window.innerHeight - bounds.bottom)}px ${bounds.left}px)`;\n host.style.setProperty('--swarm-left', `${bounds.left}px`);\n host.style.setProperty('--swarm-top', `${bounds.top}px`);\n host.style.setProperty('--swarm-width', `${bounds.width}px`);\n host.style.setProperty('--swarm-height', `${bounds.height}px`);\n host.style.setProperty('--swarm-center-x', `${bounds.left + bounds.width / 2}px`);\n host.style.setProperty('--swarm-center-y', `${bounds.top + bounds.height * .46}px`);\n host.style.setProperty('--swarm-bottom', `${window.innerHeight - bounds.bottom + 16}px`);\n }\n }\n function prepareSnapshot() {\n if (!captureSteps) {\n capturedBounds = bounds;\n captureSteps = snapshotSteps(target, stage, finite(options.maxLayers, 2500, 1, 10000), scoped ? bounds : undefined);\n }\n const deadline = performance.now() + finite(options.snapshotBudget, 4, 1, 12);\n try {\n do {\n const next = captureSteps.next();\n if (!next.done) continue;\n layers = next.value.layers;\n state.total = layers.length;\n snapshotTaken = true; captureSteps = undefined;\n workers.forEach(worker => {\n stage.append(worker.selection);\n worker.fromX = worker.x; worker.fromY = worker.y;\n worker.idleX = worker.x; worker.idleY = worker.y; worker.idleTime = 0;\n worker.delay = options.smoothTransition === false ? 0 : worker.index * .022;\n });\n if (options.showGuides === true) {\n const positions = [...new Set(layers.filter(layer => layer.kind === 'text').map(layer => Math.round(layer.x)))].slice(0, 5);\n positions.forEach(x => { const guide = element('div', 'guide', shadow); guide.style.left = `${x - window.scrollX}px`; });\n }\n intro.style.transition = options.smoothTransition === false ? 'none' : '';\n transitionTime = 0;\n setPhase(options.smoothTransition === false ? 'building' : 'transition');\n return;\n } while (performance.now() < deadline);\n } catch (error) {\n stop(); options.onError?.(error as Error);\n if (!options.onError) console.error('[react-swarm-rebuild]', error);\n }\n }\n function makeWorker(index: number, count: number): Worker {\n const colors = options.colors?.length ? options.colors : PALETTE;\n const names = options.names?.length ? options.names : NAMES;\n const color = colors[index % colors.length];\n const node = element('div', 'worker', workersRoot);\n node.style.setProperty('--color', color);\n node.innerHTML = cursorMarkup(color);\n if (options.showNames === true) { const name = element('span', 'name', node); name.textContent = names[index % names.length]; }\n const selection = element('div', 'selection', stage);\n selection.style.setProperty('--color', color); selection.hidden = true;\n const badge = element('span', 'badge', selection);\n const angle = index / count * Math.PI * 2;\n const ring = .72 + (index % 3) * .18;\n const x = bounds.left + bounds.width / 2 + Math.cos(angle) * Math.min(105, bounds.width * .26) * ring;\n const y = bounds.top + bounds.height * .46 + Math.sin(angle) * Math.min(74, bounds.height * .21) * ring;\n node.style.transform = `translate3d(${x}px,${y}px,0)`;\n node.dataset.motion = 'orbit';\n return { node, selection, badge, index, color, x, y, angle: 0, scale: 1, vx: 0, vy: 0,\n fromX: x, fromY: y, fromVx: 0, fromVy: 0, travel: .36, curve: 0,\n idleX: x, idleY: y, idleTime: 0, delay: 0,\n exitX: x, exitY: y, exitCurveX: 0, exitCurveY: 0, exitAngle: 0,\n elapsed: 0, duration: 1, retiring: false, bornAt: -Infinity };\n }\n function setCursorCount(count: number) {\n if (destroyed) return;\n desiredCount = Math.floor(finite(count, desiredCount, 2, 48));\n if (!active || state.phase === 'exiting' || (state.phase === 'paused' && savedPhase === 'exiting')) return;\n workers.forEach(worker => { worker.retiring = false; });\n while (workers.length > desiredCount) {\n const free = [...workers].reverse().find(worker => !worker.task);\n if (!free) break;\n free.node.remove(); free.selection.remove();\n workers = workers.filter(worker => worker !== free);\n }\n const surplus = Math.max(0, workers.length - desiredCount);\n if (surplus > 0) workers.slice(-surplus).forEach(worker => { worker.retiring = true; worker.pending = undefined; });\n while (workers.length < desiredCount) {\n const worker = makeWorker(nextWorkerId++, desiredCount);\n worker.bornAt = motionTime; worker.node.style.opacity = '0';\n workers.push(worker);\n }\n state.agents = workers.length; emit();\n }\n function retireWorkers() {\n const previous = workers.length;\n workers = workers.filter(worker => {\n if (!worker.retiring || worker.task) return true;\n worker.node.remove(); worker.selection.remove(); return false;\n });\n if (previous !== workers.length) { state.agents = workers.length; emit(); }\n }\n function createWorkers() {\n nextWorkerId = 0;\n workers = Array.from({ length: desiredCount }, () => makeWorker(nextWorkerId++, desiredCount));\n state.agents = workers.length;\n if (options.showRulers === true) {\n const ruler = element('div', 'ruler-x', shadow);\n ruler.textContent = '\u3000 0\u3000\u3000\u3000\u3000 100\u3000\u3000\u3000\u3000 200\u3000\u3000\u3000\u3000 300\u3000\u3000\u3000\u3000 400\u3000\u3000\u3000\u3000 500\u3000\u3000\u3000\u3000 600\u3000\u3000\u3000\u3000 700\u3000\u3000\u3000\u3000 800\u3000\u3000\u3000\u3000 900';\n element('div', 'ruler-y', shadow);\n }\n const opacity = options.fadeIn === false ? '1' : '0';\n workersRoot.style.opacity = opacity; intro.style.opacity = opacity;\n const bar = shadow?.querySelector<HTMLElement>('.toolbar');\n if (bar) bar.style.opacity = opacity;\n }\n function dependenciesReady(layer: Layer) {\n if (options.parallelDrawing === false) return (!layer.parent || layer.parent.done) && (!layer.master || layer.master.done);\n // DOM order already fixes visual stacking. Begin details while their\n // backdrop is drawing, or once a duplicated parent has mostly landed.\n const parentThreshold = layer.parent?.master ? .68 : .15;\n return (!layer.parent || layer.parent.done || layer.parent.progress >= parentThreshold) &&\n (!layer.master || layer.master.done || layer.master.progress >= .35);\n }\n function choosePending(worker: Worker) {\n if (worker.pending && !worker.pending.started && !worker.pending.done) return;\n const claimed = new Set(workers.filter(other => other !== worker).map(other => other.pending));\n const next = layers.find(layer => !layer.started && !layer.done && !claimed.has(layer));\n if (next !== worker.pending) { worker.pending = next; worker.idleTime = 0; }\n }\n function assign(worker: Worker) {\n const top = window.scrollY, bottom = top + viewportHeight;\n let best: Layer | undefined, score = Infinity;\n for (const layer of layers) {\n if (layer.done || layer.started || !dependenciesReady(layer)) continue;\n if (layer.cy - layer.height * .5 > bottom + 80) continue;\n const priority = Math.max(0, layer.cy - layer.height * .5 - top) * .78 + Math.hypot(layer.cx - window.scrollX - worker.x, layer.cy - top - worker.y) * .22 - (worker.pending === layer ? 150 : 0);\n if (priority < score) { best = layer; score = priority; }\n }\n if (!best) { choosePending(worker); return; }\n worker.pending = undefined;\n best.started = true; worker.task = best; worker.elapsed = 0;\n worker.fromX = worker.x; worker.fromY = worker.y;\n worker.fromVx = worker.vx; worker.fromVy = worker.vy;\n const first = best.text?.[0]?.units[0];\n const startPt = layerPoint(best, first && options.typing !== false ? first.startX : best.master ? best.master.x : best.x, first && options.typing !== false ? first.y : best.master ? best.master.y : best.y);\n const dist = Math.hypot(startPt.x - window.scrollX - worker.x, startPt.y - window.scrollY - worker.y);\n worker.travel = clamp(.2 + Math.sqrt(dist) * .013, .2, .52);\n const sign = (worker.index + best.id) % 2 === 0 ? 1 : -1;\n worker.curve = sign * clamp(dist * (.11 + ((worker.index + best.id) % 4) * .03), 8, 64);\n const count = best.text?.reduce((sum, run) => sum + run.units.length, 0) ?? 0;\n const rawTyping = count / finite(options.typingSpeed, 45, 5, 300);\n worker.duration = best.kind === 'text'\n ? clamp(rawTyping < 1 ? .48 + rawTyping * .52 : rawTyping, .48, 8)\n : .45 + Math.min(1, (best.width + best.height) / 950);\n worker.node.dataset.motion = 'working';\n worker.node.dataset.tool = 'arrow';\n worker.node.style.setProperty('--caret-angle', `${best.container.angle.toFixed(2)}deg`);\n if (worker.selection.parentElement !== best.container.node) best.container.node.append(worker.selection);\n worker.selection.style.borderStyle = best.master ? 'dashed' : 'solid';\n if (best.master && options.showGuides === true) {\n const measure = element('span', 'measure', worker.selection);\n measure.textContent = `\u2325 ${Math.round(Math.hypot(best.x - best.master.x, best.y - best.master.y))}`;\n }\n }\n function work(worker: Worker, dt: number) {\n const task = worker.task!;\n worker.elapsed += dt;\n const travel = worker.travel;\n const first = task.text?.[0]?.units[0];\n const rawStartX = first && options.typing !== false ? first.startX : task.master ? task.master.x : task.x;\n const rawStartY = first && options.typing !== false ? first.y : task.master ? task.master.y : task.y;\n const startPt = layerPoint(task, rawStartX, rawStartY);\n const startX = startPt.x - window.scrollX, startY = startPt.y - window.scrollY;\n if (worker.elapsed < travel) {\n const t = clamp(worker.elapsed / travel, 0, 1), blend = smooth(t);\n const dx = startX - worker.fromX, dy = startY - worker.fromY;\n const len = Math.hypot(dx, dy) || 1;\n const nx = -dy / len, ny = dx / len;\n const arc = 4 * blend * (1 - blend) * worker.curve;\n // Hermite travel with a lateral Bezier arc retains departure velocity\n // and curves naturally like a human hand moving across a canvas.\n const tangent = t * (1 - t) * (1 - t) * travel / state.speed;\n const prevX = worker.x, prevY = worker.y;\n worker.x = worker.fromX + dx * blend + nx * arc + worker.fromVx * tangent;\n worker.y = worker.fromY + dy * blend + ny * arc + worker.fromVy * tangent;\n const stepDt = Math.max(.004, dt / state.speed);\n const vx = (worker.x - prevX) / stepDt, vy = (worker.y - prevY) / stepDt;\n const bank = clamp(vx * .026 - vy * .01, -26, 26) * (1 - blend * .65);\n worker.angle += (bank - worker.angle) * (1 - Math.exp(-14 * stepDt));\n return;\n }\n const t = clamp((worker.elapsed - travel) / worker.duration, 0, 1);\n const draw = smooth(t);\n task.progress = t;\n task.element.dataset.swarmProgress = String(t);\n const width = task.width * draw, height = task.height * draw;\n const duplicateX = task.master ? (task.master.x - task.x) * (1 - draw) : 0;\n const duplicateY = task.master ? (task.master.y - task.y) * (1 - draw) - Math.sin(draw * Math.PI) * 10 : 0;\n task.element.style.opacity = '1';\n task.element.style.visibility = 'visible';\n task.element.style.transform = task.master ? `translate(${duplicateX}px,${duplicateY}px)` : '';\n if (task.text) {\n worker.selection.hidden = true;\n const typing = options.typing !== false;\n worker.node.dataset.tool = typing ? 'type' : 'arrow';\n const count = task.text.reduce((sum, run) => sum + run.units.length, 0);\n // Modulate typing with a gentle human cadence while guaranteeing at\n // least the first grapheme is visible as soon as the caret arrives.\n const cadence = clamp(t + Math.sin(t * Math.PI * 3 + worker.index) * (.12 / Math.max(4, count)) * (1 - t), 0, 1);\n const totalTyped = typing ? (t >= 1 ? count : Math.min(count, Math.max(1, Math.floor(cadence * (count + .7))))) : count;\n let remaining = totalTyped;\n let caret = first;\n let typed = false;\n for (const run of task.text) {\n const shown = Math.min(run.units.length, Math.max(0, remaining));\n const value = run.value.slice(0, shown ? run.units[shown - 1].end : 0);\n if (run.write) {\n if (run.shown !== value) { run.shown = value; run.write(value); typed = true; }\n }\n if (run.node.textContent !== value) { run.node.textContent = value; typed = true; }\n if (shown) caret = run.units[shown - 1];\n remaining -= run.units.length;\n run.node.style.opacity = typing ? run.opacity : String(Number(run.opacity || 1) * draw);\n }\n const anyTyped = !typing || totalTyped > 0;\n const rawX = caret ? (anyTyped ? caret.x : caret.startX) : task.x;\n const rawY = caret ? caret.y : task.y;\n const pt = layerPoint(task, rawX, rawY);\n worker.x = pt.x - window.scrollX;\n worker.y = pt.y - window.scrollY;\n worker.node.style.setProperty('--caret-height', `${clamp(caret?.height ?? task.height, 12, 80)}px`);\n worker.node.style.setProperty('--caret-angle', `${task.container.angle.toFixed(2)}deg`);\n if (typing && typed) audio.play('type', worker.x / viewportWidth);\n } else {\n worker.node.dataset.tool = task.master ? 'duplicate' : task.kind === 'line' ? 'pen' : 'cross';\n worker.selection.hidden = false;\n const localLeft = task.x - task.container.ox + duplicateX;\n const localTop = task.y - task.container.oy + duplicateY;\n worker.selection.style.left = `${localLeft}px`; worker.selection.style.top = `${localTop}px`;\n worker.selection.style.width = `${Math.max(1, task.master ? task.width : width)}px`;\n worker.selection.style.height = `${Math.max(1, task.master ? task.height : height)}px`;\n worker.selection.style.background = task.kind === 'box' && !task.master && t < .65 ? '#a0a5ab18' : '';\n worker.badge.textContent = `${Math.round(width)} \u00D7 ${Math.round(height)}`;\n const localX = task.master ? task.x + duplicateX : task.kind === 'line' && task.height > task.width ? task.x + task.width * .5 : task.x + width;\n const localY = task.master ? task.y + duplicateY : task.kind === 'line' && task.width >= task.height ? task.y + task.height * .5 : task.y + height;\n const pt = layerPoint(task, localX, localY);\n worker.x = pt.x - window.scrollX;\n worker.y = pt.y - window.scrollY;\n const visual = task.element.firstElementChild as HTMLElement;\n const clipRight = (1 - draw) * 100, clipBottom = (1 - draw) * 100;\n visual.style.clipPath = task.master || draw > .97\n ? ''\n : task.kind === 'line'\n ? (task.height > task.width ? `inset(0 0 ${clipBottom}% 0)` : `inset(0 ${clipRight}% 0 0)`)\n : `inset(0 ${clipRight}% ${clipBottom}% 0)`;\n visual.style.transform = task.master || task.kind === 'line' ? '' : `scale(${(.975 + .025 * draw).toFixed(4)})`;\n visual.style.opacity = String(Number(task.opacity || 1) * (.28 + .72 * draw));\n }\n if (t > .02 && t < .08) audio.play('draw', worker.x / viewportWidth);\n if (t >= 1) {\n task.done = true;\n const visual = task.element.firstElementChild as HTMLElement;\n visual.style.clipPath = ''; visual.style.opacity = task.opacity; visual.style.transform = '';\n task.element.style.transform = '';\n worker.selection.hidden = true; worker.selection.querySelector('.measure')?.remove();\n worker.node.dataset.tool = 'arrow'; worker.node.dataset.motion = 'idle';\n worker.node.style.setProperty('--caret-angle', '0deg');\n worker.task = undefined; worker.vx = 0; worker.vy = 0;\n worker.idleX = worker.x; worker.idleY = worker.y; worker.idleTime = 0;\n worker.delay = options.smoothTransition === false ? 0 : .06 + (worker.index % 5) * .022;\n state.completed++; state.progress = state.total ? state.completed / state.total : 1;\n }\n }\n function float(worker: Worker, dt: number, orbit: boolean) {\n const phase = worker.index * 2.399963;\n const rate = finite(options.floatSpeed, 1, .25, 3), amplitude = finite(options.floatAmplitude, 1, .25, 3);\n const time = motionTime * rate;\n let tx: number, ty: number;\n if (orbit) {\n const buoyant = options.floatingIntro !== false;\n const ring = buoyant ? .74 + (worker.index % 3) * .17 : 1;\n const direction = buoyant && worker.index % 4 === 3 ? -.72 : .85;\n const theta = worker.index / workers.length * Math.PI * 2 + time * direction;\n const breathe = buoyant ? Math.sin(time * 1.45 + phase) * 26 * amplitude : 0;\n const radius = Math.min((108 + breathe) * ring, bounds.width * .32, bounds.height * .32);\n tx = bounds.left + bounds.width / 2 + Math.cos(theta) * radius + (buoyant ? Math.sin(time * 1.65 + phase) * 20 * amplitude : 0);\n ty = bounds.top + bounds.height * .46 + Math.sin(theta) * radius * .72 + (buoyant ? Math.cos(time * 2.05 + phase) * 24 * amplitude : 0);\n } else if (options.floatingIdle !== false) {\n worker.idleTime += dt;\n const settle = smooth(worker.idleTime / .32);\n if (worker.pending && !worker.pending.started && !worker.pending.done) {\n const nextX = clamp(worker.pending.cx - window.scrollX, bounds.left + 25, Math.max(bounds.left + 25, bounds.right - 35));\n const nextY = clamp(worker.pending.cy - window.scrollY, bounds.top + 35, Math.max(bounds.top + 35, bounds.bottom - 45));\n const reposition = 1 - Math.exp(-3.1 * dt);\n worker.idleX += (nextX - worker.idleX) * reposition;\n worker.idleY += (nextY - worker.idleY) * reposition;\n }\n tx = worker.idleX + (Math.sin(time * 1.55 + phase) * 52 + Math.sin(time * 2.4 + phase * .7) * 16) * amplitude * settle;\n ty = worker.idleY + (Math.cos(time * 1.85 + phase) * 36 + Math.sin(time * 2.75 + phase * 1.3) * 12) * amplitude * settle;\n } else {\n const theta = worker.index / workers.length * Math.PI * 2 + time * .28;\n const radius = 55 + (worker.index % 4) * 23;\n tx = pointer.x + Math.cos(theta) * radius; ty = pointer.y + Math.sin(theta) * radius * .7;\n }\n // The waiting motion has energy and banks into turns while staying damped.\n const respond = (position: number, velocity: number, destination: number) => {\n const nextVelocity = (velocity + (destination - position) * 38 * dt) * Math.exp(-8 * dt);\n return { position: position + nextVelocity * dt, velocity: nextVelocity };\n };\n const sx = respond(worker.x, worker.vx, clamp(tx, bounds.left + 15, Math.max(bounds.left + 15, bounds.right - 25)));\n const sy = respond(worker.y, worker.vy, clamp(ty, bounds.top + 25, Math.max(bounds.top + 25, bounds.bottom - 35)));\n worker.x = sx.position; worker.vx = sx.velocity; worker.y = sy.position; worker.vy = sy.velocity;\n worker.node.dataset.motion = orbit ? 'orbit' : worker.pending && !worker.pending.started ? 'staging' : 'idle';\n const bank = clamp(worker.vx * .045 - worker.vy * .015, -24, 24);\n const tilt = Math.sin(time * 1.5 + phase) * 16 + bank;\n worker.angle += (tilt - worker.angle) * (1 - Math.exp(-8 * dt));\n }\n function beginExit() {\n if (options.burstOnComplete === false || finite(options.exitDuration, 700, 0, 3000) === 0) { goLive(); return; }\n const baseDistance = Math.hypot(bounds.width, bounds.height) + 120;\n // Shuffle sector indices so cursors scatter in random, uncorrelated\n // directions from their current spots rather than a uniform wheel.\n const indices = workers.map((_, i) => i);\n for (let i = indices.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [indices[i], indices[j]] = [indices[j], indices[i]];\n }\n workers.forEach((worker, i) => {\n const sector = indices[i] / Math.max(1, workers.length);\n const jitter = (Math.random() - .5) * (Math.PI * 1.35 / Math.max(1, workers.length) + .85);\n const angle = -Math.PI + sector * Math.PI * 2 + jitter;\n const distance = baseDistance * (.78 + Math.random() * .62);\n const dx = Math.cos(angle) * distance, dy = Math.sin(angle) * distance;\n const curve = (Math.random() - .5) * 220;\n worker.fromX = worker.x; worker.fromY = worker.y;\n worker.exitX = worker.x + dx;\n worker.exitY = worker.y + dy;\n worker.exitCurveX = -Math.sin(angle) * curve;\n worker.exitCurveY = Math.cos(angle) * curve;\n worker.exitAngle = clamp(Math.cos(angle) * 28 - Math.sin(angle) * 14 + (Math.random() - .5) * 18, -42, 42);\n worker.node.dataset.tool = 'arrow'; worker.node.dataset.motion = 'exit';\n worker.selection.hidden = true;\n });\n exitTime = 0; setPhase('exiting');\n }\n function drawWorker(worker: Worker) {\n if (state.phase !== 'exiting' && Number.isFinite(worker.bornAt)) worker.node.style.opacity = String(smooth((motionTime - worker.bornAt) / .25));\n worker.node.style.transform = `translate3d(${worker.x.toFixed(2)}px,${worker.y.toFixed(2)}px,0)`;\n const arrow = worker.node.querySelector<SVGElement>('.pointer');\n if (arrow) arrow.style.transform = `translate(-3px,-2.5px) rotate(${worker.angle.toFixed(2)}deg) scale(${worker.scale.toFixed(3)})`;\n }\n function tick(now: number) {\n if (!active) return;\n if (!target.isConnected) { stop(); return; }\n updateBounds();\n if (scoped && capturedBounds && ['left', 'top', 'width', 'height'].some(key =>\n Math.abs(bounds[key as keyof DOMRect] as number - (capturedBounds![key as keyof DOMRect] as number)) > 2)) {\n goLive(); return;\n }\n const realDt = Math.min(.05, Math.max(0, (now - last) / 1000)); last = now;\n stage.style.transform = `translate(${-window.scrollX}px,${-window.scrollY}px)`;\n if (state.phase !== 'paused') {\n const dt = realDt * state.speed;\n elapsed += dt; motionTime += realDt; entranceTime += realDt;\n const entrance = options.fadeIn === false ? 1 : smooth(entranceTime * 1000 / Math.max(1, finite(options.fadeInDuration, 360, 0, 3000)));\n workersRoot.style.opacity = String(entrance);\n const bar = shadow?.querySelector<HTMLElement>('.toolbar');\n if (bar) bar.style.opacity = String(entrance);\n if (state.phase === 'intro') {\n intro.style.opacity = String(entrance);\n const pulse = 1 + Math.sin(motionTime * 3.2) * .045;\n intro.style.transform = `translate(-50%,-50%) scale(${pulse.toFixed(3)})`;\n workers.forEach(worker => float(worker, realDt, true));\n if (ready && elapsed * 1000 >= finite(options.introDuration, 1600, 0, 15000)) prepareSnapshot();\n if (!active) return;\n } else if (state.phase === 'transition') {\n transitionTime += realDt;\n const t = smooth(transitionTime * 1000 / Math.max(1, finite(options.transitionDuration, 480, 0, 3000)));\n intro.style.opacity = String(1 - t);\n intro.style.transform = `translate(-50%,-50%) scale(${(1 - t * .18).toFixed(3)})`;\n workers.forEach(worker => {\n // Brake the existing orbit with the same spring, keeping velocity\n // continuous while workers settle into independent waiting spots.\n const phase = worker.index * 2.399963;\n const sx = stepSpring(worker.x, worker.vx, worker.fromX + Math.sin(phase) * 22 * t, realDt);\n const sy = stepSpring(worker.y, worker.vy, worker.fromY + Math.cos(phase) * 16 * t, realDt);\n worker.x = sx.position; worker.vx = sx.velocity;\n worker.y = sy.position; worker.vy = sy.velocity;\n worker.node.dataset.motion = 'handoff';\n worker.idleX = worker.x; worker.idleY = worker.y;\n });\n if (t >= 1) { intro.style.opacity = '0'; setPhase('building'); }\n } else if (state.phase === 'building') {\n intro.style.opacity = '0';\n workers.forEach(worker => {\n worker.delay = Math.max(0, worker.delay - realDt);\n if (worker.retiring && !worker.task) return;\n if (!worker.retiring && !worker.task && worker.delay <= 0) assign(worker);\n if (worker.task) {\n if (worker.elapsed >= worker.travel) worker.angle *= Math.exp(-10 * realDt);\n work(worker, dt);\n } else float(worker, realDt, false);\n });\n retireWorkers();\n if (state.tour && !scoped) {\n const next = layers.filter(layer => !layer.done).reduce((min, layer) => Math.min(min, layer.cy - layer.height * .5), Infinity);\n if (Number.isFinite(next)) {\n const goal = Math.max(0, next - viewportHeight * .35);\n if (goal > window.scrollY + 1) window.scrollBy(0, Math.min(goal - window.scrollY, 180 * dt));\n }\n }\n if (state.completed === state.total) {\n state.progress = 1; shadow?.querySelectorAll('.guide,.ruler-x,.ruler-y').forEach(node => node.remove());\n audio.play('complete'); setPhase('complete'); options.onComplete?.();\n if (!active) return;\n if (options.finishBehavior !== 'flock') beginExit();\n if (!active) return;\n }\n } else if (state.phase === 'exiting') {\n exitTime += realDt;\n const t = clamp(exitTime * 1000 / Math.max(1, finite(options.exitDuration, 700, 0, 3000)), 0, 1);\n const progress = t * (.36 + .64 * t);\n const arc = 4 * t * (1 - t);\n workers.forEach(worker => {\n worker.x = worker.fromX + (worker.exitX - worker.fromX) * progress + worker.exitCurveX * arc;\n worker.y = worker.fromY + (worker.exitY - worker.fromY) * progress + worker.exitCurveY * arc;\n worker.angle += (worker.exitAngle - worker.angle) * (1 - Math.exp(-12 * realDt));\n worker.scale = 1 - smooth(t) * .12;\n worker.node.style.opacity = String(1 - smooth((t - .42) / .58));\n });\n cover.style.opacity = String(1 - smooth((t - .42) / .58));\n if (bar) bar.style.opacity = String(1 - smooth(t));\n if (t >= 1) { goLive(); return; }\n } else if (state.phase === 'complete') {\n workers.forEach(worker => float(worker, realDt, false));\n }\n workers.forEach(drawWorker);\n if (now - lastEmit > 150) { lastEmit = now; emit(); }\n }\n if (active) frame = window.requestAnimationFrame(tick);\n }\n return { start, replay: start, pause, resume, goLive, stop, setSpeed, setSound, setTour, setReady, setCursorCount, getState, destroy() { dispose(); audio.destroy(); destroyed = true; state = { ...state, phase: 'idle', agents: 0 }; } };\n}\n"],
|
|
5
|
+
"mappings": ";ubAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,GAAA,uBAAAC,GAAA,oBAAAC,KAAA,eAAAC,GAAAL,IAAA,IAAAM,EAA6E,iBCCtE,IAAMC,GAAN,KAAiB,CAAjB,cAEL,KAAQ,QAAU,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ind", "x", "ctx", "oscillator", "gain", "pan", "time", "notes", "frequency", "duration", "visibleBounds", "target", "rect", "left", "top", "right", "bottom", "parent", "css", "box", "backgroundColor", "node", "color", "clamp", "n", "min", "max", "finite", "n", "fallback", "min", "max", "clamp", "stepSpring", "position", "velocity", "target", "dt", "nextVelocity", "PALETTE", "NAMES", "cursorMarkup", "color", "styles", "boxProps", "textProps", "decorationProps", "transparent", "value", "ignoredTags", "mediaTags", "typedInputs", "Segmenter", "graphemeSegmenter", "graphemes", "text", "codePoints", "index", "segment", "copyStyles", "from", "to", "css", "property", "attr", "child", "i", "near", "expected", "linearTransform", "rotate", "scale", "transform", "m", "hasBoxSurface", "hasBorder", "s", "neutralize", "el", "hasKeyframe", "style", "properties", "values", "saved", "name", "restore", "priority", "entry", "transition", "snapshotSteps", "target", "stage", "maxLayers", "viewport", "layers", "masters", "scrollX", "scrollY", "background", "containerId", "transformDepth", "root", "decorations", "clipSources", "measure", "visible", "rect", "clip", "insetFor", "toPage", "container", "x", "y", "lx", "ly", "probe", "origin", "points", "dot", "box", "p0", "p1", "p2", "parent", "node", "group", "add", "kind", "visual", "signature", "element", "center", "layer", "key", "decoration", "found", "depth", "clipSource", "runStyle", "span", "opacity", "decorated", "paintClip", "left", "top", "source", "commit", "flow", "measureText", "holder", "whitespaceOnly", "range", "bounds", "rtl", "justify", "preformatted", "raw", "current", "lastTop", "lastEdge", "afterSpace", "measured", "ellipsis", "char", "space", "token", "previous", "edge", "lineBreak", "fieldText", "clone", "isInput", "shownValue", "font", "spacing", "px", "right", "fontSize", "lineHeight", "width", "lines", "align", "units", "offset", "line", "row", "total", "available", "start", "prefix", "startX", "marker", "textLayer", "walk", "inline", "tag", "styled", "transformed", "host", "wrapper", "own", "withClip", "canvas", "image", "childClip", "v", "ownHolder", "next", "nextTag", "nextCss", "shadowChild", "layerPoint", "smooth", "t", "x", "clamp", "initialState", "options", "finite", "createSwarmRebuild", "state", "host", "shadow", "cover", "stage", "workersRoot", "intro", "status", "progress", "help", "workers", "layers", "frame", "last", "elapsed", "lastEmit", "destroyed", "active", "previousFocus", "savedPhase", "pointer", "cleanup", "viewportWidth", "viewportHeight", "target", "scoped", "ready", "bounds", "capturedBounds", "snapshotTaken", "captureSteps", "motionTime", "entranceTime", "transitionTime", "exitTime", "desiredCount", "nextWorkerId", "audio", "SwarmAudio", "getState", "emit", "updateToolbar", "listen", "name", "handler", "settings", "element", "tag", "className", "parent", "node", "setPhase", "phase", "update", "action", "text", "pressed", "button", "dispose", "restoreFocus", "fn", "stop", "goLive", "pause", "resume", "setSpeed", "speed", "setSound", "enabled", "setTour", "setReady", "value", "toolbar", "minimal", "bar", "avatars", "PALETTE", "color", "avatar", "track", "start", "label", "resolveTarget", "resolved", "error", "visibleBounds", "style", "styles", "backgroundColor", "updateBounds", "event", "buttons", "index", "createWorkers", "tick", "prepareSnapshot", "snapshotSteps", "deadline", "next", "worker", "layer", "guide", "makeWorker", "count", "colors", "names", "NAMES", "cursorMarkup", "selection", "badge", "angle", "ring", "y", "setCursorCount", "free", "surplus", "retireWorkers", "previous", "ruler", "opacity", "dependenciesReady", "parentThreshold", "choosePending", "claimed", "other", "assign", "top", "bottom", "best", "score", "priority", "first", "startPt", "layerPoint", "dist", "sign", "rawTyping", "sum", "run", "measure", "work", "dt", "task", "travel", "rawStartX", "rawStartY", "startX", "startY", "blend", "dx", "dy", "len", "nx", "ny", "arc", "tangent", "prevX", "prevY", "stepDt", "vx", "vy", "bank", "draw", "width", "height", "duplicateX", "duplicateY", "typing", "cadence", "totalTyped", "remaining", "caret", "typed", "shown", "anyTyped", "rawX", "rawY", "pt", "localLeft", "localTop", "localX", "localY", "visual", "clipRight", "clipBottom", "float", "orbit", "rate", "amplitude", "time", "tx", "ty", "buoyant", "direction", "theta", "breathe", "radius", "settle", "nextX", "nextY", "reposition", "respond", "position", "velocity", "destination", "nextVelocity", "sx", "sy", "tilt", "beginExit", "baseDistance", "indices", "_", "i", "j", "sector", "jitter", "distance", "curve", "drawWorker", "arrow", "now", "key", "realDt", "entrance", "pulse", "stepSpring", "min", "goal", "useSwarmRebuild", "options", "optionsRef", "settings", "instance", "state", "setState", "initialState", "api", "ensure", "createSwarmRebuild", "next", "error", "value", "SwarmRebuild", "active", "ref", "swarm", "start", "stop"]
|
|
7
|
+
}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SwarmController, SwarmOptions, SwarmState } from './types.cjs';
|
|
3
|
+
export { createSwarmRebuild } from './engine.cjs';
|
|
4
|
+
export type { SwarmController, SwarmOptions, SwarmPhase, SwarmState } from './types.cjs';
|
|
5
|
+
export interface UseSwarmRebuildResult extends SwarmController {
|
|
6
|
+
state: SwarmState;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSwarmRebuild(options?: SwarmOptions): UseSwarmRebuildResult;
|
|
9
|
+
export interface SwarmRebuildProps extends SwarmOptions {
|
|
10
|
+
/** Run on mount and whenever this changes from false to true. Default: true. */
|
|
11
|
+
active?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Render once beside the UI to rebuild. It adds no wrapper to your React tree. */
|
|
14
|
+
export declare const SwarmRebuild: import("react").ForwardRefExoticComponent<SwarmRebuildProps & import("react").RefAttributes<SwarmController>>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SwarmController, SwarmOptions, SwarmState } from './types.js';
|
|
3
|
+
export { createSwarmRebuild } from './engine.js';
|
|
4
|
+
export type { SwarmController, SwarmOptions, SwarmPhase, SwarmState } from './types.js';
|
|
5
|
+
export interface UseSwarmRebuildResult extends SwarmController {
|
|
6
|
+
state: SwarmState;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSwarmRebuild(options?: SwarmOptions): UseSwarmRebuildResult;
|
|
9
|
+
export interface SwarmRebuildProps extends SwarmOptions {
|
|
10
|
+
/** Run on mount and whenever this changes from false to true. Default: true. */
|
|
11
|
+
active?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Render once beside the UI to rebuild. It adds no wrapper to your React tree. */
|
|
14
|
+
export declare const SwarmRebuild: import("react").ForwardRefExoticComponent<SwarmRebuildProps & import("react").RefAttributes<SwarmController>>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{forwardRef as Le,useEffect as Pt,useImperativeHandle as Pe,useRef as Wt,useState as $e}from"react";var zt=class{constructor(){this.enabled=!1;this.last=0}setEnabled(n){if(this.enabled=n,n)try{this.context??(this.context=new AudioContext),this.context.resume().catch(()=>{})}catch{}}play(n,l=.5){let a=this.context;if(!this.enabled||!a||a.state!=="running"||a.currentTime-this.last<.035)return;this.last=a.currentTime;let u=a.createOscillator(),R=a.createGain(),b=a.createStereoPanner(),P=a.currentTime;u.type=n==="type"?"triangle":"sine";let E=[164.81,185,207.65,246.94,277.18,329.63,369.99],Z=n==="type"?650+Math.random()*800:E[Math.floor(Math.max(0,Math.min(.999,l))*E.length)];u.frequency.setValueAtTime(Z,P),u.frequency.exponentialRampToValueAtTime(n==="type"?180:Z,P+.04);let at=n==="complete"?.8:n==="type"?.035:.18;R.gain.setValueAtTime(1e-4,P),R.gain.exponentialRampToValueAtTime(n==="type"?.018:.035,P+.004),R.gain.exponentialRampToValueAtTime(1e-4,P+at),b.pan.value=Math.max(-1,Math.min(1,l*2-1)),u.connect(R).connect(b).connect(a.destination),u.start(),u.stop(P+at+.01)}destroy(){this.context&&this.context.close().catch(()=>{}),this.context=void 0}};function jt(o){let n=o.getBoundingClientRect(),l=Math.max(0,n.left),a=Math.max(0,n.top),u=Math.min(window.innerWidth,n.right),R=Math.min(window.innerHeight,n.bottom);for(let b=o.parentElement;b;b=b.parentElement){let P=getComputedStyle(b),E=b.getBoundingClientRect();/^(hidden|clip|auto|scroll)$/.test(P.overflowX)&&(l=Math.max(l,E.left+b.clientLeft),u=Math.min(u,E.left+b.clientLeft+b.clientWidth)),/^(hidden|clip|auto|scroll)$/.test(P.overflowY)&&(a=Math.max(a,E.top+b.clientTop),R=Math.min(R,E.top+b.clientTop+b.clientHeight))}return new DOMRect(l,a,Math.max(0,u-l),Math.max(0,R-a))}function te(o){for(let n=o;n;n=n.parentElement){let l=getComputedStyle(n).backgroundColor;if(l&&l!=="transparent"&&l!=="rgba(0, 0, 0, 0)")return l}return"#ffffff"}var K=(o,n,l)=>Math.max(n,Math.min(l,o));function Q(o,n,l,a){return Number.isFinite(o)?K(o,l,a):n}function Jt(o,n,l,a){let u=(n+(l-o)*20*a)*Math.exp(-7*a);return{position:o+u*a,velocity:u}}var _t=["#f56551","#8b5cf6","#25a9ed","#31bd8c","#e35b9d","#e9a52a","#526cf5","#19b8bc"],ee=["C\u01B0\u1EDDng","Linh","Alex","Maya","Kai","An","Sam","Minh","Jules","Quinn","Rin","Noah"];function ne(o){return`<svg class="pointer" width="26" height="29" viewBox="0 0 26 29" fill="none"><path d="M3 2.5L7.4 23.5L12.2 16.5L20.8 15.9L3 2.5Z" fill="${o.replace(/[^#\w(),.%\s-]/g,"")}" stroke="white" stroke-width="1.75" stroke-linejoin="round"/></svg><svg class="cross" width="22" height="22" viewBox="0 0 22 22"><path d="M11 1V21M1 11H21" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="11" cy="11" r="2.2" fill="#fff" stroke="currentColor" stroke-width="1.4"/></svg><svg class="ibeam" width="12" height="24" viewBox="0 0 12 24" preserveAspectRatio="none" aria-hidden="true"><path d="M3 1H9M6 1V23M3 23H9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg><span class="pen">\u2712</span>`}var oe=`
|
|
3
|
+
:host{all:initial;color-scheme:light;font:12px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#fff}
|
|
4
|
+
.toolbar,.help,.worker{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
|
|
5
|
+
*,*::before,*::after{box-sizing:border-box}button{font:inherit;cursor:pointer}
|
|
6
|
+
.cover{position:fixed;inset:0;overflow:hidden;pointer-events:auto;isolation:isolate}
|
|
7
|
+
.stage{position:absolute;inset:0;pointer-events:none;transform-origin:0 0}
|
|
8
|
+
.workers{position:fixed;inset:0;pointer-events:none;overflow:hidden}
|
|
9
|
+
.worker{position:absolute;left:0;top:0;will-change:transform,opacity;color:var(--color);filter:drop-shadow(0 2px 4px #0000002e)}
|
|
10
|
+
.worker .pointer{display:block;transform-origin:4px 3.5px;transform:translate(-3px,-2.5px)}
|
|
11
|
+
.worker .cross,.worker .ibeam,.worker .pen{display:none;position:absolute;left:-11px;top:-11px}
|
|
12
|
+
.worker[data-tool=cross] .pointer,.worker[data-tool=type] .pointer,.worker[data-tool=pen] .pointer{display:none}
|
|
13
|
+
.worker[data-tool=cross] .cross,.worker[data-tool=type] .ibeam,.worker[data-tool=pen] .pen{display:block}
|
|
14
|
+
.worker .ibeam{left:-6px;top:0;width:12px;height:var(--caret-height,24px);color:var(--color);transform-origin:6px 0;transform:rotate(var(--caret-angle,0deg));filter:drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 4px var(--color))}
|
|
15
|
+
.pen{font:22px/1 serif;transform-origin:2px 20px}
|
|
16
|
+
.worker[data-tool=duplicate]::before{content:'\u2325';position:absolute;left:-11px;top:-15px;font:600 10px/1.2 ui-monospace,monospace;background:#fff;color:var(--color);border:1px solid var(--color);border-radius:3px;padding:0 3px;box-shadow:0 1px 3px #0002}
|
|
17
|
+
.name{display:block;position:absolute;left:13px;top:19px;background:var(--color);border:1px solid #fff6;border-radius:4px;padding:1.5px 6px;color:#fff;font-size:10px;font-weight:500;white-space:nowrap;opacity:.95;box-shadow:0 2px 6px #0002}
|
|
18
|
+
.selection{position:absolute;pointer-events:none;border:1.25px solid var(--color);min-width:1px;min-height:1px;box-shadow:0 0 0 1px #ffffff55;border-radius:1px}
|
|
19
|
+
.selection::before,.selection::after{content:'';position:absolute;width:6px;height:6px;background:#fff;border:1.5px solid var(--color);border-radius:1.5px;box-shadow:0 1px 2px #0002}
|
|
20
|
+
.selection::before{left:-3.5px;top:-3.5px}.selection::after{right:-3.5px;bottom:-3.5px}
|
|
21
|
+
.badge{position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);font:600 10px/1.35 ui-monospace,monospace;font-variant-numeric:tabular-nums;padding:2px 6px;background:var(--color);color:white;border-radius:4px;white-space:nowrap;box-shadow:0 2px 6px #00000029}
|
|
22
|
+
.guide{position:fixed;top:var(--swarm-top,20px);height:var(--swarm-height,100vh);border-left:1px solid #f16a56;opacity:.65;pointer-events:none}
|
|
23
|
+
.measure{position:absolute;top:-19px;left:0;right:0;border-bottom:1px solid #f16a56;color:#f16a56;text-align:center;font:10px/1.5 monospace}
|
|
24
|
+
.ruler-x{position:fixed;left:var(--swarm-left,20px);width:var(--swarm-width,100vw);top:var(--swarm-top,0px);height:20px;background:repeating-linear-gradient(90deg,#aaa5 0px,#aaa5 1px,transparent 1px,transparent 10px),#fafafae8;border-bottom:1px solid #ddd8;color:#999;font:9px/18px monospace;pointer-events:none}
|
|
25
|
+
.ruler-y{position:fixed;left:var(--swarm-left,0px);top:var(--swarm-top,20px);height:var(--swarm-height,100vh);width:20px;background:repeating-linear-gradient(0deg,#aaa5 0px,#aaa5 1px,transparent 1px,transparent 10px),#fafafae8;border-right:1px solid #ddd8;pointer-events:none}
|
|
26
|
+
.toolbar{pointer-events:auto;position:fixed;bottom:var(--swarm-bottom,24px);left:var(--swarm-center-x,50%);transform:translateX(-50%);display:flex;align-items:center;gap:7px;padding:8px 10px;background:#25292eef;color:#f8fafc;border:1px solid #ffffff28;border-radius:14px;box-shadow:0 12px 40px #0003,0 0 0 5px #ffffff80;backdrop-filter:blur(16px);white-space:nowrap;max-width:calc(var(--swarm-width,100vw) - 24px);z-index:5;font-size:11px}
|
|
27
|
+
.toolbar button{background:none;color:#dce1e9;border:0;border-radius:6px;padding:6px 8px;min-height:30px;white-space:nowrap}
|
|
28
|
+
.toolbar button:hover,.toolbar button[aria-pressed=true]{background:#ffffff18;color:#fff}
|
|
29
|
+
.toolbar button:focus-visible{outline:2px solid #7dcfff;outline-offset:2px}
|
|
30
|
+
.toolbar .live{background:#e4f5c8;color:#24351c;font-weight:650}
|
|
31
|
+
.status{min-width:115px;color:#c4cbd5;font-variant-numeric:tabular-nums}.track{width:54px;height:3px;background:#ffffff24;border-radius:9px;overflow:hidden}.fill{height:100%;background:#b8ee8a;width:0;transition:width .2s}
|
|
32
|
+
.avatars{display:flex;padding-left:5px}.avatar{width:16px;height:16px;border:2px solid #30343a;border-radius:50%;margin-left:-5px}
|
|
33
|
+
.divider{height:16px;width:1px;background:#ffffff20}.intro{position:fixed;left:var(--swarm-center-x,50%);top:var(--swarm-center-y,46%);transform:translate(-50%,-50%);width:48px;height:48px;display:grid;place-items:center;background:#25292e;color:#e4f5c8;border-radius:14px;font-size:26px;box-shadow:0 6px 24px #00000024,0 0 0 6px #25292e14;transition:opacity .3s,transform .3s}
|
|
34
|
+
.help{position:fixed;bottom:calc(var(--swarm-bottom,24px) + 64px);left:var(--swarm-center-x,50%);transform:translateX(-50%);color:#687078;font-size:11px;pointer-events:none;background:#ffffffc9;padding:5px 12px;border-radius:20px}
|
|
35
|
+
.toolbar.minimal{gap:12px;box-shadow:0 6px 24px #0002;max-width:calc(var(--swarm-width,100vw) - 24px)}
|
|
36
|
+
.toolbar.minimal .status{min-width:0}
|
|
37
|
+
@media(max-width:600px){.toolbar{gap:2px;bottom:var(--swarm-bottom,14px);padding:6px}.toolbar button{padding:6px}.avatars,.track,.divider{display:none}.status{min-width:90px;font-size:10px}.name{font-size:9px}.help{bottom:calc(var(--swarm-bottom,14px) + 60px)}}
|
|
38
|
+
`;var ve=["background","background-image","background-size","background-position","background-repeat","background-origin","background-clip","-webkit-background-clip","border-top","border-right","border-bottom","border-left","border-radius","box-shadow","opacity","filter","backdrop-filter","-webkit-backdrop-filter","mix-blend-mode","outline","outline-offset","clip-path"],Me=["font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-variant-ligatures","font-variant-caps","font-variant-numeric","font-variant-east-asian","font-variant-position","font-feature-settings","font-variation-settings","font-kerning","font-optical-sizing","font-synthesis","font-size-adjust","text-rendering","-webkit-font-smoothing","color","letter-spacing","word-spacing","text-transform","text-shadow","-webkit-text-fill-color","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order","direction","unicode-bidi"],Ee=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-underline-position"],Qt=o=>o==="transparent"||o==="rgba(0, 0, 0, 0)"||!o,Se=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","LINK","META","OPTION"]),re=new Set(["IMG","SVG","VIDEO","CANVAS","IFRAME","INPUT","TEXTAREA","SELECT","PICTURE","OBJECT","EMBED"]),we=new Set(["","text","search","email","url","tel","number","password","button","submit","reset"]),ie=typeof Intl<"u"?Intl.Segmenter:void 0,ae;function se(o){return ie?(ae??(ae=new ie(void 0,{granularity:"grapheme"}))).segment(o):Te(o)}function*Te(o){let n=0;for(let l of o)yield{segment:l,index:n},n+=l.length}function de(o,n){if(!(n instanceof HTMLElement||n instanceof SVGElement))return;let l=getComputedStyle(o);for(let a of l)n.style.setProperty(a,l.getPropertyValue(a));n.style.animation="none",n.style.transition="none",n.removeAttribute("id");for(let a of Array.from(n.attributes))(/^on/i.test(a.name)||["autofocus","autoplay","srcdoc"].includes(a.name))&&n.removeAttribute(a.name);Array.from(o.children).forEach((a,u)=>{n.children[u]&&de(a,n.children[u])})}var it=(o,n)=>Math.abs(o-n)<1e-4;function le(o){let n=o.getPropertyValue("rotate"),l=o.getPropertyValue("scale");if(n&&n!=="none"&&!/^(0|0deg|0rad|0turn|0grad)$/.test(n.trim())||l&&l!=="none"&&l.trim().split(/\s+/).some(u=>parseFloat(u)!==1))return!0;let a=o.transform;if(!a||a==="none")return!1;try{let u=new DOMMatrixReadOnly(a);return!it(u.a,1)||!it(u.b,0)||!it(u.c,0)||!it(u.d,1)?!0:!u.is2D&&(!it(u.m13,0)||!it(u.m23,0)||!it(u.m31,0)||!it(u.m32,0)||!it(u.m33,1)||!it(u.m14,0)||!it(u.m24,0)||!it(u.m34,0))}catch{return!1}}function ce(o){let n=["top","right","bottom","left"].some(u=>parseFloat(o.getPropertyValue(`border-${u}-width`))>0&&o.getPropertyValue(`border-${u}-style`)!=="none");return!(o.getPropertyValue("-webkit-background-clip")==="text"||o.getPropertyValue("background-clip")==="text")&&(!Qt(o.backgroundColor)||o.backgroundImage!=="none")||n||o.boxShadow!=="none"}function Ce(o,n){let l=o.style,a=n?["transform","rotate","scale","translate","animation"]:["transform","rotate","scale","translate"],u={transform:"translate(0px)",rotate:"none",scale:"none",translate:"none",animation:"none"},R=[...a,"transition"].map(b=>[b,l.getPropertyValue(b),l.getPropertyPriority(b)]);l.setProperty("transition","none","important");for(let b of a)l.setProperty(b,u[b],"important");return()=>{let b=([E,Z,at])=>{l.getPropertyPriority(E)==="important"&&(Z?l.setProperty(E,Z,at):l.removeProperty(E))};R.filter(([E])=>E!=="transition").forEach(E=>{l.getPropertyValue(E[0]).replace(/\s/g,"")===u[E[0]].replace(/\s/g,"")&&b(E)}),getComputedStyle(o).transform;let P=R.find(([E])=>E==="transition");l.getPropertyValue("transition")==="none"&&b(P)}}function*ue(o,n,l,a){let u=[],R=new Map,b=window.scrollX,P=window.scrollY,Z=getComputedStyle(o).backgroundColor;Qt(Z)&&(Z=getComputedStyle(document.documentElement).backgroundColor),Qt(Z)&&(Z="#ffffff");let at=0,$=0,st={id:at++,node:n,ox:0,oy:0,angle:0,frame:void 0};st.frame=st;let ft=new Map,xt=new Map,J,$t=(r,p)=>!p||r.bottom>p.top&&r.top<p.bottom&&r.right>p.left&&r.left<p.right,Ht=(r,p)=>`inset(${Math.max(0,p.top-r.top)}px ${Math.max(0,r.right-p.right)}px ${Math.max(0,r.bottom-p.bottom)}px ${Math.max(0,p.left-r.left)}px)`,nt=(r,p,h)=>{let c=r.matrix;if(!c)return{x:p,y:h};let x=p-r.ox,S=h-r.oy;return{x:c.a*x+c.c*S+c.e,y:c.b*x+c.d*S+c.f}},Rt=r=>{let p=n.getBoundingClientRect(),h=[[0,0],[100,0],[0,100]].map(([m,z])=>{let T=document.createElement("i");T.style.cssText=`position:absolute;left:${m}px;top:${z}px;width:0;height:0;`,r.node.append(T);let G=T.getBoundingClientRect();return T.remove(),{x:G.left-p.left,y:G.top-p.top}}),[c,x,S]=h;r.matrix={a:(x.x-c.x)/100,b:(x.y-c.y)/100,c:(S.x-c.x)/100,d:(S.y-c.y)/100,e:c.x,f:c.y},r.angle=Math.atan2(r.matrix.b,r.matrix.a)*180/Math.PI},At=(r,p,h,c,x)=>{r.node.append(p);let S={id:at++,node:p,ox:h,oy:c,angle:r.angle,frame:r.frame};return x&&(S.frame=S),(x||r.matrix)&&Rt(S),S},ht=(r,p,h,c,x,S="")=>{let m=document.createElement("div");m.dataset.swarmKind=r;let z=p.left+b,T=p.top+P;m.style.cssText=`position:absolute;left:${z-c.ox}px;top:${T-c.oy}px;width:${p.width}px;height:${p.height}px;visibility:hidden;opacity:0;pointer-events:none;box-sizing:border-box;`,m.append(h),c.node.append(m);let G=nt(c,z+p.width/2,T+p.height/2),A={id:u.length,kind:r,x:z,y:T,width:p.width,height:p.height,cx:G.x,cy:G.y,element:m,container:c,parent:x,signature:S,done:!1,started:!1,progress:0,opacity:h.style.opacity};if(r==="box"&&S){let F=`${c.id}|${S}`;A.master=R.get(F),A.master||R.set(F,A)}return u.push(A),A},Ft=r=>{if(ft.has(r))return ft.get(r);let p=null;for(let h=r,c=0;h&&c<12;h=h.parentElement,c++){let x=getComputedStyle(h);if(x.textDecorationLine&&x.textDecorationLine!=="none"){p=x;break}if(h===o||/^inline-|^table/.test(x.display)||x.float!=="none"||x.position==="absolute"||x.position==="fixed")break}return ft.set(r,p),p},Et=r=>{if(xt.has(r))return xt.get(r);let p=null;for(let h=r,c=0;h&&c<6;h=h.parentElement,c++){let x=getComputedStyle(h);if(x.getPropertyValue("-webkit-background-clip")==="text"||x.getPropertyValue("background-clip")==="text"){p=h;break}if(h===o)break}return xt.set(r,p),p},St=(r,p,h,c)=>{for(let S of Me)r.style.setProperty(S,h.getPropertyValue(S));let x=Ft(p);if(x)for(let S of Ee)r.style.setProperty(S,x.getPropertyValue(S));r.style.opacity=String(c)},dt=(r,p,h,c)=>{let x=Et(p);if(!x)return;let S=getComputedStyle(x),m=x.getBoundingClientRect();r.style.backgroundImage=S.backgroundImage,r.style.backgroundColor=S.backgroundColor,r.style.backgroundRepeat=S.backgroundRepeat,r.style.backgroundSize=/px/.test(S.backgroundSize)&&!/auto|%|cover|contain/.test(S.backgroundSize)?S.backgroundSize:`${m.width}px ${m.height}px`,r.style.backgroundPosition=`${m.left-h}px ${m.top-c}px`,r.style.setProperty("-webkit-background-clip","text"),r.style.setProperty("background-clip","text"),r.style.setProperty("-webkit-text-fill-color",S.getPropertyValue("-webkit-text-fill-color")||"transparent")},k=r=>{if(!r.runs.length||u.length>=l)return;let p={left:r.left,top:r.top,width:r.right-r.left,height:r.bottom-r.top};r.visual.style.cssText=`position:absolute;left:${r.originX-r.left}px;top:${r.originY-r.top}px;`;let h=ht("text",p,r.visual,r.container,r.owner);h.text=r.runs,r.clip&&(h.element.style.clipPath=Ht(r,r.clip))};function*Xt(r,p,h,c,x,S=!1){let m=document.createRange();m.selectNodeContents(r);let z=m.getBoundingClientRect();if(!z.width||!z.height||!$t(z,x.clip)||x.ellipsis?.done)return;let T=x.current;T||(T=x.current={visual:document.createElement("div"),runs:[],left:1/0,top:1/0,right:-1/0,bottom:-1/0,originX:z.left,originY:z.top,owner:x.owner,clip:x.clip,container:x.container,opacity:c});let G=h.direction==="rtl",A=h.textAlign==="justify",F=/^pre|break-spaces/.test(h.whiteSpace),g=(r.textContent??"").slice(0,12e3),C=S?T.runs[T.runs.length-1]:void 0,pt=-1/0,j=NaN,V=!1,y=0,M=x.ellipsis;for(let{segment:X,index:O}of se(g)){$===0&&y++%24===0&&(yield),m.setStart(r,O),m.setEnd(r,O+X.length);let w=m.getBoundingClientRect(),lt=/^\s+$/.test(X),_=!F&<&&X.length===1&&X!==" "?" ":X;if(!w.width&<){if(S)continue;let W=C?.units[C.units.length-1];C&&W&&(C.value+=_,C.units.push({...W,end:C.value.length}),V=!0);continue}if(!w.width&&!w.height)continue;if(M&&!G&&w.right>M.limit+.5){if(M.done=!0,C){let W=C.units[C.units.length-1];C.value+="\u2026",C.units.push({end:C.value.length,startX:W.x,x:W.x+M.width,y:W.y,height:W.height})}break}let yt=G?w.right:w.left,Dt=!S&&(Math.abs(w.top-pt)>2||(G?yt>j+2:yt<j-2));if(!C||Dt||A&&V&&!lt){let W=document.createElement("span");St(W,p,h,c);let wt=w.left-T.originX,It=w.top-T.originY;W.style.cssText+=G?`;position:absolute;right:${T.originX-w.right}px;top:${It}px;white-space:pre;line-height:${w.height}px;`:`;position:absolute;left:${wt}px;top:${It}px;white-space:pre;line-height:${w.height}px;`,dt(W,p,w.left,w.top),T.visual.append(W),C={node:W,value:"",opacity:String(c),units:[]},T.runs.push(C),V=!1}C.value+=_,C.units.push({end:C.value.length,startX:(G?w.right:w.left)+b,x:(G?w.left:w.right)+b,y:w.top+P,height:w.height}),lt&&(V=!0),T.left=Math.min(T.left,w.left),T.top=Math.min(T.top,w.top),T.right=Math.max(T.right,w.right),T.bottom=Math.max(T.bottom,w.bottom),pt=w.top,j=yt}}let v=(r,p,h,c,x)=>{if(u.length>=l)return;let S=r instanceof HTMLInputElement;if(S&&!we.has(r.type))return;let m=S&&r.type==="password"&&r.value?"\u2022".repeat(Math.min(12,[...r.value].length)):r.value,z=m?"value":"placeholder",T=(m||r.placeholder||"").slice(0,2e3);if(!T.trim())return;p.value="",p.placeholder="",J??(J=document.createElement("canvas").getContext("2d"));let G=`${h.fontStyle} ${h.fontWeight} ${h.fontSize} ${h.fontFamily}`;J&&(J.font=G);let A=parseFloat(h.letterSpacing)||0,F=_=>parseFloat(h.getPropertyValue(_))||0,g=c.left+F("border-left-width")+F("padding-left"),C=c.right-F("border-right-width")-F("padding-right"),pt=F("font-size")||14,j=parseFloat(h.lineHeight)||pt*1.25,V=_=>(J?J.measureText(_).width:_.length*pt*.55)+[..._].length*A,y=S?[T]:T.split(`
|
|
39
|
+
`),M=h.textAlign,X=[],O=0;if(y.forEach((_,yt)=>{let Dt=V(_),W=C-g,wt=M==="center"||S&&/button|submit|reset/.test(r.type)&&M!=="left"&&M!=="start"?g+Math.max(0,W-Dt)/2:M==="right"||M==="end"?g+Math.max(0,W-Dt):g,It=S?c.top+(c.height-j)/2:c.top+F("border-top-width")+F("padding-top")+yt*j,Tt="";for(let{segment:Gt}of se(_)){let qt=Math.min(C,wt+V(Tt));Tt+=Gt,X.push({end:O+Tt.length,startX:qt+b,x:Math.min(C,wt+V(Tt))+b,y:Math.max(c.top,It)+P,height:Math.min(j,c.height)})}O+=_.length+1,yt<y.length-1&&X.length&&(X[X.length-1]={...X[X.length-1],end:O})}),!X.length)return;let w=document.createElement("div"),lt=ht("text",c,w,x.container,x);lt.element.style.visibility="hidden",lt.text=[{node:w,value:T,opacity:"1",units:X,write:_=>{p[z]=_}}]};function*ut(r,p,h,c,x,S){if($===0&&(yield),u.length>=l||Se.has(r.tagName.toUpperCase())||r.hasAttribute("data-swarm-ignore")||r.hasAttribute("data-swarm-overlay"))return;let m=getComputedStyle(r);if(m.display==="none"||m.visibility==="hidden"||m.getPropertyValue("content-visibility")==="hidden"||(h*=Number(m.opacity),h<.01))return;let z=r.tagName.toUpperCase(),T=r instanceof HTMLElement||r instanceof SVGElement,G=!S&&T&&le(m),A=G?{transform:m.transform,rotate:m.getPropertyValue("rotate"),scale:m.getPropertyValue("scale"),translate:m.getPropertyValue("translate"),origin:m.transformOrigin}:void 0,F=G?($++,Ce(r,!!(m.animationName&&m.animationName!=="none"))):void 0;try{let g=r.getBoundingClientRect();if(g.top+P>4e4||g.bottom+P<0)return;if(A&&g.width>0&&g.height>0){let y=x;if(c){let w=document.createElement("div");w.style.cssText=`position:absolute;left:${c.left+b-y.ox}px;top:${c.top+P-y.oy}px;width:${c.width}px;height:${c.height}px;overflow:hidden;pointer-events:none;`,y=At(y,w,c.left+b,c.top+P,!1),c=void 0}let M=document.createElement("div"),X=g.left+b,O=g.top+P;M.style.cssText=`position:absolute;left:${X-y.ox}px;top:${O-y.oy}px;width:${g.width}px;height:${g.height}px;pointer-events:none;transform-origin:${A.origin};`,M.style.transform=A.transform==="none"?"":A.transform,A.translate&&A.translate!=="none"&&M.style.setProperty("translate",A.translate),A.rotate&&A.rotate!=="none"&&M.style.setProperty("rotate",A.rotate),A.scale&&A.scale!=="none"&&M.style.setProperty("scale",A.scale),M.dataset.swarmGroup="",x=At(y,M,X,O,!0)}let C=p,pt=y=>{c&&(y.element.style.clipPath=Ht(g,c))};if(g.width>0&&g.height>0&&$t(g,c)){if(re.has(z)){let y=document.createElement("div");y.style.cssText="width:100%;height:100%;overflow:hidden;";let M;if(r instanceof HTMLCanvasElement){let O=document.createElement("canvas");O.width=r.width,O.height=r.height;try{O.getContext("2d")?.drawImage(r,0,0)}catch{}M=O}else if(r instanceof HTMLVideoElement){let O=document.createElement("canvas");O.width=Math.max(1,r.videoWidth),O.height=Math.max(1,r.videoHeight);try{O.getContext("2d")?.drawImage(r,0,0)}catch{}if(r.poster&&r.readyState<2){let w=document.createElement("img");w.src=r.poster,M=w}else M=O}else r instanceof HTMLIFrameElement||z==="OBJECT"||z==="EMBED"?(M=document.createElement("div"),M.textContent="Embedded content"):M=r.cloneNode(!0);de(r,M),(M instanceof HTMLElement||M instanceof SVGElement)&&(M.style.cssText+=";position:relative!important;inset:auto!important;margin:0!important;transform:none!important;rotate:none!important;scale:none!important;translate:none!important;width:100%!important;height:100%!important;box-sizing:border-box!important;",r instanceof HTMLInputElement&&M instanceof HTMLInputElement&&(M.value=r.type==="password"?"\u2022\u2022\u2022\u2022\u2022\u2022":r.value,M.name="",M.disabled=!0),r instanceof HTMLTextAreaElement&&M instanceof HTMLTextAreaElement&&(M.value=r.value),r instanceof HTMLSelectElement&&M instanceof HTMLSelectElement&&(M.selectedIndex=r.selectedIndex)),y.append(M);let X=ht("media",g,y,x,p);pt(X),(r instanceof HTMLInputElement&&M instanceof HTMLInputElement||r instanceof HTMLTextAreaElement&&M instanceof HTMLTextAreaElement)&&v(r,M,m,g,X);return}if(ce(m)){let y=document.createElement("div");y.style.cssText="width:100%;height:100%;box-sizing:border-box;";for(let X of ve)y.style.setProperty(X,m.getPropertyValue(X));y.style.opacity=String(h);let M=`${Math.round(g.width)}:${Math.round(g.height)}:${m.background}:${m.border}:${m.borderRadius}`;C=ht(g.height<=3||g.width<=3?"line":"box",g,y,x,p,M),pt(C)}}let j=S||!["hidden","clip","auto","scroll"].some(y=>m.overflowX===y||m.overflowY===y)||r===document.body||r===document.documentElement?c:c?new DOMRect(Math.max(c.left,g.left),Math.max(c.top,g.top),Math.max(0,Math.min(c.right,g.right)-Math.max(c.left,g.left)),Math.max(0,Math.min(c.bottom,g.bottom)-Math.max(c.top,g.top))):g,V=S;if(!V){let y={owner:C,clip:j,container:x,flush:()=>{y.current&&k(y.current),y.current=void 0}};if(m.textOverflow==="ellipsis"&&m.overflowX!=="visible"&&r instanceof HTMLElement&&r.scrollWidth>r.clientWidth+1){J??(J=document.createElement("canvas").getContext("2d")),J&&(J.font=`${m.fontStyle} ${m.fontWeight} ${m.fontSize} ${m.fontFamily}`);let M=J?J.measureText("\u2026").width:parseFloat(m.fontSize)*.8;y.ellipsis={limit:g.right-(parseFloat(m.borderRightWidth)||0)-(parseFloat(m.paddingRight)||0)-M,width:M,done:!1}}V=y}for(let y of Array.from(r.childNodes)){if(u.length>=l)break;if(y.nodeType===Node.ELEMENT_NODE){let X=y,O=X.tagName.toUpperCase(),w=getComputedStyle(X);(w.display==="inline"||w.display==="contents")&&!re.has(O)&&!ce(w)&&!le(w)?yield*ut(X,C,h,j,x,V):(V.flush(),yield*ut(X,C,h,j,x));continue}if(y.nodeType!==Node.TEXT_NODE||!y.textContent)continue;if(!y.textContent.trim()){V.current?.runs.length&&(yield*Xt(y,r,m,h,V,!0));continue}yield*Xt(y,r,m,h,V,!1)}if(r.shadowRoot){V.flush();for(let y of Array.from(r.shadowRoot.children))yield*ut(y,C,h,j,x)}S||V.flush()}finally{F&&($--,F())}}return yield*ut(o,void 0,1,a,st),{layers:u,background:Z}}function Vt(o,n,l){let a=o.container.matrix;if(!a)return{x:n,y:l};let u=n-o.container.ox,R=l-o.container.oy;return{x:a.a*u+a.c*R+a.e,y:a.b*u+a.d*R+a.f}}var mt=o=>{let n=K(o,0,1);return n*n*(3-2*n)},Ot=(o={})=>({phase:"idle",completed:0,total:0,progress:0,agents:0,speed:Q(o.speed,1,.25,8),sound:o.sound??!1,tour:o.tour??!1});function Zt(o={}){let n=Ot(o),l,a,u,R,b,P,E,Z,at,$=[],st=[],ft=0,xt=0,J=0,$t=0,Ht=!1,nt=!1,Rt=null,At="building",ht={x:0,y:0},Ft=[],Et=0,St=0,dt,k=!1,Xt=o.ready!==!1,v,ut,r=!1,p,h=0,c=0,x=0,S=0,m=Math.floor(Q(o.cursorCount,16,2,48)),z=0,T=new zt,G=()=>({...n}),A=()=>{l&&(l.dataset.swarmPhase=n.phase),pt(),o.onStateChange?.(G())},F=(t,i,e,s)=>{t.addEventListener(i,e,s),Ft.push(()=>t.removeEventListener(i,e,s))},g=(t,i,e)=>{let s=document.createElement(t);return s.className=i,e?.appendChild(s),s};function C(t){n.phase=t,A()}function pt(){if(!a)return;E&&(E.textContent=n.phase==="scanning"?"Scanning page\u2026":n.phase==="intro"?Xt?"Gathering the swarm\u2026":"Preparing content\u2026":n.phase==="transition"?"Preparing the canvas\u2026":n.phase==="exiting"?"Ready.":n.phase==="complete"?"Built.":`${n.completed} / ${n.total} layers`),Z&&(Z.style.width=`${n.progress*100}%`);let t=(i,e,s)=>{let D=a.querySelector(`[data-action="${i}"]`);D&&(D.textContent=e,s!==void 0&&D.setAttribute("aria-pressed",String(s)))};t("speed",`${n.speed}\xD7`),t("sound",n.sound?"\u266A On":"\u266A Off",n.sound),t("tour","Tour",n.tour),t("pause",n.phase==="paused"?"Resume":"Pause",n.phase==="paused"),at&&(at.textContent=n.phase==="complete"?"Move your mouse \xB7 Go live to use the page":"Scroll to build more \xB7 Esc to exit")}function j(){let t=!!a?.activeElement;nt=!1,p?.return(void 0),p=void 0,ft&&window.cancelAnimationFrame(ft),ft=0,Ft.splice(0).forEach(i=>i()),l?.remove(),l=void 0,a=void 0,$=[],st=[],T.setEnabled(!1),t&&Rt?.isConnected&&Rt.focus({preventScroll:!0}),Rt=null}function V(){j(),n.agents=0,C("idle")}function y(){j(),n.agents=0,C("live")}function M(){!nt||n.phase==="paused"||n.phase==="scanning"||(At=n.phase,C("paused"))}function X(){n.phase==="paused"&&(xt=performance.now(),C(At))}function O(t){n.speed=Q(t,n.speed,.25,8),A()}function w(t){n.sound=t,T.setEnabled(t&&nt),A()}function lt(t){n.tour=t,A()}function _(t){if(Xt=t,!t&&p){p.return(void 0),p=void 0,ut=void 0;for(let i of Array.from(R.children))i.classList.contains("selection")||i.remove()}}function yt(){if(!o.controls)return;let t=o.controls==="minimal",i=g("div",t?"toolbar minimal":"toolbar",a);if(i.setAttribute("role","toolbar"),i.setAttribute("aria-label","Swarm rebuild controls"),t){i.style.pointerEvents="none",E=g("span","status",i),E.setAttribute("role","status");return}let e=g("div","avatars",i);_t.slice(0,5).forEach(d=>{let f=g("span","avatar",e);f.style.background=d}),E=g("span","status",i),E.setAttribute("role","status"),E.setAttribute("aria-live","polite");let s=g("div","track",i);Z=g("div","fill",s),g("div","divider",i),[["pause","Pause / resume animation",()=>n.phase==="paused"?X():M()],["tour","Toggle automatic scrolling",()=>lt(!n.tour)],["speed","Change playback speed",()=>O(n.speed>=3?1:Math.floor(n.speed)+1)],["sound","Toggle sound",()=>w(!n.sound)],["replay","Replay animation",W],["live","Go live",y],["close","Close animation",V]].forEach(([d,f,Y])=>{let L=g("button",d==="live"?"live":"",i);L.type="button",L.dataset.action=d,L.setAttribute("aria-label",f),L.title=f,L.textContent={replay:"Replay",live:"Go live",close:"\xD7"}[d]??d,F(L,"click",Y)}),at=g("div","help",a)}function Dt(){let t=o.target,i=typeof t=="string"?document.querySelector(t):t&&"current"in t?t.current:t??document.body;if(!(i instanceof HTMLElement)||!i.isConnected)throw new Error("Swarm target must be a connected HTMLElement. Check your selector or ref.");return i}function W(){if(Ht)return;if(typeof window>"u"||typeof document>"u")throw new Error("Start Swarm Rebuild in a browser effect or event handler.");j();try{dt=Dt()}catch(i){if(C("idle"),o.onError?.(i),!o.onError)throw i;return}if(n={...n,phase:"scanning",completed:0,total:0,progress:0,agents:0},o.respectReducedMotion!==!1&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){n.progress=1,C("live"),o.onComplete?.();return}k=o.scope==="target"||o.scope!=="viewport"&&dt!==document.body&&dt!==document.documentElement,Et=window.innerWidth,St=window.innerHeight,v=k?jt(dt):new DOMRect(0,0,Et,St),ut=void 0,r=!1,p=void 0,h=0,c=0,x=0,S=0,ht={x:v.left+v.width/2,y:v.top+v.height*.46},Rt=document.activeElement instanceof HTMLElement?document.activeElement:null,l=document.createElement("div"),l.setAttribute("data-swarm-overlay",""),l.style.cssText=`all:initial;position:fixed;inset:0;display:block;z-index:${Q(o.zIndex,2147483e3,0,2147483647)};isolation:isolate;`,l.style.pointerEvents="none",l.dataset.swarmScope=k?"target":"viewport",a=l.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=oe,a.append(t),u=g("div","cover",a),u.style.background=o.background??te(dt),R=g("div","stage",u),R.inert=!0,R.setAttribute("aria-hidden","true"),b=g("div","workers",a),b.setAttribute("aria-hidden","true"),P=g("div","intro",a),P.textContent="\u2197",P.setAttribute("aria-hidden","true"),yt(),document.documentElement.append(l),wt(),nt=!0,J=0,xt=performance.now(),$t=0,F(window,"pointermove",(i=>{ht={x:i.clientX,y:i.clientY}}),{passive:!0}),F(window,"keydown",(i=>{if(i.key==="Escape"&&(i.preventDefault(),V()),(!k||a?.activeElement)&&i.key.toLowerCase()==="m"&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&w(!n.sound),i.key==="Tab"&&a&&!k){let e=Array.from(a.querySelectorAll("button"));if(!e.length)return;let s=e.indexOf(a.activeElement);i.preventDefault(),e[(s+(i.shiftKey?-1:1)+e.length)%e.length].focus()}})),o.clickToSkip!==!1&&(u.style.cursor="pointer",u.tabIndex=0,u.setAttribute("role","button"),u.setAttribute("aria-label","Skip animation"),F(u,"click",i=>{i.preventDefault(),i.stopPropagation(),y()}),F(u,"keydown",(i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),i.stopPropagation(),y())}))),F(window,"resize",()=>{Math.abs(window.innerWidth-Et)>2?k?y():W():St=window.innerHeight},{passive:!0}),T.setEnabled(n.sound),A(),k&&F(document,"scroll",()=>{(r||p)&&y()},{capture:!0,passive:!0}),pe(),C("intro"),ft=window.requestAnimationFrame(kt)}function wt(){l&&(v=k?jt(dt):new DOMRect(0,0,window.innerWidth,window.innerHeight),k&&(l.style.clipPath=`inset(${v.top}px ${Math.max(0,window.innerWidth-v.right)}px ${Math.max(0,window.innerHeight-v.bottom)}px ${v.left}px)`,l.style.setProperty("--swarm-left",`${v.left}px`),l.style.setProperty("--swarm-top",`${v.top}px`),l.style.setProperty("--swarm-width",`${v.width}px`),l.style.setProperty("--swarm-height",`${v.height}px`),l.style.setProperty("--swarm-center-x",`${v.left+v.width/2}px`),l.style.setProperty("--swarm-center-y",`${v.top+v.height*.46}px`),l.style.setProperty("--swarm-bottom",`${window.innerHeight-v.bottom+16}px`)))}function It(){p||(ut=v,p=ue(dt,R,Q(o.maxLayers,2500,1,1e4),k?v:void 0));let t=performance.now()+Q(o.snapshotBudget,4,1,12);try{do{let i=p.next();if(i.done){st=i.value.layers,n.total=st.length,r=!0,p=void 0,$.forEach(e=>{R.append(e.selection),e.fromX=e.x,e.fromY=e.y,e.idleX=e.x,e.idleY=e.y,e.idleTime=0,e.delay=o.smoothTransition===!1?0:e.index*.022}),o.showGuides===!0&&[...new Set(st.filter(s=>s.kind==="text").map(s=>Math.round(s.x)))].slice(0,5).forEach(s=>{let D=g("div","guide",a);D.style.left=`${s-window.scrollX}px`}),P.style.transition=o.smoothTransition===!1?"none":"",x=0,C(o.smoothTransition===!1?"building":"transition");return}}while(performance.now()<t)}catch(i){V(),o.onError?.(i),o.onError||console.error("[react-swarm-rebuild]",i)}}function Tt(t,i){let e=o.colors?.length?o.colors:_t,s=o.names?.length?o.names:ee,D=e[t%e.length],d=g("div","worker",b);if(d.style.setProperty("--color",D),d.innerHTML=ne(D),o.showNames===!0){let ot=g("span","name",d);ot.textContent=s[t%s.length]}let f=g("div","selection",R);f.style.setProperty("--color",D),f.hidden=!0;let Y=g("span","badge",f),L=t/i*Math.PI*2,tt=.72+t%3*.18,I=v.left+v.width/2+Math.cos(L)*Math.min(105,v.width*.26)*tt,H=v.top+v.height*.46+Math.sin(L)*Math.min(74,v.height*.21)*tt;return d.style.transform=`translate3d(${I}px,${H}px,0)`,d.dataset.motion="orbit",{node:d,selection:f,badge:Y,index:t,color:D,x:I,y:H,angle:0,scale:1,vx:0,vy:0,fromX:I,fromY:H,fromVx:0,fromVy:0,travel:.36,curve:0,idleX:I,idleY:H,idleTime:0,delay:0,exitX:I,exitY:H,exitCurveX:0,exitCurveY:0,exitAngle:0,elapsed:0,duration:1,retiring:!1,bornAt:-1/0}}function Gt(t){if(Ht||(m=Math.floor(Q(t,m,2,48)),!nt||n.phase==="exiting"||n.phase==="paused"&&At==="exiting"))return;for($.forEach(e=>{e.retiring=!1});$.length>m;){let e=[...$].reverse().find(s=>!s.task);if(!e)break;e.node.remove(),e.selection.remove(),$=$.filter(s=>s!==e)}let i=Math.max(0,$.length-m);for(i>0&&$.slice(-i).forEach(e=>{e.retiring=!0,e.pending=void 0});$.length<m;){let e=Tt(z++,m);e.bornAt=h,e.node.style.opacity="0",$.push(e)}n.agents=$.length,A()}function qt(){let t=$.length;$=$.filter(i=>!i.retiring||i.task?!0:(i.node.remove(),i.selection.remove(),!1)),t!==$.length&&(n.agents=$.length,A())}function pe(){if(z=0,$=Array.from({length:m},()=>Tt(z++,m)),n.agents=$.length,o.showRulers===!0){let e=g("div","ruler-x",a);e.textContent="\u3000 0\u3000\u3000\u3000\u3000 100\u3000\u3000\u3000\u3000 200\u3000\u3000\u3000\u3000 300\u3000\u3000\u3000\u3000 400\u3000\u3000\u3000\u3000 500\u3000\u3000\u3000\u3000 600\u3000\u3000\u3000\u3000 700\u3000\u3000\u3000\u3000 800\u3000\u3000\u3000\u3000 900",g("div","ruler-y",a)}let t=o.fadeIn===!1?"1":"0";b.style.opacity=t,P.style.opacity=t;let i=a?.querySelector(".toolbar");i&&(i.style.opacity=t)}function me(t){if(o.parallelDrawing===!1)return(!t.parent||t.parent.done)&&(!t.master||t.master.done);let i=t.parent?.master?.68:.15;return(!t.parent||t.parent.done||t.parent.progress>=i)&&(!t.master||t.master.done||t.master.progress>=.35)}function fe(t){if(t.pending&&!t.pending.started&&!t.pending.done)return;let i=new Set($.filter(s=>s!==t).map(s=>s.pending)),e=st.find(s=>!s.started&&!s.done&&!i.has(s));e!==t.pending&&(t.pending=e,t.idleTime=0)}function he(t){let i=window.scrollY,e=i+St,s,D=1/0;for(let H of st){if(H.done||H.started||!me(H)||H.cy-H.height*.5>e+80)continue;let ot=Math.max(0,H.cy-H.height*.5-i)*.78+Math.hypot(H.cx-window.scrollX-t.x,H.cy-i-t.y)*.22-(t.pending===H?150:0);ot<D&&(s=H,D=ot)}if(!s){fe(t);return}t.pending=void 0,s.started=!0,t.task=s,t.elapsed=0,t.fromX=t.x,t.fromY=t.y,t.fromVx=t.vx,t.fromVy=t.vy;let d=s.text?.[0]?.units[0],f=Vt(s,d&&o.typing!==!1?d.startX:s.master?s.master.x:s.x,d&&o.typing!==!1?d.y:s.master?s.master.y:s.y),Y=Math.hypot(f.x-window.scrollX-t.x,f.y-window.scrollY-t.y);t.travel=K(.2+Math.sqrt(Y)*.013,.2,.52);let L=(t.index+s.id)%2===0?1:-1;t.curve=L*K(Y*(.11+(t.index+s.id)%4*.03),8,64);let I=(s.text?.reduce((H,ot)=>H+ot.units.length,0)??0)/Q(o.typingSpeed,45,5,300);if(t.duration=s.kind==="text"?K(I<1?.48+I*.52:I,.48,8):.45+Math.min(1,(s.width+s.height)/950),t.node.dataset.motion="working",t.node.dataset.tool="arrow",t.node.style.setProperty("--caret-angle",`${s.container.angle.toFixed(2)}deg`),t.selection.parentElement!==s.container.node&&s.container.node.append(t.selection),t.selection.style.borderStyle=s.master?"dashed":"solid",s.master&&o.showGuides===!0){let H=g("span","measure",t.selection);H.textContent=`\u2325 ${Math.round(Math.hypot(s.x-s.master.x,s.y-s.master.y))}`}}function ge(t,i){let e=t.task;t.elapsed+=i;let s=t.travel,D=e.text?.[0]?.units[0],d=D&&o.typing!==!1?D.startX:e.master?e.master.x:e.x,f=D&&o.typing!==!1?D.y:e.master?e.master.y:e.y,Y=Vt(e,d,f),L=Y.x-window.scrollX,tt=Y.y-window.scrollY;if(t.elapsed<s){let B=K(t.elapsed/s,0,1),N=mt(B),gt=L-t.fromX,ct=tt-t.fromY,bt=Math.hypot(gt,ct)||1,et=-ct/bt,vt=gt/bt,Ct=4*N*(1-N)*t.curve,Bt=B*(1-B)*(1-B)*s/n.speed,Kt=t.x,Nt=t.y;t.x=t.fromX+gt*N+et*Ct+t.fromVx*Bt,t.y=t.fromY+ct*N+vt*Ct+t.fromVy*Bt;let q=Math.max(.004,i/n.speed),Mt=(t.x-Kt)/q,Lt=(t.y-Nt)/q,be=K(Mt*.026-Lt*.01,-26,26)*(1-N*.65);t.angle+=(be-t.angle)*(1-Math.exp(-14*q));return}let I=K((t.elapsed-s)/t.duration,0,1),H=mt(I);e.progress=I,e.element.dataset.swarmProgress=String(I);let ot=e.width*H,Yt=e.height*H,U=e.master?(e.master.x-e.x)*(1-H):0,rt=e.master?(e.master.y-e.y)*(1-H)-Math.sin(H*Math.PI)*10:0;if(e.element.style.opacity="1",e.element.style.visibility="visible",e.element.style.transform=e.master?`translate(${U}px,${rt}px)`:"",e.text){t.selection.hidden=!0;let B=o.typing!==!1;t.node.dataset.tool=B?"type":"arrow";let N=e.text.reduce((q,Mt)=>q+Mt.units.length,0),gt=K(I+Math.sin(I*Math.PI*3+t.index)*(.12/Math.max(4,N))*(1-I),0,1),ct=B?I>=1?N:Math.min(N,Math.max(1,Math.floor(gt*(N+.7)))):N,bt=ct,et=D,vt=!1;for(let q of e.text){let Mt=Math.min(q.units.length,Math.max(0,bt)),Lt=q.value.slice(0,Mt?q.units[Mt-1].end:0);q.write&&q.shown!==Lt&&(q.shown=Lt,q.write(Lt),vt=!0),q.node.textContent!==Lt&&(q.node.textContent=Lt,vt=!0),Mt&&(et=q.units[Mt-1]),bt-=q.units.length,q.node.style.opacity=B?q.opacity:String(Number(q.opacity||1)*H)}let Ct=!B||ct>0,Bt=et?Ct?et.x:et.startX:e.x,Kt=et?et.y:e.y,Nt=Vt(e,Bt,Kt);t.x=Nt.x-window.scrollX,t.y=Nt.y-window.scrollY,t.node.style.setProperty("--caret-height",`${K(et?.height??e.height,12,80)}px`),t.node.style.setProperty("--caret-angle",`${e.container.angle.toFixed(2)}deg`),B&&vt&&T.play("type",t.x/Et)}else{t.node.dataset.tool=e.master?"duplicate":e.kind==="line"?"pen":"cross",t.selection.hidden=!1;let B=e.x-e.container.ox+U,N=e.y-e.container.oy+rt;t.selection.style.left=`${B}px`,t.selection.style.top=`${N}px`,t.selection.style.width=`${Math.max(1,e.master?e.width:ot)}px`,t.selection.style.height=`${Math.max(1,e.master?e.height:Yt)}px`,t.selection.style.background=e.kind==="box"&&!e.master&&I<.65?"#a0a5ab18":"",t.badge.textContent=`${Math.round(ot)} \xD7 ${Math.round(Yt)}`;let gt=e.master?e.x+U:e.kind==="line"&&e.height>e.width?e.x+e.width*.5:e.x+ot,ct=e.master?e.y+rt:e.kind==="line"&&e.width>=e.height?e.y+e.height*.5:e.y+Yt,bt=Vt(e,gt,ct);t.x=bt.x-window.scrollX,t.y=bt.y-window.scrollY;let et=e.element.firstElementChild,vt=(1-H)*100,Ct=(1-H)*100;et.style.clipPath=e.master||H>.97?"":e.kind==="line"?e.height>e.width?`inset(0 0 ${Ct}% 0)`:`inset(0 ${vt}% 0 0)`:`inset(0 ${vt}% ${Ct}% 0)`,et.style.transform=e.master||e.kind==="line"?"":`scale(${(.975+.025*H).toFixed(4)})`,et.style.opacity=String(Number(e.opacity||1)*(.28+.72*H))}if(I>.02&&I<.08&&T.play("draw",t.x/Et),I>=1){e.done=!0;let B=e.element.firstElementChild;B.style.clipPath="",B.style.opacity=e.opacity,B.style.transform="",e.element.style.transform="",t.selection.hidden=!0,t.selection.querySelector(".measure")?.remove(),t.node.dataset.tool="arrow",t.node.dataset.motion="idle",t.node.style.setProperty("--caret-angle","0deg"),t.task=void 0,t.vx=0,t.vy=0,t.idleX=t.x,t.idleY=t.y,t.idleTime=0,t.delay=o.smoothTransition===!1?0:.06+t.index%5*.022,n.completed++,n.progress=n.total?n.completed/n.total:1}}function Ut(t,i,e){let s=t.index*2.399963,D=Q(o.floatSpeed,1,.25,3),d=Q(o.floatAmplitude,1,.25,3),f=h*D,Y,L;if(e){let U=o.floatingIntro!==!1,rt=U?.74+t.index%3*.17:1,B=U&&t.index%4===3?-.72:.85,N=t.index/$.length*Math.PI*2+f*B,gt=U?Math.sin(f*1.45+s)*26*d:0,ct=Math.min((108+gt)*rt,v.width*.32,v.height*.32);Y=v.left+v.width/2+Math.cos(N)*ct+(U?Math.sin(f*1.65+s)*20*d:0),L=v.top+v.height*.46+Math.sin(N)*ct*.72+(U?Math.cos(f*2.05+s)*24*d:0)}else if(o.floatingIdle!==!1){t.idleTime+=i;let U=mt(t.idleTime/.32);if(t.pending&&!t.pending.started&&!t.pending.done){let rt=K(t.pending.cx-window.scrollX,v.left+25,Math.max(v.left+25,v.right-35)),B=K(t.pending.cy-window.scrollY,v.top+35,Math.max(v.top+35,v.bottom-45)),N=1-Math.exp(-3.1*i);t.idleX+=(rt-t.idleX)*N,t.idleY+=(B-t.idleY)*N}Y=t.idleX+(Math.sin(f*1.55+s)*52+Math.sin(f*2.4+s*.7)*16)*d*U,L=t.idleY+(Math.cos(f*1.85+s)*36+Math.sin(f*2.75+s*1.3)*12)*d*U}else{let U=t.index/$.length*Math.PI*2+f*.28,rt=55+t.index%4*23;Y=ht.x+Math.cos(U)*rt,L=ht.y+Math.sin(U)*rt*.7}let tt=(U,rt,B)=>{let N=(rt+(B-U)*38*i)*Math.exp(-8*i);return{position:U+N*i,velocity:N}},I=tt(t.x,t.vx,K(Y,v.left+15,Math.max(v.left+15,v.right-25))),H=tt(t.y,t.vy,K(L,v.top+25,Math.max(v.top+25,v.bottom-35)));t.x=I.position,t.vx=I.velocity,t.y=H.position,t.vy=H.velocity,t.node.dataset.motion=e?"orbit":t.pending&&!t.pending.started?"staging":"idle";let ot=K(t.vx*.045-t.vy*.015,-24,24),Yt=Math.sin(f*1.5+s)*16+ot;t.angle+=(Yt-t.angle)*(1-Math.exp(-8*i))}function xe(){if(o.burstOnComplete===!1||Q(o.exitDuration,700,0,3e3)===0){y();return}let t=Math.hypot(v.width,v.height)+120,i=$.map((e,s)=>s);for(let e=i.length-1;e>0;e--){let s=Math.floor(Math.random()*(e+1));[i[e],i[s]]=[i[s],i[e]]}$.forEach((e,s)=>{let D=i[s]/Math.max(1,$.length),d=(Math.random()-.5)*(Math.PI*1.35/Math.max(1,$.length)+.85),f=-Math.PI+D*Math.PI*2+d,Y=t*(.78+Math.random()*.62),L=Math.cos(f)*Y,tt=Math.sin(f)*Y,I=(Math.random()-.5)*220;e.fromX=e.x,e.fromY=e.y,e.exitX=e.x+L,e.exitY=e.y+tt,e.exitCurveX=-Math.sin(f)*I,e.exitCurveY=Math.cos(f)*I,e.exitAngle=K(Math.cos(f)*28-Math.sin(f)*14+(Math.random()-.5)*18,-42,42),e.node.dataset.tool="arrow",e.node.dataset.motion="exit",e.selection.hidden=!0}),S=0,C("exiting")}function ye(t){n.phase!=="exiting"&&Number.isFinite(t.bornAt)&&(t.node.style.opacity=String(mt((h-t.bornAt)/.25))),t.node.style.transform=`translate3d(${t.x.toFixed(2)}px,${t.y.toFixed(2)}px,0)`;let i=t.node.querySelector(".pointer");i&&(i.style.transform=`translate(-3px,-2.5px) rotate(${t.angle.toFixed(2)}deg) scale(${t.scale.toFixed(3)})`)}function kt(t){if(!nt)return;if(!dt.isConnected){V();return}if(wt(),k&&ut&&["left","top","width","height"].some(e=>Math.abs(v[e]-ut[e])>2)){y();return}let i=Math.min(.05,Math.max(0,(t-xt)/1e3));if(xt=t,R.style.transform=`translate(${-window.scrollX}px,${-window.scrollY}px)`,n.phase!=="paused"){let e=i*n.speed;J+=e,h+=i,c+=i;let s=o.fadeIn===!1?1:mt(c*1e3/Math.max(1,Q(o.fadeInDuration,360,0,3e3)));b.style.opacity=String(s);let D=a?.querySelector(".toolbar");if(D&&(D.style.opacity=String(s)),n.phase==="intro"){P.style.opacity=String(s);let d=1+Math.sin(h*3.2)*.045;if(P.style.transform=`translate(-50%,-50%) scale(${d.toFixed(3)})`,$.forEach(f=>Ut(f,i,!0)),Xt&&J*1e3>=Q(o.introDuration,1600,0,15e3)&&It(),!nt)return}else if(n.phase==="transition"){x+=i;let d=mt(x*1e3/Math.max(1,Q(o.transitionDuration,480,0,3e3)));P.style.opacity=String(1-d),P.style.transform=`translate(-50%,-50%) scale(${(1-d*.18).toFixed(3)})`,$.forEach(f=>{let Y=f.index*2.399963,L=Jt(f.x,f.vx,f.fromX+Math.sin(Y)*22*d,i),tt=Jt(f.y,f.vy,f.fromY+Math.cos(Y)*16*d,i);f.x=L.position,f.vx=L.velocity,f.y=tt.position,f.vy=tt.velocity,f.node.dataset.motion="handoff",f.idleX=f.x,f.idleY=f.y}),d>=1&&(P.style.opacity="0",C("building"))}else if(n.phase==="building"){if(P.style.opacity="0",$.forEach(d=>{d.delay=Math.max(0,d.delay-i),!(d.retiring&&!d.task)&&(!d.retiring&&!d.task&&d.delay<=0&&he(d),d.task?(d.elapsed>=d.travel&&(d.angle*=Math.exp(-10*i)),ge(d,e)):Ut(d,i,!1))}),qt(),n.tour&&!k){let d=st.filter(f=>!f.done).reduce((f,Y)=>Math.min(f,Y.cy-Y.height*.5),1/0);if(Number.isFinite(d)){let f=Math.max(0,d-St*.35);f>window.scrollY+1&&window.scrollBy(0,Math.min(f-window.scrollY,180*e))}}if(n.completed===n.total&&(n.progress=1,a?.querySelectorAll(".guide,.ruler-x,.ruler-y").forEach(d=>d.remove()),T.play("complete"),C("complete"),o.onComplete?.(),!nt||(o.finishBehavior!=="flock"&&xe(),!nt)))return}else if(n.phase==="exiting"){S+=i;let d=K(S*1e3/Math.max(1,Q(o.exitDuration,700,0,3e3)),0,1),f=d*(.36+.64*d),Y=4*d*(1-d);if($.forEach(L=>{L.x=L.fromX+(L.exitX-L.fromX)*f+L.exitCurveX*Y,L.y=L.fromY+(L.exitY-L.fromY)*f+L.exitCurveY*Y,L.angle+=(L.exitAngle-L.angle)*(1-Math.exp(-12*i)),L.scale=1-mt(d)*.12,L.node.style.opacity=String(1-mt((d-.42)/.58))}),u.style.opacity=String(1-mt((d-.42)/.58)),D&&(D.style.opacity=String(1-mt(d))),d>=1){y();return}}else n.phase==="complete"&&$.forEach(d=>Ut(d,i,!1));$.forEach(ye),t-$t>150&&($t=t,A())}nt&&(ft=window.requestAnimationFrame(kt))}return{start:W,replay:W,pause:M,resume:X,goLive:y,stop:V,setSpeed:O,setSound:w,setTour:lt,setReady:_,setCursorCount:Gt,getState:G,destroy(){j(),T.destroy(),Ht=!0,n={...n,phase:"idle",agents:0}}}}function He(o={}){let n=Wt(o);n.current=o;let l=Wt({}),a=Wt(null),[u,R]=$e(()=>Ot(o)),b=Wt(null);if(!b.current){let P=()=>(a.current||(a.current=Zt({...n.current,...l.current,onStateChange:E=>{l.current={...l.current,speed:E.speed,sound:E.sound,tour:E.tour},R(E),n.current.onStateChange?.(E)},onComplete:()=>n.current.onComplete?.(),onError:E=>{n.current.onError?n.current.onError(E):console.error("[react-swarm-rebuild]",E)}})),a.current);b.current={start:()=>{a.current?.destroy(),a.current=null,P().start()},replay:()=>b.current.start(),pause:()=>a.current?.pause(),resume:()=>a.current?.resume(),goLive:()=>a.current?.goLive(),stop:()=>a.current?.stop(),setSpeed:E=>P().setSpeed(E),setSound:E=>P().setSound(E),setTour:E=>P().setTour(E),setReady:E=>{l.current.ready=E,a.current?.setReady(E)},setCursorCount:E=>{l.current.cursorCount=E,a.current?.setCursorCount(E)},getState:()=>a.current?.getState()??Ot(n.current),destroy:()=>{a.current?.destroy(),a.current=null,R(Ot(n.current))}}}return Pt(()=>()=>{a.current?.destroy(),a.current=null},[]),Pt(()=>{o.speed!==void 0&&a.current?.setSpeed(o.speed)},[o.speed]),Pt(()=>{o.sound!==void 0&&a.current?.setSound(o.sound)},[o.sound]),Pt(()=>{o.tour!==void 0&&a.current?.setTour(o.tour)},[o.tour]),Pt(()=>{o.ready!==void 0&&b.current?.setReady(o.ready)},[o.ready]),Pt(()=>{o.cursorCount!==void 0&&b.current?.setCursorCount(o.cursorCount)},[o.cursorCount]),{...b.current,state:u}}var Ge=Le(function({active:n=!0,...l},a){let u=He(l);Pe(a,()=>u,[u]);let{start:R,stop:b}=u;return Pt(()=>(n?R():b(),b),[n,R,b]),null});export{Ge as SwarmRebuild,Zt as createSwarmRebuild,He as useSwarmRebuild};
|
|
40
|
+
//# sourceMappingURL=index.js.map
|