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