{"version":3,"file":"copy-C-k21X8l.js","sources":["../../../node_modules/.pnpm/toggle-selection@1.0.6/node_modules/toggle-selection/index.js","../../../frontend/common/utils/copy.js"],"sourcesContent":["\nmodule.exports = function () {\n var selection = document.getSelection();\n if (!selection.rangeCount) {\n return function () {};\n }\n var active = document.activeElement;\n\n var ranges = [];\n for (var i = 0; i < selection.rangeCount; i++) {\n ranges.push(selection.getRangeAt(i));\n }\n\n switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML\n case 'INPUT':\n case 'TEXTAREA':\n active.blur();\n break;\n\n default:\n active = null;\n break;\n }\n\n selection.removeAllRanges();\n return function () {\n selection.type === 'Caret' &&\n selection.removeAllRanges();\n\n if (!selection.rangeCount) {\n ranges.forEach(function(range) {\n selection.addRange(range);\n });\n }\n\n active &&\n active.focus();\n };\n};\n","import deselectCurrent from 'toggle-selection';\n\nconst isMacOs = /mac os x/i.test(navigator.userAgent)\n\nconst promtMessage = `Copy to clipboard: ${isMacOs ? '⌘' : 'Ctrl'} +C, Enter`\n\nfunction copy(text) {\n const reselectPrevious = deselectCurrent();\n const openedModal = document.querySelector('ds-modal[aria-expanded=\"true\"]')\n const root = openedModal || document.body\n let selection\n let mark\n let range\n try {\n range = document.createRange();\n selection = document.getSelection();\n\n mark = document.createElement(\"span\");\n mark.textContent = text;\n // avoid screen readers from reading out loud the text\n mark.ariaHidden = \"true\"\n mark.setAttribute('style', 'position: fixed; transform: translate(-10000px, -10000px);')\n \n root.appendChild(mark);\n\n range.selectNodeContents(mark);\n selection.addRange(range);\n\n const successful = document.execCommand(\"copy\");\n if (!successful) {\n throw new Error(\"copy command was unsuccessful\");\n }\n } catch (err) {\n try {\n window.clipboardData.setData('text', text);\n } catch (err) {\n window.prompt(promtMessage, text);\n }\n } finally {\n if (selection) {\n if (typeof selection.removeRange === 'function') {\n selection.removeRange(range);\n } else {\n selection.removeAllRanges();\n }\n }\n\n if (mark) {\n root.removeChild(mark);\n }\n reselectPrevious();\n }\n}\n\nexport default copy\n"],"names":["toggleSelection","selection","active","ranges","i","range","isMacOs","promtMessage","copy","text","reselectPrevious","deselectCurrent","root","mark"],"mappings":"mDAAA,IAAAA,EAAiB,UAAY,CAC3B,IAAIC,EAAY,SAAS,eACzB,GAAI,CAACA,EAAU,WACb,OAAO,UAAY,CAAA,EAIrB,QAFIC,EAAS,SAAS,cAClBC,EAAS,CAAA,EACJC,EAAI,EAAGA,EAAIH,EAAU,WAAYG,IACxCD,EAAO,KAAKF,EAAU,WAAWG,CAAC,CAAC,EAErC,OAAQF,EAAO,QAAQ,YAAa,EAAA,CAElC,IAAK,QACL,IAAK,WACHA,EAAO,KAAI,EACX,MACF,QACEA,EAAS,KACT,KACH,CACD,OAAAD,EAAU,gBAAe,EAClB,UAAY,CACjBA,EAAU,OAAS,SAAWA,EAAU,gBAAe,EAClDA,EAAU,YACbE,EAAO,QAAQ,SAAUE,EAAO,CAC9BJ,EAAU,SAASI,CAAK,CAChC,CAAO,EAEHH,GAAUA,EAAO,OACrB,CACA,eC7BMI,EAAU,YAAY,KAAK,UAAU,SAAS,EAC9CC,EAAe,sBAAsBD,EAAU,IAAM,MAAM,aACjE,SAASE,EAAKC,EAAM,CAClB,MAAMC,EAAmBC,IAEnBC,EADc,SAAS,cAAc,gCAAgC,GAC/C,SAAS,KACrC,IAAIX,EACAY,EACAR,EACJ,GAAI,CAYF,GAXAA,EAAQ,SAAS,cACjBJ,EAAY,SAAS,eACrBY,EAAO,SAAS,cAAc,MAAM,EACpCA,EAAK,YAAcJ,EAEnBI,EAAK,WAAa,OAClBA,EAAK,aAAa,QAAS,4DAA4D,EACvFD,EAAK,YAAYC,CAAI,EACrBR,EAAM,mBAAmBQ,CAAI,EAC7BZ,EAAU,SAASI,CAAK,EAEpB,CADe,SAAS,YAAY,MAAM,EAE5C,MAAM,IAAI,MAAM,+BAA+B,CAElD,MAAa,CACZ,GAAI,CACF,OAAO,cAAc,QAAQ,OAAQI,CAAI,CAC1C,MAAa,CACZ,OAAO,OAAOF,EAAcE,CAAI,CACjC,CACL,QAAY,CACJR,IACE,OAAOA,EAAU,aAAgB,WACnCA,EAAU,YAAYI,CAAK,EAE3BJ,EAAU,gBAAe,GAGzBY,GACFD,EAAK,YAAYC,CAAI,EAEvBH,GACD,CACH","x_google_ignoreList":[0]}