!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var s=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.NOTICE_CLASS_STATUSES={"notice-success":"success",updated:"success","notice-warning":"warning","notice-error":"error",error:"error","notice-info":"info"},this.contentCreated=!1,this.convertOldStyledToOTGSNotices();var n=this.getNotices();n.forEach(function(e){e.innerHTML=e.outerHTML,e.classList.remove("notice"),e.classList.add("otgs-notice-wrap"),e.childNodes[0].classList.remove("notice","info","success","warning","error","notice-info","notice-success","notice-warning","notice-error")}),this.totalNumberOfNotices=n.length,this.addedNumberOfNotices=0,wp.data.subscribe(function(){return t.createBlockEditorNotices()}),wp.data.subscribe(function(){return t.hideCloseButtonOnAddingNotice()}),this.bindEvents()}return i(e,[{key:"bindEvents",value:function(){var e=this;document.addEventListener("otgs-notice-dismiss",function(t){e.closeNotice(t)})}},{key:"hideCloseButtonOnAddingNotice",value:function(){var e=this,t=this.getAddedOTGSNotices(),n=t.length;n>this.addedNumberOfNotices&&(this.addedNumberOfNotices=n,t.forEach(function(t){var n=e.getComponentDismiss(t);n&&(n.style.visibility="hidden")}),n===this.totalNumberOfNotices&&document.dispatchEvent(new Event("otgs-notices-added")))}},{key:"getNoticeHTML",value:function(e){var t=[];return Object.values(e.childNodes).map(function(e){e.nodeType!==window.Node.ELEMENT_NODE?e.nodeValue.trim()&&t.push(e.nodeValue):e.classList.contains("notice-dismiss")||t.push(e.outerHTML)}),t.join("")}},{key:"getNoticeStatus",value:function(e){var t=!0,n=!1,i=void 0;try{for(var o,s=e.classList[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){var r=o.value;if(this.NOTICE_CLASS_STATUSES.hasOwnProperty(r))return this.NOTICE_CLASS_STATUSES[r]}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}}},{key:"createBlockEditorNotices",value:function(){var e=this;if(!this.contentCreated&&document.querySelector(".edit-post-layout__content")){this.contentCreated=!0;var t=this.getOTGSNotices().reverse();t.length>0&&t.forEach(function(t){var n=e.getNoticeStatus(t),i=e.getNoticeHTML(t),o=t.classList.contains("is-dismissible");wp.data.dispatch("core/notices").createNotice(n,i,{speak:!1,__unstableHTML:!0,isDismissible:o})})}}},{key:"closeNotice",value:function(e){if(e.detail){var t=e.detail[0];if(void 0!==t){var n=this.getComponentDismiss(t);n&&(n.style.visibility="visible",n.click())}}}},{key:"getComponentDismiss",value:function(e){return e.closest(".components-notice").querySelector(".components-notice__dismiss")}},{key:"getAddedOTGSNotices",value:function(){return[].concat(o(document.querySelectorAll(".components-notice .otgs-notice")))}},{key:"getNotices",value:function(){return[].concat(o(document.querySelectorAll(".otgs-notice")))}},{key:"getOTGSNotices",value:function(){return[].concat(o(document.querySelectorAll(".otgs-notice-wrap")))}},{key:"getOldStyledAdminNotices",value:function(){return[].concat(o(document.querySelectorAll(["#wpbody-content > .icl-admin-message"].join(", "))))}},{key:"convertOldStyledToOTGSNotices",value:function(){this.getOldStyledAdminNotices().forEach(function(e){e.classList.contains("otgs-is-dismissible")&&(e.classList.remove("otgs-is-dismissible"),e.classList.add("is-dismissible")),e.classList.remove("message","updated","icl-admin-message","icl-admin-message-error","icl-admin-message-information","icl-admin-message-warning","update-nag"),e.classList.add("notice","otgs-notice")})}}]),e}();t.default=s},function(e,t,n){"use strict";var i,o=n(0),s=(i=o)&&i.__esModule?i:{default:i};document.addEventListener("DOMContentLoaded",function(){new s.default})},function(e,t,n){e.exports=n(1)}]);