| 1 |
import{j as t}from"./chunks/jsx-runtime.js?ver=1.6.4";import{a as y,P as E,b as C,c as D,d as S}from"./chunks/ProductExcerptBlock.js?ver=1.6.4";import{u as T}from"./chunks/ProductContext.js?ver=1.6.4";import{S as $}from"./chunks/SingleProductContext.js?ver=1.6.4";import{P as z}from"./chunks/ProductContainerContext.js?ver=1.6.4";import{b as v}from"./chunks/BlockEditorTranslator.js?ver=1.6.4";const{InnerBlocks:F,useBlockProps:g,useInnerBlocksProps:L,__experimentalUseBlockPreview:M,BlockContextProvider:O}=wp.blockEditor,A=M||null,{useContext:H,useEffect:x,useState:m,useMemo:lt,memo:R}=wp.element,{useSelect:V}=wp.data,W=()=>{const s=L({className:"fct-block-product"},{__unstableDisableLayoutClassNames:!0});return t.jsx("div",{...s})},K=({blocks:s,blockContextId:e,isHidden:o,setActiveBlockContextId:r})=>{const n=A({blocks:s,props:{className:"fct-block-product"}}),a=()=>{r(e)},i={display:o?"none":void 0};return t.jsx("div",{...n,tabIndex:0,role:"button",onClick:a,onKeyPress:a,style:i})},U=R(K),q=({displayTemplate:s,blocks:e,blockContext:o,setActiveBlockContextId:r})=>t.jsxs(O,{value:o,children:[s?t.jsx(W,{}):null,t.jsx(U,{blocks:e,blockContextId:o.ID,setActiveBlockContextId:r,isHidden:s})]},o.ID),G={attributes:{wp_client_id:{type:"string",default:""},last_changed:{type:"string",default:""}},edit:s=>{const{attributes:e,setAttributes:o,clientId:r,context:n}=s,{simulateLoading:a,simulateNoResults:i}=H(z);let b=a||i?"hide":"",j=n["fluent-cart/enable_filter"]?"":"not-enable-filter";const h=g({className:"fct-shop-app-preview-wrap "+b+" "+j});x(()=>{o({last_changed:new Date().toISOString()}),!e.wp_client_id&&o({wp_client_id:r})},[r,e.wp_client_id,o]);const l=T(),u=V(c=>c("core/block-editor").getBlock(r),[r]),[d,B]=m(1);x(()=>{if(d>1){new Date().toISOString();return}B(d+1)},[u]);const N=u.innerBlocks,[_,w]=m();return t.jsx("div",{...h,children:t.jsx("div",{className:"fct-product-loop-editor",style:{display:"flex"},children:l==null?void 0:l.products.map(c=>{var p;const I=c.ID===(_||((p=l==null?void 0:l.products[0])==null?void 0:p.ID));return t.jsx($,{value:{product:c},children:t.jsx("div",{className:"fluent-cart-product-loop fct-product-block-editor-product-card",children:t.jsx(q,{attributes:{productId:c.ID},blocks:N,displayTemplate:I,blockContext:c,setActiveBlockContextId:w},c.ID)},c.ID)},c.ID)})})})},save:s=>{const e=g.save();return t.jsx("div",{...e,className:"fluent-cart-product-loop fct-product-block-editor-product-card",children:t.jsx(F.Content,{})})},supports:{align:["wide","full"],html:!1},usesContext:["fluent-cart/carousel_settings","fluent-cart/product_ids"]},{useBlockProps:J}=wp.blockEditor,{useContext:it}=wp.element,Q={edit:({context:s})=>{const o=(s["fluent-cart/carousel_settings"]||{}).arrows!=="no",r=J({className:"fct-carousel-controls-editor"});return o?t.jsxs("div",{...r,children:[t.jsx("button",{className:"editor-carousel-nav prev","aria-hidden":"true",children:"‹"}),t.jsx("button",{className:"editor-carousel-nav next","aria-hidden":"true",children:"›"})]}):t.jsx("div",{...r,style:{opacity:.5}})},save:()=>null,supports:{html:!1},usesContext:["fluent-cart/carousel_settings"]},{useBlockProps:X}=wp.blockEditor,Y={edit:({context:s})=>{const e=s["fluent-cart/carousel_settings"]||{},o=e.pagination!=="no",r=e.paginationType||"bullets",n=X({className:"fct-carousel-pagination-editor"});if(!o)return t.jsx("div",{...n,style:{opacity:.5}});const a=()=>{switch(r){case"fraction":return t.jsxs("div",{className:"editor-carousel-pagination editor-carousel-pagination--fraction",children:[t.jsx("span",{className:"fraction-current",style:{fontSize:"18px",fontWeight:"700",color:"#111827"},children:"1"}),t.jsx("span",{style:{margin:"0 8px",fontSize:"14px",color:"#6b7280"},children:"—"}),t.jsx("span",{className:"fraction-total",style:{fontSize:"14px",fontWeight:"400",color:"#9ca3af"},children:"5"})]});case"progress":return t.jsx("div",{className:"editor-carousel-pagination editor-carousel-pagination--progress",children:t.jsx("div",{className:"progress-bar",style:{width:"40%"}})});case"segmented":return t.jsxs("div",{className:"editor-carousel-pagination editor-carousel-pagination--segmented",children:[t.jsx("div",{className:"progress-segment is-completed"}),t.jsx("div",{className:"progress-segment is-active"}),t.jsx("div",{className:"progress-segment"}),t.jsx("div",{className:"progress-segment"}),t.jsx("div",{className:"progress-segment"}),t.jsx("span",{className:"segment-counter",children:"1 / 5"})]});case"bullets":default:return t.jsxs("div",{className:"editor-carousel-pagination",children:[t.jsx("span",{className:"editor-carousel-dot is-active"}),t.jsx("span",{className:"editor-carousel-dot"}),t.jsx("span",{className:"editor-carousel-dot"})]})}};return t.jsx("div",{...n,children:a()})},save:()=>null,supports:{html:!1},usesContext:["fluent-cart/carousel_settings"]},{registerBlockType:P}=wp.blocks,Z=window.fluent_cart_product_carousel_inner_blocks,{InnerBlocks:f,useBlockProps:k}=wp.blockEditor,tt={ProductTitleBlockEditor:S,ProductPriceBlockEditor:D,ProductImageBlockEditor:C,ProductButtonBlockEditor:E,ProductExcerptBlockEditor:y,ProductCarouselLoopBlock:G,CarouselControlsBlock:Q,CarouselPaginationBlock:Y};Z.blocks.forEach(s=>{const e=tt[s.component],o=[];s.parent&&o.push(...s.parent),e!=null&&e.parent&&o.push(...e.parent),P(s.slug,{apiVersion:3,category:"product-elements",title:s.title,name:s.slug,icon:s.icon||null,parent:o.length>0?o:null,edit:(e==null?void 0:e.edit)||(()=>v("No edit found")),save:(e==null?void 0:e.save)||(()=>null),supports:(e==null?void 0:e.supports)||{},usesContext:(e==null?void 0:e.usesContext)||[],attributes:(e==null?void 0:e.attributes)||{}})});P("fluent-cart/product-paginator",{apiVersion:3,title:v("Paginator"),icon:"screenoptions",parent:["fluent-cart/product_carousel","core/column"],category:"layout",attributes:{},edit:s=>{const e=k({className:"fluent-cart-product-paginator"});return t.jsx("div",{...e,children:t.jsx("div",{children:t.jsx(f,{allowedBlocks:["fluent-cart/product-paginator-info","fluent-cart/product-paginator-number","core/paragraph"]})})})},save:s=>{const e=k.save();return t.jsx("div",{...e,className:"fluent-cart-product-paginator",children:t.jsx(f.Content,{})})},usesContext:["fluent-cart/carousel_settings","fluent-cart/product_ids"]}); |