import{j as o,b as l}from"./chunks/BlockEditorTranslator.js?ver=1.3.21";import{t as f}from"./chunks/Icons.js?ver=1.3.21";const{InspectorControls:L,MediaUpload:T,MediaUploadCheck:N}=wp.blockEditor,{TextControl:j,ToggleControl:U,Button:y,PanelBody:_,__experimentalToggleGroupControl:M,__experimentalToggleGroupControlOption:B}=wp.components,I=M,v=B,C=({attributes:a,setAttributes:t,hasLogo:s,onRemoveImage:r})=>{const{is_link:c,link_target:g,max_width:d,max_height:x,logo_id:p}=a,h=e=>{t({logo_id:e.id,logo_url:e.url})};return o.jsxs(L,{children:[s&&o.jsx(_,{title:l("Logo Image"),initialOpen:!0,children:o.jsxs("div",{className:"fct-logo-actions flex items-center justify-between gap-2",children:[o.jsx(N,{children:o.jsx(T,{onSelect:h,allowedTypes:["image"],value:p,render:({open:e})=>o.jsx(y,{variant:"secondary",onClick:e,children:l("Replace Logo")})})}),p>0&&o.jsx(y,{variant:"link",isDestructive:!0,onClick:r,children:l("Remove")})]})}),o.jsxs(_,{title:l("Logo Settings"),initialOpen:!s,children:[o.jsx(j,{label:l("Max Width (px)"),value:d,type:"number",min:"0",onChange:e=>t({max_width:e})}),o.jsx(j,{label:l("Max Height (px)"),value:x,type:"number",min:"0",onChange:e=>t({max_height:e})})]}),o.jsxs(_,{title:l("Link Settings"),initialOpen:!1,children:[o.jsx(U,{label:l("Link to Home"),checked:c,onChange:e=>t({is_link:e})}),c&&o.jsxs(I,{label:l("Open in"),value:g,isBlock:!0,onChange:e=>t({link_target:e}),children:[o.jsx(v,{value:"_self",label:l("Same Tab")}),o.jsx(v,{value:"_blank",label:l("New Tab")})]})]})]})},{useBlockProps:O,MediaUpload:P,MediaUploadCheck:E}=wp.blockEditor,{registerBlockType:G}=wp.blocks,{Placeholder:R,Button:D}=wp.components,n=window.fluent_cart_store_logo_data;G(n.slug+"/"+n.name,{apiVersion:3,title:n.title,description:n.description,icon:{src:f},category:"fluent-cart",attributes:{is_link:{type:"boolean",default:!0},link_target:{type:"string",default:"_self"},max_width:{type:"string",default:"150"},max_height:{type:"string",default:"70"},logo_id:{type:"number",default:0},logo_url:{type:"string",default:""}},supports:{},edit:({attributes:a,setAttributes:t})=>{const s=O(),{is_link:r,link_target:c,max_width:g,max_height:d,logo_id:x,logo_url:p}=a,h=n.store_logo,e=n.store_name,w=n.home_url,u=p||h,m={};g&&(m.maxWidth=g+"px"),d&&(m.maxHeight=d+"px");const b=r?{href:w,target:c,rel:c==="_blank"?"noopener noreferrer":void 0,onClick:i=>i.preventDefault()}:{},S=i=>{t({logo_id:i.id,logo_url:i.url})},k=()=>{t({logo_id:0,logo_url:""})};return u?o.jsxs("div",{...s,children:[o.jsx(C,{attributes:a,setAttributes:t,hasLogo:!0,onRemoveImage:k}),o.jsxs("div",{className:"fct-store-logo-wrapper",children:[r&&o.jsx("a",{...b,className:"fct-store-logo-link",children:o.jsx("img",{src:u,alt:e,className:"fct-store-logo-img",style:m})}),!r&&o.jsx("div",{className:"fct-store-logo-without-link",children:o.jsx("img",{src:u,alt:e,className:"fct-store-logo-img",style:m})})]})]}):o.jsxs("div",{...s,children:[o.jsx(C,{attributes:a,setAttributes:t,hasLogo:!1,onRemoveImage:k}),o.jsx(E,{children:o.jsx(R,{icon:f,label:l("Store Logo"),instructions:l("Upload a logo or select one from your media library. You can also set your store logo in Settings."),className:"fct-store-logo-placeholder",children:o.jsx(P,{onSelect:S,allowedTypes:["image"],value:x,render:({open:i})=>o.jsx(D,{variant:"primary",onClick:i,children:l("Upload Logo")})})})})]})},save:function(){return null}});
