(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.plugins,n=window.wp.data,o=window.wp.hooks,r=window.wp.blocks,i=window.wp.element,a=window.ReactJSXRuntime,{InspectorControls:s,PanelColorSettings:l,MediaUpload:c,MediaUploadCheck:d}=wp.blockEditor,{__}=wp.i18n,{useState:u,useEffect:m,useRef:p}=wp.element,{PanelBody:f,PanelRow:g,ToggleControl:h,SelectControl:y,ComboboxControl:_,Spinner:I}=wp.components,b=_||wp.components.__experimentalComboboxControl,w=e=>{const{attributes:{productId:t,showDescription:n,showPrice:o,template:r,backgroundColor:i,contentColor:c,pricingColor:d},setAttributes:_}=e,[w,x]=u([]),[v,C]=u(t?t.toString():null),[S,N]=u(""),[j,M]=u(!1),[k,T]=u(!1),E=p(null),D=wp.apiFetch,{addQueryArgs:A}=wp.url;m(()=>{t&&(C(t.toString()),P(t))},[t]),m(()=>()=>{E.current&&clearTimeout(E.current)},[]);const L=e=>{M(!0),D({path:A("wc/store/products",{per_page:20,...e})}).then(e=>{x(e)}).catch(e=>{T(!0)}).finally(()=>{M(!1)})},P=e=>{e&&D({path:A("wc/store/products/"+e)}).then(e=>{N(e.name||"")}).catch(()=>{N(""),T(!0)})},B=e=>{if(!e)return;C(e);const t=w.find(t=>t.id.toString()===e);t&&N(t.name||""),_({productId:e})},R=w.map(e=>({value:e.id.toString(),label:e.name}));return v&&S&&!R.find(e=>e.value===v)&&R.unshift({value:v,label:S}),t?(0,a.jsxs)(s,{children:[(0,a.jsx)(f,{title:__("Template Settings"),initialOpen:!0,children:(0,a.jsx)(g,{children:(0,a.jsxs)("div",{className:"fluent-singleProduct-template-settings",children:[(0,a.jsxs)("div",{style:{marginBottom:"12px"},children:[b?(0,a.jsx)(b,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Select Product"),value:v,options:R,onChange:B,onFilterValueChange:e=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{L(e?{search:e}:{})},1200)},onFocus:()=>{w.length||L()},placeholder:__("Search product"),expandOnFocus:!0}):(0,a.jsx)(y,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Select Product"),value:v,options:R,onChange:B}),j&&(0,a.jsx)("div",{style:{marginTop:"8px"},children:(0,a.jsx)(I,{})})]}),(0,a.jsx)(y,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Design Template"),value:r,options:[{value:"left",name:"Image Left"},{value:"top",name:"Image Top"},{value:"none",name:"No Image"}].map(e=>({value:e.value,label:e.name})),onChange:e=>_({template:e})}),(0,a.jsx)(h,{__nextHasNoMarginBottom:!0,label:__("Show Description"),checked:n,onChange:()=>_({showDescription:!n})}),(0,a.jsx)(h,{__nextHasNoMarginBottom:!0,label:__("Show Price"),checked:o,onChange:()=>_({showPrice:!o})})]})})}),(0,a.jsx)("div",{className:"fluent-singleProduct-titleAndSubtitle-settings",children:(0,a.jsx)(l,{title:__("Customization"),colorSettings:[{value:c,onChange:e=>{_({contentColor:e})},label:__("Content Color")},{value:i,onChange:e=>{_({backgroundColor:e})},label:__("Background Color")},{value:d,onChange:e=>{_({pricingColor:e})},label:__("Pricing Color")}]})})]}):null},x=window.wp.i18n,v=window.wp.blockEditor;function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n2?n-2:0),r=2;r1?t-1:0),o=1;o1?n-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:G;if(j&&j(e,null),!U(t))return e;let o=t.length;for(;o--;){let r=t[o];if("string"==typeof r){const e=n(r);e!==r&&(M(t)||(t[o]=e),r=e)}e[r]=!0}return e}function ae(e){for(let t=0;t/g),xe=D(/\${[\w\W]*/g),ve=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ce=D(/^aria-[\-\w]+$/),Se=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ne=D(/^(?:\w+script|data):/i),je=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Me=D(/^html$/i),ke=D(/^[a-z][.\w]*(-[.\w]+)+$/i),Te=D(/<[/\w!]/g),Ee=D(/<[/\w]/g),De=D(/<\/no(script|embed|frames)/i),Ae=D(/\/>/i),Le=function(){return"undefined"==typeof window?null:window},Pe=function(e,t,n,o){return X(e,t)&&U(e[t])?ie(o.base?se(o.base):{},e[t],o.transform):n};var Be=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Le();const n=t=>e(t);if(n.version="3.4.11",n.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return n.isSupported=!1,n;let o=t.document;const r=o,i=r.currentScript;t.DocumentFragment;const a=t.HTMLTemplateElement,s=t.Node,l=t.Element,c=t.NodeFilter;void 0===t.NamedNodeMap&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const d=t.DOMParser,u=t.trustedTypes,m=l.prototype,p=le(m,"cloneNode"),f=le(m,"remove"),g=le(m,"nextSibling"),h=le(m,"childNodes"),y=le(m,"parentNode"),_=le(m,"shadowRoot"),I=le(m,"attributes"),b=s&&s.prototype?le(s.prototype,"nodeType"):null,w=s&&s.prototype?le(s.prototype,"nodeName"):null;if("function"==typeof a){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let x,v,C="",S=!1,j=0;const M=function(){if(j>0)throw ne('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},k=function(e){M(),j++;try{return x.createHTML(e)}finally{j--}},T=o,L=T.implementation,P=T.createNodeIterator,B=T.createDocumentFragment,oe=T.getElementsByTagName,re=r.importNode;let ae={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof N&&"function"==typeof y&&L&&void 0!==L.createHTMLDocument;const Be=be,Re=we,ze=xe,He=ve,Oe=Ce,Fe=Ne,Ue=je,Ge=ke;let Ze=Se,Ve=null;const We=ie({},[...ce,...de,...ue,...pe,...ge]);let Qe=null;const Ye=ie({},[...he,...ye,..._e,...Ie]);let Je=Object.seal(A(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$e=null,qe=null;const Ke=Object.seal(A(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Xe=!0,et=!0,tt=!1,nt=!0,ot=!1,rt=!0,it=!1,at=!1,st=null,lt=null,ct=!1,dt=!1,ut=!1,mt=!1,pt=!0,ft=!1;const gt="user-content-";let ht=!0,yt=!1,_t={},It=null;const bt=ie({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let wt=null;const xt=ie({},["audio","video","img","source","image","track"]);let vt=null;const Ct=ie({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),St="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",jt="http://www.w3.org/1999/xhtml";let Mt=jt,kt=!1,Tt=null;const Et=ie({},[St,Nt,jt],Z),Dt=E(["mi","mo","mn","ms","mtext"]);let At=ie({},Dt);const Lt=E(["annotation-xml"]);let Pt=ie({},Lt);const Bt=ie({},["title","style","font","a","script"]);let Rt=null;const zt=["application/xhtml+xml","text/html"];let Ht=null,Ot=null;const Ft=o.createElement("form"),Ut=function(e){return e instanceof RegExp||e instanceof Function},Gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Ot&&Ot===e)return;e&&"object"==typeof e||(e={}),e=se(e),Rt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ht="application/xhtml+xml"===Rt?Z:G,Ve=Pe(e,"ALLOWED_TAGS",We,{transform:Ht}),Qe=Pe(e,"ALLOWED_ATTR",Ye,{transform:Ht}),Tt=Pe(e,"ALLOWED_NAMESPACES",Et,{transform:Z}),vt=Pe(e,"ADD_URI_SAFE_ATTR",Ct,{transform:Ht,base:Ct}),wt=Pe(e,"ADD_DATA_URI_TAGS",xt,{transform:Ht,base:xt}),It=Pe(e,"FORBID_CONTENTS",bt,{transform:Ht}),$e=Pe(e,"FORBID_TAGS",se({}),{transform:Ht}),qe=Pe(e,"FORBID_ATTR",se({}),{transform:Ht}),_t=!!X(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?se(e.USE_PROFILES):e.USE_PROFILES),Xe=!1!==e.ALLOW_ARIA_ATTR,et=!1!==e.ALLOW_DATA_ATTR,tt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,nt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ot=e.SAFE_FOR_TEMPLATES||!1,rt=!1!==e.SAFE_FOR_XML,it=e.WHOLE_DOCUMENT||!1,dt=e.RETURN_DOM||!1,ut=e.RETURN_DOM_FRAGMENT||!1,mt=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,pt=!1!==e.SANITIZE_DOM,ft=e.SANITIZE_NAMED_PROPS||!1,ht=!1!==e.KEEP_CONTENT,yt=e.IN_PLACE||!1,Ze=function(e){try{return te(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Se,Mt="string"==typeof e.NAMESPACE?e.NAMESPACE:jt,At=X(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?se(e.MATHML_TEXT_INTEGRATION_POINTS):ie({},Dt),Pt=X(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?se(e.HTML_INTEGRATION_POINTS):ie({},Lt);const t=X(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?se(e.CUSTOM_ELEMENT_HANDLING):A(null);if(Je=A(null),X(t,"tagNameCheck")&&Ut(t.tagNameCheck)&&(Je.tagNameCheck=t.tagNameCheck),X(t,"attributeNameCheck")&&Ut(t.attributeNameCheck)&&(Je.attributeNameCheck=t.attributeNameCheck),X(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Je.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),D(Je),ot&&(et=!1),ut&&(dt=!0),_t&&(Ve=ie({},ge),Qe=A(null),!0===_t.html&&(ie(Ve,ce),ie(Qe,he)),!0===_t.svg&&(ie(Ve,de),ie(Qe,ye),ie(Qe,Ie)),!0===_t.svgFilters&&(ie(Ve,ue),ie(Qe,ye),ie(Qe,Ie)),!0===_t.mathMl&&(ie(Ve,pe),ie(Qe,_e),ie(Qe,Ie))),Ke.tagCheck=null,Ke.attributeCheck=null,X(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Ke.tagCheck=e.ADD_TAGS:U(e.ADD_TAGS)&&(Ve===We&&(Ve=se(Ve)),ie(Ve,e.ADD_TAGS,Ht))),X(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Ke.attributeCheck=e.ADD_ATTR:U(e.ADD_ATTR)&&(Qe===Ye&&(Qe=se(Qe)),ie(Qe,e.ADD_ATTR,Ht))),X(e,"ADD_URI_SAFE_ATTR")&&U(e.ADD_URI_SAFE_ATTR)&&ie(vt,e.ADD_URI_SAFE_ATTR,Ht),X(e,"FORBID_CONTENTS")&&U(e.FORBID_CONTENTS)&&(It===bt&&(It=se(It)),ie(It,e.FORBID_CONTENTS,Ht)),X(e,"ADD_FORBID_CONTENTS")&&U(e.ADD_FORBID_CONTENTS)&&(It===bt&&(It=se(It)),ie(It,e.ADD_FORBID_CONTENTS,Ht)),ht&&(Ve["#text"]=!0),it&&ie(Ve,["html","head","body"]),Ve.table&&(ie(Ve,["tbody"]),delete $e.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ne('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ne('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=x;x=e.TRUSTED_TYPES_POLICY;try{C=k("")}catch(e){throw x=t,e}}else null===e.TRUSTED_TYPES_POLICY?(x=void 0,C=""):(void 0===x&&(S||(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(u,i),S=!0),x=v),x&&"string"==typeof C&&(C=k("")));E&&E(e),Ot=e},Zt=ie({},[...de,...ue,...me]),Vt=ie({},[...pe,...fe]),Wt=function(e){O(n.removed,{element:e});try{y(e).removeChild(e)}catch(t){if(f(e),!y(e))throw ne("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Qt=function(e){const t=h(e);if(t){const e=[];R(t,t=>{O(e,t)}),R(e,e=>{try{f(e)}catch(e){}})}const n=I(e);if(n)for(let t=n.length-1;t>=0;--t){const o=n[t],r=o&&o.name;if("string"==typeof r)try{e.removeAttribute(r)}catch(e){}}},Yt=function(e,t){try{O(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){O(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(dt||ut)try{Wt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Jt=function(e){const t=I(e);if(t)for(let n=t.length-1;n>=0;--n){const o=t[n],r=o&&o.name;if("string"==typeof r&&!Qe[Ht(r)])try{e.removeAttribute(r)}catch(e){}}},$t=function(e){let t=null,n=null;if(ct)e=""+e;else{const t=V(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Rt&&Mt===jt&&(e=''+e+"");const r=x?k(e):e;if(Mt===jt)try{t=(new d).parseFromString(r,Rt)}catch(e){}if(!t||!t.documentElement){t=L.createDocument(Mt,"template",null);try{t.documentElement.innerHTML=kt?C:r}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(o.createTextNode(n),i.childNodes[0]||null),Mt===jt?oe.call(t,it?"html":"body")[0]:it?t.documentElement:i},qt=function(e){return P.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(e){return e=W(e,Be," "),e=W(e,Re," "),W(e,ze," ")},Xt=function(e){var t;e.normalize();const n=P.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let o=n.nextNode();for(;o;)o.data=Kt(o.data),o=n.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&R(r,e=>{tn(e.content)&&Xt(e.content)})},en=function(e){const t=w?w(e):null;return"string"==typeof t&&"form"===Ht(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==I(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==b(e)||e.childNodes!==h(e))},tn=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return 11===b(e)}catch(e){return!1}},nn=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return"number"==typeof b(e)}catch(e){return!1}};function on(e,t,o){0!==e.length&&R(e,e=>{e.call(n,t,o,Ot)})}const rn=function(e){if(on(ae.beforeSanitizeElements,e,null),en(e))return Wt(e),!0;const t=Ht(w?w(e):e.nodeName);if(on(ae.uponSanitizeElement,e,{tagName:t,allowedTags:Ve}),function(e,t){return!!(rt&&e.hasChildNodes()&&!nn(e.firstElementChild)&&te(Te,e.textContent)&&te(Te,e.innerHTML))||!(!rt||e.namespaceURI!==jt||"style"!==t||!nn(e.firstElementChild))||7===e.nodeType||!(!rt||8!==e.nodeType||!te(Ee,e.data))}(e,t))return Wt(e),!0;if($e[t]||!(Ke.tagCheck instanceof Function&&Ke.tagCheck(t))&&!Ve[t])return function(e,t){if(!$e[t]&&ln(t)){if(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,t))return!1;if(Je.tagNameCheck instanceof Function&&Je.tagNameCheck(t))return!1}if(ht&&!It[t]){const t=y(e),n=h(e);if(n&&t)for(let o=n.length-1;o>=0;--o){const r=yt?n[o]:p(n[o],!0);t.insertBefore(r,g(e))}}return Wt(e),!0}(e,t);if(1===(b?b(e):e.nodeType)&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:Mt,tagName:"template"});const n=G(e.tagName),o=G(t.tagName);return!!Tt[e.namespaceURI]&&(e.namespaceURI===Nt?function(e,t,n){return t.namespaceURI===jt?"svg"===e:t.namespaceURI===St?"svg"===e&&("annotation-xml"===n||At[n]):Boolean(Zt[e])}(n,t,o):e.namespaceURI===St?function(e,t,n){return t.namespaceURI===jt?"math"===e:t.namespaceURI===Nt?"math"===e&&Pt[n]:Boolean(Vt[e])}(n,t,o):e.namespaceURI===jt?function(e,t,n){return!(t.namespaceURI===Nt&&!Pt[n])&&!(t.namespaceURI===St&&!At[n])&&!Vt[e]&&(Bt[e]||!Zt[e])}(n,t,o):!("application/xhtml+xml"!==Rt||!Tt[e.namespaceURI]))}(e))return Wt(e),!0;if(("noscript"===t||"noembed"===t||"noframes"===t)&&te(De,e.innerHTML))return Wt(e),!0;if(ot&&3===e.nodeType){const t=Kt(e.textContent);e.textContent!==t&&(O(n.removed,{element:e.cloneNode()}),e.textContent=t)}return on(ae.afterSanitizeElements,e,null),!1},an=function(e,t,n){if(qe[t])return!1;if(pt&&("id"===t||"name"===t)&&(n in o||n in Ft))return!1;const r=Qe[t]||Ke.attributeCheck instanceof Function&&Ke.attributeCheck(t,e);if(et&&te(He,t));else if(Xe&&te(Oe,t));else if(r){if(vt[t]);else if(te(Ze,W(n,Ue,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Q(n,"data:")||!wt[e])if(tt&&!te(Fe,W(n,Ue,"")));else if(n)return!1}else if(!(ln(e)&&(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,e)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(e))&&(Je.attributeNameCheck instanceof RegExp&&te(Je.attributeNameCheck,t)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(t,e))||"is"===t&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,n)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(n))))return!1;return!0},sn=ie({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(e){return!sn[G(e)]&&te(Ge,e)},cn=function(e,t,n,o){if(x&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!n)switch(u.getAttributeType(e,t)){case"TrustedHTML":return k(o);case"TrustedScriptURL":return function(e){M(),j++;try{return x.createScriptURL(e)}finally{j--}}(o)}return o},dn=function(e,t,o,r){try{o?e.setAttributeNS(o,t,r):e.setAttribute(t,r),en(e)?Wt(e):H(n.removed)}catch(n){Yt(t,e)}},un=function(e){on(ae.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||en(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Qe,forceKeepAttr:void 0};let o=t.length;const r=Ht(e.nodeName);for(;o--;){const i=t[o],a=i.name,s=i.namespaceURI,l=i.value,c=Ht(a),d=l;let u="value"===a?d:Y(d);n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,on(ae.uponSanitizeAttribute,e,n),u=n.attrValue,!ft||"id"!==c&&"name"!==c||0===Q(u,gt)||(Yt(a,e),u=gt+u),rt&&te(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)||"attributename"===c&&V(u,"href")?Yt(a,e):n.forceKeepAttr||(!n.keepAttr||!nt&&te(Ae,u)?Yt(a,e):(ot&&(u=Kt(u)),an(r,c,u)?(u=cn(r,c,s,u),u!==d&&dn(e,a,s,u)):Yt(a,e)))}on(ae.afterSanitizeAttributes,e,null)},mn=function(e){let t=null;const n=qt(e);for(on(ae.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(on(ae.uponSanitizeShadowNode,t,null),rn(t),un(t),tn(t.content)&&mn(t.content),1===(b?b(t):t.nodeType)){const e=_(t);tn(e)&&(pn(e),mn(e))}on(ae.afterSanitizeShadowDOM,e,null)},pn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){mn(e.shadow);continue}const n=e.node,o=1===(b?b(n):n.nodeType),r=h(n);if(r)for(let e=r.length-1;e>=0;--e)t.push({node:r[e],shadow:null});if(o){const e=w?w(n):null;if("string"==typeof e&&"template"===Ht(e)){const e=n.content;tn(e)&&t.push({node:e,shadow:null})}}if(o){const e=_(n);tn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,s=null;if(kt=!e,kt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!nn(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return J(e);case"boolean":return $(e);case"bigint":return q?q(e):"0";case"symbol":return K?K(e):"Symbol()";case"undefined":default:return ee(e);case"function":case"object":{if(null===e)return ee(e);const t=e,n=le(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:ee(e)}return ee(e)}}}(e)))throw ne("dirty is not a string, aborting");if(!n.isSupported)return e;at?(Ve=st,Qe=lt):Gt(t),(ae.uponSanitizeElement.length>0||ae.uponSanitizeAttribute.length>0)&&(Ve=se(Ve)),ae.uponSanitizeAttribute.length>0&&(Qe=se(Qe)),n.removed=[];const l=yt&&"string"!=typeof e&&nn(e);if(l){const t=w?w(e):e.nodeName;if("string"==typeof t){const e=Ht(t);if(!Ve[e]||$e[e])throw ne("root node is forbidden and cannot be sanitized in-place")}if(en(e))throw ne("root node is clobbered and cannot be sanitized in-place");try{pn(e)}catch(t){throw Qt(e),t}}else if(nn(e))o=$t("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i),pn(i);else{if(!dt&&!ot&&!it&&-1===e.indexOf("<"))return x&&mt?k(e):e;if(o=$t(e),!o)return dt?null:mt?C:""}o&&ct&&Wt(o.firstChild);const c=qt(l?e:o);try{for(;a=c.nextNode();)rn(a),un(a),tn(a.content)&&mn(a.content)}catch(t){throw l&&Qt(e),t}if(l)return R(n.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(b?b(e):e.nodeType)&&Jt(e);const n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e.element)}),ot&&Xt(e),e;if(dt){if(ot&&Xt(o),ut)for(s=B.call(o.ownerDocument);o.firstChild;)s.appendChild(o.firstChild);else s=o;return(Qe.shadowroot||Qe.shadowrootmode)&&(s=re.call(r,s,!0)),s}let d=it?o.outerHTML:o.innerHTML;return it&&Ve["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&te(Me,o.ownerDocument.doctype.name)&&(d="\n"+d),ot&&(d=Kt(d)),x&&mt?k(d):d},n.setConfig=function(){Gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),at=!0,st=Ve,lt=Qe},n.clearConfig=function(){Ot=null,at=!1,st=null,lt=null,x=v,C=""},n.isValidAttribute=function(e,t,n){Ot||Gt({});const o=Ht(e),r=Ht(t);return an(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&X(ae,e)&&O(ae[e],t)},n.removeHook=function(e,t){if(X(ae,e)){if(void 0!==t){const n=z(ae[e],t);return-1===n?void 0:F(ae[e],n,1)[0]}return H(ae[e])}},n.removeHooks=function(e){X(ae,e)&&(ae[e]=[])},n.removeAllHooks=function(){ae={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const Re={ALLOWED_TAGS:["span","bdi","bdo","del","ins","small","strong","em","sup","sub"],ALLOWED_ATTR:["class","dir"],ALLOW_DATA_ATTR:!1},ze=(e,t="Free")=>{const n=Be.sanitize(e?String(e):t,Re);if("undefined"!=typeof document){const e=document.createElement("div");return e.innerHTML=n,e.querySelectorAll(".screen-reader-text").forEach(e=>e.remove()),e.querySelectorAll("del[aria-hidden], ins[aria-hidden]").forEach(e=>e.removeAttribute("aria-hidden")),e.innerHTML}return n.replace(/]*\bclass=(["'])[^"']*\bscreen-reader-text\b[^"']*\1)[^>]*>[\s\S]*?<\/span>/gi,"").replace(/<(del|ins)\b([^>]*)>/gi,(e,t,n)=>`<${t}${n.replace(/\saria-hidden=(["']).*?\1|\saria-hidden=[^\s>]*/gi,"")}>`)},{RadioControl:He,Spinner:Oe}=wp.components,{useState:Fe,useEffect:Ue}=wp.element,{__:Ge}=wp.i18n,Ze=e=>{const{attributes:{productId:t,showDescription:n,showPrice:o,buttonText:r,customImage:i,template:s,backgroundColor:l,contentColor:c,pricingColor:d},setAttributes:u}=e,{InnerBlocks:m}=wp.blockEditor,[p,f]=Fe([]),[g,h]=Fe(""),[y,_]=Fe(""),[I,b]=Fe({}),[w,x]=Fe(!1),[v,C]=Fe(!1),[S,N]=Fe(!1);Ue(()=>{t?T(t):k()},[t]);const j=wp.apiFetch,{addQueryArgs:M}=wp.url,k=e=>{C(!0),j({path:M("wc/store/products",{per_page:6,...e})}).then(e=>{f(e)}).catch(e=>{N(!0)}).finally(()=>{C(!1)})},T=e=>{x(!0),j({path:M("wc/store/products/"+e)}).then(e=>{b(e),u({productId:e.id}),x(!1)}).catch(e=>{N(!0)})},E={backgroundColor:l,color:c},D=["fcw_p","fcw_template_"+s,w?"fc_product_loading":""].filter(Boolean).join(" "),A=["fcw_search_box",w?"fc_product_loading":""].filter(Boolean).join(" ");return(0,a.jsxs)("div",{children:[w&&(0,a.jsxs)("div",{style:E,className:"fc_woo_loader",children:[(0,a.jsx)(Oe,{}),(0,a.jsx)("h3",{children:"Loading product"})]}),I.id&&t?(0,a.jsxs)("div",{style:E,className:D,children:["none"!=s&&(0,a.jsx)("div",{className:"fcw_image",children:(0,a.jsx)("img",{src:i||I&&I.images&&I.images.length&&I.images[0].src||""})}),(0,a.jsxs)("div",{className:"fcw_p_content",children:[(0,a.jsx)("h2",{style:{color:c},className:"fcw_p_title",dangerouslySetInnerHTML:{__html:I.name}}),n&&(0,a.jsx)("div",{style:{color:c},className:"fcw_p_desc",dangerouslySetInnerHTML:{__html:I.short_description}}),o&&(0,a.jsx)("div",{style:{color:d},className:"fcw_p_price",dangerouslySetInnerHTML:{__html:ze(I.price_html,Ge("Free"))}}),(0,a.jsx)("div",{className:"fcb_p_button",children:(0,a.jsx)(m,{template:[["core/buttons",{},[["core/button",{text:r,url:I.permalink,align:"left"}]]]],templateLock:"all"})})]})]}):(0,a.jsxs)("div",{className:A,children:[(0,a.jsx)("h4",{children:"Search and Select a Product"}),(0,a.jsx)("hr",{}),(0,a.jsxs)("div",{style:{marginBottom:"25px",display:"flex"},className:"fluent-single-product-search-bar",children:[(0,a.jsx)("div",{style:{width:"80%"},children:(0,a.jsx)("input",{placeholder:"product",style:{width:"100%",height:"30px"},value:g,onChange:e=>{h(e.target.value)},onKeyDown:e=>{"Enter"!==e.key&&""!==e.target.value||k({search:g})}})}),(0,a.jsx)("button",{style:{width:"20%",height:"30px"},onClick:()=>{k({search:g})},children:"Search"})]}),v?(0,a.jsx)("h2",{children:(0,a.jsx)(Oe,{})}):(0,a.jsx)("div",{className:"fcw_results",children:p&&p.length?(0,a.jsx)(He,{selected:y,options:p.map(e=>({value:e.id.toString(),label:e.name})),onChange:e=>{_(e)}}):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No products found!"})})}),(0,a.jsx)("div",{style:{marginTop:"20px"},className:"components-button is-primary",onClick:()=>{T(y)},children:"Done"})]})]})},{Fragment:Ve}=wp.element,We=e=>{const t=(0,v.useBlockProps)({className:"fluent-single-product-block"});return(0,a.jsxs)(Ve,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(Ze,{attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(w,{attributes:e.attributes,setAttributes:e.setAttributes})]})},Qe=()=>{const e=v.useBlockProps.save();return(0,a.jsx)("div",{...e,children:(0,a.jsx)(v.InnerBlocks.Content,{})})},{__:Ye}=wp.i18n,Je={productId:{type:"number",default:null},showDescription:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},buttonText:{type:"string",default:Ye("Buy Now")},customImage:{type:"string",default:""},backgroundColor:{type:"string",default:"#fffeeb"},contentColor:{type:"string",default:""},pricingColor:{type:"string",default:""},template:{type:"string",default:"left"}},$e=wp.element.createElement,{__:qe}=wp.i18n,{registerBlockType:Ke}=wp.blocks,Xe=window.fcrmBlockEditorConfig?.modules||{},et=[{attributes:Je,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],tt=$e("svg",{width:20,height:20,viewBox:"0 0 24 24"},$e("path",{fill:"#7F54B3",d:"M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8.2L7 20v-4H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"}),$e("text",{x:12,y:12.8,textAnchor:"middle",fontSize:6.5,fontFamily:"Arial, sans-serif",fontWeight:700,fill:"#fff"},"woo"));if(!1!==Xe.hasWooCommerce){const e={apiVersion:3,title:qe("Woo Product (Single)"),description:qe("Product Block For your Email"),category:"layout",icon:tt,keywords:[qe("product"),qe("woocommerce"),qe("card")],supports:{align:["wide","full"],html:!0},attributes:Je,deprecated:et,edit:We,save:Qe};Ke("fluentcrm/woo-product",e),Ke("fluent-crm/woo-product",{...e,supports:{...e.supports,inserter:!1}})}window.React;const nt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAzIiBoZWlnaHQ9IjM1NCIgdmlld0JveD0iMCAwIDQwMyAzNTQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MDEiIGhlaWdodD0iMzUyIiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iNDQiIHk9IjIyNSIgd2lkdGg9IjMxNCIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI1NyIgd2lkdGg9IjM0OSIgaGVpZ2h0PSIxMCIgcng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yB3aWR0aD0iNDAzIiBoZWlnaHQ9IjM3MSIgdmlld0JveD0iMCAwIDQwMyAzNzEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MDEiIGhlaWdodD0iMzY5IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iMjciIHk9IjIyNSIgd2lkdGg9IjMxNCIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI1NyIgd2lkdGg9IjM0OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI4MCIgd2lkdGg9IjI1OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHBhdGggZD0iTTEgMTBDMSA0LjQ3NzE2IDUuNDc3MTUgMCAxMSAwSDM5MkMzOTcuNTIzIDAgNDAyIDQuNDc3MTUgNDAyIDEwVjIwMEgxVjEwWiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyOCIgeT0iMzEyIiB3aWR0aD0iODAiIGhlaWdodD0iMzEiIHJ4PSI0IiBzdHJva2U9IiNFREVFRjQiIHN0cm9rZS13aWR0aD0iMiIvPgo8cmVjdCB4PSI0NCIgeT0iMzI0IiB3aWR0aD0iNDgiIGhlaWdodD0iNyIgcng9IjMuNSIgZmlsbD0iI0VERUVGNCIvPgo8L3N2Zz4K",{InspectorControls:ct,PanelColorSettings:dt}=wp.blockEditor,{__:ut}=wp.i18n,{PanelBody:mt,PanelRow:pt,SelectControl:ft,ToggleControl:gt,TextControl:ht,Dropdown:yt,Button:_t,FormTokenField:It}=wp.components,{useState:bt,useEffect:wt}=wp.element,xt=e=>{const{attributes:{selectedPostType:t,postTypes:n,selectedPostsPerPage:o,selectedLayout:r,contentColor:i,titleColor:s,backgroundColor:l,authorColor:c,commentColor:d,buttonColor:u,showImage:m,showMeta:p,showMetaAuthor:f,showMetaAuthorImg:g,showMetaComments:h,showButton:y,buttonText:_,showDescription:I,orderBy:b,order:w,taxTypes:x,catType:v,recentPostDays:C,selectedExcerptLength:S,backgroundType:N,selectedOperatorType:j,postsGap:M},setAttributes:k}=e,[T,E]=bt([]);wt(()=>{L()},[]);const D=wp.apiFetch,{addQueryArgs:A}=wp.url,L=e=>{D({path:A("fluent-crm/v2/campaigns-pro/posts/taxonomies",{...e})}).then(e=>{E(e.taxonomies)}).catch(()=>{}).finally(()=>{})},P=e=>{const t=T[e]?.terms;if(!t)return"";const n=Object.keys(t);return n.length?n[0]:""};wt(()=>{const e=P(t);e&&v!==e&&k({catType:e})},[t,T]);const B=[{value:s,onChange:e=>{k({titleColor:e})},label:ut("Title Color","fluent-crm")}];"layout-5"!==r&&B.push({value:l,onChange:e=>{k({backgroundColor:e})},label:ut("Box Background Color","fluent-crm")}),"default"!==r&&"layout-5"!==r&&"layout-7"!==r&&!0===p&&(!0===f&&B.push({value:c,onChange:e=>{k({authorColor:e})},label:ut("Author Color","fluent-crm")}),!0===h&&B.push({value:d,onChange:e=>{k({commentColor:e})},label:ut("Meta Comment Color","fluent-crm")})),"layout-6"!==r&&"layout-5"!==r&&B.push({value:i,onChange:e=>{k({contentColor:e})},label:ut("Content Color","fluent-crm")}),"layout-6"!==r&&"layout-4"!==r&&"layout-5"!==r&&B.push({value:u,onChange:e=>{k({buttonColor:e})},label:ut("Button Color","fluent-crm")});const R=[{value:"all",label:"All"}];T[t]?.terms&&T[t]?.terms[v]&&T[t]?.terms[v].map(e=>R.push(e));const z=e=>{if(!x||x.length<1)return[];const[t]=x;return t.hasOwnProperty(e)?t[e]:[]};let H=nt;"layout-2"===r?H=ot:"layout-3"===r?H=rt:"layout-4"===r?H=it:"layout-5"===r?H=at:"layout-6"===r?H=st:"layout-7"===r&&(H=lt);const O=[{value:"default",label:ut("Default","fluent-crm"),image:nt},{value:"layout-2",label:ut("Layout 2","fluent-crm"),image:ot},{value:"layout-3",label:ut("Layout 3","fluent-crm"),image:rt},{value:"layout-4",label:ut("Layout 4","fluent-crm"),image:it},{value:"layout-5",label:ut("Layout 5","fluent-crm"),image:at},{value:"layout-6",label:ut("Layout 6","fluent-crm"),image:st},{value:"layout-7",label:ut("Layout 7","fluent-crm"),image:lt}];return(0,a.jsxs)(ct,{children:[(0,a.jsx)(mt,{title:ut("General Settings","fluent-crm"),initialOpen:!0,children:(0,a.jsx)(pt,{children:(0,a.jsxs)("div",{className:"fluent-latest-posts-settings",children:[n&&n.length?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Select Post Type","fluent-crm"),value:t,options:n.map(e=>({value:e.value,label:e.label})),onChange:e=>{const t={selectedPostType:e},n=P(e);n&&(t.catType=n),t.taxTypes=[],k(t)}}):null,T[t]?.terms?(0,a.jsx)("div",{children:Object.entries(T[t]?.terms).map(([e,t],n)=>{return(0,a.jsx)(It,{value:z(e),suggestions:t?.map(e=>e.label),label:(o=e,ut("Taxonomy","fluent-crm")+" "+o.replaceAll("_"," ")),onChange:t=>((e,t)=>{const n=[...x];n.length<1&&n.push({}),n[0][e]=t,k({taxTypes:[...n]})})(e,t)},e+n);var o})}):null,T[t]?.terms?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,className:"fc-operator-type",label:ut("Select Operator Type","fluent-crm"),value:j,options:[{label:"AND",value:"AND"},{label:"OR",value:"OR"}],help:ut("Select the operator type for the taxonomy filter","fluent-crm"),onChange:e=>{k({selectedOperatorType:e})}}):"",(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Order by","fluent-crm"),options:[{label:ut("Newest to Oldest","fluent-crm"),value:"date/desc"},{label:ut("Oldest to Newest","fluent-crm"),value:"date/asc"},{label:ut("A → Z","fluent-crm"),value:"title/asc"},{label:ut("Z → A","fluent-crm"),value:"title/desc"}],value:`${b}/${w}`,onChange:e=>{const[t,n]=e.split("/");n!==w&&k({order:n}),t!==b&&k({orderBy:t})}}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fc-recent-posts-number",value:C,label:ut("Posts from last (days)","fluent-crm"),help:ut("e.g get posts in the last (7) days","fluent-crm"),onChange:e=>k({recentPostDays:e})}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fce-dimension-box",value:o,label:ut("Show Posts","fluent-crm"),help:ut("e.g how many posts you want to show","fluent-crm"),onChange:e=>k({selectedPostsPerPage:e})}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",min:0,max:500,className:"fce-dimension-box",value:M,label:ut("Posts Gap (px)","fluent-crm"),help:ut("Space between each post item","fluent-crm"),onChange:e=>k({postsGap:Math.min(500,Math.max(0,parseInt(e,10)||0))})}),(0,a.jsxs)("div",{className:"show-setting-control-box select-layout",children:[(0,a.jsx)("p",{children:ut("Select Layout","fluent-crm")}),(0,a.jsx)(yt,{className:"show-setting-dropdown",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("img",{onClick:t,"aria-expanded":e,src:H,alt:""}),(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})})]}),renderContent:({onToggle:e})=>(0,a.jsxs)("div",{className:"dropdown-render-content dropdown-render-selected-layout fc-layout-picker",children:[(0,a.jsx)("p",{children:ut("Select Layout","fluent-crm")}),(0,a.jsx)("div",{className:"fc-layout-picker-grid",role:"radiogroup","aria-label":ut("Layout","fluent-crm"),children:O.map(t=>(0,a.jsxs)("button",{type:"button",className:"fc-layout-picker-option "+(r===t.value?"is-active":""),role:"radio","aria-checked":r===t.value,onClick:()=>{k({selectedLayout:t.value}),e()},children:[(0,a.jsx)("img",{src:t.image,alt:t.label}),(0,a.jsx)("span",{children:t.label})]},t.value))})]})})]}),"layout-5"!==r?(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Image","fluent-crm"),checked:m,onChange:()=>k({showImage:!m})}):null,"layout-5"!==r&&"layout-6"!==r?(0,a.jsxs)("div",{className:"show-setting-control-box",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Excerpt","fluent-crm"),checked:I,onChange:()=>k({showDescription:!I})}),!0===I?(0,a.jsx)(yt,{className:"show-setting-dropdown",contentClassName:"my-popover-content-classname",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})}),renderContent:()=>(0,a.jsx)("div",{className:"dropdown-render-content",children:(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",max:100,className:"fce-dimension-box",value:S,label:ut("Excerpt Length","fluent-crm"),onChange:e=>k({selectedExcerptLength:e})})})}):null]}):null,"default"!==r&&"layout-5"!==r&&"layout-7"!==r?(0,a.jsxs)("div",{className:"show-setting-control-box",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Meta","fluent-crm"),checked:p,onChange:()=>k({showMeta:!p})}),!0===p?(0,a.jsx)(yt,{className:"show-setting-dropdown",contentClassName:"my-popover-content-classname",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})}),renderContent:()=>(0,a.jsxs)("div",{className:"dropdown-render-content setting-dropdown-meta",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Comments","fluent-crm"),checked:h,onChange:()=>k({showMetaComments:!h})}),(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Author","fluent-crm"),checked:f,onChange:()=>k({showMetaAuthor:!f})}),!0===f&&"layout-6"!==r?(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Author Avatar","fluent-crm"),checked:g,onChange:()=>k({showMetaAuthorImg:!g})}):null]})}):null]}):null,"layout-4"!==r&&"layout-5"!==r&&"layout-6"!==r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Button","fluent-crm"),checked:y,onChange:()=>k({showButton:!y})}),!0===y?(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"text",value:_,label:ut("Button Text","fluent-crm"),onChange:e=>k({buttonText:e})}):null]}):null,"layout-5"!==r?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Post Image Type","fluent-crm"),options:[{label:ut("Cover","fluent-crm"),value:"cover"},{label:ut("Contain","fluent-crm"),value:"contain"},{label:ut("None","fluent-crm"),value:"inherit"}],value:N,onChange:e=>k({backgroundType:e})}):null]})})}),(0,a.jsx)("div",{className:"fluent-latest-posts-content-color-settings",children:(0,a.jsx)(dt,{title:ut("Customization","fluent-crm"),colorSettings:B})})]})},{Spinner:vt}=wp.components,{useState:Ct,useEffect:St}=wp.element,{__:Nt,_n}=wp.i18n,jt=e=>{const{attributes:{selectedPostType:t,selectedPostsPerPage:n,selectedLayout:o,contentColor:r,titleColor:i,backgroundColor:s,authorColor:l,commentColor:c,buttonColor:d,showImage:u,showMeta:m,showMetaAuthor:p,showMetaAuthorImg:f,showMetaComments:g,showButton:h,showDescription:y,selectedExcerptLength:_,orderBy:I,order:b,taxTypes:w,catType:x,recentPostDays:v,buttonText:C,backgroundType:S,selectedOperatorType:N,postsGap:j},setAttributes:M}=e,[k,T]=Ct([]),[E,D]=Ct(!1),[A,L]=Ct(!1);St(()=>{R()},[t,n,I,b,w,x,v,N]);const P=wp.apiFetch,{addQueryArgs:B}=wp.url,R=e=>{D(!0),P({path:B("fluent-crm/v2/campaigns-pro/posts",{per_page:n,post_type:t,orderBy:I,order:b,taxTypes:w,catType:x,days:v,excerptLength:_,operator:N,...e})}).then(e=>{T(e.posts),M({postTypes:e.post_types})}).catch(e=>{L(!0)}).finally(()=>{D(!1)})},z={color:r},H={color:i},O={background:s,marginBottom:(j??20)+"px"},F={color:l},U={color:c};let G="";G="layout-7"===o?{color:d,border:"2px solid "+d}:{color:d};const Z=e=>{const t=_,n=e.split(/\s+/);return n.length<=t?e:n.slice(0,t).join(" ")+"..."};return(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"fc_latest_blog_posts",children:E?(0,a.jsx)("h2",{children:(0,a.jsx)(vt,{})}):(0,a.jsx)("div",{className:"fc_latest_posts_items template-"+o,children:k&&k.length?k.map((e,t)=>(0,a.jsx)("div",{className:"fc_latest_post_item",style:O,children:"layout-6"===o?(0,a.jsxs)(a.Fragment,{children:[e.thumbnail&&!0===u?(0,a.jsx)("div",{className:"fc_latest_post_thumbnail",style:{backgroundImage:`url(${e.thumbnail})`,backgroundSize:S}}):null,(0,a.jsxs)("div",{className:"fc_latest_post_content",children:[(0,a.jsx)("h1",{className:"title",style:H,children:e.post_title?e.post_title:"(no title)"}),!0===m?(0,a.jsxs)("p",{className:"meta",style:F,children:[!0===p?(0,a.jsx)("span",{className:"author",children:(0,a.jsx)("span",{style:F,children:e.author})}):null,!0===p&&!0===g&&e.comment_count?"-":null,!0===g&&e.comment_count?(0,a.jsx)("span",{className:"comments",style:U,children:_n(e.comment_count+" comment",e.comment_count+" comments",e.comment_count)}):null]}):null]})]}):(0,a.jsxs)(a.Fragment,{children:[e.thumbnail&&!0===u&&"layout-5"!==o?(0,a.jsx)("div",{className:"fc_latest_post_thumbnail",style:{backgroundImage:`url(${e.thumbnail})`,backgroundSize:S}}):null,(0,a.jsxs)("div",{className:"fc_latest_post_content",children:[!0===m&&"default"!==o&&"layout-5"!==o&&"layout-7"!==o?(0,a.jsxs)("p",{className:"meta",style:F,children:[!0===p?(0,a.jsxs)("span",{className:"author",children:[!0===f?(0,a.jsx)("img",{src:e.author_avatar,alt:e.author}):null,(0,a.jsx)("span",{style:F,children:e.author})]}):null,!0===p&&!0===g&&e.comment_count?"-":null,!0===g&&e.comment_count?(0,a.jsx)("span",{className:"comments",style:U,children:_n(e.comment_count+" comment",e.comment_count+" comments",e.comment_count)}):null]}):null,(0,a.jsx)("h1",{className:"title",style:H,children:e.post_title?e.post_title:"(no title)"}),!0===y&&"layout-5"!==o&&e.post_excerpt?(0,a.jsx)("p",{className:"description",style:z,children:Z(e.post_excerpt)}):null,!0===h&&"layout-4"!==o&&"layout-5"!==o?(0,a.jsx)("span",{style:G,className:"fc_latest_post_btn",children:C}):null]})]})},t)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Posts found!"})})})})})},{Fragment:Mt}=((0,n.withSelect)((e,t)=>{const{selectedPostType:n}=t.attributes;return{selectedPostType:n}})(jt),wp.element),{__:kt}=wp.i18n,Tt={selectedPostType:{type:"string",default:"post"},selectedPostsPerPage:{type:"string",default:"3"},selectedLayout:{type:"string",default:"default"},showImage:{type:"boolean",default:!0},showMeta:{type:"boolean",default:!0},showMetaAuthor:{type:"boolean",default:!0},showMetaAuthorImg:{type:"boolean",default:!0},showMetaComments:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},selectedExcerptLength:{type:"string",default:"55"},contentColor:{type:"string",default:"#6b6d7c"},titleColor:{type:"string",default:"#393d57"},backgroundColor:{type:"string",default:"#ffffff"},authorColor:{type:"string",default:"#393d57"},commentColor:{type:"string",default:"#acacac"},buttonColor:{type:"string",default:"#000000"},taxTypes:{type:"array",default:[]},catType:{type:"string",default:"category"},order:{type:"string",default:"desc"},orderBy:{type:"string",default:"date"},recentPostDays:{type:"string",default:""},buttonText:{type:"string",default:"Read More"},backgroundType:{type:"string",default:"cover"},selectedOperatorType:{type:"string",default:"OR"},postsGap:{type:"number",default:20}},Et=wp.element.createElement,{__:Dt}=wp.i18n,{registerBlockType:At}=wp.blocks,Lt=window.fcrmBlockEditorConfig?.modules||{},Pt=[{attributes:Tt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],Bt=Et("svg",{width:20,height:20},Et("path",{d:"M0 0h24v24H0V0z",fill:"none"}),Et("path",{fill:"#96588a",d:"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"}));!1!==Lt.hasFluentCampaign&&At("fluent-crm/latest-posts",{apiVersion:3,title:Dt("Latest Posts Block"),description:Dt("Latest Posts Block For your Email"),category:"layout",icon:Bt,keywords:[Dt("card"),Dt("latest blog"),Dt("latest posts")],supports:{align:["wide","full"],html:!0},attributes:Tt,deprecated:Pt,edit:e=>{const t=(0,v.useBlockProps)({className:"fluent-latest-posts-block"});return(0,a.jsxs)(Mt,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(jt,{attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(xt,{attributes:e.attributes,setAttributes:e.setAttributes})]})},save:Qe});const Rt={selectedLayout:{type:"string",default:"default"},selectedPostsPerPage:{type:"string",default:"3"},showDescription:{type:"boolean",default:!0},showImage:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},taxonomies:{type:"array",default:[]},taxType:{type:"string",default:"all"},order:{type:"string",default:"desc"},orderBy:{type:"string",default:"date"},buttonText:{type:"string",default:"Buy Now"},titleColor:{type:"string",default:"#2a363d"},descriptionColor:{type:"string",default:""},priceColor:{type:"string",default:"#37454e"},buttonColor:{type:"string",default:""},buttonBG:{type:"string",default:"#2a363d"}},{Fragment:zt}=wp.element,Ht=({attributes:e,setAttributes:t,LandingPage:n,InspectorSettings:o})=>{const r=(0,v.useBlockProps)({className:"fluent-latest-posts-block"});return(0,a.jsxs)(zt,{children:[(0,a.jsx)("div",{...r,children:(0,a.jsx)(n,{attributes:e,setAttributes:t})}),(0,a.jsx)(o,{attributes:e,setAttributes:t})]})},{Spinner:Ot}=wp.components,{useState:Ft,useEffect:Ut}=wp.element,{__:Gt,_n:Zt}=wp.i18n,Vt=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e,[I,b]=Ft([]),[w,x]=Ft(!1),v=wp.apiFetch,{addQueryArgs:C}=wp.url,[S,N]=Ft(!1),j=window.fcrmBlockEditorConfig||{},M=j.endpoints?.products||"fluent-crm/v2/campaigns-pro/products";Ut(()=>{k()},[s,n,o,i]);const k=e=>{x(!0),N(!1),v({path:C(M,{per_page:s,order:n,orderby:o,taxType:i,...e})}).then(e=>{const t=(e=>{const t={product:{terms:{product_cat:[]}}};return Array.isArray(e)?{products:e,taxonomies:t}:{products:Array.isArray(e?.products)?e.products:Array.isArray(e?.data?.products)?e.data.products:[],taxonomies:e?.taxonomies||e?.data?.taxonomies||t}})(e);b(t.products),_({taxonomies:t.taxonomies})}).catch(()=>(e=>v({path:C("wc/store/products",{per_page:s,order:n,orderby:o,...e})}).then(e=>({products:Array.isArray(e)?e:[],taxonomies:{product:{terms:{product_cat:[]}}}})))(e).then(e=>{b(e.products),_({taxonomies:e.taxonomies})})).catch(()=>{b([]),N(!0)}).finally(()=>{x(!1)})},T=e=>e?e.image?e.image:e.images&&e.images.length&&e.images[0].src||"":"",E={color:p},D={color:y},A={color:f};let L="";return"layout-3"!==t&&!0===u&&(L={color:g}),"layout-2"===t&&(L={color:g,background:h}),(0,a.jsx)("div",{children:w?(0,a.jsx)("h2",{children:(0,a.jsx)(Ot,{})}):(0,a.jsx)("div",{className:"fc_woo_products template-"+t,children:I&&I.length?I.map((e,n)=>(0,a.jsxs)("div",{className:"fc_woo_product"+(c?"":" no-image"),children:[!0===c?(0,a.jsx)("div",{className:"fc_woo_product_img",children:(0,a.jsx)("img",{src:T(e),alt:""})}):null,(0,a.jsxs)("div",{className:"fc_woo_product_info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"title",style:E,dangerouslySetInnerHTML:{__html:e.name}}),"layout-2"===t&&!0===l?(0,a.jsx)("p",{className:"description",style:D,dangerouslySetInnerHTML:{__html:e.short_description}}):null,!0===d?(0,a.jsx)("span",{className:"price",style:A,dangerouslySetInnerHTML:{__html:ze(e.price_html,Gt("Free"))}}):null]}),"layout-3"!==t&&!0===u?(0,a.jsx)("span",{className:"add-to-cart-btn",style:L,children:m}):null]})]},n)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Products found!"})})})})},Wt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzM2IiBoZWlnaHQ9IjM2OSIgdmlld0JveD0iMCAwIDMzNiAzNjkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm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MTMiIHJ4PSIxMCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSI2NiIgeT0iMjYzIiB3aWR0aD0iMjAzIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxNDIiIHk9IjI5NCIgd2lkdGg9IjUxIiBoZWlnaHQ9IjEyIiByeD0iNiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxIiB5PSIxIiB3aWR0aD0iMzM0IiBoZWlnaHQ9IjMzMCIgcng9IjkiIHN0cm9rZT0iI0VERUVGNCIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=",{InspectorControls:Jt,PanelColorSettings:$t}=wp.blockEditor,{__:qt}=wp.i18n,{PanelBody:Kt,PanelRow:Xt,SelectControl:en,ToggleControl:tn,TextControl:nn,Dropdown:on,Button:rn}=wp.components,an=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e;let I=Wt;"layout-2"===t?I=Qt:"layout-3"===t&&(I=Yt);const b=[{value:"default",label:qt("Default","fluent-crm"),image:Wt},{value:"layout-2",label:qt("Layout 2","fluent-crm"),image:Qt},{value:"layout-3",label:qt("Layout 3","fluent-crm"),image:Yt}],w=[{value:p,onChange:e=>{_({titleColor:e})},label:qt("Title Color")}];"layout-2"===t&&!0===l&&w.push({value:y,onChange:e=>{_({descriptionColor:e})},label:qt("Description Color")}),!0===d&&w.push({value:f,onChange:e=>{_({priceColor:e})},label:qt("Price Color")}),"layout-3"!==t&&!0===u&&w.push({value:g,onChange:e=>{_({buttonColor:e})},label:qt("Button Color")}),"layout-2"===t&&!0===u&&w.push({value:h,onChange:e=>{_({buttonBG:e})},label:qt("Button Background")});const x=[{value:"all",label:"All"}];return r.product?.terms&&r.product?.terms.product_cat&&r.product?.terms.product_cat.map(e=>x.push(e)),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Kt,{title:"General Settings",initialOpen:!0,children:(0,a.jsx)(Xt,{children:(0,a.jsxs)("div",{className:"fc-latest-products-settings",children:[r.product?.terms?(0,a.jsx)(en,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:i,options:x,placeholder:qt("Select Taxonomy","fluent-crm"),label:qt("Select Taxonomy","fluent-crm"),clearable:!0,onChange:e=>{_({taxType:e})}}):null,(0,a.jsx)(en,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:qt("Order by","fluent-crm"),options:[{label:qt("Newest to Oldest","fluent-crm"),value:"date/desc"},{label:qt("Oldest to Newest","fluent-crm"),value:"date/asc"},{label:qt("A → Z","fluent-crm"),value:"title/asc"},{label:qt("Z → A","fluent-crm"),value:"title/desc"}],value:`${o}/${n}`,onChange:e=>{const[t,r]=e.split("/");r!==n&&_({order:r}),t!==o&&_({orderBy:t})}}),(0,a.jsx)(nn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fce-dimension-box",value:s,label:qt("Show Products"),help:"e.g how many products you want to show",onChange:e=>_({selectedPostsPerPage:e})}),(0,a.jsxs)("div",{className:"show-setting-control-box select-layout",children:[(0,a.jsx)("p",{children:"Select Layout"}),(0,a.jsx)(on,{className:"show-setting-dropdown",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("img",{onClick:t,"aria-expanded":e,src:I,alt:""}),(0,a.jsx)(rn,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})})]}),renderContent:({onToggle:e})=>(0,a.jsxs)("div",{className:"dropdown-render-content dropdown-render-selected-layout fc-layout-picker",children:[(0,a.jsx)("p",{children:"Select Layout"}),(0,a.jsx)("div",{className:"fc-layout-picker-grid",role:"radiogroup","aria-label":qt("Layout","fluent-crm"),children:b.map(n=>(0,a.jsxs)("button",{type:"button",className:"fc-layout-picker-option "+(t===n.value?"is-active":""),role:"radio","aria-checked":t===n.value,onClick:()=>{_({selectedLayout:n.value}),e()},children:[(0,a.jsx)("img",{src:n.image,alt:n.label}),(0,a.jsx)("span",{children:n.label})]},n.value))})]})})]}),(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Image"),checked:c,onChange:()=>_({showImage:!c})}),"layout-2"===t?(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Description"),checked:l,onChange:()=>_({showDescription:!l})}):null,(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Price"),checked:d,onChange:()=>_({showPrice:!d})}),"layout-3"!==t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Button"),checked:u,onChange:()=>_({showButton:!u})}),!0===u?(0,a.jsx)(nn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"text",value:m,label:qt("Button Text"),onChange:e=>_({buttonText:e})}):null]}):null]})})}),(0,a.jsx)("div",{className:"fc-latest-products-content-color-settings",children:(0,a.jsx)($t,{title:qt("Customization"),colorSettings:w})})]})},sn=wp.element.createElement,{__:ln}=wp.i18n,{registerBlockType:cn}=wp.blocks,dn=window.fcrmBlockEditorConfig?.modules||{},un=[{attributes:Rt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],mn=sn("svg",{width:20,height:20,viewBox:"0 0 24 24"},sn("path",{fill:"#7F54B3",d:"M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8.2L7 20v-4H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"}),sn("text",{x:12,y:12.8,textAnchor:"middle",fontSize:6.5,fontFamily:"Arial, sans-serif",fontWeight:700,fill:"#fff"},"woo"));!1!==dn.hasFluentCampaign&&!1!==dn.hasWooCommerce&&cn("fluent-crm/woo-products",{apiVersion:3,title:ln("WooCommerce Products"),description:ln("WooCommerce Products For your Email"),category:"layout",icon:mn,keywords:[ln("card"),ln("latest product"),ln("latest products"),ln("products")],supports:{align:["wide","full"],html:!0},attributes:Rt,deprecated:un,edit:e=>(0,a.jsx)(Ht,{attributes:e.attributes,setAttributes:e.setAttributes,LandingPage:Vt,InspectorSettings:an}),save:Qe});const pn=(e="")=>((e="")=>{const t=document.createElement("textarea");return t.innerHTML=String(e),t.value})(e).replace(/\s+/g," ").trim(),fn=()=>{const e=window.fcrmBlockEditorConfig||{};return e.endpoints?.cartProducts||"fluent-crm/v2/editor/cart-products"},gn=e=>e?e.image?e.image:e.thumbnail?e.thumbnail:e.images&&e.images.length&&e.images[0].src||"":"",hn=(e={})=>{if(e?.label)return e.label;const t=e?.id?`#${e.id}`:"",n=e?.name||e?.post_title||"";return[t?`${t} - ${n}`:n,pn(e?.price_html?ze(e.price_html).replace(/<[^>]*>/g,""):e?.price_text),Array.isArray(e?.categories)?e.categories.filter(Boolean).join(", "):""].filter(Boolean).join(" | ")},yn=(e={})=>({id:e?.id,name:e?.name||e?.post_title||`#${e?.id}`,label:hn(e),short_description:e?.short_description||e?.post_excerpt||"",price_html:ze(e?.price_html||e?.price||""),image:gn(e),permalink:e?.permalink||"#"}),In=e=>{const t=Array.isArray(e?.products)?e.products:null,n=Array.isArray(e?.data?.products)?e.data.products:null;return{products:(t||n||[]).map(yn).filter(e=>!!e.id),taxonomies:e?.taxonomies||e?.data?.taxonomies||{}}},bn=e=>{const t=e?.product||e?.data?.product;return t&&t.id?yn(t):In(e).products[0]||null},{Spinner:wn}=wp.components,{useState:xn,useEffect:vn}=wp.element,{__:Cn}=wp.i18n,Sn=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e,[I,b]=xn([]),[w,x]=xn(!1),v=wp.apiFetch,{addQueryArgs:C}=wp.url,[S,N]=xn(!1),j=fn();vn(()=>{M()},[s,n,o,i]);const M=e=>{x(!0),v({path:C(j,{per_page:s,order:n,orderby:o,taxType:i,...e})}).then(e=>{const t=In(e);b(t.products),_({taxonomies:t.taxonomies})}).catch(e=>{N(!0)}).finally(()=>{x(!1)})},k=e=>e?.name||e?.post_title||"",T=e=>e?.short_description||e?.post_excerpt||"",E=e=>ze(e?.price_html||e?.price||e?.detail?.formatted_min_price,Cn("Free")),D={color:p},A={color:y},L={color:f};let P="";return"layout-3"!==t&&!0===u&&(P={color:g}),"layout-2"===t&&(P={color:g,background:h}),(0,a.jsx)("div",{children:w?(0,a.jsx)("h2",{children:(0,a.jsx)(wn,{})}):(0,a.jsx)("div",{className:"fc_woo_products template-"+t,children:I&&I.length?I.map((e,n)=>(0,a.jsxs)("div",{className:"fc_woo_product"+(c?"":" no-image"),children:[!0===c?(0,a.jsx)("div",{className:"fc_woo_product_img",children:(0,a.jsx)("img",{src:gn(e),alt:""})}):null,(0,a.jsxs)("div",{className:"fc_woo_product_info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"title",style:D,dangerouslySetInnerHTML:{__html:k(e)}}),"layout-2"===t&&!0===l?(0,a.jsx)("p",{className:"description",style:A,dangerouslySetInnerHTML:{__html:T(e)}}):null,!0===d?(0,a.jsx)("span",{className:"price",style:L,dangerouslySetInnerHTML:{__html:E(e)}}):null]}),"layout-3"!==t&&!0===u?(0,a.jsx)("span",{className:"add-to-cart-btn",style:P,children:m}):null]})]},n)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Products found!"})})})})},Nn=wp.element.createElement,{__:jn}=wp.i18n,{registerBlockType:Mn}=wp.blocks,kn=window.fcrmBlockEditorConfig?.modules||{},Tn=[{attributes:Rt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],En=Nn("svg",{width:20,height:20,viewBox:"0 0 24 24"},Nn("rect",{x:0,y:0,width:24,height:24,rx:4,fill:"#0b4dbb"}),Nn("path",{fill:"#fff",d:"M11.2 16.4H4.2l1.1-2.5c.3-.7 1-1.2 1.8-1.2h8.3l-.6 1.3c-.6 1.5-2 2.4-3.6 2.4z"}),Nn("path",{fill:"#fff",d:"M17 11.2H7.2l.6-1.3c.6-1.5 2-2.4 3.6-2.4h8.5l-1.1 2.5c-.3.7-1 1.2-1.8 1.2z"}));!1!==kn.hasFluentCart&&Mn("fluent-crm/cart-products",{apiVersion:3,title:jn("FluentCart Products"),description:jn("FluentCart Products For your Email"),category:"layout",icon:En,keywords:[jn("card"),jn("fluentcart"),jn("products")],supports:{align:["wide","full"],html:!0},attributes:Rt,deprecated:Tn,edit:e=>(0,a.jsx)(Ht,{attributes:e.attributes,setAttributes:e.setAttributes,LandingPage:Sn,InspectorSettings:an}),save:Qe});const{InspectorControls:Dn,PanelColorSettings:An}=wp.blockEditor,{__:Ln}=wp.i18n,{useState:Pn,useEffect:Bn,useRef:Rn}=wp.element,{PanelBody:zn,PanelRow:Hn,SelectControl:On,ToggleControl:Fn,ComboboxControl:Un,Spinner:Gn}=wp.components,Zn=Un||wp.components.__experimentalComboboxControl,Vn=e=>{const{attributes:{productId:t,showImage:n,showDescription:o,showPrice:r,showButton:i,template:s,backgroundColor:l,contentColor:c,pricingColor:d},setAttributes:u}=e,[m,p]=Pn([]),[f,g]=Pn(""),[h,y]=Pn(!1),_=Rn(null),I=wp.apiFetch,{addQueryArgs:b}=wp.url,w=fn(),x=[{value:"left",label:Ln("Image Left")},{value:"top",label:Ln("Image Top")},{value:"none",label:Ln("No Image")}];Bn(()=>(t&&C(t),()=>{_.current&&clearTimeout(_.current)}),[]);const v=(e={})=>{y(!0),I({path:b(w,{per_page:25,...e})}).then(e=>{p(In(e).products)}).catch(()=>{p([])}).finally(()=>{y(!1)})},C=e=>{e&&I({path:b(w,{product_id:e})}).then(e=>{const t=bn(e);g(t?.label||t?.name||"")}).catch(()=>{g("")})},S=e=>{if(!e)return;const t=m.find(t=>String(t.id)===String(e));t&&g(t.label||t.name||""),u({productId:parseInt(e,10)})},N=m.map(e=>({value:String(e.id),label:e.label||e.name})),j=t?String(t):null;j&&f&&!N.find(e=>e.value===j)&&N.unshift({value:j,label:f});const M=[{value:c,onChange:e=>u({contentColor:e}),label:Ln("Content Color")},{value:l,onChange:e=>u({backgroundColor:e}),label:Ln("Background Color")},{value:d,onChange:e=>u({pricingColor:e}),label:Ln("Price Color")}];return t?(0,a.jsxs)(Dn,{children:[(0,a.jsx)(zn,{title:Ln("Template Settings"),initialOpen:!0,children:(0,a.jsx)(Hn,{children:(0,a.jsxs)("div",{className:"fc-latest-products-settings",children:[(0,a.jsxs)("div",{style:{marginBottom:"12px"},children:[Zn?(0,a.jsx)(Zn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Select Product"),value:j,options:N,onChange:S,onFilterValueChange:e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(e?{search:e}:{})},1200)},onFocus:()=>{m.length||v()},placeholder:Ln("Search product"),expandOnFocus:!0}):(0,a.jsx)(On,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Select Product"),value:j,options:[{value:"",label:Ln("Select a Product")},...N],onChange:S}),h&&(0,a.jsx)("div",{style:{marginTop:"8px"},children:(0,a.jsx)(Gn,{})})]}),(0,a.jsx)(On,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Design Template"),value:s,options:x,onChange:e=>{const t={template:e};"none"===e&&(t.showImage=!1),u(t)}}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Image"),checked:n,onChange:e=>u({showImage:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Description"),checked:o,onChange:e=>u({showDescription:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Price"),checked:r,onChange:e=>u({showPrice:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Button"),checked:i,onChange:e=>u({showButton:e})})]})})}),(0,a.jsx)("div",{className:"fc-latest-products-content-color-settings",children:(0,a.jsx)(An,{title:Ln("Customization"),colorSettings:M})})]}):null},{RadioControl:Wn,Spinner:Qn}=wp.components,{InnerBlocks:Yn}=wp.blockEditor,{useState:Jn,useEffect:$n}=wp.element,{__:qn}=wp.i18n,Kn=e=>{const{clientId:t,attributes:{productId:n,showImage:o,showDescription:r,showPrice:i,showButton:s,buttonText:l,customImage:c,template:d,backgroundColor:u,contentColor:m,pricingColor:p},setAttributes:f}=e,[g,h]=Jn([]),[y,_]=Jn(""),[I,b]=Jn(""),[w,x]=Jn({}),[v,C]=Jn(!1),[S,N]=Jn(!1),j=wp.apiFetch,{addQueryArgs:M}=wp.url,k=fn();$n(()=>{n?P(n):L()},[n]);const{useDispatch:T,useSelect:E}=wp.data,{updateBlockAttributes:D}=T("core/block-editor"),A=E(e=>e("core/block-editor").getBlocks(t),[t]);$n(()=>{w.permalink&&A.forEach(e=>{"core/buttons"===e.name&&e.innerBlocks.forEach(e=>{"core/button"===e.name&&D(e.clientId,{url:w.permalink})})})},[w.permalink]);const L=(e={})=>{N(!0),j({path:M(k,{per_page:10,...e})}).then(e=>{const t=In(e).products;h(t)}).catch(()=>{h([])}).finally(()=>{N(!1)})},P=e=>{const t=parseInt(e,10);t&&(C(!0),j({path:M(k,{product_id:t})}).then(e=>{const t=bn(e);t&&(x(t),b(String(t.id)),f({productId:t.id}))}).catch(()=>{x({})}).finally(()=>{C(!1)}))},B=c||(w&&w.image?w.image:""),R=o&&"none"!==d&&B?d:"none",z={backgroundColor:u,color:m},H=["fcw_p",`fcw_template_${R}`,v?"fc_product_loading":""].filter(Boolean).join(" "),O=["fcw_search_box",v?"fc_product_loading":""].filter(Boolean).join(" ");return(0,a.jsxs)("div",{children:[v?(0,a.jsxs)("div",{style:z,className:"fc_woo_loader",children:[(0,a.jsx)(Qn,{}),(0,a.jsx)("h3",{children:qn("Loading product")})]}):null,w.id&&n?(0,a.jsxs)("div",{style:z,className:H,children:["none"!==R?(0,a.jsx)("div",{className:"fcw_image",children:(0,a.jsx)("img",{src:B,alt:""})}):null,(0,a.jsxs)("div",{className:"fcw_p_content",children:[(0,a.jsx)("h2",{style:{color:m||void 0},className:"fcw_p_title",dangerouslySetInnerHTML:{__html:w.name||""}}),r?(0,a.jsx)("div",{style:{color:m||void 0},className:"fcw_p_desc",dangerouslySetInnerHTML:{__html:w.short_description||""}}):null,i?(0,a.jsx)("div",{style:{color:p||void 0},className:"fcw_p_price",dangerouslySetInnerHTML:{__html:ze(w.price_html,qn("Free"))}}):null,s?(0,a.jsx)("div",{className:"fcb_p_button",children:(0,a.jsx)(Yn,{template:[["core/buttons",{},[["core/button",{text:l,url:w.permalink||"#",align:"left"}]]]],templateLock:"all"})}):null]})]}):(0,a.jsxs)("div",{className:O,children:[(0,a.jsx)("h4",{children:qn("Search and Select a Product")}),(0,a.jsx)("hr",{}),(0,a.jsxs)("div",{style:{marginBottom:"25px"},className:"fluent-single-product-search-bar",children:[(0,a.jsx)("div",{children:(0,a.jsx)("input",{placeholder:qn("Product name or id:1122"),style:{height:"36px"},value:y,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"!==e.key&&""!==e.target.value||L({search:y})}})}),(0,a.jsx)("button",{style:{height:"36px"},onClick:()=>L({search:y}),children:qn("Search")})]}),S?(0,a.jsx)("h2",{children:(0,a.jsx)(Qn,{})}):(0,a.jsx)("div",{className:"fcw_results",children:g.length?(0,a.jsx)(Wn,{selected:I,options:g.map(e=>({value:String(e.id),label:e.label||e.name})),onChange:e=>b(e)}):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:qn("No products found!")})})}),(0,a.jsx)("button",{type:"button",style:{marginTop:"20px"},className:"components-button is-primary",disabled:!I,onClick:()=>P(I),children:qn("Done")})]})]})},{Fragment:Xn}=wp.element,{__:eo}=wp.i18n,to={productId:{type:"number",default:null},showImage:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},buttonText:{type:"string",default:eo("Buy Now")},customImage:{type:"string",default:""},backgroundColor:{type:"string",default:"#fffeeb"},contentColor:{type:"string",default:""},pricingColor:{type:"string",default:""},template:{type:"string",default:"left"}},no=wp.element.createElement,{__:oo}=wp.i18n,{registerBlockType:ro}=wp.blocks,io=window.fcrmBlockEditorConfig?.modules||{},ao=[{attributes:{...to,buttonColor:{type:"string",default:"#ffffff"},buttonBG:{type:"string",default:"#2a363d"}},save:Qe},{attributes:to,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],so=no("svg",{width:20,height:20,viewBox:"0 0 24 24"},no("rect",{x:0,y:0,width:24,height:24,rx:4,fill:"#0b4dbb"}),no("path",{fill:"#fff",d:"M11.2 16.4H4.2l1.1-2.5c.3-.7 1-1.2 1.8-1.2h8.3l-.6 1.3c-.6 1.5-2 2.4-3.6 2.4z"}),no("path",{fill:"#fff",d:"M17 11.2H7.2l.6-1.3c.6-1.5 2-2.4 3.6-2.4h8.5l-1.1 2.5c-.3.7-1 1.2-1.8 1.2z"}));!1!==io.hasFluentCart&&ro("fluent-crm/cart-product",{apiVersion:3,title:oo("FluentCart Product (Single)"),description:oo("Single FluentCart product block for your email"),category:"layout",icon:so,keywords:[oo("fluentcart"),oo("product"),oo("single")],supports:{align:["wide","full"],html:!0},attributes:to,deprecated:ao,edit:e=>{const t=(0,v.useBlockProps)({className:"fluent-single-product-block"});return(0,a.jsxs)(Xn,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(Kn,{clientId:e.clientId,attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(Vn,{attributes:e.attributes,setAttributes:e.setAttributes})]})},save:Qe});const lo=function({children:e,...t}){return(0,a.jsx)("div",{className:"fc-cond-section",...t,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:e})})},co=window.fcrmBlockEditorConfig?.endpoints?.tags||"fluent-crm/v2/reports/options?fields=tags",uo=e=>Array.isArray(e)?e.map(e=>{const t=String(e.id??e.value??"");return{id:t,title:e.title||e.label||t}}).filter(e=>!!e.id):[],mo=()=>{const e=window.fcrmEditorBoot?.available_tags||window.fcAdmin?.available_tags||window._fcrm_available_tags||[];return uo(e)},po=(e,t)=>{window.wp&&window.wp.apiFetch&&(t(!0),window.wp.apiFetch({path:co}).then(t=>{const n=uo(t?.options?.tags||[]);window._fcrm_available_tags=n,e(n)}).catch(()=>{}).finally(()=>t(!1)))},fo=()=>!1!==(window.fcrmBlockEditorConfig?.modules||{}).hasFluentCampaign,go=window.wp.components,{__:ho,_x}=wp.i18n,{registerBlockType:yo}=wp.blocks,_o=[{attributes:{condition_type:{type:"string",default:"show_if_tag_exist"},tag_ids:{type:"array",default:[]}},save:()=>(0,a.jsx)(lo,{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}];yo("fluentcrm/conditional-group",{apiVersion:3,title:ho("Conditional Section"),description:ho("Add a section that shows content conditionally by subscriber tags."),category:"layout",icon:"welcome-widgets-menus",keywords:[_x("conditional"),_x("section")],supports:{align:["wide","full"],anchor:!0,html:!1},attributes:{condition_type:{type:"string",default:"show_if_tag_exist"},tag_ids:{type:"array",default:[]}},deprecated:_o,edit:e=>{const{attributes:t,setAttributes:n}=e,{condition_type:o,tag_ids:r}=t,[s,l]=(0,i.useState)(mo()),[c,d]=(0,i.useState)(!1),u=fo(),m=(0,i.useMemo)(()=>Array.isArray(r)?r.map(e=>String(e)):[],[r]);(0,i.useEffect)(()=>{s.length||po(l,d)},[]);const p=(0,i.useMemo)(()=>{const e={};return s.forEach(t=>{e[t.id]=t.title}),e},[s]),f=(0,i.useMemo)(()=>{const e={};return s.forEach(t=>{e[t.title]=t.id}),e},[s]),g=(0,i.useMemo)(()=>m.map(e=>p[e]||e),[m,p]),h=(0,i.useMemo)(()=>s.map(e=>e.title),[s]),y=ho("show_if_tag_exist"===o?"Shown to subscribers with any selected tag.":"Hidden from subscribers with any selected tag.","fluent-crm"),_=(0,v.useBlockProps)({className:"fc-cond-section"});return(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(v.InspectorControls,{children:(0,a.jsxs)(go.PanelBody,{title:ho("Conditional Settings"),children:[(0,a.jsx)(go.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ho("Condition Type"),value:o,onChange:e=>n({condition_type:e||"show_if_tag_exist"}),options:[{value:"show_if_tag_exist",label:ho("Show if in selected tags","fluent-crm")},{value:"show_if_tag_not_exist",label:ho("Show if not in selected tags","fluent-crm")}]}),c?(0,a.jsx)(go.Spinner,{}):(0,a.jsx)(go.FormTokenField,{label:ho("Tags","fluent-crm"),value:g,suggestions:h,onChange:e=>{if(!u)return;const t=e.map(e=>f[e]).filter(Boolean);n({tag_ids:t})},disabled:!u,__experimentalExpandOnFocus:!0,__experimentalAutoSelectFirstMatch:!0,__experimentalShowHowTo:!1,__next40pxDefaultSize:!0}),u?(0,a.jsx)("p",{className:"components-base-control__help",children:y}):(0,a.jsx)(go.Notice,{status:"warning",isDismissible:!1,children:ho("Conditional Section requires FluentCRM Pro.","fluent-crm")})]})}),(0,a.jsx)("div",{..._,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:(0,a.jsx)(v.InnerBlocks,{})})})]})},save:()=>{const e=v.useBlockProps.save({className:"fc-cond-section"});return(0,a.jsx)("div",{...e,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:(0,a.jsx)(v.InnerBlocks.Content,{})})})}});const Io=window.wp.apiFetch;var bo=e.n(Io);const{__:wo,_x:xo}=wp.i18n,{registerBlockType:vo,createBlock:Co}=wp.blocks,So=wp.element.createElement,No="fcrm_ai_writing_tone",jo="fcrm_ai_writing_length",Mo=["Professional","Casual","Friendly","Urgent","Persuasive","Formal"],ko=["Short","Medium","Long"];function To(e,t,n){try{const n=localStorage.getItem(e);if(n&&t.includes(n))return n}catch(e){}return n}const Eo=So("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},So("path",{d:"M9.9991 3C10.1943 3 10.3841 3.06406 10.5397 3.18199C10.6564 3.2705 10.7492 3.38584 10.8105 3.51729L10.8616 3.65356L10.8642 3.66522L11.88 7.6072C11.9117 7.73016 11.9758 7.84279 12.0656 7.93263C12.1554 8.02249 12.268 8.08733 12.391 8.11911L16.3339 9.13486L16.3429 9.13665V9.13755C16.4845 9.17662 16.6136 9.2493 16.7194 9.34913L16.8171 9.45761L16.896 9.58043C16.9642 9.70896 17 9.85305 17 10C17 10.1959 16.9358 10.3865 16.8171 10.5424C16.6984 10.6982 16.5317 10.8104 16.3429 10.8624L16.3339 10.8651L12.391 11.8809C12.268 11.9127 12.1554 11.9775 12.0656 12.0674C11.9758 12.1572 11.9117 12.2698 11.88 12.3928L10.8633 16.3348L10.8607 16.3464C10.808 16.5344 10.6952 16.7 10.5397 16.818C10.3841 16.9361 10.1935 17 9.99821 17C9.80298 16.9999 9.61315 16.936 9.45761 16.818C9.30206 16.7 9.18933 16.5344 9.13665 16.3464L9.13307 16.3348L8.11732 12.3928L8.08773 12.3023C8.05209 12.2146 7.99908 12.1347 7.93174 12.0674C7.84184 11.9775 7.72941 11.9126 7.6063 11.8809L3.66432 10.8642C3.65986 10.8631 3.6553 10.8619 3.65087 10.8607C3.46355 10.8075 3.29852 10.695 3.1811 10.5397C3.09296 10.4231 3.035 10.2872 3.01165 10.1443L3 10L3.01165 9.85566C3.035 9.71281 3.09296 9.57693 3.1811 9.4603C3.29852 9.30496 3.46354 9.19251 3.65087 9.13934L3.66432 9.13576L7.6063 8.11821C7.7293 8.0865 7.84186 8.0224 7.93174 7.93263C8.02162 7.84281 8.0855 7.73022 8.11732 7.6072L9.13397 3.66522L9.13665 3.65356H9.13755C9.19024 3.4656 9.30297 3.29997 9.4585 3.18199L9.58133 3.104C9.7095 3.0363 9.8527 3.00001 9.9991 3ZM9.229 7.89408C9.14588 8.21551 8.9779 8.50928 8.74308 8.74398C8.50825 8.97865 8.21464 9.14607 7.89319 9.229L4.90599 9.9991L7.89319 10.7701L8.01242 10.8051C8.28729 10.896 8.53756 11.0505 8.74308 11.256C8.94862 11.4616 9.10316 11.7118 9.19403 11.9867L9.229 12.1059L9.99821 15.0931L10.7692 12.1059C10.8522 11.7844 11.0195 11.4909 11.2542 11.256C11.4891 11.0211 11.7833 10.8531 12.105 10.7701L15.0931 10L12.105 9.22989C11.7833 9.14691 11.4891 8.97888 11.2542 8.74398C11.0488 8.53848 10.895 8.2881 10.8042 8.01332L10.7692 7.89408L9.9991 4.90779L9.229 7.89408ZM4.28381 14.4978V14.4297H4.21568C3.89888 14.4297 3.64205 14.1727 3.64191 13.8559C3.64191 13.539 3.89879 13.2821 4.21568 13.2821H4.28381V13.2131C4.28381 12.8964 4.54089 12.6396 4.85758 12.6393C5.17447 12.6393 5.43135 12.8962 5.43135 13.2131V13.2821H5.50038C5.81727 13.2821 6.07415 13.539 6.07415 13.8559C6.07401 14.1727 5.81718 14.4297 5.50038 14.4297H5.43135V14.4978C5.43135 14.8147 5.17447 15.0716 4.85758 15.0716C4.54089 15.0714 4.28381 14.8146 4.28381 14.4978ZM14.566 6.78689V6.07595H13.8541C13.5375 6.07575 13.2806 5.81875 13.2804 5.50218C13.2804 5.18541 13.5374 4.9286 13.8541 4.92841H14.566V4.21657C14.566 3.89969 14.8228 3.6428 15.1397 3.6428C15.4566 3.64282 15.7135 3.8997 15.7135 4.21657V4.92841H16.4253C16.742 4.92863 16.9991 5.18543 16.9991 5.50218C16.9989 5.81873 16.7419 6.07572 16.4253 6.07595H15.7135V6.78689C15.7135 7.10376 15.4566 7.36064 15.1397 7.36066C14.8228 7.36066 14.566 7.10377 14.566 6.78689Z",fill:"currentColor"})),Do=window.fcrmEditorBoot||{};Do.ai_writing&&Do.ai_writing.enabled&&vo("fluent-crm/ai-writer",{apiVersion:3,title:wo("Write with AI","fluent-crm"),description:wo("Generate a complete email section with AI. Type a prompt and the block will be replaced with generated content.","fluent-crm"),category:"text",icon:Eo,keywords:[xo("ai"),xo("writer"),xo("generate"),xo("prompt")],supports:{html:!1,reusable:!1,multiple:!0},attributes:{prompt:{type:"string",default:""}},edit:({attributes:e,setAttributes:t,clientId:o})=>{const{prompt:s}=e,[l,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(""),[m,p]=(0,i.useState)(()=>To(No,Mo,"Professional")),[f,g]=(0,i.useState)(()=>To(jo,ko,"Medium")),h=(0,v.useBlockProps)({className:"fcrm-ai-writer-block"}),y=(0,i.useCallback)(()=>{s&&s.trim()&&(u(""),c(!0),bo()({path:"fluent-crm/v2/ai/generate-email-body",method:"POST",data:{prompt:s.trim(),tone:m.toLowerCase(),length:f.toLowerCase(),audience:"",cta:"",context:{design_template:(window.fcrmEditorBoot||{}).current_design_template||"",editor_type:"block_editor",output_format:"gutenberg_blocks",campaign_type:((window.fcrmEditorBoot||{}).entity||{}).block_type||"",has_existing_body:"yes"}}}).then(e=>{if(e&&e.email_body){const i=(t=e.email_body)?t.includes("\x3c!-- wp:")?(0,r.parse)(t):(0,r.rawHandler)({HTML:t})||(0,r.pasteHandler)({HTML:t,mode:"BLOCKS"})||(0,r.pasteHandler)({plainText:t,mode:"BLOCKS"}):[];i&&i.length?(0,n.dispatch)("core/block-editor").replaceBlocks([o],i):u(wo("Could not generate content. Try a different prompt.","fluent-crm"))}else u(wo("No content was generated. Please try again.","fluent-crm"));var t}).catch(e=>{u(e&&e.message||wo("An error occurred. Please try again.","fluent-crm"))}).finally(()=>{c(!1)}))},[s,m,f,o]),_=(0,i.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},[y]);return(0,i.useCallback)(()=>{(0,n.dispatch)("core/block-editor").replaceBlocks([o],[Co("core/paragraph")])},[o]),(0,a.jsx)("div",{...h,children:(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__inner",children:[(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__header",children:[(0,a.jsx)("span",{className:"fcrm-ai-writer-block__icon",children:Eo}),(0,a.jsx)("span",{className:"fcrm-ai-writer-block__title",children:wo("Write with AI","fluent-crm")}),(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__controls",children:[(0,a.jsx)("select",{className:"fcrm-ai-writer-block__select","aria-label":wo("Tone","fluent-crm"),value:m,onChange:e=>{p(e.target.value);try{localStorage.setItem(No,e.target.value)}catch(e){}},children:Mo.map(e=>(0,a.jsx)("option",{value:e,children:e},e))}),(0,a.jsx)("select",{className:"fcrm-ai-writer-block__select","aria-label":wo("Length","fluent-crm"),value:f,onChange:e=>{g(e.target.value);try{localStorage.setItem(jo,e.target.value)}catch(e){}},children:ko.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]})]}),(0,a.jsx)("textarea",{className:"fcrm-ai-writer-block__prompt",value:s||"",onChange:e=>t({prompt:e.target.value}),onKeyDown:_,placeholder:wo("Describe the email you want to write... (Ctrl+Enter to generate)","fluent-crm"),rows:3,disabled:l}),d?(0,a.jsx)("div",{className:"fcrm-ai-writer-block__error",children:d}):null,(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__footer",children:[(0,a.jsx)("span",{className:"fcrm-ai-writer-block__tip",children:wo("Tip: Be specific about your audience and goal","fluent-crm")}),l?(0,a.jsxs)("div",{className:"components-button fcrm-ai-writer-block__generate-button fcrm-ai-writer-block__loading",children:[(0,a.jsx)(go.Spinner,{}),wo("Generating...","fluent-crm")]}):(0,a.jsxs)("div",{className:"fcrm_ai_button_anim_wrapper",children:[s||s&&s.trim()?(0,a.jsx)("div",{className:"fcrm_ai_button_anim",children:(0,a.jsx)("div",{className:"fcrm_ai_button_anim_inner"})}):null,(0,a.jsxs)(go.Button,{variant:"primary",disabled:!s||!s.trim(),onClick:y,className:"fcrm_ai_button fcrm-ai-writer-block__generate-button",children:[(0,a.jsx)("span",{className:"icon",children:(0,a.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{d:"M9.9991 3C10.1943 3 10.3841 3.06406 10.5397 3.18199C10.6564 3.2705 10.7492 3.38584 10.8105 3.51729L10.8616 3.65356L10.8642 3.66522L11.88 7.6072C11.9117 7.73016 11.9758 7.84279 12.0656 7.93263C12.1554 8.02249 12.268 8.08733 12.391 8.11911L16.3339 9.13486L16.3429 9.13665V9.13755C16.4845 9.17662 16.6136 9.2493 16.7194 9.34913L16.8171 9.45761L16.896 9.58043C16.9642 9.70896 17 9.85305 17 10C17 10.1959 16.9358 10.3865 16.8171 10.5424C16.6984 10.6982 16.5317 10.8104 16.3429 10.8624L16.3339 10.8651L12.391 11.8809C12.268 11.9127 12.1554 11.9775 12.0656 12.0674C11.9758 12.1572 11.9117 12.2698 11.88 12.3928L10.8633 16.3348L10.8607 16.3464C10.808 16.5344 10.6952 16.7 10.5397 16.818C10.3841 16.9361 10.1935 17 9.99821 17C9.80298 16.9999 9.61315 16.936 9.45761 16.818C9.30206 16.7 9.18933 16.5344 9.13665 16.3464L9.13307 16.3348L8.11732 12.3928L8.08773 12.3023C8.05209 12.2146 7.99908 12.1347 7.93174 12.0674C7.84184 11.9775 7.72941 11.9126 7.6063 11.8809L3.66432 10.8642C3.65986 10.8631 3.6553 10.8619 3.65087 10.8607C3.46355 10.8075 3.29852 10.695 3.1811 10.5397C3.09296 10.4231 3.035 10.2872 3.01165 10.1443L3 10L3.01165 9.85566C3.035 9.71281 3.09296 9.57693 3.1811 9.4603C3.29852 9.30496 3.46354 9.19251 3.65087 9.13934L3.66432 9.13576L7.6063 8.11821C7.7293 8.0865 7.84186 8.0224 7.93174 7.93263C8.02162 7.84281 8.0855 7.73022 8.11732 7.6072L9.13397 3.66522L9.13665 3.65356H9.13755C9.19024 3.4656 9.30297 3.29997 9.4585 3.18199L9.58133 3.104C9.7095 3.0363 9.8527 3.00001 9.9991 3ZM9.229 7.89408C9.14588 8.21551 8.9779 8.50928 8.74308 8.74398C8.50825 8.97865 8.21464 9.14607 7.89319 9.229L4.90599 9.9991L7.89319 10.7701L8.01242 10.8051C8.28729 10.896 8.53756 11.0505 8.74308 11.256C8.94862 11.4616 9.10316 11.7118 9.19403 11.9867L9.229 12.1059L9.99821 15.0931L10.7692 12.1059C10.8522 11.7844 11.0195 11.4909 11.2542 11.256C11.4891 11.0211 11.7833 10.8531 12.105 10.7701L15.0931 10L12.105 9.22989C11.7833 9.14691 11.4891 8.97888 11.2542 8.74398C11.0488 8.53848 10.895 8.2881 10.8042 8.01332L10.7692 7.89408L9.9991 4.90779L9.229 7.89408ZM4.28381 14.4978V14.4297H4.21568C3.89888 14.4297 3.64205 14.1727 3.64191 13.8559C3.64191 13.539 3.89879 13.2821 4.21568 13.2821H4.28381V13.2131C4.28381 12.8964 4.54089 12.6396 4.85758 12.6393C5.17447 12.6393 5.43135 12.8962 5.43135 13.2131V13.2821H5.50038C5.81727 13.2821 6.07415 13.539 6.07415 13.8559C6.07401 14.1727 5.81718 14.4297 5.50038 14.4297H5.43135V14.4978C5.43135 14.8147 5.17447 15.0716 4.85758 15.0716C4.54089 15.0714 4.28381 14.8146 4.28381 14.4978ZM14.566 6.78689V6.07595H13.8541C13.5375 6.07575 13.2806 5.81875 13.2804 5.50218C13.2804 5.18541 13.5374 4.9286 13.8541 4.92841H14.566V4.21657C14.566 3.89969 14.8228 3.6428 15.1397 3.6428C15.4566 3.64282 15.7135 3.8997 15.7135 4.21657V4.92841H16.4253C16.742 4.92863 16.9991 5.18543 16.9991 5.50218C16.9989 5.81873 16.7419 6.07572 16.4253 6.07595H15.7135V6.78689C15.7135 7.10376 15.4566 7.36064 15.1397 7.36066C14.8228 7.36066 14.566 7.10377 14.566 6.78689Z",fill:"currentColor"})})}),wo("Generate with AI","fluent-crm")]})]})]})]})})},save:()=>null});const Ao=window.wp.editor,Lo=Object.freeze({LAYOUT_CHANGE:"EDITOR_LAYOUT_CHANGE",FULLSCREEN_TOGGLE:"EDITOR_FULLSCREEN_TOGGLE",OPEN_EMAIL_PREVIEW:"EDITOR_OPEN_EMAIL_PREVIEW",OPEN_TEMPLATES:"EDITOR_OPEN_TEMPLATES",OPEN_SAVE_TEMPLATE:"EDITOR_OPEN_SAVE_TEMPLATE",SAVE_DRAFT:"EDITOR_SAVE_DRAFT",BACK:"EDITOR_BACK",NEXT:"EDITOR_NEXT",RECOVERY_NOTICE:"EDITOR_RECOVERY_NOTICE",STYLE_CONFIG_CHANGE:"EDITOR_STYLE_CONFIG_CHANGE",FOOTER_SETTINGS_CHANGE:"EDITOR_FOOTER_SETTINGS_CHANGE"}),Po=Object.freeze({LAYOUT_SYNC:"LAYOUT_SYNC",UPDATE_EDITOR:"UPDATE_EDITOR",STYLE_CONFIG_SYNC:"STYLE_CONFIG_SYNC",FOOTER_SETTINGS_SYNC:"FOOTER_SETTINGS_SYNC",INSERT_SMARTCODE:"INSERT_SMARTCODE"}),Bo=(e,t={})=>{window.parent&&window.parent.postMessage({action:e,...t},"*")},Ro=e=>!(!e||e.action!==Po.LAYOUT_SYNC||"string"!=typeof e.design_template),zo=e=>!(!e||e.action!==Po.STYLE_CONFIG_SYNC||!e.template_config||"object"!=typeof e.template_config),Ho=(e,t)=>{if("undefined"==typeof window)return()=>{};const n=(()=>{const e=window.fcrmEditorBoot||{},t=e.parent_origin||e.parentOrigin||"";if(t)try{return new URL(String(t),window.location.origin).origin}catch(e){}try{if(document.referrer)return new URL(document.referrer).origin}catch(e){}return window.location.origin})(),o=o=>{if(!window.parent||o.source!==window.parent)return;if(!o.origin||o.origin!==n)return;const r=(e=>e&&"object"==typeof e&&e.data?e.data:null)(o);r&&("function"!=typeof e||e(r,o))&&t(r,o)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},Oo=/%(\d*)s|%d/g;function Fo(e,...t){return function(e,t=[]){if(!t.length)return e;let n=0;return String(e).replace(Oo,(e,o)=>{if(o){const n=parseInt(o,10)-1;return n