{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-01",
  "title": "设置页",
  "description": "用方条控件拼成的完整设置页：分区导航、实时预览、已修改计数、恢复默认与异步保存。",
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "https://yiui.dev/r/value-slider.json",
    "https://yiui.dev/r/segmented-control.json",
    "https://yiui.dev/r/toggle-switch.json",
    "https://yiui.dev/r/tone-picker.json",
    "https://yiui.dev/r/control-panel.json",
    "https://yiui.dev/r/flow-tone.json",
    "item",
    "popover",
    "sheet"
  ],
  "files": [
    {
      "path": "src/registry/blocks/settings-01/page.tsx",
      "content": "\"use client\"\n\nimport { Settings01 } from \"@/components/settings-01/settings-01\"\n\n/**\n * 设置页入口：用 onSave 把设置存到你自己的后端。\n * 回调返回 Promise；失败时 throw new Error(\"中文原因\")，原因会显示在底部保存栏上。\n * 想把改动实时应用到页面（例如切换主题），在 onValueChange 里处理。\n */\nexport default function SettingsPage() {\n  return (\n    <Settings01\n      onSave={async (values) => {\n        // TODO: 调用你的接口，例如 await fetch(\"/api/settings\", { method: \"PUT\", body: JSON.stringify(values) })\n        console.info(\"save settings\", values)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n    />\n  )\n}\n",
      "type": "registry:page",
      "target": "app/settings/page.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/settings-01.tsx",
      "content": "\"use client\"\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { Check, LoaderCircle, Settings } from \"lucide-react\"\nimport { useMemo, useState, type ReactNode } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { cn } from \"@/lib/utils\"\nimport { useControllableState } from \"@/hooks/use-controllable-state\"\nimport { flowToneStyle } from \"@/lib/flow-tone\"\n\nimport { Settings01Changes } from \"./changes\"\nimport { AppearanceSection } from \"./appearance-section\"\nimport {\n  DEFAULT_VALUES,\n  SECTION_IDS,\n  SECTION_KEYS,\n  resolveLabels,\n  type Settings01Labels,\n} from \"./config\"\nimport { EditorSection } from \"./editor-section\"\nimport { NotificationsSection } from \"./notifications-section\"\nimport { PrivacySection } from \"./privacy-section\"\nimport type { SectionProps, SetValue } from \"./section-layout\"\nimport { SectionNav, SectionTabs } from \"./section-nav\"\nimport { SoundSection } from \"./sound-section\"\nimport type { Settings01SectionId, Settings01Values } from \"./types\"\nimport { useSaveAction } from \"./use-save-action\"\nimport { isSameValue } from \"./utils\"\n\nconst SECTIONS: Record<\n  Settings01SectionId,\n  (props: SectionProps) => ReactNode\n> = {\n  appearance: AppearanceSection,\n  notifications: NotificationsSection,\n  sound: SoundSection,\n  editor: EditorSection,\n  privacy: PrivacySection,\n}\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n// 未传回调时的示例实现：只在控制台打印，并模拟 0.8 秒的网络请求\nasync function demoSave(values: Settings01Values) {\n  console.info(\"[settings-01] onSave\", values)\n  await wait(800)\n}\n\nfunction pickKeys(\n  values: Settings01Values,\n  keys: readonly (keyof Settings01Values)[],\n) {\n  return Object.fromEntries(keys.map((key) => [key, values[key]]))\n}\n\n/**\n * 设置页：左侧分区导航（窄屏变成顶部分段选择）+ 右侧当前分区的控制面板 + 底部保存栏。\n * 值同时支持受控与非受控；保存回调返回 Promise，组件管理 loading，回调 throw 的 Error.message 会显示在保存栏上。\n */\nfunction Settings01({\n  value: valueProp,\n  defaultValue,\n  defaults,\n  onValueChange,\n  section: sectionProp,\n  defaultSection = \"appearance\",\n  onSectionChange,\n  onSave = demoSave,\n  labels,\n  className,\n}: {\n  /** 受控的全部设置值 */\n  value?: Settings01Values\n  /** 非受控时的初始值，没写的项取 `defaults` */\n  defaultValue?: Partial<Settings01Values>\n  /** 出厂默认值，逐项覆盖 config.ts 的 DEFAULT_VALUES；「已修改」「恢复默认」都以它为准 */\n  defaults?: Partial<Settings01Values>\n  /** 任何一项变化时回调，参数是变化后的全部设置 */\n  onValueChange?: (value: Settings01Values) => void\n  /** 受控的当前分区 */\n  section?: Settings01SectionId\n  defaultSection?: Settings01SectionId\n  onSectionChange?: (section: Settings01SectionId) => void\n  /** 点击「保存」时调用；失败时 throw new Error(\"原因\")，原因会显示在保存栏 */\n  onSave?: (values: Settings01Values) => Promise<void>\n  /** 覆盖默认文案，见 config.ts 的 DEFAULT_LABELS */\n  labels?: Partial<Settings01Labels>\n  className?: string\n}) {\n  const text = resolveLabels(labels)\n  const reducedMotion = useReducedMotion()\n  const resolvedDefaults = useMemo<Settings01Values>(\n    () => ({ ...DEFAULT_VALUES, ...defaults }),\n    [defaults],\n  )\n  const [values, setValues] = useControllableState<Settings01Values>({\n    prop: valueProp,\n    defaultProp: { ...resolvedDefaults, ...defaultValue },\n    onChange: onValueChange,\n  })\n  const [section, setSection] = useControllableState<Settings01SectionId>({\n    prop: sectionProp,\n    defaultProp: defaultSection,\n    onChange: onSectionChange,\n  })\n  // 上一次保存（或首次载入）时的值：和默认值比出「已修改」，和它比出「有未保存的更改」\n  const [saved, setSaved] = useState(values)\n  const action = useSaveAction(text.saveFailed)\n\n  const set: SetValue = (key, next) => {\n    setValues((previous) => ({ ...previous, [key]: next }))\n    action.reset()\n  }\n  const modified = (key: keyof Settings01Values) =>\n    !isSameValue(values[key], resolvedDefaults[key])\n  const counts = Object.fromEntries(\n    SECTION_IDS.map((id) => [id, SECTION_KEYS[id].filter(modified).length]),\n  ) as Record<Settings01SectionId, number>\n  const changes = SECTION_IDS.flatMap((section) => SECTION_KEYS[section].filter(modified).map((key) => ({ key, section })))\n  const total = changes.length\n  const dirty = (Object.keys(values) as (keyof Settings01Values)[]).some(\n    (key) => !isSameValue(values[key], saved[key]),\n  )\n  const pending = action.status === \"pending\"\n\n  const resetSection = (id: Settings01SectionId) => {\n    setValues((previous) => ({\n      ...previous,\n      ...pickKeys(resolvedDefaults, SECTION_KEYS[id]),\n    }))\n    action.reset()\n  }\n  const resetAll = () => {\n    setValues({ ...resolvedDefaults })\n    action.reset()\n  }\n  const save = async () => {\n    const snapshot = values\n    if (await action.run(() => onSave(snapshot))) setSaved(snapshot)\n  }\n\n  const Section = SECTIONS[section]\n  const sectionProps: SectionProps = {\n    values,\n    labels: text,\n    set,\n    modified,\n    count: counts[section],\n    onReset: () => resetSection(section),\n    getCode: () =>\n      JSON.stringify(pickKeys(values, SECTION_KEYS[section]), null, 2),\n  }\n\n  return (\n    <div\n      data-slot=\"settings-01\"\n      className={cn(\n        \"relative flex min-h-svh flex-col bg-background text-foreground\",\n        className,\n      )}\n      // 强调色同时作为 --flow-tone，导航的选中标记等跟着它走\n      style={flowToneStyle(values.accent)}\n    >\n      <header className=\"border-b border-edge\">\n        <div className=\"mx-auto flex w-full max-w-6xl items-center gap-3 px-4 py-4 sm:px-6 lg:border-x lg:border-edge\">\n          <span\n            aria-hidden=\"true\"\n            className=\"flex size-8 shrink-0 items-center justify-center rounded-md border border-edge bg-muted/50\"\n          >\n            <Settings className=\"size-4\" />\n          </span>\n          <div className=\"min-w-0\">\n            <h1 className=\"text-base leading-tight font-semibold tracking-tight\">\n              {text.title}\n            </h1>\n            <p className=\"truncate text-xs text-muted-foreground\">\n              {text.description}\n            </p>\n          </div>\n        </div>\n      </header>\n\n      <div className=\"mx-auto flex w-full max-w-6xl flex-1 flex-col md:flex-row lg:border-x lg:border-edge\">\n        <SectionNav\n          section={section}\n          onSectionChange={setSection}\n          counts={counts}\n          labels={text}\n        />\n        <SectionTabs\n          section={section}\n          onSectionChange={setSection}\n          labels={text}\n          tone={values.accent}\n        />\n        <main className=\"min-w-0 flex-1 p-4 sm:p-6\">\n          <AnimatePresence mode=\"wait\" initial={false}>\n            <motion.div\n              key={section}\n              initial={{ opacity: 0, y: reducedMotion ? 0 : 8 }}\n              animate={{ opacity: 1, y: 0 }}\n              exit={{ opacity: 0, y: reducedMotion ? 0 : -8 }}\n              transition={{ duration: 0.18 }}\n            >\n              <Section {...sectionProps} />\n            </motion.div>\n          </AnimatePresence>\n        </main>\n      </div>\n\n      <footer\n        aria-label={text.footerLabel}\n        data-slot=\"settings-01-footer\"\n        className=\"sticky bottom-0 z-20 border-t border-edge bg-background/90 backdrop-blur\"\n      >\n        <div className=\"mx-auto flex w-full max-w-6xl items-center justify-between gap-3 px-4 py-3 sm:px-6 lg:border-x lg:border-edge\">\n          <div className=\"min-w-0 text-sm\">\n            <Settings01Changes changes={changes} values={values} defaults={resolvedDefaults} labels={text} pending={pending} dirty={dirty} onUndo={(key) => set(key, resolvedDefaults[key])} onReset={resetAll} onSave={save} />\n            {/* 状态行固定占一行高度，避免保存时底栏跳动；出错时同一位置换成红色的错误原因 */}\n            {action.status === \"error\" ? (\n              <p\n                role=\"alert\"\n                data-slot=\"settings-01-error\"\n                className=\"min-h-4 truncate text-xs text-destructive\"\n              >\n                {action.error}\n              </p>\n            ) : (\n              <p\n                role=\"status\"\n                data-slot=\"settings-01-status\"\n                className=\"flex min-h-4 items-center gap-1 truncate text-xs text-muted-foreground\"\n              >\n                {pending ? (\n                  text.saving\n                ) : action.status === \"saved\" ? (\n                  <>\n                    <Check className=\"size-3.5 shrink-0\" />\n                    {text.saved}\n                  </>\n                ) : dirty ? (\n                  text.unsaved\n                ) : (\n                  text.upToDate\n                )}\n              </p>\n            )}\n          </div>\n          <div className=\"flex shrink-0 items-center gap-2\">\n            <Button\n              variant=\"outline\"\n              disabled={total === 0 || pending}\n              onClick={resetAll}\n            >\n              {text.resetAll}\n            </Button>\n            <Button disabled={!dirty || pending} onClick={save}>\n              {pending ? (\n                <LoaderCircle className=\"animate-spin\" data-icon=\"inline-start\" />\n              ) : null}\n              {pending ? text.saving : text.save}\n            </Button>\n          </div>\n        </div>\n      </footer>\n    </div>\n  )\n}\n\nexport { Settings01 }\nexport type { Settings01Labels, Settings01SectionId, Settings01Values }\n",
      "type": "registry:component",
      "target": "@components/settings-01/settings-01.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/config.ts",
      "content": "import type { Settings01SectionId, Settings01Values } from \"./types\"\n\n/**\n * 设置页所有用户可见的文案。\n * 含 {count}、{value}、{section} 的文案在渲染时由 formatLabel 填入实际值。\n */\nconst DEFAULT_LABELS = {\n  // 页面\n  title: \"设置\",\n  description: \"调整外观、通知、声音与编辑器的偏好\",\n  navLabel: \"设置分区\",\n  navSectionModified: \"已修改 {count} 项\",\n  // 分区名（导航与面板）\n  sectionAppearance: \"外观\",\n  sectionNotifications: \"通知\",\n  sectionSound: \"声音与触感\",\n  sectionEditor: \"编辑器\",\n  sectionPrivacy: \"隐私\",\n  // 窄屏顶部分段选择里的短名，宽度有限所以单独一份\n  navAppearance: \"外观\",\n  navNotifications: \"通知\",\n  navSound: \"声音\",\n  navEditor: \"编辑器\",\n  navPrivacy: \"隐私\",\n  // 分区说明\n  descriptionAppearance: \"主题、强调色与界面尺寸，右侧预览会实时变化\",\n  descriptionNotifications: \"决定哪些事件会打扰你，以及什么时候不打扰\",\n  descriptionSound: \"音量、按键音效与触感反馈\",\n  descriptionEditor: \"缩进、行高与空白字符的显示方式\",\n  descriptionPrivacy: \"谁能看到你，以及我们收集哪些数据\",\n  // 面板头部\n  panelModified: \"已修改 {count} 项\",\n  panelDefault: \"全部为默认值\",\n  copySection: \"复制本分区设置\",\n  copiedSection: \"已复制\",\n  resetSection: \"恢复本分区默认值\",\n  // 外观\n  groupTheme: \"主题\",\n  groupShape: \"尺寸与形状\",\n  groupMotion: \"动态\",\n  theme: \"主题模式\",\n  themeLight: \"浅色\",\n  themeDark: \"深色\",\n  themeSystem: \"跟随系统\",\n  accent: \"强调色\",\n  fontSize: \"界面字号\",\n  radius: \"圆角\",\n  density: \"信息密度\",\n  densityCompact: \"紧凑\",\n  densityComfortable: \"舒适\",\n  densitySpacious: \"宽松\",\n  reduceMotion: \"减少动态效果\",\n  reduceMotionHint: \"关闭动画\",\n  readoutPx: \"{value}px\",\n  // 预览卡片\n  previewTitle: \"实时预览\",\n  previewHeading: \"本周回顾\",\n  previewBody: \"已完成 12 项任务，比上周多 3 项。\",\n  previewAction: \"查看详情\",\n  previewProgress: \"进度\",\n  previewLive: \"实时\",\n  previewModeLight: \"浅色\",\n  previewModeDark: \"深色\",\n  previewModeSystem: \"跟随系统\",\n  // 通知\n  groupChannels: \"通知渠道\",\n  groupQuiet: \"免打扰\",\n  notifications: \"允许通知\",\n  notificationsHint: \"总开关\",\n  notifyMentions: \"提及我\",\n  notifyMentionsHint: \"有人 @ 我时\",\n  notifyReplies: \"评论回复\",\n  notifyRepliesHint: \"有人回复时\",\n  notifyEmail: \"邮件摘要\",\n  notifyEmailHint: \"每天一封\",\n  notifyUpdates: \"产品动态\",\n  notifyUpdatesHint: \"新功能上线\",\n  quietHours: \"免打扰时段\",\n  // 声音与触感\n  groupVolume: \"音量\",\n  groupFeedback: \"反馈\",\n  volume: \"主音量\",\n  keySound: \"按键音效\",\n  keySoundHint: \"输入时发声\",\n  soundTheme: \"音色\",\n  soundSoft: \"柔和\",\n  soundCrisp: \"清脆\",\n  soundMechanical: \"机械\",\n  haptics: \"触感反馈\",\n  hapticsHint: \"设备震动\",\n  // 编辑器\n  groupIndent: \"缩进与行距\",\n  groupWhitespace: \"空白字符\",\n  indent: \"缩进宽度\",\n  indentTwo: \"2 空格\",\n  indentFour: \"4 空格\",\n  indentTab: \"制表符\",\n  lineHeight: \"行高\",\n  showTabs: \"显示制表符\",\n  showTabsHint: \"标出缩进\",\n  editorPreviewTitle: \"代码预览\",\n  // 隐私\n  groupProfile: \"个人资料\",\n  groupData: \"数据\",\n  visibility: \"资料可见范围\",\n  visibilityPublic: \"公开\",\n  visibilityTeam: \"团队\",\n  visibilityPrivate: \"仅自己\",\n  analytics: \"使用统计\",\n  analyticsHint: \"匿名数据\",\n  crashReports: \"崩溃报告\",\n  crashReportsHint: \"自动上报\",\n  retention: \"历史保留\",\n  readoutDays: \"{value} 天\",\n  changesTitle: \"改动对比\",\n  undoChange: \"撤销 {field} 的修改\",\n  resetChanges: \"全部恢复\",\n  valueOn: \"开\",\n  valueOff: \"关\",\n  // 底部操作栏\n  footerLabel: \"保存设置\",\n  modifiedCount: \"已修改 {count} 项\",\n  unmodified: \"全部为默认值\",\n  unsaved: \"有未保存的更改\",\n  upToDate: \"没有未保存的更改\",\n  saving: \"保存中…\",\n  saved: \"已保存\",\n  save: \"保存\",\n  resetAll: \"恢复默认\",\n  saveFailed: \"保存失败，请稍后重试\",\n} as const\n\ntype Settings01Labels = { [Key in keyof typeof DEFAULT_LABELS]: string }\n\n/** 出厂默认值。组件的「已修改」判断、恢复默认和未受控时的初始值都以它为准。 */\nconst DEFAULT_VALUES: Settings01Values = {\n  theme: \"system\",\n  accent: \"primary\",\n  fontSize: 14,\n  radius: 10,\n  density: \"comfortable\",\n  reduceMotion: false,\n  notifications: true,\n  notifyMentions: true,\n  notifyReplies: true,\n  notifyEmail: false,\n  notifyUpdates: false,\n  quietHours: [22, 31],\n  volume: 60,\n  keySound: false,\n  soundTheme: \"soft\",\n  haptics: true,\n  indent: \"2\",\n  lineHeight: 1.6,\n  showTabs: false,\n  visibility: \"team\",\n  analytics: true,\n  crashReports: true,\n  retention: 90,\n}\n\n/** 分区的显示顺序 */\nconst SECTION_IDS: readonly Settings01SectionId[] = [\n  \"appearance\",\n  \"notifications\",\n  \"sound\",\n  \"editor\",\n  \"privacy\",\n]\n\n/** 每个分区管哪些设置项：分区计数、分区复制与分区恢复默认都按它来。 */\nconst SECTION_KEYS: Record<Settings01SectionId, readonly (keyof Settings01Values)[]> =\n  {\n    appearance: [\n      \"theme\",\n      \"accent\",\n      \"fontSize\",\n      \"radius\",\n      \"density\",\n      \"reduceMotion\",\n    ],\n    notifications: [\n      \"notifications\",\n      \"notifyMentions\",\n      \"notifyReplies\",\n      \"notifyEmail\",\n      \"notifyUpdates\",\n      \"quietHours\",\n    ],\n    sound: [\"volume\", \"keySound\", \"soundTheme\", \"haptics\"],\n    editor: [\"indent\", \"lineHeight\", \"showTabs\"],\n    privacy: [\"visibility\", \"analytics\", \"crashReports\", \"retention\"],\n  }\n\n/** 每个分区用到的文案键：完整名称、说明与窄屏短名。 */\nconst SECTION_LABEL_KEYS: Record<\n  Settings01SectionId,\n  {\n    title: keyof Settings01Labels\n    description: keyof Settings01Labels\n    nav: keyof Settings01Labels\n  }\n> = {\n  appearance: {\n    title: \"sectionAppearance\",\n    description: \"descriptionAppearance\",\n    nav: \"navAppearance\",\n  },\n  notifications: {\n    title: \"sectionNotifications\",\n    description: \"descriptionNotifications\",\n    nav: \"navNotifications\",\n  },\n  sound: {\n    title: \"sectionSound\",\n    description: \"descriptionSound\",\n    nav: \"navSound\",\n  },\n  editor: {\n    title: \"sectionEditor\",\n    description: \"descriptionEditor\",\n    nav: \"navEditor\",\n  },\n  privacy: {\n    title: \"sectionPrivacy\",\n    description: \"descriptionPrivacy\",\n    nav: \"navPrivacy\",\n  },\n}\n\n/** 合并用户传入的文案与默认文案。 */\nfunction resolveLabels(labels?: Partial<Settings01Labels>): Settings01Labels {\n  return { ...DEFAULT_LABELS, ...labels }\n}\n\n/** 把文案里的 {key} 占位符替换成实际值，例如「已修改 {count} 项」。 */\nfunction formatLabel(\n  template: string,\n  values: Record<string, string | number>,\n): string {\n  return Object.entries(values).reduce(\n    (text, [key, value]) => text.replaceAll(`{${key}}`, String(value)),\n    template,\n  )\n}\n\nexport {\n  DEFAULT_LABELS,\n  DEFAULT_VALUES,\n  SECTION_IDS,\n  SECTION_KEYS,\n  SECTION_LABEL_KEYS,\n  formatLabel,\n  resolveLabels,\n}\nexport type { Settings01Labels }\n",
      "type": "registry:component",
      "target": "@components/settings-01/config.ts"
    },
    {
      "path": "src/registry/blocks/settings-01/types.ts",
      "content": "type ThemeMode = \"light\" | \"dark\" | \"system\"\ntype Density = \"compact\" | \"comfortable\" | \"spacious\"\ntype SoundTheme = \"soft\" | \"crisp\" | \"mechanical\"\ntype IndentWidth = \"2\" | \"4\" | \"tab\"\ntype ProfileVisibility = \"public\" | \"team\" | \"private\"\n\n/** 设置页的全部取值。键按分区归类，见 config.ts 的 SECTION_KEYS。 */\ntype Settings01Values = {\n  // 外观\n  theme: ThemeMode\n  /** 强调色，取值是 tone-picker 的色调名（primary、blue……）或任意 CSS 颜色 */\n  accent: string\n  /** 界面字号（px） */\n  fontSize: number\n  /** 圆角（px） */\n  radius: number\n  density: Density\n  reduceMotion: boolean\n  // 通知\n  notifications: boolean\n  notifyMentions: boolean\n  notifyReplies: boolean\n  notifyEmail: boolean\n  notifyUpdates: boolean\n  /** 免打扰时段 [起点, 终点]，单位小时，范围 12–36（36 即次日 12:00），读数按 24 小时取模 */\n  quietHours: [number, number]\n  // 声音与触感\n  volume: number\n  keySound: boolean\n  soundTheme: SoundTheme\n  haptics: boolean\n  // 编辑器\n  indent: IndentWidth\n  lineHeight: number\n  showTabs: boolean\n  // 隐私\n  visibility: ProfileVisibility\n  analytics: boolean\n  crashReports: boolean\n  /** 历史记录保留天数 */\n  retention: number\n}\n\ntype Settings01SectionId =\n  | \"appearance\"\n  | \"notifications\"\n  | \"sound\"\n  | \"editor\"\n  | \"privacy\"\n\nexport type {\n  Density,\n  IndentWidth,\n  ProfileVisibility,\n  Settings01SectionId,\n  Settings01Values,\n  SoundTheme,\n  ThemeMode,\n}\n",
      "type": "registry:component",
      "target": "@components/settings-01/types.ts"
    },
    {
      "path": "src/registry/blocks/settings-01/utils.ts",
      "content": "import { DEFAULT_LABELS } from \"./config\"\n\n/** 两个设置值是否相同；区间（数组）逐项比较。 */\nfunction isSameValue(a: unknown, b: unknown): boolean {\n  if (Array.isArray(a) && Array.isArray(b))\n    return a.length === b.length && a.every((item, index) => item === b[index])\n  return Object.is(a, b)\n}\n\n/**\n * 把小时数格式化成「22:00」。\n * 免打扰滑块的范围是 12–36（跨午夜），所以先对 24 取模；用 Intl 并固定 UTC，保证服务端与客户端一致。\n */\nfunction formatHour(hour: number, locale: string = \"zh-CN\"): string {\n  const whole = Math.floor(hour)\n  const minutes = Math.round((hour - whole) * 60)\n  return new Intl.DateTimeFormat(locale, {\n    hour: \"2-digit\",\n    minute: \"2-digit\",\n    hourCycle: \"h23\",\n    timeZone: \"UTC\",\n  }).format(new Date(Date.UTC(1970, 0, 1, whole % 24, minutes)))\n}\n\n/** 把未知错误转成可展示的文案；没有 message 时用兜底文案。 */\nfunction errorMessage(\n  error: unknown,\n  fallback: string = DEFAULT_LABELS.saveFailed,\n) {\n  return error instanceof Error && error.message ? error.message : fallback\n}\n\nexport { errorMessage, formatHour, isSameValue }\n",
      "type": "registry:component",
      "target": "@components/settings-01/utils.ts"
    },
    {
      "path": "src/registry/blocks/settings-01/section-layout.tsx",
      "content": "import type * as React from \"react\"\nimport { useId } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport {\n  ControlPanel,\n  ControlPanelActions,\n  ControlPanelCopy,\n  ControlPanelHeader,\n  ControlPanelReset,\n  ControlPanelTitle,\n} from \"@/components/ui/control-panel/control-panel\"\n\nimport {\n  SECTION_LABEL_KEYS,\n  formatLabel,\n  type Settings01Labels,\n} from \"./config\"\nimport type { Settings01SectionId, Settings01Values } from \"./types\"\n\ntype SetValue = <Key extends keyof Settings01Values>(\n  key: Key,\n  value: Settings01Values[Key],\n) => void\n\n/** 每个分区组件收到的同一组属性 */\ntype SectionProps = {\n  values: Settings01Values\n  labels: Settings01Labels\n  set: SetValue\n  /** 某一项是否与默认值不同，传给控件的 `modified` */\n  modified: (key: keyof Settings01Values) => boolean\n  /** 本分区有几项不是默认值 */\n  count: number\n  /** 把本分区恢复为默认值 */\n  onReset: () => void\n  /** 本分区当前取值的 JSON，复制按钮用 */\n  getCode: () => string\n}\n\n/**\n * 分区外壳：标题与说明 + 控制面板（头部显示本分区已修改项数，带复制与恢复）。\n * 有 `aside` 时在宽屏放到右侧，窄屏排在面板上方。\n */\nfunction SectionLayout({\n  id,\n  labels,\n  count,\n  onReset,\n  getCode,\n  aside,\n  children,\n}: Pick<SectionProps, \"labels\" | \"count\" | \"onReset\" | \"getCode\"> & {\n  id: Settings01SectionId\n  aside?: React.ReactNode\n  children: React.ReactNode\n}) {\n  const headingId = useId()\n  const keys = SECTION_LABEL_KEYS[id]\n  return (\n    <section\n      id={`settings-01-${id}`}\n      aria-labelledby={headingId}\n      data-slot=\"settings-01-section\"\n      data-section={id}\n      className=\"flex flex-col gap-4\"\n    >\n      <header>\n        <h2\n          id={headingId}\n          className=\"text-base font-semibold tracking-tight\"\n        >\n          {labels[keys.title]}\n        </h2>\n        <p className=\"mt-1 text-sm leading-6 text-muted-foreground\">\n          {labels[keys.description]}\n        </p>\n      </header>\n      <div\n        className={cn(\n          \"grid items-start gap-6\",\n          aside && \"lg:grid-cols-[minmax(0,1fr)_16rem]\",\n        )}\n      >\n        <ControlPanel className={cn(\"max-w-2xl\", aside && \"lg:max-w-none\")}>\n          <ControlPanelHeader>\n            <ControlPanelTitle>\n              {count > 0\n                ? formatLabel(labels.panelModified, { count })\n                : labels.panelDefault}\n            </ControlPanelTitle>\n            <ControlPanelActions>\n              <ControlPanelCopy\n                code={getCode}\n                label={labels.copySection}\n                copiedLabel={labels.copiedSection}\n              />\n              <ControlPanelReset\n                label={labels.resetSection}\n                disabled={count === 0}\n                onClick={onReset}\n              />\n            </ControlPanelActions>\n          </ControlPanelHeader>\n          {children}\n        </ControlPanel>\n        {aside ? (\n          <div\n            data-slot=\"settings-01-aside\"\n            className=\"order-first lg:sticky lg:top-6 lg:order-none\"\n          >\n            {aside}\n          </div>\n        ) : null}\n      </div>\n    </section>\n  )\n}\n\nexport { SectionLayout }\nexport type { SectionProps, SetValue }\n",
      "type": "registry:component",
      "target": "@components/settings-01/section-layout.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/section-nav.tsx",
      "content": "import type * as React from \"react\"\nimport { Bell, Code, Palette, ShieldCheck, Volume2 } from \"lucide-react\"\n\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\n\nimport {\n  SECTION_IDS,\n  SECTION_LABEL_KEYS,\n  formatLabel,\n  type Settings01Labels,\n} from \"./config\"\nimport type { Settings01SectionId } from \"./types\"\n\nconst SECTION_ICONS: Record<\n  Settings01SectionId,\n  React.ComponentType<{ className?: string }>\n> = {\n  appearance: Palette,\n  notifications: Bell,\n  sound: Volume2,\n  editor: Code,\n  privacy: ShieldCheck,\n}\n\n/** 宽屏左侧的分区导航：一行一个分区，右侧小圆标显示该分区已修改的项数。 */\nfunction SectionNav({\n  section,\n  onSectionChange,\n  counts,\n  labels,\n}: {\n  section: Settings01SectionId\n  onSectionChange: (section: Settings01SectionId) => void\n  counts: Record<Settings01SectionId, number>\n  labels: Settings01Labels\n}) {\n  return (\n    <nav\n      aria-label={labels.navLabel}\n      data-slot=\"settings-01-nav\"\n      className=\"hidden w-52 shrink-0 flex-col border-r border-edge md:flex\"\n    >\n      {SECTION_IDS.map((id) => {\n        const Icon = SECTION_ICONS[id]\n        const active = id === section\n        const count = counts[id]\n        return (\n          <button\n            key={id}\n            type=\"button\"\n            aria-current={active ? \"page\" : undefined}\n            data-slot=\"settings-01-nav-item\"\n            onClick={() => onSectionChange(id)}\n            className=\"relative flex h-10 w-full shrink-0 cursor-pointer items-center gap-2.5 border-b border-edge px-4 text-start text-sm text-muted-foreground outline-none transition-colors before:absolute before:inset-y-0 before:left-0 before:w-0.5 hover:bg-muted/50 hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset aria-[current=page]:bg-muted/60 aria-[current=page]:font-medium aria-[current=page]:text-foreground aria-[current=page]:before:bg-(--flow-tone)\"\n          >\n            <Icon className=\"size-4 shrink-0\" />\n            <span className=\"truncate\">{labels[SECTION_LABEL_KEYS[id].title]}</span>\n            {count > 0 ? (\n              <span\n                data-slot=\"settings-01-nav-count\"\n                title={formatLabel(labels.navSectionModified, { count })}\n                className=\"ms-auto min-w-5 rounded-full bg-foreground/10 px-1.5 text-center text-[11px] leading-5 text-foreground tabular-nums\"\n              >\n                {count}\n                <span className=\"sr-only\">\n                  {formatLabel(labels.navSectionModified, { count })}\n                </span>\n              </span>\n            ) : null}\n          </button>\n        )\n      })}\n    </nav>\n  )\n}\n\n/** 窄屏顶部的分段选择：用短名，五项刚好排进 375px。 */\nfunction SectionTabs({\n  section,\n  onSectionChange,\n  labels,\n  tone,\n}: {\n  section: Settings01SectionId\n  onSectionChange: (section: Settings01SectionId) => void\n  labels: Settings01Labels\n  tone: string\n}) {\n  return (\n    <div\n      data-slot=\"settings-01-tabs\"\n      className=\"border-b border-edge p-4 sm:px-6 md:hidden\"\n    >\n      <SegmentedControl\n        aria-label={labels.navLabel}\n        tone={tone}\n        value={section}\n        onValueChange={(next) => onSectionChange(next as Settings01SectionId)}\n        options={SECTION_IDS.map((id) => ({\n          value: id,\n          label: labels[SECTION_LABEL_KEYS[id].nav],\n        }))}\n      />\n    </div>\n  )\n}\n\nexport { SectionNav, SectionTabs }\n",
      "type": "registry:component",
      "target": "@components/settings-01/section-nav.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/previews.tsx",
      "content": "import type * as React from \"react\"\nimport { Monitor, Moon, Sparkles, Sun } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { flowToneStyle } from \"@/lib/flow-tone\"\n\nimport type { Settings01Labels } from \"./config\"\nimport type { Density, Settings01Values, ThemeMode } from \"./types\"\n\nconst DENSITY_CLASSES: Record<Density, string> = {\n  compact: \"gap-2 p-3\",\n  comfortable: \"gap-3 p-4\",\n  spacious: \"gap-4 p-5\",\n}\n\nconst MODE_ICONS: Record<ThemeMode, React.ComponentType<{ className?: string }>> =\n  { light: Sun, dark: Moon, system: Monitor }\n\n/** 预览卡片的外框：标题栏 + 内容区。纯展示，对读屏隐藏。 */\nfunction PreviewFrame({\n  title,\n  badge,\n  dark = false,\n  className,\n  style,\n  children,\n}: {\n  title: string\n  badge?: React.ReactNode\n  /** 在卡片内套用深色主题变量 */\n  dark?: boolean\n  className?: string\n  style?: React.CSSProperties\n  children: React.ReactNode\n}) {\n  return (\n    <div\n      aria-hidden=\"true\"\n      data-slot=\"settings-01-preview\"\n      className={cn(\n        \"overflow-hidden rounded-lg border border-edge bg-muted/40 text-foreground\",\n        dark && \"dark bg-background\",\n        className,\n      )}\n      style={style}\n    >\n      <div className=\"flex h-10 items-center justify-between gap-2 border-b border-edge px-3 text-xs text-muted-foreground\">\n        <span className=\"truncate\">{title}</span>\n        {badge ? (\n          <span className=\"flex shrink-0 items-center gap-1 [&_svg]:size-3.5\">\n            {badge}\n          </span>\n        ) : null}\n      </div>\n      {children}\n    </div>\n  )\n}\n\n/**\n * 外观预览：一张小卡片，随主题模式、强调色、字号、圆角、信息密度和动态效果实时变化。\n * 深色用 `.dark` 变量在卡片内套用；站点本身已是深色时，浅色无法在卡片里反向还原，所以标题栏另外写出当前模式。\n */\nfunction AppearancePreview({\n  values,\n  labels,\n}: {\n  values: Settings01Values\n  labels: Settings01Labels\n}) {\n  const ModeIcon = MODE_ICONS[values.theme]\n  const modeLabel = {\n    light: labels.previewModeLight,\n    dark: labels.previewModeDark,\n    system: labels.previewModeSystem,\n  }[values.theme]\n  return (\n    <PreviewFrame\n      title={labels.previewTitle}\n      dark={values.theme === \"dark\"}\n      badge={\n        <>\n          <ModeIcon />\n          {modeLabel}\n        </>\n      }\n      style={\n        {\n          ...flowToneStyle(values.accent),\n          \"--preview-radius\": `${values.radius}px`,\n        } as React.CSSProperties\n      }\n    >\n      <div className=\"p-3\">\n        <div\n          className={cn(\n            \"flex flex-col rounded-(--preview-radius) border border-edge bg-background shadow-xs transition-[gap,padding] duration-200 motion-reduce:transition-none\",\n            DENSITY_CLASSES[values.density],\n          )}\n          style={{ fontSize: values.fontSize }}\n        >\n          <div className=\"flex items-center gap-2.5\">\n            <span className=\"flex size-8 shrink-0 items-center justify-center rounded-(--preview-radius) bg-(--flow-tone)/15 text-(--flow-tone)\">\n              <Sparkles className=\"size-4\" />\n            </span>\n            <div className=\"min-w-0 flex-1\">\n              <p className=\"truncate text-[1.1em] leading-tight font-medium\">\n                {labels.previewHeading}\n              </p>\n              <p className=\"flex items-center gap-1.5 text-[0.8em] text-muted-foreground\">\n                <span\n                  className={cn(\n                    \"size-1.5 rounded-full bg-(--flow-tone)\",\n                    !values.reduceMotion && \"animate-pulse motion-reduce:animate-none\",\n                  )}\n                />\n                {labels.previewLive}\n              </p>\n            </div>\n          </div>\n          <p className=\"text-[1em] leading-snug text-muted-foreground\">\n            {labels.previewBody}\n          </p>\n          <div className=\"flex flex-col gap-1.5\">\n            <div className=\"flex items-center justify-between text-[0.8em] text-muted-foreground\">\n              <span>{labels.previewProgress}</span>\n              <span className=\"tabular-nums\">72%</span>\n            </div>\n            <div className=\"h-1.5 overflow-hidden rounded-full bg-muted\">\n              <div className=\"h-full w-[72%] rounded-full bg-(--flow-tone)\" />\n            </div>\n          </div>\n          {/* 模拟按钮：高度取默认档 32px，圆角跟随预览圆角 */}\n          <span className=\"inline-flex h-8 items-center justify-center self-start rounded-(--preview-radius) border border-(--flow-tone) bg-(--flow-tone)/10 px-3 text-[0.9em] font-medium\">\n            {labels.previewAction}\n          </span>\n        </div>\n      </div>\n    </PreviewFrame>\n  )\n}\n\n/** 示例代码：level 是嵌套层级 */\nconst SAMPLE_CODE = [\n  { level: 0, text: \"function greet(name) {\" },\n  { level: 1, text: \"if (name) {\" },\n  { level: 2, text: \"return `Hi, ${name}`\" },\n  { level: 1, text: \"}\" },\n  { level: 1, text: 'return \"Hi\"' },\n  { level: 0, text: \"}\" },\n] as const\n\nconst INDENT_WIDTH = { \"2\": 2, \"4\": 4, tab: 4 } as const\n\n/** 编辑器预览：缩进宽度、行高与空白字符的显示会实时变化。 */\nfunction EditorPreview({\n  values,\n  labels,\n}: {\n  values: Settings01Values\n  labels: Settings01Labels\n}) {\n  const width = INDENT_WIDTH[values.indent]\n  const marker = values.indent === \"tab\" ? \"→\" : \"·\".repeat(width)\n  return (\n    <PreviewFrame title={labels.editorPreviewTitle}>\n      <pre\n        className=\"overflow-hidden bg-background p-3 font-mono text-xs\"\n        style={{ lineHeight: values.lineHeight }}\n      >\n        {SAMPLE_CODE.map((line, index) => (\n          <div key={index} className=\"flex\">\n            <span className=\"w-5 shrink-0 pe-2 text-end text-muted-foreground/60 tabular-nums select-none\">\n              {index + 1}\n            </span>\n            {Array.from({ length: line.level }, (_, unit) => (\n              <span\n                key={unit}\n                className=\"inline-block shrink-0 overflow-hidden text-muted-foreground/50\"\n                style={{ width: `${width}ch` }}\n              >\n                {values.showTabs ? marker : \"\"}\n              </span>\n            ))}\n            <span className=\"whitespace-pre\">{line.text}</span>\n          </div>\n        ))}\n      </pre>\n    </PreviewFrame>\n  )\n}\n\nexport { AppearancePreview, EditorPreview }\n",
      "type": "registry:component",
      "target": "@components/settings-01/previews.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/appearance-section.tsx",
      "content": "import { Monitor, Moon, Sun } from \"lucide-react\"\n\nimport { ControlPanelGroup } from \"@/components/ui/control-panel/control-panel\"\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\nimport { TonePicker } from \"@/components/ui/tone-picker/tone-picker\"\nimport { ValueSlider } from \"@/components/ui/value-slider/value-slider\"\n\nimport { formatLabel } from \"./config\"\nimport { AppearancePreview } from \"./previews\"\nimport { SectionLayout, type SectionProps } from \"./section-layout\"\nimport type { Density, ThemeMode } from \"./types\"\n\n/** 外观：主题、强调色、字号、圆角、信息密度、动态效果，右侧是实时预览。 */\nfunction AppearanceSection(props: SectionProps) {\n  const { values, labels, set, modified } = props\n  const tone = values.accent\n  return (\n    <SectionLayout\n      id=\"appearance\"\n      {...props}\n      aside={<AppearancePreview values={values} labels={labels} />}\n    >\n      <ControlPanelGroup title={labels.groupTheme}>\n        <SegmentedControl\n          label={labels.theme}\n          tone={tone}\n          value={values.theme}\n          onValueChange={(next) => set(\"theme\", next as ThemeMode)}\n          modified={modified(\"theme\")}\n          options={[\n            { value: \"light\", label: labels.themeLight, icon: <Sun /> },\n            { value: \"dark\", label: labels.themeDark, icon: <Moon /> },\n            { value: \"system\", label: labels.themeSystem, icon: <Monitor /> },\n          ]}\n        />\n        <TonePicker\n          label={labels.accent}\n          value={values.accent}\n          onValueChange={(next) => set(\"accent\", next)}\n          modified={modified(\"accent\")}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupShape} columns={2}>\n        <ValueSlider\n          label={labels.fontSize}\n          tone={tone}\n          min={12}\n          max={20}\n          step={1}\n          editable\n          formatValue={(value) =>\n            formatLabel(labels.readoutPx, { value })\n          }\n          value={values.fontSize}\n          onValueChange={(next) => set(\"fontSize\", next)}\n          modified={modified(\"fontSize\")}\n        />\n        <ValueSlider\n          label={labels.radius}\n          tone={tone}\n          min={0}\n          max={20}\n          step={1}\n          editable\n          formatValue={(value) =>\n            formatLabel(labels.readoutPx, { value })\n          }\n          value={values.radius}\n          onValueChange={(next) => set(\"radius\", next)}\n          modified={modified(\"radius\")}\n        />\n        <SegmentedControl\n          className=\"sm:col-span-2\"\n          label={labels.density}\n          tone={tone}\n          value={values.density}\n          onValueChange={(next) => set(\"density\", next as Density)}\n          modified={modified(\"density\")}\n          options={[\n            { value: \"compact\", label: labels.densityCompact },\n            { value: \"comfortable\", label: labels.densityComfortable },\n            { value: \"spacious\", label: labels.densitySpacious },\n          ]}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupMotion}>\n        <ToggleSwitch\n          label={labels.reduceMotion}\n          description={labels.reduceMotionHint}\n          tone={tone}\n          checked={values.reduceMotion}\n          onCheckedChange={(next) => set(\"reduceMotion\", next)}\n          modified={modified(\"reduceMotion\")}\n        />\n      </ControlPanelGroup>\n    </SectionLayout>\n  )\n}\n\nexport { AppearanceSection }\n",
      "type": "registry:component",
      "target": "@components/settings-01/appearance-section.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/notifications-section.tsx",
      "content": "import { ControlPanelGroup } from \"@/components/ui/control-panel/control-panel\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\nimport { ValueSlider } from \"@/components/ui/value-slider/value-slider\"\n\nimport { SectionLayout, type SectionProps } from \"./section-layout\"\nimport { formatHour } from \"./utils\"\n\n/** 一天里从中午到次日中午，免打扰通常跨午夜，所以滑块范围取 12–36 */\nconst QUIET_MIN = 12\nconst QUIET_MAX = 36\n\n/** 通知：总开关控制其余开关的禁用态，免打扰时段是区间滑块。 */\nfunction NotificationsSection(props: SectionProps) {\n  const { values, labels, set, modified } = props\n  const tone = values.accent\n  const off = !values.notifications\n  return (\n    <SectionLayout id=\"notifications\" {...props}>\n      <ControlPanelGroup title={labels.groupChannels} columns={2}>\n        <ToggleSwitch\n          className=\"sm:col-span-2\"\n          label={labels.notifications}\n          description={labels.notificationsHint}\n          tone={tone}\n          checked={values.notifications}\n          onCheckedChange={(next) => set(\"notifications\", next)}\n          modified={modified(\"notifications\")}\n        />\n        <ToggleSwitch\n          label={labels.notifyMentions}\n          description={labels.notifyMentionsHint}\n          tone={tone}\n          disabled={off}\n          checked={values.notifyMentions}\n          onCheckedChange={(next) => set(\"notifyMentions\", next)}\n          modified={modified(\"notifyMentions\")}\n        />\n        <ToggleSwitch\n          label={labels.notifyReplies}\n          description={labels.notifyRepliesHint}\n          tone={tone}\n          disabled={off}\n          checked={values.notifyReplies}\n          onCheckedChange={(next) => set(\"notifyReplies\", next)}\n          modified={modified(\"notifyReplies\")}\n        />\n        <ToggleSwitch\n          label={labels.notifyEmail}\n          description={labels.notifyEmailHint}\n          tone={tone}\n          disabled={off}\n          checked={values.notifyEmail}\n          onCheckedChange={(next) => set(\"notifyEmail\", next)}\n          modified={modified(\"notifyEmail\")}\n        />\n        <ToggleSwitch\n          label={labels.notifyUpdates}\n          description={labels.notifyUpdatesHint}\n          tone={tone}\n          disabled={off}\n          checked={values.notifyUpdates}\n          onCheckedChange={(next) => set(\"notifyUpdates\", next)}\n          modified={modified(\"notifyUpdates\")}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupQuiet}>\n        {/* 区间读数较长，用矮轨让标签与读数排在轨道上方，窄屏也不会被手柄压住 */}\n        <ValueSlider\n          label={labels.quietHours}\n          variant=\"slim\"\n          tone={tone}\n          min={QUIET_MIN}\n          max={QUIET_MAX}\n          step={0.5}\n          largeStep={3}\n          minStepsBetweenValues={1}\n          ticks={[18, 24, 30]}\n          disabled={off}\n          formatValue={formatHour}\n          value={values.quietHours}\n          onValueChange={(next) => set(\"quietHours\", [next[0], next[1]])}\n          modified={modified(\"quietHours\")}\n        />\n      </ControlPanelGroup>\n    </SectionLayout>\n  )\n}\n\nexport { NotificationsSection }\n",
      "type": "registry:component",
      "target": "@components/settings-01/notifications-section.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/sound-section.tsx",
      "content": "import { Volume2, VolumeX } from \"lucide-react\"\n\nimport { ControlPanelGroup } from \"@/components/ui/control-panel/control-panel\"\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\nimport { ValueSlider } from \"@/components/ui/value-slider/value-slider\"\n\nimport { SectionLayout, type SectionProps } from \"./section-layout\"\nimport type { SoundTheme } from \"./types\"\n\n/** 声音与触感：主音量带拖动音效，音色在按键音效关闭时禁用。 */\nfunction SoundSection(props: SectionProps) {\n  const { values, labels, set, modified } = props\n  const tone = values.accent\n  return (\n    <SectionLayout id=\"sound\" {...props}>\n      <ControlPanelGroup title={labels.groupVolume}>\n        <ValueSlider\n          label={labels.volume}\n          tone={tone}\n          sound\n          editable\n          min={0}\n          max={100}\n          step={1}\n          startIcon={<VolumeX />}\n          endIcon={<Volume2 />}\n          value={values.volume}\n          onValueChange={(next) => set(\"volume\", next)}\n          modified={modified(\"volume\")}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupFeedback} columns={2}>\n        <ToggleSwitch\n          label={labels.keySound}\n          description={labels.keySoundHint}\n          tone={tone}\n          checked={values.keySound}\n          onCheckedChange={(next) => set(\"keySound\", next)}\n          modified={modified(\"keySound\")}\n        />\n        <ToggleSwitch\n          label={labels.haptics}\n          description={labels.hapticsHint}\n          tone={tone}\n          checked={values.haptics}\n          onCheckedChange={(next) => set(\"haptics\", next)}\n          modified={modified(\"haptics\")}\n        />\n        <SegmentedControl\n          className=\"sm:col-span-2\"\n          label={labels.soundTheme}\n          tone={tone}\n          disabled={!values.keySound}\n          value={values.soundTheme}\n          onValueChange={(next) => set(\"soundTheme\", next as SoundTheme)}\n          modified={modified(\"soundTheme\")}\n          options={[\n            { value: \"soft\", label: labels.soundSoft },\n            { value: \"crisp\", label: labels.soundCrisp },\n            { value: \"mechanical\", label: labels.soundMechanical },\n          ]}\n        />\n      </ControlPanelGroup>\n    </SectionLayout>\n  )\n}\n\nexport { SoundSection }\n",
      "type": "registry:component",
      "target": "@components/settings-01/sound-section.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/editor-section.tsx",
      "content": "import { ControlPanelGroup } from \"@/components/ui/control-panel/control-panel\"\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\nimport { ValueSlider } from \"@/components/ui/value-slider/value-slider\"\n\nimport { EditorPreview } from \"./previews\"\nimport { SectionLayout, type SectionProps } from \"./section-layout\"\nimport type { IndentWidth } from \"./types\"\n\n/** 编辑器：缩进、行高与制表符显示，右侧是代码预览。 */\nfunction EditorSection(props: SectionProps) {\n  const { values, labels, set, modified } = props\n  const tone = values.accent\n  return (\n    <SectionLayout\n      id=\"editor\"\n      {...props}\n      aside={<EditorPreview values={values} labels={labels} />}\n    >\n      <ControlPanelGroup title={labels.groupIndent}>\n        <SegmentedControl\n          label={labels.indent}\n          tone={tone}\n          value={values.indent}\n          onValueChange={(next) => set(\"indent\", next as IndentWidth)}\n          modified={modified(\"indent\")}\n          options={[\n            { value: \"2\", label: labels.indentTwo },\n            { value: \"4\", label: labels.indentFour },\n            { value: \"tab\", label: labels.indentTab },\n          ]}\n        />\n        <ValueSlider\n          label={labels.lineHeight}\n          tone={tone}\n          editable\n          min={1.2}\n          max={2}\n          step={0.1}\n          value={values.lineHeight}\n          onValueChange={(next) => set(\"lineHeight\", next)}\n          modified={modified(\"lineHeight\")}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupWhitespace}>\n        <ToggleSwitch\n          label={labels.showTabs}\n          description={labels.showTabsHint}\n          tone={tone}\n          checked={values.showTabs}\n          onCheckedChange={(next) => set(\"showTabs\", next)}\n          modified={modified(\"showTabs\")}\n        />\n      </ControlPanelGroup>\n    </SectionLayout>\n  )\n}\n\nexport { EditorSection }\n",
      "type": "registry:component",
      "target": "@components/settings-01/editor-section.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/privacy-section.tsx",
      "content": "import { ControlPanelGroup } from \"@/components/ui/control-panel/control-panel\"\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\nimport { ValueSlider } from \"@/components/ui/value-slider/value-slider\"\n\nimport { formatLabel } from \"./config\"\nimport { SectionLayout, type SectionProps } from \"./section-layout\"\nimport type { ProfileVisibility } from \"./types\"\n\n/** 隐私：资料可见范围、数据收集开关与历史保留天数。 */\nfunction PrivacySection(props: SectionProps) {\n  const { values, labels, set, modified } = props\n  const tone = values.accent\n  return (\n    <SectionLayout id=\"privacy\" {...props}>\n      <ControlPanelGroup title={labels.groupProfile}>\n        <SegmentedControl\n          label={labels.visibility}\n          tone={tone}\n          value={values.visibility}\n          onValueChange={(next) => set(\"visibility\", next as ProfileVisibility)}\n          modified={modified(\"visibility\")}\n          options={[\n            { value: \"public\", label: labels.visibilityPublic },\n            { value: \"team\", label: labels.visibilityTeam },\n            { value: \"private\", label: labels.visibilityPrivate },\n          ]}\n        />\n      </ControlPanelGroup>\n      <ControlPanelGroup title={labels.groupData} columns={2}>\n        <ToggleSwitch\n          label={labels.analytics}\n          description={labels.analyticsHint}\n          tone={tone}\n          checked={values.analytics}\n          onCheckedChange={(next) => set(\"analytics\", next)}\n          modified={modified(\"analytics\")}\n        />\n        <ToggleSwitch\n          label={labels.crashReports}\n          description={labels.crashReportsHint}\n          tone={tone}\n          checked={values.crashReports}\n          onCheckedChange={(next) => set(\"crashReports\", next)}\n          modified={modified(\"crashReports\")}\n        />\n        <ValueSlider\n          className=\"sm:col-span-2\"\n          label={labels.retention}\n          tone={tone}\n          editable\n          min={7}\n          max={365}\n          step={1}\n          largeStep={30}\n          ticks={[30, 90, 180]}\n          snapToTicks\n          formatValue={(value) => formatLabel(labels.readoutDays, { value })}\n          value={values.retention}\n          onValueChange={(next) => set(\"retention\", next)}\n          modified={modified(\"retention\")}\n        />\n      </ControlPanelGroup>\n    </SectionLayout>\n  )\n}\n\nexport { PrivacySection }\n",
      "type": "registry:component",
      "target": "@components/settings-01/privacy-section.tsx"
    },
    {
      "path": "src/registry/blocks/settings-01/use-save-action.ts",
      "content": "\"use client\"\n\nimport { useCallback, useState } from \"react\"\n\nimport { DEFAULT_LABELS } from \"./config\"\nimport { errorMessage } from \"./utils\"\n\ntype SaveStatus = \"idle\" | \"pending\" | \"saved\" | \"error\"\n\n/** 包装保存动作：管理 loading，成功后记为 saved，抛出的错误转成可展示的文案。 */\nfunction useSaveAction(fallbackError: string = DEFAULT_LABELS.saveFailed) {\n  const [status, setStatus] = useState<SaveStatus>(\"idle\")\n  const [error, setError] = useState<string | null>(null)\n  const run = useCallback(\n    async (action: () => Promise<void>) => {\n      setStatus(\"pending\")\n      setError(null)\n      try {\n        await action()\n        setStatus(\"saved\")\n        return true\n      } catch (caught) {\n        setError(errorMessage(caught, fallbackError))\n        setStatus(\"error\")\n        return false\n      }\n    },\n    [fallbackError],\n  )\n  /** 回到空闲：设置被再次修改后，「已保存」「出错」的提示就该消失 */\n  const reset = useCallback(() => {\n    setStatus(\"idle\")\n    setError(null)\n  }, [])\n  return { status, error, run, reset }\n}\n\nexport { useSaveAction }\nexport type { SaveStatus }\n",
      "type": "registry:component",
      "target": "@components/settings-01/use-save-action.ts"
    },
    {
      "path": "src/registry/blocks/settings-01/changes.tsx",
      "content": "\"use client\"\n\nimport { useSyncExternalStore } from \"react\"\nimport { ArrowRight, Undo2 } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Item, ItemContent, ItemTitle, ItemDescription, ItemGroup } from \"@/components/ui/item\"\nimport { Popover, PopoverTrigger, PopoverContent, PopoverTitle } from \"@/components/ui/popover\"\nimport { Sheet, SheetTrigger, SheetContent, SheetTitle } from \"@/components/ui/sheet\"\nimport { flowToneStyle } from \"@/lib/flow-tone\"\n\nimport { SECTION_LABEL_KEYS, formatLabel, type Settings01Labels } from \"./config\"\nimport type { Settings01SectionId, Settings01Values } from \"./types\"\nimport { formatHour } from \"./utils\"\n\nfunction subscribe(callback: () => void) {\n  const media = window.matchMedia(\"(max-width: 767px)\")\n  media.addEventListener(\"change\", callback)\n  return () => media.removeEventListener(\"change\", callback)\n}\n\n/** 所有字段的对比读数在这里统一格式化。 */\nfunction formatSetting(key: keyof Settings01Values, value: Settings01Values[keyof Settings01Values], labels: Settings01Labels): string {\n  if (typeof value === \"boolean\") return value ? labels.valueOn : labels.valueOff\n  if (Array.isArray(value)) return value.map((hour) => formatHour(hour)).join(\" – \")\n  if (key === \"fontSize\" || key === \"radius\") return formatLabel(labels.readoutPx, { value: String(value) })\n  if (key === \"retention\") return formatLabel(labels.readoutDays, { value: String(value) })\n  if (key === \"volume\") return `${value}%`\n  const options: Partial<Record<keyof Settings01Values, Record<string, string>>> = {\n    theme: { light: labels.themeLight, dark: labels.themeDark, system: labels.themeSystem },\n    density: { compact: labels.densityCompact, comfortable: labels.densityComfortable, spacious: labels.densitySpacious },\n    soundTheme: { soft: labels.soundSoft, crisp: labels.soundCrisp, mechanical: labels.soundMechanical },\n    indent: { \"2\": labels.indentTwo, \"4\": labels.indentFour, tab: labels.indentTab },\n    visibility: { public: labels.visibilityPublic, team: labels.visibilityTeam, private: labels.visibilityPrivate },\n  }\n  return options[key]?.[String(value)] ?? String(value)\n}\n\nfunction Settings01Changes({ changes, values, defaults, labels, pending, dirty, onUndo, onReset, onSave }: {\n  changes: { key: keyof Settings01Values; section: Settings01SectionId }[]\n  values: Settings01Values\n  defaults: Settings01Values\n  labels: Settings01Labels\n  pending: boolean\n  dirty: boolean\n  onUndo: (key: keyof Settings01Values) => void\n  onReset: () => void\n  onSave: () => void\n}) {\n  const mobile = useSyncExternalStore(subscribe, () => window.matchMedia(\"(max-width: 767px)\").matches, () => false)\n  const trigger = <Button variant=\"ghost\" disabled={!changes.length || pending} className=\"max-w-full justify-start px-0 tabular-nums\">{changes.length ? formatLabel(labels.modifiedCount, { count: changes.length }) : labels.unmodified}</Button>\n  const content = (\n    <div data-slot=\"settings-01-changes\" className=\"min-w-0\">\n      <ItemGroup className=\"max-h-[55svh] gap-0 overflow-y-auto\">\n        {changes.map(({ key, section }) => (\n          <Item key={key} role=\"listitem\" size=\"xs\" className=\"flex-nowrap gap-2 px-0\">\n            <ItemContent className=\"min-w-0\">\n              <ItemTitle>{labels[key]}</ItemTitle>\n              <ItemDescription className=\"text-xs\">{labels[SECTION_LABEL_KEYS[section].title]}</ItemDescription>\n            </ItemContent>\n            <div className=\"flex min-w-0 flex-wrap items-center justify-end gap-1 text-xs\">\n              <span className=\"inline-flex items-center gap-1 text-muted-foreground line-through\">\n                {key === \"accent\" && <span aria-hidden className=\"size-2.5 rounded-sm bg-(--flow-tone)\" style={flowToneStyle(String(defaults[key]))} />}\n                {formatSetting(key, defaults[key], labels)}\n              </span>\n              <ArrowRight aria-hidden className=\"size-3 shrink-0 text-muted-foreground\" />\n              <span className=\"inline-flex items-center gap-1 font-medium text-foreground\">\n                {key === \"accent\" && <span aria-hidden className=\"size-2.5 rounded-sm bg-(--flow-tone)\" style={flowToneStyle(String(values[key]))} />}\n                {formatSetting(key, values[key], labels)}\n              </span>\n            </div>\n            {/* 行内次要操作使用 icon-sm；底部主操作统一 default。 */}\n            <Button variant=\"ghost\" size=\"icon-sm\" disabled={pending} aria-label={formatLabel(labels.undoChange, { field: labels[key] })} onClick={() => onUndo(key)}><Undo2 aria-hidden /></Button>\n          </Item>\n        ))}\n      </ItemGroup>\n      <div className=\"mt-3 flex justify-end gap-2 border-t border-edge pt-3\">\n        <Button variant=\"outline\" disabled={!changes.length || pending} onClick={onReset}>{labels.resetChanges}</Button>\n        <Button disabled={!dirty || pending} onClick={onSave}>{pending ? labels.saving : labels.save}</Button>\n      </div>\n    </div>\n  )\n  return mobile ? (\n    <Sheet>\n      <SheetTrigger render={trigger} />\n      <SheetContent side=\"bottom\" className=\"p-4 pb-[max(1rem,env(safe-area-inset-bottom))]\">\n        <SheetTitle>{labels.changesTitle}</SheetTitle>\n        {content}\n      </SheetContent>\n    </Sheet>\n  ) : (\n    <Popover>\n      <PopoverTrigger render={trigger} />\n      <PopoverContent side=\"top\" align=\"start\" className=\"w-88 max-w-[calc(100vw-2rem)] p-4\">\n        <PopoverTitle>{labels.changesTitle}</PopoverTitle>\n        {content}\n      </PopoverContent>\n    </Popover>\n  )\n}\n\nexport { Settings01Changes }\n",
      "type": "registry:component",
      "target": "@components/settings-01/changes.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-edge": "var(--edge)"
    },
    "light": {
      "edge": "color-mix(in oklch, var(--foreground) 12%, transparent)"
    },
    "dark": {
      "edge": "color-mix(in oklch, var(--foreground) 18%, transparent)"
    }
  },
  "meta": {
    "iframeHeight": "860px"
  },
  "type": "registry:block"
}
