{"version":3,"file":"extension-B_qJnv3m.mjs","names":[],"sources":["../src/extensions/global-content.ts","../src/plugins/email-theming/css-transforms.ts","../src/plugins/email-theming/themes.ts","../src/plugins/email-theming/normalization.ts","../src/plugins/email-theming/theme-config.ts","../src/plugins/email-theming/extension.tsx"],"sourcesContent":["import { type Editor, mergeAttributes, Node } from '@tiptap/core';\n\nconst GLOBAL_CONTENT_NODE_TYPE = 'globalContent' as const;\n\nexport interface GlobalContentOptions {\n  key: string;\n  data: Record<string, unknown>;\n}\n\ndeclare module '@tiptap/core' {\n  interface GlobalContent<ReturnType> {\n    setGlobalContent: (key: string, value: unknown) => ReturnType;\n  }\n\n  interface Commands<ReturnType> {\n    globalContent: GlobalContent<ReturnType>;\n  }\n}\n\nlet cachedGlobalPosition: number | null = null;\n\nfunction findGlobalContentPositions(doc: Editor['state']['doc']) {\n  const positions: number[] = [];\n\n  doc.descendants((node, position) => {\n    if (node.type.name === GLOBAL_CONTENT_NODE_TYPE) {\n      positions.push(position);\n    }\n  });\n\n  return positions;\n}\n\nfunction getCachedGlobalContentPosition(doc: Editor['state']['doc']) {\n  if (cachedGlobalPosition != null) {\n    try {\n      if (\n        doc.nodeAt(cachedGlobalPosition)?.type.name === GLOBAL_CONTENT_NODE_TYPE\n      ) {\n        return cachedGlobalPosition;\n      }\n    } catch {\n      cachedGlobalPosition = null;\n    }\n  }\n\n  const positions = findGlobalContentPositions(doc);\n  cachedGlobalPosition = positions[0] ?? null;\n  return cachedGlobalPosition;\n}\n\nexport function getGlobalContent(key: string, editor: Editor): unknown | null {\n  const position = getCachedGlobalContentPosition(editor.state.doc);\n  if (cachedGlobalPosition == null) {\n    return null;\n  }\n  return editor.state.doc.nodeAt(position)?.attrs.data[key] ?? null;\n}\n\nexport const GlobalContent = Node.create<GlobalContentOptions>({\n  name: GLOBAL_CONTENT_NODE_TYPE,\n\n  addOptions() {\n    return {\n      key: GLOBAL_CONTENT_NODE_TYPE,\n      data: {},\n    };\n  },\n\n  group: 'block',\n\n  selectable: false,\n  draggable: false,\n  atom: true,\n\n  addAttributes() {\n    return {\n      data: {\n        default: this.options.data,\n      },\n    };\n  },\n\n  parseHTML() {\n    return [{ tag: `div[data-type=\"${this.name}\"]` }];\n  },\n\n  renderHTML({ HTMLAttributes }) {\n    return [\n      'div',\n      mergeAttributes(HTMLAttributes, {\n        'data-type': this.name,\n        // The node needs to have a width and height, so then\n        // internal TipTap extension can find the first node position\n        // and calculate the correct position of the document container\n        style:\n          'width: 100%; height: 1px; visibility: hidden; background-color: transparent;',\n      }),\n    ];\n  },\n\n  addCommands() {\n    return {\n      setGlobalContent:\n        (key: string, value: unknown) =>\n        ({ tr, dispatch }) => {\n          const ensureGlobalPosition = () => {\n            const positions = findGlobalContentPositions(tr.doc);\n\n            for (let i = positions.length - 1; i > 0; i--) {\n              tr.delete(positions[i], positions[i] + 1);\n            }\n\n            const pos = positions[0] ?? -1;\n            if (pos >= 0) {\n              cachedGlobalPosition = pos;\n            } else {\n              cachedGlobalPosition = 0;\n              tr.insert(0, this.type.create());\n            }\n          };\n\n          if (dispatch) {\n            ensureGlobalPosition();\n\n            if (cachedGlobalPosition == null) {\n              return false;\n            }\n            tr.setNodeAttribute(cachedGlobalPosition, 'data', {\n              ...tr.doc.nodeAt(cachedGlobalPosition)?.attrs.data,\n              [key]: value,\n            });\n          }\n\n          return true;\n        },\n    };\n  },\n});\n","import { ensureBorderStyleFallback } from '../../utils/styles';\nimport { RESET_NODE_TYPES } from './extension';\nimport type { CssJs, KnownThemeComponents, PanelGroup } from './types';\n\nexport function transformToCssJs(\n  styleArray: PanelGroup[],\n  baseFontSize: number,\n): CssJs {\n  const cssJS = {} as CssJs;\n\n  if (!Array.isArray(styleArray)) {\n    return cssJS;\n  }\n\n  for (const style of styleArray) {\n    for (const input of style.inputs) {\n      let value = input.value;\n\n      // If there's a unit property, append it to the value\n      if (input.unit && typeof value === 'number') {\n        // if font size prop convert px unit to em to adjust size in mobile\n        if (input.prop === 'fontSize') {\n          value = `${value / baseFontSize}em`;\n        } else {\n          value = `${value}${input.unit}`;\n        }\n      }\n\n      if (!input.classReference) {\n        continue;\n      }\n\n      if (!cssJS[input.classReference]) {\n        cssJS[input.classReference] = {};\n      }\n\n      // @ts-expect-error -- backward compatibility: 'h-padding' is a legacy prop not in KnownCssProperties\n      if (input.prop === 'h-padding') {\n        cssJS[input.classReference].paddingLeft = value;\n        cssJS[input.classReference].paddingRight = value;\n\n        continue;\n      }\n\n      // @ts-expect-error -- input.prop is KnownCssProperties but CssJs values are React.CSSProperties; dynamic assignment is intentional\n      cssJS[input.classReference][input.prop] = value;\n    }\n  }\n\n  for (const key of Object.keys(cssJS)) {\n    ensureBorderStyleFallback(\n      cssJS[key as keyof CssJs] as Record<string, string | number>,\n    );\n  }\n\n  return cssJS;\n}\n\nexport function mergeCssJs(original: CssJs, newCssJs: CssJs) {\n  const merged = { ...original };\n\n  for (const key in newCssJs) {\n    const keyType = key as keyof CssJs;\n\n    if (\n      Object.hasOwn(merged, key) &&\n      typeof merged[keyType] === 'object' &&\n      !Array.isArray(merged[keyType])\n    ) {\n      merged[keyType] = {\n        ...merged[keyType],\n        ...newCssJs[keyType],\n      };\n    } else {\n      merged[keyType] = newCssJs[keyType];\n    }\n  }\n\n  return merged;\n}\n\nexport function injectThemeCss(\n  styles: CssJs,\n  options: { styleId?: string; scopeSelector?: string } = {},\n) {\n  const container =\n    options.scopeSelector ?? '.tiptap-extended .tiptap.ProseMirror';\n  const prefix = '.node-';\n  const styleId = options.styleId ?? 'tiptap-extended-theme-css';\n  const getNodeSelector = (classReference: string) =>\n    `${container} ${prefix}${classReference}`;\n  const getSelectors = (classReference: KnownThemeComponents) => {\n    switch (classReference) {\n      case 'body':\n        return [container];\n      case 'reset':\n        return [];\n      case 'list':\n        return [\n          getNodeSelector('list'),\n          getNodeSelector('bulletList'),\n          getNodeSelector('orderedList'),\n        ];\n      case 'bulletList':\n        return [getNodeSelector('bulletList')];\n      case 'orderedList':\n        return [getNodeSelector('orderedList')];\n      case 'nestedList':\n        return [\n          getNodeSelector('nestedList'),\n          `${container} .node-list .node-list`,\n          `${container} .node-bulletList .node-bulletList`,\n          `${container} .node-bulletList .node-orderedList`,\n          `${container} .node-orderedList .node-bulletList`,\n          `${container} .node-orderedList .node-orderedList`,\n        ];\n      case 'listParagraph':\n        return [`${container} .node-listItem > .node-paragraph`];\n      default:\n        return [getNodeSelector(classReference)];\n    }\n  };\n  const resetStyles = styles.reset ?? {};\n\n  const css = Object.entries(styles).reduce((acc, [key, value]) => {\n    const classReference = key as KnownThemeComponents;\n    const selectors = getSelectors(classReference);\n    if (selectors.length === 0) {\n      return acc;\n    }\n\n    const resolvedStyles = RESET_NODE_TYPES.has(classReference)\n      ? { ...resetStyles, ...value }\n      : value;\n\n    const cssString = Object.entries(resolvedStyles).reduce(\n      (acc, [prop, val]) => {\n        const normalizeProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();\n\n        if (val === undefined) {\n          return acc;\n        }\n\n        return `${acc}${normalizeProp}:${val};`;\n      },\n      '',\n    );\n\n    return `${acc}${selectors.join(',')}{${cssString}}`;\n  }, '');\n\n  let styleTag = document.getElementById(styleId) as HTMLStyleElement;\n\n  if (!styleTag) {\n    styleTag = document.createElement('style');\n    styleTag.textContent = css;\n    styleTag.id = styleId;\n\n    document.head.appendChild(styleTag);\n\n    return;\n  }\n\n  styleTag.textContent = css;\n}\n\nexport function injectGlobalPlainCss(\n  css?: string | null,\n  options: { styleId?: string; scopeSelector?: string } = {},\n) {\n  const styleId = options.styleId ?? 'global-editor-style';\n  const container = options.scopeSelector ?? '.tiptap-extended .ProseMirror';\n  let styleElement = document.getElementById(styleId);\n\n  if (!css) {\n    if (styleElement) {\n      styleElement.textContent = '';\n    }\n    return;\n  }\n\n  if (!styleElement) {\n    styleElement = document.createElement('style');\n    styleElement.id = styleId;\n    document.head.appendChild(styleElement);\n  }\n\n  // Remove CSS within @media (prefers-color-scheme: dark) blocks\n  const cleanedCSS = css.replace(\n    /@media\\s?\\(prefers-color-scheme:\\s?dark\\)\\s?{([\\s\\S]+?})\\s*}/g,\n    '',\n  );\n\n  // TODO: Figure out a way to extract the body and apply the styles out of the nested .tiptap-extended\n  styleElement.textContent = `${container} { ${cleanedCSS} }`;\n}\n","import type {\n  EditorTheme,\n  PanelGroup,\n  PanelSectionId,\n  ResetTheme,\n  SupportedCssProperties,\n} from './types';\n\n/**\n * Single source of truth for panel section display titles.\n * Titles are resolved from here at render time via `getPanelTitle`,\n * so they never depend on what's persisted in the DB.\n */\nconst PANEL_SECTION_TITLES: Record<PanelSectionId, string> = {\n  body: 'Background',\n  container: 'Body',\n  typography: 'Text',\n  h1: 'Title',\n  h2: 'Subtitle',\n  h3: 'Heading',\n  paragraph: 'Paragraph',\n  list: 'List',\n  'nested-list': 'Nested List',\n  'list-item': 'List Item',\n  link: 'Link',\n  image: 'Image',\n  button: 'Button',\n  'code-block': 'Code Block',\n  'inline-code': 'Inline Code',\n};\n\n/**\n * Resolves the display title for a panel group.\n * Uses the `id` lookup when available, falls back to the\n * DB-persisted `title` for backwards compatibility.\n */\nexport function getPanelTitle(group: PanelGroup): string {\n  if (group.id && group.id in PANEL_SECTION_TITLES) {\n    return PANEL_SECTION_TITLES[group.id];\n  }\n  return group.title;\n}\n\nconst THEME_BASIC: PanelGroup[] = [\n  {\n    id: 'body',\n    title: 'Background',\n    classReference: 'body',\n    inputs: [\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#ffffff',\n        prop: 'backgroundColor',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'body',\n      },\n    ],\n  },\n  {\n    id: 'container',\n    title: 'Content',\n    classReference: 'container',\n    inputs: [\n      {\n        label: 'Align',\n        type: 'select',\n        value: 'left',\n        options: {\n          left: 'Left',\n          center: 'Center',\n          right: 'Right',\n        },\n        prop: 'align',\n        classReference: 'container',\n      },\n      {\n        label: 'Width',\n        type: 'number',\n        value: 600,\n        unit: 'px',\n        prop: 'width',\n        classReference: 'container',\n      },\n      {\n        label: 'Height',\n        type: 'number',\n        unit: 'px',\n        prop: 'height',\n        classReference: 'container',\n      },\n      {\n        label: 'Text',\n        type: 'color',\n        value: '#000000',\n        prop: 'color',\n        classReference: 'container',\n      },\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#ffffff',\n        prop: 'backgroundColor',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'container',\n      },\n      {\n        label: 'Corner radius',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'container',\n      },\n      {\n        label: 'Border color',\n        type: 'color',\n        value: '#000000',\n        prop: 'borderColor',\n        classReference: 'container',\n      },\n    ],\n  },\n  {\n    id: 'typography',\n    title: 'Text',\n    classReference: 'body',\n    inputs: [\n      {\n        label: 'Font size',\n        type: 'number',\n        value: 14,\n        unit: 'px',\n        prop: 'fontSize',\n        classReference: 'body',\n      },\n      {\n        label: 'Line Height',\n        type: 'number',\n        value: 155,\n        unit: '%',\n        prop: 'lineHeight',\n        classReference: 'container',\n      },\n    ],\n  },\n  {\n    id: 'h1',\n    title: 'Title',\n    category: 'Text',\n    classReference: 'h1',\n    inputs: [],\n  },\n  {\n    id: 'h2',\n    title: 'Subtitle',\n    category: 'Text',\n    classReference: 'h2',\n    inputs: [],\n  },\n  {\n    id: 'h3',\n    title: 'Heading',\n    category: 'Text',\n    classReference: 'h3',\n    inputs: [],\n  },\n  {\n    id: 'paragraph',\n    title: 'Paragraph',\n    category: 'Text',\n    classReference: 'paragraph',\n    inputs: [],\n  },\n  {\n    id: 'list',\n    title: 'List',\n    category: 'Text',\n    classReference: 'list',\n    inputs: [],\n  },\n  {\n    id: 'nested-list',\n    title: 'Nested List',\n    category: 'Text',\n    classReference: 'nestedList',\n    inputs: [],\n  },\n  {\n    id: 'list-item',\n    title: 'List Item',\n    category: 'Text',\n    classReference: 'listItem',\n    inputs: [],\n  },\n  {\n    id: 'link',\n    title: 'Link',\n    classReference: 'link',\n    inputs: [\n      {\n        label: 'Color',\n        type: 'color',\n        value: '#0670DB',\n        prop: 'color',\n        classReference: 'link',\n      },\n      {\n        label: 'Decoration',\n        type: 'select',\n        value: 'underline',\n        prop: 'textDecoration',\n        options: {\n          underline: 'Underline',\n          none: 'None',\n        },\n        classReference: 'link',\n      },\n    ],\n  },\n  {\n    id: 'image',\n    title: 'Image',\n    classReference: 'image',\n    inputs: [\n      {\n        label: 'Border radius',\n        type: 'number',\n        value: 8,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'image',\n      },\n    ],\n  },\n  {\n    id: 'button',\n    title: 'Button',\n    classReference: 'button',\n    inputs: [\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#000000',\n        prop: 'backgroundColor',\n        classReference: 'button',\n      },\n      {\n        label: 'Text color',\n        type: 'color',\n        value: '#ffffff',\n        prop: 'color',\n        classReference: 'button',\n      },\n      {\n        label: 'Radius',\n        type: 'number',\n        value: 4,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'button',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: 7,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'button',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: 12,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'button',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: 7,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'button',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: 12,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'button',\n      },\n    ],\n  },\n  {\n    id: 'code-block',\n    title: 'Code Block',\n    classReference: 'codeBlock',\n    inputs: [\n      {\n        label: 'Border Radius',\n        type: 'number',\n        value: 4,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'codeBlock',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: 12,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'codeBlock',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: 12,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'codeBlock',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: 16,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'codeBlock',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: 16,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'codeBlock',\n      },\n    ],\n  },\n  {\n    id: 'inline-code',\n    title: 'Inline Code',\n    classReference: 'inlineCode',\n    inputs: [\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#e5e7eb',\n        prop: 'backgroundColor',\n        classReference: 'inlineCode',\n      },\n      {\n        label: 'Text color',\n        type: 'color',\n        value: '#1e293b',\n        prop: 'color',\n        classReference: 'inlineCode',\n      },\n      {\n        label: 'Radius',\n        type: 'number',\n        value: 4,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'inlineCode',\n      },\n    ],\n  },\n];\n\nconst THEME_MINIMAL: PanelGroup[] = [\n  {\n    id: 'body',\n    title: 'Background',\n    classReference: 'body',\n    inputs: [\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#ffffff',\n        prop: 'backgroundColor',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'body',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: undefined,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'body',\n      },\n    ],\n  },\n  {\n    id: 'container',\n    title: 'Content',\n    classReference: 'container',\n    inputs: [\n      {\n        label: 'Align',\n        type: 'select',\n        value: 'left',\n        options: {\n          left: 'Left',\n          center: 'Center',\n          right: 'Right',\n        },\n        prop: 'align',\n        classReference: 'container',\n      },\n      {\n        label: 'Width',\n        type: 'number',\n        value: 600,\n        unit: 'px',\n        prop: 'width',\n        classReference: 'container',\n      },\n      {\n        label: 'Height',\n        type: 'number',\n        unit: 'px',\n        prop: 'height',\n        classReference: 'container',\n      },\n      {\n        label: 'Text',\n        type: 'color',\n        value: '#000000',\n        prop: 'color',\n        classReference: 'container',\n      },\n      {\n        label: 'Background',\n        type: 'color',\n        value: '#ffffff',\n        prop: 'backgroundColor',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Top',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingTop',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Right',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingRight',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Bottom',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingBottom',\n        classReference: 'container',\n      },\n      {\n        label: 'Padding Left',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'paddingLeft',\n        classReference: 'container',\n      },\n      {\n        label: 'Corner radius',\n        type: 'number',\n        value: 0,\n        unit: 'px',\n        prop: 'borderRadius',\n        classReference: 'container',\n      },\n      {\n        label: 'Border color',\n        type: 'color',\n        value: '#000000',\n        prop: 'borderColor',\n        classReference: 'container',\n      },\n    ],\n  },\n  {\n    id: 'typography',\n    title: 'Text',\n    classReference: 'body',\n    inputs: [],\n  },\n  {\n    id: 'h1',\n    title: 'Title',\n    category: 'Text',\n    classReference: 'h1',\n    inputs: [],\n  },\n  {\n    id: 'h2',\n    title: 'Subtitle',\n    category: 'Text',\n    classReference: 'h2',\n    inputs: [],\n  },\n  {\n    id: 'h3',\n    title: 'Heading',\n    category: 'Text',\n    classReference: 'h3',\n    inputs: [],\n  },\n  {\n    id: 'paragraph',\n    title: 'Paragraph',\n    category: 'Text',\n    classReference: 'paragraph',\n    inputs: [],\n  },\n  {\n    id: 'list',\n    title: 'List',\n    category: 'Text',\n    classReference: 'list',\n    inputs: [],\n  },\n  {\n    id: 'nested-list',\n    title: 'Nested List',\n    category: 'Text',\n    classReference: 'nestedList',\n    inputs: [],\n  },\n  {\n    id: 'list-item',\n    title: 'List Item',\n    category: 'Text',\n    classReference: 'listItem',\n    inputs: [],\n  },\n  {\n    id: 'link',\n    title: 'Link',\n    classReference: 'link',\n    inputs: [],\n  },\n  {\n    id: 'image',\n    title: 'Image',\n    classReference: 'image',\n    inputs: [],\n  },\n  {\n    id: 'button',\n    title: 'Button',\n    classReference: 'button',\n    inputs: [],\n  },\n  {\n    id: 'code-block',\n    title: 'Code Block',\n    classReference: 'codeBlock',\n    inputs: [],\n  },\n  {\n    id: 'inline-code',\n    title: 'Inline Code',\n    classReference: 'inlineCode',\n    inputs: [],\n  },\n];\n\nconst RESET_BASIC: ResetTheme = {\n  reset: {\n    margin: '0',\n    padding: '0',\n  },\n  body: {\n    fontFamily:\n      \"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif\",\n    fontSize: '14px',\n    minHeight: '100%',\n    lineHeight: '155%',\n  },\n  container: {},\n  h1: {\n    fontSize: '2.25em',\n    lineHeight: '1.44em',\n    paddingTop: '0.389em',\n    fontWeight: 600,\n  },\n  h2: {\n    fontSize: '1.8em',\n    lineHeight: '1.44em',\n    paddingTop: '0.389em',\n    fontWeight: 600,\n  },\n  h3: {\n    fontSize: '1.4em',\n    lineHeight: '1.08em',\n    paddingTop: '0.389em',\n    fontWeight: 600,\n  },\n  paragraph: {\n    fontSize: '1em',\n    paddingTop: '0.5em',\n    paddingBottom: '0.5em',\n  },\n  list: {\n    paddingLeft: '1.1em',\n    paddingBottom: '1em',\n  },\n  bulletList: {\n    listStyleType: 'disc',\n  },\n  orderedList: {\n    listStyleType: 'decimal',\n  },\n  nestedList: {\n    paddingLeft: '1.1em',\n    paddingBottom: '0',\n  },\n  listItem: {\n    marginLeft: '1em',\n    paddingBottom: '0.3em',\n    paddingTop: '0.3em',\n  },\n  listParagraph: { padding: '0', margin: '0' },\n  blockquote: {\n    borderLeft: '3px solid #acb3be',\n    color: '#7e8a9a',\n    marginLeft: 0,\n    paddingLeft: '0.8em',\n    fontSize: '1.1em',\n    fontFamily:\n      \"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif\",\n  },\n  link: { color: '#0670DB', textDecoration: 'underline' },\n  footer: {\n    fontSize: '0.8em',\n  },\n  hr: {\n    paddingBottom: '1em',\n    borderStyle: 'solid',\n    borderWidth: 0,\n    borderTopWidth: '2px',\n  },\n  image: {\n    maxWidth: '100%',\n  },\n  button: {\n    lineHeight: '100%',\n    display: 'inline-block',\n    paddingTop: '0.625em',\n    paddingRight: '1.25em',\n    paddingBottom: '0.625em',\n    paddingLeft: '1.25em',\n    backgroundColor: '#000000',\n    color: '#ffffff',\n    borderRadius: '0.375em',\n    fontWeight: 500,\n    fontSize: '0.875em',\n    textDecoration: 'none',\n    textAlign: 'center',\n  },\n  inlineCode: {\n    paddingTop: '0.25em',\n    paddingBottom: '0.25em',\n    paddingLeft: '0.4em',\n    paddingRight: '0.4em',\n    background: '#e5e7eb',\n    color: '#1e293b',\n    borderRadius: '4px',\n  },\n  codeBlock: {\n    background: '#f1f5f9',\n    borderRadius: '4px',\n    paddingTop: '0.75rem',\n    paddingRight: '1rem',\n    paddingBottom: '0.75rem',\n    paddingLeft: '1rem',\n    overflowX: 'auto',\n    fontFamily: 'monospace',\n    fontWeight: '500',\n    fontSize: '.92em',\n  },\n  codeTag: {\n    lineHeight: '130%',\n    fontFamily: 'monospace',\n    fontSize: '.92em',\n  },\n  section: {\n    padding: '10px 20px 10px 20px',\n    boxSizing: 'border-box' as const,\n  },\n};\n\nconst RESET_MINIMAL: ResetTheme = {\n  ...Object.keys(RESET_BASIC).reduce<ResetTheme>((acc, key) => {\n    acc[key as keyof ResetTheme] = {};\n    return acc;\n  }, {} as ResetTheme),\n  reset: RESET_BASIC.reset,\n  button: {\n    lineHeight: RESET_BASIC.button.lineHeight,\n    display: RESET_BASIC.button.display,\n  },\n  image: RESET_BASIC.image,\n  list: RESET_BASIC.list,\n  bulletList: RESET_BASIC.bulletList,\n  orderedList: RESET_BASIC.orderedList,\n  nestedList: RESET_BASIC.nestedList,\n  listItem: RESET_BASIC.listItem,\n  listParagraph: RESET_BASIC.listParagraph,\n  link: RESET_BASIC.link,\n};\n\nexport const RESET_THEMES: Record<EditorTheme, ResetTheme> = {\n  basic: RESET_BASIC,\n  minimal: RESET_MINIMAL,\n};\n\nexport function resolveResetValue(\n  value: string | number | undefined,\n  targetUnit: 'px' | '%',\n  bodyFontSizePx: number,\n): number | undefined {\n  if (value === undefined) {\n    return undefined;\n  }\n  const str = String(value);\n  const num = Number.parseFloat(str);\n  if (Number.isNaN(num)) {\n    return undefined;\n  }\n  if (str.endsWith('em')) {\n    return targetUnit === 'px' ? Math.floor(num * bodyFontSizePx) : num * 100;\n  }\n  return num;\n}\n\nexport const EDITOR_THEMES: Record<EditorTheme, PanelGroup[]> = {\n  minimal: THEME_MINIMAL,\n  basic: THEME_BASIC,\n};\n\nexport function getThemeBodyFontSizePx(theme: EditorTheme): number {\n  for (const group of EDITOR_THEMES[theme]) {\n    if (group.classReference !== 'body') {\n      continue;\n    }\n    for (const input of group.inputs) {\n      if (input.prop === 'fontSize' && typeof input.value === 'number') {\n        return input.value;\n      }\n    }\n  }\n  return 14;\n}\n\n/**\n * Use to make the preview nicer once the theme might miss some\n * important properties to make layout accurate\n */\nexport const DEFAULT_INBOX_FONT_SIZE_PX = 14;\nexport const INBOX_EMAIL_DEFAULTS: Partial<ResetTheme> = {\n  body: {\n    color: '#000000',\n    fontFamily:\n      \"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif\",\n    fontSize: `${DEFAULT_INBOX_FONT_SIZE_PX}px`,\n  },\n  container: {\n    width: 600,\n  },\n};\n\nexport const SUPPORTED_CSS_PROPERTIES: SupportedCssProperties = {\n  align: {\n    label: 'Align',\n    type: 'select',\n    options: {\n      left: 'Left',\n      center: 'Center',\n      right: 'Right',\n    },\n    defaultValue: 'left',\n    category: 'layout',\n  },\n  backgroundColor: {\n    label: 'Background',\n    type: 'color',\n    excludeNodes: ['image', 'youtube'],\n    defaultValue: '#ffffff',\n    category: 'appearance',\n  },\n  color: {\n    label: 'Text color',\n    type: 'color',\n    excludeNodes: ['image', 'youtube'],\n    defaultValue: '#000000',\n    category: 'typography',\n  },\n  fontSize: {\n    label: 'Font size',\n    type: 'number',\n    unit: 'px',\n    excludeNodes: ['image', 'youtube'],\n    defaultValue: 14,\n    category: 'typography',\n  },\n  fontWeight: {\n    label: 'Font weight',\n    type: 'select',\n    options: {\n      300: 'Light',\n      400: 'Normal',\n      600: 'Semi Bold',\n      700: 'Bold',\n      800: 'Extra Bold',\n    },\n    excludeNodes: ['image', 'youtube'],\n    defaultValue: 400,\n    category: 'typography',\n  },\n  letterSpacing: {\n    label: 'Letter spacing',\n    type: 'number',\n    unit: 'px',\n    excludeNodes: ['image', 'youtube'],\n    defaultValue: 0,\n    category: 'typography',\n  },\n  lineHeight: {\n    label: 'Line height',\n    type: 'number',\n    unit: '%',\n    defaultValue: 155,\n    category: 'typography',\n  },\n  textDecoration: {\n    label: 'Text decoration',\n    type: 'select',\n    options: {\n      none: 'None',\n      underline: 'Underline',\n      'line-through': 'Line-through',\n    },\n    defaultValue: 'none',\n    category: 'typography',\n  },\n  borderRadius: {\n    label: 'Border Radius',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'appearance',\n  },\n  borderTopLeftRadius: {\n    label: 'Border Radius (Top-Left)',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'appearance',\n  },\n  borderTopRightRadius: {\n    label: 'Border Radius (Top-Right)',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'appearance',\n  },\n  borderBottomLeftRadius: {\n    label: 'Border Radius (Bottom-Left)',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'appearance',\n  },\n  borderBottomRightRadius: {\n    label: 'Border Radius (Bottom-Right)',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'appearance',\n  },\n  borderWidth: {\n    label: 'Border Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 1,\n    category: 'appearance',\n  },\n  borderTopWidth: {\n    label: 'Border Top Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 1,\n    category: 'appearance',\n  },\n  borderRightWidth: {\n    label: 'Border Right Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 1,\n    category: 'appearance',\n  },\n  borderBottomWidth: {\n    label: 'Border Bottom Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 1,\n    category: 'appearance',\n  },\n  borderLeftWidth: {\n    label: 'Border Left Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 1,\n    category: 'appearance',\n  },\n  borderStyle: {\n    label: 'Border Style',\n    type: 'select',\n    options: {\n      solid: 'Solid',\n      dashed: 'Dashed',\n      dotted: 'Dotted',\n    },\n    defaultValue: 'solid',\n    category: 'appearance',\n  },\n  borderTopStyle: {\n    label: 'Border Top Style',\n    type: 'select',\n    options: {\n      solid: 'Solid',\n      dashed: 'Dashed',\n      dotted: 'Dotted',\n    },\n    defaultValue: 'solid',\n    category: 'appearance',\n  },\n  borderRightStyle: {\n    label: 'Border Right Style',\n    type: 'select',\n    options: {\n      solid: 'Solid',\n      dashed: 'Dashed',\n      dotted: 'Dotted',\n    },\n    defaultValue: 'solid',\n    category: 'appearance',\n  },\n  borderBottomStyle: {\n    label: 'Border Bottom Style',\n    type: 'select',\n    options: {\n      solid: 'Solid',\n      dashed: 'Dashed',\n      dotted: 'Dotted',\n    },\n    defaultValue: 'solid',\n    category: 'appearance',\n  },\n  borderLeftStyle: {\n    label: 'Border Left Style',\n    type: 'select',\n    options: {\n      solid: 'Solid',\n      dashed: 'Dashed',\n      dotted: 'Dotted',\n    },\n    defaultValue: 'solid',\n    category: 'appearance',\n  },\n  borderColor: {\n    label: 'Border Color',\n    type: 'color',\n    defaultValue: '#000000',\n    category: 'appearance',\n  },\n  borderTopColor: {\n    label: 'Border Top Color',\n    type: 'color',\n    defaultValue: '#000000',\n    category: 'appearance',\n  },\n  borderRightColor: {\n    label: 'Border Right Color',\n    type: 'color',\n    defaultValue: '#000000',\n    category: 'appearance',\n  },\n  borderBottomColor: {\n    label: 'Border Bottom Color',\n    type: 'color',\n    defaultValue: '#000000',\n    category: 'appearance',\n  },\n  borderLeftColor: {\n    label: 'Border Left Color',\n    type: 'color',\n    defaultValue: '#000000',\n    category: 'appearance',\n  },\n  padding: {\n    label: 'Padding',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'layout',\n  },\n  paddingTop: {\n    label: 'Padding Top',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'layout',\n  },\n  paddingLeft: {\n    label: 'Padding Left',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'layout',\n  },\n  paddingBottom: {\n    label: 'Padding Bottom',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'layout',\n  },\n  paddingRight: {\n    label: 'Padding Right',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 8,\n    category: 'layout',\n  },\n  width: {\n    label: 'Width',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 600,\n    category: 'layout',\n  },\n  height: {\n    label: 'Height',\n    type: 'number',\n    unit: 'px',\n    defaultValue: 400,\n    category: 'layout',\n  },\n};\n","import { EDITOR_THEMES } from './themes';\nimport type {\n  EditorTheme,\n  KnownThemeComponents,\n  PanelGroup,\n  PanelSectionId,\n} from './types';\n\nconst PANEL_SECTION_IDS = new Set<PanelSectionId>([\n  'body',\n  'container',\n  'typography',\n  'paragraph',\n  'list',\n  'nested-list',\n  'list-item',\n  'link',\n  'image',\n  'button',\n  'code-block',\n  'inline-code',\n]);\n\nconst PANEL_SECTION_IDS_BY_TITLE: Record<string, PanelSectionId> = {\n  background: 'body',\n  body: 'body',\n  content: 'container',\n  container: 'container',\n  typography: 'typography',\n  paragraph: 'paragraph',\n  list: 'list',\n  'nested list': 'nested-list',\n  'list item': 'list-item',\n  link: 'link',\n  image: 'image',\n  button: 'button',\n  'code block': 'code-block',\n  'inline code': 'inline-code',\n};\n\nconst PANEL_SECTION_IDS_BY_CLASS_REFERENCE: Partial<\n  Record<KnownThemeComponents, PanelSectionId>\n> = {\n  container: 'container',\n  paragraph: 'paragraph',\n  list: 'list',\n  nestedList: 'nested-list',\n  listItem: 'list-item',\n  link: 'link',\n  image: 'image',\n  button: 'button',\n  codeBlock: 'code-block',\n  inlineCode: 'inline-code',\n};\n\nfunction isPanelSectionId(value: unknown): value is PanelSectionId {\n  return (\n    typeof value === 'string' && PANEL_SECTION_IDS.has(value as PanelSectionId)\n  );\n}\n\nfunction normalizeTitle(title: string | undefined): string {\n  return title?.trim().toLowerCase().replace(/\\s+/g, ' ') ?? '';\n}\n\nfunction resolvePanelSectionId(group: PanelGroup): PanelSectionId | null {\n  if (isPanelSectionId(group.id)) {\n    return group.id;\n  }\n\n  const normalizedTitle = normalizeTitle(group.title);\n\n  if (group.classReference === 'body') {\n    if (normalizedTitle === 'typography') {\n      return 'typography';\n    }\n\n    return 'body';\n  }\n\n  if (\n    group.classReference &&\n    PANEL_SECTION_IDS_BY_CLASS_REFERENCE[group.classReference]\n  ) {\n    return PANEL_SECTION_IDS_BY_CLASS_REFERENCE[group.classReference] ?? null;\n  }\n\n  return PANEL_SECTION_IDS_BY_TITLE[normalizedTitle] ?? null;\n}\n\nfunction normalizePanelInputs(\n  inputs: PanelGroup['inputs'],\n  defaultInputs: PanelGroup['inputs'],\n  fallbackClassReference?: KnownThemeComponents,\n): PanelGroup['inputs'] {\n  if (!Array.isArray(inputs)) {\n    return [];\n  }\n\n  return inputs.map((input) => {\n    const defaultInput = defaultInputs.find(\n      (candidate) => candidate.prop === input.prop,\n    );\n\n    return {\n      ...defaultInput,\n      ...input,\n      classReference:\n        input.classReference ??\n        defaultInput?.classReference ??\n        fallbackClassReference,\n    };\n  });\n}\n\nexport function inferThemeFromPanelStyles(\n  panelStyles: PanelGroup[] | null | undefined,\n): EditorTheme | null {\n  if (!Array.isArray(panelStyles) || panelStyles.length === 0) {\n    return null;\n  }\n\n  let finalTheme: EditorTheme | null = null;\n  for (const group of panelStyles) {\n    if (!Array.isArray(group?.inputs)) {\n      finalTheme = null;\n      break;\n    }\n\n    if (group.inputs.length !== 0) {\n      finalTheme = 'basic';\n      break;\n    }\n\n    finalTheme = 'minimal';\n  }\n\n  return finalTheme;\n}\n\nexport function normalizeThemePanelStyles(\n  theme: EditorTheme,\n  panelStyles: PanelGroup[] | null | undefined,\n): PanelGroup[] | null {\n  if (!Array.isArray(panelStyles)) {\n    return null;\n  }\n\n  return panelStyles.map((group) => {\n    const panelId = resolvePanelSectionId(group);\n\n    if (!panelId) {\n      return group;\n    }\n\n    const defaultGroup = EDITOR_THEMES[theme].find(\n      (candidate) => candidate.id === panelId,\n    );\n\n    if (!defaultGroup) {\n      return group;\n    }\n\n    return {\n      ...group,\n      id: panelId,\n      title: defaultGroup.title,\n      classReference: defaultGroup.classReference,\n      inputs: normalizePanelInputs(\n        group.inputs,\n        defaultGroup.inputs,\n        defaultGroup.classReference,\n      ),\n    };\n  });\n}\n","import { SUPPORTED_CSS_PROPERTIES } from './themes';\nimport type {\n  EditorTheme,\n  EditorThemeInput,\n  KnownCssProperties,\n  PanelGroup,\n  PanelSectionId,\n  ThemeableComponent,\n  ThemeComponentStyles,\n  ThemeConfig,\n} from './types';\n\nconst CLASS_REFERENCE_TO_PANEL_ID: Record<ThemeableComponent, PanelSectionId> =\n  {\n    body: 'body',\n    container: 'container',\n    h1: 'h1',\n    h2: 'h2',\n    h3: 'h3',\n    paragraph: 'paragraph',\n    link: 'link',\n    image: 'image',\n    button: 'button',\n    list: 'list',\n    nestedList: 'nested-list',\n    listItem: 'list-item',\n    codeBlock: 'code-block',\n    inlineCode: 'inline-code',\n  };\n\nexport function parseCssValue(value: string | number): {\n  value: string | number;\n  unit?: 'px' | '%';\n} {\n  if (typeof value === 'number') {\n    return { value };\n  }\n  const pxMatch = /^(-?\\d+(?:\\.\\d+)?)px$/.exec(value);\n  if (pxMatch) {\n    return { value: Number.parseFloat(pxMatch[1]), unit: 'px' };\n  }\n  const percentMatch = /^(-?\\d+(?:\\.\\d+)?)%$/.exec(value);\n  if (percentMatch) {\n    return { value: Number.parseFloat(percentMatch[1]), unit: '%' };\n  }\n  return { value };\n}\n\nexport function isThemeConfig(\n  theme: EditorThemeInput | undefined,\n): theme is ThemeConfig {\n  return typeof theme === 'object' && theme !== null && 'styles' in theme;\n}\n\nexport function themeStylesToPanelOverrides(\n  styles: ThemeComponentStyles,\n  basePanels: PanelGroup[],\n): PanelGroup[] {\n  const result: PanelGroup[] = basePanels.map((group) => ({\n    ...group,\n    inputs: group.inputs.map((input) => ({ ...input })),\n  }));\n\n  for (const [component, cssProps] of Object.entries(styles) as [\n    ThemeableComponent,\n    React.CSSProperties,\n  ][]) {\n    if (!cssProps) continue;\n    const panelId = CLASS_REFERENCE_TO_PANEL_ID[component];\n\n    const group = result.find((g) => g.id === panelId);\n    if (!group) continue;\n\n    for (const [cssProp, cssValue] of Object.entries(cssProps) as [\n      KnownCssProperties,\n      string | number,\n    ][]) {\n      if (cssValue === undefined) continue;\n\n      const existingInput = group.inputs.find(\n        (i) => i.prop === cssProp && i.classReference === component,\n      );\n\n      const parsed = parseCssValue(cssValue);\n\n      if (existingInput) {\n        existingInput.value = parsed.value;\n        if (parsed.unit !== undefined) {\n          existingInput.unit = parsed.unit;\n        }\n      } else {\n        const propMeta = SUPPORTED_CSS_PROPERTIES[cssProp];\n        group.inputs.push({\n          label: propMeta?.label ?? cssProp,\n          type: propMeta?.type ?? 'text',\n          prop: cssProp,\n          classReference: component,\n          value: parsed.value,\n          unit: parsed.unit ?? propMeta?.unit,\n          options: propMeta?.options,\n        });\n      }\n    }\n  }\n\n  return result;\n}\n\nexport function createTheme(styles: ThemeComponentStyles): ThemeConfig {\n  return { styles };\n}\n\nexport function extendTheme(\n  base: EditorTheme,\n  overrides: ThemeComponentStyles,\n): ThemeConfig {\n  return { extends: base, styles: overrides };\n}\n","import type { Editor, JSONContent } from '@tiptap/core';\nimport { Extension } from '@tiptap/core';\nimport { Plugin, PluginKey } from '@tiptap/pm/state';\nimport { useEditorState } from '@tiptap/react';\nimport type * as React from 'react';\nimport { Body, Head, Html, Preview } from 'react-email';\nimport type { SerializerPlugin } from '../../core/serializer/serializer-plugin';\nimport { getGlobalContent } from '../../extensions/global-content';\nimport {\n  injectGlobalPlainCss,\n  injectThemeCss,\n  mergeCssJs,\n  transformToCssJs,\n} from './css-transforms';\nimport {\n  inferThemeFromPanelStyles,\n  normalizeThemePanelStyles,\n} from './normalization';\nimport { isThemeConfig, themeStylesToPanelOverrides } from './theme-config';\nimport {\n  DEFAULT_INBOX_FONT_SIZE_PX,\n  EDITOR_THEMES,\n  RESET_THEMES,\n} from './themes';\nimport type {\n  CssJs,\n  EditorTheme,\n  EditorThemeInput,\n  KnownThemeComponents,\n  PanelGroup,\n} from './types';\n\n/**\n * Maps a document node (type + attrs) to the theme component key used for style lookup.\n * Centralizes all node-type → theme-component knowledge.\n */\nexport function getThemeComponentKey(\n  nodeType: string,\n  depth: number,\n  attrs: Record<string, unknown> = {},\n): KnownThemeComponents | null {\n  switch (nodeType) {\n    case 'paragraph':\n      if (depth > 0) {\n        return 'listParagraph';\n      }\n      return 'paragraph';\n    case 'heading': {\n      const level = attrs.level as number | undefined;\n      return `h${level ?? 1}` as KnownThemeComponents;\n    }\n    case 'blockquote':\n      return 'blockquote';\n    case 'button':\n      return 'button';\n    case 'container':\n      return 'container';\n    case 'section':\n      return 'section';\n    case 'footer':\n      return 'footer';\n    case 'image':\n      return 'image';\n    case 'youtube':\n    case 'twitter':\n      return 'image';\n    case 'orderedList':\n    case 'bulletList':\n      if (depth > 0) {\n        return 'nestedList';\n      }\n      return 'list';\n    case 'listItem':\n      return 'listItem';\n    case 'codeBlock':\n      return 'codeBlock';\n    case 'code':\n      return 'inlineCode';\n    case 'link':\n      return 'link';\n    case 'horizontalRule':\n      return 'hr';\n    default:\n      return null;\n  }\n}\n\n/**\n * Returns merged theme styles (reset + panel styles) for the given editor.\n * Use when you have editor access and need the full CssJs map.\n */\nexport function getMergedCssJs(\n  theme: EditorTheme,\n  panelStyles: PanelGroup[] | undefined,\n): CssJs {\n  const panels: PanelGroup[] =\n    normalizeThemePanelStyles(theme, panelStyles) ?? EDITOR_THEMES[theme];\n  const parsed = transformToCssJs(panels, DEFAULT_INBOX_FONT_SIZE_PX);\n  const merged = mergeCssJs(RESET_THEMES[theme], parsed);\n\n  return merged;\n}\n\n/**\n * Node types and theme component keys that should receive the universal\n * `reset` CSS (e.g. `margin: 0; padding: 0`) layered underneath their own\n * theme styles. Shared between `getResolvedNodeStyles` (email serializer)\n * and `injectThemeCss` (editor preview) so both surfaces stay in sync.\n *\n * Includes both raw tiptap node names (e.g. `tableCell`) and theme\n * component keys (e.g. `list`) because the serializer matches against both.\n *\n * `bulletList` and `orderedList` are intentionally omitted: their elements\n * already carry the shared `node-list` class, so the `list` reset rule\n * covers them without forcing the dedicated `.node-bulletList` /\n * `.node-orderedList` rules to redundantly emit `margin: 0; padding: 0`.\n */\nexport const RESET_NODE_TYPES = new Set<string>([\n  'body',\n  'button',\n  'columns',\n  'div',\n  'h1',\n  'h2',\n  'h3',\n  'list',\n  'listItem',\n  'listParagraph',\n  'nestedList',\n  'table',\n  'paragraph',\n  'tableCell',\n  'tableHeader',\n  'tableRow',\n  'youtube',\n]);\n\n/**\n * Returns resolved React.CSSProperties for a node when you already have merged CssJs\n * (e.g. in the serializer where there is no editor). Centralizes which theme keys\n * apply to which node type.\n */\nexport function getResolvedNodeStyles(\n  node: JSONContent,\n  depth: number,\n  mergedCssJs: CssJs,\n): React.CSSProperties {\n  const key = getThemeComponentKey(node.type ?? '', depth, node.attrs ?? {});\n  if (!key) {\n    if (RESET_NODE_TYPES.has(node.type ?? '')) {\n      return mergedCssJs.reset ?? {};\n    }\n    return {};\n  }\n  const component = mergedCssJs[key] ?? {};\n  const shouldReset =\n    RESET_NODE_TYPES.has(key) || RESET_NODE_TYPES.has(node.type ?? '');\n  if (shouldReset) {\n    const reset = mergedCssJs.reset ?? {};\n    return { ...reset, ...component };\n  }\n  return { ...component };\n}\n\nexport function stylesToCss(\n  styles: PanelGroup[],\n  theme: EditorTheme,\n): Record<KnownThemeComponents, React.CSSProperties> {\n  const parsed = transformToCssJs(\n    normalizeThemePanelStyles(theme, styles) ?? EDITOR_THEMES[theme],\n    DEFAULT_INBOX_FONT_SIZE_PX,\n  );\n  return mergeCssJs(RESET_THEMES[theme], parsed);\n}\n\nfunction resolveThemeConfig(config: EditorThemeInput): {\n  baseTheme: EditorTheme;\n  panels: PanelGroup[] | undefined;\n} {\n  if (!isThemeConfig(config)) {\n    return { baseTheme: config, panels: undefined };\n  }\n  const baseTheme: EditorTheme = config.extends ?? 'minimal';\n  const basePanels = EDITOR_THEMES[baseTheme];\n  const panels = themeStylesToPanelOverrides(config.styles, basePanels);\n  return { baseTheme, panels };\n}\n\nexport function getEmailTheming(editor: Editor) {\n  const theme = getEmailTheme(editor);\n  const normalizedStyles =\n    normalizeThemePanelStyles(theme, getEmailStyles(editor)) ??\n    EDITOR_THEMES[theme];\n\n  return {\n    styles: normalizedStyles,\n    theme,\n    css: getEmailCss(editor),\n  };\n}\n\nexport function useEmailTheming(editor: Editor | null) {\n  return useEditorState({\n    editor,\n    selector({ editor: ed }) {\n      if (!ed) {\n        return null;\n      }\n      return getEmailTheming(ed);\n    },\n  });\n}\n\nfunction getEmailStyles(editor: Editor) {\n  return getGlobalContent('styles', editor) as PanelGroup[] | null;\n}\n\n/**\n * Sets the global panel styles on the editor document.\n * Persists into the `GlobalContent` node under the `'styles'` key.\n */\nexport function setGlobalStyles(editor: Editor, styles: PanelGroup[]): boolean {\n  return editor.commands.setGlobalContent('styles', styles);\n}\n\n/**\n * Sets the current email theme on the editor document.\n * Persists into the `GlobalContent` node under the `'theme'` key.\n */\nexport function setCurrentTheme(editor: Editor, theme: EditorTheme): boolean {\n  return editor.commands.setGlobalContent('theme', theme);\n}\n\n/**\n * Sets the global CSS string injected into the email `<head>`.\n * Persists into the `GlobalContent` node under the `'css'` key.\n */\nexport function setGlobalCssInjected(editor: Editor, css: string): boolean {\n  return editor.commands.setGlobalContent('css', css);\n}\n\nfunction getEmailTheme(editor: Editor): EditorTheme {\n  const extensionOptions = (\n    editor.extensionManager.extensions.find(\n      (extension) => extension.name === 'theming',\n    ) as { options?: { theme?: EditorThemeInput } }\n  )?.options?.theme;\n\n  if (isThemeConfig(extensionOptions)) {\n    return extensionOptions.extends ?? 'minimal';\n  }\n\n  if (extensionOptions === 'basic' || extensionOptions === 'minimal') {\n    return extensionOptions;\n  }\n\n  const globalTheme = getGlobalContent('theme', editor) as EditorTheme | null;\n  if (globalTheme === 'basic' || globalTheme === 'minimal') {\n    return globalTheme;\n  }\n\n  const inferredTheme = inferThemeFromPanelStyles(getEmailStyles(editor));\n  if (inferredTheme) {\n    return inferredTheme;\n  }\n\n  return 'basic';\n}\n\nfunction getEmailCss(editor: Editor) {\n  return getGlobalContent('css', editor) as string | null;\n}\n\nexport const EmailTheming = Extension.create<{\n  theme?: EditorThemeInput;\n  serializerPlugin: SerializerPlugin;\n}>({\n  name: 'theming',\n\n  addOptions() {\n    return {\n      theme: undefined as EditorThemeInput | undefined,\n      serializerPlugin: {\n        getNodeStyles(node, depth, editor): React.CSSProperties {\n          const theming = getEmailTheming(editor);\n\n          return getResolvedNodeStyles(\n            node,\n            depth,\n            getMergedCssJs(theming.theme, theming.styles),\n          );\n        },\n        BaseTemplate({ previewText, children, editor }) {\n          const { css: globalCss, styles, theme } = getEmailTheming(editor);\n          const mergedStyles = getMergedCssJs(theme, styles);\n\n          return (\n            <Html>\n              <Head>\n                <meta content=\"width=device-width\" name=\"viewport\" />\n                <meta content=\"IE=edge\" httpEquiv=\"X-UA-Compatible\" />\n                <meta name=\"x-apple-disable-message-reformatting\" />\n                <meta\n                  content=\"telephone=no,address=no,email=no,date=no,url=no\"\n                  name=\"format-detection\"\n                />\n\n                {globalCss && <style>{globalCss}</style>}\n              </Head>\n              {previewText && previewText !== '' && (\n                <Preview>{previewText}</Preview>\n              )}\n\n              <Body style={mergedStyles.body}>{children}</Body>\n            </Html>\n          );\n        },\n      } satisfies SerializerPlugin,\n    };\n  },\n\n  addProseMirrorPlugins() {\n    const { editor } = this;\n    const scopeId = `tiptap-theme-${Math.random().toString(36).slice(2, 10)}`;\n    const scopeAttribute = 'data-editor-theme-scope';\n    const scopeSelector = `.tiptap.ProseMirror[${scopeAttribute}=\"${scopeId}\"]`;\n    const themeStyleId = `${scopeId}-theme`;\n    const globalStyleId = `${scopeId}-global`;\n\n    return [\n      new Plugin({\n        key: new PluginKey('themingStyleInjector'),\n        view(view) {\n          let prevStyles: PanelGroup[] | null = null;\n          let prevTheme: EditorTheme | null = null;\n          let prevCss: string | null = null;\n          let seededFromConfig = false;\n\n          view.dom.setAttribute(scopeAttribute, scopeId);\n\n          const sync = () => {\n            if (!seededFromConfig) {\n              seededFromConfig = true;\n              const extensionTheme = (\n                editor.extensionManager.extensions.find(\n                  (ext) => ext.name === 'theming',\n                ) as { options?: { theme?: EditorThemeInput } }\n              )?.options?.theme;\n\n              if (isThemeConfig(extensionTheme)) {\n                const { baseTheme, panels } =\n                  resolveThemeConfig(extensionTheme);\n                if (panels && !getGlobalContent('styles', editor)) {\n                  editor.commands.setGlobalContent('styles', panels);\n                }\n                if (!getGlobalContent('theme', editor)) {\n                  editor.commands.setGlobalContent('theme', baseTheme);\n                }\n              }\n            }\n\n            const theme = getEmailTheme(editor);\n            const styles = getEmailStyles(editor);\n            const resolvedStyles = styles ?? EDITOR_THEMES[theme];\n            const css = getEmailCss(editor);\n\n            if (styles !== prevStyles || theme !== prevTheme) {\n              prevStyles = styles as PanelGroup[] | null;\n              prevTheme = theme;\n              const mergedCssJs = getMergedCssJs(theme, resolvedStyles);\n              injectThemeCss(mergedCssJs, {\n                scopeSelector,\n                styleId: themeStyleId,\n              });\n            }\n\n            if (css !== prevCss) {\n              prevCss = css;\n              injectGlobalPlainCss(css, {\n                scopeSelector,\n                styleId: globalStyleId,\n              });\n            }\n          };\n\n          sync();\n\n          return {\n            update: sync,\n            destroy() {\n              document.getElementById(themeStyleId)?.remove();\n              document.getElementById(globalStyleId)?.remove();\n              view.dom.removeAttribute(scopeAttribute);\n            },\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gB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACF;EACF;CACD;EACE,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,QAAQ;GACN;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;KACP,MAAM;KACN,QAAQ;KACR,OAAO;KACR;IACD,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OA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ACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACF;EACF;CACD;EACE,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,QAAQ;GACN;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACF;EACF;CACD;EACE,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,QAAQ;GACN;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACF;EACF;CACF;AAED,MAAM,gBAA8B;CAClC;EACE,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,QAAQ;GACN;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO,KAAA;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACF;EACF;CACD;EACE,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,QAAQ;GACN;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;KACP,MAAM;KACN,QAAQ;KACR,OAAO;KACR;IACD,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,gBAAgB;IACjB;GACD;IACE,OAAO;IACP,MAA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AAC,SAAS,UAAU;EAClC,cAAc;EACd,UAAU;EACX;CACD,OAAO;EACL,OAAO;EACP,MAAM;EACN,cAAc,CAAC,SAAS,UAAU;EAClC,cAAc;EACd,UAAU;EACX;CACD,UAAU;EACR,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc,CAAC,SAAS,UAAU;EAClC,cAAc;EACd,UAAU;EACX;CACD,YAAY;EACV,OAAO;EACP,MAAM;EACN,SAAS;GACP,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACN;EACD,cAAc,CAAC,SAAS,UAAU;EAClC,cAAc;EACd,UAAU;EACX;CACD,eAAe;EACb,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc,CAAC,SAAS,UAAU;EAClC,cAAc;EACd,UAAU;EACX;CACD,YAAY;EACV,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,gBAAgB;EACd,OAAO;EACP,MAAM;EACN,SAAS;GACP,MAAM;GACN,WAAW;GACX,gBAAgB;GACjB;EACD,cAAc;EACd,UAAU;EACX;CACD,cAAc;EACZ,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,qBAAqB;EACnB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,sBAAsB;EACpB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,wBAAwB;EACtB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,yBAAyB;EACvB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,aAAa;EACX,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,gBAAgB;EACd,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,kBAAkB;EAChB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,mBAAmB;EACjB,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,aAAa;EACX,OAAO;EACP,MAAM;EACN,SAAS;GACP,OAAO;GACP,QAAQ;GACR,QAAQ;GACT;EACD,cAAc;EACd,UAAU;EACX;CACD,gBAAgB;EACd,OAAO;EACP,MAAM;EACN,SAAS;GACP,OAAO;GACP,QAAQ;GACR,QAAQ;GACT;EACD,cAAc;EACd,UAAU;EACX;CACD,kBAAkB;EAChB,OAAO;EACP,MAAM;EACN,SAAS;GACP,OAAO;GACP,QAAQ;GACR,QAAQ;GACT;EACD,cAAc;EACd,UAAU;EACX;CACD,mBAAmB;EACjB,OAAO;EACP,MAAM;EACN,SAAS;GACP,OAAO;GACP,QAAQ;GACR,QAAQ;GACT;EACD,cAAc;EACd,UAAU;EACX;CACD,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,SAAS;GACP,OAAO;GACP,QAAQ;GACR,QAAQ;GACT;EACD,cAAc;EACd,UAAU;EACX;CACD,aAAa;EACX,OAAO;EACP,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,gBAAgB;EACd,OAAO;EACP,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,kBAAkB;EAChB,OAAO;EACP,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,mBAAmB;EACjB,OAAO;EACP,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,SAAS;EACP,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,YAAY;EACV,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd,UAAU;EACX;CACD,aAAa;EACX,OAAO;EACP,MAAM;EACN,MAAM;EACN,cAAc;EACd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