"use client";import"./chunk-GAKP4BZM.mjs";import{a as u}from"./chunk-EI3IJHIE.mjs";import"./chunk-HDKBSM4X.mjs";import"./chunk-MSXDLSXH.mjs";import{c as b}from"./chunk-S7CSCIW4.mjs";import"./chunk-JZXLCA2E.mjs";import{useCallback as y,useEffect as I,useMemo as V,useState as h}from"react";import{flattenValues as k}from"@uniformdev/canvas";import{UniformSlot as E,UniformText as F}from"@uniformdev/canvas-next-rsc/component";var f=({color:r,variant:a})=>b("flex flex-row overflow-x-auto ",{[`border-${r} border-b`]:r&&a==="bordered"}),p=({color:r,variant:a,tabItem:t,activeTabId:e})=>b("text-lg shrink-0 font-medium px-5 py-3",{[`text-${r}`]:r,[`border-${r}`]:t.id===e&&a==="bordered","border-b-2":a==="bordered","opacity-60 hover:opacity-100":t.id!==e,"border-transparent":t.id!==e&&a==="bordered"});import{Fragment as C,jsx as o,jsxs as N}from"react/jsx-runtime";var J=({slots:r,color:a,component:t,context:e,backgroundColor:g,spacing:T,border:c,fluidContent:x,fullHeight:B})=>{let m=t.variant||"default",[i,d]=h(t?.slots?.tabItems?.[0]?._id),n=V(()=>t?.slots?.tabItems?t.slots.tabItems.map(s=>({...k(s),id:s._id})):[],[t?.slots?.tabItems]);I(()=>{n.length&&(i||d(n[0]?.id||""))},[n,i]);let P=y(s=>{e.isContextualEditing&&d(s)},[e.isContextualEditing]);return N(u,{className:"flex flex-col gap-5",backgroundColor:g,spacing:T,border:c,fluidContent:x,fullHeight:B,children:[o("div",{className:f({color:a,variant:m}),children:n.map((s,l)=>o("button",{onClick:()=>d(s.id),className:p({color:a,variant:m,tabItem:s,activeTabId:i}),children:t?.slots?.tabItems?.[l]&&o(F,{onFocus:()=>P(s.id),context:e,parameterId:"text",component:t?.slots?.tabItems[l],placeholder:"Tab title"})},s.id))}),o(E,{data:t,context:e,slot:r.tabItems,children:({child:s,component:l})=>l._id===i?o(C,{children:s}):o(C,{})})]})};export{J as Tabs};
