(()=>{"use strict";const e=window.wp.blocks,s=window.wp.i18n,t=window.wp.blockEditor,o=window.wp.components,n=(window.wp.apiFetch,window.wp.element,JSON.parse('{"UU":"floating-awesome-button/social-sharing","h_":"Add beautiful social share buttons to your content. Boost engagement and make it easy for visitors to share your posts across social media platforms."}')),a=window.ReactJSXRuntime;(0,e.registerBlockType)(n.UU,{edit:function({attributes:e,setAttributes:i}){const{premium:r,upgrade_url:c}=window.FAB_PLUGIN,{social_media:l,nonce:d}=window.FAB_BLOCK_SOCIAL_SHARING,{options:p}=window.FAB_BLOCK_SOCIAL_SHARING;let m=(0,t.useBlockProps)({className:"fab-container"});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.InspectorControls,{children:(0,a.jsx)(o.PanelBody,{title:"Settings",className:"fab-container",children:(0,a.jsxs)("div",{className:"flex flex-col gap-y-4",children:[!r&&(0,a.jsxs)("div",{className:"flex flex-col items-center gap-y-2 text-sm text-gray-500 border-2 border-primary-600 rounded-md p-4",children:[(0,a.jsx)("span",{children:(0,s.__)("Upgrade to premium to unlock all social media buttons.","floating-awesome-button")}),(0,a.jsxs)("a",{href:c,className:"bg-primary-600 text-white px-4 py-2 rounded-md flex items-center gap-x-2",children:[(0,a.jsx)("i",{className:"fa-solid fa-circle-check"}),(0,s.__)("Upgrade Now","floating-awesome-button")]})]}),(0,a.jsx)("div",{className:"flex flex-col gap-y-1",children:Object.keys(l).map(e=>(0,a.jsx)("div",{className:"flex items-center gap-x-2",children:(0,a.jsx)(o.ToggleControl,{label:l[e].label,checked:p.buttons.includes(e),onChange:s=>((e,s)=>{const t=s?[...p.buttons,e]:p.buttons.filter(s=>s!==e);p.buttons=t,i({buttons:t})})(e,s)})},e))})]})})}),(0,a.jsx)("div",{...m,children:(0,a.jsxs)("div",{className:"px-6 py-4 border-2 border-gray-300 rounded-md",children:[(0,a.jsxs)("h2",{className:"text-xl font-bold flex items-center gap-x-2",children:[(0,a.jsx)("i",{className:"fa-solid fa-share-nodes"}),(0,a.jsx)("span",{children:(0,s.__)("Social Sharing","floating-awesome-button")})]}),(0,a.jsx)("p",{className:"text-sm text-gray-500 pt-2",children:n.h_})]})})]})},save:function(e){const{attributes:s}=e,{nonce:t}=window.FAB_BLOCK_SOCIAL_SHARING,o=window.wp.data.dispatch("core/editor"),n=o.savePost;return o.savePost=function(e){return n(e=e||{}).then(()=>{if(!e.isAutosave){const e=new FormData;return e.append("action","fab_save_social_sharing_block_options"),e.append("nonce",t),e.append("post_id",wp.data.select("core/editor").getCurrentPostId()),e.append("options",JSON.stringify({buttons:s.buttons})),fetch(ajaxurl,{method:"POST",body:e}).then(e=>e.json()).then(e=>{e.success||console.error("Error saving social sharing options:",e.data)}).catch(e=>{console.error("Error saving social sharing options:",e)})}})},null}})})();