{
  "$schema": "https://shadcn-vue.com/schema/registry-item.json",
  "name": "lamp-switch",
  "type": "registry:ui",
  "title": "Lamp Switch",
  "description": "A pendant lamp over a liquid switch. Flip the switch, drag its knob, or pull the lamp down to turn the light on with a flicker.",
  "dependencies": ["@vueuse/core", "motion-v"],
  "files": [
    {
      "path": "registry/new-york/lamp-switch/LampSwitch.vue",
      "content": "<script setup lang=\"ts\">\n  // Vue port of Lamp Switch from Pin UI (https://pinui.xyz), MIT licence.\n  import {\n    computed,\n    onBeforeUnmount,\n    onMounted,\n    ref,\n    useId,\n    useTemplateRef,\n    watch,\n  } from 'vue';\n  import { usePreferredReducedMotion, useResizeObserver } from '@vueuse/core';\n  import { cn } from '~/lib/utils';\n  import {\n    CARD,\n    RING_RADII,\n    createLampSwitchEngine,\n  } from './lamp-switch-engine';\n  import type { LampSwitchEngine, LampSwitchProps } from './types';\n\n  const props = withDefaults(defineProps<LampSwitchProps>(), {\n    autoOn: true,\n    theme: 'dark',\n    size: 354,\n    label: 'Lamp',\n    class: '',\n  });\n\n  const emit = defineEmits<{ toggle: [on: boolean] }>();\n\n  /** Whether the light is on. Setting it flips the switch. */\n  const isOn = defineModel<boolean>('on', { default: false });\n\n  const uid = useId().replace(/[^a-z0-9]/gi, '');\n  const id = (name: string) => `plamp-${uid}-${name}`;\n  const url = (name: string) => `url(#${id(name)})`;\n  const href = (name: string) => `#${id(name)}`;\n  const gooFilter = { filter: url('goo') };\n  const ceilingStop = { stopColor: 'var(--plamp-ceiling)' };\n\n  const reducedMotion = usePreferredReducedMotion();\n\n  const rootRef = useTemplateRef<HTMLElement>('root');\n  const cardRef = useTemplateRef<HTMLElement>('card');\n  const ringsRef = useTemplateRef<SVGGElement>('rings');\n  const ambientRef = useTemplateRef<HTMLElement>('ambient');\n  const lampRef = useTemplateRef<HTMLElement>('lamp');\n  const beamRef = useTemplateRef<SVGSVGElement>('beam');\n  const haloRef = useTemplateRef<SVGEllipseElement>('halo');\n  const bulbOnRef = useTemplateRef<SVGCircleElement>('bulbOn');\n  const bulbOffRef = useTemplateRef<SVGCircleElement>('bulbOff');\n  const rimRef = useTemplateRef<SVGPathElement>('rim');\n  const rimOffRef = useTemplateRef<SVGPathElement>('rimOff');\n  const dimRef = useTemplateRef<SVGGElement>('dim');\n  const grabRef = useTemplateRef<HTMLElement>('grab');\n  const switchRef = useTemplateRef<HTMLButtonElement>('switchEl');\n  const trackLightRef = useTemplateRef<HTMLElement>('trackLight');\n  const labelOnRef = useTemplateRef<HTMLElement>('labelOn');\n  const labelOffRef = useTemplateRef<HTMLElement>('labelOff');\n  const tailRef = useTemplateRef<HTMLElement>('tail');\n  const knobRef = useTemplateRef<HTMLElement>('knob');\n  const faceRef = useTemplateRef<HTMLElement>('face');\n  const iconRef = useTemplateRef<SVGSVGElement>('icon');\n\n  /* size: never larger than asked, and it fits its container */\n  const scale = ref(props.size / CARD);\n  const rootStyle = computed(() => ({ '--plamp-scale': String(scale.value) }));\n  const parentEl = computed(() => rootRef.value?.parentElement ?? null);\n\n  let engine: LampSwitchEngine | null = null;\n\n  function fit(): void {\n    const parent = parentEl.value;\n    let room = Infinity;\n    if (parent) {\n      const cs = getComputedStyle(parent);\n      room =\n        parent.clientWidth -\n        Number.parseFloat(cs.paddingLeft) -\n        Number.parseFloat(cs.paddingRight);\n    }\n    scale.value = Math.max(0.4, Math.min(props.size, room) / CARD);\n    engine?.setScale(scale.value);\n  }\n\n  useResizeObserver(parentEl, fit);\n  watch(() => props.size, fit);\n  watch(\n    () => props.theme,\n    () => engine?.repaint(),\n  );\n  watch(isOn, (next) => engine?.setOn(next));\n\n  function onToggle(on: boolean): void {\n    isOn.value = on;\n    emit('toggle', on);\n  }\n\n  onMounted(() => {\n    const root = rootRef.value;\n    const card = cardRef.value;\n    const rings = ringsRef.value;\n    const ambient = ambientRef.value;\n    const lamp = lampRef.value;\n    const beam = beamRef.value;\n    const halo = haloRef.value;\n    const bulbOn = bulbOnRef.value;\n    const bulbOff = bulbOffRef.value;\n    const rim = rimRef.value;\n    const rimOff = rimOffRef.value;\n    const dim = dimRef.value;\n    const grab = grabRef.value;\n    const sw = switchRef.value;\n    const trackLight = trackLightRef.value;\n    const labelOn = labelOnRef.value;\n    const labelOff = labelOffRef.value;\n    const tail = tailRef.value;\n    const knob = knobRef.value;\n    const face = faceRef.value;\n    const icon = iconRef.value;\n    if (\n      !root ||\n      !card ||\n      !rings ||\n      !ambient ||\n      !lamp ||\n      !beam ||\n      !halo ||\n      !bulbOn ||\n      !bulbOff ||\n      !rim ||\n      !rimOff ||\n      !dim ||\n      !grab ||\n      !sw ||\n      !trackLight ||\n      !labelOn ||\n      !labelOff ||\n      !tail ||\n      !knob ||\n      !face ||\n      !icon\n    )\n      return;\n    engine = createLampSwitchEngine(\n      {\n        root,\n        card,\n        rings,\n        ambient,\n        lamp,\n        beam,\n        halo,\n        bulbOn,\n        bulbOff,\n        rim,\n        rimOff,\n        dim,\n        grab,\n        switch: sw,\n        trackLight,\n        labelOn,\n        labelOff,\n        tail,\n        knob,\n        face,\n        icon,\n      },\n      {\n        autoOn: () => props.autoOn,\n        reduced: () => reducedMotion.value === 'reduce',\n        theme: () => props.theme,\n        onToggle,\n      },\n    );\n    fit();\n    if (isOn.value) engine.setOn(true);\n  });\n\n  onBeforeUnmount(() => {\n    engine?.destroy();\n    engine = null;\n  });\n\n  function onSwitchDown(e: PointerEvent): void {\n    engine?.switchDown(e);\n  }\n  function onSwitchMove(e: PointerEvent): void {\n    engine?.switchMove(e);\n  }\n  function onSwitchUp(e: PointerEvent): void {\n    engine?.switchUp(e);\n  }\n  function onSwitchCancel(e: PointerEvent): void {\n    engine?.switchCancel(e);\n  }\n  function onSwitchClick(): void {\n    engine?.switchClick();\n  }\n  function onLampDown(e: PointerEvent): void {\n    engine?.lampDown(e);\n  }\n  function onLampMove(e: PointerEvent): void {\n    engine?.lampMove(e);\n  }\n  function onLampUp(e: PointerEvent): void {\n    engine?.lampUp(e);\n  }\n\n  /* imperative hooks, so a host (e.g. an idle demo) can drive it */\n  defineExpose({\n    toggle: () => engine?.toggle(),\n    nudge: (swing: number, stretch?: number) => engine?.nudge(swing, stretch),\n  });\n</script>\n\n<template>\n  <div\n    ref=\"root\"\n    :class=\"cn('plamp', props.class)\"\n    :data-theme=\"theme\"\n    :style=\"rootStyle\"\n  >\n    <svg class=\"plamp__defs\" aria-hidden=\"true\">\n      <defs>\n        <!-- the liquid knob's goo -->\n        <filter :id=\"id('goo')\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"7\" result=\"blur\" />\n          <feColorMatrix\n            in=\"blur\"\n            mode=\"matrix\"\n            values=\"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 22 -10\"\n            result=\"goo\"\n          />\n          <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n        </filter>\n      </defs>\n    </svg>\n\n    <div class=\"plamp__stage\">\n      <div ref=\"card\" class=\"plamp__card\">\n        <!-- concentric arcs -->\n        <svg class=\"plamp__rings\" viewBox=\"0 0 412 412\" aria-hidden=\"true\">\n          <defs>\n            <radialGradient\n              :id=\"id('ringFade')\"\n              cx=\"206\"\n              cy=\"250\"\n              r=\"260\"\n              gradientUnits=\"userSpaceOnUse\"\n            >\n              <stop offset=\"0\" stop-color=\"#fff\" stop-opacity=\"1\" />\n              <stop offset=\"1\" stop-color=\"#fff\" stop-opacity=\"0.35\" />\n            </radialGradient>\n            <mask :id=\"id('ringMask')\">\n              <rect width=\"412\" height=\"412\" :fill=\"url('ringFade')\" />\n            </mask>\n          </defs>\n          <g\n            ref=\"rings\"\n            class=\"plamp__ringGroup\"\n            :mask=\"url('ringMask')\"\n            fill=\"none\"\n            stroke-width=\"0.7\"\n          >\n            <circle\n              v-for=\"r in RING_RADII\"\n              :key=\"r\"\n              cx=\"206\"\n              cy=\"-140\"\n              :r=\"r\"\n            />\n          </g>\n        </svg>\n\n        <!-- the warm glow the light casts on the card -->\n        <div ref=\"ambient\" class=\"plamp__ambient\" />\n\n        <!-- the lamp: it hangs from the ceiling, drops in, and swings on its cord -->\n        <div ref=\"lamp\" class=\"plamp__lamp\">\n          <svg\n            ref=\"beam\"\n            class=\"plamp__beam\"\n            viewBox=\"0 0 412 412\"\n            aria-hidden=\"true\"\n          >\n            <defs>\n              <linearGradient :id=\"id('beamGrad')\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0\" stop-color=\"#fff4dc\" stop-opacity=\"0.62\" />\n                <stop offset=\"0.5\" stop-color=\"#efe3c6\" stop-opacity=\"0.26\" />\n                <stop offset=\"1\" stop-color=\"#efe3c6\" stop-opacity=\"0\" />\n              </linearGradient>\n              <linearGradient :id=\"id('beamCore')\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0\" stop-color=\"#fffaf0\" stop-opacity=\"0.45\" />\n                <stop offset=\"1\" stop-color=\"#fffaf0\" stop-opacity=\"0\" />\n              </linearGradient>\n              <filter\n                :id=\"id('beamBlur')\"\n                x=\"-30%\"\n                y=\"-30%\"\n                width=\"160%\"\n                height=\"160%\"\n              >\n                <feGaussianBlur stdDeviation=\"4\" />\n              </filter>\n            </defs>\n            <path\n              d=\"M138 192 L274 192 L312 306 L100 306 Z\"\n              :fill=\"url('beamGrad')\"\n              :filter=\"url('beamBlur')\"\n            />\n            <path\n              d=\"M164 194 L248 194 L268 262 L144 262 Z\"\n              :fill=\"url('beamCore')\"\n              :filter=\"url('beamBlur')\"\n            />\n          </svg>\n\n          <svg class=\"plamp__fixture\" viewBox=\"0 0 412 412\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient :id=\"id('wood')\" x1=\"0\" x2=\"1\">\n                <stop offset=\"0\" stop-color=\"#a7713f\" />\n                <stop offset=\"0.28\" stop-color=\"#e0b887\" />\n                <stop offset=\"0.55\" stop-color=\"#d9ab76\" />\n                <stop offset=\"0.85\" stop-color=\"#b47c47\" />\n                <stop offset=\"1\" stop-color=\"#8f5c30\" />\n              </linearGradient>\n              <!-- the cord fades into the ceiling: the card's own colour at the top -->\n              <linearGradient :id=\"id('woodFade')\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0\" :style=\"ceilingStop\" stop-opacity=\"1\" />\n                <stop offset=\"1\" :style=\"ceilingStop\" stop-opacity=\"0\" />\n              </linearGradient>\n              <linearGradient :id=\"id('shadeGrad')\" x1=\"0\" x2=\"1\">\n                <stop offset=\"0\" stop-color=\"#d6d2cb\" />\n                <stop offset=\"0.22\" stop-color=\"#efece7\" />\n                <stop offset=\"0.5\" stop-color=\"#f5f3ef\" />\n                <stop offset=\"0.78\" stop-color=\"#e3e0da\" />\n                <stop offset=\"1\" stop-color=\"#b9b4ac\" />\n              </linearGradient>\n              <linearGradient :id=\"id('shadeVert')\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0\" stop-color=\"#000\" stop-opacity=\"0.12\" />\n                <stop offset=\"0.35\" stop-color=\"#000\" stop-opacity=\"0\" />\n                <stop offset=\"1\" stop-color=\"#fff\" stop-opacity=\"0.05\" />\n              </linearGradient>\n              <linearGradient :id=\"id('lipTop')\" x1=\"0\" x2=\"1\">\n                <stop offset=\"0\" stop-color=\"#c9c5be\" />\n                <stop offset=\"0.4\" stop-color=\"#fbfaf7\" />\n                <stop offset=\"1\" stop-color=\"#bcb7af\" />\n              </linearGradient>\n              <linearGradient :id=\"id('lipBottom')\" x1=\"0\" x2=\"1\">\n                <stop offset=\"0\" stop-color=\"#cdc9c2\" />\n                <stop offset=\"0.45\" stop-color=\"#ebe8e3\" />\n                <stop offset=\"1\" stop-color=\"#aaa59d\" />\n              </linearGradient>\n              <radialGradient :id=\"id('bulb')\" cx=\"0.5\" cy=\"0.35\" r=\"0.65\">\n                <stop offset=\"0\" stop-color=\"#fffef6\" />\n                <stop offset=\"0.55\" stop-color=\"#fbf0cf\" />\n                <stop offset=\"1\" stop-color=\"#e5d3a2\" />\n              </radialGradient>\n              <radialGradient :id=\"id('bulbOff')\" cx=\"0.5\" cy=\"0.35\" r=\"0.65\">\n                <stop offset=\"0\" stop-color=\"#6a675f\" />\n                <stop offset=\"1\" stop-color=\"#36342f\" />\n              </radialGradient>\n              <linearGradient :id=\"id('rimGlow')\" x1=\"0\" x2=\"1\">\n                <stop offset=\"0\" stop-color=\"#d9cfb9\" />\n                <stop offset=\"0.5\" stop-color=\"#fff8e6\" />\n                <stop offset=\"1\" stop-color=\"#d4c9b2\" />\n              </linearGradient>\n              <filter\n                :id=\"id('softer')\"\n                x=\"-100%\"\n                y=\"-100%\"\n                width=\"300%\"\n                height=\"300%\"\n              >\n                <feGaussianBlur stdDeviation=\"12\" />\n              </filter>\n              <!-- matte ceramic grain -->\n              <filter :id=\"id('grain')\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n                <feTurbulence\n                  type=\"fractalNoise\"\n                  baseFrequency=\"1.1\"\n                  numOctaves=\"2\"\n                  seed=\"4\"\n                  result=\"n\"\n                />\n                <feColorMatrix\n                  in=\"n\"\n                  type=\"matrix\"\n                  values=\"0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.07 0\"\n                  result=\"g\"\n                />\n                <feComposite in=\"g\" in2=\"SourceGraphic\" operator=\"in\" />\n              </filter>\n              <!-- the lamp's shapes, reused by the dimming overlay when it is off -->\n              <path\n                :id=\"id('pStem')\"\n                d=\"M191 -340 L221 -340 L221 59 L191 59 Z\"\n              />\n              <path\n                :id=\"id('pLipTop')\"\n                d=\"M191 57 L221 57 L253 68.5 L159 68.5 Z\"\n              />\n              <path\n                :id=\"id('pLipBottom')\"\n                d=\"M159 68.5 L253 68.5 L237 88 L175 88 Z\"\n              />\n              <path\n                :id=\"id('pShade')\"\n                d=\"M175 87.5 L237 87.5 L291 186 Q206 192 121 186 Z\"\n              />\n            </defs>\n\n            <!-- the stem; the cord above it fades into the ceiling -->\n            <use :href=\"href('pStem')\" :fill=\"url('wood')\" />\n            <rect\n              x=\"190\"\n              y=\"-340\"\n              width=\"32\"\n              height=\"340\"\n              :fill=\"url('woodFade')\"\n            />\n\n            <!-- the bulb, glowing under the shade -->\n            <ellipse\n              ref=\"halo\"\n              class=\"plamp__off\"\n              cx=\"206\"\n              cy=\"196\"\n              rx=\"46\"\n              ry=\"22\"\n              fill=\"#fff0c8\"\n              :filter=\"url('softer')\"\n            />\n            <circle\n              ref=\"bulbOn\"\n              class=\"plamp__off\"\n              cx=\"206\"\n              cy=\"191\"\n              r=\"21\"\n              :fill=\"url('bulb')\"\n            />\n            <circle\n              ref=\"bulbOff\"\n              cx=\"206\"\n              cy=\"191\"\n              r=\"21\"\n              :fill=\"url('bulbOff')\"\n            />\n\n            <!-- the bow-tie collar -->\n            <use :href=\"href('pLipTop')\" :fill=\"url('lipTop')\" />\n            <use :href=\"href('pLipBottom')\" :fill=\"url('lipBottom')\" />\n            <path\n              d=\"M159.5 68.5 L252.5 68.5\"\n              stroke=\"#fff\"\n              stroke-opacity=\"0.75\"\n              stroke-width=\"0.8\"\n            />\n\n            <!-- the shade -->\n            <use :href=\"href('pShade')\" :fill=\"url('shadeGrad')\" />\n            <use :href=\"href('pShade')\" :fill=\"url('shadeVert')\" />\n            <use :href=\"href('pShade')\" fill=\"#000\" :filter=\"url('grain')\" />\n            <use\n              :href=\"href('pLipBottom')\"\n              fill=\"#000\"\n              :filter=\"url('grain')\"\n            />\n\n            <!-- the inside of the shade, lit by the bulb -->\n            <path\n              ref=\"rim\"\n              class=\"plamp__off\"\n              d=\"M121 186 Q206 179 291 186 Q206 192 121 186 Z\"\n              :fill=\"url('rimGlow')\"\n            />\n            <path\n              ref=\"rimOff\"\n              d=\"M121 186 Q206 179 291 186 Q206 192 121 186 Z\"\n              fill=\"#5f5c57\"\n            />\n\n            <!-- dims the whole fixture while the light is off -->\n            <g ref=\"dim\" class=\"plamp__dim\">\n              <use :href=\"href('pStem')\" />\n              <use :href=\"href('pLipTop')\" />\n              <use :href=\"href('pLipBottom')\" />\n              <use :href=\"href('pShade')\" />\n            </g>\n          </svg>\n\n          <!-- the grab area over the shade: drag to swing, pull down to click the light -->\n          <div\n            ref=\"grab\"\n            class=\"plamp__grab\"\n            aria-hidden=\"true\"\n            @pointerdown=\"onLampDown\"\n            @pointermove=\"onLampMove\"\n            @pointerup=\"onLampUp\"\n            @pointercancel=\"onLampUp\"\n          />\n        </div>\n\n        <!-- the switch -->\n        <button\n          ref=\"switchEl\"\n          type=\"button\"\n          role=\"switch\"\n          aria-checked=\"false\"\n          :aria-label=\"label\"\n          class=\"plamp__switch\"\n          @pointerdown=\"onSwitchDown\"\n          @pointermove=\"onSwitchMove\"\n          @pointerup=\"onSwitchUp\"\n          @pointercancel=\"onSwitchCancel\"\n          @click=\"onSwitchClick\"\n        >\n          <span ref=\"trackLight\" class=\"plamp__trackLight\" />\n          <span ref=\"labelOn\" class=\"plamp__label plamp__label--on\">On</span>\n          <span ref=\"labelOff\" class=\"plamp__label plamp__label--off\">Off</span>\n\n          <!-- the liquid knob: a blob and its trailing drop, merged by the goo -->\n          <span class=\"plamp__goo\" :style=\"gooFilter\">\n            <span ref=\"tail\" class=\"plamp__fill\" />\n            <span ref=\"knob\" class=\"plamp__fill\" />\n          </span>\n\n          <!-- the icon rides on top of the knob -->\n          <span ref=\"face\" class=\"plamp__face\">\n            <span class=\"plamp__sheen\" />\n            <svg\n              ref=\"icon\"\n              class=\"plamp__icon\"\n              viewBox=\"0 0 24 24\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              stroke-width=\"1.3\"\n              stroke-linecap=\"round\"\n              stroke-linejoin=\"round\"\n              aria-hidden=\"true\"\n            >\n              <path d=\"M12 2v10\" />\n              <path d=\"M18.4 6.6a9 9 0 1 1-12.77.04\" />\n            </svg>\n          </span>\n        </button>\n      </div>\n    </div>\n  </div>\n</template>\n\n<style scoped>\n  /* The card is drawn at its native 412 × 412 and scaled as one object by\n     --plamp-scale, set by the component to fit its container. Pointer deltas\n     are divided by the same scale, so the physics feels the same at any size. */\n  .plamp {\n    --plamp-scale: 0.86;\n    /* dark: a dim room, a warm bulb */\n    --plamp-card: radial-gradient(\n      120% 90% at 50% 10%,\n      #171513 0%,\n      #0c0b0a 60%,\n      #090908 100%\n    );\n    --plamp-card-shadow:\n      0 30px 60px -20px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.04);\n    --plamp-ceiling: #0c0b0a;\n    --plamp-ring: #ffffff;\n    --plamp-ambient: radial-gradient(\n      60% 45% at 50% 62%,\n      rgb(255 236 200 / 0.08),\n      transparent 70%\n    );\n    --plamp-dim: #0b0a09;\n    --plamp-track: linear-gradient(\n      180deg,\n      rgb(78 75 70 / 0.78) 0%,\n      rgb(52 50 47 / 0.82) 100%\n    );\n    --plamp-track-shadow:\n      inset 0 1px 0 rgb(255 255 255 / 0.07),\n      inset 0 -8px 18px rgb(0 0 0 / 0.25), 0 10px 28px -8px rgb(0 0 0 / 0.6);\n    --plamp-track-light: linear-gradient(\n      180deg,\n      rgb(255 240 210 / 0.16) 0%,\n      rgb(255 240 210 / 0) 60%\n    );\n    --plamp-label-on: #e9e6e0;\n    --plamp-label-off: #9d9a94;\n    --plamp-fill-off: #4b4945;\n    --plamp-icon-off: #8f8c86;\n    --plamp-sheen:\n      radial-gradient(\n        90% 70% at 40% 20%,\n        rgb(255 255 255 / 0.22),\n        transparent 60%\n      ),\n      linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(0 0 0 / 0.12));\n    --plamp-sheen-edge: inset 0 1px 0 rgb(255 255 255 / 0.18);\n    --plamp-focus: rgb(255 255 255 / 0.4);\n\n    position: relative;\n    flex-shrink: 0;\n    width: calc(412px * var(--plamp-scale));\n    height: calc(412px * var(--plamp-scale));\n    font-family: inherit;\n    user-select: none;\n    -webkit-user-select: none;\n    -webkit-tap-highlight-color: transparent;\n  }\n\n  /* light: the same lamp in a daylit room — parchment walls, the shade lit warm */\n  .plamp[data-theme='light'] {\n    --plamp-card: radial-gradient(\n      120% 90% at 50% 10%,\n      #fbf8f2 0%,\n      #f1ece3 60%,\n      #e9e2d6 100%\n    );\n    --plamp-card-shadow:\n      0 0 0 1px rgb(60 40 20 / 0.06), 0 30px 60px -24px rgb(90 60 30 / 0.35),\n      inset 0 1px 0 rgb(255 255 255 / 0.9);\n    --plamp-ceiling: #faf6f0;\n    --plamp-ring: #3a2a18;\n    --plamp-ambient: radial-gradient(\n      60% 45% at 50% 62%,\n      rgb(255 196 110 / 0.28),\n      transparent 70%\n    );\n    --plamp-dim: #7c766c;\n    --plamp-track: linear-gradient(\n      180deg,\n      rgb(255 255 255 / 0.82) 0%,\n      rgb(236 230 220 / 0.9) 100%\n    );\n    --plamp-track-shadow:\n      inset 0 1px 0 rgb(255 255 255 / 0.95),\n      inset 0 -8px 18px rgb(120 90 50 / 0.1),\n      0 10px 26px -10px rgb(90 60 30 / 0.35);\n    --plamp-track-light: linear-gradient(\n      180deg,\n      rgb(255 210 140 / 0.3) 0%,\n      rgb(255 210 140 / 0) 60%\n    );\n    --plamp-label-on: #3a342c;\n    --plamp-label-off: #8d877d;\n    --plamp-fill-off: #d9d4cb;\n    --plamp-icon-off: #8d877d;\n    --plamp-sheen:\n      radial-gradient(\n        90% 70% at 40% 20%,\n        rgb(255 255 255 / 0.9),\n        transparent 60%\n      ),\n      linear-gradient(180deg, rgb(255 255 255 / 0.3), rgb(120 90 50 / 0.08));\n    --plamp-sheen-edge:\n      inset 0 1px 0 rgb(255 255 255 / 0.95),\n      0 4px 12px -4px rgb(90 60 30 / 0.35);\n    --plamp-focus: rgb(40 30 20 / 0.45);\n  }\n\n  .plamp__defs {\n    position: absolute;\n    width: 0;\n    height: 0;\n  }\n\n  .plamp__stage {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 412px;\n    height: 412px;\n    transform: scale(var(--plamp-scale));\n    transform-origin: 0 0;\n  }\n\n  .plamp__card {\n    position: relative;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    border-radius: 52px;\n    background: var(--plamp-card);\n    box-shadow: var(--plamp-card-shadow);\n    transition:\n      background 0.35s ease,\n      box-shadow 0.35s ease;\n  }\n\n  .plamp__rings {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n  }\n\n  /* the starting state, before the engine takes over: light off */\n  .plamp__ringGroup {\n    stroke: var(--plamp-ring);\n    opacity: 0.035;\n  }\n\n  .plamp__ambient {\n    position: absolute;\n    inset: 0;\n    background: var(--plamp-ambient);\n    opacity: 0;\n    pointer-events: none;\n  }\n\n  /* the lamp hangs from a pivot well above the card */\n  .plamp__lamp {\n    position: absolute;\n    inset: 0;\n    opacity: 0;\n    pointer-events: none;\n    transform-origin: 50% -60%;\n  }\n\n  .plamp__beam,\n  .plamp__fixture {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: visible;\n  }\n\n  .plamp__beam,\n  .plamp__off {\n    opacity: 0;\n  }\n\n  /* in daylight the beam reads as a warm cast on the wall rather than a glow */\n  .plamp[data-theme='light'] .plamp__beam {\n    filter: sepia(0.9) saturate(2.6) brightness(0.96);\n    mix-blend-mode: multiply;\n  }\n\n  .plamp__dim {\n    fill: var(--plamp-dim);\n    opacity: 0.42;\n  }\n\n  .plamp__grab {\n    position: absolute;\n    top: 40px;\n    left: 121px;\n    width: 170px;\n    height: 176px;\n    border-radius: 0 0 48px 48px;\n    pointer-events: auto;\n    cursor: grab;\n    touch-action: none;\n  }\n\n  /* ── the switch ── */\n\n  .plamp__switch {\n    position: absolute;\n    top: 285px;\n    left: 90px;\n    width: 232px;\n    height: 90px;\n    padding: 0;\n    border: 0;\n    border-radius: 999px;\n    background: var(--plamp-track);\n    box-shadow: var(--plamp-track-shadow);\n    font: inherit;\n    cursor: pointer;\n    outline: none;\n    touch-action: none;\n    backdrop-filter: blur(6px);\n    -webkit-tap-highlight-color: transparent;\n    transition:\n      background 0.35s ease,\n      box-shadow 0.35s ease;\n  }\n\n  .plamp__switch:focus-visible {\n    box-shadow:\n      var(--plamp-track-shadow),\n      0 0 0 3px var(--plamp-focus);\n  }\n\n  .plamp__trackLight {\n    position: absolute;\n    inset: 0;\n    border-radius: inherit;\n    background: var(--plamp-track-light);\n    opacity: 0;\n    pointer-events: none;\n  }\n\n  .plamp__label {\n    position: absolute;\n    top: 0;\n    display: grid;\n    place-items: center;\n    width: 142px;\n    height: 100%;\n    font-size: 30px;\n    font-weight: 300;\n    letter-spacing: -0.01em;\n    pointer-events: none;\n  }\n\n  .plamp__label--on {\n    left: 0;\n    padding-left: 12px;\n    color: var(--plamp-label-on);\n    opacity: 0;\n  }\n\n  .plamp__label--off {\n    right: 0;\n    padding-right: 12px;\n    color: var(--plamp-label-off);\n  }\n\n  .plamp__goo {\n    position: absolute;\n    inset: 0;\n    pointer-events: none;\n  }\n\n  .plamp__fill {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 90px;\n    height: 90px;\n    border-radius: 50%;\n    background-color: var(--plamp-fill-off);\n  }\n\n  .plamp__face {\n    position: absolute;\n    top: 0;\n    left: 0;\n    display: grid;\n    place-items: center;\n    width: 90px;\n    height: 90px;\n    border-radius: 50%;\n    pointer-events: none;\n  }\n\n  .plamp__sheen {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    background: var(--plamp-sheen);\n    box-shadow: var(--plamp-sheen-edge);\n  }\n\n  .plamp__icon {\n    position: relative;\n    width: 46px;\n    height: 46px;\n    color: var(--plamp-icon-off);\n  }\n\n  .plamp__switch.is-dragging,\n  .plamp.is-grabbing,\n  .plamp.is-grabbing * {\n    cursor: grabbing !important;\n  }\n\n  @media (prefers-reduced-motion: reduce) {\n    .plamp__card,\n    .plamp__switch {\n      transition: none;\n    }\n  }\n</style>\n",
      "type": "registry:ui",
      "target": "components/ui/lamp-switch/LampSwitch.vue"
    },
    {
      "path": "registry/new-york/lamp-switch/index.ts",
      "content": "export { default as LampSwitch } from './LampSwitch.vue';\nexport { createLampSwitchEngine } from './lamp-switch-engine';\nexport type {\n  LampSwitchColours,\n  LampSwitchEngine,\n  LampSwitchProps,\n  LampSwitchTheme,\n} from './types';\n",
      "type": "registry:ui",
      "target": "components/ui/lamp-switch/index.ts"
    },
    {
      "path": "registry/new-york/lamp-switch/lamp-switch-engine.ts",
      "content": "import { animate } from 'motion-v';\nimport type { AnimationOptions } from 'motion-v';\nimport type {\n  LampSwitchBody,\n  LampSwitchColours,\n  LampSwitchElements,\n  LampSwitchEngine,\n  LampSwitchEngineOptions,\n  LampSwitchKnobDrag,\n  LampSwitchLampDrag,\n  LampSwitchTheme,\n} from './types';\n\nexport const CARD = 412;\nconst KNOB_ON = 232 - 90;\nconst KNOB_OFF = 0;\n\n/* the hanging lamp: a drop under gravity, then a cord spring and a pendulum */\nconst PHYS = {\n  dropFrom: -330, // px above rest\n  dropDelay: 0.4, // s\n  dropTime: 0.6, // s\n  absorb: 0.38, // the share of the landing speed the cord keeps\n  cordK: 230, // cord stiffness\n  cordC: 7, // cord damping\n  swingK: 9, // pendulum stiffness (ω²)\n  swingC: 1.35, // pendulum damping\n};\nconst PIVOT_Y = -0.6 * CARD; // matches the lamp's transform-origin\nconst PULL_DETENT = 38;\nconst DRAG_SLOP = 4;\n\n/* the concentric arcs behind the lamp */\nexport const RING_RADII: number[] = Array.from(\n  { length: Math.floor((760 - 170) / 11) + 1 },\n  (_, i) => 170 + i * 11,\n);\n\n/* the switch's colours, per theme: knob fill and icon, on and off */\nconst SWITCH_COLOURS: Record<LampSwitchTheme, LampSwitchColours> = {\n  dark: {\n    fillOn: '#858279',\n    fillOff: '#4b4945',\n    iconOn: '#ecebe7',\n    iconOff: '#8f8c86',\n  },\n  light: {\n    fillOn: '#fbfaf7',\n    fillOff: '#d9d4cb',\n    iconOn: '#e0a43a',\n    iconOff: '#8d877d',\n  },\n};\n\nconst INSTANT: AnimationOptions = { duration: 0 };\nconst KNOB_SPRING: AnimationOptions = {\n  type: 'spring',\n  stiffness: 420,\n  damping: 30,\n  mass: 0.9,\n};\n/* the trailing drop is looser, so it stretches behind the knob — the liquid feel */\nconst TAIL_SPRING: AnimationOptions = {\n  type: 'spring',\n  stiffness: 170,\n  damping: 17,\n  mass: 1,\n};\nconst FLICKER_TIMES = [0, 0.12, 0.22, 0.36, 0.5, 1];\nconst LABEL_EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\nconst rubber = (x: number, max: number) => max * (1 - Math.exp(-x / max)); // a soft limit toward max\nconst clamp = (v: number, lo: number, hi: number) =>\n  Math.min(hi, Math.max(lo, v));\nconst knobLimit = (x: number) =>\n  x < KNOB_OFF\n    ? KNOB_OFF - rubber(KNOB_OFF - x, 14)\n    : x > KNOB_ON\n      ? KNOB_ON + rubber(x - KNOB_ON, 14)\n      : x;\n\n/**\n * The lamp and the switch, driven imperatively: a drop-in under gravity, a\n * damped cord spring and pendulum, a flickering light, and a liquid knob.\n */\nexport function createLampSwitchEngine(\n  el: LampSwitchElements,\n  opts: LampSwitchEngineOptions,\n): LampSwitchEngine {\n  let alive = true;\n  let scale = 1;\n  const d = (s: number) => (opts.reduced() ? 0 : s);\n  const fills = [el.tail, el.knob];\n\n  /* ── the hanging lamp's physics; the loop sleeps once everything is at rest ── */\n  const body: LampSwitchBody = { y: 0, vy: 0, th: 0, vth: 0 };\n  let phase: 'wait' | 'fall' | 'hang' = 'hang';\n  let phaseT = 0;\n  let raf = 0;\n  let running = false;\n  let prevT = 0;\n  let onLand: (() => void) | null = null;\n  let held = false; // the pointer is holding the lamp: physics pauses, the pointer drives it\n\n  function render() {\n    el.lamp.style.transform = `translateY(${body.y.toFixed(2)}px) rotate(${body.th.toFixed(3)}deg)`;\n  }\n\n  function integrate(dt: number) {\n    /* semi-implicit Euler: the cord's spring (stretch) and the pendulum (swing) */\n    body.vy += (-PHYS.cordK * body.y - PHYS.cordC * body.vy) * dt;\n    body.y += body.vy * dt;\n    body.vth += (-PHYS.swingK * body.th - PHYS.swingC * body.vth) * dt;\n    body.th += body.vth * dt;\n  }\n\n  function step(now: number) {\n    if (held || !alive) {\n      running = false;\n      return;\n    }\n    /* real elapsed time, capped, in small sub-steps: the same at 30, 60 or 144fps */\n    const elapsed = prevT ? Math.min(0.1, (now - prevT) / 1000) : 1 / 60;\n    prevT = now;\n\n    if (phase === 'wait' || phase === 'fall') {\n      phaseT += elapsed;\n      const t = phaseT - PHYS.dropDelay;\n      if (t >= 0) {\n        phase = 'fall';\n        el.lamp.style.opacity = '1';\n      }\n      const g = (-2 * PHYS.dropFrom) / PHYS.dropTime ** 2;\n      if (t >= PHYS.dropTime) {\n        phase = 'hang';\n        body.y = 0;\n        body.vy = g * PHYS.dropTime * PHYS.absorb;\n        body.vth = -13; // a slight sideways kick, so it swings as it lands\n        onLand?.();\n        onLand = null;\n        /* spend the rest of this frame on the cord */\n        for (let left = t - PHYS.dropTime; left > 0; left -= 1 / 240)\n          integrate(Math.min(left, 1 / 240));\n      } else if (t >= 0) {\n        body.y = PHYS.dropFrom + 0.5 * g * t * t;\n      }\n    } else {\n      const n = Math.ceil(elapsed / (1 / 240));\n      for (let i = 0; i < n; i++) integrate(elapsed / n);\n    }\n\n    render();\n\n    const resting =\n      phase === 'hang' &&\n      Math.abs(body.y) < 0.05 &&\n      Math.abs(body.vy) < 0.5 &&\n      Math.abs(body.th) < 0.01 &&\n      Math.abs(body.vth) < 0.05;\n    if (resting) {\n      body.y = body.vy = body.th = body.vth = 0;\n      render();\n      running = false;\n      return;\n    }\n    raf = requestAnimationFrame(step);\n  }\n\n  function wake() {\n    if (running || !alive) return;\n    running = true;\n    prevT = 0;\n    raf = requestAnimationFrame(step);\n  }\n\n  function nudge(vth: number, vy = 0) {\n    if (opts.reduced()) return;\n    body.vth += vth;\n    body.vy += vy;\n    wake();\n  }\n\n  /* ── the switch and the light ── */\n  const knobSpring = () => (opts.reduced() ? INSTANT : KNOB_SPRING);\n  const tailSpring = () => (opts.reduced() ? INSTANT : TAIL_SPRING);\n\n  let on = false;\n  function paintSwitch(t: AnimationOptions) {\n    const c = SWITCH_COLOURS[opts.theme()];\n    fills.forEach((node) =>\n      animate(node, { backgroundColor: on ? c.fillOn : c.fillOff }, t),\n    );\n    animate(el.icon, { color: on ? c.iconOn : c.iconOff }, t);\n  }\n\n  function lightOn() {\n    /* a flicker as the bulb warms up */\n    const flicker: AnimationOptions = {\n      duration: d(0.75),\n      times: FLICKER_TIMES,\n      ease: 'easeOut',\n    };\n    animate(el.beam, { opacity: [0, 0.7, 0.15, 0.9, 0.45, 1] }, flicker);\n    animate(el.halo, { opacity: [0, 0.8, 0.2, 0.9, 0.5, 0.9] }, flicker);\n    animate(el.bulbOn, { opacity: [0, 1, 0.3, 1, 0.7, 1] }, flicker);\n    animate(el.rim, { opacity: [0, 1, 0.3, 1, 0.7, 1] }, flicker);\n    animate(el.bulbOff, { opacity: 0 }, { duration: d(0.3) });\n    animate(el.rimOff, { opacity: 0 }, { duration: d(0.3) });\n    animate(el.dim, { opacity: 0 }, { duration: d(0.5) });\n    animate(el.ambient, { opacity: 1 }, { duration: d(0.8), delay: d(0.1) });\n    animate(el.trackLight, { opacity: 1 }, { duration: d(0.6), delay: d(0.1) });\n    animate(el.rings, { opacity: 0.1 }, { duration: d(0.8) });\n  }\n\n  function lightOff(now = false) {\n    const t: AnimationOptions = now\n      ? INSTANT\n      : { duration: d(0.28), ease: 'easeIn' };\n    animate(el.beam, { opacity: 0 }, t);\n    animate(el.halo, { opacity: 0 }, t);\n    animate(el.bulbOn, { opacity: 0 }, t);\n    animate(el.rim, { opacity: 0 }, t);\n    animate(el.bulbOff, { opacity: 1 }, t);\n    animate(el.rimOff, { opacity: 1 }, t);\n    animate(el.dim, { opacity: 0.42 }, now ? t : { duration: d(0.45) });\n    animate(el.ambient, { opacity: 0 }, t);\n    animate(el.trackLight, { opacity: 0 }, t);\n    animate(el.rings, { opacity: 0.035 }, now ? t : { duration: d(0.5) });\n  }\n\n  /* labels: a blurred cross-fade, sliding away from the knob */\n  function settleLabels(state: boolean, dir: number) {\n    const incoming = state ? el.labelOn : el.labelOff;\n    const outgoing = state ? el.labelOff : el.labelOn;\n    animate(\n      outgoing,\n      { opacity: 0, x: dir * 14, filter: 'blur(6px)' },\n      { duration: d(0.22), ease: 'easeIn' },\n    );\n    animate(\n      incoming,\n      { opacity: 1, x: 0, filter: 'blur(0px)' },\n      { duration: d(0.4), delay: d(0.12), ease: LABEL_EASE },\n    );\n  }\n\n  function toggle() {\n    on = !on;\n    el.switch.setAttribute('aria-checked', String(on));\n    const x = on ? KNOB_ON : KNOB_OFF;\n    const dir = on ? 1 : -1;\n\n    /* the liquid knob: the blob springs, the drop trails behind, the goo merges them */\n    animate(el.knob, { x }, knobSpring());\n    animate(el.face, { x }, knobSpring());\n    animate(el.tail, { x }, tailSpring());\n    if (!opts.reduced()) {\n      animate(\n        el.knob,\n        {\n          scaleX: [null, 1.18, 0.94, 1.03, 1],\n          scaleY: [null, 0.88, 1.05, 0.98, 1],\n        },\n        { duration: 0.6, ease: 'easeOut' },\n      );\n      animate(\n        el.tail,\n        { scale: [1, 0.78, 0.9, 1] },\n        { duration: 0.7, ease: 'easeOut' },\n      );\n      animate(\n        el.icon,\n        { rotate: [null, dir * 90, 0], scale: [1, 0.82, 1] },\n        { duration: 0.55, ease: 'easeInOut' },\n      );\n    }\n    paintSwitch({ duration: d(0.35) });\n    settleLabels(on, dir);\n\n    /* flicking the switch tugs the cord: the lamp bobs and swings */\n    nudge(dir * 9, 70);\n\n    if (on) lightOn();\n    else lightOff();\n    opts.onToggle(on);\n  }\n\n  /* the starting state: light off, switch off */\n  animate(el.knob, { x: KNOB_OFF }, INSTANT);\n  animate(el.tail, { x: KNOB_OFF }, INSTANT);\n  animate(el.face, { x: KNOB_OFF }, INSTANT);\n  animate(el.labelOn, { opacity: 0, x: -14, filter: 'blur(6px)' }, INSTANT);\n  paintSwitch(INSTANT);\n  el.switch.setAttribute('aria-checked', 'false');\n  lightOff(true);\n\n  let auto = opts.autoOn(); // it switches itself on after the drop, unless someone got there first\n  function userToggle() {\n    auto = false;\n    toggle();\n  }\n\n  /* ── the switch: tap it, or drag the liquid knob ── */\n  let swDrag: LampSwitchKnobDrag | null = null;\n  let suppressClick = false;\n  let clickTimer: ReturnType<typeof setTimeout> | undefined;\n\n  function scrubLabels(p: number) {\n    animate(\n      el.labelOn,\n      { opacity: p, x: -14 * (1 - p), filter: `blur(${6 * (1 - p)}px)` },\n      INSTANT,\n    );\n    animate(\n      el.labelOff,\n      { opacity: 1 - p, x: 14 * p, filter: `blur(${6 * p}px)` },\n      INSTANT,\n    );\n  }\n\n  function switchDown(e: PointerEvent) {\n    if (e.button !== 0 || swDrag) return;\n    const base = on ? KNOB_ON : KNOB_OFF;\n    swDrag = {\n      id: e.pointerId,\n      startX: e.clientX,\n      base,\n      x: base,\n      moved: false,\n      lastX: e.clientX,\n      lastT: e.timeStamp,\n      v: 0,\n    };\n    el.switch.setPointerCapture(e.pointerId);\n    animate(\n      el.switch,\n      { scale: 0.97 },\n      { type: 'spring', stiffness: 600, damping: 30 },\n    );\n  }\n\n  function switchMove(e: PointerEvent) {\n    if (!swDrag || e.pointerId !== swDrag.id) return;\n    const dx = (e.clientX - swDrag.startX) / scale;\n    if (!swDrag.moved) {\n      if (Math.abs(dx) < DRAG_SLOP) return;\n      swDrag.moved = true;\n      el.switch.classList.add('is-dragging');\n      animate(\n        el.switch,\n        { scale: 1 },\n        { type: 'spring', stiffness: 500, damping: 22 },\n      );\n      animate(\n        el.face,\n        { scale: 1.06 },\n        { type: 'spring', stiffness: 500, damping: 22 },\n      );\n    }\n\n    /* velocity in card px/s, lightly smoothed */\n    const dt = Math.max(1, e.timeStamp - swDrag.lastT) / 1000;\n    const inst = (e.clientX - swDrag.lastX) / scale / dt;\n    swDrag.v = swDrag.v * 0.6 + inst * 0.4;\n    swDrag.lastX = e.clientX;\n    swDrag.lastT = e.timeStamp;\n\n    const x = knobLimit(swDrag.base + dx);\n    swDrag.x = x;\n    animate(el.knob, { x }, INSTANT);\n    animate(el.face, { x }, INSTANT);\n    animate(el.tail, { x }, tailSpring()); // it lags behind: the liquid stretch\n\n    /* squash and stretch with speed */\n    const stretch = Math.min(Math.abs(swDrag.v) / 2600, 0.2);\n    animate(\n      el.knob,\n      { scaleX: 1 + stretch, scaleY: 1 - stretch * 0.5 },\n      { duration: 0.08 },\n    );\n\n    scrubLabels(clamp(x / KNOB_ON, 0, 1));\n    animate(el.icon, { rotate: ((x - swDrag.base) / KNOB_ON) * 120 }, INSTANT);\n  }\n\n  function endSwitchDrag(e: PointerEvent, cancelled: boolean) {\n    if (!swDrag || e.pointerId !== swDrag.id) return;\n    const drag = swDrag;\n    swDrag = null;\n    el.switch.classList.remove('is-dragging');\n    animate(\n      el.switch,\n      { scale: 1 },\n      { type: 'spring', stiffness: 500, damping: 18 },\n    );\n    if (!drag.moved) return; // a plain tap: the click handler toggles\n\n    suppressClick = true;\n    clearTimeout(clickTimer);\n    clickTimer = setTimeout(() => (suppressClick = false), 0);\n    animate(\n      el.face,\n      { scale: 1 },\n      { type: 'spring', stiffness: 500, damping: 20 },\n    );\n\n    /* where a flick would land, and so which side it settles on */\n    const projected = drag.x + clamp(drag.v, -2000, 2000) * 0.12;\n    const next = cancelled ? on : projected > KNOB_ON / 2;\n    if (next !== on) {\n      userToggle();\n    } else {\n      const x = on ? KNOB_ON : KNOB_OFF;\n      animate(el.knob, { x }, knobSpring());\n      animate(el.face, { x }, knobSpring());\n      animate(el.tail, { x }, tailSpring());\n      animate(\n        el.knob,\n        { scaleX: 1, scaleY: 1 },\n        { type: 'spring', stiffness: 500, damping: 15 },\n      );\n      animate(\n        el.icon,\n        { rotate: 0 },\n        { type: 'spring', stiffness: 300, damping: 18 },\n      );\n      settleLabels(on, on ? 1 : -1);\n    }\n  }\n\n  function switchClick() {\n    if (suppressClick) return;\n    userToggle();\n  }\n\n  /* ── the lamp: grab it, swing it, pull it ──\n     Holding the shade pauses the physics and maps the pointer onto the\n     pendulum — sideways is the swing round the ceiling pivot, vertical is\n     the cord's stretch, both rubber-banded. Letting go hands the throw back\n     to the physics. Pulling past the detent clicks the light, once per\n     pull, mid-pull rather than on release. */\n  let lampDrag: LampSwitchLampDrag | null = null;\n\n  function lampDown(e: PointerEvent) {\n    if (e.button !== 0 || phase !== 'hang' || lampDrag) return;\n    e.preventDefault();\n    const r = el.card.getBoundingClientRect();\n    const localY = (e.clientY - r.top) / scale - body.y;\n    lampDrag = {\n      id: e.pointerId,\n      sx: e.clientX,\n      sy: e.clientY,\n      y0: body.y,\n      th0: body.th,\n      arm: Math.max(120, localY - PIVOT_Y), // from the pivot to the grab point\n      pulled: false,\n      lastT: e.timeStamp,\n      lastY: body.y,\n      lastTh: body.th,\n      vy: 0,\n      vth: 0,\n    };\n    held = true;\n    el.grab.setPointerCapture(e.pointerId);\n    el.root.classList.add('is-grabbing');\n  }\n\n  function lampMove(e: PointerEvent) {\n    if (!lampDrag || e.pointerId !== lampDrag.id) return;\n    const dx = (e.clientX - lampDrag.sx) / scale;\n    const dy = (e.clientY - lampDrag.sy) / scale;\n\n    const rawY = lampDrag.y0 + dy;\n    body.y = rawY >= 0 ? rubber(rawY, 70) : -rubber(-rawY, 26);\n    /* the pivot is above the lamp, so dragging right is a counter-clockwise angle */\n    const rawTh =\n      lampDrag.th0 - (Math.atan2(dx, lampDrag.arm + body.y) * 180) / Math.PI;\n    body.th = Math.sign(rawTh) * rubber(Math.abs(rawTh), 18);\n    render();\n\n    const dt = Math.max(1, e.timeStamp - lampDrag.lastT) / 1000;\n    lampDrag.vy = lampDrag.vy * 0.5 + ((body.y - lampDrag.lastY) / dt) * 0.5;\n    lampDrag.vth =\n      lampDrag.vth * 0.5 + ((body.th - lampDrag.lastTh) / dt) * 0.5;\n    lampDrag.lastY = body.y;\n    lampDrag.lastTh = body.th;\n    lampDrag.lastT = e.timeStamp;\n\n    if (!lampDrag.pulled && body.y >= PULL_DETENT) {\n      lampDrag.pulled = true;\n      navigator.vibrate?.(8);\n      userToggle();\n    }\n  }\n\n  function lampUp(e: PointerEvent) {\n    if (!lampDrag || e.pointerId !== lampDrag.id) return;\n    /* a stale sample — the pointer held still before letting go — means no throw */\n    const still = e.timeStamp - lampDrag.lastT > 80;\n    body.vy = still ? 0 : clamp(lampDrag.vy, -700, 700);\n    body.vth = still ? 0 : clamp(lampDrag.vth, -55, 55);\n    lampDrag = null;\n    held = false;\n    el.root.classList.remove('is-grabbing');\n    wake();\n  }\n\n  /* ── the entrance: the lamp drops in, then the light switches itself on ── */\n  let autoTimer: ReturnType<typeof setTimeout> | undefined;\n  if (opts.reduced()) {\n    el.lamp.style.opacity = '1';\n    render();\n    if (auto) toggle();\n  } else {\n    el.lamp.style.opacity = '0';\n    body.y = PHYS.dropFrom;\n    render();\n    phase = 'wait';\n    phaseT = 0;\n    onLand = () => {\n      autoTimer = setTimeout(() => {\n        if (alive && auto && !on) toggle();\n      }, 450);\n    };\n    wake();\n  }\n\n  return {\n    toggle: userToggle,\n    setOn: (next: boolean) => {\n      if (next !== on) userToggle();\n    },\n    isOn: () => on,\n    nudge,\n    repaint: () => paintSwitch({ duration: d(0.35) }),\n    setScale: (next: number) => {\n      scale = next;\n    },\n    switchDown,\n    switchMove,\n    switchUp: (e: PointerEvent) => endSwitchDrag(e, false),\n    switchCancel: (e: PointerEvent) => endSwitchDrag(e, true),\n    switchClick,\n    lampDown,\n    lampMove,\n    lampUp,\n    destroy: () => {\n      alive = false;\n      cancelAnimationFrame(raf);\n      clearTimeout(autoTimer);\n      clearTimeout(clickTimer);\n    },\n  };\n}\n",
      "type": "registry:ui",
      "target": "components/ui/lamp-switch/lamp-switch-engine.ts"
    },
    {
      "path": "registry/new-york/lamp-switch/types.ts",
      "content": "export type LampSwitchTheme = 'light' | 'dark';\n\nexport interface LampSwitchProps {\n  /** Switch the light on by itself once the lamp has landed. */\n  autoOn?: boolean;\n  theme?: LampSwitchTheme;\n  /** The card's size in px at most; it shrinks to fit a narrow container. */\n  size?: number;\n  /** Accessible name of the switch. */\n  label?: string;\n  class?: string;\n}\n\n/** The switch knob's colours for one theme. */\nexport interface LampSwitchColours {\n  fillOn: string;\n  fillOff: string;\n  iconOn: string;\n  iconOff: string;\n}\n\n/** The elements the engine drives. */\nexport interface LampSwitchElements {\n  root: HTMLElement;\n  card: HTMLElement;\n  rings: SVGGElement;\n  ambient: HTMLElement;\n  lamp: HTMLElement;\n  beam: SVGSVGElement;\n  halo: SVGEllipseElement;\n  bulbOn: SVGCircleElement;\n  bulbOff: SVGCircleElement;\n  rim: SVGPathElement;\n  rimOff: SVGPathElement;\n  dim: SVGGElement;\n  grab: HTMLElement;\n  switch: HTMLButtonElement;\n  trackLight: HTMLElement;\n  labelOn: HTMLElement;\n  labelOff: HTMLElement;\n  tail: HTMLElement;\n  knob: HTMLElement;\n  face: HTMLElement;\n  icon: SVGSVGElement;\n}\n\n/** Live settings the engine reads on every use, so changing them never rebuilds it. */\nexport interface LampSwitchEngineOptions {\n  autoOn: () => boolean;\n  reduced: () => boolean;\n  theme: () => LampSwitchTheme;\n  onToggle: (on: boolean) => void;\n}\n\nexport interface LampSwitchEngine {\n  /** Flip the light, as a press of the switch would. */\n  toggle: () => void;\n  /** Set the light on or off; does nothing if it already is. */\n  setOn: (on: boolean) => void;\n  isOn: () => boolean;\n  /** Give the hanging lamp a push: swing in deg/s, stretch in px/s. */\n  nudge: (swing: number, stretch?: number) => void;\n  /** Repaint the switch after a theme change. */\n  repaint: () => void;\n  /** The card's current scale, so pointer deltas map to card units. */\n  setScale: (scale: number) => void;\n  switchDown: (event: PointerEvent) => void;\n  switchMove: (event: PointerEvent) => void;\n  switchUp: (event: PointerEvent) => void;\n  switchCancel: (event: PointerEvent) => void;\n  switchClick: () => void;\n  lampDown: (event: PointerEvent) => void;\n  lampMove: (event: PointerEvent) => void;\n  lampUp: (event: PointerEvent) => void;\n  destroy: () => void;\n}\n\n/** One frame of the hanging lamp: cord stretch (px) and swing (deg). */\nexport interface LampSwitchBody {\n  y: number;\n  vy: number;\n  th: number;\n  vth: number;\n}\n\nexport interface LampSwitchKnobDrag {\n  id: number;\n  startX: number;\n  base: number;\n  x: number;\n  moved: boolean;\n  lastX: number;\n  lastT: number;\n  v: number;\n}\n\nexport interface LampSwitchLampDrag {\n  id: number;\n  sx: number;\n  sy: number;\n  y0: number;\n  th0: number;\n  arm: number;\n  pulled: boolean;\n  lastT: number;\n  lastY: number;\n  lastTh: number;\n  vy: number;\n  vth: number;\n}\n",
      "type": "registry:ui",
      "target": "components/ui/lamp-switch/types.ts"
    }
  ]
}
