"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let _ of __getOwnPropNames(t))__hasOwnProp.call(e,_)||_===r||__defProp(e,_,{get:()=>t[_],enumerable:!(o=__getOwnPropDesc(t,_))||o.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?r:__defProp(r,"default",{value:e,enumerable:!0}),e)),__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),edit_exports={};__export(edit_exports,{TabBlockEdit:()=>TabBlockEdit}),module.exports=__toCommonJS(edit_exports);var import_i18n=require("@wordpress/i18n"),import_block_editor=require("@wordpress/block-editor"),import_clsx=__toESM(require("clsx")),import_element=require("@wordpress/element"),import_block_templates=require("@woocommerce/block-templates"),import_components=require("@woocommerce/components"),import_tab_button=require("./tab-button");function TabBlockEdit({setAttributes:e,attributes:t,context:r}){const o=(0,import_block_templates.useWooBlockProps)(t),{id:_,title:c,_templateBlockOrder:n,isSelected:p}=t,l=(0,import_clsx.default)("wp-block-woocommerce-product-tab__content",{"is-selected":p}),[m,a]=(0,import_element.useState)(!1);return(0,import_element.useEffect)(()=>{if(!r.selectedTab)return;const t=r.selectedTab===_;if(e({isSelected:t}),t)return void a(!0);const o=setTimeout(a,300,!0);return()=>clearTimeout(o)},[r.selectedTab,_,e]),(0,import_element.createElement)("div",{...o},(0,import_element.createElement)(import_tab_button.TabButton,{id:_,selected:p,order:n},c),(0,import_element.createElement)("div",{id:`woocommerce-product-tab__${_}-content`,"aria-labelledby":`woocommerce-product-tab__${_}`,role:"tabpanel",className:l},(0,import_element.createElement)(import_components.__experimentalErrorBoundary,{errorMessage:(0,import_i18n.__)("An unexpected error occurred in this tab. Make sure any unsaved changes are saved and then try reloading the page to see if the error recurs.","woocommerce"),onError:(e,t)=>{console.error(`Error caught in tab '${_}'`,e,t)}},m&&(0,import_element.createElement)(import_block_editor.InnerBlocks,{templateLock:"contentOnly"}))))}