@mhmo91/schmancy 0.10.18 → 0.10.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/{flow-CvG1fLW5.js.map → flow-3RrZM-e7.js.map} +1 -1
- package/dist/agent/overlay.confirm-body-D3jQyXgA.js +2863 -0
- package/dist/agent/overlay.confirm-body-D3jQyXgA.js.map +1 -0
- package/dist/agent/{rolldown-runtime-DsMetpgY.js → rolldown-runtime-BIIoCavz.js} +9 -2
- package/dist/agent/schmancy.agent.js +3870 -5769
- package/dist/agent/schmancy.agent.js.map +1 -1
- package/dist/agent/{vendor-material-color-DcL7ZPxx.js.map → vendor-material-color-33Mj762T.js.map} +1 -1
- package/dist/{audio-D-TZzpXF.cjs → audio-Cvmemu84.cjs} +1 -1
- package/dist/{audio-D-TZzpXF.cjs.map → audio-Cvmemu84.cjs.map} +1 -1
- package/dist/{audio-DS43uoRA.js → audio-CxO5a2HL.js} +1 -1
- package/dist/{audio-DS43uoRA.js.map → audio-CxO5a2HL.js.map} +1 -1
- package/dist/audio.cjs +1 -1
- package/dist/audio.js +2 -2
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/{boat-cuoSkhGI.js → boat-CNWIQPA1.js} +1 -1
- package/dist/{boat-cuoSkhGI.js.map → boat-CNWIQPA1.js.map} +1 -1
- package/dist/{boat-DN1_tyvx.cjs → boat-OatK_MGh.cjs} +1 -1
- package/dist/{boat-DN1_tyvx.cjs.map → boat-OatK_MGh.cjs.map} +1 -1
- package/dist/boat.cjs +1 -1
- package/dist/boat.js +1 -1
- package/dist/{chips-m2NPN480.js → chips-D1kJrbzo.js} +1 -1
- package/dist/{chips-m2NPN480.js.map → chips-D1kJrbzo.js.map} +1 -1
- package/dist/{chips-DSdvCpmi.cjs → chips-Dx_WvOGk.cjs} +1 -1
- package/dist/{chips-DSdvCpmi.cjs.map → chips-Dx_WvOGk.cjs.map} +1 -1
- package/dist/chips.cjs +1 -1
- package/dist/chips.js +1 -1
- package/dist/connectivity.cjs +1 -1
- package/dist/connectivity.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/{date-range-D98QcCHl.js → date-range-Dv-DM6mB.js} +1 -1
- package/dist/{date-range-D98QcCHl.js.map → date-range-Dv-DM6mB.js.map} +1 -1
- package/dist/{date-range-DxS3Agbj.cjs → date-range-H903Vt_r.cjs} +1 -1
- package/dist/{date-range-DxS3Agbj.cjs.map → date-range-H903Vt_r.cjs.map} +1 -1
- package/dist/date-range.cjs +1 -1
- package/dist/date-range.js +1 -1
- package/dist/directives.cjs +1 -1
- package/dist/directives.js +1 -1
- package/dist/{float-B8NcSE3a.cjs → float-CfbQM_2v.cjs} +1 -1
- package/dist/{float-B8NcSE3a.cjs.map → float-CfbQM_2v.cjs.map} +1 -1
- package/dist/{float-C-glc-3u.js → float-KmbhaQHA.js} +1 -1
- package/dist/{float-C-glc-3u.js.map → float-KmbhaQHA.js.map} +1 -1
- package/dist/float.cjs +1 -1
- package/dist/float.js +1 -1
- package/dist/{form-DJvxIyfW.js → form-8IcmP8uV.js} +2 -2
- package/dist/{form-DJvxIyfW.js.map → form-8IcmP8uV.js.map} +1 -1
- package/dist/{form-St_IwR7y.cjs → form-CuBIrKOA.cjs} +1 -1
- package/dist/{form-St_IwR7y.cjs.map → form-CuBIrKOA.cjs.map} +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +2 -2
- package/dist/handover/agent-runtime-followups.md +1 -1
- package/dist/handover/agent-runtime-v1.md +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +56 -53
- package/dist/json.cjs +1 -1
- package/dist/json.js +1 -1
- package/dist/{layout-Delq-QvR.cjs → layout-BbCIfIgo.cjs} +1 -1
- package/dist/{layout-Delq-QvR.cjs.map → layout-BbCIfIgo.cjs.map} +1 -1
- package/dist/{layout-BH28sKGc.js → layout-Dq2oeOTS.js} +1 -1
- package/dist/{layout-BH28sKGc.js.map → layout-Dq2oeOTS.js.map} +1 -1
- package/dist/{menu-Dag0cuWV.cjs → menu-BqKQ-s0C.cjs} +1 -1
- package/dist/{menu-Dag0cuWV.cjs.map → menu-BqKQ-s0C.cjs.map} +1 -1
- package/dist/{menu-B_-weNpZ.js → menu-C5ksITpG.js} +1 -1
- package/dist/{menu-B_-weNpZ.js.map → menu-C5ksITpG.js.map} +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/navigation-bar.cjs +1 -1
- package/dist/navigation-bar.js +1 -1
- package/dist/{notification-yd2KeHjd.cjs → notification-DR3gvWt8.cjs} +1 -1
- package/dist/{notification-yd2KeHjd.cjs.map → notification-DR3gvWt8.cjs.map} +1 -1
- package/dist/{notification-DySnvQeO.js → notification-eZxtr3NN.js} +1 -1
- package/dist/{notification-DySnvQeO.js.map → notification-eZxtr3NN.js.map} +1 -1
- package/dist/notification.cjs +1 -1
- package/dist/notification.js +1 -1
- package/dist/overlay-DG6EeyKt.cjs +80 -0
- package/dist/overlay-DG6EeyKt.cjs.map +1 -0
- package/dist/overlay-oxM9OLXP.js +745 -0
- package/dist/overlay-oxM9OLXP.js.map +1 -0
- package/dist/overlay.cjs +1 -80
- package/dist/{overlay.confirm-body-sUmd_zVy.cjs.map → overlay.confirm-body-78e1WrN9.cjs.map} +1 -1
- package/dist/{overlay.confirm-body-DESGpbru.js.map → overlay.confirm-body-D_P2e7l6.js.map} +1 -1
- package/dist/overlay.js +5 -746
- package/dist/{overlay.service-DV_o_xQ0.js → overlay.service-C8NwO4Bx.js} +2 -2
- package/dist/{overlay.service-DV_o_xQ0.js.map → overlay.service-C8NwO4Bx.js.map} +1 -1
- package/dist/{overlay.service-BxtEFFSH.cjs → overlay.service-DQkGPUY7.cjs} +1 -1
- package/dist/{overlay.service-BxtEFFSH.cjs.map → overlay.service-DQkGPUY7.cjs.map} +1 -1
- package/dist/page.cjs +1 -1
- package/dist/page.js +2 -2
- package/dist/{rxjs-utils-Dv9T9IpA.js.map → rxjs-utils-Cs6XGwF6.js.map} +1 -1
- package/dist/{rxjs-utils-BKB2UM_j.cjs.map → rxjs-utils-Dsj75cJy.cjs.map} +1 -1
- package/dist/rxjs-utils.cjs +1 -1
- package/dist/rxjs-utils.js +1 -1
- package/dist/{sound.service-DyY78ukR.cjs → sound.service-DVJZb9ox.cjs} +1 -1
- package/dist/{sound.service-DyY78ukR.cjs.map → sound.service-DVJZb9ox.cjs.map} +1 -1
- package/dist/{sound.service-BIN2W7Rv.js → sound.service-v_jqCkos.js} +1 -1
- package/dist/{sound.service-BIN2W7Rv.js.map → sound.service-v_jqCkos.js.map} +1 -1
- package/dist/{splash-screen-25PTDqnp.cjs.map → splash-screen-BvaDkvJU.cjs.map} +1 -1
- package/dist/{splash-screen-bGW_sS4i.js.map → splash-screen-ChMkAPLU.js.map} +1 -1
- package/dist/splash-screen.cjs +1 -1
- package/dist/splash-screen.js +1 -1
- package/dist/{src-Blm9PNcf.cjs → src-BIlD63Cz.cjs} +1 -1
- package/dist/{src-Blm9PNcf.cjs.map → src-BIlD63Cz.cjs.map} +1 -1
- package/dist/{src-olrlFt4e.js → src-DnunCC4X.js} +18 -17
- package/dist/{src-olrlFt4e.js.map → src-DnunCC4X.js.map} +1 -1
- package/dist/{state-nm8yzMPp.js → state-CHbIt2Dw.js} +198 -202
- package/dist/{state-nm8yzMPp.js.map → state-CHbIt2Dw.js.map} +1 -1
- package/dist/state-DcGj-pJJ.cjs +1 -0
- package/dist/{state-avic94Ft.cjs.map → state-DcGj-pJJ.cjs.map} +1 -1
- package/dist/state.cjs +1 -1
- package/dist/state.js +1 -1
- package/dist/{tabs-BVC_qn8S.js.map → tabs-CkDNLbiS.js.map} +1 -1
- package/dist/{tabs-Dc3_Ox2B.cjs.map → tabs-lxQHWEb7.cjs.map} +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/dist/{theme-DCybsrfv.cjs → theme-CMyXTDht.cjs} +1 -1
- package/dist/{theme-DCybsrfv.cjs.map → theme-CMyXTDht.cjs.map} +1 -1
- package/dist/{theme-BiCwFfCf.js → theme-CNWRYdfn.js} +2 -2
- package/dist/{theme-BiCwFfCf.js.map → theme-CNWRYdfn.js.map} +1 -1
- package/dist/{theme-button-DqiA0rJg.js.map → theme-button-CixloLin.js.map} +1 -1
- package/dist/{theme-button-cZGRyQRK.cjs.map → theme-button-kMhsX5Oe.cjs.map} +1 -1
- package/dist/theme-button.cjs +1 -1
- package/dist/theme-button.js +1 -1
- package/dist/theme.cjs +1 -1
- package/dist/theme.js +2 -2
- package/dist/{theme.service-BOWIT_5k.js → theme.service-CSzNkqBB.js} +1 -1
- package/dist/{theme.service-BOWIT_5k.js.map → theme.service-CSzNkqBB.js.map} +1 -1
- package/dist/{theme.service-DkdH1t60.cjs → theme.service-CnFUmUpc.cjs} +1 -1
- package/dist/{theme.service-DkdH1t60.cjs.map → theme.service-CnFUmUpc.cjs.map} +1 -1
- package/dist/{utils-D2QUu4-g.cjs.map → utils-C-Q8ePtG.cjs.map} +1 -1
- package/dist/{utils-Cj_nRRyx.js.map → utils-DXE5fBBd.js.map} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{window-DMy5Gsgu.js → window-BcvDNi9D.js} +1 -1
- package/dist/{window-DMy5Gsgu.js.map → window-BcvDNi9D.js.map} +1 -1
- package/dist/{window-BMecbTzs.cjs → window-qaGFMn_4.cjs} +1 -1
- package/dist/{window-BMecbTzs.cjs.map → window-qaGFMn_4.cjs.map} +1 -1
- package/dist/window.cjs +1 -1
- package/dist/window.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +8 -0
- package/src/state/index.ts +31 -9
- package/types/src/index.d.ts +1 -0
- package/dist/overlay.cjs.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/state-avic94Ft.cjs +0 -1
- /package/dist/agent/{flow-CvG1fLW5.js → flow-3RrZM-e7.js} +0 -0
- /package/dist/agent/{vendor-material-color-DcL7ZPxx.js → vendor-material-color-33Mj762T.js} +0 -0
- /package/dist/{overlay.confirm-body-sUmd_zVy.cjs → overlay.confirm-body-78e1WrN9.cjs} +0 -0
- /package/dist/{overlay.confirm-body-DESGpbru.js → overlay.confirm-body-D_P2e7l6.js} +0 -0
- /package/dist/{rxjs-utils-Dv9T9IpA.js → rxjs-utils-Cs6XGwF6.js} +0 -0
- /package/dist/{rxjs-utils-BKB2UM_j.cjs → rxjs-utils-Dsj75cJy.cjs} +0 -0
- /package/dist/{splash-screen-25PTDqnp.cjs → splash-screen-BvaDkvJU.cjs} +0 -0
- /package/dist/{splash-screen-bGW_sS4i.js → splash-screen-ChMkAPLU.js} +0 -0
- /package/dist/{tabs-BVC_qn8S.js → tabs-CkDNLbiS.js} +0 -0
- /package/dist/{tabs-Dc3_Ox2B.cjs → tabs-lxQHWEb7.cjs} +0 -0
- /package/dist/{theme-button-DqiA0rJg.js → theme-button-CixloLin.js} +0 -0
- /package/dist/{theme-button-cZGRyQRK.cjs → theme-button-kMhsX5Oe.cjs} +0 -0
- /package/dist/{utils-D2QUu4-g.cjs → utils-C-Q8ePtG.cjs} +0 -0
- /package/dist/{utils-Cj_nRRyx.js → utils-DXE5fBBd.js} +0 -0
|
@@ -66,7 +66,7 @@ function D(e, t = {}) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
async function O(e = {}) {
|
|
69
|
-
let { SchmancyOverlayPromptBody: t } = await import("./overlay.confirm-body-
|
|
69
|
+
let { SchmancyOverlayPromptBody: t } = await import("./overlay.confirm-body-D_P2e7l6.js").then((e) => e.n);
|
|
70
70
|
return !0 === await c(D(t, {
|
|
71
71
|
anchor: e.anchor,
|
|
72
72
|
signal: e.signal,
|
|
@@ -82,7 +82,7 @@ async function O(e = {}) {
|
|
|
82
82
|
}).pipe(i(!1)));
|
|
83
83
|
}
|
|
84
84
|
async function k(e = {}) {
|
|
85
|
-
let { SchmancyOverlayPromptBody: t } = await import("./overlay.confirm-body-
|
|
85
|
+
let { SchmancyOverlayPromptBody: t } = await import("./overlay.confirm-body-D_P2e7l6.js").then((e) => e.n), n = await c(D(t, {
|
|
86
86
|
anchor: e.anchor,
|
|
87
87
|
signal: e.signal,
|
|
88
88
|
props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.service-DV_o_xQ0.js","names":[],"sources":["../src/overlay/overlay.stack.ts","../src/overlay/overlay.service.ts"],"sourcesContent":["import { BehaviorSubject, distinctUntilChanged, map, Observable } from 'rxjs'\nimport type { OverlayEntry } from './overlay.types'\n\n/**\n * Overlay stack — single source of truth for \"what is currently open.\"\n *\n * A module-scope BehaviorSubject matching the `schmancy` skill's\n * \"contexts at module scope; many small contexts beat one monolith\"\n * guidance. Reactive pipelines inside the overlay service and public\n * `openOverlays$` observable project off this.\n *\n * Scroll lock and the stack-aware inert manager are both derived from\n * the stack state — no separate mutable counter variables. Honors rxjs\n * SUBSCRIPTION_IS_STATE: the stack IS the state; scroll lock / inert\n * are declarative projections.\n */\n\nconst stack$$ = new BehaviorSubject<readonly OverlayEntry[]>([])\n\n/** Public read-only stream of the current stack. Emits on every push/pop. */\nexport const stack$: Observable<readonly OverlayEntry[]> = stack$$.asObservable()\n\n/** Synchronous snapshot. Use only when a component can't subscribe. */\nexport function currentStack(): readonly OverlayEntry[] {\n\treturn stack$$.value\n}\n\n/** Append an entry (top of stack). */\nexport function pushEntry(entry: OverlayEntry): void {\n\tstack$$.next([...stack$$.value, entry])\n}\n\n/** Remove by id. No-op if the id is not in the stack. */\nexport function removeEntry(id: string): void {\n\tconst current = stack$$.value\n\tconst next = current.filter((e) => e.id !== id)\n\tif (next.length !== current.length) {\n\t\tstack$$.next(next)\n\t}\n}\n\n/** Clear the entire stack. Used by dismissAll(). */\nexport function clearStack(): void {\n\tif (stack$$.value.length > 0) {\n\t\tstack$$.next([])\n\t}\n}\n\n/* ---------------- scroll lock -------------------------------------------- */\n\n/**\n * Ref-counted body scroll lock. Active whenever ANY modal-tier overlay is\n * in the stack. Popover-tier (Tier 1/2) overlays do NOT lock body scroll —\n * a menu / share card / picker shouldn't freeze the page scroll behind it\n * (that's platform UX convention).\n *\n * Subscription is idempotent — subscribing multiple times won't stack\n * effects, because it's a distinctUntilChanged boolean projection.\n *\n * Inner overlay close does NOT release the lock while an outer modal is\n * still open (this was the pre-existing bug in sheet.service.ts).\n */\nlet scrollLockActive = false\nlet previousOverflow = ''\nlet previousScrollbarGutter = ''\n\nstack$$\n\t.pipe(\n\t\tmap((s) => s.some((e) => e.modal)),\n\t\tdistinctUntilChanged(),\n\t)\n\t.subscribe((shouldLock) => {\n\t\tif (typeof document === 'undefined') return\n\n\t\tif (shouldLock && !scrollLockActive) {\n\t\t\tpreviousOverflow = document.documentElement.style.overflow\n\t\t\tpreviousScrollbarGutter = document.documentElement.style.getPropertyValue('scrollbar-gutter')\n\t\t\tdocument.documentElement.style.overflow = 'hidden'\n\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', 'stable')\n\t\t\tscrollLockActive = true\n\t\t} else if (!shouldLock && scrollLockActive) {\n\t\t\tdocument.documentElement.style.overflow = previousOverflow\n\t\t\tif (previousScrollbarGutter) {\n\t\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', previousScrollbarGutter)\n\t\t\t} else {\n\t\t\t\tdocument.documentElement.style.removeProperty('scrollbar-gutter')\n\t\t\t}\n\t\t\tpreviousOverflow = ''\n\t\t\tpreviousScrollbarGutter = ''\n\t\t\tscrollLockActive = false\n\t\t}\n\t})\n\n/* ---------------- stack-aware inert -------------------------------------- */\n\n/**\n * When the first modal overlay opens, mark every sibling outside the\n * overlay host subtree as `inert` so AT and keyboard focus can't reach\n * them. Restored when the last modal overlay closes.\n *\n * Note: native `<dialog>.showModal()` already inerts the rest of the\n * document automatically. We keep this as a safety net for:\n * - anchored (popover) overlays which are non-modal by design but may\n * carry `modal: true` as the escape hatch;\n * - stacked overlays where an inner modal opens above a non-modal —\n * the sibling-inert is a no-op but we still guarantee the invariant.\n *\n * Callers that don't want inert (anchored/menu overlays) skip registration\n * via `markNonModal(id)`.\n */\nconst modalIds = new Set<string>()\nconst inertedSiblings = new Set<HTMLElement>()\n\nexport function markModal(id: string, hostContainer: HTMLElement): void {\n\tmodalIds.add(id)\n\tif (modalIds.size === 1) {\n\t\tapplyInert(hostContainer)\n\t}\n}\n\nexport function unmarkModal(id: string): void {\n\tmodalIds.delete(id)\n\tif (modalIds.size === 0) {\n\t\treleaseInert()\n\t}\n}\n\nfunction applyInert(hostContainer: HTMLElement): void {\n\tconst parent = hostContainer.parentElement ?? document.body\n\tfor (let i = 0; i < parent.children.length; i++) {\n\t\tconst child = parent.children[i]\n\t\tif (child !== hostContainer && child instanceof HTMLElement && !child.inert) {\n\t\t\tchild.inert = true\n\t\t\tinertedSiblings.add(child)\n\t\t}\n\t}\n}\n\nfunction releaseInert(): void {\n\tfor (const el of inertedSiblings) {\n\t\tel.inert = false\n\t}\n\tinertedSiblings.clear()\n}\n\n/* ---------------- overlayEvents multicast helper ------------------------- */\n\n/**\n * Returns an Observable of `tagName` elements currently in the stack.\n * The overlayEvents public helper composes `fromEvent` over this stream\n * via switchMap to tap events without owning the overlay lifecycle.\n *\n * Stays alive across open/close cycles — the caller owns completion via\n * `takeUntil(this.disconnecting)`, matching the house rxjs convention.\n */\nexport function elementsByTag$(tagName: string): Observable<readonly HTMLElement[]> {\n\tconst lower = tagName.toLowerCase()\n\treturn stack$$.pipe(\n\t\tmap((entries) => {\n\t\t\tconst matches: HTMLElement[] = []\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst inner = entry.element.querySelector<HTMLElement>(lower)\n\t\t\t\tif (inner) matches.push(inner)\n\t\t\t}\n\t\t\treturn matches\n\t\t}),\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t)\n}\n","import {\n\tBehaviorSubject,\n\tdefer,\n\tdefaultIfEmpty,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfirstValueFrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tSubject,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n} from 'rxjs'\nimport type { THistoryStrategy } from '../area/router.types'\nimport { SchmancyOverlay } from './overlay.component'\nimport {\n\tclearStack,\n\tcurrentStack,\n\telementsByTag$,\n\tmarkModal,\n\tpushEntry,\n\tremoveEntry,\n\tstack$ as internalStack$,\n\tunmarkModal,\n} from './overlay.stack'\nimport type {\n\tCloseReason,\n\tOverlayConfirmOptions,\n\tContent,\n\tOverlayEntry,\n\tOverlayPromptOptions,\n\tShowOptions,\n} from './overlay.types'\n\n/**\n * Public read-only stream of the current overlay stack. Subscribe to\n * observe stack changes — e.g. to update a breadcrumb, show a \"close\n * all\" button, or gate another action while any overlay is open.\n *\n * Emits synchronously with the current snapshot on subscribe. Never\n * completes — the caller owns teardown via `takeUntil(this.disconnecting)`.\n */\nexport const openOverlays$: Observable<readonly OverlayEntry[]> = internalStack$\n\n/* ======================================================================= *\n * ambient event capture *\n * ======================================================================= *\n * Novel: callers do not need to pass `anchor: event` manually. The service\n * listens to pointerdown / click / keydown at capture phase on the document\n * and remembers the most-recent user gesture. When show() is invoked\n * synchronously (or shortly after) in response to that gesture, the remembered\n * event becomes the default anchor. This matches the \"anchored is the novel\n * default\" principle without forcing callers to thread events through\n * handlers.\n *\n * Staleness guard: an event older than AMBIENT_ANCHOR_MAX_AGE_MS is ignored.\n * Timer-driven or async show() calls that don't originate from a user gesture\n * fall through to centered / sheet layout.\n */\nconst AMBIENT_ANCHOR_MAX_AGE_MS = 750\n\ninterface AmbientAnchor {\n\tevent: MouseEvent\n\tcapturedAt: number\n}\n\n/**\n * BehaviorSubject projected off three document-level event streams,\n * merged as Observables per rxjs principle 3 (every async source\n * lifted into fromEvent). Keydown activations synthesize a MouseEvent\n * at the focused element's bounding rect so the anchor path can\n * carry keyboard-triggered opens uniformly.\n *\n * The singleton subscribe has no explicit teardown — the module's\n * lifetime IS the subscription's lifetime, which is the correct\n * SUBSCRIPTION_IS_STATE shape for a document-level event sink.\n */\nconst ambientAnchor$ = new BehaviorSubject<AmbientAnchor | null>(null)\n\nif (typeof document !== 'undefined') {\n\tconst pointerdown$ = fromEvent<PointerEvent>(document, 'pointerdown', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst click$ = fromEvent<MouseEvent>(document, 'click', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst keydown$ = fromEvent<KeyboardEvent>(document, 'keydown', { capture: true }).pipe(\n\t\tfilter((e) => e.target instanceof Element),\n\t\tmap((e): AmbientAnchor => {\n\t\t\tconst rect = (e.target as Element).getBoundingClientRect()\n\t\t\tconst synthetic = new MouseEvent('click', {\n\t\t\t\tclientX: rect.left + rect.width / 2,\n\t\t\t\tclientY: rect.top + rect.height / 2,\n\t\t\t\tbubbles: true,\n\t\t\t})\n\t\t\treturn { event: synthetic, capturedAt: performance.now() }\n\t\t}),\n\t)\n\n\tmerge(pointerdown$, click$, keydown$).subscribe((ambient) => ambientAnchor$.next(ambient))\n}\n\nfunction ambientAnchor(): MouseEvent | undefined {\n\tconst cur = ambientAnchor$.value\n\tif (!cur) return undefined\n\tif (performance.now() - cur.capturedAt > AMBIENT_ANCHOR_MAX_AGE_MS) return undefined\n\treturn cur.event\n}\n\n\n/* ======================================================================= *\n * show *\n * ======================================================================= */\n\n/**\n * Open an overlay containing `content`. Returns a cold Observable — the\n * overlay mounts on subscribe and dismisses on unsubscribe. Emits at\n * most one value (the result from content's `close` event) then completes.\n *\n * The subscription IS the overlay lifecycle. `takeUntil(this.disconnecting)`\n * on the caller's side means the overlay auto-dismisses when the caller\n * unmounts — no handles to track, no leaks.\n *\n * **Anchored is the novel default.** When triggered by a user event, pass\n * it as `anchor` — the overlay blooms from the point of attention. Falls\n * back to centered or sheet when the viewport / content makes that the\n * better layout (see overlay.layout.ts).\n *\n * @example\n * show(MyEditor, { props: { id }, anchor: event })\n * .pipe(takeUntil(this.disconnecting))\n * .subscribe(saved => saved && this.store.persist(saved))\n */\nexport function show<T = void>(\n\tcontent: Content,\n\toptions: ShowOptions = {},\n): Observable<T | undefined> {\n\treturn defer(() => {\n\t\t// Resolve anchor at subscribe time: caller's explicit anchor wins,\n\t\t// otherwise the ambient gesture captured by ambientAnchor$ fills in.\n\t\tconst resolvedOptions: ShowOptions = {\n\t\t\t...options,\n\t\t\tanchor: options.anchor ?? ambientAnchor(),\n\t\t}\n\n\t\treturn new Observable<T | undefined>((subscriber) => {\n\t\t\tlet el: SchmancyOverlay | null = null\n\t\t\tlet entry: OverlayEntry | null = null\n\t\t\tlet historyPushed = false\n\t\t\tlet settled = false\n\n\t\t\tconst teardown$ = new Subject<void>()\n\n\t\t\tconst mount = async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Create and append the overlay element.\n\t\t\t\t\tel = document.createElement('schmancy-overlay') as SchmancyOverlay\n\t\t\t\t\t;(document.body ?? document.documentElement).appendChild(el)\n\t\t\t\t\tawait el.updateComplete\n\n\t\t\t\t\t// Open it — mount content, resolve layout, animate in.\n\t\t\t\t\tawait el.open(content, resolvedOptions)\n\n\t\t\t\t\t// Register with the stack (post-open so layout, modal, tier are all\n\t\t\t\t\t// resolved by the element).\n\t\t\t\t\tconst id = generateId()\n\t\t\t\t\tentry = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\telement: el,\n\t\t\t\t\t\tlayout: el.layout,\n\t\t\t\t\t\tmodal: el.modal,\n\t\t\t\t\t\ttier: el.tier,\n\t\t\t\t\t}\n\t\t\t\t\tpushEntry(entry)\n\n\t\t\t\t\t// Register modality for the stack-aware inert manager when modal.\n\t\t\t\t\tif (el.modal && el.parentElement) {\n\t\t\t\t\t\tmarkModal(id, el)\n\t\t\t\t\t}\n\n\t\t\t\t\t// History integration — push a sentinel unless silent.\n\t\t\t\t\tconst strategy: THistoryStrategy = resolvedOptions.historyStrategy ?? 'push'\n\t\t\t\t\tif (strategy === 'push') {\n\t\t\t\t\t\thistory.pushState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t\thistoryPushed = true\n\t\t\t\t\t} else if (strategy === 'replace') {\n\t\t\t\t\t\thistory.replaceState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t}\n\n\t\t\t\t\t// popstate — close this overlay when the user hits back past us.\n\t\t\t\t\t// If another overlay's popstate fires first, that's fine; each overlay\n\t\t\t\t\t// handles its own via this listener.\n\t\t\t\t\tif (historyPushed) {\n\t\t\t\t\t\tfromEvent<PopStateEvent>(window, 'popstate')\n\t\t\t\t\t\t\t.pipe(take(1), takeUntil(teardown$))\n\t\t\t\t\t\t\t.subscribe(() => {\n\t\t\t\t\t\t\t\t// Avoid double-pop on teardown — set settled so the\n\t\t\t\t\t\t\t\t// teardown fn doesn't call history.back() again.\n\t\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\t\tvoid el?.close('popstate')\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\t// Subscribe to the element's internal close$ — the single source of\n\t\t\t\t\t// truth for lifecycle completion. Emits reason + optional result.\n\t\t\t\t\tel.closed$.pipe(take(1), takeUntil(teardown$)).subscribe(({ result }) => {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\tsubscriber.next(result as T | undefined)\n\t\t\t\t\t\tsubscriber.complete()\n\t\t\t\t\t})\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsubscriber.error(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvoid mount()\n\n\t\t\treturn () => {\n\t\t\t\tteardown$.next()\n\t\t\t\tteardown$.complete()\n\n\t\t\t\t// Unsubscribe path — caller cancelled. Tear down the overlay.\n\t\t\t\tif (el && !settled) {\n\t\t\t\t\tvoid el.close('programmatic')\n\t\t\t\t}\n\n\t\t\t\t// Clean up registry entries.\n\t\t\t\tif (entry) {\n\t\t\t\t\tunmarkModal(entry.id)\n\t\t\t\t\tremoveEntry(entry.id)\n\t\t\t\t}\n\n\t\t\t\t// Pop history if we pushed one and it's still current.\n\t\t\t\tif (historyPushed && !settled) {\n\t\t\t\t\t// Check before calling — if the user already popped, this is a noop.\n\t\t\t\t\tif (history.state?.__schmancyOverlayId === entry?.id) {\n\t\t\t\t\t\thistory.back()\n\t\t\t\t\t}\n\t\t\t\t\thistoryPushed = false\n\t\t\t\t}\n\n\t\t\t\t// Remove element after exit animation has had a chance to play.\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tel?.remove()\n\t\t\t\t\tel = null\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t})\n}\n\n/* ======================================================================= *\n * confirm / prompt sugar *\n * ======================================================================= */\n\n/**\n * Yes/no confirmation dialog. Returns a Promise that resolves with the\n * user's choice. `variant: 'danger'` flips to destructive styling and\n * `role=\"alertdialog\"`.\n */\nexport async function confirm(options: OverlayConfirmOptions = {}): Promise<boolean> {\n\t// Lazy-import the confirm body so push-only callers don't ship these\n\t// deps. The module is small; one-shot import penalty is fine.\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<boolean>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'confirm',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tconfirmText: options.confirmText ?? 'Confirm',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t\tvariant: options.variant ?? 'default',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(false as boolean | undefined)),\n\t)\n\treturn result === true\n}\n\n/**\n * Input prompt dialog. Returns the entered string, or `null` if the user\n * cancels or dismisses.\n */\nexport async function prompt(options: OverlayPromptOptions = {}): Promise<string | null> {\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<string | null>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'prompt',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tlabel: options.label,\n\t\t\t\tdefaultValue: options.defaultValue ?? '',\n\t\t\t\tplaceholder: options.placeholder,\n\t\t\t\tinputType: options.inputType ?? 'text',\n\t\t\t\tpattern: options.pattern,\n\t\t\t\trequired: options.required ?? false,\n\t\t\t\tconfirmText: options.confirmText ?? 'OK',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(null as string | null | undefined)),\n\t)\n\treturn typeof result === 'string' ? result : null\n}\n\n/* ======================================================================= *\n * overlayEvents *\n * ======================================================================= */\n\n/**\n * Subscribe to custom events emitted from any currently-open overlay\n * whose content matches `tagName`. Inspired by `area.on(name)` — keyed\n * by tag name (stable across HMR / lazy chunks) rather than a uid or\n * class reference.\n *\n * The returned Observable never completes on its own — the caller owns\n * teardown via `takeUntil(this.disconnecting)`. During gaps where no\n * matching overlay is open, no events are emitted; when an instance\n * mounts, events flow.\n *\n * Stacked instances of the same content merge their event streams.\n */\nexport function overlayEvents<E extends Event = CustomEvent>(\n\ttagName: string,\n\teventName: string,\n): Observable<E> {\n\treturn elementsByTag$(tagName).pipe(\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t\tswitchMap((elements) =>\n\t\t\telements.length === 0 ? EMPTY : merge(...elements.map((el) => fromEvent<E>(el, eventName))),\n\t\t),\n\t\tmap((e) => e),\n\t)\n}\n\n/* ======================================================================= *\n * dismissAll *\n * ======================================================================= */\n\n/**\n * Close every currently-open overlay. LIFO order. Imperative — use for\n * app-level flows like logout or route reset.\n */\nexport function dismissAll(): void {\n\tconst stack = [...currentStack()]\n\t// LIFO: close top-of-stack first.\n\tfor (let i = stack.length - 1; i >= 0; i--) {\n\t\tconst entry = stack[i]\n\t\tconst overlay = entry.element as SchmancyOverlay\n\t\tvoid overlay.close('programmatic')\n\t}\n\tclearStack()\n}\n\n/* ======================================================================= *\n * helpers *\n * ======================================================================= */\n\nfunction generateId(): string {\n\t// 8-char base36 is enough entropy for session-scoped uniqueness.\n\treturn 'ov_' + Math.random().toString(36).slice(2, 10) + Date.now().toString(36)\n}\n\n// Re-export the close reason type for consumers who want to narrow on it.\nexport type { CloseReason }\n"],"mappings":";AAiBA,IAAM,IAAU,IAAI,EAAyC,EAAA,CAAA,EAGhD,IAA8C,EAAQ,cAAA,EA0C/D,IAAA,CAAmB,GACnB,IAAmB,IACnB,IAA0B;AAE9B,EACE,KACA,GAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAA,CAAA,EAC3B,GAAA,CAAA,CAEA,WAAW,MAAA;CACa,AAAA,OAAb,WAAa,QAEpB,KAAA,CAAe,KAClB,IAAmB,SAAS,gBAAgB,MAAM,UAClD,IAA0B,SAAS,gBAAgB,MAAM,iBAAiB,mBAAA,EAC1E,SAAS,gBAAgB,MAAM,WAAW,UAC1C,SAAS,gBAAgB,MAAM,YAAY,oBAAoB,SAAA,EAC/D,IAAA,CAAmB,KAAA,CACR,KAAc,MACzB,SAAS,gBAAgB,MAAM,WAAW,GACtC,IACH,SAAS,gBAAgB,MAAM,YAAY,oBAAoB,EAAA,GAE/D,SAAS,gBAAgB,MAAM,eAAe,mBAAA,EAE/C,IAAmB,IACnB,IAA0B,IAC1B,IAAA,CAAmB;EAAA;AAqBtB,IAAM,oBAAW,IAAI,KAAA,EACf,oBAAkB,IAAI,KAAA;AAE5B,SAAgB,EAAU,GAAY,GAAA;CACrC,EAAS,IAAI,EAAA,EACT,EAAS,SAAS,KAYvB,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EAAe,KAAK,EAAA,CAAA;AAAA,SAAA,KAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"overlay.service-C8NwO4Bx.js","names":[],"sources":["../src/overlay/overlay.stack.ts","../src/overlay/overlay.service.ts"],"sourcesContent":["import { BehaviorSubject, distinctUntilChanged, map, Observable } from 'rxjs'\nimport type { OverlayEntry } from './overlay.types'\n\n/**\n * Overlay stack — single source of truth for \"what is currently open.\"\n *\n * A module-scope BehaviorSubject matching the `schmancy` skill's\n * \"contexts at module scope; many small contexts beat one monolith\"\n * guidance. Reactive pipelines inside the overlay service and public\n * `openOverlays$` observable project off this.\n *\n * Scroll lock and the stack-aware inert manager are both derived from\n * the stack state — no separate mutable counter variables. Honors rxjs\n * SUBSCRIPTION_IS_STATE: the stack IS the state; scroll lock / inert\n * are declarative projections.\n */\n\nconst stack$$ = new BehaviorSubject<readonly OverlayEntry[]>([])\n\n/** Public read-only stream of the current stack. Emits on every push/pop. */\nexport const stack$: Observable<readonly OverlayEntry[]> = stack$$.asObservable()\n\n/** Synchronous snapshot. Use only when a component can't subscribe. */\nexport function currentStack(): readonly OverlayEntry[] {\n\treturn stack$$.value\n}\n\n/** Append an entry (top of stack). */\nexport function pushEntry(entry: OverlayEntry): void {\n\tstack$$.next([...stack$$.value, entry])\n}\n\n/** Remove by id. No-op if the id is not in the stack. */\nexport function removeEntry(id: string): void {\n\tconst current = stack$$.value\n\tconst next = current.filter((e) => e.id !== id)\n\tif (next.length !== current.length) {\n\t\tstack$$.next(next)\n\t}\n}\n\n/** Clear the entire stack. Used by dismissAll(). */\nexport function clearStack(): void {\n\tif (stack$$.value.length > 0) {\n\t\tstack$$.next([])\n\t}\n}\n\n/* ---------------- scroll lock -------------------------------------------- */\n\n/**\n * Ref-counted body scroll lock. Active whenever ANY modal-tier overlay is\n * in the stack. Popover-tier (Tier 1/2) overlays do NOT lock body scroll —\n * a menu / share card / picker shouldn't freeze the page scroll behind it\n * (that's platform UX convention).\n *\n * Subscription is idempotent — subscribing multiple times won't stack\n * effects, because it's a distinctUntilChanged boolean projection.\n *\n * Inner overlay close does NOT release the lock while an outer modal is\n * still open (this was the pre-existing bug in sheet.service.ts).\n */\nlet scrollLockActive = false\nlet previousOverflow = ''\nlet previousScrollbarGutter = ''\n\nstack$$\n\t.pipe(\n\t\tmap((s) => s.some((e) => e.modal)),\n\t\tdistinctUntilChanged(),\n\t)\n\t.subscribe((shouldLock) => {\n\t\tif (typeof document === 'undefined') return\n\n\t\tif (shouldLock && !scrollLockActive) {\n\t\t\tpreviousOverflow = document.documentElement.style.overflow\n\t\t\tpreviousScrollbarGutter = document.documentElement.style.getPropertyValue('scrollbar-gutter')\n\t\t\tdocument.documentElement.style.overflow = 'hidden'\n\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', 'stable')\n\t\t\tscrollLockActive = true\n\t\t} else if (!shouldLock && scrollLockActive) {\n\t\t\tdocument.documentElement.style.overflow = previousOverflow\n\t\t\tif (previousScrollbarGutter) {\n\t\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', previousScrollbarGutter)\n\t\t\t} else {\n\t\t\t\tdocument.documentElement.style.removeProperty('scrollbar-gutter')\n\t\t\t}\n\t\t\tpreviousOverflow = ''\n\t\t\tpreviousScrollbarGutter = ''\n\t\t\tscrollLockActive = false\n\t\t}\n\t})\n\n/* ---------------- stack-aware inert -------------------------------------- */\n\n/**\n * When the first modal overlay opens, mark every sibling outside the\n * overlay host subtree as `inert` so AT and keyboard focus can't reach\n * them. Restored when the last modal overlay closes.\n *\n * Note: native `<dialog>.showModal()` already inerts the rest of the\n * document automatically. We keep this as a safety net for:\n * - anchored (popover) overlays which are non-modal by design but may\n * carry `modal: true` as the escape hatch;\n * - stacked overlays where an inner modal opens above a non-modal —\n * the sibling-inert is a no-op but we still guarantee the invariant.\n *\n * Callers that don't want inert (anchored/menu overlays) skip registration\n * via `markNonModal(id)`.\n */\nconst modalIds = new Set<string>()\nconst inertedSiblings = new Set<HTMLElement>()\n\nexport function markModal(id: string, hostContainer: HTMLElement): void {\n\tmodalIds.add(id)\n\tif (modalIds.size === 1) {\n\t\tapplyInert(hostContainer)\n\t}\n}\n\nexport function unmarkModal(id: string): void {\n\tmodalIds.delete(id)\n\tif (modalIds.size === 0) {\n\t\treleaseInert()\n\t}\n}\n\nfunction applyInert(hostContainer: HTMLElement): void {\n\tconst parent = hostContainer.parentElement ?? document.body\n\tfor (let i = 0; i < parent.children.length; i++) {\n\t\tconst child = parent.children[i]\n\t\tif (child !== hostContainer && child instanceof HTMLElement && !child.inert) {\n\t\t\tchild.inert = true\n\t\t\tinertedSiblings.add(child)\n\t\t}\n\t}\n}\n\nfunction releaseInert(): void {\n\tfor (const el of inertedSiblings) {\n\t\tel.inert = false\n\t}\n\tinertedSiblings.clear()\n}\n\n/* ---------------- overlayEvents multicast helper ------------------------- */\n\n/**\n * Returns an Observable of `tagName` elements currently in the stack.\n * The overlayEvents public helper composes `fromEvent` over this stream\n * via switchMap to tap events without owning the overlay lifecycle.\n *\n * Stays alive across open/close cycles — the caller owns completion via\n * `takeUntil(this.disconnecting)`, matching the house rxjs convention.\n */\nexport function elementsByTag$(tagName: string): Observable<readonly HTMLElement[]> {\n\tconst lower = tagName.toLowerCase()\n\treturn stack$$.pipe(\n\t\tmap((entries) => {\n\t\t\tconst matches: HTMLElement[] = []\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst inner = entry.element.querySelector<HTMLElement>(lower)\n\t\t\t\tif (inner) matches.push(inner)\n\t\t\t}\n\t\t\treturn matches\n\t\t}),\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t)\n}\n","import {\n\tBehaviorSubject,\n\tdefer,\n\tdefaultIfEmpty,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfirstValueFrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tSubject,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n} from 'rxjs'\nimport type { THistoryStrategy } from '../area/router.types'\nimport { SchmancyOverlay } from './overlay.component'\nimport {\n\tclearStack,\n\tcurrentStack,\n\telementsByTag$,\n\tmarkModal,\n\tpushEntry,\n\tremoveEntry,\n\tstack$ as internalStack$,\n\tunmarkModal,\n} from './overlay.stack'\nimport type {\n\tCloseReason,\n\tOverlayConfirmOptions,\n\tContent,\n\tOverlayEntry,\n\tOverlayPromptOptions,\n\tShowOptions,\n} from './overlay.types'\n\n/**\n * Public read-only stream of the current overlay stack. Subscribe to\n * observe stack changes — e.g. to update a breadcrumb, show a \"close\n * all\" button, or gate another action while any overlay is open.\n *\n * Emits synchronously with the current snapshot on subscribe. Never\n * completes — the caller owns teardown via `takeUntil(this.disconnecting)`.\n */\nexport const openOverlays$: Observable<readonly OverlayEntry[]> = internalStack$\n\n/* ======================================================================= *\n * ambient event capture *\n * ======================================================================= *\n * Novel: callers do not need to pass `anchor: event` manually. The service\n * listens to pointerdown / click / keydown at capture phase on the document\n * and remembers the most-recent user gesture. When show() is invoked\n * synchronously (or shortly after) in response to that gesture, the remembered\n * event becomes the default anchor. This matches the \"anchored is the novel\n * default\" principle without forcing callers to thread events through\n * handlers.\n *\n * Staleness guard: an event older than AMBIENT_ANCHOR_MAX_AGE_MS is ignored.\n * Timer-driven or async show() calls that don't originate from a user gesture\n * fall through to centered / sheet layout.\n */\nconst AMBIENT_ANCHOR_MAX_AGE_MS = 750\n\ninterface AmbientAnchor {\n\tevent: MouseEvent\n\tcapturedAt: number\n}\n\n/**\n * BehaviorSubject projected off three document-level event streams,\n * merged as Observables per rxjs principle 3 (every async source\n * lifted into fromEvent). Keydown activations synthesize a MouseEvent\n * at the focused element's bounding rect so the anchor path can\n * carry keyboard-triggered opens uniformly.\n *\n * The singleton subscribe has no explicit teardown — the module's\n * lifetime IS the subscription's lifetime, which is the correct\n * SUBSCRIPTION_IS_STATE shape for a document-level event sink.\n */\nconst ambientAnchor$ = new BehaviorSubject<AmbientAnchor | null>(null)\n\nif (typeof document !== 'undefined') {\n\tconst pointerdown$ = fromEvent<PointerEvent>(document, 'pointerdown', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst click$ = fromEvent<MouseEvent>(document, 'click', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst keydown$ = fromEvent<KeyboardEvent>(document, 'keydown', { capture: true }).pipe(\n\t\tfilter((e) => e.target instanceof Element),\n\t\tmap((e): AmbientAnchor => {\n\t\t\tconst rect = (e.target as Element).getBoundingClientRect()\n\t\t\tconst synthetic = new MouseEvent('click', {\n\t\t\t\tclientX: rect.left + rect.width / 2,\n\t\t\t\tclientY: rect.top + rect.height / 2,\n\t\t\t\tbubbles: true,\n\t\t\t})\n\t\t\treturn { event: synthetic, capturedAt: performance.now() }\n\t\t}),\n\t)\n\n\tmerge(pointerdown$, click$, keydown$).subscribe((ambient) => ambientAnchor$.next(ambient))\n}\n\nfunction ambientAnchor(): MouseEvent | undefined {\n\tconst cur = ambientAnchor$.value\n\tif (!cur) return undefined\n\tif (performance.now() - cur.capturedAt > AMBIENT_ANCHOR_MAX_AGE_MS) return undefined\n\treturn cur.event\n}\n\n\n/* ======================================================================= *\n * show *\n * ======================================================================= */\n\n/**\n * Open an overlay containing `content`. Returns a cold Observable — the\n * overlay mounts on subscribe and dismisses on unsubscribe. Emits at\n * most one value (the result from content's `close` event) then completes.\n *\n * The subscription IS the overlay lifecycle. `takeUntil(this.disconnecting)`\n * on the caller's side means the overlay auto-dismisses when the caller\n * unmounts — no handles to track, no leaks.\n *\n * **Anchored is the novel default.** When triggered by a user event, pass\n * it as `anchor` — the overlay blooms from the point of attention. Falls\n * back to centered or sheet when the viewport / content makes that the\n * better layout (see overlay.layout.ts).\n *\n * @example\n * show(MyEditor, { props: { id }, anchor: event })\n * .pipe(takeUntil(this.disconnecting))\n * .subscribe(saved => saved && this.store.persist(saved))\n */\nexport function show<T = void>(\n\tcontent: Content,\n\toptions: ShowOptions = {},\n): Observable<T | undefined> {\n\treturn defer(() => {\n\t\t// Resolve anchor at subscribe time: caller's explicit anchor wins,\n\t\t// otherwise the ambient gesture captured by ambientAnchor$ fills in.\n\t\tconst resolvedOptions: ShowOptions = {\n\t\t\t...options,\n\t\t\tanchor: options.anchor ?? ambientAnchor(),\n\t\t}\n\n\t\treturn new Observable<T | undefined>((subscriber) => {\n\t\t\tlet el: SchmancyOverlay | null = null\n\t\t\tlet entry: OverlayEntry | null = null\n\t\t\tlet historyPushed = false\n\t\t\tlet settled = false\n\n\t\t\tconst teardown$ = new Subject<void>()\n\n\t\t\tconst mount = async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Create and append the overlay element.\n\t\t\t\t\tel = document.createElement('schmancy-overlay') as SchmancyOverlay\n\t\t\t\t\t;(document.body ?? document.documentElement).appendChild(el)\n\t\t\t\t\tawait el.updateComplete\n\n\t\t\t\t\t// Open it — mount content, resolve layout, animate in.\n\t\t\t\t\tawait el.open(content, resolvedOptions)\n\n\t\t\t\t\t// Register with the stack (post-open so layout, modal, tier are all\n\t\t\t\t\t// resolved by the element).\n\t\t\t\t\tconst id = generateId()\n\t\t\t\t\tentry = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\telement: el,\n\t\t\t\t\t\tlayout: el.layout,\n\t\t\t\t\t\tmodal: el.modal,\n\t\t\t\t\t\ttier: el.tier,\n\t\t\t\t\t}\n\t\t\t\t\tpushEntry(entry)\n\n\t\t\t\t\t// Register modality for the stack-aware inert manager when modal.\n\t\t\t\t\tif (el.modal && el.parentElement) {\n\t\t\t\t\t\tmarkModal(id, el)\n\t\t\t\t\t}\n\n\t\t\t\t\t// History integration — push a sentinel unless silent.\n\t\t\t\t\tconst strategy: THistoryStrategy = resolvedOptions.historyStrategy ?? 'push'\n\t\t\t\t\tif (strategy === 'push') {\n\t\t\t\t\t\thistory.pushState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t\thistoryPushed = true\n\t\t\t\t\t} else if (strategy === 'replace') {\n\t\t\t\t\t\thistory.replaceState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t}\n\n\t\t\t\t\t// popstate — close this overlay when the user hits back past us.\n\t\t\t\t\t// If another overlay's popstate fires first, that's fine; each overlay\n\t\t\t\t\t// handles its own via this listener.\n\t\t\t\t\tif (historyPushed) {\n\t\t\t\t\t\tfromEvent<PopStateEvent>(window, 'popstate')\n\t\t\t\t\t\t\t.pipe(take(1), takeUntil(teardown$))\n\t\t\t\t\t\t\t.subscribe(() => {\n\t\t\t\t\t\t\t\t// Avoid double-pop on teardown — set settled so the\n\t\t\t\t\t\t\t\t// teardown fn doesn't call history.back() again.\n\t\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\t\tvoid el?.close('popstate')\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\t// Subscribe to the element's internal close$ — the single source of\n\t\t\t\t\t// truth for lifecycle completion. Emits reason + optional result.\n\t\t\t\t\tel.closed$.pipe(take(1), takeUntil(teardown$)).subscribe(({ result }) => {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\tsubscriber.next(result as T | undefined)\n\t\t\t\t\t\tsubscriber.complete()\n\t\t\t\t\t})\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsubscriber.error(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvoid mount()\n\n\t\t\treturn () => {\n\t\t\t\tteardown$.next()\n\t\t\t\tteardown$.complete()\n\n\t\t\t\t// Unsubscribe path — caller cancelled. Tear down the overlay.\n\t\t\t\tif (el && !settled) {\n\t\t\t\t\tvoid el.close('programmatic')\n\t\t\t\t}\n\n\t\t\t\t// Clean up registry entries.\n\t\t\t\tif (entry) {\n\t\t\t\t\tunmarkModal(entry.id)\n\t\t\t\t\tremoveEntry(entry.id)\n\t\t\t\t}\n\n\t\t\t\t// Pop history if we pushed one and it's still current.\n\t\t\t\tif (historyPushed && !settled) {\n\t\t\t\t\t// Check before calling — if the user already popped, this is a noop.\n\t\t\t\t\tif (history.state?.__schmancyOverlayId === entry?.id) {\n\t\t\t\t\t\thistory.back()\n\t\t\t\t\t}\n\t\t\t\t\thistoryPushed = false\n\t\t\t\t}\n\n\t\t\t\t// Remove element after exit animation has had a chance to play.\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tel?.remove()\n\t\t\t\t\tel = null\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t})\n}\n\n/* ======================================================================= *\n * confirm / prompt sugar *\n * ======================================================================= */\n\n/**\n * Yes/no confirmation dialog. Returns a Promise that resolves with the\n * user's choice. `variant: 'danger'` flips to destructive styling and\n * `role=\"alertdialog\"`.\n */\nexport async function confirm(options: OverlayConfirmOptions = {}): Promise<boolean> {\n\t// Lazy-import the confirm body so push-only callers don't ship these\n\t// deps. The module is small; one-shot import penalty is fine.\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<boolean>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'confirm',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tconfirmText: options.confirmText ?? 'Confirm',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t\tvariant: options.variant ?? 'default',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(false as boolean | undefined)),\n\t)\n\treturn result === true\n}\n\n/**\n * Input prompt dialog. Returns the entered string, or `null` if the user\n * cancels or dismisses.\n */\nexport async function prompt(options: OverlayPromptOptions = {}): Promise<string | null> {\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<string | null>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'prompt',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tlabel: options.label,\n\t\t\t\tdefaultValue: options.defaultValue ?? '',\n\t\t\t\tplaceholder: options.placeholder,\n\t\t\t\tinputType: options.inputType ?? 'text',\n\t\t\t\tpattern: options.pattern,\n\t\t\t\trequired: options.required ?? false,\n\t\t\t\tconfirmText: options.confirmText ?? 'OK',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(null as string | null | undefined)),\n\t)\n\treturn typeof result === 'string' ? result : null\n}\n\n/* ======================================================================= *\n * overlayEvents *\n * ======================================================================= */\n\n/**\n * Subscribe to custom events emitted from any currently-open overlay\n * whose content matches `tagName`. Inspired by `area.on(name)` — keyed\n * by tag name (stable across HMR / lazy chunks) rather than a uid or\n * class reference.\n *\n * The returned Observable never completes on its own — the caller owns\n * teardown via `takeUntil(this.disconnecting)`. During gaps where no\n * matching overlay is open, no events are emitted; when an instance\n * mounts, events flow.\n *\n * Stacked instances of the same content merge their event streams.\n */\nexport function overlayEvents<E extends Event = CustomEvent>(\n\ttagName: string,\n\teventName: string,\n): Observable<E> {\n\treturn elementsByTag$(tagName).pipe(\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t\tswitchMap((elements) =>\n\t\t\telements.length === 0 ? EMPTY : merge(...elements.map((el) => fromEvent<E>(el, eventName))),\n\t\t),\n\t\tmap((e) => e),\n\t)\n}\n\n/* ======================================================================= *\n * dismissAll *\n * ======================================================================= */\n\n/**\n * Close every currently-open overlay. LIFO order. Imperative — use for\n * app-level flows like logout or route reset.\n */\nexport function dismissAll(): void {\n\tconst stack = [...currentStack()]\n\t// LIFO: close top-of-stack first.\n\tfor (let i = stack.length - 1; i >= 0; i--) {\n\t\tconst entry = stack[i]\n\t\tconst overlay = entry.element as SchmancyOverlay\n\t\tvoid overlay.close('programmatic')\n\t}\n\tclearStack()\n}\n\n/* ======================================================================= *\n * helpers *\n * ======================================================================= */\n\nfunction generateId(): string {\n\t// 8-char base36 is enough entropy for session-scoped uniqueness.\n\treturn 'ov_' + Math.random().toString(36).slice(2, 10) + Date.now().toString(36)\n}\n\n// Re-export the close reason type for consumers who want to narrow on it.\nexport type { CloseReason }\n"],"mappings":";AAiBA,IAAM,IAAU,IAAI,EAAyC,EAAA,CAAA,EAGhD,IAA8C,EAAQ,cAAA,EA0C/D,IAAA,CAAmB,GACnB,IAAmB,IACnB,IAA0B;AAE9B,EACE,KACA,GAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAA,CAAA,EAC3B,GAAA,CAAA,CAEA,WAAW,MAAA;CACa,AAAA,OAAb,WAAa,QAEpB,KAAA,CAAe,KAClB,IAAmB,SAAS,gBAAgB,MAAM,UAClD,IAA0B,SAAS,gBAAgB,MAAM,iBAAiB,mBAAA,EAC1E,SAAS,gBAAgB,MAAM,WAAW,UAC1C,SAAS,gBAAgB,MAAM,YAAY,oBAAoB,SAAA,EAC/D,IAAA,CAAmB,KAAA,CACR,KAAc,MACzB,SAAS,gBAAgB,MAAM,WAAW,GACtC,IACH,SAAS,gBAAgB,MAAM,YAAY,oBAAoB,EAAA,GAE/D,SAAS,gBAAgB,MAAM,eAAe,mBAAA,EAE/C,IAAmB,IACnB,IAA0B,IAC1B,IAAA,CAAmB;EAAA;AAqBtB,IAAM,oBAAW,IAAI,KAAA,EACf,oBAAkB,IAAI,KAAA;AAE5B,SAAgB,EAAU,GAAY,GAAA;CACrC,EAAS,IAAI,EAAA,EACT,EAAS,SAAS,KAYvB,SAAoB,GAAA;EACnB,IAAM,IAAS,EAAc,iBAAiB,SAAS;EACvD,KAAK,IAAI,IAAI,GAAG,IAAI,EAAO,SAAS,QAAQ,KAAK;GAChD,IAAM,IAAQ,EAAO,SAAS;GAC1B,M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Lb2.cjs`);let e=require(`rxjs`);var t=new e.BehaviorSubject([]),n=t.asObservable(),r=!1,i=``,a=``;t.pipe((0,e.map)(e=>e.some(e=>e.modal)),(0,e.distinctUntilChanged)()).subscribe(e=>{typeof document<`u`&&(e&&!r?(i=document.documentElement.style.overflow,a=document.documentElement.style.getPropertyValue(`scrollbar-gutter`),document.documentElement.style.overflow=`hidden`,document.documentElement.style.setProperty(`scrollbar-gutter`,`stable`),r=!0):!e&&r&&(document.documentElement.style.overflow=i,a?document.documentElement.style.setProperty(`scrollbar-gutter`,a):document.documentElement.style.removeProperty(`scrollbar-gutter`),i=``,a=``,r=!1))});var o=new Set,s=new Set;function c(e,t){o.add(e),o.size===1&&function(e){let t=e.parentElement??document.body;for(let n=0;n<t.children.length;n++){let r=t.children[n];r!==e&&r instanceof HTMLElement&&!r.inert&&(r.inert=!0,s.add(r))}}(t)}function l(e){o.delete(e),o.size===0&&function(){for(let e of s)e.inert=!1;s.clear()}()}var u=n,d=new e.BehaviorSubject(null);function f(){let e=d.value;if(e&&!(performance.now()-e.capturedAt>750))return e.event}function p(n,r={}){return(0,e.defer)(()=>{let i={...r,anchor:r.anchor??f()};return new e.Observable(r=>{let a=null,o=null,s=!1,u=!1,d=new e.Subject;return(async()=>{try{a=document.createElement(`schmancy-overlay`),(document.body??document.documentElement).appendChild(a),await a.updateComplete,await a.open(n,i);let l=`ov_`+Math.random().toString(36).slice(2,10)+Date.now().toString(36);o={id:l,element:a,layout:a.layout,modal:a.modal,tier:a.tier},function(e){t.next([...t.value,e])}(o),a.modal&&a.parentElement&&c(l,a);let f=i.historyStrategy??`push`;f===`push`?(history.pushState({u:l},``,location.href),s=!0):f===`replace`&&history.replaceState({u:l},``,location.href),s&&(0,e.fromEvent)(window,`popstate`).pipe((0,e.take)(1),(0,e.takeUntil)(d)).subscribe(()=>{u=!0,a?.close(`popstate`)}),a.closed$.pipe((0,e.take)(1),(0,e.takeUntil)(d)).subscribe(({result:e})=>{u=!0,r.next(e),r.complete()})}catch(e){r.error(e)}})(),()=>{d.next(),d.complete(),a&&!u&&a.close(`programmatic`),o&&(l(o.id),function(e){let n=t.value,r=n.filter(t=>t.id!==e);r.length!==n.length&&t.next(r)}(o.id)),s&&!u&&(history.state?.u===o?.id&&history.back(),s=!1),queueMicrotask(()=>{a?.remove(),a=null})}})})}async function m(t={}){let{SchmancyOverlayPromptBody:n}=await Promise.resolve().then(()=>require(`./overlay.confirm-body-
|
|
1
|
+
require(`./chunk-CncqDLb2.cjs`);let e=require(`rxjs`);var t=new e.BehaviorSubject([]),n=t.asObservable(),r=!1,i=``,a=``;t.pipe((0,e.map)(e=>e.some(e=>e.modal)),(0,e.distinctUntilChanged)()).subscribe(e=>{typeof document<`u`&&(e&&!r?(i=document.documentElement.style.overflow,a=document.documentElement.style.getPropertyValue(`scrollbar-gutter`),document.documentElement.style.overflow=`hidden`,document.documentElement.style.setProperty(`scrollbar-gutter`,`stable`),r=!0):!e&&r&&(document.documentElement.style.overflow=i,a?document.documentElement.style.setProperty(`scrollbar-gutter`,a):document.documentElement.style.removeProperty(`scrollbar-gutter`),i=``,a=``,r=!1))});var o=new Set,s=new Set;function c(e,t){o.add(e),o.size===1&&function(e){let t=e.parentElement??document.body;for(let n=0;n<t.children.length;n++){let r=t.children[n];r!==e&&r instanceof HTMLElement&&!r.inert&&(r.inert=!0,s.add(r))}}(t)}function l(e){o.delete(e),o.size===0&&function(){for(let e of s)e.inert=!1;s.clear()}()}var u=n,d=new e.BehaviorSubject(null);function f(){let e=d.value;if(e&&!(performance.now()-e.capturedAt>750))return e.event}function p(n,r={}){return(0,e.defer)(()=>{let i={...r,anchor:r.anchor??f()};return new e.Observable(r=>{let a=null,o=null,s=!1,u=!1,d=new e.Subject;return(async()=>{try{a=document.createElement(`schmancy-overlay`),(document.body??document.documentElement).appendChild(a),await a.updateComplete,await a.open(n,i);let l=`ov_`+Math.random().toString(36).slice(2,10)+Date.now().toString(36);o={id:l,element:a,layout:a.layout,modal:a.modal,tier:a.tier},function(e){t.next([...t.value,e])}(o),a.modal&&a.parentElement&&c(l,a);let f=i.historyStrategy??`push`;f===`push`?(history.pushState({u:l},``,location.href),s=!0):f===`replace`&&history.replaceState({u:l},``,location.href),s&&(0,e.fromEvent)(window,`popstate`).pipe((0,e.take)(1),(0,e.takeUntil)(d)).subscribe(()=>{u=!0,a?.close(`popstate`)}),a.closed$.pipe((0,e.take)(1),(0,e.takeUntil)(d)).subscribe(({result:e})=>{u=!0,r.next(e),r.complete()})}catch(e){r.error(e)}})(),()=>{d.next(),d.complete(),a&&!u&&a.close(`programmatic`),o&&(l(o.id),function(e){let n=t.value,r=n.filter(t=>t.id!==e);r.length!==n.length&&t.next(r)}(o.id)),s&&!u&&(history.state?.u===o?.id&&history.back(),s=!1),queueMicrotask(()=>{a?.remove(),a=null})}})})}async function m(t={}){let{SchmancyOverlayPromptBody:n}=await Promise.resolve().then(()=>require(`./overlay.confirm-body-78e1WrN9.cjs`)).then(e=>e.n);return!0===await(0,e.firstValueFrom)(p(n,{anchor:t.anchor,signal:t.signal,props:{mode:`confirm`,heading:t.title,subtitle:t.subtitle,message:t.message,confirmText:t.confirmText??`Confirm`,cancelText:t.cancelText??`Cancel`,variant:t.variant??`default`}}).pipe((0,e.defaultIfEmpty)(!1)))}async function h(t={}){let{SchmancyOverlayPromptBody:n}=await Promise.resolve().then(()=>require(`./overlay.confirm-body-78e1WrN9.cjs`)).then(e=>e.n),r=await(0,e.firstValueFrom)(p(n,{anchor:t.anchor,signal:t.signal,props:{mode:`prompt`,heading:t.title,subtitle:t.subtitle,message:t.message,label:t.label,defaultValue:t.defaultValue??``,placeholder:t.placeholder,inputType:t.inputType??`text`,pattern:t.pattern,required:t.required??!1,confirmText:t.confirmText??`OK`,cancelText:t.cancelText??`Cancel`}}).pipe((0,e.defaultIfEmpty)(null)));return typeof r==`string`?r:null}function g(n,r){return function(n){let r=n.toLowerCase();return t.pipe((0,e.map)(e=>{let t=[];for(let n of e){let e=n.element.querySelector(r);e&&t.push(e)}return t}),(0,e.distinctUntilChanged)((e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n])))}(n).pipe((0,e.distinctUntilChanged)((e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n])),(0,e.switchMap)(t=>t.length===0?e.EMPTY:(0,e.merge)(...t.map(t=>(0,e.fromEvent)(t,r)))),(0,e.map)(e=>e))}function _(){let e=[...t.value];for(let t=e.length-1;t>=0;t--)e[t].element.close(`programmatic`);t.value.length>0&&t.next([])}typeof document<`u`&&(0,e.merge)((0,e.fromEvent)(document,`pointerdown`,{capture:!0,passive:!0}).pipe((0,e.map)(e=>({event:e,capturedAt:performance.now()}))),(0,e.fromEvent)(document,`click`,{capture:!0,passive:!0}).pipe((0,e.map)(e=>({event:e,capturedAt:performance.now()}))),(0,e.fromEvent)(document,`keydown`,{capture:!0}).pipe((0,e.filter)(e=>e.target instanceof Element),(0,e.map)(e=>{let t=e.target.getBoundingClientRect();return{event:new MouseEvent(`click`,{clientX:t.left+t.width/2,clientY:t.top+t.height/2,bubbles:!0}),capturedAt:performance.now()}}))).subscribe(e=>d.next(e)),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return m}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.service-BxtEFFSH.cjs","names":[],"sources":["../src/overlay/overlay.stack.ts","../src/overlay/overlay.service.ts"],"sourcesContent":["import { BehaviorSubject, distinctUntilChanged, map, Observable } from 'rxjs'\nimport type { OverlayEntry } from './overlay.types'\n\n/**\n * Overlay stack — single source of truth for \"what is currently open.\"\n *\n * A module-scope BehaviorSubject matching the `schmancy` skill's\n * \"contexts at module scope; many small contexts beat one monolith\"\n * guidance. Reactive pipelines inside the overlay service and public\n * `openOverlays$` observable project off this.\n *\n * Scroll lock and the stack-aware inert manager are both derived from\n * the stack state — no separate mutable counter variables. Honors rxjs\n * SUBSCRIPTION_IS_STATE: the stack IS the state; scroll lock / inert\n * are declarative projections.\n */\n\nconst stack$$ = new BehaviorSubject<readonly OverlayEntry[]>([])\n\n/** Public read-only stream of the current stack. Emits on every push/pop. */\nexport const stack$: Observable<readonly OverlayEntry[]> = stack$$.asObservable()\n\n/** Synchronous snapshot. Use only when a component can't subscribe. */\nexport function currentStack(): readonly OverlayEntry[] {\n\treturn stack$$.value\n}\n\n/** Append an entry (top of stack). */\nexport function pushEntry(entry: OverlayEntry): void {\n\tstack$$.next([...stack$$.value, entry])\n}\n\n/** Remove by id. No-op if the id is not in the stack. */\nexport function removeEntry(id: string): void {\n\tconst current = stack$$.value\n\tconst next = current.filter((e) => e.id !== id)\n\tif (next.length !== current.length) {\n\t\tstack$$.next(next)\n\t}\n}\n\n/** Clear the entire stack. Used by dismissAll(). */\nexport function clearStack(): void {\n\tif (stack$$.value.length > 0) {\n\t\tstack$$.next([])\n\t}\n}\n\n/* ---------------- scroll lock -------------------------------------------- */\n\n/**\n * Ref-counted body scroll lock. Active whenever ANY modal-tier overlay is\n * in the stack. Popover-tier (Tier 1/2) overlays do NOT lock body scroll —\n * a menu / share card / picker shouldn't freeze the page scroll behind it\n * (that's platform UX convention).\n *\n * Subscription is idempotent — subscribing multiple times won't stack\n * effects, because it's a distinctUntilChanged boolean projection.\n *\n * Inner overlay close does NOT release the lock while an outer modal is\n * still open (this was the pre-existing bug in sheet.service.ts).\n */\nlet scrollLockActive = false\nlet previousOverflow = ''\nlet previousScrollbarGutter = ''\n\nstack$$\n\t.pipe(\n\t\tmap((s) => s.some((e) => e.modal)),\n\t\tdistinctUntilChanged(),\n\t)\n\t.subscribe((shouldLock) => {\n\t\tif (typeof document === 'undefined') return\n\n\t\tif (shouldLock && !scrollLockActive) {\n\t\t\tpreviousOverflow = document.documentElement.style.overflow\n\t\t\tpreviousScrollbarGutter = document.documentElement.style.getPropertyValue('scrollbar-gutter')\n\t\t\tdocument.documentElement.style.overflow = 'hidden'\n\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', 'stable')\n\t\t\tscrollLockActive = true\n\t\t} else if (!shouldLock && scrollLockActive) {\n\t\t\tdocument.documentElement.style.overflow = previousOverflow\n\t\t\tif (previousScrollbarGutter) {\n\t\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', previousScrollbarGutter)\n\t\t\t} else {\n\t\t\t\tdocument.documentElement.style.removeProperty('scrollbar-gutter')\n\t\t\t}\n\t\t\tpreviousOverflow = ''\n\t\t\tpreviousScrollbarGutter = ''\n\t\t\tscrollLockActive = false\n\t\t}\n\t})\n\n/* ---------------- stack-aware inert -------------------------------------- */\n\n/**\n * When the first modal overlay opens, mark every sibling outside the\n * overlay host subtree as `inert` so AT and keyboard focus can't reach\n * them. Restored when the last modal overlay closes.\n *\n * Note: native `<dialog>.showModal()` already inerts the rest of the\n * document automatically. We keep this as a safety net for:\n * - anchored (popover) overlays which are non-modal by design but may\n * carry `modal: true` as the escape hatch;\n * - stacked overlays where an inner modal opens above a non-modal —\n * the sibling-inert is a no-op but we still guarantee the invariant.\n *\n * Callers that don't want inert (anchored/menu overlays) skip registration\n * via `markNonModal(id)`.\n */\nconst modalIds = new Set<string>()\nconst inertedSiblings = new Set<HTMLElement>()\n\nexport function markModal(id: string, hostContainer: HTMLElement): void {\n\tmodalIds.add(id)\n\tif (modalIds.size === 1) {\n\t\tapplyInert(hostContainer)\n\t}\n}\n\nexport function unmarkModal(id: string): void {\n\tmodalIds.delete(id)\n\tif (modalIds.size === 0) {\n\t\treleaseInert()\n\t}\n}\n\nfunction applyInert(hostContainer: HTMLElement): void {\n\tconst parent = hostContainer.parentElement ?? document.body\n\tfor (let i = 0; i < parent.children.length; i++) {\n\t\tconst child = parent.children[i]\n\t\tif (child !== hostContainer && child instanceof HTMLElement && !child.inert) {\n\t\t\tchild.inert = true\n\t\t\tinertedSiblings.add(child)\n\t\t}\n\t}\n}\n\nfunction releaseInert(): void {\n\tfor (const el of inertedSiblings) {\n\t\tel.inert = false\n\t}\n\tinertedSiblings.clear()\n}\n\n/* ---------------- overlayEvents multicast helper ------------------------- */\n\n/**\n * Returns an Observable of `tagName` elements currently in the stack.\n * The overlayEvents public helper composes `fromEvent` over this stream\n * via switchMap to tap events without owning the overlay lifecycle.\n *\n * Stays alive across open/close cycles — the caller owns completion via\n * `takeUntil(this.disconnecting)`, matching the house rxjs convention.\n */\nexport function elementsByTag$(tagName: string): Observable<readonly HTMLElement[]> {\n\tconst lower = tagName.toLowerCase()\n\treturn stack$$.pipe(\n\t\tmap((entries) => {\n\t\t\tconst matches: HTMLElement[] = []\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst inner = entry.element.querySelector<HTMLElement>(lower)\n\t\t\t\tif (inner) matches.push(inner)\n\t\t\t}\n\t\t\treturn matches\n\t\t}),\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t)\n}\n","import {\n\tBehaviorSubject,\n\tdefer,\n\tdefaultIfEmpty,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfirstValueFrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tSubject,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n} from 'rxjs'\nimport type { THistoryStrategy } from '../area/router.types'\nimport { SchmancyOverlay } from './overlay.component'\nimport {\n\tclearStack,\n\tcurrentStack,\n\telementsByTag$,\n\tmarkModal,\n\tpushEntry,\n\tremoveEntry,\n\tstack$ as internalStack$,\n\tunmarkModal,\n} from './overlay.stack'\nimport type {\n\tCloseReason,\n\tOverlayConfirmOptions,\n\tContent,\n\tOverlayEntry,\n\tOverlayPromptOptions,\n\tShowOptions,\n} from './overlay.types'\n\n/**\n * Public read-only stream of the current overlay stack. Subscribe to\n * observe stack changes — e.g. to update a breadcrumb, show a \"close\n * all\" button, or gate another action while any overlay is open.\n *\n * Emits synchronously with the current snapshot on subscribe. Never\n * completes — the caller owns teardown via `takeUntil(this.disconnecting)`.\n */\nexport const openOverlays$: Observable<readonly OverlayEntry[]> = internalStack$\n\n/* ======================================================================= *\n * ambient event capture *\n * ======================================================================= *\n * Novel: callers do not need to pass `anchor: event` manually. The service\n * listens to pointerdown / click / keydown at capture phase on the document\n * and remembers the most-recent user gesture. When show() is invoked\n * synchronously (or shortly after) in response to that gesture, the remembered\n * event becomes the default anchor. This matches the \"anchored is the novel\n * default\" principle without forcing callers to thread events through\n * handlers.\n *\n * Staleness guard: an event older than AMBIENT_ANCHOR_MAX_AGE_MS is ignored.\n * Timer-driven or async show() calls that don't originate from a user gesture\n * fall through to centered / sheet layout.\n */\nconst AMBIENT_ANCHOR_MAX_AGE_MS = 750\n\ninterface AmbientAnchor {\n\tevent: MouseEvent\n\tcapturedAt: number\n}\n\n/**\n * BehaviorSubject projected off three document-level event streams,\n * merged as Observables per rxjs principle 3 (every async source\n * lifted into fromEvent). Keydown activations synthesize a MouseEvent\n * at the focused element's bounding rect so the anchor path can\n * carry keyboard-triggered opens uniformly.\n *\n * The singleton subscribe has no explicit teardown — the module's\n * lifetime IS the subscription's lifetime, which is the correct\n * SUBSCRIPTION_IS_STATE shape for a document-level event sink.\n */\nconst ambientAnchor$ = new BehaviorSubject<AmbientAnchor | null>(null)\n\nif (typeof document !== 'undefined') {\n\tconst pointerdown$ = fromEvent<PointerEvent>(document, 'pointerdown', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst click$ = fromEvent<MouseEvent>(document, 'click', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst keydown$ = fromEvent<KeyboardEvent>(document, 'keydown', { capture: true }).pipe(\n\t\tfilter((e) => e.target instanceof Element),\n\t\tmap((e): AmbientAnchor => {\n\t\t\tconst rect = (e.target as Element).getBoundingClientRect()\n\t\t\tconst synthetic = new MouseEvent('click', {\n\t\t\t\tclientX: rect.left + rect.width / 2,\n\t\t\t\tclientY: rect.top + rect.height / 2,\n\t\t\t\tbubbles: true,\n\t\t\t})\n\t\t\treturn { event: synthetic, capturedAt: performance.now() }\n\t\t}),\n\t)\n\n\tmerge(pointerdown$, click$, keydown$).subscribe((ambient) => ambientAnchor$.next(ambient))\n}\n\nfunction ambientAnchor(): MouseEvent | undefined {\n\tconst cur = ambientAnchor$.value\n\tif (!cur) return undefined\n\tif (performance.now() - cur.capturedAt > AMBIENT_ANCHOR_MAX_AGE_MS) return undefined\n\treturn cur.event\n}\n\n\n/* ======================================================================= *\n * show *\n * ======================================================================= */\n\n/**\n * Open an overlay containing `content`. Returns a cold Observable — the\n * overlay mounts on subscribe and dismisses on unsubscribe. Emits at\n * most one value (the result from content's `close` event) then completes.\n *\n * The subscription IS the overlay lifecycle. `takeUntil(this.disconnecting)`\n * on the caller's side means the overlay auto-dismisses when the caller\n * unmounts — no handles to track, no leaks.\n *\n * **Anchored is the novel default.** When triggered by a user event, pass\n * it as `anchor` — the overlay blooms from the point of attention. Falls\n * back to centered or sheet when the viewport / content makes that the\n * better layout (see overlay.layout.ts).\n *\n * @example\n * show(MyEditor, { props: { id }, anchor: event })\n * .pipe(takeUntil(this.disconnecting))\n * .subscribe(saved => saved && this.store.persist(saved))\n */\nexport function show<T = void>(\n\tcontent: Content,\n\toptions: ShowOptions = {},\n): Observable<T | undefined> {\n\treturn defer(() => {\n\t\t// Resolve anchor at subscribe time: caller's explicit anchor wins,\n\t\t// otherwise the ambient gesture captured by ambientAnchor$ fills in.\n\t\tconst resolvedOptions: ShowOptions = {\n\t\t\t...options,\n\t\t\tanchor: options.anchor ?? ambientAnchor(),\n\t\t}\n\n\t\treturn new Observable<T | undefined>((subscriber) => {\n\t\t\tlet el: SchmancyOverlay | null = null\n\t\t\tlet entry: OverlayEntry | null = null\n\t\t\tlet historyPushed = false\n\t\t\tlet settled = false\n\n\t\t\tconst teardown$ = new Subject<void>()\n\n\t\t\tconst mount = async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Create and append the overlay element.\n\t\t\t\t\tel = document.createElement('schmancy-overlay') as SchmancyOverlay\n\t\t\t\t\t;(document.body ?? document.documentElement).appendChild(el)\n\t\t\t\t\tawait el.updateComplete\n\n\t\t\t\t\t// Open it — mount content, resolve layout, animate in.\n\t\t\t\t\tawait el.open(content, resolvedOptions)\n\n\t\t\t\t\t// Register with the stack (post-open so layout, modal, tier are all\n\t\t\t\t\t// resolved by the element).\n\t\t\t\t\tconst id = generateId()\n\t\t\t\t\tentry = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\telement: el,\n\t\t\t\t\t\tlayout: el.layout,\n\t\t\t\t\t\tmodal: el.modal,\n\t\t\t\t\t\ttier: el.tier,\n\t\t\t\t\t}\n\t\t\t\t\tpushEntry(entry)\n\n\t\t\t\t\t// Register modality for the stack-aware inert manager when modal.\n\t\t\t\t\tif (el.modal && el.parentElement) {\n\t\t\t\t\t\tmarkModal(id, el)\n\t\t\t\t\t}\n\n\t\t\t\t\t// History integration — push a sentinel unless silent.\n\t\t\t\t\tconst strategy: THistoryStrategy = resolvedOptions.historyStrategy ?? 'push'\n\t\t\t\t\tif (strategy === 'push') {\n\t\t\t\t\t\thistory.pushState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t\thistoryPushed = true\n\t\t\t\t\t} else if (strategy === 'replace') {\n\t\t\t\t\t\thistory.replaceState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t}\n\n\t\t\t\t\t// popstate — close this overlay when the user hits back past us.\n\t\t\t\t\t// If another overlay's popstate fires first, that's fine; each overlay\n\t\t\t\t\t// handles its own via this listener.\n\t\t\t\t\tif (historyPushed) {\n\t\t\t\t\t\tfromEvent<PopStateEvent>(window, 'popstate')\n\t\t\t\t\t\t\t.pipe(take(1), takeUntil(teardown$))\n\t\t\t\t\t\t\t.subscribe(() => {\n\t\t\t\t\t\t\t\t// Avoid double-pop on teardown — set settled so the\n\t\t\t\t\t\t\t\t// teardown fn doesn't call history.back() again.\n\t\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\t\tvoid el?.close('popstate')\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\t// Subscribe to the element's internal close$ — the single source of\n\t\t\t\t\t// truth for lifecycle completion. Emits reason + optional result.\n\t\t\t\t\tel.closed$.pipe(take(1), takeUntil(teardown$)).subscribe(({ result }) => {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\tsubscriber.next(result as T | undefined)\n\t\t\t\t\t\tsubscriber.complete()\n\t\t\t\t\t})\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsubscriber.error(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvoid mount()\n\n\t\t\treturn () => {\n\t\t\t\tteardown$.next()\n\t\t\t\tteardown$.complete()\n\n\t\t\t\t// Unsubscribe path — caller cancelled. Tear down the overlay.\n\t\t\t\tif (el && !settled) {\n\t\t\t\t\tvoid el.close('programmatic')\n\t\t\t\t}\n\n\t\t\t\t// Clean up registry entries.\n\t\t\t\tif (entry) {\n\t\t\t\t\tunmarkModal(entry.id)\n\t\t\t\t\tremoveEntry(entry.id)\n\t\t\t\t}\n\n\t\t\t\t// Pop history if we pushed one and it's still current.\n\t\t\t\tif (historyPushed && !settled) {\n\t\t\t\t\t// Check before calling — if the user already popped, this is a noop.\n\t\t\t\t\tif (history.state?.__schmancyOverlayId === entry?.id) {\n\t\t\t\t\t\thistory.back()\n\t\t\t\t\t}\n\t\t\t\t\thistoryPushed = false\n\t\t\t\t}\n\n\t\t\t\t// Remove element after exit animation has had a chance to play.\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tel?.remove()\n\t\t\t\t\tel = null\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t})\n}\n\n/* ======================================================================= *\n * confirm / prompt sugar *\n * ======================================================================= */\n\n/**\n * Yes/no confirmation dialog. Returns a Promise that resolves with the\n * user's choice. `variant: 'danger'` flips to destructive styling and\n * `role=\"alertdialog\"`.\n */\nexport async function confirm(options: OverlayConfirmOptions = {}): Promise<boolean> {\n\t// Lazy-import the confirm body so push-only callers don't ship these\n\t// deps. The module is small; one-shot import penalty is fine.\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<boolean>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'confirm',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tconfirmText: options.confirmText ?? 'Confirm',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t\tvariant: options.variant ?? 'default',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(false as boolean | undefined)),\n\t)\n\treturn result === true\n}\n\n/**\n * Input prompt dialog. Returns the entered string, or `null` if the user\n * cancels or dismisses.\n */\nexport async function prompt(options: OverlayPromptOptions = {}): Promise<string | null> {\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<string | null>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'prompt',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tlabel: options.label,\n\t\t\t\tdefaultValue: options.defaultValue ?? '',\n\t\t\t\tplaceholder: options.placeholder,\n\t\t\t\tinputType: options.inputType ?? 'text',\n\t\t\t\tpattern: options.pattern,\n\t\t\t\trequired: options.required ?? false,\n\t\t\t\tconfirmText: options.confirmText ?? 'OK',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(null as string | null | undefined)),\n\t)\n\treturn typeof result === 'string' ? result : null\n}\n\n/* ======================================================================= *\n * overlayEvents *\n * ======================================================================= */\n\n/**\n * Subscribe to custom events emitted from any currently-open overlay\n * whose content matches `tagName`. Inspired by `area.on(name)` — keyed\n * by tag name (stable across HMR / lazy chunks) rather than a uid or\n * class reference.\n *\n * The returned Observable never completes on its own — the caller owns\n * teardown via `takeUntil(this.disconnecting)`. During gaps where no\n * matching overlay is open, no events are emitted; when an instance\n * mounts, events flow.\n *\n * Stacked instances of the same content merge their event streams.\n */\nexport function overlayEvents<E extends Event = CustomEvent>(\n\ttagName: string,\n\teventName: string,\n): Observable<E> {\n\treturn elementsByTag$(tagName).pipe(\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t\tswitchMap((elements) =>\n\t\t\telements.length === 0 ? EMPTY : merge(...elements.map((el) => fromEvent<E>(el, eventName))),\n\t\t),\n\t\tmap((e) => e),\n\t)\n}\n\n/* ======================================================================= *\n * dismissAll *\n * ======================================================================= */\n\n/**\n * Close every currently-open overlay. LIFO order. Imperative — use for\n * app-level flows like logout or route reset.\n */\nexport function dismissAll(): void {\n\tconst stack = [...currentStack()]\n\t// LIFO: close top-of-stack first.\n\tfor (let i = stack.length - 1; i >= 0; i--) {\n\t\tconst entry = stack[i]\n\t\tconst overlay = entry.element as SchmancyOverlay\n\t\tvoid overlay.close('programmatic')\n\t}\n\tclearStack()\n}\n\n/* ======================================================================= *\n * helpers *\n * ======================================================================= */\n\nfunction generateId(): string {\n\t// 8-char base36 is enough entropy for session-scoped uniqueness.\n\treturn 'ov_' + Math.random().toString(36).slice(2, 10) + Date.now().toString(36)\n}\n\n// Re-export the close reason type for consumers who want to narrow on it.\nexport type { CloseReason }\n"],"mappings":"sDAiBA,IAAM,EAAU,IAAI,EAAA,gBAAyC,EAAA,CAAA,CAGhD,EAA8C,EAAQ,cAAA,C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,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA,CAAA,OAAA,eAAA,QAAA,IAAA,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA,CAAA,OAAA,eAAA,QAAA,IAAA,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA,CAAA,OAAA,eAAA,QAAA,IAAA,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA,CAAA,OAAA,eAAA,QAAA,IAAA,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"overlay.service-DQkGPUY7.cjs","names":[],"sources":["../src/overlay/overlay.stack.ts","../src/overlay/overlay.service.ts"],"sourcesContent":["import { BehaviorSubject, distinctUntilChanged, map, Observable } from 'rxjs'\nimport type { OverlayEntry } from './overlay.types'\n\n/**\n * Overlay stack — single source of truth for \"what is currently open.\"\n *\n * A module-scope BehaviorSubject matching the `schmancy` skill's\n * \"contexts at module scope; many small contexts beat one monolith\"\n * guidance. Reactive pipelines inside the overlay service and public\n * `openOverlays$` observable project off this.\n *\n * Scroll lock and the stack-aware inert manager are both derived from\n * the stack state — no separate mutable counter variables. Honors rxjs\n * SUBSCRIPTION_IS_STATE: the stack IS the state; scroll lock / inert\n * are declarative projections.\n */\n\nconst stack$$ = new BehaviorSubject<readonly OverlayEntry[]>([])\n\n/** Public read-only stream of the current stack. Emits on every push/pop. */\nexport const stack$: Observable<readonly OverlayEntry[]> = stack$$.asObservable()\n\n/** Synchronous snapshot. Use only when a component can't subscribe. */\nexport function currentStack(): readonly OverlayEntry[] {\n\treturn stack$$.value\n}\n\n/** Append an entry (top of stack). */\nexport function pushEntry(entry: OverlayEntry): void {\n\tstack$$.next([...stack$$.value, entry])\n}\n\n/** Remove by id. No-op if the id is not in the stack. */\nexport function removeEntry(id: string): void {\n\tconst current = stack$$.value\n\tconst next = current.filter((e) => e.id !== id)\n\tif (next.length !== current.length) {\n\t\tstack$$.next(next)\n\t}\n}\n\n/** Clear the entire stack. Used by dismissAll(). */\nexport function clearStack(): void {\n\tif (stack$$.value.length > 0) {\n\t\tstack$$.next([])\n\t}\n}\n\n/* ---------------- scroll lock -------------------------------------------- */\n\n/**\n * Ref-counted body scroll lock. Active whenever ANY modal-tier overlay is\n * in the stack. Popover-tier (Tier 1/2) overlays do NOT lock body scroll —\n * a menu / share card / picker shouldn't freeze the page scroll behind it\n * (that's platform UX convention).\n *\n * Subscription is idempotent — subscribing multiple times won't stack\n * effects, because it's a distinctUntilChanged boolean projection.\n *\n * Inner overlay close does NOT release the lock while an outer modal is\n * still open (this was the pre-existing bug in sheet.service.ts).\n */\nlet scrollLockActive = false\nlet previousOverflow = ''\nlet previousScrollbarGutter = ''\n\nstack$$\n\t.pipe(\n\t\tmap((s) => s.some((e) => e.modal)),\n\t\tdistinctUntilChanged(),\n\t)\n\t.subscribe((shouldLock) => {\n\t\tif (typeof document === 'undefined') return\n\n\t\tif (shouldLock && !scrollLockActive) {\n\t\t\tpreviousOverflow = document.documentElement.style.overflow\n\t\t\tpreviousScrollbarGutter = document.documentElement.style.getPropertyValue('scrollbar-gutter')\n\t\t\tdocument.documentElement.style.overflow = 'hidden'\n\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', 'stable')\n\t\t\tscrollLockActive = true\n\t\t} else if (!shouldLock && scrollLockActive) {\n\t\t\tdocument.documentElement.style.overflow = previousOverflow\n\t\t\tif (previousScrollbarGutter) {\n\t\t\t\tdocument.documentElement.style.setProperty('scrollbar-gutter', previousScrollbarGutter)\n\t\t\t} else {\n\t\t\t\tdocument.documentElement.style.removeProperty('scrollbar-gutter')\n\t\t\t}\n\t\t\tpreviousOverflow = ''\n\t\t\tpreviousScrollbarGutter = ''\n\t\t\tscrollLockActive = false\n\t\t}\n\t})\n\n/* ---------------- stack-aware inert -------------------------------------- */\n\n/**\n * When the first modal overlay opens, mark every sibling outside the\n * overlay host subtree as `inert` so AT and keyboard focus can't reach\n * them. Restored when the last modal overlay closes.\n *\n * Note: native `<dialog>.showModal()` already inerts the rest of the\n * document automatically. We keep this as a safety net for:\n * - anchored (popover) overlays which are non-modal by design but may\n * carry `modal: true` as the escape hatch;\n * - stacked overlays where an inner modal opens above a non-modal —\n * the sibling-inert is a no-op but we still guarantee the invariant.\n *\n * Callers that don't want inert (anchored/menu overlays) skip registration\n * via `markNonModal(id)`.\n */\nconst modalIds = new Set<string>()\nconst inertedSiblings = new Set<HTMLElement>()\n\nexport function markModal(id: string, hostContainer: HTMLElement): void {\n\tmodalIds.add(id)\n\tif (modalIds.size === 1) {\n\t\tapplyInert(hostContainer)\n\t}\n}\n\nexport function unmarkModal(id: string): void {\n\tmodalIds.delete(id)\n\tif (modalIds.size === 0) {\n\t\treleaseInert()\n\t}\n}\n\nfunction applyInert(hostContainer: HTMLElement): void {\n\tconst parent = hostContainer.parentElement ?? document.body\n\tfor (let i = 0; i < parent.children.length; i++) {\n\t\tconst child = parent.children[i]\n\t\tif (child !== hostContainer && child instanceof HTMLElement && !child.inert) {\n\t\t\tchild.inert = true\n\t\t\tinertedSiblings.add(child)\n\t\t}\n\t}\n}\n\nfunction releaseInert(): void {\n\tfor (const el of inertedSiblings) {\n\t\tel.inert = false\n\t}\n\tinertedSiblings.clear()\n}\n\n/* ---------------- overlayEvents multicast helper ------------------------- */\n\n/**\n * Returns an Observable of `tagName` elements currently in the stack.\n * The overlayEvents public helper composes `fromEvent` over this stream\n * via switchMap to tap events without owning the overlay lifecycle.\n *\n * Stays alive across open/close cycles — the caller owns completion via\n * `takeUntil(this.disconnecting)`, matching the house rxjs convention.\n */\nexport function elementsByTag$(tagName: string): Observable<readonly HTMLElement[]> {\n\tconst lower = tagName.toLowerCase()\n\treturn stack$$.pipe(\n\t\tmap((entries) => {\n\t\t\tconst matches: HTMLElement[] = []\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst inner = entry.element.querySelector<HTMLElement>(lower)\n\t\t\t\tif (inner) matches.push(inner)\n\t\t\t}\n\t\t\treturn matches\n\t\t}),\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t)\n}\n","import {\n\tBehaviorSubject,\n\tdefer,\n\tdefaultIfEmpty,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfirstValueFrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tObservable,\n\tSubject,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n} from 'rxjs'\nimport type { THistoryStrategy } from '../area/router.types'\nimport { SchmancyOverlay } from './overlay.component'\nimport {\n\tclearStack,\n\tcurrentStack,\n\telementsByTag$,\n\tmarkModal,\n\tpushEntry,\n\tremoveEntry,\n\tstack$ as internalStack$,\n\tunmarkModal,\n} from './overlay.stack'\nimport type {\n\tCloseReason,\n\tOverlayConfirmOptions,\n\tContent,\n\tOverlayEntry,\n\tOverlayPromptOptions,\n\tShowOptions,\n} from './overlay.types'\n\n/**\n * Public read-only stream of the current overlay stack. Subscribe to\n * observe stack changes — e.g. to update a breadcrumb, show a \"close\n * all\" button, or gate another action while any overlay is open.\n *\n * Emits synchronously with the current snapshot on subscribe. Never\n * completes — the caller owns teardown via `takeUntil(this.disconnecting)`.\n */\nexport const openOverlays$: Observable<readonly OverlayEntry[]> = internalStack$\n\n/* ======================================================================= *\n * ambient event capture *\n * ======================================================================= *\n * Novel: callers do not need to pass `anchor: event` manually. The service\n * listens to pointerdown / click / keydown at capture phase on the document\n * and remembers the most-recent user gesture. When show() is invoked\n * synchronously (or shortly after) in response to that gesture, the remembered\n * event becomes the default anchor. This matches the \"anchored is the novel\n * default\" principle without forcing callers to thread events through\n * handlers.\n *\n * Staleness guard: an event older than AMBIENT_ANCHOR_MAX_AGE_MS is ignored.\n * Timer-driven or async show() calls that don't originate from a user gesture\n * fall through to centered / sheet layout.\n */\nconst AMBIENT_ANCHOR_MAX_AGE_MS = 750\n\ninterface AmbientAnchor {\n\tevent: MouseEvent\n\tcapturedAt: number\n}\n\n/**\n * BehaviorSubject projected off three document-level event streams,\n * merged as Observables per rxjs principle 3 (every async source\n * lifted into fromEvent). Keydown activations synthesize a MouseEvent\n * at the focused element's bounding rect so the anchor path can\n * carry keyboard-triggered opens uniformly.\n *\n * The singleton subscribe has no explicit teardown — the module's\n * lifetime IS the subscription's lifetime, which is the correct\n * SUBSCRIPTION_IS_STATE shape for a document-level event sink.\n */\nconst ambientAnchor$ = new BehaviorSubject<AmbientAnchor | null>(null)\n\nif (typeof document !== 'undefined') {\n\tconst pointerdown$ = fromEvent<PointerEvent>(document, 'pointerdown', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst click$ = fromEvent<MouseEvent>(document, 'click', { capture: true, passive: true }).pipe(\n\t\tmap((e): AmbientAnchor => ({ event: e, capturedAt: performance.now() })),\n\t)\n\tconst keydown$ = fromEvent<KeyboardEvent>(document, 'keydown', { capture: true }).pipe(\n\t\tfilter((e) => e.target instanceof Element),\n\t\tmap((e): AmbientAnchor => {\n\t\t\tconst rect = (e.target as Element).getBoundingClientRect()\n\t\t\tconst synthetic = new MouseEvent('click', {\n\t\t\t\tclientX: rect.left + rect.width / 2,\n\t\t\t\tclientY: rect.top + rect.height / 2,\n\t\t\t\tbubbles: true,\n\t\t\t})\n\t\t\treturn { event: synthetic, capturedAt: performance.now() }\n\t\t}),\n\t)\n\n\tmerge(pointerdown$, click$, keydown$).subscribe((ambient) => ambientAnchor$.next(ambient))\n}\n\nfunction ambientAnchor(): MouseEvent | undefined {\n\tconst cur = ambientAnchor$.value\n\tif (!cur) return undefined\n\tif (performance.now() - cur.capturedAt > AMBIENT_ANCHOR_MAX_AGE_MS) return undefined\n\treturn cur.event\n}\n\n\n/* ======================================================================= *\n * show *\n * ======================================================================= */\n\n/**\n * Open an overlay containing `content`. Returns a cold Observable — the\n * overlay mounts on subscribe and dismisses on unsubscribe. Emits at\n * most one value (the result from content's `close` event) then completes.\n *\n * The subscription IS the overlay lifecycle. `takeUntil(this.disconnecting)`\n * on the caller's side means the overlay auto-dismisses when the caller\n * unmounts — no handles to track, no leaks.\n *\n * **Anchored is the novel default.** When triggered by a user event, pass\n * it as `anchor` — the overlay blooms from the point of attention. Falls\n * back to centered or sheet when the viewport / content makes that the\n * better layout (see overlay.layout.ts).\n *\n * @example\n * show(MyEditor, { props: { id }, anchor: event })\n * .pipe(takeUntil(this.disconnecting))\n * .subscribe(saved => saved && this.store.persist(saved))\n */\nexport function show<T = void>(\n\tcontent: Content,\n\toptions: ShowOptions = {},\n): Observable<T | undefined> {\n\treturn defer(() => {\n\t\t// Resolve anchor at subscribe time: caller's explicit anchor wins,\n\t\t// otherwise the ambient gesture captured by ambientAnchor$ fills in.\n\t\tconst resolvedOptions: ShowOptions = {\n\t\t\t...options,\n\t\t\tanchor: options.anchor ?? ambientAnchor(),\n\t\t}\n\n\t\treturn new Observable<T | undefined>((subscriber) => {\n\t\t\tlet el: SchmancyOverlay | null = null\n\t\t\tlet entry: OverlayEntry | null = null\n\t\t\tlet historyPushed = false\n\t\t\tlet settled = false\n\n\t\t\tconst teardown$ = new Subject<void>()\n\n\t\t\tconst mount = async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Create and append the overlay element.\n\t\t\t\t\tel = document.createElement('schmancy-overlay') as SchmancyOverlay\n\t\t\t\t\t;(document.body ?? document.documentElement).appendChild(el)\n\t\t\t\t\tawait el.updateComplete\n\n\t\t\t\t\t// Open it — mount content, resolve layout, animate in.\n\t\t\t\t\tawait el.open(content, resolvedOptions)\n\n\t\t\t\t\t// Register with the stack (post-open so layout, modal, tier are all\n\t\t\t\t\t// resolved by the element).\n\t\t\t\t\tconst id = generateId()\n\t\t\t\t\tentry = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\telement: el,\n\t\t\t\t\t\tlayout: el.layout,\n\t\t\t\t\t\tmodal: el.modal,\n\t\t\t\t\t\ttier: el.tier,\n\t\t\t\t\t}\n\t\t\t\t\tpushEntry(entry)\n\n\t\t\t\t\t// Register modality for the stack-aware inert manager when modal.\n\t\t\t\t\tif (el.modal && el.parentElement) {\n\t\t\t\t\t\tmarkModal(id, el)\n\t\t\t\t\t}\n\n\t\t\t\t\t// History integration — push a sentinel unless silent.\n\t\t\t\t\tconst strategy: THistoryStrategy = resolvedOptions.historyStrategy ?? 'push'\n\t\t\t\t\tif (strategy === 'push') {\n\t\t\t\t\t\thistory.pushState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t\thistoryPushed = true\n\t\t\t\t\t} else if (strategy === 'replace') {\n\t\t\t\t\t\thistory.replaceState({ __schmancyOverlayId: id }, '', location.href)\n\t\t\t\t\t}\n\n\t\t\t\t\t// popstate — close this overlay when the user hits back past us.\n\t\t\t\t\t// If another overlay's popstate fires first, that's fine; each overlay\n\t\t\t\t\t// handles its own via this listener.\n\t\t\t\t\tif (historyPushed) {\n\t\t\t\t\t\tfromEvent<PopStateEvent>(window, 'popstate')\n\t\t\t\t\t\t\t.pipe(take(1), takeUntil(teardown$))\n\t\t\t\t\t\t\t.subscribe(() => {\n\t\t\t\t\t\t\t\t// Avoid double-pop on teardown — set settled so the\n\t\t\t\t\t\t\t\t// teardown fn doesn't call history.back() again.\n\t\t\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\t\t\tvoid el?.close('popstate')\n\t\t\t\t\t\t\t})\n\t\t\t\t\t}\n\n\t\t\t\t\t// Subscribe to the element's internal close$ — the single source of\n\t\t\t\t\t// truth for lifecycle completion. Emits reason + optional result.\n\t\t\t\t\tel.closed$.pipe(take(1), takeUntil(teardown$)).subscribe(({ result }) => {\n\t\t\t\t\t\tsettled = true\n\t\t\t\t\t\tsubscriber.next(result as T | undefined)\n\t\t\t\t\t\tsubscriber.complete()\n\t\t\t\t\t})\n\t\t\t\t} catch (err) {\n\t\t\t\t\tsubscriber.error(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvoid mount()\n\n\t\t\treturn () => {\n\t\t\t\tteardown$.next()\n\t\t\t\tteardown$.complete()\n\n\t\t\t\t// Unsubscribe path — caller cancelled. Tear down the overlay.\n\t\t\t\tif (el && !settled) {\n\t\t\t\t\tvoid el.close('programmatic')\n\t\t\t\t}\n\n\t\t\t\t// Clean up registry entries.\n\t\t\t\tif (entry) {\n\t\t\t\t\tunmarkModal(entry.id)\n\t\t\t\t\tremoveEntry(entry.id)\n\t\t\t\t}\n\n\t\t\t\t// Pop history if we pushed one and it's still current.\n\t\t\t\tif (historyPushed && !settled) {\n\t\t\t\t\t// Check before calling — if the user already popped, this is a noop.\n\t\t\t\t\tif (history.state?.__schmancyOverlayId === entry?.id) {\n\t\t\t\t\t\thistory.back()\n\t\t\t\t\t}\n\t\t\t\t\thistoryPushed = false\n\t\t\t\t}\n\n\t\t\t\t// Remove element after exit animation has had a chance to play.\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tel?.remove()\n\t\t\t\t\tel = null\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t})\n}\n\n/* ======================================================================= *\n * confirm / prompt sugar *\n * ======================================================================= */\n\n/**\n * Yes/no confirmation dialog. Returns a Promise that resolves with the\n * user's choice. `variant: 'danger'` flips to destructive styling and\n * `role=\"alertdialog\"`.\n */\nexport async function confirm(options: OverlayConfirmOptions = {}): Promise<boolean> {\n\t// Lazy-import the confirm body so push-only callers don't ship these\n\t// deps. The module is small; one-shot import penalty is fine.\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<boolean>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'confirm',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tconfirmText: options.confirmText ?? 'Confirm',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t\tvariant: options.variant ?? 'default',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(false as boolean | undefined)),\n\t)\n\treturn result === true\n}\n\n/**\n * Input prompt dialog. Returns the entered string, or `null` if the user\n * cancels or dismisses.\n */\nexport async function prompt(options: OverlayPromptOptions = {}): Promise<string | null> {\n\tconst { SchmancyOverlayPromptBody } = await import('./overlay.confirm-body')\n\n\tconst result = await firstValueFrom(\n\t\tshow<string | null>(SchmancyOverlayPromptBody, {\n\t\t\tanchor: options.anchor,\n\t\t\tsignal: options.signal,\n\t\t\tprops: {\n\t\t\t\tmode: 'prompt',\n\t\t\t\theading: options.title,\n\t\t\t\tsubtitle: options.subtitle,\n\t\t\t\tmessage: options.message,\n\t\t\t\tlabel: options.label,\n\t\t\t\tdefaultValue: options.defaultValue ?? '',\n\t\t\t\tplaceholder: options.placeholder,\n\t\t\t\tinputType: options.inputType ?? 'text',\n\t\t\t\tpattern: options.pattern,\n\t\t\t\trequired: options.required ?? false,\n\t\t\t\tconfirmText: options.confirmText ?? 'OK',\n\t\t\t\tcancelText: options.cancelText ?? 'Cancel',\n\t\t\t},\n\t\t}).pipe(defaultIfEmpty(null as string | null | undefined)),\n\t)\n\treturn typeof result === 'string' ? result : null\n}\n\n/* ======================================================================= *\n * overlayEvents *\n * ======================================================================= */\n\n/**\n * Subscribe to custom events emitted from any currently-open overlay\n * whose content matches `tagName`. Inspired by `area.on(name)` — keyed\n * by tag name (stable across HMR / lazy chunks) rather than a uid or\n * class reference.\n *\n * The returned Observable never completes on its own — the caller owns\n * teardown via `takeUntil(this.disconnecting)`. During gaps where no\n * matching overlay is open, no events are emitted; when an instance\n * mounts, events flow.\n *\n * Stacked instances of the same content merge their event streams.\n */\nexport function overlayEvents<E extends Event = CustomEvent>(\n\ttagName: string,\n\teventName: string,\n): Observable<E> {\n\treturn elementsByTag$(tagName).pipe(\n\t\tdistinctUntilChanged((a, b) => a.length === b.length && a.every((el, i) => el === b[i])),\n\t\tswitchMap((elements) =>\n\t\t\telements.length === 0 ? EMPTY : merge(...elements.map((el) => fromEvent<E>(el, eventName))),\n\t\t),\n\t\tmap((e) => e),\n\t)\n}\n\n/* ======================================================================= *\n * dismissAll *\n * ======================================================================= */\n\n/**\n * Close every currently-open overlay. LIFO order. Imperative — use for\n * app-level flows like logout or route reset.\n */\nexport function dismissAll(): void {\n\tconst stack = [...currentStack()]\n\t// LIFO: close top-of-stack first.\n\tfor (let i = stack.length - 1; i >= 0; i--) {\n\t\tconst entry = stack[i]\n\t\tconst overlay = entry.element as SchmancyOverlay\n\t\tvoid overlay.close('programmatic')\n\t}\n\tclearStack()\n}\n\n/* ======================================================================= *\n * helpers *\n * ======================================================================= */\n\nfunction generateId(): string {\n\t// 8-char base36 is enough entropy for session-scoped uniqueness.\n\treturn 'ov_' + Math.random().toString(36).slice(2, 10) + Date.now().toString(36)\n}\n\n// Re-export the close reason type for consumers who want to narrow on it.\nexport type { CloseReason }\n"],"mappings":"sDAiBA,IAAM,EAAU,IAAI,EAAA,gBAAyC,EAAA,CAAA,CAGhD,EAA8C,EAAQ,cAAA,CA0C/D,EAAA,CAAmB,EACnB,EAAmB,GACnB,EAA0B,GAE9B,EACE,MAAA,EAAA,EAAA,KACK,GAAM,EAAE,KAAM,GAAM,EAAE,MAAA,CAAA,EAAO,EAAA,EAAA,uBAAA,CAAA,CAGlC,UAAW,GAAA,CACa,OAAb,SAAa,MAEpB,GAAA,CAAe,GAClB,EAAmB,SAAS,gBAAgB,MAAM,SAClD,EAA0B,SAAS,gBAAgB,MAAM,iBAAiB,mBAAA,CAC1E,SAAS,gBAAgB,MAAM,SAAW,SAC1C,SAAS,gBAAgB,MAAM,YAAY,mBAAoB,SAAA,CAC/D,EAAA,CAAmB,GAAA,CACR,GAAc,IACzB,SAAS,gBAAgB,MAAM,SAAW,EACtC,EACH,SAAS,gBAAgB,MAAM,YAAY,mBAAoB,EAAA,CAE/D,SAAS,gBAAgB,MAAM,eAAe,mBAA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DLb2.cjs`);const e=require(`./mixins-Du9HMrIG.cjs`),t=require(`./active-host-jH3iloCR.cjs`),n=require(`./theme.service-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-CncqDLb2.cjs`);const e=require(`./mixins-Du9HMrIG.cjs`),t=require(`./active-host-jH3iloCR.cjs`),n=require(`./theme.service-CnFUmUpc.cjs`),r=require(`./layout-BbCIfIgo.cjs`);require(`./scroll-S-bXF2u6.cjs`);let i=require(`rxjs`),a=require(`rxjs/operators`),o=require(`lit/decorators.js`),s=require(`lit`);var c=class extends e.c{constructor(...e){super(...e),this.rows=`auto_1fr_auto`,this.showScrollbar=!1,this.noSelect=!1,this.heightDisconnecting$=new i.Subject}static{this.styles=[s.css`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
box-sizing: border-box;
|
package/dist/page.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as e } from "./mixins-DCVXqL1Q.js";
|
|
2
2
|
import { a as t } from "./active-host-BP0zy_Y9.js";
|
|
3
|
-
import { n } from "./theme.service-
|
|
4
|
-
import { t as r } from "./layout-
|
|
3
|
+
import { n } from "./theme.service-CSzNkqBB.js";
|
|
4
|
+
import { t as r } from "./layout-Dq2oeOTS.js";
|
|
5
5
|
import "./scroll-C1klVgSQ.js";
|
|
6
6
|
import { EMPTY as i, Subject as a, combineLatest as o, fromEvent as s, merge as c, timer as l } from "rxjs";
|
|
7
7
|
import { debounceTime as u, distinctUntilChanged as d, map as f, startWith as p, switchMap as m, takeUntil as h, tap as g } from "rxjs/operators";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxjs-utils-
|
|
1
|
+
{"version":3,"file":"rxjs-utils-Cs6XGwF6.js","names":[],"sources":["../src/rxjs-utils/mutation-observer.ts","../node_modules/ts-is-present/lib/index.js","../src/rxjs-utils/waitForElements.ts"],"sourcesContent":["import { Observable } from 'rxjs'\n\nexport const mutationObserver = (\n\ttarget: HTMLElement,\n\tconfig: MutationObserverInit = {\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t},\n): Observable<MutationRecord[]> => {\n\treturn new Observable(observer => {\n\t\tconst mutation = new MutationObserver(mutations => {\n\t\t\tobserver.next(mutations)\n\t\t})\n\t\tmutation.observe(target, config)\n\t\tconst unsubscribe = () => {\n\t\t\tmutation.disconnect()\n\t\t}\n\t\treturn unsubscribe\n\t})\n}\nexport default mutationObserver\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.hasValueAtKey = exports.hasPresentKey = exports.isFilled = exports.isDefined = exports.isPresent = void 0;\nfunction isPresent(t) {\n return t !== undefined && t !== null;\n}\nexports.isPresent = isPresent;\nfunction isDefined(t) {\n return t !== undefined;\n}\nexports.isDefined = isDefined;\nfunction isFilled(t) {\n return t !== null;\n}\nexports.isFilled = isFilled;\n/**\n * Returns a function that can be used to filter down objects\n * to the ones that have a defined non-null value under the key `k`.\n *\n * @example\n * ```ts\n * const filesWithUrl = files.filter(file => file.url);\n * files[0].url // In this case, TS might still treat this as undefined/null\n *\n * const filesWithUrl = files.filter(hasPresentKey(\"url\"));\n * files[0].url // TS will know that this is present\n * ```\n *\n * See https://github.com/microsoft/TypeScript/issues/16069\n * why is that useful.\n */\nfunction hasPresentKey(k) {\n return function (a) {\n return a[k] !== undefined && a[k] !== null;\n };\n}\nexports.hasPresentKey = hasPresentKey;\n/**\n * Returns a function that can be used to filter down objects\n * to the ones that have a specific value V under a key `k`.\n *\n * @example\n * ```ts\n * type File = { type: \"image\", imageUrl: string } | { type: \"pdf\", pdfUrl: string };\n * const files: File[] = [];\n *\n * const imageFiles = files.filter(file => file.type === \"image\");\n * files[0].type // In this case, TS will still treat it as `\"image\" | \"pdf\"`\n *\n * const filesWithUrl = files.filter(hasValueKey(\"type\", \"image\" as const));\n * files[0].type // TS will now know that this is \"image\"\n * files[0].imageUrl // TS will know this is present, because already it excluded the other union members.\n *\n * Note: the cast `as const` is necessary, otherwise TS will only know that type is a string.\n * ```\n *\n * See https://github.com/microsoft/TypeScript/issues/16069\n * why is that useful.\n */\nfunction hasValueAtKey(k, v) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (a) {\n return a[k] === v;\n };\n}\nexports.hasValueAtKey = hasValueAtKey;\n//# sourceMappingURL=index.js.map","import { filter, map, startWith, take, tap, timeout } from 'rxjs'\nimport { isPresent } from 'ts-is-present'\nimport observeOnMutation from './mutation-observer'\n\n/**\n * @returns An observable that emits the elements when they are found\n * @description This function is useful when you want to wait for multiple elements to appear\n * @example waitForElements(['button', 'input']).subscribe(([button, input]) => button.click())\n * @returns\n */\nexport default function waitForElements(\n /**\n * @param selectors The selectors to use to find the elements\n * @type { string[] }\n * @description The order of the elements in the array is the same as the order of the elements in the emitted array\n */\n selectors: string[],\n /**\n * @param timeoutAfter How long to wait for the elements to appear before throwing an error\n * @default 5000\n * @type { number | undefined }\n * @description If you don't want to wait for the elements to appear, pass `undefined` as the second argument\n */\n timeoutAfter = 5000,\n) {\n return observeOnMutation(document.body).pipe(\n startWith(document.body),\n filter(() => selectors.every(s => !!document.querySelector(s))),\n take(1),\n map(() => selectors.map(s => document.querySelector(s)).filter(isPresent)), // why filter again? see https://github.com/Microsoft/TypeScript/issues/16069\n map(elements => {\n if (elements.length === selectors.length) {\n return elements\n } else {\n throw new Error('Not all elements were found')\n }\n }),\n timeoutAfter ? timeout(timeoutAfter) : tap(),\n )\n}\n"],"x_google_ignoreList":[1],"mappings":";;AAEA,IAAa,KACZ,GACA,IAA+B;CAC9B,YAAA,CAAY;CACZ,WAAA,CAAW;CACX,SAAA,CAAS;CAAA,KAGH,IAAI,GAAW,MAAA;CACrB,IAAM,IAAW,IAAI,kBAAiB,MAAA;EACrC,EAAS,KAAK,EAAA;GAAA;CAMf,OAJA,EAAS,QAAQ,GAAQ,EAAA,QACnB;EACL,EAAS,YAAA;;EAAA;AAAA,GAAA,MAAA;CCfZ,OAAO,eAAe,GAAS,KAAc,EAAE,OAAA,CAAO,GAAA,CAAA,EACtD,EAAQ,gBAAgB,EAAQ,gBAAgB,EAAQ,WAAW,EAAQ,YAAY,EAAQ,YAAA,KAAiB,GAIhH,EAAQ,YAHR,SAAmB,GAAA;EACf,OAAO,KAAA;IAMX,EAAQ,YAHR,SAAmB,GAAA;EACf,OAAO,MAAP,KAAa;IAMjB,EAAQ,WAHR,SAAkB,GAAA;EACd,OAAO,MAAM;IAwBjB,EAAQ,gBALR,SAAuB,GAAA;EACnB,OAAO,SAAU,GAAA;GACb,OAAO,EAAE,OAAT,KAAgB,KAAa,EAAE,OAAO;;IAgC9C,EAAQ,gBANR,SAAuB,GAAG,GAAA;EAEtB,OAAO,SAAU,GAAA;GACb,OAAO,EAAE,OAAO;;;EAAA,EAAA;AAAA,SAAA,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxjs-utils-
|
|
1
|
+
{"version":3,"file":"rxjs-utils-Dsj75cJy.cjs","names":[],"sources":["../src/rxjs-utils/mutation-observer.ts","../node_modules/ts-is-present/lib/index.js","../src/rxjs-utils/waitForElements.ts"],"sourcesContent":["import { Observable } from 'rxjs'\n\nexport const mutationObserver = (\n\ttarget: HTMLElement,\n\tconfig: MutationObserverInit = {\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t},\n): Observable<MutationRecord[]> => {\n\treturn new Observable(observer => {\n\t\tconst mutation = new MutationObserver(mutations => {\n\t\t\tobserver.next(mutations)\n\t\t})\n\t\tmutation.observe(target, config)\n\t\tconst unsubscribe = () => {\n\t\t\tmutation.disconnect()\n\t\t}\n\t\treturn unsubscribe\n\t})\n}\nexport default mutationObserver\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.hasValueAtKey = exports.hasPresentKey = exports.isFilled = exports.isDefined = exports.isPresent = void 0;\nfunction isPresent(t) {\n return t !== undefined && t !== null;\n}\nexports.isPresent = isPresent;\nfunction isDefined(t) {\n return t !== undefined;\n}\nexports.isDefined = isDefined;\nfunction isFilled(t) {\n return t !== null;\n}\nexports.isFilled = isFilled;\n/**\n * Returns a function that can be used to filter down objects\n * to the ones that have a defined non-null value under the key `k`.\n *\n * @example\n * ```ts\n * const filesWithUrl = files.filter(file => file.url);\n * files[0].url // In this case, TS might still treat this as undefined/null\n *\n * const filesWithUrl = files.filter(hasPresentKey(\"url\"));\n * files[0].url // TS will know that this is present\n * ```\n *\n * See https://github.com/microsoft/TypeScript/issues/16069\n * why is that useful.\n */\nfunction hasPresentKey(k) {\n return function (a) {\n return a[k] !== undefined && a[k] !== null;\n };\n}\nexports.hasPresentKey = hasPresentKey;\n/**\n * Returns a function that can be used to filter down objects\n * to the ones that have a specific value V under a key `k`.\n *\n * @example\n * ```ts\n * type File = { type: \"image\", imageUrl: string } | { type: \"pdf\", pdfUrl: string };\n * const files: File[] = [];\n *\n * const imageFiles = files.filter(file => file.type === \"image\");\n * files[0].type // In this case, TS will still treat it as `\"image\" | \"pdf\"`\n *\n * const filesWithUrl = files.filter(hasValueKey(\"type\", \"image\" as const));\n * files[0].type // TS will now know that this is \"image\"\n * files[0].imageUrl // TS will know this is present, because already it excluded the other union members.\n *\n * Note: the cast `as const` is necessary, otherwise TS will only know that type is a string.\n * ```\n *\n * See https://github.com/microsoft/TypeScript/issues/16069\n * why is that useful.\n */\nfunction hasValueAtKey(k, v) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (a) {\n return a[k] === v;\n };\n}\nexports.hasValueAtKey = hasValueAtKey;\n//# sourceMappingURL=index.js.map","import { filter, map, startWith, take, tap, timeout } from 'rxjs'\nimport { isPresent } from 'ts-is-present'\nimport observeOnMutation from './mutation-observer'\n\n/**\n * @returns An observable that emits the elements when they are found\n * @description This function is useful when you want to wait for multiple elements to appear\n * @example waitForElements(['button', 'input']).subscribe(([button, input]) => button.click())\n * @returns\n */\nexport default function waitForElements(\n /**\n * @param selectors The selectors to use to find the elements\n * @type { string[] }\n * @description The order of the elements in the array is the same as the order of the elements in the emitted array\n */\n selectors: string[],\n /**\n * @param timeoutAfter How long to wait for the elements to appear before throwing an error\n * @default 5000\n * @type { number | undefined }\n * @description If you don't want to wait for the elements to appear, pass `undefined` as the second argument\n */\n timeoutAfter = 5000,\n) {\n return observeOnMutation(document.body).pipe(\n startWith(document.body),\n filter(() => selectors.every(s => !!document.querySelector(s))),\n take(1),\n map(() => selectors.map(s => document.querySelector(s)).filter(isPresent)), // why filter again? see https://github.com/Microsoft/TypeScript/issues/16069\n map(elements => {\n if (elements.length === selectors.length) {\n return elements\n } else {\n throw new Error('Not all elements were found')\n }\n }),\n timeoutAfter ? timeout(timeoutAfter) : tap(),\n )\n}\n"],"x_google_ignoreList":[1],"mappings":"8DAEA,IAAa,GACZ,EACA,EAA+B,CAC9B,WAAA,CAAY,EACZ,UAAA,CAAW,EACX,QAAA,CAAS,EAAA,GAGH,IAAI,EAAA,WAAW,GAAA,CACrB,IAAM,EAAW,IAAI,iBAAiB,GAAA,CACrC,EAAS,KAAK,EAAA,EAAA,CAMf,OAJA,EAAS,QAAQ,EAAQ,EAAA,KACnB,CACL,EAAS,YAAA,GAAA,CAAA,EAAA,EAAA,GAAA,CCfZ,OAAO,eAAe,EAAS,IAAc,CAAE,MAAA,CAAO,EAAA,CAAA,CACtD,EAAQ,cAAgB,EAAQ,cAAgB,EAAQ,SAAW,EAAQ,UAAY,EAAQ,UAAA,IAAiB,GAIhH,EAAQ,UAHR,SAAmB,EAAA,CACf,OAAO,GAAA,MAMX,EAAQ,UAHR,SAAmB,EAAA,CACf,OAAO,IAAP,IAAa,IAMjB,EAAQ,SAHR,SAAkB,EAAA,CACd,OAAO,IAAM,MAwBjB,EAAQ,cALR,SAAuB,EAAA,CACnB,OAAO,SAAU,EAAA,CACb,OAAO,EAAE,KAAT,IAAgB,IAAa,EAAE,KAAO,OAgC9C,EAAQ,cANR,SAAuB,EAAG,EAAA,CAEtB,OAAO,SAAU,EAAA,CACb,OAAO,EAAE,KAAO,KAAA,EAAA,CAAA,OAAA,eAAA,QAAA,IAAA,CAAA,WAAA,CAAA,EAAA,IAAA,UAAA,CAAA,OAAA,GAAA,CAAA"}
|
package/dist/rxjs-utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./rxjs-utils-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./rxjs-utils-Dsj75cJy.cjs`);exports.mutationObserver=e.t;
|
package/dist/rxjs-utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./rxjs-utils-
|
|
1
|
+
import { t as e } from "./rxjs-utils-Cs6XGwF6.js";
|
|
2
2
|
export { e as mutationObserver };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk-CncqDLb2.cjs`);const e=require(`./state-avic94Ft.cjs`);let t=require(`rxjs`);var n=e.i(`schmancy/sound`).local({theme:null,volume:.15,muted:!1}),r={joyful:{puffs:[{startTime:0,duration:.08,frequency:3e3,volume:.3},{startTime:.06,duration:.1,frequency:3500,volume:.35}],tones:[{startTime:.02,duration:.15,frequency:784,volume:.25,type:`sine`},{startTime:.1,duration:.2,frequency:988,volume:.3,type:`sine`},{startTime:.18,duration:.25,frequency:1175,volume:.25,type:`sine`}]},content:{puffs:[{startTime:0,duration:.2,frequency:1500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:523,volume:.2,type:`sine`,filterFrequency:800},{startTime:.15,duration:.35,frequency:659,volume:.15,type:`sine`,filterFrequency:800}]},excited:{puffs:[{startTime:0,duration:.06,frequency:2500,volume:.25},{startTime:.05,duration:.06,frequency:3e3,volume:.3},{startTime:.1,duration:.08,frequency:3500,volume:.35}],tones:[{startTime:.02,duration:.12,frequency:880,volume:.2,type:`sine`},{startTime:.08,duration:.12,frequency:1047,volume:.25,type:`sine`},{startTime:.14,duration:.15,frequency:1319,volume:.3,type:`sine`}]},proud:{puffs:[{startTime:0,duration:.15,frequency:1800,volume:.3}],tones:[{startTime:.05,duration:.25,frequency:523,volume:.25,type:`sine`},{startTime:.08,duration:.25,frequency:659,volume:.2,type:`sine`},{startTime:.11,duration:.3,frequency:784,volume:.25,type:`sine`}]},hopeful:{puffs:[{startTime:0,duration:.12,frequency:2200,volume:.2}],tones:[{startTime:.03,duration:.3,frequency:659,volume:.2,type:`sine`,frequencyEnd:880}]},relieved:{puffs:[{startTime:0,duration:.25,frequency:1200,volume:.35}],tones:[{startTime:.1,duration:.35,frequency:659,volume:.2,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:523,volume:.15,type:`sine`,filterFrequency:800}]},grateful:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:440,volume:.2,type:`sine`,filterFrequency:800},{startTime:.15,duration:.35,frequency:523,volume:.2,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:659,volume:.15,type:`sine`,filterFrequency:800}]},peaceful:{puffs:[{startTime:0,duration:.3,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:500}]},playful:{puffs:[{startTime:0,duration:.05,frequency:2800,volume:.2},{startTime:.08,duration:.05,frequency:3200,volume:.25},{startTime:.14,duration:.06,frequency:2800,volume:.2}],tones:[{startTime:.03,duration:.1,frequency:784,volume:.2,type:`sine`},{startTime:.1,duration:.08,frequency:988,volume:.25,type:`sine`},{startTime:.16,duration:.12,frequency:784,volume:.2,type:`sine`}]},amused:{puffs:[{startTime:0,duration:.04,frequency:2500,volume:.2},{startTime:.06,duration:.04,frequency:2800,volume:.22},{startTime:.11,duration:.05,frequency:2600,volume:.18}],tones:[{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},curious:{puffs:[{startTime:0,duration:.1,frequency:2e3,volume:.2}],tones:[{startTime:.03,duration:.2,frequency:659,volume:.2,type:`sine`,frequencyEnd:880}]},inspired:{puffs:[{startTime:0,duration:.1,frequency:2500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:523,volume:.2,type:`sine`},{startTime:.07,duration:.28,frequency:784.5,volume:.16,type:`sine`},{startTime:.09,duration:.26,frequency:1046,volume:.12,type:`sine`}]},confident:{puffs:[{startTime:0,duration:.12,frequency:1500,volume:.3}],tones:[{startTime:.04,duration:.2,frequency:523,volume:.25,type:`sine`},{startTime:.06,duration:.22,frequency:659,volume:.2,type:`sine`}]},loved:{puffs:[{startTime:0,duration:.2,frequency:1e3,volume:.2}],tones:[{startTime:.08,duration:.4,frequency:392,volume:.18,type:`sine`,filterFrequency:600},{startTime:.2,duration:.45,frequency:494,volume:.15,type:`sine`,filterFrequency:600}]},comforted:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:523,volume:.15,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:800}]},energized:{puffs:[{startTime:0,duration:.05,frequency:3e3,volume:.25},{startTime:.04,duration:.05,frequency:3500,volume:.28}],tones:[{startTime:.02,duration:.1,frequency:784,volume:.2,type:`sine`},{startTime:.08,duration:.12,frequency:988,volume:.25,type:`sine`},{startTime:.14,duration:.15,frequency:1175,volume:.22,type:`sine`}]},celebrated:{puffs:[{startTime:0,duration:.08,frequency:2500,volume:.2}],tones:[{startTime:.02,duration:.18,frequency:523,volume:.22,type:`sine`},{startTime:.08,duration:.18,frequency:659,volume:.24,type:`sine`},{startTime:.14,duration:.2,frequency:784,volume:.26,type:`sine`},{startTime:.22,duration:.3,frequency:1047,volume:.22,type:`sine`}]},sad:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},lonely:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},disappointed:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},heartbroken:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},grieving:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},hopeless:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},empty:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},discouraged:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},melancholic:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.18}],tones:[{startTime:.1,duration:.45,frequency:440,volume:.15,type:`sine`,filterFrequency:500},{startTime:.3,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:450}]},homesick:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:500},{startTime:.3,duration:.45,frequency:392,volume:.1,type:`sine`,filterFrequency:450}]},hurt:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},miserable:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},regretful:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.18}],tones:[{startTime:.1,duration:.45,frequency:440,volume:.15,type:`sine`,filterFrequency:500},{startTime:.3,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:450}]},ashamed:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},inferior:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},anxious:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}],description:`Tight, quick puffs with uncertain wobble`},worried:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},afraid:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},terrified:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},panicked:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},nervous:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},uneasy:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},insecure:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},overwhelmed:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},stressed:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},tense:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},apprehensive:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},startled:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},suspicious:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},vulnerable:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},annoyed:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},irritated:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},frustrated:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},angry:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},enraged:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},bitter:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},resentful:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},jealous:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},envious:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},indignant:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},impatient:{puffs:[{startTime:0,duration:.04,frequency:1500,volume:.2},{startTime:.08,duration:.04,frequency:1500,volume:.2},{startTime:.16,duration:.04,frequency:1500,volume:.22}],tones:[{startTime:.06,duration:.1,frequency:523,volume:.15,type:`sine`}]},hostile:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},contemptuous:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},tired:{puffs:[{startTime:0,duration:.35,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:330,volume:.12,type:`sine`,filterFrequency:350}]},exhausted:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},drained:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},burnedOut:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},numb:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},bored:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},unmotivated:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},apathetic:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},restless:{puffs:[{startTime:0,duration:.35,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:330,volume:.12,type:`sine`,filterFrequency:350}]},calm:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},relaxed:{puffs:[{startTime:0,duration:.35,frequency:700,volume:.15}],tones:[{startTime:.15,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800},{startTime:.35,duration:.5,frequency:392,volume:.08,type:`sine`,filterFrequency:800}]},atEase:{puffs:[{startTime:0,duration:.35,frequency:700,volume:.15}],tones:[{startTime:.15,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800},{startTime:.35,duration:.5,frequency:392,volume:.08,type:`sine`,filterFrequency:800}]},balanced:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},stable:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},secure:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.25,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},safe:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.25,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},centered:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},grounded:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},accepting:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},connected:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},accepted:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},included:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},belonging:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},appreciated:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},valued:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},respected:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},supported:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.15,duration:.4,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},protective:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.15,duration:.4,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},compassionate:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},empathetic:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},conflicted:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},confused:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},ambivalent:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},nostalgic:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:500},{startTime:.3,duration:.45,frequency:392,volume:.1,type:`sine`,filterFrequency:450}]},guilty:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},embarrassed:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},surprised:{puffs:[{startTime:0,duration:.06,frequency:2800,volume:.25}],tones:[{startTime:.02,duration:.15,frequency:659,volume:.2,type:`sine`,frequencyEnd:988}]},shocked:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},awestruck:{puffs:[{startTime:0,duration:.2,frequency:1500,volume:.2}],tones:[{startTime:.08,duration:.4,frequency:440,volume:.15,type:`sine`},{startTime:.1,duration:.38,frequency:660,volume:.12,type:`sine`},{startTime:.12,duration:.36,frequency:880,volume:.09,type:`sine`}]},skeptical:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]}},i=class e{get theme(){return n.value.theme}get volume(){return n.value.volume}get muted(){return n.value.muted}get themeName(){return this.theme?.name??`default`}constructor(){this.audioContext=null,this.theme$=n.$.pipe((0,t.map)(e=>e.theme),(0,t.shareReplay)(1)),this.volume$=n.$.pipe((0,t.map)(e=>e.volume),(0,t.distinctUntilChanged)(),(0,t.shareReplay)(1)),this.muted$=n.$.pipe((0,t.map)(e=>e.muted),(0,t.distinctUntilChanged)(),(0,t.shareReplay)(1)),this._themeName$=new t.BehaviorSubject(`default`),this.themeName$=this._themeName$.asObservable(),this.theme$.subscribe(e=>{this._themeName$.next(e?.name??`default`)})}getContext(){if(!this.audioContext){let e=window.AudioContext||window.webkitAudioContext;this.audioContext=new e}return this.audioContext.state===`suspended`&&this.audioContext.resume(),this.audioContext}playPuff(e,t,n){let r=this.getContext(),i=Math.floor(r.sampleRate*t.duration),a=r.createBuffer(1,i,r.sampleRate),o=a.getChannelData(0);for(let e=0;e<i;e++)o[e]=2*Math.random()-1;let s=r.createBufferSource();s.buffer=a;let c=r.createBiquadFilter();c.type=`bandpass`,c.frequency.value=t.frequency,c.Q.value=.7;let l=r.createGain();l.gain.setValueAtTime(0,e),l.gain.linearRampToValueAtTime(t.volume*n,e+.015),l.gain.exponentialRampToValueAtTime(.001,e+t.duration),s.connect(c).connect(l).connect(r.destination),s.start(e),s.stop(e+t.duration)}playTone(e,t,n){let r=this.getContext(),i=r.createOscillator(),a=r.createGain();i.type=t.type,i.frequency.setValueAtTime(t.frequency,e),t.frequencyEnd&&i.frequency.exponentialRampToValueAtTime(t.frequencyEnd,e+.8*t.duration);let o=i;if(t.filterFrequency){let e=r.createBiquadFilter();e.type=`lowpass`,e.frequency.value=t.filterFrequency,i.connect(e),o=e}a.gain.setValueAtTime(0,e),a.gain.linearRampToValueAtTime(t.volume*n,e+.02),a.gain.exponentialRampToValueAtTime(.001,e+t.duration),o.connect(a).connect(r.destination),i.start(e),i.stop(e+t.duration)}setTheme(e){n.set({theme:e})}resetTheme(){n.set({theme:null})}setVolume(e){n.set({volume:Math.max(0,Math.min(1,e))})}mute(){n.set({muted:!0})}unmute(){n.set({muted:!1})}toggleMute(){n.set({muted:!this.muted})}getSoundForFeeling(e){let t=this.theme;if(t?.feelings?.[e])return t.feelings[e];if(t?.categoryDefaults){let n=this.getCategoryForFeeling(e);if(t.categoryDefaults[n])return t.categoryDefaults[n]}return r[e]}getCategoryForFeeling(e){return[`joyful`,`content`,`excited`,`proud`,`hopeful`,`relieved`,`grateful`,`peaceful`,`playful`,`amused`,`curious`,`inspired`,`confident`,`loved`,`comforted`,`energized`,`celebrated`].includes(e)?`happy`:[`sad`,`lonely`,`disappointed`,`heartbroken`,`grieving`,`hopeless`,`empty`,`discouraged`,`melancholic`,`homesick`,`hurt`,`miserable`,`regretful`,`ashamed`,`inferior`].includes(e)?`sad`:[`anxious`,`worried`,`afraid`,`terrified`,`panicked`,`nervous`,`uneasy`,`insecure`,`overwhelmed`,`stressed`,`tense`,`apprehensive`,`startled`,`suspicious`,`vulnerable`].includes(e)?`anxious`:[`annoyed`,`irritated`,`frustrated`,`angry`,`enraged`,`bitter`,`resentful`,`jealous`,`envious`,`indignant`,`impatient`,`hostile`,`contemptuous`].includes(e)?`angry`:[`tired`,`exhausted`,`drained`,`burnedOut`,`numb`,`bored`,`unmotivated`,`apathetic`,`restless`].includes(e)?`tired`:[`calm`,`relaxed`,`atEase`,`balanced`,`stable`,`secure`,`safe`,`centered`,`grounded`,`accepting`].includes(e)?`calm`:[`connected`,`accepted`,`included`,`belonging`,`appreciated`,`valued`,`respected`,`supported`,`protective`,`compassionate`,`empathetic`].includes(e)?`connected`:`mixed`}play(e){if(this.muted)return;let t=this.getSoundForFeeling(e),n=this.getContext().currentTime,r=this.theme?.masterVolume??1,i=this.volume*r;t.puffs.forEach(e=>{this.playPuff(n+e.startTime,e,i)}),t.tones.forEach(e=>{this.playTone(n+e.startTime,e,i)})}dispose(){this.audioContext&&=(this.audioContext.close(),null)}static getInstance(){return e.instance||=new e,e.instance}}.getInstance(),a=i;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
1
|
+
require(`./chunk-CncqDLb2.cjs`);const e=require(`./state-DcGj-pJJ.cjs`);let t=require(`rxjs`);var n=e.i(`schmancy/sound`).local({theme:null,volume:.15,muted:!1}),r={joyful:{puffs:[{startTime:0,duration:.08,frequency:3e3,volume:.3},{startTime:.06,duration:.1,frequency:3500,volume:.35}],tones:[{startTime:.02,duration:.15,frequency:784,volume:.25,type:`sine`},{startTime:.1,duration:.2,frequency:988,volume:.3,type:`sine`},{startTime:.18,duration:.25,frequency:1175,volume:.25,type:`sine`}]},content:{puffs:[{startTime:0,duration:.2,frequency:1500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:523,volume:.2,type:`sine`,filterFrequency:800},{startTime:.15,duration:.35,frequency:659,volume:.15,type:`sine`,filterFrequency:800}]},excited:{puffs:[{startTime:0,duration:.06,frequency:2500,volume:.25},{startTime:.05,duration:.06,frequency:3e3,volume:.3},{startTime:.1,duration:.08,frequency:3500,volume:.35}],tones:[{startTime:.02,duration:.12,frequency:880,volume:.2,type:`sine`},{startTime:.08,duration:.12,frequency:1047,volume:.25,type:`sine`},{startTime:.14,duration:.15,frequency:1319,volume:.3,type:`sine`}]},proud:{puffs:[{startTime:0,duration:.15,frequency:1800,volume:.3}],tones:[{startTime:.05,duration:.25,frequency:523,volume:.25,type:`sine`},{startTime:.08,duration:.25,frequency:659,volume:.2,type:`sine`},{startTime:.11,duration:.3,frequency:784,volume:.25,type:`sine`}]},hopeful:{puffs:[{startTime:0,duration:.12,frequency:2200,volume:.2}],tones:[{startTime:.03,duration:.3,frequency:659,volume:.2,type:`sine`,frequencyEnd:880}]},relieved:{puffs:[{startTime:0,duration:.25,frequency:1200,volume:.35}],tones:[{startTime:.1,duration:.35,frequency:659,volume:.2,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:523,volume:.15,type:`sine`,filterFrequency:800}]},grateful:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:440,volume:.2,type:`sine`,filterFrequency:800},{startTime:.15,duration:.35,frequency:523,volume:.2,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:659,volume:.15,type:`sine`,filterFrequency:800}]},peaceful:{puffs:[{startTime:0,duration:.3,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:500}]},playful:{puffs:[{startTime:0,duration:.05,frequency:2800,volume:.2},{startTime:.08,duration:.05,frequency:3200,volume:.25},{startTime:.14,duration:.06,frequency:2800,volume:.2}],tones:[{startTime:.03,duration:.1,frequency:784,volume:.2,type:`sine`},{startTime:.1,duration:.08,frequency:988,volume:.25,type:`sine`},{startTime:.16,duration:.12,frequency:784,volume:.2,type:`sine`}]},amused:{puffs:[{startTime:0,duration:.04,frequency:2500,volume:.2},{startTime:.06,duration:.04,frequency:2800,volume:.22},{startTime:.11,duration:.05,frequency:2600,volume:.18}],tones:[{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},curious:{puffs:[{startTime:0,duration:.1,frequency:2e3,volume:.2}],tones:[{startTime:.03,duration:.2,frequency:659,volume:.2,type:`sine`,frequencyEnd:880}]},inspired:{puffs:[{startTime:0,duration:.1,frequency:2500,volume:.25}],tones:[{startTime:.05,duration:.3,frequency:523,volume:.2,type:`sine`},{startTime:.07,duration:.28,frequency:784.5,volume:.16,type:`sine`},{startTime:.09,duration:.26,frequency:1046,volume:.12,type:`sine`}]},confident:{puffs:[{startTime:0,duration:.12,frequency:1500,volume:.3}],tones:[{startTime:.04,duration:.2,frequency:523,volume:.25,type:`sine`},{startTime:.06,duration:.22,frequency:659,volume:.2,type:`sine`}]},loved:{puffs:[{startTime:0,duration:.2,frequency:1e3,volume:.2}],tones:[{startTime:.08,duration:.4,frequency:392,volume:.18,type:`sine`,filterFrequency:600},{startTime:.2,duration:.45,frequency:494,volume:.15,type:`sine`,filterFrequency:600}]},comforted:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:523,volume:.15,type:`sine`,filterFrequency:800},{startTime:.25,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:800}]},energized:{puffs:[{startTime:0,duration:.05,frequency:3e3,volume:.25},{startTime:.04,duration:.05,frequency:3500,volume:.28}],tones:[{startTime:.02,duration:.1,frequency:784,volume:.2,type:`sine`},{startTime:.08,duration:.12,frequency:988,volume:.25,type:`sine`},{startTime:.14,duration:.15,frequency:1175,volume:.22,type:`sine`}]},celebrated:{puffs:[{startTime:0,duration:.08,frequency:2500,volume:.2}],tones:[{startTime:.02,duration:.18,frequency:523,volume:.22,type:`sine`},{startTime:.08,duration:.18,frequency:659,volume:.24,type:`sine`},{startTime:.14,duration:.2,frequency:784,volume:.26,type:`sine`},{startTime:.22,duration:.3,frequency:1047,volume:.22,type:`sine`}]},sad:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},lonely:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},disappointed:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},heartbroken:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},grieving:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},hopeless:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},empty:{puffs:[{startTime:0,duration:.2,frequency:700,volume:.2}],tones:[{startTime:.15,duration:.5,frequency:330,volume:.12,type:`sine`,filterFrequency:450}]},discouraged:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},melancholic:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.18}],tones:[{startTime:.1,duration:.45,frequency:440,volume:.15,type:`sine`,filterFrequency:500},{startTime:.3,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:450}]},homesick:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:500},{startTime:.3,duration:.45,frequency:392,volume:.1,type:`sine`,filterFrequency:450}]},hurt:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},miserable:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.25}],tones:[{startTime:.1,duration:.4,frequency:392,volume:.2,type:`sine`,filterFrequency:400},{startTime:.3,duration:.45,frequency:294,volume:.15,type:`sine`,filterFrequency:350}]},regretful:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.18}],tones:[{startTime:.1,duration:.45,frequency:440,volume:.15,type:`sine`,filterFrequency:500},{startTime:.3,duration:.5,frequency:392,volume:.12,type:`sine`,filterFrequency:450}]},ashamed:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},inferior:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},anxious:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}],description:`Tight, quick puffs with uncertain wobble`},worried:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},afraid:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},terrified:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},panicked:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},nervous:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},uneasy:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},insecure:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},overwhelmed:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},stressed:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},tense:{puffs:[{startTime:0,duration:.08,frequency:1800,volume:.2},{startTime:.12,duration:.08,frequency:1900,volume:.22}],tones:[{startTime:.03,duration:.25,frequency:440,volume:.15,type:`sine`}]},apprehensive:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},startled:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},suspicious:{puffs:[{startTime:0,duration:.15,frequency:1200,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:349,volume:.15,type:`sine`,frequencyEnd:392}]},vulnerable:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},annoyed:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},irritated:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},frustrated:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},angry:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},enraged:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},bitter:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},resentful:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},jealous:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},envious:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},indignant:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},impatient:{puffs:[{startTime:0,duration:.04,frequency:1500,volume:.2},{startTime:.08,duration:.04,frequency:1500,volume:.2},{startTime:.16,duration:.04,frequency:1500,volume:.22}],tones:[{startTime:.06,duration:.1,frequency:523,volume:.15,type:`sine`}]},hostile:{puffs:[{startTime:0,duration:.12,frequency:900,volume:.28}],tones:[{startTime:.04,duration:.15,frequency:349,volume:.2,type:`sine`},{startTime:.12,duration:.12,frequency:330,volume:.18,type:`sine`}]},contemptuous:{puffs:[{startTime:0,duration:.1,frequency:1e3,volume:.25}],tones:[{startTime:.03,duration:.2,frequency:294,volume:.18,type:`sine`,filterFrequency:400}]},tired:{puffs:[{startTime:0,duration:.35,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:330,volume:.12,type:`sine`,filterFrequency:350}]},exhausted:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},drained:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},burnedOut:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},numb:{puffs:[{startTime:0,duration:.45,frequency:400,volume:.18}],tones:[{startTime:.15,duration:.5,frequency:294,volume:.1,type:`sine`,filterFrequency:300}]},bored:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},unmotivated:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},apathetic:{puffs:[{startTime:0,duration:.25,frequency:600,volume:.15}],tones:[{startTime:.1,duration:.3,frequency:349,volume:.1,type:`sine`,filterFrequency:400}]},restless:{puffs:[{startTime:0,duration:.35,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:330,volume:.12,type:`sine`,filterFrequency:350}]},calm:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},relaxed:{puffs:[{startTime:0,duration:.35,frequency:700,volume:.15}],tones:[{startTime:.15,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800},{startTime:.35,duration:.5,frequency:392,volume:.08,type:`sine`,filterFrequency:800}]},atEase:{puffs:[{startTime:0,duration:.35,frequency:700,volume:.15}],tones:[{startTime:.15,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800},{startTime:.35,duration:.5,frequency:392,volume:.08,type:`sine`,filterFrequency:800}]},balanced:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},stable:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},secure:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.25,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},safe:{puffs:[{startTime:0,duration:.3,frequency:700,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.25,duration:.45,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},centered:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},grounded:{puffs:[{startTime:0,duration:.25,frequency:500,volume:.2}],tones:[{startTime:.1,duration:.4,frequency:262,volume:.15,type:`sine`,filterFrequency:350}]},accepting:{puffs:[{startTime:0,duration:.3,frequency:600,volume:.12}],tones:[{startTime:.1,duration:.5,frequency:392,volume:.1,type:`sine`,filterFrequency:500}]},connected:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},accepted:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},included:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},belonging:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},appreciated:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},valued:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},respected:{puffs:[{startTime:0,duration:.15,frequency:1500,volume:.2}],tones:[{startTime:.05,duration:.25,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.15,duration:.3,frequency:523,volume:.18,type:`sine`,filterFrequency:800}]},supported:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.15,duration:.4,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},protective:{puffs:[{startTime:0,duration:.25,frequency:900,volume:.18}],tones:[{startTime:.1,duration:.35,frequency:349,volume:.12,type:`sine`,filterFrequency:800},{startTime:.15,duration:.4,frequency:440,volume:.1,type:`sine`,filterFrequency:800}]},compassionate:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},empathetic:{puffs:[{startTime:0,duration:.2,frequency:1200,volume:.18}],tones:[{startTime:.08,duration:.3,frequency:440,volume:.15,type:`sine`,filterFrequency:800},{startTime:.12,duration:.32,frequency:523,volume:.12,type:`sine`,filterFrequency:800}]},conflicted:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},confused:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},ambivalent:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]},nostalgic:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.15}],tones:[{startTime:.1,duration:.4,frequency:440,volume:.12,type:`sine`,filterFrequency:500},{startTime:.3,duration:.45,frequency:392,volume:.1,type:`sine`,filterFrequency:450}]},guilty:{puffs:[{startTime:0,duration:.25,frequency:800,volume:.25}],tones:[{startTime:.08,duration:.3,frequency:523,volume:.18,type:`sine`,frequencyEnd:349}]},embarrassed:{puffs:[{startTime:0,duration:.05,frequency:2e3,volume:.18},{startTime:.08,duration:.05,frequency:2100,volume:.18},{startTime:.15,duration:.06,frequency:2e3,volume:.16}],tones:[{startTime:.04,duration:.2,frequency:494,volume:.12,type:`sine`}]},surprised:{puffs:[{startTime:0,duration:.06,frequency:2800,volume:.25}],tones:[{startTime:.02,duration:.15,frequency:659,volume:.2,type:`sine`,frequencyEnd:988}]},shocked:{puffs:[{startTime:0,duration:.04,frequency:3500,volume:.3}],tones:[{startTime:0,duration:.08,frequency:1047,volume:.25,type:`sine`},{startTime:.05,duration:.15,frequency:880,volume:.15,type:`sine`}]},awestruck:{puffs:[{startTime:0,duration:.2,frequency:1500,volume:.2}],tones:[{startTime:.08,duration:.4,frequency:440,volume:.15,type:`sine`},{startTime:.1,duration:.38,frequency:660,volume:.12,type:`sine`},{startTime:.12,duration:.36,frequency:880,volume:.09,type:`sine`}]},skeptical:{puffs:[{startTime:0,duration:.12,frequency:1200,volume:.18}],tones:[{startTime:.04,duration:.2,frequency:440,volume:.12,type:`sine`,frequencyEnd:494},{startTime:.15,duration:.15,frequency:466,volume:.1,type:`sine`}]}},i=class e{get theme(){return n.value.theme}get volume(){return n.value.volume}get muted(){return n.value.muted}get themeName(){return this.theme?.name??`default`}constructor(){this.audioContext=null,this.theme$=n.$.pipe((0,t.map)(e=>e.theme),(0,t.shareReplay)(1)),this.volume$=n.$.pipe((0,t.map)(e=>e.volume),(0,t.distinctUntilChanged)(),(0,t.shareReplay)(1)),this.muted$=n.$.pipe((0,t.map)(e=>e.muted),(0,t.distinctUntilChanged)(),(0,t.shareReplay)(1)),this._themeName$=new t.BehaviorSubject(`default`),this.themeName$=this._themeName$.asObservable(),this.theme$.subscribe(e=>{this._themeName$.next(e?.name??`default`)})}getContext(){if(!this.audioContext){let e=window.AudioContext||window.webkitAudioContext;this.audioContext=new e}return this.audioContext.state===`suspended`&&this.audioContext.resume(),this.audioContext}playPuff(e,t,n){let r=this.getContext(),i=Math.floor(r.sampleRate*t.duration),a=r.createBuffer(1,i,r.sampleRate),o=a.getChannelData(0);for(let e=0;e<i;e++)o[e]=2*Math.random()-1;let s=r.createBufferSource();s.buffer=a;let c=r.createBiquadFilter();c.type=`bandpass`,c.frequency.value=t.frequency,c.Q.value=.7;let l=r.createGain();l.gain.setValueAtTime(0,e),l.gain.linearRampToValueAtTime(t.volume*n,e+.015),l.gain.exponentialRampToValueAtTime(.001,e+t.duration),s.connect(c).connect(l).connect(r.destination),s.start(e),s.stop(e+t.duration)}playTone(e,t,n){let r=this.getContext(),i=r.createOscillator(),a=r.createGain();i.type=t.type,i.frequency.setValueAtTime(t.frequency,e),t.frequencyEnd&&i.frequency.exponentialRampToValueAtTime(t.frequencyEnd,e+.8*t.duration);let o=i;if(t.filterFrequency){let e=r.createBiquadFilter();e.type=`lowpass`,e.frequency.value=t.filterFrequency,i.connect(e),o=e}a.gain.setValueAtTime(0,e),a.gain.linearRampToValueAtTime(t.volume*n,e+.02),a.gain.exponentialRampToValueAtTime(.001,e+t.duration),o.connect(a).connect(r.destination),i.start(e),i.stop(e+t.duration)}setTheme(e){n.set({theme:e})}resetTheme(){n.set({theme:null})}setVolume(e){n.set({volume:Math.max(0,Math.min(1,e))})}mute(){n.set({muted:!0})}unmute(){n.set({muted:!1})}toggleMute(){n.set({muted:!this.muted})}getSoundForFeeling(e){let t=this.theme;if(t?.feelings?.[e])return t.feelings[e];if(t?.categoryDefaults){let n=this.getCategoryForFeeling(e);if(t.categoryDefaults[n])return t.categoryDefaults[n]}return r[e]}getCategoryForFeeling(e){return[`joyful`,`content`,`excited`,`proud`,`hopeful`,`relieved`,`grateful`,`peaceful`,`playful`,`amused`,`curious`,`inspired`,`confident`,`loved`,`comforted`,`energized`,`celebrated`].includes(e)?`happy`:[`sad`,`lonely`,`disappointed`,`heartbroken`,`grieving`,`hopeless`,`empty`,`discouraged`,`melancholic`,`homesick`,`hurt`,`miserable`,`regretful`,`ashamed`,`inferior`].includes(e)?`sad`:[`anxious`,`worried`,`afraid`,`terrified`,`panicked`,`nervous`,`uneasy`,`insecure`,`overwhelmed`,`stressed`,`tense`,`apprehensive`,`startled`,`suspicious`,`vulnerable`].includes(e)?`anxious`:[`annoyed`,`irritated`,`frustrated`,`angry`,`enraged`,`bitter`,`resentful`,`jealous`,`envious`,`indignant`,`impatient`,`hostile`,`contemptuous`].includes(e)?`angry`:[`tired`,`exhausted`,`drained`,`burnedOut`,`numb`,`bored`,`unmotivated`,`apathetic`,`restless`].includes(e)?`tired`:[`calm`,`relaxed`,`atEase`,`balanced`,`stable`,`secure`,`safe`,`centered`,`grounded`,`accepting`].includes(e)?`calm`:[`connected`,`accepted`,`included`,`belonging`,`appreciated`,`valued`,`respected`,`supported`,`protective`,`compassionate`,`empathetic`].includes(e)?`connected`:`mixed`}play(e){if(this.muted)return;let t=this.getSoundForFeeling(e),n=this.getContext().currentTime,r=this.theme?.masterVolume??1,i=this.volume*r;t.puffs.forEach(e=>{this.playPuff(n+e.startTime,e,i)}),t.tones.forEach(e=>{this.playTone(n+e.startTime,e,i)})}dispose(){this.audioContext&&=(this.audioContext.close(),null)}static getInstance(){return e.instance||=new e,e.instance}}.getInstance(),a=i;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|