import{j as e,b as j}from"./BlockEditorTranslator.js?ver=1.3.25";import{E as S,S as y,C as O}from"./Icons.js?ver=1.3.25";function A({text:a}){return e.jsxs("div",{className:"fct-pricing-block-editor-empty-block",children:[e.jsx(S,{}),e.jsx("p",{children:a})]})}const P=({placeholder:a=j("Search"),name:l,type:d="text",onClick:c,onInput:n,onBlur:m,onKeyDown:o,icon:r=!1})=>e.jsxs("div",{className:"fct-input-group",children:[r&&e.jsx("div",{className:"input-icon",children:e.jsx(y,{})}),e.jsx("input",{className:"fct-input",name:l,type:d,placeholder:a,onClick:c,onInput:n,onBlur:m,onKeyDown:o})]}),{useState:R}=wp.element,{CheckboxControl:I}=wp.components,E=window.fluent_cart_block_editor_asset.placeholder_image,_=a=>{const{variant:l,title:d,media:c,stock:n,price:m,showCollapseButton:o=!1,toggleCollapse:r=()=>{},updateSelectedVariations:i,checked:u=!1,isOpen:s,isMultiple:t=!0}=a;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:`fct-collapsible-item ${o?"has-collapse-item":""}`,children:[e.jsxs("div",{className:"fct-collapsible-content-wrapper",children:[o&&e.jsx("div",{className:`content-collapsible-btn ${s?"is-collapsed":""}`,onClick:r,children:e.jsx("div",{className:"icon",children:e.jsx(O,{})})}),!o&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"content-checkbox",children:e.jsx(I,{checked:u,onChange:h=>{i(l,h)}})})}),e.jsx("div",{className:"content-img",children:e.jsx("img",{src:c||E,alt:""})}),e.jsx("div",{className:"content-title",children:e.jsx("div",{className:"title",children:d})})]}),n&&e.jsx("div",{className:"fct-collapsible-stock-wrapper",children:n}),e.jsx("div",{className:"fct-collapsible-value-wrapper",children:e.jsx("span",{children:m})})]})})},M=a=>{const{variants:l,isOpen:d,updateSelectedVariations:c,selectedVariations:n,isMultiple:m,allow_subscription:o=!0}=a;return e.jsx(e.Fragment,{children:e.jsx("div",{className:`fct-collapsible-item-child-container ${d?"is-collapsed":""}`,children:e.jsx("ul",{className:"fct-collapsible-item-child-inner",children:Object.entries(l).map((r,i)=>{const u=l[i].available===0?j("Unlimited"):j("%d Available",l[i].available);return e.jsx("li",{children:e.jsx(_,{isMultiple:m,variant:l[i],title:l[i].variation_title,media:l[i].thumbnail,stock:u,price:"",updateSelectedVariations:c,checked:Object.keys(n).includes(String(l[i].id))})},i)})})})})},{useState:F}=wp.element,U=a=>{var b,v,x;const{products:l,index:d,updateSelectedVariations:c,selectedVariations:n,isMultiple:m=!1,allow_subscription:o=!0}=a,[r,i]=F(!1),u=()=>{i(!r)},s=l[d],t={...s.variants[0],variation_type:(b=s==null?void 0:s.detail)==null?void 0:b.variation_type,variation_title:s==null?void 0:s.post_title,is_child:!1},h=s.variants.length>1,k=h?s==null?void 0:s.post_title:t==null?void 0:t.variation_title,N=h?"":(t==null?void 0:t.manage_stock)=="1"?j("%d Available",t==null?void 0:t.available):j("Unlimited"),f=s.variants.length,w=h?(x=(v=s==null?void 0:s.detail)==null?void 0:v.featured_media)==null?void 0:x.url:t==null?void 0:t.thumbnail,C=()=>(o?s.variants:s.variants.filter(p=>(p==null?void 0:p.payment_type)!=="subscription")).map(p=>{var g;return{...p,variation_type:(g=s==null?void 0:s.detail)==null?void 0:g.variation_type,variation_title:p==null?void 0:p.variation_title,is_child:!0}});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fct-collapsible-list-item-inner",children:[e.jsx(_,{variant:t,title:k,media:w,stock:N,price:f,showCollapseButton:h,checked:Object.keys(n).includes(String(t==null?void 0:t.id)),toggleCollapse:u,updateSelectedVariations:c,isOpen:r,isMultiple:m}),h&&e.jsx(M,{allow_subscription:o,isMultiple:!0,variants:C(),isOpen:r,updateSelectedVariations:c,selectedVariations:n})]})})};export{A as E,P as I,_ as L,U as P};
