@aglyn/plugins-marketing 1.0.0-beta.178 → 1.0.0-beta.180

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.
Files changed (71) hide show
  1. package/README.md +3 -3
  2. package/package.json +15 -15
  3. package/src/lib/components/campaign-conversions-card.js +22 -4
  4. package/src/lib/components/campaign-conversions-card.js.map +1 -1
  5. package/src/lib/components/campaign-detail-card.js +3 -4
  6. package/src/lib/components/campaign-detail-card.js.map +1 -1
  7. package/src/lib/components/campaign-report-card.js +3 -3
  8. package/src/lib/components/campaign-report-card.js.map +1 -1
  9. package/src/lib/components/email-compose-card.d.ts +5 -2
  10. package/src/lib/components/email-compose-card.js +2 -3
  11. package/src/lib/components/email-compose-card.js.map +1 -1
  12. package/src/lib/components/email-detail.d.ts +5 -2
  13. package/src/lib/components/email-detail.js +4 -4
  14. package/src/lib/components/email-detail.js.map +1 -1
  15. package/src/lib/components/email-messages-widget.d.ts +17 -2
  16. package/src/lib/components/email-messages-widget.js +33 -2
  17. package/src/lib/components/email-messages-widget.js.map +1 -1
  18. package/src/lib/components/emails-list-card.d.ts +9 -6
  19. package/src/lib/components/emails-list-card.js +9 -9
  20. package/src/lib/components/emails-list-card.js.map +1 -1
  21. package/src/lib/components/host-experiments-card.component.d.ts +2 -0
  22. package/src/lib/components/host-experiments-card.component.js +20 -25
  23. package/src/lib/components/host-experiments-card.component.js.map +1 -1
  24. package/src/lib/components/host-marketing-summary-card.component.d.ts +15 -0
  25. package/src/lib/components/host-marketing-summary-card.component.js +59 -68
  26. package/src/lib/components/host-marketing-summary-card.component.js.map +1 -1
  27. package/src/lib/components/host-overlays-card.component.js +15 -37
  28. package/src/lib/components/host-overlays-card.component.js.map +1 -1
  29. package/src/lib/components/inbox-campaigns-widget.d.ts +23 -0
  30. package/src/lib/components/inbox-campaigns-widget.js +63 -0
  31. package/src/lib/components/inbox-campaigns-widget.js.map +1 -0
  32. package/src/lib/components/marketing-aggregates.d.ts +95 -0
  33. package/src/lib/components/marketing-aggregates.js +114 -0
  34. package/src/lib/components/marketing-aggregates.js.map +1 -0
  35. package/src/lib/components/marketing-console-page.js +32 -27
  36. package/src/lib/components/marketing-console-page.js.map +1 -1
  37. package/src/lib/components/marketing-console-sections.d.ts +24 -13
  38. package/src/lib/components/marketing-console-sections.js +37 -12
  39. package/src/lib/components/marketing-console-sections.js.map +1 -1
  40. package/src/lib/components/org-conversions-section.d.ts +32 -0
  41. package/src/lib/components/org-conversions-section.js +130 -0
  42. package/src/lib/components/org-conversions-section.js.map +1 -0
  43. package/src/lib/components/org-experiments-card.d.ts +32 -0
  44. package/src/lib/components/org-experiments-card.js +407 -0
  45. package/src/lib/components/org-experiments-card.js.map +1 -0
  46. package/src/lib/components/org-marketing-overview-card.d.ts +34 -0
  47. package/src/lib/components/org-marketing-overview-card.js +342 -0
  48. package/src/lib/components/org-marketing-overview-card.js.map +1 -0
  49. package/src/lib/components/org-overlays-card.d.ts +35 -0
  50. package/src/lib/components/org-overlays-card.js +345 -0
  51. package/src/lib/components/org-overlays-card.js.map +1 -0
  52. package/src/lib/components/org-site-picker-button.d.ts +26 -0
  53. package/src/lib/components/org-site-picker-button.js +104 -0
  54. package/src/lib/components/org-site-picker-button.js.map +1 -0
  55. package/src/lib/components/overlay-labels.d.ts +38 -0
  56. package/src/lib/components/overlay-labels.js +55 -0
  57. package/src/lib/components/overlay-labels.js.map +1 -0
  58. package/src/lib/components/use-emails-hub-path.d.ts +17 -8
  59. package/src/lib/components/use-emails-hub-path.js +29 -11
  60. package/src/lib/components/use-emails-hub-path.js.map +1 -1
  61. package/src/lib/components/use-one-shot-reads.d.ts +55 -0
  62. package/src/lib/components/use-one-shot-reads.js +168 -0
  63. package/src/lib/components/use-one-shot-reads.js.map +1 -0
  64. package/src/lib/model/experiments.d.ts +35 -0
  65. package/src/lib/model/experiments.js +34 -0
  66. package/src/lib/model/experiments.js.map +1 -1
  67. package/src/lib/model/overlays.d.ts +13 -2
  68. package/src/lib/model/overlays.js +18 -6
  69. package/src/lib/model/overlays.js.map +1 -1
  70. package/src/lib/plugin.js +13 -8
  71. package/src/lib/plugin.js.map +1 -1
@@ -39,17 +39,29 @@
39
39
  if (overlay.endAtMs && nowMs > overlay.endAtMs) return false;
40
40
  return true;
41
41
  }
42
+ /**
43
+ * Whether an overlay is switched off, switched on but outside its window, or
44
+ * showing now — the status every overlay list draws as a chip.
45
+ */ export function overlayStatus(overlay, nowMs) {
46
+ if (overlay.enabled === false) return 'off';
47
+ return overlayActiveAt(overlay, nowMs) ? 'live' : 'scheduled';
48
+ }
49
+ /**
50
+ * The precedence overlays take when several match a page: `order`, then
51
+ * name. Only the console's reorder arrows ever write `order`, so most
52
+ * overlays share its default of 0 and fall through to their names.
53
+ */ export function compareOverlayPrecedence(a, b) {
54
+ var _a_order, _b_order, _a_name, _b_name;
55
+ return ((_a_order = a.order) != null ? _a_order : 0) - ((_b_order = b.order) != null ? _b_order : 0) || String((_a_name = a.name) != null ? _a_name : '').localeCompare(String((_b_name = b.name) != null ? _b_name : ''));
56
+ }
42
57
  /**
43
58
  * Picks the overlays to render for a page: enabled, inside their window,
44
- * targeting the path — sorted by `order` then name, first of each kind
45
- * wins (one bar + one popup per page render).
59
+ * targeting the path — sorted by {@link compareOverlayPrecedence}, first of
60
+ * each kind wins (one bar + one popup per page render).
46
61
  */ export function resolveActiveOverlays(overlays, context) {
47
62
  var _context_nowMs, _active_find, _active_find1;
48
63
  const nowMs = (_context_nowMs = context.nowMs) != null ? _context_nowMs : Date.now();
49
- const active = overlays.filter((overlay)=>overlay.enabled !== false && overlayActiveAt(overlay, nowMs) && overlayMatchesPath(overlay, context.path)).sort((a, b)=>{
50
- var _a_order, _b_order, _a_name, _b_name;
51
- return ((_a_order = a.order) != null ? _a_order : 0) - ((_b_order = b.order) != null ? _b_order : 0) || String((_a_name = a.name) != null ? _a_name : '').localeCompare(String((_b_name = b.name) != null ? _b_name : ''));
52
- });
64
+ const active = overlays.filter((overlay)=>overlay.enabled !== false && overlayActiveAt(overlay, nowMs) && overlayMatchesPath(overlay, context.path)).sort(compareOverlayPrecedence);
53
65
  return {
54
66
  bar: (_active_find = active.find((overlay)=>overlay.kind === 'bar' && overlay.bar)) != null ? _active_find : null,
55
67
  popup: (_active_find1 = active.find((overlay)=>overlay.kind === 'popup' && overlay.popup)) != null ? _active_find1 : null
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/model/overlays.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n HostAnnouncementBar,\n HostPopup,\n} from '@aglyn/aglyn'\n\n/**\n * Marketing hub overlays (AGL-251): multiple announcement bars and\n * promotional popups per host at `hosts/{hostId}/overlays/{overlayId}`,\n * each with its own schedule window and page targeting. The legacy single\n * `host.announcementBar` / `host.popup` fields keep working as fallbacks\n * when no overlay doc matches. Pure types + resolution helpers here; the\n * tenant render picks the first active match per kind.\n */\nexport interface HostOverlay {\n kind: 'bar' | 'popup'\n /** Display name in the console list (e.g. \"Black Friday bar\"). */\n name?: string\n /** Disabled overlays never render; new overlays default enabled. */\n enabled?: boolean\n /** Bar payload when `kind: 'bar'` (the legacy shape, minus enabled). */\n bar?: Omit<HostAnnouncementBar, 'enabled'>\n /** Popup payload when `kind: 'popup'` (the legacy shape, minus enabled). */\n popup?: Omit<HostPopup, 'enabled' | 'startAtMs' | 'endAtMs'>\n /** Showing window (epoch millis; simple to serialize). */\n startAtMs?: number\n endAtMs?: number\n /**\n * Path patterns the overlay shows on; empty/absent = every page.\n * Patterns are exact paths or prefix globs (`/pricing`, `/blog/*`).\n */\n pathPatterns?: string[]\n /** Path patterns the overlay never shows on; wins over includes. */\n excludePathPatterns?: string[]\n /** List order; lower renders first when several match. */\n order?: number\n /**\n * Aggregate engagement counters (AGL-271), incremented server-side by\n * the tenant beacon — never written from the console.\n */\n stats?: {\n impressions?: number\n clicks?: number\n dismissals?: number\n }\n}\n\n/** Exact-or-prefix-glob path match: `/blog/*` matches `/blog/anything`. */\nexport function overlayPatternMatches(pattern: string, path: string): boolean {\n const cleaned = pattern.trim()\n if (!cleaned) return false\n const normalizedPath = path === '' ? '/' : path\n if (cleaned.endsWith('/*')) {\n const prefix = cleaned.slice(0, -2)\n if (!prefix || prefix === '/') return normalizedPath.startsWith('/')\n return (\n normalizedPath === prefix || normalizedPath.startsWith(`${prefix}/`)\n )\n }\n return normalizedPath === cleaned\n}\n\n/** True when the overlay targets the given path (include/exclude rules). */\nexport function overlayMatchesPath(\n overlay: Pick<HostOverlay, 'pathPatterns' | 'excludePathPatterns'>,\n path: string,\n): boolean {\n const excludes = overlay.excludePathPatterns ?? []\n if (excludes.some((pattern) => overlayPatternMatches(pattern, path))) {\n return false\n }\n const includes = (overlay.pathPatterns ?? []).filter((pattern) =>\n pattern.trim(),\n )\n if (!includes.length) return true\n return includes.some((pattern) => overlayPatternMatches(pattern, path))\n}\n\n/** True when `nowMs` falls inside the overlay's schedule window. */\nexport function overlayActiveAt(\n overlay: Pick<HostOverlay, 'startAtMs' | 'endAtMs'>,\n nowMs: number,\n): boolean {\n if (overlay.startAtMs && nowMs < overlay.startAtMs) return false\n if (overlay.endAtMs && nowMs > overlay.endAtMs) return false\n return true\n}\n\n/**\n * Picks the overlays to render for a page: enabled, inside their window,\n * targeting the path — sorted by `order` then name, first of each kind\n * wins (one bar + one popup per page render).\n */\nexport function resolveActiveOverlays(\n overlays: Array<HostOverlay & { $id?: string }>,\n context: { path: string; nowMs?: number },\n): {\n bar: (HostOverlay & { $id?: string }) | null\n popup: (HostOverlay & { $id?: string }) | null\n} {\n const nowMs = context.nowMs ?? Date.now()\n const active = overlays\n .filter(\n (overlay) =>\n overlay.enabled !== false &&\n overlayActiveAt(overlay, nowMs) &&\n overlayMatchesPath(overlay, context.path),\n )\n .sort(\n (a, b) =>\n (a.order ?? 0) - (b.order ?? 0) ||\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n return {\n bar: active.find((overlay) => overlay.kind === 'bar' && overlay.bar) ?? null,\n popup:\n active.find((overlay) => overlay.kind === 'popup' && overlay.popup) ??\n null,\n }\n}\n\n/** What a popup's frequency cap reads and writes. */\nexport type PopupCapStore = 'session' | 'local'\n\n/**\n * Which store a popup's frequency cap uses (AGL-2174).\n *\n * `sessionStorage` for a per-session cap, because that IS the lifetime the\n * setting names: it clears when the tab closes. `frequencyDays: 1` cannot\n * express it — a visitor who dismissed at 23:59 would be suppressed for\n * one minute and then shown the popup again.\n *\n * The read and the write must agree. Stamping `localStorage` for a\n * session-capped popup leaves a timestamp nothing reads, which outlives\n * the cap it was meant to record.\n */\nexport function popupCapStore(popup: {\n oncePerSession?: boolean\n}): PopupCapStore {\n return popup?.oncePerSession ? 'session' : 'local'\n}\n\n/**\n * Whether a popup is currently suppressed by its own frequency cap.\n *\n * `sessionFlag` is whatever `sessionStorage` holds for it; `lastShownMs`\n * is the `localStorage` timestamp. Exactly one is consulted — the two caps\n * are alternative answers to the same question, and honouring both would\n * suppress a popup for the session AND for a week afterwards.\n */\nexport function popupSuppressed(\n popup: { oncePerSession?: boolean; frequencyDays?: number },\n state: { sessionFlag?: string | null; lastShownMs?: number | null },\n nowMs: number,\n): boolean {\n if (popup?.oncePerSession) return Boolean(state.sessionFlag)\n const stamp = Number(state.lastShownMs ?? 0)\n if (!stamp) return false\n // A missing or zero `frequencyDays` means \"no day cap configured\", and\n // the comparison already says so: `now - stamp` is positive for any\n // real stamp, so it is never below zero. Stated rather than guarded —\n // an `if (!days) return false` above this line reads like a guard while\n // being unreachable, which is the kind of line a later reader trusts.\n const days = Number(popup?.frequencyDays ?? 0)\n return nowMs - stamp < days * 86_400_000\n}\n"],"names":["overlayPatternMatches","pattern","path","cleaned","trim","normalizedPath","endsWith","prefix","slice","startsWith","overlayMatchesPath","overlay","excludes","excludePathPatterns","some","includes","pathPatterns","filter","length","overlayActiveAt","nowMs","startAtMs","endAtMs","resolveActiveOverlays","overlays","context","active","Date","now","enabled","sort","a","b","order","String","name","localeCompare","bar","find","kind","popup","popupCapStore","oncePerSession","popupSuppressed","state","Boolean","sessionFlag","stamp","Number","lastShownMs","days","frequencyDays"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAgDD,yEAAyE,GACzE,OAAO,SAASA,sBAAsBC,OAAe,EAAEC,IAAY;IACjE,MAAMC,UAAUF,QAAQG,IAAI;IAC5B,IAAI,CAACD,SAAS,OAAO;IACrB,MAAME,iBAAiBH,SAAS,KAAK,MAAMA;IAC3C,IAAIC,QAAQG,QAAQ,CAAC,OAAO;QAC1B,MAAMC,SAASJ,QAAQK,KAAK,CAAC,GAAG,CAAC;QACjC,IAAI,CAACD,UAAUA,WAAW,KAAK,OAAOF,eAAeI,UAAU,CAAC;QAChE,OACEJ,mBAAmBE,UAAUF,eAAeI,UAAU,CAAC,GAAGF,OAAO,CAAC,CAAC;IAEvE;IACA,OAAOF,mBAAmBF;AAC5B;AAEA,0EAA0E,GAC1E,OAAO,SAASO,mBACdC,OAAkE,EAClET,IAAY;QAEKS,8BAICA;IAJlB,MAAMC,YAAWD,+BAAAA,QAAQE,mBAAmB,YAA3BF,+BAA+B,EAAE;IAClD,IAAIC,SAASE,IAAI,CAAC,CAACb,UAAYD,sBAAsBC,SAASC,QAAQ;QACpE,OAAO;IACT;IACA,MAAMa,WAAW,EAACJ,wBAAAA,QAAQK,YAAY,YAApBL,wBAAwB,EAAE,EAAEM,MAAM,CAAC,CAAChB,UACpDA,QAAQG,IAAI;IAEd,IAAI,CAACW,SAASG,MAAM,EAAE,OAAO;IAC7B,OAAOH,SAASD,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dH,KAA2D,EAC3DI,KAAmE,EACnExB,KAAa;QAGQwB;IADrB,IAAIJ,yBAAAA,MAAOE,cAAc,EAAE,OAAOG,QAAQD,MAAME,WAAW;IAC3D,MAAMC,QAAQC,QAAOJ,qBAAAA,MAAMK,WAAW,YAAjBL,qBAAqB;IAC1C,IAAI,CAACG,OAAO,OAAO;IACnB,uEAAuE;IACvE,oEAAoE;IACpE,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,MAAMG,OAAOF,eAAOR,yBAAAA,MAAOW,aAAa,mBAAI;IAC5C,OAAO/B,QAAQ2B,QAAQG,OAAO;AAChC"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/model/overlays.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n HostAnnouncementBar,\n HostPopup,\n} from '@aglyn/aglyn'\n\n/**\n * Marketing hub overlays (AGL-251): multiple announcement bars and\n * promotional popups per host at `hosts/{hostId}/overlays/{overlayId}`,\n * each with its own schedule window and page targeting. The legacy single\n * `host.announcementBar` / `host.popup` fields keep working as fallbacks\n * when no overlay doc matches. Pure types + resolution helpers here; the\n * tenant render picks the first active match per kind.\n */\nexport interface HostOverlay {\n kind: 'bar' | 'popup'\n /** Display name in the console list (e.g. \"Black Friday bar\"). */\n name?: string\n /** Disabled overlays never render; new overlays default enabled. */\n enabled?: boolean\n /** Bar payload when `kind: 'bar'` (the legacy shape, minus enabled). */\n bar?: Omit<HostAnnouncementBar, 'enabled'>\n /** Popup payload when `kind: 'popup'` (the legacy shape, minus enabled). */\n popup?: Omit<HostPopup, 'enabled' | 'startAtMs' | 'endAtMs'>\n /** Showing window (epoch millis; simple to serialize). */\n startAtMs?: number\n endAtMs?: number\n /**\n * Path patterns the overlay shows on; empty/absent = every page.\n * Patterns are exact paths or prefix globs (`/pricing`, `/blog/*`).\n */\n pathPatterns?: string[]\n /** Path patterns the overlay never shows on; wins over includes. */\n excludePathPatterns?: string[]\n /** List order; lower renders first when several match. */\n order?: number\n /**\n * Aggregate engagement counters (AGL-271), incremented server-side by\n * the tenant beacon — never written from the console.\n */\n stats?: {\n impressions?: number\n clicks?: number\n dismissals?: number\n }\n}\n\n/** Exact-or-prefix-glob path match: `/blog/*` matches `/blog/anything`. */\nexport function overlayPatternMatches(pattern: string, path: string): boolean {\n const cleaned = pattern.trim()\n if (!cleaned) return false\n const normalizedPath = path === '' ? '/' : path\n if (cleaned.endsWith('/*')) {\n const prefix = cleaned.slice(0, -2)\n if (!prefix || prefix === '/') return normalizedPath.startsWith('/')\n return (\n normalizedPath === prefix || normalizedPath.startsWith(`${prefix}/`)\n )\n }\n return normalizedPath === cleaned\n}\n\n/** True when the overlay targets the given path (include/exclude rules). */\nexport function overlayMatchesPath(\n overlay: Pick<HostOverlay, 'pathPatterns' | 'excludePathPatterns'>,\n path: string,\n): boolean {\n const excludes = overlay.excludePathPatterns ?? []\n if (excludes.some((pattern) => overlayPatternMatches(pattern, path))) {\n return false\n }\n const includes = (overlay.pathPatterns ?? []).filter((pattern) =>\n pattern.trim(),\n )\n if (!includes.length) return true\n return includes.some((pattern) => overlayPatternMatches(pattern, path))\n}\n\n/** True when `nowMs` falls inside the overlay's schedule window. */\nexport function overlayActiveAt(\n overlay: Pick<HostOverlay, 'startAtMs' | 'endAtMs'>,\n nowMs: number,\n): boolean {\n if (overlay.startAtMs && nowMs < overlay.startAtMs) return false\n if (overlay.endAtMs && nowMs > overlay.endAtMs) return false\n return true\n}\n\n/**\n * Whether an overlay is switched off, switched on but outside its window, or\n * showing now — the status every overlay list draws as a chip.\n */\nexport function overlayStatus(\n overlay: Pick<HostOverlay, 'enabled' | 'startAtMs' | 'endAtMs'>,\n nowMs: number,\n): 'off' | 'scheduled' | 'live' {\n if (overlay.enabled === false) return 'off'\n return overlayActiveAt(overlay, nowMs) ? 'live' : 'scheduled'\n}\n\n/**\n * The precedence overlays take when several match a page: `order`, then\n * name. Only the console's reorder arrows ever write `order`, so most\n * overlays share its default of 0 and fall through to their names.\n */\nexport function compareOverlayPrecedence(\n a: Pick<HostOverlay, 'order' | 'name'>,\n b: Pick<HostOverlay, 'order' | 'name'>,\n): number {\n return (\n (a.order ?? 0) - (b.order ?? 0) ||\n String(a.name ?? '').localeCompare(String(b.name ?? ''))\n )\n}\n\n/**\n * Picks the overlays to render for a page: enabled, inside their window,\n * targeting the path — sorted by {@link compareOverlayPrecedence}, first of\n * each kind wins (one bar + one popup per page render).\n */\nexport function resolveActiveOverlays(\n overlays: Array<HostOverlay & { $id?: string }>,\n context: { path: string; nowMs?: number },\n): {\n bar: (HostOverlay & { $id?: string }) | null\n popup: (HostOverlay & { $id?: string }) | null\n} {\n const nowMs = context.nowMs ?? Date.now()\n const active = overlays\n .filter(\n (overlay) =>\n overlay.enabled !== false &&\n overlayActiveAt(overlay, nowMs) &&\n overlayMatchesPath(overlay, context.path),\n )\n .sort(compareOverlayPrecedence)\n return {\n bar: active.find((overlay) => overlay.kind === 'bar' && overlay.bar) ?? null,\n popup:\n active.find((overlay) => overlay.kind === 'popup' && overlay.popup) ??\n null,\n }\n}\n\n/** What a popup's frequency cap reads and writes. */\nexport type PopupCapStore = 'session' | 'local'\n\n/**\n * Which store a popup's frequency cap uses (AGL-2174).\n *\n * `sessionStorage` for a per-session cap, because that IS the lifetime the\n * setting names: it clears when the tab closes. `frequencyDays: 1` cannot\n * express it — a visitor who dismissed at 23:59 would be suppressed for\n * one minute and then shown the popup again.\n *\n * The read and the write must agree. Stamping `localStorage` for a\n * session-capped popup leaves a timestamp nothing reads, which outlives\n * the cap it was meant to record.\n */\nexport function popupCapStore(popup: {\n oncePerSession?: boolean\n}): PopupCapStore {\n return popup?.oncePerSession ? 'session' : 'local'\n}\n\n/**\n * Whether a popup is currently suppressed by its own frequency cap.\n *\n * `sessionFlag` is whatever `sessionStorage` holds for it; `lastShownMs`\n * is the `localStorage` timestamp. Exactly one is consulted — the two caps\n * are alternative answers to the same question, and honouring both would\n * suppress a popup for the session AND for a week afterwards.\n */\nexport function popupSuppressed(\n popup: { oncePerSession?: boolean; frequencyDays?: number },\n state: { sessionFlag?: string | null; lastShownMs?: number | null },\n nowMs: number,\n): boolean {\n if (popup?.oncePerSession) return Boolean(state.sessionFlag)\n const stamp = Number(state.lastShownMs ?? 0)\n if (!stamp) return false\n // A missing or zero `frequencyDays` means \"no day cap configured\", and\n // the comparison already says so: `now - stamp` is positive for any\n // real stamp, so it is never below zero. Stated rather than guarded —\n // an `if (!days) return false` above this line reads like a guard while\n // being unreachable, which is the kind of line a later reader trusts.\n const days = Number(popup?.frequencyDays ?? 0)\n return nowMs - stamp < days * 86_400_000\n}\n"],"names":["overlayPatternMatches","pattern","path","cleaned","trim","normalizedPath","endsWith","prefix","slice","startsWith","overlayMatchesPath","overlay","excludes","excludePathPatterns","some","includes","pathPatterns","filter","length","overlayActiveAt","nowMs","startAtMs","endAtMs","overlayStatus","enabled","compareOverlayPrecedence","a","b","order","String","name","localeCompare","resolveActiveOverlays","overlays","context","active","Date","now","sort","bar","find","kind","popup","popupCapStore","oncePerSession","popupSuppressed","state","Boolean","sessionFlag","stamp","Number","lastShownMs","days","frequencyDays"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAgDD,yEAAyE,GACzE,OAAO,SAASA,sBAAsBC,OAAe,EAAEC,IAAY;IACjE,MAAMC,UAAUF,QAAQG,IAAI;IAC5B,IAAI,CAACD,SAAS,OAAO;IACrB,MAAME,iBAAiBH,SAAS,KAAK,MAAMA;IAC3C,IAAIC,QAAQG,QAAQ,CAAC,OAAO;QAC1B,MAAMC,SA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/plugin.js CHANGED
@@ -24,7 +24,10 @@ import { BUNDLE_ID } from "./constants/bundle-common.js";
24
24
  import { registerMarketingRecordRoutes } from "./model/marketing-record-routes.js";
25
25
  /** Code-split: the Marketing console page only loads when opened. */ const MarketingConsolePage = lazy(()=>import("./components/marketing-console-page.js"));
26
26
  /** Dashboard glance card, loaded only where the shell renders the slot. */ const CampaignGlanceCard = lazy(()=>import("./components/campaign-glance-card.component.js"));
27
- /** The site's campaigns, drawn in the Inbox's Campaigns section. */ const HostCampaignsCard = lazy(()=>import("./components/campaigns-card.js"));
27
+ /**
28
+ * The campaigns drawn in the Inbox's Campaigns section: one site's, or every
29
+ * site's on the organization's Inbox.
30
+ */ const InboxCampaignsWidget = lazy(()=>import("./components/inbox-campaigns-widget.js"));
28
31
  /** The Emails page's Messages section: the list, one message, its composer. */ const EmailMessagesWidget = lazy(()=>import("./components/email-messages-widget.js"));
29
32
  /** Who received the sends built from one template, on the template's page. */ const EmailRecipientsCard = lazy(()=>import("./components/email-recipients-card.js"));
30
33
  /** Loaded where a record page draws one of the attribution zones. */ const RecordAttributionWidget = lazy(()=>import("./components/record-attribution-widget.js"));
@@ -131,7 +134,7 @@ import { registerMarketingRecordRoutes } from "./model/marketing-record-routes.j
131
134
  slot: 'inboxCampaigns',
132
135
  widgetId: 'marketing-inbox-campaigns',
133
136
  title: 'Campaigns',
134
- Component: HostCampaignsCard
137
+ Component: InboxCampaignsWidget
135
138
  },
136
139
  {
137
140
  slot: 'inboxRecordAttribution',
@@ -162,11 +165,13 @@ import { registerMarketingRecordRoutes } from "./model/marketing-record-routes.j
162
165
  }
163
166
  ],
164
167
  /*
165
- * The ORGANIZATION's Marketing hub, at `/[orgSlug]/marketing`. Campaigns,
166
- * their emails and their sequence rollups belong to the organization, so
167
- * this is where one campaign is placed across several sites and where
168
- * every site's mail is read at once. The page is the same component;
169
- * handed no site, it renders the org sections.
168
+ * The ORGANIZATION's Marketing hub, at `/[orgSlug]/marketing`: every
169
+ * section the site hub has, over every site. Campaigns and their sequence
170
+ * rollups belong to the organization, so this is where one campaign is
171
+ * placed across several sites; overlays, tests and conversions stay each
172
+ * site's and are read across them. Every site's mail is on the
173
+ * organization's Emails page, as a site's is on its own. The page is the
174
+ * same component; handed no site, it renders the org sections.
170
175
  *
171
176
  * It carries the SITE tab's id on purpose, the way the org CRM tab does:
172
177
  * `release_marketing` names `nav-tab-marketing`, so one flag holds both
@@ -186,7 +191,7 @@ import { registerMarketingRecordRoutes } from "./model/marketing-record-routes.j
186
191
  icon: {
187
192
  path: mdiBullhornOutline.path
188
193
  },
189
- docsTopic: 'emailCampaigns'
194
+ docsTopic: 'marketingOverlays'
190
195
  },
191
196
  Component: MarketingConsolePage
192
197
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/marketing/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n registerPluginZone,\n type PluginZone,\n} from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport { mdiBullhornOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport {\n CAMPAIGN_DESIGN_CREATE_ZONE,\n CAMPAIGN_DESIGN_PREVIEW_ZONE,\n CAMPAIGN_SENDER_EDITOR_ZONE,\n CAMPAIGN_TOPIC_OPTIONS_ZONE,\n CAMPAIGN_TOPIC_SELECT_ZONE,\n} from './components/campaign-email-zones'\nimport {\n EXPERIMENT_RESULT_ZONE,\n EXPERIMENT_VARIANTS_ZONE,\n} from './components/experiment-zones'\nimport {\n MARKETING_CONSOLE_SECTIONS,\n MARKETING_ORG_CONSOLE_SECTIONS,\n} from './components/marketing-console-sections'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { registerMarketingRecordRoutes } from './model/marketing-record-routes'\n\n/** Code-split: the Marketing console page only loads when opened. */\nconst MarketingConsolePage = lazy(\n () => import('./components/marketing-console-page'),\n)\n\n/** Dashboard glance card, loaded only where the shell renders the slot. */\nconst CampaignGlanceCard = lazy(\n () => import('./components/campaign-glance-card.component'),\n)\n\n/** The site's campaigns, drawn in the Inbox's Campaigns section. */\nconst HostCampaignsCard = lazy(() => import('./components/campaigns-card'))\n\n/** The Emails page's Messages section: the list, one message, its composer. */\nconst EmailMessagesWidget = lazy(\n () => import('./components/email-messages-widget'),\n)\n\n/** Who received the sends built from one template, on the template's page. */\nconst EmailRecipientsCard = lazy(\n () => import('./components/email-recipients-card'),\n)\n\n/** Loaded where a record page draws one of the attribution zones. */\nconst RecordAttributionWidget = lazy(\n () => import('./components/record-attribution-widget'),\n)\n\n/**\n * Marketing feature plugin (AGL-395). Console-only — overlays and popups\n * render on published sites through the tenant runtime, not a canvas\n * element of their own, so there is no UI bundle. The console half declares\n * the Marketing nav + page through the ConsoleExtension registry (always-on;\n * the surface itself is not release-flagged — its overlays/A-B cards run\n * their own per-plan checks off the passed `org`). The popup image picker\n * uses the shell's media browser via `useMediaPicker`.\n */\nexport function registerMarketingConsole(): void {\n /*\n * The two positions the A/B testing card hosts (AGL-2914), declared before\n * the extension that draws the card. An id another plugin has already taken\n * is refused, naming both. What each zone hands a widget is carried on its\n * token, in `components/experiment-zones`, so a widget elsewhere is written\n * against the same shape without importing this plugin.\n */\n registerPluginZone(\n {\n zone: EXPERIMENT_VARIANTS_ZONE,\n label: 'A/B test variants',\n surface: 'console',\n description:\n 'In the experiment editor, beside the variants. A widget here proposes copy for the variants the editor holds; the dialog’s Save is the write, and nothing a widget returns starts or changes a test.',\n },\n // Named rather than left to the loader's marker, because this function is\n // also called directly — by a spec, and by an app that loads the plugin\n // without the loader — and a zone with no owner is refused.\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: EXPERIMENT_RESULT_ZONE,\n label: 'A/B test result',\n surface: 'console',\n description:\n 'Below the results of one test. A widget here explains what the figures show. There is nothing to apply, and a widget may not declare a winner the card has not.',\n },\n { pluginId: BUNDLE_ID },\n )\n /*\n * What a campaign email asks of whichever plugin keeps the mail itself —\n * the topic catalog, the sending identities, the design document and its\n * renderer. Each is a zone the composer or a message's page hosts; see\n * `components/campaign-email-zones` for what each hands a widget. All are\n * `bare`: a widget there is a field, a button, a drawer or nothing at all,\n * and the stack's spacing around it would be a gap in a form.\n */\n const bareZone = <Props,>(\n zone: PluginZone<Props>,\n label: string,\n description: string,\n ) =>\n registerPluginZone(\n { zone, label, description, surface: 'console', layout: 'bare' },\n { pluginId: BUNDLE_ID },\n )\n bareZone(\n CAMPAIGN_TOPIC_SELECT_ZONE,\n 'An email’s topic',\n 'In the campaign composer’s field stack. A widget here is the picker for the stream the email belongs to: it is handed the chosen id and reports a new one through `onChange`. The composer records it; the widget writes nothing.',\n )\n bareZone(\n CAMPAIGN_TOPIC_OPTIONS_ZONE,\n 'The topics a campaign can open on',\n 'Beside the drawers that create and edit a campaign. A widget here draws nothing: while `enabled` it reads the streams a recipient can still leave and answers through `onTopics`.',\n )\n bareZone(\n CAMPAIGN_SENDER_EDITOR_ZONE,\n 'Add a sender while composing',\n 'Mounted by the campaign composer once its author asks to add a sender. A widget here is that editor, open in its add mode; `onSaved` names the sender it created.',\n )\n bareZone(\n CAMPAIGN_DESIGN_CREATE_ZONE,\n 'A design for one email',\n 'In the campaign composer, beside the design picker. A widget here is the control that mints a design document and names it through `onCreated`; the composer records the choice on the campaign and opens the editor.',\n )\n bareZone(\n CAMPAIGN_DESIGN_PREVIEW_ZONE,\n 'A sent email as an inbox receives it',\n 'On one message’s page. A widget here renders the stored design, or the plain-text body, through the renderer the send path uses.',\n )\n registerMarketingRecordRoutes()\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Marketing',\n /*\n * The host dashboard's `Last campaign` card (AGL-433). A widget rather\n * than a direct import by the dashboard page, so it appears only on\n * workspaces that have the plugin that owns the campaign history — a card\n * about campaigns on a console with no campaigns page could only ever be\n * blank, and its header links straight into `/marketing/campaigns`.\n */\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n // The id a reader's dashboard preferences already name — it is what\n // `isDashboardWidgetHidden` and the customize order are keyed on, so\n // it is persisted and does not follow the plugin.\n widgetId: 'email-campaign-glance',\n title: 'Last campaign',\n Component: CampaignGlanceCard,\n },\n // Which campaign or link brought a person, drawn where the plugins that\n // keep and list people host a zone for it. They hand over what the\n // record is and its id; neither imports this plugin.\n {\n slot: 'crmRecordAttribution',\n widgetId: 'marketing-crm-record-attribution',\n title: 'Campaign attribution',\n Component: RecordAttributionWidget,\n },\n // The Emails page hosts its Messages section as a zone: a message is\n // one send of a campaign, and every action on it is this plugin's route.\n {\n slot: 'emailMessages',\n widgetId: 'marketing-email-messages',\n title: 'Messages',\n Component: EmailMessagesWidget,\n },\n {\n slot: 'emailTemplateRecipients',\n widgetId: 'marketing-email-template-recipients',\n title: 'Recipients',\n Component: EmailRecipientsCard,\n },\n // The Inbox's Campaigns tab is a zone; this is the card that fills it.\n {\n slot: 'inboxCampaigns',\n widgetId: 'marketing-inbox-campaigns',\n title: 'Campaigns',\n Component: HostCampaignsCard,\n },\n {\n slot: 'inboxRecordAttribution',\n widgetId: 'marketing-inbox-record-attribution',\n title: 'Campaign attribution',\n Component: RecordAttributionWidget,\n },\n ],\n navItems: [\n {\n label: 'Marketing',\n href: '/marketing',\n // Sections as ROUTES (AGL-2501): each is a real URL the shell\n // resolves and gates, so the page mounts the one being read.\n sections: MARKETING_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-marketing',\n icon: { path: mdiBullhornOutline.path },\n header: {\n title: 'Marketing',\n icon: { path: mdiBullhornOutline.path },\n docsTopic: 'marketingOverlays',\n },\n Component: MarketingConsolePage,\n },\n ],\n /*\n * The ORGANIZATION's Marketing hub, at `/[orgSlug]/marketing`. Campaigns,\n * their emails and their sequence rollups belong to the organization, so\n * this is where one campaign is placed across several sites and where\n * every site's mail is read at once. The page is the same component;\n * handed no site, it renders the org sections.\n *\n * It carries the SITE tab's id on purpose, the way the org CRM tab does:\n * `release_marketing` names `nav-tab-marketing`, so one flag holds both\n * halves of the surface, and the org half cannot ship while the site half\n * is switched off.\n */\n orgNavItems: [\n {\n label: 'Marketing',\n href: '/marketing',\n sections: MARKETING_ORG_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-marketing',\n icon: { path: mdiBullhornOutline.path },\n header: {\n title: 'Marketing',\n icon: { path: mdiBullhornOutline.path },\n docsTopic: 'emailCampaigns',\n },\n Component: MarketingConsolePage,\n },\n ],\n })\n}\n\nexport * from './site'\n"],"names":["Aglyn","registerPluginZone","mdiBullhornOutline","lazy","CAMPAIGN_DESIGN_CREATE_ZONE","CAMPAIGN_DESIGN_PREVIEW_ZONE","CAMPAIGN_SENDER_EDITOR_ZONE","CAMPAIGN_TOPIC_OPTIONS_ZONE","CAMPAIGN_TOPIC_SELECT_ZONE","EXPERIMENT_RESULT_ZONE","EXPERIMENT_VARIANTS_ZONE","MARKETING_CONSOLE_SECTIONS","MARKETING_ORG_CONSOLE_SECTIONS","BUNDLE_ID","registerMarketingRecordRoutes","MarketingConsolePage","CampaignGlanceCard","HostCampaignsCard","EmailMessagesWidget","EmailRecipientsCard","RecordAttributionWidget","registerMarketingConsole","zone","label","surface","description","pluginId","bareZone","layout","registerConsoleExtension","displayName","widgets","slot","CONSOLE_WIDGET_SLOTS","hostDashboard","widgetId","title","Component","navItems","href","sections","navTabId","icon","path","header","docsTopic","orgNavItems"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SACEC,kBAAkB,QAEb,2CAA0C;AACjD,SA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AAmByC,IAAI;oBAAC;oBACtCE,WAAW;gBACb;gBACAR,WAAWtB;YACb;SACD;IACH;AACF;AAEA,cAAc,YAAQ"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/marketing/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n registerPluginZone,\n type PluginZone,\n} from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport { mdiBullhornOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport {\n CAMPAIGN_DESIGN_CREATE_ZONE,\n CAMPAIGN_DESIGN_PREVIEW_ZONE,\n CAMPAIGN_SENDER_EDITOR_ZONE,\n CAMPAIGN_TOPIC_OPTIONS_ZONE,\n CAMPAIGN_TOPIC_SELECT_ZONE,\n} from './components/campaign-email-zones'\nimport {\n EXPERIMENT_RESULT_ZONE,\n EXPERIMENT_VARIANTS_ZONE,\n} from './components/experiment-zones'\nimport {\n MARKETING_CONSOLE_SECTIONS,\n MARKETING_ORG_CONSOLE_SECTIONS,\n} from './components/marketing-console-sections'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { registerMarketingRecordRoutes } from './model/marketing-record-routes'\n\n/** Code-split: the Marketing console page only loads when opened. */\nconst MarketingConsolePage = lazy(\n () => import('./components/marketing-console-page'),\n)\n\n/** Dashboard glance card, loaded only where the shell renders the slot. */\nconst CampaignGlanceCard = lazy(\n () => import('./components/campaign-glance-card.component'),\n)\n\n/**\n * The campaigns drawn in the Inbox's Campaigns section: one site's, or every\n * site's on the organization's Inbox.\n */\nconst InboxCampaignsWidget = lazy(\n () => import('./components/inbox-campaigns-widget'),\n)\n\n/** The Emails page's Messages section: the list, one message, its composer. */\nconst EmailMessagesWidget = lazy(\n () => import('./components/email-messages-widget'),\n)\n\n/** Who received the sends built from one template, on the template's page. */\nconst EmailRecipientsCard = lazy(\n () => import('./components/email-recipients-card'),\n)\n\n/** Loaded where a record page draws one of the attribution zones. */\nconst RecordAttributionWidget = lazy(\n () => import('./components/record-attribution-widget'),\n)\n\n/**\n * Marketing feature plugin (AGL-395). Console-only — overlays and popups\n * render on published sites through the tenant runtime, not a canvas\n * element of their own, so there is no UI bundle. The console half declares\n * the Marketing nav + page through the ConsoleExtension registry (always-on;\n * the surface itself is not release-flagged — its overlays/A-B cards run\n * their own per-plan checks off the passed `org`). The popup image picker\n * uses the shell's media browser via `useMediaPicker`.\n */\nexport function registerMarketingConsole(): void {\n /*\n * The two positions the A/B testing card hosts (AGL-2914), declared before\n * the extension that draws the card. An id another plugin has already taken\n * is refused, naming both. What each zone hands a widget is carried on its\n * token, in `components/experiment-zones`, so a widget elsewhere is written\n * against the same shape without importing this plugin.\n */\n registerPluginZone(\n {\n zone: EXPERIMENT_VARIANTS_ZONE,\n label: 'A/B test variants',\n surface: 'console',\n description:\n 'In the experiment editor, beside the variants. A widget here proposes copy for the variants the editor holds; the dialog’s Save is the write, and nothing a widget returns starts or changes a test.',\n },\n // Named rather than left to the loader's marker, because this function is\n // also called directly — by a spec, and by an app that loads the plugin\n // without the loader — and a zone with no owner is refused.\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: EXPERIMENT_RESULT_ZONE,\n label: 'A/B test result',\n surface: 'console',\n description:\n 'Below the results of one test. A widget here explains what the figures show. There is nothing to apply, and a widget may not declare a winner the card has not.',\n },\n { pluginId: BUNDLE_ID },\n )\n /*\n * What a campaign email asks of whichever plugin keeps the mail itself —\n * the topic catalog, the sending identities, the design document and its\n * renderer. Each is a zone the composer or a message's page hosts; see\n * `components/campaign-email-zones` for what each hands a widget. All are\n * `bare`: a widget there is a field, a button, a drawer or nothing at all,\n * and the stack's spacing around it would be a gap in a form.\n */\n const bareZone = <Props,>(\n zone: PluginZone<Props>,\n label: string,\n description: string,\n ) =>\n registerPluginZone(\n { zone, label, description, surface: 'console', layout: 'bare' },\n { pluginId: BUNDLE_ID },\n )\n bareZone(\n CAMPAIGN_TOPIC_SELECT_ZONE,\n 'An email’s topic',\n 'In the campaign composer’s field stack. A widget here is the picker for the stream the email belongs to: it is handed the chosen id and reports a new one through `onChange`. The composer records it; the widget writes nothing.',\n )\n bareZone(\n CAMPAIGN_TOPIC_OPTIONS_ZONE,\n 'The topics a campaign can open on',\n 'Beside the drawers that create and edit a campaign. A widget here draws nothing: while `enabled` it reads the streams a recipient can still leave and answers through `onTopics`.',\n )\n bareZone(\n CAMPAIGN_SENDER_EDITOR_ZONE,\n 'Add a sender while composing',\n 'Mounted by the campaign composer once its author asks to add a sender. A widget here is that editor, open in its add mode; `onSaved` names the sender it created.',\n )\n bareZone(\n CAMPAIGN_DESIGN_CREATE_ZONE,\n 'A design for one email',\n 'In the campaign composer, beside the design picker. A widget here is the control that mints a design document and names it through `onCreated`; the composer records the choice on the campaign and opens the editor.',\n )\n bareZone(\n CAMPAIGN_DESIGN_PREVIEW_ZONE,\n 'A sent email as an inbox receives it',\n 'On one message’s page. A widget here renders the stored design, or the plain-text body, through the renderer the send path uses.',\n )\n registerMarketingRecordRoutes()\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Marketing',\n /*\n * The host dashboard's `Last campaign` card (AGL-433). A widget rather\n * than a direct import by the dashboard page, so it appears only on\n * workspaces that have the plugin that owns the campaign history — a card\n * about campaigns on a console with no campaigns page could only ever be\n * blank, and its header links straight into `/marketing/campaigns`.\n */\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n // The id a reader's dashboard preferences already name — it is what\n // `isDashboardWidgetHidden` and the customize order are keyed on, so\n // it is persisted and does not follow the plugin.\n widgetId: 'email-campaign-glance',\n title: 'Last campaign',\n Component: CampaignGlanceCard,\n },\n // Which campaign or link brought a person, drawn where the plugins that\n // keep and list people host a zone for it. They hand over what the\n // record is and its id; neither imports this plugin.\n {\n slot: 'crmRecordAttribution',\n widgetId: 'marketing-crm-record-attribution',\n title: 'Campaign attribution',\n Component: RecordAttributionWidget,\n },\n // The Emails page hosts its Messages section as a zone: a message is\n // one send of a campaign, and every action on it is this plugin's route.\n {\n slot: 'emailMessages',\n widgetId: 'marketing-email-messages',\n title: 'Messages',\n Component: EmailMessagesWidget,\n },\n {\n slot: 'emailTemplateRecipients',\n widgetId: 'marketing-email-template-recipients',\n title: 'Recipients',\n Component: EmailRecipientsCard,\n },\n // The Inbox's Campaigns tab is a zone; this is the card that fills it.\n {\n slot: 'inboxCampaigns',\n widgetId: 'marketing-inbox-campaigns',\n title: 'Campaigns',\n Component: InboxCampaignsWidget,\n },\n {\n slot: 'inboxRecordAttribution',\n widgetId: 'marketing-inbox-record-attribution',\n title: 'Campaign attribution',\n Component: RecordAttributionWidget,\n },\n ],\n navItems: [\n {\n label: 'Marketing',\n href: '/marketing',\n // Sections as ROUTES (AGL-2501): each is a real URL the shell\n // resolves and gates, so the page mounts the one being read.\n sections: MARKETING_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-marketing',\n icon: { path: mdiBullhornOutline.path },\n header: {\n title: 'Marketing',\n icon: { path: mdiBullhornOutline.path },\n docsTopic: 'marketingOverlays',\n },\n Component: MarketingConsolePage,\n },\n ],\n /*\n * The ORGANIZATION's Marketing hub, at `/[orgSlug]/marketing`: every\n * section the site hub has, over every site. Campaigns and their sequence\n * rollups belong to the organization, so this is where one campaign is\n * placed across several sites; overlays, tests and conversions stay each\n * site's and are read across them. Every site's mail is on the\n * organization's Emails page, as a site's is on its own. The page is the\n * same component; handed no site, it renders the org sections.\n *\n * It carries the SITE tab's id on purpose, the way the org CRM tab does:\n * `release_marketing` names `nav-tab-marketing`, so one flag holds both\n * halves of the surface, and the org half cannot ship while the site half\n * is switched off.\n */\n orgNavItems: [\n {\n label: 'Marketing',\n href: '/marketing',\n sections: MARKETING_ORG_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-marketing',\n icon: { path: mdiBullhornOutline.path },\n header: {\n title: 'Marketing',\n icon: { path: mdiBullhornOutline.path },\n docsTopic: 'marketingOverlays',\n },\n Component: MarketingConsolePage,\n },\n ],\n })\n}\n\nexport * from './site'\n"],"names":["Aglyn","registerPluginZone","mdiBullhornOutline","lazy","CAMPAIGN_DESIGN_CREATE_ZONE","CAMPAIGN_DESIGN_PREVIEW_ZONE","CAMPAIGN_SENDER_EDITOR_ZONE","CAMPAIGN_TOPIC_OPTIONS_ZONE","CAMPAIGN_TOPIC_SELECT_ZONE","EXPERIMENT_RESULT_ZONE","EXPERIMENT_VARIANTS_ZONE","MARKETING_CONSOLE_SECTIONS","MARKETING_ORG_CONSOLE_SECTIONS","BUNDLE_ID","registerMarketingRecordRoutes","MarketingConsolePage","CampaignGlanceCard","InboxCampaignsWidget","EmailMessagesWidget","EmailRecipientsCard","RecordAttributionWidget","registerMarketingConsole","zone","label","surface","description","pluginId","bareZone","layout","registerConsoleExtension","displayName","widgets","slot","CONSOLE_WIDGET_SLOTS","hostDashboard","widgetId","title","Component","navItems","href","sections","navTabId","icon","path","header","docsTopic","orgNavItems"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SACEC,kBAAkB,QAEb,2CAA0C;AACjD,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,IAAI,QAAQ,QAAO;AAC5B,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,0BAA0B,QACrB,uCAAmC;AAC1C,SACEC,sBAAsB,EACtBC,wBAAwB,QACnB,mCAA+B;AACtC,SACEC,0BAA0B,EAC1BC,8BAA8B,QACz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