{"version":3,"file":"AzureImage.DcXT7I47.mjs","names":["useState","useRef","useCallback","useEffect","useLayoutEffect"],"sources":["https:/framerusercontent.com/modules/LUpmAbpaHrdZooNrWED8/mPqx5DiBjY0WNYrEBwhi/AzureImage.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{forwardRef,useCallback,useEffect,useLayoutEffect,useRef,useState}from\"react\";const VARIANT_WIDTHS=[512,1024,2048];/** Longest a deferred picture waits for the eager ones, in ms. */const DEFER_TIMEOUT=3500;/** Framer serves scaled copies of an uploaded picture from the same url. */function variantsOf(src){if(!src)return undefined;if(src.indexOf(\"framerusercontent.com\")===-1)return undefined;const join=src.indexOf(\"?\")===-1?\"?\":\"&\";return VARIANT_WIDTHS.map(w=>src+join+\"scale-down-to=\"+w+\" \"+w+\"w\").join(\", \");}/*\n * Shared by every Azure Image on the page: eager pictures still loading,\n * and deferred pictures waiting for them to finish. A stack of pictures\n * that are all on screen at once (a pinned stage) would otherwise start\n * downloading together and split the bandwidth with the first picture.\n */let pendingEager=0;const waiting=new Set;function eagerDone(){pendingEager=Math.max(0,pendingEager-1);if(pendingEager>0)return;waiting.forEach(release=>release());waiting.clear();}const useIsomorphicLayoutEffect=typeof window===\"undefined\"?useEffect:useLayoutEffect;/** How far below the screen, in screens, a waiting picture starts to load. */const NEAR_SCREENS=2;/**\n * True once the element comes within two screens of the viewport. Pictures\n * further down the page wait for it, so a phone does not fetch them all up\n * front. The box is measured directly, because the browser's own lazy\n * loading never fires behind a closed clip-path or a track pushed sideways,\n * which is where the pinned stages keep their pictures.\n */export function useNear(ref,skip=false){const[near,setNear]=useState(skip);useEffect(()=>{if(near)return;if(RenderTarget.hasRestrictions()){setNear(true);return;}let frame=0;const check=()=>{frame=0;const el=ref.current;if(!el)return;const r=el.getBoundingClientRect();// Not laid out (a hidden breakpoint): wait until it is.\nif(r.width===0&&r.height===0)return;const h=window.innerHeight||800;if(r.top<h*(1+NEAR_SCREENS)&&r.bottom>-h*NEAR_SCREENS)setNear(true);};const onScroll=()=>{if(!frame)frame=requestAnimationFrame(check);};check();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);if(frame)cancelAnimationFrame(frame);};},[near]);return near;}/** Passes Framer's ref on and keeps a copy for measuring. */function useForwardedBox(ref){const box=useRef(null);const setRef=useCallback(el=>{box.current=el;if(typeof ref===\"function\")ref(el);else if(ref)ref.current=el;},[ref]);return[box,setRef];}/**\n * Code override for a layer with an image fill further down the page: the\n * picture is left out until the layer comes within two screens, then loads\n * as usual. Framer drops its own lazy loading for pictures inside pinned\n * sections, and the published page then fetched every one of them at once.\n */export function withLazyImage(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[box,setRef]=useForwardedBox(ref);const near=useNear(box);return /*#__PURE__*/_jsx(Component,{...props,ref:setRef,background:near?props.background:undefined});});}/**\n * Azure Image\n *\n * Renders a picture as a real <img> element, so it carries alt text for\n * screen readers and search engines. Bind Image to a CMS image field and\n * Alt Text to the matching alt field on the same collection.\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function AzureImage(props){const{image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"\"},alt=\"\",fit=\"cover\",focalPoint=\"center\",sizes=\"100vw\",eager=false,deferred=false,style}=props;const src=image?.src;const description=(alt||image?.alt||\"\").trim();const srcSet=image?.srcSet||variantsOf(src);const imgRef=useRef(null);const[released,setReleased]=useState(!deferred);// Layout effects run before any passive effect, so every eager picture\n// is counted before a deferred one checks whether it may start.\nuseIsomorphicLayoutEffect(()=>{if(!eager||deferred)return;const img=imgRef.current;if(!img||img.complete)return;pendingEager++;let settled=false;const settle=()=>{if(settled)return;settled=true;img.removeEventListener(\"load\",settle);img.removeEventListener(\"error\",settle);eagerDone();};img.addEventListener(\"load\",settle);img.addEventListener(\"error\",settle);return settle;},[eager,deferred,src]);// A deferred picture that is loaded eagerly usually sits behind a closed\n// clip-path, where lazy loading would never fire and the browser would\n// not decode it until the first frame it shows. Decode it ahead of time.\nuseEffect(()=>{if(!deferred||!eager||!released)return;const img=imgRef.current;if(!img||!img.decode)return;const warm=()=>{img.decode().catch(()=>{});};if(img.complete)warm();else img.addEventListener(\"load\",warm,{once:true});return()=>img.removeEventListener(\"load\",warm);},[deferred,eager,released,src]);// A deferred picture also waits until it comes within two screens, so a\n// stage far down the page does not load with the first screen.\nconst near=useNear(imgRef,!deferred);useEffect(()=>{if(!deferred){setReleased(true);return;}if(!near)return;const release=()=>setReleased(true);if(pendingEager===0){release();return;}waiting.add(release);const timer=setTimeout(release,DEFER_TIMEOUT);return()=>{waiting.delete(release);clearTimeout(timer);};},[deferred,near]);const eagerAttrs=eager&&!deferred?{fetchpriority:\"high\"}:{};return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"img\",{// Before src: React sets attributes in order, and a src set\n// first starts the download before the browser reads \"lazy\".\nloading:eager?\"eager\":\"lazy\",ref:imgRef,src:released?src:undefined,srcSet:released?srcSet:undefined,sizes:released&&srcSet?sizes:undefined,alt:description,decoding:\"async\",draggable:false,...eagerAttrs,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",objectFit:fit,objectPosition:focalPoint,borderRadius:\"inherit\",display:\"block\",userSelect:\"none\",visibility:released?undefined:\"hidden\"}})});}AzureImage.displayName=\"Azure Image\";addPropertyControls(AzureImage,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},alt:{type:ControlType.String,title:\"Alt Text\",defaultValue:\"\",placeholder:\"Describe this picture\",description:\"Read aloud by screen readers and used by search engines. Leave empty only for purely decorative pictures.\"},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\"],optionTitles:[\"Cover\",\"Contain\"],defaultValue:\"cover\",displaySegmentedControl:true},focalPoint:{type:ControlType.Enum,title:\"Focus\",options:[\"center\",\"top\",\"bottom\",\"left\",\"right\"],optionTitles:[\"Center\",\"Top\",\"Bottom\",\"Left\",\"Right\"],defaultValue:\"center\"},eager:{type:ControlType.Boolean,title:\"Load Eagerly\",defaultValue:false,description:\"Turn on for a picture that is visible without scrolling. It is fetched first.\"},deferred:{type:ControlType.Boolean,title:\"Load After First\",defaultValue:false,description:\"Waits until the eager pictures on the page have loaded. With Load Eagerly on as well, it then loads straight away even while hidden, for pictures stacked behind the first one.\"},sizes:{type:ControlType.String,title:\"Sizes\",defaultValue:\"100vw\",placeholder:\"100vw\",description:\"Advanced. How wide this picture is on screen, so the browser can pick the lightest file. Example: 33vw inside a three column grid.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"withLazyImage\":{\"type\":\"reactHoc\",\"name\":\"withLazyImage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"AzureImage\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"useNear\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AzureImage.map"],"mappings":"kOAA4Y,SAAS,EAAW,EAAI,CAA0B,GAAtB,CAAC,GAAwB,EAAI,QAAQ,uBAAuB,IAAI,GAAG,OAAiB,IAAM,EAAK,EAAI,QAAQ,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,EAAe,IAAI,GAAG,EAAI,EAAK,iBAAiB,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,CAAE,CAKxkB,SAAS,GAAW,CA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