@maily-to/render 0.1.4 → 0.2.0
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.
- package/LICENSE +21 -0
- package/dist/index.d.mts +217 -243
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +217 -243
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- package/readme.md +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,117 +1,91 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export { JSONContent } from '@tiptap/core';
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import { HtmlProps } from "@react-email/components";
|
|
3
|
+
import { JSONContent, JSONContent as JSONContent$1 } from "@tiptap/core";
|
|
4
|
+
import { RendererThemeOptions } from "@maily-to/shared";
|
|
6
5
|
|
|
6
|
+
//#region src/meta.d.ts
|
|
7
7
|
type MetaDescriptor = {
|
|
8
|
-
|
|
8
|
+
charSet: 'utf-8';
|
|
9
9
|
} | {
|
|
10
|
-
|
|
10
|
+
title: string;
|
|
11
11
|
} | {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
name: string;
|
|
13
|
+
content: string;
|
|
14
14
|
} | {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
property: string;
|
|
16
|
+
content: string;
|
|
17
17
|
} | {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
httpEquiv: string;
|
|
19
|
+
content: string;
|
|
20
20
|
} | {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
tagName: 'meta' | 'link';
|
|
22
|
+
[attribute: string]: string;
|
|
23
23
|
} | {
|
|
24
|
-
|
|
24
|
+
[name: string]: string;
|
|
25
25
|
};
|
|
26
26
|
type MetaDescriptors = MetaDescriptor[];
|
|
27
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/maily.d.ts
|
|
28
29
|
interface NodeOptions {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
parent?: JSONContent$1;
|
|
31
|
+
prev?: JSONContent$1;
|
|
32
|
+
next?: JSONContent$1;
|
|
33
|
+
payloadValue?: PayloadValue;
|
|
33
34
|
}
|
|
34
35
|
interface MarkType {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
interface ThemeOptions {
|
|
40
|
-
colors?: Partial<{
|
|
41
|
-
heading: string;
|
|
42
|
-
paragraph: string;
|
|
43
|
-
horizontal: string;
|
|
44
|
-
footer: string;
|
|
45
|
-
blockquoteBorder: string;
|
|
46
|
-
codeBackground: string;
|
|
47
|
-
codeText: string;
|
|
48
|
-
linkCardTitle: string;
|
|
49
|
-
linkCardDescription: string;
|
|
50
|
-
linkCardBadgeText: string;
|
|
51
|
-
linkCardBadgeBackground: string;
|
|
52
|
-
linkCardSubTitle: string;
|
|
53
|
-
}>;
|
|
54
|
-
container?: Partial<CSSProperties>;
|
|
55
|
-
fontSize?: Partial<{
|
|
56
|
-
paragraph: Partial<{
|
|
57
|
-
size: string;
|
|
58
|
-
lineHeight: string;
|
|
59
|
-
}>;
|
|
60
|
-
footer: Partial<{
|
|
61
|
-
size: string;
|
|
62
|
-
lineHeight: string;
|
|
63
|
-
}>;
|
|
64
|
-
}>;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
type: string;
|
|
38
|
+
attrs?: Record<string, any> | undefined;
|
|
65
39
|
}
|
|
66
40
|
interface MailyConfig {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The preview text is the snippet of text that is pulled into the inbox
|
|
43
|
+
* preview of an email client, usually right after the subject line.
|
|
44
|
+
*
|
|
45
|
+
* Default: `undefined`
|
|
46
|
+
*/
|
|
47
|
+
preview?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The theme object allows you to customize the colors and font sizes of the
|
|
50
|
+
* rendered email.
|
|
51
|
+
*
|
|
52
|
+
* Default:
|
|
53
|
+
* ```js
|
|
54
|
+
* {
|
|
55
|
+
* colors: {
|
|
56
|
+
* heading: '#111827',
|
|
57
|
+
* paragraph: '#374151',
|
|
58
|
+
* horizontal: '#EAEAEA',
|
|
59
|
+
* footer: '#64748B',
|
|
60
|
+
* },
|
|
61
|
+
* fontSize: {
|
|
62
|
+
* paragraph: '15px',
|
|
63
|
+
* footer: {
|
|
64
|
+
* size: '14px',
|
|
65
|
+
* lineHeight: '24px',
|
|
66
|
+
* },
|
|
67
|
+
* },
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```js
|
|
73
|
+
* const maily = new Maily(content, {
|
|
74
|
+
* theme: {
|
|
75
|
+
* colors: {
|
|
76
|
+
* heading: '#111827',
|
|
77
|
+
* },
|
|
78
|
+
* fontSize: {
|
|
79
|
+
* footer: {
|
|
80
|
+
* size: '14px',
|
|
81
|
+
* lineHeight: '24px',
|
|
82
|
+
* },
|
|
83
|
+
* },
|
|
84
|
+
* },
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
theme?: Partial<RendererThemeOptions>;
|
|
115
89
|
}
|
|
116
90
|
declare const DEFAULT_SECTION_BACKGROUND_COLOR = "#ffffff";
|
|
117
91
|
declare const DEFAULT_SECTION_ALIGN = "left";
|
|
@@ -140,158 +114,158 @@ declare const DEFAULT_INLINE_IMAGE_WIDTH = 20;
|
|
|
140
114
|
declare const LINK_PROTOCOL_REGEX: RegExp;
|
|
141
115
|
declare const DEFAULT_META_TAGS: MetaDescriptors;
|
|
142
116
|
declare const DEFAULT_HTML_PROPS: HtmlProps;
|
|
143
|
-
declare const DEFAULT_BUTTON_PADDING_TOP = 10;
|
|
144
|
-
declare const DEFAULT_BUTTON_PADDING_RIGHT = 32;
|
|
145
|
-
declare const DEFAULT_BUTTON_PADDING_BOTTOM = 10;
|
|
146
|
-
declare const DEFAULT_BUTTON_PADDING_LEFT = 32;
|
|
147
117
|
interface RenderOptions {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
118
|
+
/**
|
|
119
|
+
* The options object allows you to customize the output of the rendered
|
|
120
|
+
* email.
|
|
121
|
+
* - `pretty` - If `true`, the output will be formatted with indentation and
|
|
122
|
+
* line breaks.
|
|
123
|
+
* - `plainText` - If `true`, the output will be plain text instead of HTML.
|
|
124
|
+
* This is useful for testing purposes.
|
|
125
|
+
*
|
|
126
|
+
* Default: `pretty` - `false`, `plainText` - `false`
|
|
127
|
+
*/
|
|
128
|
+
pretty?: boolean;
|
|
129
|
+
plainText?: boolean;
|
|
160
130
|
}
|
|
161
131
|
type VariableFormatter = (options: {
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
variable: string;
|
|
133
|
+
fallback?: string;
|
|
164
134
|
}) => string;
|
|
165
135
|
type VariableValues = Map<string, string>;
|
|
166
136
|
type LinkValues = Map<string, string>;
|
|
167
137
|
type PayloadValue = Record<string, any> | boolean;
|
|
168
138
|
type PayloadValues = Map<string, PayloadValue>;
|
|
169
139
|
declare class Maily {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
140
|
+
private readonly content;
|
|
141
|
+
private config;
|
|
142
|
+
private variableFormatter;
|
|
143
|
+
private shouldReplaceVariableValues;
|
|
144
|
+
private variableValues;
|
|
145
|
+
private linkValues;
|
|
146
|
+
private openTrackingPixel;
|
|
147
|
+
private payloadValues;
|
|
148
|
+
private marksOrder;
|
|
149
|
+
private meta;
|
|
150
|
+
private htmlProps;
|
|
151
|
+
constructor(content?: JSONContent$1);
|
|
152
|
+
setPreviewText(preview?: string): void;
|
|
153
|
+
setTheme(theme: Partial<RendererThemeOptions>): void;
|
|
154
|
+
setVariableFormatter(formatter: VariableFormatter): void;
|
|
155
|
+
/**
|
|
156
|
+
* `setVariableValue` will set the variable value.
|
|
157
|
+
* It will also set `shouldReplaceVariableValues` to `true`.
|
|
158
|
+
*
|
|
159
|
+
* @param variable - The variable name
|
|
160
|
+
* @param value - The variable value
|
|
161
|
+
*/
|
|
162
|
+
setVariableValue(variable: string, value: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* `setVariableValues` will set the variable values.
|
|
165
|
+
* It will also set `shouldReplaceVariableValues` to `true`.
|
|
166
|
+
*
|
|
167
|
+
* @param values - The variable values
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```js
|
|
171
|
+
* const maily = new Maily(content);
|
|
172
|
+
* maily.setVariableValues({
|
|
173
|
+
* name: 'John Doe',
|
|
174
|
+
* email: 'john@doe.com',
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
setVariableValues(values: Record<string, string>): void;
|
|
179
|
+
setLinkValue(link: string, value: string): void;
|
|
180
|
+
setLinkValues(values: Record<string, string>): void;
|
|
181
|
+
setPayloadValue(key: string, value: PayloadValue): void;
|
|
182
|
+
setPayloadValues(values: Record<string, PayloadValue>): void;
|
|
183
|
+
/**
|
|
184
|
+
* `setOpenTrackingPixel` will set the open tracking pixel.
|
|
185
|
+
*
|
|
186
|
+
* @param pixel - The open tracking pixel
|
|
187
|
+
*/
|
|
188
|
+
setOpenTrackingPixel(pixel?: string): void;
|
|
189
|
+
/**
|
|
190
|
+
* `setShouldReplaceVariableValues` will determine whether to replace the
|
|
191
|
+
* variable values or not. Otherwise, it will just return the formatted variable.
|
|
192
|
+
*
|
|
193
|
+
* Default: `false`
|
|
194
|
+
*/
|
|
195
|
+
setShouldReplaceVariableValues(shouldReplace: boolean): void;
|
|
196
|
+
/**
|
|
197
|
+
* `setMetaTags` will add the meta tags.
|
|
198
|
+
*
|
|
199
|
+
* @param meta - The meta tags
|
|
200
|
+
*/
|
|
201
|
+
setMetaTags(meta: MetaDescriptors): void;
|
|
202
|
+
/**
|
|
203
|
+
* `setHtmlProps` will set the HTML props.
|
|
204
|
+
*
|
|
205
|
+
* @param props - The HTML props
|
|
206
|
+
*/
|
|
207
|
+
setHtmlProps(props: HtmlProps): void;
|
|
208
|
+
getAllLinks(): Set<string>;
|
|
209
|
+
private isValidUrl;
|
|
210
|
+
render(options?: RenderOptions): Promise<string>;
|
|
211
|
+
/**
|
|
212
|
+
* `markup` will render the JSON content into React Email markup.
|
|
213
|
+
* and return the raw React Tree.
|
|
214
|
+
*/
|
|
215
|
+
markup(): react_jsx_runtime0.JSX.Element;
|
|
216
|
+
private getMarginOverrideConditions;
|
|
217
|
+
private getMappedContent;
|
|
218
|
+
private renderNode;
|
|
219
|
+
private renderMark;
|
|
220
|
+
private paragraph;
|
|
221
|
+
private text;
|
|
222
|
+
private bold;
|
|
223
|
+
private italic;
|
|
224
|
+
private underline;
|
|
225
|
+
private strike;
|
|
226
|
+
private textStyle;
|
|
227
|
+
private link;
|
|
228
|
+
private removeLinkProtocol;
|
|
229
|
+
private variableUrlValue;
|
|
230
|
+
private heading;
|
|
231
|
+
private variable;
|
|
232
|
+
private getVariableValue;
|
|
233
|
+
private horizontalRule;
|
|
234
|
+
private orderedList;
|
|
235
|
+
private bulletList;
|
|
236
|
+
private listItem;
|
|
237
|
+
private button;
|
|
238
|
+
private spacer;
|
|
239
|
+
private hardBreak;
|
|
240
|
+
private logo;
|
|
241
|
+
private image;
|
|
242
|
+
private footer;
|
|
243
|
+
private blockquote;
|
|
244
|
+
private code;
|
|
245
|
+
private linkCard;
|
|
246
|
+
private section;
|
|
247
|
+
private columns;
|
|
248
|
+
private adjustColumnsContent;
|
|
249
|
+
private column;
|
|
250
|
+
private repeat;
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated
|
|
253
|
+
* This for node is an alias for the repeat node
|
|
254
|
+
* we will remove this in the future
|
|
255
|
+
* @param node
|
|
256
|
+
* @param options
|
|
257
|
+
* @returns JSX.Element
|
|
258
|
+
*/
|
|
259
|
+
private for;
|
|
260
|
+
private shouldShow;
|
|
261
|
+
htmlCodeBlock(node: JSONContent$1, options?: NodeOptions): JSX.Element;
|
|
262
|
+
private inlineImage;
|
|
293
263
|
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/render.d.ts
|
|
266
|
+
declare function render(content: JSONContent$1, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
267
|
+
//# sourceMappingURL=render.d.ts.map
|
|
294
268
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
269
|
+
//#endregion
|
|
270
|
+
export { DEFAULT_COLUMNS_GAP, DEFAULT_COLUMNS_WIDTH, DEFAULT_COLUMN_BACKGROUND_COLOR, DEFAULT_COLUMN_BORDER_COLOR, DEFAULT_COLUMN_BORDER_RADIUS, DEFAULT_COLUMN_BORDER_WIDTH, DEFAULT_COLUMN_PADDING_BOTTOM, DEFAULT_COLUMN_PADDING_LEFT, DEFAULT_COLUMN_PADDING_RIGHT, DEFAULT_COLUMN_PADDING_TOP, DEFAULT_HTML_PROPS, DEFAULT_INLINE_IMAGE_HEIGHT, DEFAULT_INLINE_IMAGE_WIDTH, DEFAULT_META_TAGS, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, JSONContent, LINK_PROTOCOL_REGEX, LinkValues, Maily, MailyConfig, MarkType, PayloadValue, PayloadValues, RenderOptions, VariableFormatter, VariableValues, render };
|
|
271
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/meta.tsx","../src/maily.tsx","../src/render.ts"],"sourcesContent":[],"mappings":";;;;;;KAAY,cAAA;;;;;;EAAA,OAAA,EAAA,MAAA;AA2BZ,CAAA,GAAY;;;;ECUF,SAAA,EAAA,MAAW;EAAA,OAAA,EAAA,MAAA;CAAA,GAAA;EACC,OACb,EAAA,MAAA,GAAA,MAAA;EAAW,CAAA,SACX,EAAA,MAAA,CAAA,EAAA,MAAA;CAAW,GAAA;EAES,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAG7B,CAAA;AAyCiB,KD3DL,eAAA,GAAkB,cC2DF,EAAA;;;UAjDlB,WAAA;WACC;EDtCC,IAAA,CAAA,ECuCH,aDvCiB;EA2Bd,IAAA,CAAA,ECaH,aDbkB;iBCeV;;UAGA,QAAA;EARP,CAAA,GAAA,EAAA,MAAA,CAAA,EAAW,GAAA;EAAA,IAAA,EAAA,MAAA;EAAA,KACV,CAAA,EAUD,MAVC,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,SAAA;;AAEF,UA8CQ,WAAA,CA9CR;EAAW;AAES;AAG7B;AAyCA;;;EAgD8B,OAApB,CAAA,EAAA,MAAA;EAAO;AAKjB;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AA4BA;AAUA;AAeA;AAIA;AACA;AAEA;AACA;;;;AAA+B;AAE/B;;EAAkB,KAqBK,CAAA,EA1Hb,OA0Ha,CA1HL,oBA0HK,CAAA;;AAQL,cA7HL,gCAAA,GA6HK,SAAA;AAOgB,cAnIrB,qBAAA,GAmIqB,MAAA;AAkCN,cApKf,4BAAA,GAoKe,CAAA;AAcJ,cAjLX,4BAAA,GAiLW,SAAA;AAMc,cArLzB,0BAAA,GAqLyB,CAAA;AAQI,cA5L7B,4BAAA,GA4L6B,CAAA;AAAf,cA3Ld,6BAAA,GA2Lc,CAAA;AA8BP,cAxNP,2BAAA,GAwNO,CAAA;AASE,cA/NT,2BAAA,GA+NS,CAAA;AAOT,cArOA,6BAAA,GAqOA,CAAA;AAuDA,cA3RA,8BAAA,GA2RA,CAAA;AACR,cA3RQ,4BAAA,GA2RR,CAAA;AAUG,cAnSK,qBAAA,GAmSL,MAAA;AAquCc,cAvgDT,mBAAA,GAugDS,CAAA;AAAuB,cArgDhC,+BAAA,GAqgDgC,aAAA;AAAc,cApgD9C,4BAAA,GAogDkD,CAAA;AAAO,cAngDzD,2BAAA,GAmgDyD,CAAA;cAlgDzD,2BAAA;cAEA,0BAAA;cACA,4BAAA;AC/JS,cDgKT,6BAAA,GChKe,CAAA;AAAA,cDiKf,2BAAA,GCjKe,CAAA;AACjB,cDkKE,2BAAA,GClKF,EAAA;AACA,cDkKE,0BAAA,GClKF,EAAA;AAAc,cDoKZ,mBCpKY,EDoKO,MCpKP;AACtB,cDqKU,iBCrKV,EDqK6B,eCrK7B;AAAO,cDiMG,kBCjMH,EDiMuB,SCjMvB;UD2MO,aAAA;;;;;;;;;;;;;;KAeL,iBAAA;;;;KAIA,cAAA,GAAiB;KACjB,UAAA,GAAa;KAEb,YAAA,GAAe;KACf,aAAA,GAAgB,YAAY;cAE3B,KAAA;;;;;;;;;;;;wBAqBU;;kBAQL,QAAQ;kCAOQ;;;;;;;;;;;;;;;;;;;;;;;;4BAkCN;;wBAcJ;sCAMc;2BAQX,eAAe;;;;;;;;;;;;;;;;;;;oBA8BtB;;;;;;sBASE;iBAOT;;mBAuDA,gBACR;;;;;YAUG,kBAAA,CAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAquCc,yBAAuB,cAAc,GAAA,CAAI;;;;;iBC9pDzC,MAAA,UACX,wBACA,cAAc,gBACtB"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var yt=Object.create;var M=Object.defineProperty,bt=Object.defineProperties,Ot=Object.getOwnPropertyDescriptor,wt=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,Nt=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var U=(a,t,e)=>t in a?M(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,g=(a,t)=>{for(var e in t||(t={}))F.call(t,e)&&U(a,e,t[e]);if(R)for(var e of R(t))W.call(t,e)&&U(a,e,t[e]);return a},b=(a,t)=>bt(a,wt(t));var P=(a,t)=>{var e={};for(var n in a)F.call(a,n)&&t.indexOf(n)<0&&(e[n]=a[n]);if(a!=null&&R)for(var n of R(a))t.indexOf(n)<0&&W.call(a,n)&&(e[n]=a[n]);return e};var Tt=(a,t)=>{for(var e in t)M(a,e,{get:t[e],enumerable:!0})},H=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ct(t))!F.call(a,r)&&r!==e&&M(a,r,{get:()=>t[r],enumerable:!(n=Ot(t,r))||n.enumerable});return a};var Et=(a,t,e)=>(e=a!=null?yt(Nt(a)):{},H(t||!a||!a.__esModule?M(e,"default",{value:a,enumerable:!0}):e,a)),vt=a=>H(M({},"__esModule",{value:!0}),a);var L=(a,t,e)=>new Promise((n,r)=>{var i=c=>{try{l(e.next(c))}catch(d){r(d)}},s=c=>{try{l(e.throw(c))}catch(d){r(d)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,s);l((e=e.apply(a,t)).next())});var zt={};Tt(zt,{DEFAULT_BUTTON_PADDING_BOTTOM:()=>St,DEFAULT_BUTTON_PADDING_LEFT:()=>xt,DEFAULT_BUTTON_PADDING_RIGHT:()=>gt,DEFAULT_BUTTON_PADDING_TOP:()=>ft,DEFAULT_COLUMNS_GAP:()=>ct,DEFAULT_COLUMNS_WIDTH:()=>Rt,DEFAULT_COLUMN_BACKGROUND_COLOR:()=>Pt,DEFAULT_COLUMN_BORDER_COLOR:()=>Bt,DEFAULT_COLUMN_BORDER_RADIUS:()=>Jt,DEFAULT_COLUMN_BORDER_WIDTH:()=>It,DEFAULT_COLUMN_PADDING_BOTTOM:()=>Wt,DEFAULT_COLUMN_PADDING_LEFT:()=>Ht,DEFAULT_COLUMN_PADDING_RIGHT:()=>Ut,DEFAULT_COLUMN_PADDING_TOP:()=>Ft,DEFAULT_HTML_PROPS:()=>mt,DEFAULT_INLINE_IMAGE_HEIGHT:()=>ut,DEFAULT_INLINE_IMAGE_WIDTH:()=>pt,DEFAULT_META_TAGS:()=>dt,DEFAULT_SECTION_ALIGN:()=>Q,DEFAULT_SECTION_BACKGROUND_COLOR:()=>Y,DEFAULT_SECTION_BORDER_COLOR:()=>tt,DEFAULT_SECTION_BORDER_WIDTH:()=>Z,DEFAULT_SECTION_MARGIN_BOTTOM:()=>rt,DEFAULT_SECTION_MARGIN_LEFT:()=>ot,DEFAULT_SECTION_MARGIN_RIGHT:()=>nt,DEFAULT_SECTION_MARGIN_TOP:()=>et,DEFAULT_SECTION_PADDING_BOTTOM:()=>at,DEFAULT_SECTION_PADDING_LEFT:()=>lt,DEFAULT_SECTION_PADDING_RIGHT:()=>st,DEFAULT_SECTION_PADDING_TOP:()=>it,LINK_PROTOCOL_REGEX:()=>ht,Maily:()=>k,render:()=>Xt});module.exports=vt(zt);var V=require("react"),p=require("@react-email/components"),$=require("@react-email/render");var _t=a=>Object.prototype.toString.call(a);var Mt=a=>_t(a)==="[object Object]";function Lt(a){return Object.keys(a)}function I(a,...t){if(!t.length)return a;let e=t.shift();return e===void 0?a:(J(a)&&J(e)&&Lt(e).forEach(n=>{n==="__proto__"||n==="constructor"||n==="prototype"||(J(e[n])?(a[n]||(a[n]={}),J(a[n])?I(a[n],e[n]):a[n]=e[n]):a[n]=e[n])}),I(a,...t))}function J(a){return Mt(a)&&!Array.isArray(a)}var Qt=Symbol("p-void");function B(){return Math.random().toString(36).substr(2,6)}var A=require("react/jsx-runtime");function z(a){return a.filter((t,e,n)=>{let r=X(t);return e===n.findIndex(i=>X(i)===r)}).map(At).filter(Boolean)}function At(a){if("tagName"in a){let t=a,{tagName:e}=t,n=P(t,["tagName"]);return(0,A.jsx)(e,g({},n),JSON.stringify(n))}return"title"in a?(0,A.jsx)("title",{children:a.title}):"charSet"in a?(0,A.jsx)("meta",{charSet:a.charSet}):(0,A.jsx)("meta",g({},a),JSON.stringify(a))}function X(a){let t=Object.keys(a).sort().reduce((e,n)=>{let r=n;return e[r]=a[r],e},{});return JSON.stringify(t)}var q=require("node-html-parser"),K=Et(require("juice"));var o=require("react/jsx-runtime"),D={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var Dt={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var j={sm:"40px",md:"48px",lg:"64px"},Vt={pretty:!1,plainText:!1},G={colors:{heading:"#111827",paragraph:"#374151",horizontal:"#EAEAEA",footer:"#64748B",blockquoteBorder:"#D1D5DB",codeBackground:"#EFEFEF",codeText:"#111827",linkCardTitle:"#111827",linkCardDescription:"#6B7280",linkCardBadgeText:"#111827",linkCardBadgeBackground:"#FEF08A",linkCardSubTitle:"#6B7280"},container:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},fontSize:{paragraph:{size:"15px",lineHeight:"26.25px"},footer:{size:"14px",lineHeight:"24px"}}},kt='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',Y="#ffffff",Q="left",Z=1,tt="#000000",et=0,nt=0,rt=0,ot=0,it=5,st=5,at=5,lt=5,Rt="100%",ct=8,Pt="transparent",Jt=0,It=0,Bt="transparent",Ft=0,Ut=0,Wt=0,Ht=0,ut=20,pt=20,ht=/https?:\/\//,dt=[{name:"viewport",content:"width=device-width"},{httpEquiv:"X-UA-Compatible",content:"IE=edge"},{name:"x-apple-disable-message-reformatting"},{name:"format-detection",content:"telephone=no,address=no,email=no,date=no,url=no"},{name:"color-scheme",content:"light"},{name:"supported-color-schemes",content:"light"}],mt={lang:"en",dir:"ltr"},ft=10,gt=32,St=10,xt=32,k=class{constructor(t={type:"doc",content:[]}){this.config={theme:G};this.variableFormatter=({variable:t,fallback:e})=>e?`{{${t},fallback=${e}}}`:`{{${t}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.payloadValues=new Map;this.marksOrder=["underline","bold","italic","textStyle","link"];this.meta=dt;this.htmlProps=mt;this.content=t}setPreviewText(t){this.config.preview=t}setTheme(t){this.config.theme=I(this.config.theme||G,t)}setVariableFormatter(t){this.variableFormatter=t}setVariableValue(t,e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(t,e)}setVariableValues(t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(t).forEach(([e,n])=>{this.setVariableValue(e,n)})}setLinkValue(t,e){this.linkValues.set(t,e)}setLinkValues(t){Object.entries(t).forEach(([e,n])=>{this.setLinkValue(e,n)})}setPayloadValue(t,e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(t,e)}setPayloadValues(t){Object.entries(t).forEach(([e,n])=>{this.setPayloadValue(e,n)})}setOpenTrackingPixel(t){this.openTrackingPixel=t}setShouldReplaceVariableValues(t){this.shouldReplaceVariableValues=t}setMetaTags(t){this.meta.push(...t)}setHtmlProps(t){this.htmlProps=g(g({},this.htmlProps),t)}getAllLinks(){let t=this.content.content||[],e=new Set,n=i=>i&&this.isValidUrl(i)&&!i.startsWith("#")&&!i.startsWith("mailto:")&&!i.startsWith("tel:")&&typeof i=="string",r=i=>{var s;if(i.type==="button"){let l=(s=i.attrs)==null?void 0:s.url;n(l)&&l&&e.add(l)}else i.content&&i.content.forEach(l=>{l.marks&&l.marks.forEach(c=>{var m;let d=(m=c.attrs)==null?void 0:m.href;c.type==="link"&&n(d)&&e.add(d)}),l.content&&r(l)})};return t.forEach(i=>{r(i)}),e}isValidUrl(t){try{let e=new URL(t);return!0}catch(e){return!1}}render(){return L(this,arguments,function*(t=Vt){let e=this.markup();return(0,$.renderAsync)(e,t)})}markup(){var c;let t=this.content.content||[],e=t.map((d,m)=>{let u={prev:t[m-1],next:t[m+1],parent:d},h=this.renderNode(d,u);return h?(0,o.jsx)(V.Fragment,{children:h},B()):null}),{preview:n}=this.config,r=z(this.meta),i=this.htmlProps,s=(c=this.config.theme)==null?void 0:c.container;return(0,o.jsxs)(p.Html,b(g({},i),{children:[(0,o.jsxs)(p.Head,{children:[(0,o.jsx)(p.Font,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}"}}),r]}),(0,o.jsxs)(p.Body,{style:{margin:0},children:[n?(0,o.jsx)(p.Preview,{id:"__react-email-preview",children:n}):null,(0,o.jsx)(p.Container,{style:s,children:e}),this.openTrackingPixel?(0,o.jsx)(p.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]}))}getMarginOverrideConditions(t,e){let{parent:n,prev:r,next:i}=e||{},s=(i==null?void 0:i.type)==="spacer",l=(r==null?void 0:r.type)==="spacer",c=(n==null?void 0:n.type)==="listItem",d=(n==null?void 0:n.type)==="section"&&!i,m=(n==null?void 0:n.type)==="section"&&!r,u=(n==null?void 0:n.type)==="column"&&!i,h=(n==null?void 0:n.type)==="column"&&!r,f=(n==null?void 0:n.type)==="repeat"&&!r,S=(n==null?void 0:n.type)==="repeat"&&!i,x=(n==null?void 0:n.type)==="show"&&!r,y=(n==null?void 0:n.type)==="show"&&!i;return{isNextSpacer:s,isPrevSpacer:l,isLastSectionElement:d,isFirstSectionElement:m,isParentListItem:c,isLastColumnElement:u,isFirstColumnElement:h,isFirstRepeatElement:f,isLastRepeatElement:S,isFirstShowElement:x,isLastShowElement:y,shouldRemoveTopMargin:l||m||h||f||x,shouldRemoveBottomMargin:s||d||u||S||y}}getMappedContent(t,e){let n=t.content||[];return n.map((r,i)=>{let s=this.renderNode(r,b(g({},e),{next:n[i+1],prev:n[i-1]}));return s?(0,o.jsx)(V.Fragment,{children:s},B()):null}).filter(r=>r!==null)}renderNode(t,e={}){var r;let n=t.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t,e){let n=(t==null?void 0:t.text)||(0,o.jsx)(o.Fragment,{children:"\xA0"}),r=(t==null?void 0:t.marks)||[];return r.sort((i,s)=>this.marksOrder.indexOf(i.type)-this.marksOrder.indexOf(s.type)),r.reduce((i,s)=>{var c;let l=s.type;if(l in this)return(c=this[l])==null?void 0:c.call(this,s,i);throw new Error(`Mark type "${l}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:n}))}paragraph(t,e){var d,m,u,h,f,S,x,y;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{isParentListItem:i,shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,e);if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let c=i||s?0:20;return(0,o.jsx)(p.Text,{style:b(g(g({},r!=="left"?{textAlign:r}:{}),D),{fontSize:(u=(m=(d=this.config.theme)==null?void 0:d.fontSize)==null?void 0:m.paragraph)==null?void 0:u.size,lineHeight:(S=(f=(h=this.config.theme)==null?void 0:h.fontSize)==null?void 0:f.paragraph)==null?void 0:S.lineHeight,color:(y=(x=this.config.theme)==null?void 0:x.colors)==null?void 0:y.paragraph,margin:`0 0 ${c}px 0`}),children:t.content?this.getMappedContent(t,b(g({},e),{parent:t})):(0,o.jsx)(o.Fragment,{children:"\xA0"})})}text(t,e){let n=t.text||" ";if(t.marks)return this.renderMark(t,e);let r=n==null?void 0:n.match(/\s/g);return r&&r.length===n.length?(0,o.jsx)(o.Fragment,{children:r.map((i,s)=>(0,o.jsx)(V.Fragment,{children:"\xA0"},s))}):(0,o.jsx)(o.Fragment,{children:n})}bold(t,e){return(0,o.jsx)("strong",{children:e})}italic(t,e){return(0,o.jsx)("em",{children:e})}underline(t,e){return(0,o.jsx)("u",{children:e})}strike(t,e){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:e})}textStyle(t,e){var i,s;let{attrs:n}=t,{color:r=(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.paragraph}=n||{};return(0,o.jsx)("span",{style:{color:r},children:e})}link(t,e,n){var d,m,u;let{attrs:r}=t,i=(r==null?void 0:r.href)||"#",s=(r==null?void 0:r.target)||"_blank",l=(r==null?void 0:r.rel)||"noopener noreferrer nofollow";if((d=r==null?void 0:r.isUrlVariable)!=null?d:!1){let h=this.removeLinkProtocol(i);i=this.variableUrlValue(h,n)}else i=this.linkValues.get(i)||i;return(0,o.jsx)(p.Link,{href:i,rel:l,style:{fontWeight:500,textDecoration:"none",color:(u=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:u.heading},target:s,children:e})}removeLinkProtocol(t){return t.replace(ht,"")}variableUrlValue(t,e){var i,s;let{payloadValue:n}=e||{},r=this.removeLinkProtocol(t);return(s=(i=typeof n=="object"?n[r]:n)!=null?i:this.variableValues.get(r))!=null?s:t}heading(t,e){var u,h;let{attrs:n}=t,r=`h${Number(n==null?void 0:n.level)||1}`,i=(n==null?void 0:n.textAlign)||"left",{shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,e),{fontSize:l,lineHeight:c,fontWeight:d}=Dt[r];return this.shouldShow(t,e)?(0,o.jsx)(p.Heading,{as:r,style:{textAlign:i,color:(h=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:h.heading,fontSize:l,lineHeight:c,fontWeight:d},mb:s?0:12,mt:0,mx:0,children:this.getMappedContent(t,b(g({},e),{parent:t}))}):(0,o.jsx)(o.Fragment,{})}variable(t,e){let{payloadValue:n}=e||{},{id:r,fallback:i}=t.attrs||{};if(!this.shouldShow(t,e)||!r)return(0,o.jsx)(o.Fragment,{});let l=this.getVariableValue(r,i,e);return t!=null&&t.marks?this.renderMark({text:l,marks:t.marks},e):(0,o.jsx)(o.Fragment,{children:l})}getVariableValue(t,e,n){var s,l,c;let{payloadValue:r}=n||{},i=this.variableFormatter({variable:t,fallback:e});return this.shouldReplaceVariableValues&&(i=(c=(l=(s=typeof r=="object"?r[t]:r)!=null?s:this.variableValues.get(t))!=null?l:e)!=null?c:i),i}horizontalRule(t,e){return(0,o.jsx)(p.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(t,e);return(0,o.jsx)(p.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:n?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t,b(g({},e),{parent:t}))})})}bulletList(t,e){let{parent:n,next:r}=e||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,{parent:n,next:r});return(0,o.jsx)(p.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:i?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t,b(g({},e),{parent:t}))})})}listItem(t,e){return(0,o.jsx)("li",{style:g({marginBottom:"8px",paddingLeft:"6px"},D),children:this.getMappedContent(t,b(g({},e),{parent:t}))})}button(t,e){let{attrs:n}=t,{text:r,isTextVariable:i,url:s,isUrlVariable:l,variant:c,buttonColor:d,textColor:m,borderRadius:u,alignment:h="left",paddingTop:f=ft,paddingRight:S=gt,paddingBottom:x=St,paddingLeft:y=xt}=n||{};if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let O="0px";u==="round"?O="9999px":u==="smooth"&&(O="6px");let{shouldRemoveBottomMargin:w}=this.getMarginOverrideConditions(t,e),N=l?this.variableUrlValue(s,e):this.linkValues.get(s)||s,T=i?this.variableUrlValue(r,e):r;return f+=2,x+=2,(0,o.jsx)(p.Container,{style:{textAlign:h,maxWidth:"100%",marginBottom:w?"0px":"20px"},children:(0,o.jsx)(p.Button,{href:N,style:{color:String(m),backgroundColor:c==="filled"?String(d):"transparent",borderColor:String(d),borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:O,padding:`${f}px ${S}px ${x}px ${y}px`},children:T})})}spacer(t,e){let{attrs:n}=t,{height:r}=n||{};return this.shouldShow(t,e)?(0,o.jsx)(p.Container,{style:{height:`${r}px`}}):(0,o.jsx)(o.Fragment,{})}hardBreak(t,e){return(0,o.jsx)("br",{})}logo(t,e){let{attrs:n}=t,{src:r,isSrcVariable:i,alt:s,title:l,size:c,alignment:d="left"}=n||{};if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});r=i?this.variableUrlValue(r,e):r;let{shouldRemoveBottomMargin:u}=this.getMarginOverrideConditions(t,e);return(0,o.jsx)(p.Row,{style:{marginTop:"0px",marginBottom:u?"0px":"32px"},children:(0,o.jsx)(p.Column,{align:d,children:(0,o.jsx)(p.Img,{alt:s||l||"Logo",src:r,style:{width:j[c]||c,height:j[c]||c},title:l||s||"Logo"})})})}image(t,e){let{attrs:n}=t,{src:r,isSrcVariable:i,alt:s,title:l,width:c="auto",height:d="auto",alignment:m="center",externalLink:u="",isExternalLinkVariable:h,borderRadius:f=0}=n||{};if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let{shouldRemoveBottomMargin:x}=this.getMarginOverrideConditions(t,e);r=i?this.variableUrlValue(r,e):r,u=h?this.variableUrlValue(u,e):u;let y=c==="auto"?"auto":Number(c),C=y==="auto"?"auto":`${y}px`,O=d==="auto"?"auto":Number(d),w=O==="auto"?"auto":`${O}px`,N=(0,o.jsx)(p.Img,{alt:s||l||"Image",src:r,style:{width:C,height:w,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none",display:"block",borderRadius:f},title:l||s||"Image"});return(0,o.jsx)(p.Row,{style:{marginTop:"0px",marginBottom:x?"0px":"32px"},children:(0,o.jsx)(p.Column,{align:m,children:u?(0,o.jsx)("a",{href:u,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:N}):N})})}footer(t,e){var s,l,c,d,m,u,h,f;let{attrs:n}=t,{textAlign:r="left"}=n||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,e);return(0,o.jsx)(p.Text,{style:g({fontSize:(c=(l=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:l.footer)==null?void 0:c.size,lineHeight:(u=(m=(d=this.config.theme)==null?void 0:d.fontSize)==null?void 0:m.footer)==null?void 0:u.lineHeight,color:(f=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:i?"0px":"20px",textAlign:r},D),children:this.getMappedContent(t,b(g({},e),{parent:t}))})}blockquote(t,e){var i,s;let{isPrevSpacer:n,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,e);return(0,o.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:n?"0px":"20px",marginBottom:r?"0px":"20px"},children:this.getMappedContent(t,b(g({},e),{parent:t}))})}code(t,e){var n,r,i,s;return(0,o.jsx)("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:kt,fontWeight:400,letterSpacing:0},children:e})}linkCard(t,e){var f,S,x,y,C,O,w,N,T,v,E,_;let{attrs:n}=t,{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,e),{title:i,description:s,link:l,linkTitle:c,image:d,badgeText:m,subTitle:u}=n||{},h=this.linkValues.get(l)||this.variableValues.get(l)||l||"#";return(0,o.jsxs)("a",{href:h,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r?"0px":"20px"},target:"_blank",children:[d?(0,o.jsx)(p.Row,{style:{marginBottom:"6px"},children:(0,o.jsx)(p.Column,{style:{width:"100%",height:"100%"},children:(0,o.jsx)(p.Img,{alt:i||"Link Card",src:d,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:i||"Link Card"})})}):null,(0,o.jsx)(p.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,o.jsxs)(p.Column,{style:{verticalAlign:"top"},children:[(0,o.jsxs)(p.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,o.jsx)(p.Column,{children:(0,o.jsx)(p.Text,{style:g({fontSize:"18px",fontWeight:600,color:(S=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:S.linkCardTitle,margin:"0px"},D),children:i})}),m||u?(0,o.jsxs)(p.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[m?(0,o.jsx)("span",{style:{fontWeight:600,color:(y=(x=this.config.theme)==null?void 0:x.colors)==null?void 0:y.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(O=(C=this.config.theme)==null?void 0:C.colors)==null?void 0:O.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:m}):null," ",u&&!m?(0,o.jsx)("span",{style:{fontWeight:"normal",color:(N=(w=this.config.theme)==null?void 0:w.colors)==null?void 0:N.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:u}):null]}):null]}),(0,o.jsxs)(p.Text,{style:g({fontSize:"16px",color:(v=(T=this.config.theme)==null?void 0:T.colors)==null?void 0:v.linkCardDescription,marginTop:"0px",marginBottom:"0px"},D),children:[s," ",c?(0,o.jsx)("a",{href:h,rel:"noopener noreferrer",style:{color:(_=(E=this.config.theme)==null?void 0:E.colors)==null?void 0:_.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:c}):null]})]})})]})}section(t,e){let{attrs:n}=t,{borderRadius:r=0,backgroundColor:i=Y,align:s=Q,borderWidth:l=Z,borderColor:c=tt,marginTop:d=et,marginRight:m=nt,marginBottom:u=rt,marginLeft:h=ot,paddingTop:f=it,paddingRight:S=st,paddingBottom:x=at,paddingLeft:y=lt}=n||{};return this.shouldShow(t,e)?(0,o.jsx)(p.Row,{style:{marginTop:d,marginRight:m,marginBottom:u,marginLeft:h},children:(0,o.jsx)(p.Column,{align:s,style:{borderColor:c,borderWidth:l,borderStyle:"solid",backgroundColor:i,borderRadius:r,paddingTop:f,paddingRight:S,paddingBottom:x,paddingLeft:y},children:this.getMappedContent(t,b(g({},e),{parent:t}))})}):(0,o.jsx)(o.Fragment,{})}columns(t,e){let{attrs:n}=t;if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let[i,s]=this.adjustColumnsContent(t);return(0,o.jsx)(p.Row,{width:`${s}%`,style:{margin:0,padding:0,width:`${s}%`},className:"tab-row-full",children:this.getMappedContent(i,b(g({},e),{parent:i}))})}adjustColumnsContent(t){var u;let{content:e=[]}=t,n=100,r=e.filter(h=>{var f;return h.type==="column"&&!!Number(((f=h.attrs)==null?void 0:f.width)||0)}),i=e.filter(h=>{var f,S;return h.type==="column"&&(((f=h.attrs)==null?void 0:f.width)==="auto"||!((S=h.attrs)!=null&&S.width))}),s=r.reduce((h,f)=>{var S;return h+Number((S=f.attrs)==null?void 0:S.width)},0),l=n-s,c=Math.round(l/i.length),d=e.filter(h=>h.type==="column").length,m=((u=t.attrs)==null?void 0:u.gap)||ct;return[b(g({},t),{content:e.map((h,f)=>{var N,T,v;let S=h.type==="column"&&(((N=h.attrs)==null?void 0:N.width)==="auto"||!((T=h.attrs)!=null&&T.width)),x=f===0,y=f>0&&f<d-1,C=f===e.length-1,O=0,w=0;if(d<3)O=x?0:m/2,w=C?0:m/2;else{let E=m/2*1.5,_=E/2;O=x?0:y?_:E,w=C?0:y?_:E}return O=Math.round(O*100)/100,w=Math.round(w*100)/100,b(g({},h),{attrs:b(g({},h.attrs),{width:S?c:(v=h.attrs)==null?void 0:v.width,isFirstColumn:x,isLastColumn:C,index:f,paddingLeft:O,paddingRight:w})})})}),i.length===0?Math.min(n,s):n]}column(t,e){let{attrs:n}=t,{width:r,verticalAlign:i="top",paddingLeft:s=0,paddingRight:l=0}=n||{};return(0,o.jsx)(p.Column,{width:`${Number(r)}%`,style:{width:`${Number(r)}%`,margin:0,verticalAlign:i},className:"tab-col-full",children:(0,o.jsx)(p.Section,{style:{margin:0,paddingLeft:s,paddingRight:l},className:"tab-pad",children:this.getMappedContent(t,b(g({},e),{parent:t}))})})}repeat(t,e){var c,d;let{attrs:n}=t,{each:r=""}=n||{};if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let{payloadValue:s}=e||{};s=typeof s=="object"?s:{};let l=(d=(c=this.payloadValues.get(r))!=null?c:s[r])!=null?d:[];if(!Array.isArray(l))throw new Error(`Payload value for each "${r}" is not an array`);return(0,o.jsx)(o.Fragment,{children:l.map(m=>(0,o.jsx)(V.Fragment,{children:this.getMappedContent(t,b(g({},e),{parent:t,payloadValue:m}))},B()))})}for(t,e){return this.repeat(t,e)}shouldShow(t,e){var i,s,l;let n=(s=(i=t==null?void 0:t.attrs)==null?void 0:i.showIfKey)!=null?s:"";if(!n)return!0;let{payloadValue:r}=e||{};return r=typeof r=="object"?r:{},!!((l=this.payloadValues.get(n))!=null?l:r[n])}htmlCodeBlock(t,e){var d;if(!this.shouldShow(t,e))return(0,o.jsx)(o.Fragment,{});let r=((d=t.content)==null?void 0:d.reduce((m,u)=>{var h,f;if((u==null?void 0:u.type)==="text")return m+(u==null?void 0:u.text);if((u==null?void 0:u.type)==="variable"){let S=this.getVariableValue((h=u==null?void 0:u.attrs)==null?void 0:h.id,(f=u==null?void 0:u.attrs)==null?void 0:f.fallback,e);return m+S}return m},""))||"",i=(0,K.default)(r),s=(0,q.parse)(i),l=s==null?void 0:s.querySelector("head");l==null||l.remove();let c=s.toString();return(0,o.jsx)("table",{align:"left",width:"100%",border:0,cellPadding:"0",cellSpacing:"0",role:"presentation",children:(0,o.jsx)("tbody",{children:(0,o.jsx)("tr",{style:{width:"100%"},children:(0,o.jsx)("td",{style:{width:"100%"},dangerouslySetInnerHTML:{__html:c}})})})})}inlineImage(t,e){let{attrs:n}=t,{src:r,isSrcVariable:i,alt:s="",title:l="",height:c=ut,width:d=pt,externalLink:m="",isExternalLinkVariable:u}=n||{};r=i?this.variableUrlValue(r,e):r,m=u?this.variableUrlValue(m,e):m;let h=(0,o.jsx)("img",{src:r,alt:s,title:l,width:d,height:c,style:{display:"inline",verticalAlign:"middle",width:`${d}px`,height:`${c}px`,outline:"none",border:"none",textDecoration:"none"}});return m?(0,o.jsx)("a",{href:m,rel:"noopener noreferrer",style:{display:"inline",textDecoration:"none"},target:"_blank",children:h}):h}};function Xt(a,t){return L(this,null,function*(){let s=t||{},{theme:e,preview:n}=s,r=P(s,["theme","preview"]),i=new k(a);return i.setPreviewText(n),i.setTheme(e||{}),i.render(r)})}0&&(module.exports={DEFAULT_BUTTON_PADDING_BOTTOM,DEFAULT_BUTTON_PADDING_LEFT,DEFAULT_BUTTON_PADDING_RIGHT,DEFAULT_BUTTON_PADDING_TOP,DEFAULT_COLUMNS_GAP,DEFAULT_COLUMNS_WIDTH,DEFAULT_COLUMN_BACKGROUND_COLOR,DEFAULT_COLUMN_BORDER_COLOR,DEFAULT_COLUMN_BORDER_RADIUS,DEFAULT_COLUMN_BORDER_WIDTH,DEFAULT_COLUMN_PADDING_BOTTOM,DEFAULT_COLUMN_PADDING_LEFT,DEFAULT_COLUMN_PADDING_RIGHT,DEFAULT_COLUMN_PADDING_TOP,DEFAULT_HTML_PROPS,DEFAULT_INLINE_IMAGE_HEIGHT,DEFAULT_INLINE_IMAGE_WIDTH,DEFAULT_META_TAGS,DEFAULT_SECTION_ALIGN,DEFAULT_SECTION_BACKGROUND_COLOR,DEFAULT_SECTION_BORDER_COLOR,DEFAULT_SECTION_BORDER_WIDTH,DEFAULT_SECTION_MARGIN_BOTTOM,DEFAULT_SECTION_MARGIN_LEFT,DEFAULT_SECTION_MARGIN_RIGHT,DEFAULT_SECTION_MARGIN_TOP,DEFAULT_SECTION_PADDING_BOTTOM,DEFAULT_SECTION_PADDING_LEFT,DEFAULT_SECTION_PADDING_RIGHT,DEFAULT_SECTION_PADDING_TOP,LINK_PROTOCOL_REGEX,Maily,render});
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`react`)),l=s(require(`@react-email/components`)),u=s(require(`@react-email/render`)),d=s(require(`react/jsx-runtime`)),f=s(require(`node-html-parser`)),p=s(require(`juice`)),m=e=>Object.prototype.toString.call(e),h=e=>m(e)===`[object Object]`;function g(e){return Object.keys(e)}function _(e,...t){if(!t.length)return e;let n=t.shift();return n===void 0?e:(v(e)&&v(n)&&g(n).forEach(t=>{t===`__proto__`||t===`constructor`||t===`prototype`||(v(n[t])?(e[t]||(e[t]={}),v(e[t])?_(e[t],n[t]):e[t]=n[t]):e[t]=n[t])}),_(e,...t))}function v(e){return h(e)&&!Array.isArray(e)}const y=Symbol(`p-void`);function b(){return Math.random().toString(36).substr(2,6)}function x(e){return e.filter((e,t,n)=>{let r=C(e);return t===n.findIndex(e=>C(e)===r)}).map(S).filter(Boolean)}function S(e){if(`tagName`in e){let{tagName:t,...n}=e,r=t;return(0,d.jsx)(r,{...n},JSON.stringify(n))}return`title`in e?(0,d.jsx)(`title`,{children:e.title}):`charSet`in e?(0,d.jsx)(`meta`,{charSet:e.charSet}):(0,d.jsx)(`meta`,{...e},JSON.stringify(e))}function C(e){let t=Object.keys(e).sort().reduce((t,n)=>{let r=n;return t[r]=e[r],t},{});return JSON.stringify(t)}const w={fallbackFontFamily:`sans-serif`,fontFamily:`Inter`,webFont:{url:`https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19`,format:`woff2`}},T=`#111827`,E={colors:{heading:`#111827`,paragraph:`#374151`,horizontal:`#EAEAEA`,footer:`#64748B`,blockquoteBorder:`#D1D5DB`,codeBackground:`#EFEFEF`,codeText:`#111827`,linkCardTitle:`#111827`,linkCardDescription:`#6B7280`,linkCardBadgeText:`#111827`,linkCardBadgeBackground:`#FEF08A`,linkCardSubTitle:`#6B7280`},fontSize:{paragraph:{size:`15px`,lineHeight:`26.25px`},footer:{size:`14px`,lineHeight:`24px`}},container:{backgroundColor:`#ffffff`,maxWidth:`600px`,minWidth:`300px`,paddingTop:`0.5rem`,paddingRight:`0.5rem`,paddingBottom:`0.5rem`,paddingLeft:`0.5rem`,borderRadius:`0px`,borderWidth:`0px`,borderColor:`transparent`},body:{backgroundColor:`#ffffff`,paddingTop:`0px`,paddingRight:`0px`,paddingBottom:`0px`,paddingLeft:`0px`},button:{backgroundColor:`#000000`,color:`#ffffff`,paddingTop:`10px`,paddingRight:`32px`,paddingBottom:`10px`,paddingLeft:`32px`},link:{color:T},font:w},D={WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`},O={h1:{fontSize:`36px`,lineHeight:`40px`,fontWeight:800},h2:{fontSize:`30px`,lineHeight:`36px`,fontWeight:700},h3:{fontSize:`24px`,lineHeight:`38px`,fontWeight:600}},k={sm:`40px`,md:`48px`,lg:`64px`},A=`SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,j=`#ffffff`,M=`left`,N=1,P=`#000000`,F=0,I=0,L=0,R=0,z=5,B=5,V=5,H=5,U=`100%`,W=8,G=`transparent`,K=0,q=0,ee=`transparent`,te=0,ne=0,re=0,ie=0,J=20,Y=20,X=/https?:\/\//,Z=[{name:`viewport`,content:`width=device-width`},{httpEquiv:`X-UA-Compatible`,content:`IE=edge`},{name:`x-apple-disable-message-reformatting`},{name:`format-detection`,content:`telephone=no,address=no,email=no,date=no,url=no`},{name:`color-scheme`,content:`light`},{name:`supported-color-schemes`,content:`light`}],Q={lang:`en`,dir:`ltr`},ae={pretty:!1,plainText:!1};var $=class{content;config={theme:E};variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${e}}}`;shouldReplaceVariableValues=!1;variableValues=new Map;linkValues=new Map;openTrackingPixel;payloadValues=new Map;marksOrder=[`underline`,`bold`,`italic`,`textStyle`,`link`];meta=Z;htmlProps=Q;constructor(e={type:`doc`,content:[]}){this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=_(this.config.theme||E,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([e,t])=>{this.setVariableValue(e,t)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([e,t])=>{this.setLinkValue(e,t)})}setPayloadValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(e,t)}setPayloadValues(e){Object.entries(e).forEach(([e,t])=>{this.setPayloadValue(e,t)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}setMetaTags(e){this.meta.push(...e)}setHtmlProps(e){this.htmlProps={...this.htmlProps,...e}}getAllLinks(){let e=this.content.content||[],t=new Set,n=e=>e&&this.isValidUrl(e)&&!e.startsWith(`#`)&&!e.startsWith(`mailto:`)&&!e.startsWith(`tel:`)&&typeof e==`string`,r=e=>{if(e.type===`button`){let r=e.attrs?.url;n(r)&&r&&t.add(r)}else e.content&&e.content.forEach(e=>{e.marks&&e.marks.forEach(e=>{let r=e.attrs?.href;e.type===`link`&&n(r)&&t.add(r)}),e.content&&r(e)})};return e.forEach(e=>{r(e)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(e){return!1}}async render(e=ae){let t=this.markup();return(0,u.renderAsync)(t,e)}markup(){let e=this.content.content||[],t=e.map((t,n)=>{let r={prev:e[n-1],next:e[n+1],parent:t},i=this.renderNode(t,r);return i?(0,d.jsx)(c.Fragment,{children:i},b()):null}),{preview:n}=this.config,r=x(this.meta),i=this.htmlProps,a=this.config.theme?.container,o={...this.config.theme?.font||w,fontStyle:`normal`,fontWeight:400},s={margin:`0px`,...this.config.theme?.body},u=(0,d.jsxs)(l.Html,{...i,children:[(0,d.jsxs)(l.Head,{children:[(0,d.jsx)(l.Font,{...o}),(0,d.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}`}}),r]}),(0,d.jsxs)(l.Body,{style:s,children:[n?(0,d.jsx)(l.Preview,{id:`__react-email-preview`,children:n}):null,(0,d.jsx)(l.Container,{style:{width:`100%`,marginLeft:`auto`,marginRight:`auto`,borderStyle:`solid`,...a},children:t}),this.openTrackingPixel?(0,d.jsx)(l.Img,{alt:``,src:this.openTrackingPixel,style:{display:`none`,width:`1px`,height:`1px`}}):null]})]});return u}getMarginOverrideConditions(e,t){let{parent:n,prev:r,next:i}=t||{},a=i?.type===`spacer`,o=r?.type===`spacer`,s=n?.type===`listItem`,c=n?.type===`section`&&!i,l=n?.type===`section`&&!r,u=n?.type===`column`&&!i,d=n?.type===`column`&&!r,f=n?.type===`repeat`&&!r,p=n?.type===`repeat`&&!i,m=n?.type===`show`&&!r,h=n?.type===`show`&&!i;return{isNextSpacer:a,isPrevSpacer:o,isLastSectionElement:c,isFirstSectionElement:l,isParentListItem:s,isLastColumnElement:u,isFirstColumnElement:d,isFirstRepeatElement:f,isLastRepeatElement:p,isFirstShowElement:m,isLastShowElement:h,shouldRemoveTopMargin:o||l||d||f||m,shouldRemoveBottomMargin:a||c||u||p||h}}getMappedContent(e,t){let n=e.content||[];return n.map((e,r)=>{let i=this.renderNode(e,{...t,next:n[r+1],prev:n[r-1]});return i?(0,d.jsx)(c.Fragment,{children:i},b()):null}).filter(e=>e!==null)}renderNode(e,t={}){let n=e.type||``;if(n in this)return this[n]?.(e,t);throw Error(`Node type "${n}" is not supported.`)}renderMark(e,t){let n=e?.text||(0,d.jsx)(d.Fragment,{children:`\xA0`}),r=e?.marks||[];return r.sort((e,t)=>this.marksOrder.indexOf(e.type)-this.marksOrder.indexOf(t.type)),r.reduce((e,t)=>{let n=t.type;if(n in this)return this[n]?.(t,e);throw Error(`Mark type "${n}" is not supported.`)},(0,d.jsx)(d.Fragment,{children:n}))}paragraph(e,t){let{attrs:n}=e,r=n?.textAlign||`left`,{isParentListItem:i,shouldRemoveBottomMargin:a}=this.getMarginOverrideConditions(e,t),o=this.shouldShow(e,t);if(!o)return(0,d.jsx)(d.Fragment,{});let s=i||a?0:20;return(0,d.jsx)(l.Text,{style:{...r===`left`?{}:{textAlign:r},...D,fontSize:this.config.theme?.fontSize?.paragraph?.size,lineHeight:this.config.theme?.fontSize?.paragraph?.lineHeight,color:this.config.theme?.colors?.paragraph,margin:`0 0 ${s}px 0`},children:e.content?this.getMappedContent(e,{...t,parent:e}):(0,d.jsx)(d.Fragment,{children:`\xA0`})})}text(e,t){if(e.marks)return this.renderMark(e,t);let n=e.text,r=n?.match(/\s/g);return r&&r.length===n?.length?(0,d.jsx)(d.Fragment,{children:r.map((e,t)=>(0,d.jsx)(c.Fragment,{children:`\xA0`},t))}):n?(0,d.jsx)(d.Fragment,{children:n}):(0,d.jsx)(d.Fragment,{children:`\xA0`})}bold(e,t){return(0,d.jsx)(`strong`,{children:t})}italic(e,t){return(0,d.jsx)(`em`,{children:t})}underline(e,t){return(0,d.jsx)(`u`,{children:t})}strike(e,t){return(0,d.jsx)(`s`,{style:{textDecoration:`line-through`},children:t})}textStyle(e,t){let{attrs:n}=e,{color:r=this.config.theme?.colors?.paragraph}=n||{};return(0,d.jsx)(`span`,{style:{color:r},children:t})}link(e,t,n){let{attrs:r}=e,i=this.config.theme?.link,a=r?.href||`#`,o=r?.target||`_blank`,s=r?.rel||`noopener noreferrer nofollow`,c=r?.isUrlVariable??!1;if(c){let e=this.removeLinkProtocol(a);a=this.variableUrlValue(e,n)}else a=this.linkValues.get(a)||a;return(0,d.jsx)(l.Link,{href:a,rel:s,style:{fontWeight:500,textDecoration:`none`,color:i?.color||T},target:o,children:t})}removeLinkProtocol(e){return e.replace(X,``)}variableUrlValue(e,t){let{payloadValue:n}=t||{},r=this.removeLinkProtocol(e);return this.shouldReplaceVariableValues?(typeof n==`object`?n[r]:n)??this.variableValues.get(r)??e:this.variableFormatter({variable:r})}heading(e,t){let{attrs:n}=e,r=`h${Number(n?.level)||1}`,i=n?.textAlign||`left`,{shouldRemoveBottomMargin:a}=this.getMarginOverrideConditions(e,t),{fontSize:o,lineHeight:s,fontWeight:c}=O[r],u=this.shouldShow(e,t);return u?(0,d.jsx)(l.Heading,{as:r,style:{textAlign:i,color:this.config.theme?.colors?.heading,fontSize:o,lineHeight:s,fontWeight:c},mb:a?0:12,mt:0,mx:0,children:this.getMappedContent(e,{...t,parent:e})}):(0,d.jsx)(d.Fragment,{})}variable(e,t){let{payloadValue:n}=t||{},{id:r,fallback:i}=e.attrs||{},a=this.shouldShow(e,t);if(!a||!r)return(0,d.jsx)(d.Fragment,{});let o=this.getVariableValue(r,i,t);return e?.marks?this.renderMark({text:o,marks:e.marks},t):(0,d.jsx)(d.Fragment,{children:o})}getVariableValue(e,t,n){let{payloadValue:r}=n||{},i=this.variableFormatter({variable:e,fallback:t});return this.shouldReplaceVariableValues&&(i=(typeof r==`object`?r[e]:r)??this.variableValues.get(e)??t??i),i}horizontalRule(e,t){return(0,d.jsx)(l.Hr,{style:{marginTop:`32px`,marginBottom:`32px`}})}orderedList(e,t){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Container,{style:{marginTop:`0px`,marginBottom:n?`0`:`20px`},children:(0,d.jsx)(`ol`,{style:{paddingLeft:`26px`,listStyleType:`decimal`},children:this.getMappedContent(e,{...t,parent:e})})})}bulletList(e,t){let{parent:n,next:r}=t||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(e,{parent:n,next:r});return(0,d.jsx)(l.Container,{style:{maxWidth:`100%`,marginTop:`0px`,marginBottom:i?`0`:`20px`},children:(0,d.jsx)(`ul`,{style:{paddingLeft:`26px`,listStyleType:`disc`},children:this.getMappedContent(e,{...t,parent:e})})})}listItem(e,t){return(0,d.jsx)(`li`,{style:{marginBottom:`8px`,marginTop:`8px`,paddingLeft:`6px`,...D},children:this.getMappedContent(e,{...t,parent:e})})}button(e,t){let{attrs:n}=e,r=this.config.theme?.button,{text:i,isTextVariable:a,url:o,isUrlVariable:s,variant:c,buttonColor:u,textColor:f,borderRadius:p,alignment:m=`left`,paddingTop:h,paddingRight:g,paddingBottom:_,paddingLeft:v}=n||{},y=u||r?.backgroundColor,b=f||r?.color,x=parseInt(String(h||r?.paddingTop))||0,S=parseInt(String(g||r?.paddingRight))||0,C=parseInt(String(_||r?.paddingBottom))||0,w=parseInt(String(v||r?.paddingLeft))||0,T=this.shouldShow(e,t);if(!T)return(0,d.jsx)(d.Fragment,{});let E=`0px`;p===`round`?E=`9999px`:p===`smooth`&&(E=`6px`);let{shouldRemoveBottomMargin:D}=this.getMarginOverrideConditions(e,t),O=s?this.variableUrlValue(o,t):this.linkValues.get(o)||o,k=a?this.variableUrlValue(i,t):i;return x+=2,C+=2,(0,d.jsx)(l.Container,{style:{textAlign:m,maxWidth:`100%`,marginBottom:D?`0px`:`20px`},children:(0,d.jsx)(l.Button,{href:O,style:{color:String(b),backgroundColor:c===`filled`?String(y):`transparent`,borderColor:String(y),borderWidth:`2px`,borderStyle:`solid`,textDecoration:`none`,fontSize:`14px`,fontWeight:500,borderRadius:E,padding:`${x}px ${S}px ${C}px ${w}px`},children:k})})}spacer(e,t){let{attrs:n}=e,{height:r}=n||{},i=this.shouldShow(e,t);return i?(0,d.jsx)(l.Container,{style:{height:`${r}px`}}):(0,d.jsx)(d.Fragment,{})}hardBreak(e,t){return(0,d.jsx)(`br`,{})}logo(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a,title:o,size:s,alignment:c=`left`}=n||{},u=this.shouldShow(e,t);if(!u)return(0,d.jsx)(d.Fragment,{});r=i?this.variableUrlValue(r,t):r;let{shouldRemoveBottomMargin:f}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Row,{style:{marginTop:`0px`,marginBottom:f?`0px`:`32px`},children:(0,d.jsx)(l.Column,{align:c,children:(0,d.jsx)(l.Img,{alt:a||o||`Logo`,src:r,style:{width:k[s]||s,height:k[s]||s},title:o||a||`Logo`})})})}image(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a,title:o,width:s=`auto`,height:c=`auto`,alignment:u=`center`,externalLink:f=``,isExternalLinkVariable:p,borderRadius:m=0}=n||{},h=this.shouldShow(e,t);if(!h)return(0,d.jsx)(d.Fragment,{});let{shouldRemoveBottomMargin:g}=this.getMarginOverrideConditions(e,t);r=i?this.variableUrlValue(r,t):r,f=p?this.variableUrlValue(f,t):f;let _=s===`auto`?`auto`:Number(s),v=_===`auto`?`auto`:`${_}px`,y=c===`auto`?`auto`:Number(c),b=y===`auto`?`auto`:`${y}px`,x=(0,d.jsx)(l.Img,{alt:a||o||`Image`,src:r,style:{width:v,height:b,maxWidth:`100%`,outline:`none`,border:`none`,textDecoration:`none`,display:`block`,borderRadius:m},title:o||a||`Image`});return(0,d.jsx)(l.Row,{style:{marginTop:`0px`,marginBottom:g?`0px`:`32px`},children:(0,d.jsx)(l.Column,{align:u,children:f?(0,d.jsx)(`a`,{href:f,rel:`noopener noreferrer`,style:{display:`block`,maxWidth:`100%`,textDecoration:`none`},target:`_blank`,children:x}):x})})}footer(e,t){let{attrs:n}=e,{textAlign:r=`left`}=n||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(l.Text,{style:{fontSize:this.config.theme?.fontSize?.footer?.size,lineHeight:this.config.theme?.fontSize?.footer?.lineHeight,color:this.config.theme?.colors?.footer,marginTop:`0px`,marginBottom:i?`0px`:`20px`,textAlign:r,...D},children:this.getMappedContent(e,{...t,parent:e})})}blockquote(e,t){let{isPrevSpacer:n,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(e,t);return(0,d.jsx)(`blockquote`,{style:{borderLeftWidth:`4px`,borderLeftStyle:`solid`,borderLeftColor:this.config.theme?.colors?.blockquoteBorder,paddingLeft:`16px`,marginLeft:`0px`,marginRight:`0px`,marginTop:n?`0px`:`20px`,marginBottom:r?`0px`:`20px`},children:this.getMappedContent(e,{...t,parent:e})})}code(e,t){return(0,d.jsx)(`code`,{style:{backgroundColor:this.config.theme?.colors?.codeBackground,color:this.config.theme?.colors?.codeText,padding:`2px 4px`,borderRadius:`6px`,fontFamily:A,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){let{attrs:n}=e,{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(e,t),{title:i,description:a,link:o,linkTitle:s,image:c,badgeText:u,subTitle:f}=n||{},p=this.linkValues.get(o)||this.variableValues.get(o)||o||`#`;return(0,d.jsxs)(`a`,{href:p,rel:`noopener noreferrer`,style:{border:`1px solid #eaeaea`,borderRadius:`10px`,textDecoration:`none`,color:`inherit`,display:`block`,marginBottom:r?`0px`:`20px`},target:`_blank`,children:[c?(0,d.jsx)(l.Row,{style:{marginBottom:`6px`},children:(0,d.jsx)(l.Column,{style:{width:`100%`,height:`100%`},children:(0,d.jsx)(l.Img,{alt:i||`Link Card`,src:c,style:{borderRadius:`10px 10px 0 0`,width:`100%`,height:`100%`,objectFit:`cover`},title:i||`Link Card`})})}):null,(0,d.jsx)(l.Row,{style:{padding:`15px`,marginTop:0,marginBottom:0},children:(0,d.jsxs)(l.Column,{style:{verticalAlign:`top`},children:[(0,d.jsxs)(l.Row,{align:void 0,style:{marginBottom:`8px`,marginTop:`0px`},width:`auto`,children:[(0,d.jsx)(l.Column,{children:(0,d.jsx)(l.Text,{style:{fontSize:`18px`,fontWeight:600,color:this.config.theme?.colors?.linkCardTitle,margin:`0px`,...D},children:i})}),u||f?(0,d.jsxs)(l.Column,{style:{paddingLeft:`6px`,verticalAlign:`middle`},children:[u?(0,d.jsx)(`span`,{style:{fontWeight:600,color:this.config.theme?.colors?.linkCardBadgeText,padding:`4px 8px`,borderRadius:`8px`,backgroundColor:this.config.theme?.colors?.linkCardBadgeBackground,fontSize:`12px`,lineHeight:`12px`},children:u}):null,` `,f&&!u?(0,d.jsx)(`span`,{style:{fontWeight:`normal`,color:this.config.theme?.colors?.linkCardSubTitle,fontSize:`12px`,lineHeight:`12px`},children:f}):null]}):null]}),(0,d.jsxs)(l.Text,{style:{fontSize:`16px`,color:this.config.theme?.colors?.linkCardDescription,marginTop:`0px`,marginBottom:`0px`,...D},children:[a,` `,s?(0,d.jsx)(`a`,{href:p,rel:`noopener noreferrer`,style:{color:this.config.theme?.colors?.linkCardTitle,fontSize:`14px`,fontWeight:600,textDecoration:`underline`},children:s}):null]})]})})]})}section(e,t){let{attrs:n}=e,{borderRadius:r=0,backgroundColor:i=j,align:a=M,borderWidth:o=N,borderColor:s=P,marginTop:c=F,marginRight:u=I,marginBottom:f=L,marginLeft:p=R,paddingTop:m=z,paddingRight:h=B,paddingBottom:g=V,paddingLeft:_=H}=n||{},v=this.shouldShow(e,t);return v?(0,d.jsx)(l.Row,{style:{marginTop:c,marginRight:u,marginBottom:f,marginLeft:p},children:(0,d.jsx)(l.Column,{align:a,style:{borderColor:s,borderWidth:o,borderStyle:`solid`,backgroundColor:i,borderRadius:r,paddingTop:m,paddingRight:h,paddingBottom:g,paddingLeft:_},children:this.getMappedContent(e,{...t,parent:e})})}):(0,d.jsx)(d.Fragment,{})}columns(e,t){let{attrs:n}=e,r=this.shouldShow(e,t);if(!r)return(0,d.jsx)(d.Fragment,{});let[i,a]=this.adjustColumnsContent(e);return(0,d.jsx)(l.Row,{width:`${a}%`,style:{margin:0,padding:0,width:`${a}%`},className:`tab-row-full`,children:this.getMappedContent(i,{...t,parent:i})})}adjustColumnsContent(e){let{content:t=[]}=e,n=100,r=t.filter(e=>e.type===`column`&&!!Number(e.attrs?.width||0)),i=t.filter(e=>e.type===`column`&&(e.attrs?.width===`auto`||!e.attrs?.width)),a=r.reduce((e,t)=>e+Number(t.attrs?.width),0),o=n-a,s=Math.round(o/i.length),c=t.filter(e=>e.type===`column`).length,l=e.attrs?.gap??W;return[{...e,content:t.map((e,n)=>{let r=e.type===`column`&&(e.attrs?.width===`auto`||!e.attrs?.width),i=n===0,a=n>0&&n<c-1,o=n===t.length-1,u=0,d=0;if(c<3)u=i?0:l/2,d=o?0:l/2;else{let e=l/2*1.5,t=e/2;u=i?0:a?t:e,d=o?0:a?t:e}return u=Math.round(u*100)/100,d=Math.round(d*100)/100,{...e,attrs:{...e.attrs,width:r?s:e.attrs?.width,isFirstColumn:i,isLastColumn:o,index:n,paddingLeft:u,paddingRight:d}}})},i.length===0?Math.min(n,a):n]}column(e,t){let{attrs:n}=e,{width:r,verticalAlign:i=`top`,paddingLeft:a=0,paddingRight:o=0}=n||{};return(0,d.jsx)(l.Column,{width:`${Number(r)}%`,style:{width:`${Number(r)}%`,margin:0,verticalAlign:i},className:`tab-col-full`,children:(0,d.jsx)(l.Section,{style:{margin:0,paddingLeft:a,paddingRight:o},className:`tab-pad`,children:this.getMappedContent(e,{...t,parent:e})})})}repeat(e,t){let{attrs:n}=e,{each:r=``}=n||{},i=this.shouldShow(e,t);if(!i)return(0,d.jsx)(d.Fragment,{});let{payloadValue:a}=t||{};a=typeof a==`object`?a:{};let o=this.payloadValues.get(r)??a[r]??[];if(!Array.isArray(o))throw Error(`Payload value for each "${r}" is not an array`);return(0,d.jsx)(d.Fragment,{children:o.map(n=>(0,d.jsx)(c.Fragment,{children:this.getMappedContent(e,{...t,parent:e,payloadValue:n})},b()))})}for(e,t){return this.repeat(e,t)}shouldShow(e,t){let n=e?.attrs?.showIfKey??``;if(!n)return!0;let{payloadValue:r}=t||{};return r=typeof r==`object`?r:{},!!(this.payloadValues.get(n)??r[n])}htmlCodeBlock(e,t){let n=this.shouldShow(e,t);if(!n)return(0,d.jsx)(d.Fragment,{});let r=e.content?.reduce((e,n)=>{if(n?.type===`text`)return e+n?.text;if(n?.type===`variable`){let r=this.getVariableValue(n?.attrs?.id,n?.attrs?.fallback,t);return e+r}return e},``)||``,i=(0,p.default)(r),a=(0,f.parse)(i),o=a?.querySelector(`head`);o?.remove();let s=a.toString();return(0,d.jsx)(`table`,{align:`left`,width:`100%`,border:0,cellPadding:`0`,cellSpacing:`0`,role:`presentation`,children:(0,d.jsx)(`tbody`,{children:(0,d.jsx)(`tr`,{style:{width:`100%`},children:(0,d.jsx)(`td`,{style:{width:`100%`},dangerouslySetInnerHTML:{__html:s}})})})})}inlineImage(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a=``,title:o=``,height:s=J,width:c=Y,externalLink:l=``,isExternalLinkVariable:u}=n||{};r=i?this.variableUrlValue(r,t):r,l=u?this.variableUrlValue(l,t):l;let f=(0,d.jsx)(`img`,{src:r,alt:a,title:o,width:c,height:s,style:{display:`inline`,verticalAlign:`middle`,width:`${c}px`,height:`${s}px`,outline:`none`,border:`none`,textDecoration:`none`}});return l?(0,d.jsx)(`a`,{href:l,rel:`noopener noreferrer`,style:{display:`inline`,textDecoration:`none`},target:`_blank`,children:f}):f}};async function oe(e,t){let{theme:n,preview:r,...i}=t||{},a=new $(e);return a.setPreviewText(r),a.setTheme(n||{}),a.render(i)}exports.DEFAULT_COLUMNS_GAP=W,exports.DEFAULT_COLUMNS_WIDTH=U,exports.DEFAULT_COLUMN_BACKGROUND_COLOR=G,exports.DEFAULT_COLUMN_BORDER_COLOR=ee,exports.DEFAULT_COLUMN_BORDER_RADIUS=K,exports.DEFAULT_COLUMN_BORDER_WIDTH=q,exports.DEFAULT_COLUMN_PADDING_BOTTOM=re,exports.DEFAULT_COLUMN_PADDING_LEFT=ie,exports.DEFAULT_COLUMN_PADDING_RIGHT=ne,exports.DEFAULT_COLUMN_PADDING_TOP=te,exports.DEFAULT_HTML_PROPS=Q,exports.DEFAULT_INLINE_IMAGE_HEIGHT=J,exports.DEFAULT_INLINE_IMAGE_WIDTH=Y,exports.DEFAULT_META_TAGS=Z,exports.DEFAULT_SECTION_ALIGN=M,exports.DEFAULT_SECTION_BACKGROUND_COLOR=j,exports.DEFAULT_SECTION_BORDER_COLOR=P,exports.DEFAULT_SECTION_BORDER_WIDTH=N,exports.DEFAULT_SECTION_MARGIN_BOTTOM=L,exports.DEFAULT_SECTION_MARGIN_LEFT=R,exports.DEFAULT_SECTION_MARGIN_RIGHT=I,exports.DEFAULT_SECTION_MARGIN_TOP=F,exports.DEFAULT_SECTION_PADDING_BOTTOM=V,exports.DEFAULT_SECTION_PADDING_LEFT=H,exports.DEFAULT_SECTION_PADDING_RIGHT=B,exports.DEFAULT_SECTION_PADDING_TOP=z,exports.LINK_PROTOCOL_REGEX=X,exports.Maily=$,exports.render=oe;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|