PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | assets/PricingTableBlockEditor.js +1 -1 1.6.3 → 1.6.5 View file →
@@ -1,2 +1,2 @@
1 -import{b as t,j as e}from"./chunks/BlockEditorTranslator.js?ver=1.6.3";import"./chunks/index6.js?ver=1.6.3";import{a as L,C as K,D as M}from"./chunks/Icons.js?ver=1.6.3";import{E as H}from"./chunks/ProductListItem.js?ver=1.6.3";import{S as W}from"./chunks/SelectVariationModal.js?ver=1.6.3";import{a as A}from"./chunks/index5.js?ver=1.6.3";import{C as k}from"./chunks/ColorPickerField.js?ver=1.6.3";import{E as _}from"./chunks/EditorPanel.js?ver=1.6.3";import{C as U}from"./chunks/CustomSelect.js?ver=1.6.3";import{a as X}from"./chunks/add-query-args.js?ver=1.6.3";const $={generalColors:{"--fluent-cart-pricing-table-primary-color":{value:"",label:t("Primary Color")},"--fluent-cart-pricing-table-card-title-color":{value:"",label:t("Title Color")},"--fluent-cart-pricing-table-card-sub-title-color":{value:"",label:t("Subtitle Color")},"--fluent-cart-pricing-table-card-feature-color":{value:"",label:t("Text Color")},"--fluent-cart-pricing-table-border-color":{value:"",label:t("Border Color")},"--fluent-cart-pricing-table-divider-color":{value:"",label:t("Divider Color")}},badgeColors:{"--fluent-cart-pricing-table-badge-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-badge-color":{value:"",label:t("Text Color")}},cardColors:{"--fluent-cart-pricing-table-card-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-card-active-bg":{value:"",label:t("Active BG")},"--fluent-cart-pricing-table-card-title-color":{value:"",label:t("Title Color")},"--fluent-cart-pricing-table-card-sub-title-color":{value:"",label:t("Subtitle Color")},"--fluent-cart-pricing-table-card-payment-type-color":{value:"",label:t("Payment Type Color")},"--fluent-cart-pricing-table-card-price-color":{value:"",label:t("Price Color")},"--fluent-cart-pricing-table-card-repeat-interval-color":{value:"",label:t("Repeat Interval Color")},"--fluent-cart-pricing-table-card-compare-price-color":{value:"",label:t("Compare Price Color")},"--fluent-cart-pricing-table-card-feature-color":{value:"",label:t("Feature List Color")},"--fluent-cart-pricing-table-card-feature-icon-color":{value:"",label:t("Icon Color")}},tabColors:{"--fluent-cart-pricing-table-tab-nav-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-tab-nav-active-bg":{value:"",label:t("Active BG")},"--fluent-cart-pricing-table-tab-nav-border":{value:"",label:t("Border Color")},"--fluent-cart-pricing-table-tab-nav-color":{value:"",label:t("Text Color")},"--fluent-cart-pricing-table-tab-nav-active-color":{value:"",label:t("Active Text Color")}}},{InspectorControls:z}=wp.blockEditor,{ToggleControl:R,TextControl:P,Button:Q,RangeControl:J,Tooltip:Y}=wp.components,Z=r=>{const{attributes:a,setAttributes:b,onChangeVariationGroup:B}=r,T=Object.entries(a.colors.badgeColors),V=Object.entries(a.colors.cardColors),O=Object.entries(a.colors.generalColors),D=Object.entries(a.colors.tabColors),C=$,N=(o,i)=>{b({badge:{...a.badge,[o]:i}})},x=(o,i,p)=>{b({colors:{...a.colors,[p]:{...a.colors[p],[o]:{...a.colors[p][o],value:i}}}})},E=()=>{const o={};Object.keys(C).forEach(i=>{o[i]={},Object.keys(C[i]).forEach(p=>{o[i][p]={...C[i][p],value:""}})}),b({colors:o})},w=o=>{b({group_by:o}),B(a.variationsData,o)},y=o=>{b({product_per_row:o})},S=(o,i)=>{b({buttonOptions:{...a.buttonOptions,[o]:i}})};return e.jsx(z,{children:e.jsxs("div",{className:"fct-inspector-control-wrap",children:[e.jsxs("div",{className:"fct-inspector-control-group",children:[e.jsx("div",{className:"fct-inspector-control-heading",children:t("Grouping")}),e.jsxs("div",{className:"fct-inspector-control-body",children:[e.jsx("div",{className:"fct-inspector-control-settings",children:e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Price Grouping")}),e.jsx(U,{customKeys:{key:"value",label:"label"},defaultValue:a.group_by,options:[{label:t("Repeat Interval"),value:"repeat_interval"},{label:t("Payment Type"),value:"payment_type"},{label:t("None"),value:"none"}],onChange:function(o){w(o)}})]})}),e.jsx("div",{className:"fct-inspector-control-settings",children:e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Product Per Row")}),e.jsx(J,{value:a.product_per_row,onChange:y,min:0,max:5})]})})]})]}),e.jsxs("div",{className:"fct-inspector-control-group",children:[e.jsxs("div",{className:"fct-inspector-control-heading",children:[t("Settings"),e.jsx("div",{className:"fct-reset-button-wrap",children:e.jsx(Y,{text:t("Reset Colors"),delay:100,children:e.jsx(Q,{onClick:E,icon:"update",size:"small"})})})]}),e.jsxs("div",{className:"fct-inspector-control-body",children:[e.jsx(_,{title:t("General"),children:e.jsx("div",{className:"fct-inspector-control-settings",children:O.map(([o,{value:i,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:i,onChange:n=>x(o,n,"generalColors")})},h))})}),e.jsx(_,{title:t("Button"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show Checkout Button")}),e.jsx(R,{checked:a.show_checkout_button,onChange:o=>{b({show_checkout_button:o})}})]}),a.show_checkout_button&&e.jsxs("div",{children:[e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Checkout Button Text")}),e.jsx(P,{value:a.buttonOptions.text,onChange:o=>S("text",o)})]}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Button Url Params")}),e.jsx(P,{value:a.checkout_button_url_params,onChange:o=>b({checkout_button_url_params:o})}),e.jsx("div",{className:"fct-inspector-control-hint",children:t("Add any query params you want to pass to the checkout page. eg: utm_source=google&utm_medium=cpc")})]})]}),e.jsx("hr",{}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show Cart Button")}),e.jsx(R,{checked:a.show_cart_button,onChange:o=>{b({show_cart_button:o})}})]}),a.show_cart_button&&e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Cart Button Text")}),e.jsx(P,{value:a.buttonOptions.cartButtonText,onChange:o=>S("cartButtonText",o)}),e.jsx("div",{className:"fct-inspector-control-hint",children:t("Add to cart button only will show for non subscription product")})]})]})}),e.jsx(_,{title:t("Badge"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Text")}),e.jsx(P,{value:a.badge.text,onChange:o=>N("text",o)})]}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Position")}),e.jsx(U,{options:[{label:t("Center"),value:"center"},{label:t("Right"),value:"right"},{label:t("Left"),value:"left"}],defaultValue:a.badge.position,onChange:o=>N("position",o),customKeys:{key:"value",label:"label"}})]}),T.map(([o,{value:i,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:i,onChange:n=>x(o,n,"badgeColors")})},h))]})}),e.jsx(_,{title:t("Card"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show/Hide Icon")}),e.jsx(R,{checked:a.iconVisibility,onChange:o=>{b({iconVisibility:o})}})]}),V.map(([o,{value:i,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:i,onChange:n=>x(o,n,"cardColors")})},h))]})}),e.jsx(_,{title:t("Tab"),children:e.jsx("div",{className:"fct-inspector-control-settings",children:D.map(([o,{value:i,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:i,onChange:n=>x(o,n,"tabColors")})},h))})})]})]})]})})},ee=""+new URL("assets/PricingTable.png",import.meta.url).href,{InspectorControls:me}=wp.editor,{registerBlockType:te}=wp.blocks,I=window.fluent_cart_product_pricing_table_data,q=window.fluentCartRestVars.rest,F=q.url+"/products/variants/",{TextControl:oe}=wp.components,{useEffect:ae,useState:G}=wp.element,{useBlockProps:ne}=wp.blockEditor,{Button:le}=wp.components;te(I.slug+"/"+I.name,{apiVersion:3,icon:{src:L},example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:ee,alt:"Pricing Table Preview",style:{width:"100%",height:"auto"}}}]},category:"fluent-cart",title:I.title,attributes:{variations:[],show_cart_button:{type:"boolean",default:!0},show_checkout_button:{type:"boolean",default:!0},primary_variation:{type:"int",default:null},group_by:{type:"string",default:"repeat_interval"},product_per_row:{type:"number",default:0},active_variant:{type:"object",default:{}},active_tab:{type:"number",default:0},variationsData:{type:[Array,Object],default:[]},tabContent:{type:"array",default:[]},badge:{type:"object",default:{text:t("Recommended"),position:"right"}},colors:{type:"object",default:$},buttonOptions:{type:"object",default:{text:"",cartButtonText:""}},checkout_button_url_params:{type:"string",default:""},iconVisibility:{type:Boolean,default:!0}},edit:({attributes:r,setAttributes:a})=>{var p,h;const b=ne();ae(()=>{C()},[]);let B={variant_ids:r.variations,select:["id","other_info","variation_title"],per_page:10,page:1,order_by:"ID",order_type:"DESC"};const[T,V]=G({}),[O,D]=G({}),C=()=>{A({path:X(F,{params:B}),headers:{"X-WP-Nonce":q.nonce}}).then(n=>{const s=n.variants.reduce((d,c)=>(d[c.id]={other_info:c.other_info,variation_title:c.variation_title},d),{});V(s),a({variationsData:s}),y(s)}).finally(()=>{})},N=(n,l)=>{o(!0),wp.data.dispatch("core/editor").savePost(),A({path:F+n+"/pricing-table",method:"PUT",data:{description:l.other_info.description},headers:{"X-WP-Nonce":fluentCartRestVars.rest.nonce}}).then(s=>{}).finally(()=>{})},x=n=>{var u;let l={...r.variationsData};l.hasOwnProperty(n)&&delete l[n],a({variationsData:{...l}}),a({variations:Object.keys(l)});const{active_tab:s,tabContent:d}=r,c=[...d];if(c[s]){const m=c[s];(u=m.content)!=null&&u[n]&&(delete m.content[n],Object.keys(m.content).length===0?c.splice(s,1):c[s]={...m,content:{...m.content}},a({tabContent:c}),c.length===0?a({active_tab:0,active_variant:{},tabContent:[]}):s>=c.length&&a({active_tab:0}))}},E=[{key:"daily",value:"daily"},{key:"weekly",value:"weekly"},{key:"monthly",value:"monthly"},{key:"quarterly",value:"quarterly"},{key:"half_yearly",value:"half_yearly"},{key:"yearly",value:"yearly"},{key:"onetime",value:"onetime"},{key:"subscription",value:"subscription"},{key:"installment",value:"installment"}],w=n=>{const l=E.find(s=>s.key===n);return l?l.value:"onetime"},y=(n,l=r.group_by)=>{let s={},d="repeat_interval",c=n;l==="payment_type"?d="payment_type":l==="none"&&(d="onetime"),l!=="none"?Object.entries(c).forEach(([f,g])=>{let v=g.other_info[d]||"onetime";g.other_info.installment==="yes"&&(v="installment"),s[v]=w(v)}):s.onetime=w("onetime");const u=Object.entries(c).reduce((f,[g,v])=>{let j=v.other_info[d]||"onetime";return v.other_info.installment==="yes"&&(j="installment"),f[j]||(f[j]={}),f[j][g]={id:g,other_info:v.other_info,variation_title:v.variation_title},f},{}),m=Array.isArray(u)?u:Object.keys(u).map(f=>({title:f,content:Object.entries(u[f]).reduce((g,[v,j])=>(g[v]={id:v,...j},g),{})}));return Object.keys(s).length===1&&a({active_tab:0}),a({tabContent:m})},[S,o]=G(!1),i=n=>{D(l=>{const s=Object.keys(l).reduce((d,c)=>(d[c]=!1,d),{});return s[n]=!l[n],s})};return e.jsx("div",{...b,children:e.jsxs("div",{className:"py-4",children:[e.jsx(Z,{attributes:r,setAttributes:a,onChangeVariationGroup:y}),e.jsxs("div",{className:"fluent-cart-pricing-table-block-editor",children:[e.jsx("div",{className:"fluent-cart-pricing-table-block-editor-head",children:e.jsx(W,{setAttributes:a,preSelectedVariations:T,onModalClosed:n=>{let l={...n};a({variationsData:{...l}}),a({variations:Object.keys(l)}),y(l)}})}),e.jsx("div",{className:"fluent-cart-pricing-table-block-editor-body",children:Object.keys(((p=r.tabContent[r.active_tab])==null?void 0:p.content)||{}).length>0?e.jsxs("div",{className:"fct-custom-tabs",children:[r.tabContent.length>1&&e.jsx("div",{className:"fct-tab-header",children:Array.isArray(r.tabContent)&&r.tabContent.map((n,l)=>e.jsx(le,{isPrimary:r.active_tab===l,onClick:()=>a({active_tab:l}),children:n.title},l))}),e.jsx("div",{className:"fct-tab-content",children:Array.isArray(r.tabContent)&&r.tabContent[r.active_tab]&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fct-tab-content-inner",children:[e.jsx("div",{className:"fct-active-product-select-container",children:e.jsxs("div",{className:"fct-form-group",children:[e.jsx("label",{children:t("Recommended variant")}),(()=>{var s,d;const n=r.tabContent[r.active_tab],l=(n==null?void 0:n.title)||"";return e.jsx(e.Fragment,{children:e.jsx(U,{customKeys:{key:"value",label:"label"},options:Object.keys(((s=r.tabContent[r.active_tab])==null?void 0:s.content)||{}).map(c=>{var u,m;return{value:c,label:((m=(u=r.tabContent[r.active_tab])==null?void 0:u.content[c])==null?void 0:m.variation_title)||c}}),defaultValue:((d=r.active_variant)==null?void 0:d[l])||null,name:l,onChange:c=>{const u={...r.active_variant};c===null||Array.isArray(c)&&c.length===0?delete u[l]:u[l]=c,a({active_variant:u})}},l)})})()]})}),e.jsx("div",{className:"fct-selected-products-container",children:Object.keys(((h=r.tabContent[r.active_tab])==null?void 0:h.content)||{}).map(n=>{var d;const l=((d=r.tabContent[r.active_tab])==null?void 0:d.content[n])||{},s=O[n];return e.jsxs("div",{className:"fct-selected-product",children:[e.jsx("div",{className:`fct-selected-product-toggle ${s?"is-expanded":""}`,onClick:()=>i(n),children:e.jsx("div",{className:"icon",children:e.jsx(K,{})})}),e.jsxs("div",{className:"fct-selected-product-contents",children:[e.jsx("div",{className:"product-title",title:l.variation_title,children:l.variation_title}),e.jsxs("div",{className:"product-id",children:["#",n]}),e.jsx("div",{className:`product-textarea ${s?"is-expanded":""}`,children:e.jsxs("div",{className:"product-textarea-inner",children:[e.jsx("textarea",{placeholder:t("Variants features..."),defaultValue:l.other_info.description||"",onBlur:c=>{l.other_info.description=c.target.value.replace(/\r?\n/g,`
1 +import{j as e}from"./chunks/jsx-runtime.js?ver=1.6.5";import"./chunks/index6.js?ver=1.6.5";import{a as L,C as K,D as M}from"./chunks/Icons.js?ver=1.6.5";import{E as H}from"./chunks/ProductListItem.js?ver=1.6.5";import{S as W}from"./chunks/SelectVariationModal.js?ver=1.6.5";import{a as A}from"./chunks/index5.js?ver=1.6.5";import{C as k}from"./chunks/ColorPickerField.js?ver=1.6.5";import{E as _}from"./chunks/EditorPanel.js?ver=1.6.5";import{b as t}from"./chunks/BlockEditorTranslator.js?ver=1.6.5";import{C as U}from"./chunks/CustomSelect.js?ver=1.6.5";import{a as X}from"./chunks/add-query-args.js?ver=1.6.5";const $={generalColors:{"--fluent-cart-pricing-table-primary-color":{value:"",label:t("Primary Color")},"--fluent-cart-pricing-table-card-title-color":{value:"",label:t("Title Color")},"--fluent-cart-pricing-table-card-sub-title-color":{value:"",label:t("Subtitle Color")},"--fluent-cart-pricing-table-card-feature-color":{value:"",label:t("Text Color")},"--fluent-cart-pricing-table-border-color":{value:"",label:t("Border Color")},"--fluent-cart-pricing-table-divider-color":{value:"",label:t("Divider Color")}},badgeColors:{"--fluent-cart-pricing-table-badge-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-badge-color":{value:"",label:t("Text Color")}},cardColors:{"--fluent-cart-pricing-table-card-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-card-active-bg":{value:"",label:t("Active BG")},"--fluent-cart-pricing-table-card-title-color":{value:"",label:t("Title Color")},"--fluent-cart-pricing-table-card-sub-title-color":{value:"",label:t("Subtitle Color")},"--fluent-cart-pricing-table-card-payment-type-color":{value:"",label:t("Payment Type Color")},"--fluent-cart-pricing-table-card-price-color":{value:"",label:t("Price Color")},"--fluent-cart-pricing-table-card-repeat-interval-color":{value:"",label:t("Repeat Interval Color")},"--fluent-cart-pricing-table-card-compare-price-color":{value:"",label:t("Compare Price Color")},"--fluent-cart-pricing-table-card-feature-color":{value:"",label:t("Feature List Color")},"--fluent-cart-pricing-table-card-feature-icon-color":{value:"",label:t("Icon Color")}},tabColors:{"--fluent-cart-pricing-table-tab-nav-bg":{value:"",label:t("Background")},"--fluent-cart-pricing-table-tab-nav-active-bg":{value:"",label:t("Active BG")},"--fluent-cart-pricing-table-tab-nav-border":{value:"",label:t("Border Color")},"--fluent-cart-pricing-table-tab-nav-color":{value:"",label:t("Text Color")},"--fluent-cart-pricing-table-tab-nav-active-color":{value:"",label:t("Active Text Color")}}},{InspectorControls:z}=wp.blockEditor,{ToggleControl:R,TextControl:P,Button:Q,RangeControl:J,Tooltip:Y}=wp.components,Z=r=>{const{attributes:a,setAttributes:b,onChangeVariationGroup:B}=r,T=Object.entries(a.colors.badgeColors),V=Object.entries(a.colors.cardColors),O=Object.entries(a.colors.generalColors),D=Object.entries(a.colors.tabColors),C=$,N=(o,s)=>{b({badge:{...a.badge,[o]:s}})},x=(o,s,p)=>{b({colors:{...a.colors,[p]:{...a.colors[p],[o]:{...a.colors[p][o],value:s}}}})},E=()=>{const o={};Object.keys(C).forEach(s=>{o[s]={},Object.keys(C[s]).forEach(p=>{o[s][p]={...C[s][p],value:""}})}),b({colors:o})},w=o=>{b({group_by:o}),B(a.variationsData,o)},y=o=>{b({product_per_row:o})},S=(o,s)=>{b({buttonOptions:{...a.buttonOptions,[o]:s}})};return e.jsx(z,{children:e.jsxs("div",{className:"fct-inspector-control-wrap",children:[e.jsxs("div",{className:"fct-inspector-control-group",children:[e.jsx("div",{className:"fct-inspector-control-heading",children:t("Grouping")}),e.jsxs("div",{className:"fct-inspector-control-body",children:[e.jsx("div",{className:"fct-inspector-control-settings",children:e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Price Grouping")}),e.jsx(U,{customKeys:{key:"value",label:"label"},defaultValue:a.group_by,options:[{label:t("Repeat Interval"),value:"repeat_interval"},{label:t("Payment Type"),value:"payment_type"},{label:t("None"),value:"none"}],onChange:function(o){w(o)}})]})}),e.jsx("div",{className:"fct-inspector-control-settings",children:e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Product Per Row")}),e.jsx(J,{value:a.product_per_row,onChange:y,min:0,max:5})]})})]})]}),e.jsxs("div",{className:"fct-inspector-control-group",children:[e.jsxs("div",{className:"fct-inspector-control-heading",children:[t("Settings"),e.jsx("div",{className:"fct-reset-button-wrap",children:e.jsx(Y,{text:t("Reset Colors"),delay:100,children:e.jsx(Q,{onClick:E,icon:"update",size:"small"})})})]}),e.jsxs("div",{className:"fct-inspector-control-body",children:[e.jsx(_,{title:t("General"),children:e.jsx("div",{className:"fct-inspector-control-settings",children:O.map(([o,{value:s,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:s,onChange:n=>x(o,n,"generalColors")})},h))})}),e.jsx(_,{title:t("Button"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show Checkout Button")}),e.jsx(R,{checked:a.show_checkout_button,onChange:o=>{b({show_checkout_button:o})}})]}),a.show_checkout_button&&e.jsxs("div",{children:[e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Checkout Button Text")}),e.jsx(P,{value:a.buttonOptions.text,onChange:o=>S("text",o)})]}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Button Url Params")}),e.jsx(P,{value:a.checkout_button_url_params,onChange:o=>b({checkout_button_url_params:o})}),e.jsx("div",{className:"fct-inspector-control-hint",children:t("Add any query params you want to pass to the checkout page. eg: utm_source=google&utm_medium=cpc")})]})]}),e.jsx("hr",{}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show Cart Button")}),e.jsx(R,{checked:a.show_cart_button,onChange:o=>{b({show_cart_button:o})}})]}),a.show_cart_button&&e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Cart Button Text")}),e.jsx(P,{value:a.buttonOptions.cartButtonText,onChange:o=>S("cartButtonText",o)}),e.jsx("div",{className:"fct-inspector-control-hint",children:t("Add to cart button only will show for non subscription product")})]})]})}),e.jsx(_,{title:t("Badge"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Text")}),e.jsx(P,{value:a.badge.text,onChange:o=>N("text",o)})]}),e.jsxs("div",{className:"fct-inspector-control-row flex-col",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Position")}),e.jsx(U,{options:[{label:t("Center"),value:"center"},{label:t("Right"),value:"right"},{label:t("Left"),value:"left"}],defaultValue:a.badge.position,onChange:o=>N("position",o),customKeys:{key:"value",label:"label"}})]}),T.map(([o,{value:s,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:s,onChange:n=>x(o,n,"badgeColors")})},h))]})}),e.jsx(_,{title:t("Card"),children:e.jsxs("div",{className:"fct-inspector-control-settings",children:[e.jsxs("div",{className:"fct-inspector-control-row",children:[e.jsx("div",{className:"fct-inspector-control-label",children:t("Show/Hide Icon")}),e.jsx(R,{checked:a.iconVisibility,onChange:o=>{b({iconVisibility:o})}})]}),V.map(([o,{value:s,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:s,onChange:n=>x(o,n,"cardColors")})},h))]})}),e.jsx(_,{title:t("Tab"),children:e.jsx("div",{className:"fct-inspector-control-settings",children:D.map(([o,{value:s,label:p}],h)=>e.jsx("div",{className:"fct-inspector-control-row",children:e.jsx(k,{label:p,value:s,onChange:n=>x(o,n,"tabColors")})},h))})})]})]})]})})},ee=""+new URL("assets/PricingTable.png",import.meta.url).href,{InspectorControls:fe}=wp.editor,{registerBlockType:te}=wp.blocks,I=window.fluent_cart_product_pricing_table_data,q=window.fluentCartRestVars.rest,F=q.url+"/products/variants/",{TextControl:oe}=wp.components,{useEffect:ae,useState:G}=wp.element,{useBlockProps:ne}=wp.blockEditor,{Button:le}=wp.components;te(I.slug+"/"+I.name,{apiVersion:3,icon:{src:L},example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:ee,alt:"Pricing Table Preview",style:{width:"100%",height:"auto"}}}]},category:"fluent-cart",title:I.title,attributes:{variations:[],show_cart_button:{type:"boolean",default:!0},show_checkout_button:{type:"boolean",default:!0},primary_variation:{type:"int",default:null},group_by:{type:"string",default:"repeat_interval"},product_per_row:{type:"number",default:0},active_variant:{type:"object",default:{}},active_tab:{type:"number",default:0},variationsData:{type:[Array,Object],default:[]},tabContent:{type:"array",default:[]},badge:{type:"object",default:{text:t("Recommended"),position:"right"}},colors:{type:"object",default:$},buttonOptions:{type:"object",default:{text:"",cartButtonText:""}},checkout_button_url_params:{type:"string",default:""},iconVisibility:{type:Boolean,default:!0}},edit:({attributes:r,setAttributes:a})=>{var p,h;const b=ne();ae(()=>{C()},[]);let B={variant_ids:r.variations,select:["id","other_info","variation_title"],per_page:10,page:1,order_by:"ID",order_type:"DESC"};const[T,V]=G({}),[O,D]=G({}),C=()=>{A({path:X(F,{params:B}),headers:{"X-WP-Nonce":q.nonce}}).then(n=>{const i=n.variants.reduce((d,c)=>(d[c.id]={other_info:c.other_info,variation_title:c.variation_title},d),{});V(i),a({variationsData:i}),y(i)}).finally(()=>{})},N=(n,l)=>{o(!0),wp.data.dispatch("core/editor").savePost(),A({path:F+n+"/pricing-table",method:"PUT",data:{description:l.other_info.description},headers:{"X-WP-Nonce":fluentCartRestVars.rest.nonce}}).then(i=>{}).finally(()=>{})},x=n=>{var u;let l={...r.variationsData};l.hasOwnProperty(n)&&delete l[n],a({variationsData:{...l}}),a({variations:Object.keys(l)});const{active_tab:i,tabContent:d}=r,c=[...d];if(c[i]){const m=c[i];(u=m.content)!=null&&u[n]&&(delete m.content[n],Object.keys(m.content).length===0?c.splice(i,1):c[i]={...m,content:{...m.content}},a({tabContent:c}),c.length===0?a({active_tab:0,active_variant:{},tabContent:[]}):i>=c.length&&a({active_tab:0}))}},E=[{key:"daily",value:"daily"},{key:"weekly",value:"weekly"},{key:"monthly",value:"monthly"},{key:"quarterly",value:"quarterly"},{key:"half_yearly",value:"half_yearly"},{key:"yearly",value:"yearly"},{key:"onetime",value:"onetime"},{key:"subscription",value:"subscription"},{key:"installment",value:"installment"}],w=n=>{const l=E.find(i=>i.key===n);return l?l.value:"onetime"},y=(n,l=r.group_by)=>{let i={},d="repeat_interval",c=n;l==="payment_type"?d="payment_type":l==="none"&&(d="onetime"),l!=="none"?Object.entries(c).forEach(([f,g])=>{let v=g.other_info[d]||"onetime";g.other_info.installment==="yes"&&(v="installment"),i[v]=w(v)}):i.onetime=w("onetime");const u=Object.entries(c).reduce((f,[g,v])=>{let j=v.other_info[d]||"onetime";return v.other_info.installment==="yes"&&(j="installment"),f[j]||(f[j]={}),f[j][g]={id:g,other_info:v.other_info,variation_title:v.variation_title},f},{}),m=Array.isArray(u)?u:Object.keys(u).map(f=>({title:f,content:Object.entries(u[f]).reduce((g,[v,j])=>(g[v]={id:v,...j},g),{})}));return Object.keys(i).length===1&&a({active_tab:0}),a({tabContent:m})},[S,o]=G(!1),s=n=>{D(l=>{const i=Object.keys(l).reduce((d,c)=>(d[c]=!1,d),{});return i[n]=!l[n],i})};return e.jsx("div",{...b,children:e.jsxs("div",{className:"py-4",children:[e.jsx(Z,{attributes:r,setAttributes:a,onChangeVariationGroup:y}),e.jsxs("div",{className:"fluent-cart-pricing-table-block-editor",children:[e.jsx("div",{className:"fluent-cart-pricing-table-block-editor-head",children:e.jsx(W,{setAttributes:a,preSelectedVariations:T,onModalClosed:n=>{let l={...n};a({variationsData:{...l}}),a({variations:Object.keys(l)}),y(l)}})}),e.jsx("div",{className:"fluent-cart-pricing-table-block-editor-body",children:Object.keys(((p=r.tabContent[r.active_tab])==null?void 0:p.content)||{}).length>0?e.jsxs("div",{className:"fct-custom-tabs",children:[r.tabContent.length>1&&e.jsx("div",{className:"fct-tab-header",children:Array.isArray(r.tabContent)&&r.tabContent.map((n,l)=>e.jsx(le,{isPrimary:r.active_tab===l,onClick:()=>a({active_tab:l}),children:n.title},l))}),e.jsx("div",{className:"fct-tab-content",children:Array.isArray(r.tabContent)&&r.tabContent[r.active_tab]&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fct-tab-content-inner",children:[e.jsx("div",{className:"fct-active-product-select-container",children:e.jsxs("div",{className:"fct-form-group",children:[e.jsx("label",{children:t("Recommended variant")}),(()=>{var i,d;const n=r.tabContent[r.active_tab],l=(n==null?void 0:n.title)||"";return e.jsx(e.Fragment,{children:e.jsx(U,{customKeys:{key:"value",label:"label"},options:Object.keys(((i=r.tabContent[r.active_tab])==null?void 0:i.content)||{}).map(c=>{var u,m;return{value:c,label:((m=(u=r.tabContent[r.active_tab])==null?void 0:u.content[c])==null?void 0:m.variation_title)||c}}),defaultValue:((d=r.active_variant)==null?void 0:d[l])||null,name:l,onChange:c=>{const u={...r.active_variant};c===null||Array.isArray(c)&&c.length===0?delete u[l]:u[l]=c,a({active_variant:u})}},l)})})()]})}),e.jsx("div",{className:"fct-selected-products-container",children:Object.keys(((h=r.tabContent[r.active_tab])==null?void 0:h.content)||{}).map(n=>{var d;const l=((d=r.tabContent[r.active_tab])==null?void 0:d.content[n])||{},i=O[n];return e.jsxs("div",{className:"fct-selected-product",children:[e.jsx("div",{className:`fct-selected-product-toggle ${i?"is-expanded":""}`,onClick:()=>s(n),children:e.jsx("div",{className:"icon",children:e.jsx(K,{})})}),e.jsxs("div",{className:"fct-selected-product-contents",children:[e.jsx("div",{className:"product-title",title:l.variation_title,children:l.variation_title}),e.jsxs("div",{className:"product-id",children:["#",n]}),e.jsx("div",{className:`product-textarea ${i?"is-expanded":""}`,children:e.jsxs("div",{className:"product-textarea-inner",children:[e.jsx("textarea",{placeholder:t("Variants features..."),defaultValue:l.other_info.description||"",onBlur:c=>{l.other_info.description=c.target.value.replace(/\r?\n/g,`
2 2 `),N(n,l)}}),e.jsxs("div",{className:"hint-text",children:[e.jsx("strong",{children:t("Hint: ")}),t("Use Enter to add line breaks for a list format")]}),e.jsxs("div",{className:"product-url-params-inner",children:[e.jsx("div",{className:"product-title",children:t("Button Url Params")}),e.jsx(oe,{value:r.checkout_button_url_params,onChange:c=>a({checkout_button_url_params:c})}),e.jsx("div",{className:"fct-inspector-control-hint",children:t("Add any query params you want to pass to the checkout page. eg: utm_source=google&utm_medium=cpc")})]})]})})]}),e.jsx("div",{className:"product-delete-icon",onClick:()=>{x(n)},title:t("Delete"),children:e.jsx(M,{})})]},`variations-${l.id}`)})})]})})})]}):e.jsx(H,{text:t("Find products to make a pricing table")})})]})]})})},save:function(r){return null}});