@maily-to/render 0.1.5 → 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/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var Z=Object.defineProperty,tt=Object.defineProperties;var et=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var j=(l,t,e)=>t in l?Z(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,g=(l,t)=>{for(var e in t||(t={}))G.call(t,e)&&j(l,e,t[e]);if(R)for(var e of R(t))$.call(t,e)&&j(l,e,t[e]);return l},b=(l,t)=>tt(l,et(t));var P=(l,t)=>{var e={};for(var n in l)G.call(l,n)&&t.indexOf(n)<0&&(e[n]=l[n]);if(l!=null&&R)for(var n of R(l))t.indexOf(n)<0&&$.call(l,n)&&(e[n]=l[n]);return e};var D=(l,t,e)=>new Promise((n,r)=>{var o=c=>{try{a(e.next(c))}catch(p){r(p)}},i=c=>{try{a(e.throw(c))}catch(p){r(p)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,i);a((e=e.apply(l,t)).next())});import{Fragment as U}from"react";import{Text as W,Html as st,Head as at,Body as lt,Font as ct,Container as V,Link as ut,Heading as pt,Hr as ht,Button as dt,Img as H,Preview as mt,Row as _,Column as T,Section as ft}from"@react-email/components";import{renderAsync as gt}from"@react-email/render";var nt=l=>Object.prototype.toString.call(l);var rt=l=>nt(l)==="[object Object]";function ot(l){return Object.keys(l)}function I(l,...t){if(!t.length)return l;let e=t.shift();return e===void 0?l:(J(l)&&J(e)&&ot(e).forEach(n=>{n==="__proto__"||n==="constructor"||n==="prototype"||(J(e[n])?(l[n]||(l[n]={}),J(l[n])?I(l[n],e[n]):l[n]=e[n]):l[n]=e[n])}),I(l,...t))}function J(l){return rt(l)&&!Array.isArray(l)}var Kt=Symbol("p-void");function B(){return Math.random().toString(36).substr(2,6)}import{jsx as F}from"react/jsx-runtime";function K(l){return l.filter((t,e,n)=>{let r=q(t);return e===n.findIndex(o=>q(o)===r)}).map(it).filter(Boolean)}function it(l){if("tagName"in l){let t=l,{tagName:e}=t,n=P(t,["tagName"]);return F(e,g({},n),JSON.stringify(n))}return"title"in l?F("title",{children:l.title}):"charSet"in l?F("meta",{charSet:l.charSet}):F("meta",g({},l),JSON.stringify(l))}function q(l){let t=Object.keys(l).sort().reduce((e,n)=>{let r=n;return e[r]=l[r],e},{});return JSON.stringify(t)}import{parse as St}from"node-html-parser";import xt from"juice";import{Fragment as y,jsx as s,jsxs as E}from"react/jsx-runtime";var k={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var yt={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var Y={sm:"40px",md:"48px",lg:"64px"},bt={pretty:!1,plainText:!1},Q={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"}}},Ot='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',wt="#ffffff",Ct="left",Nt=1,Tt="#000000",Et=0,vt=0,_t=0,Mt=0,Lt=5,At=5,Dt=5,Vt=5,he="100%",kt=8,de="transparent",me=0,fe=0,ge="transparent",Se=0,xe=0,ye=0,be=0,Rt=20,Pt=20,Jt=/https?:\/\//,It=[{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"}],Bt={lang:"en",dir:"ltr"},Ft=10,Ut=32,Wt=10,Ht=32,X=class{constructor(t={type:"doc",content:[]}){this.config={theme:Q};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=It;this.htmlProps=Bt;this.content=t}setPreviewText(t){this.config.preview=t}setTheme(t){this.config.theme=I(this.config.theme||Q,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=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var i;if(o.type==="button"){let a=(i=o.attrs)==null?void 0:i.url;n(a)&&a&&e.add(a)}else o.content&&o.content.forEach(a=>{a.marks&&a.marks.forEach(c=>{var h;let p=(h=c.attrs)==null?void 0:h.href;c.type==="link"&&n(p)&&e.add(p)}),a.content&&r(a)})};return t.forEach(o=>{r(o)}),e}isValidUrl(t){try{let e=new URL(t);return!0}catch(e){return!1}}render(){return D(this,arguments,function*(t=bt){let e=this.markup();return gt(e,t)})}markup(){var c;let t=this.content.content||[],e=t.map((p,h)=>{let u={prev:t[h-1],next:t[h+1],parent:p},m=this.renderNode(p,u);return m?s(U,{children:m},B()):null}),{preview:n}=this.config,r=K(this.meta),o=this.htmlProps,i=(c=this.config.theme)==null?void 0:c.container;return E(st,b(g({},o),{children:[E(at,{children:[s(ct,{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"}}),s("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]}),E(lt,{style:{margin:0},children:[n?s(mt,{id:"__react-email-preview",children:n}):null,s(V,{style:i,children:e}),this.openTrackingPixel?s(H,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]}))}getMarginOverrideConditions(t,e){let{parent:n,prev:r,next:o}=e||{},i=(o==null?void 0:o.type)==="spacer",a=(r==null?void 0:r.type)==="spacer",c=(n==null?void 0:n.type)==="listItem",p=(n==null?void 0:n.type)==="section"&&!o,h=(n==null?void 0:n.type)==="section"&&!r,u=(n==null?void 0:n.type)==="column"&&!o,m=(n==null?void 0:n.type)==="column"&&!r,d=(n==null?void 0:n.type)==="repeat"&&!r,f=(n==null?void 0:n.type)==="repeat"&&!o,S=(n==null?void 0:n.type)==="show"&&!r,x=(n==null?void 0:n.type)==="show"&&!o;return{isNextSpacer:i,isPrevSpacer:a,isLastSectionElement:p,isFirstSectionElement:h,isParentListItem:c,isLastColumnElement:u,isFirstColumnElement:m,isFirstRepeatElement:d,isLastRepeatElement:f,isFirstShowElement:S,isLastShowElement:x,shouldRemoveTopMargin:a||h||m||d||S,shouldRemoveBottomMargin:i||p||u||f||x}}getMappedContent(t,e){let n=t.content||[];return n.map((r,o)=>{let i=this.renderNode(r,b(g({},e),{next:n[o+1],prev:n[o-1]}));return i?s(U,{children:i},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)||s(y,{children:"\xA0"}),r=(t==null?void 0:t.marks)||[];return r.sort((o,i)=>this.marksOrder.indexOf(o.type)-this.marksOrder.indexOf(i.type)),r.reduce((o,i)=>{var c;let a=i.type;if(a in this)return(c=this[a])==null?void 0:c.call(this,i,o);throw new Error(`Mark type "${a}" is not supported.`)},s(y,{children:n}))}paragraph(t,e){var p,h,u,m,d,f,S,x;let{attrs:n}=t,r=(n==null?void 0:n.textAlign)||"left",{isParentListItem:o,shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,e);if(!this.shouldShow(t,e))return s(y,{});let c=o||i?0:20;return s(W,{style:b(g(g({},r!=="left"?{textAlign:r}:{}),k),{fontSize:(u=(h=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:h.paragraph)==null?void 0:u.size,lineHeight:(f=(d=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:d.paragraph)==null?void 0:f.lineHeight,color:(x=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:x.paragraph,margin:`0 0 ${c}px 0`}),children:t.content?this.getMappedContent(t,b(g({},e),{parent:t})):s(y,{children:"\xA0"})})}text(t,e){if(t.marks)return this.renderMark(t,e);let n=t.text,r=n==null?void 0:n.match(/\s/g);return r&&r.length===(n==null?void 0:n.length)?s(y,{children:r.map((o,i)=>s(U,{children:"\xA0"},i))}):n?s(y,{children:n}):s(y,{children:"\xA0"})}bold(t,e){return s("strong",{children:e})}italic(t,e){return s("em",{children:e})}underline(t,e){return s("u",{children:e})}strike(t,e){return s("s",{style:{textDecoration:"line-through"},children:e})}textStyle(t,e){var o,i;let{attrs:n}=t,{color:r=(i=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:i.paragraph}=n||{};return s("span",{style:{color:r},children:e})}link(t,e,n){var p,h,u;let{attrs:r}=t,o=(r==null?void 0:r.href)||"#",i=(r==null?void 0:r.target)||"_blank",a=(r==null?void 0:r.rel)||"noopener noreferrer nofollow";if((p=r==null?void 0:r.isUrlVariable)!=null?p:!1){let m=this.removeLinkProtocol(o);o=this.variableUrlValue(m,n)}else o=this.linkValues.get(o)||o;return s(ut,{href:o,rel:a,style:{fontWeight:500,textDecoration:"none",color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.heading},target:i,children:e})}removeLinkProtocol(t){return t.replace(Jt,"")}variableUrlValue(t,e){var o,i;let{payloadValue:n}=e||{},r=this.removeLinkProtocol(t);return(i=(o=typeof n=="object"?n[r]:n)!=null?o:this.variableValues.get(r))!=null?i:t}heading(t,e){var u,m;let{attrs:n}=t,r=`h${Number(n==null?void 0:n.level)||1}`,o=(n==null?void 0:n.textAlign)||"left",{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,e),{fontSize:a,lineHeight:c,fontWeight:p}=yt[r];return this.shouldShow(t,e)?s(pt,{as:r,style:{textAlign:o,color:(m=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:m.heading,fontSize:a,lineHeight:c,fontWeight:p},mb:i?0:12,mt:0,mx:0,children:this.getMappedContent(t,b(g({},e),{parent:t}))}):s(y,{})}variable(t,e){let{payloadValue:n}=e||{},{id:r,fallback:o}=t.attrs||{};if(!this.shouldShow(t,e)||!r)return s(y,{});let a=this.getVariableValue(r,o,e);return t!=null&&t.marks?this.renderMark({text:a,marks:t.marks},e):s(y,{children:a})}getVariableValue(t,e,n){var i,a,c;let{payloadValue:r}=n||{},o=this.variableFormatter({variable:t,fallback:e});return this.shouldReplaceVariableValues&&(o=(c=(a=(i=typeof r=="object"?r[t]:r)!=null?i:this.variableValues.get(t))!=null?a:e)!=null?c:o),o}horizontalRule(t,e){return s(ht,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(t,e);return s(V,{children:s("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:o}=this.getMarginOverrideConditions(t,{parent:n,next:r});return s(V,{style:{maxWidth:"100%"},children:s("ul",{style:{marginTop:"0px",marginBottom:o?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t,b(g({},e),{parent:t}))})})}listItem(t,e){return s("li",{style:g({marginBottom:"8px",paddingLeft:"6px"},k),children:this.getMappedContent(t,b(g({},e),{parent:t}))})}button(t,e){let{attrs:n}=t,{text:r,isTextVariable:o,url:i,isUrlVariable:a,variant:c,buttonColor:p,textColor:h,borderRadius:u,alignment:m="left",paddingTop:d=Ft,paddingRight:f=Ut,paddingBottom:S=Wt,paddingLeft:x=Ht}=n||{};if(!this.shouldShow(t,e))return s(y,{});let O="0px";u==="round"?O="9999px":u==="smooth"&&(O="6px");let{shouldRemoveBottomMargin:C}=this.getMarginOverrideConditions(t,e),w=a?this.variableUrlValue(i,e):this.linkValues.get(i)||i,v=o?this.variableUrlValue(r,e):r;return d+=2,S+=2,s(V,{style:{textAlign:m,maxWidth:"100%",marginBottom:C?"0px":"20px"},children:s(dt,{href:w,style:{color:String(h),backgroundColor:c==="filled"?String(p):"transparent",borderColor:String(p),borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:O,padding:`${d}px ${f}px ${S}px ${x}px`},children:v})})}spacer(t,e){let{attrs:n}=t,{height:r}=n||{};return this.shouldShow(t,e)?s(V,{style:{height:`${r}px`}}):s(y,{})}hardBreak(t,e){return s("br",{})}logo(t,e){let{attrs:n}=t,{src:r,isSrcVariable:o,alt:i,title:a,size:c,alignment:p="left"}=n||{};if(!this.shouldShow(t,e))return s(y,{});r=o?this.variableUrlValue(r,e):r;let{shouldRemoveBottomMargin:u}=this.getMarginOverrideConditions(t,e);return s(_,{style:{marginTop:"0px",marginBottom:u?"0px":"32px"},children:s(T,{align:p,children:s(H,{alt:i||a||"Logo",src:r,style:{width:Y[c]||c,height:Y[c]||c},title:a||i||"Logo"})})})}image(t,e){let{attrs:n}=t,{src:r,isSrcVariable:o,alt:i,title:a,width:c="auto",height:p="auto",alignment:h="center",externalLink:u="",isExternalLinkVariable:m,borderRadius:d=0}=n||{};if(!this.shouldShow(t,e))return s(y,{});let{shouldRemoveBottomMargin:S}=this.getMarginOverrideConditions(t,e);r=o?this.variableUrlValue(r,e):r,u=m?this.variableUrlValue(u,e):u;let x=c==="auto"?"auto":Number(c),N=x==="auto"?"auto":`${x}px`,O=p==="auto"?"auto":Number(p),C=O==="auto"?"auto":`${O}px`,w=s(H,{alt:i||a||"Image",src:r,style:{width:N,height:C,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none",display:"block",borderRadius:d},title:a||i||"Image"});return s(_,{style:{marginTop:"0px",marginBottom:S?"0px":"32px"},children:s(T,{align:h,children:u?s("a",{href:u,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:w}):w})})}footer(t,e){var i,a,c,p,h,u,m,d;let{attrs:n}=t,{textAlign:r="left"}=n||{},{shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(t,e);return s(W,{style:g({fontSize:(c=(a=(i=this.config.theme)==null?void 0:i.fontSize)==null?void 0:a.footer)==null?void 0:c.size,lineHeight:(u=(h=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:h.footer)==null?void 0:u.lineHeight,color:(d=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:d.footer,marginTop:"0px",marginBottom:o?"0px":"20px",textAlign:r},k),children:this.getMappedContent(t,b(g({},e),{parent:t}))})}blockquote(t,e){var o,i;let{isPrevSpacer:n,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,e);return s("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(i=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:i.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,o,i;return s("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(i=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:i.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:Ot,fontWeight:400,letterSpacing:0},children:e})}linkCard(t,e){var d,f,S,x,N,O,C,w,v,L,A,M;let{attrs:n}=t,{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,e),{title:o,description:i,link:a,linkTitle:c,image:p,badgeText:h,subTitle:u}=n||{},m=this.linkValues.get(a)||this.variableValues.get(a)||a||"#";return E("a",{href:m,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r?"0px":"20px"},target:"_blank",children:[p?s(_,{style:{marginBottom:"6px"},children:s(T,{style:{width:"100%",height:"100%"},children:s(H,{alt:o||"Link Card",src:p,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:o||"Link Card"})})}):null,s(_,{style:{padding:"15px",marginTop:0,marginBottom:0},children:E(T,{style:{verticalAlign:"top"},children:[E(_,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[s(T,{children:s(W,{style:g({fontSize:"18px",fontWeight:600,color:(f=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:f.linkCardTitle,margin:"0px"},k),children:o})}),h||u?E(T,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[h?s("span",{style:{fontWeight:600,color:(x=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:x.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(O=(N=this.config.theme)==null?void 0:N.colors)==null?void 0:O.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:h}):null," ",u&&!h?s("span",{style:{fontWeight:"normal",color:(w=(C=this.config.theme)==null?void 0:C.colors)==null?void 0:w.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:u}):null]}):null]}),E(W,{style:g({fontSize:"16px",color:(L=(v=this.config.theme)==null?void 0:v.colors)==null?void 0:L.linkCardDescription,marginTop:"0px",marginBottom:"0px"},k),children:[i," ",c?s("a",{href:m,rel:"noopener noreferrer",style:{color:(M=(A=this.config.theme)==null?void 0:A.colors)==null?void 0:M.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:c}):null]})]})})]})}section(t,e){let{attrs:n}=t,{borderRadius:r=0,backgroundColor:o=wt,align:i=Ct,borderWidth:a=Nt,borderColor:c=Tt,marginTop:p=Et,marginRight:h=vt,marginBottom:u=_t,marginLeft:m=Mt,paddingTop:d=Lt,paddingRight:f=At,paddingBottom:S=Dt,paddingLeft:x=Vt}=n||{};return this.shouldShow(t,e)?s(_,{style:{marginTop:p,marginRight:h,marginBottom:u,marginLeft:m},children:s(T,{align:i,style:{borderColor:c,borderWidth:a,borderStyle:"solid",backgroundColor:o,borderRadius:r,paddingTop:d,paddingRight:f,paddingBottom:S,paddingLeft:x},children:this.getMappedContent(t,b(g({},e),{parent:t}))})}):s(y,{})}columns(t,e){let{attrs:n}=t;if(!this.shouldShow(t,e))return s(y,{});let[o,i]=this.adjustColumnsContent(t);return s(_,{width:`${i}%`,style:{margin:0,padding:0,width:`${i}%`},className:"tab-row-full",children:this.getMappedContent(o,b(g({},e),{parent:o}))})}adjustColumnsContent(t){var u,m;let{content:e=[]}=t,n=100,r=e.filter(d=>{var f;return d.type==="column"&&!!Number(((f=d.attrs)==null?void 0:f.width)||0)}),o=e.filter(d=>{var f,S;return d.type==="column"&&(((f=d.attrs)==null?void 0:f.width)==="auto"||!((S=d.attrs)!=null&&S.width))}),i=r.reduce((d,f)=>{var S;return d+Number((S=f.attrs)==null?void 0:S.width)},0),a=n-i,c=Math.round(a/o.length),p=e.filter(d=>d.type==="column").length,h=(m=(u=t.attrs)==null?void 0:u.gap)!=null?m:kt;return[b(g({},t),{content:e.map((d,f)=>{var v,L,A;let S=d.type==="column"&&(((v=d.attrs)==null?void 0:v.width)==="auto"||!((L=d.attrs)!=null&&L.width)),x=f===0,N=f>0&&f<p-1,O=f===e.length-1,C=0,w=0;if(p<3)C=x?0:h/2,w=O?0:h/2;else{let M=h/2*1.5,z=M/2;C=x?0:N?z:M,w=O?0:N?z:M}return C=Math.round(C*100)/100,w=Math.round(w*100)/100,b(g({},d),{attrs:b(g({},d.attrs),{width:S?c:(A=d.attrs)==null?void 0:A.width,isFirstColumn:x,isLastColumn:O,index:f,paddingLeft:C,paddingRight:w})})})}),o.length===0?Math.min(n,i):n]}column(t,e){let{attrs:n}=t,{width:r,verticalAlign:o="top",paddingLeft:i=0,paddingRight:a=0}=n||{};return s(T,{width:`${Number(r)}%`,style:{width:`${Number(r)}%`,margin:0,verticalAlign:o},className:"tab-col-full",children:s(ft,{style:{margin:0,paddingLeft:i,paddingRight:a},className:"tab-pad",children:this.getMappedContent(t,b(g({},e),{parent:t}))})})}repeat(t,e){var c,p;let{attrs:n}=t,{each:r=""}=n||{};if(!this.shouldShow(t,e))return s(y,{});let{payloadValue:i}=e||{};i=typeof i=="object"?i:{};let a=(p=(c=this.payloadValues.get(r))!=null?c:i[r])!=null?p:[];if(!Array.isArray(a))throw new Error(`Payload value for each "${r}" is not an array`);return s(y,{children:a.map(h=>s(U,{children:this.getMappedContent(t,b(g({},e),{parent:t,payloadValue:h}))},B()))})}for(t,e){return this.repeat(t,e)}shouldShow(t,e){var o,i,a;let n=(i=(o=t==null?void 0:t.attrs)==null?void 0:o.showIfKey)!=null?i:"";if(!n)return!0;let{payloadValue:r}=e||{};return r=typeof r=="object"?r:{},!!((a=this.payloadValues.get(n))!=null?a:r[n])}htmlCodeBlock(t,e){var p;if(!this.shouldShow(t,e))return s(y,{});let r=((p=t.content)==null?void 0:p.reduce((h,u)=>{var m,d;if((u==null?void 0:u.type)==="text")return h+(u==null?void 0:u.text);if((u==null?void 0:u.type)==="variable"){let f=this.getVariableValue((m=u==null?void 0:u.attrs)==null?void 0:m.id,(d=u==null?void 0:u.attrs)==null?void 0:d.fallback,e);return h+f}return h},""))||"",o=xt(r),i=St(o),a=i==null?void 0:i.querySelector("head");a==null||a.remove();let c=i.toString();return s("table",{align:"left",width:"100%",border:0,cellPadding:"0",cellSpacing:"0",role:"presentation",children:s("tbody",{children:s("tr",{style:{width:"100%"},children:s("td",{style:{width:"100%"},dangerouslySetInnerHTML:{__html:c}})})})})}inlineImage(t,e){let{attrs:n}=t,{src:r,isSrcVariable:o,alt:i="",title:a="",height:c=Rt,width:p=Pt,externalLink:h="",isExternalLinkVariable:u}=n||{};r=o?this.variableUrlValue(r,e):r,h=u?this.variableUrlValue(h,e):h;let m=s("img",{src:r,alt:i,title:a,width:p,height:c,style:{display:"inline",verticalAlign:"middle",width:`${p}px`,height:`${c}px`,outline:"none",border:"none",textDecoration:"none"}});return h?s("a",{href:h,rel:"noopener noreferrer",style:{display:"inline",textDecoration:"none"},target:"_blank",children:m}):m}};function Te(l,t){return D(this,null,function*(){let i=t||{},{theme:e,preview:n}=i,r=P(i,["theme","preview"]),o=new X(l);return o.setPreviewText(n),o.setTheme(e||{}),o.render(r)})}export{Wt as DEFAULT_BUTTON_PADDING_BOTTOM,Ht as DEFAULT_BUTTON_PADDING_LEFT,Ut as DEFAULT_BUTTON_PADDING_RIGHT,Ft as DEFAULT_BUTTON_PADDING_TOP,kt as DEFAULT_COLUMNS_GAP,he as DEFAULT_COLUMNS_WIDTH,de as DEFAULT_COLUMN_BACKGROUND_COLOR,ge as DEFAULT_COLUMN_BORDER_COLOR,me as DEFAULT_COLUMN_BORDER_RADIUS,fe as DEFAULT_COLUMN_BORDER_WIDTH,ye as DEFAULT_COLUMN_PADDING_BOTTOM,be as DEFAULT_COLUMN_PADDING_LEFT,xe as DEFAULT_COLUMN_PADDING_RIGHT,Se as DEFAULT_COLUMN_PADDING_TOP,Bt as DEFAULT_HTML_PROPS,Rt as DEFAULT_INLINE_IMAGE_HEIGHT,Pt as DEFAULT_INLINE_IMAGE_WIDTH,It as DEFAULT_META_TAGS,Ct as DEFAULT_SECTION_ALIGN,wt as DEFAULT_SECTION_BACKGROUND_COLOR,Tt as DEFAULT_SECTION_BORDER_COLOR,Nt as DEFAULT_SECTION_BORDER_WIDTH,_t as DEFAULT_SECTION_MARGIN_BOTTOM,Mt as DEFAULT_SECTION_MARGIN_LEFT,vt as DEFAULT_SECTION_MARGIN_RIGHT,Et as DEFAULT_SECTION_MARGIN_TOP,Dt as DEFAULT_SECTION_PADDING_BOTTOM,Vt as DEFAULT_SECTION_PADDING_LEFT,At as DEFAULT_SECTION_PADDING_RIGHT,Lt as DEFAULT_SECTION_PADDING_TOP,Jt as LINK_PROTOCOL_REGEX,X as Maily,Te as render};
1
+ import{Fragment as e}from"react";import{Body as t,Button as n,Column as r,Container as i,Font as a,Head as o,Heading as s,Hr as c,Html as l,Img as u,Link as d,Preview as f,Row as p,Section as m,Text as h}from"@react-email/components";import{renderAsync as g}from"@react-email/render";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";import{parse as b}from"node-html-parser";import x from"juice";const S=e=>Object.prototype.toString.call(e),C=e=>S(e)===`[object Object]`;function w(e){return Object.keys(e)}function T(e,...t){if(!t.length)return e;let n=t.shift();return n===void 0?e:(E(e)&&E(n)&&w(n).forEach(t=>{t===`__proto__`||t===`constructor`||t===`prototype`||(E(n[t])?(e[t]||(e[t]={}),E(e[t])?T(e[t],n[t]):e[t]=n[t]):e[t]=n[t])}),T(e,...t))}function E(e){return C(e)&&!Array.isArray(e)}const ee=Symbol(`p-void`);function D(){return Math.random().toString(36).substr(2,6)}function O(e){return e.filter((e,t,n)=>{let r=A(e);return t===n.findIndex(e=>A(e)===r)}).map(k).filter(Boolean)}function k(e){if(`tagName`in e){let{tagName:t,...n}=e,r=t;return v(r,{...n},JSON.stringify(n))}return`title`in e?v(`title`,{children:e.title}):`charSet`in e?v(`meta`,{charSet:e.charSet}):v(`meta`,{...e},JSON.stringify(e))}function A(e){let t=Object.keys(e).sort().reduce((t,n)=>{let r=n;return t[r]=e[r],t},{});return JSON.stringify(t)}const j={fallbackFontFamily:`sans-serif`,fontFamily:`Inter`,webFont:{url:`https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19`,format:`woff2`}},M=`#111827`,N={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:M},font:j},P={WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`},te={h1:{fontSize:`36px`,lineHeight:`40px`,fontWeight:800},h2:{fontSize:`30px`,lineHeight:`36px`,fontWeight:700},h3:{fontSize:`24px`,lineHeight:`38px`,fontWeight:600}},F={sm:`40px`,md:`48px`,lg:`64px`},ne=`SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,I=`#ffffff`,L=`left`,R=1,z=`#000000`,B=0,V=0,H=0,U=0,W=5,G=5,K=5,q=5,re=`100%`,J=8,ie=`transparent`,ae=0,oe=0,se=`transparent`,ce=0,le=0,ue=0,de=0,Y=20,X=20,Z=/https?:\/\//,Q=[{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`}],$={lang:`en`,dir:`ltr`},fe={pretty:!1,plainText:!1};var pe=class{content;config={theme:N};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=Q;htmlProps=$;constructor(e={type:`doc`,content:[]}){this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=T(this.config.theme||N,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=fe){let t=this.markup();return g(t,e)}markup(){let n=this.content.content||[],r=n.map((t,r)=>{let i={prev:n[r-1],next:n[r+1],parent:t},a=this.renderNode(t,i);return a?v(e,{children:a},D()):null}),{preview:s}=this.config,c=O(this.meta),d=this.htmlProps,p=this.config.theme?.container,m={...this.config.theme?.font||j,fontStyle:`normal`,fontWeight:400},h={margin:`0px`,...this.config.theme?.body},g=y(l,{...d,children:[y(o,{children:[v(a,{...m}),v(`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}}`}}),c]}),y(t,{style:h,children:[s?v(f,{id:`__react-email-preview`,children:s}):null,v(i,{style:{width:`100%`,marginLeft:`auto`,marginRight:`auto`,borderStyle:`solid`,...p},children:r}),this.openTrackingPixel?v(u,{alt:``,src:this.openTrackingPixel,style:{display:`none`,width:`1px`,height:`1px`}}):null]})]});return g}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(t,n){let r=t.content||[];return r.map((t,i)=>{let a=this.renderNode(t,{...n,next:r[i+1],prev:r[i-1]});return a?v(e,{children:a},D()):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||v(_,{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.`)},v(_,{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 v(_,{});let s=i||a?0:20;return v(h,{style:{...r===`left`?{}:{textAlign:r},...P,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}):v(_,{children:`\xA0`})})}text(t,n){if(t.marks)return this.renderMark(t,n);let r=t.text,i=r?.match(/\s/g);return i&&i.length===r?.length?v(_,{children:i.map((t,n)=>v(e,{children:`\xA0`},n))}):r?v(_,{children:r}):v(_,{children:`\xA0`})}bold(e,t){return v(`strong`,{children:t})}italic(e,t){return v(`em`,{children:t})}underline(e,t){return v(`u`,{children:t})}strike(e,t){return v(`s`,{style:{textDecoration:`line-through`},children:t})}textStyle(e,t){let{attrs:n}=e,{color:r=this.config.theme?.colors?.paragraph}=n||{};return v(`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 v(d,{href:a,rel:s,style:{fontWeight:500,textDecoration:`none`,color:i?.color||M},target:o,children:t})}removeLinkProtocol(e){return e.replace(Z,``)}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:c,fontWeight:l}=te[r],u=this.shouldShow(e,t);return u?v(s,{as:r,style:{textAlign:i,color:this.config.theme?.colors?.heading,fontSize:o,lineHeight:c,fontWeight:l},mb:a?0:12,mt:0,mx:0,children:this.getMappedContent(e,{...t,parent:e})}):v(_,{})}variable(e,t){let{payloadValue:n}=t||{},{id:r,fallback:i}=e.attrs||{},a=this.shouldShow(e,t);if(!a||!r)return v(_,{});let o=this.getVariableValue(r,i,t);return e?.marks?this.renderMark({text:o,marks:e.marks},t):v(_,{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 v(c,{style:{marginTop:`32px`,marginBottom:`32px`}})}orderedList(e,t){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(e,t);return v(i,{style:{marginTop:`0px`,marginBottom:n?`0`:`20px`},children:v(`ol`,{style:{paddingLeft:`26px`,listStyleType:`decimal`},children:this.getMappedContent(e,{...t,parent:e})})})}bulletList(e,t){let{parent:n,next:r}=t||{},{shouldRemoveBottomMargin:a}=this.getMarginOverrideConditions(e,{parent:n,next:r});return v(i,{style:{maxWidth:`100%`,marginTop:`0px`,marginBottom:a?`0`:`20px`},children:v(`ul`,{style:{paddingLeft:`26px`,listStyleType:`disc`},children:this.getMappedContent(e,{...t,parent:e})})})}listItem(e,t){return v(`li`,{style:{marginBottom:`8px`,marginTop:`8px`,paddingLeft:`6px`,...P},children:this.getMappedContent(e,{...t,parent:e})})}button(e,t){let{attrs:r}=e,a=this.config.theme?.button,{text:o,isTextVariable:s,url:c,isUrlVariable:l,variant:u,buttonColor:d,textColor:f,borderRadius:p,alignment:m=`left`,paddingTop:h,paddingRight:g,paddingBottom:y,paddingLeft:b}=r||{},x=d||a?.backgroundColor,S=f||a?.color,C=parseInt(String(h||a?.paddingTop))||0,w=parseInt(String(g||a?.paddingRight))||0,T=parseInt(String(y||a?.paddingBottom))||0,E=parseInt(String(b||a?.paddingLeft))||0,ee=this.shouldShow(e,t);if(!ee)return v(_,{});let D=`0px`;p===`round`?D=`9999px`:p===`smooth`&&(D=`6px`);let{shouldRemoveBottomMargin:O}=this.getMarginOverrideConditions(e,t),k=l?this.variableUrlValue(c,t):this.linkValues.get(c)||c,A=s?this.variableUrlValue(o,t):o;return C+=2,T+=2,v(i,{style:{textAlign:m,maxWidth:`100%`,marginBottom:O?`0px`:`20px`},children:v(n,{href:k,style:{color:String(S),backgroundColor:u===`filled`?String(x):`transparent`,borderColor:String(x),borderWidth:`2px`,borderStyle:`solid`,textDecoration:`none`,fontSize:`14px`,fontWeight:500,borderRadius:D,padding:`${C}px ${w}px ${T}px ${E}px`},children:A})})}spacer(e,t){let{attrs:n}=e,{height:r}=n||{},a=this.shouldShow(e,t);return a?v(i,{style:{height:`${r}px`}}):v(_,{})}hardBreak(e,t){return v(`br`,{})}logo(e,t){let{attrs:n}=e,{src:i,isSrcVariable:a,alt:o,title:s,size:c,alignment:l=`left`}=n||{},d=this.shouldShow(e,t);if(!d)return v(_,{});i=a?this.variableUrlValue(i,t):i;let{shouldRemoveBottomMargin:f}=this.getMarginOverrideConditions(e,t);return v(p,{style:{marginTop:`0px`,marginBottom:f?`0px`:`32px`},children:v(r,{align:l,children:v(u,{alt:o||s||`Logo`,src:i,style:{width:F[c]||c,height:F[c]||c},title:s||o||`Logo`})})})}image(e,t){let{attrs:n}=e,{src:i,isSrcVariable:a,alt:o,title:s,width:c=`auto`,height:l=`auto`,alignment:d=`center`,externalLink:f=``,isExternalLinkVariable:m,borderRadius:h=0}=n||{},g=this.shouldShow(e,t);if(!g)return v(_,{});let{shouldRemoveBottomMargin:y}=this.getMarginOverrideConditions(e,t);i=a?this.variableUrlValue(i,t):i,f=m?this.variableUrlValue(f,t):f;let b=c===`auto`?`auto`:Number(c),x=b===`auto`?`auto`:`${b}px`,S=l===`auto`?`auto`:Number(l),C=S===`auto`?`auto`:`${S}px`,w=v(u,{alt:o||s||`Image`,src:i,style:{width:x,height:C,maxWidth:`100%`,outline:`none`,border:`none`,textDecoration:`none`,display:`block`,borderRadius:h},title:s||o||`Image`});return v(p,{style:{marginTop:`0px`,marginBottom:y?`0px`:`32px`},children:v(r,{align:d,children:f?v(`a`,{href:f,rel:`noopener noreferrer`,style:{display:`block`,maxWidth:`100%`,textDecoration:`none`},target:`_blank`,children:w}):w})})}footer(e,t){let{attrs:n}=e,{textAlign:r=`left`}=n||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(e,t);return v(h,{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,...P},children:this.getMappedContent(e,{...t,parent:e})})}blockquote(e,t){let{isPrevSpacer:n,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(e,t);return v(`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 v(`code`,{style:{backgroundColor:this.config.theme?.colors?.codeBackground,color:this.config.theme?.colors?.codeText,padding:`2px 4px`,borderRadius:`6px`,fontFamily:ne,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){let{attrs:n}=e,{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(e,t),{title:a,description:o,link:s,linkTitle:c,image:l,badgeText:d,subTitle:f}=n||{},m=this.linkValues.get(s)||this.variableValues.get(s)||s||`#`;return y(`a`,{href:m,rel:`noopener noreferrer`,style:{border:`1px solid #eaeaea`,borderRadius:`10px`,textDecoration:`none`,color:`inherit`,display:`block`,marginBottom:i?`0px`:`20px`},target:`_blank`,children:[l?v(p,{style:{marginBottom:`6px`},children:v(r,{style:{width:`100%`,height:`100%`},children:v(u,{alt:a||`Link Card`,src:l,style:{borderRadius:`10px 10px 0 0`,width:`100%`,height:`100%`,objectFit:`cover`},title:a||`Link Card`})})}):null,v(p,{style:{padding:`15px`,marginTop:0,marginBottom:0},children:y(r,{style:{verticalAlign:`top`},children:[y(p,{align:void 0,style:{marginBottom:`8px`,marginTop:`0px`},width:`auto`,children:[v(r,{children:v(h,{style:{fontSize:`18px`,fontWeight:600,color:this.config.theme?.colors?.linkCardTitle,margin:`0px`,...P},children:a})}),d||f?y(r,{style:{paddingLeft:`6px`,verticalAlign:`middle`},children:[d?v(`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:d}):null,` `,f&&!d?v(`span`,{style:{fontWeight:`normal`,color:this.config.theme?.colors?.linkCardSubTitle,fontSize:`12px`,lineHeight:`12px`},children:f}):null]}):null]}),y(h,{style:{fontSize:`16px`,color:this.config.theme?.colors?.linkCardDescription,marginTop:`0px`,marginBottom:`0px`,...P},children:[o,` `,c?v(`a`,{href:m,rel:`noopener noreferrer`,style:{color:this.config.theme?.colors?.linkCardTitle,fontSize:`14px`,fontWeight:600,textDecoration:`underline`},children:c}):null]})]})})]})}section(e,t){let{attrs:n}=e,{borderRadius:i=0,backgroundColor:a=I,align:o=L,borderWidth:s=R,borderColor:c=z,marginTop:l=B,marginRight:u=V,marginBottom:d=H,marginLeft:f=U,paddingTop:m=W,paddingRight:h=G,paddingBottom:g=K,paddingLeft:y=q}=n||{},b=this.shouldShow(e,t);return b?v(p,{style:{marginTop:l,marginRight:u,marginBottom:d,marginLeft:f},children:v(r,{align:o,style:{borderColor:c,borderWidth:s,borderStyle:`solid`,backgroundColor:a,borderRadius:i,paddingTop:m,paddingRight:h,paddingBottom:g,paddingLeft:y},children:this.getMappedContent(e,{...t,parent:e})})}):v(_,{})}columns(e,t){let{attrs:n}=e,r=this.shouldShow(e,t);if(!r)return v(_,{});let[i,a]=this.adjustColumnsContent(e);return v(p,{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??J;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:i,verticalAlign:a=`top`,paddingLeft:o=0,paddingRight:s=0}=n||{};return v(r,{width:`${Number(i)}%`,style:{width:`${Number(i)}%`,margin:0,verticalAlign:a},className:`tab-col-full`,children:v(m,{style:{margin:0,paddingLeft:o,paddingRight:s},className:`tab-pad`,children:this.getMappedContent(e,{...t,parent:e})})})}repeat(t,n){let{attrs:r}=t,{each:i=``}=r||{},a=this.shouldShow(t,n);if(!a)return v(_,{});let{payloadValue:o}=n||{};o=typeof o==`object`?o:{};let s=this.payloadValues.get(i)??o[i]??[];if(!Array.isArray(s))throw Error(`Payload value for each "${i}" is not an array`);return v(_,{children:s.map(r=>v(e,{children:this.getMappedContent(t,{...n,parent:t,payloadValue:r})},D()))})}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 v(_,{});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=x(r),a=b(i),o=a?.querySelector(`head`);o?.remove();let s=a.toString();return v(`table`,{align:`left`,width:`100%`,border:0,cellPadding:`0`,cellSpacing:`0`,role:`presentation`,children:v(`tbody`,{children:v(`tr`,{style:{width:`100%`},children:v(`td`,{style:{width:`100%`},dangerouslySetInnerHTML:{__html:s}})})})})}inlineImage(e,t){let{attrs:n}=e,{src:r,isSrcVariable:i,alt:a=``,title:o=``,height:s=Y,width:c=X,externalLink:l=``,isExternalLinkVariable:u}=n||{};r=i?this.variableUrlValue(r,t):r,l=u?this.variableUrlValue(l,t):l;let d=v(`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?v(`a`,{href:l,rel:`noopener noreferrer`,style:{display:`inline`,textDecoration:`none`},target:`_blank`,children:d}):d}};async function me(e,t){let{theme:n,preview:r,...i}=t||{},a=new pe(e);return a.setPreviewText(r),a.setTheme(n||{}),a.render(i)}export{J as DEFAULT_COLUMNS_GAP,re as DEFAULT_COLUMNS_WIDTH,ie as DEFAULT_COLUMN_BACKGROUND_COLOR,se as DEFAULT_COLUMN_BORDER_COLOR,ae as DEFAULT_COLUMN_BORDER_RADIUS,oe as DEFAULT_COLUMN_BORDER_WIDTH,ue as DEFAULT_COLUMN_PADDING_BOTTOM,de as DEFAULT_COLUMN_PADDING_LEFT,le as DEFAULT_COLUMN_PADDING_RIGHT,ce as DEFAULT_COLUMN_PADDING_TOP,$ as DEFAULT_HTML_PROPS,Y as DEFAULT_INLINE_IMAGE_HEIGHT,X as DEFAULT_INLINE_IMAGE_WIDTH,Q as DEFAULT_META_TAGS,L as DEFAULT_SECTION_ALIGN,I as DEFAULT_SECTION_BACKGROUND_COLOR,z as DEFAULT_SECTION_BORDER_COLOR,R as DEFAULT_SECTION_BORDER_WIDTH,H as DEFAULT_SECTION_MARGIN_BOTTOM,U as DEFAULT_SECTION_MARGIN_LEFT,V as DEFAULT_SECTION_MARGIN_RIGHT,B as DEFAULT_SECTION_MARGIN_TOP,K as DEFAULT_SECTION_PADDING_BOTTOM,q as DEFAULT_SECTION_PADDING_LEFT,G as DEFAULT_SECTION_PADDING_RIGHT,W as DEFAULT_SECTION_PADDING_TOP,Z as LINK_PROTOCOL_REGEX,pe as Maily,me as render};
2
2
  //# sourceMappingURL=index.mjs.map