(()=>{var e={146:()=>{}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var c=t[r]={exports:{}};return e[r](c,c.exports,o),c.exports}(()=>{"use strict";const e=window.wp.editor,t=window.wp.data,r=window.wp.blocks,n=window.wp.components,c=window.wp.i18n,i=window.wp.element,s=window.wp.coreData,d=window.wp.blockEditor,l=window.wp.plugins;o(146);const a=window.ReactJSXRuntime,u=e=>e.some((e=>"woocommerce/legacy-template"===e.name||u(e.innerBlocks))),p=()=>{const{blocks:o,editedPostId:l}=(0,t.useSelect)((e=>({blocks:e(d.store).getBlocks(),editedPostId:e("core/edit-site").getEditedPostId()})),[]),{replaceBlocks:p}=(0,t.useDispatch)(d.store),w=(0,s.useEntityRecord)("postType","wp_template",l),m=(0,i.useMemo)((()=>u(o)),[o]),g=(0,i.useMemo)((()=>(e=>e.reduce(((e,t)=>"core/template-part"===t.name?e:[...e,t.clientId]),[]))(o)),[o]);return(0,a.jsx)(a.Fragment,{children:!m&&(0,a.jsx)(e.PluginDocumentSettingPanel,{name:"wc-block-editor-revert-button-panel",children:(0,a.jsxs)("div",{className:"wc-block-editor-revert-button-container",children:[(0,a.jsx)(n.Button,{variant:"secondary",onClick:()=>{p(g,(0,r.createBlock)("core/group",{layout:{inherit:!0,type:"constrained"}},[(0,r.createBlock)("woocommerce/legacy-template",{template:w?.record?.slug})]))},children:(0,c.__)("Revert to Classic Template","woocommerce")}),(0,a.jsx)("span",{children:(0,i.createInterpolateElement)((0,c.__)("The <strongText /> template doesn’t allow for reordering or customizing blocks, but might work better with your extensions.","woocommerce"),{strongText:(0,a.jsx)("strong",{children:w?.record?.title?.rendered?`${w.record.title.rendered} (Classic)`:""})})})]})})})},w=["single-product","archive-product","product-search-results","taxonomy-product_cat","taxonomy-product_tag","taxonomy-product_attribute"],m="woocommerce-blocks-revert-button-templates";let g;(0,t.subscribe)((()=>{const o=g,r=(0,t.select)("core/edit-site");if(!(e=>{if(!(e=>null===e)(t=e)&&t instanceof Object&&t.constructor===Object){const t=e.getEditedPostType();return"wp_template"===t||"wp_template_part"===t}var t;return!1})(r))return;if(g=r?.getEditedPostId(),o===g)return;const n=w.some((e=>g?.includes(e))),c=void 0!==e.PluginDocumentSettingPanel;if(n&&c){if((0,l.getPlugin)(m))return;return(0,l.registerPlugin)(m,{render:p})}void 0!==(0,l.getPlugin)(m)&&(0,l.unregisterPlugin)(m)}),"core/edit-site")})()})();