{"version":3,"file":"ImageswithURL.DroGiTa2.mjs","names":["useMemo","useState"],"sources":["https:/framerusercontent.com/modules/OYnYxhxs6JYFywlSlzmx/58O9OWrk8US9zxzdyIMM/ImageswithURL.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useMemo,useState}from\"react\";/**\n * User instructions:\n * Create an image component where I provide an image link via a variable from CMS in Framer; it should display that image.\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 360\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ImagewithURL(props){const{imageUrl,altText,caption,fit,topRadius,bottomRadius,// eslint-disable-next-line @typescript-eslint/no-unused-vars\nmarginTop,// eslint-disable-next-line @typescript-eslint/no-unused-vars\nmarginRight,// eslint-disable-next-line @typescript-eslint/no-unused-vars\nmarginBottom,// eslint-disable-next-line @typescript-eslint/no-unused-vars\nmarginLeft,showErrorText,errorTextEmpty,errorTextFailed,boxShadow,style}=props;const rawUrl=useMemo(()=>{if(!imageUrl)return\"\";// Handle Framer CMS Image objects\nif(typeof imageUrl===\"object\"&&imageUrl!==null&&\"src\"in imageUrl){return(imageUrl.src||\"\").trim();}// Handle string URLs (Plain Text CMS field)\nif(typeof imageUrl===\"string\"){return imageUrl.trim();}return\"\";},[imageUrl]);const url=useMemo(()=>{if(!rawUrl)return\"\";// If it's already a full URL, return it (trimmed)\nif(rawUrl.startsWith(\"http://\")||rawUrl.startsWith(\"https://\")||rawUrl.startsWith(\"//\")){return rawUrl;}// Otherwise, try to handle encoding\ntry{return encodeURI(rawUrl);}catch(e){return rawUrl;}},[rawUrl]);const[hasError,setHasError]=useState(false);const[isHydrated,setIsHydrated]=useState(false);useEffect(()=>{setIsHydrated(true);setHasError(false);},[url]);const containerStyle=useMemo(()=>({position:\"relative\",width:\"100%\",height:\"100%\",minHeight:\"inherit\",overflow:\"hidden\",background:\"transparent\",borderTopLeftRadius:topRadius,borderTopRightRadius:topRadius,borderBottomLeftRadius:bottomRadius,borderBottomRightRadius:bottomRadius,marginTop:marginTop,boxShadow:boxShadow,...style}),[style,topRadius,bottomRadius,marginTop,boxShadow]);// Essential for Framer SSR: Ensure server HTML matches client initial render\nif(!isHydrated){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle});}if(!url||hasError){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,\"aria-label\":\"Image (empty)\",children:showErrorText?/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:16,textAlign:\"center\",color:\"#999\",fontSize:\"14px\",fontWeight:500},children:hasError?errorTextFailed||\"Failed to load image\":errorTextEmpty||\"No image URL set\"}):null});}return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,\"aria-label\":caption?`image: ${caption}`:\"image\",children:/*#__PURE__*/_jsx(\"img\",{src:url,alt:(altText||\"\").trim(),title:(caption||\"\").trim(),style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:fit,borderTopLeftRadius:topRadius,borderTopRightRadius:topRadius,borderBottomLeftRadius:bottomRadius,borderBottomRightRadius:bottomRadius,display:\"block\"},loading:\"lazy\",decoding:\"async\",onError:()=>setHasError(true)},url)});}addPropertyControls(ImagewithURL,{imageUrl:{type:ControlType.String,title:\"Image URL\",defaultValue:\"\"},altText:{type:ControlType.String,title:\"Alt Text\",defaultValue:\"\"},caption:{type:ControlType.String,title:\"Caption\",defaultValue:\"\"},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\",\"fill\",\"scale-down\",\"none\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\",\"Scale Down\",\"None\"],defaultValue:\"cover\",displaySegmentedControl:false},topRadius:{type:ControlType.Number,title:\"Top Radius\",defaultValue:0,min:0,max:80,step:1,unit:\"px\"},bottomRadius:{type:ControlType.Number,title:\"Bottom Radius\",defaultValue:0,min:0,max:80,step:1,unit:\"px\"},marginTop:{type:ControlType.Number,title:\"Margin Top\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"},boxShadow:{type:ControlType.BoxShadow,title:\"Shadow\",defaultValue:\"0px 4px 10px rgba(0, 0, 0, 0.1)\"},marginRight:{type:ControlType.Number,title:\"Margin Right\",defaultValue:0,min:0,max:100,step:1,unit:\"px\",hidden:()=>true},marginBottom:{type:ControlType.Number,title:\"Margin Bottom\",defaultValue:0,min:0,max:100,step:1,unit:\"px\",hidden:()=>true},marginLeft:{type:ControlType.Number,title:\"Margin Left\",defaultValue:0,min:0,max:100,step:1,unit:\"px\",hidden:()=>true},showErrorText:{type:ControlType.Boolean,title:\"Error Text\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},errorTextEmpty:{type:ControlType.String,title:\"Empty Text\",defaultValue:\"Set an image URL\",displayTextArea:true,hidden:({showErrorText})=>!showErrorText},errorTextFailed:{type:ControlType.String,title:\"Failed Text\",defaultValue:\"Image failed to load. Check the URL and that the host allows hotlinking.\",displayTextArea:true,hidden:({showErrorText})=>!showErrorText}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImagewithURL\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"360\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageswithURL.map"],"mappings":"wLASG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,WAAS,UAAQ,UAAQ,MAAI,YAAU,eAC5F,YACA,cACA,eACA,aAAW,gBAAc,iBAAe,kBAAgB,YAAU,SAAO,EAAY,EAAOA,MAAiB,EAC1G,OAAO,GAAW,UAAU,GAAiB,QAAQ,GAAiB,EAAS,KAAK,GAAA,CAAI,KAAK,EAC7F,OAAO,G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