import{b as e,j as o}from"./chunks/BlockEditorTranslator.js?ver=1.3.17";import"./chunks/index4.js?ver=1.3.17";import"./chunks/SingleProductContext.js?ver=1.3.17";import{p,u as m,v as f}from"./chunks/Icons.js?ver=1.3.17";const{InspectorControls:h,PanelColorSettings:W,__experimentalColorGradientSettingsDropdown:b,__experimentalUseMultipleOriginColorsAndGradients:v}=wp.blockEditor,{PanelBody:S,CheckboxControl:$,RadioControl:k,ToggleControl:T,BaseControl:_,TextControl:G,__experimentalToggleGroupControl:E,__experimentalToggleGroupControlOption:B}=wp.components,{useState:z}=wp.element,N=E,i=B,O=b,I=v,P=({attributes:n,setAttributes:l,clientId:a})=>{const c=[{label:e("Icon","fluent-cart"),colorValue:n.icon_color,onColorChange:t=>l({icon_color:t})}];n.show_total_price&&c.push({label:e("Price","fluent-cart"),colorValue:n.price_color,onColorChange:t=>l({price_color:t})}),n.show_item_count!=="never"&&c.push({label:e("Product Count","fluent-cart"),colorValue:n.product_count_color,onColorChange:t=>l({product_count_color:t})});const s=I();return o.jsxs(o.Fragment,{children:[o.jsx(h,{group:"color",children:o.jsx(O,{panelId:a,settings:c,...s})}),o.jsx(h,{children:o.jsxs(S,{title:e("Settings","fluent-cart"),initialOpen:!0,children:[o.jsxs(N,{className:"fct-mini-cart-inspector-controls",isBlock:!0,label:e("Cart Icon","fluent-cart"),value:n.cart_icon,onChange:t=>l({cart_icon:t}),children:[o.jsx(i,{value:"cart",label:o.jsx(p,{})}),o.jsx(i,{value:"bag",label:o.jsx(m,{})}),o.jsx(i,{value:"bag-alt",label:o.jsx(f,{})})]}),o.jsx(G,{label:e("Or use custom icon URL","fluent-cart"),help:e("Leave empty to use the selected icon above. Enter a URL to override with a custom icon.","fluent-cart"),value:["cart","bag","bag-alt"].includes(n.cart_icon)?"":n.cart_icon,onChange:t=>l({cart_icon:t||"cart"}),placeholder:"https://example.com/icon.svg",type:"url"}),o.jsx(_,{label:e("Display options","fluent-cart"),children:o.jsx(T,{label:e("Display total price","fluent-cart"),help:e("Toggle to display the total price of the cart.","fluent-cart"),checked:n.show_total_price,onChange:t=>l({show_total_price:t})})}),o.jsx(_,{label:e("Show cart item count","fluent-cart"),help:e("The editor does not display the real count value, but a placeholder to indicate how it will look on the front-end.","fluent-cart"),children:o.jsx(k,{selected:n.show_item_count,options:[{label:e("Always (even if empty)","fluent-cart"),value:"always"},{label:e("Only if cart has items","fluent-cart"),value:"has_items"},{label:e("Never","fluent-cart"),value:"never"}],onChange:t=>l({show_item_count:t})})})]})})]})},{useBlockProps:R,RichText:H}=wp.blockEditor,{registerBlockType:D}=wp.blocks,{useEffect:q,useState:J}=wp.element,{useSelect:K}=wp.data,{store:Q}=wp.blockEditor,r=window.fluent_cart_mini_cart_data,V=window.fluentCartRestVars.rest;V.url+"";D(r.slug+"/"+r.name,{apiVersion:3,title:r.title,description:r.description,icon:{src:p},category:"fluent-cart",attributes:{cart_icon:{type:"string",default:"cart"},show_total_price:{type:"boolean",default:!0},show_item_count:{type:"string",default:"has_items"},icon_color:{type:"string",default:""},price_color:{type:"string",default:""},product_count_color:{type:"string",default:""}},supports:{html:!1,alignWide:!1,typography:{fontSize:!0,fontFamily:!0,fontWeight:!0,lineHeight:!0},spacing:{margin:!0,padding:!0},reusable:!1,shadow:!1},edit:({attributes:n,setAttributes:l,clientId:a})=>{const{cart_icon:c,show_total_price:s,show_item_count:t,icon_color:u,price_color:d,product_count_color:g}=n,x=R(),w=u?{color:u}:{},C=d?{color:d}:{},j=g?{backgroundColor:g}:{},y=c&&!["cart","bag","bag-alt"].includes(c);return o.jsxs("div",{...x,children:[o.jsx(P,{attributes:n,setAttributes:l,clientId:a}),o.jsxs("button",{className:"fct-mini-cart-button",children:[o.jsxs("span",{className:"fct-mini-cart-wrap",style:w,children:[y?o.jsx("img",{src:c,alt:"Mini cart icon",className:"fct-mini-cart-custom-icon",style:{width:"20px",height:"20px",objectFit:"contain"}}):c==="cart"?o.jsx(p,{}):c==="bag"?o.jsx(m,{}):o.jsx(f,{}),t!=="never"&&o.jsx("span",{className:"fct-mini-cart-badge",style:j,children:"0"})]}),s&&o.jsx("span",{className:"fct-mini-cart-amount",style:C,children:"$0.00"})]})]})},save:function(n){return null}});
