{"version":3,"sources":["jsdelivr-header.js","/npm/blockmate-react-link@1.0.0/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ICNa,WAAa,WACxB,OAAO,OAAO,YAAY,CAAE,KAAM,eAAe,MAAQ,IAC3D,EAEa,YAAc,SAAC,GAC1B,OAAO,OAAO,YAAY,CAAE,KAAM,eAAe,MAAO,OAAO,IACjE,EAEM,eAAiB,CACrB,KAAM,wBACN,MAAO,0BAGI,UAAY,SAAH,GAAuD,IAAjD,EAAG,EAAH,IAAG,EAAA,EAAE,WAAG,IAAA,EAAG,gCAA+B,EACpE,IAAK,EAAK,OAAO,KAEjB,IAAM,EAAO,SAAS,cAAc,QA8BpC,OATA,OAAO,UAAY,SAAU,GAAO,IAAA,EAAA,EAf5B,GAgBF,SAAW,QAAN,EAAL,EAAO,YAAI,IAAA,OAAN,EAAL,EAAa,QAAS,eAAe,OATtB,SAAC,GACpB,IAAM,EAAS,SAAS,cAAc,gBACtC,EAAK,YAAY,GACb,EAAM,KAAK,MACb,OAAO,SAAW,EAAM,KAAK,I,CAM7B,CAAa,IAEX,SAAW,QAAN,EAAL,EAAO,YAAI,IAAA,OAAN,EAAL,EAAa,QAAS,eAAe,QAnBnC,EAAS,SAAS,cAAc,WAC/B,aAAa,MAAU,EAAG,SAAS,GAC1C,EAAO,aAAa,QALpB,oGAMA,EAAO,aAAa,KAAM,eAC1B,EAAK,YAAY,G,EAoBZ,IACT,E","file":"/npm/blockmate-react-link@1.0.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/blockmate-react-link@1.0.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export const handleOpen = () => {\n  window.parent.postMessage({ type: EVENT_MESSAGES.open }, '*')\n}\n\nexport const handleClose = (url) => {\n  window.parent.postMessage({ type: EVENT_MESSAGES.close, url }, '*')\n}\n\nconst EVENT_MESSAGES = {\n  open: 'blockmate-iframe-open',\n  close: 'blockmate-iframe-close'\n}\n\nexport const LinkModal = ({ jwt, url = 'https://link-dev.blockmate.io' }) => {\n  if (!jwt) return null\n\n  const body = document.querySelector('body')\n\n  const iframeStyle =\n    'display:block; position:fixed; width:100%; height:100%; z-index:100; border:none; top:0; right:0'\n\n  const createIframe = () => {\n    const iframe = document.createElement('iframe')\n    iframe.setAttribute('src', `${url}/?jwt=${jwt}`)\n    iframe.setAttribute('style', iframeStyle)\n    iframe.setAttribute('id', 'link-iframe')\n    body.appendChild(iframe)\n  }\n\n  const removeIframe = (event) => {\n    const iframe = document.querySelector('#link-iframe')\n    body.removeChild(iframe)\n    if (event.data.url) {\n      window.location = event.data.url\n    }\n  }\n\n  window.onmessage = function (event) {\n    if (event?.data?.type === EVENT_MESSAGES.close) {\n      removeIframe(event)\n    }\n    if (event?.data?.type === EVENT_MESSAGES.open) {\n      createIframe()\n    }\n  }\n\n  return null\n}\n"]}