# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
# Copyright (C) 2017-2023 Osimis S.A., Belgium
# Copyright (C) 2024-2026 Orthanc Team SRL, Belgium
# Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


set(BASE_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads")

DownloadPackage(
  "b7de8bba890ccc3858920bd66dd79d2d"
  "${BASE_URL}/WSI/openlayers-10.6.1-package.tar.gz"
  "openlayers-10.6.1-package")

DownloadPackage(
  "102a4386a022f26a3b604e3852fffba8"
  "${BASE_URL}/bootstrap-5.3.3.zip"
  "${CMAKE_CURRENT_BINARY_DIR}/bootstrap-5.3.3")

DownloadPackage(
  "6e819ef7fcd49bb13cf809fd8c5fb20b"
  "${BASE_URL}/bootstrap-icons-1.13.1.zip"
  "${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1")

DownloadPackage(
  "8242afdc5bd44105d9dc9e6535315484"
  "${BASE_URL}/dicom-web/vuejs-2.6.10.tar.gz"
  "${CMAKE_CURRENT_BINARY_DIR}/vue-2.6.10")

# axios v0.31.0 is the last release before Axios removed the committed dist/ artifacts
# https://github.com/axios/axios/releases?page=2#release-v0.31.0
DownloadPackage(
  "e1fe2cd9270b513874aea946977f2d47"
  "${BASE_URL}/axios-0.31.0.tar.gz"
  "${CMAKE_CURRENT_BINARY_DIR}/axios-0.31.0")

# curl -L https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js | gzip > /tmp/popper-2.11.8.min.js.gz

DownloadCompressedFile(
  "309f660accb8025e06ca99feae3c1d7c"
  "${BASE_URL}/WSI/popper-2.11.8.min.js.gz"
  "${CMAKE_CURRENT_BINARY_DIR}/popper.min.js")

DownloadFile(
  "aa2c54fdbbbeb1bb056793ec480928eb"
  "${BASE_URL}/WSI/modern-screenshot-4.7.0.js")


set(JAVASCRIPT_LIBS_DIR  ${CMAKE_CURRENT_BINARY_DIR}/javascript-libs)
file(MAKE_DIRECTORY ${JAVASCRIPT_LIBS_DIR})


file(COPY
  ${CMAKE_CURRENT_BINARY_DIR}/axios-0.31.0/dist/axios.min.js
  ${CMAKE_CURRENT_BINARY_DIR}/axios-0.31.0/dist/axios.min.js.map
  ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-5.3.3/dist/js/bootstrap.min.js
  ${CMAKE_CURRENT_BINARY_DIR}/openlayers-10.6.1-package/dist/ol.js
  ${CMAKE_CURRENT_BINARY_DIR}/popper.min.js
  ${CMAKE_CURRENT_BINARY_DIR}/vue-2.6.10/dist/vue.min.js
  ${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/modern-screenshot-4.7.0.js
  DESTINATION
  ${JAVASCRIPT_LIBS_DIR}/js
  )

file(RENAME
  ${JAVASCRIPT_LIBS_DIR}/js/modern-screenshot-4.7.0.js
  ${JAVASCRIPT_LIBS_DIR}/js/modern-screenshot.js
  )

file(COPY
  ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-5.3.3/dist/css/bootstrap.min.css
  ${CMAKE_CURRENT_BINARY_DIR}/openlayers-10.6.1-package/ol.css
  DESTINATION
  ${JAVASCRIPT_LIBS_DIR}/css
  )

file(COPY
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/arrow-clockwise.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/arrows-fullscreen.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/arrows-move.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/arrows.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/brightness-high.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/camera.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/chevron-compact-left.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/chevron-compact-right.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/circle.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/cloud-download.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/eye-slash.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/eye.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/file-earmark-plus.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/geo-alt.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/hand-index.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/pen.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/pentagon.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/share.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/square.svg
  ${CMAKE_CURRENT_BINARY_DIR}/icons-1.13.1/icons/trash.svg

  ${CMAKE_CURRENT_LIST_DIR}/../Icons/freehand-area-svgrepo-com.svg
  ${CMAKE_CURRENT_LIST_DIR}/../Icons/freehand-svgrepo-com.svg

  DESTINATION
  ${JAVASCRIPT_LIBS_DIR}/svg
  )
