(()=>{"use strict";const e=window.wp.i18n,t=window.wp.plugins,n=window.wp.element,l=window.wp.data,r=window.wp.coreData,o=window.wp.components,a=window.wp.compose,i=window.wp.editor;function s(e){return s="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},s(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n){return(t=function(e){var t=function(e){if("object"!=s(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==s(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=Array(t);n<t;n++)l[n]=e[n];return l}var f=(window.lazyblocksTemplatesData||{}).used_post_types_for_templates;(0,t.registerPlugin)("lazy-blocks-template",{render:function(){var t,s,c=(0,l.useSelect)((function(e){var t=e("core/editor").getCurrentPostType,n=e("core").getPostTypes,l=e("core/block-editor").getBlocks;return{postType:t(),postTypes:n({show_ui:!0,per_page:-1})||[],blocks:l()}}),[]),y=c.postType,m=c.postTypes,w=c.blocks,_=(t=(0,r.useEntityProp)("postType",y,"meta"),s=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var l,r,o,a,i=[],s=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(l=o.call(n)).done)&&(i.push(l.value),i.length!==t);s=!0);}catch(e){c=!0,r=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return i}}(t,s)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(t,s)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),g=_[0],v=_[1],d=g._lzb_template_post_types||[],h=g._lzb_template_lock||"",k=g._lzb_template_blocks||"";function O(e,t){v(u(u({},g),{},p({},e,t)))}function S(e){var t=[];return e.forEach((function(e){var n=[e.name,e.attributes];e.innerBlocks&&e.innerBlocks.length&&n.push(S(e.innerBlocks)),t.push(n)})),t}var z=(0,n.useCallback)((0,a.useDebounce)((function(e,t){var n=encodeURIComponent(JSON.stringify(S(e)));t!==n&&O("_lzb_template_blocks",n)}),500),[]);(0,n.useEffect)((function(){z(w,k)}),[w,k,z]);var P=[{label:(0,e.__)("None","lazy-blocks"),value:""},{label:(0,e.__)("All - prevents all operations","lazy-blocks"),value:"all"},{label:(0,e.__)("Insert - prevents inserting new blocks, but allows moving existing ones","lazy-blocks"),value:"insert"},{label:(0,e.__)("Content Only - prevents all operations, except the content editing.","lazy-blocks"),value:"contentOnly"}],j=[],E=[];return m.filter((function(e){return e.viewable&&"lazyblocks"!==e.slug&&"lazyblocks_templates"!==e.slug&&"attachment"!==e.slug})).forEach((function(e){var t=e.label;e.labels&&e.labels.singular_name&&(t=e.labels.singular_name),E.push(e.slug),j.push({label:t,value:e.slug,disabled:f.includes(e.slug)})})),d&&d.length&&d.forEach((function(e){E.includes(e)||j.push({label:e,value:e})})),wp.element.createElement(i.PluginDocumentSettingPanel,{name:"LZBTemplateSettings",title:(0,e.__)("Template Settings","lazy-blocks"),className:"lzb-template-settings-panel"},wp.element.createElement(o.PanelRow,null,wp.element.createElement("div",{style:{width:"100%"}},wp.element.createElement(o.SelectControl,{label:(0,e.__)("Post Types","lazy-blocks"),multiple:!0,options:j,value:d,onChange:function(e){O("_lzb_template_post_types",e)},__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}))),wp.element.createElement(o.PanelRow,null,wp.element.createElement("div",{style:{width:"100%"}},wp.element.createElement(o.SelectControl,{label:(0,e.__)("Template Lock","lazy-blocks"),options:P,value:h,onChange:function(e){O("_lzb_template_lock",e)},__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}))))}})})();