{"version":3,"file":"Embed.CSiwSWmD.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/o1PI5S8YtkA5bP5g4dFz/4uFi0eQcCd35PpjiP8FM/Embed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useIsOnCanvas,emptyStateStyle,containerStyles}from\"https://framer.com/m/framer/default-utils.js\";/**\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */ export default function Embed({type,url,html}){if(type===\"url\"&&url){return(/*#__PURE__*/ _jsx(EmbedURL,{url:url}));}if(type===\"html\"&&html){return(/*#__PURE__*/ _jsx(EmbedHTML,{html:html}));}return(/*#__PURE__*/ _jsx(Instructions,{}));};addPropertyControls(Embed,{type:{type:ControlType.Enum,defaultValue:\"url\",displaySegmentedControl:true,options:[\"url\",\"html\"],optionTitles:[\"URL\",\"HTML\"]},url:{title:\"URL\",type:ControlType.String,description:\"Some websites don’t support embedding.\",hidden(props){return props.type!==\"url\";}},html:{title:\"HTML\",displayTextArea:true,type:ControlType.String,hidden(props){return props.type!==\"html\";}}});function Instructions(){return(/*#__PURE__*/ _jsx(\"div\",{style:{...emptyStateStyle,overflow:\"hidden\"},children:/*#__PURE__*/ _jsx(\"div\",{style:centerTextStyle,children:\"To embed a website or widget, add it to the properties\\xa0panel.\"})}));}function EmbedURL({url}){// Add https:// if the URL does not have a protocol\nif(!/[a-z]+:\\/\\//.test(url)){url=\"https://\"+url;}const onCanvas=useIsOnCanvas();// We need to check if the url is blocked inside an iframe by the X-Frame-Options\n// or Content-Security-Policy headers on the backend:\nconst[state,setState]=useState(onCanvas?undefined:false);useEffect(()=>{// We only want to check on the canvas.\n// On the website we want to avoid the additional delay.\nif(!onCanvas)return;// TODO: We could also use AbortController here.\nlet isLastEffect=true;setState(undefined);async function load(){const response=await fetch(\"https://api.framer.com/functions/check-iframe-url?url=\"+encodeURIComponent(url));if(response.status==200){const{isBlocked}=await response.json();if(isLastEffect){setState(isBlocked);}}else{const message=await response.text();console.error(message);const error=new Error(\"This site can’t be reached.\");setState(error);}}load().catch(error=>{console.error(error);setState(error);});return()=>{isLastEffect=false;};},[url]);if(!url.startsWith(\"https://\")){return(/*#__PURE__*/ _jsx(ErrorMessage,{message:\"Unsupported protocol.\"}));}if(state===undefined){return(/*#__PURE__*/ _jsx(LoadingIndicator,{}));}if(state instanceof Error){return(/*#__PURE__*/ _jsx(ErrorMessage,{message:state.message}));}if(state===true){const message=`Can't embed ${url} due to its content security policy.`;return(/*#__PURE__*/ _jsx(ErrorMessage,{message:message}));}return(/*#__PURE__*/ _jsx(\"iframe\",{src:url,style:iframeStyle,loading:\"lazy\",// @ts-ignore\nfetchPriority:onCanvas?\"low\":\"auto\",referrerPolicy:\"no-referrer\",sandbox:getSandbox(onCanvas)}));}const iframeStyle={width:\"100%\",height:\"100%\",border:\"none\"};function getSandbox(onCanvas){const result=[\"allow-same-origin\",\"allow-scripts\"];if(!onCanvas){result.push(\"allow-downloads\",\"allow-forms\",\"allow-modals\",\"allow-orientation-lock\",\"allow-pointer-lock\",\"allow-popups\",\"allow-popups-to-escape-sandbox\",\"allow-presentation\",\"allow-storage-access-by-user-activation\",\"allow-top-navigation-by-user-activation\");}return result.join(\" \");}function EmbedHTML({html}){const ref=useRef();useEffect(()=>{const div=ref.current;div.innerHTML=html;return()=>{div.innerHTML=\"\";};},[html]);return(/*#__PURE__*/ _jsx(\"div\",{ref:ref,style:htmlStyle}));}const htmlStyle={width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\"};// Generic components\nfunction LoadingIndicator(){return(/*#__PURE__*/ _jsx(\"div\",{className:\"framerInternalUI-componentPlaceholder\",style:{...containerStyles,overflow:\"hidden\"},children:/*#__PURE__*/ _jsx(\"div\",{style:centerTextStyle,children:\"Loading…\"})}));}function ErrorMessage({message}){return(/*#__PURE__*/ _jsx(\"div\",{className:\"framerInternalUI-errorPlaceholder\",style:{...containerStyles,overflow:\"hidden\"},children:/*#__PURE__*/ _jsxs(\"div\",{style:centerTextStyle,children:[\"Error: \",message]})}));}const centerTextStyle={textAlign:\"center\",minWidth:140};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Embed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Embed.map"],"mappings":"sVAMI,SAAwB,EAAM,CAAC,OAAK,MAAI,QAAM,CAAkJ,OAA9I,IAAO,OAAO,EAA0B,EAAK,EAAS,CAAK,MAAI,CAAC,CAAM,IAAO,QAAQ,EAA2B,EAAK,EAAU,CAAM,OAAK,CAAC,CAAwB,EAAK,EAAa,EAAE,CAAC,CAAsZ,SAAS,GAAc,CAAC,OAAqB,EAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAgB,SAAS,SAAS,CAAC,SAAuB,EAAK,MAAM,CAAC,MAAM,EAAgB,SAAS,mEAAmE,CAAC,CAAC,CAAC,CAAG,SAAS,EAAS,CAAC,OAAK,CACz4B,cAAc,KAAK,EAAI,GAAE,EAAI,WAAW,GAAK,IAAM,EAAS,GAAe,CAE1E,CAAC,EAAM,GAAUA,EAAS,EAAS,IAAA,GAAU,GAAM,CAG62B,OAH52B,MAAc,CAEvE,GAAG,CAAC,EAAS,OACb,IAAI,EAAa,GAAK,EAAS,IAAA,GAAU,CAAC,eAAe,GAAM,CAAC,IAAM,EAAS,MAAM,MAAM,yDAAyD,mBAAmB,EAAI,CAAC,CAAC,GAAG,EAAS,QAAQ,IAAI,CAAC,GAAK,CAAC,aAAW,MAAM,EAAS,MA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