{"version":3,"file":"styloviz-core-services.mjs","names":[],"sources":["../../../../projects/core/services/theme.service.ts","../../../../projects/core/services/toast.service.ts"],"sourcesContent":["import { Injectable, signal, effect, inject } from '@angular/core';\nimport { STYLOVIZ_CONFIG } from '@styloviz/core/tokens';\nimport { prefersReducedMotion } from '@styloviz/core/a11y';\n\nexport type Theme = 'light' | 'dark';\n\nconst STORAGE_KEY = 'styloviz-theme';\n\n/**\n * ★★★ EVERY STORAGE ACCESS IS GUARDED, INCLUDING READING THE GLOBAL (1.0 audit, H3).\n *     With cookies/site data blocked — a browser setting, some sandboxed\n *     iframes — merely evaluating `localStorage` throws a `SecurityError`. This\n *     service reads it while it is being CONSTRUCTED, so the throw took down\n *     every component that injects it, `sv-topbar` and with it the app shell.\n *     Without storage the theme still works; it is just not remembered.\n */\nfunction readStoredTheme(): Theme | null {\n  try {\n    if (typeof localStorage === 'undefined') return null;\n    const stored = localStorage.getItem(STORAGE_KEY);\n    return stored === 'dark' || stored === 'light' ? stored : null;\n  } catch {\n    return null;\n  }\n}\n\nfunction storeTheme(theme: Theme): void {\n  try {\n    if (typeof localStorage !== 'undefined') localStorage.setItem(STORAGE_KEY, theme);\n  } catch {\n    // Blocked or full storage: the switch still happens, it is just not remembered.\n  }\n}\n\n/** Minimal typing for the View Transitions API (not yet in lib.dom). */\ntype ViewTransitionDocument = Document & {\n  readonly startViewTransition?: (callback: () => void) => unknown;\n};\n\n/**\n * ThemeService — Dark/Light mode manager for Styloviz components.\n *\n * Priority order on init: localStorage → provideStyloviz colorScheme → OS preference → light.\n * Only `setTheme` / `toggleTheme` write localStorage — a theme that was merely\n * resolved (OS, config) is never stored, so it keeps following its source.\n *\n * Usage:\n *   const theme = inject(ThemeService);\n *   theme.toggleTheme();\n *   theme.isDark();   // signal\n */\n@Injectable({ providedIn: 'root' })\nexport class ThemeService {\n  private readonly config = inject(STYLOVIZ_CONFIG, { optional: true });\n\n  readonly isDark = signal<boolean>(this.resolveInitialTheme() === 'dark');\n\n  constructor() {\n    effect(() => {\n      this.applyTheme(this.isDark() ? 'dark' : 'light');\n    });\n  }\n\n  toggleTheme(): void {\n    this.setTheme(this.isDark() ? 'light' : 'dark');\n  }\n\n  setTheme(theme: Theme): void {\n    if (theme === (this.isDark() ? 'dark' : 'light')) return;\n\n    // ★★ Only an EXPLICIT choice is remembered (1.0 audit, H3). The effect used\n    //    to persist whatever theme was in force on first load — the OS\n    //    preference or `provideStyloviz({ colorScheme })` — as if the user had\n    //    picked it, so a later change to either was ignored for every\n    //    returning visitor.\n    storeTheme(theme);\n\n    const doc =\n      typeof document !== 'undefined'\n        ? (document as ViewTransitionDocument)\n        : undefined;\n    const startViewTransition = doc?.startViewTransition;\n\n    // Instant switch when the API is unavailable or reduced motion is\n    // requested; the cross-fade itself adds no per-element transitions.\n    if (!startViewTransition || this.prefersReducedMotion()) {\n      this.isDark.set(theme === 'dark');\n      return;\n    }\n\n    startViewTransition.call(doc, () => {\n      this.isDark.set(theme === 'dark');\n      this.applyTheme(theme);\n    });\n  }\n\n  private prefersReducedMotion(): boolean {\n    return prefersReducedMotion();\n  }\n\n  private resolveInitialTheme(): Theme {\n    if (typeof window === 'undefined') return 'light';\n\n    // 1. localStorage (user's last explicit choice)\n    const stored = readStoredTheme();\n    if (stored) return stored;\n\n    // 2. provideStyloviz colorScheme config\n    const scheme = this.config?.colorScheme;\n    if (scheme === 'dark') return 'dark';\n    if (scheme === 'light') return 'light';\n\n    // 3. OS preference — only when the browser can actually be asked.\n    if (typeof window.matchMedia !== 'function') return 'light';\n    return window.matchMedia('(prefers-color-scheme: dark)').matches\n      ? 'dark'\n      : 'light';\n  }\n\n  private applyTheme(theme: Theme): void {\n    if (typeof document === 'undefined') return;\n\n    const html = document.documentElement;\n    html.classList.toggle('dark', theme === 'dark');\n    html.classList.toggle('light', theme === 'light');\n  }\n}\n","import { Injectable, signal, type OnDestroy } from '@angular/core';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport type ToastVariant  = 'success' | 'error' | 'warning' | 'info';\nexport type ToastPosition =\n  | 'top-right'    | 'top-left'    | 'top-center'\n  | 'bottom-right' | 'bottom-left' | 'bottom-center';\n\nexport interface ToastAction {\n  readonly label:    string;\n  readonly callback: () => void;\n}\n\n/**\n * How long a toast is allowed to outlive the page it was raised on (`X-13`,\n * `OF-19-I5`).\n *\n * ★★★ THE OBVIOUS ANSWER — \"close everything on navigation\" — IS WRONG HERE,\n *     and it is wrong in the one case toasts exist for. `toast.success('Saved')`\n *     followed by `router.navigate(['/invoices'])` is THE canonical success\n *     toast: the whole point is that it survives the navigation the save\n *     triggered. A blanket route-close would delete every confirmation the user\n *     is meant to read, and it would do it in the flow that matters most.\n *\n * ★★ WHAT IS ACTUALLY STALE IS A TOAST ABOUT THE PAGE, not about the action.\n *    \"3 filters could not be applied to this view\", \"This report is still\n *    loading\" — those refer to something the user has left, and reading them\n *    two pages later is worse than not seeing them. So the staleness is a\n *    property of the MESSAGE, which only the caller knows, and it is declared\n *    per toast rather than guessed globally.\n *\n * | Scope             | Survives navigation | Use for                          |\n * |-------------------|---------------------|----------------------------------|\n * | `'global'` (default) | yes              | outcomes: saved, deleted, sent   |\n * | `'route'`         | no                  | statements about the current page |\n */\nexport type ToastScope = 'global' | 'route';\n\nexport interface Toast {\n  readonly id:          string;\n  readonly variant:     ToastVariant;\n  readonly title?:      string;\n  readonly message:     string;\n  readonly duration:    number;     // ms — 0 = persist until dismissed\n  readonly dismissible: boolean;\n  readonly action?:     ToastAction;\n  readonly position:    ToastPosition;\n  /** Whether this toast survives a route change. Defaults to `'global'`. */\n  readonly scope:       ToastScope;\n  /**\n   * Identity for deduplication (`X-12`, `OF-19-I1`). `null` opted out.\n   *\n   * Derived from variant + title + message + position when the caller does not\n   * supply one, so two calls that would render the identical toast are the\n   * same toast.\n   */\n  readonly dedupeKey:   string | null;\n  /**\n   * How many times this toast has been raised. `1` for a first occurrence.\n   *\n   * ★ A repeat is COUNTED, not dropped and not duplicated. Dropping it hides\n   *   that the thing is still happening — the difference between one failed\n   *   save and a retry loop failing eleven times is the whole diagnosis —\n   *   and duplicating it buries the rest of the stack under one message.\n   */\n  readonly count:       number;\n  /**\n   * True while the work behind a `promise()` toast is still running — the host\n   * draws a spinner in place of the variant icon and marks the toast busy.\n   * Absent on every other toast.\n   */\n  readonly pending?:    boolean;\n}\n\n/**\n * The three messages of a {@link ToastService.promise} toast. `success` and\n * `error` may be functions of the outcome — \"Saved 3 rows\", \"Upload failed:\n * quota exceeded\".\n */\nexport interface ToastPromiseMessages<T> {\n  /** Shown while the work runs, e.g. `'Saving…'`. */\n  readonly loading: string;\n  /** Replaces it when the work resolves. */\n  readonly success: string | ((value: T) => string);\n  /** Replaces it when the work rejects. */\n  readonly error:   string | ((error: unknown) => string);\n}\n\nexport interface ToastOptions {\n  readonly title?:       string;\n  readonly duration?:    number;\n  readonly dismissible?: boolean;\n  readonly action?:      ToastAction;\n  readonly position?:    ToastPosition;\n  /**\n   * `'route'` dismisses this toast on the next navigation; `'global'` (the\n   * default) keeps it. See {@link ToastScope} — the default is `'global'`\n   * because the commonest toast of all is raised BY a navigating action.\n   */\n  readonly scope?:       ToastScope;\n  /**\n   * Deduplication identity (`X-12`, `OF-19-I1`).\n   *\n   * | Value       | Meaning                                                    |\n   * |-------------|------------------------------------------------------------|\n   * | omitted     | derive one from variant + title + message + position       |\n   * | a string    | dedupe on that, whatever the text — e.g. `'sync-failed'`   |\n   * | `null`      | never dedupe; this call always adds a toast                |\n   *\n   * ★★ THE DEFAULT IS ON, because \"no deduplication\" is the defect: a retry\n   *    loop that fails eleven times filled the screen with eleven identical\n   *    toasts and pushed every other message out of a bounded stack. A repeat\n   *    now refreshes the one that is up, increments its `count`, and restarts\n   *    its countdown.\n   *\n   * ★ An EXPLICIT key is the interesting one: it makes \"Saving…\" and \"Saved\"\n   *   for the same record replace each other, and it makes two different\n   *   records' failures two toasts even when the wording is identical.\n   */\n  readonly dedupeKey?:   string | null;\n}\n\n// ─── Service ─────────────────────────────────────────────────────────────────\n\n// module-id-counter: data id — never rendered as a DOM id during a server render.\nlet _idCounter = 0;\n\n/**\n * ToastService — Imperative notification API.\n *\n * Inject anywhere and call convenience methods:\n *   toast.success('Saved!');\n *   toast.error('Failed', { title: 'Error', duration: 0 });\n *\n * Pair with `<sv-toast-host>` from `@styloviz/toast` in your root layout.\n */\ninterface ToastTimer {\n  /**\n   * The live `setTimeout` handle, or `undefined` while paused.\n   *\n   * ★ `undefined` is the pause flag, and both `pause()` and `resume()` guard on\n   *   it. A paused entry is KEPT (rather than deleted) so `resume()` can restart\n   *   from `remaining`; the absent handle is what distinguishes \"paused\" from\n   *   \"running\" without a second boolean that could disagree with it.\n   */\n  handle?:   ReturnType<typeof setTimeout>;\n  /** ms remaining when the timer was last (re)started. */\n  remaining: number;\n  /** wall-clock time the timer was last started. */\n  startedAt: number;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class ToastService implements OnDestroy {\n  readonly toasts = signal<Toast[]>([]);\n\n  /** Active auto-dismiss timers keyed by toast id (enables pause/resume). */\n  private readonly timers = new Map<string, ToastTimer>();\n\n  success(message: string, opts?: ToastOptions): string {\n    return this.show('success', message, opts);\n  }\n\n  error(message: string, opts?: ToastOptions): string {\n    return this.show('error', message, { duration: 6000, ...opts });\n  }\n\n  warning(message: string, opts?: ToastOptions): string {\n    return this.show('warning', message, opts);\n  }\n\n  info(message: string, opts?: ToastOptions): string {\n    return this.show('info', message, opts);\n  }\n\n  show(variant: ToastVariant, message: string, opts: ToastOptions = {}): string {\n    const duration    = opts.duration ?? 4000;\n    const dismissible = opts.dismissible ?? true;\n    const position    = opts.position ?? 'top-right';\n    const scope       = opts.scope ?? 'global';\n    const dedupeKey   =\n      opts.dedupeKey === null\n        ? null\n        : opts.dedupeKey ??\n          // ★ `\\u0000` as the separator, not `|`: a message may contain any\n          //   printable character, and a joined key that a message can forge\n          //   is a key that can collide with a different message on purpose.\n          //   Position is part of it because two hosts render two stacks —\n          //   the same text top-right and bottom-left is two toasts.\n          [variant, opts.title ?? '', message, position].join('\\u0000');\n\n    if (dedupeKey !== null) {\n      const existing = this.toasts().find((t) => t.dedupeKey === dedupeKey);\n      if (existing) {\n        return this._refresh(existing, {\n          variant,\n          message,\n          title: opts.title,\n          duration,\n          dismissible,\n          action: opts.action,\n          position,\n          scope,\n          dedupeKey,\n        });\n      }\n    }\n\n    const id = `svz-toast-${++_idCounter}`; // sv-i18n-ignore: DOM id\n    const toast: Toast = {\n      id,\n      variant,\n      message,\n      title:       opts.title,\n      duration,\n      dismissible,\n      action:      opts.action,\n      position,\n      scope,\n      dedupeKey,\n      count:       1,\n    };\n\n    this.toasts.update(list => [...list, toast]);\n\n    if (toast.duration > 0) {\n      this.startTimer(id, toast.duration);\n    }\n\n    return id;\n  }\n\n  /**\n   * A repeat of a toast that is already up (`X-12`, `OF-19-I1`).\n   *\n   * ★★★ IT KEEPS ITS PLACE IN THE STACK. Moving a repeat to the newest slot\n   *     displaces every toast below it — under a pointer that is, by design,\n   *     hovering the stack to pause it, which is how a user clicks Dismiss on\n   *     the wrong message. The count and the restarted countdown already say\n   *     \"again, now\". The cost, stated rather than hidden: a repeat of a toast\n   *     that `maxVisible` has already pushed out of view stays out of view.\n   *\n   * ★★ IT KEEPS ITS ID, and returns it. The caller's handle from the first\n   *    call still dismisses, pauses and resumes the thing on screen — and the\n   *    host's \"already announced\" set is keyed by id, so a repeat does not\n   *    shout the same sentence at a screen-reader user a second time.\n   *\n   * ★ The newer call's text, action and duration WIN. With a derived key they\n   *   are identical by construction; with an explicit key the newer wording is\n   *   the fresher truth — that is what makes `'Saving…'` → `'Saved'` on one key\n   *   a replacement rather than two toasts.\n   */\n  private _refresh(existing: Toast, next: Omit<Toast, 'id' | 'count'>): string {\n    const refreshed: Toast = { ...next, id: existing.id, count: existing.count + 1 };\n    this.toasts.update(list => list.map(t => (t.id === existing.id ? refreshed : t)));\n    this.clearTimer(existing.id);\n    if (refreshed.duration > 0) this.startTimer(existing.id, refreshed.duration);\n    return existing.id;\n  }\n\n  /**\n   * One toast for an async action: it shows `messages.loading` while the work\n   * runs, then turns into the success or the error toast — the same toast, in\n   * the same place, announced once more with the outcome (FL-J3-OF-07,\n   * `OF-19-M5`).\n   *\n   * ```ts\n   * await this.toast.promise(this.api.save(row), {\n   *   loading: 'Saving…',\n   *   success: 'Saved',\n   *   error: (e) => `Could not save: ${describe(e)}`,\n   * });\n   * ```\n   *\n   * ★★ THE PENDING TOAST PERSISTS (`duration: 0`) UNTIL THE WORK SETTLES, and\n   *    is not dismissible by default — a \"Saving…\" that times out or is closed\n   *    while the save is still running is a statement about the save that is\n   *    not true. The outcome then takes `opts.duration` (or the variant's\n   *    default: 6 s for an error, 4 s otherwise).\n   *\n   * ★ It RETURNS THE WORK'S OWN PROMISE, so the caller awaits the result and\n   *   handles the rejection exactly as without the toast. If the pending toast\n   *   was dismissed in the meantime, the outcome is raised as a new toast.\n   *\n   * @param work the promise, or a function that starts the work.\n   * @returns the work's promise — it resolves and rejects as the work does.\n   */\n  promise<T>(\n    work: Promise<T> | (() => Promise<T>),\n    messages: ToastPromiseMessages<T>,\n    opts: ToastOptions = {},\n  ): Promise<T> {\n    // ★ A key of its own unless the caller named one: two concurrent saves are\n    //   two toasts, and an identical \"Saving…\" must not fold into the other.\n    const dedupeKey = opts.dedupeKey ?? `svz-promise-${++_idCounter}`; // sv-i18n-ignore: data key\n    const id = this.show('info', messages.loading, {\n      ...opts,\n      dedupeKey,\n      duration: 0,\n      dismissible: opts.dismissible ?? false,\n    });\n    this.toasts.update(list => list.map(t => (t.id === id ? { ...t, pending: true } : t)));\n\n    const settle = (variant: ToastVariant, message: string): void => {\n      const duration = opts.duration ?? (variant === 'error' ? 6000 : 4000);\n      const current = this.toasts().find(t => t.id === id);\n      if (!current) {\n        this.show(variant, message, { ...opts, dedupeKey, duration });\n        return;\n      }\n      // ★ Replaced in place, count untouched: an outcome is not a repeat, and\n      //   a \"×2\" badge on \"Saved\" would claim it happened twice.\n      const settled: Toast = {\n        ...current,\n        variant,\n        message,\n        duration,\n        dismissible: opts.dismissible ?? true,\n        pending: false,\n      };\n      this.toasts.update(list => list.map(t => (t.id === id ? settled : t)));\n      this.clearTimer(id);\n      if (duration > 0) this.startTimer(id, duration);\n    };\n\n    let running: Promise<T>;\n    try {\n      running = typeof work === 'function' ? work() : work;\n    } catch (thrown) {\n      running = Promise.reject(thrown);\n    }\n    return running.then(\n      (value) => {\n        settle('success', typeof messages.success === 'function' ? messages.success(value) : messages.success);\n        return value;\n      },\n      (error: unknown) => {\n        settle('error', typeof messages.error === 'function' ? messages.error(error) : messages.error);\n        throw error;\n      },\n    );\n  }\n\n  dismiss(id: string): void {\n    this.clearTimer(id);\n    this.toasts.update(list => list.filter(t => t.id !== id));\n  }\n\n  dismissAll(): void {\n    this.timers.forEach(t => clearTimeout(t.handle));\n    this.timers.clear();\n    this.toasts.set([]);\n  }\n\n  /**\n   * The app navigated — drop the toasts that were about the page just left\n   * (`X-13`, `OF-19-I5`).\n   *\n   * Router-agnostic on purpose, exactly like `SvOverlayRouteService.navigated()`:\n   * core does not depend on `@angular/router`. `provideSvOverlayRouteClose()`\n   * from `@styloviz/layout` calls this on `NavigationEnd`; an app on a different\n   * router calls it itself.\n   *\n   * ★★ IT IS A POINT IN TIME, NOT A MODE. Only the toasts standing when it is\n   *    called are considered; a `'route'` toast raised afterwards belongs to the\n   *    page just arrived at and is not retroactively stale. That is what makes\n   *    `toast.error('Could not load this view', { scope: 'route' })` usable from\n   *    a route resolver or a landing-page effect.\n   *\n   * ★ Each one goes through `dismiss()` rather than a bulk `set([])`, so its\n   *   auto-dismiss timer is cleared with it. A surviving timer would later fire\n   *   `dismiss(id)` for an id nothing holds — harmless today, and exactly the\n   *   kind of leak that stops being harmless once ids are reused for dedupe\n   *   (`T6`).\n   */\n  navigated(): void {\n    for (const toast of this.toasts()) {\n      if (toast.scope === 'route') this.dismiss(toast.id);\n    }\n  }\n\n  /**\n   * Pause a toast's auto-dismiss countdown (e.g. while the pointer hovers the\n   * stack), preserving the time that was left. No-op for persistent toasts.\n   *\n   * ★ The `!timer.handle` guard is load-bearing, not defensive tidiness.\n   *   `sv-toast-host` calls `pauseAll()` from BOTH `mouseenter` and `focusin`,\n   *   and hovering a toast then tabbing into it fires both. Without the guard\n   *   the second call subtracts the SAME elapsed span from `remaining` a second\n   *   time, so the toast dismisses at roughly half the time it had left —\n   *   under the user's pointer, while they are reading it. `resume()` has\n   *   always had the mirror-image guard; this one was missing.\n   */\n  pause(id: string): void {\n    const timer = this.timers.get(id);\n    if (!timer || !timer.handle) return;\n    clearTimeout(timer.handle);\n    // Keep the entry (with no live handle) so resume() can restart it.\n    this.timers.set(id, {\n      ...timer,\n      handle: undefined,\n      remaining: timer.remaining - (Date.now() - timer.startedAt),\n    });\n  }\n\n  /** Resume a previously paused auto-dismiss countdown with its remaining time. */\n  resume(id: string): void {\n    const timer = this.timers.get(id);\n    if (!timer || timer.handle) return;\n    this.startTimer(id, Math.max(timer.remaining, 0));\n  }\n\n  // ── Internal timer helpers ──────────────────────────────────────────────────\n\n  private startTimer(id: string, duration: number): void {\n    const handle = setTimeout(() => this.dismiss(id), duration);\n    this.timers.set(id, { handle, remaining: duration, startedAt: Date.now() });\n  }\n\n  private clearTimer(id: string): void {\n    const timer = this.timers.get(id);\n    if (timer?.handle) clearTimeout(timer.handle);\n    this.timers.delete(id);\n  }\n\n  /**\n   * Clear every pending auto-dismiss timer when the injector goes (`OF-19-I4`,\n   * and the same defect class as the Alert Banner's `X-2`).\n   *\n   * ★★★ A PENDING `setTimeout` IS A STRONG REFERENCE HELD BY THE RUNTIME. Its\n   *     closure holds this service, which holds every toast in the signal, and\n   *     nothing can collect any of it until the timer fires — up to six\n   *     seconds after the injector that owned it was destroyed. On the server\n   *     that is once per REQUEST: a per-request root injector with a toast in\n   *     flight stays alive, and the callback then calls `dismiss()` on a\n   *     service nothing will ever read again.\n   *\n   * ★★ `ngOnDestroy` RATHER THAN `inject(DestroyRef)`, and the reason is\n   *    testability rather than taste: this service is constructed directly\n   *    (`new ToastService()`) by its own specs and by hosts that want an\n   *    isolated stack, and `inject()` outside an injection context throws.\n   *    Angular calls `ngOnDestroy` on a `providedIn: 'root'` service when its\n   *    injector is destroyed, so both paths work.\n   *\n   * ★ The toasts themselves are left alone. Nothing will read the signal after\n   *   this, and clearing it would be work done for an observer that does not\n   *   exist; the timers are the leak.\n   */\n  ngOnDestroy(): void {\n    this.timers.forEach(t => { if (t.handle) clearTimeout(t.handle); });\n    this.timers.clear();\n  }\n}\n"],"mappings":";;;;AAMA,MAAM,cAAc;AAUpB,SAAS,kBAAe;CACtB,IAAI;EACF,IAAI,OAAO,iBAAiB,aAAa,OAAO;EAChD,MAAM,SAAS,aAAa,QAAQ,WAAW;EAC/C,OAAO,WAAW,UAAU,WAAW,UAAU,SAAS;CAC5D,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,WAAW,OAAY;CAC9B,IAAI;EACF,IAAI,OAAO,iBAAiB,aAAa,aAAa,QAAQ,aAAa,KAAK;CAClF,QAAQ,CAER;AACF;AAoBA,IAAa,eAAb,MAAa,aAAY;CACN,SAAS,OAAO,iBAAiB,EAAE,UAAU,KAAI,CAAE;CAE3D,SAAS,OAAgB,KAAK,oBAAmB,MAAO,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAExE,cAAA;EACE,aAAY;GACV,KAAK,WAAW,KAAK,OAAM,IAAK,SAAS,OAAO;EAClD,CAAC;CACH;CAEA,cAAW;EACT,KAAK,SAAS,KAAK,OAAM,IAAK,UAAU,MAAM;CAChD;CAEA,SAAS,OAAY;EACnB,IAAI,WAAW,KAAK,OAAM,IAAK,SAAS,UAAU;EAOlD,WAAW,KAAK;EAEhB,MAAM,MACJ,OAAO,aAAa,cACf,WACD;EACN,MAAM,sBAAsB,KAAK;EAIjC,IAAI,CAAC,uBAAuB,KAAK,qBAAoB,GAAI;GACvD,KAAK,OAAO,IAAI,UAAU,MAAM;GAChC;EACF;EA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