{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast-region",
  "type": "registry:item",
  "title": "Toast Region",
  "description": "Short notifications that appear in a corner and go away by themselves. Put one region on the page; anything (a framework, a plain script) shows a toast by dispatching an event, so nothing needs a reference to it: `document.dispatchEvent(new CustomEvent('toast', { detail: { message: 'Saved', variant: 'success' } }))`. `detail` takes `message`, `heading`, `variant` (info, success, warning, danger), `duration` in ms (0 keeps it until closed) and `action: { label, href }`. Toasts are announced politely (an error assertively), wait while hovered or focused, and sit above dialogs (the top layer).",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "app"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/toast-region.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/toast-region.js",
      "content": "// Generated by zubra from toast-region.zb. Do not edit.\nimport * as $motion from \"@zubra/runtime/motion\";\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit, onUnmount } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"toast-region\";\n\nexport default $define(tag, {\n  props: {\n    \"position\": { attribute: \"position\", default: \"bottom-end\", required: false },\n    \"duration\": { attribute: \"duration\", default: 5000, required: false },\n    \"max\": { attribute: \"max\", default: 3, required: false },\n    \"label\": { attribute: \"label\", default: \"Notifications\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"toastclose\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (toast-region) to ([data-zb-slotted=\\\"toast-region\\\"]) {\\n  :scope { display: contents; }\\n  .toast-region { position: fixed; inset: auto; margin: 0; padding: 1rem; border: 0; background: none; overflow: visible; display: grid; gap: 0.6rem; width: min(24rem, 100vw); box-sizing: border-box; pointer-events: none; }\\n  .toast-region:not(:popover-open) { display: none; }\\n  .toast-bottom-end { right: 0; bottom: 0; } .toast-bottom-start { left: 0; bottom: 0; } .toast-top-end { right: 0; top: 0; } .toast-top-start { left: 0; top: 0; }\\n  .toast-bottom-center { left: 50%; bottom: 0; translate: -50% 0; } .toast-top-center { left: 50%; top: 0; translate: -50% 0; }\\n  .toast-item { pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 0.15rem 0.7rem; align-items: start; padding: 0.85rem 0.9rem; border: 1px solid var(--border, #e4e4e7); border-radius: var(--radius, 0.625rem); background: var(--popover, #fff); color: var(--popover-foreground, #18181b); box-shadow: 0 10px 30px #0000001f; animation: enter var(--duration-normal, 200ms) var(--ease-out, ease-out); transition: opacity var(--duration-normal, 200ms) var(--ease-out, ease-out), translate var(--duration-normal, 200ms) var(--ease-out, ease-out); }\\n  .toast-item[data-leaving] { opacity: 0; translate: 0.75rem 0; }\\n  .toast-mark { width: 0.6rem; height: 0.6rem; margin-top: 0.4rem; border-radius: 50%; background: oklch(0.55 0.15 255); }\\n  .toast-success .toast-mark { background: oklch(0.6 0.15 150); } .toast-warning .toast-mark { background: oklch(0.75 0.15 75); } .toast-danger .toast-mark { background: var(--destructive, #dc2626); }\\n  .toast-content { display: grid; gap: 0.15rem; min-width: 0; }\\n  strong:empty { display: none; }\\n  .toast-message { color: color-mix(in oklab, var(--foreground, #18181b) 85%, var(--muted-foreground, #71717a)); }\\n  .toast-action { justify-self: start; margin-top: 0.3rem; color: var(--primary, #18181b); font-weight: 600; }\\n  .toast-close { width: 1.6rem; height: 1.6rem; margin: -0.2rem -0.3rem 0 0; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer; }\\n  .toast-close:hover { background: var(--accent, #f4f4f5); }\\n  .toast-close:focus-visible, .toast-action:focus-visible { outline: 2px solid var(--ring, #a1a1aa); outline-offset: 1px; }\\n  @keyframes enter { from { opacity: 0; transform: translateY(0.5rem) scale(0.98); } }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <!---->\\n  <section popover=\\\"manual\\\">\\n    \\n    <!--[--><!--]-->\\n  </section>\\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  const toasts = __zubraState([])\n  const region = __zubraState(null)\n  const paused = __zubraState(false)\n  const next = __zubraState(1)\n  const timers = new Map()\n\n  function remove(toast) {\n    clearTimeout(timers.get(toast.id))\n    timers.delete(toast.id)\n    __zubraAssign(toasts, toasts.get().filter((item) => item.id !== toast.id))\n    emit('toastclose', toast.message)\n  }\n  function schedule(toast) {\n    if (!toast.duration || paused.get()) return\n    clearTimeout(timers.get(toast.id))\n    timers.set(toast.id, setTimeout(() => remove(toast), toast.duration))\n  }\n  function show(event) {\n    const detail = typeof event.detail === \"string\" ? { message: event.detail } : event.detail ?? {}\n    const toast = { id: __zubraUpdate(next, 1, false), message: String(detail.message ?? \"\"), heading: detail.heading ?? \"\", variant: detail.variant ?? \"info\", duration: detail.duration ?? $p.duration, action: detail.action ?? null }\n    // The same message again replaces the one showing, rather than stacking a copy.\n    __zubraAssign(toasts, [...toasts.get().filter((item) => item.message !== toast.message || item.heading !== toast.heading).slice(-($p.max - 1)), toast])\n    // In the top layer, so a toast shows above an open modal dialog.\n    if (region.get() && !region.get().matches(\":popover-open\")) region.get().showPopover?.()\n    schedule(toast)\n  }\n  function pause(on) {\n    __zubraAssign(paused, on)\n    if (on) { timers.forEach((timer) => clearTimeout(timer)); timers.clear() }\n    else toasts.get().forEach(schedule)\n  }\n  // Escape closes the newest toast, unless a dialog or menu is using it.\n  function escape(event) {\n    if (!toasts.get().length || event.defaultPrevented || document.querySelector(\"dialog:modal, :popover-open:not(section)\")) return\n    remove(toasts.get()[toasts.get().length - 1])\n  }\n  onUnmount(() => timers.forEach((timer) => clearTimeout(timer)))\n    return [\n      { path: [0], global: \"document\", on: \"toast\", handler: () => $r(show) },\n      { path: [0], global: \"document\", on: \"keydown\", handler: () => $r(escape), modifiers: { keys: [\"Escape\"] } },\n      { path: [1], ref: () => (($el) => (__zubraAssign(region, $el))) },\n      { path: [1], attribute: \"class\", value: () => \"toast-region toast-\" + $t($p.position) },\n      { path: [1], attribute: \"aria-label\", value: () => $p.label },\n      { path: [1], on: \"mouseenter\", handler: () => (() => pause(true)) },\n      { path: [1], on: \"mouseleave\", handler: () => (() => pause(false)) },\n      { path: [1], on: \"focusin\", handler: () => (() => pause(true)) },\n      { path: [1], on: \"focusout\", handler: () => (() => pause(false)) },\n      { path: [1, 0], each: () => $r(toasts), key: (toast, $index) => $r(toast).id, block: { template: \"\\n      <div>\\n        <span class=\\\"toast-mark\\\" aria-hidden=\\\"true\\\"></span>\\n        <div class=\\\"toast-content\\\">\\n          <strong></strong>\\n          <span class=\\\"toast-message\\\"></span>\\n          <!--[--><!--]-->\\n        </div>\\n        <button type=\\\"button\\\" class=\\\"toast-close\\\" aria-label=\\\"Dismiss notification\\\">×</button>\\n      </div>\\n    \", parts: (toast, $index) => [{ path: [0], attribute: \"class\", value: () => \"toast-item toast-\" + $t($r(toast).variant) }, { path: [0], attribute: \"role\", value: () => (($r(toast).variant === \"danger\") ? \"alert\" : \"status\") }, { path: [0, 1, 0], text: () => $t($r(toast).heading) }, { path: [0, 1, 1], text: () => $t($r(toast).message) }, { path: [0, 1, 2], when: () => $r(toast).action, blocks: [{ template: \"<a class=\\\"toast-action\\\"></a>\", parts: () => [{ path: [0], attribute: \"href\", url: true, value: () => $r(toast).action?.href }, { path: [0], text: () => $t($r(toast).action?.label) }] }, null] }, { path: [0, 2], on: \"click\", handler: () => (() => remove($r(toast))) }] }, animate: $motion },\n    ];\n  },\n});\n"
    }
  ]
}
