{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "phone-number",
  "title": "Phone Number",
  "description": "Phone-number plugin with verification-code and password sign-in, password recovery, and verified phone-number management.",
  "dependencies": [
    "@better-auth-ui/core@latest",
    "@better-auth-ui/react@latest",
    "@tanstack/react-form",
    "@tanstack/react-query",
    "cn",
    "date-fns",
    "input-otp",
    "lucide-react"
  ],
  "registryDependencies": [
    "alert",
    "alert-dialog",
    "badge",
    "button",
    "calendar",
    "card",
    "checkbox",
    "combobox",
    "field",
    "https://better-auth-ui.com/r/radix-nova/account-settings.json",
    "input",
    "input-group",
    "input-otp",
    "popover",
    "select",
    "skeleton",
    "slider",
    "sonner",
    "spinner",
    "switch",
    "textarea"
  ],
  "files": [
    {
      "path": "examples/start-shadcn-example/src/components/auth/additional-field.tsx",
      "content": "\"use client\"\n\nimport {\n  type AdditionalField as AdditionalFieldConfig,\n  type AdditionalFieldFormValue,\n  getFormFieldErrors,\n  resolveInputType\n} from \"@better-auth-ui/core\"\nimport { useAuth, useCopyToClipboard } from \"@better-auth-ui/react\"\nimport { format } from \"date-fns\"\nimport { CalendarIcon, Check, ChevronDownIcon, Copy } from \"lucide-react\"\nimport { type ComponentType, useRef, useState } from \"react\"\nimport { toast } from \"sonner\"\n\nimport { buttonVariants } from \"@/components/ui/button\"\nimport { Calendar } from \"@/components/ui/calendar\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport {\n  Combobox,\n  ComboboxContent,\n  ComboboxEmpty,\n  ComboboxInput,\n  ComboboxItem,\n  ComboboxList\n} from \"@/components/ui/combobox\"\nimport {\n  Field,\n  FieldContent,\n  FieldError,\n  FieldLabel\n} from \"@/components/ui/field\"\nimport { Input } from \"@/components/ui/input\"\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupButton,\n  InputGroupInput\n} from \"@/components/ui/input-group\"\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTrigger\n} from \"@/components/ui/popover\"\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue\n} from \"@/components/ui/select\"\nimport { Slider } from \"@/components/ui/slider\"\nimport { Switch } from \"@/components/ui/switch\"\nimport { Textarea } from \"@/components/ui/textarea\"\nimport { cn } from \"cn\"\n\nexport type AdditionalFieldProps = {\n  name: string\n  field: AdditionalFieldConfig\n  value: AdditionalFieldFormValue\n  onBlur: () => void\n  onChange: (value: AdditionalFieldFormValue) => void\n  isInvalid?: boolean\n  errors?: unknown[]\n  isPending?: boolean\n  /** Complete suffix appended to labels for fields that are not required. */\n  optionalLabel?: string\n}\n\nfunction valueToString(value: AdditionalFieldFormValue) {\n  if (value == null) return \"\"\n  return value instanceof Date ? value.toISOString() : String(value)\n}\n\n/** Convert a `defaultValue` into a `Date` for the calendar. */\nfunction toDate(value: unknown): Date | undefined {\n  if (value instanceof Date) return value\n  if (typeof value === \"string\") {\n    const parsed = new Date(value)\n    return Number.isNaN(parsed.getTime()) ? undefined : parsed\n  }\n  return undefined\n}\n\n/** Format a Date as `HH:mm:ss` for an `<input type=\"time\">`. */\nfunction formatTime(date: Date) {\n  const pad = (n: number) => n.toString().padStart(2, \"0\")\n  return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`\n}\n\n/**\n * Icon-only copy button used as an `InputGroupAddon`. `getValue` is invoked\n * lazily on click so the button copies the input's *live* value rather than a\n * stale snapshot — important when paired with editable inputs.\n */\nfunction CopyButton({\n  getValue,\n  isDisabled\n}: {\n  getValue: () => string | undefined\n  isDisabled?: boolean\n}) {\n  const { localization } = useAuth()\n  const { copied, copy } = useCopyToClipboard({\n    onError: (error) => {\n      console.error(\"[Better Auth UI] Copy failed\", error)\n      toast.error(localization.errors.copyFailed)\n    }\n  })\n\n  async function handleCopy() {\n    const value = getValue()\n    if (!value) return\n\n    await copy(value)\n  }\n\n  return (\n    <InputGroupButton\n      aria-label={\n        copied\n          ? localization.settings.copiedToClipboard\n          : localization.settings.copyToClipboard\n      }\n      title={\n        copied\n          ? localization.settings.copiedToClipboard\n          : localization.settings.copyToClipboard\n      }\n      onClick={handleCopy}\n      disabled={isDisabled}\n    >\n      {copied ? <Check /> : <Copy />}\n    </InputGroupButton>\n  )\n}\n\n/** Renders a single additional user field via shadcn primitives. */\nexport function AdditionalField({\n  name,\n  field: configuredField,\n  value,\n  onBlur,\n  onChange,\n  isInvalid,\n  errors,\n  isPending,\n  optionalLabel\n}: AdditionalFieldProps) {\n  const field =\n    optionalLabel && !configuredField.required\n      ? {\n          ...configuredField,\n          label: (\n            <>\n              {configuredField.label}\n              {optionalLabel}\n            </>\n          )\n        }\n      : configuredField\n  const inputType = resolveInputType(field)\n  const fieldErrors = getFormFieldErrors(errors ?? [])\n\n  if (field.render) {\n    const FieldRenderer = field.render as ComponentType<AdditionalFieldProps>\n    return (\n      <FieldRenderer\n        name={name}\n        field={field}\n        value={value}\n        onBlur={onBlur}\n        onChange={onChange}\n        isInvalid={isInvalid}\n        errors={errors}\n        isPending={isPending}\n        optionalLabel={optionalLabel}\n      />\n    )\n  }\n\n  if (inputType === \"hidden\") {\n    return (\n      <input type=\"hidden\" name={name} value={valueToString(value)} readOnly />\n    )\n  }\n\n  if (inputType === \"textarea\") {\n    return (\n      <Field data-invalid={isInvalid}>\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n        <Textarea\n          id={name}\n          name={name}\n          value={valueToString(value)}\n          onBlur={onBlur}\n          onChange={(event) => onChange(event.target.value || null)}\n          placeholder={field.placeholder}\n          required={field.required}\n          readOnly={field.readOnly}\n          disabled={isPending}\n          aria-invalid={isInvalid}\n        />\n\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"number\") {\n    const maxFractionDigits = field.formatOptions?.maximumFractionDigits\n\n    return (\n      <Field data-invalid={isInvalid}>\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n        <Input\n          id={name}\n          name={name}\n          type=\"number\"\n          inputMode={maxFractionDigits ? \"decimal\" : \"numeric\"}\n          min={field.min}\n          max={field.max}\n          step={\n            field.step ??\n            (maxFractionDigits ? 1 / 10 ** maxFractionDigits : undefined)\n          }\n          value={typeof value === \"number\" ? value : \"\"}\n          onBlur={onBlur}\n          onChange={(event) =>\n            onChange(\n              event.target.value === \"\" ? null : event.target.valueAsNumber\n            )\n          }\n          placeholder={field.placeholder}\n          required={field.required}\n          readOnly={field.readOnly}\n          disabled={isPending}\n          aria-invalid={isInvalid}\n        />\n\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"slider\") {\n    return (\n      <SliderField\n        name={name}\n        field={field}\n        value={value}\n        onBlur={onBlur}\n        onChange={onChange}\n        isInvalid={isInvalid}\n        errors={errors}\n        isPending={isPending}\n      />\n    )\n  }\n\n  if (inputType === \"switch\") {\n    return (\n      <Field data-invalid={isInvalid} orientation=\"horizontal\">\n        <Switch\n          id={name}\n          name={name}\n          checked={value === true}\n          onBlur={onBlur}\n          onCheckedChange={onChange}\n          disabled={isPending || field.readOnly}\n          aria-invalid={isInvalid}\n        />\n\n        <FieldContent>\n          <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n        </FieldContent>\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"checkbox\") {\n    return (\n      <Field data-invalid={isInvalid} orientation=\"horizontal\">\n        <Checkbox\n          id={name}\n          name={name}\n          checked={value === true}\n          onBlur={onBlur}\n          onCheckedChange={(checked) => onChange(checked === true)}\n          required={field.required}\n          disabled={isPending || field.readOnly}\n          aria-invalid={isInvalid}\n        />\n\n        <FieldContent>\n          <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n        </FieldContent>\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"select\") {\n    return (\n      <Field data-invalid={isInvalid}>\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n        <Select\n          name={name}\n          value={valueToString(value) || undefined}\n          onValueChange={(nextValue) => onChange(nextValue)}\n          required={field.required}\n          disabled={isPending || field.readOnly}\n        >\n          <SelectTrigger\n            id={name}\n            className=\"w-full\"\n            onBlur={onBlur}\n            aria-invalid={isInvalid}\n          >\n            <SelectValue placeholder={field.placeholder} />\n          </SelectTrigger>\n\n          <SelectContent>\n            {field.options?.map((option) => (\n              <SelectItem key={option.value} value={option.value}>\n                {option.label}\n              </SelectItem>\n            ))}\n          </SelectContent>\n        </Select>\n\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"combobox\") {\n    const selectedOption = field.options?.find(\n      (option) => option.value === valueToString(value)\n    )\n\n    return (\n      <Field data-invalid={isInvalid}>\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n        <Combobox\n          items={field.options ?? []}\n          name={name}\n          value={selectedOption ?? null}\n          onValueChange={(option) => onChange(option?.value ?? null)}\n          required={field.required}\n          disabled={isPending || field.readOnly}\n        >\n          <ComboboxInput\n            placeholder={field.placeholder}\n            id={name}\n            onBlur={onBlur}\n            aria-invalid={isInvalid}\n          />\n\n          <ComboboxContent>\n            <ComboboxEmpty>No items found.</ComboboxEmpty>\n\n            <ComboboxList>\n              {(option) => (\n                <ComboboxItem key={option.value} value={option}>\n                  {option.label}\n                </ComboboxItem>\n              )}\n            </ComboboxList>\n          </ComboboxContent>\n        </Combobox>\n\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  if (inputType === \"date\" || inputType === \"datetime\") {\n    return (\n      <DateInput\n        name={name}\n        field={field}\n        value={value}\n        onBlur={onBlur}\n        onChange={onChange}\n        isInvalid={isInvalid}\n        errors={errors}\n        isPending={isPending}\n      />\n    )\n  }\n\n  return (\n    <InputField\n      name={name}\n      field={field}\n      value={value}\n      onBlur={onBlur}\n      onChange={onChange}\n      isInvalid={isInvalid}\n      errors={errors}\n      isPending={isPending}\n    />\n  )\n}\n\nfunction InputField({\n  name,\n  field,\n  value,\n  onBlur,\n  onChange,\n  isInvalid,\n  errors,\n  isPending\n}: AdditionalFieldProps) {\n  const inputRef = useRef<HTMLInputElement>(null)\n  const fieldErrors = getFormFieldErrors(errors ?? [])\n\n  const hasPrefix = field.prefix != null\n  const hasSuffix = field.suffix != null || field.copyable\n\n  const isNumeric = field.type === \"number\"\n  const maxFractionDigits = field.formatOptions?.maximumFractionDigits\n  const nativeInputType = isNumeric ? \"number\" : undefined\n  const nativeInputMode = isNumeric\n    ? maxFractionDigits\n      ? \"decimal\"\n      : \"numeric\"\n    : undefined\n  const nativeStep = maxFractionDigits ? 1 / 10 ** maxFractionDigits : undefined\n\n  if (hasPrefix || hasSuffix) {\n    return (\n      <Field data-invalid={isInvalid}>\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n        <InputGroup>\n          {hasPrefix && (\n            <InputGroupAddon align=\"inline-start\">\n              {field.prefix}\n            </InputGroupAddon>\n          )}\n\n          <InputGroupInput\n            ref={inputRef}\n            id={name}\n            name={name}\n            type={nativeInputType}\n            inputMode={nativeInputMode}\n            step={nativeStep}\n            value={valueToString(value)}\n            onBlur={onBlur}\n            onChange={(event) => onChange(event.target.value || null)}\n            placeholder={field.placeholder}\n            required={field.required}\n            readOnly={field.readOnly}\n            disabled={isPending}\n            aria-invalid={isInvalid}\n          />\n\n          {field.copyable ? (\n            <InputGroupAddon align=\"inline-end\">\n              <CopyButton\n                getValue={() => inputRef.current?.value}\n                isDisabled={isPending}\n              />\n            </InputGroupAddon>\n          ) : (\n            field.suffix != null && (\n              <InputGroupAddon align=\"inline-end\">\n                {field.suffix}\n              </InputGroupAddon>\n            )\n          )}\n        </InputGroup>\n\n        <FieldError errors={fieldErrors} />\n      </Field>\n    )\n  }\n\n  return (\n    <Field data-invalid={isInvalid}>\n      <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n\n      <Input\n        id={name}\n        name={name}\n        type={nativeInputType}\n        inputMode={nativeInputMode}\n        step={nativeStep}\n        value={valueToString(value)}\n        onBlur={onBlur}\n        onChange={(event) => onChange(event.target.value || null)}\n        placeholder={field.placeholder}\n        required={field.required}\n        readOnly={field.readOnly}\n        disabled={isPending}\n        aria-invalid={isInvalid}\n      />\n\n      <FieldError errors={fieldErrors} />\n    </Field>\n  )\n}\n\n/**\n * Slider field. Radix Slider doesn't render the current value, so we render\n * it next to the label and control the state to keep the displayed value in\n * sync. The selected value is submitted via the underlying Radix `name` prop.\n */\nfunction SliderField({\n  name,\n  field,\n  value,\n  onBlur,\n  onChange,\n  isInvalid,\n  errors,\n  isPending\n}: AdditionalFieldProps) {\n  const maxFractionDigits = field.formatOptions?.maximumFractionDigits\n  const min = field.min ?? 0\n  const max = field.max ?? 100\n  const step =\n    field.step ?? (maxFractionDigits ? 1 / 10 ** maxFractionDigits : 1)\n  const numericValue = typeof value === \"number\" ? value : min\n  const fieldErrors = getFormFieldErrors(errors ?? [])\n\n  const formatter = new Intl.NumberFormat(undefined, field.formatOptions)\n\n  return (\n    <Field data-invalid={isInvalid}>\n      <div className=\"flex items-center justify-between gap-2\">\n        <FieldLabel htmlFor={name}>{field.label}</FieldLabel>\n        <span className=\"text-sm text-muted-foreground tabular-nums\">\n          {formatter.format(numericValue)}\n        </span>\n      </div>\n\n      <Slider\n        id={name}\n        name={name}\n        value={[numericValue]}\n        onBlur={onBlur}\n        onValueChange={(nextValue) =>\n          onChange((Array.isArray(nextValue) ? nextValue[0] : nextValue) ?? min)\n        }\n        min={min}\n        max={max}\n        step={step}\n        disabled={isPending || field.readOnly}\n        aria-invalid={isInvalid}\n      />\n\n      <FieldError errors={fieldErrors} />\n    </Field>\n  )\n}\n\n/**\n * Date / datetime input. Composes `Popover` + `Calendar` for the date and\n * (optionally) `<input type=\"time\">` for the time. Submits the combined ISO\n * value via a hidden `<input>` so it shows up in `FormData`.\n */\nfunction DateInput({\n  name,\n  field,\n  value,\n  onBlur,\n  onChange,\n  isInvalid,\n  errors,\n  isPending\n}: AdditionalFieldProps) {\n  const { localization } = useAuth()\n  const inputType = resolveInputType(field)\n  const isDateTime = inputType === \"datetime\"\n  const fieldErrors = getFormFieldErrors(errors ?? [])\n\n  const date = toDate(value)\n  const [time, setTime] = useState<string>(\n    isDateTime && date ? formatTime(date) : \"\"\n  )\n  const [open, setOpen] = useState(false)\n\n  // Compose the hidden form value: ISO date for \"date\", ISO datetime for\n  // \"datetime\" (date + time).\n  return (\n    <Field data-invalid={isInvalid}>\n      <FieldLabel htmlFor={`${name}-date`}>{field.label}</FieldLabel>\n\n      <div className=\"relative flex gap-2\">\n        <Popover open={open} onOpenChange={setOpen}>\n          <PopoverTrigger\n            type=\"button\"\n            id={`${name}-date`}\n            data-empty={!date}\n            aria-invalid={isInvalid}\n            aria-required={field.required}\n            onBlur={onBlur}\n            disabled={isPending || field.readOnly}\n            className={cn(\n              buttonVariants({ variant: \"outline\" }),\n              \"flex-1 justify-between font-normal\",\n              \"data-[empty=true]:text-muted-foreground\"\n            )}\n          >\n            {date ? format(date, \"PPP\") : <span>{field.placeholder}</span>}\n\n            {isDateTime ? <ChevronDownIcon /> : <CalendarIcon />}\n          </PopoverTrigger>\n\n          <PopoverContent className=\"w-auto overflow-hidden p-0\" align=\"start\">\n            <Calendar\n              mode=\"single\"\n              selected={date}\n              defaultMonth={date}\n              captionLayout=\"dropdown\"\n              onSelect={(value) => {\n                if (!value) {\n                  onChange(null)\n                } else {\n                  const nextValue = new Date(value)\n                  if (isDateTime && time.trim()) {\n                    const [hours = \"0\", minutes = \"0\", seconds = \"0\"] =\n                      time.split(\":\")\n                    nextValue.setHours(\n                      Number(hours),\n                      Number(minutes),\n                      Number(seconds),\n                      0\n                    )\n                  } else {\n                    nextValue.setHours(0, 0, 0, 0)\n                  }\n                  onChange(nextValue)\n                }\n                if (!isDateTime) setOpen(false)\n              }}\n            />\n          </PopoverContent>\n        </Popover>\n\n        {isDateTime && (\n          <Field className=\"w-32\">\n            <FieldLabel htmlFor={`${name}-time`} className=\"sr-only\">\n              {localization.settings.time}\n            </FieldLabel>\n\n            <Input\n              type=\"time\"\n              id={`${name}-time`}\n              step=\"1\"\n              value={time}\n              onChange={(event) => {\n                const nextTime = event.target.value\n                setTime(nextTime)\n                if (!date) return\n                const nextValue = new Date(date)\n                const [hours = \"0\", minutes = \"0\", seconds = \"0\"] =\n                  nextTime.split(\":\")\n                nextValue.setHours(\n                  Number(hours),\n                  Number(minutes),\n                  Number(seconds),\n                  0\n                )\n                onChange(nextValue)\n              }}\n              disabled={isPending || field.readOnly}\n              className=\"appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none\"\n            />\n          </Field>\n        )}\n      </div>\n\n      <FieldError errors={fieldErrors} />\n    </Field>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/additional-field.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/auth-form.tsx",
      "content": "\"use client\"\n\nimport {\n  type AdditionalField as AdditionalFieldConfig,\n  type AdditionalFieldFormValue,\n  DEFAULT_ADDITIONAL_FIELD_VALIDATION_DEBOUNCE_MS,\n  getFormFieldErrors,\n  normalizeAuthFormServerError,\n  validateAdditionalFieldRequired,\n  validateAdditionalFieldValue\n} from \"@better-auth-ui/core\"\nimport {\n  type AnyFormApi,\n  createFormHook,\n  createFormHookContexts\n} from \"@tanstack/react-form\"\nimport {\n  type ComponentProps,\n  type FormEvent,\n  type ReactNode,\n  useRef\n} from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Field,\n  FieldDescription,\n  FieldError,\n  FieldLabel\n} from \"@/components/ui/field\"\nimport { Input } from \"@/components/ui/input\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport { AdditionalField, type AdditionalFieldProps } from \"./additional-field\"\n\nconst { fieldContext, formContext, useFieldContext, useFormContext } =\n  createFormHookContexts()\n\nconst DEFAULT_AUTH_FORM_SERVER_ERROR = \"Unable to submit this form. Try again.\"\n\nexport function focusFirstInvalidAuthFormControl(form: HTMLFormElement) {\n  requestAnimationFrame(() => {\n    form\n      .querySelector<HTMLElement>(\n        '[aria-invalid=\"true\"]:not([disabled]), :invalid:not([disabled])'\n      )\n      ?.focus()\n  })\n}\n\nfunction AuthFormFieldError() {\n  const field = useFieldContext<unknown>()\n  const isInvalid = field.state.meta.isTouched && !field.state.meta.isValid\n\n  if (!isInvalid) return null\n\n  const errors = getFormFieldErrors(field.state.meta.errors)\n\n  return errors.length > 0 ? <FieldError errors={errors} /> : null\n}\n\nfunction AuthFormServerError() {\n  const form = useFormContext()\n\n  return (\n    <form.Subscribe selector={(state) => state.errorMap.onServer}>\n      {(error) => {\n        const formError =\n          error && typeof error === \"object\" && \"form\" in error\n            ? error.form\n            : error\n        const errors = getFormFieldErrors(formError ? [formError] : [])\n        return errors.length > 0 ? <FieldError errors={errors} /> : null\n      }}\n    </form.Subscribe>\n  )\n}\n\nexport function setAuthFormServerError(\n  form: AnyFormApi,\n  error: unknown,\n  fallbackMessage: string\n) {\n  const normalized = normalizeAuthFormServerError(error, fallbackMessage)\n  form.setErrorMap({\n    onServer: {\n      fields: normalized.fields ?? {},\n      form: normalized.form\n    }\n  })\n}\n\nexport function clearAuthFormServerError(form: AnyFormApi) {\n  form.setErrorMap({ onServer: { fields: {} } })\n}\n\nexport function clearAuthFormFieldServerError(\n  form: AnyFormApi,\n  fieldName: string\n) {\n  form.setErrorMap({ onServer: undefined })\n  if (!fieldName) return\n\n  const fieldMeta = form.getFieldMeta(fieldName as never)\n  if (!fieldMeta?.errorMap.onServer) return\n\n  form.setFieldMeta(fieldName as never, (current = fieldMeta) => ({\n    ...current,\n    errorMap: { ...current.errorMap, onServer: undefined },\n    errorSourceMap: { ...current.errorSourceMap, onServer: undefined }\n  }))\n}\n\nexport async function runAuthFormAction(\n  form: AnyFormApi,\n  action: () => Promise<unknown>,\n  serverErrorMessage = DEFAULT_AUTH_FORM_SERVER_ERROR\n) {\n  clearAuthFormServerError(form)\n  try {\n    await action()\n    return true\n  } catch (error) {\n    if (!form.state.errorMap.onServer) {\n      setAuthFormServerError(form, error, serverErrorMessage)\n    }\n    return false\n  }\n}\n\nexport async function submitAuthForm(\n  form: AnyFormApi,\n  serverErrorMessage = DEFAULT_AUTH_FORM_SERVER_ERROR\n) {\n  clearAuthFormServerError(form)\n  try {\n    await form.handleSubmit()\n    return form.state.isValid\n  } catch (error) {\n    if (!form.state.errorMap.onServer) {\n      setAuthFormServerError(form, error, serverErrorMessage)\n    }\n    return false\n  }\n}\n\ntype AuthFormRootProps = Omit<ComponentProps<\"form\">, \"onSubmit\"> & {\n  onBeforeSubmit?: () => void\n  serverErrorMessage?: string\n}\n\nfunction AuthFormRoot({\n  children,\n  onBeforeSubmit,\n  onInput,\n  serverErrorMessage = DEFAULT_AUTH_FORM_SERVER_ERROR,\n  ...props\n}: AuthFormRootProps) {\n  const form = useFormContext()\n  const submittingRef = useRef(false)\n\n  async function submit(event: FormEvent<HTMLFormElement>) {\n    event.preventDefault()\n    if (submittingRef.current || form.state.isSubmitting) return\n\n    const formElement = event.currentTarget\n    onBeforeSubmit?.()\n    submittingRef.current = true\n    try {\n      const isValid = await submitAuthForm(form, serverErrorMessage)\n      if (!isValid) focusFirstInvalidAuthFormControl(formElement)\n    } finally {\n      submittingRef.current = false\n    }\n  }\n\n  return (\n    <form\n      {...props}\n      onInvalid={(event) =>\n        focusFirstInvalidAuthFormControl(event.currentTarget)\n      }\n      onInput={(event) => {\n        const target = event.target\n        const fieldName =\n          target instanceof HTMLInputElement ||\n          target instanceof HTMLSelectElement ||\n          target instanceof HTMLTextAreaElement\n            ? target.name\n            : \"\"\n        clearAuthFormFieldServerError(form, fieldName)\n        onInput?.(event)\n      }}\n      onSubmit={submit}\n    >\n      {children}\n    </form>\n  )\n}\n\ntype AuthFormTextFieldProps = Omit<\n  ComponentProps<typeof Input>,\n  \"name\" | \"onBlur\" | \"onChange\" | \"value\"\n> & {\n  description?: ReactNode\n  label: ReactNode\n}\n\nfunction AuthFormTextField({\n  description,\n  id,\n  label,\n  ...props\n}: AuthFormTextFieldProps) {\n  const field = useFieldContext<string>()\n  const form = useFormContext()\n  const isInvalid = isAuthFormFieldInvalid(field.state.meta)\n  const inputId = id ?? field.name\n\n  return (\n    <Field data-invalid={isInvalid}>\n      <FieldLabel htmlFor={inputId}>{label}</FieldLabel>\n      <Input\n        {...props}\n        aria-busy={field.state.meta.isValidating || undefined}\n        aria-invalid={isInvalid}\n        id={inputId}\n        name={field.name}\n        onBlur={field.handleBlur}\n        onChange={(event) => {\n          clearAuthFormFieldServerError(form, field.name)\n          field.handleChange(event.target.value)\n        }}\n        value={field.state.value}\n      />\n      {description ? <FieldDescription>{description}</FieldDescription> : null}\n      <AuthFormFieldError />\n    </Field>\n  )\n}\n\nfunction AuthFormSubmitButton({\n  children,\n  disabled,\n  isPending,\n  ...props\n}: ComponentProps<typeof Button> & { isPending?: boolean }) {\n  const form = useFormContext()\n\n  return (\n    <form.Subscribe\n      selector={(state) => [state.isSubmitting, state.isValidating] as const}\n    >\n      {([isSubmitting, isValidating]) => (\n        <Button\n          {...props}\n          aria-busy={isPending || isSubmitting || undefined}\n          aria-disabled={\n            disabled || isPending || isSubmitting || isValidating || undefined\n          }\n          disabled={disabled || isPending || isSubmitting || isValidating}\n          type=\"submit\"\n        >\n          {isPending || isSubmitting ? (\n            <Spinner data-icon=\"inline-start\" />\n          ) : null}\n          {children}\n        </Button>\n      )}\n    </form.Subscribe>\n  )\n}\n\ntype AuthFormAdditionalFieldProps = Omit<\n  AdditionalFieldProps,\n  \"errors\" | \"isInvalid\" | \"name\" | \"onBlur\" | \"onChange\" | \"value\"\n>\n\nfunction AuthFormAdditionalField(props: AuthFormAdditionalFieldProps) {\n  const field = useFieldContext<AdditionalFieldFormValue>()\n  const form = useFormContext()\n  const isInvalid = isAuthFormFieldInvalid(field.state.meta)\n\n  return (\n    <AdditionalField\n      {...props}\n      errors={\n        isInvalid ? getFormFieldErrors(field.state.meta.errors) : undefined\n      }\n      isInvalid={isInvalid}\n      name={field.name}\n      onBlur={field.handleBlur}\n      onChange={(value) => {\n        clearAuthFormFieldServerError(form, field.name)\n        field.handleChange(value)\n      }}\n      value={field.state.value}\n    />\n  )\n}\n\nexport const {\n  useAppForm: useAuthForm,\n  withFieldGroup: withAuthFieldGroup,\n  withForm: withAuthForm\n} = createFormHook({\n  fieldComponents: {\n    AuthFormAdditionalField,\n    AuthFormFieldError,\n    AuthFormTextField\n  },\n  fieldContext,\n  formComponents: {\n    AuthFormRoot,\n    AuthFormServerError,\n    AuthFormSubmitButton\n  },\n  formContext\n})\n\nexport function isAuthFormFieldInvalid({\n  isTouched,\n  isValid\n}: {\n  isTouched: boolean\n  isValid: boolean\n}) {\n  return isTouched && !isValid\n}\n\nexport function getAuthAdditionalFieldValidators(\n  field: AdditionalFieldConfig,\n  requiredMessage: string\n) {\n  return {\n    onChange: ({ value }: { value: AdditionalFieldFormValue }) =>\n      validateAdditionalFieldRequired(field, value, requiredMessage),\n    onChangeAsync: field.validate\n      ? ({ value }: { value: AdditionalFieldFormValue }) =>\n          validateAdditionalFieldValue(field, value)\n      : undefined,\n    onChangeAsyncDebounceMs: field.validate\n      ? (field.validateDebounceMs ??\n        DEFAULT_ADDITIONAL_FIELD_VALIDATION_DEBOUNCE_MS)\n      : undefined\n  }\n}\n",
      "type": "registry:component",
      "target": "@components/auth/auth-form.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/last-login-method/last-used-badge.tsx",
      "content": "\"use client\"\n\nimport { useLastLoginMethod } from \"@better-auth-ui/react\"\n\nimport { Badge } from \"@/components/ui/badge\"\n\nexport type LastUsedBadgeProps = {\n  /** Login method IDs that should display the indicator. */\n  method: string | string[]\n  /** Use the shorter label in constrained layouts. */\n  compact?: boolean\n  /** Float the compact indicator over the top-right edge of its container. */\n  floating?: boolean\n}\n\n/**\n * Displays an indicator when one of the supplied method IDs matches Better\n * Auth's stored last login method.\n */\nexport function LastUsedBadge({\n  method,\n  compact,\n  floating\n}: LastUsedBadgeProps) {\n  const { method: lastLoginMethod, localization } = useLastLoginMethod()\n  const methods = Array.isArray(method) ? method : [method]\n\n  if (!lastLoginMethod || !methods.includes(lastLoginMethod)) return null\n\n  return (\n    <Badge\n      className={\n        floating\n          ? \"pointer-events-none absolute top-0 right-0 z-10 translate-x-1/4 -translate-y-1/2 shadow-sm\"\n          : undefined\n      }\n      variant=\"secondary\"\n    >\n      {compact || floating ? localization.lastUsedShort : localization.lastUsed}\n    </Badge>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/last-login-method/last-used-badge.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/otp-field.tsx",
      "content": "\"use client\"\n\nimport { REGEXP_ONLY_DIGITS } from \"input-otp\"\nimport { useId } from \"react\"\n\nimport { Field, FieldError, FieldLabel } from \"@/components/ui/field\"\nimport {\n  InputOTP,\n  InputOTPGroup,\n  InputOTPSlot\n} from \"@/components/ui/input-otp\"\nimport { cn } from \"cn\"\n\nexport type OtpFieldProps = {\n  /** Visible label rendered above the slots. */\n  label: string\n  /** Number of slots — keep in sync with the server's code length. */\n  length: number\n  value: string\n  onChange: (value: string) => void\n  onComplete?: (value: string) => void\n  autoFocus?: boolean\n  className?: string\n  errorMessage?: string\n  disabled?: boolean\n  name?: string\n}\n\n/** Strip everything the numeric slots can't hold — pasted codes often carry spaces or dashes. */\nfunction normalizeCode(value: string) {\n  return value.replace(/\\D/g, \"\")\n}\n\n/**\n * Labelled one-time-code input.\n *\n * Shared by every code-based flow (email OTP, two-factor challenge,\n * two-factor enrollment) so slot sizing, pasting, and error wiring behave the\n * same everywhere.\n *\n * @param label - Visible label, also used as the accessible name.\n * @param length - Number of code characters.\n * @param errorMessage - Rendered below the slots when set.\n */\nexport function OtpField({\n  autoFocus,\n  className,\n  disabled,\n  errorMessage,\n  label,\n  length,\n  name,\n  onChange,\n  onComplete,\n  value\n}: OtpFieldProps) {\n  const inputId = useId()\n\n  return (\n    <Field className={cn(className)} data-invalid={!!errorMessage}>\n      <FieldLabel htmlFor={inputId}>{label}</FieldLabel>\n\n      <InputOTP\n        aria-invalid={!!errorMessage}\n        aria-label={label}\n        autoComplete=\"one-time-code\"\n        autoFocus={autoFocus}\n        containerClassName=\"w-full justify-center\"\n        disabled={disabled}\n        id={inputId}\n        inputMode=\"numeric\"\n        maxLength={length}\n        name={name}\n        pasteTransformer={normalizeCode}\n        pattern={REGEXP_ONLY_DIGITS}\n        value={value}\n        onChange={(next) => onChange(normalizeCode(next))}\n        onComplete={(completedCode) =>\n          onComplete?.(normalizeCode(completedCode))\n        }\n      >\n        <InputOTPGroup>\n          {Array.from({ length }, (_, slotIndex) => (\n            <InputOTPSlot\n              index={slotIndex}\n              key={`otp-slot-${String(slotIndex + 1)}`}\n            />\n          ))}\n        </InputOTPGroup>\n      </InputOTP>\n\n      <FieldError>{errorMessage}</FieldError>\n    </Field>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/otp-field.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/password-strength-meter.tsx",
      "content": "\"use client\"\n\nimport {\n  evaluatePasswordStrength,\n  type PasswordStrengthLevel\n} from \"@better-auth-ui/core\"\nimport { useAuth } from \"@better-auth-ui/react\"\n\nimport { cn } from \"cn\"\n\n/** Fixed segment identities, so the bars keep their own React keys. */\nconst STRENGTH_SEGMENTS = [1, 2, 3, 4] as const\n\ntype FilledLevel = Exclude<PasswordStrengthLevel, \"empty\">\n\nconst segmentColors: Record<FilledLevel, string> = {\n  weak: \"bg-destructive\",\n  fair: \"bg-amber-500\",\n  good: \"bg-sky-500\",\n  strong: \"bg-emerald-500\"\n}\n\nexport type PasswordStrengthMeterProps = {\n  /** The password as typed. Renders nothing while it is empty. */\n  password: string\n  className?: string\n}\n\n/**\n * Four-segment strength hint shown while someone picks a new password.\n *\n * Renders nothing when `emailAndPassword.strengthMeter` is off or the field is\n * empty. The score never gates submission: your server rules stay the\n * authority on what is acceptable.\n */\nexport function PasswordStrengthMeter({\n  password,\n  className\n}: PasswordStrengthMeterProps) {\n  const { emailAndPassword, localization } = useAuth()\n\n  if (!emailAndPassword?.strengthMeter) return null\n\n  const { score, level } = evaluatePasswordStrength(password, {\n    minLength: emailAndPassword.minPasswordLength\n  })\n\n  if (level === \"empty\") return null\n\n  const levelLabels: Record<FilledLevel, string> = {\n    weak: localization.auth.passwordWeak,\n    fair: localization.auth.passwordFair,\n    good: localization.auth.passwordGood,\n    strong: localization.auth.passwordStrong\n  }\n\n  return (\n    <div className={cn(\"flex flex-col gap-1.5\", className)}>\n      {/* Decorative: the live region below is what gets announced. */}\n      <div aria-hidden=\"true\" className=\"flex gap-1\">\n        {STRENGTH_SEGMENTS.map((segment) => (\n          <span\n            key={segment}\n            className={cn(\n              \"h-1 flex-1 rounded-full bg-muted transition-colors\",\n              segment <= score && segmentColors[level]\n            )}\n          />\n        ))}\n      </div>\n\n      <p aria-live=\"polite\" className=\"text-muted-foreground text-xs\">\n        {localization.auth.passwordStrength}:{\" \"}\n        <span className=\"font-medium text-foreground\">\n          {levelLabels[level]}\n        </span>\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/password-strength-meter.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/change-phone-number.tsx",
      "content": "\"use client\"\n\nimport { getFormFieldErrorMessage } from \"@better-auth-ui/core\"\nimport {\n  createPhoneNumberValue,\n  type PhoneNumberAuthClient\n} from \"@better-auth-ui/core/plugins/phone-number\"\nimport {\n  useAuth,\n  useAuthPlugin,\n  useSession,\n  useUpdateUser\n} from \"@better-auth-ui/react\"\nimport {\n  useSendPhoneNumberOtp,\n  useVerifyPhoneNumber\n} from \"@better-auth-ui/react/plugins/phone-number\"\nimport { useSelector } from \"@tanstack/react-form\"\nimport { useEffect, useState } from \"react\"\nimport { toast } from \"sonner\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Card, CardContent, CardFooter } from \"@/components/ui/card\"\nimport { FieldDescription } from \"@/components/ui/field\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { phoneNumberPlugin } from \"@/lib/auth/phone-number-plugin\"\nimport { cn } from \"cn\"\nimport { useAuthForm } from \"../auth-form\"\nimport { OtpField } from \"../otp-field\"\nimport { InternationalPhoneField } from \"./international-phone-field\"\nimport { RemovePhoneNumberDialog } from \"./remove-phone-number-dialog\"\n\ntype PhoneNumberUser = {\n  phoneNumber?: string | null\n}\n\nexport type ChangePhoneNumberProps = {\n  className?: string\n}\n\n/** Add, replace, or remove the authenticated user's verified phone number. */\nexport function ChangePhoneNumber({ className }: ChangePhoneNumberProps) {\n  const { authClient } = useAuth()\n  const {\n    adapter,\n    countries,\n    defaultCountry,\n    locale,\n    localization,\n    otpLength\n  } = useAuthPlugin(phoneNumberPlugin)\n  const phoneClient = authClient as PhoneNumberAuthClient\n  const { data: session } = useSession(phoneClient)\n  const currentPhoneNumber =\n    (session?.user as PhoneNumberUser | undefined)?.phoneNumber ?? \"\"\n  const [codeSent, setCodeSent] = useState(false)\n\n  const { mutateAsync: sendOtp, isPending: isSending } = useSendPhoneNumberOtp(\n    phoneClient,\n    { onSuccess: () => setCodeSent(true) }\n  )\n  const { mutateAsync: verify, isPending: isVerifying } = useVerifyPhoneNumber(\n    phoneClient,\n    {\n      onError: () => form.setFieldValue(\"code\", \"\"),\n      onSuccess: () => {\n        form.setFieldValue(\"code\", \"\")\n        setCodeSent(false)\n        toast.success(localization.phoneNumberUpdated)\n      }\n    }\n  )\n  const { mutate: updateUser, isPending: isRemoving } = useUpdateUser(\n    phoneClient,\n    {\n      onSuccess: () => {\n        form.setFieldValue(\n          \"phoneNumber\",\n          createPhoneNumberValue(\"\", defaultCountry, adapter)\n        )\n        toast.success(localization.phoneNumberRemoved)\n      }\n    }\n  )\n  const isPending = isSending || isVerifying || isRemoving\n\n  const form = useAuthForm({\n    defaultValues: {\n      code: \"\",\n      phoneNumber: createPhoneNumberValue(\"\", defaultCountry, adapter)\n    },\n    onSubmit: async ({ value }) => {\n      if (!value.phoneNumber.e164) return\n      if (!codeSent) {\n        await sendOtp({ phoneNumber: value.phoneNumber.e164 })\n        return\n      }\n      await verify({\n        phoneNumber: value.phoneNumber.e164,\n        code: value.code,\n        updatePhoneNumber: true\n      })\n    }\n  })\n  const codeComplete = useSelector(\n    form.store,\n    (formState) => formState.values.code.length === otpLength\n  )\n  const phoneNumberDisplay = useSelector(\n    form.store,\n    (formState) => formState.values.phoneNumber.display\n  )\n\n  useEffect(() => {\n    if (session) {\n      form.setFieldValue(\n        \"phoneNumber\",\n        createPhoneNumberValue(currentPhoneNumber, defaultCountry, adapter)\n      )\n    }\n  }, [adapter, currentPhoneNumber, defaultCountry, form.setFieldValue, session])\n  const removePhoneNumber = () =>\n    updateUser({\n      phoneNumber: null\n    } as Parameters<PhoneNumberAuthClient[\"updateUser\"]>[0])\n\n  return (\n    <div>\n      <h2 className=\"mb-3 text-sm font-semibold\">\n        {localization.changePhoneNumber}\n      </h2>\n      <form.AppForm>\n        <form.AuthFormRoot>\n          <Card className={cn(className)}>\n            <CardContent className=\"flex flex-col gap-6\">\n              {codeSent ? (\n                <>\n                  <FieldDescription>\n                    {localization.codeSentTo.replace(\n                      \"{{phoneNumber}}\",\n                      phoneNumberDisplay\n                    )}\n                  </FieldDescription>\n                  <form.AppField name=\"code\">\n                    {(field) => (\n                      <OtpField\n                        autoFocus\n                        disabled={isPending}\n                        label={localization.phoneCode}\n                        length={otpLength}\n                        name=\"otp\"\n                        value={field.state.value}\n                        onChange={field.handleChange}\n                      />\n                    )}\n                  </form.AppField>\n                </>\n              ) : session ? (\n                <form.AppField\n                  name=\"phoneNumber\"\n                  validators={{\n                    onChange: ({ value }) =>\n                      value.e164 ? undefined : localization.invalidPhoneNumber\n                  }}\n                >\n                  {(field) => (\n                    <InternationalPhoneField\n                      adapter={adapter}\n                      countryCodes={countries}\n                      countryLabel={localization.country}\n                      disabled={isPending}\n                      error={getFormFieldErrorMessage(field.state.meta.errors)}\n                      locale={locale}\n                      phoneLabel={localization.phoneNumber}\n                      placeholder={localization.phoneNumberPlaceholder}\n                      value={field.state.value}\n                      onChange={field.handleChange}\n                    />\n                  )}\n                </form.AppField>\n              ) : (\n                <Skeleton className=\"h-14 w-full\" />\n              )}\n            </CardContent>\n            <CardFooter className=\"gap-3\">\n              {codeSent && (\n                <Button\n                  type=\"button\"\n                  size=\"sm\"\n                  variant=\"outline\"\n                  disabled={isPending}\n                  onClick={() => {\n                    form.setFieldValue(\"code\", \"\")\n                    setCodeSent(false)\n                    form.setFieldValue(\n                      \"phoneNumber\",\n                      createPhoneNumberValue(\n                        currentPhoneNumber,\n                        defaultCountry,\n                        adapter\n                      )\n                    )\n                  }}\n                >\n                  {localization.cancel}\n                </Button>\n              )}\n              <form.AuthFormSubmitButton\n                isPending={isSending || isVerifying}\n                size=\"sm\"\n                disabled={isPending || !session || (codeSent && !codeComplete)}\n              >\n                {codeSent\n                  ? localization.verifyCode\n                  : localization.updatePhoneNumber}\n              </form.AuthFormSubmitButton>\n              {!codeSent && currentPhoneNumber && (\n                <RemovePhoneNumberDialog\n                  cancelLabel={localization.cancel}\n                  description={localization.removePhoneNumberDescription}\n                  isPending={isRemoving}\n                  label={localization.removePhoneNumber}\n                  title={localization.removePhoneNumberTitle}\n                  onConfirm={removePhoneNumber}\n                />\n              )}\n            </CardFooter>\n          </Card>\n        </form.AuthFormRoot>\n      </form.AppForm>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/change-phone-number.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/forgot-phone-number-password.tsx",
      "content": "\"use client\"\n\nimport { getFormFieldErrorMessage } from \"@better-auth-ui/core\"\nimport {\n  createPhoneNumberValue,\n  type PhoneNumberAuthClient\n} from \"@better-auth-ui/core/plugins/phone-number\"\nimport { useAuth, useAuthPlugin, useFetchOptions } from \"@better-auth-ui/react\"\nimport { useRequestPhoneNumberPasswordReset } from \"@better-auth-ui/react/plugins/phone-number\"\n\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\"\nimport { FieldDescription, FieldGroup } from \"@/components/ui/field\"\nimport { phoneNumberPlugin } from \"@/lib/auth/phone-number-plugin\"\nimport { cn } from \"cn\"\nimport { useAuthForm } from \"../auth-form\"\nimport { InternationalPhoneField } from \"./international-phone-field\"\n\nexport const PHONE_NUMBER_RESET_STORAGE_KEY =\n  \"better-auth-ui.phone-number-reset\"\n\nexport type ForgotPhoneNumberPasswordProps = {\n  className?: string\n}\n\n/** Request the verification code used to reset a phone credential password. */\nexport function ForgotPhoneNumberPassword({\n  className\n}: ForgotPhoneNumberPasswordProps) {\n  const { authClient, basePaths, localization, navigate, plugins, Link } =\n    useAuth()\n  const {\n    adapter,\n    countries,\n    defaultCountry,\n    locale,\n    localization: phoneLocalization,\n    viewPaths: phoneNumberViewPaths\n  } = useAuthPlugin(phoneNumberPlugin)\n  const { fetchOptions, resetFetchOptions } = useFetchOptions()\n  const { mutateAsync: requestReset, isPending } =\n    useRequestPhoneNumberPasswordReset(authClient as PhoneNumberAuthClient, {\n      onError: () => resetFetchOptions(),\n      onSuccess: (_data, { phoneNumber }) => {\n        sessionStorage.setItem(PHONE_NUMBER_RESET_STORAGE_KEY, phoneNumber)\n        navigate({\n          to: `${basePaths.auth}/${phoneNumberViewPaths.auth.phoneNumberResetPassword}`\n        })\n      }\n    })\n  const Captcha = plugins.find(\n    (plugin) => plugin.captchaComponent\n  )?.captchaComponent\n\n  const form = useAuthForm({\n    defaultValues: {\n      phoneNumber: createPhoneNumberValue(\"\", defaultCountry, adapter)\n    },\n    onSubmit: async ({ value }) => {\n      if (!value.phoneNumber.e164) return\n      await requestReset({ phoneNumber: value.phoneNumber.e164, fetchOptions })\n    }\n  })\n\n  return (\n    <Card className={cn(\"w-full max-w-sm\", className)}>\n      <CardHeader>\n        <CardTitle className=\"text-xl\">\n          {phoneLocalization.forgotPassword}\n        </CardTitle>\n      </CardHeader>\n      <CardContent>\n        <form.AppForm>\n          <form.AuthFormRoot>\n            <FieldGroup>\n              <form.AppField\n                name=\"phoneNumber\"\n                validators={{\n                  onChange: ({ value }) =>\n                    value.e164\n                      ? undefined\n                      : phoneLocalization.invalidPhoneNumber\n                }}\n              >\n                {(field) => (\n                  <InternationalPhoneField\n                    adapter={adapter}\n                    countryCodes={countries}\n                    countryLabel={phoneLocalization.country}\n                    disabled={isPending}\n                    error={getFormFieldErrorMessage(field.state.meta.errors)}\n                    locale={locale}\n                    phoneLabel={phoneLocalization.phoneNumber}\n                    placeholder={phoneLocalization.phoneNumberPlaceholder}\n                    value={field.state.value}\n                    onChange={field.handleChange}\n                  />\n                )}\n              </form.AppField>\n              {Captcha && <div className=\"flex justify-center\">{Captcha}</div>}\n              <form.AuthFormSubmitButton\n                isPending={isPending}\n                disabled={isPending}\n              >\n                {phoneLocalization.sendCode}\n              </form.AuthFormSubmitButton>\n            </FieldGroup>\n          </form.AuthFormRoot>\n        </form.AppForm>\n        <FieldDescription className=\"mt-4 text-center\">\n          {localization.auth.rememberYourPassword}{\" \"}\n          <Link\n            href={`${basePaths.auth}/${phoneNumberViewPaths.auth.phoneNumber}`}\n            className=\"underline underline-offset-4\"\n          >\n            {localization.auth.signIn}\n          </Link>\n        </FieldDescription>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/forgot-phone-number-password.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/international-phone-field.tsx",
      "content": "\"use client\"\n\nimport {\n  createPhoneNumberValue,\n  getPhoneNumberCountries,\n  type PhoneNumberAdapter,\n  type PhoneNumberCountryCode,\n  type PhoneNumberValue\n} from \"@better-auth-ui/core/plugins/phone-number\"\nimport { useId, useMemo } from \"react\"\n\nimport { Field, FieldError, FieldLabel } from \"@/components/ui/field\"\nimport { Input } from \"@/components/ui/input\"\nimport {\n  Select,\n  SelectContent,\n  SelectGroup,\n  SelectItem,\n  SelectTrigger,\n  SelectValue\n} from \"@/components/ui/select\"\n\ntype InternationalPhoneFieldProps = {\n  adapter: PhoneNumberAdapter\n  countryLabel: string\n  countryCodes?: readonly PhoneNumberCountryCode[]\n  disabled?: boolean\n  error?: string\n  locale?: string\n  name?: string\n  phoneLabel: string\n  placeholder: string\n  value: PhoneNumberValue\n  onChange: (value: PhoneNumberValue) => void\n}\n\nexport function InternationalPhoneField({\n  adapter,\n  countryLabel,\n  countryCodes,\n  disabled,\n  error,\n  locale,\n  name = \"phoneNumber\",\n  phoneLabel,\n  placeholder,\n  value,\n  onChange\n}: InternationalPhoneFieldProps) {\n  const id = useId()\n  const countries = useMemo(\n    () => getPhoneNumberCountries(locale, countryCodes),\n    [countryCodes, locale]\n  )\n  const selectedCountry = countries.find(\n    (country) => country.code === value.country\n  )\n\n  return (\n    <div className=\"grid grid-cols-[8.5rem_minmax(0,1fr)] gap-2\">\n      <Field>\n        <FieldLabel htmlFor={`${id}-country`}>{countryLabel}</FieldLabel>\n        <Select\n          disabled={disabled}\n          value={value.country}\n          onValueChange={(country) => {\n            const nextCountry = country as PhoneNumberCountryCode\n            const input = value.display.startsWith(\"+\") ? \"\" : value.display\n            onChange(createPhoneNumberValue(input, nextCountry, adapter))\n          }}\n        >\n          <SelectTrigger id={`${id}-country`} className=\"w-full\">\n            <SelectValue>\n              {selectedCountry ? (\n                <span className=\"flex items-center gap-2\">\n                  <span aria-hidden=\"true\">{selectedCountry.flag}</span>\n                  <span>{selectedCountry.callingCode}</span>\n                </span>\n              ) : null}\n            </SelectValue>\n          </SelectTrigger>\n          <SelectContent>\n            <SelectGroup>\n              {countries.map((country) => (\n                <SelectItem key={country.code} value={country.code}>\n                  <span className=\"flex w-full items-center justify-between gap-4\">\n                    <span className=\"flex min-w-0 items-center gap-2\">\n                      <span aria-hidden=\"true\">{country.flag}</span>\n                      <span>{country.label}</span>\n                    </span>\n                    <span className=\"text-muted-foreground\">\n                      {country.callingCode}\n                    </span>\n                  </span>\n                </SelectItem>\n              ))}\n            </SelectGroup>\n          </SelectContent>\n        </Select>\n      </Field>\n      <Field data-invalid={Boolean(error)}>\n        <FieldLabel htmlFor={`${id}-number`}>{phoneLabel}</FieldLabel>\n        <Input\n          id={`${id}-number`}\n          aria-invalid={Boolean(error)}\n          autoComplete=\"tel-national\"\n          disabled={disabled}\n          inputMode=\"tel\"\n          name={name}\n          placeholder={placeholder}\n          required\n          type=\"tel\"\n          value={value.display}\n          onChange={(event) =>\n            onChange(\n              createPhoneNumberValue(event.target.value, value.country, adapter)\n            )\n          }\n        />\n        <FieldError>{error}</FieldError>\n      </Field>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/international-phone-field.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/phone-number-button.tsx",
      "content": "\"use client\"\n\nimport { type AuthView, authMutationKeys } from \"@better-auth-ui/core\"\nimport { useAuth, useAuthPlugin } from \"@better-auth-ui/react\"\nimport { useIsMutating } from \"@tanstack/react-query\"\nimport { Lock, Smartphone } from \"lucide-react\"\n\nimport { buttonVariants } from \"@/components/ui/button\"\nimport { phoneNumberPlugin } from \"@/lib/auth/phone-number-plugin\"\nimport { cn } from \"cn\"\n\nexport type PhoneNumberButtonProps = {\n  /** @remarks `AuthView` */\n  view?: AuthView\n}\n\n/** Switch between the configured phone-number view and password sign-in. */\nexport function PhoneNumberButton({ view }: PhoneNumberButtonProps) {\n  const { basePaths, emailAndPassword, localization, viewPaths, Link } =\n    useAuth()\n  const { localization: phoneLocalization, viewPaths: phoneNumberViewPaths } =\n    useAuthPlugin(phoneNumberPlugin)\n  const isPhoneNumberView = view === \"phoneNumber\"\n  const isPending =\n    useIsMutating({ mutationKey: authMutationKeys.signIn.all }) +\n      useIsMutating({ mutationKey: authMutationKeys.signUp.all }) >\n    0\n\n  if (isPhoneNumberView && !emailAndPassword?.enabled) return null\n\n  return (\n    <Link\n      href={`${basePaths.auth}/${\n        isPhoneNumberView\n          ? viewPaths.auth.signIn\n          : phoneNumberViewPaths.auth.phoneNumber\n      }`}\n      aria-disabled={isPending || undefined}\n      tabIndex={isPending ? -1 : undefined}\n      onClick={(event) => {\n        if (isPending) event.preventDefault()\n      }}\n      className={cn(\n        buttonVariants({ variant: \"outline\" }),\n        \"w-full\",\n        isPending && \"pointer-events-none opacity-50\"\n      )}\n    >\n      {isPhoneNumberView ? (\n        <Lock data-icon=\"inline-start\" />\n      ) : (\n        <Smartphone data-icon=\"inline-start\" />\n      )}\n\n      {localization.auth.continueWith.replace(\n        \"{{provider}}\",\n        isPhoneNumberView\n          ? localization.auth.password\n          : phoneLocalization.phoneNumber\n      )}\n    </Link>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/phone-number-button.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/phone-number.tsx",
      "content": "\"use client\"\n\nimport {\n  authMutationKeys,\n  getFormFieldErrorMessage\n} from \"@better-auth-ui/core\"\nimport {\n  createPhoneNumberValue,\n  type PhoneNumberAuthClient\n} from \"@better-auth-ui/core/plugins/phone-number\"\nimport {\n  AuthPrompts,\n  useAuth,\n  useAuthPlugin,\n  useFetchOptions\n} from \"@better-auth-ui/react\"\nimport {\n  useSendPhoneNumberOtp,\n  useSignInPhoneNumber,\n  useVerifyPhoneNumber\n} from \"@better-auth-ui/react/plugins/phone-number\"\nimport { useSelector } from \"@tanstack/react-form\"\nimport { useIsMutating } from \"@tanstack/react-query\"\nimport { Eye, EyeOff } from \"lucide-react\"\nimport { useState } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle\n} from \"@/components/ui/card\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport {\n  Field,\n  FieldDescription,\n  FieldGroup,\n  FieldLabel,\n  FieldSeparator\n} from \"@/components/ui/field\"\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupButton,\n  InputGroupInput\n} from \"@/components/ui/input-group\"\nimport { phoneNumberPlugin } from \"@/lib/auth/phone-number-plugin\"\nimport { useResendCooldown } from \"@/lib/auth/use-resend-cooldown\"\nimport { useSignInContinuation } from \"@/lib/auth/use-sign-in-continuation\"\nimport { cn } from \"cn\"\nimport { runAuthFormAction, submitAuthForm, useAuthForm } from \"../auth-form\"\nimport { OtpField } from \"../otp-field\"\nimport { ProviderButtons, type SocialLayout } from \"../provider-buttons\"\nimport { ReauthenticationNotice } from \"../reauthentication\"\nimport { InternationalPhoneField } from \"./international-phone-field\"\n\ntype PhoneNumberMode = \"code\" | \"password\"\n\nexport type PhoneNumberProps = {\n  className?: string\n  socialLayout?: SocialLayout\n  socialPosition?: \"top\" | \"bottom\"\n}\n\n/** Sign in with either a phone verification code or a phone and password. */\nexport function PhoneNumber({\n  className,\n  socialLayout,\n  socialPosition = \"bottom\"\n}: PhoneNumberProps) {\n  const {\n    authClient,\n    basePaths,\n    emailAndPassword,\n    localization,\n    plugins,\n    socialProviders,\n    viewPaths,\n    Link\n  } = useAuth()\n  const {\n    adapter,\n    countries,\n    defaultCountry,\n    locale,\n    localization: phoneLocalization,\n    otpLength,\n    passwordReset,\n    passwordSignIn,\n    signIn,\n    viewPaths: phoneNumberViewPaths\n  } = useAuthPlugin(phoneNumberPlugin)\n  const phoneClient = authClient as PhoneNumberAuthClient\n  const { fetchOptions, resetFetchOptions } = useFetchOptions()\n  const continueSignIn = useSignInContinuation()\n  const { cooldown, isCoolingDown, startCooldown } = useResendCooldown()\n  const [mode, setMode] = useState<PhoneNumberMode>(\n    signIn ? \"code\" : \"password\"\n  )\n  const [codeSent, setCodeSent] = useState(false)\n  const [isPasswordVisible, setIsPasswordVisible] = useState(false)\n\n  const { mutateAsync: sendOtp, isPending: isSending } = useSendPhoneNumberOtp(\n    phoneClient,\n    {\n      onError: () => resetFetchOptions(),\n      onSuccess: () => {\n        setCodeSent(true)\n        startCooldown()\n      }\n    }\n  )\n  const { mutateAsync: verify, isPending: isVerifying } = useVerifyPhoneNumber(\n    phoneClient,\n    {\n      onError: () => form.setFieldValue(\"code\", \"\"),\n      onSuccess: (data) => continueSignIn(data)\n    }\n  )\n  const { mutateAsync: signInWithPassword, isPending: isPasswordPending } =\n    useSignInPhoneNumber(phoneClient, {\n      onError: (error) => {\n        form.setFieldValue(\"password\", \"\")\n        resetFetchOptions()\n\n        if (signIn && error.error?.code === \"PHONE_NUMBER_NOT_VERIFIED\") {\n          setMode(\"code\")\n          setCodeSent(true)\n          startCooldown()\n        }\n      },\n      onSuccess: (data) => continueSignIn(data)\n    })\n\n  const signInMutating = useIsMutating({\n    mutationKey: authMutationKeys.signIn.all\n  })\n  const signUpMutating = useIsMutating({\n    mutationKey: authMutationKeys.signUp.all\n  })\n  const isPending =\n    signInMutating + signUpMutating > 0 || isSending || isVerifying\n  const canSwitchMode = signIn && passwordSignIn\n  const showProviders = !codeSent && Boolean(socialProviders?.length)\n  const showSeparator =\n    !codeSent &&\n    Boolean(\n      socialProviders?.length &&\n      (emailAndPassword?.enabled || signIn || passwordSignIn)\n    )\n  const Captcha = plugins.find(\n    (plugin) => plugin.captchaComponent\n  )?.captchaComponent\n\n  const sendCode = async () => {\n    const normalizedPhoneNumber = form.state.values.phoneNumber.e164\n    if (!normalizedPhoneNumber) return\n    await sendOtp({\n      phoneNumber: normalizedPhoneNumber,\n      fetchOptions\n    } as Parameters<typeof sendOtp>[0])\n  }\n  const verifyCode = async (completedCode: string) => {\n    if (isPending || completedCode.length !== otpLength) return\n\n    if (!form.state.values.phoneNumber.e164) return\n    await verify({\n      phoneNumber: form.state.values.phoneNumber.e164,\n      code: completedCode\n    })\n  }\n  const switchMode = () => {\n    setMode((current) => (current === \"code\" ? \"password\" : \"code\"))\n    form.setFieldValue(\"code\", \"\")\n    setCodeSent(false)\n    form.setFieldValue(\"password\", \"\")\n  }\n\n  const form = useAuthForm({\n    defaultValues: {\n      code: \"\",\n      password: \"\",\n      phoneNumber: createPhoneNumberValue(\"\", defaultCountry, adapter),\n      rememberMe: false\n    },\n    onSubmit: async ({ value }) => {\n      if (mode === \"password\") {\n        const normalizedPhoneNumber = value.phoneNumber.e164\n        if (!normalizedPhoneNumber) return\n        await signInWithPassword({\n          phoneNumber: normalizedPhoneNumber,\n          password: value.password,\n          ...(emailAndPassword?.rememberMe\n            ? { rememberMe: value.rememberMe }\n            : {}),\n          fetchOptions\n        })\n        return\n      }\n\n      if (!codeSent) {\n        await sendCode()\n        return\n      }\n\n      await verifyCode(value.code)\n    }\n  })\n  const codeComplete = useSelector(\n    form.store,\n    (state) => state.values.code.length === otpLength\n  )\n  const phoneNumberDisplay = useSelector(\n    form.store,\n    (state) => state.values.phoneNumber.display\n  )\n\n  return (\n    <Card className={cn(\"w-full max-w-sm\", className)}>\n      <AuthPrompts view=\"phoneNumber\" />\n      <ReauthenticationNotice />\n      <CardHeader>\n        <CardTitle className=\"text-xl font-semibold\">\n          {localization.auth.signIn}\n        </CardTitle>\n\n        {codeSent && (\n          <CardDescription>\n            {phoneLocalization.codeSentTo.replace(\n              \"{{phoneNumber}}\",\n              phoneNumberDisplay\n            )}\n          </CardDescription>\n        )}\n      </CardHeader>\n\n      <CardContent>\n        <div className=\"flex flex-col gap-6\">\n          {socialPosition === \"top\" && showProviders && (\n            <>\n              <ProviderButtons socialLayout={socialLayout} view=\"phoneNumber\" />\n              {showSeparator && (\n                <FieldSeparator className=\"m-0 flex items-center text-xs *:data-[slot=field-separator-content]:bg-card\">\n                  {localization.auth.or}\n                </FieldSeparator>\n              )}\n            </>\n          )}\n\n          <form.AppForm>\n            <form.AuthFormRoot>\n              <FieldGroup>\n                {codeSent ? (\n                  <form.AppField name=\"code\">\n                    {(field) => (\n                      <OtpField\n                        autoFocus\n                        disabled={isPending}\n                        label={phoneLocalization.phoneCode}\n                        length={otpLength}\n                        name=\"otp\"\n                        value={field.state.value}\n                        onChange={field.handleChange}\n                        onComplete={() => void submitAuthForm(form)}\n                      />\n                    )}\n                  </form.AppField>\n                ) : (\n                  <>\n                    <form.AppField\n                      name=\"phoneNumber\"\n                      validators={{\n                        onChange: ({ value }) =>\n                          value.e164\n                            ? undefined\n                            : phoneLocalization.invalidPhoneNumber\n                      }}\n                    >\n                      {(field) => (\n                        <InternationalPhoneField\n                          adapter={adapter}\n                          countryCodes={countries}\n                          countryLabel={phoneLocalization.country}\n                          disabled={isPending}\n                          error={getFormFieldErrorMessage(\n                            field.state.meta.errors\n                          )}\n                          locale={locale}\n                          phoneLabel={phoneLocalization.phoneNumber}\n                          placeholder={phoneLocalization.phoneNumberPlaceholder}\n                          value={field.state.value}\n                          onChange={field.handleChange}\n                        />\n                      )}\n                    </form.AppField>\n\n                    {mode === \"password\" && (\n                      <form.AppField name=\"password\">\n                        {(field) => (\n                          <Field>\n                            <FieldLabel htmlFor=\"phoneNumberPassword\">\n                              {localization.auth.password}\n                            </FieldLabel>\n                            <InputGroup>\n                              <InputGroupInput\n                                id=\"phoneNumberPassword\"\n                                name={field.name}\n                                type={isPasswordVisible ? \"text\" : \"password\"}\n                                autoComplete=\"current-password\"\n                                value={field.state.value}\n                                placeholder={\n                                  localization.auth.passwordPlaceholder\n                                }\n                                required\n                                minLength={emailAndPassword?.minPasswordLength}\n                                maxLength={emailAndPassword?.maxPasswordLength}\n                                disabled={isPending}\n                                onBlur={field.handleBlur}\n                                onChange={(event) =>\n                                  field.handleChange(event.target.value)\n                                }\n                              />\n                              <InputGroupAddon align=\"inline-end\">\n                                <InputGroupButton\n                                  type=\"button\"\n                                  size=\"icon-xs\"\n                                  aria-label={\n                                    isPasswordVisible\n                                      ? localization.auth.hidePassword\n                                      : localization.auth.showPassword\n                                  }\n                                  title={\n                                    isPasswordVisible\n                                      ? localization.auth.hidePassword\n                                      : localization.auth.showPassword\n                                  }\n                                  onClick={() =>\n                                    setIsPasswordVisible((visible) => !visible)\n                                  }\n                                >\n                                  {isPasswordVisible ? <EyeOff /> : <Eye />}\n                                </InputGroupButton>\n                              </InputGroupAddon>\n                            </InputGroup>\n                            <field.AuthFormFieldError />\n                          </Field>\n                        )}\n                      </form.AppField>\n                    )}\n\n                    {mode === \"password\" && emailAndPassword?.rememberMe && (\n                      <form.AppField name=\"rememberMe\">\n                        {(field) => (\n                          <Field orientation=\"horizontal\">\n                            <Checkbox\n                              id=\"phoneNumberRememberMe\"\n                              name={field.name}\n                              disabled={isPending}\n                              checked={field.state.value}\n                              onCheckedChange={(checked) =>\n                                field.handleChange(checked === true)\n                              }\n                            />\n                            <FieldLabel\n                              htmlFor=\"phoneNumberRememberMe\"\n                              className=\"cursor-pointer font-normal\"\n                            >\n                              {localization.auth.rememberMe}\n                            </FieldLabel>\n                          </Field>\n                        )}\n                      </form.AppField>\n                    )}\n\n                    {Captcha && (\n                      <div className=\"flex justify-center\">{Captcha}</div>\n                    )}\n                  </>\n                )}\n\n                <form.AuthFormServerError />\n\n                <div className=\"flex flex-col gap-3\">\n                  <form.AuthFormSubmitButton\n                    isPending={isSending || isVerifying || isPasswordPending}\n                    disabled={isPending || (codeSent && !codeComplete)}\n                  >\n                    {mode === \"password\"\n                      ? localization.auth.signIn\n                      : codeSent\n                        ? phoneLocalization.verifyCode\n                        : phoneLocalization.sendCode}\n                  </form.AuthFormSubmitButton>\n\n                  {codeSent ? (\n                    <>\n                      <Button\n                        type=\"button\"\n                        variant=\"outline\"\n                        disabled={isPending || isCoolingDown}\n                        onClick={() => void runAuthFormAction(form, sendCode)}\n                      >\n                        {isCoolingDown\n                          ? localization.auth.resendIn.replace(\n                              \"{{seconds}}\",\n                              String(cooldown)\n                            )\n                          : localization.auth.resend}\n                      </Button>\n                      <Button\n                        type=\"button\"\n                        variant=\"ghost\"\n                        disabled={isPending}\n                        onClick={() => {\n                          form.setFieldValue(\"code\", \"\")\n                          setCodeSent(false)\n                        }}\n                      >\n                        {phoneLocalization.useDifferentPhoneNumber}\n                      </Button>\n                    </>\n                  ) : (\n                    <>\n                      {canSwitchMode && (\n                        <Button\n                          type=\"button\"\n                          variant=\"outline\"\n                          disabled={isPending}\n                          onClick={switchMode}\n                        >\n                          {mode === \"code\"\n                            ? phoneLocalization.usePassword\n                            : phoneLocalization.useVerificationCode}\n                        </Button>\n                      )}\n                      {plugins.flatMap((plugin) =>\n                        (plugin.authButtons ?? []).map((AuthButton) => (\n                          <AuthButton\n                            key={`${plugin.id}-${AuthButton.displayName ?? AuthButton.name}`}\n                            view=\"phoneNumber\"\n                          />\n                        ))\n                      )}\n                    </>\n                  )}\n                </div>\n              </FieldGroup>\n            </form.AuthFormRoot>\n          </form.AppForm>\n\n          {socialPosition === \"bottom\" && showProviders && (\n            <>\n              {showSeparator && (\n                <FieldSeparator className=\"flex items-center text-xs *:data-[slot=field-separator-content]:bg-card\">\n                  {localization.auth.or}\n                </FieldSeparator>\n              )}\n              <ProviderButtons socialLayout={socialLayout} view=\"phoneNumber\" />\n            </>\n          )}\n        </div>\n\n        <div className=\"mt-4 flex w-full flex-col items-center gap-3\">\n          {mode === \"password\" && passwordReset && (\n            <Link\n              href={`${basePaths.auth}/${phoneNumberViewPaths.auth.phoneNumberForgotPassword}`}\n              className=\"text-sm underline-offset-4 hover:underline\"\n            >\n              {phoneLocalization.forgotPassword}\n            </Link>\n          )}\n          {emailAndPassword?.enabled && (\n            <FieldDescription className=\"text-center\">\n              {localization.auth.needToCreateAnAccount}{\" \"}\n              <Link\n                href={`${basePaths.auth}/${viewPaths.auth.signUp}`}\n                className=\"underline underline-offset-4\"\n              >\n                {localization.auth.signUp}\n              </Link>\n            </FieldDescription>\n          )}\n        </div>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/phone-number.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/remove-phone-number-dialog.tsx",
      "content": "\"use client\"\n\nimport {\n  AlertDialog,\n  AlertDialogAction,\n  AlertDialogCancel,\n  AlertDialogContent,\n  AlertDialogDescription,\n  AlertDialogFooter,\n  AlertDialogHeader,\n  AlertDialogTitle,\n  AlertDialogTrigger\n} from \"@/components/ui/alert-dialog\"\nimport { Button } from \"@/components/ui/button\"\nimport { Spinner } from \"@/components/ui/spinner\"\n\nexport type RemovePhoneNumberDialogProps = {\n  description: string\n  isPending: boolean\n  label: string\n  title: string\n  cancelLabel: string\n  onConfirm: () => void\n}\n\n/** Confirm removal because it can disable a sign-in and recovery method. */\nexport function RemovePhoneNumberDialog({\n  cancelLabel,\n  description,\n  isPending,\n  label,\n  onConfirm,\n  title\n}: RemovePhoneNumberDialogProps) {\n  return (\n    <AlertDialog>\n      <AlertDialogTrigger asChild>\n        <Button type=\"button\" size=\"sm\" variant=\"outline\" disabled={isPending}>\n          {label}\n        </Button>\n      </AlertDialogTrigger>\n      <AlertDialogContent>\n        <AlertDialogHeader>\n          <AlertDialogTitle>{title}</AlertDialogTitle>\n          <AlertDialogDescription>{description}</AlertDialogDescription>\n        </AlertDialogHeader>\n        <AlertDialogFooter>\n          <AlertDialogCancel disabled={isPending}>\n            {cancelLabel}\n          </AlertDialogCancel>\n          <AlertDialogAction\n            variant=\"destructive\"\n            disabled={isPending}\n            onClick={onConfirm}\n          >\n            {isPending && <Spinner />}\n            {label}\n          </AlertDialogAction>\n        </AlertDialogFooter>\n      </AlertDialogContent>\n    </AlertDialog>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/remove-phone-number-dialog.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/phone-number/reset-phone-number-password.tsx",
      "content": "\"use client\"\n\nimport {\n  isPasswordCompromisedError,\n  validateMatchingValue,\n  validateStringLength\n} from \"@better-auth-ui/core\"\nimport type { PhoneNumberAuthClient } from \"@better-auth-ui/core/plugins/phone-number\"\nimport { useAuth, useAuthPlugin } from \"@better-auth-ui/react\"\nimport { useResetPhoneNumberPassword } from \"@better-auth-ui/react/plugins/phone-number\"\nimport { useSelector } from \"@tanstack/react-form\"\nimport { Eye, EyeOff } from \"lucide-react\"\nimport { useEffect, useState } from \"react\"\nimport { toast } from \"sonner\"\n\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle\n} from \"@/components/ui/card\"\nimport { Field, FieldGroup, FieldLabel } from \"@/components/ui/field\"\nimport { Input } from \"@/components/ui/input\"\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupButton,\n  InputGroupInput\n} from \"@/components/ui/input-group\"\nimport { phoneNumberPlugin } from \"@/lib/auth/phone-number-plugin\"\nimport { cn } from \"cn\"\nimport {\n  isAuthFormFieldInvalid,\n  setAuthFormServerError,\n  useAuthForm\n} from \"../auth-form\"\nimport { OtpField } from \"../otp-field\"\nimport { PasswordStrengthMeter } from \"../password-strength-meter\"\nimport { useIsHydrated } from \"../use-is-hydrated\"\nimport { PHONE_NUMBER_RESET_STORAGE_KEY } from \"./forgot-phone-number-password\"\n\nexport type ResetPhoneNumberPasswordProps = {\n  className?: string\n}\n\n/** Reset a phone credential password with the code sent to the user. */\nexport function ResetPhoneNumberPassword({\n  className\n}: ResetPhoneNumberPasswordProps) {\n  const { authClient, basePaths, emailAndPassword, localization, navigate } =\n    useAuth()\n  const {\n    localization: phoneLocalization,\n    otpLength,\n    viewPaths: phoneNumberViewPaths\n  } = useAuthPlugin(phoneNumberPlugin)\n  const isHydrated = useIsHydrated()\n  const initialPhoneNumber =\n    (isHydrated && sessionStorage.getItem(PHONE_NUMBER_RESET_STORAGE_KEY)) || \"\"\n  const [hasStoredPhoneNumber, setHasStoredPhoneNumber] = useState(\n    Boolean(initialPhoneNumber)\n  )\n  const [isPasswordVisible, setIsPasswordVisible] = useState(false)\n\n  const { mutateAsync: resetPassword, isPending } = useResetPhoneNumberPassword(\n    authClient as PhoneNumberAuthClient,\n    {\n      onError: (error) => {\n        // The haveIBeenPwned plugin rejects on the password itself, so it\n        // belongs against the field rather than in a toast.\n        if (isPasswordCompromisedError(error)) {\n          setAuthFormServerError(\n            form,\n            { fields: { password: localization.auth.passwordCompromised } },\n            localization.auth.passwordCompromised\n          )\n        }\n\n        form.setFieldValue(\"code\", \"\")\n      },\n      onSuccess: () => {\n        sessionStorage.removeItem(PHONE_NUMBER_RESET_STORAGE_KEY)\n        toast.success(localization.auth.passwordResetSuccess)\n        navigate({\n          to: `${basePaths.auth}/${phoneNumberViewPaths.auth.phoneNumber}`\n        })\n      }\n    }\n  )\n\n  const validatePassword = (value: string) =>\n    validateStringLength(value, {\n      maxLength: emailAndPassword?.maxPasswordLength,\n      maxLengthMessage: localization.auth.tooLong.replace(\n        \"{{max}}\",\n        String(emailAndPassword?.maxPasswordLength)\n      ),\n      minLength: emailAndPassword?.minPasswordLength,\n      minLengthMessage: localization.auth.tooShort.replace(\n        \"{{min}}\",\n        String(emailAndPassword?.minPasswordLength)\n      ),\n      requiredMessage: localization.auth.fieldRequired\n    })\n\n  const form = useAuthForm({\n    defaultValues: {\n      code: \"\",\n      confirmPassword: \"\",\n      password: \"\",\n      phoneNumber: initialPhoneNumber\n    },\n    onSubmit: async ({ value }) => {\n      await resetPassword({\n        phoneNumber: value.phoneNumber,\n        otp: value.code,\n        newPassword: value.password\n      })\n    }\n  })\n  const phoneNumber = useSelector(\n    form.store,\n    (formState) => formState.values.phoneNumber\n  )\n\n  useEffect(() => {\n    const stored = sessionStorage.getItem(PHONE_NUMBER_RESET_STORAGE_KEY) ?? \"\"\n    form.setFieldValue(\"phoneNumber\", stored)\n    setHasStoredPhoneNumber(Boolean(stored))\n  }, [form.setFieldValue])\n\n  return (\n    <Card className={cn(\"w-full max-w-sm\", className)}>\n      <CardHeader>\n        <CardTitle className=\"text-xl\">\n          {phoneLocalization.resetPassword}\n        </CardTitle>\n        {hasStoredPhoneNumber && (\n          <CardDescription>\n            {phoneLocalization.codeSentTo.replace(\n              \"{{phoneNumber}}\",\n              phoneNumber\n            )}\n          </CardDescription>\n        )}\n      </CardHeader>\n      <CardContent>\n        <form.AppForm>\n          <form.AuthFormRoot>\n            <FieldGroup>\n              {!hasStoredPhoneNumber && (\n                <form.AppField\n                  name=\"phoneNumber\"\n                  validators={{\n                    onChange: ({ value }) =>\n                      value.trim() ? undefined : localization.auth.fieldRequired\n                  }}\n                >\n                  {(field) => (\n                    <Field\n                      data-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                    >\n                      <FieldLabel htmlFor=\"passwordResetPhoneNumber\">\n                        {phoneLocalization.phoneNumber}\n                      </FieldLabel>\n                      <Input\n                        id=\"passwordResetPhoneNumber\"\n                        name={field.name}\n                        type=\"tel\"\n                        autoComplete=\"tel\"\n                        inputMode=\"tel\"\n                        value={field.state.value}\n                        placeholder={phoneLocalization.phoneNumberPlaceholder}\n                        required\n                        disabled={isPending}\n                        onBlur={field.handleBlur}\n                        onChange={(event) =>\n                          field.handleChange(event.target.value)\n                        }\n                        aria-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                      />\n                      <field.AuthFormFieldError />\n                    </Field>\n                  )}\n                </form.AppField>\n              )}\n\n              <form.AppField\n                name=\"code\"\n                validators={{\n                  onChange: ({ value }) =>\n                    value.length === otpLength\n                      ? undefined\n                      : phoneLocalization.codeLengthMismatch.replace(\n                          \"{{length}}\",\n                          String(otpLength)\n                        )\n                }}\n              >\n                {(field) => (\n                  <OtpField\n                    autoFocus={hasStoredPhoneNumber}\n                    disabled={isPending}\n                    label={phoneLocalization.phoneCode}\n                    length={otpLength}\n                    name=\"otp\"\n                    value={field.state.value}\n                    onChange={field.handleChange}\n                  />\n                )}\n              </form.AppField>\n\n              <form.AppField\n                name=\"password\"\n                validators={{\n                  onChange: ({ value }) => validatePassword(value)\n                }}\n              >\n                {(field) => (\n                  <Field\n                    data-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                  >\n                    <FieldLabel htmlFor=\"phoneNumberNewPassword\">\n                      {localization.auth.newPassword}\n                    </FieldLabel>\n                    <InputGroup>\n                      <InputGroupInput\n                        id=\"phoneNumberNewPassword\"\n                        name={field.name}\n                        type={isPasswordVisible ? \"text\" : \"password\"}\n                        autoComplete=\"new-password\"\n                        value={field.state.value}\n                        placeholder={localization.auth.newPasswordPlaceholder}\n                        required\n                        minLength={emailAndPassword?.minPasswordLength}\n                        maxLength={emailAndPassword?.maxPasswordLength}\n                        disabled={isPending}\n                        onBlur={field.handleBlur}\n                        onChange={(event) => {\n                          field.handleChange(event.target.value)\n                        }}\n                        aria-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                      />\n                      <InputGroupAddon align=\"inline-end\">\n                        <InputGroupButton\n                          type=\"button\"\n                          size=\"icon-xs\"\n                          aria-label={\n                            isPasswordVisible\n                              ? localization.auth.hidePassword\n                              : localization.auth.showPassword\n                          }\n                          onClick={() =>\n                            setIsPasswordVisible((visible) => !visible)\n                          }\n                        >\n                          {isPasswordVisible ? <EyeOff /> : <Eye />}\n                        </InputGroupButton>\n                      </InputGroupAddon>\n                    </InputGroup>\n                    <field.AuthFormFieldError />\n\n                    <PasswordStrengthMeter password={field.state.value} />\n                  </Field>\n                )}\n              </form.AppField>\n\n              {emailAndPassword?.confirmPassword && (\n                <form.AppField\n                  name=\"confirmPassword\"\n                  validators={{\n                    onChangeListenTo: [\"password\"],\n                    onChange: ({ value, fieldApi }) =>\n                      validateMatchingValue(\n                        value,\n                        fieldApi.form.getFieldValue(\"password\"),\n                        localization.auth.passwordsDoNotMatch\n                      )\n                  }}\n                >\n                  {(field) => (\n                    <Field\n                      data-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                    >\n                      <FieldLabel htmlFor=\"phoneNumberConfirmPassword\">\n                        {localization.auth.confirmPassword}\n                      </FieldLabel>\n                      <Input\n                        id=\"phoneNumberConfirmPassword\"\n                        name={field.name}\n                        type=\"password\"\n                        autoComplete=\"new-password\"\n                        placeholder={\n                          localization.auth.confirmPasswordPlaceholder\n                        }\n                        required\n                        minLength={emailAndPassword?.minPasswordLength}\n                        maxLength={emailAndPassword?.maxPasswordLength}\n                        disabled={isPending}\n                        value={field.state.value}\n                        onBlur={field.handleBlur}\n                        onChange={(event) =>\n                          field.handleChange(event.target.value)\n                        }\n                        aria-invalid={isAuthFormFieldInvalid(field.state.meta)}\n                      />\n\n                      <field.AuthFormFieldError />\n                    </Field>\n                  )}\n                </form.AppField>\n              )}\n\n              <form.AuthFormSubmitButton disabled={isPending}>\n                {phoneLocalization.resetPassword}\n              </form.AuthFormSubmitButton>\n              <form.AuthFormServerError />\n            </FieldGroup>\n          </form.AuthFormRoot>\n        </form.AppForm>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/phone-number/reset-phone-number-password.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/provider-button.tsx",
      "content": "\"use client\"\n\nimport {\n  type AuthSocialProvider,\n  type AuthView,\n  authMutationKeys,\n  getProviderId,\n  getProviderName,\n  type OAuthPopupAuthClient\n} from \"@better-auth-ui/core\"\nimport {\n  renderProviderIcon,\n  useAuth,\n  useFetchOptions,\n  useSignInOAuthPopup,\n  useSignInSocial\n} from \"@better-auth-ui/react\"\nimport { useIsMutating } from \"@tanstack/react-query\"\nimport type { ComponentProps } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport { cn } from \"cn\"\nimport { LastUsedBadge } from \"./last-login-method/last-used-badge\"\n\nexport type ProviderButtonProps = {\n  provider: AuthSocialProvider\n  display?: \"full\" | \"name\" | \"icon\"\n  view?: AuthView\n} & Omit<ComponentProps<typeof Button>, \"onClick\" | \"children\" | \"disabled\">\n\n/**\n * Social provider sign-in button.\n *\n * @param provider - Provider to sign in with.\n * @param display - `\"full\"` (e.g. \"Continue with Google\"), `\"name\"` (just the provider name), or `\"icon\"` (icon only).\n */\nexport function ProviderButton({\n  provider,\n  display = \"full\",\n  view = \"signIn\",\n  variant = \"outline\",\n  className,\n  ...props\n}: ProviderButtonProps) {\n  const {\n    authClient,\n    baseURL,\n    localization,\n    navigate,\n    redirectTo,\n    socialSignInMode\n  } = useAuth()\n\n  const callbackURL = `${baseURL}${redirectTo}`\n  const { fetchOptions, resetFetchOptions } = useFetchOptions()\n\n  const { mutate: signInSocial, isPending: signInSocialPending } =\n    useSignInSocial(authClient, { onError: resetFetchOptions })\n  const { mutate: signInPopup, isPending: signInPopupPending } =\n    useSignInOAuthPopup(authClient as OAuthPopupAuthClient, {\n      onError: resetFetchOptions\n    })\n\n  const providerId = getProviderId(provider)\n  const providerIcon = renderProviderIcon(provider)\n\n  const signInMutating = useIsMutating({\n    mutationKey: authMutationKeys.signIn.all\n  })\n  const signUpMutating = useIsMutating({\n    mutationKey: authMutationKeys.signUp.all\n  })\n  const isPending = signInMutating + signUpMutating > 0\n\n  const handleSignIn = () => {\n    if (socialSignInMode === \"popup\") {\n      signInPopup(\n        {\n          provider: providerId,\n          callbackURL,\n          requestSignUp: view === \"signUp\"\n        },\n        { onSuccess: () => navigate({ to: redirectTo }) }\n      )\n      return\n    }\n\n    signInSocial({ provider: providerId, callbackURL, fetchOptions })\n  }\n\n  return (\n    <Button\n      type=\"button\"\n      variant={variant}\n      disabled={isPending}\n      onClick={handleSignIn}\n      className={cn(\"relative overflow-visible\", className)}\n      {...props}\n    >\n      {signInSocialPending || signInPopupPending ? <Spinner /> : providerIcon}\n\n      {display === \"full\"\n        ? localization.auth.continueWith.replace(\n            \"{{provider}}\",\n            getProviderName(provider)\n          )\n        : display === \"name\"\n          ? getProviderName(provider)\n          : null}\n\n      {display === \"icon\" && (\n        <span className=\"sr-only\">{getProviderName(provider)}</span>\n      )}\n\n      {view !== \"signUp\" && <LastUsedBadge method={providerId} floating />}\n    </Button>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/provider-button.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/provider-buttons.tsx",
      "content": "\"use client\"\n\nimport { type AuthView, getProviderId } from \"@better-auth-ui/core\"\nimport { useAuth } from \"@better-auth-ui/react\"\nimport { useMemo } from \"react\"\n\nimport { cn } from \"cn\"\nimport { ProviderButton } from \"./provider-button\"\n\nexport type ProviderButtonsProps = {\n  socialLayout?: SocialLayout\n  view?: AuthView\n}\n\nexport type SocialLayout = \"auto\" | \"horizontal\" | \"vertical\" | \"grid\"\n\n/**\n * Render sign-in buttons for configured social providers. Each button owns its own sign-in mutation\n * and reads the shared sign-in pending state from React Query.\n *\n * @param socialLayout - Preferred layout for the provider buttons; `\"auto\"` chooses based on the number of providers.\n */\nexport function ProviderButtons({\n  socialLayout = \"auto\",\n  view = \"signIn\"\n}: ProviderButtonsProps) {\n  const { socialProviders } = useAuth()\n\n  const resolvedSocialLayout = useMemo(() => {\n    if (socialLayout === \"auto\") {\n      if (socialProviders?.length && socialProviders.length >= 4) {\n        return \"horizontal\"\n      }\n\n      return \"vertical\"\n    }\n\n    return socialLayout\n  }, [socialLayout, socialProviders?.length])\n\n  return (\n    <div\n      className={cn(\n        \"gap-3\",\n        resolvedSocialLayout === \"grid\" && \"grid grid-cols-2\",\n        resolvedSocialLayout === \"vertical\" && \"flex flex-col\",\n        resolvedSocialLayout === \"horizontal\" && \"flex flex-row flex-wrap\"\n      )}\n    >\n      {socialProviders?.map((provider) => (\n        <ProviderButton\n          key={getProviderId(provider)}\n          provider={provider}\n          view={view}\n          display={\n            resolvedSocialLayout === \"vertical\"\n              ? \"full\"\n              : resolvedSocialLayout === \"grid\"\n                ? \"name\"\n                : \"icon\"\n          }\n          className={cn(resolvedSocialLayout === \"horizontal\" && \"flex-1\")}\n        />\n      ))}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/provider-buttons.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/reauthentication.tsx",
      "content": "\"use client\"\n\nimport {\n  getReauthenticationSignInURL,\n  isReauthenticationSignInURL\n} from \"@better-auth-ui/core\"\nimport { useAuth, useSignOut } from \"@better-auth-ui/react\"\nimport { useSyncExternalStore } from \"react\"\nimport { Alert, AlertDescription, AlertTitle } from \"@/components/ui/alert\"\nimport { Button } from \"@/components/ui/button\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport { cn } from \"cn\"\n\nconst subscribeToLocation = () => () => undefined\n\nfunction useIsReauthenticationSignIn() {\n  return useSyncExternalStore(\n    subscribeToLocation,\n    () => isReauthenticationSignInURL(new URL(window.location.href)),\n    () => false\n  )\n}\n\nexport type ReauthenticationActionProps = {\n  className?: string\n  showTitle?: boolean\n}\n\nexport function ReauthenticationAction({\n  className,\n  showTitle = true\n}: ReauthenticationActionProps) {\n  const auth = useAuth()\n  const signOut = useSignOut(auth.authClient)\n\n  const handleReauthentication = () => {\n    const signInURL = getReauthenticationSignInURL(\n      new URL(window.location.href),\n      `${auth.basePaths.auth}/${auth.viewPaths.auth.signIn}`\n    )\n    signOut.mutate(undefined, {\n      onSuccess: () => auth.navigate({ to: signInURL })\n    })\n  }\n\n  return (\n    <div className={cn(\"flex flex-col items-start gap-3 p-4\", className)}>\n      <div className=\"flex flex-col gap-1\">\n        {showTitle ? (\n          <h3 className=\"text-sm font-medium\">\n            {auth.localization.settings.reauthenticationTitle}\n          </h3>\n        ) : null}\n        <p className=\"text-sm text-muted-foreground\">\n          {auth.localization.settings.reauthenticationDescription}\n        </p>\n      </div>\n      <Button\n        disabled={signOut.isPending}\n        onClick={handleReauthentication}\n        size=\"sm\"\n      >\n        {signOut.isPending ? <Spinner data-icon=\"inline-start\" /> : null}\n        {auth.localization.settings.reauthenticationAction}\n      </Button>\n    </div>\n  )\n}\n\nexport function ReauthenticationNotice() {\n  const auth = useAuth()\n  const isReauthenticationSignIn = useIsReauthenticationSignIn()\n  if (!isReauthenticationSignIn) return null\n\n  return (\n    <Alert className=\"mx-4 w-auto group-data-[size=sm]/card:mx-3\">\n      <AlertTitle>\n        {auth.localization.settings.reauthenticationTitle}\n      </AlertTitle>\n      <AlertDescription>\n        {auth.localization.settings.reauthenticationDescription}\n      </AlertDescription>\n    </Alert>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/reauthentication.tsx"
    },
    {
      "path": "examples/start-shadcn-example/src/components/auth/use-is-hydrated.ts",
      "content": "\"use client\"\n\nimport { useSyncExternalStore } from \"react\"\n\n/**\n * Returns `true` once the component is mounted on the client (hydrated) and\n * `false` while rendering on the server, so client-only reads (e.g.\n * `sessionStorage`) stay safe during SSR.\n *\n * @returns Whether the component has hydrated on the client.\n */\nexport function useIsHydrated() {\n  const subscribe = () => () => {}\n  return useSyncExternalStore(\n    subscribe,\n    () => true,\n    () => false\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/use-is-hydrated.ts"
    },
    {
      "path": "examples/start-shadcn-example/src/lib/auth/auth-plugin.ts",
      "content": "import type {\n  AuthPluginComponents,\n  AuthPlugin as AuthPluginPrimitive\n} from \"@better-auth-ui/react\"\n\ndeclare module \"@better-auth-ui/core\" {\n  /** Widens `useAuth().plugins` to the shadcn-typed `AuthPlugin`. */\n  interface AuthPluginRegister {\n    shadcn: AuthPlugin\n  }\n}\n\n/** Props the shadcn `<Auth>` router spreads onto plugin-contributed auth views. */\nexport type AuthViewProps = {\n  className?: string\n  socialLayout?: \"auto\" | \"horizontal\" | \"vertical\" | \"grid\"\n  socialPosition?: \"top\" | \"bottom\"\n}\n\n/** Props the shadcn `<Settings>` router spreads onto plugin-contributed settings views. */\nexport type SettingsViewProps = {\n  className?: string\n}\n\n/** Shadcn plugin type. Plugin authors import this from `@/lib/auth/auth-plugin`. */\nexport type AuthPlugin = AuthPluginPrimitive<\n  AuthPluginComponents,\n  AuthViewProps,\n  SettingsViewProps\n>\n",
      "type": "registry:lib",
      "target": "@lib/auth/auth-plugin.ts"
    },
    {
      "path": "examples/start-shadcn-example/src/lib/auth/phone-number-plugin.ts",
      "content": "import { createAuthPlugin } from \"@better-auth-ui/core\"\nimport {\n  phoneNumberPlugin as corePhoneNumberPlugin,\n  type PhoneNumberPluginOptions\n} from \"@better-auth-ui/core/plugins/phone-number\"\n\nimport { ChangePhoneNumber } from \"@/components/auth/phone-number/change-phone-number\"\nimport { ForgotPhoneNumberPassword } from \"@/components/auth/phone-number/forgot-phone-number-password\"\nimport { PhoneNumber } from \"@/components/auth/phone-number/phone-number\"\nimport { PhoneNumberButton } from \"@/components/auth/phone-number/phone-number-button\"\nimport { ResetPhoneNumberPassword } from \"@/components/auth/phone-number/reset-phone-number-password\"\n\nexport const phoneNumberPlugin = createAuthPlugin(\n  corePhoneNumberPlugin.id,\n  (options: PhoneNumberPluginOptions = {}) => {\n    const plugin = corePhoneNumberPlugin(options)\n    const hasSignIn = plugin.signIn || plugin.passwordSignIn\n\n    return {\n      ...plugin,\n      authButtons: hasSignIn ? [PhoneNumberButton] : [],\n      views: {\n        auth: {\n          ...(hasSignIn && { phoneNumber: PhoneNumber }),\n          ...(plugin.passwordReset && {\n            phoneNumberForgotPassword: ForgotPhoneNumberPassword,\n            phoneNumberResetPassword: ResetPhoneNumberPassword\n          })\n        }\n      },\n      ...(hasSignIn && {\n        fallbackViews: { auth: { signIn: PhoneNumber } }\n      }),\n      accountCards: plugin.changePhoneNumber ? [ChangePhoneNumber] : []\n    }\n  }\n)\n",
      "type": "registry:lib",
      "target": "@lib/auth/phone-number-plugin.ts"
    },
    {
      "path": "examples/start-shadcn-example/src/lib/auth/two-factor-methods.ts",
      "content": "/**\n * Second-factor methods a user can complete the challenge with.\n *\n * `totp` and `otp` come from the server's `twoFactorMethods` list. Backup\n * codes are always available when the server has them enabled, so they are\n * never part of that list.\n */\nexport type TwoFactorMethod = \"totp\" | \"otp\"\n\nconst TWO_FACTOR_METHODS: TwoFactorMethod[] = [\"totp\", \"otp\"]\n\n/** Auth plugin id used by Better Auth UI's two-factor integration. */\nexport const TWO_FACTOR_PLUGIN_ID = \"twoFactor\"\n\n/**\n * `sessionStorage` key holding the methods reported by the sign-in response.\n *\n * Only the non-sensitive method names are stored, never a code, token, or the\n * two-factor cookie, which stays HTTP-only.\n */\nexport const TWO_FACTOR_METHODS_STORAGE_KEY =\n  \"better-auth-ui.two-factor-methods\"\n\ntype TwoFactorRedirect = {\n  twoFactorRedirect: true\n  twoFactorMethods?: unknown\n}\n\n/** Detect the redirect payload Better Auth returns before a second factor. */\nexport function isTwoFactorRedirect(data: unknown): data is TwoFactorRedirect {\n  return (\n    typeof data === \"object\" &&\n    data !== null &&\n    (data as { twoFactorRedirect?: unknown }).twoFactorRedirect === true\n  )\n}\n\n/** Narrow arbitrary method names to the challenge views this UI supports. */\nexport function parseTwoFactorMethods(methods?: unknown): TwoFactorMethod[] {\n  if (!Array.isArray(methods)) return []\n\n  return TWO_FACTOR_METHODS.filter((method) => methods.includes(method))\n}\n\n/** Persist the enabled method names without blocking sign-in on storage errors. */\nexport function storeTwoFactorMethods(methods?: unknown) {\n  if (typeof sessionStorage === \"undefined\") return\n\n  try {\n    sessionStorage.setItem(\n      TWO_FACTOR_METHODS_STORAGE_KEY,\n      JSON.stringify(parseTwoFactorMethods(methods))\n    )\n  } catch {\n    // The challenge falls back to every method when storage is unavailable.\n  }\n}\n\n/** Read the stored methods, falling back to every supported challenge. */\nexport function readTwoFactorMethods(): TwoFactorMethod[] {\n  if (typeof sessionStorage === \"undefined\") return TWO_FACTOR_METHODS\n\n  try {\n    const stored = sessionStorage.getItem(TWO_FACTOR_METHODS_STORAGE_KEY)\n    if (!stored) return TWO_FACTOR_METHODS\n\n    const methods = parseTwoFactorMethods(JSON.parse(stored))\n    return methods.length ? methods : TWO_FACTOR_METHODS\n  } catch {\n    return TWO_FACTOR_METHODS\n  }\n}\n\n/** Clear stored method hints after the challenge finishes or is abandoned. */\nexport function clearTwoFactorMethods() {\n  if (typeof sessionStorage === \"undefined\") return\n\n  try {\n    sessionStorage.removeItem(TWO_FACTOR_METHODS_STORAGE_KEY)\n  } catch {\n    // Stale method hints are harmless and must not block navigation.\n  }\n}\n",
      "type": "registry:lib",
      "target": "@lib/auth/two-factor-methods.ts"
    },
    {
      "path": "examples/start-shadcn-example/src/lib/auth/use-resend-cooldown.ts",
      "content": "\"use client\"\n\nimport { useCallback, useEffect, useState } from \"react\"\n\n/** Seconds a resend button stays disabled to keep users off the rate limit. */\nexport const RESEND_COOLDOWN_SECONDS = 60\n\n/**\n * Countdown state for \"resend code\" buttons.\n *\n * @param initialSeconds - Seconds to start at. Pass `0` when nothing has been\n *   sent yet, or the cooldown length when the flow arrives right after a send.\n */\nexport function useResendCooldown(initialSeconds = 0) {\n  const [cooldown, setCooldown] = useState(initialSeconds)\n\n  useEffect(() => {\n    if (cooldown <= 0) return\n\n    const interval = setInterval(() => {\n      setCooldown((current) => (current > 0 ? current - 1 : 0))\n    }, 1000)\n\n    return () => clearInterval(interval)\n  }, [cooldown])\n\n  // Stable so callers can start the cooldown from an effect without\n  // re-running it on every render.\n  const startCooldown = useCallback(\n    (seconds = RESEND_COOLDOWN_SECONDS) => setCooldown(seconds),\n    []\n  )\n\n  return {\n    cooldown,\n    isCoolingDown: cooldown > 0,\n    startCooldown\n  }\n}\n",
      "type": "registry:lib",
      "target": "@lib/auth/use-resend-cooldown.ts"
    },
    {
      "path": "examples/start-shadcn-example/src/lib/auth/use-sign-in-continuation.ts",
      "content": "\"use client\"\n\nimport { useAuth } from \"@better-auth-ui/react\"\nimport { useCallback } from \"react\"\nimport {\n  isTwoFactorRedirect,\n  storeTwoFactorMethods,\n  TWO_FACTOR_PLUGIN_ID\n} from \"./two-factor-methods\"\n\n/**\n * Resolve what happens after a sign-in request succeeds.\n *\n * Better Auth withholds the session when a second factor is required and\n * answers with `{ twoFactorRedirect: true, twoFactorMethods }` instead, so no\n * sign-in strategy may navigate to `redirectTo` unconditionally. This hook is\n * the single place that decision lives — every password-based form calls it\n * from `onSuccess`.\n *\n * The enabled methods are stashed in session storage (names only, never a\n * code or token) and `redirectTo` rides along in the query string so the\n * challenge view can finish the original navigation.\n *\n * The two-factor plugin is looked up by its stable id, so sign-in forms stay\n * installable without either the two-factor components or a matching release\n * of `@better-auth-ui/core`.\n *\n * @returns A callback taking the resolved data of a sign-in mutation.\n */\nexport function useSignInContinuation() {\n  const { basePaths, navigate, plugins, redirectTo } = useAuth()\n\n  const twoFactorPath = plugins.find(\n    (plugin) => plugin.id === TWO_FACTOR_PLUGIN_ID\n  )?.viewPaths?.auth?.twoFactor\n\n  return useCallback(\n    (data: unknown) => {\n      if (twoFactorPath && isTwoFactorRedirect(data)) {\n        storeTwoFactorMethods(data.twoFactorMethods)\n\n        navigate({\n          to: `${basePaths.auth}/${twoFactorPath}?redirectTo=${encodeURIComponent(redirectTo)}`\n        })\n        return\n      }\n\n      navigate({ to: redirectTo })\n    },\n    [basePaths.auth, navigate, redirectTo, twoFactorPath]\n  )\n}\n",
      "type": "registry:lib",
      "target": "@lib/auth/use-sign-in-continuation.ts"
    }
  ],
  "type": "registry:component"
}