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H,GAAK,CAC1CA,EAAE,aAAa,OAAQG,CAAW,CACpC,CAAC,CACH,CACF,CACF,CAKA,MAAMC,EAAU,IAAIR,EAEpB,SAAS,iBAAiB,mBAAoB,IAAM,CAClDQ,EAAQ,KAAK,CACf,CAAC,C","sources":["webpack:///./src/js/sections/workshop/iv-pitch.ts"],"sourcesContent":["/* Types\n  ========================================================================== */\ndeclare global {\n  interface Window {\n    EDU_IV: {\n      locale: string,\n      workshopApiEndpoint: string,\n      workshopSlug: string,\n      workshopViewerUrl: string,\n    }\n  }\n}\n\ntype WorkshopData = {\n  title: string,\n  slug: string,\n  demo_code: string,\n  student_guide: string\n}\n\ntype WorkshopApiResponse = {\n  items: WorkshopData[],\n  meta: {\n    media : {\n      original_url: string\n    }\n  }\n}\n\n/* IVPitch class\n  ========================================================================== */\n\nexport default class IVPitch {\n  workshopData: WorkshopData | null = null\n\n  demoBtnList: NodeListOf<HTMLLinkElement> | null = null\n\n  downloadStudentGuideList: NodeListOf<HTMLLinkElement> | null = null\n  downloadGuideUrlPattern: string = ''\n\n  init () {\n    this.demoBtnList = document.querySelectorAll('[data-ui-el=\"demo-btn\"]')\n    this.downloadStudentGuideList = document.querySelectorAll('[data-ui-el=\"student-guide\"]')\n\n    this.getWorkshopData()\n  }\n\n  async getWorkshopData () {\n    try {\n      const WORKSHOP_API_ENDPOINT = `${window.EDU_IV.workshopApiEndpoint}v1/workshops/?language=${window.EDU_IV.locale}`\n      const response = await fetch(WORKSHOP_API_ENDPOINT)\n\n      if (response.ok) {\n        const data: WorkshopApiResponse = await response.json()\n        this.workshopData = data.items.find((e: WorkshopData) => e.slug === window.EDU_IV.workshopSlug) ?? null\n        if (this.workshopData) {\n          this.enableDemoLink()\n\n          this.downloadGuideUrlPattern = data.meta.media.original_url\n          if (this.downloadGuideUrlPattern) {\n            this.enableDownloadGuideLink()\n          }\n        }\n      } else {\n        this.disableTryLink()\n      }\n    } catch {\n      this.disableTryLink()\n    }\n  }\n\n  enableDemoLink () {\n    if (this.workshopData?.demo_code) {\n      const demoUrl: string = window.EDU_IV.workshopViewerUrl.replace('FAKEIV', this.workshopData?.demo_code)\n      this.demoBtnList?.forEach(link => link.setAttribute('href', demoUrl))\n    } else {\n      this.disableTryLink()\n    }\n  }\n\n  disableTryLink () {\n    this.demoBtnList?.forEach(link => link.classList.add('hidden'))\n  }\n\n  enableDownloadGuideLink () {\n    if (this.workshopData?.student_guide) {\n      const downloadUrl: string = this.downloadGuideUrlPattern.replace('{path}', this.workshopData.student_guide)\n      this.downloadStudentGuideList?.forEach(e => {\n        e.setAttribute('href', downloadUrl)\n      })\n    }\n  }\n}\n\n/* Init\n  ========================================================================== */\n\nconst iVPitch = new IVPitch()\n\ndocument.addEventListener('DOMContentLoaded', () => {\n  iVPitch.init()\n})\n"],"names":["IVPitch","WORKSHOP_API_ENDPOINT","response","data","e","demoUrl","link","downloadUrl","iVPitch"],"sourceRoot":""}