{"version":3,"file":"AspectLogo_Prod.DN_O3qMS.mjs","names":["useState","useRef","width","height"],"sources":["https:/framerusercontent.com/modules/exixtAlsKOrVXmqj9VvS/g0G8s15ZrJqtXysHroX4/AspectLogo_Prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Logo Uploader with Aspect Ratio\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function AspectRatioLogo(props){const{logoFile=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",fixedHeight=80,invertColors=false,style}=props;const[aspectRatio,setAspectRatio]=useState(1);const[isSVG,setIsSVG]=useState(false);const[svgSize,setSvgSize]=useState({width:1,height:1});const imgRef=useRef(null);const[isLoading,setIsLoading]=useState(true)// New state for loading\n;useEffect(()=>{if(!logoFile){startTransition(()=>{setAspectRatio(1);setIsSVG(false);setIsLoading(false);});return;}const isSvgFile=logoFile.endsWith(\".svg\");startTransition(()=>{setIsLoading(true);setIsSVG(isSvgFile);});if(isSvgFile){fetch(logoFile).then(res=>res.text()).then(svgText=>{const parser=new DOMParser;const doc=parser.parseFromString(svgText,\"image/svg+xml\");const svg=doc.querySelector(\"svg\");let newAspectRatio=1// Default aspect ratio\n;if(svg){let width=parseFloat(svg.getAttribute(\"width\")||\"0\");let height=parseFloat(svg.getAttribute(\"height\")||\"0\");if(!width||!height){const viewBox=svg.getAttribute(\"viewBox\");if(viewBox){const parts=viewBox.split(\" \").map(Number);if(parts.length===4){width=parts[2];height=parts[3];}}}if(width&&height){setSvgSize({width,height})// Kept as in original\n;newAspectRatio=width/height;}}startTransition(()=>{setAspectRatio(newAspectRatio);setIsLoading(false);});}).catch(()=>{startTransition(()=>{setAspectRatio(1)// Fallback on error\n;setIsLoading(false);});});}else{// For raster images, isLoading is true. The other useEffect will handle setting it to false.\n}},[logoFile]);// For raster images, get natural size\nuseEffect(()=>{if(isSVG||!logoFile){// If it's an SVG, or no logo file, this effect should not run or interfere.\n// isLoading state is managed by the primary effect for these cases.\nreturn;}const img=imgRef.current;if(img){const handleLoad=()=>{if(img.naturalWidth&&img.naturalHeight){startTransition(()=>{setAspectRatio(img.naturalWidth/img.naturalHeight);setIsLoading(false);});}else{// Image loaded but has no dimensions (e.g. broken but onload fired)\nstartTransition(()=>{setAspectRatio(1)// Fallback\n;setIsLoading(false);});}};const handleError=()=>{startTransition(()=>{setAspectRatio(1)// Fallback aspect ratio\n;setIsLoading(false);});};// Add event listeners\nimg.addEventListener(\"load\",handleLoad);img.addEventListener(\"error\",handleError);// Check if the image is already complete (e.g., from cache)\nif(img.complete){// If already complete, remove listeners and call handler to avoid double execution\nimg.removeEventListener(\"load\",handleLoad);img.removeEventListener(\"error\",handleError);if(img.naturalWidth&&img.naturalHeight){handleLoad()// Manually call if valid and complete\n;}else{handleError()// Manually call if broken and complete\n;}}return()=>{img.removeEventListener(\"load\",handleLoad);img.removeEventListener(\"error\",handleError);};}},[isSVG,logoFile])// Depends on isSVG and logoFile to re-run for new raster images\n;// Calculate width from aspect ratio and fixed height\nconst width=Math.round(fixedHeight*aspectRatio);const height=fixedHeight;// Container style\nconst containerStyle={...style,width:style&&style.width===\"100%\"?\"100%\":width,height:style&&style.height===\"100%\"?\"100%\":height,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\",background:\"transparent\",position:\"relative\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",pointerEvents:\"auto\",opacity:isLoading?0:1,visibility:isLoading?\"hidden\":\"visible\",transition:\"opacity 0.2s ease-in-out\"};// Image style\nconst imageStyle={width:\"100%\",height:\"100%\",objectFit:\"contain\",pointerEvents:\"none\",userSelect:\"none\",WebkitUserDrag:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",display:\"block\"};// Invert filter\nconst filterStyle=invertColors?{filter:\"invert(1) hue-rotate(180deg)\"}:{};return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,\"aria-label\":\"Logo Container\",children:isSVG?/*#__PURE__*/_jsx(\"img\",{src:logoFile,alt:\"Logo\",style:{...imageStyle,...filterStyle},draggable:false,\"aria-label\":\"Logo\"}):/*#__PURE__*/_jsx(\"img\",{ref:imgRef,src:logoFile,alt:\"Logo\",style:{...imageStyle,...filterStyle},draggable:false,\"aria-label\":\"Logo\"})});}addPropertyControls(AspectRatioLogo,{logoFile:{type:ControlType.File,allowedFileTypes:[\"svg\",\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\"],title:\"Logo\"},fixedHeight:{type:ControlType.Number,title:\"Height\",defaultValue:80,min:1,max:512,step:1,unit:\"px\",displayStepper:true},invertColors:{type:ControlType.Boolean,title:\"Invert\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});AspectRatioLogo.displayName=\"Aspect Ratio Logo\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AspectRatioLogo\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AspectLogo_Prod.map"],"mappings":"yRAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,WAAS,sEAAsE,cAAY,GAAG,eAAa,GAAM,SAAO,EAAW,CAAC,EAAY,GAAgBA,EAAS,EAAE,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAO,EAAOC,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcD,EAAS,GAAK,CACtY,MAAc,CAAC,GAAG,CAAC,EAAS,CAAC,MAAoB,CAAC,EAAe,EAAE,CAAC,EAAS,GAAM,C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