{"version":3,"names":["createContext","useContext","createPopupCore","SNAPSHOT_KEYS","snapshotKeys","AlertDialogContext","useAlertDialog","optional","ctx","Error","createAlertDialog","options","core","open","disabled","onOpenChange","api","modal","disablePointerDismissal","setOpen","toggle","Provider","props","children","ALERT_DIALOG_SNAPSHOT_KEYS"],"sources":["create-alert-dialog.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport { createPopupCore } from \"../internals/create-popup-core\";\nimport type { MaybeAccessor } from \"../internals/maybe-accessor\";\nimport {\n\tSNAPSHOT_KEYS,\n\ttype Snapshottable,\n\tsnapshotKeys,\n} from \"../internals/observability/snapshot\";\n\n/**\n * Why the alert dialog's open state changed.\n *\n * Alert dialogs cannot be dismissed by an outside press or Escape without\n * an explicit action, so those reasons are excluded from the public surface.\n *\n * - `\"trigger-press\"` — trigger was clicked or keyboard-activated.\n * - `\"close-button\"` — `<AlertDialog.Close>` / an action button was pressed.\n * - `\"imperative\"` — `ad.setOpen()` called programmatically.\n */\nexport type AlertDialogChangeReason =\n\t| \"trigger-press\"\n\t| \"close-button\"\n\t| \"imperative\";\n\n/**\n * Options for {@link createAlertDialog}.\n */\nexport interface CreateAlertDialogOptions {\n\t/**\n\t * Open state. Consumer-owned signal.\n\t */\n\topen: MaybeAccessor<boolean>;\n\t/**\n\t * Whether interaction is suppressed.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean>;\n\t/**\n\t * Pre-change callback fired via `runWithOwner(null, ...)`.\n\t */\n\tonOpenChange?: (\n\t\topen: boolean,\n\t\tevent: Event,\n\t\treason: AlertDialogChangeReason,\n\t) => void;\n}\n\n/**\n * Public API returned by {@link createAlertDialog}.\n */\nexport interface AlertDialogApi {\n\t/** Reactive accessor for the current open state. */\n\topen: Accessor<boolean>;\n\t/** Whether interaction is suppressed. */\n\tdisabled: Accessor<boolean>;\n\t/**\n\t * Alert dialogs are always modal and never close on outside press —\n\t * this is a fixed behavioral invariant, not a knob.\n\t */\n\treadonly modal: true;\n\treadonly disablePointerDismissal: true;\n\n\t/** Imperative open setter. */\n\tsetOpen: (\n\t\tnext: boolean,\n\t\tevent?: Event,\n\t\treason?: AlertDialogChangeReason,\n\t) => void;\n\t/** Flip open (no-op when disabled). */\n\ttoggle: (event?: Event, reason?: AlertDialogChangeReason) => void;\n\n\t/** Context provider. */\n\tProvider: (props: { children: JSX.Element }) => JSX.Element;\n}\n\nconst AlertDialogContext = createContext<AlertDialogApi | null>(null);\n\n/**\n * Read the nearest {@link AlertDialogApi}. Throws unless `optional` is true.\n */\nexport function useAlertDialog(): AlertDialogApi;\nexport function useAlertDialog(optional: true): AlertDialogApi | null;\nexport function useAlertDialog(optional?: boolean): AlertDialogApi | null {\n\tconst ctx = useContext(AlertDialogContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: useAlertDialog() must be called inside an <ad.Provider>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n\n/**\n * Headless primitive for an alert-dialog compound. Always modal, always\n * disables outside-press dismissal — both are fixed invariants of the\n * ARIA `alertdialog` role. DOM machinery lives in `<AlertDialog.Root>`.\n */\nexport function createAlertDialog(\n\toptions: CreateAlertDialogOptions,\n): AlertDialogApi {\n\tconst core = createPopupCore<AlertDialogChangeReason>({\n\t\topen: options.open,\n\t\tdisabled: options.disabled,\n\t\tonOpenChange: options.onOpenChange,\n\t});\n\n\tconst api: AlertDialogApi = {\n\t\topen: core.open,\n\t\tdisabled: core.disabled,\n\t\tmodal: true,\n\t\tdisablePointerDismissal: true,\n\t\tsetOpen: core.setOpen,\n\t\ttoggle: core.toggle,\n\t\tProvider: (props) => (\n\t\t\t<AlertDialogContext value={api}>{props.children}</AlertDialogContext>\n\t\t),\n\t};\n\n\t(api as AlertDialogApi & Snapshottable)[SNAPSHOT_KEYS] =\n\t\tALERT_DIALOG_SNAPSHOT_KEYS;\n\n\treturn api;\n}\n\nconst ALERT_DIALOG_SNAPSHOT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