{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-03",
  "title": "Seats and usage calculator",
  "description": "Seats and recording hours set on sliders you can drag, key through or type into, with ticks where the plan changes: a lifted marker glides to the plan that fits while every figure of the month rolls, and a seat-cap notice offers its one-click fix.",
  "dependencies": [
    "@base-ui/react",
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/recipes.json",
    "https://ui.ndekocode.dev/r/segments.json",
    "https://ui.ndekocode.dev/r/slider.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/index.tsx",
      "content": "'use client';\n\nimport { useId, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll, type WordRollWord } from '@/components/core/word-roll';\nimport {\n  type AutoplayStep,\n  useAutoplay,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport {\n  keyDelayOf,\n  PRESS_LEAD_MS,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport { countOf } from '@/registry/ndeko/lib/words';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { type Segment, Segments } from '@/registry/ndeko/ui/segments';\n\nimport {\n  type BillingPeriod,\n  HOUR_RANGE,\n  type Plan,\n  SEAT_RANGE,\n  SECTION,\n  START,\n} from './data';\nimport { EstimateCard } from './estimate-card';\nimport { MeterSlider } from './meter-slider';\nimport { PlanColumns } from './plan-columns';\nimport {\n  type CapNotice,\n  capNoticeOf,\n  estimateOf,\n  fittingPlanOf,\n  formatMoney,\n  hourTicksOf,\n  MONEY_FORMAT,\n  PERIOD_ORDER,\n  seatTicksOf,\n  type Usage,\n  yearlySavingOf,\n} from './pricing-model';\n\nconst PERIODS: Segment<BillingPeriod>[] = [\n  { value: 'monthly', label: 'Monthly' },\n  { value: 'yearly', label: 'Yearly' },\n];\n\n/** Where the demonstration takes the two numbers: past the cap of Starter, then past the hours it includes. */\nconst DEMO = {\n  seats: 14,\n  hoursPerPerson: 30,\n};\n\n/** The pause between two notches of a slider the demonstration drags. */\nconst DRAG_STEP_MS = 110;\n\nconst LOOP_AFTER_MS = 3200;\n\n/** A drag of the demonstration, one notch after the other, through the same handler a hand uses. */\nfunction dragSteps(\n  from: number,\n  to: number,\n  write: (value: number) => void,\n  startAfter: number\n): AutoplayStep[] {\n  const distance = to - from;\n  const direction = Math.sign(distance);\n  const count = Math.abs(distance);\n  const indexes = Array.from({ length: count }, (_, index) => index);\n  return indexes.map((index) => {\n    const walked = index + 1;\n    const offset = walked * direction;\n    const value = from + offset;\n    const after = keyDelayOf(index, startAfter, DRAG_STEP_MS);\n    return { after, run: () => write(value) };\n  });\n}\n\n/** The amount keeps its place while its digits roll; only a change of period rolls the words around it. */\nfunction savingWordsOf(period: BillingPeriod, saving: number): WordRollWord[] {\n  const amount: WordRollWord = {\n    key: 'saving',\n    text: formatMoney(saving),\n    node: (\n      <MotionNumber\n        value={saving}\n        format={MONEY_FORMAT}\n        className='text-foreground font-medium'\n      />\n    ),\n  };\n  if (period === 'yearly') {\n    return ['Saving', amount, 'a', 'year'];\n  }\n  return ['Yearly', 'billing', 'saves', amount];\n}\n\nfunction announcementOf(fit: Plan, notice: CapNotice | null) {\n  if (notice) {\n    return `${fit.name} fits. ${notice.plan.name} holds up to ${notice.seats} seats.`;\n  }\n  return `${fit.name} fits your numbers.`;\n}\n\nexport default function Pricing03() {\n  const [seats, setSeats] = useState(START.seats);\n  const [hoursPerPerson, setHoursPerPerson] = useState(START.hoursPerPerson);\n  const [period, setPeriod] = useState<BillingPeriod>(START.period);\n  const { pressed, press } = usePress<'fix'>();\n  const markerId = useId();\n  const seatsId = useId();\n  const hoursId = useId();\n  const usage: Usage = { seats, hoursPerPerson, period };\n  const fit = fittingPlanOf(usage);\n  const estimate = estimateOf(fit, usage);\n  const notice = capNoticeOf(usage, fit);\n  const seatTicks = seatTicksOf(usage);\n  const hourTicks = hourTicksOf(usage);\n  const saving = yearlySavingOf(fit, seats);\n  const savingWords = savingWordsOf(period, saving);\n  const periodOrder = PERIOD_ORDER[period];\n\n  function fixSeats() {\n    if (!notice) {\n      return;\n    }\n    setSeats(notice.seats);\n  }\n\n  function startOver() {\n    setSeats(START.seats);\n    setHoursPerPerson(START.hoursPerPerson);\n    setPeriod(START.period);\n  }\n\n  function seatsTextOf(value: number) {\n    const valueUsage: Usage = { ...usage, seats: value };\n    const plan = fittingPlanOf(valueUsage);\n    const label = countOf(value, 'seat');\n    return `${label}, ${plan.name} fits`;\n  }\n\n  function hoursTextOf(value: number) {\n    const valueUsage: Usage = { ...usage, hoursPerPerson: value };\n    const plan = fittingPlanOf(valueUsage);\n    const label = countOf(value, 'hour');\n    return `${label} each, ${plan.name} fits`;\n  }\n\n  const steps: AutoplayStep[] = [\n    ...dragSteps(START.seats, DEMO.seats, setSeats, 1400),\n    { after: 1700, run: () => press('fix') },\n    { after: PRESS_LEAD_MS, run: fixSeats },\n    ...dragSteps(\n      START.hoursPerPerson,\n      DEMO.hoursPerPerson,\n      setHoursPerPerson,\n      1500\n    ),\n    { after: 1600, run: () => setPeriod('yearly') },\n  ];\n  const { ref, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: LOOP_AFTER_MS,\n    onReset: startOver,\n  });\n  const announcement = announcementOf(fit, notice);\n  const message = spokenUnless(isAutoplaying, announcement);\n\n  useKeptHeight(ref);\n\n  return (\n    <section className='@container'>\n      <div\n        ref={ref}\n        className='mx-auto flex min-h-[55rem] max-w-6xl flex-col gap-8 px-4 py-16 @2xl:gap-10 @2xl:px-6 @2xl:py-24'\n      >\n        <div className='flex flex-col gap-6 @4xl:flex-row @4xl:items-end @4xl:justify-between'>\n          <div className='flex max-w-2xl flex-col gap-3'>\n            <h2 className='text-2xl font-semibold text-balance @2xl:text-3xl'>\n              {SECTION.title}\n            </h2>\n            <p className='text-muted-foreground text-base text-pretty'>\n              {SECTION.description}\n            </p>\n          </div>\n          <div className='flex flex-wrap items-center gap-x-3 gap-y-2'>\n            <Segments\n              value={period}\n              segments={PERIODS}\n              onValueChange={setPeriod}\n              label='Billing period'\n            />\n            <p className='text-muted-foreground text-xs tabular-nums'>\n              <WordRoll words={savingWords} value={periodOrder} />\n            </p>\n          </div>\n        </div>\n        <div className='grid items-start gap-6 @4xl:grid-cols-[minmax(0,1fr)_20rem]'>\n          <div className='flex min-w-0 flex-col gap-4'>\n            <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] grid gap-x-8 gap-y-4 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @md:p-5 @2xl:grid-cols-2'>\n              <MeterSlider\n                id={seatsId}\n                label='People who record'\n                unit='seats'\n                range={SEAT_RANGE}\n                value={seats}\n                ticks={seatTicks}\n                valueTextOf={seatsTextOf}\n                onValueChange={setSeats}\n              />\n              <MeterSlider\n                id={hoursId}\n                label='Hours each one records a month'\n                unit='hours'\n                range={HOUR_RANGE}\n                value={hoursPerPerson}\n                ticks={hourTicks}\n                valueTextOf={hoursTextOf}\n                onValueChange={setHoursPerPerson}\n              />\n            </div>\n            <PlanColumns period={period} fit={fit} markerId={markerId} />\n          </div>\n          <EstimateCard\n            estimate={estimate}\n            period={period}\n            notice={notice}\n            isFixPressed={pressed === 'fix'}\n            onFix={fixSeats}\n          />\n        </div>\n      </div>\n      <LiveRegion message={message} />\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/meter-slider.tsx",
      "content": "'use client';\n\nimport { NumberField } from '@base-ui/react/number-field';\nimport { AnimatePresence, motion } from 'motion/react';\nimport type { CSSProperties } from 'react';\n\nimport { fadePresence } from '@/registry/ndeko/lib/motion-presets';\nimport { CONTROL_RECIPE } from '@/registry/ndeko/lib/recipes';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Slider, SliderThumbValue } from '@/registry/ndeko/ui/slider';\n\nimport type { Range } from './data';\nimport { formatCount, type Tick } from './pricing-model';\n\n/** Below this share of the track between two ticks their names would touch: the marks stay, the names go. */\nconst MIN_NAME_GAP = 0.16;\n\n/** Two names written towards each other need the room of both. */\nconst MIN_FACING_GAP = 0.34;\n\n/** A tick past this share of the track writes its name on its left, so the name never leaves the block. */\nconst NAME_ON_LEFT_FROM = 0.78;\n\nconst TICK_PRESENCE = fadePresence();\n\n/** Seats and hours are whole: a typed 12.5 rounds to 13 instead of reaching the estimate. */\nconst WHOLE_NUMBERS: Intl.NumberFormatOptions = { maximumFractionDigits: 0 };\n\nfunction amountOf(value: number | readonly number[]) {\n  if (typeof value === 'number') {\n    return value;\n  }\n  return value[0];\n}\n\nfunction shareOf(value: number, range: Range) {\n  const span = range.max - range.min;\n  const offset = value - range.min;\n  return offset / span;\n}\n\n/** The anchor has no width and moves by a share of the row, so it glides with a transform and never widens the page. */\nfunction anchorStyleOf(share: number): CSSProperties {\n  const percent = share * 100;\n  return { transform: `translateX(${percent}cqw)` };\n}\n\nfunction isNameOnLeft(share: number) {\n  return share >= NAME_ON_LEFT_FROM;\n}\n\nfunction nameSideOf(share: number) {\n  if (isNameOnLeft(share)) {\n    return 'end-1.5';\n  }\n  return 'start-1.5';\n}\n\n/** True when two neighbouring ticks have room for both names, wherever each name is written. */\nfunction isClearBetween(\n  first: Tick | undefined,\n  second: Tick | undefined,\n  range: Range\n) {\n  if (!first || !second) {\n    return true;\n  }\n  const firstShare = shareOf(first.value, range);\n  const secondShare = shareOf(second.value, range);\n  const gap = secondShare - firstShare;\n  const isFirstOnRight = !isNameOnLeft(firstShare);\n  const isSecondOnLeft = isNameOnLeft(secondShare);\n  const isFacing = isFirstOnRight && isSecondOnLeft;\n  if (isFacing) {\n    return gap >= MIN_FACING_GAP;\n  }\n  return gap >= MIN_NAME_GAP;\n}\n\nfunction hasRoomForName(ticks: readonly Tick[], index: number, range: Range) {\n  const tick = ticks[index];\n  const isClearBefore = isClearBetween(ticks[index - 1], tick, range);\n  const isClearAfter = isClearBetween(tick, ticks[index + 1], range);\n  return isClearBefore && isClearAfter;\n}\n\ntype TickRowProps = {\n  ticks: readonly Tick[];\n  range: Range;\n};\n\n/** Marks under the track where the plan that fits changes, named with the plan they lead to. */\nfunction TickRow({ ticks, range }: TickRowProps) {\n  return (\n    <div aria-hidden='true' className='@container relative -mt-1 h-6'>\n      <AnimatePresence initial={false}>\n        {ticks.map((tick, index) => {\n          const share = shareOf(tick.value, range);\n          const showsName = hasRoomForName(ticks, index, range);\n          return (\n            <span\n              key={tick.key}\n              style={anchorStyleOf(share)}\n              className='absolute top-0 left-0 w-0 transition-transform duration-300 ease-(--ease-out-strong)'\n            >\n              <motion.span {...TICK_PRESENCE} className='absolute top-0 left-0'>\n                <span className='bg-foreground/30 absolute top-0 left-0 h-2 w-px -translate-x-1/2' />\n                {showsName && (\n                  <span\n                    className={cn(\n                      'text-muted-foreground absolute top-2 text-xs whitespace-nowrap',\n                      nameSideOf(share)\n                    )}\n                  >\n                    {tick.plan.name}\n                  </span>\n                )}\n              </motion.span>\n            </span>\n          );\n        })}\n      </AnimatePresence>\n    </div>\n  );\n}\n\ntype MeterSliderProps = {\n  /** The id of the typed field, so its label names it. */\n  id: string;\n  label: string;\n  /** What the typed number counts, written after the field. */\n  unit: string;\n  range: Range;\n  value: number;\n  ticks: readonly Tick[];\n  /** What the thumb says to a screen reader, for example \"14 seats, Team fits\". */\n  valueTextOf: (value: number) => string;\n  onValueChange: (value: number) => void;\n};\n\n/** One number set three ways: dragged or keyed on the slider, or typed in the field beside its label. */\nexport function MeterSlider({\n  id,\n  label,\n  unit,\n  range,\n  value,\n  ticks,\n  valueTextOf,\n  onValueChange,\n}: MeterSliderProps) {\n  const bubble = formatCount(value);\n\n  function changeFromSlider(next: number | readonly number[]) {\n    const amount = amountOf(next);\n    onValueChange(amount);\n  }\n\n  function changeFromField(next: number | null) {\n    if (next === null) {\n      return;\n    }\n    onValueChange(next);\n  }\n\n  function spokenValueOf(_formatted: string, next: number) {\n    return valueTextOf(next);\n  }\n\n  return (\n    <div className='flex flex-col gap-1.5'>\n      <div className='flex items-center justify-between gap-3'>\n        <label htmlFor={id} className='text-[13px] font-medium text-pretty'>\n          {label}\n        </label>\n        <NumberField.Root\n          id={id}\n          value={value}\n          min={range.min}\n          max={range.max}\n          step={range.step}\n          locale='en-US'\n          format={WHOLE_NUMBERS}\n          onValueChange={changeFromField}\n          className='flex shrink-0 items-center gap-2'\n        >\n          <NumberField.Input\n            className={cn(\n              CONTROL_RECIPE,\n              'h-8 w-16 px-2.5 text-end tabular-nums'\n            )}\n          />\n          <span className='text-muted-foreground w-10 text-xs'>{unit}</span>\n        </NumberField.Root>\n      </div>\n      <Slider\n        value={value}\n        min={range.min}\n        max={range.max}\n        step={range.step}\n        thumbLabels={[label]}\n        getAriaValueText={spokenValueOf}\n        thumbContent={() => <SliderThumbValue>{bubble}</SliderThumbValue>}\n        onValueChange={changeFromSlider}\n      />\n      <TickRow ticks={ticks} range={range} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/meter-slider.tsx"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/plan-columns.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { INSTANT } from '@/registry/ndeko/lib/motion-presets';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport { type BillingPeriod, type Plan, PLANS } from './data';\nimport { formatRate, MONEY_FORMAT, seatPriceOf } from './pricing-model';\n\nconst GLIDE: Transition = { type: 'spring', bounce: 0, duration: 0.45 };\n\nfunction glideOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return GLIDE;\n}\n\nfunction currentOf(isFit: boolean) {\n  if (isFit) {\n    return 'true' as const;\n  }\n  return undefined;\n}\n\ntype PlanColumnProps = {\n  plan: Plan;\n  period: BillingPeriod;\n  fit: Plan;\n  markerId: string;\n  glide: Transition;\n};\n\nfunction PlanColumn({ plan, period, fit, markerId, glide }: PlanColumnProps) {\n  const isFit = plan === fit;\n  const seatPrice = seatPriceOf(plan, period);\n  const extraHourPrice = formatRate(plan.pricePerExtraHour);\n\n  return (\n    <li\n      aria-current={currentOf(isFit)}\n      className='bg-foreground/[0.03] dark:bg-foreground/[0.04] relative isolate flex flex-col gap-3 rounded-xl p-4'\n    >\n      {isFit && (\n        <motion.span\n          layoutId={markerId}\n          layoutDependency={fit.id}\n          transition={glide}\n          aria-hidden='true'\n          className='surface-brand absolute inset-0 -z-10 rounded-xl'\n        >\n          <Wash />\n          <span className='text-primary-ink absolute end-4 top-4 text-xs font-medium'>\n            Fits\n          </span>\n        </motion.span>\n      )}\n      <h3 className='text-sm font-medium'>\n        {plan.name}\n        {isFit && <span className='sr-only'>, fits your numbers</span>}\n      </h3>\n      <p className='flex items-baseline gap-1.5'>\n        <MotionNumber\n          value={seatPrice}\n          format={MONEY_FORMAT}\n          className='text-2xl font-semibold'\n        />\n        <span className='text-muted-foreground text-xs'>per seat a month</span>\n      </p>\n      <ul className='text-muted-foreground flex flex-col gap-1 text-xs tabular-nums'>\n        <li>{plan.includedHoursPerSeat} hours included per seat</li>\n        <li>{extraHourPrice} per extra hour</li>\n        <li>Up to {plan.maxSeats} seats</li>\n      </ul>\n    </li>\n  );\n}\n\ntype PlanColumnsProps = {\n  period: BillingPeriod;\n  fit: Plan;\n  /** Unique to this block on the page, so two calculators never share a marker. */\n  markerId: string;\n};\n\n/** The plans side by side, with one lifted marker that glides to the plan that fits. */\nexport function PlanColumns({ period, fit, markerId }: PlanColumnsProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const glide = glideOf(shouldReduceMotion);\n\n  return (\n    <ul aria-label='Plans' className='grid gap-2 @xl:grid-cols-3'>\n      {PLANS.map((plan) => (\n        <PlanColumn\n          key={plan.id}\n          plan={plan}\n          period={period}\n          fit={fit}\n          markerId={markerId}\n          glide={glide}\n        />\n      ))}\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/plan-columns.tsx"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/estimate-card.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { type ReactNode, useRef } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll, type WordRollWord } from '@/components/core/word-roll';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { InfoIcon } from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport { type BillingPeriod, SECTION } from './data';\nimport {\n  type CapNotice,\n  type Estimate,\n  formatMoney,\n  formatRate,\n  MONEY_FORMAT,\n  PERIOD_ORDER,\n  yearlySeatBillOf,\n} from './pricing-model';\n\n/** The amount keeps its place while its digits roll; only a change of period rolls the words around it. */\nfunction billingWordsOf(\n  period: BillingPeriod,\n  estimate: Estimate\n): WordRollWord[] {\n  if (period === 'monthly') {\n    return ['Billed', 'every', 'month'];\n  }\n  const yearlyBill = yearlySeatBillOf(estimate);\n  const amount: WordRollWord = {\n    key: 'yearly-bill',\n    text: formatMoney(yearlyBill),\n    node: <MotionNumber value={yearlyBill} format={MONEY_FORMAT} />,\n  };\n  return ['Seats', 'billed', amount, 'once', 'a', 'year'];\n}\n\ntype LineProps = {\n  term: string;\n  detail: ReactNode;\n  children: ReactNode;\n};\n\nfunction Line({ term, detail, children }: LineProps) {\n  return (\n    <div className='flex items-start justify-between gap-3'>\n      <dt className='flex min-w-0 flex-col gap-0.5'>\n        <span>{term}</span>\n        <span className='text-muted-foreground text-xs tabular-nums'>\n          {detail}\n        </span>\n      </dt>\n      <dd className='font-medium tabular-nums'>{children}</dd>\n    </div>\n  );\n}\n\ntype NoticeProps = {\n  notice: CapNotice;\n  isFixPressed: boolean;\n  onFix: () => void;\n};\n\nfunction Notice({ notice, isFixPressed, onFix }: NoticeProps) {\n  const total = formatMoney(notice.total);\n\n  return (\n    <div className='pt-4'>\n      <div className='bg-info/10 flex flex-col gap-2.5 rounded-lg p-3'>\n        <p className='flex gap-2 text-[13px] text-pretty'>\n          <InfoIcon className='text-info-foreground mt-0.5 size-4 shrink-0' />\n          <span>\n            {notice.plan.name} holds up to {notice.seats} seats. With{' '}\n            {notice.seats} seats there, your month comes to {total}.\n          </span>\n        </p>\n        <Button\n          type='button'\n          variant='outline'\n          size='sm'\n          onClick={onFix}\n          className={cn('ms-6 self-start', pressedQuietOf(isFixPressed))}\n        >\n          Use {notice.seats} seats on {notice.plan.name}\n        </Button>\n      </div>\n    </div>\n  );\n}\n\ntype EstimateCardProps = {\n  estimate: Estimate;\n  period: BillingPeriod;\n  notice: CapNotice | null;\n  isFixPressed: boolean;\n  onFix: () => void;\n};\n\n/** The month on the plan that fits, line by line, with the seat-cap notice and its fix. */\nexport function EstimateCard({\n  estimate,\n  period,\n  notice,\n  isFixPressed,\n  onFix,\n}: EstimateCardProps) {\n  const startRef = useRef<HTMLAnchorElement>(null);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n  const planName = estimate.plan.name;\n  const extraHourPrice = formatRate(estimate.plan.pricePerExtraHour);\n  const billingWords = billingWordsOf(period, estimate);\n  const periodOrder = PERIOD_ORDER[period];\n\n  /** The fix folds the notice away with the button that was pressed: the focus goes on to the next action. */\n  function fixByHand() {\n    onFix();\n    startRef.current?.focus();\n  }\n\n  return (\n    <section\n      aria-label='Your estimate'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col rounded-xl p-5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <div className='flex items-center justify-between gap-3'>\n        <h3 className='min-w-0 text-sm font-medium'>\n          <WordRoll text={`Your month on ${planName}`} />\n        </h3>\n        <Badge variant='secondary'>Illustrative</Badge>\n      </div>\n      <dl className='mt-4 flex flex-col gap-3 text-[13px]'>\n        <Line\n          term='Seats'\n          detail={\n            <>\n              <MotionNumber value={estimate.seats} /> ×{' '}\n              <MotionNumber value={estimate.seatPrice} format={MONEY_FORMAT} />\n            </>\n          }\n        >\n          <MotionNumber value={estimate.seatCost} format={MONEY_FORMAT} />\n        </Line>\n        <Line\n          term='Hours recorded'\n          detail={\n            <>\n              <MotionNumber value={estimate.includedHours} /> included with the\n              seats\n            </>\n          }\n        >\n          <MotionNumber value={estimate.recordedHours} suffix=' h' />\n        </Line>\n        <Line\n          term='Extra hours'\n          detail={\n            <>\n              <MotionNumber value={estimate.extraHours} /> × {extraHourPrice}\n            </>\n          }\n        >\n          <MotionNumber value={estimate.extraCost} format={MONEY_FORMAT} />\n        </Line>\n      </dl>\n      <div className='bg-foreground/[0.04] mt-4 flex flex-col gap-1 rounded-lg p-3'>\n        <div className='flex items-baseline justify-between gap-3'>\n          <span className='text-[13px]'>Total per month</span>\n          <MotionNumber\n            value={estimate.total}\n            format={MONEY_FORMAT}\n            className='text-[1.75rem] leading-none font-semibold'\n          />\n        </div>\n        <p className='text-muted-foreground text-xs tabular-nums'>\n          <WordRoll words={billingWords} value={periodOrder} />\n        </p>\n      </div>\n      <AnimatePresence initial={false}>\n        {notice && (\n          <motion.div key='notice' {...presence} className='overflow-hidden'>\n            <Notice\n              notice={notice}\n              isFixPressed={isFixPressed}\n              onFix={fixByHand}\n            />\n          </motion.div>\n        )}\n      </AnimatePresence>\n      <Button\n        size='lg'\n        nativeButton={false}\n        render={<a href='#' ref={startRef} />}\n        className='mt-5 w-full'\n      >\n        <WordRoll text={`Start with ${planName}`} />\n      </Button>\n      <p className='text-muted-foreground mt-3 text-xs text-pretty'>\n        {SECTION.footnote}\n      </p>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/estimate-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/pricing-model.ts",
      "content": "import {\n  type BillingPeriod,\n  HOUR_RANGE,\n  type Plan,\n  PLANS,\n  type Range,\n  SEAT_RANGE,\n} from './data';\n\nexport type Usage = {\n  seats: number;\n  hoursPerPerson: number;\n  period: BillingPeriod;\n};\n\nexport type Estimate = {\n  plan: Plan;\n  seats: number;\n  seatPrice: number;\n  seatCost: number;\n  recordedHours: number;\n  includedHours: number;\n  extraHours: number;\n  extraCost: number;\n  total: number;\n};\n\n/** A place on a slider where the plan that fits changes. */\nexport type Tick = {\n  /** The plan it leads to, counted, so a tick glides when the other number moves instead of being born again. */\n  key: string;\n  value: number;\n  plan: Plan;\n};\n\nexport type CapNotice = {\n  plan: Plan;\n  seats: number;\n  total: number;\n};\n\nconst MONTHS_PER_YEAR = 12;\n\n/** The seat range ends at its cap, so this plan only answers for a number no slider can reach. */\nconst LARGEST_PLAN: Plan = PLANS.at(-1) ?? PLANS[0];\n\n/** Monthly comes first, so a phrase that changes with the period rolls up to yearly and down back. */\nexport const PERIOD_ORDER: Record<BillingPeriod, number> = {\n  monthly: 0,\n  yearly: 1,\n};\n\nexport const MONEY_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n};\n\nconst RATE_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n};\n\nconst MONEY_FORMATTER = new Intl.NumberFormat('en-US', MONEY_FORMAT);\n\nconst RATE_FORMATTER = new Intl.NumberFormat('en-US', RATE_FORMAT);\n\nconst COUNT_FORMATTER = new Intl.NumberFormat('en-US');\n\nexport function formatMoney(amount: number) {\n  return MONEY_FORMATTER.format(amount);\n}\n\nexport function formatRate(amount: number) {\n  return RATE_FORMATTER.format(amount);\n}\n\nexport function formatCount(count: number) {\n  return COUNT_FORMATTER.format(count);\n}\n\nexport function seatPriceOf(plan: Plan, period: BillingPeriod) {\n  if (period === 'yearly') {\n    return plan.yearlySeatPrice;\n  }\n  return plan.monthlySeatPrice;\n}\n\n/** Extra hours are rounded to whole dollars once, so the lines of an estimate always add up to its total. */\nexport function estimateOf(plan: Plan, usage: Usage): Estimate {\n  const seatPrice = seatPriceOf(plan, usage.period);\n  const seatCost = seatPrice * usage.seats;\n  const recordedHours = usage.seats * usage.hoursPerPerson;\n  const includedHours = usage.seats * plan.includedHoursPerSeat;\n  const hoursOver = recordedHours - includedHours;\n  const extraHours = Math.max(0, hoursOver);\n  const exactExtraCost = extraHours * plan.pricePerExtraHour;\n  const extraCost = Math.round(exactExtraCost);\n  const total = seatCost + extraCost;\n  return {\n    plan,\n    seats: usage.seats,\n    seatPrice,\n    seatCost,\n    recordedHours,\n    includedHours,\n    extraHours,\n    extraCost,\n    total,\n  };\n}\n\nfunction holdsSeats(plan: Plan, seats: number) {\n  return seats <= plan.maxSeats;\n}\n\nfunction cheaperOf(current: Estimate | null, candidate: Estimate) {\n  if (current === null) {\n    return candidate;\n  }\n  if (candidate.total < current.total) {\n    return candidate;\n  }\n  return current;\n}\n\n/** The cheapest plan that holds every seat. A tie goes to the smaller plan. */\nexport function fittingPlanOf(usage: Usage) {\n  let best: Estimate | null = null;\n  for (const plan of PLANS) {\n    if (!holdsSeats(plan, usage.seats)) {\n      continue;\n    }\n    const estimate = estimateOf(plan, usage);\n    best = cheaperOf(best, estimate);\n  }\n  if (best === null) {\n    return LARGEST_PLAN;\n  }\n  return best.plan;\n}\n\n/**\n * The plan one step down would cost less for these numbers but holds fewer seats than the team\n * has: the notice offers to stay on it with as many seats as it holds.\n */\nexport function capNoticeOf(usage: Usage, fit: Plan): CapNotice | null {\n  const fitIndex = PLANS.indexOf(fit);\n  const smaller: Plan | undefined = PLANS[fitIndex - 1];\n  if (smaller === undefined) {\n    return null;\n  }\n  if (holdsSeats(smaller, usage.seats)) {\n    return null;\n  }\n  const smallerTotal = estimateOf(smaller, usage).total;\n  const fitTotal = estimateOf(fit, usage).total;\n  if (smallerTotal >= fitTotal) {\n    return null;\n  }\n  const seats = smaller.maxSeats;\n  const cappedUsage: Usage = { ...usage, seats };\n  const total = estimateOf(smaller, cappedUsage).total;\n  return { plan: smaller, seats, total };\n}\n\nfunction valuesOf(range: Range) {\n  const values: number[] = [];\n  for (let value = range.min; value <= range.max; value += range.step) {\n    values.push(value);\n  }\n  return values;\n}\n\nconst SEAT_VALUES = valuesOf(SEAT_RANGE);\n\nconst HOUR_VALUES = valuesOf(HOUR_RANGE);\n\nfunction keyOfTick(ticks: Tick[], plan: Plan) {\n  const earlier = ticks.filter((tick) => tick.plan === plan);\n  return `${plan.id}-${earlier.length}`;\n}\n\nfunction ticksAlong(\n  values: readonly number[],\n  usageAt: (value: number) => Usage\n) {\n  const ticks: Tick[] = [];\n  let previous: Plan | null = null;\n  for (const value of values) {\n    const usage = usageAt(value);\n    const plan = fittingPlanOf(usage);\n    const hasPrevious = previous !== null;\n    const isChange = hasPrevious && plan !== previous;\n    if (isChange) {\n      const key = keyOfTick(ticks, plan);\n      ticks.push({ key, value, plan });\n    }\n    previous = plan;\n  }\n  return ticks;\n}\n\nexport function seatTicksOf(usage: Usage) {\n  return ticksAlong(SEAT_VALUES, (seats) => ({ ...usage, seats }));\n}\n\nexport function hourTicksOf(usage: Usage) {\n  return ticksAlong(HOUR_VALUES, (hoursPerPerson) => ({\n    ...usage,\n    hoursPerPerson,\n  }));\n}\n\n/** What yearly billing takes off the seats over twelve months. Extra hours are billed as they come. */\nexport function yearlySavingOf(plan: Plan, seats: number) {\n  const perSeat = plan.monthlySeatPrice - plan.yearlySeatPrice;\n  const perMonth = perSeat * seats;\n  return perMonth * MONTHS_PER_YEAR;\n}\n\nexport function yearlySeatBillOf(estimate: Estimate) {\n  return estimate.seatCost * MONTHS_PER_YEAR;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/pricing-model.ts"
    },
    {
      "path": "registry/ndeko/blocks/pricing/pricing-03/data.ts",
      "content": "export type BillingPeriod = 'monthly' | 'yearly';\n\nexport type PlanId = 'starter' | 'team' | 'scale';\n\nexport type Plan = {\n  id: PlanId;\n  name: string;\n  /** Per seat and per month, billed every month. */\n  monthlySeatPrice: number;\n  /** Per seat and per month, billed once a year. */\n  yearlySeatPrice: number;\n  maxSeats: number;\n  includedHoursPerSeat: number;\n  /** For each hour recorded past what the seats include. */\n  pricePerExtraHour: number;\n};\n\nexport type Range = {\n  min: number;\n  max: number;\n  step: number;\n};\n\nexport const PLANS: Plan[] = [\n  {\n    id: 'starter',\n    name: 'Starter',\n    monthlySeatPrice: 10,\n    yearlySeatPrice: 8,\n    maxSeats: 10,\n    includedHoursPerSeat: 10,\n    pricePerExtraHour: 0.8,\n  },\n  {\n    id: 'team',\n    name: 'Team',\n    monthlySeatPrice: 18,\n    yearlySeatPrice: 15,\n    maxSeats: 40,\n    includedHoursPerSeat: 25,\n    pricePerExtraHour: 0.6,\n  },\n  {\n    id: 'scale',\n    name: 'Scale',\n    monthlySeatPrice: 30,\n    yearlySeatPrice: 25,\n    maxSeats: 100,\n    includedHoursPerSeat: 60,\n    pricePerExtraHour: 0.4,\n  },\n];\n\nexport const SEAT_RANGE: Range = { min: 1, max: 100, step: 1 };\n\nexport const HOUR_RANGE: Range = { min: 0, max: 80, step: 1 };\n\nexport type Start = {\n  seats: number;\n  hoursPerPerson: number;\n  period: BillingPeriod;\n};\n\nexport const START: Start = {\n  seats: 6,\n  hoursPerPerson: 12,\n  period: 'monthly',\n};\n\nexport const SECTION = {\n  title: 'One seat per person, with recording hours in every seat',\n  description:\n    'Echoleaf records and transcribes your meetings. Set how many people use it and how long each one records, and the plan that fits moves under your numbers.',\n  footnote:\n    'Illustrative prices in US dollars for an example app, taxes added at checkout',\n};\n",
      "type": "registry:component",
      "target": "components/blocks/pricing-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "pricing"
  ],
  "type": "registry:block"
}