(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>a});function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,i(o.key),o)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var r="color-scheme-dark-temp";const a=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.initialize()},(t=[{key:"initialize",value:function(){var e,t,n=this;this.darkModeSetting=null===(e=window.document.documentElement.dataset)||void 0===e?void 0:e.darkModeAdvanced,this.matchMedia=window.matchMedia("(prefers-color-scheme: dark)"),this.storageItemKey="color-scheme-dark",this.callbacks=[],t=function(){(function(){if(!function(){try{return window.self!==window.top}catch(e){return!0}}())return!1;try{var e;return!(null===(e=window)||void 0===e||null===(e=e.parent)||void 0===e||null===(e=e.wp)||void 0===e||!e.customize)}catch(e){return!1}}()||window.document.body.classList.contains("logged-in"))&&(localStorage.removeItem(r),n.storageItemKey=r),n.initializeCustomizePreview(),n.bindEvents(),n.update(),n.observeEditorIframe()},"loading"!=document.readyState?t():document.addEventListener("DOMContentLoaded",t)}},{key:"initializeCustomizePreview",value:function(){var e,t=this,n=null===(e=window.wp)||void 0===e?void 0:e.customize;if(!n)try{var o;n=null===(o=window.parent)||void 0===o||null===(o=o.wp)||void 0===o?void 0:o.customize}catch(e){}n&&n("sm_dark_mode_advanced",function(e){t.darkModeSetting=e(),t.update(),e.bind(function(e){t.darkModeSetting=e,localStorage.removeItem(r),t.update()})})}},{key:"bindEvents",value:function(){var e,t,n,o,i=this;e=document.documentElement,t="click",n=".js-sm-dark-mode-toggle",o=this.onClick.bind(this),e.addEventListener(t,function(e){for(var t=e.target;t&&t!=this;t=t.parentNode)if(t.matches(n)){o.call(t,e);break}},!1),this.matchMedia.addEventListener("change",function(){localStorage.removeItem(r),i.update()})}},{key:"bind",value:function(e){var t=this.callbacks.indexOf(e);"function"==typeof e&&-1===t&&this.callbacks.push(e)}},{key:"unbind",value:function(e){var t=this.callbacks.indexOf(e);t>-1&&this.callbacks.splice(t,1)}},{key:"onClick",value:function(e){e.preventDefault(),localStorage.setItem(this.storageItemKey,this.isCompiledDark()?"light":"dark"),this.update()}},{key:"isSystemDark",value:function(){var e="on"===this.darkModeSetting;return"auto"===this.darkModeSetting&&this.matchMedia.matches&&(e=!0),e}},{key:"isCompiledDark",value:function(){if("off"===this.darkModeSetting)return!1;var e=this.isSystemDark(),t=localStorage.getItem(this.storageItemKey);return null!==t&&(e="dark"===t),e}},{key:"update",value:function(){var e=this.isCompiledDark();this.callbacks.forEach(function(t){t(e)}),e?window.document.documentElement.classList.add("is-dark"):window.document.documentElement.classList.remove("is-dark"),this.syncDarkModeToEditorIframe(e)}},{key:"syncDarkModeToEditorIframe",value:function(e){var t=document.querySelector('iframe[name="editor-canvas"]');if(null!=t&&t.contentDocument)try{e?t.contentDocument.documentElement.classList.add("is-dark"):t.contentDocument.documentElement.classList.remove("is-dark")}catch(e){}}},{key:"observeEditorIframe",value:function(){var e=this;new MutationObserver(function(){var t=document.querySelector('iframe[name="editor-canvas"]');t&&(t.addEventListener("load",function(){e.syncDarkModeToEditorIframe(e.isCompiledDark())}),e.syncDarkModeToEditorIframe(e.isCompiledDark()))}).observe(document.body,{childList:!0,subtree:!0})}}])&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}());(window.sm=window.sm||{}).darkMode=t})();