import{c as e,a as r,j as a,b as o,u as n,r as s,f as t,P as i,o as c}from"./ui-vendor-Dyu0xMC9.js";import{R as d,r as l}from"./react-vendor-BiKEbLqf.js";import{c as p,R as f,T as m,b as u}from"./index-D9xaiIhE.js";import{c as h}from"./index-CxSR60Bh.js";import{C as x}from"./chevron-right-LutMVzxT.js";var b="Accordion",j=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[v,w,A]=e(b),[g,y]=r(b,[A,p]),_=p(),N=d.forwardRef((e,r)=>{const{type:o,...n}=e,s=n,t=n;return a.jsx(v.Provider,{scope:e.__scopeAccordion,children:"multiple"===o?a.jsx(O,{...t,ref:r}):a.jsx(D,{...s,ref:r})})});N.displayName=b;var[R,C]=g(b),[I,k]=g(b,{collapsible:!1}),D=d.forwardRef((e,r)=>{const{value:n,defaultValue:s,onValueChange:t=()=>{},collapsible:i=!1,...c}=e,[l,p]=o({prop:n,defaultProp:s??"",onChange:t,caller:b});return a.jsx(R,{scope:e.__scopeAccordion,value:d.useMemo(()=>l?[l]:[],[l]),onItemOpen:p,onItemClose:d.useCallback(()=>i&&p(""),[i,p]),children:a.jsx(I,{scope:e.__scopeAccordion,collapsible:i,children:a.jsx(H,{...c,ref:r})})})}),O=d.forwardRef((e,r)=>{const{value:n,defaultValue:s,onValueChange:t=()=>{},...i}=e,[c,l]=o({prop:n,defaultProp:s??[],onChange:t,caller:b}),p=d.useCallback(e=>l((r=[])=>[...r,e]),[l]),f=d.useCallback(e=>l((r=[])=>r.filter(r=>r!==e)),[l]);return a.jsx(R,{scope:e.__scopeAccordion,value:c,onItemOpen:p,onItemClose:f,children:a.jsx(I,{scope:e.__scopeAccordion,collapsible:!0,children:a.jsx(H,{...i,ref:r})})})}),[P,V]=g(b),H=d.forwardRef((e,r)=>{const{__scopeAccordion:o,disabled:c,dir:l,orientation:p="vertical",...f}=e,m=d.useRef(null),u=n(m,r),h=w(o),x="ltr"===s(l),b=t(e.onKeyDown,e=>{if(!j.includes(e.key))return;const r=e.target,a=h().filter(e=>!e.ref.current?.disabled),o=a.findIndex(e=>e.ref.current===r),n=a.length;if(-1===o)return;e.preventDefault();let s=o;const t=n-1,i=()=>{s=o+1,s>t&&(s=0)},c=()=>{s=o-1,s<0&&(s=t)};switch(e.key){case"Home":s=0;break;case"End":s=t;break;case"ArrowRight":"horizontal"===p&&(x?i():c());break;case"ArrowDown":"vertical"===p&&i();break;case"ArrowLeft":"horizontal"===p&&(x?c():i());break;case"ArrowUp":"vertical"===p&&c()}const d=s%n;a[d].ref.current?.focus()});return a.jsx(P,{scope:o,disabled:c,direction:l,orientation:p,children:a.jsx(v.Slot,{scope:o,children:a.jsx(i.div,{...f,"data-orientation":p,ref:u,onKeyDown:c?void 0:b})})})}),z="AccordionItem",[E,K]=g(z),L=d.forwardRef((e,r)=>{const{__scopeAccordion:o,value:n,...s}=e,t=V(z,o),i=C(z,o),d=_(o),l=c(),p=n&&i.value.includes(n)||!1,m=t.disabled||e.disabled;return a.jsx(E,{scope:o,open:p,disabled:m,triggerId:l,children:a.jsx(f,{"data-orientation":t.orientation,"data-state":F(p),...d,...s,ref:r,disabled:m,open:p,onOpenChange:e=>{e?i.onItemOpen(n):i.onItemClose(n)}})})});L.displayName=z;var S="AccordionHeader",T=d.forwardRef((e,r)=>{const{__scopeAccordion:o,...n}=e,s=V(b,o),t=K(S,o);return a.jsx(i.h3,{"data-orientation":s.orientation,"data-state":F(t.open),"data-disabled":t.disabled?"":void 0,...n,ref:r})});T.displayName=S;var U="AccordionTrigger",M=d.forwardRef((e,r)=>{const{__scopeAccordion:o,...n}=e,s=V(b,o),t=K(U,o),i=k(U,o),c=_(o);return a.jsx(v.ItemSlot,{scope:o,children:a.jsx(m,{"aria-disabled":t.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:t.triggerId,...c,...n,ref:r})})});M.displayName=U;var q="AccordionContent",B=d.forwardRef((e,r)=>{const{__scopeAccordion:o,...n}=e,s=V(b,o),t=K(q,o),i=_(o);return a.jsx(u,{role:"region","aria-labelledby":t.triggerId,"data-orientation":s.orientation,...i,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function F(e){return e?"open":"closed"}B.displayName=q;var G=L,J=T,Q=M,W=B;const X=N,Y=l.forwardRef(({className:e,...r},o)=>a.jsx(G,{ref:o,className:h("border-b",e),...r}));Y.displayName="AccordionItem";const Z=l.forwardRef(({className:e,children:r,...o},n)=>a.jsx(J,{className:"flex",children:a.jsxs(Q,{ref:n,className:h("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...o,children:[r,a.jsx(x,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Z.displayName=Q.displayName;const $=l.forwardRef(({className:e,children:r,...o},n)=>a.jsx(W,{ref:n,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...o,children:a.jsx("div",{className:h("pb-4 pt-0",e),children:r})}));$.displayName=W.displayName;export{X as A,Y as a,Z as b,$ as c};