!function(t){if(t&&t.blocks&&t.blockEditor&&t.components&&t.element&&t.i18n){var n,e=t.blocks.registerBlockType,i=t.blockEditor,o=t.components,l=t.element,s=t.i18n,r=i.InspectorControls,a=i.InnerBlocks,c=i.useBlockProps,u=o.PanelBody,_=o.SelectControl,f=o.FormTokenField,d=o.Notice,g=l.createElement,h=l.Fragment,m=l.useMemo,w=l.useEffect,p=s.__,x=window.fcrmConditionalContentConfig||{},v=!!x.hasPro,y=g("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},g("rect",{x:1,y:1,width:22,height:22,rx:5,fill:"#6E41E2"}),g("path",{d:"M6 9.8L18.4 6.4L17.6 9.3L7.8 12L6 9.8Z",fill:"#FFFFFF"}),g("path",{d:"M7.5 14.2L16.5 11.8L15.8 14.6L9.3 16.4L7.5 14.2Z",fill:"#FFFFFF"})),b=(n=x.tags||[],Array.isArray(n)?n.map(function(t){return{id:String(t.id||""),title:String(t.title||"").trim()}}).filter(function(t){return!!t.id&&!!t.title}):[]);e("fluent-crm/conditional-content",{apiVersion:3,title:p("Conditional Content","fluent-crm"),description:p("Show or hide content based on contact tags or visitor login state.","fluent-crm"),category:"widgets",icon:y,keywords:[p("conditional","fluent-crm"),p("visibility","fluent-crm"),p("fluentcrm","fluent-crm")],supports:{align:["wide","full"],anchor:!0,html:!1},attributes:{condition_type:{type:"string",default:"show_if_tag_exist"},tag_ids:{type:"array",default:[]}},edit:function(t){var n,e,i=t.attributes,o=t.setAttributes,l=(n=i.condition_type||"show_if_tag_exist",(e=String(n).trim())?{show_if_logged_in:"show_if_user_logged_in",show_if_public_users:"show_if_user_not_logged_in",show_if_tag_exists:"show_if_tag_exist",show_if_tag_not_exists:"show_if_tag_not_exist"}[e]||e:"show_if_tag_exist"),s=Array.isArray(i.tag_ids)?i.tag_ids.map(String):[],x="show_if_tag_exist"===l||"show_if_tag_not_exist"===l;w(function(){(i.condition_type||"")!==l&&o({condition_type:l})},[i.condition_type,l]);var y=m(function(){var t={};return b.forEach(function(n){t[n.id]=n.title}),t},[]),S=m(function(){var t={};return b.forEach(function(n){t[n.title]=n.id}),t},[]),F=m(function(){return s.map(function(t){return y[t]||t})},[s,y]),C=m(function(){return b.map(function(t){return t.title})},[]),k=c({className:"fc-cond-section",style:{backgroundColor:"#fff8d9",border:"1px solid #f1d676",borderRadius:"6px",padding:"12px"}});return g(h,null,g(r,null,g(u,{title:p("Conditional Settings","fluent-crm")},g(_,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:p("Condition Type","fluent-crm"),value:l,onChange:function(t){var n=t||"show_if_tag_exist";o({condition_type:n,tag_ids:"show_if_tag_exist"===n||"show_if_tag_not_exist"===n?s:[]})},options:[{value:"show_if_tag_exist",label:p("Show if in selected tags","fluent-crm")},{value:"show_if_tag_not_exist",label:p("Show if not in selected tags","fluent-crm")},{value:"show_if_user_logged_in",label:p("Show if user is logged in","fluent-crm")},{value:"show_if_user_not_logged_in",label:p("Show if user is not logged in","fluent-crm")}]}),v?x?g(f,{label:p("Tags","fluent-crm"),value:F,suggestions:C,onChange:function(t){if(v){var n=t.map(function(t){return S[t]}).filter(Boolean);o({tag_ids:n})}},__experimentalExpandOnFocus:!0,__experimentalAutoSelectFirstMatch:!0,__experimentalShowHowTo:!1,__next40pxDefaultSize:!0}):null:g(d,{status:"warning",isDismissible:!1},p("Conditional Content requires FluentCRM Pro.","fluent-crm")),g("div",{className:"components-base-control__help",style:{marginTop:"12px"}},g("strong",null,p("How conditions work","fluent-crm")),g("ul",{style:{margin:"8px 0 0 16px"}},g("li",null,p("Show if in selected tags: visible when contact has any selected tag.","fluent-crm")),g("li",null,p("Show if not in selected tags: hidden when contact has any selected tag.","fluent-crm")),g("li",null,p("Show if user is logged in: visible for logged-in visitors only.","fluent-crm")),g("li",null,p("Show if user is not logged in: visible for logged-out visitors only.","fluent-crm"))),g("p",{style:{margin:"8px 0 0"}},p("Yellow background is editor-only to identify conditional content.","fluent-crm"))))),g("div",k,g("div",{className:"fc-cond-blocks"},g(a,null))))},save:function(){var t=c.save({className:"fc-cond-section"});return g("div",t,g("div",{className:"fc-cond-blocks"},g(a.Content,null)))}})}}(window.wp);
