import{b as t,j as o}from"./chunks/BlockEditorTranslator.js?ver=1.5.0";import"./chunks/index5.js?ver=1.5.0";import"./chunks/SingleProductContext.js?ver=1.5.0";import{p as u,u as f,v as x}from"./chunks/Icons.js?ver=1.5.0";const{InspectorControls:_,PanelColorSettings:q,__experimentalColorGradientSettingsDropdown:v,__experimentalUseMultipleOriginColorsAndGradients:S}=wp.blockEditor,{PanelBody:k,CheckboxControl:W,RadioControl:m,ToggleControl:T,BaseControl:i,TextControl:G,__experimentalToggleGroupControl:B,__experimentalToggleGroupControlOption:E}=wp.components,{useState:$}=wp.element,N=B,p=E,O=v,I=S,P=({attributes:n,setAttributes:l,clientId:r})=>{const c=[{label:t("Icon","fluent-cart"),colorValue:n.icon_color,onColorChange:e=>l({icon_color:e})}];n.show_total_price&&c.push({label:t("Price","fluent-cart"),colorValue:n.price_color,onColorChange:e=>l({price_color:e})}),n.show_item_count!=="never"&&c.push({label:t("Product Count","fluent-cart"),colorValue:n.product_count_color,onColorChange:e=>l({product_count_color:e})});const s=I();return o.jsxs(o.Fragment,{children:[o.jsx(_,{group:"color",children:o.jsx(O,{panelId:r,settings:c,...s})}),o.jsx(_,{children:o.jsxs(k,{title:t("Settings","fluent-cart"),initialOpen:!0,children:[o.jsxs(N,{className:"fct-mini-cart-inspector-controls",isBlock:!0,label:t("Cart Icon","fluent-cart"),value:n.cart_icon,onChange:e=>l({cart_icon:e}),children:[o.jsx(p,{value:"cart",label:o.jsx(u,{})}),o.jsx(p,{value:"bag",label:o.jsx(f,{})}),o.jsx(p,{value:"bag-alt",label:o.jsx(x,{})})]}),o.jsx(G,{label:t("Or use custom icon URL","fluent-cart"),help:t("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:e=>l({cart_icon:e||"cart"}),placeholder:"https://example.com/icon.svg",type:"url"}),o.jsx(i,{label:t("Display options","fluent-cart"),children:o.jsx(T,{label:t("Display total price","fluent-cart"),help:t("Toggle to display the total price of the cart.","fluent-cart"),checked:n.show_total_price,onChange:e=>l({show_total_price:e})})}),o.jsx(i,{label:t("Show cart item count","fluent-cart"),help:t("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(m,{selected:n.show_item_count,options:[{label:t("Always (even if empty)","fluent-cart"),value:"always"},{label:t("Only if cart has items","fluent-cart"),value:"has_items"},{label:t("Never","fluent-cart"),value:"never"}],onChange:e=>l({show_item_count:e})})}),n.show_item_count!=="never"&&o.jsx(i,{label:t("Badge count shows","fluent-cart"),children:o.jsx(m,{selected:n.count_mode,options:[{label:t("Count distinct products","fluent-cart"),value:"distinct_products"},{label:t("Count total item quantity","fluent-cart"),value:"total_quantity"}],onChange:e=>l({count_mode:e})})})]})})]})},{useBlockProps:R,RichText:z}=wp.blockEditor,{registerBlockType:D}=wp.blocks,{useEffect:H,useState:J}=wp.element,{useSelect:K}=wp.data,{store:Q}=wp.blockEditor,a=window.fluent_cart_mini_cart_data,V=window.fluentCartRestVars.rest;V.url+"";D(a.slug+"/"+a.name,{apiVersion:3,title:a.title,description:a.description,icon:{src:u},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:""},count_mode:{type:"string",default:"distinct_products"}},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:r})=>{const{cart_icon:c,show_total_price:s,show_item_count:e,icon_color:d,price_color:h,product_count_color:g}=n,C=R(),w=d?{color:d}:{},j=h?{color:h}:{},y=g?{backgroundColor:g}:{},b=c&&!["cart","bag","bag-alt"].includes(c);return o.jsxs("div",{...C,children:[o.jsx(P,{attributes:n,setAttributes:l,clientId:r}),o.jsxs("button",{className:"fct-mini-cart-button",children:[o.jsxs("span",{className:"fct-mini-cart-wrap",style:w,children:[b?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(u,{}):c==="bag"?o.jsx(f,{}):o.jsx(x,{}),e!=="never"&&o.jsx("span",{className:"fct-mini-cart-badge",style:y,children:"0"})]}),s&&o.jsx("span",{className:"fct-mini-cart-amount",style:j,children:"$0.00"})]})]})},save:function(n){return null}});
