(()=>{"use strict";var e,t={2499:(e,t,r)=>{const a=window.wp.blocks,s=window.moment;var n=r.n(s);function o(e){var t,r,a="";if("string"==typeof e||"number"==typeof e)a+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;te?.[t],GatherPress)}function g(e,t){if("object"!=typeof GatherPress)return;const r=e.split("."),a=r.pop();r.reduce((e,t)=>{var r;return null!==(r=e[t])&&void 0!==r?r:e[t]={}},GatherPress)[a]=t}function f(){(0,u.dispatch)("core/editor")?.editPost({meta:{_non_existing_meta:!0}})}function _(){const e=(0,u.select)("core/editor")?.getCurrentPostType();return["wp_template","wp_template_part"].includes(e)}const v=window.wp.date,x=window.ReactJSXRuntime,T="YYYY-MM-DD HH:mm:ss";function y(){const e=k();return E(n()().format("YYYY-MM-DD HH:mm:ss"),e).add(1,"day").set("hour",18).set("minute",0).set("second",0).format(T)}const b=y(),D=function(){const e=k();return E(y(),e).add(2,"hours").format(T)}();function j(){const e=[{label:(0,l.__)("1 hour","gatherpress"),value:1},{label:(0,l.__)("1.5 hours","gatherpress"),value:1.5},{label:(0,l.__)("2 hours","gatherpress"),value:2},{label:(0,l.__)("3 hours","gatherpress"),value:3},{label:(0,l.__)("Set an end time…","gatherpress"),value:!1}];return(0,m.applyFilters)("gatherpress.durationOptions",e)}function w(e){return E(function(){let e=h("eventDetails.dateTime.datetime_start");return e=""===e?b:E(e,k()).format(T),g("eventDetails.dateTime.datetime_start",e),e}(),k()).add(e,"hours").format(T)}function S(){return j().find(e=>w(e.value)===function(){let e=h("eventDetails.dateTime.datetime_end");return e=""===e?D:E(e,k()).format(T),g("eventDetails.dateTime.datetime_end",e),e}())?.value||!1}function C(){return P(h("settings.dateFormat"))+" "+P(h("settings.timeFormat"))}function z(e){return/^[+-]\d{2}:\d{2}$/.test(e)}function E(e,t){return z(t)?n()(e).utcOffset(t,!0):n().tz(e,t)}function k(e=h("eventDetails.dateTime.timezone")){return z(e)||n().tz.zone(e)?e:(0,l.__)("GMT","gatherpress")}function O(e=""){const t=/^([+-])(\d{2}):(00|15|30|45)$/,r=e.replace(t,"$1");return r!==e?"UTC"+r+parseInt(e.replace(t,"$2")).toString()+e.replace(t,"$3").replace("00","").replace("15",".25").replace("30",".5").replace("45",".75"):e}function Y(e,t=null,r=null){const a=S();g("eventDetails.dateTime.datetime_start",e),"number"==typeof a?F(E(e,k()).add(a,"hours").format(T),r):function(e,t=null,r=null){const a=k(),s=E(h("eventDetails.dateTime.datetime_end"),a).valueOf(),n=E(e,a).valueOf();if(n>=s){const e=null===r?S():r,s=!1!==e&&"number"==typeof e?e:2;F(E(n,a).add(s,"hours").format(T),t)}}(e,r,a),"function"==typeof t&&t(e),f()}function F(e,t=null,r=null){!function(e,t=null){const r=k(),a=E(h("eventDetails.dateTime.datetime_start"),r).valueOf(),s=E(e,r).valueOf();s<=a&&Y(E(s,r).subtract(2,"hours").format(T),t)}(e,r),g("eventDetails.dateTime.datetime_end",e),null!==t&&t(e),f()}function P(e){const t={d:"DD",D:"ddd",j:"D",l:"dddd",N:"E",S:"o",w:"e",z:"DDD",W:"W",F:"MMMM",m:"MM",M:"MMM",n:"M",t:"",L:"",o:"YYYY",Y:"YYYY",y:"YY",a:"a",A:"A",B:"",g:"h",G:"H",h:"hh",H:"HH",i:"mm",s:"ss",u:"SSS",e:"zz",I:"",O:"",P:"",T:"",Z:"",c:"",r:"",U:"X"};return String(e).split("").map((e,r,a)=>{const s=a[r-1];return e in t&&"\\"!==s?t[e]:e}).join("")}const M=["d","D","j","l","N","S","w","z","W","F","m","M","n","t","L","o","X","x","Y","y","e","I","O","P","p","T","Z","c","r","U",","];function $(){return"gatherpress_event"===(0,u.select)("core/editor")?.getCurrentPostType()}function H(){const e="gatherpress_event_past",t=(0,u.dispatch)("core/notices");t.removeNotice(e),function(){const e=k(),t=E(h("eventDetails.dateTime.datetime_end"),e),r=E(n()().format("YYYY-MM-DD HH:mm:ss"),e);return"gatherpress_event"===(0,u.select)("core/editor")?.getCurrentPostType()&&r.valueOf()>t.valueOf()}()&&t.createNotice("warning",(0,l.__)("This event has already passed.","gatherpress"),{id:e,isDismissible:!1})}const I=()=>{const{dateTimeStart:e,duration:t}=(0,u.useSelect)(e=>({dateTimeStart:e("gatherpress/datetime").getDateTimeStart(),duration:e("gatherpress/datetime").getDuration()}),[]),{setDateTimeStart:r,setDateTimeEnd:a}=(0,u.useDispatch)("gatherpress/datetime"),s=(0,v.getSettings)(),n=/a(?!\\)/i.test(s.formats.time.toLowerCase().replaceAll("\\\\","").split("").reverse().join(""));return(0,c.useEffect)(()=>{r(E(e,k()).format(T)),t&&a(w(t)),H()},[e,t,r,a]),(0,x.jsx)(p.PanelRow,{children:(0,x.jsxs)(p.Flex,{direction:"column",gap:"1",children:[(0,x.jsx)(p.FlexItem,{children:(0,x.jsx)("h3",{style:{marginBottom:0},children:(0,x.jsx)("label",{htmlFor:"gatherpress-datetime-start",children:(0,l.__)("Date & time start","gatherpress")})})}),(0,x.jsx)(p.FlexItem,{children:(0,x.jsx)(p.Dropdown,{popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:r})=>(0,x.jsx)(p.Button,{id:"gatherpress-datetime-start",onClick:r,"aria-expanded":t,variant:"link",children:E(e,k()).format(C())}),renderContent:()=>(0,x.jsx)(p.DateTimePicker,{currentDate:e,onChange:e=>{Y(e,r,a)},is12Hour:n})})})]})})},A=()=>{const{dateTimeEnd:e}=(0,u.useSelect)(e=>({dateTimeEnd:e("gatherpress/datetime").getDateTimeEnd()}),[]),{setDateTimeEnd:t,setDateTimeStart:r}=(0,u.useDispatch)("gatherpress/datetime"),a=(0,v.getSettings)(),s=/a(?!\\)/i.test(a.formats.time.toLowerCase().replaceAll("\\\\","").split("").reverse().join(""));return(0,c.useEffect)(()=>{t(E(e,k()).format(T)),H()}),(0,x.jsx)(p.PanelRow,{children:(0,x.jsxs)(p.Flex,{direction:"column",gap:"1",children:[(0,x.jsx)(p.FlexItem,{children:(0,x.jsx)("h3",{style:{marginBottom:0},children:(0,x.jsx)("label",{htmlFor:"gatherpress-datetime-end",children:(0,l.__)("Date & time end","gatherpress")})})}),(0,x.jsx)(p.FlexItem,{children:(0,x.jsx)(p.Dropdown,{popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:t,onToggle:r})=>(0,x.jsx)(p.Button,{id:"gatherpress-datetime-end",onClick:r,"aria-expanded":t,variant:"link",children:E(e,k()).format(C())}),renderContent:()=>(0,x.jsx)(p.DateTimePicker,{currentDate:e,onChange:e=>F(e,t,r),is12Hour:s})})})]})})},B=()=>{const{timezone:e}=(0,u.useSelect)(e=>({timezone:e("gatherpress/datetime").getTimezone()}),[]),{setTimezone:t}=(0,u.useDispatch)("gatherpress/datetime"),r=h("misc.timezoneChoices");return(0,c.useEffect)(()=>{t(h("eventDetails.dateTime.timezone"))},[t]),(0,x.jsx)(p.PanelRow,{children:(0,x.jsx)(p.SelectControl,{label:(0,l.__)("Time Zone","gatherpress"),value:O(e),onChange:e=>{e=function(e=""){const t=/^UTC([+-])(\d+)(\.\d+)?$/,r=e.replace(t,"$1");if(r===e)return e;const a=e.replace(t,"$2").padStart(2,"0");let s=e.replace(t,"$3");return""===s&&(s=":00"),s=s.replace(".25",":15").replace(".5",":30").replace(".75",":45"),r+a+s}(e),t(e),f()},__nexthasnomarginbottom:!0,children:r&&"object"==typeof r&&0(0,x.jsx)("optgroup",{label:e,children:Object.keys(r[e]).map(t=>(0,x.jsx)("option",{value:t,children:r[e][t]},t))},e)):(0,x.jsx)("option",{value:"",children:(0,l.__)("Error, no choices available","gatherpress")})})})},N=()=>{const{duration:e}=(0,u.useSelect)(e=>({duration:e("gatherpress/datetime").getDuration()}),[]),t=(0,u.useDispatch)(),{setDateTimeEnd:r,setDuration:a}=t("gatherpress/datetime");return(0,x.jsx)(p.SelectControl,{label:(0,l.__)("Duration","gatherpress"),value:!!j().some(t=>t.value===e)&&e,options:j(),onChange:e=>{(e="false"!==e&&parseFloat(e))&&r(w(e)),a(e)},__nexthasnomarginbottom:!0})},R=()=>{const e=(0,u.useDispatch)("core/editor").editPost;let t=(0,u.useSelect)(e=>e("core/editor").getEditedPostAttribute("meta")?.gatherpress_datetime);try{t=t?JSON.parse(t):{}}catch(e){console.error("Failed to parse gatherpress_datetime meta:",e),t={}}const{dateTimeStart:r,dateTimeEnd:a,duration:s,timezone:n}=(0,u.useSelect)(e=>({dateTimeStart:e("gatherpress/datetime").getDateTimeStart(),dateTimeEnd:e("gatherpress/datetime").getDateTimeEnd(),duration:e("gatherpress/datetime").getDuration(),timezone:e("gatherpress/datetime").getTimezone()}),[]),{setDuration:o}=(0,u.useDispatch)("gatherpress/datetime");return(0,c.useEffect)(()=>{const s=JSON.stringify({...t,dateTimeStart:E(r,n).format(T),dateTimeEnd:E(a,n).format(T),timezone:n});e({meta:{gatherpress_datetime:s}})},[r,a,n,t,e,o,s]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("section",{children:(0,x.jsx)(I,{})}),(0,x.jsx)("section",{children:s?(0,x.jsx)(N,{}):(0,x.jsx)(A,{})}),(0,x.jsx)("section",{children:(0,x.jsx)(B,{})})]})},G=h("settings.dateFormat"),L=h("settings.timeFormat"),W=h("settings.showTimezone"),J=`${G} ${L}`,U=(e,t,r,a,s,n,o)=>{r=k(r);let i=!1;if(e&&t){const a=P(G);i=E(e,r).format(a)===E(t,r).format(a)}const d=[];if(e&&(a=P(a||J),d.push(E(e,r).format(a))),t&&(s=s||J,(s=i?s.split("").filter(e=>!M.includes(e)).join("").trim():s)||(t=!1)),e&&t&&d.push("to"===n?(0,l.__)("to","gatherpress"):n),t&&s&&(s=P(s),d.push(E(t,r).format(s))),o?"yes"===o:W)if(z(r)){const e=r.charAt(0),t=r.substring(1).replace(":","");d.push(`GMT${e}${t}`)}else d.push(E(t||e,r).format("z"));return d.push(function(e){return e=k(e),(0,l.__)("GMT","gatherpress")===e?function(e=""){return e.replace(":","")}(h("eventDetails.dateTime.timezone")):""}(r)),d.filter(Boolean).join(" ")},X=(e,t,r)=>"start"===e?r?t?"end":"both":"start":t?r?"start":"both":"end",Z=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gatherpress/event-date","version":"2.0.0","title":"Event Date","category":"gatherpress","icon":"clock","example":{"viewportWidth":350},"description":"Displays the date and time for an event.","usesContext":["postId","queryId"],"attributes":{"eventEnd":{"type":"string"},"eventStart":{"type":"string"},"textAlign":{"type":"string"},"displayType":{"type":"string","default":"both"},"startDateFormat":{"type":"string","default":""},"endDateFormat":{"type":"string","default":""},"separator":{"type":"string","default":"to"},"showTimezone":{"type":"string","default":""}},"supports":{"gatherpress":{"postIdOverride":true},"html":false,"color":{"gradients":true,"link":true,"__experimentalDefaultControls":{"background":true,"text":true,"link":true}},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true,"__experimentalFontFamily":true,"__experimentalFontWeight":true,"__experimentalFontStyle":true,"__experimentalTextTransform":true,"__experimentalTextDecoration":true,"__experimentalLetterSpacing":true,"__experimentalDefaultControls":{"fontSize":true}},"interactivity":{"clientNavigation":true},"__experimentalBorder":{"radius":true,"color":true,"width":true,"style":true,"__experimentalDefaultControls":{"radius":true,"color":true,"width":true,"style":true}}},"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css","render":"file:./render.php"}');(0,a.registerBlockType)(Z,{edit:({attributes:e,setAttributes:t,context:r})=>{var a,s;const{textAlign:o,displayType:c,startDateFormat:m,endDateFormat:h,separator:g,showTimezone:f}=e,v=null!==(a=null!==(s=e?.postId||null)&&void 0!==s?s:r?.postId)&&void 0!==a?a:null,T=function(e=null){if(e){const t=(0,u.select)("core").getEntityRecord("postType","gatherpress_event",e),r=(0,u.select)("core/editor")?.getCurrentPostId();return r&&r===e?!!t:!!t&&"publish"===t.status}return $()}(v),y=(0,d.useBlockProps)({className:i({[`has-text-align-${o}`]:o}),style:{opacity:_()||T?1:.3}}),{dateTimeStart:b,dateTimeEnd:D,timezone:j,isLoading:w}=(0,u.useSelect)(e=>{if(!v)return{dateTimeStart:void 0,dateTimeEnd:void 0,timezone:void 0,isLoading:!1};if($())return{dateTimeStart:e("gatherpress/datetime").getDateTimeStart(),dateTimeEnd:e("gatherpress/datetime").getDateTimeEnd(),timezone:e("gatherpress/datetime").getTimezone(),isLoading:!1};const t=e("core").hasFinishedResolution("getEntityRecord",["postType","gatherpress_event",v]),r=e("core").getEntityRecord("postType","gatherpress_event",v)?.meta;return{dateTimeStart:r?.gatherpress_datetime_start,dateTimeEnd:r?.gatherpress_datetime_end,timezone:r?.gatherpress_timezone,isLoading:!t}},[v]);if(w)return(0,x.jsx)("div",{...y,children:(0,x.jsx)(p.Spinner,{})});const S=E(n()().format("YYYY-MM-DD HH:mm:ss"),k()),C=b||S.format(),z=D||S.clone().add(1,"hour").format(),O=j||k(),Y=["start","both"].includes(c),F=["end","both"].includes(c);return(0,x.jsxs)("div",{...y,children:[(0,x.jsxs)(d.BlockControls,{children:[(0,x.jsx)(d.AlignmentToolbar,{value:o,onChange:e=>t({textAlign:e})}),(0,x.jsxs)(p.ToolbarGroup,{children:[(0,x.jsx)(p.ToolbarButton,{label:(0,l.__)("Toggle start date","gatherpress"),text:(0,l.__)("Start","gatherpress"),isPressed:Y,onClick:()=>{t({displayType:X("start",Y,F)})}}),(0,x.jsx)(p.ToolbarButton,{label:(0,l.__)("Toggle end date","gatherpress"),text:(0,l.__)("End","gatherpress"),isPressed:F,onClick:()=>{t({displayType:X("end",Y,F)})}})]})]}),U(Y?C:null,F?z:null,O,m,h,g,f),$()&&(0,x.jsx)(d.InspectorControls,{children:(0,x.jsxs)(p.PanelBody,{children:[(0,x.jsx)(p.__experimentalVStack,{spacing:4,children:(0,x.jsx)(R,{})}),(0,x.jsx)("div",{style:{height:"1rem"}}),(0,x.jsx)(p.SelectControl,{label:(0,l.__)("Show time zone","gatherpress"),value:f,options:[{label:(0,l.sprintf)(/* translators: %s: Plugin "show timezone" setting */ /* translators: %s: Plugin "show timezone" setting */ (0,l.__)("%s (plugin setting)","gatherpress"),W?(0,l.__)("Yes","gatherpress"):(0,l.__)("No","gatherpress")),value:""},{label:(0,l.__)("Yes","gatherpress"),value:"yes"},{label:(0,l.__)("No","gatherpress"),value:"no"}],onChange:e=>t({showTimezone:e})}),(0,x.jsx)(p.RadioControl,{label:(0,l.__)("Display","gatherpress"),selected:c,options:[{label:(0,l.__)("Start and end date","gatherpress"),value:"both"},{label:(0,l.__)("Start date only","gatherpress"),value:"start"},{label:(0,l.__)("End date only","gatherpress"),value:"end"}],onChange:e=>t({displayType:e})}),"both"===c&&(0,x.jsx)(p.TextControl,{label:(0,l.__)("Separator","gatherpress"),value:g,placeholder:(0,l.__)("to","gatherpress"),onChange:e=>t({separator:e})}),Y&&(0,x.jsx)(p.TextControl,{label:(0,l.__)("Start date format","gatherpress"),value:m,placeholder:`${G} ${L}`,onChange:e=>t({startDateFormat:e})}),F&&(0,x.jsx)(p.TextControl,{label:(0,l.__)("End date format","gatherpress"),value:h,placeholder:`${G} ${L}`,onChange:e=>t({endDateFormat:e})}),(0,x.jsx)("p",{className:"components-base-control__help",children:(0,x.jsx)("a",{href:"https://wordpress.org/documentation/article/customize-date-and-time-format/",target:"_blank",rel:"noreferrer",children:(0,l.__)("Date/time formatting documentation","gatherpress")})})]})})]})},save:()=>null})}},r={};function a(e){var s=r[e];if(void 0!==s)return s.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,a),n.exports}a.m=t,e=[],a.O=(t,r,s,n)=>{if(!r){var o=1/0;for(p=0;p=n)&&Object.keys(a.O).every(e=>a.O[e](r[l]))?r.splice(l--,1):(i=!1,n0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[r,s,n]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={1532:0,6004:0};a.O.j=t=>0===e[t];var t=(t,r)=>{var s,n,[o,i,l]=r,d=0;if(o.some(t=>0!==e[t])){for(s in i)a.o(i,s)&&(a.m[s]=i[s]);if(l)var p=l(a)}for(t&&t(r);da(2499));s=a.O(s)})();