// axi0 Motion 0.2.0: Fiber tunnel. Comets of light race down a swirling tunnel of fibers that the pointer steers.
// Generated from src/fiber-tunnel/meta.json by motion-pack: a thin wrapper. The loader (motion.js) must be on the page once;
// it starts the effect on the element this renders. Options left out keep the effect's own defaults.
import { createElement } from "react";
import type { HTMLAttributes, ReactNode } from "react";

export interface FiberTunnelProps extends HTMLAttributes<HTMLElement> {
  /** the fibers' two colors (default "#5cc8ff,#8a7dff") */
  colors?: string;
  /** how many fibers run round the tunnel (default 40) */
  fibers?: number;
  /** how much the tunnel swirls with depth (default 1.1) */
  twist?: number;
  /** how fast the comets race (default 1) */
  speed?: number;
  /** fill the nearest positioned parent, behind its content (default false) */
  cover?: boolean;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));
// a present attribute is on; "false" turns off an option that is on by default
const flag = (v: boolean | undefined, d: boolean) => (v === undefined || v === d ? undefined : v ? "" : "false");

export function FiberTunnel({ colors, fibers, twist, speed, cover, ...rest }: FiberTunnelProps) {
  return createElement("axi0-fiber-tunnel", { ...rest, "colors": s(colors), "fibers": s(fibers), "twist": s(twist), "speed": s(speed), "cover": flag(cover, false) });
}

export default FiberTunnel;
