{"version":3,"sources":["webpack:///./src/js/components/document-library-queue.js"],"names":["Module","Component","setupDefaults","this","endpointCheckDownloads","el","dataset","endpointDownload","endpointQueue","endpointPrepareDownload","timeoutTime","parseInt","timeout","labels","JSON","parse","dom","queue","querySelector","ul","li","trigger","modal","closeModalBtn","notificationBar","notificationBarHeading","notificationBarCopy","notificationBarClose","notificationBarButtons","downloading","window","sessionStorage","getItem","split","queueStatus","tab","checkIfInterval","handleResize","addListeners","_on","bind","handleCloseNotification","addEventListener","fetchQueue","dispatchEvent","Event","length","intervalCheck","setInterval","handleCheckDownload","checkTime","clearInterval","fetch","then","response","json","data","Queue","forEach","result","clone","cloneNode","name","num","span","document","createElement","error","classList","add","hidden","setAttribute","tryAgainBtn","innerText","children","textContent","trim","downloadLink","e","handleDownload","Name","Id","push","setItem","status","days","displayStatus","method","headers","body","stringify","catch","console","ClaimNumber","appendChild","Downloaded","includes","Error","Expires","RemainingDays","remove","id","resultItem","downloadBtn","downloadingBtn","style","caption","replace","offsetHeight","downloaded","filter","errored","Errored","downloadedFilesLength","DownloadedFiles","downloadedQueueLength","QueueLength","documentName","DocumentName","erroredNotification","handleDisplayNotification","download","DefaultDays","notificationsErrorHeading","notificationErrorHeading","notificationErrorCopy","notificationsErrorCopy","notificationsReadyHeading","notificationReadyHeading","notificationReadyCopy","notificationsReadyCopy","setTimeout","clearTimeout","preventDefault","anchor","req","XMLHttpRequest","target","responseType","open","send","onreadystatechange","filename","getResponseHeader","request","isFile","readyState","fileUrl","URL","createObjectURL","href","replaceAll","click","removeAttribute","onprogress","Math","round","loaded","total","removeAttr"],"mappings":"2FAAA,mBAEA,MAAMA,UAAeC,YACnBC,gBACEC,KAAKC,uBAAyBD,KAAKE,GAAGC,QAAQF,uBAC9CD,KAAKI,iBAAmBJ,KAAKE,GAAGC,QAAQC,iBACxCJ,KAAKK,cAAgBL,KAAKE,GAAGC,QAAQE,cACrCL,KAAKM,wBAA0BN,KAAKE,GAAGC,QAAQG,wBAC/CN,KAA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MAAMkE,EAAM,IAAIC,eACVC,EAAS3D,EAAE2D,OACjBA,EAAOlE,aAAa,WAAY,QAC5BkE,EAAO/D,SAAS,KAClB+D,EAAO/D,SAAS,GAAGJ,QAAS,GAG9BiE,EAAIG,aAAe,OACnBH,EAAII,KAAK,MAAQ,GAAExI,KAAKI,uBAAuB8F,KAAM,GACrDkC,EAAIK,OAEJL,EAAIM,mBAAqB/D,IAAK,MAC5B,MAAMgE,EAAQ,UAAGP,EACdQ,kBAAkB,8BADP,aAAG,EAEb9G,MAAM,aACJ+G,EAAUlE,EAAE2D,OAEZQ,EAA0B,oBADXD,EAAQD,kBAAkB,gBAG/C,GAA2B,IAAvBC,EAAQE,YAAuC,MAAnBF,EAAQ5D,QAAkB6D,EAAQ,CAChE,MAAME,EAAUrH,OAAOsH,IAAIC,gBAAgBL,EAAQ1F,UACnDgF,EAAOgB,KAAOH,EACdb,EAAOb,SAAWqB,EACdA,EAAS,GAAGS,WAAW,IAAK,IAC5BzF,GAAQ,OACZwE,EAAOG,OAAS,SAChBH,EAAOkB,QACPf,EAAOgB,gBAAgB,iBACS,IAAvBT,EAAQE,aACjBT,EAAOgB,gBAAgB,YACvBhB,EAAO/D,SAAS,GAAGJ,QAAS,IAIhCiE,EAAImB,WAAa5E,IACI6E,KAAKC,MAAM9E,EAAE+E,OAAS/E,EAAEgF,MAAQ,KAElC,KACfxB,EAAOlC,SACPqC,EAAOsB,WAAW,eAMX/J","file":"62.7cf888.js","sourcesContent":["import { Component } from '@verndale/core';\n\nclass Module extends Component {\n  setupDefaults() {\n    this.endpointCheckDownloads = this.el.dataset.endpointCheckDownloads;\n    this.endpointDownload = this.el.dataset.endpointDownload;\n    this.endpointQueue = this.el.dataset.endpointQueue;\n    this.endpointPrepareDownload = this.el.dataset.endpointPrepareDownload;\n    this.timeoutTime = parseInt(this.el.dataset.timeout);\n    this.labels = JSON.parse(this.el.dataset.labels);\n    this.dom = {\n      queue: this.el.querySelector('.document-library-queue'),\n      ul: this.el.querySelector('.document-library-queue__list'),\n      li: this.el.querySelector('.document-library-queue__li'),\n      trigger: this.el.querySelector('.document-center-trigger'),\n      modal: this.el.querySelector('.document-library-queue__wrapper'),\n      closeModalBtn: this.el.querySelector('.btn.btn--outline'),\n      notificationBar: this.el.querySelector('.notification-bar'),\n      notificationBarHeading: this.el.querySelector(\n        '.notification-bar__heading'\n      ),\n      notificationBarCopy: this.el.querySelector('.notification-bar__copy'),\n      notificationBarClose: this.el.querySelector(\n        '.notification-bar__close-button'\n      ),\n      notificationBarButtons: this.el.querySelector(\n        '.notification-bar__buttons'\n      )\n    };\n\n    this.downloading = window.sessionStorage.getItem(\n      'documentLibraryDownloading'\n    );\n    this.downloading = this.downloading ? this.downloading.split(',') : '';\n    this.queueStatus = {};\n    if (this.el.dataset.tab !== 'true') {\n      this.checkIfInterval();\n    }\n    this.handleResize();\n  }\n\n  addListeners() {\n    window._on('resize', this.handleResize.bind(this));\n    this.dom.notificationBarClose._on(\n      'click',\n      this.handleCloseNotification.bind(this)\n    );\n    this.dom.modal.addEventListener('modalopen', () => this.fetchQueue());\n    this.dom.closeModalBtn.addEventListener('click', () =>\n      this.dom.modal.dispatchEvent(new Event('closemodal'))\n    );\n  }\n\n  checkIfInterval() {\n    if (\n      this.downloading &&\n      this.downloading.length > 0 &&\n      !this.intervalCheck\n    ) {\n      this.intervalCheck = setInterval(() => {\n        this.handleCheckDownload();\n      }, this.el.dataset.checkTime);\n    } else if (!this.downloading || this.downloading.length === 0) {\n      clearInterval(this.intervalCheck);\n      this.intervalCheck = null;\n    }\n  }\n\n  fetchQueue() {\n    fetch(this.endpointQueue)\n      .then(response => response.json())\n      .then(data => {\n        data.Queue.forEach(result => {\n          const clone = this.dom.li.cloneNode(true);\n          const name = clone.querySelector(\n            '.document-library-queue__info-name'\n          );\n          const num = clone.querySelector(\n            '.document-library-queue__info-claim-num'\n          );\n          const span = document.createElement('span');\n          const error = document.createElement('span');\n          error.classList.add('document-claims-library__caption--error');\n          error.hidden = true;\n          const downloadBtn = clone.querySelector(\n            '.document-library-queue__status-btn-success button'\n          );\n\n          downloadBtn.setAttribute('tabindex', -1);\n\n          const tryAgainBtn = clone.querySelector(\n            '.document-library-queue__status-btn-failed'\n          );\n          error.innerText = tryAgainBtn.children[0].textContent.trim();\n\n          const downloadLink = clone.querySelector(\n            '.document-library-queue__download'\n          );\n\n          downloadLink.addEventListener('click', e =>\n            this.handleDownload(e, result.Name, result.Id)\n          );\n\n          tryAgainBtn.querySelector('button').addEventListener('click', () => {\n            if (this.downloading) {\n              this.downloading.push(result.Id);\n            } else {\n              this.downloading = [result.Id];\n            }\n            this.checkIfInterval();\n            window.sessionStorage.setItem(\n              'documentLibraryDownloading',\n              this.downloading\n            );\n            this.queueStatus[result.Id] = {\n              status: 1,\n              days: this.queueStatus[result.Id].days === null ? null : ''\n            };\n            this.displayStatus(result.Id);\n            fetch(this.endpointPrepareDownload, {\n              method: 'POST',\n              headers: {\n                'Content-Type': 'application/json'\n              },\n              body: JSON.stringify(result.Id)\n            }).catch(error => {\n              console.error('Error:', error);\n            });\n          });\n\n          span.textContent = result.ClaimNumber;\n          clone.setAttribute('data-id', result.Id);\n          name.textContent = result.Name;\n          num.appendChild(span);\n\n          let status = result.Downloaded ? 2 : 0;\n          if (this.downloading.includes(result.Id)) status = 1;\n          if (result.Error) status = 0;\n          this.queueStatus[result.Id] = {\n            status,\n            days: result.Expires ? result.RemainingDays : null\n          };\n\n          this.dom.li.remove();\n          downloadLink.appendChild(error);\n          this.dom.ul.appendChild(clone);\n          this.displayStatus(result.Id);\n        });\n      })\n      .catch(error => {\n        console.error('Error:', error);\n      });\n  }\n\n  displayStatus(id) {\n    const resultItem = this.dom.ul.querySelector(`[data-id=\"${id}\"]`);\n\n    if (!resultItem) {\n      return;\n    }\n    const downloadBtn = resultItem?.querySelector(\n      '.document-library-queue__status-btn-success'\n    );\n    const downloadingBtn = resultItem?.querySelector(\n      '.document-library-queue__status-btn-downloading'\n    );\n    const tryAgainBtn = resultItem?.querySelector(\n      '.document-library-queue__status-btn-failed'\n    );\n    const downloadLink = resultItem?.querySelector(\n      '.document-library-queue__download'\n    );\n\n    switch (this.queueStatus[id].status) {\n    case 0:\n      downloadBtn.hidden = true;\n      downloadingBtn.hidden = true;\n      tryAgainBtn.hidden = false;\n      downloadLink.style = 'display: none';\n      break;\n    case 1:\n      downloadBtn.hidden = true;\n      downloadingBtn.hidden = false;\n      tryAgainBtn.hidden = true;\n      downloadLink.style = 'display: none';\n      break;\n    default:\n      downloadBtn.hidden = false;\n      downloadingBtn.hidden = true;\n      tryAgainBtn.hidden = true;\n      downloadLink.style = '';\n\n      const caption = downloadBtn.querySelector(\n        '.document-claims-library__caption'\n      );\n\n      if (this.queueStatus[id].days === null) {\n        caption?.remove();\n      } else {\n        caption.textContent = caption.innerText.replace(\n          '{0}',\n          this.queueStatus[id].days\n        );\n      }\n      break;\n    }\n  }\n\n  handleResize() {\n    this.dom.notificationBar.setAttribute(\n      'style',\n      `--button-height: ${this.dom.notificationBarButtons.offsetHeight}px`\n    );\n  }\n\n  handleCheckDownload() {\n    fetch(this.endpointCheckDownloads, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json'\n      },\n      body: JSON.stringify(this.downloading)\n    })\n      .then(response => response.json())\n      .then(data => {\n        const downloaded = data.Downloaded.filter(id =>\n          this.downloading.includes(id)\n        );\n\n        const errored = data.Errored?.filter(id =>\n          this.downloading.includes(id)\n        );\n        if (downloaded.length > 0 || errored.length > 0) {\n          this.downloading = this.downloading.filter(\n            id => !downloaded.includes(id) && !errored.includes(id)\n          );\n\n          window.sessionStorage.setItem(\n            'documentLibraryDownloading',\n            this.downloading\n          );\n\n          this.checkIfInterval();\n\n          this.downloadedFilesLength = data.DownloadedFiles;\n          this.downloadedQueueLength = data.QueueLength;\n\n          if (downloaded.length > 0 && errored.length === 0) {\n            this.documentName = data.DocumentName;\n            this.erroredNotification = false;\n            this.handleDisplayNotification();\n\n            downloaded.forEach(download => {\n              if (this.queueStatus[download]) {\n                this.queueStatus[download] = {\n                  status: 2,\n                  days:\n                    this.queueStatus[download].days === null\n                      ? null\n                      : data.DefaultDays\n                };\n                this.displayStatus(download);\n              }\n            });\n          }\n\n          if (errored.length > 0) {\n            this.erroredNotification = true;\n            this.handleDisplayNotification();\n            errored.forEach(error => {\n              if (this.queueStatus[error]) {\n                this.queueStatus[error] = {\n                  status: 0,\n                  days:\n                    this.queueStatus[error].days === null\n                      ? null\n                      : data.DefaultDays\n                };\n              } else {\n                this.queueStatus[error] = {\n                  status: 0,\n                  days: null\n                };\n                this.displayStatus(error);\n              }\n            });\n          }\n        }\n      })\n      .catch(error => {\n        console.error('Error:', error);\n      });\n  }\n\n  handleDisplayNotification() {\n    if (this.erroredNotification) {\n      this.dom.notificationBarHeading.innerText =\n        this.downloadedQueueLength > 1\n          ? this.labels.notificationsErrorHeading\n            .replace('{0}', this.downloadedFilesLength)\n            .replace('{1}', this.downloadedQueueLength)\n          : this.labels.notificationErrorHeading.replace(\n            '{0}',\n            this.documentName\n          );\n      this.dom.notificationBarCopy.innerText =\n        this.downloadedQueueLength > 1\n          ? this.labels.notificationErrorCopy\n          : this.labels.notificationsErrorCopy;\n    } else {\n      this.dom.notificationBarHeading.innerText =\n        this.downloadedQueueLength > 1\n          ? this.labels.notificationsReadyHeading\n            .replace('{0}', this.downloadedFilesLength)\n            .replace('{1}', this.downloadedQueueLength)\n          : this.labels.notificationReadyHeading.replace(\n            '{0}',\n            this.documentName\n          );\n      this.dom.notificationBarCopy.innerText =\n        this.downloadedQueueLength > 1\n          ? this.labels.notificationReadyCopy.replace('{0}', this.documentName)\n          : this.labels.notificationsReadyCopy.replace(\n            '{0}',\n            this.documentName\n          );\n    }\n\n    if (this.timeoutTime > 0) {\n      this.timeout = setTimeout(() => {\n        this.handleCloseNotification();\n      }, this.timeoutTime);\n    }\n    this.dom.notificationBar.classList.add('notification-bar--show');\n  }\n\n  handleCloseNotification() {\n    clearTimeout(this.timeout);\n    this.dom.notificationBar.classList.remove('notification-bar--show');\n  }\n\n  handleDownload(e, name, id) {\n    e.preventDefault();\n    const anchor = document.createElement('a');\n    anchor.classList.add('download-link-hidden');\n    const req = new XMLHttpRequest();\n    const target = e.target;\n    target.setAttribute('disabled', 'true');\n    if (target.children[0]) {\n      target.children[0].hidden = true;\n    }\n\n    req.responseType = 'blob';\n    req.open('get', `${this.endpointDownload}?id=${id}`, true);\n    req.send();\n\n    req.onreadystatechange = e => {\n      const filename = req\n        .getResponseHeader('content-disposition')\n        ?.split('filename=');\n      const request = e.target;\n      const responseType = request.getResponseHeader('content-type');\n      const isFile = responseType === 'application/pdf';\n\n      if (request.readyState === 4 && request.status === 200 && isFile) {\n        const fileUrl = window.URL.createObjectURL(request.response);\n        anchor.href = fileUrl;\n        anchor.download = filename\n          ? filename[1].replaceAll('\"', '')\n          : name || 'file';\n        anchor.target = '_blank';\n        anchor.click();\n        target.removeAttribute('disabled');\n      } else if (request.readyState === 4) {\n        target.removeAttribute('disabled');\n        target.children[0].hidden = false;\n      }\n    };\n\n    req.onprogress = e => {\n      const percentage = Math.round(e.loaded / e.total / 100);\n\n      if (percentage > 99) {\n        anchor.remove();\n        target.removeAttr('disabled');\n      }\n    };\n  }\n}\n\nexport default Module;\n"],"sourceRoot":""}