{"version":3,"file":"VastStore-BPwOrXvb.mjs","names":[],"sources":["../src/stores/VastStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\nimport { AdPosition } from \"./class/adserver/adPosition\";\n\ninterface VastState {\n  currentAd: google.ima.Ad|undefined;\n  isAdPlaying: boolean;\n  isAdPaused: boolean;\n  isAdSkippable: boolean;\n  isAdSkipped: boolean;\n  isSkipCurrentlyAllowed: boolean;\n  timeTillSkipInSeconds: number;\n  currentTimeAd: number;\n  currentDurationAd: number;\n  resetSessionId: boolean;\n\n  useVastPlayerPodcast: boolean;\n  adPositionIndex: number;\n  adPositionsPodcasts: { [key: number]: Array<AdPosition> };\n}\n\nfunction emptyVastState(): VastState {\n  return {\n    currentAd: undefined,\n    isAdPlaying: false,\n    isAdPaused: false,\n    isAdSkippable: false,\n    isAdSkipped: false,\n    isSkipCurrentlyAllowed: false,\n    timeTillSkipInSeconds: 0,\n    currentTimeAd: 0,\n    currentDurationAd: 0,\n    resetSessionId: false,\n\n    useVastPlayerPodcast: false,\n    adPositionIndex: 0,\n    adPositionsPodcasts: {},\n  };\n}\n\nexport const useVastStore = defineStore(\"VastStore\", {\n  state: (): VastState => emptyVastState(),\n  getters: {\n    adPercentProgress(): number {\n      if (!this.currentTimeAd) {\n        return 0;\n      }\n      return (this.currentTimeAd * 100) / this.currentDurationAd;\n    },\n    linkAdvertising(): string | undefined {\n      if (this.isAdPlaying) {\n        return this.currentAd?.data?.clickThroughUrl;\n      }\n      return undefined;\n    },\n    titleAdvertising(): string {\n      if (this.isAdPlaying) {\n        return this.currentAd?.data?.title\n          ? \" - \" + this.currentAd.data.title\n          : \"\";\n      }\n      return \"\";\n    },\n  },\n  actions: {\n    restartVastData() {\n      const saveAdPositionsPodcasts = this.adPositionsPodcasts;\n      this.$state = emptyVastState();\n      this.adPositionsPodcasts = saveAdPositionsPodcasts;\n    },\n    updateAdPositionIndex(index: number) {\n      this.adPositionIndex = index;\n    },\n    updateResetSessionId(value: boolean) {\n      this.resetSessionId = value;\n    },\n    updateAdPositionsPodcasts(\n      podcastId: number,\n      adPositions: Array<AdPosition>,\n    ) {\n      this.adPositionsPodcasts[podcastId] = adPositions;\n    },\n    updateCurrentAd(currentAd: google.ima.Ad) {\n      this.currentAd = currentAd;\n      this.isAdSkipped = false;\n    },\n    updateIsAdPlaying(isAdPlaying: boolean) {\n      this.isAdPlaying = isAdPlaying;\n    },\n    updateIsAdPaused(isAdPaused: boolean) {\n      this.isAdPaused = isAdPaused;\n    },\n    updateIsAdSkipped(isAdSkipped: boolean) {\n      this.isAdSkipped = isAdSkipped;\n    },\n    updateProgressionData(currentDurationAd: number, currentTimeAd: number) {\n      this.currentDurationAd = currentDurationAd;\n      this.currentTimeAd = currentTimeAd;\n    },\n    updateSkippableData(\n      isAdSkippable: boolean,\n      isSkipCurrentlyAllowed: boolean,\n      timeTillSkipInSeconds: number,\n    ) {\n      this.isAdSkippable = isAdSkippable;\n      this.isSkipCurrentlyAllowed = isSkipCurrentlyAllowed;\n      this.timeTillSkipInSeconds = timeTillSkipInSeconds;\n    },\n    updateuseVastPlayerPodcast(useVastPlayerPodcast: boolean) {\n      this.useVastPlayerPodcast = useVastPlayerPodcast;\n    },\n  },\n});\n"],"mappings":";;AAoBA,SAAS,iBAA4B;CACnC,OAAO;EACL,WAAW,KAAA;EACX,aAAa;EACb,YAAY;EACZ,eAAe;EACf,aAAa;EACb,wBAAwB;EACxB,uBAAuB;EACvB,eAAe;EACf,mBAAmB;EACnB,gBAAgB;EAEhB,sBAAsB;EACtB,iBAAiB;EACjB,qBAAqB,CAAC;CACxB;AACF;AAEA,IAAa,eAAe,YAAY,aAAa;CACnD,aAAwB,eAAe;CACvC,SAAS;EACP,oBAA4B;GAC1B,IAAI,CAAC,KAAK,eACR,OAAO;GAET,OAAQ,KAAK,gBAAgB,MAAO,KAAK;EAC3C;EACA,kBAAsC;GACpC,IAAI,KAAK,aACP,OAAO,KAAK,WAAW,MAAM;EAGjC;EACA,mBAA2B;GACzB,IAAI,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