{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/o1PI5S8YtkA5bP5g4dFz/pVNq3gPwiiJPmLV2YSlc/Embed.js"],
  "sourcesContent": ["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { addPropertyControls, ControlType } from \"framer\";\nimport { 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                                                                                                                */\nexport default function Embed({\n  type,\n  url,\n  html\n}) {\n  if (type === \"url\" && url) {\n    return /*#__PURE__*/_jsx(EmbedURL, {\n      url: url\n    });\n  }\n  if (type === \"html\" && html) {\n    return /*#__PURE__*/_jsx(EmbedHTML, {\n      html: html\n    });\n  }\n  return /*#__PURE__*/_jsx(Instructions, {});\n}\n;\naddPropertyControls(Embed, {\n  type: {\n    type: ControlType.Enum,\n    defaultValue: \"url\",\n    displaySegmentedControl: true,\n    options: [\"url\", \"html\"],\n    optionTitles: [\"URL\", \"HTML\"]\n  },\n  url: {\n    title: \"URL\",\n    type: ControlType.String,\n    description: \"Some websites don\u2019t support embedding.\",\n    hidden(props) {\n      return props.type !== \"url\";\n    }\n  },\n  html: {\n    title: \"HTML\",\n    displayTextArea: true,\n    type: ControlType.String,\n    hidden(props) {\n      return props.type !== \"html\";\n    }\n  }\n});\nfunction Instructions() {\n  return /*#__PURE__*/_jsx(\"div\", {\n    style: {\n      ...emptyStateStyle,\n      overflow: \"hidden\"\n    },\n    children: /*#__PURE__*/_jsx(\"div\", {\n      style: centerTextStyle,\n      children: \"To embed a website or widget, add it to the properties\\xa0panel.\"\n    })\n  });\n}\nfunction EmbedURL({\n  url\n}) {\n  // Add https:// if the URL does not have a protocol.\n  if (!/[a-z]+:\\/\\//.test(url)) {\n    url = \"https://\" + url;\n  }\n  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.\n  const [state, setState] = useState(onCanvas ? undefined : false);\n  useEffect(() => {\n    // We only want to check on the canvas.\n    // On the website we want to avoid the additional delay.\n    if (!onCanvas) return; // TODO: We could also use AbortController here.\n    let isLastEffect = true;\n    setState(undefined);\n    async function load() {\n      const response = await fetch(\"https://api.framer.com/functions/check-iframe-url?url=\" + encodeURIComponent(url));\n      if (response.status == 200) {\n        const {\n          isBlocked\n        } = await response.json();\n        if (isLastEffect) {\n          setState(isBlocked);\n        }\n      } else {\n        const message = await response.text();\n        console.error(message);\n        const error = new Error(\"This site can\u2019t be reached.\");\n        setState(error);\n      }\n    }\n    load().catch(error => {\n      console.error(error);\n      setState(error);\n    });\n    return () => {\n      isLastEffect = false;\n    };\n  }, [url]);\n  if (!url.startsWith(\"https://\")) {\n    return /*#__PURE__*/_jsx(ErrorMessage, {\n      message: \"Unsupported protocol.\"\n    });\n  }\n  if (state === undefined) {\n    return /*#__PURE__*/_jsx(LoadingIndicator, {});\n  }\n  if (state instanceof Error) {\n    return /*#__PURE__*/_jsx(ErrorMessage, {\n      message: state.message\n    });\n  }\n  if (state === true) {\n    const message = `Can't embed ${url} due to its content security policy.`;\n    return /*#__PURE__*/_jsx(ErrorMessage, {\n      message: message\n    });\n  }\n  return /*#__PURE__*/_jsx(\"iframe\", {\n    src: url,\n    style: iframeStyle,\n    loading: \"lazy\",\n    // @ts-ignore\n    fetchPriority: onCanvas ? \"low\" : \"auto\",\n    referrerPolicy: \"no-referrer\",\n    sandbox: getSandbox(onCanvas)\n  });\n}\nconst iframeStyle = {\n  width: \"100%\",\n  height: \"100%\",\n  border: \"none\"\n};\nfunction getSandbox(onCanvas) {\n  const result = [\"allow-same-origin\", \"allow-scripts\"];\n  if (!onCanvas) {\n    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\");\n  }\n  return result.join(\" \");\n}\nfunction EmbedHTML({\n  html\n}) {\n  const ref = useRef(); // If the HTML contains a script tag we can't use\n  // dangerouslySetInnerHTML because it doesn't execute\n  // scripts on the client. Otherwise, we can benefit\n  // from SSG by using dangerouslySetInnerHTML.\n  const hasScript = html.includes(\"</script>\");\n  useEffect(() => {\n    if (!hasScript) return;\n    const div = ref.current;\n    div.innerHTML = html;\n    executeScripts(div);\n    return () => {\n      div.innerHTML = \"\";\n    };\n  }, [html, hasScript]);\n  return /*#__PURE__*/_jsx(\"div\", {\n    ref: ref,\n    style: htmlStyle,\n    dangerouslySetInnerHTML: !hasScript ? {\n      __html: html\n    } : undefined\n  });\n}\nconst htmlStyle = {\n  width: \"100%\",\n  height: \"100%\",\n  display: \"flex\",\n  flexDirection: \"column\",\n  justifyContent: \"center\",\n  alignItems: \"center\"\n}; // This function replaces scripts with executable ones.\n// https://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml\nfunction executeScripts(node) {\n  if (node instanceof Element && node.tagName === \"SCRIPT\") {\n    const script = document.createElement(\"script\");\n    script.text = node.innerHTML;\n    for (const {\n      name,\n      value\n    } of node.attributes) {\n      script.setAttribute(name, value);\n    }\n    node.parentElement.replaceChild(script, node);\n  } else {\n    for (const child of node.childNodes) {\n      executeScripts(child);\n    }\n  }\n} // Generic components\nfunction LoadingIndicator() {\n  return /*#__PURE__*/_jsx(\"div\", {\n    className: \"framerInternalUI-componentPlaceholder\",\n    style: {\n      ...containerStyles,\n      overflow: \"hidden\"\n    },\n    children: /*#__PURE__*/_jsx(\"div\", {\n      style: centerTextStyle,\n      children: \"Loading\u2026\"\n    })\n  });\n}\nfunction ErrorMessage({\n  message\n}) {\n  return /*#__PURE__*/_jsx(\"div\", {\n    className: \"framerInternalUI-errorPlaceholder\",\n    style: {\n      ...containerStyles,\n      overflow: \"hidden\"\n    },\n    children: /*#__PURE__*/_jsxs(\"div\", {\n      style: centerTextStyle,\n      children: [\"Error: \", message]\n    })\n  });\n}\nconst centerTextStyle = {\n  textAlign: \"center\",\n  minWidth: 140\n};\nexport const __FramerMetadata__ = {\n  \"exports\": {\n    \"default\": {\n      \"type\": \"reactComponent\",\n      \"name\": \"Embed\",\n      \"slots\": [],\n      \"annotations\": {\n        \"framerSupportedLayoutWidth\": \"fixed\",\n        \"framerContractVersion\": \"1\",\n        \"framerSupportedLayoutHeight\": \"fixed\",\n        \"framerIntrinsicWidth\": \"600\",\n        \"framerIntrinsicHeight\": \"400\"\n      }\n    },\n    \"__FramerMetadata__\": {\n      \"type\": \"variable\"\n    }\n  }\n};\n//# sourceMappingURL=./Embed.map"],
  "mappings": "uKAUe,SAARA,EAAuB,CAC5B,KAAAC,EACA,IAAAC,EACA,KAAAC,CACF,EAAG,CACD,OAAIF,IAAS,OAASC,EACAE,EAAKC,EAAU,CACjC,IAAKH,CACP,CAAC,EAECD,IAAS,QAAUE,EACDC,EAAKE,EAAW,CAClC,KAAMH,CACR,CAAC,EAEiBC,EAAKG,EAAc,CAAC,CAAC,CAC3C,CAEAC,EAAoBR,EAAO,CACzB,KAAM,CACJ,KAAMS,EAAY,KAClB,aAAc,MACd,wBAAyB,GACzB,QAAS,CAAC,MAAO,MAAM,EACvB,aAAc,CAAC,MAAO,MAAM,CAC9B,EACA,IAAK,CACH,MAAO,MACP,KAAMA,EAAY,OAClB,YAAa,8CACb,OAAOC,EAAO,CACZ,OAAOA,EAAM,OAAS,KACxB,CACF,EACA,KAAM,CACJ,MAAO,OACP,gBAAiB,GACjB,KAAMD,EAAY,OAClB,OAAOC,EAAO,CACZ,OAAOA,EAAM,OAAS,MACxB,CACF,CACF,CAAC,EACD,SAASH,GAAe,CACtB,OAAoBH,EAAK,MAAO,CAC9B,MAAO,CACL,GAAGO,EACH,SAAU,QACZ,EACA,SAAuBP,EAAK,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ACL,GAAGqC,EACH,SAAU,QACZ,EACA,SAAuBrC,EAAK,MAAO,CACjC,MAAOQ,EACP,SAAU,eACZ,CAAC,CACH,CAAC,CACH,CACA,SAASa,EAAa,CACpB,QAAAF,CACF,EAAG,CACD,OAAoBnB,EAAK,MAAO,CAC9B,UAAW,oCACX,MAAO,CACL,GAAGqC,EACH,SAAU,QACZ,EACA,SAAuBC,EAAM,MAAO,CAClC,MAAO9B,EACP,SAAU,CAAC,UAAWW,CAAO,CAC/B,CAAC,CACH,CAAC,CACH,CACA,IAAMX,EAAkB,CACtB,UAAW,SACX,SAAU,GACZ",
  "names": ["Embed", "type", "url", "html", "p", "EmbedURL", "EmbedHTML", "Instructions", "addPropertyControls", "ControlType", "props", "emptyStateStyle", "centerTextStyle", "onCanvas", "useIsOnCanvas", "state", "setState", "ye", "ue", "isLastEffect", "load", "response", "isBlocked", "message", "error", "ErrorMessage", "LoadingIndicator", "iframeStyle", "getSandbox", "result", "ref", "pe", "hasScript", "div", "executeScripts", "htmlStyle", "node", "script", "name", "value", "child", "containerStyles", "u"]
}
