{"version":3,"file":"SitePreloader.CccM4r-R.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/xEmlnr4lpdRxMK88F8yd/m5gYg0LLcpIGepPzBAfa/SitePreloader.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";/**\n * ULTIMATE SITE PRELOADER (FINAL)\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 450\n * @framerIntrinsicHeight 450\n */export default function SitePreloader(props){const{svgFile,strokeColor,strokeWidth,fillColor,loadingType,forcePlay,minDuration,loadingText,textStyle,textColor,textGradient,textImage,font,zIndex,pageBackgroundColor}=props;// State\nconst[isReady,setIsReady]=React.useState(false)// SVG is measured and hidden?\n;const[isLoaded,setIsLoaded]=React.useState(false)// Page content loaded?\n;const[shouldRender,setShouldRender]=React.useState(true)// Component mounted?\n;const[svgContent,setSvgContent]=React.useState(null);const containerRef=React.useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;// --- 1. SVG Processing (Strip Fills & Prepare) ---\nReact.useEffect(()=>{if(!svgFile)return;setIsReady(false)// Hide while fetching new file\n;fetch(svgFile).then(res=>res.text()).then(text=>{const parser=new DOMParser;const doc=parser.parseFromString(text,\"image/svg+xml\");const svgElement=doc.querySelector(\"svg\");if(svgElement){// AGGRESSIVE CLEANING: Remove all fills and strokes from the raw HTML\n// We will control these via CSS to prevent \"Flash of Content\"\nconst elements=svgElement.querySelectorAll(\"*\");elements.forEach(el=>{el.removeAttribute(\"fill\");el.removeAttribute(\"stroke\");el.style.fill=\"transparent\"// Inline override\n;});// Add a unique ID or class to scope styles if needed,\n// but we handle it via the parent container styles.\nsetSvgContent(svgElement.innerHTML);const viewBox=svgElement.getAttribute(\"viewBox\");if(containerRef.current&&viewBox){containerRef.current.setAttribute(\"viewBox\",viewBox);}}});},[svgFile]);// --- 2. Measure & Hide Paths (The \"No-Flash\" Logic) ---\nReact.useLayoutEffect(()=>{if(!containerRef.current||!svgContent)return;// Select all potential drawing shapes\nconst paths=containerRef.current.querySelectorAll(\"path, circle, rect, polygon, polyline, ellipse\");// 1. HIDE THEM ALL INSTANTLY\npaths.forEach(path=>{const len=path.getTotalLength?path.getTotalLength():3e3;path.style.strokeDasharray=len;path.style.strokeDashoffset=len// Fully hidden\n;path.style.fill=\"transparent\";path.style.stroke=strokeColor;path.style.strokeWidth=`${strokeWidth}px`;path.style.transition=\"none\"// No transition during setup\n;});// 2. REVEAL CONTAINER\n// Now that paths are hidden via dashoffset, we can show the container\nrequestAnimationFrame(()=>{setIsReady(true);});},[svgContent,strokeColor,strokeWidth]);// --- 3. Preloading Logic (Timer vs Smart) ---\nReact.useEffect(()=>{if(isCanvas||!isReady)return;const startTime=performance.now();let animationTriggered=false;// Function to trigger the drawing animation\nconst startAnimation=()=>{if(animationTriggered||!containerRef.current)return;animationTriggered=true;const paths=containerRef.current.querySelectorAll(\"path, circle, rect, polygon, polyline, ellipse\");paths.forEach(path=>{// Force reflow\npath.getBoundingClientRect();// Animate to 0\npath.style.transition=`stroke-dashoffset ${minDuration}s ease-in-out`;path.style.strokeDashoffset=0;});};// Function to wrap things up\nconst finalize=()=>{const elapsed=(performance.now()-startTime)/1e3;// IF FAST LOAD (<1s) AND NOT FORCED: Exit immediately without playing\nif(loadingType===\"smart\"&&!forcePlay&&elapsed<1){setShouldRender(false);return;}// OTHERWISE: Ensure animation plays\nstartAnimation();// Wait for animation to finish before showing Fill\nsetTimeout(()=>{setIsLoaded(true);},minDuration*1e3);};// A. TIMER MODE\nif(loadingType===\"timer\"){startAnimation()// Start immediately\n;setTimeout(()=>{setIsLoaded(true);},minDuration*1e3);}else{const checkReady=()=>{if(document.readyState===\"complete\"){// Deep media check\nconst media=[...document.images,...document.querySelectorAll(\"video\")];const allLoaded=media.every(m=>m.complete||m.readyState>=3);if(allLoaded)finalize();else setTimeout(checkReady,100);}else{window.addEventListener(\"load\",checkReady,{once:true});}};// Deep Watcher (MutationObserver)\n// Catches components injected late by React/Framer\nconst observer=new MutationObserver(()=>{// Reset timer check if new nodes added?\n// For simplicity, we trust the loop checkReady to catch new images\n});observer.observe(document.body,{childList:true,subtree:true});checkReady();return()=>observer.disconnect();}},[isReady,loadingType,forcePlay,minDuration,isCanvas]);// --- 4. Exit Sequence ---\nReact.useEffect(()=>{if(isLoaded){// Wait for Fill to fade in (0.8s), then remove component\nconst t=setTimeout(()=>setShouldRender(false),1e3);return()=>clearTimeout(t);}},[isLoaded]);// --- RENDER ---\nif(isCanvas){return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",background:pageBackgroundColor,display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:150,height:150,marginBottom:20,position:\"relative\"},children:svgFile?/*#__PURE__*/_jsx(\"img\",{src:svgFile,style:{width:\"100%\",height:\"100%\",objectFit:\"contain\"},alt:\"Preview\"}):/*#__PURE__*/_jsx(\"div\",{style:{border:\"1px dashed #ccc\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:10,color:\"#888\"},children:\"Upload SVG\"})}),/*#__PURE__*/_jsx(\"p\",{style:{margin:0,fontSize:12,color:\"#888\"},children:\"Preloader Preview\"})]});}return /*#__PURE__*/_jsx(AnimatePresence,{children:shouldRender&&/*#__PURE__*/_jsxs(motion.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.5},style:{position:\"fixed\",top:0,left:0,right:0,bottom:0,backgroundColor:pageBackgroundColor,zIndex:zIndex,display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{width:250,height:250,position:\"relative\",marginBottom:30},children:[/*#__PURE__*/_jsx(\"svg\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",overflow:\"visible\",position:\"absolute\",top:0,left:0,zIndex:2,opacity:isReady?1:0,transition:\"opacity 0.2s ease\"},// We inject content, but we've stripped attributes in JS\n// plus we rely on the useLayoutEffect to hide paths before opacity becomes 1\ndangerouslySetInnerHTML:{__html:svgContent||\"\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",zIndex:3,opacity:isLoaded?1:0,transition:\"opacity 0.8s ease\",background:fillColor,WebkitMaskImage:`url(${svgFile})`,maskImage:`url(${svgFile})`,WebkitMaskSize:\"contain\",maskSize:\"contain\",WebkitMaskRepeat:\"no-repeat\",maskRepeat:\"no-repeat\",WebkitMaskPosition:\"center\",maskPosition:\"center\"}})]}),/*#__PURE__*/_jsx(LoadingText,{text:loadingText,styleProps:{textStyle,textColor,textGradient,textImage,font}}),/*#__PURE__*/_jsx(\"style\",{children:`\n                        #preloader-svg-container path, \n                        #preloader-svg-container circle, \n                        #preloader-svg-container rect, \n                        #preloader-svg-container polygon, \n                        #preloader-svg-container polyline, \n                        #preloader-svg-container ellipse {\n                            fill: transparent !important;\n                            stroke-linecap: round;\n                            stroke-linejoin: round;\n                        }\n                        `})]},\"preloader-main\")});}// --- Helper ---\nfunction LoadingText({text,styleProps}){const{textStyle,textColor,textGradient,textImage,font}=styleProps;const base={...font,fontSize:16,fontWeight:600,textAlign:\"center\",margin:0};let specific={};if(textStyle===\"solid\")specific={color:textColor};else if(textStyle===\"gradient\")specific={background:textGradient,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:\"transparent\"};else if(textStyle===\"image\")specific={backgroundImage:`url(${textImage})`,backgroundSize:\"cover\",WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:\"transparent\"};return /*#__PURE__*/_jsx(\"h1\",{style:{...base,...specific},children:text});}addPropertyControls(SitePreloader,{loadingType:{type:ControlType.SegmentedEnum,title:\"Logic\",options:[\"timer\",\"smart\"],optionTitles:[\"Timer\",\"Smart\"],defaultValue:\"smart\"},forcePlay:{type:ControlType.Boolean,title:\"Force Play\",defaultValue:false,hidden:props=>props.loadingType===\"timer\",description:\"If ON, plays animation even if page loads instantly.\"},minDuration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.5,max:10,step:.5,unit:\"s\"},pageBackgroundColor:{type:ControlType.Color,title:\"Page BG\",defaultValue:\"#FFFFFF\"},svgFile:{type:ControlType.File,title:\"SVG Logo\",allowedFileTypes:[\"svg\"]},strokeColor:{type:ControlType.Color,title:\"Stroke Color\",defaultValue:\"#000000\"},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:2,min:1,max:20},fillColor:{type:ControlType.Color,title:\"Fill Color\",defaultValue:\"#0099FF\",description:\"Supports Gradients and Solids.\"},loadingText:{type:ControlType.String,title:\"Text\",defaultValue:\"Loading...\"},textStyle:{type:ControlType.Enum,title:\"Text Style\",options:[\"solid\",\"gradient\",\"image\"],optionTitles:[\"Solid\",\"Gradient\",\"Image Mask\"],defaultValue:\"solid\"},textColor:{type:ControlType.Color,title:\"Text Color\",hidden:props=>props.textStyle!==\"solid\",defaultValue:\"#333\"},textGradient:{type:ControlType.Color,title:\"Text Gradient\",hidden:props=>props.textStyle!==\"gradient\",defaultValue:\"linear-gradient(90deg, #FF0080 0%, #7928CA 100%)\"},textImage:{type:ControlType.Image,title:\"Text Image\",hidden:props=>props.textStyle!==\"image\"},zIndex:{type:ControlType.Number,title:\"Z-Index\",defaultValue:9999}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SitePreloader\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"450\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"450\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL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