(()=>{"use strict";var e,t={662(){const e=window.wp.blocks,t=window.wp.element,n=window.wp.blockEditor,o=window.wp.components,r=window.wp.i18n,a=window.wp.data;function l(e){const t=e=>String(e).padStart(2,"0"),n=Math.floor(e/86400),o=Math.floor(e/3600),r=Math.floor(e/60),a=e;return{days:t(n),hours:t(o),minutes:t(r),seconds:t(a)}}const i=window.ReactJSXRuntime,s=JSON.parse('{"UU":"ultimate-coming-soon/single-counter"}');(0,e.registerBlockType)(s.UU,{edit:({attributes:e,setAttributes:s,clientId:u})=>{const c=(0,n.useBlockProps)(),m=(0,t.useRef)(null),d=(0,t.useRef)(null),f=`${e.date||(new Date).toISOString().split("T")[0]}T${e.time||"00:00"}`,g=e.format,p=(0,a.useSelect)(e=>{const t=e("core/block-editor").getBlock(u);return t?.innerBlocks?.length>0},[u]);return(0,t.useEffect)(()=>{m.current&&p&&(d.current&&clearInterval(d.current),d.current=function(e){if(!e)return null;const t=e.dataset.enddate,n=e.dataset.format||"seconds";if(!t)return null;let o=function(e){const t=new Date,n=new Date(e);if(Number.isNaN(n.getTime()))return 0;const o=n.getTime()-t.getTime();return o<=0?0:Math.floor(o/1e3)}(t);if(0==o)return null;const r=e.querySelector(".single-counter-value");if(!r)return null;let a=setInterval(()=>{if(o<1)try{return e.setAttribute("data-show_finished_message","true"),clearInterval(a)}catch(e){return clearInterval(a)}o-=1;let t=l(o);r.innerText=Intl.NumberFormat().format(t[n])},1e3),i=l(o);return r.innerText=Intl.NumberFormat().format(i[n]),a}(m.current))},[p,f,g]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.InspectorControls,{children:(0,i.jsxs)(o.PanelBody,{title:(0,r.__)("Settings","ultimate-coming-soon"),initialOpen:!0,children:[(0,i.jsx)(o.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,r.__)("Date:","ultimate-coming-soon"),value:e.date,onChange:e=>s({date:e}),type:"date"}),(0,i.jsx)(o.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,r.__)("Time:","ultimate-coming-soon"),value:e.time,onChange:e=>s({time:e}),type:"time"}),(0,i.jsx)(o.SelectControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,r.__)("Display Time Format:","ultimate-coming-soon"),value:e.format,options:[{label:(0,r.__)("Days","ultimate-coming-soon"),value:"days"},{label:(0,r.__)("Hours","ultimate-coming-soon"),value:"hours"},{label:(0,r.__)("Minutes","ultimate-coming-soon"),value:"minutes"},{label:(0,r.__)("Seconds","ultimate-coming-soon"),value:"seconds"}],onChange:e=>s({format:e})})]})}),(0,i.jsx)("div",{...c,ref:m,"data-enddate":f,"data-format":g,children:(0,i.jsx)(n.InnerBlocks,{allowedBlocks:["core/paragraph","core/group"],template:[["core/group",{className:"single-counter"},[["core/paragraph",{className:"single-counter-value"},[]]]]]})})]})},save:({attributes:e})=>{const t=n.useBlockProps.save(),o=`${e.date||(new Date).toISOString().split("T")[0]}T${e.time||"00:00"}`;return(0,i.jsx)("div",{...t,"data-enddate":o,"data-format":e.format,className:"single-counter front hide",children:(0,i.jsx)(n.InnerBlocks.Content,{})})}})}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.m=t,e=[],o.O=(t,n,r,a)=>{if(!n){var l=1/0;for(c=0;c<e.length;c++){for(var[n,r,a]=e[c],i=!0,s=0;s<n.length;s++)(!1&a||l>=a)&&Object.keys(o.O).every(e=>o.O[e](n[s]))?n.splice(s--,1):(i=!1,a<l&&(l=a));if(i){e.splice(c--,1);var u=r();void 0!==u&&(t=u)}}return t}a=a||0;for(var c=e.length;c>0&&e[c-1][2]>a;c--)e[c]=e[c-1];e[c]=[n,r,a]},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={559:0,671:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,a,[l,i,s]=n,u=0;if(l.some(t=>0!==e[t])){for(r in i)o.o(i,r)&&(o.m[r]=i[r]);if(s)var c=s(o)}for(t&&t(n);u<l.length;u++)a=l[u],o.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return o.O(c)},n=globalThis.webpackChunkultimate_coming_soon=globalThis.webpackChunkultimate_coming_soon||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var r=o.O(void 0,[671],()=>o(662));r=o.O(r)})();