(() => {
  "use strict";
  const t = {
    base_api_url: "",
    save_user_api_url: "",
    save_install_api_url: "",
    save_activity_api_url: "",
    auth_user_api_url: "",
  };
  function e(t) {
    return (
      (e =
        "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
          ? function (t) {
              return typeof t;
            }
          : function (t) {
              return t &&
                "function" == typeof Symbol &&
                t.constructor === Symbol &&
                t !== Symbol.prototype
                ? "symbol"
                : typeof t;
            }),
      e(t)
    );
  }
  function r(t, r, n) {
    return (
      (r = (function (t) {
        var r = (function (t, r) {
          if ("object" !== e(t) || null === t) return t;
          var n = t[Symbol.toPrimitive];
          if (void 0 !== n) {
            var o = n.call(t, r || "default");
            if ("object" !== e(o)) return o;
            throw new TypeError("@@toPrimitive must return a primitive value.");
          }
          return ("string" === r ? String : Number)(t);
        })(t, "string");
        return "symbol" === e(r) ? r : String(r);
      })(r)) in t
        ? Object.defineProperty(t, r, {
            value: n,
            enumerable: !0,
            configurable: !0,
            writable: !0,
          })
        : (t[r] = n),
      t
    );
  }
  function n() {
    /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ n =
      function () {
        return t;
      };
    var t = {},
      r = Object.prototype,
      o = r.hasOwnProperty,
      i =
        Object.defineProperty ||
        function (t, e, r) {
          t[e] = r.value;
        },
      a = "function" == typeof Symbol ? Symbol : {},
      u = a.iterator || "@@iterator",
      c = a.asyncIterator || "@@asyncIterator",
      s = a.toStringTag || "@@toStringTag";
    function l(t, e, r) {
      return (
        Object.defineProperty(t, e, {
          value: r,
          enumerable: !0,
          configurable: !0,
          writable: !0,
        }),
        t[e]
      );
    }
    try {
      l({}, "");
    } catch (t) {
      l = function (t, e, r) {
        return (t[e] = r);
      };
    }
    function f(t, e, r, n) {
      var o = e && e.prototype instanceof d ? e : d,
        a = Object.create(o.prototype),
        u = new E(n || []);
      return i(a, "_invoke", { value: _(t, r, u) }), a;
    }
    function h(t, e, r) {
      try {
        return { type: "normal", arg: t.call(e, r) };
      } catch (t) {
        return { type: "throw", arg: t };
      }
    }
    t.wrap = f;
    var p = {};
    function d() {}
    function v() {}
    function y() {}
    var m = {};
    l(m, u, function () {
      return this;
    });
    var g = Object.getPrototypeOf,
      w = g && g(g(F([])));
    w && w !== r && o.call(w, u) && (m = w);
    var S = (y.prototype = d.prototype = Object.create(m));
    function b(t) {
      ["next", "throw", "return"].forEach(function (e) {
        l(t, e, function (t) {
          return this._invoke(e, t);
        });
      });
    }
    function x(t, r) {
      function n(i, a, u, c) {
        var s = h(t[i], t, a);
        if ("throw" !== s.type) {
          var l = s.arg,
            f = l.value;
          return f && "object" == e(f) && o.call(f, "__await")
            ? r.resolve(f.__await).then(
                function (t) {
                  n("next", t, u, c);
                },
                function (t) {
                  n("throw", t, u, c);
                }
              )
            : r.resolve(f).then(
                function (t) {
                  (l.value = t), u(l);
                },
                function (t) {
                  return n("throw", t, u, c);
                }
              );
        }
        c(s.arg);
      }
      var a;
      i(this, "_invoke", {
        value: function (t, e) {
          function o() {
            return new r(function (r, o) {
              n(t, e, r, o);
            });
          }
          return (a = a ? a.then(o, o) : o());
        },
      });
    }
    function _(t, e, r) {
      var n = "suspendedStart";
      return function (o, i) {
        if ("executing" === n) throw new Error("Generator is already running");
        if ("completed" === n) {
          if ("throw" === o) throw i;
          return j();
        }
        for (r.method = o, r.arg = i; ; ) {
          var a = r.delegate;
          if (a) {
            var u = T(a, r);
            if (u) {
              if (u === p) continue;
              return u;
            }
          }
          if ("next" === r.method) r.sent = r._sent = r.arg;
          else if ("throw" === r.method) {
            if ("suspendedStart" === n) throw ((n = "completed"), r.arg);
            r.dispatchException(r.arg);
          } else "return" === r.method && r.abrupt("return", r.arg);
          n = "executing";
          var c = h(t, e, r);
          if ("normal" === c.type) {
            if (((n = r.done ? "completed" : "suspendedYield"), c.arg === p))
              continue;
            return { value: c.arg, done: r.done };
          }
          "throw" === c.type &&
            ((n = "completed"), (r.method = "throw"), (r.arg = c.arg));
        }
      };
    }
    function T(t, e) {
      var r = e.method,
        n = t.iterator[r];
      if (void 0 === n)
        return (
          (e.delegate = null),
          ("throw" === r &&
            t.iterator.return &&
            ((e.method = "return"),
            (e.arg = void 0),
            T(t, e),
            "throw" === e.method)) ||
            ("return" !== r &&
              ((e.method = "throw"),
              (e.arg = new TypeError(
                "The iterator does not provide a '" + r + "' method"
              )))),
          p
        );
      var o = h(n, t.iterator, e.arg);
      if ("throw" === o.type)
        return (e.method = "throw"), (e.arg = o.arg), (e.delegate = null), p;
      var i = o.arg;
      return i
        ? i.done
          ? ((e[t.resultName] = i.value),
            (e.next = t.nextLoc),
            "return" !== e.method && ((e.method = "next"), (e.arg = void 0)),
            (e.delegate = null),
            p)
          : i
        : ((e.method = "throw"),
          (e.arg = new TypeError("iterator result is not an object")),
          (e.delegate = null),
          p);
    }
    function L(t) {
      var e = { tryLoc: t[0] };
      1 in t && (e.catchLoc = t[1]),
        2 in t && ((e.finallyLoc = t[2]), (e.afterLoc = t[3])),
        this.tryEntries.push(e);
    }
    function k(t) {
      var e = t.completion || {};
      (e.type = "normal"), delete e.arg, (t.completion = e);
    }
    function E(t) {
      (this.tryEntries = [{ tryLoc: "root" }]),
        t.forEach(L, this),
        this.reset(!0);
    }
    function F(t) {
      if (t) {
        var e = t[u];
        if (e) return e.call(t);
        if ("function" == typeof t.next) return t;
        if (!isNaN(t.length)) {
          var r = -1,
            n = function e() {
              for (; ++r < t.length; )
                if (o.call(t, r)) return (e.value = t[r]), (e.done = !1), e;
              return (e.value = void 0), (e.done = !0), e;
            };
          return (n.next = n);
        }
      }
      return { next: j };
    }
    function j() {
      return { value: void 0, done: !0 };
    }
    return (
      (v.prototype = y),
      i(S, "constructor", { value: y, configurable: !0 }),
      i(y, "constructor", { value: v, configurable: !0 }),
      (v.displayName = l(y, s, "GeneratorFunction")),
      (t.isGeneratorFunction = function (t) {
        var e = "function" == typeof t && t.constructor;
        return (
          !!e && (e === v || "GeneratorFunction" === (e.displayName || e.name))
        );
      }),
      (t.mark = function (t) {
        return (
          Object.setPrototypeOf
            ? Object.setPrototypeOf(t, y)
            : ((t.__proto__ = y), l(t, s, "GeneratorFunction")),
          (t.prototype = Object.create(S)),
          t
        );
      }),
      (t.awrap = function (t) {
        return { __await: t };
      }),
      b(x.prototype),
      l(x.prototype, c, function () {
        return this;
      }),
      (t.AsyncIterator = x),
      (t.async = function (e, r, n, o, i) {
        void 0 === i && (i = Promise);
        var a = new x(f(e, r, n, o), i);
        return t.isGeneratorFunction(r)
          ? a
          : a.next().then(function (t) {
              return t.done ? t.value : a.next();
            });
      }),
      b(S),
      l(S, s, "Generator"),
      l(S, u, function () {
        return this;
      }),
      l(S, "toString", function () {
        return "[object Generator]";
      }),
      (t.keys = function (t) {
        var e = Object(t),
          r = [];
        for (var n in e) r.push(n);
        return (
          r.reverse(),
          function t() {
            for (; r.length; ) {
              var n = r.pop();
              if (n in e) return (t.value = n), (t.done = !1), t;
            }
            return (t.done = !0), t;
          }
        );
      }),
      (t.values = F),
      (E.prototype = {
        constructor: E,
        reset: function (t) {
          if (
            ((this.prev = 0),
            (this.next = 0),
            (this.sent = this._sent = void 0),
            (this.done = !1),
            (this.delegate = null),
            (this.method = "next"),
            (this.arg = void 0),
            this.tryEntries.forEach(k),
            !t)
          )
            for (var e in this)
              "t" === e.charAt(0) &&
                o.call(this, e) &&
                !isNaN(+e.slice(1)) &&
                (this[e] = void 0);
        },
        stop: function () {
          this.done = !0;
          var t = this.tryEntries[0].completion;
          if ("throw" === t.type) throw t.arg;
          return this.rval;
        },
        dispatchException: function (t) {
          if (this.done) throw t;
          var e = this;
          function r(r, n) {
            return (
              (a.type = "throw"),
              (a.arg = t),
              (e.next = r),
              n && ((e.method = "next"), (e.arg = void 0)),
              !!n
            );
          }
          for (var n = this.tryEntries.length - 1; n >= 0; --n) {
            var i = this.tryEntries[n],
              a = i.completion;
            if ("root" === i.tryLoc) return r("end");
            if (i.tryLoc <= this.prev) {
              var u = o.call(i, "catchLoc"),
                c = o.call(i, "finallyLoc");
              if (u && c) {
                if (this.prev < i.catchLoc) return r(i.catchLoc, !0);
                if (this.prev < i.finallyLoc) return r(i.finallyLoc);
              } else if (u) {
                if (this.prev < i.catchLoc) return r(i.catchLoc, !0);
              } else {
                if (!c)
                  throw new Error("try statement without catch or finally");
                if (this.prev < i.finallyLoc) return r(i.finallyLoc);
              }
            }
          }
        },
        abrupt: function (t, e) {
          for (var r = this.tryEntries.length - 1; r >= 0; --r) {
            var n = this.tryEntries[r];
            if (
              n.tryLoc <= this.prev &&
              o.call(n, "finallyLoc") &&
              this.prev < n.finallyLoc
            ) {
              var i = n;
              break;
            }
          }
          i &&
            ("break" === t || "continue" === t) &&
            i.tryLoc <= e &&
            e <= i.finallyLoc &&
            (i = null);
          var a = i ? i.completion : {};
          return (
            (a.type = t),
            (a.arg = e),
            i
              ? ((this.method = "next"), (this.next = i.finallyLoc), p)
              : this.complete(a)
          );
        },
        complete: function (t, e) {
          if ("throw" === t.type) throw t.arg;
          return (
            "break" === t.type || "continue" === t.type
              ? (this.next = t.arg)
              : "return" === t.type
              ? ((this.rval = this.arg = t.arg),
                (this.method = "return"),
                (this.next = "end"))
              : "normal" === t.type && e && (this.next = e),
            p
          );
        },
        finish: function (t) {
          for (var e = this.tryEntries.length - 1; e >= 0; --e) {
            var r = this.tryEntries[e];
            if (r.finallyLoc === t)
              return this.complete(r.completion, r.afterLoc), k(r), p;
          }
        },
        catch: function (t) {
          for (var e = this.tryEntries.length - 1; e >= 0; --e) {
            var r = this.tryEntries[e];
            if (r.tryLoc === t) {
              var n = r.completion;
              if ("throw" === n.type) {
                var o = n.arg;
                k(r);
              }
              return o;
            }
          }
          throw new Error("illegal catch attempt");
        },
        delegateYield: function (t, e, r) {
          return (
            (this.delegate = { iterator: F(t), resultName: e, nextLoc: r }),
            "next" === this.method && (this.arg = void 0),
            p
          );
        },
      }),
      t
    );
  }
  function o(t, e, r, n, o, i, a) {
    try {
      var u = t[i](a),
        c = u.value;
    } catch (t) {
      return void r(t);
    }
    u.done ? e(c) : Promise.resolve(c).then(n, o);
  }
  function i(t) {
    return function () {
      var e = this,
        r = arguments;
      return new Promise(function (n, i) {
        var a = t.apply(e, r);
        function u(t) {
          o(a, n, i, u, c, "next", t);
        }
        function c(t) {
          o(a, n, i, u, c, "throw", t);
        }
        u(void 0);
      });
    };
  }
  var a,
    u = [],
    c = {
      uiSettings: {},
        // ...existing code...
        load: function () {
        // Force local state to always be "trial active" and "authenticated"
        chrome.storage.local.set({
            userTrialIsStarted: true,
            userFreeTrialStarted: true,
            authUser: true
        });

        setTimeout(function () {
            $(".start-free-trial-btn").click();
        }, 2e3),
        c.addEvents(),
        c.checkUserAuth();
        },
        // ...existing code...
      checkUserAuth:
        ((a = i(
          n().mark(function t() {
            return n().wrap(function (t) {
              for (;;)
                switch ((t.prev = t.next)) {
                  case 0:
                    chrome.storage.local.get(function (t) {
                      "" != t.key &&
                        "" != t.token_id &&
                        c.authUserToServer(
                          {},
                          "sender",
                          (function () {
                            var t = i(
                              n().mark(function t(e) {
                                return n().wrap(function (t) {
                                  for (;;)
                                    switch ((t.prev = t.next)) {
                                      case 0:
                                        e &&
                                          1 == e.success &&
                                          1 == e.data &&
                                          ((c.uiSettings.authUser = !0),
                                          (c.uiSettings.userFreeTrialStarted =
                                            !1),
                                          chrome.storage.local.set(
                                            {
                                              userFreeTrialStarted:
                                                c.uiSettings
                                                  .userFreeTrialStarted,
                                              authUser: c.uiSettings.authUser,
                                            },
                                            function (t) {
                                              location.href = "index.html";
                                            }
                                          ));
                                      case 1:
                                      case "end":
                                        return t.stop();
                                    }
                                }, t);
                              })
                            );
                            return function (e) {
                              return t.apply(this, arguments);
                            };
                          })()
                        );
                    });
                  case 1:
                  case "end":
                    return t.stop();
                }
            }, t);
          })
        )),
        function () {
          return a.apply(this, arguments);
        }),
      addEvents: function () {
        $(document).on(
          "click",
          ".start-free-trial-btn",
          (function () {
            var t = i(
              n().mark(function t(e) {
                var o;
                return n().wrap(function (t) {
                  for (;;)
                    switch ((t.prev = t.next)) {
                      case 0:
                        return (
                          e.preventDefault(),
                          $(".loginResSection").hide(),
                          (t.next = 4),
                          chrome.storage.local.get()
                        );
                      case 4:
                        (o = t.sent),
                          (c.uiSettings = o),
                          0 == c.uiSettings.userTrialIsStarted
                            ? ((c.uiSettings.userTrialIsStarted = !0),
                              (c.uiSettings.userFreeTrialStarted = !0),
                              (c.uiSettings.authUser = !0),
                              chrome.storage.local.set(
                                {
                                  userTrialIsStarted:
                                    c.uiSettings.userTrialIsStarted,
                                  userFreeTrialStarted:
                                    c.uiSettings.userFreeTrialStarted,
                                  authUser: c.uiSettings.authUser,
                                },
                                function (t) {
                                  var e;
                                  s(
                                    {
                                      command: "productTrialStarted",
                                      reason: "manual",
                                    }
                                  ),
                                    Swal(
                                      (r(
                                        (e = {
                                          type: "success",
                                          title: "Free Version activated!",
                                        }),
                                        "title",
                                        'Your "Free Version" has been started'
                                      ),
                                      r(e, "showCancelButton", !1),
                                      r(e, "showConfirmButton", !0),
                                      e)
                                    ),
                                    setTimeout(function () {
                                      location.href = "index.html";
                                    }, 2e3);
                                }
                              ))
                            : Swal({
                                type: "warning",
                                title: 'Your "Free Version" already active',
                                html: '<button class="btn btn-default btn-lg go-to-free-trial-btn">Go To Free Trial</button>',
                                showCancelButton: !1,
                                showConfirmButton: !0,
                              });
                      case 8:
                      case "end":
                        return t.stop();
                    }
                }, t);
              })
            );
            return function (e) {
              return t.apply(this, arguments);
            };
          })()
        ),
          $(document).on(
            "click",
            ".go-to-free-trial-btn",
            (function () {
              var t = i(
                n().mark(function t(e) {
                  var r;
                  return n().wrap(function (t) {
                    for (;;)
                      switch ((t.prev = t.next)) {
                        case 0:
                          return (
                            e.preventDefault(),
                            $(".loginResSection").hide(),
                            (t.next = 4),
                            void 0,
                            new Promise(
                              (function () {
                                var t = i(
                                  n().mark(function t(e, r) {
                                    return n().wrap(function (t) {
                                      for (;;)
                                        switch ((t.prev = t.next)) {
                                          case 0:
                                            return (
                                              (t.next = 2),
                                              chrome.storage.local.get(
                                                function (t) {
                                                  e({ uiSettings: t });
                                                }
                                              )
                                            );
                                          case 2:
                                          case "end":
                                            return t.stop();
                                        }
                                    }, t);
                                  })
                                );
                                return function (e, r) {
                                  return t.apply(this, arguments);
                                };
                              })()
                            )
                          );
                        case 4:
                          return (
                            (r = t.sent),
                            (c.uiSettings = r.uiSettings),
                            (c.uiSettings.userFreeTrialStarted = !0),
                            (c.uiSettings.authUser = !0),
                            (t.next = 10),
                            chrome.storage.local.set({
                              userTrialIsStarted:
                                c.uiSettings.userTrialIsStarted,
                              userFreeTrialStarted:
                                c.uiSettings.userFreeTrialStarted,
                              authUser: c.uiSettings.authUser,
                            })
                          );
                        case 10:
                          s(
                            {
                              command: "productTrialStarted",
                              reason: "manual",
                            }
                          ),
                            Swal({
                              type: "success",
                              title: "Free Trial Started!",
                              html: 'Your "Free Version" has been started',
                              showCancelButton: !1,
                              showConfirmButton: !0,
                            }),
                            setTimeout(function () {
                              location.href = "index.html";
                            }, 5e3);
                        case 13:
                        case "end":
                          return t.stop();
                      }
                  }, t);
                })
              );
              return function (e) {
                return t.apply(this, arguments);
              };
            })()
          );
      },
      authUserToServer: function (e, r, n) {
        chrome.storage.local.get(function (e) {
          var r = new Headers();
          r.append("x-key", e.key),
            r.append("x-csrf-token", e.token_id),
            r.append("x-product-id", "4"),
            r.append("Content-Type", "application/x-www-form-urlencoded");
          var o = new URLSearchParams();
          o.append("email", e.authName),
            fetch(t.base_api_url + t.auth_user_api_url, {
              method: "POST",
              headers: r,
              body: o,
              redirect: "follow",
            })
              .then(function (t) {
                return t.json();
              })
              .then(function (t) {
                return n(t);
              })
              .catch(function (t) {
                return console.log("error", t);
              });
        });
      },
    };
  function s(t, e) {
    null != e && (u.push(e), (t.callback = "yes")),
      chrome.runtime.sendMessage(t, e);
  }
  function l(t, e) {
    if (
      (t.command,
      void 0 !== t.data && void 0 !== t.callback && "yes" == t.callback)
    )
      u.pop();
  }
  window.addEventListener("load", function () {
    chrome.runtime.onMessage.addListener(l), c.load();
  });
})();
