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,SAAK,EAXD,IAAU,CAYjB,EAEA,EAAU,UAAU,SAAW,SAAS,EAAS,GAC/C,GAAe,MAAX,EAKJ,OADA,EAAQ,MAAM,YAAY,UAAW,KAC9B,KAAK,uBAAyB,EAJnC,GAKJ,EAEA,EAAU,UAAU,QAAU,SAAS,EAAS,GAC9C,GAAe,MAAX,EAKJ,OADA,EAAQ,MAAM,YAAY,UAAW,KAC9B,KAAK,uBAAyB,EAJnC,GAKJ,EAEA,EAAU,UAAU,gBAAkB,SAAS,GAC7C,IAAI,EAiBJ,OAhBA,EAAQ,CACN,KAzaS,OA0aT,KAAM,EAAK,KACX,OAAQ,EAAK,QAEX,EAAK,SACP,EAAM,SAAU,EAChB,EAAM,KAAO,EAAK,OAElB,EAAM,SAAU,EAChB,EAAM,KAAO,EAAK,KAClB,EAAM,SAAW,EAAK,UAEnB,KAAK,wBACR,EAAM,UAAY,EAAK,WAElB,CACT,EAEA,EAAU,UAAU,WAAa,SAAS,GAIxC,OAHI,EAAK,OAAS,IAChB,KAAK,yBAA2B,GAED,mBAAnB,KAAK,UAA2B,KAAK,UAAU,QAAQ,CACvE,EAEA,EAAU,UAAU,WAAa,SAAS,GACxC,OAAQ,MAAM,WAAW,KAAO,SAAS,EAC3C,EAEO,CAER,CAlbW,GAobZ,OAAO,QAAU,CAElB,GAAE,KAAK","file":"/npm/cortex-scheduler@2.10.4/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cortex-scheduler@2.10.4/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","(function() {\n  var BLACK_SCREEN, BLACK_SCREEN_SLOT_NAME, DEFAULT_VIEW, HC_BLACKSCREEN_ACTIVATION_TIME, HC_BLACKSCREEN_THRESHOLD, HC_LAST_RUN_THRESHOLD, Scheduler, TAG;\n\n  TAG = 'scheduler:';\n\n  DEFAULT_VIEW = '__dv';\n\n  BLACK_SCREEN_SLOT_NAME = '__bs';\n\n  BLACK_SCREEN = {\n    slot: BLACK_SCREEN_SLOT_NAME,\n    view: \"\",\n    duration: 1000,\n    isVideo: false,\n    callbacks: {\n      error: function(err) {\n        return console.log(TAG + \" Even black screens fail... err=\" + (err != null ? err.message : void 0));\n      }\n    }\n  };\n\n  HC_LAST_RUN_THRESHOLD = 5 * 60 * 1000;\n\n  HC_BLACKSCREEN_ACTIVATION_TIME = 5 * 60 * 1000;\n\n  HC_BLACKSCREEN_THRESHOLD = 10;\n\n  Scheduler = (function() {\n    function Scheduler(opts, onVideoView, onViewEnd) {\n      this.onVideoView = onVideoView;\n      this.onViewEnd = onViewEnd;\n      if (opts == null) {\n        opts = {};\n      }\n      this._maxViewDuration = 60 * 1000;\n      if (opts.maxViewDuration != null) {\n        this._maxViewDuration = opts.maxViewDuration;\n      }\n      this._defaultViewQueueLen = 10;\n      if (opts.defaultViewQueueLen != null) {\n        this._defaultViewQueueLen = opts.defaultViewQueueLen;\n      }\n      this._defaultView = void 0;\n      this._defaultViewQueue = [];\n      this._defaultViewRenderIndex = 0;\n      this._defaultViewTrackMode = false;\n      this._slots = {};\n      this._viewOrder = [];\n      this._fallbackSlots = {};\n      this._fallbackViewOrder = [];\n      this._current = 0;\n      this._transitionEndCallback = void 0;\n      this._exit = false;\n      this._started = false;\n      this._schedulerStartTime = 0;\n      this._lastRunTime = new Date().getTime();\n      this._consecutiveBlackScreens = 0;\n    }\n\n    Scheduler.prototype.exit = function() {\n      return this._exit = true;\n    };\n\n    Scheduler.prototype.register = function(sname, fallback) {\n      console.log(TAG + \" Registering new slot: \" + sname + \" with fallback: \" + fallback);\n      if (!this._defaultViewTrackMode && !!this._defaultView && (this._defaultView === sname || this._defaultView === fallback)) {\n        throw new Error(this._defaultView + \" is already registered as the default view. You should register a slot before calling the setDefaultView(), if you want the default slot to track submissions to \" + this._defaultView + \".\");\n      }\n      if (this._slots[sname] == null) {\n        this._slots[sname] = [];\n      }\n      this._viewOrder.push(sname);\n      if (!!fallback) {\n        if (this._fallbackSlots[fallback] == null) {\n          this._fallbackSlots[fallback] = [];\n          return this._fallbackViewOrder.push(fallback);\n        }\n      }\n    };\n\n    Scheduler.prototype.setDefaultView = function(sname) {\n      this._defaultView = sname;\n      if (sname in this._slots || sname in this._fallbackSlots) {\n        this._defaultViewTrackMode = true;\n      }\n      return console.log(TAG + \" Setting default view to \" + this._defaultView + \". Track mode: \" + this._defaultViewTrackMode);\n    };\n\n    Scheduler.prototype._submitDefaultView = function(view) {\n      if (view.isNoop) {\n        return;\n      }\n      if (this._defaultViewTrackMode && this._defaultViewQueue.length >= this._defaultViewQueueLen) {\n        this._defaultViewQueue.shift();\n      }\n      return this._defaultViewQueue.push(view);\n    };\n\n    Scheduler.prototype.submitNoop = function(sname, callbacks) {\n      return this._submit({\n        slot: sname,\n        isNoop: true,\n        callbacks: callbacks\n      });\n    };\n\n    Scheduler.prototype.submitView = function(sname, view, duration, callbacks, opts) {\n      if (!this._isNumeric(duration)) {\n        throw new RangeError(\"View duration should be in the range of (0, \" + this._maxViewDuration + \")\");\n      }\n      duration = Number(duration);\n      if (duration <= 0 || duration > this._maxViewDuration) {\n        throw new RangeError(\"View duration should be in the range of (0, \" + this._maxViewDuration + \")\");\n      }\n      return this._submit({\n        slot: sname,\n        view: view,\n        duration: duration,\n        callbacks: callbacks,\n        opts: opts,\n        isNoop: false,\n        isVideo: false\n      });\n    };\n\n    Scheduler.prototype.submitVideo = function(sname, file, callbacks, opts) {\n      return this._submit({\n        slot: sname,\n        file: file,\n        callbacks: callbacks,\n        opts: opts,\n        isNoop: false,\n        isVideo: true\n      });\n    };\n\n    Scheduler.prototype._submit = function(view) {\n      var ref, ref1;\n      console.log(TAG + \" New view to be submitted to slot \" + view.slot + \". isNoop=\" + view.isNoop + \", isVideo=\" + view.isVideo + \", duration=\" + view.duration + \" file=\" + view.file + \", label=\" + ((ref = view.opts) != null ? (ref1 = ref.view) != null ? ref1.label : void 0 : void 0));\n      if (view.slot === this._defaultView) {\n        if (!this._defaultViewTrackMode && view.isNoop) {\n          throw new Error('Default views cannot be noop.');\n        }\n        this._submitDefaultView(this._newDefaultView(view));\n        if (!this._defaultViewTrackMode) {\n          return;\n        }\n      }\n      if (view.slot in this._slots) {\n        return this._slots[view.slot].push(view);\n      } else if (view.slot in this._fallbackSlots) {\n        return this._fallbackSlots[view.slot].push(view);\n      } else {\n        throw new Error(\"Unknown view slot: \" + view.slot);\n      }\n    };\n\n    Scheduler.prototype.start = function(window, document, root) {\n      if (this._defaultView == null) {\n        console.warn(\"Scheduler: No default view is set. Consider selecting one of the view slots as default by calling setDefaultView(slotName). Views from the default slot will get played automatically when everything else fail.\");\n      }\n      this.window = window;\n      this.document = document;\n      this.root = root || document.body;\n      this._initSchedulerRoot();\n      this._started = true;\n      this._schedulerStartTime = new Date().getTime();\n      return this._run();\n    };\n\n    Scheduler.prototype.onHealthCheck = function(report) {\n      var now;\n      if (this._exit || !this._started) {\n        report({\n          status: true\n        });\n        return;\n      }\n      now = new Date().getTime();\n      if (this._lastRunTime + HC_LAST_RUN_THRESHOLD < now) {\n        return report({\n          status: false,\n          reason: 'Scheduler has stopped working.'\n        });\n      } else if ((this._schedulerStartTime + HC_BLACKSCREEN_ACTIVATION_TIME < now) && (this._consecutiveBlackScreens > HC_BLACKSCREEN_THRESHOLD)) {\n        return report({\n          status: false,\n          reason: 'Application is rendering black screens.'\n        });\n      } else {\n        return report({\n          status: true\n        });\n      }\n    };\n\n    Scheduler.prototype._initSchedulerRoot = function() {\n      var onTransitionEnd;\n      if (this.root == null) {\n        console.warn(TAG + \" No root node specified.\");\n        return;\n      }\n      onTransitionEnd = (function(_this) {\n        return function() {\n          return _this._onTransitionEnd();\n        };\n      })(this);\n      this.root.addEventListener('webkitTransitionEnd', onTransitionEnd, false);\n      this.root.style.setProperty('opacity', '1');\n      return this.root.style.setProperty('transition', 'opacity 0.5s linear');\n    };\n\n    Scheduler.prototype._onTransitionEnd = function() {\n      console.log(TAG + \" Transition ended: \" + (new Date().getTime()));\n      if (this._transitionEndCallback != null) {\n        this._transitionEndCallback();\n        return this._transitionEndCallback = void 0;\n      }\n    };\n\n    Scheduler.prototype._run = function() {\n      var checked, done, results;\n      if (this._exit) {\n        console.log(TAG + \" Scheduler will exit.\");\n        return;\n      }\n      this._lastRunTime = new Date().getTime();\n      done = (function(_this) {\n        return function(sname) {\n          var et;\n          et = new Date().getTime() - _this._lastRunTime;\n          console.log(TAG + \" \" + sname + \" completed in \" + et + \" msecs.\");\n          return process.nextTick(function() {\n            return _this._run();\n          });\n        };\n      })(this);\n      if (this._viewOrder.length === 0) {\n        return this._renderDefaultView(done);\n      } else {\n        checked = 0;\n        results = [];\n        while (true) {\n          if (this._tryToRenderCurrent(done)) {\n            break;\n          } else {\n            checked++;\n            if (checked >= this._viewOrder.length) {\n              this._renderFallbackElseDefaultView(done);\n              break;\n            } else {\n              results.push(void 0);\n            }\n          }\n        }\n        return results;\n      }\n    };\n\n    Scheduler.prototype._tryToRenderCurrent = function(done) {\n      var cslot, sname, view;\n      if (this._viewOrder.length === 0) {\n        return false;\n      }\n      if (this._current >= this._viewOrder.length) {\n        this._current = 0;\n      }\n      sname = this._viewOrder[this._current];\n      cslot = this._slots[sname];\n      this._current++;\n      if ((cslot != null ? cslot.length : void 0) > 0) {\n        view = cslot.shift();\n        console.log(TAG + \" Rendering a view from \" + sname + \" for \" + view.duration + \" msecs.\");\n        if (view.isNoop) {\n          this._fireNoopCallbacks(view);\n          this._renderFallbackElseDefaultView(done);\n        } else {\n          this._render(view, done);\n        }\n        return true;\n      }\n      return false;\n    };\n\n    Scheduler.prototype._fireNoopCallbacks = function(view) {\n      var ref, ref1, ref2;\n      if (!view.isNoop) {\n        return;\n      }\n      if ((ref = view.callbacks) != null) {\n        if (typeof ref.begin === \"function\") {\n          ref.begin();\n        }\n      }\n      if ((ref1 = view.callbacks) != null) {\n        if (typeof ref1.ready === \"function\") {\n          ref1.ready();\n        }\n      }\n      return (ref2 = view.callbacks) != null ? typeof ref2.end === \"function\" ? ref2.end() : void 0 : void 0;\n    };\n\n    Scheduler.prototype._renderFallbackElseDefaultView = function(done) {\n      var fallback, i, len, ref, slot, sname;\n      if (this._fallbackViewOrder.length > 0) {\n        ref = this._fallbackViewOrder;\n        for (i = 0, len = ref.length; i < len; i++) {\n          sname = ref[i];\n          slot = this._fallbackSlots[sname];\n          if (slot.length > 0) {\n            fallback = slot.shift();\n            console.log(TAG + \" Rendering a fallback view from \" + sname + \" for \" + fallback.duration + \" msecs.\");\n            if (!fallback.isNoop) {\n              this._render(fallback, done);\n              return;\n            } else {\n              this._fireNoopCallbacks(fallback);\n            }\n          }\n        }\n      }\n      return this._renderDefaultView(done);\n    };\n\n    Scheduler.prototype._renderDefaultView = function(done) {\n      var view;\n      if (this._defaultViewQueue.length > 0) {\n        if (this._defaultViewTrackMode) {\n          if (this._defaultViewRenderIndex >= this._defaultViewQueue.length) {\n            this._defaultViewRenderIndex = 0;\n          }\n          view = this._defaultViewQueue[this._defaultViewRenderIndex];\n          this._defaultViewRenderIndex += 1;\n        } else {\n          view = this._defaultViewQueue.shift();\n        }\n        console.warn(TAG + \" Rendering the default view for \" + view.duration + \" msecs.\");\n        return this._render(view, done);\n      } else {\n        console.warn(TAG + \" BLACK SCREEN!!!!!!! for \" + BLACK_SCREEN.duration + \" msecs.\");\n        this._consecutiveBlackScreens += 1;\n        return this._render(BLACK_SCREEN, done);\n      }\n    };\n\n    Scheduler.prototype._render = function(view, done) {\n      var err, ref, ref1;\n      try {\n        console.log(TAG + \" Rendering view \" + view.slot + \", video=\" + view.isVideo);\n        if ((ref = view.callbacks) != null) {\n          if (typeof ref.begin === \"function\") {\n            ref.begin();\n          }\n        }\n        return this._fadeOut(this.root, (function(_this) {\n          return function() {\n            var end;\n            if (view.isVideo) {\n              _this._renderVideoView(_this.root, view, done);\n            } else {\n              _this._renderHtmlView(_this.root, view);\n              end = function() {\n                var ref1;\n                done(view.slot);\n                _this._onViewEnd(view);\n                return (ref1 = view.callbacks) != null ? typeof ref1.end === \"function\" ? ref1.end() : void 0 : void 0;\n              };\n              global.setTimeout(end, view.duration);\n            }\n            return _this._fadeIn(_this.root, function() {});\n          };\n        })(this));\n      } catch (_error) {\n        err = _error;\n        console.log(TAG + \" Error while rendering \" + view.slot + \" view. video=\" + view.isVideo + \", e=\" + (err != null ? err.message : void 0));\n        done(view.slot);\n        return (ref1 = view.callbacks) != null ? typeof ref1.error === \"function\" ? ref1.error(err) : void 0 : void 0;\n      }\n    };\n\n    Scheduler.prototype._renderHtmlView = function(div, view) {\n      var ref;\n      div.innerHTML = view.view;\n      return (ref = view.callbacks) != null ? typeof ref.ready === \"function\" ? ref.ready() : void 0 : void 0;\n    };\n\n    Scheduler.prototype._renderVideoView = function(div, view, done) {\n      if (div != null) {\n        while (div.firstChild != null) {\n          div.removeChild(div.firstChild);\n        }\n      }\n      return typeof this.onVideoView === \"function\" ? this.onVideoView(div, view.file, view.opts, (function() {\n        var ref;\n        return (ref = view.callbacks) != null ? typeof ref.ready === \"function\" ? ref.ready() : void 0 : void 0;\n      }), ((function(_this) {\n        return function() {\n          var ref;\n          done(view.slot);\n          _this._onViewEnd(view);\n          return (ref = view.callbacks) != null ? typeof ref.end === \"function\" ? ref.end() : void 0 : void 0;\n        };\n      })(this)), (function(err) {\n        var ref;\n        done(view.slot);\n        return (ref = view.callbacks) != null ? typeof ref.error === \"function\" ? ref.error(err) : void 0 : void 0;\n      })) : void 0;\n    };\n\n    Scheduler.prototype._fadeOut = function(element, cb) {\n      if (element == null) {\n        cb();\n        return;\n      }\n      element.style.setProperty('opacity', '0');\n      return this._transitionEndCallback = cb;\n    };\n\n    Scheduler.prototype._fadeIn = function(element, cb) {\n      if (element == null) {\n        cb();\n        return;\n      }\n      element.style.setProperty('opacity', '1');\n      return this._transitionEndCallback = cb;\n    };\n\n    Scheduler.prototype._newDefaultView = function(view) {\n      var nview;\n      nview = {\n        slot: DEFAULT_VIEW,\n        opts: view.opts,\n        isNoop: view.isNoop\n      };\n      if (view.isVideo) {\n        nview.isVideo = true;\n        nview.file = view.file;\n      } else {\n        nview.isVideo = false;\n        nview.view = view.view;\n        nview.duration = view.duration;\n      }\n      if (!this._defaultViewTrackMode) {\n        nview.callbacks = view.callbacks;\n      }\n      return nview;\n    };\n\n    Scheduler.prototype._onViewEnd = function(view) {\n      if (view.slot !== BLACK_SCREEN_SLOT_NAME) {\n        this._consecutiveBlackScreens = 0;\n      }\n      return typeof this.onViewEnd === \"function\" ? this.onViewEnd(view) : void 0;\n    };\n\n    Scheduler.prototype._isNumeric = function(n) {\n      return !isNaN(parseFloat(n)) && isFinite(n);\n    };\n\n    return Scheduler;\n\n  })();\n\n  module.exports = Scheduler;\n\n}).call(this);\n"]}