mn-angular-lib 2.0.61 → 2.0.63

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.
@@ -13,6 +13,7 @@ var MnLanguageService = class MnLanguageService {
13
13
  _translations = {};
14
14
  _locale$ = new BehaviorSubject("en");
15
15
  _locale = signal("en", ...ngDevMode ? [{ debugName: "_locale" }] : /* istanbul ignore next */ []);
16
+ _revision = signal(0, ...ngDevMode ? [{ debugName: "_revision" }] : /* istanbul ignore next */ []);
16
17
  _urlPattern = null;
17
18
  _debug = false;
18
19
  _pluralRules = /* @__PURE__ */ new Map();
@@ -57,8 +58,10 @@ var MnLanguageService = class MnLanguageService {
57
58
  ...this._translations[locale] ?? {},
58
59
  ...translations
59
60
  };
61
+ this._revision.update((v) => v + 1);
60
62
  }
61
63
  translate(key, params) {
64
+ this._revision();
62
65
  const map = this._translations[this.locale] ?? {};
63
66
  let value = this.getValueFromMap(map, this.resolvePluralKey(map, key, params));
64
67
  if (value === void 0) {
@@ -100,6 +103,7 @@ var MnLanguageService = class MnLanguageService {
100
103
  return typeof current === "string" ? current : void 0;
101
104
  }
102
105
  translateIfPresent(key, params) {
106
+ this._revision();
103
107
  const map = this._translations[this.locale] ?? {};
104
108
  if (this.getValueFromMap(map, key) === void 0) return void 0;
105
109
  return this.translate(key, params);
@@ -696,21 +700,144 @@ function lucideIcons(nodes) {
696
700
  function toKebabCase(name) {
697
701
  return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([a-zA-Z])(\d)/g, "$1-$2").toLowerCase();
698
702
  }
703
+ const HOVER_ATTR = "data-mn-preview-hover";
704
+ const STYLE_ID = "mn-preview-edit-style";
705
+ const MAX_TEXT_DEPTH = 4;
699
706
  function enableMnPreviewMode(configService, langService, allowedOrigins) {
707
+ const origins = allowedOrigins?.length ? allowedOrigins : null;
708
+ let editorOrigin = null;
709
+ const post = (message, origin) => {
710
+ if (window.parent === window) return;
711
+ for (const target of origin ? [origin] : origins ?? ["*"]) window.parent.postMessage(message, target);
712
+ };
713
+ const where = () => ({
714
+ locale: langService.locale,
715
+ path: location.pathname
716
+ });
700
717
  window.addEventListener("message", async (event) => {
701
- if (allowedOrigins?.length && !allowedOrigins.includes(event.origin)) return;
718
+ if (origins && !origins.includes(event.origin)) return;
702
719
  const data = event.data;
703
720
  if (!data?.type) return;
704
721
  switch (data.type) {
705
722
  case "mn-config-update":
706
723
  if (data.config) await configService.loadFromObject(data.config);
707
724
  break;
708
- case "mn-translations-update": if (data.translations) {
709
- for (const [locale, translations] of Object.entries(data.translations)) langService.registerTranslations(locale, translations);
710
- await langService.setLocale(langService.locale);
711
- }
725
+ case "mn-translations-update":
726
+ if (data.translations) {
727
+ for (const [locale, translations] of Object.entries(data.translations)) langService.registerTranslations(locale, translations);
728
+ await langService.setLocale(langService.locale);
729
+ }
730
+ break;
731
+ case "mn-preview-edit-mode":
732
+ editorOrigin = event.origin && event.origin !== "null" ? event.origin : null;
733
+ setEditMode(!!data.enabled, (selection) => post({
734
+ ...selection,
735
+ ...where()
736
+ }, editorOrigin));
712
737
  }
713
738
  });
739
+ post({
740
+ type: "mn-preview-ready",
741
+ ...where()
742
+ });
743
+ let lastPath = location.pathname;
744
+ const onNavigate = () => {
745
+ if (location.pathname === lastPath) return;
746
+ lastPath = location.pathname;
747
+ post({
748
+ type: "mn-preview-ready",
749
+ ...where()
750
+ });
751
+ };
752
+ window.addEventListener("popstate", onNavigate);
753
+ for (const method of ["pushState", "replaceState"]) {
754
+ const original = history[method].bind(history);
755
+ history[method] = (...args) => {
756
+ original(...args);
757
+ onNavigate();
758
+ };
759
+ }
760
+ }
761
+ let editListeners = null;
762
+ function setEditMode(enabled, report) {
763
+ if (editListeners) {
764
+ document.removeEventListener("mouseover", editListeners.over, true);
765
+ document.removeEventListener("click", editListeners.click, true);
766
+ editListeners = null;
767
+ }
768
+ document.querySelectorAll(`[${HOVER_ATTR}]`).forEach((el) => el.removeAttribute(HOVER_ATTR));
769
+ document.getElementById(STYLE_ID)?.remove();
770
+ if (!enabled) return;
771
+ const style = document.createElement("style");
772
+ style.id = STYLE_ID;
773
+ style.textContent = `[${HOVER_ATTR}]{outline:2px dashed #0ea5e9 !important;outline-offset:2px !important;cursor:pointer !important}`;
774
+ document.head.appendChild(style);
775
+ let hovered = null;
776
+ const over = (e) => {
777
+ const target = pickTarget(e.target);
778
+ if (target === hovered) return;
779
+ hovered?.removeAttribute(HOVER_ATTR);
780
+ hovered = target;
781
+ hovered?.setAttribute(HOVER_ATTR, "");
782
+ };
783
+ const click = (e) => {
784
+ const selection = describe(e);
785
+ if (!selection) return;
786
+ e.preventDefault();
787
+ e.stopPropagation();
788
+ report(selection);
789
+ };
790
+ document.addEventListener("mouseover", over, true);
791
+ document.addEventListener("click", click, true);
792
+ editListeners = {
793
+ over,
794
+ click
795
+ };
796
+ }
797
+ function pickTarget(target) {
798
+ if (!(target instanceof Element)) return null;
799
+ if (imageSource(target)) return target;
800
+ let el = target;
801
+ for (let depth = 0; el && depth < MAX_TEXT_DEPTH; depth++, el = el.parentElement) if (ownText(el)) return el;
802
+ return null;
803
+ }
804
+ function describe(e) {
805
+ const target = pickTarget(e.target);
806
+ if (!target) return null;
807
+ const src = imageSource(target);
808
+ if (src) return {
809
+ type: "mn-preview-select",
810
+ kind: "image",
811
+ src,
812
+ alt: target.getAttribute("alt") ?? ""
813
+ };
814
+ const text = textAtPoint(e.clientX, e.clientY, target) || ownText(target);
815
+ const context = collapse(target.innerText ?? target.textContent ?? "").slice(0, 1e3);
816
+ return text ? {
817
+ type: "mn-preview-select",
818
+ kind: "text",
819
+ text,
820
+ context
821
+ } : null;
822
+ }
823
+ function imageSource(el) {
824
+ if (el instanceof HTMLImageElement) return el.getAttribute("src") || el.currentSrc || el.src;
825
+ const bg = getComputedStyle(el).backgroundImage;
826
+ return /url\(["']?(.*?)["']?\)/.exec(bg ?? "")?.[1] ?? "";
827
+ }
828
+ function ownText(el) {
829
+ let text = "";
830
+ for (const node of Array.from(el.childNodes)) if (node.nodeType === Node.TEXT_NODE) text += node.textContent ?? "";
831
+ return collapse(text);
832
+ }
833
+ function textAtPoint(x, y, within) {
834
+ const doc = document;
835
+ const node = doc.caretPositionFromPoint?.(x, y)?.offsetNode ?? doc.caretRangeFromPoint?.(x, y)?.startContainer;
836
+ if (!node || node.nodeType !== Node.TEXT_NODE || !within.contains(node)) return "";
837
+ return collapse(node.textContent ?? "");
838
+ }
839
+ function collapse(text) {
840
+ return text.replace(/\s+/g, " ").trim();
714
841
  }
715
842
  export { API_BASE_URL, CrudService, MN_INSTANCE_ID, MN_IN_BOTTOM_SHEET, MN_IN_MODAL, MN_SECTION_PATH, MnConfigService, MnHttpService, MnInstanceDirective, MnLanguageService, MnSectionDirective, MnTranslatePipe, enableMnPreviewMode, isTranslatable, lucideIcons, parseConfigText, provideMnComponentConfig, provideMnConfig, provideMnLanguage };
716
843
 
@@ -1 +1 @@
1
- {"version":3,"file":"mn-angular-lib-core.mjs","names":[],"sources":["../../../projects/mn-angular-lib/core/src/language/mn-language.types.ts","../../../projects/mn-angular-lib/core/src/language/mn-language.service.ts","../../../projects/mn-angular-lib/core/src/language/mn-language.providers.ts","../../../projects/mn-angular-lib/core/src/language/mn-translate.pipe.ts","../../../projects/mn-angular-lib/core/src/config/mn-config.service.ts","../../../projects/mn-angular-lib/core/src/config/mn-config.providers.ts","../../../projects/mn-angular-lib/core/src/context/mn-context.tokens.ts","../../../projects/mn-angular-lib/core/src/config/mn-component-config.providers.ts","../../../projects/mn-angular-lib/core/src/context/mn-section.directive.ts","../../../projects/mn-angular-lib/core/src/context/mn-instance.directive.ts","../../../projects/mn-angular-lib/core/src/shared/crud/crud.tokens.ts","../../../projects/mn-angular-lib/core/src/shared/crud/crud.service.ts","../../../projects/mn-angular-lib/core/src/shared/http/mn-http.service.ts","../../../projects/mn-angular-lib/core/src/shared/icons/lucide-icons.ts","../../../projects/mn-angular-lib/core/src/preview/mn-preview-listener.ts"],"sourcesContent":["/**\n * A marker object used in config values to indicate that the value\n * should be resolved via the MnLanguageService.\n *\n * Example in mn-config.json5:\n * label: { $translate: \"form.email.label\" }\n */\nexport type MnTranslatable = {\n $translate: string;\n params?: Record<string, string | number>;\n}\n\n/**\n * A config value that is either a plain value or a translatable marker.\n */\nexport type MnConfigValue<T = string> = T | MnTranslatable;\n\n/**\n * Translations for a single locale, as a tree of keys.\n *\n * Both shapes resolve through the same dotted lookup: a bundle may nest\n * (`{ form: { email: { label } } }`), flatten (`{ \"form.email.label\": … }`), or mix the two.\n */\nexport type MnTranslationMap = { [key: string]: string | MnTranslationMap };\n\n/**\n * All loaded translations keyed by locale code (e.g. \"en\", \"nl\", \"de\").\n */\nexport type MnTranslations = Record<string, MnTranslationMap>;\n\n/**\n * Configuration for the language provider.\n */\nexport type MnLanguageConfig = {\n /** URL pattern for loading translation files. Use `{locale}` as placeholder. e.g. \"assets/i18n/{locale}.json\" */\n urlPattern: string;\n /** The default/fallback locale. */\n defaultLocale: string;\n /** Locales to preload at bootstrap. */\n preload?: string[];\n /**\n * Optional mapping of domain hostnames to locale codes.\n * When set, the service will use the current domain to determine the initial locale.\n * Example: { \"example.nl\": \"nl\", \"example.de\": \"de\", \"example.com\": \"en\" }\n */\n domainLocaleMap?: Record<string, string>;\n /** Whether to enable debug logging. */\n debug?: boolean;\n}\n\n/**\n * Type guard: checks whether a value is a translatable marker object.\n */\nexport function isTranslatable(value: unknown): value is MnTranslatable {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<string, unknown>)['$translate'] === 'string'\n );\n}\n","import {ApplicationRef, inject, Injectable, signal} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {BehaviorSubject, firstValueFrom, Observable} from 'rxjs';\nimport {MnTranslationMap, MnTranslations} from './mn-language.types';\n\n/**\n * Key suffix per CLDR plural category.\n *\n * Only `one` earns a suffix: every locale shipped so far (`en`, `nl`) has exactly the two\n * categories `one` and `other`, and `other` keeps the bare key. A locale with `few`/`many`\n * (Polish, Russian, Arabic) resolves those to the plural until an entry is added here —\n * adding one is the whole change, since the lookup is category-driven already.\n */\nconst PLURAL_SUFFIX: Partial<Record<Intl.LDMLPluralRule, string>> = {\n one: 'One',\n};\n\n/** Params key whose presence turns a translation into a plural-aware lookup. */\nconst COUNT_PARAM = 'count';\n\n@Injectable({ providedIn: 'root' })\nexport class MnLanguageService {\n private readonly http = inject(HttpClient);\n private readonly appRef = inject(ApplicationRef);\n\n private _translations: MnTranslations = {};\n private _locale$ = new BehaviorSubject<string>('en');\n\n /**\n * The active locale as a signal, read by {@link locale} and so by every lookup.\n *\n * Components are OnPush, and `setLocale` only ran one `appRef.tick()`, which skips every view\n * nobody marked: a tab bar, a card heading or a bar label kept the old language until the page\n * was reloaded. A signal read while a template renders (through the `mnTranslate` pipe, or a\n * getter calling `translate`) is tracked by that view, so switching the locale marks exactly\n * the views that translated something, and a `computed` built on `translate` recomputes.\n */\n private readonly _locale = signal('en');\n private _urlPattern: string | null = null;\n private _debug = false;\n\n /**\n * `Intl.PluralRules` per locale. Cached because {@link translate} runs on every change\n * detection through the impure `mnTranslate` pipe, and constructing one is not cheap.\n */\n private readonly _pluralRules = new Map<string, Intl.PluralRules | null>();\n\n /** Observable of the current active locale. */\n readonly locale$: Observable<string> = this._locale$.asObservable();\n\n /** Current active locale. */\n get locale(): string {\n return this._locale();\n }\n\n /**\n * Enable or disable debug logging.\n */\n setDebug(enabled: boolean): void {\n this._debug = enabled;\n if (enabled) {\n console.log(`[MnLanguage] Debug mode enabled`);\n }\n }\n\n /**\n * Configure the URL pattern used to fetch translation files.\n * Use `{locale}` as placeholder, e.g. `\"assets/i18n/{locale}.json\"`.\n */\n configure(urlPattern: string): void {\n if (this._debug) {\n console.log(`[MnLanguage] Configured urlPattern: ${urlPattern}`);\n }\n this._urlPattern = urlPattern;\n }\n\n /**\n * Load translations for a locale from the configured URL pattern.\n * If translations are already loaded for this locale, this is a no-op.\n */\n async loadLocale(locale: string): Promise<void> {\n if (this._translations[locale]) return;\n\n if (!this._urlPattern) {\n console.warn(`[MnLanguage] No URL pattern configured. Call configure() or use provideMnLanguage().`);\n return;\n }\n\n const url = this._urlPattern.replace('{locale}', locale);\n if (this._debug) {\n console.log(`[MnLanguage] Loading locale \"${locale}\" from ${url}`);\n }\n\n try {\n const map = await firstValueFrom(\n this.http.get<MnTranslationMap>(url)\n );\n this._translations[locale] = map ?? {};\n if (this._debug) {\n console.log(`[MnLanguage] Loaded locale \"${locale}\"`, this._translations[locale]);\n }\n } catch (err) {\n console.warn(`[MnLanguage] Failed to load translations from ${url}`, err);\n this._translations[locale] = {};\n }\n }\n\n /**\n * Switch the active locale. Loads translations if not yet loaded.\n */\n async setLocale(locale: string): Promise<void> {\n if (this._debug) {\n console.log(`[MnLanguage] Setting locale to \"${locale}\"`);\n }\n await this.loadLocale(locale);\n this._locale.set(locale);\n this._locale$.next(locale);\n this.appRef.tick();\n }\n\n /**\n * Register translations for a locale directly from code (no HTTP needed).\n */\n registerTranslations(locale: string, translations: MnTranslationMap): void {\n this._translations[locale] = {\n ...(this._translations[locale] ?? {}),\n ...translations,\n };\n }\n\n /**\n * Translate a key using the current locale, with optional parameter interpolation.\n * Falls back to the key itself if no translation is found.\n *\n * Interpolation replaces `{{paramName}}` with the provided value.\n *\n * A `count` param additionally selects the wording that agrees with it: the key is\n * resolved against its CLDR plural category first (`key` + `One`/`Two`/`Few`/`Many`/\n * `Zero`), falling back to `key` when that sibling is undefined. Nothing has to opt in —\n * a key with no sibling behaves exactly as before.\n *\n * ```ts\n * // 'shift.asked' → '{{count}} members are notified'\n * // 'shift.askedOne' → '{{count}} member is notified'\n * lang.translate('shift.asked', { count: 3 }); // 3 members are notified\n * lang.translate('shift.asked', { count: 1 }); // 1 member is notified\n * ```\n */\n translate(key: string, params?: Record<string, string | number>): string {\n const map = this._translations[this.locale] ?? {};\n let value = this.getValueFromMap(map, this.resolvePluralKey(map, key, params));\n\n if (value === undefined) {\n if (this._debug) {\n console.warn(`[MnLanguage] Missing translation for key: \"${key}\" in locale: \"${this.locale}\"`);\n }\n return key;\n }\n\n if (params) {\n for (const [paramKey, paramValue] of Object.entries(params)) {\n value = value.replace(new RegExp(`\\\\{\\\\{${paramKey}\\\\}\\\\}`, 'g'), String(paramValue));\n }\n }\n\n return value;\n }\n\n /**\n * Picks the wording that agrees with a `count` param.\n *\n * A key carrying a count resolves against its CLDR plural category first, so\n * `askedMessage` + `askedMessageOne` render \"3 leden krijgen bericht\" and \"1 lid krijgt\n * bericht\" off the same call. Both languages change the verb as well as the noun, which\n * is why each form is a whole sentence under its own key rather than a swapped noun.\n *\n * Falls back to `key` whenever the sibling is undefined, so a key that never needed a\n * plural — or an app that has not written one yet — behaves exactly as it did before.\n * @param map The active locale's translations.\n * @param key The dot-notated translation key.\n * @param params The interpolation values, inspected for `count`.\n * @returns The key to look up: the plural sibling, or `key` itself.\n */\n private resolvePluralKey(\n map: MnTranslationMap,\n key: string,\n params?: Record<string, string | number>,\n ): string {\n const raw = params?.[COUNT_PARAM];\n if (raw === undefined) return key;\n\n // A count off a JSON payload arrives as a string often enough that comparing it\n // strictly would silently pick the plural for a count of one.\n const count = Number(raw);\n if (!Number.isFinite(count)) return key;\n\n const suffix = PLURAL_SUFFIX[this.pluralCategory(count)];\n if (suffix === undefined) return key;\n\n const variant = key + suffix;\n return this.getValueFromMap(map, variant) !== undefined ? variant : key;\n }\n\n /**\n * The CLDR plural category of a count in the active locale.\n * @param count The count being quoted.\n * @returns The category, falling back to English rules for an unusable locale.\n */\n private pluralCategory(count: number): Intl.LDMLPluralRule {\n if (!this._pluralRules.has(this.locale)) {\n try {\n this._pluralRules.set(this.locale, new Intl.PluralRules(this.locale));\n } catch {\n // An unknown or malformed locale tag: fall back rather than break every string.\n this._pluralRules.set(this.locale, null);\n }\n }\n const rules = this._pluralRules.get(this.locale);\n if (!rules) return count === 1 ? 'one' : 'other';\n return rules.select(count);\n }\n\n /**\n * Helper to retrieve a value from a potentially nested translation map using a dot-notated key.\n */\n private getValueFromMap(map: MnTranslationMap, key: string): string | undefined {\n // A flattened bundle holds the dotted key verbatim; a nested one is walked below.\n const direct = map[key];\n if (typeof direct === 'string') return direct;\n\n const parts = key.split('.');\n let current: MnTranslationMap | string | undefined = map;\n\n for (const part of parts) {\n if (current === null || typeof current !== 'object') return undefined;\n current = current[part];\n }\n\n return typeof current === 'string' ? current : undefined;\n }\n\n /**\n * Translate a key **only if it is defined**, returning `undefined` otherwise.\n *\n * {@link translate} deliberately returns the key itself when it is missing, which\n * makes it unusable for a library's own default labels: a consumer that never\n * defined `mnCollection.rowsPerPage` would see that raw string in their UI. This\n * lets a caller try a conventional key and fall back to a readable English default\n * when the app has not translated it, so components ship translatable strings\n * without forcing every consumer to define them.\n *\n * @param key The dot-notated translation key.\n * @param params Optional `{{name}}` interpolation values.\n * @returns The translation, or `undefined` when the key is not defined.\n */\n translateIfPresent(key: string, params?: Record<string, string | number>): string | undefined {\n const map = this._translations[this.locale] ?? {};\n if (this.getValueFromMap(map, key) === undefined) return undefined;\n return this.translate(key, params);\n }\n\n /**\n * Shorthand alias for `translate`.\n */\n t(key: string, params?: Record<string, string | number>): string {\n return this.translate(key, params);\n }\n\n /**\n * Resolve the effective default locale from a domain-to-locale map.\n * Matches `window.location.hostname` against the map keys.\n * Returns the mapped locale, or the provided fallback if no match is found.\n */\n resolveLocaleForDomain(domainLocaleMap: Record<string, string> | undefined, fallback: string): string {\n if (!domainLocaleMap || typeof window === 'undefined') return fallback;\n const hostname = window.location.hostname;\n return domainLocaleMap[hostname] ?? fallback;\n }\n}\n","import { APP_INITIALIZER, Provider } from '@angular/core';\nimport { MnLanguageService } from './mn-language.service';\nimport { MnLanguageConfig } from './mn-language.types';\n\n/**\n * Provides an APP_INITIALIZER that configures the MnLanguageService and\n * preloads the requested locales during application bootstrap.\n *\n * Usage in app.config.ts:\n * ...provideMnLanguage({\n * urlPattern: 'assets/i18n/{locale}.json',\n * defaultLocale: 'en',\n * preload: ['en', 'nl'],\n * })\n */\nexport function provideMnLanguage(config: MnLanguageConfig): Provider[] {\n return [\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: (svc: MnLanguageService) => async () => {\n if (config.debug) {\n svc.setDebug(true);\n }\n svc.configure(config.urlPattern);\n\n const effectiveLocale = svc.resolveLocaleForDomain(config.domainLocaleMap, config.defaultLocale);\n const localesToLoad = config.preload ?? [effectiveLocale];\n await Promise.all(localesToLoad.map(l => svc.loadLocale(l)));\n await svc.setLocale(effectiveLocale);\n },\n deps: [MnLanguageService],\n },\n ];\n}\n","import {Pipe, PipeTransform, inject} from '@angular/core';\nimport { MnLanguageService } from './mn-language.service';\n\n/**\n * Pipe that translates a key via MnLanguageService.\n *\n * Usage in templates:\n * {{ 'form.email.label' | mnTranslate }}\n * {{ 'greeting' | mnTranslate:{ name: 'World' } }}\n *\n * Note: This pipe is impure so it re-evaluates when the locale changes.\n */\n@Pipe({\n name: 'mnTranslate',\n standalone: true,\n pure: false,\n})\nexport class MnTranslatePipe implements PipeTransform {\n private readonly lang = inject(MnLanguageService);\n\n\n transform(key: string, params?: Record<string, string | number>): string {\n return this.lang.translate(key, params);\n }\n}\n","import {inject, Injectable, signal} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {firstValueFrom} from 'rxjs';\nimport {MnConfigFile, MnConfigSettings} from './mn-config.types';\nimport {isTranslatable, MnLanguageConfig, MnLanguageService} from '../language';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Parses a config file. Strict JSON goes through `JSON.parse`; only a file that needs JSON5\n * syntax (comments, unquoted keys, trailing commas) loads the `json5` parser, as its own chunk.\n * A static import put the CommonJS `json5` package (~32 kB) into every consumer's startup bundle.\n *\n * @param text The raw file content.\n * @returns The parsed value.\n */\nexport async function parseConfigText(text: string): Promise<unknown> {\n try {\n return JSON.parse(text);\n } catch {\n const { default: JSON5 } = await import('json5');\n return JSON5.parse(text);\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class MnConfigService {\n private readonly http = inject(HttpClient);\n\n private _config: MnConfigFile | null = null;\n private _settings: MnConfigSettings = {};\n private _debugMode = false;\n\n /** Reactive version counter — incremented on every config load. */\n private _configVersion = signal(0);\n readonly configVersion = this._configVersion.asReadonly();\n\n private readonly lang = inject(MnLanguageService);\n\n /** General settings from the config file (version, name, etc.). */\n get settings(): Readonly<MnConfigSettings> {\n return this._settings;\n }\n\n /**\n * Load the configuration JSON from the provided URL and cache it in memory.\n * Consumers should typically call this via the APP_INITIALIZER helper.\n */\n async load(url: string, debugMode = false): Promise<void> {\n this._debugMode = debugMode;\n this.lang.setDebug(debugMode);\n let text: string;\n\n try {\n text = await firstValueFrom(\n this.http.get(url, { responseType: 'text' })\n );\n } catch (err) {\n console.warn(`[MnConfig] Failed to load config from ${url}`, err);\n this._config = { defaults: {}, overrides: {} };\n return;\n }\n\n let json: unknown;\n\n try {\n json = await parseConfigText(text);\n } catch (err) {\n console.warn(`[MnConfig] Failed to parse JSON5 from ${url}`, err, text);\n json = {};\n }\n\n const cfg = (isPlainObject(json) ? json : {}) as Record<string, unknown>;\n const defaults = isPlainObject(cfg['defaults']) ? cfg['defaults'] : {};\n const overrides: Record<string, unknown> = isPlainObject(cfg['overrides']) ? cfg['overrides'] : {};\n\n const settings: MnConfigSettings = isPlainObject(cfg['settings']) ? cfg['settings'] as MnConfigSettings : {};\n\n this._config = { settings, defaults, overrides };\n this._settings = settings;\n\n // Bootstrap language service from config if a \"language\" section is present.\n // This avoids circular dependency: config reads raw language settings and\n // pushes them into the language service (language service never imports config).\n const langCfg = cfg['language'];\n if (isPlainObject(langCfg) && typeof langCfg['urlPattern'] === 'string') {\n const lc = langCfg as MnLanguageConfig;\n if (this._debugMode) {\n console.log(`[MnConfig] Applying language config from file`, lc);\n }\n this.lang.configure(lc.urlPattern);\n const effectiveLocale = this.lang.resolveLocaleForDomain(lc.domainLocaleMap, lc.defaultLocale);\n const localesToLoad = Array.from(new Set([...(lc.preload ?? []), effectiveLocale]));\n await Promise.all(localesToLoad.map(l => this.lang.loadLocale(l)));\n await this.lang.setLocale(effectiveLocale);\n }\n\n this._configVersion.update(v => v + 1);\n }\n\n /**\n * Load configuration from a pre-parsed object (no HTTP fetch).\n * Used for live preview scenarios where config is pushed via postMessage.\n * Optionally re-bootstraps the language service if a `language` section is present.\n */\n async loadFromObject(config: Record<string, unknown>, bootstrapLanguage = false): Promise<void> {\n const defaults = isPlainObject(config['defaults']) ? config['defaults'] : {};\n const overrides = isPlainObject(config['overrides']) ? config['overrides'] : {};\n const settings: MnConfigSettings = isPlainObject(config['settings']) ? config['settings'] as MnConfigSettings : {};\n\n this._config = { settings, defaults, overrides };\n this._settings = settings;\n\n if (bootstrapLanguage) {\n const langCfg = config['language'];\n if (isPlainObject(langCfg) && typeof langCfg['urlPattern'] === 'string') {\n const lc = langCfg as MnLanguageConfig;\n if (this._debugMode) {\n console.log(`[MnConfig] Applying language config from object`, lc);\n }\n this.lang.configure(lc.urlPattern);\n const effectiveLocale = this.lang.resolveLocaleForDomain(lc.domainLocaleMap, lc.defaultLocale);\n const localesToLoad = Array.from(new Set([...(lc.preload ?? []), effectiveLocale]));\n await Promise.all(localesToLoad.map(l => this.lang.loadLocale(l)));\n await this.lang.setLocale(effectiveLocale);\n }\n }\n\n this._configVersion.update(v => v + 1);\n }\n\n\n /**\n * Resolve a configuration object for a component, optionally scoped to a section path\n * and optionally overridden by an instance id.\n */\n resolve<T extends object = Record<string, unknown>>(\n componentName: string,\n sectionPath: string[] = [],\n instanceId?: string,\n ): T {\n const baseConfig: Record<string, unknown> = isPlainObject(this._config?.defaults)\n ? (isPlainObject((this._config as MnConfigFile).defaults[componentName])\n ? { ...(this._config as MnConfigFile).defaults[componentName] as Record<string, unknown> }\n : {})\n : {};\n\n const leaf = this.walkOverrides(this._config?.overrides ?? {}, sectionPath);\n\n let resolved: Record<string, unknown> = baseConfig;\n\n if (leaf && isPlainObject((leaf as Record<string, unknown>)[componentName])) {\n resolved = this.deepMerge(resolved, (leaf as Record<string, unknown>)[componentName] as Record<string, unknown>);\n }\n\n if (instanceId) {\n const instKey = `#${instanceId}`;\n if (leaf && isPlainObject((leaf as Record<string, unknown>)[instKey])) {\n resolved = this.deepMerge(resolved, (leaf as Record<string, unknown>)[instKey] as Record<string, unknown>);\n }\n }\n\n if (this._debugMode) {\n console.debug(`[MnConfig] Resolving for ${componentName}`, {\n sectionPath,\n instanceId,\n resolved,\n });\n }\n\n return this.resolveTranslatables(resolved) as T;\n }\n\n /**\n * Walk the overrides nested object using the provided section path and return the leaf node.\n * If any segment is missing or the current node is not a plain object, returns undefined.\n */\n walkOverrides(overridesRoot: unknown, sectionPath: string[]): unknown | undefined {\n let node: unknown = overridesRoot;\n for (const segment of sectionPath) {\n if (!isPlainObject(node)) return undefined;\n node = (node as Record<string, unknown>)[segment];\n if (node === undefined) return undefined;\n }\n return node;\n }\n\n /**\n * Recursively walk a resolved config object and replace any `{ $translate: \"key\" }` markers\n * with their translated values from MnLanguageService.\n */\n private resolveTranslatables(obj: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (isTranslatable(value)) {\n out[key] = this.lang.translate(value.$translate, value.params);\n } else if (Array.isArray(value)) {\n out[key] = value.map(item => {\n if (isTranslatable(item)) {\n return this.lang.translate(item.$translate, item.params);\n } else if (isPlainObject(item)) {\n return this.resolveTranslatables(item as Record<string, unknown>);\n }\n return item;\n });\n } else if (isPlainObject(value)) {\n out[key] = this.resolveTranslatables(value as Record<string, unknown>);\n } else {\n out[key] = value;\n }\n }\n return out;\n }\n\n /**\n * Deep merge two plain-object trees. Arrays and non-plain values are replaced by the patch.\n * Does not mutate inputs; returns a new object.\n */\n deepMerge<A extends Record<string, unknown>, B extends Record<string, unknown>>(base: A, patch: B): A & B {\n const out: Record<string, unknown> = {...base};\n for (const key of Object.keys(patch)) {\n const bVal = base[key];\n const pVal = patch[key];\n\n if (isPlainObject(bVal) && isPlainObject(pVal)) {\n out[key] = this.deepMerge(bVal, pVal);\n } else {\n // replace for arrays, primitives, null, undefined, and non-plain objects\n out[key] = pVal;\n }\n }\n return out as A & B;\n }\n}\n","import { APP_INITIALIZER, Provider } from '@angular/core';\nimport { MnConfigService } from './mn-config.service';\n\n/**\n * Provides an APP_INITIALIZER that loads the mn-lib configuration from the given URL\n * during application bootstrap. The consuming application is responsible for providing\n * HttpClient (e.g., via HttpClientModule or provideHttpClient()).\n */\nexport function provideMnConfig(url: string, debugMode = false): Provider[] {\n return [\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: (svc: MnConfigService) => () => svc.load(url, debugMode),\n deps: [MnConfigService],\n },\n ];\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * Represents the current section path based on nested mn-section directives.\n */\nexport const MN_SECTION_PATH = new InjectionToken<string[]>(\n 'MN_SECTION_PATH',\n {\n providedIn: 'root',\n factory: () => [],\n },\n);\n\n/**\n * Whether the injecting component renders inside an mn modal. `MnModalShellComponent` provides\n * `true` for everything in its view, so a component deep in a modal body can tell without the\n * consumer passing anything: mn-table uses it to skip its own bottom sheet, because a sheet\n * opened over a modal that is already a sheet on a phone stacks two drawers on one screen.\n */\nexport const MN_IN_MODAL = new InjectionToken<boolean>(\n 'MN_IN_MODAL',\n {\n providedIn: 'root',\n factory: () => false,\n },\n);\n\n/**\n * Whether the injecting component renders inside an `mn-bottom-sheet`. The sheet provides `true`\n * to its content. mn-select and mn-multi-select read it: on a phone they normally open their\n * options as a bottom sheet of their own, which inside a sheet stacks a second one on top and\n * hides the form around it, so there they open as an anchored dropdown instead.\n */\nexport const MN_IN_BOTTOM_SHEET = new InjectionToken<boolean>(\n 'MN_IN_BOTTOM_SHEET',\n {\n providedIn: 'root',\n factory: () => false,\n },\n);\n\n/**\n * Represents the current component instance id provided by [mn-instance].\n */\nexport const MN_INSTANCE_ID = new InjectionToken<string | null>(\n 'MN_INSTANCE_ID',\n {\n providedIn: 'root',\n factory: () => null,\n },\n);\n","import { DestroyRef, InjectionToken, Optional, Provider } from '@angular/core';\nimport { MN_INSTANCE_ID, MN_SECTION_PATH } from '../context/mn-context.tokens';\nimport { MnConfigService } from './mn-config.service';\nimport { MnLanguageService } from '../language/mn-language.service';\n\n/**\n * Helper to provide a resolved, typed component config via DI.\n *\n * Usage in a component/module providers:\n * const MY_CFG = new InjectionToken<MyCfg>('MY_CFG');\n * providers: [ provideMnComponentConfig(MY_CFG, 'my-component') ]\n * Then in the component:\n * readonly cfg = inject(MY_CFG)\n *\n * The returned config object is **reactive**: when the active locale changes,\n * all translatable values are re-resolved in place so that templates using\n * `cfg.someLabel` automatically reflect the new language on the next change-detection cycle.\n */\nexport function provideMnComponentConfig<T extends object>(\n token: InjectionToken<T>,\n componentName: string,\n initial?: Partial<T>,\n): Provider {\n return {\n provide: token,\n deps: [\n MnConfigService,\n MnLanguageService,\n DestroyRef,\n [new Optional(), MN_SECTION_PATH],\n [new Optional(), MN_INSTANCE_ID],\n ],\n useFactory: (\n svc: MnConfigService,\n lang: MnLanguageService,\n destroyRef: DestroyRef,\n sectionPath: string[] | null,\n instanceId: string | null,\n ): T => {\n const resolveConfig = (): T => {\n const resolved = svc.resolve<T>(componentName, sectionPath ?? [], instanceId ?? undefined);\n return Object.assign({}, initial ?? {}, resolved);\n };\n\n // Create the initial config object that will be shared by reference.\n const cfg = resolveConfig();\n\n // Re-resolve translatable values whenever the locale changes.\n // skip(1) because the current locale was already used for the initial resolve.\n const sub = lang.locale$.subscribe(() => {\n const updated = resolveConfig();\n // Mutate the existing object in place so all template bindings pick up the new values.\n for (const key of Object.keys(updated)) {\n (cfg as Record<string, unknown>)[key] = (updated as Record<string, unknown>)[key];\n }\n });\n\n destroyRef.onDestroy(() => sub.unsubscribe());\n\n return cfg;\n },\n };\n}\n","import { Attribute, Directive, Input, Optional, SkipSelf } from '@angular/core';\nimport { MN_SECTION_PATH } from './mn-context.tokens';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector -- kebab-case is intentional: matches the Attribute() token and is stable public API\n selector: '[mn-section]',\n standalone: true,\n providers: [\n {\n provide: MN_SECTION_PATH,\n // Read parent MN_SECTION_PATH from ancestor injector (skipSelf to avoid self-reference),\n // and read the attribute value using Attribute so it's available at provider creation time.\n deps: [[new Optional(), new SkipSelf(), MN_SECTION_PATH], new Attribute('mn-section')],\n useFactory: (parentPath: string[] | null, attr: string | null) => {\n const parent = Array.isArray(parentPath) ? parentPath : [];\n const name = (attr ?? '').trim();\n return name ? [...parent, name] : [...parent];\n },\n },\n ],\n})\nexport class MnSectionDirective {\n /** Section name contributed by this DOM node to the section path */\n @Input('mn-section') mnSection: string | undefined;\n}\n","import { Attribute, Directive, Input } from '@angular/core';\nimport { MN_INSTANCE_ID } from './mn-context.tokens';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector -- kebab-case is intentional: matches the Attribute() token and is stable public API\n selector: '[mn-instance]',\n standalone: true,\n providers: [\n {\n provide: MN_INSTANCE_ID,\n // Read the attribute at provider creation time using Attribute token; Inputs may not be set yet.\n deps: [new Attribute('mn-instance')],\n useFactory: (attr: string | null) => (attr ?? '').trim() || null,\n },\n ],\n})\nexport class MnInstanceDirective {\n /** Instance id for targeting per-component instance overrides */\n @Input('mn-instance') mnInstance: string | undefined;\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * Injection token for the base URL used by all CRUD service requests.\n *\n * Provide this token at the application or module level to configure\n * the root API URL that `CrudService` prepends to every endpoint.\n */\nexport const API_BASE_URL = new InjectionToken<string>('API_BASE_URL');\n","import {inject} from '@angular/core';\nimport {ApiError, FailureResult, QueryParams, Result, ResultMeta, SuccessResult} from './crud.model';\nimport {catchError, map, Observable, of} from 'rxjs';\nimport {HttpClient, HttpErrorResponse, HttpParams, HttpResponse, HttpStatusCode} from '@angular/common/http';\nimport {API_BASE_URL} from './crud.tokens';\n\n/**\n * Configuration for a CRUD service endpoint.\n *\n * Passed to the `CrudService` constructor to define which API\n * resource the service operates on.\n */\nexport type CrudConfig = {\n endpoint: string;\n}\n\n/**\n * Abstract base class for CRUD services.\n * Provides standard HTTP operations with typed `Result<T>` responses.\n *\n * @template TEntity The entity type returned by single-item operations.\n * @template TListResponse The response type for list operations (defaults to `TEntity[]`).\n * @template TCreatePayload The payload type for create operations (defaults to `Partial<TEntity>`).\n * @template TUpdatePayload The payload type for update operations (defaults to `Partial<TEntity>`).\n * @template TId The type of the entity identifier (defaults to `number`).\n * @template TGetByIdResponse The response type for getById (defaults to `TEntity`).\n * @template TCreateResponse The response type for create (defaults to `TEntity`).\n * @template TUpdateResponse The response type for update and patch (defaults to `TEntity`).\n * @template TDeleteResponse The response type for delete (defaults to `void`).\n */\nexport abstract class CrudService<\n TEntity,\n TListResponse = TEntity[],\n TCreatePayload = Partial<TEntity>,\n TUpdatePayload = Partial<TEntity>,\n TId extends string | number = number,\n TGetByIdResponse = TEntity,\n TCreateResponse = TEntity,\n TUpdateResponse = TEntity,\n TDeleteResponse = void\n> {\n protected readonly http = inject(HttpClient);\n protected readonly baseUrl = inject(API_BASE_URL);\n protected readonly endpoint: string;\n\n protected constructor(config: CrudConfig) {\n this.endpoint = `${this.baseUrl}${config.endpoint}`;\n }\n\n /**\n * Retrieves all entities from the configured endpoint.\n *\n * Sends a GET request to the base endpoint. Query values are\n * converted to `HttpParams` before the request is sent.\n *\n * @param query Optional query parameters appended to the request URL.\n * @returns An observable emitting a `Result` with the list response or a structured failure.\n */\n getAll(query?: QueryParams): Observable<Result<TListResponse>> {\n return this.http\n .get<TListResponse>(this.endpoint, {\n params: this.toHttpParams(query)\n })\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Retrieves a single entity by its identifier.\n *\n * Sends a GET request to `{endpoint}/{id}`.\n *\n * @param id The unique identifier of the entity to retrieve.\n * @returns An observable emitting a `Result` with the entity or a structured failure.\n */\n getById(id: TId): Observable<Result<TGetByIdResponse>> {\n return this.http\n .get<TGetByIdResponse>(this.itemUrl(id))\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Creates a new entity at the configured endpoint.\n *\n * Sends a POST request with the provided payload as the request body.\n *\n * @param payload The data used to create the entity.\n * @returns An observable emitting a `Result` with the created entity or a structured failure.\n */\n create(payload: TCreatePayload): Observable<Result<TCreateResponse>> {\n return this.http\n .post<TCreateResponse>(this.endpoint, payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Fully replaces an existing entity.\n *\n * Sends a PUT request to `{endpoint}/{id}` with the provided payload,\n * replacing the entire entity.\n *\n * @param id The unique identifier of the entity to update.\n * @param payload The complete data to replace the existing entity with.\n * @returns An observable emitting a `Result` with the updated entity or a structured failure.\n */\n update(id: TId, payload: TUpdatePayload): Observable<Result<TUpdateResponse>> {\n return this.http\n .put<TUpdateResponse>(this.itemUrl(id), payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Partially updates an existing entity.\n *\n * Sends a PATCH request to `{endpoint}/{id}` with the provided payload,\n * merging changes into the existing entity.\n *\n * @param id The unique identifier of the entity to patch.\n * @param payload A partial set of fields to update on the existing entity.\n * @returns An observable emitting a `Result` with the updated entity or a structured failure.\n */\n patch(id: TId, payload: Partial<TUpdatePayload>): Observable<Result<TUpdateResponse>> {\n return this.http\n .patch<TUpdateResponse>(this.itemUrl(id), payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Deletes an entity by its identifier.\n *\n * Sends a DELETE request to `{endpoint}/{id}`.\n *\n * @param id The unique identifier of the entity to delete.\n * @returns An observable emitting a `Result` with the delete response or a structured failure.\n */\n delete(id: TId): Observable<Result<TDeleteResponse>> {\n return this.http\n .delete<TDeleteResponse>(this.itemUrl(id))\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Retrieves all entities with the full `HttpResponse` wrapper.\n *\n * Behaves like {@link getAll} but observes the complete HTTP response,\n * giving access to headers, status code, and URL alongside the body.\n *\n * @param query Optional query parameters appended to the request URL.\n * @returns An observable emitting a `Result` with the full HTTP response or a structured failure.\n */\n getAllResponse(query?: QueryParams): Observable<Result<HttpResponse<TListResponse>>> {\n return this.http\n .get<TListResponse>(this.endpoint, {\n params: this.toHttpParams(query),\n observe: 'response',\n })\n .pipe(\n map((response) =>\n this.success(response, {\n statusCode: response.status,\n headers: response.headers,\n url: response.url ?? undefined,\n })\n ),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Builds the URL for a single entity by appending the identifier to the endpoint.\n *\n * @param id The unique identifier to append.\n * @returns The full URL targeting the specific entity.\n */\n protected itemUrl(id: TId): string {\n return `${this.endpoint}/${id}`;\n }\n\n /**\n * Wraps a value in a `SuccessResult`.\n *\n * @template T The type of the response data.\n * @param data The response data to wrap.\n * @param meta Optional metadata (status code, headers, URL) to attach.\n * @returns A `SuccessResult` containing the provided data.\n */\n protected success<T>(data: T, meta?: ResultMeta): SuccessResult<T> {\n return {ok: true, data, meta};\n }\n\n /**\n * Wraps an error in a `FailureResult`.\n *\n * When no explicit metadata is provided, metadata is derived from\n * the `ApiError` itself (status code, headers, URL).\n *\n * @param error The structured API error.\n * @param meta Optional metadata to override the error-derived values.\n * @returns A `FailureResult` containing the error and metadata.\n */\n protected failure(error: ApiError, meta?: ResultMeta): FailureResult {\n return {\n ok: false,\n error,\n meta: meta ?? {\n statusCode: error.status ?? undefined,\n headers: error.headers,\n url: error.url ?? undefined,\n },\n };\n }\n\n /**\n * Maps an unknown error into a structured `ApiError`.\n *\n * Handles both `HttpErrorResponse` instances and unexpected error types.\n * Extracts backend messages, validation errors, and retry information\n * so callers receive a consistent error shape.\n *\n * @param error The raw error caught from the HTTP pipeline.\n * @returns A fully populated `ApiError` object.\n */\n protected mapHttpError(error: unknown): ApiError {\n const timestamp = new Date().toISOString();\n\n if (!(error instanceof HttpErrorResponse)) {\n return {\n status: null,\n message: 'Unknown error',\n original: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n timestamp,\n };\n }\n\n const status = this.normalizeStatus(error.status);\n const details = error.error;\n const backendMessage = this.extractBackendMessage(details);\n const validationErrors = this.extractValidationErrors(details);\n\n return {\n status,\n message: backendMessage ?? this.defaultMessage(status),\n details,\n backendMessage,\n validationErrors,\n url: error.url,\n headers: error.headers,\n original: error,\n retryable: this.isRetryable(status),\n timestamp,\n };\n }\n\n /**\n * Extracts a human-readable message from the error response body.\n *\n * Checks common keys (`message`, `title`, `detail`, `error`) on the\n * body object and returns the first non-empty string found.\n *\n * @param body The parsed error response body.\n * @returns The extracted message, or `undefined` if none was found.\n */\n protected extractBackendMessage(body: unknown): string | undefined {\n if (typeof body === 'string' && body.trim()) {\n return body;\n }\n\n if (!body || typeof body !== 'object') {\n return undefined;\n }\n\n const obj = body as Record<string, unknown>;\n\n for (const key of ['message', 'title', 'detail', 'error']) {\n const value = obj[key];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n return undefined;\n }\n\n /**\n * Extracts field-level validation errors from the error response body.\n *\n * Expects an `errors` property on the body containing a record of\n * field names to error messages (string or string array).\n *\n * @param body The parsed error response body.\n * @returns A record mapping field names to their error messages, or `undefined` if none were found.\n */\n protected extractValidationErrors(body: unknown): Record<string, string[]> | undefined {\n if (!body || typeof body !== 'object') {\n return undefined;\n }\n\n const obj = body as Record<string, unknown>;\n const errors = obj['errors'];\n\n if (!errors || typeof errors !== 'object') {\n return undefined;\n }\n\n const result: Record<string, string[]> = {};\n\n for (const [key, value] of Object.entries(errors as Record<string, unknown>)) {\n if (Array.isArray(value)) {\n result[key] = value.map(String);\n } else if (typeof value === 'string') {\n result[key] = [value];\n }\n }\n return Object.keys(result).length ? result : undefined;\n }\n\n /**\n * Returns a default user-facing message for the given HTTP status code.\n *\n * Provides human-readable messages for common HTTP status codes.\n * Override this method to customise messages.\n *\n * @param status The HTTP status code, or `null` when unknown.\n * @returns A descriptive error message.\n */\n protected defaultMessage(status: HttpStatusCode | null): string {\n switch (status) {\n case HttpStatusCode.BadRequest:\n return 'Bad request';\n case HttpStatusCode.Unauthorized:\n return 'Unauthorized';\n case HttpStatusCode.Forbidden:\n return 'Forbidden';\n case HttpStatusCode.NotFound:\n return 'Not found';\n case HttpStatusCode.Conflict:\n return 'Conflict';\n case HttpStatusCode.UnprocessableEntity:\n return 'Unprocessable entity';\n case HttpStatusCode.InternalServerError:\n return 'Internal server error';\n case null:\n return 'Unknown error';\n default:\n return `Request failed with status ${status}`;\n }\n }\n\n /**\n * Determines whether a request with the given status can be retried.\n *\n * Timeouts, rate-limiting responses, and server errors\n * (5xx) are considered retryable by default.\n *\n * @param status The HTTP status code, or `null` when unknown.\n * @returns `true` if the request is safe to retry.\n */\n protected isRetryable(status: HttpStatusCode | null): boolean {\n if (status === HttpStatusCode.RequestTimeout) return true;\n if (status === HttpStatusCode.TooManyRequests) return true;\n if (typeof status === 'number' && status >= 500) return true;\n return false;\n }\n\n /**\n * Normalises a raw HTTP status into an `HttpStatusCode | null` value.\n *\n * Converts `undefined`, `NaN`, and `0` (network error) to `null`\n * so downstream code only needs to handle `HttpStatusCode | null`.\n *\n * @param status The raw status value from the HTTP response.\n * @returns The normalised status code, or `null` when indeterminate.\n */\n protected normalizeStatus(status: number | null | undefined): HttpStatusCode | null {\n if (status === null || status === undefined || status === 0 || Number.isNaN(status)) return null;\n return status as HttpStatusCode;\n }\n\n /**\n * Converts query parameters into Angular `HttpParams`.\n *\n * `null` and `undefined` values are silently skipped.\n * Array values are appended as multiple entries for the same key.\n *\n * @param query The query parameter record to convert.\n * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.\n */\n protected toHttpParams(query?: QueryParams): HttpParams | undefined {\n if (!query) return undefined;\n\n let params = new HttpParams();\n\n for (const [key, rawValue] of Object.entries(query)) {\n if (rawValue === null || rawValue === undefined) continue;\n\n const values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\n for (const value of values) {\n if (value === null || value === undefined) continue;\n params = params.append(key, String(value));\n }\n }\n return params;\n }\n}\n","import {inject} from '@angular/core';\nimport {HttpClient, HttpParams} from '@angular/common/http';\nimport {firstValueFrom} from 'rxjs';\nimport {API_BASE_URL} from '../crud';\n\n/** A single query parameter value. */\ntype MnQueryValue = string | number | boolean | null | undefined;\n\n/** A record of query parameter key-value pairs. Arrays are appended as multiple entries. */\nexport type MnQueryParams = Record<string, MnQueryValue | MnQueryValue[]>;\n\n/**\n * Lightweight abstract HTTP base class that removes common boilerplate\n * from API services.\n *\n * Provides typed `get`, `post`, `patch`, `put`, and `delete` methods\n * that return Promises, automatic query-param building, and base-URL\n * injection via the `API_BASE_URL` token.\n *\n * Subclass this directly for services with static or mixed endpoints.\n * No CRUD structure is imposed — every method accepts a free-form path.\n */\nexport abstract class MnHttpService {\n /** Angular HTTP client injected automatically. */\n protected readonly http = inject(HttpClient);\n\n /** Base API URL provided via the `API_BASE_URL` injection token. */\n protected readonly baseUrl = inject(API_BASE_URL);\n\n /**\n * Sends a typed GET request.\n * @param path The path appended to the base URL.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected get<T>(path: string, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.get<T>(`${this.baseUrl}${path}`, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed POST request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected post<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.post<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed PATCH request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected patch<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.patch<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed PUT request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected put<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.put<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed DELETE request.\n * @param path The path appended to the base URL.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected delete<T = void>(path: string, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.delete<T>(`${this.baseUrl}${path}`, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Converts a query-params record to Angular `HttpParams`.\n * Null and undefined values are silently skipped.\n * Array values are appended as multiple entries for the same key.\n * @param query The query parameter record to convert.\n * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.\n */\n protected toHttpParams(query?: MnQueryParams): HttpParams | undefined {\n if (!query) return undefined;\n\n let params = new HttpParams();\n\n for (const [key, rawValue] of Object.entries(query)) {\n if (rawValue === null || rawValue === undefined) continue;\n\n const values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\n for (const value of values) {\n if (value === null || value === undefined) continue;\n params = params.append(key, String(value));\n }\n }\n\n return params;\n }\n}\n","import type { LucideIconData } from '@lucide/angular';\nimport type { IconNode } from 'lucide';\n\n/**\n * Turns icon nodes from the vanilla `lucide` package into the icon data that\n * `<svg [lucideIcon]>` (`LucideDynamicIcon`) and MnLib's icon inputs accept.\n *\n * Why not `@lucide/angular`'s per-icon components (`<svg lucideArrowLeft>`): that\n * package is a single module, and the Angular linker compiles a full copy of the\n * SVG template into every icon class, so each icon cost ~2.8 kB and all of them\n * landed in the startup chunk. With `lucide` an icon is a few hundred bytes of data, and\n * only the icons something imports are bundled. esbuild keeps all of them in one shared\n * chunk (they hang off the package's re-export barrel), about 30 kB for the whole app.\n *\n * Import the namespace and name each icon, so an icon called `Component`, `Map`\n * or `X` never shadows another import:\n *\n * ```ts\n * import * as lucide from 'lucide';\n * const ICONS = lucideIcons({ ArrowLeft: lucide.ArrowLeft, Trash2: lucide.Trash2 });\n * // template: <svg [lucideIcon]=\"icons.ArrowLeft\" [size]=\"16\"></svg>\n * ```\n *\n * @param nodes Icon nodes keyed by their PascalCase `lucide` export name.\n * @returns Icon data under the same keys, named `arrow-left`-style for the\n * `lucide-<name>` class the icon renders with.\n */\nexport function lucideIcons<K extends string>(nodes: Record<K, IconNode>): Record<K, LucideIconData> {\n const icons = {} as Record<K, LucideIconData>;\n for (const key of Object.keys(nodes) as K[]) {\n // `lucide` types attribute values as optional; its generated icon data never omits one.\n icons[key] = { name: toKebabCase(key), node: nodes[key] as LucideIconData['node'] };\n }\n return icons;\n}\n\n/**\n * Converts a PascalCase export name to Lucide's kebab-case icon name.\n * @param name Export name, e.g. `CircleCheck` or `Trash2`.\n * @returns The icon name, e.g. `circle-check` or `trash-2`.\n */\nfunction toKebabCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([a-zA-Z])(\\d)/g, '$1-$2')\n .toLowerCase();\n}\n","import { MnConfigService } from '../config/mn-config.service';\nimport { MnLanguageService } from '../language/mn-language.service';\n\nexport type MnPreviewMessage = {\n type: 'mn-config-update' | 'mn-translations-update';\n config?: Record<string, unknown>;\n translations?: Record<string, Record<string, string>>;\n}\n\n/**\n * Enable live preview mode. Listens for postMessage events from\n * Mn Web Manager and hot-swaps config/translations at runtime.\n *\n * Call this once in your app's bootstrap (e.g., APP_INITIALIZER or root component).\n *\n * @param configService - The MnConfigService instance\n * @param langService - The MnLanguageService instance\n * @param allowedOrigins - Optional whitelist of allowed origins (security)\n */\nexport function enableMnPreviewMode(\n configService: MnConfigService,\n langService: MnLanguageService,\n allowedOrigins?: string[]\n): void {\n window.addEventListener('message', async (event: MessageEvent<MnPreviewMessage>) => {\n if (allowedOrigins?.length && !allowedOrigins.includes(event.origin)) {\n return;\n }\n\n const data = event.data;\n if (!data?.type) return;\n\n switch (data.type) {\n case 'mn-config-update':\n if (data.config) {\n await configService.loadFromObject(data.config);\n }\n break;\n\n case 'mn-translations-update':\n if (data.translations) {\n for (const [locale, translations] of Object.entries(data.translations)) {\n langService.registerTranslations(locale, translations);\n }\n await langService.setLocale(langService.locale);\n }\n break;\n }\n });\n}\n"],"mappings":";;;;AAqDA,SAAgB,eAAe,OAAc;CAC3C,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAkC,kBAAkB;AAEhE;AC9CA,MAAM,gBAA8D,EAClE,KAAK,MACN;AAGD,MAAM,cAAc;AAGpB,IAAa,oBAAb,MAAa,kBAAiB;CACX,OAAO,OAAO,UAAU;CACxB,SAAS,OAAO,cAAc;CAEvC,gBAAgC,CAAA;CAChC,WAAW,IAAI,gBAAwB,IAAI;CAWlC,UAAU,OAAO,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAC/B,cAA6B;CAC7B,SAAS;CAMA,+BAAe,IAAI,IAAG;CAG9B,UAA8B,KAAK,SAAS,aAAY;CAGjE,IAAI,SAAM;EACR,OAAO,KAAK,QAAO;CACrB;CAKA,SAAS,SAAgB;EACvB,KAAK,SAAS;EACd,IAAI,SACF,QAAQ,IAAI,iCAAiC;CAEjD;CAMA,UAAU,YAAkB;EAC1B,IAAI,KAAK,QACP,QAAQ,IAAI,uCAAuC,YAAY;EAEjE,KAAK,cAAc;CACrB;CAMA,MAAM,WAAW,QAAc;EAC7B,IAAI,KAAK,cAAc,SAAS;EAEhC,IAAI,CAAC,KAAK,aAAa;GACrB,QAAQ,KAAK,sFAAsF;GACnG;EACF;EAEA,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ACT;AACD;ACpGD,SAAgB,YAA8B,OAA0B;CACtE,MAAM,QAAQ,CAAA;CACd,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAEjC,MAAM,OAAO;EAAE,MAAM,YAAY,GAAG;EAAG,MAAM,MAAM;CAA8B;CAEnF,OAAO;AACT;AAOA,SAAS,YAAY,MAAY;CAC/B,OAAO,KACJ,QAAQ,sBAAsB,OAAO,CAAC,CACtC,QAAQ,mBAAmB,OAAO,CAAC,CACnC,YAAW;AAChB;AC3BA,SAAgB,oBACd,eACA,aACA,gBAAyB;CAEzB,OAAO,iBAAiB,WAAW,OAAO,UAAyC;EACjF,IAAI,gBAAgB,UAAU,CAAC,eAAe,SAAS,MAAM,MAAM,GACjE;EAGF,MAAM,OAAO,MAAM;EACnB,IAAI,CAAC,MAAM,MAAM;EAEjB,QAAQ,KAAK,MAAb;GACE,KAAK;IACH,IAAI,KAAK,QACP,MAAM,cAAc,eAAe,KAAK,MAAM;IAEhD;GAEF,KAAK,0BACH,IAAI,KAAK,cAAc;IACrB,KAAK,MAAM,CAAC,QAAQ,iBAAiB,OAAO,QAAQ,KAAK,YAAY,GACnE,YAAY,qBAAqB,QAAQ,YAAY;IAEvD,MAAM,YAAY,UAAU,YAAY,MAAM;GAChD;EAEJ;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"mn-angular-lib-core.mjs","names":[],"sources":["../../../projects/mn-angular-lib/core/src/language/mn-language.types.ts","../../../projects/mn-angular-lib/core/src/language/mn-language.service.ts","../../../projects/mn-angular-lib/core/src/language/mn-language.providers.ts","../../../projects/mn-angular-lib/core/src/language/mn-translate.pipe.ts","../../../projects/mn-angular-lib/core/src/config/mn-config.service.ts","../../../projects/mn-angular-lib/core/src/config/mn-config.providers.ts","../../../projects/mn-angular-lib/core/src/context/mn-context.tokens.ts","../../../projects/mn-angular-lib/core/src/config/mn-component-config.providers.ts","../../../projects/mn-angular-lib/core/src/context/mn-section.directive.ts","../../../projects/mn-angular-lib/core/src/context/mn-instance.directive.ts","../../../projects/mn-angular-lib/core/src/shared/crud/crud.tokens.ts","../../../projects/mn-angular-lib/core/src/shared/crud/crud.service.ts","../../../projects/mn-angular-lib/core/src/shared/http/mn-http.service.ts","../../../projects/mn-angular-lib/core/src/shared/icons/lucide-icons.ts","../../../projects/mn-angular-lib/core/src/preview/mn-preview-listener.ts"],"sourcesContent":["/**\n * A marker object used in config values to indicate that the value\n * should be resolved via the MnLanguageService.\n *\n * Example in mn-config.json5:\n * label: { $translate: \"form.email.label\" }\n */\nexport type MnTranslatable = {\n $translate: string;\n params?: Record<string, string | number>;\n}\n\n/**\n * A config value that is either a plain value or a translatable marker.\n */\nexport type MnConfigValue<T = string> = T | MnTranslatable;\n\n/**\n * Translations for a single locale, as a tree of keys.\n *\n * Both shapes resolve through the same dotted lookup: a bundle may nest\n * (`{ form: { email: { label } } }`), flatten (`{ \"form.email.label\": … }`), or mix the two.\n */\nexport type MnTranslationMap = { [key: string]: string | MnTranslationMap };\n\n/**\n * All loaded translations keyed by locale code (e.g. \"en\", \"nl\", \"de\").\n */\nexport type MnTranslations = Record<string, MnTranslationMap>;\n\n/**\n * Configuration for the language provider.\n */\nexport type MnLanguageConfig = {\n /** URL pattern for loading translation files. Use `{locale}` as placeholder. e.g. \"assets/i18n/{locale}.json\" */\n urlPattern: string;\n /** The default/fallback locale. */\n defaultLocale: string;\n /** Locales to preload at bootstrap. */\n preload?: string[];\n /**\n * Optional mapping of domain hostnames to locale codes.\n * When set, the service will use the current domain to determine the initial locale.\n * Example: { \"example.nl\": \"nl\", \"example.de\": \"de\", \"example.com\": \"en\" }\n */\n domainLocaleMap?: Record<string, string>;\n /** Whether to enable debug logging. */\n debug?: boolean;\n}\n\n/**\n * Type guard: checks whether a value is a translatable marker object.\n */\nexport function isTranslatable(value: unknown): value is MnTranslatable {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<string, unknown>)['$translate'] === 'string'\n );\n}\n","import {ApplicationRef, inject, Injectable, signal} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {BehaviorSubject, firstValueFrom, Observable} from 'rxjs';\nimport {MnTranslationMap, MnTranslations} from './mn-language.types';\n\n/**\n * Key suffix per CLDR plural category.\n *\n * Only `one` earns a suffix: every locale shipped so far (`en`, `nl`) has exactly the two\n * categories `one` and `other`, and `other` keeps the bare key. A locale with `few`/`many`\n * (Polish, Russian, Arabic) resolves those to the plural until an entry is added here —\n * adding one is the whole change, since the lookup is category-driven already.\n */\nconst PLURAL_SUFFIX: Partial<Record<Intl.LDMLPluralRule, string>> = {\n one: 'One',\n};\n\n/** Params key whose presence turns a translation into a plural-aware lookup. */\nconst COUNT_PARAM = 'count';\n\n@Injectable({ providedIn: 'root' })\nexport class MnLanguageService {\n private readonly http = inject(HttpClient);\n private readonly appRef = inject(ApplicationRef);\n\n private _translations: MnTranslations = {};\n private _locale$ = new BehaviorSubject<string>('en');\n\n /**\n * The active locale as a signal, read by {@link locale} and so by every lookup.\n *\n * Components are OnPush, and `setLocale` only ran one `appRef.tick()`, which skips every view\n * nobody marked: a tab bar, a card heading or a bar label kept the old language until the page\n * was reloaded. A signal read while a template renders (through the `mnTranslate` pipe, or a\n * getter calling `translate`) is tracked by that view, so switching the locale marks exactly\n * the views that translated something, and a `computed` built on `translate` recomputes.\n */\n private readonly _locale = signal('en');\n\n /**\n * Bumped whenever translations are registered at runtime, and read by every lookup, for the same\n * reason as {@link _locale}: live preview registers new texts for the locale already active, so\n * without this no view that translated something would know to render again.\n */\n private readonly _revision = signal(0);\n private _urlPattern: string | null = null;\n private _debug = false;\n\n /**\n * `Intl.PluralRules` per locale. Cached because {@link translate} runs on every change\n * detection through the impure `mnTranslate` pipe, and constructing one is not cheap.\n */\n private readonly _pluralRules = new Map<string, Intl.PluralRules | null>();\n\n /** Observable of the current active locale. */\n readonly locale$: Observable<string> = this._locale$.asObservable();\n\n /** Current active locale. */\n get locale(): string {\n return this._locale();\n }\n\n /**\n * Enable or disable debug logging.\n */\n setDebug(enabled: boolean): void {\n this._debug = enabled;\n if (enabled) {\n console.log(`[MnLanguage] Debug mode enabled`);\n }\n }\n\n /**\n * Configure the URL pattern used to fetch translation files.\n * Use `{locale}` as placeholder, e.g. `\"assets/i18n/{locale}.json\"`.\n */\n configure(urlPattern: string): void {\n if (this._debug) {\n console.log(`[MnLanguage] Configured urlPattern: ${urlPattern}`);\n }\n this._urlPattern = urlPattern;\n }\n\n /**\n * Load translations for a locale from the configured URL pattern.\n * If translations are already loaded for this locale, this is a no-op.\n */\n async loadLocale(locale: string): Promise<void> {\n if (this._translations[locale]) return;\n\n if (!this._urlPattern) {\n console.warn(`[MnLanguage] No URL pattern configured. Call configure() or use provideMnLanguage().`);\n return;\n }\n\n const url = this._urlPattern.replace('{locale}', locale);\n if (this._debug) {\n console.log(`[MnLanguage] Loading locale \"${locale}\" from ${url}`);\n }\n\n try {\n const map = await firstValueFrom(\n this.http.get<MnTranslationMap>(url)\n );\n this._translations[locale] = map ?? {};\n if (this._debug) {\n console.log(`[MnLanguage] Loaded locale \"${locale}\"`, this._translations[locale]);\n }\n } catch (err) {\n console.warn(`[MnLanguage] Failed to load translations from ${url}`, err);\n this._translations[locale] = {};\n }\n }\n\n /**\n * Switch the active locale. Loads translations if not yet loaded.\n */\n async setLocale(locale: string): Promise<void> {\n if (this._debug) {\n console.log(`[MnLanguage] Setting locale to \"${locale}\"`);\n }\n await this.loadLocale(locale);\n this._locale.set(locale);\n this._locale$.next(locale);\n this.appRef.tick();\n }\n\n /**\n * Register translations for a locale directly from code (no HTTP needed).\n */\n registerTranslations(locale: string, translations: MnTranslationMap): void {\n this._translations[locale] = {\n ...(this._translations[locale] ?? {}),\n ...translations,\n };\n this._revision.update(v => v + 1);\n }\n\n /**\n * Translate a key using the current locale, with optional parameter interpolation.\n * Falls back to the key itself if no translation is found.\n *\n * Interpolation replaces `{{paramName}}` with the provided value.\n *\n * A `count` param additionally selects the wording that agrees with it: the key is\n * resolved against its CLDR plural category first (`key` + `One`/`Two`/`Few`/`Many`/\n * `Zero`), falling back to `key` when that sibling is undefined. Nothing has to opt in —\n * a key with no sibling behaves exactly as before.\n *\n * ```ts\n * // 'shift.asked' → '{{count}} members are notified'\n * // 'shift.askedOne' → '{{count}} member is notified'\n * lang.translate('shift.asked', { count: 3 }); // 3 members are notified\n * lang.translate('shift.asked', { count: 1 }); // 1 member is notified\n * ```\n */\n translate(key: string, params?: Record<string, string | number>): string {\n this._revision();\n const map = this._translations[this.locale] ?? {};\n let value = this.getValueFromMap(map, this.resolvePluralKey(map, key, params));\n\n if (value === undefined) {\n if (this._debug) {\n console.warn(`[MnLanguage] Missing translation for key: \"${key}\" in locale: \"${this.locale}\"`);\n }\n return key;\n }\n\n if (params) {\n for (const [paramKey, paramValue] of Object.entries(params)) {\n value = value.replace(new RegExp(`\\\\{\\\\{${paramKey}\\\\}\\\\}`, 'g'), String(paramValue));\n }\n }\n\n return value;\n }\n\n /**\n * Picks the wording that agrees with a `count` param.\n *\n * A key carrying a count resolves against its CLDR plural category first, so\n * `askedMessage` + `askedMessageOne` render \"3 leden krijgen bericht\" and \"1 lid krijgt\n * bericht\" off the same call. Both languages change the verb as well as the noun, which\n * is why each form is a whole sentence under its own key rather than a swapped noun.\n *\n * Falls back to `key` whenever the sibling is undefined, so a key that never needed a\n * plural — or an app that has not written one yet — behaves exactly as it did before.\n * @param map The active locale's translations.\n * @param key The dot-notated translation key.\n * @param params The interpolation values, inspected for `count`.\n * @returns The key to look up: the plural sibling, or `key` itself.\n */\n private resolvePluralKey(\n map: MnTranslationMap,\n key: string,\n params?: Record<string, string | number>,\n ): string {\n const raw = params?.[COUNT_PARAM];\n if (raw === undefined) return key;\n\n // A count off a JSON payload arrives as a string often enough that comparing it\n // strictly would silently pick the plural for a count of one.\n const count = Number(raw);\n if (!Number.isFinite(count)) return key;\n\n const suffix = PLURAL_SUFFIX[this.pluralCategory(count)];\n if (suffix === undefined) return key;\n\n const variant = key + suffix;\n return this.getValueFromMap(map, variant) !== undefined ? variant : key;\n }\n\n /**\n * The CLDR plural category of a count in the active locale.\n * @param count The count being quoted.\n * @returns The category, falling back to English rules for an unusable locale.\n */\n private pluralCategory(count: number): Intl.LDMLPluralRule {\n if (!this._pluralRules.has(this.locale)) {\n try {\n this._pluralRules.set(this.locale, new Intl.PluralRules(this.locale));\n } catch {\n // An unknown or malformed locale tag: fall back rather than break every string.\n this._pluralRules.set(this.locale, null);\n }\n }\n const rules = this._pluralRules.get(this.locale);\n if (!rules) return count === 1 ? 'one' : 'other';\n return rules.select(count);\n }\n\n /**\n * Helper to retrieve a value from a potentially nested translation map using a dot-notated key.\n */\n private getValueFromMap(map: MnTranslationMap, key: string): string | undefined {\n // A flattened bundle holds the dotted key verbatim; a nested one is walked below.\n const direct = map[key];\n if (typeof direct === 'string') return direct;\n\n const parts = key.split('.');\n let current: MnTranslationMap | string | undefined = map;\n\n for (const part of parts) {\n if (current === null || typeof current !== 'object') return undefined;\n current = current[part];\n }\n\n return typeof current === 'string' ? current : undefined;\n }\n\n /**\n * Translate a key **only if it is defined**, returning `undefined` otherwise.\n *\n * {@link translate} deliberately returns the key itself when it is missing, which\n * makes it unusable for a library's own default labels: a consumer that never\n * defined `mnCollection.rowsPerPage` would see that raw string in their UI. This\n * lets a caller try a conventional key and fall back to a readable English default\n * when the app has not translated it, so components ship translatable strings\n * without forcing every consumer to define them.\n *\n * @param key The dot-notated translation key.\n * @param params Optional `{{name}}` interpolation values.\n * @returns The translation, or `undefined` when the key is not defined.\n */\n translateIfPresent(key: string, params?: Record<string, string | number>): string | undefined {\n // Read here too: a key that is missing now may arrive with the next registerTranslations.\n this._revision();\n const map = this._translations[this.locale] ?? {};\n if (this.getValueFromMap(map, key) === undefined) return undefined;\n return this.translate(key, params);\n }\n\n /**\n * Shorthand alias for `translate`.\n */\n t(key: string, params?: Record<string, string | number>): string {\n return this.translate(key, params);\n }\n\n /**\n * Resolve the effective default locale from a domain-to-locale map.\n * Matches `window.location.hostname` against the map keys.\n * Returns the mapped locale, or the provided fallback if no match is found.\n */\n resolveLocaleForDomain(domainLocaleMap: Record<string, string> | undefined, fallback: string): string {\n if (!domainLocaleMap || typeof window === 'undefined') return fallback;\n const hostname = window.location.hostname;\n return domainLocaleMap[hostname] ?? fallback;\n }\n}\n","import { APP_INITIALIZER, Provider } from '@angular/core';\nimport { MnLanguageService } from './mn-language.service';\nimport { MnLanguageConfig } from './mn-language.types';\n\n/**\n * Provides an APP_INITIALIZER that configures the MnLanguageService and\n * preloads the requested locales during application bootstrap.\n *\n * Usage in app.config.ts:\n * ...provideMnLanguage({\n * urlPattern: 'assets/i18n/{locale}.json',\n * defaultLocale: 'en',\n * preload: ['en', 'nl'],\n * })\n */\nexport function provideMnLanguage(config: MnLanguageConfig): Provider[] {\n return [\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: (svc: MnLanguageService) => async () => {\n if (config.debug) {\n svc.setDebug(true);\n }\n svc.configure(config.urlPattern);\n\n const effectiveLocale = svc.resolveLocaleForDomain(config.domainLocaleMap, config.defaultLocale);\n const localesToLoad = config.preload ?? [effectiveLocale];\n await Promise.all(localesToLoad.map(l => svc.loadLocale(l)));\n await svc.setLocale(effectiveLocale);\n },\n deps: [MnLanguageService],\n },\n ];\n}\n","import {Pipe, PipeTransform, inject} from '@angular/core';\nimport { MnLanguageService } from './mn-language.service';\n\n/**\n * Pipe that translates a key via MnLanguageService.\n *\n * Usage in templates:\n * {{ 'form.email.label' | mnTranslate }}\n * {{ 'greeting' | mnTranslate:{ name: 'World' } }}\n *\n * Note: This pipe is impure so it re-evaluates when the locale changes.\n */\n@Pipe({\n name: 'mnTranslate',\n standalone: true,\n pure: false,\n})\nexport class MnTranslatePipe implements PipeTransform {\n private readonly lang = inject(MnLanguageService);\n\n\n transform(key: string, params?: Record<string, string | number>): string {\n return this.lang.translate(key, params);\n }\n}\n","import {inject, Injectable, signal} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {firstValueFrom} from 'rxjs';\nimport {MnConfigFile, MnConfigSettings} from './mn-config.types';\nimport {isTranslatable, MnLanguageConfig, MnLanguageService} from '../language';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Parses a config file. Strict JSON goes through `JSON.parse`; only a file that needs JSON5\n * syntax (comments, unquoted keys, trailing commas) loads the `json5` parser, as its own chunk.\n * A static import put the CommonJS `json5` package (~32 kB) into every consumer's startup bundle.\n *\n * @param text The raw file content.\n * @returns The parsed value.\n */\nexport async function parseConfigText(text: string): Promise<unknown> {\n try {\n return JSON.parse(text);\n } catch {\n const { default: JSON5 } = await import('json5');\n return JSON5.parse(text);\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class MnConfigService {\n private readonly http = inject(HttpClient);\n\n private _config: MnConfigFile | null = null;\n private _settings: MnConfigSettings = {};\n private _debugMode = false;\n\n /** Reactive version counter — incremented on every config load. */\n private _configVersion = signal(0);\n readonly configVersion = this._configVersion.asReadonly();\n\n private readonly lang = inject(MnLanguageService);\n\n /** General settings from the config file (version, name, etc.). */\n get settings(): Readonly<MnConfigSettings> {\n return this._settings;\n }\n\n /**\n * Load the configuration JSON from the provided URL and cache it in memory.\n * Consumers should typically call this via the APP_INITIALIZER helper.\n */\n async load(url: string, debugMode = false): Promise<void> {\n this._debugMode = debugMode;\n this.lang.setDebug(debugMode);\n let text: string;\n\n try {\n text = await firstValueFrom(\n this.http.get(url, { responseType: 'text' })\n );\n } catch (err) {\n console.warn(`[MnConfig] Failed to load config from ${url}`, err);\n this._config = { defaults: {}, overrides: {} };\n return;\n }\n\n let json: unknown;\n\n try {\n json = await parseConfigText(text);\n } catch (err) {\n console.warn(`[MnConfig] Failed to parse JSON5 from ${url}`, err, text);\n json = {};\n }\n\n const cfg = (isPlainObject(json) ? json : {}) as Record<string, unknown>;\n const defaults = isPlainObject(cfg['defaults']) ? cfg['defaults'] : {};\n const overrides: Record<string, unknown> = isPlainObject(cfg['overrides']) ? cfg['overrides'] : {};\n\n const settings: MnConfigSettings = isPlainObject(cfg['settings']) ? cfg['settings'] as MnConfigSettings : {};\n\n this._config = { settings, defaults, overrides };\n this._settings = settings;\n\n // Bootstrap language service from config if a \"language\" section is present.\n // This avoids circular dependency: config reads raw language settings and\n // pushes them into the language service (language service never imports config).\n const langCfg = cfg['language'];\n if (isPlainObject(langCfg) && typeof langCfg['urlPattern'] === 'string') {\n const lc = langCfg as MnLanguageConfig;\n if (this._debugMode) {\n console.log(`[MnConfig] Applying language config from file`, lc);\n }\n this.lang.configure(lc.urlPattern);\n const effectiveLocale = this.lang.resolveLocaleForDomain(lc.domainLocaleMap, lc.defaultLocale);\n const localesToLoad = Array.from(new Set([...(lc.preload ?? []), effectiveLocale]));\n await Promise.all(localesToLoad.map(l => this.lang.loadLocale(l)));\n await this.lang.setLocale(effectiveLocale);\n }\n\n this._configVersion.update(v => v + 1);\n }\n\n /**\n * Load configuration from a pre-parsed object (no HTTP fetch).\n * Used for live preview scenarios where config is pushed via postMessage.\n * Optionally re-bootstraps the language service if a `language` section is present.\n */\n async loadFromObject(config: Record<string, unknown>, bootstrapLanguage = false): Promise<void> {\n const defaults = isPlainObject(config['defaults']) ? config['defaults'] : {};\n const overrides = isPlainObject(config['overrides']) ? config['overrides'] : {};\n const settings: MnConfigSettings = isPlainObject(config['settings']) ? config['settings'] as MnConfigSettings : {};\n\n this._config = { settings, defaults, overrides };\n this._settings = settings;\n\n if (bootstrapLanguage) {\n const langCfg = config['language'];\n if (isPlainObject(langCfg) && typeof langCfg['urlPattern'] === 'string') {\n const lc = langCfg as MnLanguageConfig;\n if (this._debugMode) {\n console.log(`[MnConfig] Applying language config from object`, lc);\n }\n this.lang.configure(lc.urlPattern);\n const effectiveLocale = this.lang.resolveLocaleForDomain(lc.domainLocaleMap, lc.defaultLocale);\n const localesToLoad = Array.from(new Set([...(lc.preload ?? []), effectiveLocale]));\n await Promise.all(localesToLoad.map(l => this.lang.loadLocale(l)));\n await this.lang.setLocale(effectiveLocale);\n }\n }\n\n this._configVersion.update(v => v + 1);\n }\n\n\n /**\n * Resolve a configuration object for a component, optionally scoped to a section path\n * and optionally overridden by an instance id.\n */\n resolve<T extends object = Record<string, unknown>>(\n componentName: string,\n sectionPath: string[] = [],\n instanceId?: string,\n ): T {\n const baseConfig: Record<string, unknown> = isPlainObject(this._config?.defaults)\n ? (isPlainObject((this._config as MnConfigFile).defaults[componentName])\n ? { ...(this._config as MnConfigFile).defaults[componentName] as Record<string, unknown> }\n : {})\n : {};\n\n const leaf = this.walkOverrides(this._config?.overrides ?? {}, sectionPath);\n\n let resolved: Record<string, unknown> = baseConfig;\n\n if (leaf && isPlainObject((leaf as Record<string, unknown>)[componentName])) {\n resolved = this.deepMerge(resolved, (leaf as Record<string, unknown>)[componentName] as Record<string, unknown>);\n }\n\n if (instanceId) {\n const instKey = `#${instanceId}`;\n if (leaf && isPlainObject((leaf as Record<string, unknown>)[instKey])) {\n resolved = this.deepMerge(resolved, (leaf as Record<string, unknown>)[instKey] as Record<string, unknown>);\n }\n }\n\n if (this._debugMode) {\n console.debug(`[MnConfig] Resolving for ${componentName}`, {\n sectionPath,\n instanceId,\n resolved,\n });\n }\n\n return this.resolveTranslatables(resolved) as T;\n }\n\n /**\n * Walk the overrides nested object using the provided section path and return the leaf node.\n * If any segment is missing or the current node is not a plain object, returns undefined.\n */\n walkOverrides(overridesRoot: unknown, sectionPath: string[]): unknown | undefined {\n let node: unknown = overridesRoot;\n for (const segment of sectionPath) {\n if (!isPlainObject(node)) return undefined;\n node = (node as Record<string, unknown>)[segment];\n if (node === undefined) return undefined;\n }\n return node;\n }\n\n /**\n * Recursively walk a resolved config object and replace any `{ $translate: \"key\" }` markers\n * with their translated values from MnLanguageService.\n */\n private resolveTranslatables(obj: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (isTranslatable(value)) {\n out[key] = this.lang.translate(value.$translate, value.params);\n } else if (Array.isArray(value)) {\n out[key] = value.map(item => {\n if (isTranslatable(item)) {\n return this.lang.translate(item.$translate, item.params);\n } else if (isPlainObject(item)) {\n return this.resolveTranslatables(item as Record<string, unknown>);\n }\n return item;\n });\n } else if (isPlainObject(value)) {\n out[key] = this.resolveTranslatables(value as Record<string, unknown>);\n } else {\n out[key] = value;\n }\n }\n return out;\n }\n\n /**\n * Deep merge two plain-object trees. Arrays and non-plain values are replaced by the patch.\n * Does not mutate inputs; returns a new object.\n */\n deepMerge<A extends Record<string, unknown>, B extends Record<string, unknown>>(base: A, patch: B): A & B {\n const out: Record<string, unknown> = {...base};\n for (const key of Object.keys(patch)) {\n const bVal = base[key];\n const pVal = patch[key];\n\n if (isPlainObject(bVal) && isPlainObject(pVal)) {\n out[key] = this.deepMerge(bVal, pVal);\n } else {\n // replace for arrays, primitives, null, undefined, and non-plain objects\n out[key] = pVal;\n }\n }\n return out as A & B;\n }\n}\n","import { APP_INITIALIZER, Provider } from '@angular/core';\nimport { MnConfigService } from './mn-config.service';\n\n/**\n * Provides an APP_INITIALIZER that loads the mn-lib configuration from the given URL\n * during application bootstrap. The consuming application is responsible for providing\n * HttpClient (e.g., via HttpClientModule or provideHttpClient()).\n */\nexport function provideMnConfig(url: string, debugMode = false): Provider[] {\n return [\n {\n provide: APP_INITIALIZER,\n multi: true,\n useFactory: (svc: MnConfigService) => () => svc.load(url, debugMode),\n deps: [MnConfigService],\n },\n ];\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * Represents the current section path based on nested mn-section directives.\n */\nexport const MN_SECTION_PATH = new InjectionToken<string[]>(\n 'MN_SECTION_PATH',\n {\n providedIn: 'root',\n factory: () => [],\n },\n);\n\n/**\n * Whether the injecting component renders inside an mn modal. `MnModalShellComponent` provides\n * `true` for everything in its view, so a component deep in a modal body can tell without the\n * consumer passing anything: mn-table uses it to skip its own bottom sheet, because a sheet\n * opened over a modal that is already a sheet on a phone stacks two drawers on one screen.\n */\nexport const MN_IN_MODAL = new InjectionToken<boolean>(\n 'MN_IN_MODAL',\n {\n providedIn: 'root',\n factory: () => false,\n },\n);\n\n/**\n * Whether the injecting component renders inside an `mn-bottom-sheet`. The sheet provides `true`\n * to its content. mn-select and mn-multi-select read it: on a phone they normally open their\n * options as a bottom sheet of their own, which inside a sheet stacks a second one on top and\n * hides the form around it, so there they open as an anchored dropdown instead.\n */\nexport const MN_IN_BOTTOM_SHEET = new InjectionToken<boolean>(\n 'MN_IN_BOTTOM_SHEET',\n {\n providedIn: 'root',\n factory: () => false,\n },\n);\n\n/**\n * Represents the current component instance id provided by [mn-instance].\n */\nexport const MN_INSTANCE_ID = new InjectionToken<string | null>(\n 'MN_INSTANCE_ID',\n {\n providedIn: 'root',\n factory: () => null,\n },\n);\n","import { DestroyRef, InjectionToken, Optional, Provider } from '@angular/core';\nimport { MN_INSTANCE_ID, MN_SECTION_PATH } from '../context/mn-context.tokens';\nimport { MnConfigService } from './mn-config.service';\nimport { MnLanguageService } from '../language/mn-language.service';\n\n/**\n * Helper to provide a resolved, typed component config via DI.\n *\n * Usage in a component/module providers:\n * const MY_CFG = new InjectionToken<MyCfg>('MY_CFG');\n * providers: [ provideMnComponentConfig(MY_CFG, 'my-component') ]\n * Then in the component:\n * readonly cfg = inject(MY_CFG)\n *\n * The returned config object is **reactive**: when the active locale changes,\n * all translatable values are re-resolved in place so that templates using\n * `cfg.someLabel` automatically reflect the new language on the next change-detection cycle.\n */\nexport function provideMnComponentConfig<T extends object>(\n token: InjectionToken<T>,\n componentName: string,\n initial?: Partial<T>,\n): Provider {\n return {\n provide: token,\n deps: [\n MnConfigService,\n MnLanguageService,\n DestroyRef,\n [new Optional(), MN_SECTION_PATH],\n [new Optional(), MN_INSTANCE_ID],\n ],\n useFactory: (\n svc: MnConfigService,\n lang: MnLanguageService,\n destroyRef: DestroyRef,\n sectionPath: string[] | null,\n instanceId: string | null,\n ): T => {\n const resolveConfig = (): T => {\n const resolved = svc.resolve<T>(componentName, sectionPath ?? [], instanceId ?? undefined);\n return Object.assign({}, initial ?? {}, resolved);\n };\n\n // Create the initial config object that will be shared by reference.\n const cfg = resolveConfig();\n\n // Re-resolve translatable values whenever the locale changes.\n // skip(1) because the current locale was already used for the initial resolve.\n const sub = lang.locale$.subscribe(() => {\n const updated = resolveConfig();\n // Mutate the existing object in place so all template bindings pick up the new values.\n for (const key of Object.keys(updated)) {\n (cfg as Record<string, unknown>)[key] = (updated as Record<string, unknown>)[key];\n }\n });\n\n destroyRef.onDestroy(() => sub.unsubscribe());\n\n return cfg;\n },\n };\n}\n","import { Attribute, Directive, Input, Optional, SkipSelf } from '@angular/core';\nimport { MN_SECTION_PATH } from './mn-context.tokens';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector -- kebab-case is intentional: matches the Attribute() token and is stable public API\n selector: '[mn-section]',\n standalone: true,\n providers: [\n {\n provide: MN_SECTION_PATH,\n // Read parent MN_SECTION_PATH from ancestor injector (skipSelf to avoid self-reference),\n // and read the attribute value using Attribute so it's available at provider creation time.\n deps: [[new Optional(), new SkipSelf(), MN_SECTION_PATH], new Attribute('mn-section')],\n useFactory: (parentPath: string[] | null, attr: string | null) => {\n const parent = Array.isArray(parentPath) ? parentPath : [];\n const name = (attr ?? '').trim();\n return name ? [...parent, name] : [...parent];\n },\n },\n ],\n})\nexport class MnSectionDirective {\n /** Section name contributed by this DOM node to the section path */\n @Input('mn-section') mnSection: string | undefined;\n}\n","import { Attribute, Directive, Input } from '@angular/core';\nimport { MN_INSTANCE_ID } from './mn-context.tokens';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector -- kebab-case is intentional: matches the Attribute() token and is stable public API\n selector: '[mn-instance]',\n standalone: true,\n providers: [\n {\n provide: MN_INSTANCE_ID,\n // Read the attribute at provider creation time using Attribute token; Inputs may not be set yet.\n deps: [new Attribute('mn-instance')],\n useFactory: (attr: string | null) => (attr ?? '').trim() || null,\n },\n ],\n})\nexport class MnInstanceDirective {\n /** Instance id for targeting per-component instance overrides */\n @Input('mn-instance') mnInstance: string | undefined;\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * Injection token for the base URL used by all CRUD service requests.\n *\n * Provide this token at the application or module level to configure\n * the root API URL that `CrudService` prepends to every endpoint.\n */\nexport const API_BASE_URL = new InjectionToken<string>('API_BASE_URL');\n","import {inject} from '@angular/core';\nimport {ApiError, FailureResult, QueryParams, Result, ResultMeta, SuccessResult} from './crud.model';\nimport {catchError, map, Observable, of} from 'rxjs';\nimport {HttpClient, HttpErrorResponse, HttpParams, HttpResponse, HttpStatusCode} from '@angular/common/http';\nimport {API_BASE_URL} from './crud.tokens';\n\n/**\n * Configuration for a CRUD service endpoint.\n *\n * Passed to the `CrudService` constructor to define which API\n * resource the service operates on.\n */\nexport type CrudConfig = {\n endpoint: string;\n}\n\n/**\n * Abstract base class for CRUD services.\n * Provides standard HTTP operations with typed `Result<T>` responses.\n *\n * @template TEntity The entity type returned by single-item operations.\n * @template TListResponse The response type for list operations (defaults to `TEntity[]`).\n * @template TCreatePayload The payload type for create operations (defaults to `Partial<TEntity>`).\n * @template TUpdatePayload The payload type for update operations (defaults to `Partial<TEntity>`).\n * @template TId The type of the entity identifier (defaults to `number`).\n * @template TGetByIdResponse The response type for getById (defaults to `TEntity`).\n * @template TCreateResponse The response type for create (defaults to `TEntity`).\n * @template TUpdateResponse The response type for update and patch (defaults to `TEntity`).\n * @template TDeleteResponse The response type for delete (defaults to `void`).\n */\nexport abstract class CrudService<\n TEntity,\n TListResponse = TEntity[],\n TCreatePayload = Partial<TEntity>,\n TUpdatePayload = Partial<TEntity>,\n TId extends string | number = number,\n TGetByIdResponse = TEntity,\n TCreateResponse = TEntity,\n TUpdateResponse = TEntity,\n TDeleteResponse = void\n> {\n protected readonly http = inject(HttpClient);\n protected readonly baseUrl = inject(API_BASE_URL);\n protected readonly endpoint: string;\n\n protected constructor(config: CrudConfig) {\n this.endpoint = `${this.baseUrl}${config.endpoint}`;\n }\n\n /**\n * Retrieves all entities from the configured endpoint.\n *\n * Sends a GET request to the base endpoint. Query values are\n * converted to `HttpParams` before the request is sent.\n *\n * @param query Optional query parameters appended to the request URL.\n * @returns An observable emitting a `Result` with the list response or a structured failure.\n */\n getAll(query?: QueryParams): Observable<Result<TListResponse>> {\n return this.http\n .get<TListResponse>(this.endpoint, {\n params: this.toHttpParams(query)\n })\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Retrieves a single entity by its identifier.\n *\n * Sends a GET request to `{endpoint}/{id}`.\n *\n * @param id The unique identifier of the entity to retrieve.\n * @returns An observable emitting a `Result` with the entity or a structured failure.\n */\n getById(id: TId): Observable<Result<TGetByIdResponse>> {\n return this.http\n .get<TGetByIdResponse>(this.itemUrl(id))\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Creates a new entity at the configured endpoint.\n *\n * Sends a POST request with the provided payload as the request body.\n *\n * @param payload The data used to create the entity.\n * @returns An observable emitting a `Result` with the created entity or a structured failure.\n */\n create(payload: TCreatePayload): Observable<Result<TCreateResponse>> {\n return this.http\n .post<TCreateResponse>(this.endpoint, payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Fully replaces an existing entity.\n *\n * Sends a PUT request to `{endpoint}/{id}` with the provided payload,\n * replacing the entire entity.\n *\n * @param id The unique identifier of the entity to update.\n * @param payload The complete data to replace the existing entity with.\n * @returns An observable emitting a `Result` with the updated entity or a structured failure.\n */\n update(id: TId, payload: TUpdatePayload): Observable<Result<TUpdateResponse>> {\n return this.http\n .put<TUpdateResponse>(this.itemUrl(id), payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Partially updates an existing entity.\n *\n * Sends a PATCH request to `{endpoint}/{id}` with the provided payload,\n * merging changes into the existing entity.\n *\n * @param id The unique identifier of the entity to patch.\n * @param payload A partial set of fields to update on the existing entity.\n * @returns An observable emitting a `Result` with the updated entity or a structured failure.\n */\n patch(id: TId, payload: Partial<TUpdatePayload>): Observable<Result<TUpdateResponse>> {\n return this.http\n .patch<TUpdateResponse>(this.itemUrl(id), payload)\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Deletes an entity by its identifier.\n *\n * Sends a DELETE request to `{endpoint}/{id}`.\n *\n * @param id The unique identifier of the entity to delete.\n * @returns An observable emitting a `Result` with the delete response or a structured failure.\n */\n delete(id: TId): Observable<Result<TDeleteResponse>> {\n return this.http\n .delete<TDeleteResponse>(this.itemUrl(id))\n .pipe(\n map((data) => this.success(data)),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Retrieves all entities with the full `HttpResponse` wrapper.\n *\n * Behaves like {@link getAll} but observes the complete HTTP response,\n * giving access to headers, status code, and URL alongside the body.\n *\n * @param query Optional query parameters appended to the request URL.\n * @returns An observable emitting a `Result` with the full HTTP response or a structured failure.\n */\n getAllResponse(query?: QueryParams): Observable<Result<HttpResponse<TListResponse>>> {\n return this.http\n .get<TListResponse>(this.endpoint, {\n params: this.toHttpParams(query),\n observe: 'response',\n })\n .pipe(\n map((response) =>\n this.success(response, {\n statusCode: response.status,\n headers: response.headers,\n url: response.url ?? undefined,\n })\n ),\n catchError((error) => of(this.failure(this.mapHttpError(error))))\n );\n }\n\n /**\n * Builds the URL for a single entity by appending the identifier to the endpoint.\n *\n * @param id The unique identifier to append.\n * @returns The full URL targeting the specific entity.\n */\n protected itemUrl(id: TId): string {\n return `${this.endpoint}/${id}`;\n }\n\n /**\n * Wraps a value in a `SuccessResult`.\n *\n * @template T The type of the response data.\n * @param data The response data to wrap.\n * @param meta Optional metadata (status code, headers, URL) to attach.\n * @returns A `SuccessResult` containing the provided data.\n */\n protected success<T>(data: T, meta?: ResultMeta): SuccessResult<T> {\n return {ok: true, data, meta};\n }\n\n /**\n * Wraps an error in a `FailureResult`.\n *\n * When no explicit metadata is provided, metadata is derived from\n * the `ApiError` itself (status code, headers, URL).\n *\n * @param error The structured API error.\n * @param meta Optional metadata to override the error-derived values.\n * @returns A `FailureResult` containing the error and metadata.\n */\n protected failure(error: ApiError, meta?: ResultMeta): FailureResult {\n return {\n ok: false,\n error,\n meta: meta ?? {\n statusCode: error.status ?? undefined,\n headers: error.headers,\n url: error.url ?? undefined,\n },\n };\n }\n\n /**\n * Maps an unknown error into a structured `ApiError`.\n *\n * Handles both `HttpErrorResponse` instances and unexpected error types.\n * Extracts backend messages, validation errors, and retry information\n * so callers receive a consistent error shape.\n *\n * @param error The raw error caught from the HTTP pipeline.\n * @returns A fully populated `ApiError` object.\n */\n protected mapHttpError(error: unknown): ApiError {\n const timestamp = new Date().toISOString();\n\n if (!(error instanceof HttpErrorResponse)) {\n return {\n status: null,\n message: 'Unknown error',\n original: error instanceof Error ? error : new Error(String(error)),\n retryable: false,\n timestamp,\n };\n }\n\n const status = this.normalizeStatus(error.status);\n const details = error.error;\n const backendMessage = this.extractBackendMessage(details);\n const validationErrors = this.extractValidationErrors(details);\n\n return {\n status,\n message: backendMessage ?? this.defaultMessage(status),\n details,\n backendMessage,\n validationErrors,\n url: error.url,\n headers: error.headers,\n original: error,\n retryable: this.isRetryable(status),\n timestamp,\n };\n }\n\n /**\n * Extracts a human-readable message from the error response body.\n *\n * Checks common keys (`message`, `title`, `detail`, `error`) on the\n * body object and returns the first non-empty string found.\n *\n * @param body The parsed error response body.\n * @returns The extracted message, or `undefined` if none was found.\n */\n protected extractBackendMessage(body: unknown): string | undefined {\n if (typeof body === 'string' && body.trim()) {\n return body;\n }\n\n if (!body || typeof body !== 'object') {\n return undefined;\n }\n\n const obj = body as Record<string, unknown>;\n\n for (const key of ['message', 'title', 'detail', 'error']) {\n const value = obj[key];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n return undefined;\n }\n\n /**\n * Extracts field-level validation errors from the error response body.\n *\n * Expects an `errors` property on the body containing a record of\n * field names to error messages (string or string array).\n *\n * @param body The parsed error response body.\n * @returns A record mapping field names to their error messages, or `undefined` if none were found.\n */\n protected extractValidationErrors(body: unknown): Record<string, string[]> | undefined {\n if (!body || typeof body !== 'object') {\n return undefined;\n }\n\n const obj = body as Record<string, unknown>;\n const errors = obj['errors'];\n\n if (!errors || typeof errors !== 'object') {\n return undefined;\n }\n\n const result: Record<string, string[]> = {};\n\n for (const [key, value] of Object.entries(errors as Record<string, unknown>)) {\n if (Array.isArray(value)) {\n result[key] = value.map(String);\n } else if (typeof value === 'string') {\n result[key] = [value];\n }\n }\n return Object.keys(result).length ? result : undefined;\n }\n\n /**\n * Returns a default user-facing message for the given HTTP status code.\n *\n * Provides human-readable messages for common HTTP status codes.\n * Override this method to customise messages.\n *\n * @param status The HTTP status code, or `null` when unknown.\n * @returns A descriptive error message.\n */\n protected defaultMessage(status: HttpStatusCode | null): string {\n switch (status) {\n case HttpStatusCode.BadRequest:\n return 'Bad request';\n case HttpStatusCode.Unauthorized:\n return 'Unauthorized';\n case HttpStatusCode.Forbidden:\n return 'Forbidden';\n case HttpStatusCode.NotFound:\n return 'Not found';\n case HttpStatusCode.Conflict:\n return 'Conflict';\n case HttpStatusCode.UnprocessableEntity:\n return 'Unprocessable entity';\n case HttpStatusCode.InternalServerError:\n return 'Internal server error';\n case null:\n return 'Unknown error';\n default:\n return `Request failed with status ${status}`;\n }\n }\n\n /**\n * Determines whether a request with the given status can be retried.\n *\n * Timeouts, rate-limiting responses, and server errors\n * (5xx) are considered retryable by default.\n *\n * @param status The HTTP status code, or `null` when unknown.\n * @returns `true` if the request is safe to retry.\n */\n protected isRetryable(status: HttpStatusCode | null): boolean {\n if (status === HttpStatusCode.RequestTimeout) return true;\n if (status === HttpStatusCode.TooManyRequests) return true;\n if (typeof status === 'number' && status >= 500) return true;\n return false;\n }\n\n /**\n * Normalises a raw HTTP status into an `HttpStatusCode | null` value.\n *\n * Converts `undefined`, `NaN`, and `0` (network error) to `null`\n * so downstream code only needs to handle `HttpStatusCode | null`.\n *\n * @param status The raw status value from the HTTP response.\n * @returns The normalised status code, or `null` when indeterminate.\n */\n protected normalizeStatus(status: number | null | undefined): HttpStatusCode | null {\n if (status === null || status === undefined || status === 0 || Number.isNaN(status)) return null;\n return status as HttpStatusCode;\n }\n\n /**\n * Converts query parameters into Angular `HttpParams`.\n *\n * `null` and `undefined` values are silently skipped.\n * Array values are appended as multiple entries for the same key.\n *\n * @param query The query parameter record to convert.\n * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.\n */\n protected toHttpParams(query?: QueryParams): HttpParams | undefined {\n if (!query) return undefined;\n\n let params = new HttpParams();\n\n for (const [key, rawValue] of Object.entries(query)) {\n if (rawValue === null || rawValue === undefined) continue;\n\n const values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\n for (const value of values) {\n if (value === null || value === undefined) continue;\n params = params.append(key, String(value));\n }\n }\n return params;\n }\n}\n","import {inject} from '@angular/core';\nimport {HttpClient, HttpParams} from '@angular/common/http';\nimport {firstValueFrom} from 'rxjs';\nimport {API_BASE_URL} from '../crud';\n\n/** A single query parameter value. */\ntype MnQueryValue = string | number | boolean | null | undefined;\n\n/** A record of query parameter key-value pairs. Arrays are appended as multiple entries. */\nexport type MnQueryParams = Record<string, MnQueryValue | MnQueryValue[]>;\n\n/**\n * Lightweight abstract HTTP base class that removes common boilerplate\n * from API services.\n *\n * Provides typed `get`, `post`, `patch`, `put`, and `delete` methods\n * that return Promises, automatic query-param building, and base-URL\n * injection via the `API_BASE_URL` token.\n *\n * Subclass this directly for services with static or mixed endpoints.\n * No CRUD structure is imposed — every method accepts a free-form path.\n */\nexport abstract class MnHttpService {\n /** Angular HTTP client injected automatically. */\n protected readonly http = inject(HttpClient);\n\n /** Base API URL provided via the `API_BASE_URL` injection token. */\n protected readonly baseUrl = inject(API_BASE_URL);\n\n /**\n * Sends a typed GET request.\n * @param path The path appended to the base URL.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected get<T>(path: string, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.get<T>(`${this.baseUrl}${path}`, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed POST request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected post<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.post<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed PATCH request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected patch<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.patch<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed PUT request.\n * @param path The path appended to the base URL.\n * @param body Optional request body.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected put<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.put<T>(`${this.baseUrl}${path}`, body ?? {}, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Sends a typed DELETE request.\n * @param path The path appended to the base URL.\n * @param query Optional query parameters.\n * @returns A promise resolving to the typed response body.\n */\n protected delete<T = void>(path: string, query?: MnQueryParams): Promise<T> {\n return firstValueFrom(\n this.http.delete<T>(`${this.baseUrl}${path}`, {\n params: this.toHttpParams(query),\n }),\n );\n }\n\n /**\n * Converts a query-params record to Angular `HttpParams`.\n * Null and undefined values are silently skipped.\n * Array values are appended as multiple entries for the same key.\n * @param query The query parameter record to convert.\n * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.\n */\n protected toHttpParams(query?: MnQueryParams): HttpParams | undefined {\n if (!query) return undefined;\n\n let params = new HttpParams();\n\n for (const [key, rawValue] of Object.entries(query)) {\n if (rawValue === null || rawValue === undefined) continue;\n\n const values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\n for (const value of values) {\n if (value === null || value === undefined) continue;\n params = params.append(key, String(value));\n }\n }\n\n return params;\n }\n}\n","import type { LucideIconData } from '@lucide/angular';\nimport type { IconNode } from 'lucide';\n\n/**\n * Turns icon nodes from the vanilla `lucide` package into the icon data that\n * `<svg [lucideIcon]>` (`LucideDynamicIcon`) and MnLib's icon inputs accept.\n *\n * Why not `@lucide/angular`'s per-icon components (`<svg lucideArrowLeft>`): that\n * package is a single module, and the Angular linker compiles a full copy of the\n * SVG template into every icon class, so each icon cost ~2.8 kB and all of them\n * landed in the startup chunk. With `lucide` an icon is a few hundred bytes of data, and\n * only the icons something imports are bundled. esbuild keeps all of them in one shared\n * chunk (they hang off the package's re-export barrel), about 30 kB for the whole app.\n *\n * Import the namespace and name each icon, so an icon called `Component`, `Map`\n * or `X` never shadows another import:\n *\n * ```ts\n * import * as lucide from 'lucide';\n * const ICONS = lucideIcons({ ArrowLeft: lucide.ArrowLeft, Trash2: lucide.Trash2 });\n * // template: <svg [lucideIcon]=\"icons.ArrowLeft\" [size]=\"16\"></svg>\n * ```\n *\n * @param nodes Icon nodes keyed by their PascalCase `lucide` export name.\n * @returns Icon data under the same keys, named `arrow-left`-style for the\n * `lucide-<name>` class the icon renders with.\n */\nexport function lucideIcons<K extends string>(nodes: Record<K, IconNode>): Record<K, LucideIconData> {\n const icons = {} as Record<K, LucideIconData>;\n for (const key of Object.keys(nodes) as K[]) {\n // `lucide` types attribute values as optional; its generated icon data never omits one.\n icons[key] = { name: toKebabCase(key), node: nodes[key] as LucideIconData['node'] };\n }\n return icons;\n}\n\n/**\n * Converts a PascalCase export name to Lucide's kebab-case icon name.\n * @param name Export name, e.g. `CircleCheck` or `Trash2`.\n * @returns The icon name, e.g. `circle-check` or `trash-2`.\n */\nfunction toKebabCase(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([a-zA-Z])(\\d)/g, '$1-$2')\n .toLowerCase();\n}\n","import { MnConfigService } from '../config/mn-config.service';\nimport { MnLanguageService } from '../language/mn-language.service';\n\n/** What the editor posts into the previewed site. */\nexport type MnPreviewMessage = {\n type: 'mn-config-update' | 'mn-translations-update' | 'mn-preview-edit-mode';\n config?: Record<string, unknown>;\n translations?: Record<string, Record<string, string>>;\n /** For `mn-preview-edit-mode`: whether clicks pick content instead of following links. */\n enabled?: boolean;\n}\n\n/**\n * What the previewed site posts to the editor.\n *\n * - `mn-preview-ready`: the listener is registered, so content posted from now on arrives (a\n * message sent earlier is lost). Sent once, and again after every page change.\n * - `mn-preview-select`: in edit mode, the visitor clicked a text or an image. `text` is the text\n * under the pointer (whitespace collapsed), `context` the whole text of the element around it;\n * for an image, `src` is the URL the page asked for. The editor works out which key or config\n * value that is: the site only knows what it rendered.\n */\nexport type MnPreviewEvent =\n | { type: 'mn-preview-ready'; locale: string; path: string }\n | { type: 'mn-preview-select'; kind: 'text'; text: string; context: string; locale: string; path: string }\n | { type: 'mn-preview-select'; kind: 'image'; src: string; alt: string; locale: string; path: string };\n\n/** The outline shown on what a click would pick. */\nconst HOVER_ATTR = 'data-mn-preview-hover';\nconst STYLE_ID = 'mn-preview-edit-style';\n/** How far up from the element under the pointer a text is looked for. */\nconst MAX_TEXT_DEPTH = 4;\n\n/**\n * Enable live preview mode. Listens for postMessage events from\n * Mn Web Manager and hot-swaps config/translations at runtime.\n *\n * Call this once in your app's bootstrap (e.g., APP_INITIALIZER or root component), in the\n * browser only and only inside a frame.\n *\n * Besides swapping content it tells the editor when it is ready (`mn-preview-ready`), and in edit\n * mode (`mn-preview-edit-mode`) it outlines the text or image under the pointer and reports a\n * click on it (`mn-preview-select`) instead of following it, so the owner can click what they want\n * to change.\n *\n * @param configService - The MnConfigService instance\n * @param langService - The MnLanguageService instance\n * @param allowedOrigins - The editor origins that may change this frame's content. Give at least\n * one: with none, any page that frames the site may rewrite it in that frame, and the site's own\n * messages go to any parent.\n */\nexport function enableMnPreviewMode(\n configService: MnConfigService,\n langService: MnLanguageService,\n allowedOrigins?: string[]\n): void {\n const origins = allowedOrigins?.length ? allowedOrigins : null;\n /** The editor that switched edit mode on; selections go back to it alone. */\n let editorOrigin: string | null = null;\n\n const post = (message: MnPreviewEvent, origin?: string | null) => {\n if (window.parent === window) return;\n // To each allowed origin: the browser drops it for every origin that isn't the parent's.\n for (const target of origin ? [origin] : (origins ?? ['*'])) {\n window.parent.postMessage(message, target);\n }\n };\n const where = () => ({ locale: langService.locale, path: location.pathname });\n\n window.addEventListener('message', async (event: MessageEvent<MnPreviewMessage>) => {\n if (origins && !origins.includes(event.origin)) {\n return;\n }\n\n const data = event.data;\n if (!data?.type) return;\n\n switch (data.type) {\n case 'mn-config-update':\n if (data.config) {\n await configService.loadFromObject(data.config);\n }\n break;\n\n case 'mn-translations-update':\n if (data.translations) {\n for (const [locale, translations] of Object.entries(data.translations)) {\n langService.registerTranslations(locale, translations);\n }\n await langService.setLocale(langService.locale);\n }\n break;\n\n case 'mn-preview-edit-mode':\n editorOrigin = event.origin && event.origin !== 'null' ? event.origin : null;\n setEditMode(!!data.enabled, selection => post({ ...selection, ...where() } as MnPreviewEvent, editorOrigin));\n break;\n }\n });\n\n post({ type: 'mn-preview-ready', ...where() });\n // A single-page app changes pages without loading one; tell the editor, which posts the draft\n // again and keeps its address bar in step.\n let lastPath = location.pathname;\n const onNavigate = () => {\n if (location.pathname === lastPath) return;\n lastPath = location.pathname;\n post({ type: 'mn-preview-ready', ...where() });\n };\n window.addEventListener('popstate', onNavigate);\n for (const method of ['pushState', 'replaceState'] as const) {\n const original = history[method].bind(history);\n history[method] = (...args: Parameters<History['pushState']>) => {\n original(...args);\n onNavigate();\n };\n }\n}\n\ntype Selection =\n | { type: 'mn-preview-select'; kind: 'text'; text: string; context: string }\n | { type: 'mn-preview-select'; kind: 'image'; src: string; alt: string };\n\nlet editListeners: { over: (e: MouseEvent) => void; click: (e: MouseEvent) => void } | null = null;\n\n/** Switches edit mode on or off; `report` receives every pick. */\nfunction setEditMode(enabled: boolean, report: (selection: Selection) => void): void {\n if (editListeners) {\n document.removeEventListener('mouseover', editListeners.over, true);\n document.removeEventListener('click', editListeners.click, true);\n editListeners = null;\n }\n document.querySelectorAll(`[${HOVER_ATTR}]`).forEach(el => el.removeAttribute(HOVER_ATTR));\n document.getElementById(STYLE_ID)?.remove();\n if (!enabled) return;\n\n const style = document.createElement('style');\n style.id = STYLE_ID;\n style.textContent =\n `[${HOVER_ATTR}]{outline:2px dashed #0ea5e9 !important;outline-offset:2px !important;cursor:pointer !important}`;\n document.head.appendChild(style);\n\n let hovered: Element | null = null;\n const over = (e: MouseEvent) => {\n const target = pickTarget(e.target);\n if (target === hovered) return;\n hovered?.removeAttribute(HOVER_ATTR);\n hovered = target;\n hovered?.setAttribute(HOVER_ATTR, '');\n };\n const click = (e: MouseEvent) => {\n const selection = describe(e);\n if (!selection) return;\n // The owner is picking what to edit: a link or button must not act.\n e.preventDefault();\n e.stopPropagation();\n report(selection);\n };\n document.addEventListener('mouseover', over, true);\n document.addEventListener('click', click, true);\n editListeners = { over, click };\n}\n\n/** The element a click at `target` would pick: an image, or the nearest element with text of its own. */\nfunction pickTarget(target: EventTarget | null): Element | null {\n if (!(target instanceof Element)) return null;\n if (imageSource(target)) return target;\n let el: Element | null = target;\n for (let depth = 0; el && depth < MAX_TEXT_DEPTH; depth++, el = el.parentElement) {\n if (ownText(el)) return el;\n }\n return null;\n}\n\nfunction describe(e: MouseEvent): Selection | null {\n const target = pickTarget(e.target);\n if (!target) return null;\n const src = imageSource(target);\n if (src) {\n return { type: 'mn-preview-select', kind: 'image', src, alt: target.getAttribute('alt') ?? '' };\n }\n const text = textAtPoint(e.clientX, e.clientY, target) || ownText(target);\n const context = collapse((target as HTMLElement).innerText ?? target.textContent ?? '').slice(0, 1000);\n return text ? { type: 'mn-preview-select', kind: 'text', text, context } : null;\n}\n\n/** An `<img>`'s source, or a `background-image` URL; '' for anything else. */\nfunction imageSource(el: Element): string {\n if (el instanceof HTMLImageElement) return el.getAttribute('src') || el.currentSrc || el.src;\n const bg = getComputedStyle(el).backgroundImage;\n const match = /url\\([\"']?(.*?)[\"']?\\)/.exec(bg ?? '');\n return match?.[1] ?? '';\n}\n\n/** The element's own text, not its children's. */\nfunction ownText(el: Element): string {\n let text = '';\n for (const node of Array.from(el.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) text += node.textContent ?? '';\n }\n return collapse(text);\n}\n\n/** The text node right under the pointer, when it lies inside `within`. */\nfunction textAtPoint(x: number, y: number, within: Element): string {\n const doc = document as Document & {\n caretPositionFromPoint?: (x: number, y: number) => { offsetNode: Node } | null;\n caretRangeFromPoint?: (x: number, y: number) => Range | null;\n };\n const node = doc.caretPositionFromPoint?.(x, y)?.offsetNode ?? doc.caretRangeFromPoint?.(x, y)?.startContainer;\n if (!node || node.nodeType !== Node.TEXT_NODE || !within.contains(node)) return '';\n return collapse(node.textContent ?? '');\n}\n\nfunction collapse(text: string): string {\n return text.replace(/\\s+/g, ' ').trim();\n}\n"],"mappings":";;;;AAqDA,SAAgB,eAAe,OAAc;CAC3C,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAkC,kBAAkB;AAEhE;AC9CA,MAAM,gBAA8D,EAClE,KAAK,MACN;AAGD,MAAM,cAAc;AAGpB,IAAa,oBAAb,MAAa,kBAAiB;CACX,OAAO,OAAO,UAAU;CACxB,SAAS,OAAO,cAAc;CAEvC,gBAAgC,CAAA;CAChC,WAAW,IAAI,gBAAwB,IAAI;CAWlC,UAAU,OAAO,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAOtB,YAAY,OAAO,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAC9B,cAA6B;CAC7B,SAAS;CAMA,+BAAe,IAA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OAAuB,aAAa,OAAO,eAAe,EAAE,CAAC,CAAC,MAAM,GAAG,GAAI;CACrG,OAAO,OAAO;EAAE,MAAM;EAAqB,MAAM;EAAQ;EAAM;CAAO,IAAK;AAC7E;AAGA,SAAS,YAAY,IAAW;CAC9B,IAAI,cAAc,kBAAkB,OAAO,GAAG,aAAa,KAAK,KAAK,GAAG,cAAc,GAAG;CACzF,MAAM,KAAK,iBAAiB,EAAE,CAAC,CAAC;CAEhC,OADc,yBAAyB,KAAK,MAAM,EAC3C,CAAA,GAAQ,MAAM;AACvB;AAGA,SAAS,QAAQ,IAAW;CAC1B,IAAI,OAAO;CACX,KAAK,MAAM,QAAQ,MAAM,KAAK,GAAG,UAAU,GACzC,IAAI,KAAK,aAAa,KAAK,WAAW,QAAQ,KAAK,eAAe;CAEpE,OAAO,SAAS,IAAI;AACtB;AAGA,SAAS,YAAY,GAAW,GAAW,QAAe;CACxD,MAAM,MAAM;CAIZ,MAAM,OAAO,IAAI,yBAAyB,GAAG,CAAC,CAAC,EAAE,cAAc,IAAI,sBAAsB,GAAG,CAAC,CAAC,EAAE;CAChG,IAAI,CAAC,QAAQ,KAAK,aAAa,KAAK,aAAa,CAAC,OAAO,SAAS,IAAI,GAAG,OAAO;CAChF,OAAO,SAAS,KAAK,eAAe,EAAE;AACxC;AAEA,SAAS,SAAS,MAAY;CAC5B,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAI;AACvC"}
@@ -196,8 +196,8 @@ var MnTourOverlay = class MnTourOverlay {
196
196
  isSignal: true
197
197
  }],
198
198
  ngImport: i0,
199
- template: "<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n",
200
- styles: [":host{--mn-tour-glide: .45s;--mn-tour-fade-in: .45s;--mn-tour-fade-out: .2s;--mn-tour-content-fade: .12s;--mn-tour-glide-ease: cubic-bezier(.2, .8, .2, 1);--mn-tour-sheet-ease: cubic-bezier(.32, .72, 0, 1);--mn-tour-dim-color: rgb(15 23 42 / .55);display:contents}.mn-tour-root{position:fixed;inset:0;z-index:9990}.mn-tour-root.mn-tour-passive{pointer-events:none}.mn-tour-passive .mn-tour-card{pointer-events:auto}.mn-tour-blocker{position:fixed;inset:0}.mn-tour-dim{position:fixed;inset:0;background:var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-dim.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole{position:fixed;border-radius:14px;box-shadow:0 0 0 3px var(--color-primary),0 0 0 200vmax var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-hole.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,top var(--mn-tour-glide) var(--mn-tour-glide-ease),left var(--mn-tour-glide) var(--mn-tour-glide-ease),width var(--mn-tour-glide) var(--mn-tour-glide-ease),height var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card{position:fixed;box-sizing:border-box;padding:1.25rem;border:1px solid var(--color-base-300);border-radius:1rem;background:var(--color-base-100);box-shadow:0 20px 50px #00000047;outline:none;opacity:0;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-card.is-shown{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-card.is-shown.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,transform var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card--beside{top:0;left:0;width:max-content;min-width:min(18rem,calc(100vw - 2rem));max-width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--centred{top:50%;left:50%;transform:translate(-50%,-50%);width:min(26rem,calc(100vw - 2rem))}.mn-tour-card--corner{right:1rem;bottom:1rem;width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--sheet{right:0;bottom:0;left:0;width:auto;border-width:1px 0 0;border-radius:1rem 1rem 0 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom));animation:mn-tour-sheet-in .35s var(--mn-tour-sheet-ease)}.mn-tour-card--sheet .mn-tour-actions,.mn-tour-card--sheet .mn-tour-primary{flex:1 1 auto}.mn-tour-content{opacity:0;transition:opacity var(--mn-tour-content-fade) ease}.mn-tour-content.is-visible{opacity:1}.mn-tour-dot{display:block;width:.375rem;height:.375rem;border-radius:9999px;background:var(--color-base-300);transition:width var(--mn-tour-glide) var(--mn-tour-glide-ease),background-color var(--mn-tour-glide) ease}.mn-tour-dot.is-active{width:1rem;background:var(--color-primary)}.mn-tour-skip:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}@keyframes mn-tour-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.mn-tour-reduced *,.mn-tour-reduced{transition:none!important;animation:none!important}@media(prefers-reduced-motion:reduce){.mn-tour-root *,.mn-tour-root{transition:none!important;animation:none!important}}\n"],
199
+ template: "<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.link) {\n <button\n (click)=\"action.emit('link')\"\n class=\"mn-tour-link mt-2 inline-flex items-center gap-1 rounded text-left text-sm font-medium text-primary hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.link }}<span aria-hidden=\"true\">&rarr;</span></button>\n }\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n",
200
+ styles: [":host{--mn-tour-glide: .45s;--mn-tour-fade-in: .45s;--mn-tour-fade-out: .2s;--mn-tour-content-fade: .12s;--mn-tour-glide-ease: cubic-bezier(.2, .8, .2, 1);--mn-tour-sheet-ease: cubic-bezier(.32, .72, 0, 1);--mn-tour-dim-color: rgb(15 23 42 / .55);display:contents}.mn-tour-root{position:fixed;inset:0;z-index:9990}.mn-tour-root.mn-tour-passive{pointer-events:none}.mn-tour-passive .mn-tour-card{pointer-events:auto}.mn-tour-blocker{position:fixed;inset:0}.mn-tour-dim{position:fixed;inset:0;background:var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-dim.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole{position:fixed;border-radius:14px;box-shadow:0 0 0 3px var(--color-primary),0 0 0 200vmax var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-hole.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,top var(--mn-tour-glide) var(--mn-tour-glide-ease),left var(--mn-tour-glide) var(--mn-tour-glide-ease),width var(--mn-tour-glide) var(--mn-tour-glide-ease),height var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card{position:fixed;box-sizing:border-box;padding:1.25rem;border:1px solid var(--color-base-300);border-radius:1rem;background:var(--color-base-100);box-shadow:0 20px 50px #00000047;outline:none;opacity:0;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-card.is-shown{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-card.is-shown.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,transform var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card--beside{top:0;left:0;width:max-content;min-width:min(18rem,calc(100vw - 2rem));max-width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--centred{top:50%;left:50%;transform:translate(-50%,-50%);width:min(26rem,calc(100vw - 2rem))}.mn-tour-card--corner{right:1rem;bottom:1rem;width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--sheet{right:0;bottom:0;left:0;width:auto;border-width:1px 0 0;border-radius:1rem 1rem 0 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom));animation:mn-tour-sheet-in .35s var(--mn-tour-sheet-ease)}.mn-tour-card--sheet .mn-tour-actions,.mn-tour-card--sheet .mn-tour-primary{flex:1 1 auto}.mn-tour-content{opacity:0;transition:opacity var(--mn-tour-content-fade) ease}.mn-tour-content.is-visible{opacity:1}.mn-tour-dot{display:block;width:.375rem;height:.375rem;border-radius:9999px;background:var(--color-base-300);transition:width var(--mn-tour-glide) var(--mn-tour-glide-ease),background-color var(--mn-tour-glide) ease}.mn-tour-dot.is-active{width:1rem;background:var(--color-primary)}.mn-tour-skip:focus-visible,.mn-tour-link:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}@keyframes mn-tour-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.mn-tour-reduced *,.mn-tour-reduced{transition:none!important;animation:none!important}@media(prefers-reduced-motion:reduce){.mn-tour-root *,.mn-tour-root{transition:none!important;animation:none!important}}\n"],
201
201
  dependencies: [{
202
202
  kind: "component",
203
203
  type: MnButton,
@@ -217,8 +217,8 @@ i0.ɵɵngDeclareClassMetadata({
217
217
  selector: "mn-tour-overlay",
218
218
  standalone: true,
219
219
  imports: [MnButton],
220
- template: "<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n",
221
- styles: [":host{--mn-tour-glide: .45s;--mn-tour-fade-in: .45s;--mn-tour-fade-out: .2s;--mn-tour-content-fade: .12s;--mn-tour-glide-ease: cubic-bezier(.2, .8, .2, 1);--mn-tour-sheet-ease: cubic-bezier(.32, .72, 0, 1);--mn-tour-dim-color: rgb(15 23 42 / .55);display:contents}.mn-tour-root{position:fixed;inset:0;z-index:9990}.mn-tour-root.mn-tour-passive{pointer-events:none}.mn-tour-passive .mn-tour-card{pointer-events:auto}.mn-tour-blocker{position:fixed;inset:0}.mn-tour-dim{position:fixed;inset:0;background:var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-dim.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole{position:fixed;border-radius:14px;box-shadow:0 0 0 3px var(--color-primary),0 0 0 200vmax var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-hole.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,top var(--mn-tour-glide) var(--mn-tour-glide-ease),left var(--mn-tour-glide) var(--mn-tour-glide-ease),width var(--mn-tour-glide) var(--mn-tour-glide-ease),height var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card{position:fixed;box-sizing:border-box;padding:1.25rem;border:1px solid var(--color-base-300);border-radius:1rem;background:var(--color-base-100);box-shadow:0 20px 50px #00000047;outline:none;opacity:0;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-card.is-shown{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-card.is-shown.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,transform var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card--beside{top:0;left:0;width:max-content;min-width:min(18rem,calc(100vw - 2rem));max-width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--centred{top:50%;left:50%;transform:translate(-50%,-50%);width:min(26rem,calc(100vw - 2rem))}.mn-tour-card--corner{right:1rem;bottom:1rem;width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--sheet{right:0;bottom:0;left:0;width:auto;border-width:1px 0 0;border-radius:1rem 1rem 0 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom));animation:mn-tour-sheet-in .35s var(--mn-tour-sheet-ease)}.mn-tour-card--sheet .mn-tour-actions,.mn-tour-card--sheet .mn-tour-primary{flex:1 1 auto}.mn-tour-content{opacity:0;transition:opacity var(--mn-tour-content-fade) ease}.mn-tour-content.is-visible{opacity:1}.mn-tour-dot{display:block;width:.375rem;height:.375rem;border-radius:9999px;background:var(--color-base-300);transition:width var(--mn-tour-glide) var(--mn-tour-glide-ease),background-color var(--mn-tour-glide) ease}.mn-tour-dot.is-active{width:1rem;background:var(--color-primary)}.mn-tour-skip:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}@keyframes mn-tour-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.mn-tour-reduced *,.mn-tour-reduced{transition:none!important;animation:none!important}@media(prefers-reduced-motion:reduce){.mn-tour-root *,.mn-tour-root{transition:none!important;animation:none!important}}\n"]
220
+ template: "<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.link) {\n <button\n (click)=\"action.emit('link')\"\n class=\"mn-tour-link mt-2 inline-flex items-center gap-1 rounded text-left text-sm font-medium text-primary hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.link }}<span aria-hidden=\"true\">&rarr;</span></button>\n }\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n",
221
+ styles: [":host{--mn-tour-glide: .45s;--mn-tour-fade-in: .45s;--mn-tour-fade-out: .2s;--mn-tour-content-fade: .12s;--mn-tour-glide-ease: cubic-bezier(.2, .8, .2, 1);--mn-tour-sheet-ease: cubic-bezier(.32, .72, 0, 1);--mn-tour-dim-color: rgb(15 23 42 / .55);display:contents}.mn-tour-root{position:fixed;inset:0;z-index:9990}.mn-tour-root.mn-tour-passive{pointer-events:none}.mn-tour-passive .mn-tour-card{pointer-events:auto}.mn-tour-blocker{position:fixed;inset:0}.mn-tour-dim{position:fixed;inset:0;background:var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-dim.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole{position:fixed;border-radius:14px;box-shadow:0 0 0 3px var(--color-primary),0 0 0 200vmax var(--mn-tour-dim-color);opacity:0;pointer-events:none;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-hole.is-visible{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-hole.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,top var(--mn-tour-glide) var(--mn-tour-glide-ease),left var(--mn-tour-glide) var(--mn-tour-glide-ease),width var(--mn-tour-glide) var(--mn-tour-glide-ease),height var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card{position:fixed;box-sizing:border-box;padding:1.25rem;border:1px solid var(--color-base-300);border-radius:1rem;background:var(--color-base-100);box-shadow:0 20px 50px #00000047;outline:none;opacity:0;transition:opacity var(--mn-tour-fade-out) ease}.mn-tour-card.is-shown{opacity:1;transition:opacity var(--mn-tour-fade-in) ease-out}.mn-tour-card.is-shown.is-gliding{transition:opacity var(--mn-tour-fade-in) ease-out,transform var(--mn-tour-glide) var(--mn-tour-glide-ease)}.mn-tour-card--beside{top:0;left:0;width:max-content;min-width:min(18rem,calc(100vw - 2rem));max-width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--centred{top:50%;left:50%;transform:translate(-50%,-50%);width:min(26rem,calc(100vw - 2rem))}.mn-tour-card--corner{right:1rem;bottom:1rem;width:min(23rem,calc(100vw - 2rem))}.mn-tour-card--sheet{right:0;bottom:0;left:0;width:auto;border-width:1px 0 0;border-radius:1rem 1rem 0 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom));animation:mn-tour-sheet-in .35s var(--mn-tour-sheet-ease)}.mn-tour-card--sheet .mn-tour-actions,.mn-tour-card--sheet .mn-tour-primary{flex:1 1 auto}.mn-tour-content{opacity:0;transition:opacity var(--mn-tour-content-fade) ease}.mn-tour-content.is-visible{opacity:1}.mn-tour-dot{display:block;width:.375rem;height:.375rem;border-radius:9999px;background:var(--color-base-300);transition:width var(--mn-tour-glide) var(--mn-tour-glide-ease),background-color var(--mn-tour-glide) ease}.mn-tour-dot.is-active{width:1rem;background:var(--color-primary)}.mn-tour-skip:focus-visible,.mn-tour-link:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}@keyframes mn-tour-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.mn-tour-reduced *,.mn-tour-reduced{transition:none!important;animation:none!important}@media(prefers-reduced-motion:reduce){.mn-tour-root *,.mn-tour-root{transition:none!important;animation:none!important}}\n"]
222
222
  }]
223
223
  }],
224
224
  propDecorators: {
@@ -522,6 +522,15 @@ var MnTourService = class MnTourService {
522
522
  }
523
523
  if (s.busy) return;
524
524
  const last = this.isLastStep(s, i);
525
+ if (action === "link") {
526
+ const link = s.options.finalLink;
527
+ if (last && link) this.endTour(s, {
528
+ status: "completed",
529
+ step: i,
530
+ startNext: false
531
+ }).then(() => link.run());
532
+ return;
533
+ }
525
534
  if (action === "primary") {
526
535
  if (last) this.endTour(s, {
527
536
  status: "completed",
@@ -588,6 +597,7 @@ var MnTourService = class MnTourService {
588
597
  title: step.title,
589
598
  body: step.body,
590
599
  nextTour: withNext ? nextTour : void 0,
600
+ link: last ? s.options.finalLink?.label : void 0,
591
601
  skip: last ? void 0 : labels.skip,
592
602
  secondary: withNext ? labels.close : this.hasPrevious(s, i) ? labels.previous : void 0,
593
603
  primary: withNext ? labels.startNext : last ? labels.done : labels.next,
@@ -1 +1 @@
1
- {"version":3,"file":"mn-angular-lib-tour.mjs","names":[],"sources":["../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour.types.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-geometry.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-overlay.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-overlay.html","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour.service.ts"],"sourcesContent":["/**\n * One stop of a tour.\n *\n * The library knows nothing about routing, modules or storage: the caller passes texts that are\n * already translated, and uses {@link before} to get the page into the state the step needs\n * (navigate, switch a tab, open a drawer).\n */\nexport type MnTourStep = {\n /**\n * Value of the `data-tour` attribute on the element to highlight (`'nav-book'` highlights\n * `[data-tour=\"nav-book\"]`). Omit it for a centred card with the page dimmed, such as a\n * welcome or final card.\n */\n target?: string;\n /** Small line above the title (e.g. the tour name). */\n kicker?: string;\n /** The step's title. Also the card's accessible name. */\n title: string;\n /** Short explanation. Also the card's accessible description. */\n body: string;\n /**\n * Runs before the step is shown, after the previous step's {@link after}. Awaited, so it can\n * navigate and return once the router has settled; the tour then still waits for the target\n * to appear. A step with `before` is treated as a page change: the highlight fades out, jumps\n * and fades back in instead of gliding. A `before` that throws skips the step.\n */\n before?: () => void | Promise<void>;\n /**\n * Runs when the tour leaves this step, in either direction or because the tour ended (e.g. to\n * close a drawer that {@link before} opened). Awaited; a throw is ignored.\n */\n after?: () => void | Promise<void>;\n};\n\n/** The \"next tour\" block on a tour's final card. */\nexport type MnTourNextTour = {\n /** Heading of the block (e.g. \"Volgende rondleiding\"). */\n kicker?: string;\n /** Name of the next tour. */\n title: string;\n /** Secondary line, e.g. its length (\"7 stappen\"). */\n meta?: string;\n};\n\n/**\n * Every label the tour card renders. The library ships no strings of its own, so all of them\n * come from the caller, already translated.\n */\nexport type MnTourLabels = {\n /** The small text link at the top right that ends the tour (e.g. \"Overslaan\"). */\n skip: string;\n /** Back one step (e.g. \"Vorige\"). */\n previous: string;\n /** Forward one step (e.g. \"Volgende\"). */\n next: string;\n /** Primary button on the last step when there is no next tour (e.g. \"Klaar\"). */\n done: string;\n /** Secondary button on the last step when a next tour is offered (e.g. \"Sluiten\"). */\n close: string;\n /** Primary button on the last step when a next tour is offered (e.g. \"Start volgende\"). */\n startNext: string;\n /**\n * Screen-reader text for the progress dots, given the 1-based position and the number of\n * steps (e.g. `(n, total) => \\`Stap ${n} van ${total}\\``).\n */\n stepLabel: (step: number, total: number) => string;\n};\n\n/** What a tour is started with. */\nexport type MnTourOptions = {\n /** The stops, in order. */\n steps: readonly MnTourStep[];\n /** Every label the card renders. */\n labels: MnTourLabels;\n /** Optional block on the final card that offers the next tour. */\n nextTour?: MnTourNextTour;\n /** Index of the first step to show (default 0), e.g. to resume a tour. */\n startAt?: number;\n /** How long a step waits for its target to appear before it is skipped (default 4000 ms). */\n targetTimeoutMs?: number;\n /**\n * Called when a step is skipped because its target never appeared or its `before` threw, so\n * the app can log a stale marker.\n */\n onStepMissing?: (index: number, step: MnTourStep, reason: 'target-not-found' | 'before-failed') => void;\n};\n\n/**\n * How a tour ended. `step` is the 0-based index (into `steps`) of the step that was on screen.\n *\n * - `completed`: the last step's primary or secondary button, or Volgende when every later step\n * turned out missing (then `step` is the last step that was shown). `startNext` is true when\n * the user chose the next tour from the final card.\n * - `skipped`: the skip link, or Escape.\n * - `closed`: ended from outside through `MnTourRef.close()` (e.g. the user navigated away), or\n * by starting another tour or offer. `step` is -1 when no step had been shown yet, which also\n * happens when every step of the tour was missing: the user saw nothing, so there is nothing\n * to resume.\n */\nexport type MnTourOutcome =\n | { status: 'completed'; step: number; startNext: boolean }\n | { status: 'skipped'; step: number }\n | { status: 'closed'; step: number };\n\n/**\n * Where an offer card appears: `centred` with the page dimmed (the general tour's welcome\n * offer), or `corner`, bottom-right with the page left undimmed and usable (a module tour).\n */\nexport type MnTourOfferPlacement = 'centred' | 'corner';\n\n/** What an offer card is opened with. */\nexport type MnTourOfferOptions = {\n /** Where the card appears. */\n placement: MnTourOfferPlacement;\n /** Small line above the title. */\n kicker?: string;\n /** The offer's title (e.g. \"Rondleiding: wedstrijden organiseren\"). */\n title: string;\n /** Short explanation, e.g. the tour's length. */\n body: string;\n /** Button labels. */\n labels: {\n /** Declines the offer (e.g. \"Niet nu\"). */\n dismiss: string;\n /** Accepts it (e.g. \"Rondleiding starten\" / \"Start\"). */\n accept: string;\n };\n};\n\n/**\n * How an offer ended: `accepted` / `dismissed` by its buttons (Escape dismisses), or `closed`\n * from outside through `MnTourOfferRef.close()` without an answer.\n */\nexport type MnTourOfferOutcome = { status: 'accepted' } | { status: 'dismissed' } | { status: 'closed' };\n\n/**\n * The library's motion timings (ms). Exported so an app's own motion and tests can line up\n * with them. Under `prefers-reduced-motion` every one of them is skipped.\n */\nexport const MN_TOUR_MOTION = {\n /** The highlight and the card glide between two stops on the same page. */\n glideMs: 450,\n /** The highlight and the dim fade in after a page, tab or drawer change (ease-out). */\n fadeInMs: 450,\n /** The highlight and the dim fade out before a page change, and at the end. */\n fadeOutMs: 200,\n /** The card's content fades out, and the new content in, over this each. */\n contentFadeMs: 120,\n} as const;\n","/** A box in viewport coordinates (px), as `getBoundingClientRect()` reports it. */\nexport type MnTourBox = { top: number; left: number; width: number; height: number };\n\n/** A width and a height (px). */\nexport type MnTourSize = { width: number; height: number };\n\n/** Air (px) between the target's edge and the highlight's ring. */\nexport const TOUR_HOLE_PADDING = 6;\n/** Gap (px) between the highlight and a card placed beside it. */\nexport const TOUR_CARD_GAP = 14;\n/** Minimum distance (px) a card keeps from the viewport edge. */\nexport const TOUR_VIEWPORT_MARGIN = 16;\n\n/**\n * Grows a target's box by {@link TOUR_HOLE_PADDING} on every side, so the ring sits around the\n * element instead of on its edge.\n * @param rect The target's box.\n * @param pad Padding to add on every side.\n */\nexport function padBox(rect: MnTourBox, pad = TOUR_HOLE_PADDING): MnTourBox {\n return { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 };\n}\n\n/** Whether two boxes differ by more than half a pixel on any edge. */\nexport function boxChanged(a: MnTourBox | null, b: MnTourBox | null): boolean {\n if (!a || !b) return a !== b;\n return (\n Math.abs(a.top - b.top) > 0.5 ||\n Math.abs(a.left - b.left) > 0.5 ||\n Math.abs(a.width - b.width) > 0.5 ||\n Math.abs(a.height - b.height) > 0.5\n );\n}\n\n/** Clamps `value` into `[min, max]`, preferring `min` when the range is empty. */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max));\n}\n\n/**\n * Where a card goes beside a highlight: to the right if it fits, else left, else below, else\n * above, else (nothing fits) below and clamped into the viewport. Along the other axis the card\n * is centred on the highlight and kept {@link TOUR_VIEWPORT_MARGIN} away from the edges.\n * @param hole The highlight's box.\n * @param card The card's rendered size, padding included.\n * @param viewport The viewport's size.\n * @returns The card's top-left corner, in viewport coordinates.\n */\nexport function placeBeside(hole: MnTourBox, card: MnTourSize, viewport: MnTourSize): { x: number; y: number } {\n const m = TOUR_VIEWPORT_MARGIN;\n const gap = TOUR_CARD_GAP;\n const maxX = viewport.width - card.width - m;\n const maxY = viewport.height - card.height - m;\n const centredY = clamp(hole.top + hole.height / 2 - card.height / 2, m, maxY);\n const centredX = clamp(hole.left + hole.width / 2 - card.width / 2, m, maxX);\n\n const right = hole.left + hole.width + gap;\n if (right + card.width + m <= viewport.width) return { x: right, y: centredY };\n\n const left = hole.left - gap - card.width;\n if (left >= m) return { x: left, y: centredY };\n\n const below = hole.top + hole.height + gap;\n if (below + card.height + m <= viewport.height) return { x: centredX, y: below };\n\n const above = hole.top - gap - card.height;\n if (above >= m) return { x: centredX, y: above };\n\n return { x: centredX, y: clamp(below, m, maxY) };\n}\n\n/** Whether an element takes up space on screen (not `display: none`, not zero-sized, not hidden). */\nfunction isRendered(el: HTMLElement): boolean {\n const rect = el.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) return false;\n return getComputedStyle(el).visibility !== 'hidden';\n}\n\n/**\n * The first rendered element carrying `data-tour=\"<name>\"`, or null. A marker that exists in\n * the DOM but is not rendered (a collapsed drawer's copy of a nav item) does not count.\n * @param name The `data-tour` value.\n * @param root Where to search (default: the document).\n */\nexport function findTourTarget(name: string, root: ParentNode = document): HTMLElement | null {\n const selector = `[data-tour=\"${CSS.escape(name)}\"]`;\n for (const el of Array.from(root.querySelectorAll<HTMLElement>(selector))) {\n if (isRendered(el)) return el;\n }\n return null;\n}\n\n/** How often (ms) a waiting step re-checks its target besides reacting to DOM mutations. */\nconst TARGET_POLL_MS = 50;\n\n/**\n * Resolves with the step's target as soon as it is rendered, or with null after `timeoutMs`.\n * Reacts to DOM mutations and also polls, because an element can become rendered without a\n * mutation in its own subtree (a parent's transition ends, a stylesheet loads). Never waits a\n * fixed delay when the target is already there.\n * @param name The `data-tour` value.\n * @param timeoutMs How long to wait at most.\n * @param isCancelled Stops the wait early (resolving null) once this returns true.\n */\nexport function waitForTourTarget(\n name: string,\n timeoutMs: number,\n isCancelled: () => boolean = () => false,\n): Promise<HTMLElement | null> {\n const found = findTourTarget(name);\n if (found || timeoutMs <= 0) return Promise.resolve(found);\n\n return new Promise((resolve) => {\n let settled = false;\n const finish = (el: HTMLElement | null): void => {\n if (settled) return;\n settled = true;\n observer.disconnect();\n clearInterval(poll);\n clearTimeout(timeout);\n resolve(el);\n };\n const check = (): void => {\n if (isCancelled()) {\n finish(null);\n return;\n }\n const el = findTourTarget(name);\n if (el) finish(el);\n };\n const observer = new MutationObserver(check);\n observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true });\n const poll = setInterval(check, TARGET_POLL_MS);\n const timeout = setTimeout(() => finish(findTourTarget(name)), timeoutMs);\n });\n}\n","import { Component, computed, ElementRef, output, signal, viewChild } from '@angular/core';\nimport { MnButton, MnButtonTypes } from 'mn-angular-lib/button';\nimport { MnTourBox, MnTourSize } from './mn-tour-geometry';\nimport { MnTourNextTour } from './mn-tour.types';\n\n/**\n * How the card is placed:\n * - `beside`: next to the highlighted target (desktop);\n * - `centred`: in the middle of the viewport (welcome and final cards, centred offers);\n * - `corner`: bottom-right, for an offer that leaves the page usable;\n * - `sheet`: a bottom sheet, below the `lg` breakpoint.\n */\nexport type MnTourCardVariant = 'beside' | 'centred' | 'corner' | 'sheet';\n\n/** Which dim is on screen: none, the whole page, or everything around the highlight. */\nexport type MnTourDim = 'none' | 'full' | 'hole';\n\n/** A button or link on the card the user pressed. The service decides what it means. */\nexport type MnTourCardAction = 'skip' | 'secondary' | 'primary';\n\n/** What the card shows. Every string is the caller's, already translated. */\nexport type MnTourCardView = {\n /** Small line above the title. */\n kicker?: string;\n /** The title; the card's accessible name. */\n title: string;\n /** The body; the card's accessible description. */\n body: string;\n /** Optional \"next tour\" block above the footer. */\n nextTour?: MnTourNextTour;\n /** Label of the small skip link top right; no link when absent. */\n skip?: string;\n /** Label of the secondary (outline) button; no button when absent. */\n secondary?: string;\n /** Label of the primary button. */\n primary: string;\n /** Progress dots; none when absent. `active` is 0-based. */\n progress?: { total: number; active: number; label: string };\n};\n\n/** Counter for unique element ids, so two overlays never share an `aria-labelledby` target. */\nlet nextOverlayId = 0;\n\n/**\n * The tour's on-screen layer: the dim, the highlight around the target and the step card.\n *\n * Rendered and driven by `MnTourService`, which writes these signals; the component itself\n * holds no tour logic and only reports which control was pressed through {@link action}. It is\n * created once per tour (or offer) and stays mounted between steps, so the card never re-enters:\n * only its content crossfades.\n *\n * Motion lives in the stylesheet and is switched by classes: `is-gliding` animates the\n * highlight's and the card's position, `is-visible` / `is-shown` fade them in (450 ms ease-out)\n * and their absence fades them out (200 ms). `reducedMotion` drops every transition.\n */\n@Component({\n selector: 'mn-tour-overlay',\n standalone: true,\n imports: [MnButton],\n templateUrl: './mn-tour-overlay.html',\n styleUrl: './mn-tour-overlay.css',\n})\nexport class MnTourOverlay {\n /** What the card shows; the card is not rendered while null. */\n readonly view = signal<MnTourCardView | null>(null);\n /** Whether the card's content is faded in. Toggled around a content swap. */\n readonly contentVisible = signal(false);\n /** Whether the card itself is faded in. */\n readonly cardVisible = signal(false);\n /** How the card is placed. */\n readonly variant = signal<MnTourCardVariant>('centred');\n /** Which dim is shown. Anything but `none` also blocks clicks on the page. */\n readonly dim = signal<MnTourDim>('none');\n /** The highlight's box (target plus padding), in viewport coordinates. */\n readonly hole = signal<MnTourBox | null>(null);\n /** Whether the highlight (and its dim) is faded in. */\n readonly holeVisible = signal(false);\n /** While true, a change of the highlight's or the card's position glides instead of jumping. */\n readonly gliding = signal(false);\n /** Top-left corner of a `beside` card, in viewport coordinates. */\n readonly cardPos = signal<{ x: number; y: number } | null>(null);\n /** Turns every transition and animation off. */\n readonly reducedMotion = signal(false);\n\n /** Emitted when the user presses the skip link or one of the buttons. */\n readonly action = output<MnTourCardAction>();\n\n /** Id of the title element, the dialog's accessible name. */\n protected readonly titleId = `mn-tour-title-${nextOverlayId}`;\n /** Id of the body element, the dialog's accessible description. */\n protected readonly bodyId = `mn-tour-body-${nextOverlayId++}`;\n\n /** The primary button's look: filled, never wrapping its label. */\n protected readonly primaryButton: Partial<MnButtonTypes> = {\n variant: 'fill',\n color: 'primary',\n size: 'sm',\n borderRadius: 'lg',\n wrap: false,\n hover: true,\n };\n /** The secondary button's look: gray outline (Vorige, Sluiten, Niet nu), never wrapping. */\n protected readonly secondaryButton: Partial<MnButtonTypes> = {\n variant: 'outline',\n color: 'gray',\n size: 'sm',\n borderRadius: 'lg',\n wrap: false,\n hover: true,\n };\n\n /** The `beside` card's position as a transform, so a glide animates on the compositor. */\n protected readonly cardTransform = computed(() => {\n const pos = this.cardPos();\n return this.variant() === 'beside' && pos ? `translate(${pos.x}px, ${pos.y}px)` : null;\n });\n\n /** The card element. */\n private readonly cardRef = viewChild<ElementRef<HTMLElement>>('card');\n\n /** The card's rendered size (padding and border included), or null while it is not rendered. */\n cardSize(): MnTourSize | null {\n const el = this.cardRef()?.nativeElement;\n return el ? { width: el.offsetWidth, height: el.offsetHeight } : null;\n }\n\n /** Moves focus into the card without scrolling the page. */\n focusCard(): void {\n this.cardRef()?.nativeElement.focus({ preventScroll: true });\n }\n\n /** Whether focus is currently inside the card. */\n hasFocus(): boolean {\n return this.contains(document.activeElement);\n }\n\n /** Whether `node` lies inside the card. */\n contains(node: Node | null): boolean {\n const el = this.cardRef()?.nativeElement;\n return !!el && !!node && el.contains(node);\n }\n\n /**\n * Keeps Tab inside the card: from its last focusable control to its first and back. Focus that\n * is outside the card (or on the card itself) goes to the first or last control.\n * @param event The Tab keydown.\n */\n trapTab(event: KeyboardEvent): void {\n const el = this.cardRef()?.nativeElement;\n if (!el) return;\n const focusable = Array.from(\n el.querySelectorAll<HTMLElement>('button:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])'),\n );\n if (focusable.length === 0) {\n event.preventDefault();\n el.focus({ preventScroll: true });\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement as HTMLElement | null;\n const inside = !!active && focusable.includes(active);\n if (event.shiftKey && (!inside || active === first)) {\n event.preventDefault();\n last.focus({ preventScroll: true });\n } else if (!event.shiftKey && (!inside || active === last)) {\n event.preventDefault();\n first.focus({ preventScroll: true });\n }\n }\n\n /** The dots to render: one entry per step, true for the active one. */\n protected dots(total: number, active: number): boolean[] {\n return Array.from({ length: total }, (_, i) => i === active);\n }\n}\n","<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n","import {\n ApplicationRef,\n ComponentRef,\n createComponent,\n EnvironmentInjector,\n inject,\n Injectable,\n OnDestroy,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\nimport { boxChanged, padBox, placeBeside, waitForTourTarget } from './mn-tour-geometry';\nimport { MnTourCardAction, MnTourCardVariant, MnTourCardView, MnTourOverlay } from './mn-tour-overlay';\nimport {\n MN_TOUR_MOTION,\n MnTourOfferOptions,\n MnTourOfferOutcome,\n MnTourOptions,\n MnTourOutcome,\n} from './mn-tour.types';\n\n/** Below this width (px) the card is a bottom sheet: Tailwind's `lg` breakpoint, exclusive. */\nconst COMPACT_MAX_WIDTH = 1023.98;\n/** How long a step waits for its target by default (ms). */\nconst DEFAULT_TARGET_TIMEOUT_MS = 4000;\n/** Space (px) a scrolled-to target keeps from the viewport's edges (and from the sheet). */\nconst SCROLL_MARGIN = 16;\n\n/** A running tour, as returned by {@link MnTourService.start}. */\nexport class MnTourRef {\n /**\n * @param result Settles once, with how the tour ended.\n * @param step The 0-based index of the step on screen (-1 before the first one shows). Read it\n * synchronously to persist \"the last step reached\" when the page unloads mid-tour.\n * @param closeFn Ends the tour from outside.\n */\n constructor(\n readonly result: Promise<MnTourOutcome>,\n readonly step: Signal<number>,\n private readonly closeFn: () => void,\n ) {}\n\n /** Ends the tour without an answer from the user (outcome `closed`). Idempotent. */\n close(): void {\n this.closeFn();\n }\n}\n\n/** An open offer card, as returned by {@link MnTourService.offer}. */\nexport class MnTourOfferRef {\n /**\n * @param result Settles once, with the user's answer.\n * @param closeFn Removes the card without an answer.\n */\n constructor(\n readonly result: Promise<MnTourOfferOutcome>,\n private readonly closeFn: () => void,\n ) {}\n\n /** Removes the card without an answer (outcome `closed`). Idempotent. */\n close(): void {\n this.closeFn();\n }\n}\n\n/** State of a tour while it runs. */\ntype TourSession = {\n /** Discriminates the session union. */\n kind: 'tour';\n /** What the tour was started with. */\n options: MnTourOptions;\n /** Index of the step on screen, -1 before the first. */\n index: WritableSignal<number>;\n /** Step whose `after` still has to run, or -1. */\n pendingAfter: number;\n /** Steps found missing, left out of the dots and skipped by Vorige. */\n missing: Set<number>;\n /** The highlighted element, null on a centred step. */\n target: HTMLElement | null;\n /** True while a step change is in flight; input is ignored meanwhile. */\n busy: boolean;\n /** True once the outcome is decided. */\n ended: boolean;\n /** Settles the ref's `result`. */\n resolve: (outcome: MnTourOutcome) => void;\n};\n\n/** State of an offer while it is open. */\ntype OfferSession = {\n /** Discriminates the session union. */\n kind: 'offer';\n /** What the offer was opened with. */\n options: MnTourOfferOptions;\n /** True once answered or closed. */\n ended: boolean;\n /** Settles the ref's `result`. */\n resolve: (outcome: MnTourOfferOutcome) => void;\n};\n\n/**\n * Runs guided tours: a highlight around `[data-tour=\"…\"]` elements and a card that walks the user\n * through them, plus the offer card that proposes a tour.\n *\n * The service knows nothing about routing, modules or storage. The caller passes translated\n * texts, moves the app between steps with each step's `before()`, and persists what the returned\n * outcome reports. One tour or offer is on screen at a time; starting another closes the current\n * one. Starting a tour straight from an accepted offer (or from a final card's \"Start volgende\")\n * reuses the card already on screen instead of removing and re-adding it.\n *\n * Motion (D10): between two targets on the same page the highlight and the card glide (450 ms).\n * A step with `before()`, a step after a centred card and a step after a missing one fade the\n * highlight out (200 ms), jump, and fade in (450 ms, ease-out). The card's content crossfades\n * (120 ms out, 120 ms in). Under `prefers-reduced-motion` there is no glide and no fade.\n *\n * Keyboard: Escape skips (on an offer: declines), ArrowRight and Enter go forward, ArrowLeft goes\n * back. Focus moves into the card and returns where it was when the tour ends. The corner offer\n * is the exception: it does not take focus, because it appears unasked on a page the user is\n * working on; it is still reachable with Tab, and Escape works once focus is inside it.\n */\n@Injectable({ providedIn: 'root' })\nexport class MnTourService implements OnDestroy {\n private readonly appRef = inject(ApplicationRef);\n private readonly injector = inject(EnvironmentInjector);\n\n /** The mounted overlay, or null. */\n private overlayRef: ComponentRef<MnTourOverlay> | null = null;\n /** The tour or offer on screen, or null. */\n private session: TourSession | OfferSession | null = null;\n /** Pending fade-out or removal of the overlay. */\n private teardownTimer: ReturnType<typeof setTimeout> | null = null;\n /** Where focus was before the overlay appeared, restored when it goes. */\n private returnFocus: HTMLElement | null = null;\n /** Undoes the listeners that keep the highlight on its target. */\n private stopTrackingFn: (() => void) | null = null;\n /** Document keydown listener, registered only while the overlay exists. */\n private readonly onKeyDown = (event: KeyboardEvent): void => this.handleKey(event);\n /** Window resize listener, registered only while the overlay exists. */\n private readonly onResize = (): void => this.reposition();\n\n /**\n * Starts a tour. A tour or offer already on screen is closed first (its outcome `closed`).\n * @param options The steps, labels and optional next-tour block.\n * @returns A ref whose `result` settles with how the tour ended.\n */\n start(options: MnTourOptions): MnTourRef {\n this.closeCurrent();\n let resolve!: (outcome: MnTourOutcome) => void;\n const result = new Promise<MnTourOutcome>((r) => (resolve = r));\n const index = signal(-1);\n const session: TourSession = {\n kind: 'tour',\n options,\n index,\n pendingAfter: -1,\n missing: new Set(),\n target: null,\n busy: false,\n ended: false,\n resolve,\n };\n const ref = new MnTourRef(result, index.asReadonly(), () => {\n void this.endTour(session, { status: 'closed', step: session.index() });\n });\n\n if (options.steps.length === 0) {\n session.ended = true;\n resolve({ status: 'completed', step: -1, startNext: false });\n return ref;\n }\n\n this.session = session;\n this.ensureOverlay();\n const first = Math.min(Math.max(options.startAt ?? 0, 0), options.steps.length - 1);\n void this.go(session, first, 1);\n return ref;\n }\n\n /**\n * Shows an offer card. A tour or offer already on screen is closed first.\n * @param options Placement, texts and button labels.\n * @returns A ref whose `result` settles with the user's answer.\n */\n offer(options: MnTourOfferOptions): MnTourOfferRef {\n this.closeCurrent();\n let resolve!: (outcome: MnTourOfferOutcome) => void;\n const result = new Promise<MnTourOfferOutcome>((r) => (resolve = r));\n const session: OfferSession = { kind: 'offer', options, ended: false, resolve };\n this.session = session;\n\n const ov = this.ensureOverlay();\n const corner = options.placement === 'corner';\n ov.variant.set(this.offerVariant(options));\n ov.view.set({\n kicker: options.kicker,\n title: options.title,\n body: options.body,\n secondary: options.labels.dismiss,\n primary: options.labels.accept,\n });\n ov.dim.set(corner ? 'none' : 'full');\n ov.holeVisible.set(false);\n ov.gliding.set(false);\n ov.cardPos.set(null);\n ov.cardVisible.set(true);\n ov.contentVisible.set(true);\n this.render();\n if (!corner) ov.focusCard();\n\n return new MnTourOfferRef(result, () => this.answerOffer(session, { status: 'closed' }));\n }\n\n /** Whether a tour or an offer is on screen. */\n isActive(): boolean {\n return this.session !== null;\n }\n\n /**\n * Whether the viewport is below `lg`, where the card is a bottom sheet. Public so a test (or\n * an app with its own breakpoint logic) can override it.\n */\n isCompactViewport(): boolean {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia(`(max-width: ${COMPACT_MAX_WIDTH}px)`).matches\n : false;\n }\n\n /** Whether the user asked for reduced motion. Public so a test can override it. */\n prefersReducedMotion(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n }\n\n /** Removes the overlay if the service itself is destroyed (an app or test teardown). */\n ngOnDestroy(): void {\n this.closeCurrent();\n this.destroyOverlay();\n }\n\n /** Steps through the tour: from the current step to `to`, skipping missing steps in `dir`. */\n private async go(s: TourSession, to: number, dir: 1 | -1): Promise<void> {\n if (s.busy || s.ended) return;\n s.busy = true;\n try {\n await this.advance(s, to, dir, true);\n } finally {\n s.busy = false;\n }\n }\n\n /**\n * {@link go} without the re-entrance guard.\n * @param allowFallback When going back finds nothing, re-show the current step once.\n */\n private async advance(s: TourSession, to: number, dir: 1 | -1, allowFallback: boolean): Promise<void> {\n const steps = s.options.steps;\n const ov = this.overlay();\n const from = s.index();\n const holeWasVisible = ov.dim() === 'hole' && ov.holeVisible();\n let left = false;\n let i = to;\n\n while (i >= 0 && i < steps.length) {\n const step = steps[i];\n const glide = holeWasVisible && !left && !!step.target && !step.before;\n\n if (!left) {\n left = true;\n this.stopTracking();\n ov.contentVisible.set(false);\n if (glide) await this.wait(MN_TOUR_MOTION.contentFadeMs);\n else await this.fadeOut();\n await this.runAfter(s);\n } else {\n await this.fadeOut();\n }\n if (s.ended) return;\n\n // From here on this step owns the page state its `before` sets up, so its `after` runs\n // even if the step turns out missing or the tour ends while it is still being prepared.\n s.pendingAfter = i;\n if (step.before) {\n try {\n await step.before();\n } catch {\n this.markMissing(s, i, 'before-failed');\n await this.runAfter(s);\n i += dir;\n continue;\n }\n if (s.ended) return;\n }\n\n let target: HTMLElement | null = null;\n if (step.target) {\n target = await waitForTourTarget(\n step.target,\n s.options.targetTimeoutMs ?? DEFAULT_TARGET_TIMEOUT_MS,\n () => s.ended,\n );\n if (s.ended) return;\n if (!target) {\n this.markMissing(s, i, 'target-not-found');\n await this.runAfter(s);\n i += dir;\n continue;\n }\n }\n\n await this.present(s, i, target, glide && i === to);\n return;\n }\n\n // Ran off an end. Back means nothing earlier exists: show the step we came from (or the\n // next one that does) again. Forward means nothing is left to show: the tour is over.\n if (dir === -1 && from >= 0 && allowFallback) {\n return this.advance(s, from, 1, false);\n }\n await this.endTour(\n s,\n s.index() >= 0 ? { status: 'completed', step: s.index(), startNext: false } : { status: 'closed', step: -1 },\n );\n }\n\n /** Puts step `i` on screen: content, highlight, card position, focus and tracking. */\n private async present(s: TourSession, i: number, target: HTMLElement | null, glide: boolean): Promise<void> {\n const ov = this.overlay();\n const reduced = this.prefersReducedMotion();\n s.index.set(i);\n s.pendingAfter = i;\n s.target = target;\n\n const variant = this.stepVariant(target);\n ov.reducedMotion.set(reduced);\n ov.variant.set(variant);\n ov.view.set(this.stepView(s, i));\n ov.dim.set(target ? 'hole' : 'full');\n this.render();\n\n if (target) this.scrollIntoView(target, variant === 'sheet');\n ov.gliding.set(glide && !reduced);\n this.place(target);\n ov.holeVisible.set(!!target);\n ov.cardVisible.set(true);\n ov.contentVisible.set(true);\n this.render();\n\n if (!ov.hasFocus()) ov.focusCard();\n this.startTracking(target);\n\n if (glide && !reduced) {\n await this.wait(MN_TOUR_MOTION.glideMs);\n if (this.session === s) ov.gliding.set(false);\n }\n }\n\n /** Sets the highlight's box and, beside a target, the card's position. */\n private place(target: HTMLElement | null): void {\n const ov = this.overlay();\n if (target) ov.hole.set(padBox(target.getBoundingClientRect()));\n const hole = ov.hole();\n const size = ov.cardSize();\n if (ov.variant() === 'beside' && hole && size) {\n ov.cardPos.set(placeBeside(hole, size, { width: window.innerWidth, height: window.innerHeight }));\n } else {\n ov.cardPos.set(null);\n }\n }\n\n /**\n * Fades the highlight and the dim out (200 ms), and the card too unless it is a bottom sheet,\n * which stays put. Returns at once when nothing was visible.\n */\n private async fadeOut(): Promise<void> {\n const ov = this.overlay();\n const holeVisible = ov.dim() === 'hole' && ov.holeVisible();\n const dimVisible = ov.dim() === 'full';\n const fadeCard = ov.cardVisible() && ov.variant() !== 'sheet';\n if (!holeVisible && !dimVisible && !fadeCard) return;\n ov.gliding.set(false);\n ov.holeVisible.set(false);\n if (dimVisible) ov.dim.set('hole');\n if (fadeCard) ov.cardVisible.set(false);\n await this.wait(MN_TOUR_MOTION.fadeOutMs);\n }\n\n /** Ends a tour once: runs the current step's `after`, settles the result, removes the overlay. */\n private async endTour(s: TourSession, outcome: MnTourOutcome): Promise<void> {\n if (s.ended) return;\n s.ended = true;\n if (this.session === s) {\n this.session = null;\n this.stopTracking();\n }\n await this.runAfter(s);\n s.resolve(outcome);\n this.scheduleTeardown();\n }\n\n /** Settles an offer once and removes the overlay unless a tour takes it over. */\n private answerOffer(s: OfferSession, outcome: MnTourOfferOutcome): void {\n if (s.ended) return;\n s.ended = true;\n if (this.session === s) this.session = null;\n s.resolve(outcome);\n this.scheduleTeardown();\n }\n\n /** Closes whatever is on screen, without an answer. */\n private closeCurrent(): void {\n const s = this.session;\n if (!s) return;\n if (s.kind === 'tour') void this.endTour(s, { status: 'closed', step: s.index() });\n else this.answerOffer(s, { status: 'closed' });\n }\n\n /** Runs the `after` of the step that was last shown, once. A throw is ignored. */\n private async runAfter(s: TourSession): Promise<void> {\n const i = s.pendingAfter;\n s.pendingAfter = -1;\n const after = i >= 0 ? s.options.steps[i].after : undefined;\n if (!after) return;\n try {\n await after();\n } catch {\n // A failing clean-up must not strand the user inside the tour.\n }\n }\n\n /** Records a step as missing and tells the caller. */\n private markMissing(s: TourSession, i: number, reason: 'target-not-found' | 'before-failed'): void {\n s.missing.add(i);\n s.options.onStepMissing?.(i, s.options.steps[i], reason);\n }\n\n /** Reacts to the card's controls. */\n private onAction(action: MnTourCardAction): void {\n const s = this.session;\n if (!s) return;\n if (s.kind === 'offer') {\n if (action === 'primary') this.answerOffer(s, { status: 'accepted' });\n else if (action === 'secondary') this.answerOffer(s, { status: 'dismissed' });\n return;\n }\n const i = s.index();\n if (i < 0) return;\n if (action === 'skip') {\n void this.endTour(s, { status: 'skipped', step: i });\n return;\n }\n if (s.busy) return;\n const last = this.isLastStep(s, i);\n if (action === 'primary') {\n if (last) void this.endTour(s, { status: 'completed', step: i, startNext: !!s.options.nextTour });\n else void this.go(s, i + 1, 1);\n } else if (last && s.options.nextTour) {\n void this.endTour(s, { status: 'completed', step: i, startNext: false });\n } else if (this.hasPrevious(s, i)) {\n void this.go(s, i - 1, -1);\n }\n }\n\n /** Keyboard: Escape skips/declines, ArrowRight/Enter forward, ArrowLeft back. */\n private handleKey(event: KeyboardEvent): void {\n const s = this.session;\n const ov = this.overlayRef?.instance;\n if (!s || !ov || event.defaultPrevented || event.isComposing) return;\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n\n // A dimmed card is modal: Tab cycles inside it instead of reaching the page behind the\n // blocker, where a focused link would navigate away mid-tour. The corner offer is not modal.\n if (event.key === 'Tab') {\n if (ov.dim() !== 'none') ov.trapTab(event);\n return;\n }\n\n if (s.kind === 'offer') {\n const inScope = s.options.placement === 'centred' || ov.hasFocus();\n if (event.key === 'Escape' && inScope) {\n event.preventDefault();\n this.answerOffer(s, { status: 'dismissed' });\n }\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n this.onAction('skip');\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n this.onAction('primary');\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n // On a final card with a next tour the secondary button is Sluiten, not Vorige.\n if (!(this.isLastStep(s, s.index()) && s.options.nextTour)) this.onAction('secondary');\n } else if (event.key === 'Enter') {\n // A focused button already turns Enter into its own click; handling it here too would\n // advance twice.\n const el = event.target as HTMLElement | null;\n if (el?.closest?.('button, a, input, textarea, select')) return;\n event.preventDefault();\n this.onAction('primary');\n }\n }\n\n /** Whether step `i` is the last one. */\n private isLastStep(s: TourSession, i: number): boolean {\n return i === s.options.steps.length - 1;\n }\n\n /** Whether there is an earlier step not known to be missing. */\n private hasPrevious(s: TourSession, i: number): boolean {\n for (let j = i - 1; j >= 0; j--) if (!s.missing.has(j)) return true;\n return false;\n }\n\n /** The card's content for step `i`. */\n private stepView(s: TourSession, i: number): MnTourCardView {\n const { steps, labels, nextTour } = s.options;\n const step = steps[i];\n const last = this.isLastStep(s, i);\n const total = steps.length - s.missing.size;\n let active = i;\n for (const m of s.missing) if (m < i) active--;\n const withNext = last && !!nextTour;\n return {\n kicker: step.kicker,\n title: step.title,\n body: step.body,\n nextTour: withNext ? nextTour : undefined,\n skip: last ? undefined : labels.skip,\n secondary: withNext ? labels.close : this.hasPrevious(s, i) ? labels.previous : undefined,\n primary: withNext ? labels.startNext : last ? labels.done : labels.next,\n progress: total > 1 ? { total, active, label: labels.stepLabel(active + 1, total) } : undefined,\n };\n }\n\n /** Where a step's card goes at the current viewport width. */\n private stepVariant(target: HTMLElement | null): MnTourCardVariant {\n if (this.isCompactViewport()) return 'sheet';\n return target ? 'beside' : 'centred';\n }\n\n /** Where an offer's card goes at the current viewport width. */\n private offerVariant(options: MnTourOfferOptions): MnTourCardVariant {\n if (options.placement === 'corner') return 'corner';\n return this.isCompactViewport() ? 'sheet' : 'centred';\n }\n\n /**\n * Scrolls the target into view if it is not fully visible: centred on desktop, and clear of\n * the sheet on a phone (a temporary `scroll-margin` makes the browser leave room for it).\n */\n private scrollIntoView(target: HTMLElement, sheet: boolean): void {\n const bottomReserve = SCROLL_MARGIN + (sheet ? (this.overlay().cardSize()?.height ?? 0) : 0);\n const rect = target.getBoundingClientRect();\n if (rect.top >= SCROLL_MARGIN && rect.bottom <= window.innerHeight - bottomReserve) return;\n const { scrollMarginTop, scrollMarginBottom } = target.style;\n target.style.scrollMarginTop = `${SCROLL_MARGIN}px`;\n target.style.scrollMarginBottom = `${bottomReserve}px`;\n // 'instant', not 'auto': 'auto' follows a page's `scroll-behavior: smooth`, and the highlight\n // would then be measured mid-scroll and chase its target while fading in.\n target.scrollIntoView({ block: sheet ? 'nearest' : 'center', inline: 'nearest', behavior: 'instant' });\n target.style.scrollMarginTop = scrollMarginTop;\n target.style.scrollMarginBottom = scrollMarginBottom;\n }\n\n /**\n * Keeps the highlight on its target while the page scrolls or the target reflows. Scroll is\n * listened for on the document in the capture phase: the app's scroll container is usually a\n * layout element, whose scroll events never reach `window`.\n */\n private startTracking(target: HTMLElement | null): void {\n this.stopTracking();\n if (!target) return;\n let frame = 0;\n const update = (): void => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n this.reposition();\n });\n };\n document.addEventListener('scroll', update, { capture: true, passive: true });\n const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(update) : null;\n observer?.observe(target);\n this.stopTrackingFn = () => {\n document.removeEventListener('scroll', update, { capture: true });\n observer?.disconnect();\n if (frame) cancelAnimationFrame(frame);\n };\n }\n\n /** Undoes {@link startTracking}. */\n private stopTracking(): void {\n this.stopTrackingFn?.();\n this.stopTrackingFn = null;\n }\n\n /**\n * Re-measures after a scroll, a resize or a reflow: the card's variant (the viewport may have\n * crossed `lg`), the highlight and the card's position. A change during a glide retargets it;\n * otherwise it is instant, so the ring never lags behind the page.\n */\n private reposition(): void {\n const s = this.session;\n const ov = this.overlayRef?.instance;\n if (!s || !ov) return;\n if (s.kind === 'offer') {\n ov.variant.set(this.offerVariant(s.options));\n return;\n }\n if (s.busy && !ov.gliding()) return;\n const target = s.target;\n if (target && !target.isConnected) {\n // The page changed under the tour (e.g. browser back): hide the ring rather than point\n // at nothing. Whether to close the tour is the app's call.\n ov.holeVisible.set(false);\n return;\n }\n const variant = this.stepVariant(target);\n const moved = !target || boxChanged(ov.hole(), padBox(target.getBoundingClientRect()));\n if (variant === ov.variant() && !moved && variant !== 'beside') return;\n ov.variant.set(variant);\n this.render();\n this.place(target);\n }\n\n /** The overlay, created and attached on first use; a pending teardown is cancelled. */\n private ensureOverlay(): MnTourOverlay {\n if (this.teardownTimer) {\n clearTimeout(this.teardownTimer);\n this.teardownTimer = null;\n }\n if (this.overlayRef) return this.overlayRef.instance;\n\n const active = document.activeElement;\n this.returnFocus = active instanceof HTMLElement && active !== document.body ? active : null;\n\n const ref = createComponent(MnTourOverlay, { environmentInjector: this.injector });\n ref.instance.reducedMotion.set(this.prefersReducedMotion());\n ref.instance.action.subscribe((action) => this.onAction(action));\n this.appRef.attachView(ref.hostView);\n document.body.appendChild(ref.location.nativeElement);\n document.addEventListener('keydown', this.onKeyDown, true);\n window.addEventListener('resize', this.onResize);\n this.overlayRef = ref;\n return ref.instance;\n }\n\n /** The overlay, recreated if a teardown raced ahead of a late step. */\n private overlay(): MnTourOverlay {\n return this.overlayRef?.instance ?? this.ensureOverlay();\n }\n\n /**\n * Removes the overlay after a session ends, unless another one starts first: after a macrotask\n * (so a tour started from an accepted offer's `then` keeps the card), fade out, then destroy.\n */\n private scheduleTeardown(): void {\n if (this.teardownTimer) clearTimeout(this.teardownTimer);\n this.teardownTimer = setTimeout(() => {\n this.teardownTimer = null;\n const ov = this.overlayRef?.instance;\n if (this.session || !ov) return;\n ov.gliding.set(false);\n ov.contentVisible.set(false);\n ov.holeVisible.set(false);\n ov.cardVisible.set(false);\n if (ov.dim() === 'full') ov.dim.set('hole');\n const delay = this.prefersReducedMotion() ? 0 : MN_TOUR_MOTION.fadeOutMs;\n this.teardownTimer = setTimeout(() => {\n this.teardownTimer = null;\n if (!this.session) this.destroyOverlay();\n }, delay);\n });\n }\n\n /** Detaches and destroys the overlay, drops the listeners and gives focus back. */\n private destroyOverlay(): void {\n if (this.teardownTimer) {\n clearTimeout(this.teardownTimer);\n this.teardownTimer = null;\n }\n this.stopTracking();\n const ref = this.overlayRef;\n if (!ref) return;\n const hadFocus = ref.instance.hasFocus();\n this.overlayRef = null;\n document.removeEventListener('keydown', this.onKeyDown, true);\n window.removeEventListener('resize', this.onResize);\n this.appRef.detachView(ref.hostView);\n ref.destroy();\n ref.location.nativeElement.remove();\n const back = this.returnFocus;\n this.returnFocus = null;\n if (back?.isConnected && (hadFocus || document.activeElement === document.body)) {\n back.focus({ preventScroll: true });\n }\n }\n\n /** Synchronously renders the overlay, so it can be measured right after a state change. */\n private render(): void {\n this.overlayRef?.changeDetectorRef.detectChanges();\n }\n\n /** Waits `ms`, or not at all under reduced motion. */\n private wait(ms: number): Promise<void> {\n if (ms <= 0 || this.prefersReducedMotion()) return Promise.resolve();\n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}
1
+ {"version":3,"file":"mn-angular-lib-tour.mjs","names":[],"sources":["../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour.types.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-geometry.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-overlay.ts","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour-overlay.html","../../../projects/mn-angular-lib/tour/src/mn-tour/mn-tour.service.ts"],"sourcesContent":["/**\n * One stop of a tour.\n *\n * The library knows nothing about routing, modules or storage: the caller passes texts that are\n * already translated, and uses {@link before} to get the page into the state the step needs\n * (navigate, switch a tab, open a drawer).\n */\nexport type MnTourStep = {\n /**\n * Value of the `data-tour` attribute on the element to highlight (`'nav-book'` highlights\n * `[data-tour=\"nav-book\"]`). Omit it for a centred card with the page dimmed, such as a\n * welcome or final card.\n */\n target?: string;\n /** Small line above the title (e.g. the tour name). */\n kicker?: string;\n /** The step's title. Also the card's accessible name. */\n title: string;\n /** Short explanation. Also the card's accessible description. */\n body: string;\n /**\n * Runs before the step is shown, after the previous step's {@link after}. Awaited, so it can\n * navigate and return once the router has settled; the tour then still waits for the target\n * to appear. A step with `before` is treated as a page change: the highlight fades out, jumps\n * and fades back in instead of gliding. A `before` that throws skips the step.\n */\n before?: () => void | Promise<void>;\n /**\n * Runs when the tour leaves this step, in either direction or because the tour ended (e.g. to\n * close a drawer that {@link before} opened). Awaited; a throw is ignored.\n */\n after?: () => void | Promise<void>;\n};\n\n/** The \"next tour\" block on a tour's final card. */\nexport type MnTourNextTour = {\n /** Heading of the block (e.g. \"Volgende rondleiding\"). */\n kicker?: string;\n /** Name of the next tour. */\n title: string;\n /** Secondary line, e.g. its length (\"7 stappen\"). */\n meta?: string;\n};\n\n/**\n * A small text link on a tour's final card, e.g. to the module's help topic. Pressing it ends\n * the tour as `completed` (with `startNext: false`) and then calls {@link run}.\n */\nexport type MnTourFinalLink = {\n /** The link's text (e.g. \"Meer over wedstrijden in de help\"). */\n label: string;\n /** Called once the tour has ended, e.g. to navigate to the help topic. */\n run: () => void | Promise<void>;\n};\n\n/**\n * Every label the tour card renders. The library ships no strings of its own, so all of them\n * come from the caller, already translated.\n */\nexport type MnTourLabels = {\n /** The small text link at the top right that ends the tour (e.g. \"Overslaan\"). */\n skip: string;\n /** Back one step (e.g. \"Vorige\"). */\n previous: string;\n /** Forward one step (e.g. \"Volgende\"). */\n next: string;\n /** Primary button on the last step when there is no next tour (e.g. \"Klaar\"). */\n done: string;\n /** Secondary button on the last step when a next tour is offered (e.g. \"Sluiten\"). */\n close: string;\n /** Primary button on the last step when a next tour is offered (e.g. \"Start volgende\"). */\n startNext: string;\n /**\n * Screen-reader text for the progress dots, given the 1-based position and the number of\n * steps (e.g. `(n, total) => \\`Stap ${n} van ${total}\\``).\n */\n stepLabel: (step: number, total: number) => string;\n};\n\n/** What a tour is started with. */\nexport type MnTourOptions = {\n /** The stops, in order. */\n steps: readonly MnTourStep[];\n /** Every label the card renders. */\n labels: MnTourLabels;\n /** Optional block on the final card that offers the next tour. */\n nextTour?: MnTourNextTour;\n /** Optional text link on the final card, shown under the body (above a next-tour block). */\n finalLink?: MnTourFinalLink;\n /** Index of the first step to show (default 0), e.g. to resume a tour. */\n startAt?: number;\n /** How long a step waits for its target to appear before it is skipped (default 4000 ms). */\n targetTimeoutMs?: number;\n /**\n * Called when a step is skipped because its target never appeared or its `before` threw, so\n * the app can log a stale marker.\n */\n onStepMissing?: (index: number, step: MnTourStep, reason: 'target-not-found' | 'before-failed') => void;\n};\n\n/**\n * How a tour ended. `step` is the 0-based index (into `steps`) of the step that was on screen.\n *\n * - `completed`: the last step's primary or secondary button, or Volgende when every later step\n * turned out missing (then `step` is the last step that was shown). `startNext` is true when\n * the user chose the next tour from the final card.\n * - `skipped`: the skip link, or Escape.\n * - `closed`: ended from outside through `MnTourRef.close()` (e.g. the user navigated away), or\n * by starting another tour or offer. `step` is -1 when no step had been shown yet, which also\n * happens when every step of the tour was missing: the user saw nothing, so there is nothing\n * to resume.\n */\nexport type MnTourOutcome =\n | { status: 'completed'; step: number; startNext: boolean }\n | { status: 'skipped'; step: number }\n | { status: 'closed'; step: number };\n\n/**\n * Where an offer card appears: `centred` with the page dimmed (the general tour's welcome\n * offer), or `corner`, bottom-right with the page left undimmed and usable (a module tour).\n */\nexport type MnTourOfferPlacement = 'centred' | 'corner';\n\n/** What an offer card is opened with. */\nexport type MnTourOfferOptions = {\n /** Where the card appears. */\n placement: MnTourOfferPlacement;\n /** Small line above the title. */\n kicker?: string;\n /** The offer's title (e.g. \"Rondleiding: wedstrijden organiseren\"). */\n title: string;\n /** Short explanation, e.g. the tour's length. */\n body: string;\n /** Button labels. */\n labels: {\n /** Declines the offer (e.g. \"Niet nu\"). */\n dismiss: string;\n /** Accepts it (e.g. \"Rondleiding starten\" / \"Start\"). */\n accept: string;\n };\n};\n\n/**\n * How an offer ended: `accepted` / `dismissed` by its buttons (Escape dismisses), or `closed`\n * from outside through `MnTourOfferRef.close()` without an answer.\n */\nexport type MnTourOfferOutcome = { status: 'accepted' } | { status: 'dismissed' } | { status: 'closed' };\n\n/**\n * The library's motion timings (ms). Exported so an app's own motion and tests can line up\n * with them. Under `prefers-reduced-motion` every one of them is skipped.\n */\nexport const MN_TOUR_MOTION = {\n /** The highlight and the card glide between two stops on the same page. */\n glideMs: 450,\n /** The highlight and the dim fade in after a page, tab or drawer change (ease-out). */\n fadeInMs: 450,\n /** The highlight and the dim fade out before a page change, and at the end. */\n fadeOutMs: 200,\n /** The card's content fades out, and the new content in, over this each. */\n contentFadeMs: 120,\n} as const;\n","/** A box in viewport coordinates (px), as `getBoundingClientRect()` reports it. */\nexport type MnTourBox = { top: number; left: number; width: number; height: number };\n\n/** A width and a height (px). */\nexport type MnTourSize = { width: number; height: number };\n\n/** Air (px) between the target's edge and the highlight's ring. */\nexport const TOUR_HOLE_PADDING = 6;\n/** Gap (px) between the highlight and a card placed beside it. */\nexport const TOUR_CARD_GAP = 14;\n/** Minimum distance (px) a card keeps from the viewport edge. */\nexport const TOUR_VIEWPORT_MARGIN = 16;\n\n/**\n * Grows a target's box by {@link TOUR_HOLE_PADDING} on every side, so the ring sits around the\n * element instead of on its edge.\n * @param rect The target's box.\n * @param pad Padding to add on every side.\n */\nexport function padBox(rect: MnTourBox, pad = TOUR_HOLE_PADDING): MnTourBox {\n return { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 };\n}\n\n/** Whether two boxes differ by more than half a pixel on any edge. */\nexport function boxChanged(a: MnTourBox | null, b: MnTourBox | null): boolean {\n if (!a || !b) return a !== b;\n return (\n Math.abs(a.top - b.top) > 0.5 ||\n Math.abs(a.left - b.left) > 0.5 ||\n Math.abs(a.width - b.width) > 0.5 ||\n Math.abs(a.height - b.height) > 0.5\n );\n}\n\n/** Clamps `value` into `[min, max]`, preferring `min` when the range is empty. */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max));\n}\n\n/**\n * Where a card goes beside a highlight: to the right if it fits, else left, else below, else\n * above, else (nothing fits) below and clamped into the viewport. Along the other axis the card\n * is centred on the highlight and kept {@link TOUR_VIEWPORT_MARGIN} away from the edges.\n * @param hole The highlight's box.\n * @param card The card's rendered size, padding included.\n * @param viewport The viewport's size.\n * @returns The card's top-left corner, in viewport coordinates.\n */\nexport function placeBeside(hole: MnTourBox, card: MnTourSize, viewport: MnTourSize): { x: number; y: number } {\n const m = TOUR_VIEWPORT_MARGIN;\n const gap = TOUR_CARD_GAP;\n const maxX = viewport.width - card.width - m;\n const maxY = viewport.height - card.height - m;\n const centredY = clamp(hole.top + hole.height / 2 - card.height / 2, m, maxY);\n const centredX = clamp(hole.left + hole.width / 2 - card.width / 2, m, maxX);\n\n const right = hole.left + hole.width + gap;\n if (right + card.width + m <= viewport.width) return { x: right, y: centredY };\n\n const left = hole.left - gap - card.width;\n if (left >= m) return { x: left, y: centredY };\n\n const below = hole.top + hole.height + gap;\n if (below + card.height + m <= viewport.height) return { x: centredX, y: below };\n\n const above = hole.top - gap - card.height;\n if (above >= m) return { x: centredX, y: above };\n\n return { x: centredX, y: clamp(below, m, maxY) };\n}\n\n/** Whether an element takes up space on screen (not `display: none`, not zero-sized, not hidden). */\nfunction isRendered(el: HTMLElement): boolean {\n const rect = el.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) return false;\n return getComputedStyle(el).visibility !== 'hidden';\n}\n\n/**\n * The first rendered element carrying `data-tour=\"<name>\"`, or null. A marker that exists in\n * the DOM but is not rendered (a collapsed drawer's copy of a nav item) does not count.\n * @param name The `data-tour` value.\n * @param root Where to search (default: the document).\n */\nexport function findTourTarget(name: string, root: ParentNode = document): HTMLElement | null {\n const selector = `[data-tour=\"${CSS.escape(name)}\"]`;\n for (const el of Array.from(root.querySelectorAll<HTMLElement>(selector))) {\n if (isRendered(el)) return el;\n }\n return null;\n}\n\n/** How often (ms) a waiting step re-checks its target besides reacting to DOM mutations. */\nconst TARGET_POLL_MS = 50;\n\n/**\n * Resolves with the step's target as soon as it is rendered, or with null after `timeoutMs`.\n * Reacts to DOM mutations and also polls, because an element can become rendered without a\n * mutation in its own subtree (a parent's transition ends, a stylesheet loads). Never waits a\n * fixed delay when the target is already there.\n * @param name The `data-tour` value.\n * @param timeoutMs How long to wait at most.\n * @param isCancelled Stops the wait early (resolving null) once this returns true.\n */\nexport function waitForTourTarget(\n name: string,\n timeoutMs: number,\n isCancelled: () => boolean = () => false,\n): Promise<HTMLElement | null> {\n const found = findTourTarget(name);\n if (found || timeoutMs <= 0) return Promise.resolve(found);\n\n return new Promise((resolve) => {\n let settled = false;\n const finish = (el: HTMLElement | null): void => {\n if (settled) return;\n settled = true;\n observer.disconnect();\n clearInterval(poll);\n clearTimeout(timeout);\n resolve(el);\n };\n const check = (): void => {\n if (isCancelled()) {\n finish(null);\n return;\n }\n const el = findTourTarget(name);\n if (el) finish(el);\n };\n const observer = new MutationObserver(check);\n observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true });\n const poll = setInterval(check, TARGET_POLL_MS);\n const timeout = setTimeout(() => finish(findTourTarget(name)), timeoutMs);\n });\n}\n","import { Component, computed, ElementRef, output, signal, viewChild } from '@angular/core';\nimport { MnButton, MnButtonTypes } from 'mn-angular-lib/button';\nimport { MnTourBox, MnTourSize } from './mn-tour-geometry';\nimport { MnTourNextTour } from './mn-tour.types';\n\n/**\n * How the card is placed:\n * - `beside`: next to the highlighted target (desktop);\n * - `centred`: in the middle of the viewport (welcome and final cards, centred offers);\n * - `corner`: bottom-right, for an offer that leaves the page usable;\n * - `sheet`: a bottom sheet, below the `lg` breakpoint.\n */\nexport type MnTourCardVariant = 'beside' | 'centred' | 'corner' | 'sheet';\n\n/** Which dim is on screen: none, the whole page, or everything around the highlight. */\nexport type MnTourDim = 'none' | 'full' | 'hole';\n\n/** A button or link on the card the user pressed. The service decides what it means. */\nexport type MnTourCardAction = 'skip' | 'secondary' | 'primary' | 'link';\n\n/** What the card shows. Every string is the caller's, already translated. */\nexport type MnTourCardView = {\n /** Small line above the title. */\n kicker?: string;\n /** The title; the card's accessible name. */\n title: string;\n /** The body; the card's accessible description. */\n body: string;\n /** Optional \"next tour\" block above the footer. */\n nextTour?: MnTourNextTour;\n /** Label of the text link under the body (final card only); no link when absent. */\n link?: string;\n /** Label of the small skip link top right; no link when absent. */\n skip?: string;\n /** Label of the secondary (outline) button; no button when absent. */\n secondary?: string;\n /** Label of the primary button. */\n primary: string;\n /** Progress dots; none when absent. `active` is 0-based. */\n progress?: { total: number; active: number; label: string };\n};\n\n/** Counter for unique element ids, so two overlays never share an `aria-labelledby` target. */\nlet nextOverlayId = 0;\n\n/**\n * The tour's on-screen layer: the dim, the highlight around the target and the step card.\n *\n * Rendered and driven by `MnTourService`, which writes these signals; the component itself\n * holds no tour logic and only reports which control was pressed through {@link action}. It is\n * created once per tour (or offer) and stays mounted between steps, so the card never re-enters:\n * only its content crossfades.\n *\n * Motion lives in the stylesheet and is switched by classes: `is-gliding` animates the\n * highlight's and the card's position, `is-visible` / `is-shown` fade them in (450 ms ease-out)\n * and their absence fades them out (200 ms). `reducedMotion` drops every transition.\n */\n@Component({\n selector: 'mn-tour-overlay',\n standalone: true,\n imports: [MnButton],\n templateUrl: './mn-tour-overlay.html',\n styleUrl: './mn-tour-overlay.css',\n})\nexport class MnTourOverlay {\n /** What the card shows; the card is not rendered while null. */\n readonly view = signal<MnTourCardView | null>(null);\n /** Whether the card's content is faded in. Toggled around a content swap. */\n readonly contentVisible = signal(false);\n /** Whether the card itself is faded in. */\n readonly cardVisible = signal(false);\n /** How the card is placed. */\n readonly variant = signal<MnTourCardVariant>('centred');\n /** Which dim is shown. Anything but `none` also blocks clicks on the page. */\n readonly dim = signal<MnTourDim>('none');\n /** The highlight's box (target plus padding), in viewport coordinates. */\n readonly hole = signal<MnTourBox | null>(null);\n /** Whether the highlight (and its dim) is faded in. */\n readonly holeVisible = signal(false);\n /** While true, a change of the highlight's or the card's position glides instead of jumping. */\n readonly gliding = signal(false);\n /** Top-left corner of a `beside` card, in viewport coordinates. */\n readonly cardPos = signal<{ x: number; y: number } | null>(null);\n /** Turns every transition and animation off. */\n readonly reducedMotion = signal(false);\n\n /** Emitted when the user presses the skip link or one of the buttons. */\n readonly action = output<MnTourCardAction>();\n\n /** Id of the title element, the dialog's accessible name. */\n protected readonly titleId = `mn-tour-title-${nextOverlayId}`;\n /** Id of the body element, the dialog's accessible description. */\n protected readonly bodyId = `mn-tour-body-${nextOverlayId++}`;\n\n /** The primary button's look: filled, never wrapping its label. */\n protected readonly primaryButton: Partial<MnButtonTypes> = {\n variant: 'fill',\n color: 'primary',\n size: 'sm',\n borderRadius: 'lg',\n wrap: false,\n hover: true,\n };\n /** The secondary button's look: gray outline (Vorige, Sluiten, Niet nu), never wrapping. */\n protected readonly secondaryButton: Partial<MnButtonTypes> = {\n variant: 'outline',\n color: 'gray',\n size: 'sm',\n borderRadius: 'lg',\n wrap: false,\n hover: true,\n };\n\n /** The `beside` card's position as a transform, so a glide animates on the compositor. */\n protected readonly cardTransform = computed(() => {\n const pos = this.cardPos();\n return this.variant() === 'beside' && pos ? `translate(${pos.x}px, ${pos.y}px)` : null;\n });\n\n /** The card element. */\n private readonly cardRef = viewChild<ElementRef<HTMLElement>>('card');\n\n /** The card's rendered size (padding and border included), or null while it is not rendered. */\n cardSize(): MnTourSize | null {\n const el = this.cardRef()?.nativeElement;\n return el ? { width: el.offsetWidth, height: el.offsetHeight } : null;\n }\n\n /** Moves focus into the card without scrolling the page. */\n focusCard(): void {\n this.cardRef()?.nativeElement.focus({ preventScroll: true });\n }\n\n /** Whether focus is currently inside the card. */\n hasFocus(): boolean {\n return this.contains(document.activeElement);\n }\n\n /** Whether `node` lies inside the card. */\n contains(node: Node | null): boolean {\n const el = this.cardRef()?.nativeElement;\n return !!el && !!node && el.contains(node);\n }\n\n /**\n * Keeps Tab inside the card: from its last focusable control to its first and back. Focus that\n * is outside the card (or on the card itself) goes to the first or last control.\n * @param event The Tab keydown.\n */\n trapTab(event: KeyboardEvent): void {\n const el = this.cardRef()?.nativeElement;\n if (!el) return;\n const focusable = Array.from(\n el.querySelectorAll<HTMLElement>('button:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])'),\n );\n if (focusable.length === 0) {\n event.preventDefault();\n el.focus({ preventScroll: true });\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement as HTMLElement | null;\n const inside = !!active && focusable.includes(active);\n if (event.shiftKey && (!inside || active === first)) {\n event.preventDefault();\n last.focus({ preventScroll: true });\n } else if (!event.shiftKey && (!inside || active === last)) {\n event.preventDefault();\n first.focus({ preventScroll: true });\n }\n }\n\n /** The dots to render: one entry per step, true for the active one. */\n protected dots(total: number, active: number): boolean[] {\n return Array.from({ length: total }, (_, i) => i === active);\n }\n}\n","<div\n [class.mn-tour-passive]=\"dim() === 'none'\"\n [class.mn-tour-reduced]=\"reducedMotion()\"\n class=\"mn-tour-root\"\n>\n @if (dim() !== 'none') {\n <!-- Catches clicks on the page while the tour runs; the dim itself is purely visual. -->\n <div aria-hidden=\"true\" class=\"mn-tour-blocker\"></div>\n }\n <div [class.is-visible]=\"dim() === 'full'\" aria-hidden=\"true\" class=\"mn-tour-dim\"></div>\n <div\n [class.is-gliding]=\"gliding()\"\n [class.is-visible]=\"dim() === 'hole' && holeVisible()\"\n [style.height.px]=\"hole()?.height ?? 0\"\n [style.left.px]=\"hole()?.left ?? 0\"\n [style.top.px]=\"hole()?.top ?? 0\"\n [style.width.px]=\"hole()?.width ?? 0\"\n aria-hidden=\"true\"\n class=\"mn-tour-hole\"\n ></div>\n\n @if (view(); as v) {\n <div\n #card\n [attr.aria-describedby]=\"bodyId\"\n [attr.aria-labelledby]=\"titleId\"\n [attr.aria-modal]=\"dim() === 'none' ? null : 'true'\"\n [class.is-gliding]=\"gliding()\"\n [class.is-shown]=\"cardVisible()\"\n [class.mn-tour-card--beside]=\"variant() === 'beside'\"\n [class.mn-tour-card--centred]=\"variant() === 'centred'\"\n [class.mn-tour-card--corner]=\"variant() === 'corner'\"\n [class.mn-tour-card--sheet]=\"variant() === 'sheet'\"\n [style.transform]=\"cardTransform()\"\n class=\"mn-tour-card text-base-content\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <div [class.is-visible]=\"contentVisible()\" aria-live=\"polite\" class=\"mn-tour-content\">\n <div class=\"flex items-start gap-4\">\n <div class=\"min-w-0 flex-1 text-left\">\n @if (v.kicker) {\n <p class=\"text-xs font-medium text-base-content/60\">{{ v.kicker }}</p>\n }\n <h2 [id]=\"titleId\" class=\"mt-0.5 text-base font-semibold leading-snug\">{{ v.title }}</h2>\n </div>\n @if (v.skip) {\n <button\n (click)=\"action.emit('skip')\"\n class=\"mn-tour-skip shrink-0 whitespace-nowrap rounded text-sm text-base-content/60 hover:text-base-content hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.skip }}</button>\n }\n </div>\n\n <p [id]=\"bodyId\" class=\"mt-1.5 text-left text-sm leading-relaxed text-base-content/80\">{{ v.body }}</p>\n\n @if (v.link) {\n <button\n (click)=\"action.emit('link')\"\n class=\"mn-tour-link mt-2 inline-flex items-center gap-1 rounded text-left text-sm font-medium text-primary hover:underline underline-offset-2 cursor-pointer\"\n type=\"button\"\n >{{ v.link }}<span aria-hidden=\"true\">&rarr;</span></button>\n }\n\n @if (v.nextTour; as next) {\n <div class=\"mn-tour-next mt-4 rounded-xl bg-primary/10 px-3.5 py-3 text-left\">\n @if (next.kicker) {\n <p class=\"text-xs font-medium text-primary\">{{ next.kicker }}</p>\n }\n <p class=\"text-sm font-semibold\">{{ next.title }}</p>\n @if (next.meta) {\n <p class=\"text-xs text-base-content/60\">{{ next.meta }}</p>\n }\n </div>\n }\n\n <div class=\"mn-tour-footer mt-5 flex items-center gap-3\">\n @if (v.progress; as p) {\n <div aria-hidden=\"true\" class=\"mn-tour-dots flex shrink-0 items-center gap-1.5\">\n @for (active of dots(p.total, p.active); track $index) {\n <span [class.is-active]=\"active\" class=\"mn-tour-dot\"></span>\n }\n </div>\n <span class=\"sr-only\">{{ p.label }}</span>\n }\n <div class=\"mn-tour-actions ml-auto flex items-center gap-2\">\n @if (v.secondary) {\n <button\n (click)=\"action.emit('secondary')\"\n [data]=\"secondaryButton\"\n class=\"mn-tour-secondary\"\n mnButton\n type=\"button\"\n >{{ v.secondary }}</button>\n }\n <button\n (click)=\"action.emit('primary')\"\n [data]=\"primaryButton\"\n class=\"mn-tour-primary\"\n mnButton\n type=\"button\"\n >{{ v.primary }}</button>\n </div>\n </div>\n </div>\n </div>\n }\n</div>\n","import {\n ApplicationRef,\n ComponentRef,\n createComponent,\n EnvironmentInjector,\n inject,\n Injectable,\n OnDestroy,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\nimport { boxChanged, padBox, placeBeside, waitForTourTarget } from './mn-tour-geometry';\nimport { MnTourCardAction, MnTourCardVariant, MnTourCardView, MnTourOverlay } from './mn-tour-overlay';\nimport {\n MN_TOUR_MOTION,\n MnTourOfferOptions,\n MnTourOfferOutcome,\n MnTourOptions,\n MnTourOutcome,\n} from './mn-tour.types';\n\n/** Below this width (px) the card is a bottom sheet: Tailwind's `lg` breakpoint, exclusive. */\nconst COMPACT_MAX_WIDTH = 1023.98;\n/** How long a step waits for its target by default (ms). */\nconst DEFAULT_TARGET_TIMEOUT_MS = 4000;\n/** Space (px) a scrolled-to target keeps from the viewport's edges (and from the sheet). */\nconst SCROLL_MARGIN = 16;\n\n/** A running tour, as returned by {@link MnTourService.start}. */\nexport class MnTourRef {\n /**\n * @param result Settles once, with how the tour ended.\n * @param step The 0-based index of the step on screen (-1 before the first one shows). Read it\n * synchronously to persist \"the last step reached\" when the page unloads mid-tour.\n * @param closeFn Ends the tour from outside.\n */\n constructor(\n readonly result: Promise<MnTourOutcome>,\n readonly step: Signal<number>,\n private readonly closeFn: () => void,\n ) {}\n\n /** Ends the tour without an answer from the user (outcome `closed`). Idempotent. */\n close(): void {\n this.closeFn();\n }\n}\n\n/** An open offer card, as returned by {@link MnTourService.offer}. */\nexport class MnTourOfferRef {\n /**\n * @param result Settles once, with the user's answer.\n * @param closeFn Removes the card without an answer.\n */\n constructor(\n readonly result: Promise<MnTourOfferOutcome>,\n private readonly closeFn: () => void,\n ) {}\n\n /** Removes the card without an answer (outcome `closed`). Idempotent. */\n close(): void {\n this.closeFn();\n }\n}\n\n/** State of a tour while it runs. */\ntype TourSession = {\n /** Discriminates the session union. */\n kind: 'tour';\n /** What the tour was started with. */\n options: MnTourOptions;\n /** Index of the step on screen, -1 before the first. */\n index: WritableSignal<number>;\n /** Step whose `after` still has to run, or -1. */\n pendingAfter: number;\n /** Steps found missing, left out of the dots and skipped by Vorige. */\n missing: Set<number>;\n /** The highlighted element, null on a centred step. */\n target: HTMLElement | null;\n /** True while a step change is in flight; input is ignored meanwhile. */\n busy: boolean;\n /** True once the outcome is decided. */\n ended: boolean;\n /** Settles the ref's `result`. */\n resolve: (outcome: MnTourOutcome) => void;\n};\n\n/** State of an offer while it is open. */\ntype OfferSession = {\n /** Discriminates the session union. */\n kind: 'offer';\n /** What the offer was opened with. */\n options: MnTourOfferOptions;\n /** True once answered or closed. */\n ended: boolean;\n /** Settles the ref's `result`. */\n resolve: (outcome: MnTourOfferOutcome) => void;\n};\n\n/**\n * Runs guided tours: a highlight around `[data-tour=\"…\"]` elements and a card that walks the user\n * through them, plus the offer card that proposes a tour.\n *\n * The service knows nothing about routing, modules or storage. The caller passes translated\n * texts, moves the app between steps with each step's `before()`, and persists what the returned\n * outcome reports. One tour or offer is on screen at a time; starting another closes the current\n * one. Starting a tour straight from an accepted offer (or from a final card's \"Start volgende\")\n * reuses the card already on screen instead of removing and re-adding it.\n *\n * Motion (D10): between two targets on the same page the highlight and the card glide (450 ms).\n * A step with `before()`, a step after a centred card and a step after a missing one fade the\n * highlight out (200 ms), jump, and fade in (450 ms, ease-out). The card's content crossfades\n * (120 ms out, 120 ms in). Under `prefers-reduced-motion` there is no glide and no fade.\n *\n * Keyboard: Escape skips (on an offer: declines), ArrowRight and Enter go forward, ArrowLeft goes\n * back. Focus moves into the card and returns where it was when the tour ends. The corner offer\n * is the exception: it does not take focus, because it appears unasked on a page the user is\n * working on; it is still reachable with Tab, and Escape works once focus is inside it.\n */\n@Injectable({ providedIn: 'root' })\nexport class MnTourService implements OnDestroy {\n private readonly appRef = inject(ApplicationRef);\n private readonly injector = inject(EnvironmentInjector);\n\n /** The mounted overlay, or null. */\n private overlayRef: ComponentRef<MnTourOverlay> | null = null;\n /** The tour or offer on screen, or null. */\n private session: TourSession | OfferSession | null = null;\n /** Pending fade-out or removal of the overlay. */\n private teardownTimer: ReturnType<typeof setTimeout> | null = null;\n /** Where focus was before the overlay appeared, restored when it goes. */\n private returnFocus: HTMLElement | null = null;\n /** Undoes the listeners that keep the highlight on its target. */\n private stopTrackingFn: (() => void) | null = null;\n /** Document keydown listener, registered only while the overlay exists. */\n private readonly onKeyDown = (event: KeyboardEvent): void => this.handleKey(event);\n /** Window resize listener, registered only while the overlay exists. */\n private readonly onResize = (): void => this.reposition();\n\n /**\n * Starts a tour. A tour or offer already on screen is closed first (its outcome `closed`).\n * @param options The steps, labels and optional next-tour block.\n * @returns A ref whose `result` settles with how the tour ended.\n */\n start(options: MnTourOptions): MnTourRef {\n this.closeCurrent();\n let resolve!: (outcome: MnTourOutcome) => void;\n const result = new Promise<MnTourOutcome>((r) => (resolve = r));\n const index = signal(-1);\n const session: TourSession = {\n kind: 'tour',\n options,\n index,\n pendingAfter: -1,\n missing: new Set(),\n target: null,\n busy: false,\n ended: false,\n resolve,\n };\n const ref = new MnTourRef(result, index.asReadonly(), () => {\n void this.endTour(session, { status: 'closed', step: session.index() });\n });\n\n if (options.steps.length === 0) {\n session.ended = true;\n resolve({ status: 'completed', step: -1, startNext: false });\n return ref;\n }\n\n this.session = session;\n this.ensureOverlay();\n const first = Math.min(Math.max(options.startAt ?? 0, 0), options.steps.length - 1);\n void this.go(session, first, 1);\n return ref;\n }\n\n /**\n * Shows an offer card. A tour or offer already on screen is closed first.\n * @param options Placement, texts and button labels.\n * @returns A ref whose `result` settles with the user's answer.\n */\n offer(options: MnTourOfferOptions): MnTourOfferRef {\n this.closeCurrent();\n let resolve!: (outcome: MnTourOfferOutcome) => void;\n const result = new Promise<MnTourOfferOutcome>((r) => (resolve = r));\n const session: OfferSession = { kind: 'offer', options, ended: false, resolve };\n this.session = session;\n\n const ov = this.ensureOverlay();\n const corner = options.placement === 'corner';\n ov.variant.set(this.offerVariant(options));\n ov.view.set({\n kicker: options.kicker,\n title: options.title,\n body: options.body,\n secondary: options.labels.dismiss,\n primary: options.labels.accept,\n });\n ov.dim.set(corner ? 'none' : 'full');\n ov.holeVisible.set(false);\n ov.gliding.set(false);\n ov.cardPos.set(null);\n ov.cardVisible.set(true);\n ov.contentVisible.set(true);\n this.render();\n if (!corner) ov.focusCard();\n\n return new MnTourOfferRef(result, () => this.answerOffer(session, { status: 'closed' }));\n }\n\n /** Whether a tour or an offer is on screen. */\n isActive(): boolean {\n return this.session !== null;\n }\n\n /**\n * Whether the viewport is below `lg`, where the card is a bottom sheet. Public so a test (or\n * an app with its own breakpoint logic) can override it.\n */\n isCompactViewport(): boolean {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia(`(max-width: ${COMPACT_MAX_WIDTH}px)`).matches\n : false;\n }\n\n /** Whether the user asked for reduced motion. Public so a test can override it. */\n prefersReducedMotion(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n }\n\n /** Removes the overlay if the service itself is destroyed (an app or test teardown). */\n ngOnDestroy(): void {\n this.closeCurrent();\n this.destroyOverlay();\n }\n\n /** Steps through the tour: from the current step to `to`, skipping missing steps in `dir`. */\n private async go(s: TourSession, to: number, dir: 1 | -1): Promise<void> {\n if (s.busy || s.ended) return;\n s.busy = true;\n try {\n await this.advance(s, to, dir, true);\n } finally {\n s.busy = false;\n }\n }\n\n /**\n * {@link go} without the re-entrance guard.\n * @param allowFallback When going back finds nothing, re-show the current step once.\n */\n private async advance(s: TourSession, to: number, dir: 1 | -1, allowFallback: boolean): Promise<void> {\n const steps = s.options.steps;\n const ov = this.overlay();\n const from = s.index();\n const holeWasVisible = ov.dim() === 'hole' && ov.holeVisible();\n let left = false;\n let i = to;\n\n while (i >= 0 && i < steps.length) {\n const step = steps[i];\n const glide = holeWasVisible && !left && !!step.target && !step.before;\n\n if (!left) {\n left = true;\n this.stopTracking();\n ov.contentVisible.set(false);\n if (glide) await this.wait(MN_TOUR_MOTION.contentFadeMs);\n else await this.fadeOut();\n await this.runAfter(s);\n } else {\n await this.fadeOut();\n }\n if (s.ended) return;\n\n // From here on this step owns the page state its `before` sets up, so its `after` runs\n // even if the step turns out missing or the tour ends while it is still being prepared.\n s.pendingAfter = i;\n if (step.before) {\n try {\n await step.before();\n } catch {\n this.markMissing(s, i, 'before-failed');\n await this.runAfter(s);\n i += dir;\n continue;\n }\n if (s.ended) return;\n }\n\n let target: HTMLElement | null = null;\n if (step.target) {\n target = await waitForTourTarget(\n step.target,\n s.options.targetTimeoutMs ?? DEFAULT_TARGET_TIMEOUT_MS,\n () => s.ended,\n );\n if (s.ended) return;\n if (!target) {\n this.markMissing(s, i, 'target-not-found');\n await this.runAfter(s);\n i += dir;\n continue;\n }\n }\n\n await this.present(s, i, target, glide && i === to);\n return;\n }\n\n // Ran off an end. Back means nothing earlier exists: show the step we came from (or the\n // next one that does) again. Forward means nothing is left to show: the tour is over.\n if (dir === -1 && from >= 0 && allowFallback) {\n return this.advance(s, from, 1, false);\n }\n await this.endTour(\n s,\n s.index() >= 0 ? { status: 'completed', step: s.index(), startNext: false } : { status: 'closed', step: -1 },\n );\n }\n\n /** Puts step `i` on screen: content, highlight, card position, focus and tracking. */\n private async present(s: TourSession, i: number, target: HTMLElement | null, glide: boolean): Promise<void> {\n const ov = this.overlay();\n const reduced = this.prefersReducedMotion();\n s.index.set(i);\n s.pendingAfter = i;\n s.target = target;\n\n const variant = this.stepVariant(target);\n ov.reducedMotion.set(reduced);\n ov.variant.set(variant);\n ov.view.set(this.stepView(s, i));\n ov.dim.set(target ? 'hole' : 'full');\n this.render();\n\n if (target) this.scrollIntoView(target, variant === 'sheet');\n ov.gliding.set(glide && !reduced);\n this.place(target);\n ov.holeVisible.set(!!target);\n ov.cardVisible.set(true);\n ov.contentVisible.set(true);\n this.render();\n\n if (!ov.hasFocus()) ov.focusCard();\n this.startTracking(target);\n\n if (glide && !reduced) {\n await this.wait(MN_TOUR_MOTION.glideMs);\n if (this.session === s) ov.gliding.set(false);\n }\n }\n\n /** Sets the highlight's box and, beside a target, the card's position. */\n private place(target: HTMLElement | null): void {\n const ov = this.overlay();\n if (target) ov.hole.set(padBox(target.getBoundingClientRect()));\n const hole = ov.hole();\n const size = ov.cardSize();\n if (ov.variant() === 'beside' && hole && size) {\n ov.cardPos.set(placeBeside(hole, size, { width: window.innerWidth, height: window.innerHeight }));\n } else {\n ov.cardPos.set(null);\n }\n }\n\n /**\n * Fades the highlight and the dim out (200 ms), and the card too unless it is a bottom sheet,\n * which stays put. Returns at once when nothing was visible.\n */\n private async fadeOut(): Promise<void> {\n const ov = this.overlay();\n const holeVisible = ov.dim() === 'hole' && ov.holeVisible();\n const dimVisible = ov.dim() === 'full';\n const fadeCard = ov.cardVisible() && ov.variant() !== 'sheet';\n if (!holeVisible && !dimVisible && !fadeCard) return;\n ov.gliding.set(false);\n ov.holeVisible.set(false);\n if (dimVisible) ov.dim.set('hole');\n if (fadeCard) ov.cardVisible.set(false);\n await this.wait(MN_TOUR_MOTION.fadeOutMs);\n }\n\n /** Ends a tour once: runs the current step's `after`, settles the result, removes the overlay. */\n private async endTour(s: TourSession, outcome: MnTourOutcome): Promise<void> {\n if (s.ended) return;\n s.ended = true;\n if (this.session === s) {\n this.session = null;\n this.stopTracking();\n }\n await this.runAfter(s);\n s.resolve(outcome);\n this.scheduleTeardown();\n }\n\n /** Settles an offer once and removes the overlay unless a tour takes it over. */\n private answerOffer(s: OfferSession, outcome: MnTourOfferOutcome): void {\n if (s.ended) return;\n s.ended = true;\n if (this.session === s) this.session = null;\n s.resolve(outcome);\n this.scheduleTeardown();\n }\n\n /** Closes whatever is on screen, without an answer. */\n private closeCurrent(): void {\n const s = this.session;\n if (!s) return;\n if (s.kind === 'tour') void this.endTour(s, { status: 'closed', step: s.index() });\n else this.answerOffer(s, { status: 'closed' });\n }\n\n /** Runs the `after` of the step that was last shown, once. A throw is ignored. */\n private async runAfter(s: TourSession): Promise<void> {\n const i = s.pendingAfter;\n s.pendingAfter = -1;\n const after = i >= 0 ? s.options.steps[i].after : undefined;\n if (!after) return;\n try {\n await after();\n } catch {\n // A failing clean-up must not strand the user inside the tour.\n }\n }\n\n /** Records a step as missing and tells the caller. */\n private markMissing(s: TourSession, i: number, reason: 'target-not-found' | 'before-failed'): void {\n s.missing.add(i);\n s.options.onStepMissing?.(i, s.options.steps[i], reason);\n }\n\n /** Reacts to the card's controls. */\n private onAction(action: MnTourCardAction): void {\n const s = this.session;\n if (!s) return;\n if (s.kind === 'offer') {\n if (action === 'primary') this.answerOffer(s, { status: 'accepted' });\n else if (action === 'secondary') this.answerOffer(s, { status: 'dismissed' });\n return;\n }\n const i = s.index();\n if (i < 0) return;\n if (action === 'skip') {\n void this.endTour(s, { status: 'skipped', step: i });\n return;\n }\n if (s.busy) return;\n const last = this.isLastStep(s, i);\n if (action === 'link') {\n // End first (the outcome settles, the overlay starts to go), then hand over to the app.\n const link = s.options.finalLink;\n if (last && link) {\n void this.endTour(s, { status: 'completed', step: i, startNext: false }).then(() => link.run());\n }\n return;\n }\n if (action === 'primary') {\n if (last) void this.endTour(s, { status: 'completed', step: i, startNext: !!s.options.nextTour });\n else void this.go(s, i + 1, 1);\n } else if (last && s.options.nextTour) {\n void this.endTour(s, { status: 'completed', step: i, startNext: false });\n } else if (this.hasPrevious(s, i)) {\n void this.go(s, i - 1, -1);\n }\n }\n\n /** Keyboard: Escape skips/declines, ArrowRight/Enter forward, ArrowLeft back. */\n private handleKey(event: KeyboardEvent): void {\n const s = this.session;\n const ov = this.overlayRef?.instance;\n if (!s || !ov || event.defaultPrevented || event.isComposing) return;\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n\n // A dimmed card is modal: Tab cycles inside it instead of reaching the page behind the\n // blocker, where a focused link would navigate away mid-tour. The corner offer is not modal.\n if (event.key === 'Tab') {\n if (ov.dim() !== 'none') ov.trapTab(event);\n return;\n }\n\n if (s.kind === 'offer') {\n const inScope = s.options.placement === 'centred' || ov.hasFocus();\n if (event.key === 'Escape' && inScope) {\n event.preventDefault();\n this.answerOffer(s, { status: 'dismissed' });\n }\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n this.onAction('skip');\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n this.onAction('primary');\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n // On a final card with a next tour the secondary button is Sluiten, not Vorige.\n if (!(this.isLastStep(s, s.index()) && s.options.nextTour)) this.onAction('secondary');\n } else if (event.key === 'Enter') {\n // A focused button already turns Enter into its own click; handling it here too would\n // advance twice.\n const el = event.target as HTMLElement | null;\n if (el?.closest?.('button, a, input, textarea, select')) return;\n event.preventDefault();\n this.onAction('primary');\n }\n }\n\n /** Whether step `i` is the last one. */\n private isLastStep(s: TourSession, i: number): boolean {\n return i === s.options.steps.length - 1;\n }\n\n /** Whether there is an earlier step not known to be missing. */\n private hasPrevious(s: TourSession, i: number): boolean {\n for (let j = i - 1; j >= 0; j--) if (!s.missing.has(j)) return true;\n return false;\n }\n\n /** The card's content for step `i`. */\n private stepView(s: TourSession, i: number): MnTourCardView {\n const { steps, labels, nextTour } = s.options;\n const step = steps[i];\n const last = this.isLastStep(s, i);\n const total = steps.length - s.missing.size;\n let active = i;\n for (const m of s.missing) if (m < i) active--;\n const withNext = last && !!nextTour;\n return {\n kicker: step.kicker,\n title: step.title,\n body: step.body,\n nextTour: withNext ? nextTour : undefined,\n link: last ? s.options.finalLink?.label : undefined,\n skip: last ? undefined : labels.skip,\n secondary: withNext ? labels.close : this.hasPrevious(s, i) ? labels.previous : undefined,\n primary: withNext ? labels.startNext : last ? labels.done : labels.next,\n progress: total > 1 ? { total, active, label: labels.stepLabel(active + 1, total) } : undefined,\n };\n }\n\n /** Where a step's card goes at the current viewport width. */\n private stepVariant(target: HTMLElement | null): MnTourCardVariant {\n if (this.isCompactViewport()) return 'sheet';\n return target ? 'beside' : 'centred';\n }\n\n /** Where an offer's card goes at the current viewport width. */\n private offerVariant(options: MnTourOfferOptions): MnTourCardVariant {\n if (options.placement === 'corner') return 'corner';\n return this.isCompactViewport() ? 'sheet' : 'centred';\n }\n\n /**\n * Scrolls the target into view if it is not fully visible: centred on desktop, and clear of\n * the sheet on a phone (a temporary `scroll-margin` makes the browser leave room for it).\n */\n private scrollIntoView(target: HTMLElement, sheet: boolean): void {\n const bottomReserve = SCROLL_MARGIN + (sheet ? (this.overlay().cardSize()?.height ?? 0) : 0);\n const rect = target.getBoundingClientRect();\n if (rect.top >= SCROLL_MARGIN && rect.bottom <= window.innerHeight - bottomReserve) return;\n const { scrollMarginTop, scrollMarginBottom } = target.style;\n target.style.scrollMarginTop = `${SCROLL_MARGIN}px`;\n target.style.scrollMarginBottom = `${bottomReserve}px`;\n // 'instant', not 'auto': 'auto' follows a page's `scroll-behavior: smooth`, and the highlight\n // would then be measured mid-scroll and chase its target while fading in.\n target.scrollIntoView({ block: sheet ? 'nearest' : 'center', inline: 'nearest', behavior: 'instant' });\n target.style.scrollMarginTop = scrollMarginTop;\n target.style.scrollMarginBottom = scrollMarginBottom;\n }\n\n /**\n * Keeps the highlight on its target while the page scrolls or the target reflows. Scroll is\n * listened for on the document in the capture phase: the app's scroll container is usually a\n * layout element, whose scroll events never reach `window`.\n */\n private startTracking(target: HTMLElement | null): void {\n this.stopTracking();\n if (!target) return;\n let frame = 0;\n const update = (): void => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n this.reposition();\n });\n };\n document.addEventListener('scroll', update, { capture: true, passive: true });\n const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(update) : null;\n observer?.observe(target);\n this.stopTrackingFn = () => {\n document.removeEventListener('scroll', update, { capture: true });\n observer?.disconnect();\n if (frame) cancelAnimationFrame(frame);\n };\n }\n\n /** Undoes {@link startTracking}. */\n private stopTracking(): void {\n this.stopTrackingFn?.();\n this.stopTrackingFn = null;\n }\n\n /**\n * Re-measures after a scroll, a resize or a reflow: the card's variant (the viewport may have\n * crossed `lg`), the highlight and the card's position. A change during a glide retargets it;\n * otherwise it is instant, so the ring never lags behind the page.\n */\n private reposition(): void {\n const s = this.session;\n const ov = this.overlayRef?.instance;\n if (!s || !ov) return;\n if (s.kind === 'offer') {\n ov.variant.set(this.offerVariant(s.options));\n return;\n }\n if (s.busy && !ov.gliding()) return;\n const target = s.target;\n if (target && !target.isConnected) {\n // The page changed under the tour (e.g. browser back): hide the ring rather than point\n // at nothing. Whether to close the tour is the app's call.\n ov.holeVisible.set(false);\n return;\n }\n const variant = this.stepVariant(target);\n const moved = !target || boxChanged(ov.hole(), padBox(target.getBoundingClientRect()));\n if (variant === ov.variant() && !moved && variant !== 'beside') return;\n ov.variant.set(variant);\n this.render();\n this.place(target);\n }\n\n /** The overlay, created and attached on first use; a pending teardown is cancelled. */\n private ensureOverlay(): MnTourOverlay {\n if (this.teardownTimer) {\n clearTimeout(this.teardownTimer);\n this.teardownTimer = null;\n }\n if (this.overlayRef) return this.overlayRef.instance;\n\n const active = document.activeElement;\n this.returnFocus = active instanceof HTMLElement && active !== document.body ? active : null;\n\n const ref = createComponent(MnTourOverlay, { environmentInjector: this.injector });\n ref.instance.reducedMotion.set(this.prefersReducedMotion());\n ref.instance.action.subscribe((action) => this.onAction(action));\n this.appRef.attachView(ref.hostView);\n document.body.appendChild(ref.location.nativeElement);\n document.addEventListener('keydown', this.onKeyDown, true);\n window.addEventListener('resize', this.onResize);\n this.overlayRef = ref;\n return ref.instance;\n }\n\n /** The overlay, recreated if a teardown raced ahead of a late step. */\n private overlay(): MnTourOverlay {\n return this.overlayRef?.instance ?? this.ensureOverlay();\n }\n\n /**\n * Removes the overlay after a session ends, unless another one starts first: after a macrotask\n * (so a tour started from an accepted offer's `then` keeps the card), fade out, then destroy.\n */\n private scheduleTeardown(): void {\n if (this.teardownTimer) clearTimeout(this.teardownTimer);\n this.teardownTimer = setTimeout(() => {\n this.teardownTimer = null;\n const ov = this.overlayRef?.instance;\n if (this.session || !ov) return;\n ov.gliding.set(false);\n ov.contentVisible.set(false);\n ov.holeVisible.set(false);\n ov.cardVisible.set(false);\n if (ov.dim() === 'full') ov.dim.set('hole');\n const delay = this.prefersReducedMotion() ? 0 : MN_TOUR_MOTION.fadeOutMs;\n this.teardownTimer = setTimeout(() => {\n this.teardownTimer = null;\n if (!this.session) this.destroyOverlay();\n }, delay);\n });\n }\n\n /** Detaches and destroys the overlay, drops the listeners and gives focus back. */\n private destroyOverlay(): void {\n if (this.teardownTimer) {\n clearTimeout(this.teardownTimer);\n this.teardownTimer = null;\n }\n this.stopTracking();\n const ref = this.overlayRef;\n if (!ref) return;\n const hadFocus = ref.instance.hasFocus();\n this.overlayRef = null;\n document.removeEventListener('keydown', this.onKeyDown, true);\n window.removeEventListener('resize', this.onResize);\n this.appRef.detachView(ref.hostView);\n ref.destroy();\n ref.location.nativeElement.remove();\n const back = this.returnFocus;\n this.returnFocus = null;\n if (back?.isConnected && (hadFocus || document.activeElement === document.body)) {\n back.focus({ preventScroll: true });\n }\n }\n\n /** Synchronously renders the overlay, so it can be measured right after a state change. */\n private render(): void {\n this.overlayRef?.changeDetectorRef.detectChanges();\n }\n\n /** Waits `ms`, or not at all under reduced motion. */\n private wait(ms: number): Promise<void> {\n if (ms <= 0 || this.prefersReducedMotion()) return Promise.resolve();\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n"],"mappings":";;;AAwJA,MAAa,iBAAiB;CAE5B,SAAS;CAET,UAAU;CAEV,WAAW;CAEX,eAAe;AACP;AC9IV,SAAgB,OAAO,MAAiB,MAAA,GAAuB;CAC7D,OAAO;EAAE,KAAK,KAAK,MAAM;EAAK,MAAM,KAAK,OAAO;EAAK,OAAO,KAAK,QAAQ,MAAM;EAAG,QAAQ,KAAK,SAAS,MAAM;CAAC;AACjH;AAGA,SAAgB,WAAW,GAAqB,GAAmB;CACjE,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,MAAM;CAC3B,OACE,KAAK,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,MAC1B,KAAK,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,MAC5B,KAAK,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,MAC9B,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI;AAEpC;AAGA,SAAS,MAAM,OAAe,KAAa,KAAW;CACpD,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,OAAO,GAAG,CAAC;AAC3C;AAWA,SAAgB,YAAY,MAAiB,MAAkB,UAAoB;CACjF,MAAM,IA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OAAM;EACjC,MAAM,OAAO,KAAK;EAClB,KAAK,cAAc;EACnB,IAAI,MAAM,gBAAgB,YAAY,SAAS,kBAAkB,SAAS,OACxE,KAAK,MAAM,EAAE,eAAe,KAAI,CAAE;CAEtC;CAGQ,SAAM;EACZ,KAAK,YAAY,kBAAkB,cAAa;CAClD;CAGQ,KAAK,IAAU;EACrB,IAAI,MAAM,KAAK,KAAK,qBAAoB,GAAI,OAAO,QAAQ,QAAO;EAClE,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;CACzD;CAzlBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAb,OAAA,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,YADA;CAAM,CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EADzB,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mn-angular-lib",
3
- "version": "2.0.61",
3
+ "version": "2.0.63",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^22.1.7",
6
6
  "@angular/core": "^22.1.7",
@@ -167,7 +167,8 @@
167
167
  background: var(--color-primary);
168
168
  }
169
169
 
170
- .mn-tour-skip:focus-visible {
170
+ .mn-tour-skip:focus-visible,
171
+ .mn-tour-link:focus-visible {
171
172
  outline: 2px solid var(--color-primary);
172
173
  outline-offset: 2px;
173
174
  }
@@ -617,6 +617,12 @@ export declare class MnLanguageService {
617
617
  * the views that translated something, and a `computed` built on `translate` recomputes.
618
618
  */
619
619
  private readonly _locale;
620
+ /**
621
+ * Bumped whenever translations are registered at runtime, and read by every lookup, for the same
622
+ * reason as {@link _locale}: live preview registers new texts for the locale already active, so
623
+ * without this no view that translated something would know to render again.
624
+ */
625
+ private readonly _revision;
620
626
  private _urlPattern;
621
627
  private _debug;
622
628
  /**
@@ -750,20 +756,60 @@ export declare class MnTranslatePipe implements PipeTransform {
750
756
  static ɵfac: i0.ɵɵFactoryDeclaration<MnTranslatePipe, never>;
751
757
  static ɵpipe: i0.ɵɵPipeDeclaration<MnTranslatePipe, "mnTranslate", true>;
752
758
  }
759
+ /** What the editor posts into the previewed site. */
753
760
  export type MnPreviewMessage = {
754
- type: 'mn-config-update' | 'mn-translations-update';
761
+ type: 'mn-config-update' | 'mn-translations-update' | 'mn-preview-edit-mode';
755
762
  config?: Record<string, unknown>;
756
763
  translations?: Record<string, Record<string, string>>;
764
+ /** For `mn-preview-edit-mode`: whether clicks pick content instead of following links. */
765
+ enabled?: boolean;
766
+ };
767
+ /**
768
+ * What the previewed site posts to the editor.
769
+ *
770
+ * - `mn-preview-ready`: the listener is registered, so content posted from now on arrives (a
771
+ * message sent earlier is lost). Sent once, and again after every page change.
772
+ * - `mn-preview-select`: in edit mode, the visitor clicked a text or an image. `text` is the text
773
+ * under the pointer (whitespace collapsed), `context` the whole text of the element around it;
774
+ * for an image, `src` is the URL the page asked for. The editor works out which key or config
775
+ * value that is: the site only knows what it rendered.
776
+ */
777
+ export type MnPreviewEvent = {
778
+ type: 'mn-preview-ready';
779
+ locale: string;
780
+ path: string;
781
+ } | {
782
+ type: 'mn-preview-select';
783
+ kind: 'text';
784
+ text: string;
785
+ context: string;
786
+ locale: string;
787
+ path: string;
788
+ } | {
789
+ type: 'mn-preview-select';
790
+ kind: 'image';
791
+ src: string;
792
+ alt: string;
793
+ locale: string;
794
+ path: string;
757
795
  };
758
796
  /**
759
797
  * Enable live preview mode. Listens for postMessage events from
760
798
  * Mn Web Manager and hot-swaps config/translations at runtime.
761
799
  *
762
- * Call this once in your app's bootstrap (e.g., APP_INITIALIZER or root component).
800
+ * Call this once in your app's bootstrap (e.g., APP_INITIALIZER or root component), in the
801
+ * browser only and only inside a frame.
802
+ *
803
+ * Besides swapping content it tells the editor when it is ready (`mn-preview-ready`), and in edit
804
+ * mode (`mn-preview-edit-mode`) it outlines the text or image under the pointer and reports a
805
+ * click on it (`mn-preview-select`) instead of following it, so the owner can click what they want
806
+ * to change.
763
807
  *
764
808
  * @param configService - The MnConfigService instance
765
809
  * @param langService - The MnLanguageService instance
766
- * @param allowedOrigins - Optional whitelist of allowed origins (security)
810
+ * @param allowedOrigins - The editor origins that may change this frame's content. Give at least
811
+ * one: with none, any page that frames the site may rewrite it in that frame, and the site's own
812
+ * messages go to any parent.
767
813
  */
768
814
  export declare function enableMnPreviewMode(configService: MnConfigService, langService: MnLanguageService, allowedOrigins?: string[]): void;
769
815
  export {};
@@ -42,6 +42,16 @@ export type MnTourNextTour = {
42
42
  /** Secondary line, e.g. its length ("7 stappen"). */
43
43
  meta?: string;
44
44
  };
45
+ /**
46
+ * A small text link on a tour's final card, e.g. to the module's help topic. Pressing it ends
47
+ * the tour as `completed` (with `startNext: false`) and then calls {@link run}.
48
+ */
49
+ export type MnTourFinalLink = {
50
+ /** The link's text (e.g. "Meer over wedstrijden in de help"). */
51
+ label: string;
52
+ /** Called once the tour has ended, e.g. to navigate to the help topic. */
53
+ run: () => void | Promise<void>;
54
+ };
45
55
  /**
46
56
  * Every label the tour card renders. The library ships no strings of its own, so all of them
47
57
  * come from the caller, already translated.
@@ -73,6 +83,8 @@ export type MnTourOptions = {
73
83
  labels: MnTourLabels;
74
84
  /** Optional block on the final card that offers the next tour. */
75
85
  nextTour?: MnTourNextTour;
86
+ /** Optional text link on the final card, shown under the body (above a next-tour block). */
87
+ finalLink?: MnTourFinalLink;
76
88
  /** Index of the first step to show (default 0), e.g. to resume a tour. */
77
89
  startAt?: number;
78
90
  /** How long a step waits for its target to appear before it is skipped (default 4000 ms). */