(()=>{"use strict";const e=window.React,t=window.wp.blocks,a=window.wp.blockEditor,l=window.wp.data,s=window.wp.element,c=["ucla-wordpress-plugin/tab-item"],n=[["ucla-wordpress-plugin/tab-item",{}],["ucla-wordpress-plugin/tab-item",{}]],r=JSON.parse('{"UU":"ucla-wordpress-plugin/tabs"}');(0,t.registerBlockType)(r.UU,{icon:{src:(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20"},(0,e.createElement)("rect",{x:"0",fill:"none",width:"20",height:"20"}),(0,e.createElement)("g",null,(0,e.createElement)("path",{d:"M13.824 88H9.536v2.88h-2.88v1.344h2.88v2.88h1.408v-2.88h2.88zM0 17.92V0h20.48v17.92H0zM6.4 1.28H1.28v3.84H6.4V1.28zm6.4 0H7.68v3.84h5.12V1.28zm6.4 0h-5.12v3.84h5.12V1.28zm0 5.056H1.28v9.024H19.2V6.336z"})))},edit:({attributes:t,setAttributes:r,clientId:i,isSelected:o})=>{let{tabValues:u,currentTab:b}=t;const m=(0,l.useSelect)((e=>e("core/block-editor").getBlocks(i)),[i]),d=(0,a.useBlockProps)(),p=(0,a.useInnerBlocksProps)({className:"ucla-tabpanels"},{allowedBlocks:c,template:n,orientation:"horizontal",renderAppender:!1});(0,s.useEffect)((()=>{if(m&&m.length>0){const e=m.map((({clientId:e,attributes:{tabLabel:t="Tab"}})=>({clientId:e,tabLabel:t})));JSON.stringify(e)!==JSON.stringify(u)&&r({tabValues:e})}}),[m]);const w=(0,s.useMemo)((()=>m&&0!==m.length?m.map(((t,a)=>{if(!t||!t.clientId)return null;const{clientId:s,attributes:{tabLabel:c="Tab"}={}}=t,n=(c||"Tab").replace(/\s+/g,"-").toLowerCase();return(0,e.createElement)("button",{key:s,type:"button",onClick:()=>{return e=a,t=s,(0,l.dispatch)("core/block-editor").selectBlock(t),void r({currentTab:e});var e,t},className:"ucla-tablink"+(b===a?" is-active":""),id:`ucla-tab-${n}-${a}`,"aria-selected":b===a,role:"tab"},c)})):null),[m,b]);return(0,e.createElement)("div",{...d},(0,e.createElement)("div",{className:"ucla-tabs"},(0,e.createElement)("nav",{className:"ucla-tabslist",role:"tablist"},w),(0,e.createElement)("section",{...p})),o&&(0,e.createElement)(a.InnerBlocks.ButtonBlockAppender,null))},save:({attributes:t})=>{const l=a.useBlockProps.save();let{tabValues:s}=t;return(0,e.createElement)("div",{...l},(0,e.createElement)("div",{className:"ucla-tabs"},(0,e.createElement)("nav",{className:"ucla-tabslist",role:"tablist"},s&&s.map((({clientId:t,tabLabel:a},l)=>(a.replace(/\s+/g,"-").toLowerCase(),(0,e.createElement)("button",{key:t,className:"ucla-tablink"+(0===l?" is-active":""),role:"tab","aria-selected":0===l},a))))),(0,e.createElement)("section",{className:"ucla-tabpanels"},(0,e.createElement)(a.InnerBlocks.Content,null))))}})})();