{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-block",
  "type": "registry:item",
  "title": "Settings Block",
  "description": "An account settings page: profile, notification switches, light or dark appearance, and a delete that asks first. `value` holds it all and is two-way; Save fires `save`.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "block"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json",
    "https://zubra-js.github.io/zubra-ui/r/toggle-switch.json",
    "https://zubra-js.github.io/zubra-ui/r/segmented-control.json",
    "https://zubra-js.github.io/zubra-ui/r/modal-dialog.json"
  ],
  "files": [
    {
      "path": "components/settings-block.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/settings-block.js",
      "content": "// Generated by zubra from settings-block.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit, id } from '@zubra/runtime';\nimport \"./toggle-switch.js\";\nimport \"./segmented-control.js\";\nimport \"./modal-dialog.js\";\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"settings-block\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: {\"name\":\"\",\"email\":\"\",\"notifications\":{},\"theme\":\"system\"}, required: false, model: true },\n    \"notifications\": { attribute: \"notifications\", default: [], required: false },\n    \"heading\": { attribute: \"heading\", default: \"Settings\", required: false },\n    \"busy\": { attribute: \"busy\", default: false, required: false },\n    \"status\": { attribute: \"status\", default: \"\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"valuechange\", \"save\", \"delete\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (settings-block) to ([data-zb-slotted=\\\"settings-block\\\"]) {\\n  :scope { display: block; max-width: 42rem; }\\n  form { display: grid; gap: 1.25rem; }\\n  section { display: grid; gap: 0.9rem; padding: 1.25rem; border: 1px solid var(--border, #e4e4e7); border-radius: calc(var(--radius, 0.625rem) + 2px); background: var(--card, #fff); color: var(--card-foreground, #09090b); }\\n  h2 { margin: 0 0 0.25rem; font-size: 1.5rem; letter-spacing: -0.01em; }\\n  h3 { margin: 0; font-size: 1.05rem; }\\n  .settings-hint { margin: -0.6rem 0 0; color: var(--muted-foreground, #71717a); font-size: 0.875rem; }\\n  .settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.9rem; }\\n  label { display: grid; gap: 0.35rem; font-size: 0.875rem; font-weight: 600; }\\n  input { box-sizing: border-box; width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--input, var(--border, #e4e4e7)); border-radius: calc(var(--radius, 0.625rem) - 2px); background: var(--background, #fff); color: inherit; font: inherit; font-weight: 400; }\\n  input:focus-visible { outline: 2px solid var(--ring, #18181b); outline-offset: 1px; }\\n  .settings-appearance { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }\\n  .settings-danger { border-color: color-mix(in oklab, var(--destructive, #dc2626) 45%, var(--border, #e4e4e7)); }\\n  .settings-danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }\\n  .settings-danger-row p { margin: 0; color: var(--muted-foreground, #71717a); font-size: 0.875rem; }\\n  .settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }\\n  .settings-status { color: var(--muted-foreground, #71717a); font-size: 0.875rem; }\\n  .settings-button { padding: 0.55rem 1rem; border: 1px solid var(--border, #e4e4e7); border-radius: calc(var(--radius, 0.625rem) - 2px); background: var(--background, #fff); color: var(--foreground, #09090b); font: inherit; font-weight: 600; cursor: pointer; }\\n  .settings-button:hover { background: var(--accent, #f4f4f5); }\\n  .settings-primary { border-color: var(--primary, #18181b); background: var(--primary, #18181b); color: var(--primary-foreground, #fafafa); }\\n  .settings-primary:hover { background: var(--primary, #18181b); opacity: 0.92; }\\n  /* White on the theme's red, darkened a little: readable in light and dark (shadcn's dark red is light). */\\n  .settings-destructive { border-color: transparent; background: color-mix(in oklab, var(--destructive, #dc2626) 78%, black); color: #fff; }\\n  .settings-destructive:hover { background: color-mix(in oklab, var(--destructive, #dc2626) 78%, black); opacity: 0.92; }\\n  .settings-button:disabled { opacity: 0.6; cursor: progress; }\\n  .settings-button:focus-visible { outline: 2px solid var(--ring, #18181b); outline-offset: 2px; }\\n  .settings-confirm { display: flex; justify-content: flex-end; gap: 0.5rem; }\\n}\\n}\\n\",\n  template: \"\\n  <form>\\n    <h2></h2>\\n    <section>\\n      <h3>Profile</h3>\\n      <div class=\\\"settings-fields\\\">\\n        <label>Name<input name=\\\"name\\\" autocomplete=\\\"name\\\" required></label>\\n        <label>Email<input type=\\\"email\\\" name=\\\"email\\\" autocomplete=\\\"email\\\"></label>\\n      </div>\\n    </section>\\n    <!--[--><!--]-->\\n    <section>\\n      <div class=\\\"settings-appearance\\\">\\n        <h3>Appearance</h3>\\n        <segmented-control></segmented-control>\\n      </div>\\n    </section>\\n    <section class=\\\"settings-danger\\\">\\n      <h3>Delete account</h3>\\n      <div class=\\\"settings-danger-row\\\">\\n        <p>This removes your account and everything in it. It can't be undone.</p>\\n        <button type=\\\"button\\\" class=\\\"settings-button settings-destructive\\\">Delete account…</button>\\n      </div>\\n    </section>\\n    <div class=\\\"settings-actions\\\">\\n      <span class=\\\"settings-status\\\" role=\\\"status\\\"></span>\\n      <button type=\\\"submit\\\" class=\\\"settings-button settings-primary\\\"></button>\\n    </div>\\n  </form>\\n  <modal-dialog>\\n    <p>Your account, settings and history will be removed for good.</p>\\n    <div slot=\\\"actions\\\" class=\\\"settings-confirm\\\">\\n      <button type=\\\"button\\\" class=\\\"settings-button\\\">Cancel</button>\\n      <button type=\\\"button\\\" class=\\\"settings-button settings-destructive\\\">Delete account</button>\\n    </div>\\n  </modal-dialog>\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                           \n                             \n                                 \n                            \n\n  const THEMES = [{ value: \"light\", label: \"Light\" }, { value: \"dark\", label: \"Dark\" }, { value: \"system\", label: \"System\" }]\n  const nameId = id()\n  const emailId = id()\n  const confirming = __zubraState(false)\n  const saved = __zubraState(false)\n\n  function set(change) {\n    $p.value = { ...$p.value, ...change }\n    __zubraAssign(saved, false)\n  }\n  function setNotification(key, on) {\n    set({ notifications: { ...($p.value.notifications ?? {}), [key]: on } })\n  }\n  function save(event) {\n    event.preventDefault()\n    emit('save', $p.value)\n    __zubraAssign(saved, true)\n  }\n  const message = __zubraComputed(() => ($p.status || (saved.get() && !$p.busy ? \"Saved.\" : \"\")))\n    return [\n      { path: [0], on: \"submit\", handler: () => $r(save) },\n      { path: [0], attribute: \"aria-busy\", value: () => ($p.busy ? \"true\" : \"false\") },\n      { path: [0, 0], text: () => $t($p.heading) },\n      { path: [0, 1], attribute: \"aria-labelledby\", value: () => $r(nameId) },\n      { path: [0, 1, 0], attribute: \"id\", value: () => $r(nameId) },\n      { path: [0, 1, 1, 0, 0], attribute: \"value\", value: () => ($p.value.name ?? \"\") },\n      { path: [0, 1, 1, 0, 0], on: \"input\", handler: () => ((event) => set({ name: event.target.value })) },\n      { path: [0, 1, 1, 1, 0], attribute: \"id\", value: () => $r(emailId) },\n      { path: [0, 1, 1, 1, 0], attribute: \"value\", value: () => ($p.value.email ?? \"\") },\n      { path: [0, 1, 1, 1, 0], on: \"input\", handler: () => ((event) => set({ email: event.target.value })) },\n      { path: [0, 2], when: () => $p.notifications.length, blocks: [{ template: \"<section>\\n      <h3>Notifications</h3>\\n      <!--[--><!--]-->\\n    </section>\", parts: () => [{ path: [0, 1], each: () => $p.notifications, key: (item, $index) => $r(item).id, block: { template: \"\\n        <toggle-switch></toggle-switch>\\n      \", parts: (item, $index) => [{ path: [0], property: \"label\", value: () => $r(item).label }, { path: [0], property: \"description\", value: () => ($r(item).description ?? \"\") }, { path: [0], property: \"checked\", value: () => (Boolean($p.value.notifications?.[$r(item).id])) }, { path: [0], on: \"checkedchange\", handler: () => ((event) => setNotification($r(item).id, event.detail)) }] } }] }, null] },\n      { path: [0, 3, 0, 1], property: \"label\", value: () => \"Theme\" },\n      { path: [0, 3, 0, 1], property: \"options\", value: () => $r(THEMES) },\n      { path: [0, 3, 0, 1], property: \"value\", value: () => ($p.value.theme ?? \"system\") },\n      { path: [0, 3, 0, 1], on: \"valuechange\", handler: () => ((event) => set({ theme: event.detail })) },\n      { path: [0, 4, 1, 1], on: \"click\", handler: () => (() => (__zubraAssign(confirming, true))) },\n      { path: [0, 5, 0], text: () => $t($r(message)) },\n      { path: [0, 5, 1], attribute: \"disabled\", boolean: true, value: () => $p.busy },\n      { path: [0, 5, 1], text: () => $t(($p.busy ? \"Saving…\" : \"Save changes\")) },\n      { path: [1], property: \"label\", value: () => \"Delete your account?\" },\n      { path: [1], property: \"open\", value: () => $r(confirming) },\n      { path: [1], on: \"openchange\", handler: () => ((event) => (__zubraAssign(confirming, event.detail))) },\n      { path: [1, 1, 0], hydrate: [1, 0, 0, 2, 0, 0, 0, 0], on: \"click\", handler: () => (() => (__zubraAssign(confirming, false))) },\n      { path: [1, 1, 1], hydrate: [1, 0, 0, 2, 0, 0, 0, 1], on: \"click\", handler: () => (() => { __zubraAssign(confirming, false); emit('delete') }) },\n    ];\n  },\n});\n"
    }
  ]
}
