{"version":3,"file":"LottieOnceInView.CnFJoxEP.mjs","names":["useRef","useState","useMemo","useCallback","__esmMin","init_ssg_sandbox_shims","de","init_npm_react_18_3_1","window","te","pe","ce","_e","init_jsx_runtime","ne","c","useInView","init_framer_motion_DhsWWWsN","init_framer_BWFVvmND","useIsStaticRenderer","addPropertyControls","ControlType","loadLottieWeb","w","lottieScriptPromise","check","resolve","script","reject","LottieOnceInView","props","isStatic","hostRef","mountRef","animRef","status","setStatus","inView","threshold","rootMargin","canLoad","lottieFile","destroyAnimation","anim","ensureAnimation","lottie","speed","dir","direction","onComplete","total","loop","renderer","showPlaceholder","style","placeholderTextColor","placeholderFont","placeholderText","init_LottieOnceInView"],"sources":["https:/framerusercontent.com/modules/06vfRQH0XB7gNderyPOC/z2KDRRcrSY5L6AdcDqry/LottieOnceInView.js"],"sourcesContent":["// Instructions: Create a Framer component that plays a Lottie animation once every time it enters the viewport, pauses at the end, and replays once if it exits and re-enters.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";let lottieScriptPromise=null;function loadLottieWeb(){if(typeof window===\"undefined\")return Promise.reject(new Error(\"No window\"));const w=window;if(w.lottie)return Promise.resolve(w.lottie);if(lottieScriptPromise)return lottieScriptPromise;lottieScriptPromise=new Promise((resolve,reject)=>{const existing=document.querySelector('script[data-framer-lottie-web=\"true\"]');if(existing){const check=()=>{if(window.lottie)resolve(window.lottie);else setTimeout(check,30);};check();return;}const script=document.createElement(\"script\");script.src=\"https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js\";script.async=true;script.setAttribute(\"data-framer-lottie-web\",\"true\");script.onload=()=>resolve(window.lottie);script.onerror=()=>reject(new Error(\"Failed to load lottie-web\"));document.head.appendChild(script);});return lottieScriptPromise;}/**\n * @framerIntrinsicWidth 240\n * @framerIntrinsicHeight 240\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function LottieOnceInView(props){const{lottieFile=\"https://assets10.lottiefiles.com/packages/lf20_jcikwtux.json\",renderer=\"svg\",loop=false,speed=1,direction=\"forward\",threshold=.25,rootMargin=\"0px\",backgroundColor=\"#FFFFFF\",placeholderText=\"Add a lottie.json file\",placeholderTextColor=\"#000000\",placeholderFont,style}=props;const isStatic=useIsStaticRenderer();const hostRef=useRef(null);const mountRef=useRef(null);const animRef=useRef(null);const[status,setStatus]=useState(\"idle\");const inView=useInView(hostRef,{amount:Math.max(0,Math.min(1,threshold)),margin:rootMargin,once:false});const canLoad=useMemo(()=>{return typeof window!==\"undefined\"&&!!lottieFile;},[lottieFile]);const destroyAnimation=useCallback(()=>{const anim=animRef.current;if(anim){try{anim.removeEventListener?.(\"complete\",anim.__framerOnComplete);}catch{}try{anim.destroy?.();}catch{}}animRef.current=null;if(mountRef.current)mountRef.current.innerHTML=\"\";},[]);const ensureAnimation=useCallback(async()=>{if(!canLoad)return;if(!mountRef.current)return;try{const lottie=await loadLottieWeb();if(!mountRef.current)return;destroyAnimation();const anim=lottie.loadAnimation({container:mountRef.current,renderer,loop,autoplay:false,path:lottieFile,rendererSettings:{preserveAspectRatio:\"xMidYMid meet\",clearCanvas:true,progressiveLoad:true,hideOnTransparent:true}});anim.setSpeed?.(Math.max(.05,speed));const dir=direction===\"reverse\"?-1:1;anim.setDirection?.(dir);const onComplete=()=>{try{const total=anim.getDuration?.(true);if(typeof total===\"number\"&&isFinite(total)){anim.goToAndStop?.(Math.max(0,total-1),true);}else{anim.pause?.();}}catch{try{anim.pause?.();}catch{}}};anim.__framerOnComplete=onComplete;anim.addEventListener?.(\"complete\",onComplete);animRef.current=anim;startTransition(()=>setStatus(\"ready\"));}catch{startTransition(()=>setStatus(\"error\"));}},[canLoad,destroyAnimation,direction,lottieFile,loop,renderer,speed]);useEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(!canLoad)return;ensureAnimation();return()=>{destroyAnimation();};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[ensureAnimation,destroyAnimation,isStatic,canLoad]);useEffect(()=>{if(isStatic)return;const anim=animRef.current;if(!anim)return;// Play once every time it enters the viewport.\nif(inView){try{anim.stop?.();const dir=direction===\"reverse\"?-1:1;anim.setDirection?.(dir);anim.setSpeed?.(Math.max(.05,speed));anim.play?.();}catch{}}},[inView,direction,speed,isStatic]);// If no file, show placeholder (also useful in canvas/static render).\nconst showPlaceholder=isStatic||!lottieFile||status===\"error\";return /*#__PURE__*/_jsxs(\"div\",{ref:hostRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",backgroundColor,...style},\"aria-label\":\"Lottie animation\",role:\"img\",children:[/*#__PURE__*/_jsx(\"div\",{ref:mountRef,style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\"},\"aria-hidden\":showPlaceholder?true:undefined}),showPlaceholder&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:12,color:placeholderTextColor,textAlign:\"center\",...placeholderFont},children:/*#__PURE__*/_jsx(\"span\",{style:{width:\"max-content\"},children:placeholderText})})]});}addPropertyControls(LottieOnceInView,{lottieFile:{type:ControlType.File,title:\"Lottie JSON\",allowedFileTypes:[\"json\",\"lottie\"]},renderer:{type:ControlType.Enum,title:\"Renderer\",options:[\"svg\",\"canvas\"],optionTitles:[\"SVG\",\"Canvas\"],defaultValue:\"svg\",displaySegmentedControl:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:1,min:.1,max:4,step:.05},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"forward\",\"reverse\"],optionTitles:[\"Forward\",\"Reverse\"],defaultValue:\"forward\",displaySegmentedControl:true},threshold:{type:ControlType.Number,title:\"InView %\",defaultValue:.25,min:0,max:1,step:.05},rootMargin:{type:ControlType.String,title:\"Root Margin\",defaultValue:\"0px\",placeholder:\"e.g. 0px 0px -10% 0px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},placeholderText:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Add a lottie.json file\"},placeholderTextColor:{type:ControlType.Color,title:\"Placeholder Text\",defaultValue:\"#000000\"},placeholderFont:{type:ControlType.Font,title:\"Placeholder Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\",textAlign:\"center\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LottieOnceInView\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"240\",\"framerIntrinsicWidth\":\"240\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LottieOnceInView.map"],"mappings":"A,2RACoR,SAASsB,GAAe,CAAC,GAAUd,IAAS,OAAY,OAAO,QAAQ,OAAO,gBAAI,MAAM,WAAW,CAAC,EAAE,IAAMe,EAAEf,EAAmrB,OAAzqBe,EAAE,OAAc,QAAQ,QAAQA,EAAE,MAAM,EAAKC,IAA+C,EAAoB,IAAI,SAAS,EAAQ,IAAS,CAAgF,GAAhE,SAAS,cAAc,uCAAmD,EAAE,CAAC,IAAMC,MAAU,CAAIjB,EAAO,OAAOkB,EAAQlB,EAAO,MAAM,EAAO,WAAWiB,EAAM,EAAE,CAAE,EAAEA,EAAM,EAAE,MAAO,CAAC,IAAME,EAAO,SAAS,cAAc,QAAQ,EAAE,EAAO,IAAI,yEAAyE,EAAO,MAAM,GAAKA,EAAO,aAAa,yBAAyB,MAAM,EAA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