text: define(["exports", "../../@polymer/polymer/polymer-element.js"], function (_exports, _polymerElement) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.SimpleTimer = void 0;
  
    var _templateObject_70071eb0af6311ebbe560fe9c4727db1;
  
    function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; }
  
    function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  
    /**
     * `simple-timer`
     * @element simple-timer
     * `Automated conversion of simple-timer/`
     *
     * @microcopy - language worth noting:
     *  -
     *
    
     * @polymer
     * @demo demo/index.html
     */
    var SimpleTimer = /*#__PURE__*/function (_PolymerElement) {
      babelHelpers.inherits(SimpleTimer, _PolymerElement);
  
      var _super = _createSuper(SimpleTimer);
  
      function SimpleTimer() {
        babelHelpers.classCallCheck(this, SimpleTimer);
        return _super.apply(this, arguments);
      }
  
      babelHelpers.createClass(SimpleTimer, [{
        key: "ready",
        value: function ready() {
          babelHelpers.get(babelHelpers.getPrototypeOf(SimpleTimer.prototype), "ready", this).call(this);
  
          if (this.countUp) {
            this.set("currentTime", 0);
            this.set("_formattedTime", "0");
          } else {
            this.set("currentTime", this.startTime);
            this.set("_formattedTime", this.startTime.toString());
          }
        }
      }, {
        key: "start",
        value: function start() {
          if (this.currentTime <= 0 && !this.countUp || this.currentTime >= this.startTime && this.countUp) {
            // timer is over
            this.currentTime = this.countUp ? this.startTime : 0;
          }
  
          if (!this.startTime || this.isRunning) {
            this.pause();
            return;
          }
  
          this._elapsed = performance.now() / 1000;
          this.isRunning = true;
          window.requestAnimationFrame(this._decreaseTimer.bind(this));
        }
      }, {
        key: "pause",
        value: function pause() {
          this.isRunning = false;
        }
      }, {
        key: "_decreaseTimer",
        value: function _decreaseTimer(timestamp) {
          if (!this.isRunning) {
            return;
          }
  
          if (this.currentTime <= 0 && !this.countUp || this.currentTime >= this.startTime && this.countUp) {
            // timer is over
            this.currentTime = this.countUp ? this.startTime : 0;
            this.pause();
            this.dispatchEvent(new CustomEvent("simple-timer-end", {
              bubbles: true,
              cancelable: true,
              composed: true,
              detail: true
            }));
            return;
          }
  
          var now = timestamp / 1000; // Compute the relative progress based on the time spent running
  
          var progress = now - this._elapsed;
          this.currentTime = this.countUp ? this.currentTime + progress : this.currentTime - progress;
          this._formattedTime = this._formatTime(this.currentTime);
          this._elapsed = now;
          window.requestAnimationFrame(this._decreaseTimer.bind(this));
        }
      }, {
        key: "_formatTime",
        value: function _formatTime(time) {
          var timeString = time.toString().split(".");
          return timeString[0].indexOf("-") === 0 ? 0 : timeString[0] + "." + timeString[1].substring(0, 2);
        }
      }], [{
        key: "template",
        get: function get() {
          return (0, _polymerElement.html)(_templateObject_70071eb0af6311ebbe560fe9c4727db1 || (_templateObject_70071eb0af6311ebbe560fe9c4727db1 = babelHelpers.taggedTemplateLiteral(["\n      <style>\n        :host {\n          display: block;\n        }\n      </style>\n      [[_formattedTime]]\n    "])));
        }
      }, {
        key: "tag",
        get: function get() {
          return "simple-timer";
        }
      }, {
        key: "properties",
        get: function get() {
          return {
            /**
             * Start time for the timer in seconds
             */
            startTime: {
              type: Number,
              value: 60
            },
  
            /**
             * Current time of the timer, in seconds
             */
            currentTime: {
              type: Number,
              notify: true
            },
  
            /**
             * True if the timer is currently running
             */
            isRunning: {
              type: Boolean,
              reflectToAttribute: true,
              notify: true,
              value: false
            },
  
            /**
             * Set to true to have timer count up
             */
            countUp: {
              type: Boolean,
              value: false
            },
  
            /**
             * Time the timer has spent running since it was started
             */
            _elapsedTime: {
              type: Number,
              value: 0
            },
            _formattedTime: {
              type: String,
              value: "0"
            }
          };
        }
      }]);
      return SimpleTimer;
    }(_polymerElement.PolymerElement);
  
    _exports.SimpleTimer = SimpleTimer;
    window.customElements.define(SimpleTimer.tag, SimpleTimer);
  });