import{Cu as e,Du as t,Eu as n,Pd as r,Su as i,Yl as a,_d as o,_u as s,bu as c,gu as l,hu as u,mu as d,vu as f,wu as p,xu as m,yu as h,zd as g}from"./index-Q5R6-AeA.js";var _=g(r(),1),v=n(),y=`Accordion`,b=[`Home`,`End`,`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`],[x,S,C]=i(y),[w,ee]=e(y,[C,f]),T=f(),E=_.forwardRef((e,t)=>{let{type:n,...r}=e,i=r,a=r;return(0,v.jsx)(x.Provider,{scope:e.__scopeAccordion,children:n===`multiple`?(0,v.jsx)(M,{...a,ref:t}):(0,v.jsx)(j,{...i,ref:t})})});E.displayName=y;var[D,O]=w(y),[k,A]=w(y,{collapsible:!1}),j=_.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:a=!1,...o}=e,[s,l]=c({prop:n,defaultProp:r??``,onChange:i,caller:y});return(0,v.jsx)(D,{scope:e.__scopeAccordion,value:_.useMemo(()=>s?[s]:[],[s]),onItemOpen:l,onItemClose:_.useCallback(()=>a&&l(``),[a,l]),children:(0,v.jsx)(k,{scope:e.__scopeAccordion,collapsible:a,children:(0,v.jsx)(F,{...o,ref:t})})})}),M=_.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=c({prop:n,defaultProp:r??[],onChange:i,caller:y}),l=_.useCallback(e=>s((t=[])=>[...t,e]),[s]),u=_.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,v.jsx)(D,{scope:e.__scopeAccordion,value:o,onItemOpen:l,onItemClose:u,children:(0,v.jsx)(k,{scope:e.__scopeAccordion,collapsible:!0,children:(0,v.jsx)(F,{...a,ref:t})})})}),[N,P]=w(y),F=_.forwardRef((e,n)=>{let{__scopeAccordion:r,disabled:i,dir:a,orientation:o=`vertical`,...s}=e,c=t(_.useRef(null),n),l=S(r),u=d(a)===`ltr`,f=m(e.onKeyDown,e=>{if(!b.includes(e.key))return;let t=e.target,n=l().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),i=n.length;if(r===-1)return;e.preventDefault();let a=r,s=i-1,c=()=>{a=r+1,a>s&&(a=0)},d=()=>{a=r-1,a<0&&(a=s)};switch(e.key){case`Home`:a=0;break;case`End`:a=s;break;case`ArrowRight`:o===`horizontal`&&(u?c():d());break;case`ArrowDown`:o===`vertical`&&c();break;case`ArrowLeft`:o===`horizontal`&&(u?d():c());break;case`ArrowUp`:o===`vertical`&&d();break}n[a%i].ref.current?.focus()});return(0,v.jsx)(N,{scope:r,disabled:i,direction:a,orientation:o,children:(0,v.jsx)(x.Slot,{scope:r,children:(0,v.jsx)(p.div,{...s,"data-orientation":o,ref:c,onKeyDown:i?void 0:f})})})}),I=`AccordionItem`,[L,R]=w(I),z=_.forwardRef((e,t)=>{let{__scopeAccordion:n,value:r,...i}=e,a=P(I,n),o=O(I,n),s=T(n),c=h(),u=r&&o.value.includes(r)||!1,d=a.disabled||e.disabled;return(0,v.jsx)(L,{scope:n,open:u,disabled:d,triggerId:c,children:(0,v.jsx)(l,{"data-orientation":a.orientation,"data-state":K(u),...s,...i,ref:t,disabled:d,open:u,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})});z.displayName=I;var B=`AccordionHeader`,V=_.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,i=P(y,n),a=R(B,n);return(0,v.jsx)(p.h3,{"data-orientation":i.orientation,"data-state":K(a.open),"data-disabled":a.disabled?``:void 0,...r,ref:t})});V.displayName=B;var H=`AccordionTrigger`,U=_.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,i=P(y,n),a=R(H,n),o=A(H,n),c=T(n);return(0,v.jsx)(x.ItemSlot,{scope:n,children:(0,v.jsx)(s,{"aria-disabled":a.open&&!o.collapsible||void 0,"data-orientation":i.orientation,id:a.triggerId,...c,...r,ref:t})})});U.displayName=H;var W=`AccordionContent`,G=_.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,i=P(y,n),a=R(W,n),o=T(n);return(0,v.jsx)(u,{role:`region`,"aria-labelledby":a.triggerId,"data-orientation":i.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":`var(--radix-collapsible-content-height)`,"--radix-accordion-content-width":`var(--radix-collapsible-content-width)`,...e.style}})});G.displayName=W;function K(e){return e?`open`:`closed`}var q=E,J=z,Y=V,X=U,Z=G;function Q({...e}){return(0,v.jsx)(q,{"data-slot":`accordion`,...e})}function $({className:e,...t}){return(0,v.jsx)(J,{"data-slot":`accordion-item`,className:a(`border-b last:border-b-0`,e),...t})}function te({className:e,children:t,...n}){return(0,v.jsx)(Y,{className:`flex`,children:(0,v.jsxs)(X,{"data-slot":`accordion-trigger`,className:a(`focus-visible:border-gray-950 focus-visible:ring-gray-950/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180 dark:focus-visible:border-gray-300 dark:focus-visible:ring-gray-300/50 hover:no-underline mx-4 my-2`,e),...n,children:[t,(0,v.jsx)(o,{className:`text-gray-500 pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200 dark:text-gray-400`})]})})}function ne({className:e,children:t,...n}){return(0,v.jsx)(Z,{"data-slot":`accordion-content`,className:`data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm mx-4`,...n,children:(0,v.jsx)(`div`,{className:a(`pt-0 pb-4`,e),children:t})})}export{te as i,ne as n,$ as r,Q as t};