{"version":3,"file":"AutoHeightEmbed.DSv2lPS1.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/Vln3bRmC2vr86524OD55/jhny6vmtJS5qhjCwU6CG/AutoHeightEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 1100\n * @framerIntrinsicHeight 3000\n */export default function AutoHeightEmbed(props){const html=props.html||\"\";const initialHeight=Number.isFinite(props.startHeight)&&props.startHeight>0?props.startHeight:3e3;const frameRef=React.useRef(null);const[height,setHeight]=React.useState(initialHeight);React.useEffect(()=>{const frame=frameRef.current;if(!frame)return;let stopped=false;let animationFrame=0;let releaseDocument=()=>{};function applyHeight(value){if(stopped||!Number.isFinite(value)||value<=0)return;// Round up so a fractional last pixel cannot create inner overflow.\nconst next=Math.ceil(value);setHeight(previous=>previous===next?previous:next);}function measure(){animationFrame=0;if(stopped)return;try{const doc=frame.contentDocument;const content=doc?.getElementById(\"dw\")||doc?.body;if(!content)return;// Measure content, not documentElement.scrollHeight: the latter\n// cannot shrink below the current iframe viewport height.\nconst top=content.getBoundingClientRect().top+(doc.defaultView?.scrollY||0);applyHeight(top+content.getBoundingClientRect().height);}catch{// Cross-origin embeds can still use the dw-height message below.\n}}function scheduleMeasure(){if(!stopped&&!animationFrame)animationFrame=requestAnimationFrame(measure);}function connectDocument(){releaseDocument();releaseDocument=()=>{};if(stopped)return;try{const doc=frame.contentDocument;const content=doc?.getElementById(\"dw\")||doc?.body;if(doc&&content){const observer=new ResizeObserver(scheduleMeasure);observer.observe(content);// Capturing load catches lazy images as they finish loading.\ndoc.addEventListener(\"load\",scheduleMeasure,true);doc.fonts?.ready.then(scheduleMeasure);releaseDocument=()=>{observer.disconnect();doc.removeEventListener(\"load\",scheduleMeasure,true);};measure();}}catch{/* Message-based sizing remains available. */}frame.contentWindow?.postMessage({type:\"dw-autosize\"},\"*\");}function onMessage(event){if(event.source!==frame.contentWindow)return;const data=event.data;if(data?.type===\"dw-height\"&&typeof data.height===\"number\"){applyHeight(data.height);}}// Install the listener before asking for a measurement. Also inspect\n// already-loaded srcdoc content, so mount timing cannot lose its height.\nwindow.addEventListener(\"message\",onMessage);window.addEventListener(\"resize\",scheduleMeasure);frame.addEventListener(\"load\",connectDocument);connectDocument();return()=>{stopped=true;cancelAnimationFrame(animationFrame);releaseDocument();frame.removeEventListener(\"load\",connectDocument);window.removeEventListener(\"message\",onMessage);window.removeEventListener(\"resize\",scheduleMeasure);};},[html]);if(!html.trim()){return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,padding:40},children:\"AutoHeightEmbed: paste the page’s HTML into the HTML field.\"});}// Keep native scroll fallback available while sizing. Once the frame fits,\n// there is no inner vertical overflow and the outer page scrolls normally.\n// Do not intercept wheel/touch input or reset the outer page's scroll position.\nreturn /*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,srcDoc:html,title:\"Case study\",style:{...props.style,display:\"block\",width:\"100%\",height,border:0,overflowAnchor:\"none\"}});}AutoHeightEmbed.defaultProps={html:\"\",startHeight:3e3};addPropertyControls(AutoHeightEmbed,{html:{type:ControlType.String,title:\"HTML\",displayTextArea:true},startHeight:{type:ControlType.Number,title:\"Start Height\",defaultValue:3e3,min:0,max:4e4,step:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AutoHeightEmbed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"1100\",\"framerIntrinsicHeight\":\"3000\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoHeightEmbed.map"],"mappings":"sMAKG,SAAwB,EAAgB,EAAM,CAAC,IAAM,EAAK,EAAM,MAAM,GAAS,EAAc,OAAO,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