import{makeGlobalSize as e,useEditorMode as t,makeStyle as r,getSingleColorVariable as o,getGlobalColorStateStyle as n,composeSize as a,removePaddingYInStyle as c}from"@gem-sdk/core";import{useState as i,useEffect as s,useMemo as m}from"react";import l from"./useMountTransition.js";import{useGetProductId as d}from"../../hooks/useGetProductId.js";import{composeIconSvg as p}from"../common/helpers.js";let useAccordionItem=u=>{let{accordions:f,index:g,builderProps:v,parentSetting:h={},parentStyle:j={},handleDropDown:$}=u,{iconPosition:w,titleTypo:I,iconCollapse:k,iconExpand:x,iconSvg:A}=h;delete I?.attrs?.color;let{itemContentSpacing:b,iconColor:y,contentSizePadding:G}=j,M=f?.includes(g?.toString()??""),P=e(G),S=t(),[T,q]=i(M),z=l(T||!1,500);s(()=>{q(M)},[M]);let B=m(()=>p({isShow:M,iconExpand:x,iconCollapse:k,iconSvg:A}),[M,x,k,A]),C=m(()=>r({fd:"left"===w?"row":"row-reverse",jc:"right"===w?"space-between":""}),[w]),D=(e,t)=>{!e.target.closest(".gp-text")&&$&&t&&(q(!T),$(t))},E=m(()=>{let e={normal:y?.normal??"transparent",hover:y?.hover??y?.active??y?.normal??"transparent",active:y?.active??y?.normal??"transparent"};return M?r({c:o(e?.active)}):n("c",e)},[y,M]),{refContainer:F,productID:H}=d(),J=m(()=>{let e=`gp-accordion-item-${v?.uid}-${g}`;return H?`${e}-${H}`:e},[v?.uid,g,H]),K=m(()=>{let e={...G&&P.padding,...b?.type||G?{}:a(b?.custom)};return M?e:c(e)},[G,b,M,P]),L=m(()=>z||T||"edit"!==S,[z,T,S]);return{productID:H,isShow:M,getIdDropdownItem:D,makeIcon:B,refContainer:F,uniqueId:J,isRenderChildren:L,composePosition:C,composeIconColor:E,composeContentSizeStyle:K,hasTransitionedIn:z,isMounted:T}};export{useAccordionItem as default};
