{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-notification",
  "type": "registry:lib",
  "title": "core/notification",
  "description": "Framework-free behaviour shared by the ui-* components (notification); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/notification.ts",
      "type": "registry:lib",
      "target": "components/ui/core/notification.ts",
      "content": "/**\n * Notification rules (Carbon InlineNotification / ToastNotification / ActionableNotification /\n * Callout): the ARIA role, and the countdown of a toast's `timeout` that pauses while the toast is\n * hovered or holds focus (WCAG 2.2.1). The countdown keeps time only; the renderer sets the timer.\n */\n\nexport type NotificationKind = 'error' | 'success' | 'info' | 'info-square' | 'warning' | 'warning-alt';\nexport type NotificationVariant = 'inline' | 'toast' | 'callout';\n/** `none`: no live region of its own (inside a toaster, whose region announces it). */\nexport type NotificationRole = 'status' | 'alert' | 'log' | 'alertdialog' | 'none';\n\n/** The role of the notification box: the one asked for; else none for a callout (static content), `alertdialog` with an action, `status` otherwise. */\nexport function notificationRole(role: NotificationRole | null | undefined, variant: NotificationVariant, hasAction: boolean): Exclude<NotificationRole, 'none'> | undefined {\n    if (role === 'none') return undefined;\n    if (role) return role;\n    if (variant === 'callout') return undefined;\n    return hasAction ? 'alertdialog' : 'status';\n}\n\n/**\n * Time left before a `timeout` closes the notification. `resume(now)` returns how long to wait\n * (undefined: don't wait — no timeout, paused, an action that must not vanish, or done);\n * `pause(now)` keeps what is left. A notification with an action never closes on its own.\n */\nexport class Countdown {\n    private remaining: number;\n    private startedAt: number | undefined;\n    private readonly total: number;\n\n    constructor(total: number) {\n        this.total = total;\n        this.remaining = total;\n    }\n\n    /** Start again from the full timeout (when the notification shows again). */\n    reset() {\n        this.remaining = this.total;\n        this.startedAt = undefined;\n    }\n\n    resume(now: number, blocked: boolean): number | undefined {\n        if (this.total <= 0 || blocked || this.remaining <= 0) return undefined;\n        this.startedAt = now;\n        return this.remaining;\n    }\n\n    pause(now: number) {\n        if (this.startedAt === undefined) return;\n        this.remaining -= now - this.startedAt;\n        this.startedAt = undefined;\n    }\n}\n\n/**\n * Tab inside an `alertdialog` notification stays inside it (Carbon `wrapFocus`): Tab on the last\n * stop goes to the first, Shift+Tab on the first to the last; from outside the stops (the box\n * itself) Tab starts at the first. `null`: let the browser move.\n */\nexport function wrapTab<T>(stops: readonly T[], current: T | undefined, backward: boolean): T | null {\n    if (stops.length === 0) return null;\n    const first = stops[0];\n    const last = stops.at(-1) as T;\n    if (current === undefined || !stops.includes(current)) return backward ? last : first;\n    if (backward) return current === first ? last : null;\n    return current === last ? first : null;\n}\n"
    }
  ]
}
