{"version":3,"file":"index.fadb2c99.js","sources":["../../node_modules/vue-inline-svg/src/index.js"],"sourcesContent":["// peer dep is not installed during test\n// eslint-disable-next-line import/no-unresolved\nimport { h as createElement } from 'vue';\n\n/** @type Record> */\nconst cache = {};\n\n/**\n * Remove false attrs\n * @param {Object} attrs\n */\nfunction filterAttrs(attrs) {\n return Object.keys(attrs).reduce((result, key) => {\n if (attrs[key] !== false && attrs[key] !== null && attrs[key] !== undefined) {\n result[key] = attrs[key];\n }\n return result;\n }, {});\n}\n\nconst InlineSvg = {\n name: 'InlineSvg',\n inheritAttrs: false,\n render() {\n if (!this.svgElSource) {\n return null;\n }\n return createElement(\n 'svg',\n Object.assign(\n {},\n // source attrs\n this.getSvgAttrs(this.svgElSource),\n // component attrs and listeners\n filterAttrs(this.$attrs),\n // content\n { innerHTML: this.getSvgContent(this.svgElSource) },\n ),\n );\n },\n props: {\n src: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n },\n transformSource: {\n type: Function,\n default: (svg) => svg,\n },\n keepDuringLoading: {\n type: Boolean,\n default: true,\n },\n },\n emits: ['loaded', 'unloaded', 'error'],\n data() {\n return {\n /** @type SVGElement */\n svgElSource: null,\n };\n },\n watch: {\n src(newValue) {\n // re-generate cached svg (`svgElSource`)\n this.getSource(newValue);\n },\n },\n mounted() {\n // generate `svgElSource`\n this.getSource(this.src);\n },\n methods: {\n getSvgAttrs(svgEl) {\n // copy attrs\n let svgAttrs = {};\n const attrs = svgEl.attributes;\n if (!attrs) {\n return svgAttrs;\n }\n for (let i = attrs.length - 1; i >= 0; i--) {\n svgAttrs[attrs[i].name] = attrs[i].value;\n }\n return svgAttrs;\n },\n getSvgContent(svgEl) {\n svgEl = svgEl.cloneNode(true);\n svgEl = this.transformSource(svgEl);\n if (this.title) {\n setTitle(svgEl, this.title);\n }\n\n // copy inner html\n return svgEl.innerHTML;\n },\n /**\n * Get svgElSource\n * @param {string} src\n */\n getSource(src) {\n // fill cache by src with promise\n if (!cache[src]) {\n // download\n cache[src] = this.download(src);\n }\n // notify svg is unloaded\n if (this.svgElSource && cache[src].getIsPending() && !this.keepDuringLoading) {\n this.svgElSource = null;\n this.$emit('unloaded');\n }\n\n // inline svg when cached promise resolves\n cache[src]\n .then((svg) => {\n this.svgElSource = svg;\n // wait to render\n this.$nextTick(() => {\n // notify\n this.$emit('loaded', this.$el);\n });\n })\n .catch((err) => {\n // notify svg is unloaded\n if (this.svgElSource) {\n this.svgElSource = null;\n this.$emit('unloaded');\n }\n // remove cached rejected promise so next image can try load again\n delete cache[src];\n this.$emit('error', err);\n });\n },\n\n /**\n * Get the contents of the SVG\n * @param {string} url\n * @returns {PromiseWithState}\n */\n download(url) {\n return makePromiseState(new Promise((resolve, reject) => {\n const request = new XMLHttpRequest();\n request.open('GET', url, true);\n\n request.onload = () => {\n if (request.status >= 200 && request.status < 400) {\n try {\n // Setup a parser to convert the response to text/xml in order for it to be manipulated and changed\n const parser = new DOMParser();\n const result = parser.parseFromString(request.responseText, 'text/xml');\n let svgEl = result.getElementsByTagName('svg')[0];\n if (svgEl) {\n // svgEl = this.transformSource(svgEl);\n resolve(svgEl);\n } else {\n reject(new Error('Loaded file is not valid SVG\"'));\n }\n } catch (e) {\n reject(e);\n }\n } else {\n reject(new Error('Error loading SVG'));\n }\n };\n\n request.onerror = reject;\n request.send();\n }));\n },\n },\n};\n\n/**\n * Create or edit the element of a SVG\n * @param {SVGElement} svg\n * @param {string} title\n */\nfunction setTitle(svg, title) {\n const titleTags = svg.getElementsByTagName('title');\n if (titleTags.length) { // overwrite existing title\n titleTags[0].textContent = title;\n } else { // create a title element if one doesn't already exist\n const titleEl = document.createElementNS('http://www.w3.org/2000/svg', 'title');\n titleEl.textContent = title;\n // svg.prepend(titleEl);\n svg.insertBefore(titleEl, svg.firstChild);\n }\n}\n\n/**\n * @typedef {Promise & object} PromiseWithState\n * @property {function: boolean} getIsPending\n * @template T\n */\n\n/**\n * This function allow you to modify a JS Promise by adding some status properties.\n * @template {any} T\n * @param {Promise<T>|PromiseWithState<T>} promise\n * @return {PromiseWithState<T>}\n */\nfunction makePromiseState(promise) {\n // Don't modify any promise that has been already modified.\n if (promise.getIsPending) return promise;\n\n // Set initial state\n let isPending = true;\n\n // Observe the promise, saving the fulfillment in a closure scope.\n let result = promise.then(\n (v) => {\n isPending = false;\n return v;\n },\n (e) => {\n isPending = false;\n throw e;\n },\n );\n\n result.getIsPending = function getIsPending() { return isPending; };\n return result;\n}\n\nexport default InlineSvg;\n"],"names":["cache","filterAttrs","attrs","result","key","InlineSvg","createElement","svg","newValue","svgEl","svgAttrs","i","setTitle","src","err","url","makePromiseState","resolve","reject","request","e","title","titleTags","titleEl","promise","isPending","v","InlineSvg$1"],"mappings":"8VAKA,MAAMA,EAAQ,CAAA,EAMd,SAASC,EAAYC,EAAO,CACxB,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC,EAAQC,KAClCF,EAAME,KAAS,IAASF,EAAME,KAAS,MAAQF,EAAME,KAAS,SAC9DD,EAAOC,GAAOF,EAAME,IAEjBD,GACR,CAAE,CAAA,CACT,CAEA,MAAME,EAAY,CACd,KAAM,YACN,aAAc,GACd,QAAS,CACL,OAAK,KAAK,YAGHC,EACH,MACA,OAAO,OACH,CAAE,EAEF,KAAK,YAAY,KAAK,WAAW,EAEjCL,EAAY,KAAK,MAAM,EAEvB,CAAE,UAAW,KAAK,cAAc,KAAK,WAAW,CAAG,CACtD,CACb,EAbmB,IAcd,EACD,MAAO,CACH,IAAK,CACD,KAAM,OACN,SAAU,EACb,EACD,MAAO,CACH,KAAM,MACT,EACD,gBAAiB,CACb,KAAM,SACN,QAAUM,GAAQA,CACrB,EACD,kBAAmB,CACf,KAAM,QACN,QAAS,EACZ,CACJ,EACD,MAAO,CAAC,SAAU,WAAY,OAAO,EACrC,MAAO,CACH,MAAO,CAEH,YAAa,IACzB,CACK,EACD,MAAO,CACH,IAAIC,EAAU,CAEV,KAAK,UAAUA,CAAQ,CAC1B,CACJ,EACD,SAAU,CA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