(()=>{"use strict";const e=window.wp.plugins,t=window.wp.components,r=window.wp.element,n=window.wp.editor,o=window.wp.i18n,i=window.ReactJSXRuntime;(0,e.registerPlugin)("dark-light-mode-sidebar",{render:function(){const[e,a]=(0,r.useState)(!1);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.PluginSidebarMoreMenuItem,{target:"dark-light-mode-sidebar",children:"Dark/Light Mode"}),(0,i.jsx)(n.PluginSidebar,{name:"dark-light-mode-sidebar",title:"Dark/Light Mode",icon:"admin-appearance",children:(0,i.jsx)("div",{style:{padding:"16px"},children:(0,i.jsx)(t.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,o.__)("Enable dark mode","caledros-blocks"),checked:e,onChange:()=>{const t=document.querySelector(".edit-site-visual-editor__editor-canvas")||document.querySelector('iframe[name="editor-canvas"]');if(!t)return void console.error("Iframe editor not found. Please refresh and try again.");const r=t.contentDocument||t.contentWindow.document;if(!r||"complete"!==r.readyState)return void console.error("Iframe document not ready. Please refresh and try again.");const n=r.querySelector(".block-editor-iframe__html");n?(n.setAttribute("data-theme",e?"light":"dark"),a((e=>!e))):console.error("Iframe editor not found. Please refresh and try again.")},help:(0,o.__)("Enable this option to preview the dark theme in the editor.","caledros-blocks")})})})]})}})})();