{"version":3,"file":"styloviz-core-dev.mjs","names":[],"sources":["../../../../projects/core/dev/warn-once.ts","../../../../projects/core/dev/simulate-warning.ts"],"sourcesContent":["import { makeEnvironmentProviders, provideEnvironmentInitializer, type EnvironmentProviders } from '@angular/core';\n\ndeclare const ngDevMode: boolean | undefined;\n\n/** How severe a kit diagnostic is. */\nexport type SvDiagnosticLevel = 'warn' | 'error';\n\n/**\n * Where the kit's diagnostics go — `provideSvDiagnostics`.\n *\n * Every warning and error the kit writes passes through `svWarn` / `svError`,\n * so this one setting governs all of them.\n */\nexport interface SvDiagnosticsConfig {\n  /** Write nothing at all. @default false */\n  readonly silent?: boolean;\n  /**\n   * Receive each diagnostic instead of the console — to forward it to your\n   * error tracker, or to fail a test on one. `message` already carries the\n   * `[styloviz]` prefix; `detail` is whatever the kit passed with it (an\n   * `Error` from a failed export, for instance).\n   */\n  readonly handler?: (level: SvDiagnosticLevel, message: string, detail: readonly unknown[]) => void;\n}\n\n/**\n * ★ Kept on `globalThis` under a registered symbol, not in this module: the\n *   icon package sits below core and cannot import it, yet its \"unregistered\n *   glyph\" warning has to obey the same switch (`@styloviz/icons` reads the\n *   same key). One app, one setting, whichever package wrote the warning.\n */\nconst KEY = Symbol.for('styloviz.diagnostics');\n\nfunction config(): SvDiagnosticsConfig {\n  return ((globalThis as Record<symbol, unknown>)[KEY] as SvDiagnosticsConfig | undefined) ?? {};\n}\n\n/** Set where the kit's diagnostics go. Prefer `provideSvDiagnostics` in an app. */\nexport function svSetDiagnostics(next: SvDiagnosticsConfig): void {\n  (globalThis as Record<symbol, unknown>)[KEY] = next;\n}\n\n/**\n * Silence the kit's console output, or route it, with one provider (FL-I2).\n *\n * ```ts\n * providers: [provideSvDiagnostics({ handler: (level, message, detail) => tracker.capture(message, detail) })]\n * ```\n */\nexport function provideSvDiagnostics(next: SvDiagnosticsConfig): EnvironmentProviders {\n  return makeEnvironmentProviders([provideEnvironmentInitializer(() => svSetDiagnostics(next))]);\n}\n\nfunction report(level: SvDiagnosticLevel, message: string, detail: readonly unknown[]): void {\n  const { silent, handler } = config();\n  if (silent) return;\n  const text = message.startsWith('[') ? message : `[styloviz] ${message}`;\n  if (handler) return handler(level, text, detail);\n  // The kit's one console sink — every other package reports through here.\n  if (level === 'error') console.error(text, ...detail);\n  else console.warn(text, ...detail);\n}\n\n/**\n * A kit warning: something the host should know and the kit cannot fix.\n * Written in every build — gate it on `isDevMode()` at the call site when it\n * is a development aid.\n */\nexport function svWarn(message: string, ...detail: unknown[]): void {\n  report('warn', message, detail);\n}\n\n/** A kit error: an operation failed (an export, a print) and the UI has already said so. */\nexport function svError(message: string, ...detail: unknown[]): void {\n  report('error', message, detail);\n}\n\n/** One warning per key, so a grid of twelve controls logs once. */\nconst warned = new Set<string>();\n\n/**\n * A dev-only warning, emitted at most once per key. Silent in production.\n *\n * ★★ THE `Set` IS THE POINT, NOT THE CONSOLE. A warning that fires on every\n *    change detection in a list of two hundred rows is noise somebody turns\n *    off, and then the next warning is invisible too.\n *\n * ⚠️ NOT A REPLACEMENT FOR A TYPE OR A TEST. It is for the case where the\n *    component can SEE the host has done something contradictory but cannot\n *    fix it, because the thing to fix is on the host's side.\n */\nexport function svWarnOnce(key: string, message: string): void {\n  if (typeof ngDevMode === 'undefined' || !ngDevMode) return;\n  if (warned.has(key)) return;\n  warned.add(key);\n  svWarn(message);\n}\n\n/** Test-only: forget what has already been warned about. */\nexport function svResetWarnOnce(): void { warned.clear(); }\n","import { svWarn } from './warn-once';\ndeclare const ngDevMode: boolean | undefined;\n\n/** One warning per component name, so a grid of twelve cards logs once. */\nconst warned = new Set<string>();\n\n/**\n * Warn that a component is faking work because `simulate` is on.\n *\n * `simulate` defaults to `false` in every component that has it, so production\n * never depends on an integrator remembering a demo switch. This covers the\n * opposite mistake: a demo left on in a dev build, where a fabricated refresh,\n * rewrite, or indexing ramp is indistinguishable from the real thing. Silent in\n * production bundles.\n *\n * Shared rather than copied per package: three components need this warning, and\n * the second copy of \"name the component and say the work was faked\" always\n * drifts from the first.\n */\nexport function svWarnSimulating(selector: string): void {\n  if (typeof ngDevMode === 'undefined' || !ngDevMode) return;\n  if (warned.has(selector)) return;\n  warned.add(selector);\n  svWarn(\n    `[styloviz] <${selector}> ran a simulated action because simulate is true. ` +\n      'Nothing left the component and no real work happened — the result you see ' +\n      'is bundled sample data. Remove simulate before shipping.',\n  );\n}\n"],"mappings":";AA+BA,MAAM,MAAM,OAAO,IAAI,sBAAsB;AAE7C,SAAS,SAAM;CACb,OAAS,WAAuC,QAA4C,CAAA;AAC9F;AAGA,SAAgB,iBAAiB,MAAyB;CACvD,WAAuC,OAAO;AACjD;AASA,SAAgB,qBAAqB,MAAyB;CAC5D,OAAO,yBAAyB,CAAC,oCAAoC,iBAAiB,IAAI,CAAC,CAAC,CAAC;AAC/F;AAEA,SAAS,OAAO,OAA0B,SAAiB,QAA0B;CACnF,MAAM,EAAE,QAAQ,YAAY,OAAM;CAClC,IAAI,QAAQ;CACZ,MAAM,OAAO,QAAQ,WAAW,GAAG,IAAI,UAAU,cAAc;CAC/D,IAAI,SAAS,OAAO,QAAQ,OAAO,MAAM,MAAM;CAE/C,IAAI,UAAU,SAAS,QAAQ,MAAM,MAAM,GAAG,MAAM;MAC/C,QAAQ,KAAK,MAAM,GAAG,MAAM;AACnC;AAOA,SAAgB,OAAO,SAAiB,GAAG,QAAiB;CAC1D,OAAO,QAAQ,SAAS,MAAM;AAChC;AAGA,SAAgB,QAAQ,SAAiB,GAAG,QAAiB;CAC3D,OAAO,SAAS,SAAS,MAAM;AACjC;AAGA,MAAM,2BAAS,IAAI,IAAG;AAatB,SAAgB,WAAW,KAAa,SAAe;CACrD,IAAI,OAAO,cAAc,eAAe,CAAC,WAAW;CACpD,IAAI,SAAO,IAAI,GAAG,GAAG;CACrB,SAAO,IAAI,GAAG;CACd,OAAO,OAAO;AAChB;AAGA,SAAgB,kBAAe;CAAW,SAAO,MAAK;AAAI;AC/F1D,MAAM,yBAAS,IAAI,IAAG;AAetB,SAAgB,iBAAiB,UAAgB;CAC/C,IAAI,OAAO,cAAc,eAAe,CAAC,WAAW;CACpD,IAAI,OAAO,IAAI,QAAQ,GAAG;CAC1B,OAAO,IAAI,QAAQ;CACnB,OACE,eAAe,SAAQ,sLAEqC;AAEhE"}