@markopolo_ai_inc/markopolo-email-editor 1.0.21 → 1.0.22
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/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{createContext as t,useContext as n,useCallback as o,useMemo as a,useState as i,useRef as l,useEffect as r,Fragment as s,useLayoutEffect as c,forwardRef as d,useReducer as p,useImperativeHandle as u}from"react";import{Modal as m,Input as g,Popover as y,Button as h,InputNumber as b,Spin as f,Select as k,Tooltip as _,Tabs as v,Switch as x,Slider as w,message as S}from"antd";import{FontAwesomeIcon as C}from"@fortawesome/react-fontawesome";import{faBold as N,faItalic as T,faUnderline as I,faStrikethrough as A,faListOl as L,faListUl as P,faLink as R,faUnlink as $,faExpandAlt as B,faCompressAlt as D,faImage as E,faUser as U,faTrash as M,faArrowsAlt as O,faLevelUpAlt as j,faDesktop as H,faMobileAlt as K,faUndo as z,faRedo as F,faInfoCircle as V,faAlignLeft as W,faAlignCenter as J,faAlignRight as q,faAlignJustify as G,faArrowsAltV as Y,faGripVertical as Z,faCloudUploadAlt as Q,faUserCircle as X,faTag as ee,faWindowMinimize as te,faWindowMaximize as ne,faCube as oe,faShareAltSquare as ae,faBars as ie,faGripLines as le,faMinusSquare as re,faFont as se,faColumns as ce,faChevronLeft as de}from"@fortawesome/free-solid-svg-icons";import{motion as pe}from"framer-motion";import{jsx as ue,jsxs as me,Fragment as ge}from"react/jsx-runtime";import{ChromePicker as ye}from"react-color";function he(e,t){if(!e||!t)return e;const n=t?.companyContext?.navigation_links,o=Array.isArray(n)&&n.length>0,a=t?.companyContext?.social_links,i=a&&"object"==typeof a&&Object.keys(a).length>0;if(!o&&!i)return e;const l={...e};let r=!1;return Object.keys(e).forEach(t=>{const s=e[t];if(s){if("menu"===s.key&&s.useNavigationLinks&&o){const e=n.map(e=>({label:e.label??"Link",url:e.url??"#",target:e.target??"_self"}));l[t]={...s,list:e},r=!0}if("social_link"===s.key&&s.useCompanySocialLinks&&i){const e="https://s.magecdn.com/social",n=[{key:"facebook",image:`${e}/tc-facebook.svg`,title:"Facebook"},{key:"twitter",image:`${e}/tc-x.svg`,title:"Twitter"},{key:"instagram",image:`${e}/tc-instagram.svg`,title:"Instagram"},{key:"linkedin",image:`${e}/tc-linkedin.svg`,title:"LinkedIn"},{key:"tiktok",image:`${e}/tc-tiktok.svg`,title:"TikTok"},{key:"youtube",image:`${e}/tc-youtube.svg`,title:"YouTube"}].map(({key:e,image:t,title:n})=>{const o=a[e];return{image:t,title:n,linkURL:null!=o&&String(o).trim()?String(o).replace(/^https?:\/\//,""):""}});l[t]={...s,list:n},r=!0}}}),r?l:e}const be=e=>{const t=e.constructor===Array?[]:{};for(let n in e)e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]?(t[n]=e[n].constructor===Array?[]:{},t[n]=be(e[n])):t[n]=e[n]);return t},fe=(e,t)=>{let n=null;return function(){n||(n=setTimeout(()=>{e.apply(this,arguments),n=null},t))}};function ke(e,t={}){if(null==e||"string"!=typeof e)return e;const n=null!=t.fontSize?Number(t.fontSize):14,o=null!=t.fontFamily?String(t.fontFamily):"sans-serif",a=null!=t.color?String(t.color):"",i=["direction: ltr",`font-size: ${n}px`,`font-family: ${o}`];a&&i.push(`color: ${a}`);const l=i.join("; ");let r=function(e){if(null==e||"string"!=typeof e)return e;let t=e.replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*font-size\s*:[^;]+;?/gi,"").replace(/\s*font-family\s*:[^;]+;?/gi,"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^;\s*|;\s*$/g,"").trim();return n?` style="${n}"`:""}),n="";for(let e=0;e<20&&n!==t;e++)n=t,t=t.replace(/<font(\s[^>]*)?>([\s\S]*?)<\/font>/gi,"$2");return t}(e.trim());const s=/^<span(?:\s[^>]*)?>([\s\S]*)<\/span>$/i.exec(r.trim()),c=/^<div(?:\s[^>]*)?>([\s\S]*)<\/div>$/i.exec(r.trim());return s?r=s[1]:c&&(r=c[1]),`<span style="${l}">${r}</span>`}function _e(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ve(e){if(!e||"object"!=typeof e)return;e.id||(e.id=_e());const t=e.children;Array.isArray(t)&&t.forEach(ve)}function xe(e){if(!e||"object"!=typeof e)return e;const t=be(e);return ve(t),t}function we(e="Drag block here"){return{id:_e(),name:e,key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function Se(e){const t={},n=[];function o(e){if(e&&"object"==typeof e)if(e.id||(e.id=_e()),"column"===e.key){const n=(e.children||[]).map(e=>{e.id||(e.id=_e());const t=[];return(e.children||[]).forEach(e=>{e.id||(e.id=_e()),o(e),t.push(e.id)}),{id:e.id,width:e.width,styles:e.styles,childrenIds:t}}),{children:a,...i}=e;t[e.id]={...i,cells:n}}else t[e.id]=e}return(e||[]).forEach(e=>{e.id||(e.id=_e()),o(e),n.push(e.id)}),{blockMap:t,rootOrder:n}}function Ce(e,t){function n(t){const o=e[t];if(!o)return null;if("column"===o.key){const e=(o.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>n(e)).filter(Boolean)})),{cells:t,...a}=o;return{...a,children:e}}return{...o}}return(t||[]).map(e=>n(e)).filter(Boolean)}function Ne(e,t){const n=t[e];if(!n)return null;if("column"!==n.key)return n;const o=(n.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>{const n=t[e];return n?"column"===n.key?Ne(e,t):n:null}).filter(Boolean)})),{cells:a,...i}=n;return{...i,children:o}}function Te(e,t,n){function o(t){const a=e[t];if(!a||"column"!==a.key)return null;for(let i=0;i<(a.cells||[]).length;i++){const l=a.cells[i];for(let a=0;a<(l.childrenIds||[]).length;a++){if(l.childrenIds[a]===n)return{containerId:t,cellIndex:i,itemIndex:a};const r=e[l.childrenIds[a]];if(r&&"column"===r.key){const e=o(l.childrenIds[a]);if(e)return e}}}return null}for(const e of t||[]){const t=o(e);if(t)return t}return null}function Ie(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return[{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}]}function a(t,o=[]){const i=e[t];if(!i||"column"!==i.key)return null;for(let t=0;t<(i.cells||[]).length;t++){const l=i.cells[t];for(let r=0;r<(l.childrenIds||[]).length;r++){const s=l.childrenIds[r];if(s===n)return[{containerBlock:i,containerType:i?.containerType??"none",cellIndex:t,isRoot:!1},...o];const c=e[s];if(c&&"column"===c.key){const e=a(s,[{containerBlock:i,containerType:i?.containerType??"none",cellIndex:t,isRoot:!1},...o]);if(e)return e}}}return null}for(const e of t||[]){const t=a(e,[]);if(t)return t}return[]}function Ae(e,t,n){const o=Ie(e,t,n),a=o.find(e=>e?.containerType&&"none"!==e.containerType)||o[0]||null,i=a?.cellIndex??0,l=a?.containerBlock??null,r=l?.columnProducts?.[i]??null,s=Array.isArray(l?.columnProducts)?l.columnProducts.find(e=>null!=e)??null:null;return{containerType:a?.containerType??"none",columnIndex:i,columnProduct:r??s,containerBlock:l,lineage:o}}function Le(e,t,n,o,a){const i=e[t];if(!i)return e;const l=i.cells.map((e,t)=>{if(t!==n)return e;const i=[...e.childrenIds];return i[o]=a,{...e,childrenIds:i}});return{...e,[t]:{...i,cells:l}}}function Pe(e,t,n,o){const a=e[t];if(!a)return{blockMap:e,removedId:null};const i=a.cells[n];if(!i)return{blockMap:e,removedId:null};const l=i.childrenIds[o],r=[...i.childrenIds];r.splice(o,1);const s=a.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{blockMap:{...e,[t]:{...a,cells:s}},removedId:l}}function Re(e,t,n,o,a){const i=e[t];if(!i)return e;const l=i.cells[n];if(!l)return e;const r=[...l.childrenIds];r.splice(o,0,a);const s=i.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{...e,[t]:{...i,cells:s}}}function $e(e,t){const n={...e};return function e(t){const o=n[t];o&&("column"===o.key&&(o.cells||[]).forEach(t=>(t.childrenIds||[]).forEach(t=>e(t))),delete n[t])}(t),n}function Be(e,t){if(!t)return{newBlockMap:e,rootId:null};if("column"===t.key){const{blockMap:n,rootOrder:o}=Se([t]);return{newBlockMap:{...e,...n},rootId:o[0]??null}}return{newBlockMap:{...e,[t.id]:t},rootId:t.id}}const De="SET_BLOCK_LIST",Ee="SET_BLOCKS",Ue="SET_IS_DRAG_START",Me="SET_ACTION_TYPE",Oe="SET_PREVIEW_MODE",je="SET_CURRENT_ITEM",He="SET_BODY_SETTINGS",Ke="SET_SELECTION_RANGE",ze="SET_TEXT_RANGE",Fe="SET_LANGUAGE",Ve="SET_LANGUAGE_LIBRARIES",We="SET_TEMPLATE_VARIABLES",Je=e=>({type:Me,actionType:e}),qe=e=>({type:je,currentItem:e}),Ge={blockMap:{},rootOrder:[],blockList:[],isDragStart:!1,actionType:"firstRender",previewMode:"desktop",currentItem:null,bodySettings:{preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}},selectionRange:null,textRange:null,language:"en",languageLibraries:{},templateData:null},Ye=t();function Ze(e,t,n){const o=he(t,e.templateData),a=Ce(o,n);let{currentItem:i}=e;if(i?.id&&o[i.id]){const e=Ne(i.id,o);e&&e!==i.data&&(i={...i,data:e})}return{...e,blockMap:o,rootOrder:n,blockList:a,currentItem:i}}function Qe(e,t){switch(t.type){case Ee:return Ze(e,t.blockMap,t.rootOrder);case De:{const{blockMap:n,rootOrder:o}=Se(t.blockList);return Ze(e,n,o)}case Ue:return{...e,isDragStart:t.isDragStart};case Me:return{...e,actionType:t.actionType};case Oe:return{...e,previewMode:t.previewMode};case je:{let n=t.currentItem;if(n?.id&&"column"===n.data?.key&&e.blockMap[n.id]){const t=Ne(n.id,e.blockMap);t&&(n={...n,data:t})}return{...e,currentItem:n}}case He:return{...e,bodySettings:t.bodySettings};case Ke:return{...e,selectionRange:t.selectionRange};case ze:return{...e,textRange:t.textRange};case Fe:return{...e,language:t.language};case Ve:return{...e,languageLibraries:t.languageLibraries};case We:{const n=t.templateData,o=he(e.blockMap,n),a=Ce(o,e.rootOrder);return{...e,templateData:n,blockMap:o,blockList:a}}default:return e}}var Xe={global:[{key:"CustomerName",token:"{{CustomerName}}",label:"Customer Name",labelKey:"variable_customer_name",type:"text",fallback:"Customer",source:"derived"},{key:"BrandName",token:"{{BrandName}}",label:"Brand Name",labelKey:"variable_brand_name",type:"text",fallback:"Company Name",source:"companyContext.name"},{key:"Tagline",token:"{{Tagline}}",label:"Tagline",labelKey:"variable_tagline",type:"text",fallback:"Your tagline here",source:"brandContext.tagline"},{key:"LogoUrl",token:"{{LogoUrl}}",label:"BrandLogo",labelKey:"variable_image_logo",type:"image",fallback:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",source:"brandContext.logo_url"},{key:"Website",token:"{{Website}}",label:"Website",labelKey:"variable_website",type:"text",fallback:"www.example.com",source:"companyContext.website"},{key:"Address",token:"{{Address}}",label:"Address",labelKey:"variable_address",type:"text",fallback:"123 Main St, City, Country",source:"companyContext.address"}],product:[{key:"ProductName",token:"{{ProductName}}",label:"Product Name",labelKey:"variable_product_name",type:"text",fallback:"Product Name",source:"content.products[].name"},{key:"ProductDescription",token:"{{ProductDescription}}",label:"Product Description",labelKey:"variable_product_description",type:"text",fallback:"Product description goes here.",source:"content.products[].description"},{key:"ProductImage",token:"{{ProductImage}}",label:"Product Image URL",labelKey:"variable_product_image",type:"image",fallback:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",source:"content.products[].image"},{key:"ProductLink",token:"{{ProductLink}}",label:"Product Link",labelKey:"variable_product_link",type:"url",fallback:"https://www.example.com",source:"content.products[].link"},{key:"ProductPrice",token:"{{ProductPrice}}",label:"Product Price (Amount)",labelKey:"variable_product_price",type:"number",fallback:"0",source:"content.products[].price.amount"},{key:"ProductCurrency",token:"{{ProductCurrency}}",label:"Product Currency",labelKey:"variable_product_currency",type:"text",fallback:"USD",source:"content.products[].price.currency"},{key:"ProductOldPrice",token:"{{ProductOldPrice}}",label:"Product Old Price",labelKey:"variable_product_old_price",type:"number",fallback:"0",source:"content.products[].old_price"},{key:"ProductNewPrice",token:"{{ProductNewPrice}}",label:"Product New Price",labelKey:"variable_product_new_price",type:"number",fallback:"0",source:"content.products[].new_price"},{key:"ProductPriceDisplay",token:"{{ProductPriceDisplay}}",label:"Product Price Display",labelKey:"variable_product_price_display",type:"text",fallback:"USD 0",source:"derived"}],discount:[{key:"DiscountValue",token:"{{DiscountValue}}",label:"Discount Value",labelKey:"variable_discount_value",type:"text",fallback:"20%",source:"content.discount.value"},{key:"DiscountCode",token:"{{DiscountCode}}",label:"Discount Code",labelKey:"variable_discount_code",type:"text",fallback:"SAVE20",source:"content.discount.code"},{key:"ValidUntil",token:"{{ValidUntil}}",label:"Valid Until",labelKey:"variable_valid_until",type:"date",fallback:"12-31-2025",source:"content.discount.valid_until"}]};const et=[{value:"none",labelKey:"container_type_none"},{value:"discount",labelKey:"container_type_discount"},{value:"product",labelKey:"container_type_product"}],tt="CustomerName",nt="DiscountValue",ot="DiscountCode",at="ValidUntil",it="CompanyName",lt="Address",rt="Website",st="BrandName",ct="LogoUrl",dt="Tagline",pt="HeroBanner",ut="FooterBanner",mt="NavLabel",gt="NavUrl",yt="ProductName",ht="ProductDescription",bt="ProductImage",ft="ProductLink",kt="ProductPrice",_t="ProductCurrency",vt="ProductOldPrice",xt="ProductNewPrice",wt="ProductPriceDisplay",St="CTALabel",Ct="CTAUrl",Nt=new Set([vt,xt]);function Tt(e){return`{{${e}}}`}const It=Xe;let At=It;function Lt(e,t=At){return t&&Array.isArray(t[e])?t[e].map(e=>({...e,token:e.token||Tt(e.key)})):[]}let Pt=[],Rt=[],$t=[],Bt={},Dt=[],Et=[],Ut=[];function Mt(){Pt=Lt("global",At),Rt=Lt("product",At),$t=Lt("discount",At),Bt=[...Pt,...Rt,...$t].reduce((e,t)=>(e[t.key]=t,e),{}),Dt=$t.map(e=>({variableKey:e.key,labelKey:e.labelKey}));const e=Rt.filter(e=>!Nt.has(e.key));Et=e.map(e=>({variableKey:e.key,labelKey:e.labelKey})),Ut=Pt.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),$t.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),e.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type}))}Mt();const Ot={[tt]:"Customer",[nt]:"20%",[ot]:"SAVE20",[at]:"12-31-2025",[it]:"Company Name",[st]:"Company Name",[lt]:"123 Main St, City, Country",[rt]:"www.example.com",[ct]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[dt]:"Your tagline here",[pt]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[ut]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[mt]:"Link",[gt]:"https://www.example.com",[yt]:"Product Name",[ht]:"Product description goes here.",[bt]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[ft]:"https://www.example.com",[kt]:"0",[_t]:"USD",[vt]:"0",[xt]:"0",[wt]:"USD 0",[St]:"Shop Now",[Ct]:"www.example.com"};function jt(e){return null==e||"string"!=typeof e?"":e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ht=new Set([wt]);function Kt(e,t,n={}){if(null==e||"string"!=typeof e)return"";const o=e.replace(/\{\{(\w+)\}\}/g,(e,o)=>{const a=Wt(t,o,n);return Ht.has(o)?a:jt(a)});return null==(a=o)||"string"!=typeof a?a:a.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>| )?\s*<\/p>\s*)+/i,"");var a}function zt(e){return Ot[e]??"—"}const Ft=/^\{\{\s*[\w.]+\s*\}\}$/;function Vt(e,t,{allowEmpty:n=!1}={}){if(null==e)return zt(t);const o=String(e).trim();return n||""!==o?function(e){return"string"==typeof e&&Ft.test(e.trim())}(o)?zt(t):o:zt(t)}function Wt(e,t,n={}){if(!e)return zt(t);const{columnIndex:o,columnProduct:a}=n;let i=a;switch(!i&&e.content?.products&&"number"==typeof o&&(i=e.content.products[o]||null),t){case tt:return zt(tt);case nt:return Vt(e.content?.discount?.value,nt);case ot:return Vt(e.content?.discount?.code,ot);case at:return Vt(e.content?.discount?.valid_until,at);case it:case st:return Vt(e.companyContext?.name,t);case lt:return Vt(e.companyContext?.address,lt);case rt:return Vt(e.companyContext?.website,rt);case ct:return Vt(e.brandContext?.logo_url,ct);case dt:return Vt(e.brandContext?.tagline,dt);case pt:return Vt(e.brandContext?.heroBanner,pt);case ut:return Vt(e.brandContext?.footerBanner,ut);case mt:case gt:return zt(t);case yt:return Vt(i?.name,yt);case ht:return Vt(i?.description,ht);case bt:return Vt(i?.image,bt);case ft:return Vt(i?.link,ft);case kt:return null!=i?.price&&"number"==typeof i.price||null!=i?.price&&"string"==typeof i.price?String(i.price):null!=i?.new_price?String(i.new_price):zt(kt);case _t:return Vt(i?.currency,_t);case vt:return Vt(i?.old_price,vt);case xt:return null!=i?.new_price?Vt(i.new_price,xt):null!=i?.price?Vt(i.price,xt):zt(xt);case wt:{const e=null!=i?.currency?String(i.currency):"",t=null!=i?.price?String(i.price):null!=i?.new_price?String(i.new_price):null,n=null!=i?.old_price||null!=i?.new_price,o=null!=i?.old_price?String(i.old_price):null,a=null!=i?.new_price?String(i.new_price):null!=i?.price?String(i.price):null;if(n&&(null!=o||null!=a)){const t=null!=o?jt(e?`${e} ${o}`:o):"";return[""!==t?`<span style="text-decoration: line-through;">${t}</span>`:"",null!=a?jt(e?`${e} ${a}`:a):""].filter(Boolean).join(" ")||zt(wt)}return e&&null!=t?jt(`${e} ${t}`):zt(wt)}case St:{const t=e.content?.cta?.text;return Vt(t,St)}case Ct:{const t=e.content?.cta?.url;return Vt(null!=t?t:e.companyContext?.website,Ct)}default:return zt(t)}}const Jt=[{variableKey:ct,labelKey:"variable_image_logo"},{variableKey:pt,labelKey:"variable_image_hero_banner"},{variableKey:ut,labelKey:"variable_image_footer_banner"}],qt=[{variableKey:bt,labelKey:"variable_image_product_image"}],Gt=[{variableKey:St,labelKey:"variable_cta_label"}],Yt=[{variableKey:Ct,labelKey:"variable_cta_url"}];function Zt(e,t,n,o={}){let a=[];return"discount"===t?a=[...Dt]:"product"===t&&(a=[...Et]),a.map(({variableKey:e,labelKey:t})=>({...Bt[e]||{},variableKey:e,labelKey:t,value:Tt(e),pasteValue:Wt(n,e,o)}))}function Qt(e,t,n,o={},a=[]){const i="none"===t?Ut.map(e=>({...e,pasteValue:Wt(n,e.key,o)})):Zt(0,t,n,o),l=(a||[]).filter(e=>e&&e.containerType&&"none"!==e.containerType).flatMap(e=>Zt(0,e.containerType,n,e.context||{})),r=new Set,s=[];return[...i,...l].forEach(e=>{const t=e.variableKey||e.key||e.value;t&&!r.has(t)&&(r.add(t),s.push(e))}),s}const Xt={display_text:"DisplayText",introduction:"Introduction",heading:"Heading",subheading:"Subheading",products_description:"ProductDescription"};function en(e,t,n,o){return{value:Tt(e),labelKey:t,variableKey:e,key:e,type:"image",pasteValue:Wt(n,e,o)}}function tn(e,t,n={}){const o=Jt.map(({variableKey:e,labelKey:o})=>en(e,o,t,n));if("product"===e){const e=qt.map(({variableKey:e,labelKey:o})=>en(e,o,t,n));return[...o,...e]}return o}function nn(e){return!1!==e?.linkEnabled}const on=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),an=e=>on(e).replace(/"/g,""").replace(/'/g,"'"),ln=(e,t="#")=>{if(null==e)return t;const n=String(e).trim();if(!n)return t;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?t:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)||/^tel:/i.test(n)?n:n.startsWith("//")?`https:${n}`:/^[a-z][a-z\d+.-]*:/i.test(n)?n:`https://${n.replace(/^\/+/,"")}`},rn=(e,t)=>{const n=new RegExp(/[A-Z]/g),o=e=>e.replace(n,e=>`-${e.toLowerCase()}`),a={desktop:t?.desktop??{},mobile:t?.mobile??{}};let i={className:e,desktop:"",mobile:""};for(let e of Object.entries(a.desktop))e[1]&&"contentBackground"!==e[0]&&(i.desktop+=`${o(e[0])}:${"number"==typeof e[1]?e[1]+"px":e[1]};`);if(Object.keys(a.mobile).length){let t="";for(let e of Object.entries(a.mobile))e[1]&&"contentBackground"!==e[0]&&(t+=`${o(e[0])}:${"number"==typeof e[1]?e[1]+"px":e[1]} !important;`);i.mobile+=`@media(max-width:620px){\n .${e} {\n ${t}\n }\n }`}return i},sn=(e,t="",n)=>{const o=e.map((e,o)=>{let a={...e};const i={desktop:e?.styles?.desktop??{},mobile:e?.styles?.mobile??{}};if(a.styleConfig=rn(n?`${n}-${e.key}-${o}`:`${e.key}-${o}`,i),a.contentStyles){const n={desktop:a.contentStyles?.desktop??{},mobile:a.contentStyles?.mobile??{}};a.contentStyleConfig=rn(`${e.key}-content-${o}`,n),a.contentStyleConfig.mobile&&(t+=a.contentStyleConfig.mobile)}if(a.styleConfig.mobile&&(t+=a.styleConfig.mobile),i.desktop.contentBackground&&(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:`background-color:${i.desktop.contentBackground};`,mobile:""}),i.mobile.contentBackground&&(a.contentStyleConfig||(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:"",mobile:""}),a.contentStyleConfig.mobile=` @media(max-width:620px){\n .${a.contentStyleConfig.className} {background-color:${i.mobile.contentBackground};}\n }`,t+=a.contentStyleConfig.mobile),e.children?.length){const{newBlockList:n,styles:i}=sn(e.children,t,o);t+=i,a.children=n}return{...a}});return{newBlockList:o,styles:t}};function cn(e,t){return e&&t?String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=`${e?`${e}; `:""}color: ${t};`;return`<a${n.replace(o[0],` style="${a}"`)}>`}return`<a${n} style="color: ${t};">`}):e}function dn(e){const t=String(e??"");return null!=(n=t)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(e){if(!e||!/<a\b/i.test(e))return e;const t=(e,t,n)=>{const o=(t[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=(o?`${o}; `:"")+"text-decoration: none;",i='"'===n?` style="${a}"`:` style='${a}'`;return`<a${e.replace(t[0],i)}>`};return String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return t(n,o,'"');const a=n.match(/\sstyle\s*=\s*'([^']*)'/i);return a?t(n,a,"'"):`<a${n} style="text-decoration: none;">`})}(t):on(t);var n}const pn=(e,t,n={})=>{let o=e.dynamicSelectedContent??e.text??"";t&&o&&(o=Kt(o,t,n));return o=cn(o,e?.styles?.desktop?.linkColor||e?.styles?.desktop?.color),`<${e.type} ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">\n ${o}\n </${e.type}>`},un=(e,t,n,o,a,i)=>{let l="";const r={columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null};return e.forEach((e,s)=>{if("column"===e.key){const r=e.styles?.desktop?.borderRadius,c=r?`border-radius:${"number"==typeof r?r+"px":r};`:"",d=c?"overflow:hidden;":"",p=e.containerType&&"none"!==e.containerType?e:o,u=e.containerType&&"none"!==e.containerType?s:a,m=e.containerType&&"none"!==e.containerType?0:i;l+=`<div ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig.desktop};width:100%;display:block;${d}">\n <table ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="width:100%;max-width:${t.contentWidth}px;margin:0 auto;${c}${e.contentStyleConfig.desktop}">\n <tbody><tr>${un(e.children,t,n,p,u,m)}</tr></tbody>\n </table></div>`}if("content"===e.key&&(l+=`<td ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="width:${e.width}; ${e.styleConfig.desktop}">${un(e.children,t,n,o,a,s)}</td>`),"text"===e.key){const t=null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r;e.type&&/^h[1-4]$/.test(e.type)?l+=pn(e,n,t):l+=((e,t,n={},o=null)=>{let a=e.dynamicSelectedContent??e.text??"";t&&a&&(a=Kt(a,t,n)),a=cn(a,e?.styles?.desktop?.linkColor||e?.styles?.desktop?.color);const i="footer"===o?.containerType,l=null==(r=a)||"string"!=typeof r?"":r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var r;return!i||""!==l&&"{{Address}}"!==l&&"{{Tagline}}"!==l?`<div ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">${a}</div>`:""})(e,n,t,o)}if("heading"===e.key&&(l+=pn(e,n,r)),"image"===e.key){l+=((e,t,n={})=>{let o=e.src||"";const a="string"==typeof e.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(e.src.trim())?e.src.trim():"";if(t&&a){const e=Wt(t,a.replace(/^\{\{\s*|\s*\}\}$/g,""),n);e&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(e).trim())&&(o=e)}const i=`<img src="${an(o)}" alt="${an(e.alt||"Image")}" style="max-width:100%;${e.styleConfig.desktop}" \n ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""}/>`,l=null!=e.linkURL?String(e.linkURL).trim():"",r=nn(e)&&""!==l?`<a href="${an(ln(l))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;">${i}</a>`:i;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n ${r}\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r)}if("button"===e.key){l+=((e,t,n={})=>{let o=e.text||"",a=e.linkURL||"";if(t){const i=o.match(/\{\{(\w+)\}\}/),l=e.labelVariable?e.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():i?i[1]:void 0;if(l){const e=Wt(t,l,n);null==e||String(e).startsWith("{{")||(o=String(e))}if(e.urlVariable){const o=Wt(t,e.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(a=String(o))}}const i=dn(o),l=an(ln(a)),r=e.styleConfig.desktop||"",s=r.includes("background-color:")?"":`background-color:${(e=>e?.brandContext?.brand_color??"#111111")(t)};`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n <a ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${r}${s}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${l}">${i}</a>\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r)}var c,d,p;"divider"===e.key&&(l+=`<div ${(c=e).contentStyleConfig.mobile?`class="${c.contentStyleConfig.className}"`:""} \n style="${c.contentStyleConfig.desktop}">\n <div ${c.styleConfig.mobile?`class="${c.styleConfig.className}"`:""} \n style="${c.styleConfig.desktop}"></div>\n </div>`),"spacer"===e.key&&(l+=(d=e,`<div ${d.contentStyleConfig?.mobile?`class="${d.contentStyleConfig.className}"`:""} \n style="${d.contentStyleConfig?.desktop||""}">\n <div ${d.styleConfig?.mobile?`class="${d.styleConfig.className}"`:""} \n style="${d.styleConfig?.desktop||""}"></div>\n </div>`)),"menu"===e.key&&(l+=(e=>{const t=e.list||[],n=null!=e.separator?String(e.separator):" | ",o=e.styleConfig?.desktop||"",a=e.contentStyleConfig?.desktop||"",i=t.map(e=>{const t=ln(e.url,"#"),n="_blank"===e.target?"_blank":"_self",a=on(e.label||"Link");return`<a target="${n}" href="${an(t)}" style="${o};text-decoration:none;display:inline-block;">${a}</a>`}).join(n);return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${a}">${i}</div>`})(e)),"avatar"===e.key&&(l+=(e=>{const t=e.src||"",n=e.alt||"Avatar",o=e.linkURL,a=e.styleConfig?.desktop||"",i=e.styles?.desktop?.width??64,l=`max-width:100%;width:${"number"==typeof i?i+"px":i};height:${"number"==typeof i?i+"px":i};object-fit:cover;border-radius:${e.styles?.desktop?.borderRadius??"50%"};${a}`,r=an(t),s=an(n),c=t?`<img src="${r}" alt="${s}" style="${l}" />`:`<div style="${l};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=e.contentStyleConfig?.desktop||"",p=o?`<a href="${an(ln(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${d}">${p}</div>`})(e)),"social_link"===e.key&&(l+=`<div ${(p=e).contentStyleConfig.mobile?`class="${p.contentStyleConfig.className}"`:""} \n style="${p.contentStyleConfig.desktop}">\n ${p.list.map(e=>{const{image:t,title:n,linkURL:o}=e;return`<a target="_blank" rel="noopener noreferrer" href="${an(ln(o))}" style="${p.styleConfig.desktop};display:inline-block;">\n <img src="${an(t)}" alt="${an(n)}" style="width:${p.imageWidth}px;" \n ${p.styleConfig.mobile?`class="${p.styleConfig.className}"`:""}/> \n </a>`}).join("")}\n </div>`)}),l},mn={preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}},gn=({bodySettings:e,blockList:t,templateData:n})=>{let o="";const a=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??null;if(!a)return e;const i=n.filter(e=>e?.id!==a.id),l=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(l):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===i.length?a:i[t%i.length]);return{...e,children:t,columnProducts:r}};return e.map(l)})(t,n),{newBlockList:i,styles:l}=sn(a);return o=un(i,e,n),`<html>\n <head>\n <meta charset="UTF-8">\n <title>email</title>\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style type="text/css">\n *{\n margin: 0;\n padding: 0;\n border: none;\n box-sizing: border-box;\n }\n\n html,body {\n height:100%;\n overflow-y:auto;\n }\n\n table {\n width: 100%;\n color:unset;\n }\n\n table, tr, td {\n vertical-align: top;\n border-collapse: collapse;\n }\n\n h1,h2,h3,h4 {\n display: block;\n margin-block-start: 0px;\n margin-block-end: 0px;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n font-weight: bold;\n }\n\n @media(max-width:620px){\n td {\n display:inline-block;\n width:100% !important;\n }\n }\n ${l}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${e.preHeader}</div>\n <div style="background-color:${e.styles.backgroundColor};color:${e.styles.color}; font-family:${e.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function yn(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==t)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...mn,styles:{...mn.styles}};Array.isArray(t)?n=t:"object"==typeof t&&(n=Array.isArray(t.blockList)?t.blockList:[],t.bodySettings&&"object"==typeof t.bodySettings&&(o={preHeader:null!=t.bodySettings.preHeader?t.bodySettings.preHeader:mn.preHeader,contentWidth:Number(t.bodySettings.contentWidth)||mn.contentWidth,styles:{backgroundColor:t.bodySettings.styles?.backgroundColor??mn.styles.backgroundColor,color:t.bodySettings.styles?.color??mn.styles.color,fontFamily:t.bodySettings.styles?.fontFamily??mn.styles.fontFamily}}));return`<!DOCTYPE html>\n${gn({bodySettings:o,blockList:n,templateData:t.templateData})}`}const hn=["product"];function bn(e){return Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[]}function fn(e,t={}){if(!e||"object"!=typeof e)return e;if("image"===e.key){const n="string"==typeof e.imageVariable&&/^\{\{\w+\}\}$/.test(e.imageVariable.trim())?e.imageVariable.trim():"",o="string"==typeof e.src&&/^\{\{\w+\}\}$/.test(e.src.trim())?e.src.trim():"",{imageVariable:a,...i}=e;return{...i,src:o||n||e.src,children:bn(e.children).map(e=>fn(e,t))}}if("column"===e.key){const{ctaText:n,...o}=e,a=e.containerType,i=function(e){return null==e||"none"===e?"none":"discount"===e?"discount":"product"===e||"hero_product"===e||"additional_product"===e?"product":"none"}(a),l="product"===i?e.productRole??("additional_product"===a?"additional":"main"):void 0,r=bn(e.children);let s=e.columnProducts;if(hn.includes(i)){const e=r.length;Array.isArray(s)||(s=[]),s=Array.from({length:e},(e,t)=>s[t]??null)}else s=[];return{...o,containerType:i,productRole:l,columnProducts:s,children:(r||[]).map(e=>fn(e,t))}}if("heading"===e.key){const n=e.id?t?.[e.id]:null,o={...e,key:"text",name:e.name,type:e.type||"h1",contentType:e.contentType??"static",text:e.text,styles:e.styles,contentStyles:e.contentStyles,selectedVariableKey:e.selectedVariableKey,dynamicVariable:n?.variable??e.dynamicVariable,dynamicPrompt:n?.prompt??e.dynamicPrompt,dynamicSelectedContent:n?.selectedContent??e.dynamicSelectedContent,dynamicOptions:Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:e.dynamicOptions};return"dynamic"===o.contentType&&(o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[]),{...o,children:bn(e.children).map(e=>fn(e,t))}}if("text"===e.key){const n=e.id?t?.[e.id]:null,o=e.contentType??"static",a={...e,type:e.type||"p",contentType:o};return"dynamic"===o&&(a.dynamicVariable=n?.variable??e.dynamicVariable??"",a.dynamicPrompt=n?.prompt??e.dynamicPrompt??"",a.dynamicSelectedContent=n?.selectedContent??e.dynamicSelectedContent??"",a.dynamicOptions=Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[]),{...a,children:bn(e.children).map(e=>fn(e,t))}}return{...e,children:bn(e.children).map(e=>fn(e,t))}}function kn(e,t={}){const n=Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):null;if(!Array.isArray(n))return e;const o=n.map(e=>fn(e,t));return o.forEach(ve),o}const _n="https://api-alpha.markopolo.ai/v1",vn="https://nbq-ml-api-stg.markopolo.ai/v1",xn="95b48b5b-cf5e-486d-817e-9839d4c4e618";function wn(e,t){const n=null!=(o=e)&&"string"==typeof o&&o.trim()?o.replace(/\/$/,""):_n;var o;const a=function(e){return null!=e&&"string"==typeof e&&e.trim()?e.replace(/\/$/,""):vn}(t);return{imageUploadEndpoint:`${n}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${n}/knowledge-base/products`,mlEmailNodesEndpoint:`${a}/ml-service/content/generate-email-nodes`}}function Sn(e={}){const t=e&&"object"==typeof e?e:{},{apiBaseUrlV1:n,apiBaseV1:o,mlGenerationApiBaseUrlV1:a,mlApiBaseUrlV1:i,headers:l,...r}=t,s=n||o||_n,c="undefined"!=typeof process&&process.env?.REACT_APP_ML_API_BASE_V1,d=wn(s,a||i||c||vn),p="undefined"!=typeof process?String(process.env?.REACT_APP_EMAIL_TEMPLATE_ID??"").trim():"",u={...d,...r},m=String(u.emailTemplateId??"").trim()||p||xn;return{...u,emailTemplateId:m,headers:{...u.headers||{},...l||{}}}}const Cn={preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}};function Nn(e){if(!e||"object"!=typeof e)return"";return`${e.severity??"unknown"}:${e.code??"issue"}:${e.blockId??"global"}:${e.location??""}`}function Tn(e,t=!1){if(null==e||""===String(e).trim())return t;const n=String(e).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const In={text:"Text",heading:"Heading",button:"Button",image:"Image",avatar:"Profile image",menu:"Menu",social_link:"Social links"};const An={none:"Container",product:"Product",discount:"Discount",header:"Header",footer:"Footer",navigation_bar:"Navigation",introduction:"Introduction",hero:"Hero",hero_product:"Hero product",body:"Body",additional_product:"Additional product"};function Ln(e,t,n){const o=e.containerType??"none",a=function(e){const t=e??"none";return An[t]?An[t]:String(t).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(o);return n<=1?a:"none"===o?`${Pn(t+1)} section`:`${Pn(t+1)} ${a} block`}function Pn(e){const t=e%10,n=e%100;return 1===t&&11!==n?`${e}st`:2===t&&12!==n?`${e}nd`:3===t&&13!==n?`${e}rd`:`${e}th`}function Rn(e,t){return t<=1?null:`${Pn(e+1)} of ${t} stacked blocks`}function $n(e,t,n,o){const a=function(e){return In[e]?In[e]:String(e||"block").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(t),i=[...e];o&&i.push(o);const l=i.length>0?i.join(" → "):"Email body";return n?`${a} ("${n}") — ${l}`:`${a} — ${l}`}function Bn(e,t){const n=function(e){return null==e||"object"!=typeof e?{...Cn,styles:{...Cn.styles}}:{preHeader:null!=e.preHeader?e.preHeader:Cn.preHeader,contentWidth:Number(e.contentWidth)||Cn.contentWidth,styles:{backgroundColor:null!=e.styles?.backgroundColor?e.styles.backgroundColor:Cn.styles.backgroundColor,color:null!=e.styles?.color?e.styles.color:Cn.styles.color,fontFamily:null!=e.styles?.fontFamily?e.styles.fontFamily:Cn.styles.fontFamily}}}(e);("number"!=typeof n.contentWidth||n.contentWidth<=0)&&t.push({severity:"error",code:"body_content_width_invalid",message:"Body content width must be a positive number.",location:"Theme settings"});const o=n.styles;null!=o.backgroundColor&&""!==String(o.backgroundColor).trim()||t.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||t.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||t.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function Dn(e,t){e.push(t)}const En=["product"];function Un(e,t,n,o,a,i){if("dynamic"!==(e.contentType??"static"))return;const l=e.dynamicSelectedContent,r=null!=e?.id?i?.[e.id]?.selectedContent:void 0;let s=null!=l&&""!==String(l).trim()?l:r;var c;null!=s&&""!==String(s).trim()||null==e.text||""===(null==(c=e.text)?"":String(c).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=e.text),null!=s&&""!==String(s).trim()||Dn(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:$n(t,o,void 0,a),blockId:e.id??null})}function Mn(e,t,n,o,a){if(!Array.isArray(e))return;const i=e.length;e.forEach((e,l)=>{if(!e||"object"!=typeof e)return;const r=e.key;if("column"===r){const r=Ln(e,l,i),s=[...t,r];return function(e,t,n){const o=e.containerType??"none";if(!En.includes(o))return;const a=e.children??[],i=e.columnProducts??[];a.forEach((o,l)=>{const r=i[l];if(null==r||"object"==typeof r&&!r.id){const o=a.length>1?`Column ${l+1} of ${a.length}`:"This column",i=[...t,o].join(" → ");Dn(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:i,blockId:e.id??null})}})}(e,s,n),void(Array.isArray(e.children)&&Mn(e.children,s,n,o,a))}if("content"===r){const r=i>1?`Column ${l+1} of ${i}`:null,s=r?[...t,r]:t;return void(Array.isArray(e.children)&&Mn(e.children,s,n,o,a))}const s=Rn(l,i);switch(r){case"image":!function(e,t,n,o){const a=e.src,i=()=>$n(t,"image",void 0,o);null!=a&&""!==String(a).trim()?(Tn(a,!1)||Dn(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:i(),blockId:e.id??null}),null!=e.alt&&""!==String(e.alt).trim()||Dn(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:i(),blockId:e.id??null})):Dn(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:i(),blockId:e.id??null})}(e,t,n,s);break;case"avatar":!function(e,t,n,o){const a=e.src,i=()=>$n(t,"avatar",void 0,o);null==a||""===String(a).trim()?Dn(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:i(),blockId:e.id??null}):Tn(a,!1)||Dn(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:i(),blockId:e.id??null})}(e,t,n,s);break;case"button":!function(e,t,n,o){const a=e.linkURL,i=()=>$n(t,"button",void 0,o);null!=a&&""!==String(a).trim()?Tn(a,!1)||Dn(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:i(),blockId:e.id??null}):Dn(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:i(),blockId:e.id??null})}(e,t,n,s);break;case"menu":!function(e,t,n,o){const a=e.list||[];a.forEach((a,i)=>{const l=e=>$n(t,"menu",e||`Item ${i+1}`,o);null!=a.label&&""!==String(a.label).trim()||Dn(n,{severity:"info",code:"menu_empty_label",message:'Menu item label is empty; will show as "Link".',location:l(`item ${i+1}`),blockId:e.id??null});const r=a.url;null==r||""===String(r).trim()?Dn(n,{severity:"warning",code:"menu_empty_url",message:'Menu item URL is empty; will be saved as href="#".',location:l(a.label||`item ${i+1}`),blockId:e.id??null}):Tn(r,!1)||Dn(n,{severity:"warning",code:"menu_invalid_url",message:"Menu item URL format is invalid.",location:l(a.label||`item ${i+1}`),blockId:e.id??null})}),0===a.length&&Dn(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:$n(t,"menu",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"social_link":!function(e,t,n,o){const a=e.list||[];a.forEach((a,i)=>{const l=a.title||a.image||`link ${i+1}`,r=e=>$n(t,"social_link",e||l,o),s=a.linkURL;null==s||""===String(s).trim()?Dn(n,{severity:"warning",code:"social_empty_link",message:'Social link URL is empty; will be saved as href="https://".',location:r(l),blockId:e.id??null}):Tn(s,!1)||Dn(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:r(l),blockId:e.id??null});const c=a.image;null==c||""===String(c).trim()?Dn(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:r(l),blockId:e.id??null}):Tn(c,!1)||Dn(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:r(l),blockId:e.id??null})}),0===a.length&&Dn(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:$n(t,"social_link",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"text":Un(e,t,n,"text",s,a);break;case"heading":Un(e,t,n,"heading",s,a)}})}function On({blockList:e,bodySettings:t,aiContentRefs:n={}}){const o=[];return Bn(t,o),Mn(Array.isArray(e)?e:[],[],o,t,n),o}function jn(){const e="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!e)return;const t=e.Image;return"function"==typeof t?t:void 0}const Hn=/^\{\{\s*[\w.]+\s*\}\}$/;function Kn(e){if(null==e||""===String(e).trim())return null;const t=String(e).trim();if(function(e){return null!=e&&"string"==typeof e&&Hn.test(e.trim())}(t))return null;if(/^https?:\/\//i.test(t))return Tn(t,!1)?t:null;if(t.startsWith("//")){const e=`https:${t}`;return Tn(e,!1)?e:null}return null}function zn(e,t=[],n=e?.length??0){const o=[];return Array.isArray(e)?(e.forEach((e,a)=>{if(!e||"object"!=typeof e)return;const i=e.key;if("column"===i){const i=Ln(e,a,n),l=[...t,i],r=e.children;return void o.push(...zn(r,l,r?.length??0))}if("content"===i){const i=n>1?`Column ${a+1} of ${n}`:null,l=i?[...t,i]:t,r=e.children;return void o.push(...zn(r,l,r?.length??0))}const l=Rn(a,n);if("image"===i){const n=Kn(e.src);n&&o.push({url:n,location:$n(t,"image",void 0,l),blockId:e.id??null})}}),o):o}function Fn(e,t=12e3){const n=jn();if(!n)return Promise.resolve(!1);const o=String(e).trim();return o?new Promise(e=>{const a=new n;let i=!1;const l=t=>{i||(i=!0,clearTimeout(r),a.onload=null,a.onerror=null,e(t))},r=setTimeout(()=>l(!1),t);a.onload=()=>l(!0),a.onerror=()=>l(!1);try{a.src=o}catch{l(!1)}}):Promise.resolve(!1)}async function Vn(e,t={}){const{timeoutMs:n=12e3,concurrent:o=6}=t;if(!jn())return[];const a=zn(Array.isArray(e)?e:[]);if(0===a.length)return[];const i=new Map;for(const e of a)i.has(e.url)||i.set(e.url,[]),i.get(e.url).push(e.location);const l=[...i.keys()],r=new Map;let s=0;const c=Math.max(1,Math.min(o,l.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<l.length;){const e=s++,t=l[e],o=await Fn(t,n);r.set(t,o)}}()));const d=[];for(const[e,t]of i)if(!0!==r.get(e))for(const n of t)d.push({severity:"warning",code:"image_url_not_loadable",message:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",location:n,blockId:a.find(t=>t.url===e&&t.location===n)?.blockId??null});return d}async function Wn(e,t){return[...On(e),...await Vn(e?.blockList??[],t)]}const Jn=(...e)=>e.filter(Boolean).join(" "),qn={drag_block_here:"请将模块拖放到此处",blocks:"模块",photos:"图片",powered_by_pexels:"图片由Pexels提供",loading:"加载中...",content:"内容",styles:"样式",ai_powered:"AI 驱动",layout:"布局",components:"组件",presets:"预设",body_settings:"邮件主题设置",global:"全局",text_and_headings:"文本与标题",pre_header:"预标题",pre_header_description:"预标题是在收件箱中查看电子邮件时跟随主题行的简短摘要文本。",confirm:"确认",cancel:"取消",add_blocks:"请添加块",block_product:"产品",block_product_single:"单个",block_product_multi:"多个",block_discount:"折扣",block_introduction:"引言",block_body:"正文",block_header:"页眉",block_footer:"页脚",no_product_found:"未找到产品",no_products_matching_search:"没有符合搜索条件的产品。清空搜索可查看完整列表。",load_more_products:"加载更多",add_products:"添加产品",add_products_in_store:"请在店铺中添加产品。",column:"列",columns:"列排版",column_settings:"列设置",column_styles:"列样式",size_px:"尺寸",column_delete:"删除列",column_delete_desc:"您确定删除多余的{{count}}列吗?",container:"容器",container_settings:"容器设置",container_type:"容器类型",container_type_help:"决定该容器可用的变量和产品映射。",container_type_none:"无",container_type_header:"页眉",container_type_discount:"折扣",container_type_introduction:"引言",container_type_body:"正文",container_type_product:"产品",container_type_hero_product:"主推产品",container_type_additional_product:"附加产品",container_type_footer:"页脚",product_role:"产品角色",product_role_main_hero:"主推产品",product_role_additional:"附加产品",assign_product_to_column:"为列分配产品",text:"文本",text_content:"这是一个文本,点击修改文本",text_settings:"文本设置",text_styles:"文本样式",text_align:"文本对齐方式",heading:"标题",heading_content:"这是一个标题,点击修改标题",heading_settings:"标题设置",heading_type:"标题类型",button:"按钮",button_settings:"按钮设置",button_action:"点击按钮触发",button_styles:"按钮样式",button_padding:"按钮内边距",spacer:"间距",spacer_block:"间距块",spacer_settings:"间距设置",divider:"分割线",divider_settings:"分割线设置",divider_type:"分割线类型",divider_styles:"分割线样式",image:"图片",image_settings:"图片设置",image_action:"点击图片跳转",image_url:"图片URL",image_alt:"图片alt",image_styles:"图片样式",image_source:"图片来源",image_source_url:"输入URL",image_source_upload:"上传图片",image_upload:"上传",image_upload_click:"点击上传",image_upload_not_configured:"未配置图片上传。请在 apiConfig 中设置 imageUploadEndpoint,或传入 null 关闭;默认使用内置 API 根地址。",image_uploaded:"图片上传成功",image_upload_failed:"图片上传失败",image_upload_error:"上传图片时出错",uploading:"上传中…",image_source_variable:"使用变量",menu:"导航栏",menu_settings:"导航栏设置",menu_items:"菜单项",menu_item:"菜单项",menu_styles:"菜单样式",add_new_item:"添加新项",label:"标签",page:"页面",url:"链接地址",target:"打开方式",same_tab:"当前窗口",new_tab:"新窗口",separator:"分隔符",letter_spacing:"字间距",link_color:"链接颜色",avatar:"头像",avatar_settings:"头像设置",avatar_image:"头像图片",avatar_border_radius:"圆角",social_link:"社交链接",add_social_link:"添加社交链接",social_link_size:"社交链接大小",social_links:"社交链接",social_link_settings:"社交链接设置",content_background_color:"内容背景颜色",background_color:"背景颜色",text_color:"文本颜色",email_theme_background_color:"邮件主题色",font_color:"字体颜色",button_color:"按钮颜色",divider_color:"分割线颜色",action_type:"按钮类型",top:"上",right:"右",left:"左",bottom:"下",line_height:"行高",link:"超链接",link_url:"超链接URL",link_url_placeholder:"example.com",padding_settings:"内边距设置",width_auto:"宽度自适应",width:"宽度",height:"高度",font_size:"字体大小",font_family:"字体",align:"对齐方式",solid:"实线",dotted:"虚线(点)",dashed:"虚线(破折号)",spacing:"间距",border_radius:"圆角",export_html:"导出html",export_json:"导出JSON",export_checking_images:"正在检查图片…",language_zh:"中文",export_validation_title:"导出前校验",export_validation_issues_found:"导出前发现以下问题",export_validation_errors:"错误",export_validation_warnings:"警告",export_validation_info:"提示",export_anyway:"仍要导出",ignore:"忽略",validation_body_content_width_invalid:"邮件内容宽度必须为正数。",validation_body_background_color_missing:"主题背景色未设置。",validation_body_text_color_missing:"主题文字颜色未设置。",validation_body_font_family_missing:"主题字体未设置。",validation_image_empty_src:"图片地址为空,图片将无法显示。",validation_image_invalid_src:"图片地址格式无效。",validation_image_url_not_loadable:"图片地址无法加载或预览;链接可能已失效、过期或被拦截。",validation_image_empty_alt:"图片未设置 alt 文本,建议添加以提升可访问性。",validation_avatar_empty_src:"头像图片地址为空,头像将无法显示。",validation_avatar_invalid_src:"头像图片地址格式无效。",validation_button_empty_link:'按钮链接为空,将被保存为 href="https://"。',validation_button_invalid_link:"按钮链接格式无效。",validation_menu_empty_label:"菜单项标签为空,将显示为「链接」。",validation_menu_empty_url:'菜单项链接为空,将被保存为 href="#"。',validation_menu_invalid_url:"菜单项链接格式无效。",validation_menu_no_items:"菜单块没有任何项。",validation_social_empty_link:'社交链接地址为空,将被保存为 href="https://"。',validation_social_invalid_link:"社交链接地址格式无效。",validation_social_empty_icon:"社交链接图标地址为空,图标将无法显示。",validation_social_invalid_icon:"社交链接图标地址格式无效。",validation_social_no_links:"社交链接块没有任何链接。",validation_container_product_not_assigned:"该列未分配产品;请在容器设置中分配产品。",validation_dynamic_content_empty:"未生成动态内容;导出将使用静态文本(如有)。",tooltip_bold:"加粗",tooltip_italic:"斜体",tooltip_underline:"下划线",tooltip_strikethrough:"删除线",tooltip_align_left:"居左",tooltip_align_center:"居中",tooltip_align_right:"居右",tooltip_ordered_list:"有序列表",tooltip_unordered_list:"无序列表",tooltip_link:"超链接",tooltip_remove_link:"删除超链接",add_link_modal_title:"添加超链接",content_type:"内容类型",content_type_static:"静态",content_type_dynamic:"动态",ai_enabled:"使用 AI 撰写",text_and_content_type:"内容类型",heading_or_body:"标题",body_paragraph:"正文",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"变量",insert_merge_field:"选择或输入变量...",dynamic_prompt_help:"描述语气,我们将推荐示例内容。",generate:"生成",ml_generation_failed:"无法生成 AI 内容",ml_ai_unavailable:"AI 生成需要分栏布局、公司 ID、模板 ID 和 ML 接口。请将文本放在栏目内并检查 apiConfig。",ml_no_variations:"未返回任何建议。请更换提示词或确认服务器上存在该模板。",ml_generation_unexpected_error:"生成内容时发生意外错误。",sample_ai_content:"示例 AI 内容",select_content:"选择内容",variable_dynamic_placeholder:"无(可选)",variable_display_text:"展示文案",variable_introduction:"引言",variable_heading:"标题",variable_subheading:"副标题",variable_products_description:"产品描述",variable_customer_name:"客户姓名",variable_introduction_title:"引言标题",variable_introduction_subtitle:"引言副标题",variable_body_title:"正文标题",variable_body_subtitle:"正文副标题",variable_discount_value:"折扣力度",variable_discount_code:"折扣码",variable_valid_until:"有效期至",variable_company_name:"公司名称",variable_brand_name:"品牌名称",variable_address:"地址",variable_website:"网站",variable_logo_url:"Logo URL",variable_tagline:"标语",variable_nav_label:"导航文案",variable_nav_url:"导航链接",variable_product_name:"产品名称",variable_product_description:"产品描述",variable_product_image:"产品图片 URL",variable_product_link:"产品链接",variable_product_price:"产品价格",variable_product_currency:"货币",variable_product_old_price:"原价",variable_product_new_price:"现价",variable_product_price_display:"产品价格展示",variable_image_logo:"Logo",variable_image_hero_banner:"主图横幅",variable_image_footer_banner:"页脚横幅",variable_image_product_image:"产品图片",variable_cta_label:"CTA 文案",variable_cta_url:"CTA 链接",button_label_variable:"按钮文案(变量)",button_url_variable:"按钮链接(变量)",button_text:"按钮文案",button_label_manual:"输入文案",button_url_manual:"输入链接",use_company_social_links:"使用公司社交链接",use_navigation_links:"使用导航链接",tooltip_container_type:"决定该容器可用的变量和产品映射。",tooltip_variables_static:"将合并字段插入内容,发送邮件时将被替换。",tooltip_dynamic_prompt:"描述语气或意图,我们将推荐示例内容。(预览模式 — 连接 AI API 后可生成真实内容。)"},Gn={drag_block_here:"Drag block here",blocks:"Blocks",photos:"Photos",powered_by_pexels:"Powered by Pexels",loading:"Loading...",content:"Content",styles:"Styles",ai_powered:"AI powered",layout:"Layout",components:"Components",presets:"Presets",body_settings:"Theme Settings",global:"Global",text_and_headings:"Text and headings",pre_header:"Pre-header",pre_header_description:"The pre-header is a short summary text that follows the subject line when viewing an email in the inbox.",confirm:"Confirm",cancel:"Cancel",add_blocks:"Add blocks",block_product:"Product",block_product_single:"Single",block_product_multi:"Multi",block_discount:"Discount",block_introduction:"Introduction",block_body:"Body",block_header:"Header",block_footer:"Footer",no_product_found:"No product found",no_products_matching_search:"No products match your search. Clear the search to see the full list.",load_more_products:"Load more",add_products:"Add products",add_products_in_store:"Add products in your store.",column:"Column",columns:"Columns",column_settings:"Column Settings",column_styles:"Column Styles",size_px:"Size",column_delete:"Delete Column",column_delete_desc:"Are you sure you want to delete {{count}} extra columns? ",container:"Container",container_settings:"Container Settings",container_type:"Container Type",container_type_help:"Determines which variables and product mappings are available.",container_type_none:"None",container_type_header:"Header",container_type_discount:"Discount",container_type_introduction:"Introduction",container_type_body:"Body",container_type_product:"Product",container_type_hero_product:"Hero Product",container_type_additional_product:"Additional Product",container_type_footer:"Footer",product_role:"Product Role",product_role_main_hero:"Primary",product_role_additional:"Secondary",assign_product_to_column:"Assign product to column",text:"Text",text_content:"This is a text, click to edit text",text_settings:"Text Settings",text_styles:"Text Styles",text_align:"Text Align",heading:"Heading",heading_content:"This is a heading, click to edit heading",heading_settings:"Heading Settings",heading_type:"Heading Type",button:"Button",button_settings:"Button Settings",button_action:"Button Action",button_styles:"Button Styles",button_padding:"Button Padding",spacer:"Spacer",spacer_block:"SPACER BLOCK",spacer_settings:"Spacer Settings",divider:"Divider",divider_settings:"Divider Settings",divider_type:"Divider Type",divider_styles:"Divider Styles",image:"Image",image_action:"Image Action",image_url:"Image URL",image_alt:"Image Alt",image_styles:"Image Styles",image_settings:"Image Settings",image_source:"Image source",image_source_url:"Enter URL",image_source_upload:"Upload image",image_upload:"Upload",image_upload_click:"Click to upload",image_upload_not_configured:"Image upload is not configured. Set imageUploadEndpoint in apiConfig or pass null to disable; defaults use the built-in API base.",image_uploaded:"Image uploaded successfully",image_upload_failed:"Failed to upload image",image_upload_error:"Error uploading image",uploading:"Uploading…",image_source_variable:"Use variable",menu:"Navigation bar",menu_settings:"Navigation bar Settings",menu_items:"Menu Items",menu_item:"Menu Item",menu_styles:"Menu Styles",add_new_item:"Add New Item",label:"Label",page:"Page",url:"URL",target:"Target",same_tab:"Same Tab",new_tab:"New Tab",separator:"Separator",letter_spacing:"Letter Spacing",link_color:"Link Color",avatar:"Avatar",avatar_settings:"Avatar Settings",avatar_image:"Avatar image",avatar_border_radius:"Border radius",social_link:"Social Link",social_link_settings:"Social Link Settings",add_social_link:"Add Social Link",social_link_size:"Social Link Size",social_links:"Social Links",content_background_color:"Content Background Color",background_color:"Background Color",text_color:"Text Color",email_theme_background_color:"Email Theme Background Color",font_color:"Font Color",button_color:"Button Color",divider_color:"Divider Color",action_type:"Action Type",top:"Top",right:"Right",left:"Left",bottom:"Bottom",line_height:"Line Height",link:"Link",link_url:"Link URL",link_url_placeholder:"example.com",padding_settings:"Padding Settings",width:"Width",height:"Height",width_auto:"Width Auto",font_size:"Font Size",font_family:"Font Family",solid:"Solid",dotted:"Dotted",dashed:"Dashed",align:"Align",spacing:"Spacing",border_radius:"Border radius",export_html:"Export HTML",export_json:"Export JSON",export_checking_images:"Checking images…",language_zh:"中文",export_validation_title:"Export validation",export_validation_issues_found:"Issues found before export",export_validation_errors:"Errors",export_validation_warnings:"Warnings",export_validation_info:"Info",export_anyway:"Export anyway",ignore:"Ignore",validation_body_content_width_invalid:"Body content width must be a positive number.",validation_body_background_color_missing:"Theme background color is missing.",validation_body_text_color_missing:"Theme text color is missing.",validation_body_font_family_missing:"Theme font family is missing.",validation_image_empty_src:"Image URL is empty; the image will not display.",validation_image_invalid_src:"Image URL format is invalid.",validation_image_url_not_loadable:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",validation_image_empty_alt:"Image alt text is empty; consider adding for accessibility.",validation_avatar_empty_src:"Avatar image URL is empty; avatar will not display.",validation_avatar_invalid_src:"Avatar image URL format is invalid.",validation_button_empty_link:'Button link URL is empty; will be saved as href="https://".',validation_button_invalid_link:"Button link URL format is invalid.",validation_menu_empty_label:'Menu item label is empty; will show as "Link".',validation_menu_empty_url:'Menu item URL is empty; will be saved as href="#".',validation_menu_invalid_url:"Menu item URL format is invalid.",validation_menu_no_items:"Menu block has no items.",validation_social_empty_link:'Social link URL is empty; will be saved as href="https://".',validation_social_invalid_link:"Social link URL format is invalid.",validation_social_empty_icon:"Social link icon URL is empty; icon will not display.",validation_social_invalid_icon:"Social link icon URL format is invalid.",validation_social_no_links:"Social link block has no links.",validation_container_product_not_assigned:"A product is not assigned to this column; assign a product in Container settings.",validation_dynamic_content_empty:"Dynamic content not generated; export will use static text if available.",tooltip_bold:"Bold",tooltip_italic:"Italic",tooltip_underline:"Underline",tooltip_strikethrough:"Strikethrough",tooltip_align_left:"Align left",tooltip_align_center:"Align center",tooltip_align_right:"Align right",tooltip_ordered_list:"Ordered list",tooltip_unordered_list:"Unordered list",tooltip_link:"Link",tooltip_remove_link:"Remove link",add_link_modal_title:"Add link",content_type:"Content type",content_type_static:"Static",content_type_dynamic:"Dynamic",ai_enabled:"Write using AI",text_and_content_type:"Content type",heading_or_body:"Heading",body_paragraph:"Body",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"Variables",insert_merge_field:"Select or type variable...",dynamic_prompt_help:"Describe the tone; we'll suggest sample content.",generate:"Generate",ml_generation_failed:"Could not generate AI content",ml_ai_unavailable:"AI generation needs a column layout, company ID, template ID, and ML endpoint. Open this text inside a section column and check apiConfig.",ml_no_variations:"No suggestions were returned. Try another prompt or verify the template exists on the server.",ml_generation_unexpected_error:"Something went wrong while generating content.",sample_ai_content:"Sample AI content",select_content:"Select content",variable_dynamic_placeholder:"None (optional)",variable_display_text:"Display text",variable_introduction:"Introduction",variable_heading:"Heading",variable_subheading:"Subheading",variable_products_description:"Products description",variable_customer_name:"Customer Name",variable_introduction_title:"Introduction Title",variable_introduction_subtitle:"Introduction Subtitle",variable_body_title:"Body Title",variable_body_subtitle:"Body Subtitle",variable_discount_value:"Discount value",variable_discount_code:"Discount code",variable_valid_until:"Valid until",variable_company_name:"Company name",variable_brand_name:"Brand name",variable_address:"Address",variable_website:"Website",variable_logo_url:"Logo URL",variable_tagline:"Tagline",variable_nav_label:"Nav link label",variable_nav_url:"Nav link URL",variable_product_name:"Product name",variable_product_description:"Product description",variable_product_image:"Product image URL",variable_product_link:"Product link",variable_product_price:"Product price",variable_product_currency:"Product currency",variable_product_old_price:"Product old price",variable_product_new_price:"Product new price",variable_product_price_display:"Product price display",variable_image_logo:"Logo",variable_image_hero_banner:"Hero banner",variable_image_footer_banner:"Footer banner",variable_image_product_image:"Product image",variable_cta_label:"CTA label",variable_cta_url:"CTA URL",button_label_variable:"Button label (variable)",button_url_variable:"Button URL (variable)",button_text:"Button text",button_label_manual:"Enter label",button_url_manual:"Enter URL",use_company_social_links:"Use company social links",use_navigation_links:"Use navigation links",tooltip_container_type:"Determines which variables and product mappings are available for this container.",tooltip_variables_static:"Insert a merge field into your content. It will be replaced when the email is sent.",tooltip_dynamic_prompt:"Describe the tone or intent; we'll suggest sample content. (Preview mode — connect an AI API for real generation.)"},Yn=()=>{const{language:e,languageLibraries:t}=n(Ye);let o={zh:qn,en:Gn};t&&(o={...o,...t,zh:{...qn,...o.zh||{}},en:{...Gn,...o.en||{}}});return{t:(t,n)=>{let a=(o[e]||{})[t];return n&&n instanceof Object&&Object.keys(n).forEach(e=>{a=a.replace(`{{${e}}}`,n[e])}),a||t}}},Zn=/\{\{(\w+)\}\}/g;function Qn(e,t){if(null!=e)if("string"!=typeof e){if(Array.isArray(e))e.forEach(e=>Qn(e,t));else if("object"==typeof e){if(void 0!==e.$$typeof)return;Object.values(e).forEach(e=>Qn(e,t))}}else(function(e){if("string"!=typeof e||0===e.length)return[];const t=[];let n;for(;null!==(n=Zn.exec(e));){const e=n[1];e&&t.push(e)}return Zn.lastIndex=0,t})(e).forEach(e=>t.add(e))}function Xn(e,t,n){e&&"object"==typeof e&&(e.id&&n.has(e.id)||(e.id&&n.add(e.id),"column"!==e.key?Qn(e,t):(e.children||[]).forEach(e=>{(e?.children||[]).forEach(e=>Xn(e,t,n))})))}function eo(e,t,n,o){if(!e||o.has(e))return;o.add(e);const a=t[e];a&&"object"==typeof a&&("column"===a.key?(a.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>eo(e,t,n,o))}):Qn(a,n))}function to(e,t){const n=new Set;if(!e||"object"!=typeof e)return n;if(Array.isArray(e.children)){const t=new Set;return Xn(e,n,t),n}if(!t||"object"!=typeof t)return n;const o=new Set;return(e.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>eo(e,t,n,o))}),n}const no=()=>{const e=(t,n)=>t?t.classList?.contains("text-content_editable")?null:t&&t.tagName?.toLocaleLowerCase()===n?t:e(t.parentNode,n):null,t=o((e,n)=>e?e.classList?.contains("text-content_editable")?null:e&&e.style?.[n]?e.style[n]:t(e.parentNode,n):null,[]);return{getSelectionNode:e,getSectionStyle:t}},oo=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"b"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_bold"),onClick:()=>{e("bold",!1,null),t()},children:ue(C,{icon:N,className:"rich-text-tools-button-icon"})})},ao=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"i"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_italic"),onClick:()=>{e("italic",!1,null),t()},children:ue(C,{icon:T,className:"rich-text-tools-button-icon"})})},io=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"u"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_underline"),onClick:()=>{e("underline",!1,null),t()},children:ue(C,{icon:I,className:"rich-text-tools-button-icon"})})},lo=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"strike"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_strikethrough"),onClick:()=>{e("strikethrough",!1,null),t()},children:ue(C,{icon:A,className:"rich-text-tools-button-icon"})})},ro=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"ol"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_ordered_list"),onClick:()=>{e("insertOrderedList",!1,null),t()},children:ue(C,{icon:L,className:"rich-text-tools-button-icon"})})},so=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"ul"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_unordered_list"),onClick:()=>{e("insertUnorderedList",!1,null),t()},children:ue(C,{icon:P,className:"rich-text-tools-button-icon"})})},co=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{t:l}=Yn(),{getSelectionNode:r}=no(),[s,c]=i(!1),[d,p]=i({value:"",range:null}),u=a(()=>o?r(o.commonAncestorContainer,"a"):null,[o,r]),y=()=>{c(!1),p({value:"",range:null})};return me(ge,{children:[ue("button",{className:Jn("rich-text-tools-button ",u&&"rich-text-tools-button-active"),title:l("tooltip_link"),onClick:()=>{let e=window.getSelection().getRangeAt(0);const n=e.commonAncestorContainer.parentNode,o="A"===n.nodeName,a={...d,range:e};o&&(a.rangeIsLink=!0,a.value=n.href.replace("https://","")),p(a),c(!0),t()},children:ue(C,{icon:R,className:"rich-text-tools-button-icon"})}),ue("button",{className:Jn("rich-text-tools-button"),title:l("tooltip_remove_link"),onClick:()=>{e("unlink",!1,null),t()},children:ue(C,{icon:$,className:"rich-text-tools-button-icon"})}),ue(m,{title:l("add_link_modal_title"),open:s,zIndex:1100,onOk:()=>{const{range:e,value:n,rangeIsLink:o}=d;if(o)e.commonAncestorContainer.parentNode.href=n;else{let t=document.createElement("a");t.target="_blank",t.href=n,e.surroundContents(t)}t(),y()},onCancel:y,okText:l("confirm"),cancelText:l("cancel"),wrapClassName:"ee-modal-dark",children:ue(g,{addonBefore:"https://",value:d.value.replace("https://",""),onChange:e=>p({...d,value:"https://"+e.target.value})})})]})},po=({id:e,textBlock:t,styles:o})=>{const{blockMap:s,rootOrder:c,templateData:d}=n(Ye),{t:p}=Yn(),u=l(null),[m,g]=i(!1),[h,b]=i(!1),f=a(()=>{const t=Ie(s,c,e),n=t?.[0]??null;return{containerBlock:n?.containerBlock??null,containerType:n?.containerType??"none",cellIndex:n?.cellIndex??0,lineage:t}},[s,c,e]),k=a(()=>{const e=f?.cellIndex??0,t=f?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[f]),_=a(()=>(f?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[f?.lineage]),v=a(()=>Qt(0,f?.containerType??"none",d,k,_),[f?.containerType,d,k,_]),x=a(()=>to(f?.containerBlock,s),[f?.containerBlock,s]),w=a(()=>v.filter(e=>"image"!==e.type&&!x.has(e.variableKey??e.key)),[v,x]);r(()=>{if(u.current){var e=u.current.parentNode?.getBoundingClientRect();const t=document.querySelector("#preview").getBoundingClientRect();e.top-190<0?(u.current.style.bottom="auto",u.current.style.top="110%"):(u.current.style.bottom="110%",u.current.style.top="auto"),e.left+375>t.left+t.width?(u.current.style.left="auto",u.current.style.right="0"):(u.current.style.left="0",u.current.style.right="auto")}},[]);const S=(e,t,n)=>{document.execCommand(e,t,n)},N=()=>{t?.current&&t.current.dispatchEvent(new Event("input",{bubbles:!0}))};return ue("div",{className:"rich-text",ref:u,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:ue(pe.div,{className:"rich-text-tools",initial:{scale:0,x:0},animate:{scale:1,x:0},style:{width:m?"auto":"375px"},children:me("div",{className:"rich-text-tools-body items-center",children:[!m&&me(ge,{children:[ue(oo,{modifyText:S,setTextContent:N}),ue(ao,{modifyText:S,setTextContent:N}),ue(io,{modifyText:S,setTextContent:N}),ue(lo,{modifyText:S,setTextContent:N}),ue(ro,{modifyText:S,setTextContent:N}),ue(so,{modifyText:S,setTextContent:N}),ue(co,{modifyText:S,setTextContent:N}),ue(y,{zIndex:1070,trigger:"click",open:h,onOpenChange:b,overlayClassName:"ee-rich-text-variables-popover",getPopupContainer:()=>document.querySelector("#preview")||document.body,content:me("div",{className:"ee-rich-text-variables-menu",children:[ue("div",{className:"ee-rich-text-variables-header",children:p("variables")}),w.map(e=>ue("div",{className:"ee-rich-text-variables-item",onMouseDown:n=>{n.preventDefault(),(e=>{if(!t?.current||!e)return;const n=window.getSelection();let o=null;if(n?.rangeCount){const e=n.getRangeAt(0);t.current.contains(e.commonAncestorContainer)&&(o=e)}o||(o=document.createRange(),o.selectNodeContents(t.current),o.collapse(!1)),o.deleteContents();const a=document.createTextNode(e);o.insertNode(a),o.setStartAfter(a),o.collapse(!0),n&&(n.removeAllRanges(),n.addRange(o)),N(),b(!1)})(e.value)},children:e.labelKey?p(e.labelKey):e.label||e.value},`variables-${e.value}`))]}),children:ue("button",{className:"rich-text-tools-button",title:p("insert_merge_field"),onMouseDown:e=>e.preventDefault(),children:ue("span",{className:"rich-text-tools-button-icon",style:{color:"#fff",fontFamily:"monospace",fontWeight:700,fontSize:13,lineHeight:1},children:"{}"})})})]}),ue("button",{className:"rich-text-tools-button",onClick:()=>g(!m),children:ue(C,{icon:m?B:D,className:"rich-text-tools-button-icon"})})]})})})},uo=({id:e,blockItem:t,displayContent:o})=>{const{currentItem:i,previewMode:s,blockMap:c,rootOrder:d,setBlocks:p,setCurrentItem:u,isDragStart:m,templateData:g}=n(Ye),y=l(null),h=i&&i.id===(e??t?.id),b="desktop"===s?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},f=b.linkColor||b.color,{linkColor:k,..._}=b,v={..._,direction:"ltr",unicodeBidi:"isolate",...f?{"--ee-rich-text-link-color":f}:{}},x=l(!1),w=null!=o?o:t.text||"",S=a(()=>{const n=Ie(c,d,e??t?.id),o=n?.[0]??null;return{containerBlock:o?.containerBlock??null,containerType:o?.containerType??"none",cellIndex:o?.cellIndex??0,lineage:n}},[c,d,e,t?.id]),C=a(()=>{const e=S?.cellIndex??0,t=S?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[S]),N=a(()=>(S?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[S?.lineage]),T=a(()=>Qt(0,S?.containerType??"none",g,C,N).map(e=>{return t=e.value,n=e.pasteValue,{token:t,pasteValue:String(n||"")};var t,n}).filter(e=>e.token&&e.pasteValue&&""!==e.pasteValue.trim()&&!e.pasteValue.includes("{{")&&e.pasteValue!==e.token).sort((e,t)=>t.pasteValue.length-e.pasteValue.length),[g,C,S?.containerType,N]);r(()=>{if(h&&y.current){const e=I(w);if(x.current){const t=y.current.innerHTML||"";e!==I(t)&&(y.current.innerHTML=e)}else y.current.innerHTML=e,y.current.focus();x.current=!0}else x.current=!1},[h,e,w]);const I=e=>"string"!=typeof e?e:e.replace(/\u202E/g,"").replace(/\u202D/g,"").replace(/\u202A/g,"").replace(/\u202B/g,"").replace(/\u202C/g,"").replace(/\sdir\s*=\s*["']rtl["']/gi,' dir="ltr"').replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*direction\s*:\s*rtl\s*;?/gi,"").trim();return n?` style="${n}"`:""}),A=I(w);return me("div",{className:"relative",dir:"ltr",style:{direction:"ltr",unicodeBidi:"isolate"},children:[h&&t&&!m&&ue(po,{textBlock:y,id:e??t?.id,styles:v}),ue("div",{className:Jn(h&&"text-block","text-content_editable"),onClick:e=>{e.preventDefault(),e.stopPropagation()},onInput:n=>{const a=e??t?.id,l=n.target.innerHTML,r=I(l),s=null!=o?I(o):null,m=null!=s&&r===s,g=c[a]||{};let y=m?t.text:r;"text"===(g.key??t?.key)&&(y=(e=>{if(!e||!T.length||"undefined"==typeof document)return e;const t=document.createElement("div");t.innerHTML=e;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o=n.nextNode();for(;o;){let e=o.nodeValue||"";T.forEach(({token:t,pasteValue:n})=>{n&&e.includes(n)&&(e=e.split(n).join(t))}),o.nodeValue=e,o=n.nextNode()}return t.innerHTML})(y));const h={...g,text:y,selectedVariableKey:m?g.selectedVariableKey:void 0},b={...c,[a]:h};p(b,d),u({...i,data:h})},style:v,dir:"ltr",contentEditable:h,suppressContentEditableWarning:!0,ref:y,dangerouslySetInnerHTML:h?void 0:{__html:A}})]})},mo=t=>{const{id:o,blockItem:i}=t,{currentItem:l,previewMode:r,templateData:s,blockMap:c,rootOrder:d}=n(Ye),p="desktop"===r?i.styles?.desktop??{}:{...i.styles?.desktop??{},...i.styles?.mobile??{}},u=l&&l.id===o,m=a(()=>Ae(c,d,o),[c,d,o]),g=a(()=>Kt(i.text,s,m),[i.text,s,m]),y=u?i.text||"":g,h=p.linkColor||p.color,b=a(()=>{return t=h,(e=y)&&t?String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=`${e?`${e}; `:""}color: ${t};`;return`<a${n.replace(o[0],` style="${a}"`)}>`}return`<a${n} style="color: ${t};">`}):e;var e,t},[y,h]),f=m?.containerBlock,k="footer"===f?.containerType,_=(g||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(k&&(""===_||"{{Address}}"===_||"{{Tagline}}"===_))return null;const v=i.type&&/^h[1-4]$/.test(i.type)?i.type:"div";return u?ue(uo,{...t,blockItem:i}):e.createElement(v,{style:{...p,direction:"ltr",unicodeBidi:"isolate"},dir:"ltr",dangerouslySetInnerHTML:{__html:b}})},go=e=>e?.brandContext?.brand_color??"#111111",yo=e=>{const{blockItem:t,id:o}=e,{currentItem:i,previewMode:l,templateData:r,blockMap:s,rootOrder:c}=n(Ye),d=a(()=>Ae(s,c,o),[o,s,c]),p=a(()=>{const e=t.text??"",n=e.match(/\{\{(\w+)\}\}/),o=t.labelVariable?t.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():n?n[1]:void 0;if(!r||!o)return e;const a=Wt(r,o,d);return null==a||String(a).startsWith("{{")?e:String(a)},[t.text,t.labelVariable,r,d]),u=i&&i.id===o,m="desktop"===l?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},g={...m,backgroundColor:m.backgroundColor??go(r)},y="desktop"===l?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},h=a(()=>ue(uo,{...e,blockItem:t,displayContent:p}),[t,p]);return ue("div",{style:{...y},children:u?h:ue("div",{style:{...g,textAlign:"center"},dangerouslySetInnerHTML:{__html:p}})})},ho=({blockItem:e})=>{const{previewMode:t}=n(Ye),o="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},a="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",children:ue("div",{style:{...a},children:ue("div",{style:{...o}})})})},bo=({blockItem:e})=>{const{previewMode:t}=n(Ye),o="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},a="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",style:{...a},children:ue("div",{style:{width:"100%",height:"number"==typeof o.height?`${o.height}px`:o.height||"16px",display:o.display||"block"}})})},fo=({blockItem:e})=>{const{previewMode:t}=n(Ye),{list:o=[],separator:a=" | "}=e,i=o,l="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},r="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},s={fontSize:null!=l.fontSize?`${l.fontSize}px`:"14px",fontFamily:l.fontFamily||"sans-serif",color:l.linkColor||l.color||"#2faade",fontWeight:l.fontWeight||"normal",letterSpacing:null!=l.letterSpacing?`${l.letterSpacing}px`:"0px",textDecoration:"none",paddingLeft:null!=l.paddingLeft?`${l.paddingLeft}px`:"8px",paddingRight:null!=l.paddingRight?`${l.paddingRight}px`:"8px",paddingTop:null!=l.paddingTop?`${l.paddingTop}px`:"4px",paddingBottom:null!=l.paddingBottom?`${l.paddingBottom}px`:"4px"},c={fontSize:null!=l.fontSize?`${l.fontSize}px`:"14px",color:l.color||"#333",paddingLeft:4,paddingRight:4};return ue("div",{className:"relative",children:ue("div",{style:{...r,display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:r.textAlign||"center"},children:i.map((e,t)=>me("span",{style:{display:"inline-flex",alignItems:"center"},children:[t>0&&ue("span",{style:c,children:a}),ue("a",{href:e.url?e.url.startsWith("http")?e.url:`https://${e.url}`:"#",target:"_blank"===e.target?"_blank":"_self",rel:"_blank"===e.target?"noopener noreferrer":void 0,style:s,children:e.label||"Link"})]},t))})})},ko=({blockItem:e,id:t})=>{const{src:o,alt:i,linkURL:l}=e,{previewMode:r,templateData:s,blockMap:c,rootOrder:d}=n(Ye),p="desktop"===r?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},u="desktop"===r?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},m=a(()=>{const e="string"==typeof o&&/^\{\{\w+\}\}$/.test(o.trim())?o.trim():"";if(o&&!e)return o;if(!s||!e)return o||"";const n=Ae(c,d,t),a=e.replace(/^\{\{|\}\}$/g,"").trim(),i=Wt(s,a,n);return i&&!i.startsWith("{{")?i:o||""},[o,s,c,d,t]),g="string"==typeof o&&/^\{\{\w+\}\}$/.test(o.trim())?o.trim():"",y=!m||m.startsWith("{{"),h=i||"Image",b=p.width,f=b&&"auto"!==b,k="string"==typeof l?l.trim():"",_=""===k?"":k.startsWith("http")?k:`https://${k.replace(/^\/+/,"")}`,v=()=>m&&!y?f?ue("div",{style:{width:b,display:"inline-block"},children:ue("img",{src:m,style:{...p,width:"100%",maxWidth:"100%"},alt:h,className:"inline-block"})}):ue("img",{src:m,style:p,alt:h,className:"inline-block"}):ue("div",{className:"empty-image",style:{...p,width:"auto"===p.width?"100%":p.width},title:y&&g?g:void 0,children:y&&g?ue("span",{className:"empty-image-variable-label",children:g}):ue(C,{icon:E,className:"empty-image-icon"})}),x=nn(e)&&_&&m&&!y?ue("a",{href:_,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"inline-block"},onClick:e=>e.stopPropagation(),children:v()}):v();return ue("div",{className:"relative",children:ue("div",{style:{...u},children:x})})},_o=({blockItem:e})=>{const{src:t,alt:o,linkURL:a}=e,{previewMode:i}=n(Ye),l="desktop"===i?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},r="desktop"===i?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},s=t?ue("img",{src:t,style:{...l,width:l.width??64,height:l.width??64,objectFit:"cover",borderRadius:l.borderRadius??"50%"},alt:o||"Avatar",className:"inline-block"}):ue("div",{className:"empty-avatar",style:{width:l.width??64,height:l.width??64,borderRadius:l.borderRadius??"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--ee-border, #eee)"},children:ue(C,{icon:U,style:{fontSize:"24px",color:"#999"}})}),c={...r,width:"100%"};return ue("div",{className:"relative",children:ue("div",{style:c,children:a?ue("a",{href:a.startsWith("http")?a:`https://${a}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:s}):s})})},vo=({blockItem:e})=>{const{previewMode:t}=n(Ye),{list:o=[],imageWidth:a}=e,i="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},l="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",children:ue("div",{style:l,children:o.map((e,t)=>{const{image:n,title:o,linkURL:l}=e,r=ue("img",{src:n,alt:o,style:{width:a}});return ue("div",{style:{...i,display:"inline-block"},children:l?ue("a",{href:l.startsWith("http")?l:`https://${l}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:r}):r},t)})})})},xo=({blockItem:e,id:t})=>{if(!e)return null;const n={blockItem:e,id:t};switch(e.key){case"text":return ue(mo,{...n});case"button":return ue(yo,{...n});case"divider":return ue(ho,{...n});case"spacer":return ue(bo,{...n});case"menu":return ue(fo,{...n});case"image":return ue(ko,{...n});case"avatar":return ue(_o,{...n});case"social_link":return ue(vo,{...n});default:return null}},wo=e=>{const{block:t,blockIndex:o,clearStyles:a}=e,{t:i}=Yn(),{previewMode:l,blockMap:r,rootOrder:c,validationMarkers:d,ignoreValidationIssue:p,setBlocks:u,currentItem:m,setCurrentItem:g,setIsDragStart:b,isDragStart:f,bodySettings:k,setActionType:_}=n(Ye),v="desktop"===l?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},{contentBackground:x,...w}=v,S="undefined"!=typeof window?window.__eeDragItemData:null,N=S?.key??(m?.id?r[m.id]?.key:null)??m?.data?.key,T=m?.id?Te(r,c,m.id):null,I=f&&("column"!==N||"add"===m?.type||Boolean(T)),A=e=>t=>{t.preventDefault(),t.stopPropagation(),g({id:e.id,data:e,type:"edit"}),_("edit")},L=e=>t=>{t.preventDefault(),t.stopPropagation();const n=r[e];n&&(g({id:n.id,data:n,type:"edit"}),_("edit"))},P=(e,t,n)=>o=>{o.preventDefault(),o.stopPropagation();const{blockMap:a,removedId:l}=Pe(r,e,t,n);let s=a;const d=a[e];if(d&&0===d.cells[t].childrenIds.length){const n=we(i("drag_block_here"));s={...a,[n.id]:n,[e]:{...d,cells:d.cells.map((e,o)=>o===t?{...e,childrenIds:[n.id]}:e)}}}l&&(s=$e(s,l)),u(s,c,"delete"),g(null)},R=e=>()=>{b(!0),g({id:e.id,data:e,type:"move"}),_("move")},$=e=>{e.preventDefault(),e.stopPropagation(),setTimeout(()=>{e.target.style.border="",e.target.children[0]&&e.target.children[0].classList.remove("sidebar-block-move"),b(!1),a&&a()},50)},B=e=>e.preventDefault(),D=e=>"desktop"===l?e.styles?.desktop||{}:{...e.styles?.desktop||{},...e.styles?.mobile||{}},E=e=>{const t=d?.[e];if(!t)return null;const n="error"===t.severity?`${t.errorCount} error${1===t.errorCount?"":"s"}`:`${t.warningCount} warning${1===t.warningCount?"":"s"}`,o=ue("div",{className:"block-validation-popover",children:t.issues.map((e,t)=>me("div",{className:"block-validation-popover-item",children:[ue("div",{className:"block-validation-popover-message",children:e.message}),ue(h,{size:"small",type:"text",className:"block-validation-popover-ignore",onClick:t=>{t.preventDefault(),t.stopPropagation(),p(e)},children:i("ignore")})]},`${e.code}-${t}`))});return ue(y,{trigger:["hover","click"],placement:"topRight",overlayClassName:"block-validation-popover-overlay",content:o,getPopupContainer:()=>document.querySelector("#preview")||document.body,children:me("button",{type:"button",className:Jn("block-validation-indicator","error"===t.severity?"block-validation-indicator-error":"block-validation-indicator-warning"),"aria-label":n,onClick:e=>{e.preventDefault(),e.stopPropagation()},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[ue("span",{className:"block-validation-indicator-dot"}),ue("span",{className:"block-validation-indicator-count",children:t.totalCount})]})})},U=(e,t,n,o,a,r,c=1)=>{const d=D({styles:e.styles}),{contentBackground:p,...u}=d,g=m?.id===e.id,y=((e=1)=>({"--nested-level":Math.max(1,e),"--nested-width":"100%"}))(c);return me(ge,{children:[me("div",{className:"relative block-content-drag-label-content","data-drop-key":a,children:[ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),I&&ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"})]}),ue("div",{className:Jn("block-item block-item-container",g&&"block-item-focus"),style:y,"data-block-id":e.id,onMouseEnter:e=>{e.currentTarget.dataset.hovered="true"},onMouseLeave:e=>{delete e.currentTarget.dataset.hovered},children:me("div",{className:"relative",children:[E(e.id),me("div",{className:"block-item-tools",onDragOver:B,onClick:A(e),children:[I&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":r,"data-type":"block-item-move"})]}),ue("span",{className:"absolute block-item-parent",onClick:L(t),title:"Select Parent",children:ue(C,{icon:j})}),ue("span",{className:"absolute block-item-delete",onClick:P(t,n,o),children:ue(C,{icon:M})}),ue("span",{className:"absolute block-item-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:R(e),children:ue(C,{icon:O})})]}),ue("div",{style:{...u,overflow:u.borderRadius?"hidden":void 0},children:ue("div",{className:"block-content block-item-container-body",style:{background:p,borderRadius:u.borderRadius},children:(e.children||[]).map((t,n)=>{const o=D(t);return ue("div",{style:{...o,width:"mobile"===l?"100%":t.width},children:(t.children||[]).map((o,a)=>{const l=`${e.id}:${n}:${a}`,r=`${e.id}:${n}:${a+1}`,d=a===t.children.length-1&&"empty"!==o.key&&"column"!==o.key;return me(s,{children:[H(o,e.id,n,a,l,r,c),d&&ue("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})})]},`${e.id}:${n}:${o.id||a}`)})},`${e.id}:${t.id||"cell"}:${n}`)})})})]})}),me("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:[ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),I&&ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":r,"data-type":"block-item-move"})]})]})},H=(e,t,n,o,a,l,r=0)=>"empty"===e.key?me("div",{className:"block-empty-content p-4 h-32 relative width-full",children:[I&&ue("div",{className:"block-empty-content-tools",onDragOver:B,"data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-type":"empty-block-item",children:i("drag_block_here")}),e.name]},e.id||o):"column"===e.key?ue(s,{children:U(e,t,n,o,a,l,r+1)},`${t}:${n}:${e.id||o}`):me(s,{children:[ue("div",{className:"relative block-content-drag-label-content","data-drop-key":a,children:ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})}),ue("div",{className:Jn("block-item",m?.id===e.id&&"block-item-focus"),"data-block-id":e.id,children:me("div",{className:"relative",children:[E(e.id),me("div",{className:"block-item-tools",onDragOver:B,onClick:t=>{t.preventDefault(),t.stopPropagation(),g({id:e.id,data:e,type:"edit"}),_("edit")},children:[I&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":l,"data-type":"block-item-move"})]}),ue("span",{className:"absolute block-item-parent",onClick:L(t),title:"Select Parent",children:ue(C,{icon:j})}),ue("span",{className:"absolute block-item-delete",onClick:P(t,n,o),children:ue(C,{icon:M})}),ue("span",{className:"absolute block-item-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:R(e),children:ue(C,{icon:O})})]}),ue(xo,{blockItem:e,id:e.id})]})})]},`${t}:${n}:${e.id||o}`);return ue(ge,{children:me("div",{className:"relative block-drag-label-content","data-index":o,"data-position":"top",children:[ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),me("div",{className:Jn("relative block",m?.id===t.id&&"block-focus","mobile"===l&&"mobile-block-focus"),"data-block-id":t.id,onClick:A(t),children:[me("div",{className:"hover-visible",children:[E(t.id),ue("span",{className:"absolute block-delete",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=$e(r,t.id),o=c.filter(e=>e!==t.id);u(n,o,"delete"),g(null)},children:ue(C,{icon:M})}),ue("span",{className:"absolute block-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:()=>{b(!0),g({id:t.id,data:t,type:"move"}),_("move")},children:ue(C,{icon:O})})]}),ue("div",{className:"width-full height-full absolute",onDragOver:B,style:{pointerEvents:f&&"column"===N?"auto":"none"},children:f&&"column"===N&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":o}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":o+1})]})}),ue("div",{className:"column margin-auto",style:{...w,maxWidth:"100%",overflow:w.borderRadius?"hidden":void 0},children:ue("div",{className:"block-content",style:{background:x,borderRadius:w.borderRadius,width:k.contentWidth},"data-index":o,children:t.children.map((e,n)=>{const a="desktop"===l?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}};return ue(s,{children:ue("div",{id:`block-content-${o}-${n}`,style:{...a,width:"mobile"===l?"100%":e.width},children:e.children.map((o,a)=>{const l=`${t.id}:${n}:${a}`,r=`${t.id}:${n}:${a+1}`,c=a===e.children.length-1&&"empty"!==o.key&&"column"!==o.key;return me(s,{children:[H(o,t.id,n,a,l,r,0),c&&ue("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})})]},`${t.id}:${n}:${o.id||a}`)})})},`${t.id}:${e.id||"content"}:${n}`)})})})]})]})})},So=()=>{const{previewMode:e,setPreviewMode:t,bodySettings:o,blockList:a,actionType:s,setBlockList:c,setBodySettings:d}=n(Ye),[p,u]=i({histories:[],index:0}),{histories:m,index:g}=p,y=l(null);r(()=>{const e=be(a),t=be(o),n=JSON.stringify({blockList:e,bodySettings:t});if(y.current!==n)return"firstRender"===s?(y.current=n,void u({histories:[{blockList:e,bodySettings:t}],index:0})):void(s.includes("set_history")?y.current=n:u(o=>{const a=o.histories.slice(0,o.index+1);return a.push({blockList:e,bodySettings:t}),y.current=n,{histories:a,index:o.index+1}}))},[a,o,s]);return me("div",{className:"header",children:[me("div",{className:"header-box",children:[ue(C,{onClick:()=>t("desktop"),icon:H,className:Jn("header-icon-small","desktop"===e&&"header-icon_active","desktop"!==e&&"header-icon_disabled")}),ue(C,{icon:K,onClick:()=>t("mobile"),className:Jn("header-icon-small","mobile"===e&&"header-icon_active","mobile"!==e&&"header-icon_disabled")})]}),ue("div",{className:"header-box text-center"}),me("div",{className:"header-box text-right",children:[ue(C,{onClick:()=>{if(m[g-1]){const e=be(m[g-1]);u({...p,index:g-1}),c(e.blockList,"set_history_"+(g-1)),d(e.bodySettings)}},icon:z,className:Jn("header-icon-history",m[g-1]&&"header-icon-history_active",!m[g-1]&&"header-icon-history_disabled")}),ue(C,{onClick:()=>{if(m[g+1]){const e=be(m[g+1]);u({...p,index:g+1}),c(e.blockList,`set_history_${g+1}`),d(e.bodySettings)}},icon:F,className:Jn("header-icon-history",m[g+1]&&"header-icon-history_active",!m[g+1]&&"header-icon-history_disabled")})]})]})},Co=e=>{const{clearStyles:t}=e,{t:o}=Yn(),{previewMode:a,bodySettings:i,blockList:c,setSelectionRange:d}=n(Ye),p=l(null);r(()=>{const e=fe(()=>{try{const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0),a=document.getElementById("preview");if(!(!!a&&(a.contains(o.commonAncestorContainer)||a===o.commonAncestorContainer)))return;const i=(e=>e?{startContainer:e.startContainer,startOffset:e.startOffset,endContainer:e.endContainer,endOffset:e.endOffset,collapsed:e.collapsed}:null)(o);if(e=p.current,t=i,e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset&&e.collapsed===t.collapsed)return;p.current=i,d(o.cloneRange())}catch(e){console.warn(e)}var e,t},100);return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[d]);return me("div",{className:"preview-main",children:[ue(So,{}),ue("div",{className:"default-scrollbar",id:"preview",children:ue("div",{className:"preview-content",style:{width:"desktop"===a?"100%":364,...i.styles},children:ue("div",{className:"margin-auto",style:{maxWidth:"100%",width:"100%"},children:c.length?me(ge,{children:[c.map((e,n)=>ue(s,{children:ue(wo,{block:e,blockIndex:n,clearStyles:t})},`${e?.id||"block"}-${n}`)),ue("div",{className:"relative block-drag-label-content","data-index":c.length,"data-position":"bottom",children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:o("drag_block_here")})})})]}):ue("div",{"data-name":"dragEmpty",className:"start-to-add",style:{width:i.contentWidth,maxWidth:"100%"},"data-type":"empty-block",onDragOver:e=>{e.preventDefault()},children:o("add_blocks")})})})})]})},No=({color:e,setColor:t})=>{const[n,o]=i(!1);return ue(y,{zIndex:1070,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,content:ue("div",{className:"select-none ee-color-picker-popover",children:ue(ye,{color:e,style:{boxShadow:"none"},onChange:t})}),trigger:"click",open:n,onOpenChange:o,children:ue("button",{className:"color-picker-button",style:{background:e}})})},To=({padding:e,setPadding:t})=>{const{t:n}=Yn();return ue("div",{className:"padding-settings",children:[{name:n("top"),value:"paddingTop"},{name:n("right"),value:"paddingRight"},{name:n("left"),value:"paddingLeft"},{name:n("bottom"),value:"paddingBottom"}].map(({name:n,value:o})=>{const a=e[o];return me("div",{children:[ue("div",{children:n}),ue(b,{className:"width-full",addonAfter:"px",min:0,value:a,onChange:(i=o,n=>{const o={...e,[i]:n};t(o)})})]},o);var i})})},Io=e=>{if(!e||"string"!=typeof e)return!1;try{const t=new URL(e);return/\/knowledge-base\/products$/i.test(t.pathname.replace(/\/$/,""))}catch{return/knowledge-base\/products\/?$/i.test(String(e).trim().replace(/\/$/,""))}},Ao=e=>{if(!e||"object"!=typeof e)return null;const t=null!=e.id?String(e.id):null!=e.resourceId?String(e.resourceId):"";if(!t)return null;const n=e.price,o="number"==typeof n?n:parseFloat(String(n??"").replace(/,/g,""));return{id:t,name:e.name??"",description:e.description??"",image:e.image_url??e.image??"",link:e.url??"",price:Number.isFinite(o)?o:0,currency:e.currency??"USD",old_price:null!=e.old_price?e.old_price:null,new_price:null!=e.new_price?e.new_price:null,resourceId:e.resourceId,source:e.source}},Lo=async(e,t,n={},{page:o=1,limit:a=20,search:i=""}={})=>{if(!e)return null;try{if(Io(e)){if(!t)return null;const l=e.replace(/\/$/,""),r=new URL(`${l}/${encodeURIComponent(t)}`);r.searchParams.set("page",String(o)),r.searchParams.set("limit",String(a)),r.searchParams.set("search",i??"");const s=await fetch(r.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!s.ok)return console.error("[API Service] KB products fetch failed:",s.status,s.statusText),null;const c=await s.json(),d=Array.isArray(c.data)?c.data:[];return{products:d.map(Ao).filter(Boolean),meta:c.meta&&"object"==typeof c.meta?c.meta:{}}}const l=new URL(e);t&&l.searchParams.append("companyId",t);const r=await fetch(l.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!r.ok)return console.error("[API Service] Products fetch failed:",r.status,r.statusText),null;const s=await r.json();if(!1===s.success)return console.error("[API Service] Products API returned error:",s.error),null;const c=s.data?.products??[];return Array.isArray(c)&&0!==c.length?{products:c,meta:{hasMore:!1,hasProducts:!0}}:{products:[],meta:{hasMore:!1,hasProducts:!1}}}catch(e){return console.error("[API Service] Error fetching products:",e),null}},Po={};function Ro(){return"undefined"!=typeof document?document.body:null}function $o(e){if(!e)return"";const t=e.currency??"",n=e.price?.amount??e.price??"";return`${e.name} — ${t} ${n}`.trim()}function Bo(e,t){const n=new Map;return[...e,...t].forEach(e=>{e&&e.id&&n.set(e.id,e)}),Array.from(n.values())}function Do({apiConfig:e,templateData:t,value:n,selectedProduct:r,onChange:s,placeholder:c,staticProductList:d=[],getPopupContainer:p}){const{t:u}=Yn(),m=e?.productsEndpoint,g=e?.companyId??t?.companyId,y=a(()=>{const t=e?.headers;return t&&"object"==typeof t?t:Po},[e?.headers]),h=Boolean(m&&g)&&Io(m),[b,_]=i([]),[v,x]=i({}),[w,S]=i(!1),[C,N]=i(""),[T,I]=i(""),A=l(null),L=l(0),P=l(1),R=l(""),$=l(!1),B=l(""),D=o(async(e,t,n)=>{if(!h)return;const o=(t??"").trim();if(n){const t=`${o}::${e}`;if($.current&&B.current===t)return;$.current=!0,B.current=t}const a=++L.current;S(!0);try{const i=await Lo(m,g,y,{page:e,limit:20,search:o});if(a!==L.current)return;if(!i)return n||(_([]),I((t??"").trim())),void x({});x(i.meta||{}),_(e=>n?Bo(e,i.products):i.products),P.current=e}finally{n&&($.current=!1,B.current=""),a===L.current&&S(!1)}},[h,m,g,y]),E=o(async e=>{if(!h)return;const t=(e??"").trim();$.current=!1,B.current="";const n=++L.current;S(!0);try{if(""!==t){const e=await Lo(m,g,y,{page:1,limit:20,search:t});if(n!==L.current)return;return e?(x(e.meta||{}),_(e.products),I(t),void(P.current=1)):(_([]),x({}),I(t),void(P.current=1))}let e=1,o=[],a={};for(;o.length<10&&e<=15;){const t=await Lo(m,g,y,{page:e,limit:20,search:""});if(n!==L.current)return;if(!t?.products?.length)break;if(o=Bo(o,t.products),a=t.meta||{},P.current=e,!a.hasMore)break;e+=1}x(a),_(o),I("")}finally{n===L.current&&S(!1)}},[h,m,g,y]),U=o(()=>{if(!h||w||!v?.hasMore)return;const e=P.current+1;D(e,R.current,!0)},[h,w,v?.hasMore,D]),M=p??Ro,O=o(e=>me("div",{children:[e,w&&b.length>0&&me("div",{className:"ee-kb-product-select-footer",children:[ue(f,{size:"small"})," ",ue("span",{children:u("loading")})]}),!w&&v?.hasMore&&ue("div",{className:"ee-kb-product-select-footer",children:ue("button",{type:"button",className:"ee-kb-product-select-load-more",onClick:U,children:u("load_more_products")})})]}),[w,b.length,v?.hasMore,U,u]),j=a(()=>{const e=h?b:d;return Bo(r?.id?[r]:[],e)},[h,b,d,r]),H=a(()=>j.map(e=>({value:e.id,label:$o(e)})),[j]),K=e=>{if(!e)return s(null),void(h&&(clearTimeout(A.current),N(""),R.current="",P.current=1,I(""),E("")));const t=j.find(t=>t.id===e)||d.find(t=>t.id===e);s(t||null)},z="ee-kb-product-select-dropdown";return ue(k,h?{className:"ee-stack-control ee-kb-product-select",value:n??void 0,placeholder:c,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:z,getPopupContainer:M,onChange:K,allowClear:!0,showSearch:!0,filterOption:!1,searchValue:C,onSearch:e=>{if(!h)return;const t=e??"";N(t);const n=t.trim();if(clearTimeout(A.current),""===n)return R.current="",P.current=1,void E("");A.current=setTimeout(()=>{R.current=n,P.current=1,E(n)},400)},onOpenChange:e=>{clearTimeout(A.current),e?($.current=!1,B.current="",N(""),R.current="",P.current=1,E("")):($.current=!1,B.current="",N(""),R.current="")},notFoundContent:w?me("span",{className:"ee-kb-product-select-loading",children:[ue(f,{size:"small"})," ",u("loading")]}):H.length>0?null:ue("span",{className:"ee-kb-product-select-empty",children:""!==T.trim()?u("no_products_matching_search"):u("no_product_found")}),options:H,dropdownRender:O}:{className:"ee-stack-control",value:n??void 0,placeholder:c,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:z,getPopupContainer:M,onChange:K,allowClear:!0,showSearch:!0,optionFilterProp:"label",options:d.map(e=>({value:e.id,label:$o(e)}))})}const Eo=()=>{const{previewMode:e,currentItem:t,blockMap:o,rootOrder:a,setBlocks:i,setCurrentItem:l}=n(Ye),r=e=>{let n;if("column"===e.key){const{blockMap:t}=Se([e]);n={...o,...t}}else n={...o,[t.id]:e};i(n,a,`edit_${(new Date).getTime()}`),l({...t,data:e})};return{findStyleItem:(t,n)=>{let o=t[e][n];return o||(o=t.desktop[n]),o},cardItemElement:(e,t)=>me("div",{className:"card-item",children:[ue("div",{className:"card-item-title",children:e}),ue("div",{children:t})]}),updateItemStyles:r,colorChange:n=>({hex:o})=>{const a=be(t.data);a.styles[e][n]=o,r(a)},paddingChange:n=>{const o=be(t.data);o.styles[e]={...o.styles[e],...n},r(o)},otherStylesChange:(n,o)=>{const a=be(t.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[e]||(a.styles[e]={}),a.styles[e][n]=o,"desktop"!==e&&(a.styles.desktop[n]=o),r(a)},inputChange:n=>o=>{const a=be(t.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[e]||(a.styles[e]={}),a.styles[e][n]=o,"desktop"!==e&&(a.styles.desktop[n]=o),r(a)}}},Uo=()=>{const{t:e}=Yn(),t=(e=>[{id:_e(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},children:[{id:_e(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}},children:[{id:_e(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}]}]},{id:_e(),name:e("text"),key:"text",text:e("text_content"),type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:void 0,lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{id:_e(),name:e("button"),key:"button",text:e("button"),type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12},mobile:{}},styles:{desktop:{width:"auto",fontSize:12,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:void 0,color:"#fff",display:"inline-block"},mobile:{}}},{id:_e(),name:e("spacer"),key:"spacer",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{height:16,width:"100%",display:"block"},mobile:{}}},{id:_e(),name:e("divider"),key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{id:_e(),name:e("image"),key:"image",src:"",alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{id:_e(),name:e("menu"),key:"menu",list:[{label:"Page",url:"",target:"_self"},{label:"Page",url:"",target:"_self"}],separator:" | ",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:"#333333",linkColor:"#2faade",paddingTop:5,paddingBottom:5,paddingLeft:15,paddingRight:15,textAlign:"center",letterSpacing:0,fontWeight:"normal"},mobile:{}}},{id:_e(),name:e("avatar"),key:"avatar",src:"",alt:"Avatar",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:64,borderRadius:"50%",display:"block"},mobile:{}}},{id:_e(),name:e("social_link"),key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:""},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:""},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:""},{image:"https://s.magecdn.com/social/tc-x.svg",title:"Twitter",linkURL:""}],imageWidth:32,contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}}}])(e),n=(e=>{const t={desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12},mobile:{}},n={key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}};return{full:{columns:1,type:"full",children:[{name:e("content"),key:"content",width:"100%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}]},"1-1":{columns:2,type:"1-1",children:Array.from({length:2}).map(()=>({name:e("content"),key:"content",width:"50%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1":{columns:3,type:"1-1-1",children:Array.from({length:3}).map(()=>({name:e("content"),key:"content",width:"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1-1":{columns:4,type:"1-1-1-1",children:Array.from({length:4}).map(()=>({name:e("content"),key:"content",width:"25%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2":{columns:2,type:"1-2",children:Array.from({length:2}).map((o,a)=>({name:e("content"),key:"content",width:0===a?"33.3%":"66.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"2-1":{columns:2,type:"2-1",children:Array.from({length:2}).map((o,a)=>({name:e("content"),key:"content",width:0===a?"66.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"2-4-2-4":{columns:4,type:"2-4-2-4",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"16.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"4-2-4-2":{columns:4,type:"4-2-4-2",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"33.3%":"16.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))}}})(e),o=(e=>t=>{const n={id:_e(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}};return{id:_e(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:[{id:_e(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}},children:[t||n]}]}})(e);return{blockConfigsList:t,columnsSetting:n,getColumnConfig:o}},Mo=[{id:"dolor-sit-amet",name:"Dolor Sit Amet",description:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",image:"https://plus.unsplash.com/premium_photo-1681711647066-ef84575c0d95?fm=jpg&q=30&w=300&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cHJvZHVjdCUyMHBob3RvZ3JhcGh5fGVufDB8fDB8fHww",link:"https://loremipsum.com/checkout/cart/12345",price:2e3,currency:"USD",old_price:2500,new_price:2e3},{id:"sample-2",name:"Sample Pearl Necklace",description:"Classic strand of lustrous freshwater pearls with a sterling silver clasp. Timeless elegance for any outfit.",image:"https://picsum.photos/seed/necklace2/200/200",link:"https://www.example.com/products/sample-2",price:750,currency:"USD",old_price:null,new_price:null},{id:"sample-3",name:"Sample Gold Bracelet",description:"Handcrafted 14K yellow gold link bracelet. Lightweight and comfortable for everyday wear.",image:"https://picsum.photos/seed/bracelet3/200/200",link:"https://www.example.com/products/sample-3",price:450,currency:"USD",old_price:500,new_price:450},{id:"sample-4",name:"Sample Silver Earrings",description:"Delicate sterling silver drop earrings with subtle sparkle. A versatile addition to your jewelry collection.",image:"https://picsum.photos/seed/earrings4/200/200",link:"https://www.example.com/products/sample-4",price:199,currency:"USD",old_price:null,new_price:null},{id:"sample-5",name:"Sample Gemstone Pendant",description:"Stunning pendant with a natural gemstone centerpiece on a fine silver chain. Makes a memorable gift.",image:"https://picsum.photos/seed/pendant5/200/200",link:"https://www.example.com/products/sample-5",price:320,currency:"USD",old_price:400,new_price:320}],Oo=["product"],jo=e=>"discount"===e||"none"===e?e:"product",Ho=e=>"additional"===e?"additional":"main",Ko=()=>{const{blockMap:e,rootOrder:t,setBlocks:o,currentItem:l,setCurrentItem:r,previewMode:s,bodySettings:c,templateData:d,setIsDragStart:p,setActionType:u,apiConfig:g}=n(Ye),{t:y}=Yn(),[h,f]=i(!1),[x,w]=i(null),[S,N]=i(!1),{findStyleItem:T,cardItemElement:I,colorChange:A,inputChange:L,paddingChange:P}=Eo(),{columnsSetting:R,blockConfigsList:$}=Uo(),B=jo(l.data.containerType??"none"),D=l.data.productRole??"main",E=l.data.columnProducts,U=a(()=>Array.isArray(E)?E:[],[E]),M=d?.content?.products?.length>0?d.content.products:d?.catalogProducts?.length>0?d.catalogProducts:Mo,O=d?.content?.primaryProductId,j=n=>{const{blockMap:a}=Se([n]);let i={...e,...a};const s=Ho(n.productRole);"product"===n.containerType&&"main"===s&&Object.keys(i).forEach(e=>{if(e===n.id)return;const t=i[e];if(!t||"column"!==t.key)return;if("product"!==t.containerType)return;"main"===Ho(t.productRole)&&(i[e]={...t,productRole:"additional"})}),o(i,t,`edit_${(new Date).getTime()}`),r({...l,data:n})},H=e=>{const t=jo(l.data.containerType),n=e.children,o=n.length,a=l.data.children?.length??0,i=l.data.columnProducts??[],r=Array.from({length:o},(e,t)=>t<a?i[t]??null:null);return{...l.data,...e,containerType:t,columnProducts:r,children:n.map((e,t)=>{let n=e;if(l.data.children?.[t]){const o=l.data.children[t];n={...o,key:e.key,name:e.name,width:e.width,styles:be(e.styles??o.styles),children:o.children}}return{...n}})}},K=e=>{if(G)return;const t=be(l.data);t.containerType=jo(e);const n=t.containerType,o=Oo.includes(n);t.productRole=o?t.productRole??"main":void 0;const a=t.children?.length??0;let i=o?Array.from({length:a},(e,n)=>t.columnProducts?.[n]??null):[];if(o&&a>0&&M.length>0){const e=O?M.find(e=>e.id===O):M[0];e&&(i[0]=e)}t.columnProducts=i,j(t)},z=e=>{const t=be(l.data);t.productRole=Ho(e);const n=t.children?.length??0;let o=Array.from({length:n},(e,n)=>t.columnProducts?.[n]??null);if(n>0&&M.length>0){const e=O?M.find(e=>e.id===O):M[0];e&&!o[0]&&(o[0]=e)}t.columnProducts=o,j(t)},F=Oo.includes(B),W=a(()=>to(l.data,e),[l.data,e]),J=a(()=>Ie(e,t,l.data?.id),[e,t,l.data?.id]),q=a(()=>(J||[]).filter(e=>e?.containerBlock&&e.containerBlock.id!==l.data?.id&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[J,l.data?.id]),G=a(()=>(J||[]).some(e=>e?.containerBlock&&e.containerBlock.id!==l.data?.id&&"none"!==e.containerType),[J,l.data?.id]),Y=Qt(0,B,d,{},q).filter(({variableKey:e,key:t})=>!("product"===B)||(e??t)!==wt).filter(({variableKey:e,key:t})=>!W.has(e??t)),Z=a(()=>{const e={columnIndex:0,columnProduct:U[0]??null};return tn(B,d,e).filter(e=>e.variableKey&&!W.has(e.variableKey))},[B,d,U,W]),Q=a(()=>{const e=new Set(Y.map(e=>e.variableKey??e.key)),t=Z.filter(t=>{const n=t.variableKey;return!(!n||e.has(n))&&(e.add(n),!0)});return[...Y,...t]},[Y,Z]),X=e=>t=>{const n=(e=>{const{value:t,type:n}=e;if("image"===n){const e=be($.find(e=>"image"===e.key));return e?(e.src=t,e):{name:y("image"),key:"image",src:t,alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}}const o=be($.find(e=>"text"===e.key));return o?(o.text=`<p>${t}</p>`,o.type="p",o.contentType="static",o):{name:y("text"),key:"text",text:`<p>${t}</p>`,type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}}})(e);"undefined"!=typeof window&&(window.__eeDragItemData=n,window.__eeDragSource="product-variables"),p(!0),u("add"),t.target.classList.add("ee-product-variable-item-dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="copy")},ee=e=>{e.target.classList.remove("ee-product-variable-item-dragging"),"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null),setTimeout(()=>{p(!1)},50)},te=[{key:"full",widths:["100%"],columns:1},{key:"1-1",widths:["50%","50%"],columns:2},{key:"1-1-1",widths:["33.33%","33.33%","33.33%"],columns:3},{key:"1-1-1-1",widths:["25%","25%","25%","25%"],columns:4}],ne="product"===B?te.filter(e=>1===e.columns):te,oe=e=>t=>{const n=be(l.data);n.children[e].styles[s]={...n.children[e].styles[s],...t},j(n)},ae=e=>{if("number"==typeof e)return e;if("string"!=typeof e)return;const t=Number.parseFloat(e);if(!Number.isNaN(t)){if(e.endsWith("%")){const e=Number(c?.contentWidth)||600;return Math.round(e*t/100)}return Math.round(t)}},ie=e=>t=>{if(null==t||Number.isNaN(Number(t)))return;const n=Math.max(1,Math.round(Number(t))),o=be(l.data);o.children[e].width=`${n}px`,j(o)};return me(ge,{children:[me("div",{className:"margin-y-30",children:[me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:y("container_settings")}),me("div",{className:"ee-right-panel-stack",children:[me("span",{className:"ee-stack-label",children:[y("container_type"),ue(_,{title:y("tooltip_container_type"),children:ue("span",{className:"ee-help-icon","aria-label":"Help",children:ue(C,{icon:V})})})]}),ue(k,{className:"ee-stack-control",value:B,onChange:K,disabled:G,style:{width:"100%"},options:et.map(({value:e,labelKey:t})=>({value:e,label:y(t)})),getPopupContainer:()=>document.querySelector(".right-settings")||document.body}),F&&me("div",{className:"ee-product-assign-section margin-top-12",children:[ue("span",{className:"ee-stack-label",children:y("product_role")}),ue(k,{className:"ee-stack-control",value:D,style:{width:"100%"},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,onChange:z,options:[{value:"main",label:y("product_role_main_hero")},{value:"additional",label:y("product_role_additional")}]})]}),F&&me("div",{className:"ee-product-assign-section margin-top-12",children:[ue("span",{className:"ee-stack-label",children:y("assign_product_to_column")}),ue(Do,{apiConfig:g,templateData:d,value:U[0]?.id??void 0,selectedProduct:U[0],onChange:e=>((e,t)=>{const n=be(l.data),o=[...n.columnProducts??[]];o[e]=t,n.columnProducts=o,j(n)})(0,e),placeholder:y("assign_product_to_column"),staticProductList:M})]}),me("div",{className:"ee-product-variables-section margin-top-12",children:[me("button",{type:"button",className:"ee-product-variables-toggle",onClick:()=>N(e=>!e),children:[ue("span",{children:y("variables")}),ue("span",{className:"ee-product-variables-toggle-icon",children:S?"▴":"▾"})]}),S&&ue("div",{className:"ee-product-variables-dropdown",children:Q.length>0?Q.map(e=>me("div",{className:"ee-product-variable-item",draggable:!0,onDragStart:X(e),onDragEnd:ee,title:e.value,children:[ue("span",{className:"ee-product-variable-item-label",children:e.labelKey?y(e.labelKey):e.label}),ue("span",{className:"ee-product-variable-item-token",children:e.value})]},e.value)):ue("div",{className:"ee-stack-help",children:"No variables available for this container type."})})]})]})]}),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("columns")]}),ue("div",{children:ne.map((e,t)=>{return ue("div",{className:Jn(l.data.type===e.key?"column-item-active":"column-item-un_active","column-item"),onClick:(n=e.key,()=>{if(l.data.children.length>R[n].children.length)return f(!0),void w(n);const e=H(R[n]);j(e)}),children:e.widths.map((t,n)=>{const o=n===e.widths.length-1;return ue("span",{style:{width:t},className:Jn(o?"":"column-item-border-right",l.data.type===e.key?"column-item-active":"column-item-un_active","height-full")},n)})},t);var n})})]}),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("column_settings")]}),ue(v,{defaultActiveKey:"1",animated:{inkBar:!0,tabPane:!0},items:l.data.children.map((e,t)=>{const n=t+1,o=T(e.styles,"backgroundColor");return{label:`${y("column")} ${n}`,key:n,children:me(ge,{children:[I(y("content_background_color"),ue(No,{color:o,setColor:({hex:e})=>((e,t)=>n=>{const o=be(l.data);o.children[t].styles[s][e]=n,j(o)})("backgroundColor",t)(e)})),I(y("size_px"),ue(b,{min:1,className:"input-width",addonAfter:"px",value:ae(e.width),onChange:ie(t)})),ue(To,{padding:{paddingTop:T(e.styles,"paddingTop"),paddingRight:T(e.styles,"paddingRight"),paddingLeft:T(e.styles,"paddingLeft"),paddingBottom:T(e.styles,"paddingBottom")},setPadding:oe(t)})]})}})})]}),(()=>{const e=T(l.data.styles,"backgroundColor"),t=T(l.data.styles,"contentBackground"),n=T(l.data.styles,"borderRadius"),o="number"==typeof n?n:parseInt(String(n||"").replace("px",""),10)||0;return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("column_styles")]}),I(y("background_color"),ue(No,{color:e,setColor:A("backgroundColor")})),I(y("content_background_color"),ue(No,{color:t,setColor:A("contentBackground")})),I(y("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:o,onChange:e=>L("borderRadius")(Number(e)||0)})),ue(To,{padding:{paddingTop:T(l.data.styles,"paddingTop"),paddingRight:T(l.data.styles,"paddingRight"),paddingLeft:T(l.data.styles,"paddingLeft"),paddingBottom:T(l.data.styles,"paddingBottom")},setPadding:P})]})})()]}),ue(m,{title:y("column_delete"),open:h,onOk:()=>{const e=H(R[x]);j(e),f(!1),w(null)},onCancel:()=>{f(!1)},width:400,okText:y("confirm"),cancelText:y("cancel"),wrapClassName:"ee-modal-dark",children:ue("p",{className:"margin-y-30",dangerouslySetInnerHTML:{__html:y("column_delete_desc",{count:`<span class="column-modal-context">\n ${x?l.data.children.length-R[x].children.length:0}\n </span>`})}})})]})},zo=({mlEmailNodesEndpoint:e,mlGenerationEndpoint:t,headers:n={},templateData:a,blockId:i,containerType:l,containerId:r,productId:s,blockName:c="Text",blockElementType:d="p",emailTemplateId:p,companyId:u,language:m="en"}={})=>{const g=!!(e&&String(p??"").trim()&&String(u??"").trim()&&i&&r),y=!!t,h=g||y;return{generateOptions:o(async(o,h,b={})=>{const{previousPrompt:f="",previousSelectedAiContent:k=""}=b,_=function(e,t={}){const{containerType:n}=t,o=String(e??"").trim();let a;return a=Xt[o]?Xt[o]:o?o.split(/[-_]/).map(e=>e.length?e[0].toUpperCase()+e.slice(1).toLowerCase():"").join(""):"DisplayText",a||(a="DisplayText"),"product"===n&&"DisplayText"===a?"ProductDescription":a}(o,{containerType:l});if(g){const t={containerType:l||"none",id:r};if("product"===(l||"")&&null!=s){const e=String(s).trim();e&&(t.productId=e)}const o={blockContext:{blockId:i,name:c,type:d||"p"},companyId:u,containerContext:t,emailTemplateId:p,language:m||"en",promptContext:{newPrompt:h||"",previousPrompt:f||"",previousSelectedAiContent:k||""},type:_},a=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] generate-email-nodes: no endpoint"),{success:!1,error:"ML endpoint is not configured."};try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});let a={};try{a=await o.json()}catch{a={}}if(!o.ok||!1===a.success){let e="";const t=a.error;if(t&&"object"==typeof t){const n=null!=t.code?String(t.code):"",o=null!=t.message?String(t.message):"";e=[n,o].filter(Boolean).join(" — ")||o||n}return e||(e=null!=a.message?String(a.message):`${o.status} ${o.statusText}`),console.error("[API Service] generate-email-nodes failed:",e),{success:!1,error:String(e),errorCode:t&&"object"==typeof t&&null!=t.code?String(t.code):void 0}}const i=Array.isArray(a.variations)?a.variations:[],l=i.map(e=>e&&"string"==typeof e.value?e.value.trim():"").filter(Boolean);return 0===l.length?(console.error("[API Service] generate-email-nodes: empty variations"),{success:!1,error:"No variations were returned for this request."}):{success:!0,options:l,variations:i,emailJson:"string"==typeof a.emailJson?a.emailJson:void 0,blockId:a.blockId,emailTemplateId:a.emailTemplateId}}catch(e){return console.error("[API Service] Error calling generate-email-nodes:",e),{success:!1,error:e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to reach the ML service. Check your network and try again."}}})(e,o,n);if(a&&a.success&&a.options?.length)return a.options;return{error:a&&"object"==typeof a&&a.error?String(a.error):"No response from the ML service."}}if(y){const e={variable:_,prompt:h,context:{templateData:a,blockId:i,containerType:l}},o=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] ML endpoint not configured"),null;try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});if(!o.ok)return console.error("[API Service] ML endpoint failed:",o.status,o.statusText),null;const a=await o.json();if(!a.success)return console.error("[API Service] ML API returned error:",a.error),null;const i=a.data?.options??[];return Array.isArray(i)&&0!==i.length?i:(console.error("[API Service] ML API returned empty options"),null)}catch(e){return console.error("[API Service] Error calling ML endpoint:",e),null}})(t,e,n);return o&&o.length?o:{error:"The legacy ML endpoint did not return any options. Check the API response."}}return{i18nKey:"ml_ai_unavailable"}},[g,y,e,t,n,a,i,l,r,s,c,d,p,u,m]),isConfigured:h}};function Fo(){const{blockMap:e,rootOrder:t,currentItem:o}=n(Ye);return a(()=>{if(!e||!o?.id)return{containerBlock:null,containerType:"none",columnIndex:0,cellIndex:0};const{containerBlock:n,containerType:a,cellIndex:i,isRoot:l,rootIndex:r}=function(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}}const a=Te(e,t,n);if(!a)return{containerBlock:null,containerType:"none",cellIndex:0,isRoot:!1};const i=e[a.containerId];return{containerBlock:i??null,containerType:i?.containerType??"none",cellIndex:a.cellIndex,isRoot:!1}}(e,t,o.id);let s=0;if(l)s=r??0;else if(n){const e=t.indexOf(n.id);s=e>=0?e:0}const c=i??0;return{containerBlock:n??null,containerType:a??"none",columnIndex:s,cellIndex:c,contentIndex:c}},[e,t,o?.id])}const{TextArea:Vo}=g;const Wo=()=>{const{currentItem:e,previewMode:t,templateData:o,apiConfig:a,language:l,aiEnabled:r=!0}=n(Ye),{t:s}=Yn(),{findStyleItem:c,cardItemElement:d,paddingChange:p,otherStylesChange:u,inputChange:m,updateItemStyles:g}=Eo(),{containerBlock:y,containerType:f,cellIndex:v}=Fo(),w="product"===f?y?.columnProducts?.[v??0]?.id:void 0,{generateOptions:S}=zo({mlEmailNodesEndpoint:a?.mlEmailNodesEndpoint,mlGenerationEndpoint:a?.mlGenerationEndpoint,headers:a?.headers||{},templateData:o,blockId:e?.id,containerType:f,containerId:y?.id,productId:w,blockName:e?.data?.name||"Text",blockElementType:e?.data?.type||"p",emailTemplateId:a?.emailTemplateId,companyId:a?.companyId??o?.companyId,language:l||"en"}),[N,T]=i(""),I=(n,o)=>{const a=be(e.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles.desktop||(a.styles.desktop={}),a.styles.mobile||(a.styles.mobile={}),a.styles.desktop[n]=o,a.styles[t][n]=o,a.text=ke(a.text,a.styles.desktop),g(a)},[A,L]=i([]),[P,R]=i(!1),[$,B]=i(""),D=e.data.contentType??"dynamic",E=e.data.type||"p",U=t=>{if(!r)return;const n=t?"dynamic":"static",o=be(e.data);o.contentType=n,"dynamic"===n&&(o.selectedVariableKey=void 0,o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[]),g(o)},M=async()=>{const t=e.data.dynamicVariable??"",n=e.data.dynamicPrompt??N??"";R(!0),B("");try{const a=await S(t,n,{previousPrompt:e.data.dynamicPreviousPrompt??"",previousSelectedAiContent:(o=e.data.dynamicSelectedContent||e.data.text,null==o||"string"!=typeof o?"":o.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())});if(a&&"object"==typeof a&&!Array.isArray(a))return a.i18nKey?B(s(a.i18nKey)):a.error?B(String(a.error)):B(s("ml_no_variations")),void L([]);if(Array.isArray(a)&&a.length>0){B(""),L(a);const t=be(e.data);t.dynamicOptions=a,t.dynamicPrompt=n,t.dynamicPreviousPrompt=n,g(t)}else B(s("ml_no_variations")),L([])}catch(e){console.error("[TextStyleSettings] Error during content generation:",e),B(e&&"object"==typeof e&&"message"in e?String(e.message):s("ml_generation_unexpected_error")),L([])}finally{R(!1)}var o},O=t=>{const n=t.target.value;T(n),B("");const o=be(e.data);o.dynamicPrompt=n,g(o)};return me("div",{className:"margin-y-30",children:[me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("text_and_content_type")}),me("div",{className:"ee-content-type-two-rows margin-bottom-12",children:[r&&me("div",{className:"ee-content-type-row ee-content-type-row-1",children:[ue("span",{className:"ee-ai-label",children:s("ai_enabled")}),ue(x,{checked:"dynamic"===D,onChange:U})]}),ue("div",{className:"ee-content-type-row ee-content-type-row-2",children:[{name:s("body_paragraph"),value:"p"},{name:s("heading_h1"),value:"h1"},{name:s("heading_h2"),value:"h2"},{name:s("heading_h3"),value:"h3"},{name:s("heading_h4"),value:"h4"}].map(({name:t,value:n})=>{return ue("div",{className:Jn(E===n?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:(o=n,()=>{let t=e.data.styles.desktop.fontSize;switch(o){case"h1":t=22;break;case"h2":t=20;break;case"h3":t=18;break;case"h4":t=16;break;default:t=t||14}const n=be(e.data);n.type=o,n.styles={...n.styles,desktop:{...n.styles.desktop,fontSize:t,fontWeight:"p"!==o?"bold":n.styles.desktop.fontWeight}},n.text=ke(n.text,n.styles.desktop),g(n)}),children:t},n);var o})})]}),r&&"dynamic"===D&&me(ge,{children:[me("div",{className:"ee-dynamic-prompt-block",children:[me("span",{className:"ee-prompt-label",children:[s("dynamic_prompt_help"),ue(_,{title:s("tooltip_dynamic_prompt"),children:ue("span",{className:"ee-help-icon","aria-label":"Help",children:ue(C,{icon:V})})})]}),ue(Vo,{rows:3,value:e.data.dynamicPrompt??N,onChange:O,placeholder:s("dynamic_prompt_help")}),ue(h,{type:"primary",size:"small",loading:P,disabled:!(e.data.dynamicPrompt??N??"").trim(),onClick:M,children:s("generate")}),$?ue("div",{className:"ee-ml-generation-error",role:"alert",children:$}):null]}),(e.data.dynamicOptions?.length>0||A.length>0)&&me("div",{className:"ee-sample-content-block",children:[ue("div",{className:"card-item-title",children:s("select_content")}),(e.data.dynamicOptions||A).map((t,n)=>{const o="string"==typeof t?t:String(t),a=(e.data.text||e.data.dynamicSelectedContent||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),i=o.replace(/\s+/g," ").trim(),l=a.length>0&&a===i;return ue("div",{className:Jn("ee-sample-content-item",l&&"ee-sample-content-item-selected"),onClick:()=>(t=>{const n=be(e.data);n.dynamicSelectedContent=t,n.text=t,g(n),L([]),B("")})(t),children:t},n)})]})]})]}),(()=>{const n=c(e.data.styles,"color"),o=c(e.data.styles,"linkColor"),a=c(e.data.styles,"textAlign"),i=c(e.data.styles,"fontFamily"),l=c(e.data.styles,"fontSize"),r=null!=l&&""!==l?Number(l):14,p=c(e.data.styles,"lineHeight"),y=null!=p&&""!==p&&Number(String(p).replace(/%/g,""))||120;return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("text_styles")}),d(s("font_color"),ue(No,{color:n,setColor:({hex:e})=>I("color",e)})),d(s("link_color"),ue(No,{color:o||n||"#2faade",setColor:({hex:n})=>((n,o)=>{const a=be(e.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles.desktop||(a.styles.desktop={}),a.styles.mobile||(a.styles.mobile={}),a.styles.desktop[n]=o,a.styles[t][n]=o,g(a)})("linkColor",n)})),d(s("text_align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:e,value:t})=>ue("div",{className:Jn(a===t?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>u("textAlign",t),children:ue(C,{icon:e,className:"tag-style-size"})},t))})),d(s("font_family"),ue(k,{className:"input-width",value:i,onChange:e=>I("fontFamily",e),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Garamond","Georgia","Courier New","cursive"].map(e=>ue(k.Option,{value:e,children:e},e))})),d(s("font_size"),ue(b,{min:1,max:999,className:"input-width",addonAfter:"px",value:r,onChange:e=>I("fontSize",null!=e&&""!==e?Number(e):14)})),d(s("line_height"),ue(b,{className:"input-width",addonAfter:"%",min:1,max:999,value:y,onChange:e=>m("lineHeight")(null!=e&&""!==e?`${e}%`:"120%")}))]})})(),me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("padding_settings")}),ue(To,{padding:{paddingTop:c(e.data.styles,"paddingTop"),paddingRight:c(e.data.styles,"paddingRight"),paddingLeft:c(e.data.styles,"paddingLeft"),paddingBottom:c(e.data.styles,"paddingBottom")},setPadding:p})]})]})},Jo=()=>{const{currentItem:e,previewMode:t,templateData:o,blockList:a}=n(Ye),{t:i}=Yn(),{containerType:l,columnIndex:r,contentIndex:s}=Fo(),c=["header","footer","discount"].includes(l),{findStyleItem:d,cardItemElement:p,colorChange:u,paddingChange:m,inputChange:y,updateItemStyles:h}=Eo(),{labelOptions:f,urlOptions:_}=function(e,t){return{labelOptions:Gt.map(({variableKey:e,labelKey:n})=>({value:Tt(e),labelKey:n,pasteValue:Wt(t,e,{})})),urlOptions:Yt.map(({variableKey:e,labelKey:n})=>({value:Tt(e),labelKey:n,pasteValue:Wt(t,e,{})}))}}(0,o);return me("div",{className:"margin-y-30",children:[(()=>{const{linkURL:t,text:n,labelVariable:l,urlVariable:d}=e.data,u=n?.replace(/<[^>]+>/g,"").trim()??"",m=l||u&&/\{\{\w+\}\}/.test(u),y=l?l.replace(/^\{\{|\}\}$/g,"").trim():u.match(/\{\{(\w+)\}\}/)?.[1]||"CTALabel",b={columnIndex:s,columnProduct:a?.[r]?.columnProducts?.[s]??null},v=o&&m?Wt(o,y,b):null,x=null==v||String(v).startsWith("{{")?u:v,w=d?d.replace(/^\{\{|\}\}$/g,"").trim():"",S=!t&&w&&o?Wt(o,w,b):null,C=t||(null==S||"string"!=typeof S||S.startsWith("{{")?"":String(S).replace(/^https?:\/\//,"").trim())||"";return me("div",{children:[ue("div",{className:"right-setting-block-item-title",children:i("button_action")}),c&&f.length>0&&ue(ge,{children:p(i("button_label_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:i("button_label_manual"),allowClear:!0,value:l||void 0,onChange:t=>{const n=be(e.data);if(!t)return n.labelVariable="",n.text=n.text||"",void h(n);const o=f.find(e=>e.value===t);n.labelVariable=t,n.text=o?o.pasteValue:t,h(n)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:i("button_label_manual")},...f.map(e=>({value:e.value,label:i(e.labelKey)}))]}))}),ue("div",{className:"card-item-title",children:i("button_text")}),ue("div",{className:"margin-top-6",children:ue(g,{value:x,onChange:t=>{const n=t.target.value,o=be(e.data);o.text=n,n&&n.startsWith("{{")||(o.labelVariable=""),h(o)},placeholder:i("button_label_manual")})}),ue("div",{className:"ee-button-action-divider"}),p(i("action_type"),ue("div",{className:"link-tag",children:i("link")})),c&&_.length>0&&ue(ge,{children:p(i("button_url_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:i("button_url_manual"),allowClear:!0,value:d||void 0,onChange:t=>{const n=be(e.data);if(!t)return n.urlVariable="",n.linkURL=n.linkURL||"",void h(n);const o=_.find(e=>e.value===t);n.urlVariable=t;const a=o?o.pasteValue:t;n.linkURL="string"==typeof a?a.replace(/^https?:\/\//,""):"",h(n)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:i("button_url_manual")},..._.map(e=>({value:e.value,label:i(e.labelKey)}))]}))}),ue("div",{className:"card-item-title",children:i("link_url")}),ue("div",{className:"margin-top-6",children:ue(g,{addonBefore:"https://",value:C,onChange:t=>{const n=t.target.value,o=be(e.data);o.linkURL=n,n&&n.startsWith("{{")||(o.urlVariable=""),h(o)}})})]})})(),(()=>{const n=d(e.data.styles,"width"),a=d(e.data.styles,"borderRadius"),l="number"==typeof a?a:parseInt(String(a||"").replace("px",""),10)||0,r=e.data.contentStyles?.[t]?.textAlign??"center",s=d(e.data.styles,"color"),c=d(e.data.styles,"fontFamily"),g=d(e.data.styles,"fontSize"),f=d(e.data.styles,"lineHeight"),_=d(e.data.styles,"backgroundColor")??(e=>e?.brandContext?.brand_color??"#111111")(o);return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:i("button_styles")}),p(i("width_auto"),ue(x,{checked:"auto"===n,className:Jn("auto"===n?"switch-active":"switch-disabled"),onChange:()=>{const e="auto"===n?"100%":"auto";y("width")(e)}})),"auto"!==n&&ue(w,{value:Number(n.replace("%","")),onChange:e=>y("width")(e+"%")}),"auto"!==n&&p(i("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"}].map(({icon:n,value:o})=>ue("div",{className:Jn(r===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>{const n=be(e.data);n.styles={...n.styles||{},[t]:{...n.styles?.[t]||{},textAlign:"center"}},n.contentStyles={...n.contentStyles||{},[t]:{...n.contentStyles?.[t]||{},textAlign:o}},h(n)},children:ue(C,{icon:n,className:"tag-style-size"})},o))})),p(i("font_color"),ue(No,{color:s,setColor:u("color")})),p(i("button_color"),ue(No,{color:_,setColor:u("backgroundColor")})),p(i("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:l,onChange:e=>y("borderRadius")(Number(e)||0)})),p(i("font_family"),ue(k,{className:"input-width",value:c,onChange:y("fontFamily"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Garamond","Georgia","Courier New","cursive"].map(e=>ue(k.Option,{value:e,children:e},e))})),p(i("font_size"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:g,onChange:y("fontSize")})),p(i("line_height"),ue(b,{className:"input-width",addonAfter:"%",min:0,value:Number(f.replace("%","")),onChange:e=>y("lineHeight")(e+"%")})),ue("div",{className:"card-item-title",children:i("button_padding")}),ue(To,{padding:{paddingTop:d(e.data.styles,"paddingTop"),paddingRight:d(e.data.styles,"paddingRight"),paddingLeft:d(e.data.styles,"paddingLeft"),paddingBottom:d(e.data.styles,"paddingBottom")},setPadding:m})]})})(),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",i("padding_settings")]}),ue(To,{padding:{paddingTop:d(e.data.contentStyles,"paddingTop"),paddingRight:d(e.data.contentStyles,"paddingRight"),paddingLeft:d(e.data.contentStyles,"paddingLeft"),paddingBottom:d(e.data.contentStyles,"paddingBottom")},setPadding:n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},h(o)}})]})]})},qo=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:o}=Yn(),{findStyleItem:a,cardItemElement:i,colorChange:l,updateItemStyles:r,inputChange:s}=Eo(),c=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},r(o)};return ue("div",{className:"margin-y-30",children:(()=>{const n=a(e.data.contentStyles,"textAlign"),d=a(e.data.styles,"width"),p=a(e.data.styles,"borderTopColor"),u=a(e.data.styles,"borderTopWidth"),m=a(e.data.styles,"borderTopStyle"),g=[{label:o("solid"),value:"solid"},{label:o("dotted"),value:"dotted"},{label:o("dashed"),value:"dashed"}];return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",o("divider_styles")]}),i(o("divider_type"),ue(k,{className:"input-width",value:m,onChange:s("borderTopStyle"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:g.map(e=>ue(k.Option,{value:e.value,children:e.label},e.value))})),i(o("height"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:u,onChange:s("borderTopWidth")})),i(o("divider_color"),ue(No,{color:p,setColor:l("borderTopColor")})),ue("div",{className:"card-item-title",children:o("width")}),ue(w,{value:Number(d.replace("%","")),onChange:e=>s("width")(e+"%")}),i(o("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:o,value:a})=>ue("div",{className:Jn(n===a?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},r(o)})(a),children:ue(C,{icon:o,className:"tag-style-size"})},a))})),me("div",{className:"card-item-title",children:[" ",o("padding_settings")]}),ue(To,{padding:{paddingTop:a(e.data.contentStyles,"paddingTop"),paddingRight:a(e.data.contentStyles,"paddingRight"),paddingLeft:a(e.data.contentStyles,"paddingLeft"),paddingBottom:a(e.data.contentStyles,"paddingBottom")},setPadding:c})]})})()})},Go=()=>{const{currentItem:e}=n(Ye),{t:t}=Yn(),{findStyleItem:o,cardItemElement:a,inputChange:i}=Eo(),l=o(e.data.styles,"height"),r="number"==typeof l?l:parseInt(l,10)||16;return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:t("spacer_block")}),a(me("span",{className:"flex items-center gap-2",children:[ue(C,{icon:Y,className:"tag-style-size"}),t("height")]}),ue(b,{min:0,max:500,className:"input-width",addonAfter:"px",value:r,onChange:e=>i("height")(e??0)}))]})},Yo=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:a}=Yn(),{findStyleItem:r,paddingChange:s,updateItemStyles:c,cardItemElement:d,colorChange:p,inputChange:u}=Eo(),{list:m=[],separator:y=" | "}=e.data,[h,f]=i(null),[_,v]=i(!1),[x,w]=i(null),S=l(null),N=(t,n)=>{const o=be(e.data);o[t]=n,c(o)},T=o(fe(e=>{e.preventDefault();const t=S.current;if(!t)return;const n=e.target.closest("[data-index]");if(!n)return;const o=Array.from(t.children).indexOf(n);if(-1===o)return;const a=parseInt(x,10);if(a===o)return;const i=be(m);[i[o],i[a]]=[i[a],i[o]],w(String(o)),N("list",i)},50),[m,x]),I=[{label:a("same_tab"),value:"_self"},{label:a("new_tab"),value:"_blank"}];return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:a("menu_items")}),ue("div",{ref:S,onDragOver:T,className:"margin-top-12",onDragStart:e=>{const t=e.target.closest("[data-index]"),n=t?.getAttribute("data-index");null!=n&&(t.classList.add("social-link-item-current"),f(t),v(!0),w(n))},onDragEnd:()=>{const e=h?.closest?.("[data-index]");e&&e.classList.remove("social-link-item-current"),f(null),v(!1),w(null)},children:m.map((e,t)=>ue("div",{"data-index":t,draggable:!0,className:Jn("social-link-item",_&&"social-link-item-drag_start",x===String(t)?"social-link-item-current":"border-transparent"),children:me("div",{className:"social-link-item-content ee-menu-item-content",children:[me("div",{className:"ee-menu-item-header flex items-center justify-between margin-bottom-8",children:[me("div",{className:"flex items-center gap-2 cursor-grab",children:[ue(C,{icon:Z,className:"tag-style-size"}),me("span",{className:"font-semibold",children:[a("menu_item")," ",t+1]})]}),ue("div",{className:"social-link-item-icon social-link-item-icon-slate ee-menu-item-delete",onClick:()=>N("list",m.filter((e,n)=>n!==t)),children:ue(C,{icon:M,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]}),me("div",{className:"ee-menu-item-fields",children:[d(a("label"),ue(g,{className:"ee-menu-item-input",value:e.label||"",onChange:e=>N("list",m.map((n,o)=>o===t?{...n,label:e.target.value}:n)),placeholder:"Page"})),d(a("url"),ue(g,{addonBefore:"https://",className:"ee-menu-item-input",value:(e.url||"").replace(/^https?:\/\//,""),onChange:e=>N("list",m.map((n,o)=>o===t?{...n,url:e.target.value}:n)),placeholder:"example.com"})),d(a("target"),ue(k,{className:"input-width ee-menu-item-input",value:e.target||"_self",onChange:e=>N("list",m.map((n,o)=>o===t?{...n,target:e}:n)),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:I.map(e=>ue(k.Option,{value:e.value,children:e.label},e.value))}))]})]})},t))}),me("button",{type:"button",className:"menu-add-new-item margin-top-12",onClick:()=>N("list",m.concat({label:a("page"),url:"",target:"_self"})),children:[ue("span",{className:"menu-add-new-item-icon",children:"+"})," ",a("add_new_item")]}),ue("div",{className:"right-setting-block-item-title margin-top-18",children:a("menu_styles")}),d(a("font_family"),ue(k,{className:"input-width",value:r(e.data.styles,"fontFamily"),onChange:u("fontFamily"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Georgia","Courier New"].map(e=>ue(k.Option,{value:e,children:e},e))})),d(a("font_size"),ue(b,{min:8,max:72,className:"input-width",addonAfter:"px",value:r(e.data.styles,"fontSize"),onChange:u("fontSize")})),d(a("letter_spacing"),ue(b,{className:"input-width",addonAfter:"px",value:r(e.data.styles,"letterSpacing"),onChange:u("letterSpacing")})),d(a("text_color"),ue(No,{color:r(e.data.styles,"color"),setColor:p("color")})),d(a("link_color"),ue(No,{color:r(e.data.styles,"linkColor"),setColor:p("linkColor")})),d(a("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"}].map(({icon:n,value:o})=>ue("div",{className:Jn(r(e.data.contentStyles,"textAlign")===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},c(o)})(o),children:ue(C,{icon:n,className:"tag-style-size"})},o))})),d(a("separator"),ue(g,{value:y,onChange:e=>N("separator",e.target.value),placeholder:" | "})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:a("padding_settings")}),ue(To,{padding:{paddingTop:r(e.data.contentStyles,"paddingTop"),paddingRight:r(e.data.contentStyles,"paddingRight"),paddingLeft:r(e.data.contentStyles,"paddingLeft"),paddingBottom:r(e.data.contentStyles,"paddingBottom")},setPadding:n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},c(o)}}),ue("div",{className:"card-item-title margin-top-18",children:a("spacing")}),ue(To,{padding:{paddingTop:r(e.data.styles,"paddingTop"),paddingRight:r(e.data.styles,"paddingRight"),paddingLeft:r(e.data.styles,"paddingLeft"),paddingBottom:r(e.data.styles,"paddingBottom")},setPadding:s})]})},Zo=({imageUploadEndpoint:e,headers:t={},companyId:n,imageUploadQueryParams:a,imageUploadCompanyField:i="companyId"}={})=>{const l=!!e;return{uploadImageFile:o(async o=>{if(!l)return console.error("[useImageUpload] No image upload endpoint configured"),null;if(!o)return console.error("[useImageUpload] No file provided"),null;if(!o.type.startsWith("image/"))return console.error("[useImageUpload] File is not an image:",o.type),null;if(o.size>10485760)return console.error("[useImageUpload] File too large:",o.size,"bytes"),null;const r=await(async(e,t,n,o={},a={})=>{if(!e)return console.error("[API Service] No image upload endpoint configured"),null;if(!t)return console.error("[API Service] No file provided for upload"),null;const{queryParams:i={},companyField:l="companyId"}=a;try{const a=new FormData;a.append("file",t),n&&("comment"===l?a.append("comment",n):a.append("companyId",n));let r=e;if(i&&Object.keys(i).length>0){const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);Object.entries(i).forEach(([e,t])=>{null!=t&&n.searchParams.set(e,String(t))}),r=n.toString()}const s={...o};Object.keys(s).forEach(e=>{"content-type"===e.toLowerCase()&&delete s[e]});const c=await fetch(r,{method:"POST",headers:{...s},body:a});if(!c.ok)return console.error("[API Service] Image upload failed:",c.status,c.statusText),null;const d=await c.json();if(d&&!1===d.success)return console.error("[API Service] Upload API returned error:",d.error),null;if(d&&"string"==typeof d.url&&d.url.trim())return d.url.trim();const p=d?.data?.url;return p&&"string"==typeof p?p.trim():(console.error("[API Service] Upload API returned no URL"),null)}catch(e){return console.error("[API Service] Error uploading image:",e),null}})(e,o,n,t,{queryParams:a,companyField:i});return r},[l,e,t,n,a,i]),isConfigured:l}},Qo=()=>{const{currentItem:e,previewMode:t,templateData:o,apiConfig:r}=n(Ye),{t:s}=Yn(),{containerBlock:c,containerType:d,contentIndex:p}=Fo(),u=c?.columnProducts?.[p]??null,{findStyleItem:m,cardItemElement:y,inputChange:h,updateItemStyles:_}=Eo(),v=l(null),[N,T]=i(!1),I=a(()=>({columnIndex:p,columnProduct:u}),[p,u]),A=a(()=>tn(d,o,I),[d,o,I]),{uploadImageFile:L,isConfigured:P}=Zo({imageUploadEndpoint:r?.imageUploadEndpoint,headers:r?.headers||{},companyId:r?.companyId,imageUploadQueryParams:r?.imageUploadQueryParams,imageUploadCompanyField:r?.imageUploadCompanyField}),R=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},_(o)};return me("div",{className:"margin-y-30",children:[(()=>{const{linkURL:t}=e.data,n=nn(e.data);return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_action")}),y(s("action_type"),me("div",{className:"ee-image-action-type-row",children:[ue("span",{className:Jn("link-tag",!n&&"ee-image-link-tag-inactive"),children:s("link")}),ue(x,{checked:n,onChange:t=>{const n=be(e);n.data.linkEnabled=Boolean(t),_(n.data)},className:Jn(n?"bg-sky-500":"bg-gray-400")})]})),n?me(ge,{children:[ue("div",{className:"card-item-title",children:s("link_url")}),ue("div",{className:"margin-top-6",children:ue(g,{addonBefore:"https://",value:t??"",onChange:t=>{const n=t.target.value??"",o=be(e);o.data.linkURL=n,_(o.data)},placeholder:s("link_url_placeholder")})})]}):null]})})(),(()=>{const{src:t,alt:n}=e.data,a="string"==typeof t&&/^\{\{\w+\}\}$/.test(t.trim())?String(t).replace(/\{\{|\}\}/g,"").trim():"",i=o&&a?Wt(o,a,I):null,l=null==i||String(i).startsWith("{{")?t||"":i,r=t=>n=>{const o=be(e),a=n.target.value;o.data[t]=a,_(o.data)},c=t=>{const n=be(e);n.data.src=t,_(n.data)};return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_settings")}),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_upload")}),ue("input",{ref:v,type:"file",accept:"image/*",className:"ee-image-upload-input-hidden",onChange:async e=>{const t=e.target.files?.[0];if(t){if(!P)return S.error(s("image_upload_not_configured")||"Image upload not configured"),console.warn("[ImageStyleSettings] Image upload endpoint not configured"),void(e.target.value="");T(!0);try{const e=await L(t);e?(c(e),S.success(s("image_uploaded")||"Image uploaded successfully")):S.error(s("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e),S.error(s("image_upload_error")||"Error uploading image")}finally{T(!1),e.target.value=""}}},disabled:N}),ue(f,{spinning:N,children:me("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:()=>{v.current?.click()},onDrop:async e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer?.files?.[0];if(t?.type?.startsWith("image/")){if(!P)return S.error(s("image_upload_not_configured")||"Image upload not configured"),void console.warn("[ImageStyleSettings] Image upload endpoint not configured");T(!0);try{const e=await L(t);e?(c(e),S.success(s("image_uploaded")||"Image uploaded successfully")):S.error(s("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e),S.error(s("image_upload_error")||"Error uploading image")}finally{T(!1),v.current.value=""}}},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:N?.6:1,cursor:N?"not-allowed":"pointer"},children:[ue(C,{icon:Q,className:"ee-image-upload-icon"}),ue("span",{children:N?s("uploading")||"Uploading...":s("image_upload_click")})]})})]})}),A.length>0&&y(s("image_source_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:s("image_source_variable"),allowClear:!0,value:"string"==typeof t&&/^\{\{\w+\}\}$/.test(String(t).trim())?String(t).trim():void 0,onChange:e=>c(e??""),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:A.map(e=>({value:e.value,label:s(e.labelKey)}))})),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_url")}),ue("div",{className:"margin-top-6",children:ue(g,{value:l,onChange:r("src"),placeholder:"https://..."})})]})}),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_alt")}),ue("div",{className:"margin-top-6",children:ue(g,{value:n||"",onChange:r("alt")})})]})})]})})(),(()=>{const n=m(e.data.styles,"width"),o=m(e.data.styles,"borderRadius"),a="number"==typeof o?o:parseInt(String(o||"").replace("px",""),10)||0,i=m(e.data.contentStyles,"textAlign");return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_styles")}),y(s("width_auto"),ue(x,{checked:"auto"===n,className:Jn("auto"===n?"bg-sky-500":"bg-gray-400"),onChange:()=>{const e="auto"===n?"100%":"auto";h("width")(e)}})),"auto"!==n&&ue(w,{value:Number(n.replace("%","")),onChange:e=>h("width")(e+"%")}),y(s("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:a,onChange:e=>h("borderRadius")(Number(e)||0)})),y(s("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:n,value:o})=>ue("div",{className:Jn(i===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},_(o)})(o),children:ue(C,{icon:n,className:"tag-style-size"})},o))})),ue("div",{className:"card-item-title",children:s("padding_settings")}),ue(To,{padding:{paddingTop:m(e.data.contentStyles,"paddingTop"),paddingRight:m(e.data.contentStyles,"paddingRight"),paddingLeft:m(e.data.contentStyles,"paddingLeft"),paddingBottom:m(e.data.contentStyles,"paddingBottom")},setPadding:R})]})})()]})},Xo=()=>{const{currentItem:e}=n(Ye),{t:t}=Yn(),{findStyleItem:o,cardItemElement:a,updateItemStyles:i}=Eo(),{src:l,alt:r,linkURL:s}=e.data,c=o(e.data.styles,"width")??64,d=o(e.data.styles,"borderRadius"),p="50%"===d?50:parseInt(String(d).replace("px",""),10)||0;return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:t("avatar_image")}),a(t("image_url"),ue(g,{addonBefore:"https://",value:l,onChange:t=>{const n=be(e.data);n.src=t.target.value??"",i(n)}})),a(t("image_alt"),ue(g,{value:r,onChange:t=>{const n=be(e.data);n.alt=t.target.value??"",i(n)},placeholder:"Avatar"})),a(t("link_url"),ue(g,{addonBefore:"https://",value:s,onChange:t=>{const n=be(e.data);n.linkURL=t.target.value??"",i(n)},placeholder:t("link_url_placeholder")})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:t("image_styles")}),a(t("width"),ue(b,{min:16,max:256,value:"number"==typeof c?c:64,onChange:t=>{const n=be(e.data);n.styles.desktop||(n.styles.desktop={}),n.styles.desktop.width=t,i(n)},addonAfter:"px"})),a(t("avatar_border_radius"),ue(b,{min:0,max:50,value:p,onChange:t=>{const n=be(e.data);n.styles.desktop||(n.styles.desktop={}),n.styles.desktop.borderRadius=50===t?"50%":`${t}px`,i(n)},addonAfter:50===p?"%":"px"})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:t("padding_settings")}),ue(To,{padding:{paddingTop:o(e.data.contentStyles,"paddingTop"),paddingRight:o(e.data.contentStyles,"paddingRight"),paddingLeft:o(e.data.contentStyles,"paddingLeft"),paddingBottom:o(e.data.contentStyles,"paddingBottom")},setPadding:t=>{const n=be(e.data);n.contentStyles||(n.contentStyles={desktop:{},mobile:{}}),n.contentStyles.desktop={...n.contentStyles.desktop,...t},i(n)}})]})},ea="https://s.magecdn.com/social",ta=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:a}=Yn(),{findStyleItem:r,paddingChange:s,updateItemStyles:c,cardItemElement:d}=Eo(),{list:p}=e.data,[u,m]=i(null),[y,h]=i(!1),[f,k]=i(null),_=l(null),v=[{image:`${ea}/tc-facebook.svg`,title:"Facebook",linkURL:""},{image:`${ea}/tc-github.svg`,title:"Github",linkURL:""},{image:`${ea}/tc-linkedin.svg`,title:"LinkedIn",linkURL:""},{image:`${ea}/tc-instagram.svg`,title:"Instagram",linkURL:""},{image:`${ea}/tc-tiktok.svg`,title:"TikTok",linkURL:""},{image:`${ea}/tc-x.svg`,title:"Twitter",linkURL:""},{image:`${ea}/tc-youtube.svg`,title:"YouTube",linkURL:""}],x=(t,n)=>{const o=be(e);o.data={...o.data,[t]:n},c(o.data)},w=o(fe(e=>{e.preventDefault();const t=_.current,n=Array.from(t.childNodes).indexOf(e.target);if(-1===n)return;const o=f,a=be(p);o!==n&&([a[n],a[o]]=[a[o],a[n]],k(n),x("list",a))},50),[u,f]),S=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},c(o)},N=t=>{const n=be(e.data);n.imageWidth=t,c(n)};return me("div",{className:"margin-y-30",children:[(()=>{const n=r(e.data.contentStyles,"textAlign"),o=e.data.imageWidth;return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",a("social_link_settings")]}),d(a("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:o,value:a})=>ue("div",{className:Jn(n===a?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},c(o)})(a),children:ue(C,{icon:o,className:"tag-style-size"})},a))})),d(a("social_link_size"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:o,onChange:N})),ue("div",{className:"card-item-title margin-top-18",children:a("social_links")}),ue("div",{ref:_,onDragOver:w,className:"margin-top-12",onDragStart:e=>{m(e.target),h(!0),k(e.target.dataset.index)},onDragEnd:()=>{u.childNodes[0].classList.remove("social-link-item-current"),m(null),h(!1),k(null)},children:p.map((e,t)=>{const{image:n,title:o,linkURL:a}=e;return ue("div",{"data-index":t,draggable:!0,className:Jn("social-link-item","cursor-grab",y&&"social-link-item-drag_start",f===t?"social-link-item-current":"border-transparent"),children:me("div",{className:"social-link-item-content",children:[me("div",{className:"flex items-center justify-between",children:[me("div",{className:"flex items-center",children:[ue("img",{src:n,alt:o,className:"social-link-item-img"}),ue("div",{className:"font-semibold",children:o})]}),ue("div",{className:"flex items-center",children:ue("div",{className:"social-link-item-icon social-link-item-icon-slate",onClick:()=>{x("list",p.filter((e,n)=>n!==t))},children:ue(C,{icon:M,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})})]}),ue("div",{className:"margin-top-12 relative",children:ue(g,{addonBefore:"https://",value:a||"",onChange:e=>x("list",p.map((n,o)=>o===t?{...n,linkURL:e.target.value}:n))})})]})},t)})}),ue("div",{className:"card-item-title margin-top-18",children:a("add_social_link")}),ue("div",{className:"social-link-add margin-top-12",children:v.map((e,t)=>{const{image:n,title:o}=e;return ue("img",{src:n,alt:o,className:"social-link-add-img",onClick:()=>x("list",p.concat(e))},t)})}),me("div",{className:"card-item-title margin-top-18",children:[" ",a("spacing")]}),ue(To,{padding:{paddingTop:r(e.data.styles,"paddingTop"),paddingRight:r(e.data.styles,"paddingRight"),paddingLeft:r(e.data.styles,"paddingLeft"),paddingBottom:r(e.data.styles,"paddingBottom")},setPadding:s})]})})(),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",a("padding_settings")]}),ue(To,{padding:{paddingTop:r(e.data.contentStyles,"paddingTop"),paddingRight:r(e.data.contentStyles,"paddingRight"),paddingLeft:r(e.data.contentStyles,"paddingLeft"),paddingBottom:r(e.data.contentStyles,"paddingBottom")},setPadding:S})]})]})},na=()=>{const{currentItem:e}=n(Ye);return me(ge,{children:["column"===e?.data.key&&ue(Ko,{}),"text"===e?.data.key&&ue(Wo,{}),"button"===e?.data.key&&ue(Jo,{}),"divider"===e?.data.key&&ue(qo,{}),"spacer"===e?.data.key&&ue(Go,{}),"menu"===e?.data.key&&ue(Yo,{}),"image"===e?.data.key&&ue(Qo,{}),"avatar"===e?.data.key&&ue(Xo,{}),"social_link"===e?.data.key&&ue(ta,{})]})};var oa={presets:[{id:"preset_header",presetName:"Header",nameKey:"preset_header",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"50%"},mobile:{}}},{name:"Container",key:"column",type:"full",containerType:"none",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 14px; font-family: Verdana; color: #333333"><a target="_blank" href="https://example.com">Shop</a> | <a target="_blank" href="https://example.com">Frey </a> | <a target="_blank" href="https://example.com">Our Story</a></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",lineHeight:"120%",paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},isPreset:!0},{name:"Image",key:"image",src:"{{HeroBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}]}]}]}]}},{id:"navigation_bar",presetName:"Navigation Bar",nameKey:"preset_navigation_bar",containerType:"none",block:{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 14px; font-family: Verdana; color: #333333"><a target="_blank" href="https://example.com">Shop</a> | <a target="_blank" href="https://example.com">Frey </a> | <a target="_blank" href="https://example.com">Our Story</a></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",lineHeight:"120%",paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},isPreset:!0}},{id:"product_single",nameKey:"preset_product_single",containerType:"product",presetName:"Hero Product",block:{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"main",columnProducts:[{id:"product-1",name:"Abundance Butterfly Diamond Ring",description:"The Maia Diamond Ring features round diamonds set along a delicate gold band, creating a refined and minimalistic look. Its versatile design makes it perfect for everyday wear or for layering with other rings.",image:"https://www.psylish.com/cdn/shop/files/IMG_4632.jpg?v=1773123202&width=1220",link:"https://www.psylish.com",price:2e3,currency:"USD",old_price:null,new_price:null}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: sans-serif"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:null,paddingLeft:12,paddingRight:12,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: sans-serif">{{ProductCurrency}} {{ProductPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:null,paddingBottom:6,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Shop Now",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:null,paddingRight:null},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:null,paddingRight:null,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}}]}]}},{id:"product_two_column",presetName:"Additional Products",nameKey:"preset_product_two_column",containerType:"product",block:{name:"Container",key:"column",type:"1-1",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},isPreset:!0,columns:2,columnProducts:[null,null],children:[{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:6,paddingRight:3,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-2",name:"Heartline Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_15.png?v=1770880382&width=1220",link:"https://www.psylish.com/",price:1e3,currency:"USD",old_price:1200,new_price:1e3}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial"><strike>{{ProductOldPrice}}</strike> {{ProductNewPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:0,paddingRight:0,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]},{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:3,paddingRight:6,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-3",name:"Lynx Heart Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_48.png?v=1770881768&width=1220",link:"https://www.psylish.com/",price:900,currency:"USD",old_price:1200,new_price:900}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial"><strike>{{ProductOldPrice}}</strike> {{ProductNewPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]}]}},{id:"preset_discount",presetName:"Discount",nameKey:"preset_discount",containerType:"discount",block:{name:"Container",key:"column",type:"full",containerType:"discount",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#ffa7aa"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<div style="text-align: center;"><font face="Arial">Use <b>{{DiscountCode}}</b> for <b>{{DiscountValue}}</b> OFF. Expires on {{ValidUntil}}</font></div>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}}]}]}},{id:"preset_footer",presetName:"Footer",nameKey:"preset_footer",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{FooterBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"35%"},mobile:{}}},{name:"Text",key:"text",text:"<p><i><b>{{Tagline}}</b></i></p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{Address}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Social Link",key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:"facebook.com/psylish"},{image:"https://s.magecdn.com/social/tc-x.svg",title:"Twitter",linkURL:"twitter.com/psylish"},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:"instagram.com/psylish"},{image:"https://s.magecdn.com/social/tc-linkedin.svg",title:"LinkedIn",linkURL:"linkedin.com/company/psylish"},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:"www.tiktok.com/@psylish"},{image:"https://s.magecdn.com/social/tc-youtube.svg",title:"YouTube",linkURL:"www.youtube.com/@psylish"}],imageWidth:32,contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}},useCompanySocialLinks:!0},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{name:"Text",key:"text",text:'<p><a href="#" style="color:#263d2d;text-decoration:underline">{{Website}}</a></p>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center",color:"#263d2d",textDecoration:"underline"},mobile:{}}}]}]}}]};function aa(e){if(!e||"object"!=typeof e)return e;const t={...e,id:_e()};return Array.isArray(t.children)&&(t.children=t.children.map(aa)),Array.isArray(t.columnProducts)&&(t.columnProducts=t.columnProducts.map(e=>e&&"object"==typeof e?{...e}:e)),t}const ia={column:ce,text:se,button:re,divider:le,spacer:Y,menu:ie,image:E,social_link:ae,product:oe,header:ne,footer:te,discount:ee,avatar:X},la={Header:"header",Footer:"footer",Discount:"discount","Navigation Bar":"menu"};function ra(e){const t=la[e];return t&&ia[t]?ia[t]:ia.product}const sa=["ai_powered","components","presets"],ca=["column","divider","spacer","button","image","avatar","social_link"];function da(e,t,n){const o={ai_powered:[],components:[],presets:[]},a=function(e){return e?{ai_powered:["text"],components:ca,presets:[]}:{ai_powered:[],components:["text",...ca],presets:[]}}(n);oa.presets.forEach(e=>{o.presets.push({key:e.id,name:e.presetName,icon:ra(e.presetName),isPreset:!0,getColumn:()=>function(e){const t=oa.presets.find(t=>t.id===e);return t?aa(JSON.parse(JSON.stringify(t.block))):null}(e.id)})});for(const t of sa){const i=a[t];i&&0!==i.length&&i.forEach(a=>{const i=e.find(e=>e.key===a);i&&("ai_powered"===t&&"text"===a&&n?o[t].push({...i,contentType:"dynamic",dynamicPrompt:"",dynamicSelectedContent:"",dynamicOptions:[],dynamicVariable:"",isPreset:!1}):o[t].push({...i,isPreset:!1}))})}return o}const pa=({clearStyles:e})=>{const{setCurrentItem:t,setIsDragStart:o,setActionType:a,templateData:i,aiEnabled:l=!0}=n(Ye),{blockConfigsList:r}=Uo(),{t:s}=Yn(),c=da(r,0,l),d=t=>{t.target.style.border="";const n=t.target.querySelector(".right-panel-block-inner");n&&n.classList.remove("right-panel-block-move"),setTimeout(()=>{o(!1),e&&e()},50)},p=e=>n=>{const l=e.isPreset?be(e.getColumn(s,i)):be(e);t({id:null,data:l,type:"add"}),o(!0),n.target.style.border="1px dashed var(--ee-primary)";const r=n.target.querySelector(".right-panel-block-inner");r&&r.classList.add("right-panel-block-move"),a("add")},u={ai_powered:s("ai_powered"),components:s("components"),presets:s("presets")};return ue("div",{className:"right-panel-block-list",children:sa.map(e=>{const t=c[e];return t&&0!==t.length?me("div",{className:"right-panel-block-category",children:[ue("div",{className:"right-panel-block-category-title",children:u[e]}),t.map(e=>(e=>ue("div",{className:"right-panel-block-row",draggable:!0,onDragEnd:d,onDragStart:p(e),children:me("div",{className:"right-panel-block-inner",children:[ue("span",{className:"right-panel-block-drag-handle",title:s("drag_block_here"),children:ue(C,{icon:Z,className:"right-panel-block-drag-icon"})}),ue("span",{className:"right-panel-block-separator","aria-hidden":!0}),ue(C,{icon:e.icon||ia[e.key]||se,className:"right-panel-block-icon"}),ue("span",{className:"right-panel-block-text",children:e.name}),l&&"text"===e.key&&!e.isPreset&&ue("span",{className:"right-panel-block-ai-pill",children:"+ AI"})]})},e.key))(e))]},e):null})})},ua="content",ma="styles",ga=e=>{const{clearStyles:t}=e,{currentItem:o,isDragStart:a,bodySettings:r,setBodySettings:d,setCurrentItem:p,setActionType:u,blockMap:m,rootOrder:y}=n(Ye),{t:h}=Yn(),{cardItemElement:f}=Eo(),[k,_]=i(ua),v=l(null),x=()=>{if(!o?.id||!m[o.id])return[];const e=[o.id],t=new Set(e);let n=o.id;for(;;){const o=Te(m,y,n);if(!o||t.has(o.containerId))break;e.unshift(o.containerId),t.add(o.containerId),n=o.containerId}return e.map(e=>({id:e,data:m[e]})).filter(e=>Boolean(e.data))},w=()=>{let e="Block";const t=o?.data.key;switch(t){case"text":e=h("text_settings");break;case"column":{const t=o?.data?.containerType;e=h("product"===t?"block_product":"container_settings");break}case"button":e=h("button_settings");break;case"divider":e=h("divider_settings");break;case"spacer":e=h("spacer_settings");break;case"menu":e=h("menu_settings");break;case"image":e=h("image_settings");break;case"avatar":e=h("avatar_settings");break;case"social_link":e=h("social_link_settings")}return e},S=e=>t=>{d({...r,styles:{...r.styles,[e]:t.hex}},"set_body_settings")},N="undefined"!=typeof window&&"product-variables"===window.__eeDragSource,T=o&&"edit"===o.type&&(!a||N);c(()=>{if(!T)return;const e=v.current;e&&(e.scrollTop=0)},[T,o?.id]);return ue("div",{ref:v,className:"right-settings default-scrollbar",onClick:e=>{e.stopPropagation()},children:me(ge,T?{children:[me("div",{className:"right-panel-block-settings-header",children:[ue("button",{type:"button",className:"right-panel-back-btn",onClick:()=>p(null),"aria-label":"Back",children:ue(C,{icon:de})}),ue("h2",{className:"right-setting-block-title right-panel-block-title-inline",children:w()})]}),ue("div",{className:"right-panel-breadcrumb-bar","aria-label":"Selection path",children:x().map((e,t,n)=>{const o=t===n.length-1,a=(e=>{if(!e)return"";switch(e.key){case"column":{const t=e.containerType;return h("product"===t?"block_product":"discount"===t?"block_discount":"container")}case"text":return h("text");case"button":return h("button");case"image":return h("image");case"divider":return h("divider");case"spacer":return h("spacer");case"menu":return h("menu");case"avatar":return h("avatar");case"social_link":return h("social_link");case"empty":return h("drag_block_here");default:return e.name||"Block"}})(e.data);return me(s,{children:[o?ue("span",{className:"right-panel-breadcrumb-current",children:a}):ue("button",{type:"button",className:"right-panel-breadcrumb-btn",onClick:(i=e.id,e=>{e.preventDefault(),e.stopPropagation();const t=m[i];t&&(p({id:i,data:t,type:"edit"}),u("edit"))}),children:a}),!o&&ue("span",{className:"right-panel-breadcrumb-separator",children:"›"})]},`${e.id||"crumb"}-${t}`);var i})}),ue("div",{className:"right-panel-block-settings-form",children:ue(na,{})})]}:{children:[me("div",{className:"right-panel-tabs",children:[ue("button",{type:"button",className:"right-panel-tab "+(k===ua?"right-panel-tab-active":""),onClick:()=>_(ua),children:h("content")}),ue("button",{type:"button",className:"right-panel-tab "+(k===ma?"right-panel-tab-active":""),onClick:()=>_(ma),children:h("styles")})]}),me("div",{className:"right-panel-tab-content",children:[k===ua&&ue(pa,{clearStyles:t}),k===ma&&me(ge,{children:[me("section",{className:"right-panel-styles-section",children:[ue("h3",{className:"right-panel-styles-section-title",children:h("global")}),me("div",{className:"right-panel-styles-section-body",children:[f(h("text_color"),ue(No,{color:r.styles.color,setColor:S("color")})),f(h("email_theme_background_color"),ue(No,{color:r.styles.backgroundColor,setColor:S("backgroundColor")})),f(h("line_height"),ue(b,{className:"input-width",addonAfter:"px",min:0,max:900,value:Number(r.contentWidth),onChange:e=>d({...r,contentWidth:e},"set_body_settings")}))]})]}),me("section",{className:"right-panel-styles-section",children:[ue("h3",{className:"right-panel-styles-section-title",children:h("text_and_headings")}),ue("div",{className:"right-panel-styles-section-body",children:me("div",{children:[ue("div",{className:"pre_header",children:h("pre_header")}),ue(g,{className:"margin-top-12",value:r.preHeader,onChange:e=>d({...r,preHeader:e.target.value},"set_body_settings")}),ue("div",{className:"pre_header-desc",children:h("pre_header_description")})]})})]})]})]})]})})},ya=({language:e})=>{const{blockMap:t,rootOrder:a,setBlocks:i,currentItem:l,setCurrentItem:s,setIsDragStart:c,setLanguage:d,templateData:p}=n(Ye),{t:u}=Yn(),{getColumnConfig:m}=Uo(),g=e=>{if(!e||"object"!=typeof e)return e;const t=p?.content?.products,n=p?.catalogProducts,o=p?.content?.primaryProductId,a=Array.isArray(t)&&t.length>0?t:Array.isArray(n)&&n.length>0?n:Mo,i=o?a.find(e=>e.id===o):a[0],l=i?a.filter(e=>e?.id!==i.id):a,r=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(r):e.children;if("column"!==e.key||"product"!==e.containerType||!i)return{...e,children:t};const n=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),o="additional"===e.productRole?"additional":"main",a=Array.from({length:n},(e,t)=>"main"===o||0===l.length?i:l[t%l.length]);return{...e,children:t,columnProducts:a}};return r(e)};r(()=>{d(e)},[e,d]);const y=()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},h=()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},b=()=>{document.querySelectorAll(".block-empty-content").forEach(e=>{e.style.borderStyle="",e.style.borderColor=""})},f=()=>{y(),h(),b()},k=o(fe(e=>{e.preventDefault(),e.stopPropagation();const{type:t}=e.target.dataset;switch(t){case"empty-block":y(),h(),e.target.style.border="1px dashed #2faade";break;case"drag-over-column":{h();const t=e.target.dataset.index,n=document.getElementsByClassName("block-drag-label-content");Array.from(n).forEach(e=>{Number(e.dataset.index)===Number(t)?e.children[0].style.visibility="visible":e.children[0].style.visibility="hidden"});break}case"block-item-move":{y();const t=e.target.dataset.dropKey,n=document.getElementsByClassName("block-content-drag-label-content");Array.from(n).forEach(e=>{e.dataset.dropKey===t?e.children[0].style.visibility="visible":e.children[0].style.visibility="hidden"});break}case"empty-block-item":y(),h();{const t=e.target.parentNode;t&&t.classList.contains("block-empty-content")&&(t.style.borderStyle="solid")&&(t.style.borderColor="var(--ee-primary)")}break;default:y(),h()}},30),[]),_=(e,t)=>{const{blockMap:n,removedId:o}=Pe(e,t.containerId,t.cellIndex,t.itemIndex);return{result:n,removedId:o}},v=(e,t,n,o)=>{const a=e[t];if(!a||a.cells[n].childrenIds.length>0)return e;const i=we(o("drag_block_here"));return{...e,[i.id]:i,[t]:{...a,cells:a.cells.map((e,t)=>t===n?{...e,childrenIds:[i.id]}:e)}}},x=(e,t,n)=>{if(!t||!n)return!1;if(t===n)return!0;const o=t=>{const a=e[t];if(!a||"column"!==a.key)return!1;for(const e of a.cells||[])for(const t of e.childrenIds||[]){if(t===n)return!0;if(o(t))return!0}return!1};return o(t)};return ue(ge,{children:ue("div",{className:"email-editor",onDragOver:k,onDrop:e=>{e.preventDefault(),e.stopPropagation();const{type:n}=e.target.dataset;c(!1);const o="undefined"!=typeof window?window.__eeDragItemData:null,r=()=>{"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null)},d=o?"add":l?.type,p=o?xe(o):l?.data;if(p){switch(n){case"empty-block":{const e="column"===p.key?p:m(p),n=g(e),{newBlockMap:o,rootId:a}=Be(t,n);if(!a)return void r();i(o,[a],"add"),s({id:a,data:o[a],type:"edit"});break}case"empty-block-item":{b();const n=e.target.dataset.containerId,o=Number(e.target.dataset.cellIndex),c=Number(e.target.dataset.itemIndex);if(!n)return void r();let m={...t};if("add"===d){const e="column"===p.key?p:xe(p),t=g(e),{newBlockMap:l,rootId:d}=Be(m,t);if(!d)return void r();m=Le(l,n,o,c,d),i(m,a,"add"),s({id:d,data:m[d],type:"edit"})}else{const e=l.id;if(x(m,e,n))return r(),void f();const t=Te(m,a,e);if(!t)return void r();{const{result:e,removedId:a}=_(m,t);m=e?v(e,t.containerId,t.cellIndex,u):m,a&&(m=Le(m,n,o,c,a))}i(m,a,"move"),s({...l,data:m[e]??l.data,type:"edit"})}break}case"drag-over-column":{const n=Number(e.target.dataset.index);let o,c=[...a],u={...t};if("add"===d){const e=xe(p),t=g(e),{newBlockMap:a,rootId:i}=Be(u,t);if(!i)return void r();u=a,c.splice(n,0,i),o={id:i,data:u[i],type:"edit"}}else{const e=l.id,t=a.indexOf(e);if(-1===t)return void r();c.splice(t,1),c.splice(n>t?n-1:n,0,e),o={...l,type:"edit"}}i(u,c,"move"),s(o),setTimeout(()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}case"block-item-move":{const n=e.target.dataset.dropKey;if(!n)return void r();const[o,c,m]=n.split(":"),y=Number(c),h=Number(m);let b,k={...t};if("add"===d){const e="column"===p.key?p:xe(p),t=g(e),{newBlockMap:n,rootId:a}=Be(k,t);if(!a)return void r();k=Re(n,o,y,h,a),b={id:a,data:k[a],type:"edit"}}else{const e=l.id;if(x(k,e,o))return r(),void f();const t=Te(k,a,e);if(!t)return void r();const{blockMap:n,removedId:i}=Pe(k,t.containerId,t.cellIndex,t.itemIndex);k=n;const s=k[t.containerId];if(s&&0===s.cells[t.cellIndex].childrenIds.length){const e=we(u("drag_block_here"));k={...k,[e.id]:e,[t.containerId]:{...s,cells:s.cells.map((n,o)=>o===t.cellIndex?{...n,childrenIds:[e.id]}:n)}}}let c=h;t.containerId===o&&t.cellIndex===y&&t.itemIndex<h&&(c=h-1),k=Re(k,o,y,c,i),b={...l,type:"edit"}}i(k,a,"move"),s(b),setTimeout(()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}}r()}else r()},onDragLeave:e=>setTimeout(()=>{switch(e.target.dataset.type){case"empty-block":e.target.style.border="";break;case"empty-block-item":e.target.parentNode&&e.target.parentNode.classList.contains("block-empty-content")&&(e.target.parentNode.style.borderStyle="",e.target.parentNode.style.borderColor="")}},50),children:me("div",{className:"email-editor-main",onClick:e=>{e.preventDefault(),e.stopPropagation(),s(null)},children:[ue(Co,{clearStyles:f}),ue(ga,{clearStyles:f})]})})})},ha=e=>Array.isArray(e)?e.map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):e&&"object"==typeof e?Object.values(e).map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):[],ba=e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},i=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:i,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??""}}Array.isArray(e.children)&&n(e.children,i)})};return n(e,[]),t},fa=e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,children:i,...l}=e;return{...l,children:fa(i)}}):e,ka=d(({defaultBlockList:e,defaultBodySettings:t,aiContentRefs:n,language:l="en",customLanguageLibraries:s,templateData:c,variableDefinitions:d,apiConfig:m={},aiEnabled:g=!0},y)=>{r(()=>{var e;At=(e=d)&&"object"==typeof e?e:It,Mt()},[d]);const h=a(()=>Sn(m),[m]),b=e&&!Array.isArray(e)&&"object"==typeof e?e:null,f=b?b.blocks??b.blockList??[]:e,k=(_=f,Array.isArray(_)?_.map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):_&&"object"==typeof _?Object.values(_).map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):[]);var _;const v=n??b?.aiContentRefs??{},x=t??b?.bodySettings??Ge.bodySettings,w=c??Ge.templateData,S=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??Mo[0]??null;if(!a)return e;const i=n.filter(e=>e?.id!==a.id),l=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(l):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===i.length?a:i[t%i.length]);return{...e,children:t,columnProducts:r}};return e.map(l)})(k,w),C=kn(S,v),{blockMap:N,rootOrder:T}=Se(C),I=he(N,w),[A,L]=p(Qe,{...Ge,blockMap:I,rootOrder:T,blockList:C,bodySettings:x,languageLibraries:s,templateData:w}),[P,R]=i([]),$=a(()=>new Set(P),[P]),B=o(e=>(Array.isArray(e)?e:[]).filter(e=>!$.has(Nn(e))),[$]),D=o(e=>{const t=Nn(e);t&&R(e=>e.includes(t)?e:[...e,t])},[]),E=o(()=>{const e=A.blockList??[];return{blockList:fa(e),bodySettings:A.bodySettings??null,aiContentRefs:ba(e)}},[A.blockList,A.bodySettings]),U=a(()=>B(On({blockList:A.blockList??[],bodySettings:A.bodySettings??null,aiContentRefs:ba(A.blockList??[])})).filter(e=>e?.blockId&&("warning"===e.severity||"error"===e.severity)).reduce((e,t)=>{const n=t.blockId,o=e[n]??{severity:t.severity,warningCount:0,errorCount:0,totalCount:0,messages:[],issues:[]};return"error"===t.severity&&(o.errorCount+=1),"warning"===t.severity&&(o.warningCount+=1),o.totalCount+=1,o.severity=o.errorCount>0?"error":"warning",o.messages.push(t.message),o.issues.push(t),e[n]=o,e},{}),[A.blockList,A.bodySettings,B]);u(y,()=>({blockList:fa(A.blockList??[]),bodySettings:A.bodySettings,aiContentRefs:ba(A.blockList??[]),actionType:A.actionType,exportJson:E,filterIgnoredValidationIssues:B,ignoreValidationIssue:D,focusBlock:e=>{if(!e||!A.blockMap?.[e])return!1;const t=A.blockMap[e],n="column"===t?.key?Ne(e,A.blockMap)??t:t;return L(qe({id:e,data:n,type:"edit"})),L(Je("edit")),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':\"!^$\[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),!0},exportHtml:()=>gn({bodySettings:A.bodySettings,blockList:A.blockList,templateData:A.templateData})}),[A.blockList,A.bodySettings,A.actionType,A.templateData,E,B,D]);const M=o(e=>{L((e=>({type:Ue,isDragStart:e}))(e))},[]),O=o((e,t)=>{t&&L(Je(t)),L((e=>({type:He,bodySettings:e}))(e))},[]),j=o((e,t,n)=>{n&&L(Je(n)),L(((e,t)=>({type:Ee,blockMap:e,rootOrder:t}))(e,t))},[]),H=o((e,t)=>{t&&L(Je(t)),L((e=>({type:De,blockList:e}))(e))},[]),K=o(e=>{L((e=>({type:Oe,previewMode:e}))(e))},[]),z=o(e=>{L(qe(e))},[]),F=o(e=>{L((e=>({type:Ke,selectionRange:e}))(e))},[]),V=o(e=>{L((e=>({type:ze,textRange:e}))(e))},[]),W=o(e=>{L(Je(e))},[]),J=o(e=>{L((e=>({type:Fe,language:e}))(e))},[]),q=o(e=>{L((e=>({type:Ve,languageLibraries:e}))(e))},[]),G=o(e=>{L((e=>({type:We,templateData:e}))(e))},[]),Y=a(()=>({blockMap:A.blockMap,rootOrder:A.rootOrder,blockList:A.blockList,actionType:A.actionType,previewMode:A.previewMode,currentItem:A.currentItem,bodySettings:A.bodySettings,isDragStart:A.isDragStart,selectionRange:A.selectionRange,textRange:A.textRange,language:A.language,languageLibraries:A.languageLibraries,templateData:A.templateData,apiConfig:h,validationMarkers:U,ignoreValidationIssue:D,aiEnabled:g,setIsDragStart:M,setBodySettings:O,setBlocks:j,setBlockList:H,setPreviewMode:K,setCurrentItem:z,setSelectionRange:F,setTextRange:V,setActionType:W,setLanguage:J,setLanguageLibraries:q,setTemplateData:G}),[A.blockMap,A.rootOrder,A.blockList,A.actionType,A.previewMode,A.currentItem,A.bodySettings,A.isDragStart,A.selectionRange,A.textRange,A.language,A.languageLibraries,A.templateData,h,U,D,g,M,O,j,H,K,z,F,V,W,J,q,G]);return ue(Ye.Provider,{value:Y,children:ue(ya,{language:l})})});const _a=/\{\{Product\w+\}\}/;function va(e,t,n,o,a){if("text"===e.key||"image"===e.key){const a="text"===e.key?e.text:"image"===e.key?e.src:null;if(a&&_a.test(a)){const i=t?t.id:null;if(!o.has(i)){const e={containerId:i,containerType:t?.containerType||t?.key||"none",nodes:[]};o.set(i,e),n.push(e)}o.get(i).nodes.push({id:e.id,key:e.key,value:a,contentType:e.key})}}if("dynamic"===e.contentType){const i=t?t.id:null;if(!o.has(i)){const e={containerId:i,containerType:t?.containerType||t?.key||"none",nodes:[]};o.set(i,e),n.push(e)}const l=a[e.id];o.get(i).nodes.push({id:e.id,key:e.key,value:"",contentType:"dynamic",ai:{prompt:l?.prompt??"",selectedSampleAiContent:l?.selectedContent??""}})}if(e.children)for(const t of e.children)va(t,e,n,o,a)}const xa={text:"text",image:"src"};function wa(e,t){if(0===t.size)return!0;if(e.id&&t.has(e.id)){const n=t.get(e.id),o=xa[e.key];o&&(e[o]=n,t.delete(e.id))}if(e.children)for(const n of e.children)if(wa(n,t))return!0;return 0===t.size}var Sa=Object.freeze({__proto__:null,jsonToHtml:function(e){return yn(e)},normalizeJson:function(e){const t="string"==typeof e?JSON.parse(e):e,n=[],o=new Map,a=t.aiContentRefs||{},i=t.blockList||[];for(const e of i)va(e,null,n,o,a);return{groups:n}},updateJsonWithMlContent:function(e,t){const n="string"==typeof e?JSON.parse(e):e,o=structuredClone(n),a=new Map;for(const e of t)e.variations.length>0&&a.set(e.nodeId,e.variations[0].value);const i=o.blockList||[];for(const e of i)if(wa(e,a))break;return o}});function Ca(e,t={}){const{validate:n=!0}=t,o=e?.current;if(!o||"function"!=typeof o.exportJson)throw new Error("exportTemplateJson: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const a=o.exportJson();if(!a||"object"!=typeof a)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:a,issues:n?On({blockList:a.blockList,bodySettings:a.bodySettings,aiContentRefs:a.aiContentRefs}):[]}}async function Na(e,t={}){const{validate:n=!0,checkImages:o=!0,imageProbe:a}=t,i=e?.current;if(!i||"function"!=typeof i.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const l=i.exportJson();if(!l||"object"!=typeof l)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");if(!n)return{payload:l,issues:[]};return{payload:l,issues:o?await Wn({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs},a):On({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs})}}const Ta=Object.freeze({keys:["content","catalogProducts","companyContext","brandContext","companyId"],description:"templateData drives placeholders, product columns, and menu/social sync. content.products + content.primaryProductId, when non-empty, override product column assignments on load. catalogProducts (optional array) is the KB/catalog list for the product picker and for newly added preset product blocks; it does not replace columnProducts in a saved template when content.products is empty. companyContext.navigation_links and companyContext.social_links sync into menu/social blocks; brandContext (including brand_color) resolves branding tokens and CTA/button fallback colors in HTML export."});function Ia(e={}){const t={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...e.content&&"object"==typeof e.content?e.content:{}},companyContext:{...t,...e.companyContext&&"object"==typeof e.companyContext?e.companyContext:{}},brandContext:{...n,..."string"==typeof e.brandColor&&e.brandColor.trim()?{brand_color:e.brandColor.trim()}:{},...e.brandContext&&"object"==typeof e.brandContext?e.brandContext:{}},companyId:null!=e.companyId?e.companyId:o}}function Aa(e){const t=[];if(null==e||"object"!=typeof e)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=e;if(null!=n.content&&"object"!=typeof n.content)t.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const e=n.content;null==e.products||Array.isArray(e.products)||t.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||t.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&t.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&t.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const e=n.brandContext;null!=e.brand_color&&"string"!=typeof e.brand_color&&t.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===t.length,warnings:t}}export{xn as DEFAULT_EMAIL_TEMPLATE_ID,_n as DEFAULT_MARKOPOLO_API_BASE_V1,vn as DEFAULT_ML_GENERATION_API_BASE_V1,ka as EmailEditor,Ta as TEMPLATE_DATA_SCHEMA,Ia as createDefaultTemplateData,ka as default,yn as exportNormalizerToHtml,Ca as exportTemplateJson,Na as exportTemplateJsonAsync,Sn as mergeMarkopoloApiConfig,Sa as utils,On as validateExportPayload,Wn as validateExportPayloadComplete,Vn as validateImageUrlsReachable,Aa as validateTemplateDataShape};
|
|
1
|
+
import e,{createContext as t,useContext as n,useCallback as o,useMemo as a,useState as i,useRef as l,useEffect as r,Fragment as s,useLayoutEffect as c,forwardRef as d,useReducer as p,useImperativeHandle as u}from"react";import{Modal as m,Input as g,Popover as y,Button as h,InputNumber as b,Spin as f,Select as k,Tooltip as _,Tabs as v,Switch as x,Slider as w,message as S}from"antd";import{FontAwesomeIcon as C}from"@fortawesome/react-fontawesome";import{faBold as N,faItalic as T,faUnderline as I,faStrikethrough as A,faListOl as L,faListUl as P,faLink as R,faUnlink as $,faExpandAlt as B,faCompressAlt as D,faImage as E,faUser as U,faTrash as M,faArrowsAlt as O,faLevelUpAlt as j,faDesktop as H,faMobileAlt as K,faUndo as z,faRedo as F,faInfoCircle as V,faAlignLeft as W,faAlignCenter as J,faAlignRight as q,faAlignJustify as G,faArrowsAltV as Y,faGripVertical as Z,faCloudUploadAlt as Q,faUserCircle as X,faTag as ee,faWindowMinimize as te,faWindowMaximize as ne,faCube as oe,faShareAltSquare as ae,faBars as ie,faGripLines as le,faMinusSquare as re,faFont as se,faColumns as ce,faChevronLeft as de}from"@fortawesome/free-solid-svg-icons";import{motion as pe}from"framer-motion";import{jsx as ue,jsxs as me,Fragment as ge}from"react/jsx-runtime";import{ChromePicker as ye}from"react-color";function he(e,t){if(!e||!t)return e;const n=t?.companyContext?.navigation_links,o=Array.isArray(n)&&n.length>0,a=t?.companyContext?.social_links,i=a&&"object"==typeof a&&Object.keys(a).length>0;if(!o&&!i)return e;const l={...e};let r=!1;return Object.keys(e).forEach(t=>{const s=e[t];if(s){if("menu"===s.key&&s.useNavigationLinks&&o){const e=n.map(e=>({label:e.label??"Link",url:e.url??"#",target:e.target??"_self"}));l[t]={...s,list:e},r=!0}if("social_link"===s.key&&s.useCompanySocialLinks&&i){const e="https://s.magecdn.com/social",n=[{key:"facebook",image:`${e}/tc-facebook.svg`,title:"Facebook"},{key:"twitter",image:`${e}/tc-x.svg`,title:"Twitter"},{key:"instagram",image:`${e}/tc-instagram.svg`,title:"Instagram"},{key:"linkedin",image:`${e}/tc-linkedin.svg`,title:"LinkedIn"},{key:"tiktok",image:`${e}/tc-tiktok.svg`,title:"TikTok"},{key:"youtube",image:`${e}/tc-youtube.svg`,title:"YouTube"}].map(({key:e,image:t,title:n})=>{const o=a[e];return{image:t,title:n,linkURL:null!=o&&String(o).trim()?String(o).replace(/^https?:\/\//,""):""}});l[t]={...s,list:n},r=!0}}}),r?l:e}const be=e=>{const t=e.constructor===Array?[]:{};for(let n in e)e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]?(t[n]=e[n].constructor===Array?[]:{},t[n]=be(e[n])):t[n]=e[n]);return t},fe=(e,t)=>{let n=null;return function(){n||(n=setTimeout(()=>{e.apply(this,arguments),n=null},t))}};function ke(e,t={}){if(null==e||"string"!=typeof e)return e;const n=null!=t.fontSize?Number(t.fontSize):14,o=null!=t.fontFamily?String(t.fontFamily):"sans-serif",a=null!=t.color?String(t.color):"",i=["direction: ltr",`font-size: ${n}px`,`font-family: ${o}`];a&&i.push(`color: ${a}`);const l=i.join("; ");let r=function(e){if(null==e||"string"!=typeof e)return e;let t=e.replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*font-size\s*:[^;]+;?/gi,"").replace(/\s*font-family\s*:[^;]+;?/gi,"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^;\s*|;\s*$/g,"").trim();return n?` style="${n}"`:""}),n="";for(let e=0;e<20&&n!==t;e++)n=t,t=t.replace(/<font(\s[^>]*)?>([\s\S]*?)<\/font>/gi,"$2");return t}(e.trim());const s=/^<span(?:\s[^>]*)?>([\s\S]*)<\/span>$/i.exec(r.trim()),c=/^<div(?:\s[^>]*)?>([\s\S]*)<\/div>$/i.exec(r.trim());return s?r=s[1]:c&&(r=c[1]),`<span style="${l}">${r}</span>`}function _e(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ve(e){if(!e||"object"!=typeof e)return;e.id||(e.id=_e());const t=e.children;Array.isArray(t)&&t.forEach(ve)}function xe(e){if(!e||"object"!=typeof e)return e;const t=be(e);return ve(t),t}function we(e="Drag block here"){return{id:_e(),name:e,key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function Se(e){const t={},n=[];function o(e){if(e&&"object"==typeof e)if(e.id||(e.id=_e()),"column"===e.key){const n=(e.children||[]).map(e=>{e.id||(e.id=_e());const t=[];return(e.children||[]).forEach(e=>{e.id||(e.id=_e()),o(e),t.push(e.id)}),{id:e.id,width:e.width,styles:e.styles,childrenIds:t}}),{children:a,...i}=e;t[e.id]={...i,cells:n}}else t[e.id]=e}return(e||[]).forEach(e=>{e.id||(e.id=_e()),o(e),n.push(e.id)}),{blockMap:t,rootOrder:n}}function Ce(e,t){function n(t){const o=e[t];if(!o)return null;if("column"===o.key){const e=(o.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>n(e)).filter(Boolean)})),{cells:t,...a}=o;return{...a,children:e}}return{...o}}return(t||[]).map(e=>n(e)).filter(Boolean)}function Ne(e,t){const n=t[e];if(!n)return null;if("column"!==n.key)return n;const o=(n.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>{const n=t[e];return n?"column"===n.key?Ne(e,t):n:null}).filter(Boolean)})),{cells:a,...i}=n;return{...i,children:o}}function Te(e,t,n){function o(t){const a=e[t];if(!a||"column"!==a.key)return null;for(let i=0;i<(a.cells||[]).length;i++){const l=a.cells[i];for(let a=0;a<(l.childrenIds||[]).length;a++){if(l.childrenIds[a]===n)return{containerId:t,cellIndex:i,itemIndex:a};const r=e[l.childrenIds[a]];if(r&&"column"===r.key){const e=o(l.childrenIds[a]);if(e)return e}}}return null}for(const e of t||[]){const t=o(e);if(t)return t}return null}function Ie(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return[{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}]}function a(t,o=[]){const i=e[t];if(!i||"column"!==i.key)return null;for(let t=0;t<(i.cells||[]).length;t++){const l=i.cells[t];for(let r=0;r<(l.childrenIds||[]).length;r++){const s=l.childrenIds[r];if(s===n)return[{containerBlock:i,containerType:i?.containerType??"none",cellIndex:t,isRoot:!1},...o];const c=e[s];if(c&&"column"===c.key){const e=a(s,[{containerBlock:i,containerType:i?.containerType??"none",cellIndex:t,isRoot:!1},...o]);if(e)return e}}}return null}for(const e of t||[]){const t=a(e,[]);if(t)return t}return[]}function Ae(e,t,n){const o=Ie(e,t,n),a=o.find(e=>e?.containerType&&"none"!==e.containerType)||o[0]||null,i=a?.cellIndex??0,l=a?.containerBlock??null,r=l?.columnProducts?.[i]??null,s=Array.isArray(l?.columnProducts)?l.columnProducts.find(e=>null!=e)??null:null;return{containerType:a?.containerType??"none",columnIndex:i,columnProduct:r??s,containerBlock:l,lineage:o}}function Le(e,t,n,o,a){const i=e[t];if(!i)return e;const l=i.cells.map((e,t)=>{if(t!==n)return e;const i=[...e.childrenIds];return i[o]=a,{...e,childrenIds:i}});return{...e,[t]:{...i,cells:l}}}function Pe(e,t,n,o){const a=e[t];if(!a)return{blockMap:e,removedId:null};const i=a.cells[n];if(!i)return{blockMap:e,removedId:null};const l=i.childrenIds[o],r=[...i.childrenIds];r.splice(o,1);const s=a.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{blockMap:{...e,[t]:{...a,cells:s}},removedId:l}}function Re(e,t,n,o,a){const i=e[t];if(!i)return e;const l=i.cells[n];if(!l)return e;const r=[...l.childrenIds];r.splice(o,0,a);const s=i.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{...e,[t]:{...i,cells:s}}}function $e(e,t){const n={...e};return function e(t){const o=n[t];o&&("column"===o.key&&(o.cells||[]).forEach(t=>(t.childrenIds||[]).forEach(t=>e(t))),delete n[t])}(t),n}function Be(e,t){if(!t)return{newBlockMap:e,rootId:null};if("column"===t.key){const{blockMap:n,rootOrder:o}=Se([t]);return{newBlockMap:{...e,...n},rootId:o[0]??null}}return{newBlockMap:{...e,[t.id]:t},rootId:t.id}}const De="SET_BLOCK_LIST",Ee="SET_BLOCKS",Ue="SET_IS_DRAG_START",Me="SET_ACTION_TYPE",Oe="SET_PREVIEW_MODE",je="SET_CURRENT_ITEM",He="SET_BODY_SETTINGS",Ke="SET_SELECTION_RANGE",ze="SET_TEXT_RANGE",Fe="SET_LANGUAGE",Ve="SET_LANGUAGE_LIBRARIES",We="SET_TEMPLATE_VARIABLES",Je=e=>({type:Me,actionType:e}),qe=e=>({type:je,currentItem:e}),Ge={blockMap:{},rootOrder:[],blockList:[],isDragStart:!1,actionType:"firstRender",previewMode:"desktop",currentItem:null,bodySettings:{preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}},selectionRange:null,textRange:null,language:"en",languageLibraries:{},templateData:null},Ye=t();function Ze(e,t,n){const o=he(t,e.templateData),a=Ce(o,n);let{currentItem:i}=e;if(i?.id&&o[i.id]){const e=Ne(i.id,o);e&&e!==i.data&&(i={...i,data:e})}return{...e,blockMap:o,rootOrder:n,blockList:a,currentItem:i}}function Qe(e,t){switch(t.type){case Ee:return Ze(e,t.blockMap,t.rootOrder);case De:{const{blockMap:n,rootOrder:o}=Se(t.blockList);return Ze(e,n,o)}case Ue:return{...e,isDragStart:t.isDragStart};case Me:return{...e,actionType:t.actionType};case Oe:return{...e,previewMode:t.previewMode};case je:{let n=t.currentItem;if(n?.id&&"column"===n.data?.key&&e.blockMap[n.id]){const t=Ne(n.id,e.blockMap);t&&(n={...n,data:t})}return{...e,currentItem:n}}case He:return{...e,bodySettings:t.bodySettings};case Ke:return{...e,selectionRange:t.selectionRange};case ze:return{...e,textRange:t.textRange};case Fe:return{...e,language:t.language};case Ve:return{...e,languageLibraries:t.languageLibraries};case We:{const n=t.templateData,o=he(e.blockMap,n),a=Ce(o,e.rootOrder);return{...e,templateData:n,blockMap:o,blockList:a}}default:return e}}var Xe={global:[{key:"CustomerName",token:"{{CustomerName}}",label:"Customer Name",labelKey:"variable_customer_name",type:"text",fallback:"Customer",source:"derived"},{key:"BrandName",token:"{{BrandName}}",label:"Brand Name",labelKey:"variable_brand_name",type:"text",fallback:"Company Name",source:"companyContext.name"},{key:"Tagline",token:"{{Tagline}}",label:"Tagline",labelKey:"variable_tagline",type:"text",fallback:"Your tagline here",source:"brandContext.tagline"},{key:"LogoUrl",token:"{{LogoUrl}}",label:"BrandLogo",labelKey:"variable_image_logo",type:"image",fallback:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",source:"brandContext.logo_url"},{key:"Website",token:"{{Website}}",label:"Website",labelKey:"variable_website",type:"text",fallback:"www.example.com",source:"companyContext.website"},{key:"Address",token:"{{Address}}",label:"Address",labelKey:"variable_address",type:"text",fallback:"123 Main St, City, Country",source:"companyContext.address"}],product:[{key:"ProductName",token:"{{ProductName}}",label:"Product Name",labelKey:"variable_product_name",type:"text",fallback:"Product Name",source:"content.products[].name"},{key:"ProductDescription",token:"{{ProductDescription}}",label:"Product Description",labelKey:"variable_product_description",type:"text",fallback:"Product description goes here.",source:"content.products[].description"},{key:"ProductImage",token:"{{ProductImage}}",label:"Product Image URL",labelKey:"variable_product_image",type:"image",fallback:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",source:"content.products[].image"},{key:"ProductLink",token:"{{ProductLink}}",label:"Product Link",labelKey:"variable_product_link",type:"url",fallback:"https://www.example.com",source:"content.products[].link"},{key:"ProductPrice",token:"{{ProductPrice}}",label:"Product Price (Amount)",labelKey:"variable_product_price",type:"number",fallback:"0",source:"content.products[].price.amount"},{key:"ProductCurrency",token:"{{ProductCurrency}}",label:"Product Currency",labelKey:"variable_product_currency",type:"text",fallback:"USD",source:"content.products[].price.currency"},{key:"ProductOldPrice",token:"{{ProductOldPrice}}",label:"Product Old Price",labelKey:"variable_product_old_price",type:"number",fallback:"0",source:"content.products[].old_price"},{key:"ProductNewPrice",token:"{{ProductNewPrice}}",label:"Product New Price",labelKey:"variable_product_new_price",type:"number",fallback:"0",source:"content.products[].new_price"},{key:"ProductPriceDisplay",token:"{{ProductPriceDisplay}}",label:"Product Price Display",labelKey:"variable_product_price_display",type:"text",fallback:"USD 0",source:"derived"}],discount:[{key:"DiscountValue",token:"{{DiscountValue}}",label:"Discount Value",labelKey:"variable_discount_value",type:"text",fallback:"20%",source:"content.discount.value"},{key:"DiscountCode",token:"{{DiscountCode}}",label:"Discount Code",labelKey:"variable_discount_code",type:"text",fallback:"SAVE20",source:"content.discount.code"},{key:"ValidUntil",token:"{{ValidUntil}}",label:"Valid Until",labelKey:"variable_valid_until",type:"date",fallback:"12-31-2025",source:"content.discount.valid_until"}]};const et=[{value:"none",labelKey:"container_type_none"},{value:"discount",labelKey:"container_type_discount"},{value:"product",labelKey:"container_type_product"}],tt="CustomerName",nt="DiscountValue",ot="DiscountCode",at="ValidUntil",it="CompanyName",lt="Address",rt="Website",st="BrandName",ct="LogoUrl",dt="Tagline",pt="HeroBanner",ut="FooterBanner",mt="NavLabel",gt="NavUrl",yt="ProductName",ht="ProductDescription",bt="ProductImage",ft="ProductLink",kt="ProductPrice",_t="ProductCurrency",vt="ProductOldPrice",xt="ProductNewPrice",wt="ProductPriceDisplay",St="CTALabel",Ct="CTAUrl",Nt=new Set([vt,xt]);function Tt(e){return`{{${e}}}`}const It=Xe;let At=It;function Lt(e,t=At){return t&&Array.isArray(t[e])?t[e].map(e=>({...e,token:e.token||Tt(e.key)})):[]}let Pt=[],Rt=[],$t=[],Bt={},Dt=[],Et=[],Ut=[];function Mt(){Pt=Lt("global",At),Rt=Lt("product",At),$t=Lt("discount",At),Bt=[...Pt,...Rt,...$t].reduce((e,t)=>(e[t.key]=t,e),{}),Dt=$t.map(e=>({variableKey:e.key,labelKey:e.labelKey}));const e=Rt.filter(e=>!Nt.has(e.key));Et=e.map(e=>({variableKey:e.key,labelKey:e.labelKey})),Ut=Pt.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),$t.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),e.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type}))}Mt();const Ot={[tt]:"Customer",[nt]:"20%",[ot]:"SAVE20",[at]:"12-31-2025",[it]:"Company Name",[st]:"Company Name",[lt]:"123 Main St, City, Country",[rt]:"www.example.com",[ct]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[dt]:"Your tagline here",[pt]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[ut]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[mt]:"Link",[gt]:"https://www.example.com",[yt]:"Product Name",[ht]:"Product description goes here.",[bt]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[ft]:"https://www.example.com",[kt]:"0",[_t]:"USD",[vt]:"0",[xt]:"0",[wt]:"USD 0",[St]:"Shop Now",[Ct]:"www.example.com"};function jt(e){return null==e||"string"!=typeof e?"":e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ht=new Set([wt]);function Kt(e,t,n={}){if(null==e||"string"!=typeof e)return"";const o=e.replace(/\{\{(\w+)\}\}/g,(e,o)=>{const a=Wt(t,o,n);return Ht.has(o)?a:jt(a)});return null==(a=o)||"string"!=typeof a?a:a.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>| )?\s*<\/p>\s*)+/i,"");var a}function zt(e){return Ot[e]??"—"}const Ft=/^\{\{\s*[\w.]+\s*\}\}$/;function Vt(e,t,{allowEmpty:n=!1}={}){if(null==e)return zt(t);const o=String(e).trim();return n||""!==o?function(e){return"string"==typeof e&&Ft.test(e.trim())}(o)?zt(t):o:zt(t)}function Wt(e,t,n={}){if(!e)return zt(t);const{columnIndex:o,columnProduct:a}=n;let i=a;switch(!i&&e.content?.products&&"number"==typeof o&&(i=e.content.products[o]||null),t){case tt:return zt(tt);case nt:return Vt(e.content?.discount?.value,nt);case ot:return Vt(e.content?.discount?.code,ot);case at:return Vt(e.content?.discount?.valid_until,at);case it:case st:return Vt(e.companyContext?.name,t);case lt:return Vt(e.companyContext?.address,lt);case rt:return Vt(e.companyContext?.website,rt);case ct:return Vt(e.brandContext?.logo_url,ct);case dt:return Vt(e.brandContext?.tagline,dt);case pt:return Vt(e.brandContext?.heroBanner,pt);case ut:return Vt(e.brandContext?.footerBanner,ut);case mt:case gt:return zt(t);case yt:return Vt(i?.name,yt);case ht:return Vt(i?.description,ht);case bt:return Vt(i?.image,bt);case ft:return Vt(i?.link,ft);case kt:return null!=i?.price&&"number"==typeof i.price||null!=i?.price&&"string"==typeof i.price?String(i.price):null!=i?.new_price?String(i.new_price):zt(kt);case _t:return Vt(i?.currency,_t);case vt:return Vt(i?.old_price,vt);case xt:return null!=i?.new_price?Vt(i.new_price,xt):null!=i?.price?Vt(i.price,xt):zt(xt);case wt:{const e=null!=i?.currency?String(i.currency):"",t=null!=i?.price?String(i.price):null!=i?.new_price?String(i.new_price):null,n=null!=i?.old_price||null!=i?.new_price,o=null!=i?.old_price?String(i.old_price):null,a=null!=i?.new_price?String(i.new_price):null!=i?.price?String(i.price):null;if(n&&(null!=o||null!=a)){const t=null!=o?jt(e?`${e} ${o}`:o):"";return[""!==t?`<span style="text-decoration: line-through;">${t}</span>`:"",null!=a?jt(e?`${e} ${a}`:a):""].filter(Boolean).join(" ")||zt(wt)}return e&&null!=t?jt(`${e} ${t}`):zt(wt)}case St:{const t=e.content?.cta?.text;return Vt(t,St)}case Ct:{const t=e.content?.cta?.url;return Vt(null!=t?t:e.companyContext?.website,Ct)}default:return zt(t)}}const Jt=[{variableKey:ct,labelKey:"variable_image_logo"},{variableKey:pt,labelKey:"variable_image_hero_banner"},{variableKey:ut,labelKey:"variable_image_footer_banner"}],qt=[{variableKey:bt,labelKey:"variable_image_product_image"}],Gt=[{variableKey:St,labelKey:"variable_cta_label"}],Yt=[{variableKey:Ct,labelKey:"variable_cta_url"}];function Zt(e,t,n,o={}){let a=[];return"discount"===t?a=[...Dt]:"product"===t&&(a=[...Et]),a.map(({variableKey:e,labelKey:t})=>({...Bt[e]||{},variableKey:e,labelKey:t,value:Tt(e),pasteValue:Wt(n,e,o)}))}function Qt(e,t,n,o={},a=[]){const i="none"===t?Ut.map(e=>({...e,pasteValue:Wt(n,e.key,o)})):Zt(0,t,n,o),l=(a||[]).filter(e=>e&&e.containerType&&"none"!==e.containerType).flatMap(e=>Zt(0,e.containerType,n,e.context||{})),r=new Set,s=[];return[...i,...l].forEach(e=>{const t=e.variableKey||e.key||e.value;t&&!r.has(t)&&(r.add(t),s.push(e))}),s}const Xt={display_text:"DisplayText",introduction:"Introduction",heading:"Heading",subheading:"Subheading",products_description:"ProductDescription"};function en(e,t,n,o){return{value:Tt(e),labelKey:t,variableKey:e,key:e,type:"image",pasteValue:Wt(n,e,o)}}function tn(e,t,n={}){const o=Jt.map(({variableKey:e,labelKey:o})=>en(e,o,t,n));if("product"===e){const e=qt.map(({variableKey:e,labelKey:o})=>en(e,o,t,n));return[...o,...e]}return o}function nn(e){return!1!==e?.linkEnabled}const on=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),an=e=>on(e).replace(/"/g,""").replace(/'/g,"'"),ln=(e,t="#")=>{if(null==e)return t;const n=String(e).trim();if(!n)return t;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?t:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)||/^tel:/i.test(n)?n:n.startsWith("//")?`https:${n}`:/^[a-z][a-z\d+.-]*:/i.test(n)?n:`https://${n.replace(/^\/+/,"")}`},rn=(e,t)=>{const n=new RegExp(/[A-Z]/g),o=e=>e.replace(n,e=>`-${e.toLowerCase()}`),a={desktop:t?.desktop??{},mobile:t?.mobile??{}};let i={className:e,desktop:"",mobile:""};for(let e of Object.entries(a.desktop))e[1]&&"contentBackground"!==e[0]&&(i.desktop+=`${o(e[0])}:${"number"==typeof e[1]?e[1]+"px":e[1]};`);if(Object.keys(a.mobile).length){let t="";for(let e of Object.entries(a.mobile))e[1]&&"contentBackground"!==e[0]&&(t+=`${o(e[0])}:${"number"==typeof e[1]?e[1]+"px":e[1]} !important;`);i.mobile+=`@media(max-width:620px){\n .${e} {\n ${t}\n }\n }`}return i},sn=(e,t="",n)=>{const o=e.map((e,o)=>{let a={...e};const i={desktop:e?.styles?.desktop??{},mobile:e?.styles?.mobile??{}};if(a.styleConfig=rn(n?`${n}-${e.key}-${o}`:`${e.key}-${o}`,i),a.contentStyles){const n={desktop:a.contentStyles?.desktop??{},mobile:a.contentStyles?.mobile??{}};a.contentStyleConfig=rn(`${e.key}-content-${o}`,n),a.contentStyleConfig.mobile&&(t+=a.contentStyleConfig.mobile)}if(a.styleConfig.mobile&&(t+=a.styleConfig.mobile),i.desktop.contentBackground&&(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:`background-color:${i.desktop.contentBackground};`,mobile:""}),i.mobile.contentBackground&&(a.contentStyleConfig||(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:"",mobile:""}),a.contentStyleConfig.mobile=` @media(max-width:620px){\n .${a.contentStyleConfig.className} {background-color:${i.mobile.contentBackground};}\n }`,t+=a.contentStyleConfig.mobile),e.children?.length){const{newBlockList:n,styles:i}=sn(e.children,t,o);t+=i,a.children=n}return{...a}});return{newBlockList:o,styles:t}};function cn(e,t){return e&&t?String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=`${e?`${e}; `:""}color: ${t};`;return`<a${n.replace(o[0],` style="${a}"`)}>`}return`<a${n} style="color: ${t};">`}):e}function dn(e){const t=String(e??"");return null!=(n=t)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(e){if(!e||!/<a\b/i.test(e))return e;const t=(e,t,n)=>{const o=(t[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=(o?`${o}; `:"")+"text-decoration: none;",i='"'===n?` style="${a}"`:` style='${a}'`;return`<a${e.replace(t[0],i)}>`};return String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return t(n,o,'"');const a=n.match(/\sstyle\s*=\s*'([^']*)'/i);return a?t(n,a,"'"):`<a${n} style="text-decoration: none;">`})}(t):on(t);var n}const pn=(e,t,n={})=>{let o=e.dynamicSelectedContent??e.text??"";t&&o&&(o=Kt(o,t,n));return o=cn(o,e?.styles?.desktop?.linkColor||e?.styles?.desktop?.color),`<${e.type} ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">\n ${o}\n </${e.type}>`},un=(e,t,n,o,a,i)=>{let l="";const r={columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null};return e.forEach((e,s)=>{if("column"===e.key){const r=e.styles?.desktop?.borderRadius,c=r?`border-radius:${"number"==typeof r?r+"px":r};`:"",d=c?"overflow:hidden;":"",p=e.containerType&&"none"!==e.containerType?e:o,u=e.containerType&&"none"!==e.containerType?s:a,m=e.containerType&&"none"!==e.containerType?0:i;l+=`<div ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig.desktop};width:100%;display:block;${d}">\n <table ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="width:100%;max-width:${t.contentWidth}px;margin:0 auto;${c}${e.contentStyleConfig.desktop}">\n <tbody><tr>${un(e.children,t,n,p,u,m)}</tr></tbody>\n </table></div>`}if("content"===e.key&&(l+=`<td ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="width:${e.width}; ${e.styleConfig.desktop}">${un(e.children,t,n,o,a,s)}</td>`),"text"===e.key){const t=null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r;e.type&&/^h[1-4]$/.test(e.type)?l+=pn(e,n,t):l+=((e,t,n={},o=null)=>{let a=e.dynamicSelectedContent??e.text??"";t&&a&&(a=Kt(a,t,n)),a=cn(a,e?.styles?.desktop?.linkColor||e?.styles?.desktop?.color);const i="footer"===o?.containerType,l=null==(r=a)||"string"!=typeof r?"":r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var r;return!i||""!==l&&"{{Address}}"!==l&&"{{Tagline}}"!==l?`<div ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">${a}</div>`:""})(e,n,t,o)}if("heading"===e.key&&(l+=pn(e,n,r)),"image"===e.key){l+=((e,t,n={})=>{let o=e.src||"";const a="string"==typeof e.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(e.src.trim())?e.src.trim():"";if(t&&a){const e=Wt(t,a.replace(/^\{\{\s*|\s*\}\}$/g,""),n);e&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(e).trim())&&(o=e)}const i=`<img src="${an(o)}" alt="${an(e.alt||"Image")}" style="max-width:100%;${e.styleConfig.desktop}" \n ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""}/>`,l=null!=e.linkURL?String(e.linkURL).trim():"",r=nn(e)&&""!==l?`<a href="${an(ln(l))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;">${i}</a>`:i;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n ${r}\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r)}if("button"===e.key){l+=((e,t,n={})=>{let o=e.text||"",a=e.linkURL||"";if(t){const i=o.match(/\{\{(\w+)\}\}/),l=e.labelVariable?e.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():i?i[1]:void 0;if(l){const e=Wt(t,l,n);null==e||String(e).startsWith("{{")||(o=String(e))}if(e.urlVariable){const o=Wt(t,e.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(a=String(o))}}const i=dn(o),l=an(ln(a)),r=e.styleConfig.desktop||"",s=r.includes("background-color:")?"":`background-color:${(e=>e?.brandContext?.brand_color??"#111111")(t)};`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n <a ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${r}${s}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${l}">${i}</a>\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[i??0]??null}:r)}var c,d,p;"divider"===e.key&&(l+=`<div ${(c=e).contentStyleConfig.mobile?`class="${c.contentStyleConfig.className}"`:""} \n style="${c.contentStyleConfig.desktop}">\n <div ${c.styleConfig.mobile?`class="${c.styleConfig.className}"`:""} \n style="${c.styleConfig.desktop}"></div>\n </div>`),"spacer"===e.key&&(l+=(d=e,`<div ${d.contentStyleConfig?.mobile?`class="${d.contentStyleConfig.className}"`:""} \n style="${d.contentStyleConfig?.desktop||""}">\n <div ${d.styleConfig?.mobile?`class="${d.styleConfig.className}"`:""} \n style="${d.styleConfig?.desktop||""}"></div>\n </div>`)),"menu"===e.key&&(l+=(e=>{const t=e.list||[],n=null!=e.separator?String(e.separator):" | ",o=e.styleConfig?.desktop||"",a=e.contentStyleConfig?.desktop||"",i=t.map(e=>{const t=ln(e.url,"#"),n="_blank"===e.target?"_blank":"_self",a=on(e.label||"Link");return`<a target="${n}" href="${an(t)}" style="${o};text-decoration:none;display:inline-block;">${a}</a>`}).join(n);return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${a}">${i}</div>`})(e)),"avatar"===e.key&&(l+=(e=>{const t=e.src||"",n=e.alt||"Avatar",o=e.linkURL,a=e.styleConfig?.desktop||"",i=e.styles?.desktop?.width??64,l=`max-width:100%;width:${"number"==typeof i?i+"px":i};height:${"number"==typeof i?i+"px":i};object-fit:cover;border-radius:${e.styles?.desktop?.borderRadius??"50%"};${a}`,r=an(t),s=an(n),c=t?`<img src="${r}" alt="${s}" style="${l}" />`:`<div style="${l};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=e.contentStyleConfig?.desktop||"",p=o?`<a href="${an(ln(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${d}">${p}</div>`})(e)),"social_link"===e.key&&(l+=`<div ${(p=e).contentStyleConfig.mobile?`class="${p.contentStyleConfig.className}"`:""} \n style="${p.contentStyleConfig.desktop}">\n ${p.list.map(e=>{const{image:t,title:n,linkURL:o}=e;return`<a target="_blank" rel="noopener noreferrer" href="${an(ln(o))}" style="${p.styleConfig.desktop};display:inline-block;">\n <img src="${an(t)}" alt="${an(n)}" style="width:${p.imageWidth}px;" \n ${p.styleConfig.mobile?`class="${p.styleConfig.className}"`:""}/> \n </a>`}).join("")}\n </div>`)}),l},mn={preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}},gn=({bodySettings:e,blockList:t,templateData:n})=>{let o="";const a=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??null;if(!a)return e;const i=n.filter(e=>e?.id!==a.id),l=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(l):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===i.length?a:i[t%i.length]);return{...e,children:t,columnProducts:r}};return e.map(l)})(t,n),{newBlockList:i,styles:l}=sn(a);return o=un(i,e,n),`<html>\n <head>\n <meta charset="UTF-8">\n <title>email</title>\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style type="text/css">\n *{\n margin: 0;\n padding: 0;\n border: none;\n box-sizing: border-box;\n }\n\n html,body {\n height:100%;\n overflow-y:auto;\n }\n\n table {\n width: 100%;\n color:unset;\n }\n\n table, tr, td {\n vertical-align: top;\n border-collapse: collapse;\n }\n\n h1,h2,h3,h4 {\n display: block;\n margin-block-start: 0px;\n margin-block-end: 0px;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n font-weight: bold;\n }\n\n @media(max-width:620px){\n td {\n display:inline-block;\n width:100% !important;\n }\n }\n ${l}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${e.preHeader}</div>\n <div style="background-color:${e.styles.backgroundColor};color:${e.styles.color}; font-family:${e.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function yn(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==t)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...mn,styles:{...mn.styles}};Array.isArray(t)?n=t:"object"==typeof t&&(n=Array.isArray(t.blockList)?t.blockList:[],t.bodySettings&&"object"==typeof t.bodySettings&&(o={preHeader:null!=t.bodySettings.preHeader?t.bodySettings.preHeader:mn.preHeader,contentWidth:Number(t.bodySettings.contentWidth)||mn.contentWidth,styles:{backgroundColor:t.bodySettings.styles?.backgroundColor??mn.styles.backgroundColor,color:t.bodySettings.styles?.color??mn.styles.color,fontFamily:t.bodySettings.styles?.fontFamily??mn.styles.fontFamily}}));return`<!DOCTYPE html>\n${gn({bodySettings:o,blockList:n,templateData:t.templateData})}`}const hn=["product"];function bn(e){return Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[]}function fn(e,t={}){if(!e||"object"!=typeof e)return e;if("image"===e.key){const n="string"==typeof e.imageVariable&&/^\{\{\w+\}\}$/.test(e.imageVariable.trim())?e.imageVariable.trim():"",o="string"==typeof e.src&&/^\{\{\w+\}\}$/.test(e.src.trim())?e.src.trim():"",{imageVariable:a,...i}=e;return{...i,src:o||n||e.src,children:bn(e.children).map(e=>fn(e,t))}}if("column"===e.key){const{ctaText:n,...o}=e,a=e.containerType,i=function(e){return null==e||"none"===e?"none":"discount"===e?"discount":"product"===e||"hero_product"===e||"additional_product"===e?"product":"none"}(a),l="product"===i?e.productRole??("additional_product"===a?"additional":"main"):void 0,r=bn(e.children);let s=e.columnProducts;if(hn.includes(i)){const e=r.length;Array.isArray(s)||(s=[]),s=Array.from({length:e},(e,t)=>s[t]??null)}else s=[];return{...o,containerType:i,productRole:l,columnProducts:s,children:(r||[]).map(e=>fn(e,t))}}if("heading"===e.key){const n=e.id?t?.[e.id]:null,o={...e,key:"text",name:e.name,type:e.type||"h1",contentType:e.contentType??"static",text:e.text,styles:e.styles,contentStyles:e.contentStyles,selectedVariableKey:e.selectedVariableKey,dynamicVariable:n?.variable??e.dynamicVariable,dynamicPrompt:n?.prompt??e.dynamicPrompt,dynamicSelectedContent:n?.selectedContent??e.dynamicSelectedContent,dynamicOptions:Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:e.dynamicOptions};return"dynamic"===o.contentType&&(o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[]),{...o,children:bn(e.children).map(e=>fn(e,t))}}if("text"===e.key){const n=e.id?t?.[e.id]:null,o=e.contentType??"static",a={...e,type:e.type||"p",contentType:o};return"dynamic"===o&&(a.dynamicVariable=n?.variable??e.dynamicVariable??"",a.dynamicPrompt=n?.prompt??e.dynamicPrompt??"",a.dynamicSelectedContent=n?.selectedContent??e.dynamicSelectedContent??"",a.dynamicOptions=Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[]),{...a,children:bn(e.children).map(e=>fn(e,t))}}return{...e,children:bn(e.children).map(e=>fn(e,t))}}function kn(e,t={}){const n=Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):null;if(!Array.isArray(n))return e;const o=n.map(e=>fn(e,t));return o.forEach(ve),o}const _n="https://api-alpha.markopolo.ai/v1",vn="https://nbq-ml-api-stg.markopolo.ai/v1",xn="95b48b5b-cf5e-486d-817e-9839d4c4e618";function wn(e,t){const n=null!=(o=e)&&"string"==typeof o&&o.trim()?o.replace(/\/$/,""):_n;var o;const a=function(e){return null!=e&&"string"==typeof e&&e.trim()?e.replace(/\/$/,""):vn}(t);return{imageUploadEndpoint:`${n}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${n}/knowledge-base/products`,mlEmailNodesEndpoint:`${a}/ml-service/content/generate-email-nodes`}}function Sn(e={}){const t=e&&"object"==typeof e?e:{},{apiBaseUrlV1:n,apiBaseV1:o,mlGenerationApiBaseUrlV1:a,mlApiBaseUrlV1:i,headers:l,...r}=t,s=n||o||_n,c="undefined"!=typeof process&&process.env?.REACT_APP_ML_API_BASE_V1,d=wn(s,a||i||c||vn),p="undefined"!=typeof process?String(process.env?.REACT_APP_EMAIL_TEMPLATE_ID??"").trim():"",u={...d,...r},m=String(u.emailTemplateId??"").trim()||p||xn;return{...u,emailTemplateId:m,headers:{...u.headers||{},...l||{}}}}const Cn={preHeader:"",contentWidth:600,styles:{backgroundColor:"#f5f5f5",color:"#152b2a",fontFamily:"Arial"}};function Nn(e){if(!e||"object"!=typeof e)return"";return`${e.severity??"unknown"}:${e.code??"issue"}:${e.blockId??"global"}:${e.location??""}`}function Tn(e,t=!1){if(null==e||""===String(e).trim())return t;const n=String(e).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const In={text:"Text",heading:"Heading",button:"Button",image:"Image",avatar:"Profile image",menu:"Menu",social_link:"Social links"};const An={none:"Container",product:"Product",discount:"Discount",header:"Header",footer:"Footer",navigation_bar:"Navigation",introduction:"Introduction",hero:"Hero",hero_product:"Hero product",body:"Body",additional_product:"Additional product"};function Ln(e,t,n){const o=e.containerType??"none",a=function(e){const t=e??"none";return An[t]?An[t]:String(t).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(o);return n<=1?a:"none"===o?`${Pn(t+1)} section`:`${Pn(t+1)} ${a} block`}function Pn(e){const t=e%10,n=e%100;return 1===t&&11!==n?`${e}st`:2===t&&12!==n?`${e}nd`:3===t&&13!==n?`${e}rd`:`${e}th`}function Rn(e,t){return t<=1?null:`${Pn(e+1)} of ${t} stacked blocks`}function $n(e,t,n,o){const a=function(e){return In[e]?In[e]:String(e||"block").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(t),i=[...e];o&&i.push(o);const l=i.length>0?i.join(" → "):"Email body";return n?`${a} ("${n}") — ${l}`:`${a} — ${l}`}function Bn(e,t){const n=function(e){return null==e||"object"!=typeof e?{...Cn,styles:{...Cn.styles}}:{preHeader:null!=e.preHeader?e.preHeader:Cn.preHeader,contentWidth:Number(e.contentWidth)||Cn.contentWidth,styles:{backgroundColor:null!=e.styles?.backgroundColor?e.styles.backgroundColor:Cn.styles.backgroundColor,color:null!=e.styles?.color?e.styles.color:Cn.styles.color,fontFamily:null!=e.styles?.fontFamily?e.styles.fontFamily:Cn.styles.fontFamily}}}(e);("number"!=typeof n.contentWidth||n.contentWidth<=0)&&t.push({severity:"error",code:"body_content_width_invalid",message:"Body content width must be a positive number.",location:"Theme settings"});const o=n.styles;null!=o.backgroundColor&&""!==String(o.backgroundColor).trim()||t.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||t.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||t.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function Dn(e,t){e.push(t)}const En=["product"];function Un(e,t,n,o,a,i){if("dynamic"!==(e.contentType??"static"))return;const l=e.dynamicSelectedContent,r=null!=e?.id?i?.[e.id]?.selectedContent:void 0;let s=null!=l&&""!==String(l).trim()?l:r;var c;null!=s&&""!==String(s).trim()||null==e.text||""===(null==(c=e.text)?"":String(c).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=e.text),null!=s&&""!==String(s).trim()||Dn(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:$n(t,o,void 0,a),blockId:e.id??null})}function Mn(e,t,n,o,a){if(!Array.isArray(e))return;const i=e.length;e.forEach((e,l)=>{if(!e||"object"!=typeof e)return;const r=e.key;if("column"===r){const r=Ln(e,l,i),s=[...t,r];return function(e,t,n){const o=e.containerType??"none";if(!En.includes(o))return;const a=e.children??[],i=e.columnProducts??[];a.forEach((o,l)=>{const r=i[l];if(null==r||"object"==typeof r&&!r.id){const o=a.length>1?`Column ${l+1} of ${a.length}`:"This column",i=[...t,o].join(" → ");Dn(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:i,blockId:e.id??null})}})}(e,s,n),void(Array.isArray(e.children)&&Mn(e.children,s,n,o,a))}if("content"===r){const r=i>1?`Column ${l+1} of ${i}`:null,s=r?[...t,r]:t;return void(Array.isArray(e.children)&&Mn(e.children,s,n,o,a))}const s=Rn(l,i);switch(r){case"image":!function(e,t,n,o){const a=e.src,i=()=>$n(t,"image",void 0,o);null!=a&&""!==String(a).trim()?(Tn(a,!1)||Dn(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:i(),blockId:e.id??null}),null!=e.alt&&""!==String(e.alt).trim()||Dn(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:i(),blockId:e.id??null})):Dn(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:i(),blockId:e.id??null})}(e,t,n,s);break;case"avatar":!function(e,t,n,o){const a=e.src,i=()=>$n(t,"avatar",void 0,o);null==a||""===String(a).trim()?Dn(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:i(),blockId:e.id??null}):Tn(a,!1)||Dn(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:i(),blockId:e.id??null})}(e,t,n,s);break;case"button":!function(e,t,n,o){const a=e.linkURL,i=()=>$n(t,"button",void 0,o);null!=a&&""!==String(a).trim()?Tn(a,!1)||Dn(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:i(),blockId:e.id??null}):Dn(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:i(),blockId:e.id??null})}(e,t,n,s);break;case"menu":!function(e,t,n,o){const a=e.list||[];a.forEach((a,i)=>{const l=e=>$n(t,"menu",e||`Item ${i+1}`,o);null!=a.label&&""!==String(a.label).trim()||Dn(n,{severity:"info",code:"menu_empty_label",message:'Menu item label is empty; will show as "Link".',location:l(`item ${i+1}`),blockId:e.id??null});const r=a.url;null==r||""===String(r).trim()?Dn(n,{severity:"warning",code:"menu_empty_url",message:'Menu item URL is empty; will be saved as href="#".',location:l(a.label||`item ${i+1}`),blockId:e.id??null}):Tn(r,!1)||Dn(n,{severity:"warning",code:"menu_invalid_url",message:"Menu item URL format is invalid.",location:l(a.label||`item ${i+1}`),blockId:e.id??null})}),0===a.length&&Dn(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:$n(t,"menu",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"social_link":!function(e,t,n,o){const a=e.list||[];a.forEach((a,i)=>{const l=a.title||a.image||`link ${i+1}`,r=e=>$n(t,"social_link",e||l,o),s=a.linkURL;null==s||""===String(s).trim()?Dn(n,{severity:"warning",code:"social_empty_link",message:'Social link URL is empty; will be saved as href="https://".',location:r(l),blockId:e.id??null}):Tn(s,!1)||Dn(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:r(l),blockId:e.id??null});const c=a.image;null==c||""===String(c).trim()?Dn(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:r(l),blockId:e.id??null}):Tn(c,!1)||Dn(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:r(l),blockId:e.id??null})}),0===a.length&&Dn(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:$n(t,"social_link",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"text":Un(e,t,n,"text",s,a);break;case"heading":Un(e,t,n,"heading",s,a)}})}function On({blockList:e,bodySettings:t,aiContentRefs:n={}}){const o=[];return Bn(t,o),Mn(Array.isArray(e)?e:[],[],o,t,n),o}function jn(){const e="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!e)return;const t=e.Image;return"function"==typeof t?t:void 0}const Hn=/^\{\{\s*[\w.]+\s*\}\}$/;function Kn(e){if(null==e||""===String(e).trim())return null;const t=String(e).trim();if(function(e){return null!=e&&"string"==typeof e&&Hn.test(e.trim())}(t))return null;if(/^https?:\/\//i.test(t))return Tn(t,!1)?t:null;if(t.startsWith("//")){const e=`https:${t}`;return Tn(e,!1)?e:null}return null}function zn(e,t=[],n=e?.length??0){const o=[];return Array.isArray(e)?(e.forEach((e,a)=>{if(!e||"object"!=typeof e)return;const i=e.key;if("column"===i){const i=Ln(e,a,n),l=[...t,i],r=e.children;return void o.push(...zn(r,l,r?.length??0))}if("content"===i){const i=n>1?`Column ${a+1} of ${n}`:null,l=i?[...t,i]:t,r=e.children;return void o.push(...zn(r,l,r?.length??0))}const l=Rn(a,n);if("image"===i){const n=Kn(e.src);n&&o.push({url:n,location:$n(t,"image",void 0,l),blockId:e.id??null})}}),o):o}function Fn(e,t=12e3){const n=jn();if(!n)return Promise.resolve(!1);const o=String(e).trim();return o?new Promise(e=>{const a=new n;let i=!1;const l=t=>{i||(i=!0,clearTimeout(r),a.onload=null,a.onerror=null,e(t))},r=setTimeout(()=>l(!1),t);a.onload=()=>l(!0),a.onerror=()=>l(!1);try{a.src=o}catch{l(!1)}}):Promise.resolve(!1)}async function Vn(e,t={}){const{timeoutMs:n=12e3,concurrent:o=6}=t;if(!jn())return[];const a=zn(Array.isArray(e)?e:[]);if(0===a.length)return[];const i=new Map;for(const e of a)i.has(e.url)||i.set(e.url,[]),i.get(e.url).push(e.location);const l=[...i.keys()],r=new Map;let s=0;const c=Math.max(1,Math.min(o,l.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<l.length;){const e=s++,t=l[e],o=await Fn(t,n);r.set(t,o)}}()));const d=[];for(const[e,t]of i)if(!0!==r.get(e))for(const n of t)d.push({severity:"warning",code:"image_url_not_loadable",message:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",location:n,blockId:a.find(t=>t.url===e&&t.location===n)?.blockId??null});return d}async function Wn(e,t){return[...On(e),...await Vn(e?.blockList??[],t)]}const Jn=(...e)=>e.filter(Boolean).join(" "),qn={drag_block_here:"请将模块拖放到此处",blocks:"模块",photos:"图片",powered_by_pexels:"图片由Pexels提供",loading:"加载中...",content:"内容",styles:"样式",ai_powered:"AI 驱动",layout:"布局",components:"组件",presets:"预设",body_settings:"邮件主题设置",global:"全局",text_and_headings:"文本与标题",pre_header:"预标题",pre_header_description:"预标题是在收件箱中查看电子邮件时跟随主题行的简短摘要文本。",confirm:"确认",cancel:"取消",add_blocks:"请添加块",block_product:"产品",block_product_single:"单个",block_product_multi:"多个",block_discount:"折扣",block_introduction:"引言",block_body:"正文",block_header:"页眉",block_footer:"页脚",no_product_found:"未找到产品",no_products_matching_search:"没有符合搜索条件的产品。清空搜索可查看完整列表。",load_more_products:"加载更多",add_products:"添加产品",add_products_in_store:"请在店铺中添加产品。",column:"列",columns:"列排版",column_settings:"列设置",column_styles:"列样式",size_px:"尺寸",column_delete:"删除列",column_delete_desc:"您确定删除多余的{{count}}列吗?",container:"容器",container_settings:"容器设置",container_type:"容器类型",container_type_help:"决定该容器可用的变量和产品映射。",container_type_none:"无",container_type_header:"页眉",container_type_discount:"折扣",container_type_introduction:"引言",container_type_body:"正文",container_type_product:"产品",container_type_hero_product:"主推产品",container_type_additional_product:"附加产品",container_type_footer:"页脚",product_role:"产品角色",product_role_main_hero:"主推产品",product_role_additional:"附加产品",assign_product_to_column:"为列分配产品",text:"文本",text_content:"这是一个文本,点击修改文本",text_settings:"文本设置",text_styles:"文本样式",text_align:"文本对齐方式",heading:"标题",heading_content:"这是一个标题,点击修改标题",heading_settings:"标题设置",heading_type:"标题类型",button:"按钮",button_settings:"按钮设置",button_action:"点击按钮触发",button_styles:"按钮样式",button_padding:"按钮内边距",spacer:"间距",spacer_block:"间距块",spacer_settings:"间距设置",divider:"分割线",divider_settings:"分割线设置",divider_type:"分割线类型",divider_styles:"分割线样式",image:"图片",image_settings:"图片设置",image_action:"点击图片跳转",image_url:"图片URL",image_alt:"图片alt",image_styles:"图片样式",image_source:"图片来源",image_source_url:"输入URL",image_source_upload:"上传图片",image_upload:"上传",image_upload_click:"点击上传",image_upload_not_configured:"未配置图片上传。请在 apiConfig 中设置 imageUploadEndpoint,或传入 null 关闭;默认使用内置 API 根地址。",image_uploaded:"图片上传成功",image_upload_failed:"图片上传失败",image_upload_error:"上传图片时出错",uploading:"上传中…",image_source_variable:"使用变量",menu:"导航栏",menu_settings:"导航栏设置",menu_items:"菜单项",menu_item:"菜单项",menu_styles:"菜单样式",add_new_item:"添加新项",label:"标签",page:"页面",url:"链接地址",target:"打开方式",same_tab:"当前窗口",new_tab:"新窗口",separator:"分隔符",letter_spacing:"字间距",link_color:"链接颜色",avatar:"头像",avatar_settings:"头像设置",avatar_image:"头像图片",avatar_border_radius:"圆角",social_link:"社交链接",add_social_link:"添加社交链接",social_link_size:"社交链接大小",social_links:"社交链接",social_link_settings:"社交链接设置",content_background_color:"内容背景颜色",background_color:"背景颜色",text_color:"文本颜色",email_theme_background_color:"邮件主题色",font_color:"字体颜色",button_color:"按钮颜色",divider_color:"分割线颜色",action_type:"按钮类型",top:"上",right:"右",left:"左",bottom:"下",line_height:"行高",link:"超链接",link_url:"超链接URL",link_url_placeholder:"example.com",padding_settings:"内边距设置",width_auto:"宽度自适应",width:"宽度",height:"高度",font_size:"字体大小",font_family:"字体",align:"对齐方式",solid:"实线",dotted:"虚线(点)",dashed:"虚线(破折号)",spacing:"间距",border_radius:"圆角",export_html:"导出html",export_json:"导出JSON",export_checking_images:"正在检查图片…",language_zh:"中文",export_validation_title:"导出前校验",export_validation_issues_found:"导出前发现以下问题",export_validation_errors:"错误",export_validation_warnings:"警告",export_validation_info:"提示",export_anyway:"仍要导出",ignore:"忽略",validation_body_content_width_invalid:"邮件内容宽度必须为正数。",validation_body_background_color_missing:"主题背景色未设置。",validation_body_text_color_missing:"主题文字颜色未设置。",validation_body_font_family_missing:"主题字体未设置。",validation_image_empty_src:"图片地址为空,图片将无法显示。",validation_image_invalid_src:"图片地址格式无效。",validation_image_url_not_loadable:"图片地址无法加载或预览;链接可能已失效、过期或被拦截。",validation_image_empty_alt:"图片未设置 alt 文本,建议添加以提升可访问性。",validation_avatar_empty_src:"头像图片地址为空,头像将无法显示。",validation_avatar_invalid_src:"头像图片地址格式无效。",validation_button_empty_link:'按钮链接为空,将被保存为 href="https://"。',validation_button_invalid_link:"按钮链接格式无效。",validation_menu_empty_label:"菜单项标签为空,将显示为「链接」。",validation_menu_empty_url:'菜单项链接为空,将被保存为 href="#"。',validation_menu_invalid_url:"菜单项链接格式无效。",validation_menu_no_items:"菜单块没有任何项。",validation_social_empty_link:'社交链接地址为空,将被保存为 href="https://"。',validation_social_invalid_link:"社交链接地址格式无效。",validation_social_empty_icon:"社交链接图标地址为空,图标将无法显示。",validation_social_invalid_icon:"社交链接图标地址格式无效。",validation_social_no_links:"社交链接块没有任何链接。",validation_container_product_not_assigned:"该列未分配产品;请在容器设置中分配产品。",validation_dynamic_content_empty:"未生成动态内容;导出将使用静态文本(如有)。",tooltip_bold:"加粗",tooltip_italic:"斜体",tooltip_underline:"下划线",tooltip_strikethrough:"删除线",tooltip_align_left:"居左",tooltip_align_center:"居中",tooltip_align_right:"居右",tooltip_ordered_list:"有序列表",tooltip_unordered_list:"无序列表",tooltip_link:"超链接",tooltip_remove_link:"删除超链接",add_link_modal_title:"添加超链接",content_type:"内容类型",content_type_static:"静态",content_type_dynamic:"动态",ai_enabled:"使用 AI 撰写",text_and_content_type:"内容类型",heading_or_body:"标题",body_paragraph:"正文",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"变量",insert_merge_field:"选择或输入变量...",dynamic_prompt_help:"描述语气,我们将推荐示例内容。",generate:"生成",ml_generation_failed:"无法生成 AI 内容",ml_ai_unavailable:"AI 生成需要分栏布局、公司 ID、模板 ID 和 ML 接口。请将文本放在栏目内并检查 apiConfig。",ml_no_variations:"未返回任何建议。请更换提示词或确认服务器上存在该模板。",ml_generation_unexpected_error:"生成内容时发生意外错误。",sample_ai_content:"示例 AI 内容",select_content:"选择内容",variable_dynamic_placeholder:"无(可选)",variable_display_text:"展示文案",variable_introduction:"引言",variable_heading:"标题",variable_subheading:"副标题",variable_products_description:"产品描述",variable_customer_name:"客户姓名",variable_introduction_title:"引言标题",variable_introduction_subtitle:"引言副标题",variable_body_title:"正文标题",variable_body_subtitle:"正文副标题",variable_discount_value:"折扣力度",variable_discount_code:"折扣码",variable_valid_until:"有效期至",variable_company_name:"公司名称",variable_brand_name:"品牌名称",variable_address:"地址",variable_website:"网站",variable_logo_url:"Logo URL",variable_tagline:"标语",variable_nav_label:"导航文案",variable_nav_url:"导航链接",variable_product_name:"产品名称",variable_product_description:"产品描述",variable_product_image:"产品图片 URL",variable_product_link:"产品链接",variable_product_price:"产品价格",variable_product_currency:"货币",variable_product_old_price:"原价",variable_product_new_price:"现价",variable_product_price_display:"产品价格展示",variable_image_logo:"Logo",variable_image_hero_banner:"主图横幅",variable_image_footer_banner:"页脚横幅",variable_image_product_image:"产品图片",variable_cta_label:"CTA 文案",variable_cta_url:"CTA 链接",button_label_variable:"按钮文案(变量)",button_url_variable:"按钮链接(变量)",button_text:"按钮文案",button_label_manual:"输入文案",button_url_manual:"输入链接",use_company_social_links:"使用公司社交链接",use_navigation_links:"使用导航链接",tooltip_container_type:"决定该容器可用的变量和产品映射。",tooltip_variables_static:"将合并字段插入内容,发送邮件时将被替换。",tooltip_dynamic_prompt:"描述语气或意图,我们将推荐示例内容。(预览模式 — 连接 AI API 后可生成真实内容。)"},Gn={drag_block_here:"Drag block here",blocks:"Blocks",photos:"Photos",powered_by_pexels:"Powered by Pexels",loading:"Loading...",content:"Content",styles:"Styles",ai_powered:"AI powered",layout:"Layout",components:"Components",presets:"Presets",body_settings:"Theme Settings",global:"Global",text_and_headings:"Text and headings",pre_header:"Pre-header",pre_header_description:"The pre-header is a short summary text that follows the subject line when viewing an email in the inbox.",confirm:"Confirm",cancel:"Cancel",add_blocks:"Add blocks",block_product:"Product",block_product_single:"Single",block_product_multi:"Multi",block_discount:"Discount",block_introduction:"Introduction",block_body:"Body",block_header:"Header",block_footer:"Footer",no_product_found:"No product found",no_products_matching_search:"No products match your search. Clear the search to see the full list.",load_more_products:"Load more",add_products:"Add products",add_products_in_store:"Add products in your store.",column:"Column",columns:"Columns",column_settings:"Column Settings",column_styles:"Column Styles",size_px:"Size",column_delete:"Delete Column",column_delete_desc:"Are you sure you want to delete {{count}} extra columns? ",container:"Container",container_settings:"Container Settings",container_type:"Container Type",container_type_help:"Determines which variables and product mappings are available.",container_type_none:"None",container_type_header:"Header",container_type_discount:"Discount",container_type_introduction:"Introduction",container_type_body:"Body",container_type_product:"Product",container_type_hero_product:"Hero Product",container_type_additional_product:"Additional Product",container_type_footer:"Footer",product_role:"Product Role",product_role_main_hero:"Primary",product_role_additional:"Secondary",assign_product_to_column:"Assign product to column",text:"Text",text_content:"This is a text, click to edit text",text_settings:"Text Settings",text_styles:"Text Styles",text_align:"Text Align",heading:"Heading",heading_content:"This is a heading, click to edit heading",heading_settings:"Heading Settings",heading_type:"Heading Type",button:"Button",button_settings:"Button Settings",button_action:"Button Action",button_styles:"Button Styles",button_padding:"Button Padding",spacer:"Spacer",spacer_block:"SPACER BLOCK",spacer_settings:"Spacer Settings",divider:"Divider",divider_settings:"Divider Settings",divider_type:"Divider Type",divider_styles:"Divider Styles",image:"Image",image_action:"Image Action",image_url:"Image URL",image_alt:"Image Alt",image_styles:"Image Styles",image_settings:"Image Settings",image_source:"Image source",image_source_url:"Enter URL",image_source_upload:"Upload image",image_upload:"Upload",image_upload_click:"Click to upload",image_upload_not_configured:"Image upload is not configured. Set imageUploadEndpoint in apiConfig or pass null to disable; defaults use the built-in API base.",image_uploaded:"Image uploaded successfully",image_upload_failed:"Failed to upload image",image_upload_error:"Error uploading image",uploading:"Uploading…",image_source_variable:"Use variable",menu:"Navigation bar",menu_settings:"Navigation bar Settings",menu_items:"Menu Items",menu_item:"Menu Item",menu_styles:"Menu Styles",add_new_item:"Add New Item",label:"Label",page:"Page",url:"URL",target:"Target",same_tab:"Same Tab",new_tab:"New Tab",separator:"Separator",letter_spacing:"Letter Spacing",link_color:"Link Color",avatar:"Avatar",avatar_settings:"Avatar Settings",avatar_image:"Avatar image",avatar_border_radius:"Border radius",social_link:"Social Link",social_link_settings:"Social Link Settings",add_social_link:"Add Social Link",social_link_size:"Social Link Size",social_links:"Social Links",content_background_color:"Content Background Color",background_color:"Background Color",text_color:"Text Color",email_theme_background_color:"Email Theme Background Color",font_color:"Font Color",button_color:"Button Color",divider_color:"Divider Color",action_type:"Action Type",top:"Top",right:"Right",left:"Left",bottom:"Bottom",line_height:"Line Height",link:"Link",link_url:"Link URL",link_url_placeholder:"example.com",padding_settings:"Padding Settings",width:"Width",height:"Height",width_auto:"Width Auto",font_size:"Font Size",font_family:"Font Family",solid:"Solid",dotted:"Dotted",dashed:"Dashed",align:"Align",spacing:"Spacing",border_radius:"Border radius",export_html:"Export HTML",export_json:"Export JSON",export_checking_images:"Checking images…",language_zh:"中文",export_validation_title:"Export validation",export_validation_issues_found:"Issues found before export",export_validation_errors:"Errors",export_validation_warnings:"Warnings",export_validation_info:"Info",export_anyway:"Export anyway",ignore:"Ignore",validation_body_content_width_invalid:"Body content width must be a positive number.",validation_body_background_color_missing:"Theme background color is missing.",validation_body_text_color_missing:"Theme text color is missing.",validation_body_font_family_missing:"Theme font family is missing.",validation_image_empty_src:"Image URL is empty; the image will not display.",validation_image_invalid_src:"Image URL format is invalid.",validation_image_url_not_loadable:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",validation_image_empty_alt:"Image alt text is empty; consider adding for accessibility.",validation_avatar_empty_src:"Avatar image URL is empty; avatar will not display.",validation_avatar_invalid_src:"Avatar image URL format is invalid.",validation_button_empty_link:'Button link URL is empty; will be saved as href="https://".',validation_button_invalid_link:"Button link URL format is invalid.",validation_menu_empty_label:'Menu item label is empty; will show as "Link".',validation_menu_empty_url:'Menu item URL is empty; will be saved as href="#".',validation_menu_invalid_url:"Menu item URL format is invalid.",validation_menu_no_items:"Menu block has no items.",validation_social_empty_link:'Social link URL is empty; will be saved as href="https://".',validation_social_invalid_link:"Social link URL format is invalid.",validation_social_empty_icon:"Social link icon URL is empty; icon will not display.",validation_social_invalid_icon:"Social link icon URL format is invalid.",validation_social_no_links:"Social link block has no links.",validation_container_product_not_assigned:"A product is not assigned to this column; assign a product in Container settings.",validation_dynamic_content_empty:"Dynamic content not generated; export will use static text if available.",tooltip_bold:"Bold",tooltip_italic:"Italic",tooltip_underline:"Underline",tooltip_strikethrough:"Strikethrough",tooltip_align_left:"Align left",tooltip_align_center:"Align center",tooltip_align_right:"Align right",tooltip_ordered_list:"Ordered list",tooltip_unordered_list:"Unordered list",tooltip_link:"Link",tooltip_remove_link:"Remove link",add_link_modal_title:"Add link",content_type:"Content type",content_type_static:"Static",content_type_dynamic:"Dynamic",ai_enabled:"Write using AI",text_and_content_type:"Content type",heading_or_body:"Heading",body_paragraph:"Body",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"Variables",insert_merge_field:"Select or type variable...",dynamic_prompt_help:"Describe the tone; we'll suggest sample content.",generate:"Generate",ml_generation_failed:"Could not generate AI content",ml_ai_unavailable:"AI generation needs a column layout, company ID, template ID, and ML endpoint. Open this text inside a section column and check apiConfig.",ml_no_variations:"No suggestions were returned. Try another prompt or verify the template exists on the server.",ml_generation_unexpected_error:"Something went wrong while generating content.",sample_ai_content:"Sample AI content",select_content:"Select content",variable_dynamic_placeholder:"None (optional)",variable_display_text:"Display text",variable_introduction:"Introduction",variable_heading:"Heading",variable_subheading:"Subheading",variable_products_description:"Products description",variable_customer_name:"Customer Name",variable_introduction_title:"Introduction Title",variable_introduction_subtitle:"Introduction Subtitle",variable_body_title:"Body Title",variable_body_subtitle:"Body Subtitle",variable_discount_value:"Discount value",variable_discount_code:"Discount code",variable_valid_until:"Valid until",variable_company_name:"Company name",variable_brand_name:"Brand name",variable_address:"Address",variable_website:"Website",variable_logo_url:"Logo URL",variable_tagline:"Tagline",variable_nav_label:"Nav link label",variable_nav_url:"Nav link URL",variable_product_name:"Product name",variable_product_description:"Product description",variable_product_image:"Product image URL",variable_product_link:"Product link",variable_product_price:"Product price",variable_product_currency:"Product currency",variable_product_old_price:"Product old price",variable_product_new_price:"Product new price",variable_product_price_display:"Product price display",variable_image_logo:"Logo",variable_image_hero_banner:"Hero banner",variable_image_footer_banner:"Footer banner",variable_image_product_image:"Product image",variable_cta_label:"CTA label",variable_cta_url:"CTA URL",button_label_variable:"Button label (variable)",button_url_variable:"Button URL (variable)",button_text:"Button text",button_label_manual:"Enter label",button_url_manual:"Enter URL",use_company_social_links:"Use company social links",use_navigation_links:"Use navigation links",tooltip_container_type:"Determines which variables and product mappings are available for this container.",tooltip_variables_static:"Insert a merge field into your content. It will be replaced when the email is sent.",tooltip_dynamic_prompt:"Describe the tone or intent; we'll suggest sample content. (Preview mode — connect an AI API for real generation.)"},Yn=()=>{const{language:e,languageLibraries:t}=n(Ye);let o={zh:qn,en:Gn};t&&(o={...o,...t,zh:{...qn,...o.zh||{}},en:{...Gn,...o.en||{}}});return{t:(t,n)=>{let a=(o[e]||{})[t];return n&&n instanceof Object&&Object.keys(n).forEach(e=>{a=a.replace(`{{${e}}}`,n[e])}),a||t}}},Zn=/\{\{(\w+)\}\}/g;function Qn(e,t){if(null!=e)if("string"!=typeof e){if(Array.isArray(e))e.forEach(e=>Qn(e,t));else if("object"==typeof e){if(void 0!==e.$$typeof)return;Object.values(e).forEach(e=>Qn(e,t))}}else(function(e){if("string"!=typeof e||0===e.length)return[];const t=[];let n;for(;null!==(n=Zn.exec(e));){const e=n[1];e&&t.push(e)}return Zn.lastIndex=0,t})(e).forEach(e=>t.add(e))}function Xn(e,t,n){e&&"object"==typeof e&&(e.id&&n.has(e.id)||(e.id&&n.add(e.id),"column"!==e.key?Qn(e,t):(e.children||[]).forEach(e=>{(e?.children||[]).forEach(e=>Xn(e,t,n))})))}function eo(e,t,n,o){if(!e||o.has(e))return;o.add(e);const a=t[e];a&&"object"==typeof a&&("column"===a.key?(a.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>eo(e,t,n,o))}):Qn(a,n))}function to(e,t){const n=new Set;if(!e||"object"!=typeof e)return n;if(Array.isArray(e.children)){const t=new Set;return Xn(e,n,t),n}if(!t||"object"!=typeof t)return n;const o=new Set;return(e.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>eo(e,t,n,o))}),n}const no=()=>{const e=(t,n)=>t?t.classList?.contains("text-content_editable")?null:t&&t.tagName?.toLocaleLowerCase()===n?t:e(t.parentNode,n):null,t=o((e,n)=>e?e.classList?.contains("text-content_editable")?null:e&&e.style?.[n]?e.style[n]:t(e.parentNode,n):null,[]);return{getSelectionNode:e,getSectionStyle:t}},oo=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"b"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_bold"),onClick:()=>{e("bold",!1,null),t()},children:ue(C,{icon:N,className:"rich-text-tools-button-icon"})})},ao=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"i"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_italic"),onClick:()=>{e("italic",!1,null),t()},children:ue(C,{icon:T,className:"rich-text-tools-button-icon"})})},io=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"u"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_underline"),onClick:()=>{e("underline",!1,null),t()},children:ue(C,{icon:I,className:"rich-text-tools-button-icon"})})},lo=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"strike"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_strikethrough"),onClick:()=>{e("strikethrough",!1,null),t()},children:ue(C,{icon:A,className:"rich-text-tools-button-icon"})})},ro=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"ol"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_ordered_list"),onClick:()=>{e("insertOrderedList",!1,null),t()},children:ue(C,{icon:L,className:"rich-text-tools-button-icon"})})},so=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{getSelectionNode:i}=no(),{t:l}=Yn(),r=a(()=>o?i(o.commonAncestorContainer,"ul"):null,[o,i]);return ue("button",{className:Jn("rich-text-tools-button ",r&&"rich-text-tools-button-active"),title:l("tooltip_unordered_list"),onClick:()=>{e("insertUnorderedList",!1,null),t()},children:ue(C,{icon:P,className:"rich-text-tools-button-icon"})})},co=({modifyText:e,setTextContent:t})=>{const{selectionRange:o}=n(Ye),{t:l}=Yn(),{getSelectionNode:r}=no(),[s,c]=i(!1),[d,p]=i({value:"",range:null}),u=a(()=>o?r(o.commonAncestorContainer,"a"):null,[o,r]),y=()=>{c(!1),p({value:"",range:null})};return me(ge,{children:[ue("button",{className:Jn("rich-text-tools-button ",u&&"rich-text-tools-button-active"),title:l("tooltip_link"),onClick:()=>{let e=window.getSelection().getRangeAt(0);const n=e.commonAncestorContainer.parentNode,o="A"===n.nodeName,a={...d,range:e};o&&(a.rangeIsLink=!0,a.value=n.href.replace("https://","")),p(a),c(!0),t()},children:ue(C,{icon:R,className:"rich-text-tools-button-icon"})}),ue("button",{className:Jn("rich-text-tools-button"),title:l("tooltip_remove_link"),onClick:()=>{e("unlink",!1,null),t()},children:ue(C,{icon:$,className:"rich-text-tools-button-icon"})}),ue(m,{title:l("add_link_modal_title"),open:s,zIndex:1100,onOk:()=>{const{range:e,value:n,rangeIsLink:o}=d;if(o)e.commonAncestorContainer.parentNode.href=n;else{let t=document.createElement("a");t.target="_blank",t.href=n,e.surroundContents(t)}t(),y()},onCancel:y,okText:l("confirm"),cancelText:l("cancel"),wrapClassName:"ee-modal-dark",children:ue(g,{addonBefore:"https://",value:d.value.replace("https://",""),onChange:e=>p({...d,value:"https://"+e.target.value})})})]})},po=({id:e,textBlock:t,styles:o})=>{const{blockMap:s,rootOrder:c,templateData:d}=n(Ye),{t:p}=Yn(),u=l(null),[m,g]=i(!1),[h,b]=i(!1),f=a(()=>{const t=Ie(s,c,e),n=t?.[0]??null;return{containerBlock:n?.containerBlock??null,containerType:n?.containerType??"none",cellIndex:n?.cellIndex??0,lineage:t}},[s,c,e]),k=a(()=>{const e=f?.cellIndex??0,t=f?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[f]),_=a(()=>(f?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[f?.lineage]),v=a(()=>Qt(0,f?.containerType??"none",d,k,_),[f?.containerType,d,k,_]),x=a(()=>to(f?.containerBlock,s),[f?.containerBlock,s]),w=a(()=>v.filter(e=>"image"!==e.type&&!x.has(e.variableKey??e.key)),[v,x]);r(()=>{if(u.current){var e=u.current.parentNode?.getBoundingClientRect();const t=document.querySelector("#preview").getBoundingClientRect();e.top-190<0?(u.current.style.bottom="auto",u.current.style.top="110%"):(u.current.style.bottom="110%",u.current.style.top="auto"),e.left+375>t.left+t.width?(u.current.style.left="auto",u.current.style.right="0"):(u.current.style.left="0",u.current.style.right="auto")}},[]);const S=(e,t,n)=>{document.execCommand(e,t,n)},N=()=>{t?.current&&t.current.dispatchEvent(new Event("input",{bubbles:!0}))};return ue("div",{className:"rich-text",ref:u,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:ue(pe.div,{className:"rich-text-tools",initial:{scale:0,x:0},animate:{scale:1,x:0},style:{width:m?"auto":"375px"},children:me("div",{className:"rich-text-tools-body items-center",children:[!m&&me(ge,{children:[ue(oo,{modifyText:S,setTextContent:N}),ue(ao,{modifyText:S,setTextContent:N}),ue(io,{modifyText:S,setTextContent:N}),ue(lo,{modifyText:S,setTextContent:N}),ue(ro,{modifyText:S,setTextContent:N}),ue(so,{modifyText:S,setTextContent:N}),ue(co,{modifyText:S,setTextContent:N}),ue(y,{zIndex:1070,trigger:"click",open:h,onOpenChange:b,overlayClassName:"ee-rich-text-variables-popover",getPopupContainer:()=>document.querySelector("#preview")||document.body,content:me("div",{className:"ee-rich-text-variables-menu",children:[ue("div",{className:"ee-rich-text-variables-header",children:p("variables")}),w.map(e=>ue("div",{className:"ee-rich-text-variables-item",onMouseDown:n=>{n.preventDefault(),(e=>{if(!t?.current||!e)return;const n=window.getSelection();let o=null;if(n?.rangeCount){const e=n.getRangeAt(0);t.current.contains(e.commonAncestorContainer)&&(o=e)}o||(o=document.createRange(),o.selectNodeContents(t.current),o.collapse(!1)),o.deleteContents();const a=document.createTextNode(e);o.insertNode(a),o.setStartAfter(a),o.collapse(!0),n&&(n.removeAllRanges(),n.addRange(o)),N(),b(!1)})(e.value)},children:e.labelKey?p(e.labelKey):e.label||e.value},`variables-${e.value}`))]}),children:ue("button",{className:"rich-text-tools-button",title:p("insert_merge_field"),onMouseDown:e=>e.preventDefault(),children:ue("span",{className:"rich-text-tools-button-icon",style:{color:"#fff",fontFamily:"monospace",fontWeight:700,fontSize:13,lineHeight:1},children:"{}"})})})]}),ue("button",{className:"rich-text-tools-button",onClick:()=>g(!m),children:ue(C,{icon:m?B:D,className:"rich-text-tools-button-icon"})})]})})})},uo=({id:e,blockItem:t,displayContent:o})=>{const{currentItem:i,previewMode:s,blockMap:c,rootOrder:d,setBlocks:p,setCurrentItem:u,isDragStart:m,templateData:g}=n(Ye),y=l(null),h=i&&i.id===(e??t?.id),b="desktop"===s?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},f=b.linkColor||b.color,{linkColor:k,..._}=b,v={..._,direction:"ltr",unicodeBidi:"isolate",...f?{"--ee-rich-text-link-color":f}:{}},x=l(!1),w=null!=o?o:t.text||"",S=a(()=>{const n=Ie(c,d,e??t?.id),o=n?.[0]??null;return{containerBlock:o?.containerBlock??null,containerType:o?.containerType??"none",cellIndex:o?.cellIndex??0,lineage:n}},[c,d,e,t?.id]),C=a(()=>{const e=S?.cellIndex??0,t=S?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[S]),N=a(()=>(S?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[S?.lineage]),T=a(()=>Qt(0,S?.containerType??"none",g,C,N).map(e=>{return t=e.value,n=e.pasteValue,{token:t,pasteValue:String(n||"")};var t,n}).filter(e=>e.token&&e.pasteValue&&""!==e.pasteValue.trim()&&!e.pasteValue.includes("{{")&&e.pasteValue!==e.token).sort((e,t)=>t.pasteValue.length-e.pasteValue.length),[g,C,S?.containerType,N]);r(()=>{if(h&&y.current){const e=I(w);if(x.current){const t=y.current.innerHTML||"";e!==I(t)&&(y.current.innerHTML=e)}else y.current.innerHTML=e,y.current.focus();x.current=!0}else x.current=!1},[h,e,w]);const I=e=>"string"!=typeof e?e:e.replace(/\u202E/g,"").replace(/\u202D/g,"").replace(/\u202A/g,"").replace(/\u202B/g,"").replace(/\u202C/g,"").replace(/\sdir\s*=\s*["']rtl["']/gi,' dir="ltr"').replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*direction\s*:\s*rtl\s*;?/gi,"").trim();return n?` style="${n}"`:""}),A=I(w);return me("div",{className:"relative",dir:"ltr",style:{direction:"ltr",unicodeBidi:"isolate"},children:[h&&t&&!m&&ue(po,{textBlock:y,id:e??t?.id,styles:v}),ue("div",{className:Jn(h&&"text-block","text-content_editable"),onClick:e=>{e.preventDefault(),e.stopPropagation()},onInput:n=>{const a=e??t?.id,l=n.target.innerHTML,r=I(l),s=null!=o?I(o):null,m=null!=s&&r===s,g=c[a]||{};let y=m?t.text:r;"text"===(g.key??t?.key)&&(y=(e=>{if(!e||!T.length||"undefined"==typeof document)return e;const t=document.createElement("div");t.innerHTML=e;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o=n.nextNode();for(;o;){let e=o.nodeValue||"";T.forEach(({token:t,pasteValue:n})=>{n&&e.includes(n)&&(e=e.split(n).join(t))}),o.nodeValue=e,o=n.nextNode()}return t.innerHTML})(y));const h={...g,text:y,selectedVariableKey:m?g.selectedVariableKey:void 0},b={...c,[a]:h};p(b,d),u({...i,data:h})},style:v,dir:"ltr",contentEditable:h,suppressContentEditableWarning:!0,ref:y,dangerouslySetInnerHTML:h?void 0:{__html:A}})]})},mo=t=>{const{id:o,blockItem:i}=t,{currentItem:l,previewMode:r,templateData:s,blockMap:c,rootOrder:d}=n(Ye),p="desktop"===r?i.styles?.desktop??{}:{...i.styles?.desktop??{},...i.styles?.mobile??{}},u=l&&l.id===o,m=a(()=>Ae(c,d,o),[c,d,o]),g=a(()=>Kt(i.text,s,m),[i.text,s,m]),y=u?i.text||"":g,h=p.linkColor||p.color,b=a(()=>{return t=h,(e=y)&&t?String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=`${e?`${e}; `:""}color: ${t};`;return`<a${n.replace(o[0],` style="${a}"`)}>`}return`<a${n} style="color: ${t};">`}):e;var e,t},[y,h]),f=m?.containerBlock,k="footer"===f?.containerType,_=(g||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(k&&(""===_||"{{Address}}"===_||"{{Tagline}}"===_))return null;const v=i.type&&/^h[1-4]$/.test(i.type)?i.type:"div";return u?ue(uo,{...t,blockItem:i}):e.createElement(v,{style:{...p,direction:"ltr",unicodeBidi:"isolate"},dir:"ltr",dangerouslySetInnerHTML:{__html:b}})},go=e=>e?.brandContext?.brand_color??"#111111",yo=e=>{const{blockItem:t,id:o}=e,{currentItem:i,previewMode:l,templateData:r,blockMap:s,rootOrder:c}=n(Ye),d=a(()=>Ae(s,c,o),[o,s,c]),p=a(()=>{const e=t.text??"",n=e.match(/\{\{(\w+)\}\}/),o=t.labelVariable?t.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():n?n[1]:void 0;if(!r||!o)return e;const a=Wt(r,o,d);return null==a||String(a).startsWith("{{")?e:String(a)},[t.text,t.labelVariable,r,d]),u=i&&i.id===o,m="desktop"===l?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},g={...m,backgroundColor:m.backgroundColor??go(r)},y="desktop"===l?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},h=a(()=>ue(uo,{...e,blockItem:{...t,styles:{...t.styles,desktop:{...t.styles?.desktop,backgroundColor:g.backgroundColor}}},displayContent:p}),[t,p,g.backgroundColor]);return ue("div",{style:{...y},children:u?h:ue("div",{style:{...g,textAlign:"center"},dangerouslySetInnerHTML:{__html:p}})})},ho=({blockItem:e})=>{const{previewMode:t}=n(Ye),o="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},a="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",children:ue("div",{style:{...a},children:ue("div",{style:{...o}})})})},bo=({blockItem:e})=>{const{previewMode:t}=n(Ye),o="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},a="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",style:{...a},children:ue("div",{style:{width:"100%",height:"number"==typeof o.height?`${o.height}px`:o.height||"16px",display:o.display||"block"}})})},fo=({blockItem:e})=>{const{previewMode:t}=n(Ye),{list:o=[],separator:a=" | "}=e,i=o,l="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},r="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},s={fontSize:null!=l.fontSize?`${l.fontSize}px`:"14px",fontFamily:l.fontFamily||"sans-serif",color:l.linkColor||l.color||"#2faade",fontWeight:l.fontWeight||"normal",letterSpacing:null!=l.letterSpacing?`${l.letterSpacing}px`:"0px",textDecoration:"none",paddingLeft:null!=l.paddingLeft?`${l.paddingLeft}px`:"8px",paddingRight:null!=l.paddingRight?`${l.paddingRight}px`:"8px",paddingTop:null!=l.paddingTop?`${l.paddingTop}px`:"4px",paddingBottom:null!=l.paddingBottom?`${l.paddingBottom}px`:"4px"},c={fontSize:null!=l.fontSize?`${l.fontSize}px`:"14px",color:l.color||"#333",paddingLeft:4,paddingRight:4};return ue("div",{className:"relative",children:ue("div",{style:{...r,display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:r.textAlign||"center"},children:i.map((e,t)=>me("span",{style:{display:"inline-flex",alignItems:"center"},children:[t>0&&ue("span",{style:c,children:a}),ue("a",{href:e.url?e.url.startsWith("http")?e.url:`https://${e.url}`:"#",target:"_blank"===e.target?"_blank":"_self",rel:"_blank"===e.target?"noopener noreferrer":void 0,style:s,children:e.label||"Link"})]},t))})})},ko=({blockItem:e,id:t})=>{const{src:o,alt:i,linkURL:l}=e,{previewMode:r,templateData:s,blockMap:c,rootOrder:d}=n(Ye),p="desktop"===r?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},u="desktop"===r?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},m=a(()=>{const e="string"==typeof o&&/^\{\{\w+\}\}$/.test(o.trim())?o.trim():"";if(o&&!e)return o;if(!s||!e)return o||"";const n=Ae(c,d,t),a=e.replace(/^\{\{|\}\}$/g,"").trim(),i=Wt(s,a,n);return i&&!i.startsWith("{{")?i:o||""},[o,s,c,d,t]),g="string"==typeof o&&/^\{\{\w+\}\}$/.test(o.trim())?o.trim():"",y=!m||m.startsWith("{{"),h=i||"Image",b=p.width,f=b&&"auto"!==b,k="string"==typeof l?l.trim():"",_=""===k?"":k.startsWith("http")?k:`https://${k.replace(/^\/+/,"")}`,v=()=>m&&!y?f?ue("div",{style:{width:b,display:"inline-block"},children:ue("img",{src:m,style:{...p,width:"100%",maxWidth:"100%"},alt:h,className:"inline-block"})}):ue("img",{src:m,style:p,alt:h,className:"inline-block"}):ue("div",{className:"empty-image",style:{...p,width:"auto"===p.width?"100%":p.width},title:y&&g?g:void 0,children:y&&g?ue("span",{className:"empty-image-variable-label",children:g}):ue(C,{icon:E,className:"empty-image-icon"})}),x=nn(e)&&_&&m&&!y?ue("a",{href:_,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"inline-block"},onClick:e=>e.stopPropagation(),children:v()}):v();return ue("div",{className:"relative",children:ue("div",{style:{...u},children:x})})},_o=({blockItem:e})=>{const{src:t,alt:o,linkURL:a}=e,{previewMode:i}=n(Ye),l="desktop"===i?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},r="desktop"===i?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile},s=t?ue("img",{src:t,style:{...l,width:l.width??64,height:l.width??64,objectFit:"cover",borderRadius:l.borderRadius??"50%"},alt:o||"Avatar",className:"inline-block"}):ue("div",{className:"empty-avatar",style:{width:l.width??64,height:l.width??64,borderRadius:l.borderRadius??"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--ee-border, #eee)"},children:ue(C,{icon:U,style:{fontSize:"24px",color:"#999"}})}),c={...r,width:"100%"};return ue("div",{className:"relative",children:ue("div",{style:c,children:a?ue("a",{href:a.startsWith("http")?a:`https://${a}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:s}):s})})},vo=({blockItem:e})=>{const{previewMode:t}=n(Ye),{list:o=[],imageWidth:a}=e,i="desktop"===t?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}},l="desktop"===t?e.contentStyles?.desktop:{...e.contentStyles?.desktop,...e.contentStyles?.mobile};return ue("div",{className:"relative",children:ue("div",{style:l,children:o.map((e,t)=>{const{image:n,title:o,linkURL:l}=e,r=ue("img",{src:n,alt:o,style:{width:a}});return ue("div",{style:{...i,display:"inline-block"},children:l?ue("a",{href:l.startsWith("http")?l:`https://${l}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:r}):r},t)})})})},xo=({blockItem:e,id:t})=>{if(!e)return null;const n={blockItem:e,id:t};switch(e.key){case"text":return ue(mo,{...n});case"button":return ue(yo,{...n});case"divider":return ue(ho,{...n});case"spacer":return ue(bo,{...n});case"menu":return ue(fo,{...n});case"image":return ue(ko,{...n});case"avatar":return ue(_o,{...n});case"social_link":return ue(vo,{...n});default:return null}},wo=e=>{const{block:t,blockIndex:o,clearStyles:a}=e,{t:i}=Yn(),{previewMode:l,blockMap:r,rootOrder:c,validationMarkers:d,ignoreValidationIssue:p,setBlocks:u,currentItem:m,setCurrentItem:g,setIsDragStart:b,isDragStart:f,bodySettings:k,setActionType:_}=n(Ye),v="desktop"===l?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},{contentBackground:x,...w}=v,S="undefined"!=typeof window?window.__eeDragItemData:null,N=S?.key??(m?.id?r[m.id]?.key:null)??m?.data?.key,T=m?.id?Te(r,c,m.id):null,I=f&&("column"!==N||"add"===m?.type||Boolean(T)),A=e=>t=>{t.preventDefault(),t.stopPropagation(),g({id:e.id,data:e,type:"edit"}),_("edit")},L=e=>t=>{t.preventDefault(),t.stopPropagation();const n=r[e];n&&(g({id:n.id,data:n,type:"edit"}),_("edit"))},P=(e,t,n)=>o=>{o.preventDefault(),o.stopPropagation();const{blockMap:a,removedId:l}=Pe(r,e,t,n);let s=a;const d=a[e];if(d&&0===d.cells[t].childrenIds.length){const n=we(i("drag_block_here"));s={...a,[n.id]:n,[e]:{...d,cells:d.cells.map((e,o)=>o===t?{...e,childrenIds:[n.id]}:e)}}}l&&(s=$e(s,l)),u(s,c,"delete"),g(null)},R=e=>()=>{b(!0),g({id:e.id,data:e,type:"move"}),_("move")},$=e=>{e.preventDefault(),e.stopPropagation(),setTimeout(()=>{e.target.style.border="",e.target.children[0]&&e.target.children[0].classList.remove("sidebar-block-move"),b(!1),a&&a()},50)},B=e=>e.preventDefault(),D=e=>"desktop"===l?e.styles?.desktop||{}:{...e.styles?.desktop||{},...e.styles?.mobile||{}},E=e=>{const t=d?.[e];if(!t)return null;const n="error"===t.severity?`${t.errorCount} error${1===t.errorCount?"":"s"}`:`${t.warningCount} warning${1===t.warningCount?"":"s"}`,o=ue("div",{className:"block-validation-popover",children:t.issues.map((e,t)=>me("div",{className:"block-validation-popover-item",children:[ue("div",{className:"block-validation-popover-message",children:e.message}),ue(h,{size:"small",type:"text",className:"block-validation-popover-ignore",onClick:t=>{t.preventDefault(),t.stopPropagation(),p(e)},children:i("ignore")})]},`${e.code}-${t}`))});return ue(y,{trigger:["hover","click"],placement:"topRight",overlayClassName:"block-validation-popover-overlay",content:o,getPopupContainer:()=>document.querySelector("#preview")||document.body,children:me("button",{type:"button",className:Jn("block-validation-indicator","error"===t.severity?"block-validation-indicator-error":"block-validation-indicator-warning"),"aria-label":n,onClick:e=>{e.preventDefault(),e.stopPropagation()},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[ue("span",{className:"block-validation-indicator-dot"}),ue("span",{className:"block-validation-indicator-count",children:t.totalCount})]})})},U=(e,t,n,o,a,r,c=1)=>{const d=D({styles:e.styles}),{contentBackground:p,...u}=d,g=m?.id===e.id,y=((e=1)=>({"--nested-level":Math.max(1,e),"--nested-width":"100%"}))(c);return me(ge,{children:[me("div",{className:"relative block-content-drag-label-content","data-drop-key":a,children:[ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),I&&ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"})]}),ue("div",{className:Jn("block-item block-item-container",g&&"block-item-focus"),style:y,"data-block-id":e.id,onMouseEnter:e=>{e.currentTarget.dataset.hovered="true"},onMouseLeave:e=>{delete e.currentTarget.dataset.hovered},children:me("div",{className:"relative",children:[E(e.id),me("div",{className:"block-item-tools",onDragOver:B,onClick:A(e),children:[I&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":r,"data-type":"block-item-move"})]}),ue("span",{className:"absolute block-item-parent",onClick:L(t),title:"Select Parent",children:ue(C,{icon:j})}),ue("span",{className:"absolute block-item-delete",onClick:P(t,n,o),children:ue(C,{icon:M})}),ue("span",{className:"absolute block-item-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:R(e),children:ue(C,{icon:O})})]}),ue("div",{style:{...u,overflow:u.borderRadius?"hidden":void 0},children:ue("div",{className:"block-content block-item-container-body",style:{background:p,borderRadius:u.borderRadius},children:(e.children||[]).map((t,n)=>{const o=D(t);return ue("div",{style:{...o,width:"mobile"===l?"100%":t.width},children:(t.children||[]).map((o,a)=>{const l=`${e.id}:${n}:${a}`,r=`${e.id}:${n}:${a+1}`,d=a===t.children.length-1&&"empty"!==o.key&&"column"!==o.key;return me(s,{children:[H(o,e.id,n,a,l,r,c),d&&ue("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})})]},`${e.id}:${n}:${o.id||a}`)})},`${e.id}:${t.id||"cell"}:${n}`)})})})]})}),me("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:[ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),I&&ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":r,"data-type":"block-item-move"})]})]})},H=(e,t,n,o,a,l,r=0)=>"empty"===e.key?me("div",{className:"block-empty-content p-4 h-32 relative width-full",children:[I&&ue("div",{className:"block-empty-content-tools",onDragOver:B,"data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-type":"empty-block-item",children:i("drag_block_here")}),e.name]},e.id||o):"column"===e.key?ue(s,{children:U(e,t,n,o,a,l,r+1)},`${t}:${n}:${e.id||o}`):me(s,{children:[ue("div",{className:"relative block-content-drag-label-content","data-drop-key":a,children:ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})}),ue("div",{className:Jn("block-item",m?.id===e.id&&"block-item-focus"),"data-block-id":e.id,children:me("div",{className:"relative",children:[E(e.id),me("div",{className:"block-item-tools",onDragOver:B,onClick:t=>{t.preventDefault(),t.stopPropagation(),g({id:e.id,data:e,type:"edit"}),_("edit")},children:[I&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":t,"data-cell-index":n,"data-item-index":o,"data-drop-key":a,"data-type":"block-item-move"}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":t,"data-cell-index":n,"data-item-index":o+1,"data-drop-key":l,"data-type":"block-item-move"})]}),ue("span",{className:"absolute block-item-parent",onClick:L(t),title:"Select Parent",children:ue(C,{icon:j})}),ue("span",{className:"absolute block-item-delete",onClick:P(t,n,o),children:ue(C,{icon:M})}),ue("span",{className:"absolute block-item-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:R(e),children:ue(C,{icon:O})})]}),ue(xo,{blockItem:e,id:e.id})]})})]},`${t}:${n}:${e.id||o}`);return ue(ge,{children:me("div",{className:"relative block-drag-label-content","data-index":o,"data-position":"top",children:[ue("div",{className:"absolute block-move-top",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})}),me("div",{className:Jn("relative block",m?.id===t.id&&"block-focus","mobile"===l&&"mobile-block-focus"),"data-block-id":t.id,onClick:A(t),children:[me("div",{className:"hover-visible",children:[E(t.id),ue("span",{className:"absolute block-delete",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=$e(r,t.id),o=c.filter(e=>e!==t.id);u(n,o,"delete"),g(null)},children:ue(C,{icon:M})}),ue("span",{className:"absolute block-move current-move-block-arrows",draggable:"true",onDragEnd:$,onDragStart:()=>{b(!0),g({id:t.id,data:t,type:"move"}),_("move")},children:ue(C,{icon:O})})]}),ue("div",{className:"width-full height-full absolute",onDragOver:B,style:{pointerEvents:f&&"column"===N?"auto":"none"},children:f&&"column"===N&&me(ge,{children:[ue("div",{className:"block-move-content-top","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":o}),ue("div",{className:"block-move-content-bottom","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":o+1})]})}),ue("div",{className:"column margin-auto",style:{...w,maxWidth:"100%",overflow:w.borderRadius?"hidden":void 0},children:ue("div",{className:"block-content",style:{background:x,borderRadius:w.borderRadius,width:k.contentWidth},"data-index":o,children:t.children.map((e,n)=>{const a="desktop"===l?e.styles?.desktop??{}:{...e.styles?.desktop??{},...e.styles?.mobile??{}};return ue(s,{children:ue("div",{id:`block-content-${o}-${n}`,style:{...a,width:"mobile"===l?"100%":e.width},children:e.children.map((o,a)=>{const l=`${t.id}:${n}:${a}`,r=`${t.id}:${n}:${a+1}`,c=a===e.children.length-1&&"empty"!==o.key&&"column"!==o.key;return me(s,{children:[H(o,t.id,n,a,l,r,0),c&&ue("div",{className:"relative block-content-drag-label-content","data-drop-key":r,children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:i("drag_block_here")})})})]},`${t.id}:${n}:${o.id||a}`)})})},`${t.id}:${e.id||"content"}:${n}`)})})})]})]})})},So=()=>{const{previewMode:e,setPreviewMode:t,bodySettings:o,blockList:a,actionType:s,setBlockList:c,setBodySettings:d}=n(Ye),[p,u]=i({histories:[],index:0}),{histories:m,index:g}=p,y=l(null);r(()=>{const e=be(a),t=be(o),n=JSON.stringify({blockList:e,bodySettings:t});if(y.current!==n)return"firstRender"===s?(y.current=n,void u({histories:[{blockList:e,bodySettings:t}],index:0})):void(s.includes("set_history")?y.current=n:u(o=>{const a=o.histories.slice(0,o.index+1);return a.push({blockList:e,bodySettings:t}),y.current=n,{histories:a,index:o.index+1}}))},[a,o,s]);return me("div",{className:"header",children:[me("div",{className:"header-box",children:[ue(C,{onClick:()=>t("desktop"),icon:H,className:Jn("header-icon-small","desktop"===e&&"header-icon_active","desktop"!==e&&"header-icon_disabled")}),ue(C,{icon:K,onClick:()=>t("mobile"),className:Jn("header-icon-small","mobile"===e&&"header-icon_active","mobile"!==e&&"header-icon_disabled")})]}),ue("div",{className:"header-box text-center"}),me("div",{className:"header-box text-right",children:[ue(C,{onClick:()=>{if(m[g-1]){const e=be(m[g-1]);u({...p,index:g-1}),c(e.blockList,"set_history_"+(g-1)),d(e.bodySettings)}},icon:z,className:Jn("header-icon-history",m[g-1]&&"header-icon-history_active",!m[g-1]&&"header-icon-history_disabled")}),ue(C,{onClick:()=>{if(m[g+1]){const e=be(m[g+1]);u({...p,index:g+1}),c(e.blockList,`set_history_${g+1}`),d(e.bodySettings)}},icon:F,className:Jn("header-icon-history",m[g+1]&&"header-icon-history_active",!m[g+1]&&"header-icon-history_disabled")})]})]})},Co=e=>{const{clearStyles:t}=e,{t:o}=Yn(),{previewMode:a,bodySettings:i,blockList:c,setSelectionRange:d}=n(Ye),p=l(null);r(()=>{const e=fe(()=>{try{const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0),a=document.getElementById("preview");if(!(!!a&&(a.contains(o.commonAncestorContainer)||a===o.commonAncestorContainer)))return;const i=(e=>e?{startContainer:e.startContainer,startOffset:e.startOffset,endContainer:e.endContainer,endOffset:e.endOffset,collapsed:e.collapsed}:null)(o);if(e=p.current,t=i,e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset&&e.collapsed===t.collapsed)return;p.current=i,d(o.cloneRange())}catch(e){console.warn(e)}var e,t},100);return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[d]);return me("div",{className:"preview-main",children:[ue(So,{}),ue("div",{className:"default-scrollbar",id:"preview",children:ue("div",{className:"preview-content",style:{width:"desktop"===a?"100%":364,...i.styles},children:ue("div",{className:"margin-auto",style:{maxWidth:"100%",width:"100%"},children:c.length?me(ge,{children:[c.map((e,n)=>ue(s,{children:ue(wo,{block:e,blockIndex:n,clearStyles:t})},`${e?.id||"block"}-${n}`)),ue("div",{className:"relative block-drag-label-content","data-index":c.length,"data-position":"bottom",children:ue("div",{className:"absolute block-move-bottom",children:ue("span",{className:"block-tools-drag_here",children:o("drag_block_here")})})})]}):ue("div",{"data-name":"dragEmpty",className:"start-to-add",style:{width:i.contentWidth,maxWidth:"100%"},"data-type":"empty-block",onDragOver:e=>{e.preventDefault()},children:o("add_blocks")})})})})]})},No=({color:e,setColor:t})=>{const[n,o]=i(!1);return ue(y,{zIndex:1070,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,content:ue("div",{className:"select-none ee-color-picker-popover",children:ue(ye,{color:e,style:{boxShadow:"none"},onChange:t})}),trigger:"click",open:n,onOpenChange:o,children:ue("button",{className:"color-picker-button",style:{background:e}})})},To=({padding:e,setPadding:t})=>{const{t:n}=Yn();return ue("div",{className:"padding-settings",children:[{name:n("top"),value:"paddingTop"},{name:n("right"),value:"paddingRight"},{name:n("left"),value:"paddingLeft"},{name:n("bottom"),value:"paddingBottom"}].map(({name:n,value:o})=>{const a=e[o];return me("div",{children:[ue("div",{children:n}),ue(b,{className:"width-full",addonAfter:"px",min:0,value:a,onChange:(i=o,n=>{const o={...e,[i]:n};t(o)})})]},o);var i})})},Io=e=>{if(!e||"string"!=typeof e)return!1;try{const t=new URL(e);return/\/knowledge-base\/products$/i.test(t.pathname.replace(/\/$/,""))}catch{return/knowledge-base\/products\/?$/i.test(String(e).trim().replace(/\/$/,""))}},Ao=e=>{if(!e||"object"!=typeof e)return null;const t=null!=e.id?String(e.id):null!=e.resourceId?String(e.resourceId):"";if(!t)return null;const n=e.price,o="number"==typeof n?n:parseFloat(String(n??"").replace(/,/g,""));return{id:t,name:e.name??"",description:e.description??"",image:e.image_url??e.image??"",link:e.url??"",price:Number.isFinite(o)?o:0,currency:e.currency??"USD",old_price:null!=e.old_price?e.old_price:null,new_price:null!=e.new_price?e.new_price:null,resourceId:e.resourceId,source:e.source}},Lo=async(e,t,n={},{page:o=1,limit:a=20,search:i=""}={})=>{if(!e)return null;try{if(Io(e)){if(!t)return null;const l=e.replace(/\/$/,""),r=new URL(`${l}/${encodeURIComponent(t)}`);r.searchParams.set("page",String(o)),r.searchParams.set("limit",String(a)),r.searchParams.set("search",i??"");const s=await fetch(r.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!s.ok)return console.error("[API Service] KB products fetch failed:",s.status,s.statusText),null;const c=await s.json(),d=Array.isArray(c.data)?c.data:[];return{products:d.map(Ao).filter(Boolean),meta:c.meta&&"object"==typeof c.meta?c.meta:{}}}const l=new URL(e);t&&l.searchParams.append("companyId",t);const r=await fetch(l.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!r.ok)return console.error("[API Service] Products fetch failed:",r.status,r.statusText),null;const s=await r.json();if(!1===s.success)return console.error("[API Service] Products API returned error:",s.error),null;const c=s.data?.products??[];return Array.isArray(c)&&0!==c.length?{products:c,meta:{hasMore:!1,hasProducts:!0}}:{products:[],meta:{hasMore:!1,hasProducts:!1}}}catch(e){return console.error("[API Service] Error fetching products:",e),null}},Po={};function Ro(){return"undefined"!=typeof document?document.body:null}function $o(e){if(!e)return"";const t=e.currency??"",n=e.price?.amount??e.price??"";return`${e.name} — ${t} ${n}`.trim()}function Bo(e,t){const n=new Map;return[...e,...t].forEach(e=>{e&&e.id&&n.set(e.id,e)}),Array.from(n.values())}function Do({apiConfig:e,templateData:t,value:n,selectedProduct:r,onChange:s,placeholder:c,staticProductList:d=[],getPopupContainer:p}){const{t:u}=Yn(),m=e?.productsEndpoint,g=e?.companyId??t?.companyId,y=a(()=>{const t=e?.headers;return t&&"object"==typeof t?t:Po},[e?.headers]),h=Boolean(m&&g)&&Io(m),[b,_]=i([]),[v,x]=i({}),[w,S]=i(!1),[C,N]=i(""),[T,I]=i(""),A=l(null),L=l(0),P=l(1),R=l(""),$=l(!1),B=l(""),D=o(async(e,t,n)=>{if(!h)return;const o=(t??"").trim();if(n){const t=`${o}::${e}`;if($.current&&B.current===t)return;$.current=!0,B.current=t}const a=++L.current;S(!0);try{const i=await Lo(m,g,y,{page:e,limit:20,search:o});if(a!==L.current)return;if(!i)return n||(_([]),I((t??"").trim())),void x({});x(i.meta||{}),_(e=>n?Bo(e,i.products):i.products),P.current=e}finally{n&&($.current=!1,B.current=""),a===L.current&&S(!1)}},[h,m,g,y]),E=o(async e=>{if(!h)return;const t=(e??"").trim();$.current=!1,B.current="";const n=++L.current;S(!0);try{if(""!==t){const e=await Lo(m,g,y,{page:1,limit:20,search:t});if(n!==L.current)return;return e?(x(e.meta||{}),_(e.products),I(t),void(P.current=1)):(_([]),x({}),I(t),void(P.current=1))}let e=1,o=[],a={};for(;o.length<10&&e<=15;){const t=await Lo(m,g,y,{page:e,limit:20,search:""});if(n!==L.current)return;if(!t?.products?.length)break;if(o=Bo(o,t.products),a=t.meta||{},P.current=e,!a.hasMore)break;e+=1}x(a),_(o),I("")}finally{n===L.current&&S(!1)}},[h,m,g,y]),U=o(()=>{if(!h||w||!v?.hasMore)return;const e=P.current+1;D(e,R.current,!0)},[h,w,v?.hasMore,D]),M=p??Ro,O=o(e=>me("div",{children:[e,w&&b.length>0&&me("div",{className:"ee-kb-product-select-footer",children:[ue(f,{size:"small"})," ",ue("span",{children:u("loading")})]}),!w&&v?.hasMore&&ue("div",{className:"ee-kb-product-select-footer",children:ue("button",{type:"button",className:"ee-kb-product-select-load-more",onClick:U,children:u("load_more_products")})})]}),[w,b.length,v?.hasMore,U,u]),j=a(()=>{const e=h?b:d;return Bo(r?.id?[r]:[],e)},[h,b,d,r]),H=a(()=>j.map(e=>({value:e.id,label:$o(e)})),[j]),K=e=>{if(!e)return s(null),void(h&&(clearTimeout(A.current),N(""),R.current="",P.current=1,I(""),E("")));const t=j.find(t=>t.id===e)||d.find(t=>t.id===e);s(t||null)},z="ee-kb-product-select-dropdown";return ue(k,h?{className:"ee-stack-control ee-kb-product-select",value:n??void 0,placeholder:c,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:z,getPopupContainer:M,onChange:K,allowClear:!0,showSearch:!0,filterOption:!1,searchValue:C,onSearch:e=>{if(!h)return;const t=e??"";N(t);const n=t.trim();if(clearTimeout(A.current),""===n)return R.current="",P.current=1,void E("");A.current=setTimeout(()=>{R.current=n,P.current=1,E(n)},400)},onOpenChange:e=>{clearTimeout(A.current),e?($.current=!1,B.current="",N(""),R.current="",P.current=1,E("")):($.current=!1,B.current="",N(""),R.current="")},notFoundContent:w?me("span",{className:"ee-kb-product-select-loading",children:[ue(f,{size:"small"})," ",u("loading")]}):H.length>0?null:ue("span",{className:"ee-kb-product-select-empty",children:""!==T.trim()?u("no_products_matching_search"):u("no_product_found")}),options:H,dropdownRender:O}:{className:"ee-stack-control",value:n??void 0,placeholder:c,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:z,getPopupContainer:M,onChange:K,allowClear:!0,showSearch:!0,optionFilterProp:"label",options:d.map(e=>({value:e.id,label:$o(e)}))})}const Eo=()=>{const{previewMode:e,currentItem:t,blockMap:o,rootOrder:a,setBlocks:i,setCurrentItem:l}=n(Ye),r=e=>{let n;if("column"===e.key){const{blockMap:t}=Se([e]);n={...o,...t}}else n={...o,[t.id]:e};i(n,a,`edit_${(new Date).getTime()}`),l({...t,data:e})};return{findStyleItem:(t,n)=>{let o=t[e][n];return o||(o=t.desktop[n]),o},cardItemElement:(e,t)=>me("div",{className:"card-item",children:[ue("div",{className:"card-item-title",children:e}),ue("div",{children:t})]}),updateItemStyles:r,colorChange:n=>({hex:o})=>{const a=be(t.data);a.styles[e][n]=o,r(a)},paddingChange:n=>{const o=be(t.data);o.styles[e]={...o.styles[e],...n},r(o)},otherStylesChange:(n,o)=>{const a=be(t.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[e]||(a.styles[e]={}),a.styles[e][n]=o,"desktop"!==e&&(a.styles.desktop[n]=o),r(a)},inputChange:n=>o=>{const a=be(t.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[e]||(a.styles[e]={}),a.styles[e][n]=o,"desktop"!==e&&(a.styles.desktop[n]=o),r(a)}}},Uo=()=>{const{t:e}=Yn(),t=(e=>[{id:_e(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},children:[{id:_e(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}},children:[{id:_e(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}]}]},{id:_e(),name:e("text"),key:"text",text:e("text_content"),type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:void 0,lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{id:_e(),name:e("button"),key:"button",text:e("button"),type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12},mobile:{}},styles:{desktop:{width:"auto",fontSize:12,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:void 0,color:"#fff",display:"inline-block"},mobile:{}}},{id:_e(),name:e("spacer"),key:"spacer",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{height:16,width:"100%",display:"block"},mobile:{}}},{id:_e(),name:e("divider"),key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{id:_e(),name:e("image"),key:"image",src:"",alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{id:_e(),name:e("menu"),key:"menu",list:[{label:"Page",url:"",target:"_self"},{label:"Page",url:"",target:"_self"}],separator:" | ",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:"#333333",linkColor:"#2faade",paddingTop:5,paddingBottom:5,paddingLeft:15,paddingRight:15,textAlign:"center",letterSpacing:0,fontWeight:"normal"},mobile:{}}},{id:_e(),name:e("avatar"),key:"avatar",src:"",alt:"Avatar",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:64,borderRadius:"50%",display:"block"},mobile:{}}},{id:_e(),name:e("social_link"),key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:""},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:""},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:""},{image:"https://s.magecdn.com/social/tc-x.svg",title:"Twitter",linkURL:""}],imageWidth:32,contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}}}])(e),n=(e=>{const t={desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12},mobile:{}},n={key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}};return{full:{columns:1,type:"full",children:[{name:e("content"),key:"content",width:"100%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}]},"1-1":{columns:2,type:"1-1",children:Array.from({length:2}).map(()=>({name:e("content"),key:"content",width:"50%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1":{columns:3,type:"1-1-1",children:Array.from({length:3}).map(()=>({name:e("content"),key:"content",width:"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1-1":{columns:4,type:"1-1-1-1",children:Array.from({length:4}).map(()=>({name:e("content"),key:"content",width:"25%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2":{columns:2,type:"1-2",children:Array.from({length:2}).map((o,a)=>({name:e("content"),key:"content",width:0===a?"33.3%":"66.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"2-1":{columns:2,type:"2-1",children:Array.from({length:2}).map((o,a)=>({name:e("content"),key:"content",width:0===a?"66.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"2-4-2-4":{columns:4,type:"2-4-2-4",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"16.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"4-2-4-2":{columns:4,type:"4-2-4-2",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"33.3%":"16.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))}}})(e),o=(e=>t=>{const n={id:_e(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}};return{id:_e(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:[{id:_e(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"transparent"},mobile:{}},children:[t||n]}]}})(e);return{blockConfigsList:t,columnsSetting:n,getColumnConfig:o}},Mo=[{id:"dolor-sit-amet",name:"Dolor Sit Amet",description:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",image:"https://plus.unsplash.com/premium_photo-1681711647066-ef84575c0d95?fm=jpg&q=30&w=300&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cHJvZHVjdCUyMHBob3RvZ3JhcGh5fGVufDB8fDB8fHww",link:"https://loremipsum.com/checkout/cart/12345",price:2e3,currency:"USD",old_price:2500,new_price:2e3},{id:"sample-2",name:"Sample Pearl Necklace",description:"Classic strand of lustrous freshwater pearls with a sterling silver clasp. Timeless elegance for any outfit.",image:"https://picsum.photos/seed/necklace2/200/200",link:"https://www.example.com/products/sample-2",price:750,currency:"USD",old_price:null,new_price:null},{id:"sample-3",name:"Sample Gold Bracelet",description:"Handcrafted 14K yellow gold link bracelet. Lightweight and comfortable for everyday wear.",image:"https://picsum.photos/seed/bracelet3/200/200",link:"https://www.example.com/products/sample-3",price:450,currency:"USD",old_price:500,new_price:450},{id:"sample-4",name:"Sample Silver Earrings",description:"Delicate sterling silver drop earrings with subtle sparkle. A versatile addition to your jewelry collection.",image:"https://picsum.photos/seed/earrings4/200/200",link:"https://www.example.com/products/sample-4",price:199,currency:"USD",old_price:null,new_price:null},{id:"sample-5",name:"Sample Gemstone Pendant",description:"Stunning pendant with a natural gemstone centerpiece on a fine silver chain. Makes a memorable gift.",image:"https://picsum.photos/seed/pendant5/200/200",link:"https://www.example.com/products/sample-5",price:320,currency:"USD",old_price:400,new_price:320}],Oo=["product"],jo=e=>"discount"===e||"none"===e?e:"product",Ho=e=>"additional"===e?"additional":"main",Ko=()=>{const{blockMap:e,rootOrder:t,setBlocks:o,currentItem:l,setCurrentItem:r,previewMode:s,bodySettings:c,templateData:d,setIsDragStart:p,setActionType:u,apiConfig:g}=n(Ye),{t:y}=Yn(),[h,f]=i(!1),[x,w]=i(null),[S,N]=i(!1),{findStyleItem:T,cardItemElement:I,colorChange:A,inputChange:L,paddingChange:P}=Eo(),{columnsSetting:R,blockConfigsList:$}=Uo(),B=jo(l.data.containerType??"none"),D=l.data.productRole??"main",E=l.data.columnProducts,U=a(()=>Array.isArray(E)?E:[],[E]),M=d?.content?.products?.length>0?d.content.products:d?.catalogProducts?.length>0?d.catalogProducts:Mo,O=d?.content?.primaryProductId,j=n=>{const{blockMap:a}=Se([n]);let i={...e,...a};const s=Ho(n.productRole);"product"===n.containerType&&"main"===s&&Object.keys(i).forEach(e=>{if(e===n.id)return;const t=i[e];if(!t||"column"!==t.key)return;if("product"!==t.containerType)return;"main"===Ho(t.productRole)&&(i[e]={...t,productRole:"additional"})}),o(i,t,`edit_${(new Date).getTime()}`),r({...l,data:n})},H=e=>{const t=jo(l.data.containerType),n=e.children,o=n.length,a=l.data.children?.length??0,i=l.data.columnProducts??[],r=Array.from({length:o},(e,t)=>t<a?i[t]??null:null);return{...l.data,...e,containerType:t,columnProducts:r,children:n.map((e,t)=>{let n=e;if(l.data.children?.[t]){const o=l.data.children[t];n={...o,key:e.key,name:e.name,width:e.width,styles:be(e.styles??o.styles),children:o.children}}return{...n}})}},K=e=>{if(G)return;const t=be(l.data);t.containerType=jo(e);const n=t.containerType,o=Oo.includes(n);t.productRole=o?t.productRole??"main":void 0;const a=t.children?.length??0;let i=o?Array.from({length:a},(e,n)=>t.columnProducts?.[n]??null):[];if(o&&a>0&&M.length>0){const e=O?M.find(e=>e.id===O):M[0];e&&(i[0]=e)}t.columnProducts=i,j(t)},z=e=>{const t=be(l.data);t.productRole=Ho(e);const n=t.children?.length??0;let o=Array.from({length:n},(e,n)=>t.columnProducts?.[n]??null);if(n>0&&M.length>0){const e=O?M.find(e=>e.id===O):M[0];e&&!o[0]&&(o[0]=e)}t.columnProducts=o,j(t)},F=Oo.includes(B),W=a(()=>to(l.data,e),[l.data,e]),J=a(()=>Ie(e,t,l.data?.id),[e,t,l.data?.id]),q=a(()=>(J||[]).filter(e=>e?.containerBlock&&e.containerBlock.id!==l.data?.id&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[J,l.data?.id]),G=a(()=>(J||[]).some(e=>e?.containerBlock&&e.containerBlock.id!==l.data?.id&&"none"!==e.containerType),[J,l.data?.id]),Y=Qt(0,B,d,{},q).filter(({variableKey:e,key:t})=>!("product"===B)||(e??t)!==wt).filter(({variableKey:e,key:t})=>!W.has(e??t)),Z=a(()=>{const e={columnIndex:0,columnProduct:U[0]??null};return tn(B,d,e).filter(e=>e.variableKey&&!W.has(e.variableKey))},[B,d,U,W]),Q=a(()=>{const e=new Set(Y.map(e=>e.variableKey??e.key)),t=Z.filter(t=>{const n=t.variableKey;return!(!n||e.has(n))&&(e.add(n),!0)});return[...Y,...t]},[Y,Z]),X=e=>t=>{const n=(e=>{const{value:t,type:n}=e;if("image"===n){const e=be($.find(e=>"image"===e.key));return e?(e.src=t,e):{name:y("image"),key:"image",src:t,alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}}const o=be($.find(e=>"text"===e.key));return o?(o.text=`<p>${t}</p>`,o.type="p",o.contentType="static",o):{name:y("text"),key:"text",text:`<p>${t}</p>`,type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}}})(e);"undefined"!=typeof window&&(window.__eeDragItemData=n,window.__eeDragSource="product-variables"),p(!0),u("add"),t.target.classList.add("ee-product-variable-item-dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="copy")},ee=e=>{e.target.classList.remove("ee-product-variable-item-dragging"),"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null),setTimeout(()=>{p(!1)},50)},te=[{key:"full",widths:["100%"],columns:1},{key:"1-1",widths:["50%","50%"],columns:2},{key:"1-1-1",widths:["33.33%","33.33%","33.33%"],columns:3},{key:"1-1-1-1",widths:["25%","25%","25%","25%"],columns:4}],ne="product"===B?te.filter(e=>1===e.columns):te,oe=e=>t=>{const n=be(l.data);n.children[e].styles[s]={...n.children[e].styles[s],...t},j(n)},ae=e=>{if("number"==typeof e)return e;if("string"!=typeof e)return;const t=Number.parseFloat(e);if(!Number.isNaN(t)){if(e.endsWith("%")){const e=Number(c?.contentWidth)||600;return Math.round(e*t/100)}return Math.round(t)}},ie=e=>t=>{if(null==t||Number.isNaN(Number(t)))return;const n=Math.max(1,Math.round(Number(t))),o=be(l.data);o.children[e].width=`${n}px`,j(o)};return me(ge,{children:[me("div",{className:"margin-y-30",children:[me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:y("container_settings")}),me("div",{className:"ee-right-panel-stack",children:[me("span",{className:"ee-stack-label",children:[y("container_type"),ue(_,{title:y("tooltip_container_type"),children:ue("span",{className:"ee-help-icon","aria-label":"Help",children:ue(C,{icon:V})})})]}),ue(k,{className:"ee-stack-control",value:B,onChange:K,disabled:G,style:{width:"100%"},options:et.map(({value:e,labelKey:t})=>({value:e,label:y(t)})),getPopupContainer:()=>document.querySelector(".right-settings")||document.body}),F&&me("div",{className:"ee-product-assign-section margin-top-12",children:[ue("span",{className:"ee-stack-label",children:y("product_role")}),ue(k,{className:"ee-stack-control",value:D,style:{width:"100%"},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,onChange:z,options:[{value:"main",label:y("product_role_main_hero")},{value:"additional",label:y("product_role_additional")}]})]}),F&&me("div",{className:"ee-product-assign-section margin-top-12",children:[ue("span",{className:"ee-stack-label",children:y("assign_product_to_column")}),ue(Do,{apiConfig:g,templateData:d,value:U[0]?.id??void 0,selectedProduct:U[0],onChange:e=>((e,t)=>{const n=be(l.data),o=[...n.columnProducts??[]];o[e]=t,n.columnProducts=o,j(n)})(0,e),placeholder:y("assign_product_to_column"),staticProductList:M})]}),me("div",{className:"ee-product-variables-section margin-top-12",children:[me("button",{type:"button",className:"ee-product-variables-toggle",onClick:()=>N(e=>!e),children:[ue("span",{children:y("variables")}),ue("span",{className:"ee-product-variables-toggle-icon",children:S?"▴":"▾"})]}),S&&ue("div",{className:"ee-product-variables-dropdown",children:Q.length>0?Q.map(e=>me("div",{className:"ee-product-variable-item",draggable:!0,onDragStart:X(e),onDragEnd:ee,title:e.value,children:[ue("span",{className:"ee-product-variable-item-label",children:e.labelKey?y(e.labelKey):e.label}),ue("span",{className:"ee-product-variable-item-token",children:e.value})]},e.value)):ue("div",{className:"ee-stack-help",children:"No variables available for this container type."})})]})]})]}),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("columns")]}),ue("div",{children:ne.map((e,t)=>{return ue("div",{className:Jn(l.data.type===e.key?"column-item-active":"column-item-un_active","column-item"),onClick:(n=e.key,()=>{if(l.data.children.length>R[n].children.length)return f(!0),void w(n);const e=H(R[n]);j(e)}),children:e.widths.map((t,n)=>{const o=n===e.widths.length-1;return ue("span",{style:{width:t},className:Jn(o?"":"column-item-border-right",l.data.type===e.key?"column-item-active":"column-item-un_active","height-full")},n)})},t);var n})})]}),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("column_settings")]}),ue(v,{defaultActiveKey:"1",animated:{inkBar:!0,tabPane:!0},items:l.data.children.map((e,t)=>{const n=t+1,o=T(e.styles,"backgroundColor");return{label:`${y("column")} ${n}`,key:n,children:me(ge,{children:[I(y("content_background_color"),ue(No,{color:o,setColor:({hex:e})=>((e,t)=>n=>{const o=be(l.data);o.children[t].styles[s][e]=n,j(o)})("backgroundColor",t)(e)})),I(y("size_px"),ue(b,{min:1,className:"input-width",addonAfter:"px",value:ae(e.width),onChange:ie(t)})),ue(To,{padding:{paddingTop:T(e.styles,"paddingTop"),paddingRight:T(e.styles,"paddingRight"),paddingLeft:T(e.styles,"paddingLeft"),paddingBottom:T(e.styles,"paddingBottom")},setPadding:oe(t)})]})}})})]}),(()=>{const e=T(l.data.styles,"backgroundColor"),t=T(l.data.styles,"contentBackground"),n=T(l.data.styles,"borderRadius"),o="number"==typeof n?n:parseInt(String(n||"").replace("px",""),10)||0;return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",y("column_styles")]}),I(y("background_color"),ue(No,{color:e,setColor:A("backgroundColor")})),I(y("content_background_color"),ue(No,{color:t,setColor:A("contentBackground")})),I(y("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:o,onChange:e=>L("borderRadius")(Number(e)||0)})),ue(To,{padding:{paddingTop:T(l.data.styles,"paddingTop"),paddingRight:T(l.data.styles,"paddingRight"),paddingLeft:T(l.data.styles,"paddingLeft"),paddingBottom:T(l.data.styles,"paddingBottom")},setPadding:P})]})})()]}),ue(m,{title:y("column_delete"),open:h,onOk:()=>{const e=H(R[x]);j(e),f(!1),w(null)},onCancel:()=>{f(!1)},width:400,okText:y("confirm"),cancelText:y("cancel"),wrapClassName:"ee-modal-dark",children:ue("p",{className:"margin-y-30",dangerouslySetInnerHTML:{__html:y("column_delete_desc",{count:`<span class="column-modal-context">\n ${x?l.data.children.length-R[x].children.length:0}\n </span>`})}})})]})},zo=({mlEmailNodesEndpoint:e,mlGenerationEndpoint:t,headers:n={},templateData:a,blockId:i,containerType:l,containerId:r,productId:s,blockName:c="Text",blockElementType:d="p",emailTemplateId:p,companyId:u,language:m="en"}={})=>{const g=!!(e&&String(p??"").trim()&&String(u??"").trim()&&i&&r),y=!!t,h=g||y;return{generateOptions:o(async(o,h,b={})=>{const{previousPrompt:f="",previousSelectedAiContent:k=""}=b,_=function(e,t={}){const{containerType:n}=t,o=String(e??"").trim();let a;return a=Xt[o]?Xt[o]:o?o.split(/[-_]/).map(e=>e.length?e[0].toUpperCase()+e.slice(1).toLowerCase():"").join(""):"DisplayText",a||(a="DisplayText"),"product"===n&&"DisplayText"===a?"ProductDescription":a}(o,{containerType:l});if(g){const t={containerType:l||"none",id:r};if("product"===(l||"")&&null!=s){const e=String(s).trim();e&&(t.productId=e)}const o={blockContext:{blockId:i,name:c,type:d||"p"},companyId:u,containerContext:t,emailTemplateId:p,language:m||"en",promptContext:{newPrompt:h||"",previousPrompt:f||"",previousSelectedAiContent:k||""},type:_},a=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] generate-email-nodes: no endpoint"),{success:!1,error:"ML endpoint is not configured."};try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});let a={};try{a=await o.json()}catch{a={}}if(!o.ok||!1===a.success){let e="";const t=a.error;if(t&&"object"==typeof t){const n=null!=t.code?String(t.code):"",o=null!=t.message?String(t.message):"";e=[n,o].filter(Boolean).join(" — ")||o||n}return e||(e=null!=a.message?String(a.message):`${o.status} ${o.statusText}`),console.error("[API Service] generate-email-nodes failed:",e),{success:!1,error:String(e),errorCode:t&&"object"==typeof t&&null!=t.code?String(t.code):void 0}}const i=Array.isArray(a.variations)?a.variations:[],l=i.map(e=>e&&"string"==typeof e.value?e.value.trim():"").filter(Boolean);return 0===l.length?(console.error("[API Service] generate-email-nodes: empty variations"),{success:!1,error:"No variations were returned for this request."}):{success:!0,options:l,variations:i,emailJson:"string"==typeof a.emailJson?a.emailJson:void 0,blockId:a.blockId,emailTemplateId:a.emailTemplateId}}catch(e){return console.error("[API Service] Error calling generate-email-nodes:",e),{success:!1,error:e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to reach the ML service. Check your network and try again."}}})(e,o,n);if(a&&a.success&&a.options?.length)return a.options;return{error:a&&"object"==typeof a&&a.error?String(a.error):"No response from the ML service."}}if(y){const e={variable:_,prompt:h,context:{templateData:a,blockId:i,containerType:l}},o=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] ML endpoint not configured"),null;try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});if(!o.ok)return console.error("[API Service] ML endpoint failed:",o.status,o.statusText),null;const a=await o.json();if(!a.success)return console.error("[API Service] ML API returned error:",a.error),null;const i=a.data?.options??[];return Array.isArray(i)&&0!==i.length?i:(console.error("[API Service] ML API returned empty options"),null)}catch(e){return console.error("[API Service] Error calling ML endpoint:",e),null}})(t,e,n);return o&&o.length?o:{error:"The legacy ML endpoint did not return any options. Check the API response."}}return{i18nKey:"ml_ai_unavailable"}},[g,y,e,t,n,a,i,l,r,s,c,d,p,u,m]),isConfigured:h}};function Fo(){const{blockMap:e,rootOrder:t,currentItem:o}=n(Ye);return a(()=>{if(!e||!o?.id)return{containerBlock:null,containerType:"none",columnIndex:0,cellIndex:0};const{containerBlock:n,containerType:a,cellIndex:i,isRoot:l,rootIndex:r}=function(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}}const a=Te(e,t,n);if(!a)return{containerBlock:null,containerType:"none",cellIndex:0,isRoot:!1};const i=e[a.containerId];return{containerBlock:i??null,containerType:i?.containerType??"none",cellIndex:a.cellIndex,isRoot:!1}}(e,t,o.id);let s=0;if(l)s=r??0;else if(n){const e=t.indexOf(n.id);s=e>=0?e:0}const c=i??0;return{containerBlock:n??null,containerType:a??"none",columnIndex:s,cellIndex:c,contentIndex:c}},[e,t,o?.id])}const{TextArea:Vo}=g;const Wo=()=>{const{currentItem:e,previewMode:t,templateData:o,apiConfig:a,language:l,aiEnabled:r=!0}=n(Ye),{t:s}=Yn(),{findStyleItem:c,cardItemElement:d,paddingChange:p,otherStylesChange:u,inputChange:m,updateItemStyles:g}=Eo(),{containerBlock:y,containerType:f,cellIndex:v}=Fo(),w="product"===f?y?.columnProducts?.[v??0]?.id:void 0,{generateOptions:S}=zo({mlEmailNodesEndpoint:a?.mlEmailNodesEndpoint,mlGenerationEndpoint:a?.mlGenerationEndpoint,headers:a?.headers||{},templateData:o,blockId:e?.id,containerType:f,containerId:y?.id,productId:w,blockName:e?.data?.name||"Text",blockElementType:e?.data?.type||"p",emailTemplateId:a?.emailTemplateId,companyId:a?.companyId??o?.companyId,language:l||"en"}),[N,T]=i(""),I=(n,o)=>{const a=be(e.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles.desktop||(a.styles.desktop={}),a.styles.mobile||(a.styles.mobile={}),a.styles.desktop[n]=o,a.styles[t][n]=o,a.text=ke(a.text,a.styles.desktop),g(a)},[A,L]=i([]),[P,R]=i(!1),[$,B]=i(""),D=e.data.contentType??"dynamic",E=e.data.type||"p",U=t=>{if(!r)return;const n=t?"dynamic":"static",o=be(e.data);o.contentType=n,"dynamic"===n&&(o.selectedVariableKey=void 0,o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[]),g(o)},M=async()=>{const t=e.data.dynamicVariable??"",n=e.data.dynamicPrompt??N??"";R(!0),B("");try{const a=await S(t,n,{previousPrompt:e.data.dynamicPreviousPrompt??"",previousSelectedAiContent:(o=e.data.dynamicSelectedContent||e.data.text,null==o||"string"!=typeof o?"":o.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())});if(a&&"object"==typeof a&&!Array.isArray(a))return a.i18nKey?B(s(a.i18nKey)):a.error?B(String(a.error)):B(s("ml_no_variations")),void L([]);if(Array.isArray(a)&&a.length>0){B(""),L(a);const t=be(e.data);t.dynamicOptions=a,t.dynamicPrompt=n,t.dynamicPreviousPrompt=n,g(t)}else B(s("ml_no_variations")),L([])}catch(e){console.error("[TextStyleSettings] Error during content generation:",e),B(e&&"object"==typeof e&&"message"in e?String(e.message):s("ml_generation_unexpected_error")),L([])}finally{R(!1)}var o},O=t=>{const n=t.target.value;T(n),B("");const o=be(e.data);o.dynamicPrompt=n,g(o)};return me("div",{className:"margin-y-30",children:[me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("text_and_content_type")}),me("div",{className:"ee-content-type-two-rows margin-bottom-12",children:[r&&me("div",{className:"ee-content-type-row ee-content-type-row-1",children:[ue("span",{className:"ee-ai-label",children:s("ai_enabled")}),ue(x,{checked:"dynamic"===D,onChange:U})]}),ue("div",{className:"ee-content-type-row ee-content-type-row-2",children:[{name:s("body_paragraph"),value:"p"},{name:s("heading_h1"),value:"h1"},{name:s("heading_h2"),value:"h2"},{name:s("heading_h3"),value:"h3"},{name:s("heading_h4"),value:"h4"}].map(({name:t,value:n})=>{return ue("div",{className:Jn(E===n?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:(o=n,()=>{let t=e.data.styles.desktop.fontSize;switch(o){case"h1":t=22;break;case"h2":t=20;break;case"h3":t=18;break;case"h4":t=16;break;default:t=t||14}const n=be(e.data);n.type=o,n.styles={...n.styles,desktop:{...n.styles.desktop,fontSize:t,fontWeight:"p"!==o?"bold":n.styles.desktop.fontWeight}},n.text=ke(n.text,n.styles.desktop),g(n)}),children:t},n);var o})})]}),r&&"dynamic"===D&&me(ge,{children:[me("div",{className:"ee-dynamic-prompt-block",children:[me("span",{className:"ee-prompt-label",children:[s("dynamic_prompt_help"),ue(_,{title:s("tooltip_dynamic_prompt"),children:ue("span",{className:"ee-help-icon","aria-label":"Help",children:ue(C,{icon:V})})})]}),ue(Vo,{rows:3,value:e.data.dynamicPrompt??N,onChange:O,placeholder:s("dynamic_prompt_help")}),ue(h,{type:"primary",size:"small",loading:P,disabled:!(e.data.dynamicPrompt??N??"").trim(),onClick:M,children:s("generate")}),$?ue("div",{className:"ee-ml-generation-error",role:"alert",children:$}):null]}),(e.data.dynamicOptions?.length>0||A.length>0)&&me("div",{className:"ee-sample-content-block",children:[ue("div",{className:"card-item-title",children:s("select_content")}),(e.data.dynamicOptions||A).map((t,n)=>{const o="string"==typeof t?t:String(t),a=(e.data.text||e.data.dynamicSelectedContent||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),i=o.replace(/\s+/g," ").trim(),l=a.length>0&&a===i;return ue("div",{className:Jn("ee-sample-content-item",l&&"ee-sample-content-item-selected"),onClick:()=>(t=>{const n=be(e.data);n.dynamicSelectedContent=t,n.text=t,g(n),L([]),B("")})(t),children:t},n)})]})]})]}),(()=>{const n=c(e.data.styles,"color"),o=c(e.data.styles,"linkColor"),a=c(e.data.styles,"textAlign"),i=c(e.data.styles,"fontFamily"),l=c(e.data.styles,"fontSize"),r=null!=l&&""!==l?Number(l):14,p=c(e.data.styles,"lineHeight"),y=null!=p&&""!==p&&Number(String(p).replace(/%/g,""))||120;return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("text_styles")}),d(s("font_color"),ue(No,{color:n,setColor:({hex:e})=>I("color",e)})),d(s("link_color"),ue(No,{color:o||n||"#2faade",setColor:({hex:n})=>((n,o)=>{const a=be(e.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles.desktop||(a.styles.desktop={}),a.styles.mobile||(a.styles.mobile={}),a.styles.desktop[n]=o,a.styles[t][n]=o,g(a)})("linkColor",n)})),d(s("text_align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:e,value:t})=>ue("div",{className:Jn(a===t?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>u("textAlign",t),children:ue(C,{icon:e,className:"tag-style-size"})},t))})),d(s("font_family"),ue(k,{className:"input-width",value:i,onChange:e=>I("fontFamily",e),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Garamond","Georgia","Courier New","cursive"].map(e=>ue(k.Option,{value:e,children:e},e))})),d(s("font_size"),ue(b,{min:1,max:999,className:"input-width",addonAfter:"px",value:r,onChange:e=>I("fontSize",null!=e&&""!==e?Number(e):14)})),d(s("line_height"),ue(b,{className:"input-width",addonAfter:"%",min:1,max:999,value:y,onChange:e=>m("lineHeight")(null!=e&&""!==e?`${e}%`:"120%")}))]})})(),me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("padding_settings")}),ue(To,{padding:{paddingTop:c(e.data.styles,"paddingTop"),paddingRight:c(e.data.styles,"paddingRight"),paddingLeft:c(e.data.styles,"paddingLeft"),paddingBottom:c(e.data.styles,"paddingBottom")},setPadding:p})]})]})},Jo=()=>{const{currentItem:e,previewMode:t,templateData:o,blockList:a}=n(Ye),{t:i}=Yn(),{containerType:l,columnIndex:r,contentIndex:s}=Fo(),c=["header","footer","discount"].includes(l),{findStyleItem:d,cardItemElement:p,colorChange:u,paddingChange:m,inputChange:y,updateItemStyles:h}=Eo(),{labelOptions:f,urlOptions:_}=function(e,t){return{labelOptions:Gt.map(({variableKey:e,labelKey:n})=>({value:Tt(e),labelKey:n,pasteValue:Wt(t,e,{})})),urlOptions:Yt.map(({variableKey:e,labelKey:n})=>({value:Tt(e),labelKey:n,pasteValue:Wt(t,e,{})}))}}(0,o);return me("div",{className:"margin-y-30",children:[(()=>{const{linkURL:t,text:n,labelVariable:l,urlVariable:d}=e.data,u=n?.replace(/<[^>]+>/g,"").trim()??"",m=l||u&&/\{\{\w+\}\}/.test(u),y=l?l.replace(/^\{\{|\}\}$/g,"").trim():u.match(/\{\{(\w+)\}\}/)?.[1]||"CTALabel",b={columnIndex:s,columnProduct:a?.[r]?.columnProducts?.[s]??null},v=o&&m?Wt(o,y,b):null,x=null==v||String(v).startsWith("{{")?u:v,w=d?d.replace(/^\{\{|\}\}$/g,"").trim():"",S=!t&&w&&o?Wt(o,w,b):null,C=t||(null==S||"string"!=typeof S||S.startsWith("{{")?"":String(S).replace(/^https?:\/\//,"").trim())||"";return me("div",{children:[ue("div",{className:"right-setting-block-item-title",children:i("button_action")}),c&&f.length>0&&ue(ge,{children:p(i("button_label_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:i("button_label_manual"),allowClear:!0,value:l||void 0,onChange:t=>{const n=be(e.data);if(!t)return n.labelVariable="",n.text=n.text||"",void h(n);const o=f.find(e=>e.value===t);n.labelVariable=t,n.text=o?o.pasteValue:t,h(n)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:i("button_label_manual")},...f.map(e=>({value:e.value,label:i(e.labelKey)}))]}))}),ue("div",{className:"card-item-title",children:i("button_text")}),ue("div",{className:"margin-top-6",children:ue(g,{value:x,onChange:t=>{const n=t.target.value,o=be(e.data);o.text=n,n&&n.startsWith("{{")||(o.labelVariable=""),h(o)},placeholder:i("button_label_manual")})}),ue("div",{className:"ee-button-action-divider"}),p(i("action_type"),ue("div",{className:"link-tag",children:i("link")})),c&&_.length>0&&ue(ge,{children:p(i("button_url_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:i("button_url_manual"),allowClear:!0,value:d||void 0,onChange:t=>{const n=be(e.data);if(!t)return n.urlVariable="",n.linkURL=n.linkURL||"",void h(n);const o=_.find(e=>e.value===t);n.urlVariable=t;const a=o?o.pasteValue:t;n.linkURL="string"==typeof a?a.replace(/^https?:\/\//,""):"",h(n)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:i("button_url_manual")},..._.map(e=>({value:e.value,label:i(e.labelKey)}))]}))}),ue("div",{className:"card-item-title",children:i("link_url")}),ue("div",{className:"margin-top-6",children:ue(g,{addonBefore:"https://",value:C,onChange:t=>{const n=t.target.value,o=be(e.data);o.linkURL=n,n&&n.startsWith("{{")||(o.urlVariable=""),h(o)}})})]})})(),(()=>{const n=d(e.data.styles,"width"),a=d(e.data.styles,"borderRadius"),l="number"==typeof a?a:parseInt(String(a||"").replace("px",""),10)||0,r=e.data.contentStyles?.[t]?.textAlign??"center",s=d(e.data.styles,"color"),c=d(e.data.styles,"fontFamily"),g=d(e.data.styles,"fontSize"),f=d(e.data.styles,"lineHeight"),_=d(e.data.styles,"backgroundColor")??(e=>e?.brandContext?.brand_color??"#111111")(o);return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:i("button_styles")}),p(i("width_auto"),ue(x,{checked:"auto"===n,className:Jn("auto"===n?"switch-active":"switch-disabled"),onChange:()=>{const e="auto"===n?"100%":"auto";y("width")(e)}})),"auto"!==n&&ue(w,{value:Number(n.replace("%","")),onChange:e=>y("width")(e+"%")}),"auto"!==n&&p(i("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"}].map(({icon:n,value:o})=>ue("div",{className:Jn(r===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>{const n=be(e.data);n.styles={...n.styles||{},[t]:{...n.styles?.[t]||{},textAlign:"center"}},n.contentStyles={...n.contentStyles||{},[t]:{...n.contentStyles?.[t]||{},textAlign:o}},h(n)},children:ue(C,{icon:n,className:"tag-style-size"})},o))})),p(i("font_color"),ue(No,{color:s,setColor:u("color")})),p(i("button_color"),ue(No,{color:_,setColor:u("backgroundColor")})),p(i("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:l,onChange:e=>y("borderRadius")(Number(e)||0)})),p(i("font_family"),ue(k,{className:"input-width",value:c,onChange:y("fontFamily"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Garamond","Georgia","Courier New","cursive"].map(e=>ue(k.Option,{value:e,children:e},e))})),p(i("font_size"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:g,onChange:y("fontSize")})),p(i("line_height"),ue(b,{className:"input-width",addonAfter:"%",min:0,value:Number(f.replace("%","")),onChange:e=>y("lineHeight")(e+"%")})),ue("div",{className:"card-item-title",children:i("button_padding")}),ue(To,{padding:{paddingTop:d(e.data.styles,"paddingTop"),paddingRight:d(e.data.styles,"paddingRight"),paddingLeft:d(e.data.styles,"paddingLeft"),paddingBottom:d(e.data.styles,"paddingBottom")},setPadding:m})]})})(),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",i("padding_settings")]}),ue(To,{padding:{paddingTop:d(e.data.contentStyles,"paddingTop"),paddingRight:d(e.data.contentStyles,"paddingRight"),paddingLeft:d(e.data.contentStyles,"paddingLeft"),paddingBottom:d(e.data.contentStyles,"paddingBottom")},setPadding:n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},h(o)}})]})]})},qo=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:o}=Yn(),{findStyleItem:a,cardItemElement:i,colorChange:l,updateItemStyles:r,inputChange:s}=Eo(),c=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},r(o)};return ue("div",{className:"margin-y-30",children:(()=>{const n=a(e.data.contentStyles,"textAlign"),d=a(e.data.styles,"width"),p=a(e.data.styles,"borderTopColor"),u=a(e.data.styles,"borderTopWidth"),m=a(e.data.styles,"borderTopStyle"),g=[{label:o("solid"),value:"solid"},{label:o("dotted"),value:"dotted"},{label:o("dashed"),value:"dashed"}];return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",o("divider_styles")]}),i(o("divider_type"),ue(k,{className:"input-width",value:m,onChange:s("borderTopStyle"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:g.map(e=>ue(k.Option,{value:e.value,children:e.label},e.value))})),i(o("height"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:u,onChange:s("borderTopWidth")})),i(o("divider_color"),ue(No,{color:p,setColor:l("borderTopColor")})),ue("div",{className:"card-item-title",children:o("width")}),ue(w,{value:Number(d.replace("%","")),onChange:e=>s("width")(e+"%")}),i(o("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:o,value:a})=>ue("div",{className:Jn(n===a?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},r(o)})(a),children:ue(C,{icon:o,className:"tag-style-size"})},a))})),me("div",{className:"card-item-title",children:[" ",o("padding_settings")]}),ue(To,{padding:{paddingTop:a(e.data.contentStyles,"paddingTop"),paddingRight:a(e.data.contentStyles,"paddingRight"),paddingLeft:a(e.data.contentStyles,"paddingLeft"),paddingBottom:a(e.data.contentStyles,"paddingBottom")},setPadding:c})]})})()})},Go=()=>{const{currentItem:e}=n(Ye),{t:t}=Yn(),{findStyleItem:o,cardItemElement:a,inputChange:i}=Eo(),l=o(e.data.styles,"height"),r="number"==typeof l?l:parseInt(l,10)||16;return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:t("spacer_block")}),a(me("span",{className:"flex items-center gap-2",children:[ue(C,{icon:Y,className:"tag-style-size"}),t("height")]}),ue(b,{min:0,max:500,className:"input-width",addonAfter:"px",value:r,onChange:e=>i("height")(e??0)}))]})},Yo=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:a}=Yn(),{findStyleItem:r,paddingChange:s,updateItemStyles:c,cardItemElement:d,colorChange:p,inputChange:u}=Eo(),{list:m=[],separator:y=" | "}=e.data,[h,f]=i(null),[_,v]=i(!1),[x,w]=i(null),S=l(null),N=(t,n)=>{const o=be(e.data);o[t]=n,c(o)},T=o(fe(e=>{e.preventDefault();const t=S.current;if(!t)return;const n=e.target.closest("[data-index]");if(!n)return;const o=Array.from(t.children).indexOf(n);if(-1===o)return;const a=parseInt(x,10);if(a===o)return;const i=be(m);[i[o],i[a]]=[i[a],i[o]],w(String(o)),N("list",i)},50),[m,x]),I=[{label:a("same_tab"),value:"_self"},{label:a("new_tab"),value:"_blank"}];return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:a("menu_items")}),ue("div",{ref:S,onDragOver:T,className:"margin-top-12",onDragStart:e=>{const t=e.target.closest("[data-index]"),n=t?.getAttribute("data-index");null!=n&&(t.classList.add("social-link-item-current"),f(t),v(!0),w(n))},onDragEnd:()=>{const e=h?.closest?.("[data-index]");e&&e.classList.remove("social-link-item-current"),f(null),v(!1),w(null)},children:m.map((e,t)=>ue("div",{"data-index":t,draggable:!0,className:Jn("social-link-item",_&&"social-link-item-drag_start",x===String(t)?"social-link-item-current":"border-transparent"),children:me("div",{className:"social-link-item-content ee-menu-item-content",children:[me("div",{className:"ee-menu-item-header flex items-center justify-between margin-bottom-8",children:[me("div",{className:"flex items-center gap-2 cursor-grab",children:[ue(C,{icon:Z,className:"tag-style-size"}),me("span",{className:"font-semibold",children:[a("menu_item")," ",t+1]})]}),ue("div",{className:"social-link-item-icon social-link-item-icon-slate ee-menu-item-delete",onClick:()=>N("list",m.filter((e,n)=>n!==t)),children:ue(C,{icon:M,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]}),me("div",{className:"ee-menu-item-fields",children:[d(a("label"),ue(g,{className:"ee-menu-item-input",value:e.label||"",onChange:e=>N("list",m.map((n,o)=>o===t?{...n,label:e.target.value}:n)),placeholder:"Page"})),d(a("url"),ue(g,{addonBefore:"https://",className:"ee-menu-item-input",value:(e.url||"").replace(/^https?:\/\//,""),onChange:e=>N("list",m.map((n,o)=>o===t?{...n,url:e.target.value}:n)),placeholder:"example.com"})),d(a("target"),ue(k,{className:"input-width ee-menu-item-input",value:e.target||"_self",onChange:e=>N("list",m.map((n,o)=>o===t?{...n,target:e}:n)),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:I.map(e=>ue(k.Option,{value:e.value,children:e.label},e.value))}))]})]})},t))}),me("button",{type:"button",className:"menu-add-new-item margin-top-12",onClick:()=>N("list",m.concat({label:a("page"),url:"",target:"_self"})),children:[ue("span",{className:"menu-add-new-item-icon",children:"+"})," ",a("add_new_item")]}),ue("div",{className:"right-setting-block-item-title margin-top-18",children:a("menu_styles")}),d(a("font_family"),ue(k,{className:"input-width",value:r(e.data.styles,"fontFamily"),onChange:u("fontFamily"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:["sans-serif","Arial","Verdana","Times New Roman","Georgia","Courier New"].map(e=>ue(k.Option,{value:e,children:e},e))})),d(a("font_size"),ue(b,{min:8,max:72,className:"input-width",addonAfter:"px",value:r(e.data.styles,"fontSize"),onChange:u("fontSize")})),d(a("letter_spacing"),ue(b,{className:"input-width",addonAfter:"px",value:r(e.data.styles,"letterSpacing"),onChange:u("letterSpacing")})),d(a("text_color"),ue(No,{color:r(e.data.styles,"color"),setColor:p("color")})),d(a("link_color"),ue(No,{color:r(e.data.styles,"linkColor"),setColor:p("linkColor")})),d(a("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"}].map(({icon:n,value:o})=>ue("div",{className:Jn(r(e.data.contentStyles,"textAlign")===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},c(o)})(o),children:ue(C,{icon:n,className:"tag-style-size"})},o))})),d(a("separator"),ue(g,{value:y,onChange:e=>N("separator",e.target.value),placeholder:" | "})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:a("padding_settings")}),ue(To,{padding:{paddingTop:r(e.data.contentStyles,"paddingTop"),paddingRight:r(e.data.contentStyles,"paddingRight"),paddingLeft:r(e.data.contentStyles,"paddingLeft"),paddingBottom:r(e.data.contentStyles,"paddingBottom")},setPadding:n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},c(o)}}),ue("div",{className:"card-item-title margin-top-18",children:a("spacing")}),ue(To,{padding:{paddingTop:r(e.data.styles,"paddingTop"),paddingRight:r(e.data.styles,"paddingRight"),paddingLeft:r(e.data.styles,"paddingLeft"),paddingBottom:r(e.data.styles,"paddingBottom")},setPadding:s})]})},Zo=({imageUploadEndpoint:e,headers:t={},companyId:n,imageUploadQueryParams:a,imageUploadCompanyField:i="companyId"}={})=>{const l=!!e;return{uploadImageFile:o(async o=>{if(!l)return console.error("[useImageUpload] No image upload endpoint configured"),null;if(!o)return console.error("[useImageUpload] No file provided"),null;if(!o.type.startsWith("image/"))return console.error("[useImageUpload] File is not an image:",o.type),null;if(o.size>10485760)return console.error("[useImageUpload] File too large:",o.size,"bytes"),null;const r=await(async(e,t,n,o={},a={})=>{if(!e)return console.error("[API Service] No image upload endpoint configured"),null;if(!t)return console.error("[API Service] No file provided for upload"),null;const{queryParams:i={},companyField:l="companyId"}=a;try{const a=new FormData;a.append("file",t),n&&("comment"===l?a.append("comment",n):a.append("companyId",n));let r=e;if(i&&Object.keys(i).length>0){const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);Object.entries(i).forEach(([e,t])=>{null!=t&&n.searchParams.set(e,String(t))}),r=n.toString()}const s={...o};Object.keys(s).forEach(e=>{"content-type"===e.toLowerCase()&&delete s[e]});const c=await fetch(r,{method:"POST",headers:{...s},body:a});if(!c.ok)return console.error("[API Service] Image upload failed:",c.status,c.statusText),null;const d=await c.json();if(d&&!1===d.success)return console.error("[API Service] Upload API returned error:",d.error),null;if(d&&"string"==typeof d.url&&d.url.trim())return d.url.trim();const p=d?.data?.url;return p&&"string"==typeof p?p.trim():(console.error("[API Service] Upload API returned no URL"),null)}catch(e){return console.error("[API Service] Error uploading image:",e),null}})(e,o,n,t,{queryParams:a,companyField:i});return r},[l,e,t,n,a,i]),isConfigured:l}},Qo=()=>{const{currentItem:e,previewMode:t,templateData:o,apiConfig:r}=n(Ye),{t:s}=Yn(),{containerBlock:c,containerType:d,contentIndex:p}=Fo(),u=c?.columnProducts?.[p]??null,{findStyleItem:m,cardItemElement:y,inputChange:h,updateItemStyles:_}=Eo(),v=l(null),[N,T]=i(!1),I=a(()=>({columnIndex:p,columnProduct:u}),[p,u]),A=a(()=>tn(d,o,I),[d,o,I]),{uploadImageFile:L,isConfigured:P}=Zo({imageUploadEndpoint:r?.imageUploadEndpoint,headers:r?.headers||{},companyId:r?.companyId,imageUploadQueryParams:r?.imageUploadQueryParams,imageUploadCompanyField:r?.imageUploadCompanyField}),R=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},_(o)};return me("div",{className:"margin-y-30",children:[(()=>{const{linkURL:t}=e.data,n=nn(e.data);return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_action")}),y(s("action_type"),me("div",{className:"ee-image-action-type-row",children:[ue("span",{className:Jn("link-tag",!n&&"ee-image-link-tag-inactive"),children:s("link")}),ue(x,{checked:n,onChange:t=>{const n=be(e);n.data.linkEnabled=Boolean(t),_(n.data)},className:Jn(n?"bg-sky-500":"bg-gray-400")})]})),n?me(ge,{children:[ue("div",{className:"card-item-title",children:s("link_url")}),ue("div",{className:"margin-top-6",children:ue(g,{addonBefore:"https://",value:t??"",onChange:t=>{const n=t.target.value??"",o=be(e);o.data.linkURL=n,_(o.data)},placeholder:s("link_url_placeholder")})})]}):null]})})(),(()=>{const{src:t,alt:n}=e.data,a="string"==typeof t&&/^\{\{\w+\}\}$/.test(t.trim())?String(t).replace(/\{\{|\}\}/g,"").trim():"",i=o&&a?Wt(o,a,I):null,l=null==i||String(i).startsWith("{{")?t||"":i,r=t=>n=>{const o=be(e),a=n.target.value;o.data[t]=a,_(o.data)},c=t=>{const n=be(e);n.data.src=t,_(n.data)};return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_settings")}),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_upload")}),ue("input",{ref:v,type:"file",accept:"image/*",className:"ee-image-upload-input-hidden",onChange:async e=>{const t=e.target.files?.[0];if(t){if(!P)return S.error(s("image_upload_not_configured")||"Image upload not configured"),console.warn("[ImageStyleSettings] Image upload endpoint not configured"),void(e.target.value="");T(!0);try{const e=await L(t);e?(c(e),S.success(s("image_uploaded")||"Image uploaded successfully")):S.error(s("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e),S.error(s("image_upload_error")||"Error uploading image")}finally{T(!1),e.target.value=""}}},disabled:N}),ue(f,{spinning:N,children:me("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:()=>{v.current?.click()},onDrop:async e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer?.files?.[0];if(t?.type?.startsWith("image/")){if(!P)return S.error(s("image_upload_not_configured")||"Image upload not configured"),void console.warn("[ImageStyleSettings] Image upload endpoint not configured");T(!0);try{const e=await L(t);e?(c(e),S.success(s("image_uploaded")||"Image uploaded successfully")):S.error(s("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e),S.error(s("image_upload_error")||"Error uploading image")}finally{T(!1),v.current.value=""}}},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:N?.6:1,cursor:N?"not-allowed":"pointer"},children:[ue(C,{icon:Q,className:"ee-image-upload-icon"}),ue("span",{children:N?s("uploading")||"Uploading...":s("image_upload_click")})]})})]})}),A.length>0&&y(s("image_source_variable"),ue(k,{className:"ee-variable-select width-full",placeholder:s("image_source_variable"),allowClear:!0,value:"string"==typeof t&&/^\{\{\w+\}\}$/.test(String(t).trim())?String(t).trim():void 0,onChange:e=>c(e??""),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:A.map(e=>({value:e.value,label:s(e.labelKey)}))})),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_url")}),ue("div",{className:"margin-top-6",children:ue(g,{value:l,onChange:r("src"),placeholder:"https://..."})})]})}),ue("div",{className:"card-item",children:me("div",{className:"width-full",children:[ue("div",{className:"card-item-title",children:s("image_alt")}),ue("div",{className:"margin-top-6",children:ue(g,{value:n||"",onChange:r("alt")})})]})})]})})(),(()=>{const n=m(e.data.styles,"width"),o=m(e.data.styles,"borderRadius"),a="number"==typeof o?o:parseInt(String(o||"").replace("px",""),10)||0,i=m(e.data.contentStyles,"textAlign");return me(ge,{children:[ue("div",{className:"right-setting-block-item-title",children:s("image_styles")}),y(s("width_auto"),ue(x,{checked:"auto"===n,className:Jn("auto"===n?"bg-sky-500":"bg-gray-400"),onChange:()=>{const e="auto"===n?"100%":"auto";h("width")(e)}})),"auto"!==n&&ue(w,{value:Number(n.replace("%","")),onChange:e=>h("width")(e+"%")}),y(s("border_radius"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:a,onChange:e=>h("borderRadius")(Number(e)||0)})),y(s("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:n,value:o})=>ue("div",{className:Jn(i===o?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},_(o)})(o),children:ue(C,{icon:n,className:"tag-style-size"})},o))})),ue("div",{className:"card-item-title",children:s("padding_settings")}),ue(To,{padding:{paddingTop:m(e.data.contentStyles,"paddingTop"),paddingRight:m(e.data.contentStyles,"paddingRight"),paddingLeft:m(e.data.contentStyles,"paddingLeft"),paddingBottom:m(e.data.contentStyles,"paddingBottom")},setPadding:R})]})})()]})},Xo=()=>{const{currentItem:e}=n(Ye),{t:t}=Yn(),{findStyleItem:o,cardItemElement:a,updateItemStyles:i}=Eo(),{src:l,alt:r,linkURL:s}=e.data,c=o(e.data.styles,"width")??64,d=o(e.data.styles,"borderRadius"),p="50%"===d?50:parseInt(String(d).replace("px",""),10)||0;return me("div",{className:"margin-y-30",children:[ue("div",{className:"right-setting-block-item-title",children:t("avatar_image")}),a(t("image_url"),ue(g,{addonBefore:"https://",value:l,onChange:t=>{const n=be(e.data);n.src=t.target.value??"",i(n)}})),a(t("image_alt"),ue(g,{value:r,onChange:t=>{const n=be(e.data);n.alt=t.target.value??"",i(n)},placeholder:"Avatar"})),a(t("link_url"),ue(g,{addonBefore:"https://",value:s,onChange:t=>{const n=be(e.data);n.linkURL=t.target.value??"",i(n)},placeholder:t("link_url_placeholder")})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:t("image_styles")}),a(t("width"),ue(b,{min:16,max:256,value:"number"==typeof c?c:64,onChange:t=>{const n=be(e.data);n.styles.desktop||(n.styles.desktop={}),n.styles.desktop.width=t,i(n)},addonAfter:"px"})),a(t("avatar_border_radius"),ue(b,{min:0,max:50,value:p,onChange:t=>{const n=be(e.data);n.styles.desktop||(n.styles.desktop={}),n.styles.desktop.borderRadius=50===t?"50%":`${t}px`,i(n)},addonAfter:50===p?"%":"px"})),ue("div",{className:"right-setting-block-item-title margin-top-18",children:t("padding_settings")}),ue(To,{padding:{paddingTop:o(e.data.contentStyles,"paddingTop"),paddingRight:o(e.data.contentStyles,"paddingRight"),paddingLeft:o(e.data.contentStyles,"paddingLeft"),paddingBottom:o(e.data.contentStyles,"paddingBottom")},setPadding:t=>{const n=be(e.data);n.contentStyles||(n.contentStyles={desktop:{},mobile:{}}),n.contentStyles.desktop={...n.contentStyles.desktop,...t},i(n)}})]})},ea="https://s.magecdn.com/social",ta=()=>{const{currentItem:e,previewMode:t}=n(Ye),{t:a}=Yn(),{findStyleItem:r,paddingChange:s,updateItemStyles:c,cardItemElement:d}=Eo(),{list:p}=e.data,[u,m]=i(null),[y,h]=i(!1),[f,k]=i(null),_=l(null),v=[{image:`${ea}/tc-facebook.svg`,title:"Facebook",linkURL:""},{image:`${ea}/tc-github.svg`,title:"Github",linkURL:""},{image:`${ea}/tc-linkedin.svg`,title:"LinkedIn",linkURL:""},{image:`${ea}/tc-instagram.svg`,title:"Instagram",linkURL:""},{image:`${ea}/tc-tiktok.svg`,title:"TikTok",linkURL:""},{image:`${ea}/tc-x.svg`,title:"Twitter",linkURL:""},{image:`${ea}/tc-youtube.svg`,title:"YouTube",linkURL:""}],x=(t,n)=>{const o=be(e);o.data={...o.data,[t]:n},c(o.data)},w=o(fe(e=>{e.preventDefault();const t=_.current,n=Array.from(t.childNodes).indexOf(e.target);if(-1===n)return;const o=f,a=be(p);o!==n&&([a[n],a[o]]=[a[o],a[n]],k(n),x("list",a))},50),[u,f]),S=n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],...n},c(o)},N=t=>{const n=be(e.data);n.imageWidth=t,c(n)};return me("div",{className:"margin-y-30",children:[(()=>{const n=r(e.data.contentStyles,"textAlign"),o=e.data.imageWidth;return me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",a("social_link_settings")]}),d(a("align"),ue("div",{className:"flex justify-center items-center",children:[{icon:W,value:"left"},{icon:J,value:"center"},{icon:q,value:"right"},{icon:G,value:"justify"}].map(({icon:o,value:a})=>ue("div",{className:Jn(n===a?"align-style-item-active":"align-style-item-un_active","align-style-item"),onClick:()=>(n=>{const o=be(e.data);o.contentStyles[t]={...o.contentStyles[t],textAlign:n},c(o)})(a),children:ue(C,{icon:o,className:"tag-style-size"})},a))})),d(a("social_link_size"),ue(b,{min:0,className:"input-width",addonAfter:"px",value:o,onChange:N})),ue("div",{className:"card-item-title margin-top-18",children:a("social_links")}),ue("div",{ref:_,onDragOver:w,className:"margin-top-12",onDragStart:e=>{m(e.target),h(!0),k(e.target.dataset.index)},onDragEnd:()=>{u.childNodes[0].classList.remove("social-link-item-current"),m(null),h(!1),k(null)},children:p.map((e,t)=>{const{image:n,title:o,linkURL:a}=e;return ue("div",{"data-index":t,draggable:!0,className:Jn("social-link-item","cursor-grab",y&&"social-link-item-drag_start",f===t?"social-link-item-current":"border-transparent"),children:me("div",{className:"social-link-item-content",children:[me("div",{className:"flex items-center justify-between",children:[me("div",{className:"flex items-center",children:[ue("img",{src:n,alt:o,className:"social-link-item-img"}),ue("div",{className:"font-semibold",children:o})]}),ue("div",{className:"flex items-center",children:ue("div",{className:"social-link-item-icon social-link-item-icon-slate",onClick:()=>{x("list",p.filter((e,n)=>n!==t))},children:ue(C,{icon:M,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})})]}),ue("div",{className:"margin-top-12 relative",children:ue(g,{addonBefore:"https://",value:a||"",onChange:e=>x("list",p.map((n,o)=>o===t?{...n,linkURL:e.target.value}:n))})})]})},t)})}),ue("div",{className:"card-item-title margin-top-18",children:a("add_social_link")}),ue("div",{className:"social-link-add margin-top-12",children:v.map((e,t)=>{const{image:n,title:o}=e;return ue("img",{src:n,alt:o,className:"social-link-add-img",onClick:()=>x("list",p.concat(e))},t)})}),me("div",{className:"card-item-title margin-top-18",children:[" ",a("spacing")]}),ue(To,{padding:{paddingTop:r(e.data.styles,"paddingTop"),paddingRight:r(e.data.styles,"paddingRight"),paddingLeft:r(e.data.styles,"paddingLeft"),paddingBottom:r(e.data.styles,"paddingBottom")},setPadding:s})]})})(),me(ge,{children:[me("div",{className:"right-setting-block-item-title",children:[" ",a("padding_settings")]}),ue(To,{padding:{paddingTop:r(e.data.contentStyles,"paddingTop"),paddingRight:r(e.data.contentStyles,"paddingRight"),paddingLeft:r(e.data.contentStyles,"paddingLeft"),paddingBottom:r(e.data.contentStyles,"paddingBottom")},setPadding:S})]})]})},na=()=>{const{currentItem:e}=n(Ye);return me(ge,{children:["column"===e?.data.key&&ue(Ko,{}),"text"===e?.data.key&&ue(Wo,{}),"button"===e?.data.key&&ue(Jo,{}),"divider"===e?.data.key&&ue(qo,{}),"spacer"===e?.data.key&&ue(Go,{}),"menu"===e?.data.key&&ue(Yo,{}),"image"===e?.data.key&&ue(Qo,{}),"avatar"===e?.data.key&&ue(Xo,{}),"social_link"===e?.data.key&&ue(ta,{})]})};var oa={presets:[{id:"preset_header",presetName:"Header",nameKey:"preset_header",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"50%"},mobile:{}}},{name:"Container",key:"column",type:"full",containerType:"none",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 14px; font-family: Verdana; color: #333333"><a target="_blank" href="https://example.com">Shop</a> | <a target="_blank" href="https://example.com">Frey </a> | <a target="_blank" href="https://example.com">Our Story</a></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",lineHeight:"120%",paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},isPreset:!0},{name:"Image",key:"image",src:"{{HeroBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}]}]}]}]}},{id:"navigation_bar",presetName:"Navigation Bar",nameKey:"preset_navigation_bar",containerType:"none",block:{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 14px; font-family: Verdana; color: #333333"><a target="_blank" href="https://example.com">Shop</a> | <a target="_blank" href="https://example.com">Frey </a> | <a target="_blank" href="https://example.com">Our Story</a></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",lineHeight:"120%",paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},isPreset:!0}},{id:"product_single",nameKey:"preset_product_single",containerType:"product",presetName:"Hero Product",block:{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"main",columnProducts:[{id:"product-1",name:"Abundance Butterfly Diamond Ring",description:"The Maia Diamond Ring features round diamonds set along a delicate gold band, creating a refined and minimalistic look. Its versatile design makes it perfect for everyday wear or for layering with other rings.",image:"https://www.psylish.com/cdn/shop/files/IMG_4632.jpg?v=1773123202&width=1220",link:"https://www.psylish.com",price:2e3,currency:"USD",old_price:null,new_price:null}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: sans-serif"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:null,paddingLeft:12,paddingRight:12,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: sans-serif">{{ProductCurrency}} {{ProductPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:null,paddingBottom:6,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Shop Now",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:null,paddingRight:null},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:null,paddingRight:null,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}}]}]}},{id:"product_two_column",presetName:"Additional Products",nameKey:"preset_product_two_column",containerType:"product",block:{name:"Container",key:"column",type:"1-1",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},isPreset:!0,columns:2,columnProducts:[null,null],children:[{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:6,paddingRight:3,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-2",name:"Heartline Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_15.png?v=1770880382&width=1220",link:"https://www.psylish.com/",price:1e3,currency:"USD",old_price:1200,new_price:1e3}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial"><strike>{{ProductOldPrice}}</strike> {{ProductNewPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:0,paddingRight:0,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]},{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:3,paddingRight:6,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-3",name:"Lynx Heart Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_48.png?v=1770881768&width=1220",link:"https://www.psylish.com/",price:900,currency:"USD",old_price:1200,new_price:900}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial"><strike>{{ProductOldPrice}}</strike> {{ProductNewPrice}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]}]}},{id:"preset_discount",presetName:"Discount",nameKey:"preset_discount",containerType:"discount",block:{name:"Container",key:"column",type:"full",containerType:"discount",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#ffa7aa"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<div style="text-align: center;"><font face="Arial">Use <b>{{DiscountCode}}</b> for <b>{{DiscountValue}}</b> OFF. Expires on {{ValidUntil}}</font></div>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}}]}]}},{id:"preset_footer",presetName:"Footer",nameKey:"preset_footer",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{FooterBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"35%"},mobile:{}}},{name:"Text",key:"text",text:"<p><i><b>{{Tagline}}</b></i></p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{Address}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Social Link",key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:"facebook.com/psylish"},{image:"https://s.magecdn.com/social/tc-x.svg",title:"Twitter",linkURL:"twitter.com/psylish"},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:"instagram.com/psylish"},{image:"https://s.magecdn.com/social/tc-linkedin.svg",title:"LinkedIn",linkURL:"linkedin.com/company/psylish"},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:"www.tiktok.com/@psylish"},{image:"https://s.magecdn.com/social/tc-youtube.svg",title:"YouTube",linkURL:"www.youtube.com/@psylish"}],imageWidth:32,contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}},useCompanySocialLinks:!0},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{name:"Text",key:"text",text:'<p><a href="#" style="color:#263d2d;text-decoration:underline">{{Website}}</a></p>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center",color:"#263d2d",textDecoration:"underline"},mobile:{}}}]}]}}]};function aa(e){if(!e||"object"!=typeof e)return e;const t={...e,id:_e()};return Array.isArray(t.children)&&(t.children=t.children.map(aa)),Array.isArray(t.columnProducts)&&(t.columnProducts=t.columnProducts.map(e=>e&&"object"==typeof e?{...e}:e)),t}const ia={column:ce,text:se,button:re,divider:le,spacer:Y,menu:ie,image:E,social_link:ae,product:oe,header:ne,footer:te,discount:ee,avatar:X},la={Header:"header",Footer:"footer",Discount:"discount","Navigation Bar":"menu"};function ra(e){const t=la[e];return t&&ia[t]?ia[t]:ia.product}const sa=["ai_powered","components","presets"],ca=["column","divider","spacer","button","image","avatar","social_link"];function da(e,t,n){const o={ai_powered:[],components:[],presets:[]},a=function(e){return e?{ai_powered:["text"],components:ca,presets:[]}:{ai_powered:[],components:["text",...ca],presets:[]}}(n);oa.presets.forEach(e=>{o.presets.push({key:e.id,name:e.presetName,icon:ra(e.presetName),isPreset:!0,getColumn:()=>function(e){const t=oa.presets.find(t=>t.id===e);return t?aa(JSON.parse(JSON.stringify(t.block))):null}(e.id)})});for(const t of sa){const i=a[t];i&&0!==i.length&&i.forEach(a=>{const i=e.find(e=>e.key===a);i&&("ai_powered"===t&&"text"===a&&n?o[t].push({...i,contentType:"dynamic",dynamicPrompt:"",dynamicSelectedContent:"",dynamicOptions:[],dynamicVariable:"",isPreset:!1}):o[t].push({...i,isPreset:!1}))})}return o}const pa=({clearStyles:e})=>{const{setCurrentItem:t,setIsDragStart:o,setActionType:a,templateData:i,aiEnabled:l=!0}=n(Ye),{blockConfigsList:r}=Uo(),{t:s}=Yn(),c=da(r,0,l),d=t=>{t.target.style.border="";const n=t.target.querySelector(".right-panel-block-inner");n&&n.classList.remove("right-panel-block-move"),setTimeout(()=>{o(!1),e&&e()},50)},p=e=>n=>{const l=e.isPreset?be(e.getColumn(s,i)):be(e);t({id:null,data:l,type:"add"}),o(!0),n.target.style.border="1px dashed var(--ee-primary)";const r=n.target.querySelector(".right-panel-block-inner");r&&r.classList.add("right-panel-block-move"),a("add")},u={ai_powered:s("ai_powered"),components:s("components"),presets:s("presets")};return ue("div",{className:"right-panel-block-list",children:sa.map(e=>{const t=c[e];return t&&0!==t.length?me("div",{className:"right-panel-block-category",children:[ue("div",{className:"right-panel-block-category-title",children:u[e]}),t.map(e=>(e=>ue("div",{className:"right-panel-block-row",draggable:!0,onDragEnd:d,onDragStart:p(e),children:me("div",{className:"right-panel-block-inner",children:[ue("span",{className:"right-panel-block-drag-handle",title:s("drag_block_here"),children:ue(C,{icon:Z,className:"right-panel-block-drag-icon"})}),ue("span",{className:"right-panel-block-separator","aria-hidden":!0}),ue(C,{icon:e.icon||ia[e.key]||se,className:"right-panel-block-icon"}),ue("span",{className:"right-panel-block-text",children:e.name}),l&&"text"===e.key&&!e.isPreset&&ue("span",{className:"right-panel-block-ai-pill",children:"+ AI"})]})},e.key))(e))]},e):null})})},ua="content",ma="styles",ga=e=>{const{clearStyles:t}=e,{currentItem:o,isDragStart:a,bodySettings:r,setBodySettings:d,setCurrentItem:p,setActionType:u,blockMap:m,rootOrder:y}=n(Ye),{t:h}=Yn(),{cardItemElement:f}=Eo(),[k,_]=i(ua),v=l(null),x=()=>{if(!o?.id||!m[o.id])return[];const e=[o.id],t=new Set(e);let n=o.id;for(;;){const o=Te(m,y,n);if(!o||t.has(o.containerId))break;e.unshift(o.containerId),t.add(o.containerId),n=o.containerId}return e.map(e=>({id:e,data:m[e]})).filter(e=>Boolean(e.data))},w=()=>{let e="Block";const t=o?.data.key;switch(t){case"text":e=h("text_settings");break;case"column":{const t=o?.data?.containerType;e=h("product"===t?"block_product":"container_settings");break}case"button":e=h("button_settings");break;case"divider":e=h("divider_settings");break;case"spacer":e=h("spacer_settings");break;case"menu":e=h("menu_settings");break;case"image":e=h("image_settings");break;case"avatar":e=h("avatar_settings");break;case"social_link":e=h("social_link_settings")}return e},S=e=>t=>{d({...r,styles:{...r.styles,[e]:t.hex}},"set_body_settings")},N="undefined"!=typeof window&&"product-variables"===window.__eeDragSource,T=o&&"edit"===o.type&&(!a||N);c(()=>{if(!T)return;const e=v.current;e&&(e.scrollTop=0)},[T,o?.id]);return ue("div",{ref:v,className:"right-settings default-scrollbar",onClick:e=>{e.stopPropagation()},children:me(ge,T?{children:[me("div",{className:"right-panel-block-settings-header",children:[ue("button",{type:"button",className:"right-panel-back-btn",onClick:()=>p(null),"aria-label":"Back",children:ue(C,{icon:de})}),ue("h2",{className:"right-setting-block-title right-panel-block-title-inline",children:w()})]}),ue("div",{className:"right-panel-breadcrumb-bar","aria-label":"Selection path",children:x().map((e,t,n)=>{const o=t===n.length-1,a=(e=>{if(!e)return"";switch(e.key){case"column":{const t=e.containerType;return h("product"===t?"block_product":"discount"===t?"block_discount":"container")}case"text":return h("text");case"button":return h("button");case"image":return h("image");case"divider":return h("divider");case"spacer":return h("spacer");case"menu":return h("menu");case"avatar":return h("avatar");case"social_link":return h("social_link");case"empty":return h("drag_block_here");default:return e.name||"Block"}})(e.data);return me(s,{children:[o?ue("span",{className:"right-panel-breadcrumb-current",children:a}):ue("button",{type:"button",className:"right-panel-breadcrumb-btn",onClick:(i=e.id,e=>{e.preventDefault(),e.stopPropagation();const t=m[i];t&&(p({id:i,data:t,type:"edit"}),u("edit"))}),children:a}),!o&&ue("span",{className:"right-panel-breadcrumb-separator",children:"›"})]},`${e.id||"crumb"}-${t}`);var i})}),ue("div",{className:"right-panel-block-settings-form",children:ue(na,{})})]}:{children:[me("div",{className:"right-panel-tabs",children:[ue("button",{type:"button",className:"right-panel-tab "+(k===ua?"right-panel-tab-active":""),onClick:()=>_(ua),children:h("content")}),ue("button",{type:"button",className:"right-panel-tab "+(k===ma?"right-panel-tab-active":""),onClick:()=>_(ma),children:h("styles")})]}),me("div",{className:"right-panel-tab-content",children:[k===ua&&ue(pa,{clearStyles:t}),k===ma&&me(ge,{children:[me("section",{className:"right-panel-styles-section",children:[ue("h3",{className:"right-panel-styles-section-title",children:h("global")}),me("div",{className:"right-panel-styles-section-body",children:[f(h("text_color"),ue(No,{color:r.styles.color,setColor:S("color")})),f(h("email_theme_background_color"),ue(No,{color:r.styles.backgroundColor,setColor:S("backgroundColor")})),f(h("line_height"),ue(b,{className:"input-width",addonAfter:"px",min:0,max:900,value:Number(r.contentWidth),onChange:e=>d({...r,contentWidth:e},"set_body_settings")}))]})]}),me("section",{className:"right-panel-styles-section",children:[ue("h3",{className:"right-panel-styles-section-title",children:h("text_and_headings")}),ue("div",{className:"right-panel-styles-section-body",children:me("div",{children:[ue("div",{className:"pre_header",children:h("pre_header")}),ue(g,{className:"margin-top-12",value:r.preHeader,onChange:e=>d({...r,preHeader:e.target.value},"set_body_settings")}),ue("div",{className:"pre_header-desc",children:h("pre_header_description")})]})})]})]})]})]})})},ya=({language:e})=>{const{blockMap:t,rootOrder:a,setBlocks:i,currentItem:l,setCurrentItem:s,setIsDragStart:c,setLanguage:d,templateData:p}=n(Ye),{t:u}=Yn(),{getColumnConfig:m}=Uo(),g=e=>{if(!e||"object"!=typeof e)return e;const t=p?.content?.products,n=p?.catalogProducts,o=p?.content?.primaryProductId,a=Array.isArray(t)&&t.length>0?t:Array.isArray(n)&&n.length>0?n:Mo,i=o?a.find(e=>e.id===o):a[0],l=i?a.filter(e=>e?.id!==i.id):a,r=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(r):e.children;if("column"!==e.key||"product"!==e.containerType||!i)return{...e,children:t};const n=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),o="additional"===e.productRole?"additional":"main",a=Array.from({length:n},(e,t)=>"main"===o||0===l.length?i:l[t%l.length]);return{...e,children:t,columnProducts:a}};return r(e)};r(()=>{d(e)},[e,d]);const y=()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},h=()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},b=()=>{document.querySelectorAll(".block-empty-content").forEach(e=>{e.style.borderStyle="",e.style.borderColor=""})},f=()=>{y(),h(),b()},k=o(fe(e=>{e.preventDefault(),e.stopPropagation();const{type:t}=e.target.dataset;switch(t){case"empty-block":y(),h(),e.target.style.border="1px dashed #2faade";break;case"drag-over-column":{h();const t=e.target.dataset.index,n=document.getElementsByClassName("block-drag-label-content");Array.from(n).forEach(e=>{Number(e.dataset.index)===Number(t)?e.children[0].style.visibility="visible":e.children[0].style.visibility="hidden"});break}case"block-item-move":{y();const t=e.target.dataset.dropKey,n=document.getElementsByClassName("block-content-drag-label-content");Array.from(n).forEach(e=>{e.dataset.dropKey===t?e.children[0].style.visibility="visible":e.children[0].style.visibility="hidden"});break}case"empty-block-item":y(),h();{const t=e.target.parentNode;t&&t.classList.contains("block-empty-content")&&(t.style.borderStyle="solid")&&(t.style.borderColor="var(--ee-primary)")}break;default:y(),h()}},30),[]),_=(e,t)=>{const{blockMap:n,removedId:o}=Pe(e,t.containerId,t.cellIndex,t.itemIndex);return{result:n,removedId:o}},v=(e,t,n,o)=>{const a=e[t];if(!a||a.cells[n].childrenIds.length>0)return e;const i=we(o("drag_block_here"));return{...e,[i.id]:i,[t]:{...a,cells:a.cells.map((e,t)=>t===n?{...e,childrenIds:[i.id]}:e)}}},x=(e,t,n)=>{if(!t||!n)return!1;if(t===n)return!0;const o=t=>{const a=e[t];if(!a||"column"!==a.key)return!1;for(const e of a.cells||[])for(const t of e.childrenIds||[]){if(t===n)return!0;if(o(t))return!0}return!1};return o(t)};return ue(ge,{children:ue("div",{className:"email-editor",onDragOver:k,onDrop:e=>{e.preventDefault(),e.stopPropagation();const{type:n}=e.target.dataset;c(!1);const o="undefined"!=typeof window?window.__eeDragItemData:null,r=()=>{"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null)},d=o?"add":l?.type,p=o?xe(o):l?.data;if(p){switch(n){case"empty-block":{const e="column"===p.key?p:m(p),n=g(e),{newBlockMap:o,rootId:a}=Be(t,n);if(!a)return void r();i(o,[a],"add"),s({id:a,data:o[a],type:"edit"});break}case"empty-block-item":{b();const n=e.target.dataset.containerId,o=Number(e.target.dataset.cellIndex),c=Number(e.target.dataset.itemIndex);if(!n)return void r();let m={...t};if("add"===d){const e="column"===p.key?p:xe(p),t=g(e),{newBlockMap:l,rootId:d}=Be(m,t);if(!d)return void r();m=Le(l,n,o,c,d),i(m,a,"add"),s({id:d,data:m[d],type:"edit"})}else{const e=l.id;if(x(m,e,n))return r(),void f();const t=Te(m,a,e);if(!t)return void r();{const{result:e,removedId:a}=_(m,t);m=e?v(e,t.containerId,t.cellIndex,u):m,a&&(m=Le(m,n,o,c,a))}i(m,a,"move"),s({...l,data:m[e]??l.data,type:"edit"})}break}case"drag-over-column":{const n=Number(e.target.dataset.index);let o,c=[...a],u={...t};if("add"===d){const e=xe(p),t=g(e),{newBlockMap:a,rootId:i}=Be(u,t);if(!i)return void r();u=a,c.splice(n,0,i),o={id:i,data:u[i],type:"edit"}}else{const e=l.id,t=a.indexOf(e);if(-1===t)return void r();c.splice(t,1),c.splice(n>t?n-1:n,0,e),o={...l,type:"edit"}}i(u,c,"move"),s(o),setTimeout(()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}case"block-item-move":{const n=e.target.dataset.dropKey;if(!n)return void r();const[o,c,m]=n.split(":"),y=Number(c),h=Number(m);let b,k={...t};if("add"===d){const e="column"===p.key?p:xe(p),t=g(e),{newBlockMap:n,rootId:a}=Be(k,t);if(!a)return void r();k=Re(n,o,y,h,a),b={id:a,data:k[a],type:"edit"}}else{const e=l.id;if(x(k,e,o))return r(),void f();const t=Te(k,a,e);if(!t)return void r();const{blockMap:n,removedId:i}=Pe(k,t.containerId,t.cellIndex,t.itemIndex);k=n;const s=k[t.containerId];if(s&&0===s.cells[t.cellIndex].childrenIds.length){const e=we(u("drag_block_here"));k={...k,[e.id]:e,[t.containerId]:{...s,cells:s.cells.map((n,o)=>o===t.cellIndex?{...n,childrenIds:[e.id]}:n)}}}let c=h;t.containerId===o&&t.cellIndex===y&&t.itemIndex<h&&(c=h-1),k=Re(k,o,y,c,i),b={...l,type:"edit"}}i(k,a,"move"),s(b),setTimeout(()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}}r()}else r()},onDragLeave:e=>setTimeout(()=>{switch(e.target.dataset.type){case"empty-block":e.target.style.border="";break;case"empty-block-item":e.target.parentNode&&e.target.parentNode.classList.contains("block-empty-content")&&(e.target.parentNode.style.borderStyle="",e.target.parentNode.style.borderColor="")}},50),children:me("div",{className:"email-editor-main",onClick:e=>{e.preventDefault(),e.stopPropagation(),s(null)},children:[ue(Co,{clearStyles:f}),ue(ga,{clearStyles:f})]})})})},ha=e=>Array.isArray(e)?e.map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):e&&"object"==typeof e?Object.values(e).map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):[],ba=e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},i=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:i,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??""}}Array.isArray(e.children)&&n(e.children,i)})};return n(e,[]),t},fa=e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,children:i,...l}=e;return{...l,children:fa(i)}}):e,ka=d(({defaultBlockList:e,defaultBodySettings:t,aiContentRefs:n,language:l="en",customLanguageLibraries:s,templateData:c,variableDefinitions:d,apiConfig:m={},aiEnabled:g=!0},y)=>{r(()=>{var e;At=(e=d)&&"object"==typeof e?e:It,Mt()},[d]);const h=a(()=>Sn(m),[m]),b=e&&!Array.isArray(e)&&"object"==typeof e?e:null,f=b?b.blocks??b.blockList??[]:e,k=(_=f,Array.isArray(_)?_.map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):_&&"object"==typeof _?Object.values(_).map(e=>e&&"object"==typeof e?{...e,children:ha(e.children)}:e):[]);var _;const v=n??b?.aiContentRefs??{},x=t??b?.bodySettings??Ge.bodySettings,w=c??Ge.templateData,S=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??Mo[0]??null;if(!a)return e;const i=n.filter(e=>e?.id!==a.id),l=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(l):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===i.length?a:i[t%i.length]);return{...e,children:t,columnProducts:r}};return e.map(l)})(k,w),C=kn(S,v),{blockMap:N,rootOrder:T}=Se(C),I=he(N,w),[A,L]=p(Qe,{...Ge,blockMap:I,rootOrder:T,blockList:C,bodySettings:x,languageLibraries:s,templateData:w}),[P,R]=i([]),$=a(()=>new Set(P),[P]),B=o(e=>(Array.isArray(e)?e:[]).filter(e=>!$.has(Nn(e))),[$]),D=o(e=>{const t=Nn(e);t&&R(e=>e.includes(t)?e:[...e,t])},[]),E=o(()=>{const e=A.blockList??[];return{blockList:fa(e),bodySettings:A.bodySettings??null,aiContentRefs:ba(e)}},[A.blockList,A.bodySettings]),U=a(()=>B(On({blockList:A.blockList??[],bodySettings:A.bodySettings??null,aiContentRefs:ba(A.blockList??[])})).filter(e=>e?.blockId&&("warning"===e.severity||"error"===e.severity)).reduce((e,t)=>{const n=t.blockId,o=e[n]??{severity:t.severity,warningCount:0,errorCount:0,totalCount:0,messages:[],issues:[]};return"error"===t.severity&&(o.errorCount+=1),"warning"===t.severity&&(o.warningCount+=1),o.totalCount+=1,o.severity=o.errorCount>0?"error":"warning",o.messages.push(t.message),o.issues.push(t),e[n]=o,e},{}),[A.blockList,A.bodySettings,B]);u(y,()=>({blockList:fa(A.blockList??[]),bodySettings:A.bodySettings,aiContentRefs:ba(A.blockList??[]),actionType:A.actionType,exportJson:E,filterIgnoredValidationIssues:B,ignoreValidationIssue:D,focusBlock:e=>{if(!e||!A.blockMap?.[e])return!1;const t=A.blockMap[e],n="column"===t?.key?Ne(e,A.blockMap)??t:t;return L(qe({id:e,data:n,type:"edit"})),L(Je("edit")),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':\"!^$\[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),!0},exportHtml:()=>gn({bodySettings:A.bodySettings,blockList:A.blockList,templateData:A.templateData})}),[A.blockList,A.bodySettings,A.actionType,A.templateData,E,B,D]);const M=o(e=>{L((e=>({type:Ue,isDragStart:e}))(e))},[]),O=o((e,t)=>{t&&L(Je(t)),L((e=>({type:He,bodySettings:e}))(e))},[]),j=o((e,t,n)=>{n&&L(Je(n)),L(((e,t)=>({type:Ee,blockMap:e,rootOrder:t}))(e,t))},[]),H=o((e,t)=>{t&&L(Je(t)),L((e=>({type:De,blockList:e}))(e))},[]),K=o(e=>{L((e=>({type:Oe,previewMode:e}))(e))},[]),z=o(e=>{L(qe(e))},[]),F=o(e=>{L((e=>({type:Ke,selectionRange:e}))(e))},[]),V=o(e=>{L((e=>({type:ze,textRange:e}))(e))},[]),W=o(e=>{L(Je(e))},[]),J=o(e=>{L((e=>({type:Fe,language:e}))(e))},[]),q=o(e=>{L((e=>({type:Ve,languageLibraries:e}))(e))},[]),G=o(e=>{L((e=>({type:We,templateData:e}))(e))},[]),Y=a(()=>({blockMap:A.blockMap,rootOrder:A.rootOrder,blockList:A.blockList,actionType:A.actionType,previewMode:A.previewMode,currentItem:A.currentItem,bodySettings:A.bodySettings,isDragStart:A.isDragStart,selectionRange:A.selectionRange,textRange:A.textRange,language:A.language,languageLibraries:A.languageLibraries,templateData:A.templateData,apiConfig:h,validationMarkers:U,ignoreValidationIssue:D,aiEnabled:g,setIsDragStart:M,setBodySettings:O,setBlocks:j,setBlockList:H,setPreviewMode:K,setCurrentItem:z,setSelectionRange:F,setTextRange:V,setActionType:W,setLanguage:J,setLanguageLibraries:q,setTemplateData:G}),[A.blockMap,A.rootOrder,A.blockList,A.actionType,A.previewMode,A.currentItem,A.bodySettings,A.isDragStart,A.selectionRange,A.textRange,A.language,A.languageLibraries,A.templateData,h,U,D,g,M,O,j,H,K,z,F,V,W,J,q,G]);return ue(Ye.Provider,{value:Y,children:ue(ya,{language:l})})});const _a=/\{\{Product\w+\}\}/;function va(e,t,n,o,a){if("text"===e.key||"image"===e.key){const a="text"===e.key?e.text:"image"===e.key?e.src:null;if(a&&_a.test(a)){const i=t?t.id:null;if(!o.has(i)){const e={containerId:i,containerType:t?.containerType||t?.key||"none",nodes:[]};o.set(i,e),n.push(e)}o.get(i).nodes.push({id:e.id,key:e.key,value:a,contentType:e.key})}}if("dynamic"===e.contentType){const i=t?t.id:null;if(!o.has(i)){const e={containerId:i,containerType:t?.containerType||t?.key||"none",nodes:[]};o.set(i,e),n.push(e)}const l=a[e.id];o.get(i).nodes.push({id:e.id,key:e.key,value:"",contentType:"dynamic",ai:{prompt:l?.prompt??"",selectedSampleAiContent:l?.selectedContent??""}})}if(e.children)for(const t of e.children)va(t,e,n,o,a)}const xa={text:"text",image:"src"};function wa(e,t){if(0===t.size)return!0;if(e.id&&t.has(e.id)){const n=t.get(e.id),o=xa[e.key];o&&(e[o]=n,t.delete(e.id))}if(e.children)for(const n of e.children)if(wa(n,t))return!0;return 0===t.size}var Sa=Object.freeze({__proto__:null,jsonToHtml:function(e){return yn(e)},normalizeJson:function(e){const t="string"==typeof e?JSON.parse(e):e,n=[],o=new Map,a=t.aiContentRefs||{},i=t.blockList||[];for(const e of i)va(e,null,n,o,a);return{groups:n}},updateJsonWithMlContent:function(e,t){const n="string"==typeof e?JSON.parse(e):e,o=structuredClone(n),a=new Map;for(const e of t)e.variations.length>0&&a.set(e.nodeId,e.variations[0].value);const i=o.blockList||[];for(const e of i)if(wa(e,a))break;return o}});function Ca(e,t={}){const{validate:n=!0}=t,o=e?.current;if(!o||"function"!=typeof o.exportJson)throw new Error("exportTemplateJson: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const a=o.exportJson();if(!a||"object"!=typeof a)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:a,issues:n?On({blockList:a.blockList,bodySettings:a.bodySettings,aiContentRefs:a.aiContentRefs}):[]}}async function Na(e,t={}){const{validate:n=!0,checkImages:o=!0,imageProbe:a}=t,i=e?.current;if(!i||"function"!=typeof i.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const l=i.exportJson();if(!l||"object"!=typeof l)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");if(!n)return{payload:l,issues:[]};return{payload:l,issues:o?await Wn({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs},a):On({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs})}}const Ta=Object.freeze({keys:["content","catalogProducts","companyContext","brandContext","companyId"],description:"templateData drives placeholders, product columns, and menu/social sync. content.products + content.primaryProductId, when non-empty, override product column assignments on load. catalogProducts (optional array) is the KB/catalog list for the product picker and for newly added preset product blocks; it does not replace columnProducts in a saved template when content.products is empty. companyContext.navigation_links and companyContext.social_links sync into menu/social blocks; brandContext (including brand_color) resolves branding tokens and CTA/button fallback colors in HTML export."});function Ia(e={}){const t={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...e.content&&"object"==typeof e.content?e.content:{}},companyContext:{...t,...e.companyContext&&"object"==typeof e.companyContext?e.companyContext:{}},brandContext:{...n,..."string"==typeof e.brandColor&&e.brandColor.trim()?{brand_color:e.brandColor.trim()}:{},...e.brandContext&&"object"==typeof e.brandContext?e.brandContext:{}},companyId:null!=e.companyId?e.companyId:o}}function Aa(e){const t=[];if(null==e||"object"!=typeof e)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=e;if(null!=n.content&&"object"!=typeof n.content)t.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const e=n.content;null==e.products||Array.isArray(e.products)||t.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||t.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&t.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&t.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const e=n.brandContext;null!=e.brand_color&&"string"!=typeof e.brand_color&&t.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===t.length,warnings:t}}export{xn as DEFAULT_EMAIL_TEMPLATE_ID,_n as DEFAULT_MARKOPOLO_API_BASE_V1,vn as DEFAULT_ML_GENERATION_API_BASE_V1,ka as EmailEditor,Ta as TEMPLATE_DATA_SCHEMA,Ia as createDefaultTemplateData,ka as default,yn as exportNormalizerToHtml,Ca as exportTemplateJson,Na as exportTemplateJsonAsync,Sn as mergeMarkopoloApiConfig,Sa as utils,On as validateExportPayload,Wn as validateExportPayloadComplete,Vn as validateImageUrlsReachable,Aa as validateTemplateDataShape};
|