"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),l=require("gsap"),J=require("@gsap/react"),M=require("../../node_modules/.pnpm/gsap@3.13.0/node_modules/gsap/ScrollTrigger.cjs.js"),Q=require("../../utils/debounce.cjs.js"),t=require("../../src/modules/CallToAction/callToAction.module.css"),k=require("../../types/analytics/analytics.cjs.js"),x=require("../../components/HighlightedTitle/HighlightedTitle.cjs.js"),h=require("../../components/Typography/Typography.cjs.js"),A=require("../../components/Icon/Icon.cjs.js"),L=require("../../components/Icon/constants.cjs.js"),U=require("../../components/Button/Button.cjs.js");l.registerPlugin(M.ScrollTrigger);const Y=({subtitle:B,titleTop:P,scrollableLabels:R,titleBottom:W,description:O,hsaText:X,buttonText:z,buttonLink:u,backgroundImage:F})=>{const d=n.useRef(null),c=n.useRef(null),T=n.useRef(null),y=n.useRef(null),f=n.useRef(null),N=n.useRef(null),g=n.useRef(null),b=n.useRef(null),v=n.useRef(null),D=()=>{var s;(s=window.eventBus)==null||s.emit("analytics",{event:k.EAnalyticsEvent.ctaClicked,type:k.EAnalyticsEventType.interaction,component:"CallToAction",element:"primary_button",payload:{link:u}})};return J.useGSAP(()=>{var C,H,S;const s=d.current&&d.current.getBoundingClientRect().top<window.innerHeight*.8,p=(C=T.current)==null?void 0:C.querySelector("p"),q=(H=N.current)==null?void 0:H.querySelector("p"),$=[p,y.current,c.current,f.current,q,g.current,b.current,v.current].filter(Boolean);l.set($,{clipPath:"inset(0% 0% 100% 0%)",yPercent:100});const m=l.to([p,y.current,c.current,f.current,q,g.current,b.current,v.current],{clipPath:"inset(0% 0% 0% 0%)",yPercent:0,duration:1,ease:"power2.out",delay:.3,stagger:{amount:1,from:"start"},paused:!0});M.ScrollTrigger.create({trigger:d.current,start:"top 80%",end:"+=500",onEnter:()=>m.play(),onEnterBack:()=>m.play(),onLeaveBack:()=>m.reverse()}),s&&l.delayedCall(.1,()=>{m.play()});const r=(S=c.current)==null?void 0:S.querySelector("ul");if(!r)return;const _=r.innerHTML;let i=null,w=!0;const E=()=>{i&&i.kill(),r.innerHTML=_,l.set(r,{y:0});const a=Array.from(r.querySelectorAll("li"));if(a.length<=1)return;const j=a[0].clientHeight;if(!j)return;l.set(c.current,{height:()=>j,overflow:"hidden"});const V=Array.from(a);V.forEach(I=>{r.appendChild(I.cloneNode(!0))});const G=w&&!s?.3:0;i=l.timeline({repeat:-1,delay:G,onRepeat:()=>{l.set(r,{y:0})}}),V.forEach((I,K)=>{i&&i.to({},{duration:2}).to(r,{y:`-${(K+1)*j}`,duration:.5,ease:"power1.inOut"})}),w=!1},o=Q.default(E,200);return E(),window.addEventListener("resize",o),()=>{var a;window.removeEventListener("resize",o),(a=o.kill)==null||a.call(o),i&&i.kill(),r&&(r.innerHTML=_,l.set(r,{y:0}))}},[R]),e.jsxs("section",{ref:d,className:t.root,children:[e.jsx("div",{className:t.backgroundImage,style:{backgroundImage:`url(${F})`}}),e.jsxs("div",{className:t.container,children:[e.jsx("div",{className:t.leftContent,children:e.jsxs("div",{className:t.content,children:[e.jsx("div",{ref:y,children:e.jsx(x.HighlightedTitle,{defaultVariant:"displayXl",mobileVariant:"displayMd",as:"div",className:t.title,title:P})}),e.jsx("div",{ref:c,className:t.scrollableLabelsWrapper,children:e.jsx("ul",{className:t.scrollableLabels,children:R.map((s,p)=>e.jsx("li",{className:t.scrollableLabel,children:e.jsx(h.Typography,{defaultVariant:"displayXl",mobileVariant:"displayMd",as:"span",children:s})},p))})}),e.jsx("div",{ref:f,children:e.jsx(x.HighlightedTitle,{defaultVariant:"displayXl",mobileVariant:"displayMd",as:"div",className:t.title,title:W})})]})}),e.jsx("div",{ref:T,className:t.subtitleWrapper,children:e.jsx(x.HighlightedTitle,{defaultVariant:"labelMd",mobileVariant:"labelSm",as:"div",className:t.subtitle,title:B})}),e.jsx("div",{ref:N,className:t.arrowWrapper,children:e.jsxs(h.Typography,{defaultVariant:"labelMd",mobileVariant:"labelXs",emphasis:!0,className:t.arrow,as:"p",children:["(",e.jsx(A.Icon,{name:L.EIconName.ARROW_FORWARD}),")"]})}),e.jsx("div",{className:t.rightContent,children:e.jsxs("div",{className:t.descriptionWrapper,children:[e.jsx("div",{ref:g,children:e.jsx(h.Typography,{as:"p",defaultVariant:"bodyLg",mobileVariant:"bodyMd",className:t.description,children:O})}),e.jsx("div",{ref:b,className:t.buttonWrapper,children:u&&e.jsx(U.Button,{as:u?"a":"button",href:u,variant:"secondary",size:"lg",onClick:D,children:z})}),e.jsxs("div",{ref:v,className:t.hsaEligible,children:[e.jsx(A.Icon,{name:L.EIconName.CIRCLE_CHECK_FILL,className:t.checkIcon}),e.jsx(h.Typography,{as:"p",defaultVariant:"bodySm",mobileVariant:"bodySm",className:t.hsaText,children:X})]})]})})]})]})};exports.CallToAction=Y;
