{"version":3,"file":"@chenfengyuan-DOv4K2dR.js","sources":["../../node_modules/@chenfengyuan/vue-qrcode/dist/vue-qrcode.esm.js"],"sourcesContent":["/*! vue-qrcode v2.0.0 | (c) 2018-present Chen Fengyuan | MIT */\nimport { defineComponent, h } from 'vue';\nimport { toString, toDataURL, toCanvas } from 'qrcode';\n\nconst EVENT_READY = 'ready';\r\nvar index = defineComponent({\r\n name: 'VueQrcode',\r\n props: {\r\n /**\r\n * The value of the QR code.\r\n */\r\n value: {\r\n type: String,\r\n default: undefined,\r\n },\r\n /**\r\n * The options for the QR code generator.\r\n * {@link https://github.com/soldair/node-qrcode#qr-code-options}\r\n */\r\n options: {\r\n type: Object,\r\n default: undefined,\r\n },\r\n /**\r\n * The tag name of the component's root element.\r\n */\r\n tag: {\r\n type: String,\r\n default: 'canvas',\r\n },\r\n },\r\n emits: [EVENT_READY],\r\n watch: {\r\n $props: {\r\n deep: true,\r\n immediate: true,\r\n /**\r\n * Update the QR code when props changed.\r\n */\r\n handler() {\r\n if (this.$el) {\r\n this.generate();\r\n }\r\n },\r\n },\r\n },\r\n mounted() {\r\n this.generate();\r\n },\r\n methods: {\r\n /**\r\n * Generate QR code.\r\n */\r\n generate() {\r\n const options = this.options || {};\r\n const value = String(this.value);\r\n const done = () => {\r\n this.$emit(EVENT_READY, this.$el);\r\n };\r\n switch (this.tag) {\r\n case 'canvas':\r\n toCanvas(this.$el, value, options, (error) => {\r\n if (error) {\r\n throw error;\r\n }\r\n done();\r\n });\r\n break;\r\n case 'img':\r\n toDataURL(value, options, (error, url) => {\r\n if (error) {\r\n throw error;\r\n }\r\n this.$el.src = url;\r\n this.$el.onload = done;\r\n });\r\n break;\r\n case 'svg':\r\n toString(value, options, (error, string) => {\r\n if (error) {\r\n throw error;\r\n }\r\n const div = document.createElement('div');\r\n div.innerHTML = string;\r\n const svg = div.querySelector('svg');\r\n if (svg) {\r\n const { attributes, childNodes } = svg;\r\n Object.keys(attributes).forEach((key) => {\r\n const attribute = attributes[Number(key)];\r\n this.$el.setAttribute(attribute.name, attribute.value);\r\n });\r\n Object.keys(childNodes).forEach((key) => {\r\n const childNode = childNodes[Number(key)];\r\n this.$el.appendChild(childNode.cloneNode(true));\r\n });\r\n done();\r\n }\r\n });\r\n break;\r\n }\r\n },\r\n },\r\n render() {\r\n return h(this.tag, this.$slots.default);\r\n },\r\n});\n\nexport { index as default };\n"],"names":["EVENT_READY","index","defineComponent","options","value","done","toCanvas","error","toDataURL","url","toString","string","div","svg","attributes","childNodes","key","attribute","childNode","h"],"mappings":"uZAAA,+DAIA,MAAMA,EAAc,QACjB,IAACC,EAAQC,EAAgB,CACxB,KAAM,YACN,MAAO,CAIH,MAAO,CACH,KAAM,OACN,QAAS,MACZ,EAKD,QAAS,CACL,KAAM,OACN,QAAS,MACZ,EAID,IAAK,CACD,KAAM,OACN,QAAS,QACZ,CACJ,EACD,MAAO,CAACF,CAAW,EACnB,MAAO,CACH,OAAQ,CACJ,KAAM,GACN,UAAW,GAIX,SAAU,CACF,KAAK,KACL,KAAK,SAAQ,CAEpB,CACJ,CACJ,EACD,SAAU,CACN,KAAK,SAAQ,CAChB,EACD,QAAS,CAIL,UAAW,CACP,MAAMG,EAAU,KAAK,SAAW,GAC1BC,EAAQ,OAAO,KAAK,KAAK,EACzBC,EAAO,IAAM,CACf,KAAK,MAAML,EAAa,KAAK,GAAG,CAChD,EACY,OAAQ,KAAK,IAAG,CACZ,IAAK,SACDM,EAAS,KAAK,IAAKF,EAAOD,EAAUI,GAAU,CAC1C,GAAIA,EACA,MAAMA,EAEVF,GACxB,CAAqB,EACD,MACJ,IAAK,MACDG,EAAUJ,EAAOD,EAAS,CAACI,EAAOE,IAAQ,CACtC,GAAIF,EACA,MAAMA,EAEV,KAAK,IAAI,IAAME,EACf,KAAK,IAAI,OAASJ,CAC1C,CAAqB,EACD,MACJ,IAAK,MACDK,EAASN,EAAOD,EAAS,CAACI,EAAOI,IAAW,CACxC,GAAIJ,EACA,MAAMA,EAEV,MAAM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