{"version":3,"sources":["webpack:///./src/components/UI/LinkPrint.vue","webpack:///src/components/UI/LinkPrint.vue","webpack:///./src/components/UI/LinkPrint.vue?d100","webpack:///./src/components/UI/LinkPrint.vue?068d"],"names":["render","_vm","this","_c","_self","staticClass","on","print","class","isLoading","attrs","domProps","_s","$t","staticRenderFns","name","props","type","String","required","id","openInModal","Boolean","default","components","data","showModal","methods","openModal","closeModal","_this","_asyncToGenerator","_regenerator","m","_callee","response","linkSource","pdfBlob","blobUrl","link","t","_t","w","_context","n","a","proposalProvider","getProposalPdf","catch","finally","v","reservationProvider","getReservationPdf","invoiceProvider","getInvoicePdf","feeinvoiceProvider","getFeeInvoicePdf","concat","dataURItoBlob","URL","createObjectURL","document","createElement","target","href","click","remove","setTimeout","window","revokeObjectURL","clearTimeout","dataURI","byteString","atob","split","mimeString","ab","ArrayBuffer","length","ia","Uint8Array","i","charCodeAt","bb","Blob","component"],"mappings":"uHAAA,IAAIA,EAAS,WAAkB,IAAIC,EAAIC,KAAKC,EAAGF,EAAIG,MAAMD,GAAG,OAAOA,EAAG,IAAI,CAACE,YAAY,yBAAyBC,GAAG,CAAC,MAAQ,WAAQL,EAAIM,WAAY,CAACJ,EAAG,OAAO,CAACE,YAAY,OAAOG,MAAM,CAAC,aAAcP,EAAIQ,YAAa,CAACN,EAAG,oBAAoB,CAACO,MAAM,CAAC,KAAO,CAAC,MAAO,aAAa,GAAGP,EAAG,OAAO,CAACQ,SAAS,CAAC,YAAcV,EAAIW,GAAGX,EAAIY,GAAG,6BAErUC,EAAkB,G,olBC0BP,GACfC,KAAA,QACAC,MAAA,CACAC,KAAA,CACAA,KAAAC,OACAC,UAAA,GAGAC,GAAA,CACAH,KAAAC,OACAC,UAAA,GAGAE,YAAA,CACAJ,KAAAK,QACAC,SAAA,IAIAC,WAAA,GAIAC,KAAA,WACA,OACAC,WAAA,EACAjB,WAAA,IAIAkB,QAAA,CACAC,UAAA,WACA,KAAAF,WAAA,GAGAG,WAAA,WACA,KAAAH,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A2B,SACA1B,EAAA2B,YAAA,WACAC,OAAAT,IAAAU,gBAAA/B,GACAgC,aAAA9B,KACA,IAEAV,EAAArB,WAAA,iBAAAkC,EAAAE,EAAA,MAAAX,MAzDAH,IA4DA2B,cAAA,SAAAa,GAUA,IATA,IAAAC,EAAAC,KAAAF,EAAAG,MAAA,SACAC,EAAAJ,EACAG,MAAA,QACAA,MAAA,QACAA,MAAA,QAGAE,EAAA,IAAAC,YAAAL,EAAAM,QACAC,EAAA,IAAAC,WAAAJ,GACAK,EAAA,EAAAA,EAAAT,EAAAM,OAAAG,IACAF,EAAAE,GAAAT,EAAAU,WAAAD,GAIA,IAAAE,EAAA,IAAAC,KAAA,CAAAR,GAAA,CAAA3D,KAAA0D,IACA,OAAAQ,KC/IiW,I,YCO7VE,EAAY,eACd,EACArF,EACAc,GACA,EACA,KACA,WACA,MAIa,aAAAuE,E","file":"js/chunk-2d221819.js?id=239d0b487772907f2b69","sourcesContent":["var render = function render(){var _vm=this,_c=_vm._self._c;return _c('a',{staticClass:\"has-icon has-text-link\",on:{\"click\":() => { _vm.print() }}},[_c('span',{staticClass:\"icon\",class:{'is-loading': _vm.isLoading }},[_c('font-awesome-icon',{attrs:{\"icon\":['far', 'print']}})],1),_c('span',{domProps:{\"textContent\":_vm._s(_vm.$t('Form.Control.Print'))}})])\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","<template>\n  <a\n    class=\"has-icon has-text-link\"\n    @click=\"() => { print() }\"\n  >\n    <span\n      class=\"icon\"\n      :class=\"{'is-loading': isLoading }\"\n    >\n      <font-awesome-icon :icon=\"['far', 'print']\" />\n    </span>\n    <span v-text=\"$t('Form.Control.Print')\"></span>\n    <!-- <ModalPrint\n      v-if=\"showModal\"\n      :showModal=\"showModal\"\n      :onCloseFunc=\"closeModal\"\n      :type=\"type\"\n      :id=\"id\"\n    /> -->\n  </a>\n</template>\n\n<script>\nimport feeinvoiceProvider from '@/providers/feeinvoice'\nimport proposalProvider from '@/providers/proposal'\nimport reservationProvider from '@/providers/reservation'\nimport invoiceProvider from '@/providers/invoice'\n// import ModalPrint from '@/components/UI/ModalPrint'\nexport default {\n  name: 'Print',\n  props: {\n    type: {\n      type: String,\n      required: true,\n    },\n\n    id: {\n      type: String,\n      required: true,\n    },\n\n    openInModal: {\n      type: Boolean,\n      default: false,\n    },\n  },\n\n  components: {\n    // ModalPrint,\n  },\n\n  data() {\n    return {\n      showModal: false,\n      isLoading: false,\n    }\n  },\n\n  methods: {\n    openModal() {\n      this.showModal = true\n    },\n\n    closeModal() {\n      this.showModal = false\n    },\n\n    async print() {\n      if (this.isLoading) { return }\n      this.isLoading = true\n      let response = null\n\n      switch (this.type) {\n        case 'proposal':\n          response = await proposalProvider.methods\n            .getProposalPdf(this.id)\n            .catch()\n            .finally(() => {\n              this.isLoading = false;\n            })\n          break\n        case 'reservation':\n          response = await reservationProvider.methods\n            .getReservationPdf(this.id)\n            .catch()\n            .finally(() => {\n              this.isLoading = false;\n            })\n          break\n        case 'invoice':\n          response = await invoiceProvider.methods\n            .getInvoicePdf(this.id)\n            .catch()\n            .finally(() => {\n              this.isLoading = false;\n            })\n          break\n        case 'feeinvoice':\n          response = await feeinvoiceProvider.methods\n            .getFeeInvoicePdf(this.id)\n            .catch()\n            .finally(() => {\n              this.isLoading = false;\n            })\n          break\n\n        default:\n          break\n      }\n\n      const linkSource = `data:application/pdf;base64,${response.data}`\n      const pdfBlob = this.dataURItoBlob(linkSource)\n      const blobUrl = URL.createObjectURL(pdfBlob)\n\n      const link = document.createElement('a')\n      link.target = '_blank'\n      link.href = blobUrl\n      link.click()\n      link.remove()\n      let t = setTimeout(() => {\n        window.URL.revokeObjectURL(blobUrl)\n        clearTimeout(t)\n      }, 20)\n\n      this.isLoading = false\n    },\n\n    dataURItoBlob(dataURI) {\n      const byteString = atob(dataURI.split(',')[1])\n      const mimeString = dataURI\n        .split(',')[0]\n        .split(':')[1]\n        .split(';')[0]\n\n      // write the bytes of the string to an ArrayBuffer\n      const ab = new ArrayBuffer(byteString.length)\n      const ia = new Uint8Array(ab)\n      for (let i = 0; i < byteString.length; i++) {\n        ia[i] = byteString.charCodeAt(i)\n      }\n\n      // write the ArrayBuffer to a blob, and you're done\n      const bb = new Blob([ab], { type: mimeString })\n      return bb\n    },\n  },\n}\n</script>\n\n<style lang=\"scss\" scoped></style>\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./LinkPrint.vue?vue&type=script&lang=js\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./LinkPrint.vue?vue&type=script&lang=js\"","import { render, staticRenderFns } from \"./LinkPrint.vue?vue&type=template&id=641f2cb6&scoped=true\"\nimport script from \"./LinkPrint.vue?vue&type=script&lang=js\"\nexport * from \"./LinkPrint.vue?vue&type=script&lang=js\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  \"641f2cb6\",\n  null\n  \n)\n\nexport default component.exports"],"sourceRoot":""}