File: /home/sarprizemain/public_html/wp-content/plugins-old/gatherpress/build/editor.js
(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.domReady;var r=e.n(t);const s=window.wp.data,n=window.wp.blocks;function o(e){if("object"==typeof GatherPress)return e.split(".").reduce((e,t)=>e?.[t],GatherPress)}function a(e,t){if("object"!=typeof GatherPress)return;const r=e.split("."),s=r.pop();r.reduce((e,t)=>{var r;return null!==(r=e[t])&&void 0!==r?r:e[t]={}},GatherPress)[s]=t}const i=window.moment;var c=e.n(i);const d=window.wp.i18n,l=window.wp.element,u=window.wp.hooks;window.wp.date;const p=window.ReactJSXRuntime,m="YYYY-MM-DD HH:mm:ss";function g(){const e=E();return _(c()().format("YYYY-MM-DD HH:mm:ss"),e).add(1,"day").set("hour",18).set("minute",0).set("second",0).format(m)}const h=g(),y=function(){const e=E();return _(g(),e).add(2,"hours").format(m)}();function f(){return function(){const e=[{label:(0,d.__)("1 hour","gatherpress"),value:1},{label:(0,d.__)("1.5 hours","gatherpress"),value:1.5},{label:(0,d.__)("2 hours","gatherpress"),value:2},{label:(0,d.__)("3 hours","gatherpress"),value:3},{label:(0,d.__)("Set an end timeā¦","gatherpress"),value:!1}];return(0,u.applyFilters)("gatherpress.durationOptions",e)}().find(e=>{return t=e.value,_(function(){let e=o("eventDetails.dateTime.datetime_start");return e=""===e?h:_(e,E()).format(m),a("eventDetails.dateTime.datetime_start",e),e}(),E()).add(t,"hours").format(m)===function(){let e=o("eventDetails.dateTime.datetime_end");return e=""===e?y:_(e,E()).format(m),a("eventDetails.dateTime.datetime_end",e),e}();var t})?.value||!1}function v(e){return/^[+-]\d{2}:\d{2}$/.test(e)}function _(e,t){return v(t)?c()(e).utcOffset(t,!0):c().tz(e,t)}function E(e=o("eventDetails.dateTime.timezone")){return v(e)||c().tz.zone(e)?e:(0,d.__)("GMT","gatherpress")}function T(){const e=E(),t=_(o("eventDetails.dateTime.datetime_end"),e),r=_(c()().format("YYYY-MM-DD HH:mm:ss"),e);return"gatherpress_event"===(0,s.select)("core/editor")?.getCurrentPostType()&&r.valueOf()>t.valueOf()}const b=()=>{const e=(0,l.useRef)(!1),t=(0,l.useRef)(!1),r=(0,l.useRef)(!1),{createNotice:n,removeNotice:o}=(0,s.useDispatch)("core/notices"),{openModal:a}=(0,s.useDispatch)("gatherpress/email-modal"),{isSaving:i,isDirty:c,shouldShowNotice:u}=(0,s.useSelect)(e=>{const t=e("core/editor"),r=t.getEditedPostAttribute("status"),n=t.isSavingPost(),o=t.isEditedPostDirty(),a=t.isAutosavingPost();return{isSaving:n&&!a,isDirty:o,shouldShowNotice:"publish"===r&&"gatherpress_event"===(0,s.select)("core/editor")?.getCurrentPostType()&&!T()}},[]);return(0,l.useEffect)(()=>{const s=e.current&&!i&&!c;u&&s?(n("success",(0,d.__)("Send an event update via email","gatherpress"),{id:"gatherpress_event_communication",isDismissible:!0,actions:[{onClick:a,label:(0,d.__)("Compose Message","gatherpress")}]}),r.current=!0):(c&&r.current||i&&r.current||!u&&r.current)&&(o("gatherpress_event_communication"),r.current=!1),e.current=i,t.current=c},[i,c,u,n,a,o]),null},S={dateTimeStart:o("eventDetails.dateTime.datetime_start")?o("eventDetails.dateTime.datetime_start"):h,dateTimeEnd:o("eventDetails.dateTime.datetime_end")?o("eventDetails.dateTime.datetime_end"):y,duration:null,timezone:o("eventDetails.dateTime.timezone")},D={setDateTimeStart:e=>(a("eventDetails.dateTime.datetime_start",e),{type:"SET_DATETIME_START",dateTimeStart:e}),setDateTimeEnd:e=>(a("eventDetails.dateTime.datetime_end",e),{type:"SET_DATETIME_END",dateTimeEnd:e}),setDuration:e=>({type:"SET_DURATION",duration:e}),setTimezone:e=>(a("eventDetails.dateTime.timezone",e),{type:"SET_TIMEZONE",timezone:e})},w=(0,s.createReduxStore)("gatherpress/datetime",{reducer:(e=S,t)=>{switch(t.type){case"SET_DATETIME_START":return{...e,dateTimeStart:t.dateTimeStart};case"SET_DATETIME_END":return{...e,dateTimeEnd:t.dateTimeEnd};case"SET_DURATION":return{...e,duration:t.duration};case"SET_TIMEZONE":return{...e,timezone:t.timezone};default:return e}},actions:D,selectors:{getDateTimeStart:e=>e.dateTimeStart,getDateTimeEnd:e=>e.dateTimeEnd,getDuration:e=>!1!==e.duration&&f(),getTimezone:e=>e.timezone}});(0,s.register)(w);const k={latitude:0,longitude:0,mapCustomLatLong:!1},O=(0,s.createReduxStore)("gatherpress/venue",{reducer:(e=k,t)=>{switch(t.type){case"UPDATE_VENUE_LATITUDE":return{...e,latitude:t.latitude};case"UPDATE_VENUE_LONGITUDE":return{...e,longitude:t.longitude};case"UPDATE_MAP_CUSTOM_LAT_LONG":return{...e,mapCustomLatLong:t.mapCustomLatLong};default:return e}},actions:{updateVenueLatitude:e=>({type:"UPDATE_VENUE_LATITUDE",latitude:e}),updateVenueLongitude:e=>({type:"UPDATE_VENUE_LONGITUDE",longitude:e}),updateMapCustomLatLong:e=>({type:"UPDATE_MAP_CUSTOM_LAT_LONG",mapCustomLatLong:e})},selectors:{getVenueLatitude:e=>e.latitude,getVenueLongitude:e=>e.longitude,getMapCustomLatLong:e=>e.mapCustomLatLong}});(0,s.register)(O);const A={isOpen:!1,isSaving:!1},L=(0,s.createReduxStore)("gatherpress/email-modal",{reducer:(e=A,t)=>{switch(t.type){case"SET_MODAL_OPEN":return{...e,isOpen:t.isOpen};case"SET_SAVING":return{...e,isSaving:t.isSaving};default:return e}},actions:{setModalOpen:e=>({type:"SET_MODAL_OPEN",isOpen:e}),openModal:()=>({type:"SET_MODAL_OPEN",isOpen:!0}),closeModal:()=>({type:"SET_MODAL_OPEN",isOpen:!1}),setSaving:e=>({type:"SET_SAVING",isSaving:e})},selectors:{isModalOpen:e=>e.isOpen,isSaving:e=>e.isSaving}});(0,s.register)(L);const M=window.wp.compose,I=window.wp.blockEditor,P=window.wp.components;(0,u.addFilter)("blocks.registerBlockType","gatherpress/add-post-id-override-support",function(e){return e.supports?.gatherpress?.postIdOverride&&(e.attributes={...e.attributes,postId:{type:"number"}}),e});const N=(0,M.createHigherOrderComponent)(e=>t=>{const{name:r,clientId:o}=t;if(!r.startsWith("gatherpress/")||!(0,n.getBlockType)(r)?.supports?.gatherpress?.postIdOverride)return(0,p.jsx)(e,{...t});const a=(0,s.useSelect)(e=>{var t;const{getBlockAttributes:r}=e("core/block-editor");return null!==(t=r(o)?.postId)&&void 0!==t?t:""},[o]),{updateBlockAttributes:i}=(0,s.useDispatch)("core/block-editor");return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(e,{...t}),(0,p.jsx)(I.InspectorAdvancedControls,{children:(0,p.jsx)(P.__experimentalNumberControl,{label:(0,d.__)("Post ID Override","gatherpress"),value:a,onChange:e=>{i(o,{postId:parseInt(e,10)||""})},help:(0,d.__)("Specify the post ID of an event to replace the default post ID used by this block.","gatherpress")})})]})},"withPostIdOverride");(0,u.addFilter)("editor.BlockEdit","gatherpress/with-post-id-override",N);const C=new Map,x=new Map;function G(){const e=document.querySelector('iframe[name="editor-canvas"]');return e?.contentDocument?e.contentDocument:document}const B=["dragover","dragenter","dragleave","drop"];function U(e){B.forEach(t=>{document.removeEventListener(t,e,!0)})}function $(e,t,r,s){const n=G();if(!n.getElementById(`block-${e}`))return;const o=Array.from(n.querySelectorAll(`[data-type="${t}"]`)),a=[];o.forEach(e=>{const s=e.id?.replace("block-","");s&&j(t,s)===r&&a.push(e)}),a.forEach(e=>{!function(e,t){if(!e)return;t?(e.inert=!0,e.style.opacity="0.95",e.style.cursor="not-allowed",e.dataset.gatherPressGuarded="true"):(e.inert=!1,e.style.opacity="",e.style.cursor="",delete e.dataset.gatherPressGuarded);const r=e.querySelector(".block-list-appender");r&&(r.style.display=t?"none":"")}(e.querySelector(".block-editor-inner-blocks"),s)})}function j(e,t){const r=G().getElementById(`block-${t}`);if(!r)return`${e}-${t}`;const s=r.closest('[data-type="core/post-template"]');if(s){const r=Array.from(s.querySelectorAll(`[data-type="${e}"]`)).findIndex(e=>e.id===`block-${t}`);if(-1!==r)return`${e}-queryloop-${s.closest('[data-type="core/query"]')?.id||"unknown-query-loop"}-position-${r}`}return`${e}-${t}`}const q=(0,M.createHigherOrderComponent)(e=>t=>{const{name:r,clientId:s}=t;if(!r.startsWith("gatherpress/")||!(0,n.getBlockType)(r)?.supports?.gatherpress?.blockGuard)return(0,p.jsx)(e,{...t});const o=j(r,s),[a,i]=function(e){C.has(e)||C.set(e,!0);const[t,r]=(0,l.useState)(C.get(e));return(0,l.useEffect)(()=>{x.has(e)||x.set(e,new Set);const t=x.get(e);return t.add(r),r(C.get(e)),()=>{t.delete(r)}},[e]),[t,t=>{C.set(e,t);const r=x.get(e);r&&r.forEach(e=>e(t))}]}(o);return(0,l.useEffect)(()=>{if(!s)return;$(s,r,o,a);const e=new MutationObserver(()=>{$(s,r,o,a)});return e.observe(document.body,{childList:!0,subtree:!0}),()=>{e.disconnect(),function(e,t){const r=G();r.querySelectorAll('[data-gather-press-guarded="true"]').forEach(e=>{e.inert=!1,e.style.opacity="",e.style.cursor="",delete e.dataset.gatherPressGuarded}),Array.from(r.querySelectorAll(`[data-type="${e}"]`)).forEach(r=>{const s=r.id?.replace("block-","");if(s&&j(e,s)===t){const e=r?.querySelector(".block-editor-inner-blocks");!function(e){if(!e)return;e.inert=!1,e.style.opacity="",e.style.cursor="",delete e.dataset.gatherPressGuarded;const t=e.querySelector(".block-list-appender");t&&(t.style.display="")}(e)}})}(r,o)}},[s,a,r,o]),(0,l.useEffect)(()=>{if(!s)return;let e=null;const t=()=>{var t;!function(e,t){const r=document.querySelector(`.block-editor-list-view-leaf[data-block="${e}"]`);if(!r)return null;const s=r.querySelector(".block-editor-list-view__expander");s&&s.querySelector("svg")&&function(e,t){if(e)if(t){e.style.pointerEvents="none",e.style.opacity="0.3";const t=e.closest(".block-editor-list-view-block-select-button");t&&(t.setAttribute("aria-expanded","false"),t.style.pointerEvents="none",t.style.pointerEvents="auto",t.classList.add("gatherpress-block-guard-enabled"))}else{e.style.pointerEvents="",e.style.opacity="";const t=e.closest(".block-editor-list-view-block-select-button");t&&(t.style.pointerEvents="",t.classList.remove("gatherpress-block-guard-enabled"))}}(s,t)}(s,a),a?e||(e=function(e){return t=>{t.target.closest(`[data-block="${e}"]`)&&("dragenter"!==t.type&&"dragover"!==t.type&&"drop"!==t.type||(t.preventDefault(),t.stopPropagation()))}}(s),t=e,B.forEach(e=>{document.addEventListener(e,t,!0)})):e&&(U(e),e=null)};t();const r=new MutationObserver(()=>{t()});return r.observe(document.body,{childList:!0,subtree:!0}),()=>{r.disconnect(),e&&U(e)}},[s,a]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(e,{...t}),(0,p.jsx)(I.InspectorControls,{children:(0,p.jsx)(P.PanelBody,{children:(0,p.jsx)(P.ToggleControl,{label:(0,d.__)("Block Guard","gatherpress"),checked:a,onChange:e=>{i(e);const t=document.querySelector(`.block-editor-list-view-leaf[data-block="${s}"][data-expanded="true"] .block-editor-list-view__expander`);e&&t&&(t.click(),t.style.pointerEvents="none")},help:a?(0,d.__)("Toggle to unprotect and update the block.","gatherpress"):(0,d.__)("Block protection is disabled. Inner blocks can be freely edited.","gatherpress")})})})]})},"withBlockGuard");(0,u.addFilter)("editor.BlockEdit","gatherpress/with-block-guard",q),r()(()=>{const e=(0,s.select)("core/edit-post"),t=(0,s.dispatch)("core/edit-post");if(e&&t){if(e.isEditorSidebarOpened("edit-post/document")||t.openGeneralSidebar("edit-post/document"),null===document.getElementById("gatherpress-email-notification-manager")){const e=document.createElement("div");e.id="gatherpress-email-notification-manager",e.style.display="none",document.body.appendChild(e);const{createRoot:t}=wp.element;t(e).render(wp.element.createElement(b))}!function(){const e="gatherpress_event_past",t=(0,s.dispatch)("core/notices");t.removeNotice(e),T()&&t.createNotice("warning",(0,d.__)("This event has already passed.","gatherpress"),{id:e,isDismissible:!1})}()}}),r()(()=>{Object.keys(o("misc.unregisterBlocks")).forEach(e=>{const t=o("misc.unregisterBlocks")[e];t&&void 0!==(0,n.getBlockType)(t)&&(0,n.unregisterBlockType)(t)})})})();