{"version":3,"file":"RechnerEmbed.BrF_J7S7.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/hgYwlNxZS0fjvtGaSdJ2/ysLHM5FTdJAyes7ew8il/RechnerEmbed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Rechner Embed\n *\n * Zeigt einen eigenen HTML/JS-Rechner in einem isolierten iframe (srcDoc).\n * Vorteil gegenueber dem direkten Einfuegen in die Seite:\n * - Das Skript laeuft in einem eigenen Dokument. Doppelte Deklarationen\n *   (const ...) bei erneutem Rendern oder Seitenwechsel in Framer fuehren\n *   nicht mehr zu einem Abbruch, der Rechner zeigt immer Werte an.\n * - CSS des Rechners (body, *, h2) veraendert nicht die restliche Seite.\n * - Die Hoehe passt sich automatisch an (Mobile und Desktop).\n * - Links im Rechner oeffnen im Hauptfenster.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function RechnerEmbed(props){const{html=\"\",placeholderTitle=\"Rechner-Platzhalter\",placeholderText=\"F\\xfcge im CMS-Feld „Rechner HTML Code“ deinen eigenen Rechner-Code ein – er erscheint hier automatisch.\",style}=props;const frameRef=useRef(null);const[height,setHeight]=useState(640);const frameId=useMemo(()=>\"rechner-\"+Math.random().toString(36).slice(2,10),[]);const srcDoc=useMemo(()=>{if(!html)return\"\";const helper='<base target=\"_top\"><script>(function(){var id='+JSON.stringify(frameId)+\";function measure(){var b=document.body;if(!b)return 0;var r=b.getBoundingClientRect();var cs=getComputedStyle(b);return Math.ceil(r.height+(parseFloat(cs.marginTop)||0)+(parseFloat(cs.marginBottom)||0));}\"+\"function send(){var h=measure();if(h>0)parent.postMessage({rechnerFrame:id,height:h},'*');}\"+\"window.addEventListener('load',send);window.addEventListener('resize',send);\"+\"if(window.ResizeObserver){var ro=new ResizeObserver(send);var tryObs=function(){if(document.body){ro.observe(document.body);send();}else{setTimeout(tryObs,50);}};tryObs();}\"+\"setInterval(send,500);})();</script>\";if(/<head[^>]*>/i.test(html)){return html.replace(/<head[^>]*>/i,m=>m+helper);}return helper+html;},[html,frameId]);useEffect(()=>{function onMessage(event){const data=event.data;if(!data||data.rechnerFrame!==frameId)return;const next=Math.ceil(Number(data.height));if(next>0&&Math.abs(next-height)>1)setHeight(next);}window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[frameId,height]);if(!html){return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:8,width:\"100%\",minHeight:240,boxSizing:\"border-box\",padding:32,borderRadius:16,border:\"1px dashed rgba(0,0,0,0.15)\",backgroundColor:\"rgba(0,0,0,0.02)\",textAlign:\"center\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{fontSize:15,fontWeight:600,color:\"#003127\"},children:placeholderTitle}),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:13,color:\"#696E77\",maxWidth:420},children:placeholderText})]});}return /*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,title:\"Rechner\",srcDoc:srcDoc,scrolling:\"no\",style:{...style,position:\"relative\",display:\"block\",width:\"100%\",height,border:\"none\",background:\"transparent\",overflow:\"hidden\"}});}addPropertyControls(RechnerEmbed,{html:{type:ControlType.String,title:\"HTML Code\",defaultValue:\"\",displayTextArea:true},placeholderTitle:{type:ControlType.String,title:\"Platzhalter-Titel\",defaultValue:\"Rechner-Platzhalter\"},placeholderText:{type:ControlType.String,title:\"Platzhalter-Text\",defaultValue:\"F\\xfcge im CMS-Feld „Rechner HTML Code“ deinen eigenen Rechner-Code ein – er erscheint hier automatisch.\",displayTextArea:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RechnerEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"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